@donotdev/functions 0.1.1 → 0.1.42

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 (348) hide show
  1. package/LICENSE.md +21 -242
  2. package/README.md +4 -4
  3. package/guidelines/FUNCTIONS.md +0 -0
  4. package/guidelines/VERCEL.md +27 -1
  5. package/lib/firebase/auth/getCustomClaims.d.ts +0 -0
  6. package/lib/firebase/auth/getUserAuthStatus.d.ts +0 -0
  7. package/lib/firebase/auth/index.d.ts +0 -0
  8. package/lib/firebase/auth/removeCustomClaims.d.ts +0 -0
  9. package/lib/firebase/auth/setCustomClaims.d.ts +0 -0
  10. package/lib/firebase/baseFunction.d.ts +0 -0
  11. package/lib/firebase/billing/cancelSubscription.d.ts +0 -0
  12. package/lib/firebase/billing/changePlan.d.ts +0 -0
  13. package/lib/firebase/billing/createCheckoutSession.d.ts +0 -0
  14. package/lib/firebase/billing/createCustomerPortal.d.ts +0 -0
  15. package/lib/firebase/billing/healthCheck.d.ts +0 -0
  16. package/lib/firebase/billing/index.d.ts +0 -0
  17. package/lib/firebase/billing/refreshSubscriptionStatus.d.ts +0 -0
  18. package/lib/firebase/billing/webhookHandler.d.ts +0 -0
  19. package/lib/firebase/config/constants.d.ts +0 -0
  20. package/lib/firebase/config/index.d.ts +0 -0
  21. package/lib/firebase/config/secrets.d.ts +0 -0
  22. package/lib/firebase/crud/aggregate.d.ts +0 -0
  23. package/lib/firebase/crud/bulk.d.ts +107 -0
  24. package/lib/firebase/crud/create.d.ts +1 -1
  25. package/lib/firebase/crud/delete.d.ts +0 -0
  26. package/lib/firebase/crud/get.d.ts +0 -0
  27. package/lib/firebase/crud/index.d.ts +1 -0
  28. package/lib/firebase/crud/list.d.ts +0 -0
  29. package/lib/firebase/crud/update.d.ts +0 -0
  30. package/lib/firebase/helpers/githubAccessHelper.d.ts +0 -0
  31. package/lib/firebase/helpers/githubTeamAccessHelper.d.ts +0 -0
  32. package/lib/firebase/helpers/index.d.ts +0 -0
  33. package/lib/firebase/index.d.ts +0 -0
  34. package/lib/firebase/index.js +3 -3
  35. package/lib/firebase/index.js.map +4 -4
  36. package/lib/firebase/oauth/disconnect.d.ts +0 -0
  37. package/lib/firebase/oauth/exchangeToken.d.ts +0 -0
  38. package/lib/firebase/oauth/getConnections.d.ts +0 -0
  39. package/lib/firebase/oauth/githubAccess.d.ts +0 -0
  40. package/lib/firebase/oauth/index.d.ts +0 -0
  41. package/lib/firebase/oauth/refreshToken.d.ts +0 -0
  42. package/lib/firebase/registerCrudFunctions.d.ts +0 -0
  43. package/lib/firebase/scheduled/checkExpiredSubscriptions.d.ts +0 -0
  44. package/lib/firebase/scheduled/index.d.ts +0 -0
  45. package/lib/shared/ai/classifyAIError.d.ts +0 -0
  46. package/lib/shared/ai/costTracker.d.ts +0 -0
  47. package/lib/shared/ai/createAIHandler.d.ts +39 -0
  48. package/lib/shared/ai/createAIRoute.d.ts +0 -0
  49. package/lib/shared/ai/index.d.ts +0 -0
  50. package/lib/shared/ai/providers/anthropic.d.ts +12 -0
  51. package/lib/shared/ai/providers/google.d.ts +10 -0
  52. package/lib/shared/ai/providers/index.d.ts +23 -0
  53. package/lib/shared/ai/providers/openai.d.ts +10 -0
  54. package/lib/shared/ai/resolveModelTier.d.ts +0 -0
  55. package/lib/shared/ai/utils/parseSSE.d.ts +22 -0
  56. package/lib/shared/billing/createCheckout.d.ts +0 -0
  57. package/lib/shared/billing/helpers/index.d.ts +0 -0
  58. package/lib/shared/billing/helpers/subscriptionManagement.d.ts +0 -0
  59. package/lib/shared/billing/helpers/updateUserSubscription.d.ts +0 -0
  60. package/lib/shared/billing/idempotency.d.ts +0 -0
  61. package/lib/shared/billing/index.d.ts +0 -0
  62. package/lib/shared/billing/webhookHandler.d.ts +0 -0
  63. package/lib/shared/crud/bulkCore.d.ts +211 -0
  64. package/lib/shared/crud/index.d.ts +13 -0
  65. package/lib/shared/email/createEmailRoute.d.ts +0 -0
  66. package/lib/shared/email/index.d.ts +0 -0
  67. package/lib/shared/email/provider.d.ts +0 -0
  68. package/lib/shared/email/resendProvider.d.ts +0 -0
  69. package/lib/shared/errorHandling.d.ts +0 -0
  70. package/lib/shared/firebase.d.ts +0 -0
  71. package/lib/shared/github.d.ts +0 -0
  72. package/lib/shared/index.d.ts +1 -0
  73. package/lib/shared/index.js +4 -4
  74. package/lib/shared/index.js.map +4 -4
  75. package/lib/shared/logger.d.ts +0 -0
  76. package/lib/shared/metadata.d.ts +6 -6
  77. package/lib/shared/oauth/exchangeToken.d.ts +0 -0
  78. package/lib/shared/oauth/grantAccess.d.ts +0 -0
  79. package/lib/shared/oauth/index.d.ts +0 -0
  80. package/lib/shared/schema.d.ts +0 -0
  81. package/lib/shared/utils/detectFirestore.d.ts +0 -0
  82. package/lib/shared/utils/external/date.d.ts +0 -0
  83. package/lib/shared/utils/external/index.d.ts +0 -0
  84. package/lib/shared/utils/external/references.d.ts +0 -0
  85. package/lib/shared/utils/external/subscription.d.ts +0 -0
  86. package/lib/shared/utils/firebaseHelpers.d.ts +0 -0
  87. package/lib/shared/utils/functionWrapper.d.ts +0 -0
  88. package/lib/shared/utils/index.d.ts +0 -0
  89. package/lib/shared/utils/internal/auth.d.ts +0 -0
  90. package/lib/shared/utils/internal/firebase.d.ts +0 -0
  91. package/lib/shared/utils/internal/idempotency.d.ts +0 -0
  92. package/lib/shared/utils/internal/index.d.ts +0 -0
  93. package/lib/shared/utils/internal/monitoring.d.ts +0 -0
  94. package/lib/shared/utils/internal/rateLimiter.d.ts +0 -0
  95. package/lib/shared/utils/internal/validation.d.ts +0 -0
  96. package/lib/shared/utils/schemaValidation.d.ts +0 -0
  97. package/lib/shared/utils/validation.d.ts +0 -0
  98. package/lib/shared/utils/vercelHelpers.d.ts +0 -0
  99. package/lib/shared/utils.d.ts +0 -0
  100. package/lib/shared/validation.d.ts +0 -0
  101. package/lib/supabase/ai/createAIFunction.d.ts +0 -0
  102. package/lib/supabase/auth/deleteAccount.d.ts +0 -0
  103. package/lib/supabase/auth/getCustomClaims.d.ts +0 -0
  104. package/lib/supabase/auth/getUserAuthStatus.d.ts +0 -0
  105. package/lib/supabase/auth/removeCustomClaims.d.ts +0 -0
  106. package/lib/supabase/auth/setCustomClaims.d.ts +0 -0
  107. package/lib/supabase/baseFunction.d.ts +0 -0
  108. package/lib/supabase/billing/cancelSubscription.d.ts +0 -0
  109. package/lib/supabase/billing/changePlan.d.ts +0 -0
  110. package/lib/supabase/billing/createCheckoutSession.d.ts +0 -0
  111. package/lib/supabase/billing/createCustomerPortal.d.ts +0 -0
  112. package/lib/supabase/billing/refreshSubscriptionStatus.d.ts +0 -0
  113. package/lib/supabase/crud/aggregate.d.ts +0 -0
  114. package/lib/supabase/crud/bulk.d.ts +63 -0
  115. package/lib/supabase/crud/create.d.ts +1 -1
  116. package/lib/supabase/crud/delete.d.ts +0 -0
  117. package/lib/supabase/crud/get.d.ts +0 -0
  118. package/lib/supabase/crud/index.d.ts +2 -0
  119. package/lib/supabase/crud/list.d.ts +0 -0
  120. package/lib/supabase/crud/update.d.ts +0 -0
  121. package/lib/supabase/edgeFunction.d.ts +0 -0
  122. package/lib/supabase/email/createEmailFunction.d.ts +0 -0
  123. package/lib/supabase/helpers/authProvider.d.ts +0 -0
  124. package/lib/supabase/index.d.ts +3 -3
  125. package/lib/supabase/index.js +3 -3
  126. package/lib/supabase/index.js.map +4 -4
  127. package/lib/supabase/oauth/disconnect.d.ts +0 -0
  128. package/lib/supabase/oauth/exchangeToken.d.ts +0 -0
  129. package/lib/supabase/oauth/getConnections.d.ts +0 -0
  130. package/lib/supabase/oauth/index.d.ts +0 -0
  131. package/lib/supabase/oauth/refreshToken.d.ts +0 -0
  132. package/lib/supabase/registerCrudFunctions.d.ts +0 -0
  133. package/lib/supabase/utils/idempotency.d.ts +0 -0
  134. package/lib/supabase/utils/monitoring.d.ts +0 -0
  135. package/lib/supabase/utils/rateLimiter.d.ts +0 -0
  136. package/lib/vercel/api/ai/chat.d.ts +0 -0
  137. package/lib/vercel/api/ai/index.d.ts +0 -0
  138. package/lib/vercel/api/auth/get-custom-claims.d.ts +0 -0
  139. package/lib/vercel/api/auth/get-user-auth-status.d.ts +0 -0
  140. package/lib/vercel/api/auth/index.d.ts +0 -0
  141. package/lib/vercel/api/auth/remove-custom-claims.d.ts +0 -0
  142. package/lib/vercel/api/auth/set-custom-claims.d.ts +0 -0
  143. package/lib/vercel/api/billing/cancel.d.ts +0 -0
  144. package/lib/vercel/api/billing/change-plan.d.ts +0 -0
  145. package/lib/vercel/api/billing/create-checkout-session.d.ts +0 -0
  146. package/lib/vercel/api/billing/customer-portal.d.ts +0 -0
  147. package/lib/vercel/api/billing/index.d.ts +0 -0
  148. package/lib/vercel/api/billing/refresh-subscription-status.d.ts +0 -0
  149. package/lib/vercel/api/billing/webhook-handler.d.ts +0 -0
  150. package/lib/vercel/api/config/constants.d.ts +0 -0
  151. package/lib/vercel/api/config/firebase-admin.d.ts +0 -0
  152. package/lib/vercel/api/config/index.d.ts +0 -0
  153. package/lib/vercel/api/crud/bulk.d.ts +31 -0
  154. package/lib/vercel/api/crud/create.d.ts +0 -0
  155. package/lib/vercel/api/crud/delete.d.ts +0 -0
  156. package/lib/vercel/api/crud/get.d.ts +0 -0
  157. package/lib/vercel/api/crud/index.d.ts +1 -0
  158. package/lib/vercel/api/crud/list.d.ts +0 -0
  159. package/lib/vercel/api/crud/update.d.ts +0 -0
  160. package/lib/vercel/api/index.d.ts +0 -0
  161. package/lib/vercel/api/index.js +3 -3
  162. package/lib/vercel/api/index.js.map +4 -4
  163. package/lib/vercel/api/oauth/check-github-access.d.ts +0 -0
  164. package/lib/vercel/api/oauth/exchange-token.d.ts +0 -0
  165. package/lib/vercel/api/oauth/grant-github-access.d.ts +0 -0
  166. package/lib/vercel/api/oauth/index.d.ts +0 -0
  167. package/lib/vercel/api/oauth/revoke-github-access.d.ts +0 -0
  168. package/lib/vercel/api/utils/cors.d.ts +0 -0
  169. package/lib/vercel/baseFunction.d.ts +0 -0
  170. package/package.json +6 -6
  171. package/src/firebase/auth/getCustomClaims.ts +0 -0
  172. package/src/firebase/auth/getUserAuthStatus.ts +0 -0
  173. package/src/firebase/auth/index.ts +0 -0
  174. package/src/firebase/auth/removeCustomClaims.ts +0 -0
  175. package/src/firebase/auth/setCustomClaims.ts +0 -0
  176. package/src/firebase/baseFunction.ts +0 -0
  177. package/src/firebase/billing/cancelSubscription.ts +0 -0
  178. package/src/firebase/billing/changePlan.ts +0 -0
  179. package/src/firebase/billing/createCheckoutSession.ts +5 -1
  180. package/src/firebase/billing/createCustomerPortal.ts +0 -0
  181. package/src/firebase/billing/healthCheck.ts +0 -0
  182. package/src/firebase/billing/index.d.ts +0 -0
  183. package/src/firebase/billing/index.ts +0 -0
  184. package/src/firebase/billing/refreshSubscriptionStatus.ts +0 -0
  185. package/src/firebase/billing/webhookHandler.ts +0 -0
  186. package/src/firebase/config/constants.ts +0 -0
  187. package/src/firebase/config/index.ts +0 -0
  188. package/src/firebase/config/secrets.ts +0 -0
  189. package/src/firebase/crud/__tests__/bulk.test.ts +322 -0
  190. package/src/firebase/crud/aggregate.ts +0 -0
  191. package/src/firebase/crud/bulk.ts +272 -0
  192. package/src/firebase/crud/create.ts +20 -33
  193. package/src/firebase/crud/delete.ts +0 -0
  194. package/src/firebase/crud/get.ts +0 -0
  195. package/src/firebase/crud/index.ts +1 -0
  196. package/src/firebase/crud/list.ts +0 -0
  197. package/src/firebase/crud/update.ts +0 -0
  198. package/src/firebase/helpers/githubAccessHelper.ts +0 -0
  199. package/src/firebase/helpers/githubTeamAccessHelper.ts +0 -0
  200. package/src/firebase/helpers/index.ts +0 -0
  201. package/src/firebase/index.d.ts +0 -0
  202. package/src/firebase/index.ts +0 -0
  203. package/src/firebase/oauth/disconnect.ts +0 -0
  204. package/src/firebase/oauth/exchangeToken.ts +0 -0
  205. package/src/firebase/oauth/getConnections.ts +0 -0
  206. package/src/firebase/oauth/githubAccess.ts +0 -0
  207. package/src/firebase/oauth/index.ts +0 -0
  208. package/src/firebase/oauth/refreshToken.ts +0 -0
  209. package/src/firebase/registerCrudFunctions.ts +13 -0
  210. package/src/firebase/scheduled/checkExpiredSubscriptions.ts +0 -0
  211. package/src/firebase/scheduled/index.ts +0 -0
  212. package/src/shared/__tests__/auth.test.ts +0 -0
  213. package/src/shared/__tests__/bulkCore.test.ts +487 -0
  214. package/src/shared/__tests__/errorHandling.test.ts +0 -0
  215. package/src/shared/__tests__/firebase.test.ts +9 -3
  216. package/src/shared/__tests__/idempotency.test.ts +0 -0
  217. package/src/shared/__tests__/internalValidation.test.ts +9 -3
  218. package/src/shared/__tests__/metadata.test.ts +10 -10
  219. package/src/shared/__tests__/rateLimiter.test.ts +0 -0
  220. package/src/shared/__tests__/schema.test.ts +0 -0
  221. package/src/shared/__tests__/schemaValidation.test.ts +0 -0
  222. package/src/shared/__tests__/subscription.test.ts +0 -0
  223. package/src/shared/__tests__/utils.test.ts +10 -4
  224. package/src/shared/__tests__/validation-env.test.ts +9 -3
  225. package/src/shared/__tests__/validation.test.ts +0 -0
  226. package/src/shared/ai/__tests__/costTracker.test.ts +25 -13
  227. package/src/shared/ai/classifyAIError.ts +26 -11
  228. package/src/shared/ai/costTracker.ts +0 -0
  229. package/src/shared/ai/createAIRoute.ts +11 -8
  230. package/src/shared/ai/index.ts +0 -0
  231. package/src/shared/ai/resolveModelTier.ts +5 -2
  232. package/src/shared/billing/__tests__/createCheckout.test.ts +0 -0
  233. package/src/shared/billing/__tests__/webhookHandler.test.ts +0 -0
  234. package/src/shared/billing/createCheckout.ts +24 -9
  235. package/src/shared/billing/helpers/index.ts +0 -0
  236. package/src/shared/billing/helpers/subscriptionManagement.ts +0 -0
  237. package/src/shared/billing/helpers/updateUserSubscription.ts +0 -0
  238. package/src/shared/billing/idempotency.ts +0 -0
  239. package/src/shared/billing/index.ts +0 -0
  240. package/src/shared/billing/webhookHandler.ts +0 -0
  241. package/src/shared/crud/bulkCore.ts +483 -0
  242. package/src/shared/crud/index.ts +23 -0
  243. package/src/shared/email/createEmailRoute.ts +0 -0
  244. package/src/shared/email/index.ts +0 -0
  245. package/src/shared/email/provider.ts +0 -0
  246. package/src/shared/email/resendProvider.ts +1 -1
  247. package/src/shared/errorHandling.ts +0 -0
  248. package/src/shared/firebase.ts +0 -0
  249. package/src/shared/github.ts +0 -0
  250. package/src/shared/index.d.ts +9 -0
  251. package/src/shared/index.ts +1 -0
  252. package/src/shared/logger.ts +0 -0
  253. package/src/shared/metadata.ts +6 -6
  254. package/src/shared/oauth/__tests__/exchangeToken.test.ts +0 -0
  255. package/src/shared/oauth/__tests__/grantAccess.test.ts +0 -0
  256. package/src/shared/oauth/exchangeToken.ts +0 -0
  257. package/src/shared/oauth/grantAccess.ts +0 -0
  258. package/src/shared/oauth/index.ts +0 -0
  259. package/src/shared/schema.ts +0 -0
  260. package/src/shared/utils/__tests__/functionWrapper.test.ts +0 -0
  261. package/src/shared/utils/detectFirestore.ts +0 -0
  262. package/src/shared/utils/external/date.ts +0 -0
  263. package/src/shared/utils/external/index.ts +0 -0
  264. package/src/shared/utils/external/references.ts +0 -0
  265. package/src/shared/utils/external/subscription.ts +0 -0
  266. package/src/shared/utils/firebaseHelpers.ts +0 -0
  267. package/src/shared/utils/functionWrapper.ts +0 -0
  268. package/src/shared/utils/index.ts +0 -0
  269. package/src/shared/utils/internal/auth.ts +0 -0
  270. package/src/shared/utils/internal/firebase.ts +0 -0
  271. package/src/shared/utils/internal/idempotency.ts +0 -0
  272. package/src/shared/utils/internal/index.ts +0 -0
  273. package/src/shared/utils/internal/monitoring.ts +0 -0
  274. package/src/shared/utils/internal/rateLimiter.ts +0 -0
  275. package/src/shared/utils/internal/validation.ts +0 -0
  276. package/src/shared/utils/schemaValidation.ts +0 -0
  277. package/src/shared/utils/validation.ts +0 -0
  278. package/src/shared/utils/vercelHelpers.ts +0 -0
  279. package/src/shared/utils.ts +0 -0
  280. package/src/shared/validation.ts +0 -0
  281. package/src/supabase/__tests__/bulk.test.ts +330 -0
  282. package/src/supabase/ai/createAIFunction.ts +17 -16
  283. package/src/supabase/auth/deleteAccount.ts +0 -0
  284. package/src/supabase/auth/getCustomClaims.ts +0 -0
  285. package/src/supabase/auth/getUserAuthStatus.ts +0 -0
  286. package/src/supabase/auth/removeCustomClaims.ts +0 -0
  287. package/src/supabase/auth/setCustomClaims.ts +1 -3
  288. package/src/supabase/baseFunction.ts +0 -0
  289. package/src/supabase/billing/cancelSubscription.ts +0 -0
  290. package/src/supabase/billing/changePlan.ts +1 -1
  291. package/src/supabase/billing/createCheckoutSession.ts +0 -0
  292. package/src/supabase/billing/createCustomerPortal.ts +0 -0
  293. package/src/supabase/billing/refreshSubscriptionStatus.ts +0 -0
  294. package/src/supabase/crud/aggregate.ts +0 -0
  295. package/src/supabase/crud/bulk.ts +244 -0
  296. package/src/supabase/crud/create.ts +15 -14
  297. package/src/supabase/crud/delete.ts +0 -0
  298. package/src/supabase/crud/get.ts +0 -0
  299. package/src/supabase/crud/index.ts +2 -0
  300. package/src/supabase/crud/list.ts +0 -0
  301. package/src/supabase/crud/update.ts +0 -0
  302. package/src/supabase/edgeFunction.ts +4 -3
  303. package/src/supabase/email/createEmailFunction.ts +9 -12
  304. package/src/supabase/helpers/authProvider.ts +0 -0
  305. package/src/supabase/index.ts +12 -3
  306. package/src/supabase/oauth/disconnect.ts +1 -2
  307. package/src/supabase/oauth/exchangeToken.ts +1 -3
  308. package/src/supabase/oauth/getConnections.ts +1 -4
  309. package/src/supabase/oauth/index.ts +0 -0
  310. package/src/supabase/oauth/refreshToken.ts +2 -7
  311. package/src/supabase/registerCrudFunctions.ts +38 -26
  312. package/src/supabase/utils/idempotency.ts +0 -0
  313. package/src/supabase/utils/monitoring.ts +0 -0
  314. package/src/supabase/utils/rateLimiter.ts +0 -0
  315. package/src/vercel/__tests__/bulk.test.ts +301 -0
  316. package/src/vercel/api/ai/chat.ts +0 -0
  317. package/src/vercel/api/ai/index.ts +2 -0
  318. package/src/vercel/api/auth/get-custom-claims.ts +0 -0
  319. package/src/vercel/api/auth/get-user-auth-status.ts +0 -0
  320. package/src/vercel/api/auth/index.ts +0 -0
  321. package/src/vercel/api/auth/remove-custom-claims.ts +0 -0
  322. package/src/vercel/api/auth/set-custom-claims.ts +0 -0
  323. package/src/vercel/api/billing/cancel.ts +0 -0
  324. package/src/vercel/api/billing/change-plan.ts +0 -0
  325. package/src/vercel/api/billing/create-checkout-session.ts +5 -1
  326. package/src/vercel/api/billing/customer-portal.ts +0 -0
  327. package/src/vercel/api/billing/index.ts +0 -0
  328. package/src/vercel/api/billing/refresh-subscription-status.ts +0 -0
  329. package/src/vercel/api/billing/webhook-handler.ts +0 -0
  330. package/src/vercel/api/config/constants.ts +0 -0
  331. package/src/vercel/api/config/firebase-admin.ts +0 -0
  332. package/src/vercel/api/config/index.ts +0 -0
  333. package/src/vercel/api/crud/bulk.ts +216 -0
  334. package/src/vercel/api/crud/create.ts +10 -9
  335. package/src/vercel/api/crud/delete.ts +0 -0
  336. package/src/vercel/api/crud/get.ts +0 -0
  337. package/src/vercel/api/crud/index.ts +1 -0
  338. package/src/vercel/api/crud/list.ts +0 -0
  339. package/src/vercel/api/crud/update.ts +0 -0
  340. package/src/vercel/api/index.d.ts +0 -0
  341. package/src/vercel/api/index.ts +0 -0
  342. package/src/vercel/api/oauth/check-github-access.ts +0 -0
  343. package/src/vercel/api/oauth/exchange-token.ts +4 -1
  344. package/src/vercel/api/oauth/grant-github-access.ts +0 -0
  345. package/src/vercel/api/oauth/index.ts +0 -0
  346. package/src/vercel/api/oauth/revoke-github-access.ts +0 -0
  347. package/src/vercel/api/utils/cors.ts +3 -1
  348. package/src/vercel/baseFunction.ts +0 -0
@@ -11,10 +11,7 @@
11
11
 
12
12
  import * as v from 'valibot';
13
13
 
14
- import {
15
- DEFAULT_STATUS_VALUE,
16
- filterVisibleFields,
17
- } from '@donotdev/core/server';
14
+ import { filterVisibleFields } from '@donotdev/core/server';
18
15
  import type { UserRole, UniqueKeyDefinition } from '@donotdev/core/server';
19
16
  import { defaultFieldMapper } from '@donotdev/supabase/server';
20
17
 
@@ -130,7 +127,8 @@ async function checkUniqueKeys(
130
127
  */
131
128
  export function createSupabaseCreateEntity(
132
129
  collection: string,
133
- documentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>,
130
+ createDocumentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>,
131
+ draftDocumentSchema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>>,
134
132
  requiredRole: UserRole
135
133
  ) {
136
134
  const requestSchema = v.object({
@@ -157,12 +155,12 @@ export function createSupabaseCreateEntity(
157
155
  }
158
156
  }
159
157
 
160
- // Determine status (default to available if not provided)
161
- const status = payload.status ?? DEFAULT_STATUS_VALUE;
158
+ // New records start as drafts unless the caller explicitly sets a status.
159
+ const status = payload.status ?? 'draft';
162
160
  const isDraft = status === 'draft';
163
161
 
164
162
  // Check unique keys if schema has metadata with uniqueKeys
165
- const schemaWithMeta = documentSchema as {
163
+ const schemaWithMeta = createDocumentSchema as {
166
164
  metadata?: { uniqueKeys?: UniqueKeyDefinition[] };
167
165
  };
168
166
  const uniqueKeys = schemaWithMeta.metadata?.uniqueKeys;
@@ -180,7 +178,7 @@ export function createSupabaseCreateEntity(
180
178
  // G67: Apply same visibility filtering as normal create path
181
179
  return filterVisibleFields(
182
180
  checkResult.existingDoc,
183
- documentSchema,
181
+ createDocumentSchema,
184
182
  userRole
185
183
  );
186
184
  }
@@ -192,11 +190,14 @@ export function createSupabaseCreateEntity(
192
190
  ? normalizePayloadForUniqueKeys(payload, uniqueKeys)
193
191
  : payload;
194
192
 
195
- // Validate the document against the schema
196
- // Skip validation for drafts - required fields can be incomplete
197
- if (!isDraft) {
198
- validateDocument(normalizedPayload, documentSchema);
199
- }
193
+ // Validate against the appropriate schema.
194
+ // Drafts must validate with `schemas.draft` so required fields become
195
+ // nullish/optional (instead of failing strict `schemas.create`).
196
+ const payloadForValidation = { ...normalizedPayload, status };
197
+ validateDocument(
198
+ payloadForValidation,
199
+ isDraft ? draftDocumentSchema : createDocumentSchema
200
+ );
200
201
 
201
202
  const metadata = createMetadata(uid);
202
203
  const snakeMetadata = mapper.toBackendKeys(
File without changes
File without changes
@@ -15,6 +15,7 @@ export { createSupabaseUpdateEntity } from './update.js';
15
15
  export { createSupabaseDeleteEntity } from './delete.js';
16
16
  export { createSupabaseListEntities } from './list.js';
17
17
  export { createSupabaseAggregateEntities } from './aggregate.js';
18
+ export { createSupabaseBulkEntity } from './bulk.js';
18
19
 
19
20
  export type { GetEntityRequest } from './get.js';
20
21
  export type { CreateEntityRequest } from './create.js';
@@ -22,3 +23,4 @@ export type { UpdateEntityRequest } from './update.js';
22
23
  export type { DeleteEntityRequest, ReferenceMetadata } from './delete.js';
23
24
  export type { ListEntityRequest } from './list.js';
24
25
  export type { AggregateEntityRequest } from './aggregate.js';
26
+ export type { BulkEntityRequest } from './bulk.js';
File without changes
File without changes
@@ -79,7 +79,7 @@ export interface EdgeFunctionOptions {
79
79
  */
80
80
  export function createEdgeFunction(
81
81
  handler: (req: Request, ctx: EdgeFunctionContext) => Promise<Response>,
82
- options?: EdgeFunctionOptions,
82
+ options?: EdgeFunctionOptions
83
83
  ): (req: Request) => Promise<Response> {
84
84
  const requireAuth = options?.requireAuth ?? true;
85
85
  const baseHeaders = 'authorization, content-type, x-client-info, apikey';
@@ -140,7 +140,8 @@ export function createEdgeFunction(
140
140
  userClient = createClient(supabaseUrl, anonKey, {
141
141
  global: { headers: { Authorization: `Bearer ${jwt}` } },
142
142
  });
143
- const { data, error: authError } = await supabaseAdmin.auth.getUser(jwt);
143
+ const { data, error: authError } =
144
+ await supabaseAdmin.auth.getUser(jwt);
144
145
  if (!authError && data.user) {
145
146
  user = { id: data.user.id, email: data.user.email ?? undefined };
146
147
  }
@@ -176,7 +177,7 @@ export function createEdgeFunction(
176
177
  function jsonResponse(
177
178
  data: unknown,
178
179
  status: number,
179
- allowedOrigin: string,
180
+ allowedOrigin: string
180
181
  ): Response {
181
182
  return new Response(JSON.stringify(data), {
182
183
  status,
@@ -10,10 +10,7 @@
10
10
  * @author AMBROISE PARK Consulting
11
11
  */
12
12
 
13
- import type {
14
- EmailRouteConfig,
15
- SendEmailRequest,
16
- } from '@donotdev/core/server';
13
+ import type { EmailRouteConfig, SendEmailRequest } from '@donotdev/core/server';
17
14
  import { SendEmailRequestSchema } from '@donotdev/core/server';
18
15
 
19
16
  import { handleEmailRequest } from '../../shared/email/index.js';
@@ -48,7 +45,10 @@ export function createEmailFunction(config: EmailRouteConfig) {
48
45
  const apiKey = getEnv('RESEND_API_KEY');
49
46
  if (!apiKey) {
50
47
  return new Response(
51
- JSON.stringify({ success: false, error: 'Email provider not configured' }),
48
+ JSON.stringify({
49
+ success: false,
50
+ error: 'Email provider not configured',
51
+ }),
52
52
  { status: 500, headers: { 'Content-Type': 'application/json' } }
53
53
  );
54
54
  }
@@ -56,13 +56,10 @@ export function createEmailFunction(config: EmailRouteConfig) {
56
56
  const provider = createResendProvider(apiKey);
57
57
  const result = await handleEmailRequest(data, config, provider);
58
58
 
59
- return new Response(
60
- JSON.stringify(result),
61
- {
62
- status: result.success ? 200 : 400,
63
- headers: { 'Content-Type': 'application/json' },
64
- }
65
- );
59
+ return new Response(JSON.stringify(result), {
60
+ status: result.success ? 200 : 400,
61
+ headers: { 'Content-Type': 'application/json' },
62
+ });
66
63
  }
67
64
  );
68
65
  }
File without changes
@@ -13,7 +13,10 @@
13
13
  export { createSupabaseHandler } from './baseFunction.js';
14
14
  export type { SupabaseHandlerContext } from './baseFunction.js';
15
15
  export { createEdgeFunction } from './edgeFunction.js';
16
- export type { EdgeFunctionContext, EdgeFunctionOptions } from './edgeFunction.js';
16
+ export type {
17
+ EdgeFunctionContext,
18
+ EdgeFunctionOptions,
19
+ } from './edgeFunction.js';
17
20
 
18
21
  // Helpers
19
22
  export { createSupabaseAuthProvider } from './helpers/authProvider.js';
@@ -44,8 +47,14 @@ export {
44
47
  // AI
45
48
  export { createAIFunction } from './ai/createAIFunction.js';
46
49
  export { resolveModelForTier } from '../shared/ai/resolveModelTier.js';
47
- export { classifyAIError, mapClassifiedToHTTP } from '../shared/ai/classifyAIError.js';
48
- export type { AIErrorCode, ClassifiedAIError } from '../shared/ai/classifyAIError.js';
50
+ export {
51
+ classifyAIError,
52
+ mapClassifiedToHTTP,
53
+ } from '../shared/ai/classifyAIError.js';
54
+ export type {
55
+ AIErrorCode,
56
+ ClassifiedAIError,
57
+ } from '../shared/ai/classifyAIError.js';
49
58
 
50
59
  // Email
51
60
  export { createEmailFunction } from './email/createEmailFunction.js';
@@ -67,8 +67,7 @@ export function createDisconnect() {
67
67
  // Revoke token if possible
68
68
  if (connection?.credentials?.accessToken) {
69
69
  const endpoints = OAUTH_PARTNERS[provider];
70
- const revokeUrl =
71
- 'revokeUrl' in endpoints ? endpoints.revokeUrl : null;
70
+ const revokeUrl = 'revokeUrl' in endpoints ? endpoints.revokeUrl : null;
72
71
  if (revokeUrl) {
73
72
  try {
74
73
  await fetch(revokeUrl.toString(), {
@@ -48,9 +48,7 @@ function sanitizeProfileData(
48
48
 
49
49
  /** Cross-runtime env var access (Deno Edge Functions + Node tests) */
50
50
  function getEnv(key: string): string | undefined {
51
- return typeof Deno !== 'undefined'
52
- ? Deno.env.get(key)
53
- : process.env[key];
51
+ return typeof Deno !== 'undefined' ? Deno.env.get(key) : process.env[key];
54
52
  }
55
53
 
56
54
  declare const Deno:
@@ -42,10 +42,7 @@ export function createGetConnections() {
42
42
  return createSupabaseHandler(
43
43
  'get-connections',
44
44
  getConnectionsSchema,
45
- async (
46
- data: { purpose?: OAuthPurpose },
47
- ctx: SupabaseHandlerContext
48
- ) => {
45
+ async (data: { purpose?: OAuthPurpose }, ctx: SupabaseHandlerContext) => {
49
46
  let query = ctx.supabaseAdmin
50
47
  .from('oauth_connections')
51
48
  .select('*')
File without changes
@@ -21,9 +21,7 @@ import type { SupabaseHandlerContext } from '../baseFunction.js';
21
21
 
22
22
  /** Cross-runtime env var access (Deno Edge Functions + Node tests) */
23
23
  function getEnv(key: string): string | undefined {
24
- return typeof Deno !== 'undefined'
25
- ? Deno.env.get(key)
26
- : process.env[key];
24
+ return typeof Deno !== 'undefined' ? Deno.env.get(key) : process.env[key];
27
25
  }
28
26
 
29
27
  declare const Deno:
@@ -36,10 +34,7 @@ const refreshTokenSchema = v.object({
36
34
  OAuthRefreshRequest['provider'],
37
35
  v.BaseIssue<unknown>
38
36
  >,
39
- refreshToken: v.pipe(
40
- v.string(),
41
- v.minLength(1, 'Refresh token is required')
42
- ),
37
+ refreshToken: v.pipe(v.string(), v.minLength(1, 'Refresh token is required')),
43
38
  redirectUri: v.pipe(v.string(), v.url('Valid redirect URI is required')),
44
39
  });
45
40
 
@@ -19,6 +19,7 @@ import {
19
19
  createSupabaseDeleteEntity,
20
20
  createSupabaseListEntities,
21
21
  createSupabaseAggregateEntities,
22
+ createSupabaseBulkEntity,
22
23
  } from './crud/index.js';
23
24
  import { createEdgeFunction } from './edgeFunction.js';
24
25
 
@@ -61,6 +62,7 @@ export function createSupabaseCrudFunctions(
61
62
  handlers[`create_${col}`] = createSupabaseCreateEntity(
62
63
  col,
63
64
  schemas.create,
65
+ schemas.draft,
64
66
  access.create
65
67
  );
66
68
  handlers[`get_${col}`] = createSupabaseGetEntity(
@@ -120,6 +122,13 @@ export function createSupabaseCrudFunctions(
120
122
  schemas.get,
121
123
  access.read
122
124
  );
125
+ handlers[`bulk_${col}`] = createSupabaseBulkEntity(
126
+ col,
127
+ schemas.create,
128
+ schemas.draft,
129
+ schemas.update,
130
+ access
131
+ );
123
132
  }
124
133
 
125
134
  /**
@@ -127,32 +136,35 @@ export function createSupabaseCrudFunctions(
127
136
  * Auth is NOT checked here (requireAuth: false) — individual handlers
128
137
  * use createSupabaseHandler which enforces auth + RBAC per operation.
129
138
  */
130
- const serve = createEdgeFunction(async (req, ctx) => {
131
- const body = await req.json().catch(() => ({}));
132
- const functionName = (body as Record<string, unknown>)
133
- ._functionName as string;
134
-
135
- if (!functionName) {
136
- return ctx.error('Missing _functionName in request body', 400);
137
- }
138
-
139
- const handler = handlers[functionName];
140
- if (!handler) {
141
- return ctx.error(`Unknown function: ${functionName}`, 404);
142
- }
143
-
144
- // Remove _functionName from body before passing to handler
145
- const { _functionName, ...handlerData } = body as Record<string, unknown>;
146
-
147
- // Create new request with cleaned body
148
- const handlerReq = new Request(req.url, {
149
- method: req.method,
150
- headers: req.headers,
151
- body: JSON.stringify(handlerData),
152
- });
153
-
154
- return handler(handlerReq);
155
- }, { requireAuth: false });
139
+ const serve = createEdgeFunction(
140
+ async (req, ctx) => {
141
+ const body = await req.json().catch(() => ({}));
142
+ const functionName = (body as Record<string, unknown>)
143
+ ._functionName as string;
144
+
145
+ if (!functionName) {
146
+ return ctx.error('Missing _functionName in request body', 400);
147
+ }
148
+
149
+ const handler = handlers[functionName];
150
+ if (!handler) {
151
+ return ctx.error(`Unknown function: ${functionName}`, 404);
152
+ }
153
+
154
+ // Remove _functionName from body before passing to handler
155
+ const { _functionName, ...handlerData } = body as Record<string, unknown>;
156
+
157
+ // Create new request with cleaned body
158
+ const handlerReq = new Request(req.url, {
159
+ method: req.method,
160
+ headers: req.headers,
161
+ body: JSON.stringify(handlerData),
162
+ });
163
+
164
+ return handler(handlerReq);
165
+ },
166
+ { requireAuth: false }
167
+ );
156
168
 
157
169
  return { handlers, serve };
158
170
  }
File without changes
File without changes
File without changes
@@ -0,0 +1,301 @@
1
+ // packages/functions/src/vercel/__tests__/bulk.test.ts
2
+
3
+ /**
4
+ * @fileoverview Tests for the Vercel bulk CRUD API handler.
5
+ * @description Unit tests for `POST /api/crud/:collection/bulk`. The Firebase
6
+ * Admin SDK is mocked — these tests exercise the handler's wire contract:
7
+ * parsing, collision rejection, transactional atomicity, method guard, and
8
+ * response shape.
9
+ */
10
+
11
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
12
+
13
+ // ---------------------------------------------------------------------------
14
+ // Mocks — must be declared before importing the handler.
15
+ // ---------------------------------------------------------------------------
16
+
17
+ // Auth: resolve to a fixed uid for all tests.
18
+ vi.mock('../../shared/utils/internal/auth.js', () => ({
19
+ verifyAuthToken: vi.fn(() => Promise.resolve('user-1')),
20
+ }));
21
+
22
+ // Collection-name validator: accept everything in tests.
23
+ vi.mock('../../shared/utils.js', () => ({
24
+ validateCollectionName: vi.fn(),
25
+ DoNotDevError: class DoNotDevError extends Error {
26
+ code: string;
27
+ details: any;
28
+ constructor(message: string, code = 'internal', opts?: any) {
29
+ super(message);
30
+ this.name = 'DoNotDevError';
31
+ this.code = code;
32
+ this.details = opts?.details;
33
+ }
34
+ },
35
+ }));
36
+
37
+ // Metadata helpers — deterministic output for snapshot-like assertions.
38
+ // `executeBulk` is the real orchestrator so end-to-end behaviour (collision
39
+ // detection, empty short-circuit, transact invocation) exercises the shared
40
+ // core.
41
+ vi.mock('../../shared/index.js', async () => {
42
+ const actual = await vi.importActual<typeof import('../../shared/index.js')>(
43
+ '../../shared/index.js'
44
+ );
45
+ return {
46
+ ...actual,
47
+ prepareForFirestore: (obj: Record<string, unknown>) => ({ ...obj }),
48
+ transformFirestoreData: (obj: Record<string, unknown>) => ({ ...obj }),
49
+ createMetadata: (uid: string) => ({
50
+ createdAt: 'now',
51
+ updatedAt: 'now',
52
+ createdById: uid,
53
+ updatedById: uid,
54
+ }),
55
+ updateMetadata: (uid: string) => ({
56
+ updatedAt: 'now',
57
+ updatedById: uid,
58
+ }),
59
+ };
60
+ });
61
+
62
+ // ---------------------------------------------------------------------------
63
+ // Firebase Admin SDK — shared spy surface so each test can assert calls.
64
+ // ---------------------------------------------------------------------------
65
+
66
+ type TxSpy = {
67
+ get: ReturnType<typeof vi.fn>;
68
+ set: ReturnType<typeof vi.fn>;
69
+ update: ReturnType<typeof vi.fn>;
70
+ delete: ReturnType<typeof vi.fn>;
71
+ };
72
+
73
+ let txSpy: TxSpy;
74
+ let existingDocIds: Set<string>;
75
+ let mintedIds: string[];
76
+ let mintedIdx: number;
77
+
78
+ vi.mock('@donotdev/firebase/server', () => {
79
+ const doc = (id?: string) => {
80
+ const docId = id ?? mintedIds[mintedIdx++] ?? `auto-${mintedIdx}`;
81
+ return { id: docId, _id: docId };
82
+ };
83
+ const collection = (_name: string) => ({ doc });
84
+
85
+ const runTransaction = vi.fn(async (work: (tx: any) => Promise<any>) => {
86
+ txSpy = {
87
+ get: vi.fn(async (ref: any) => ({
88
+ exists: existingDocIds.has(ref.id),
89
+ id: ref.id,
90
+ data: () => ({}),
91
+ })),
92
+ set: vi.fn(),
93
+ update: vi.fn(),
94
+ delete: vi.fn(),
95
+ };
96
+ return await work(txSpy);
97
+ });
98
+
99
+ return {
100
+ getFirebaseAdminFirestore: () => ({
101
+ collection,
102
+ runTransaction,
103
+ }),
104
+ };
105
+ });
106
+
107
+ // Error handling: keep real `handleError` (throws DoNotDevError-shaped) so the
108
+ // response mapping in the handler runs end-to-end.
109
+ vi.mock('../../shared/errorHandling.js', async () => {
110
+ class DoNotDevError extends Error {
111
+ code: string;
112
+ constructor(message: string, code = 'internal') {
113
+ super(message);
114
+ this.name = 'DoNotDevError';
115
+ this.code = code;
116
+ }
117
+ }
118
+ return {
119
+ DoNotDevError,
120
+ handleError: (err: unknown) => {
121
+ if (err instanceof DoNotDevError) throw err;
122
+ if (err instanceof Error && err.name === 'BulkCollisionError') {
123
+ throw new DoNotDevError(err.message, 'invalid-argument');
124
+ }
125
+ if (err instanceof Error && err.name === 'ValiError') {
126
+ throw new DoNotDevError('Validation failed', 'invalid-argument');
127
+ }
128
+ throw new DoNotDevError(
129
+ err instanceof Error ? err.message : 'Internal',
130
+ 'internal'
131
+ );
132
+ },
133
+ };
134
+ });
135
+
136
+ // ---------------------------------------------------------------------------
137
+ // Import handler AFTER mocks.
138
+ // ---------------------------------------------------------------------------
139
+
140
+ import handler from '../api/crud/bulk.js';
141
+
142
+ // ---------------------------------------------------------------------------
143
+ // Test helpers.
144
+ // ---------------------------------------------------------------------------
145
+
146
+ function makeRes() {
147
+ const res: any = {};
148
+ res.status = vi.fn((code: number) => {
149
+ res._status = code;
150
+ return res;
151
+ });
152
+ res.json = vi.fn((body: unknown) => {
153
+ res._body = body;
154
+ return res;
155
+ });
156
+ return res;
157
+ }
158
+
159
+ function makeReq(opts: {
160
+ method?: string;
161
+ collection?: string | string[];
162
+ body?: unknown;
163
+ }) {
164
+ return {
165
+ method: opts.method ?? 'POST',
166
+ query: { collection: opts.collection ?? 'events' },
167
+ body: opts.body,
168
+ headers: { authorization: 'Bearer test' },
169
+ } as any;
170
+ }
171
+
172
+ beforeEach(() => {
173
+ existingDocIds = new Set();
174
+ mintedIds = [];
175
+ mintedIdx = 0;
176
+ vi.clearAllMocks();
177
+ });
178
+
179
+ // ---------------------------------------------------------------------------
180
+ // Tests.
181
+ // ---------------------------------------------------------------------------
182
+
183
+ describe('vercel bulk handler — happy path', () => {
184
+ it('runs 2 inserts + 1 update + 1 delete in a single transaction', async () => {
185
+ existingDocIds = new Set(['u1', 'd1']);
186
+ mintedIds = ['new-1', 'new-2'];
187
+
188
+ const req = makeReq({
189
+ body: {
190
+ inserts: [{ title: 'A' }, { title: 'B' }],
191
+ updates: [{ id: 'u1', patch: { title: 'renamed' } }],
192
+ deletes: ['d1'],
193
+ },
194
+ });
195
+ const res = makeRes();
196
+
197
+ await handler(req, res);
198
+
199
+ expect(res._status).toBe(200);
200
+ expect(res._body).toEqual({
201
+ insertedIds: ['new-1', 'new-2'],
202
+ updatedIds: ['u1'],
203
+ deletedIds: ['d1'],
204
+ });
205
+ // One transaction, N writes inside it.
206
+ expect(txSpy.set).toHaveBeenCalledTimes(2);
207
+ expect(txSpy.update).toHaveBeenCalledTimes(1);
208
+ expect(txSpy.delete).toHaveBeenCalledTimes(1);
209
+ });
210
+ });
211
+
212
+ describe('vercel bulk handler — empty payload', () => {
213
+ it('returns zeroed response without touching the DB', async () => {
214
+ const req = makeReq({ body: {} });
215
+ const res = makeRes();
216
+
217
+ await handler(req, res);
218
+
219
+ expect(res._status).toBe(200);
220
+ expect(res._body).toEqual({
221
+ insertedIds: [],
222
+ updatedIds: [],
223
+ deletedIds: [],
224
+ });
225
+ // No transaction spy created → no DB work.
226
+ expect(txSpy).toBeUndefined();
227
+ });
228
+ });
229
+
230
+ describe('vercel bulk handler — collision rejection', () => {
231
+ it('rejects id present in both updates and deletes', async () => {
232
+ const req = makeReq({
233
+ body: {
234
+ updates: [{ id: 'x', patch: { a: 1 } }],
235
+ deletes: ['x'],
236
+ },
237
+ });
238
+ const res = makeRes();
239
+
240
+ await handler(req, res);
241
+
242
+ expect(res._status).toBe(400);
243
+ expect((res._body as any).error).toMatch(/BulkCollisionError/);
244
+ expect(txSpy).toBeUndefined();
245
+ });
246
+ });
247
+
248
+ describe('vercel bulk handler — validation failure', () => {
249
+ it('rolls back when an update targets a non-existent doc', async () => {
250
+ // `u1` not in existingDocIds → tx.get returns `exists: false` → throw.
251
+ existingDocIds = new Set();
252
+ mintedIds = ['new-1'];
253
+
254
+ const req = makeReq({
255
+ body: {
256
+ inserts: [{ title: 'A' }],
257
+ updates: [{ id: 'u1', patch: { title: 'x' } }],
258
+ },
259
+ });
260
+ const res = makeRes();
261
+
262
+ await handler(req, res);
263
+
264
+ expect(res._status).toBe(500);
265
+ // No writes issued — existence check runs before any tx.set/update/delete.
266
+ expect(txSpy.set).not.toHaveBeenCalled();
267
+ expect(txSpy.update).not.toHaveBeenCalled();
268
+ expect(txSpy.delete).not.toHaveBeenCalled();
269
+ });
270
+
271
+ it('rejects structurally invalid body (ACL-equivalent schema check)', async () => {
272
+ // `updates[0]` missing required `id` — schema rejects before DB access.
273
+ const req = makeReq({
274
+ body: {
275
+ updates: [{ patch: { title: 'x' } }],
276
+ },
277
+ });
278
+ const res = makeRes();
279
+
280
+ await handler(req, res);
281
+
282
+ expect(res._status).toBe(400);
283
+ expect(txSpy).toBeUndefined();
284
+ });
285
+ });
286
+
287
+ describe('vercel bulk handler — method guard', () => {
288
+ it('rejects GET with 405', async () => {
289
+ const req = makeReq({ method: 'GET', body: {} });
290
+ const res = makeRes();
291
+ await handler(req, res);
292
+ expect(res._status).toBe(405);
293
+ });
294
+
295
+ it('rejects PUT with 405', async () => {
296
+ const req = makeReq({ method: 'PUT', body: {} });
297
+ const res = makeRes();
298
+ await handler(req, res);
299
+ expect(res._status).toBe(405);
300
+ });
301
+ });
File without changes
@@ -1 +1,3 @@
1
+ // packages/functions/src/vercel/api/ai/index.ts
2
+
1
3
  export { createAIChatRoute } from './chat.js';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes