nuxt-backend 0.2.1 → 0.3.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 (858) hide show
  1. package/README.md +17 -6
  2. package/dist/capabilities/detect.js +16 -7
  3. package/dist/capabilities/gateway-route.js +24 -0
  4. package/dist/capabilities/registry.js +3 -2
  5. package/dist/capabilities/status.js +3 -1
  6. package/dist/chunks/catalog.mjs +1 -1
  7. package/dist/chunks/doctor.mjs +498 -67
  8. package/dist/chunks/email-previews.mjs +1 -1
  9. package/dist/chunks/health.mjs +2 -2
  10. package/dist/chunks/index.mjs +3 -3
  11. package/dist/chunks/install.mjs +4 -4
  12. package/dist/chunks/run.mjs +1 -1
  13. package/dist/chunks/server.mjs +8 -6
  14. package/dist/cli.mjs +394 -39
  15. package/dist/convex/access-tickets.d.ts +20 -1
  16. package/dist/convex/access-tickets.d.ts.map +1 -1
  17. package/dist/convex/access-tickets.js +28 -0
  18. package/dist/convex/access-tickets.js.map +1 -1
  19. package/dist/convex/account-data.d.ts +25 -3
  20. package/dist/convex/account-data.d.ts.map +1 -1
  21. package/dist/convex/account-data.js +26 -3
  22. package/dist/convex/account-data.js.map +1 -1
  23. package/dist/convex/app.d.ts +15 -2
  24. package/dist/convex/app.d.ts.map +1 -1
  25. package/dist/convex/app.js +16 -2
  26. package/dist/convex/app.js.map +1 -1
  27. package/dist/convex/billing-launch.d.ts +36 -0
  28. package/dist/convex/billing-launch.d.ts.map +1 -0
  29. package/dist/convex/billing-launch.js +18 -0
  30. package/dist/convex/billing-launch.js.map +1 -0
  31. package/dist/convex/catalog.d.ts +16 -2
  32. package/dist/convex/catalog.d.ts.map +1 -1
  33. package/dist/convex/catalog.js.map +1 -1
  34. package/dist/convex/client/code-binding.js +1 -1
  35. package/dist/convex/client/component.d.ts.map +1 -1
  36. package/dist/convex/client/guards.js +3 -3
  37. package/dist/convex/client/guards.js.map +1 -1
  38. package/dist/convex/client/index.d.ts +94 -40
  39. package/dist/convex/client/index.d.ts.map +1 -1
  40. package/dist/convex/client/index.js +4 -3
  41. package/dist/convex/client/index.js.map +1 -1
  42. package/dist/convex/client/plugins.d.ts +67 -30
  43. package/dist/convex/client/plugins.d.ts.map +1 -1
  44. package/dist/convex/client/plugins.js +43 -19
  45. package/dist/convex/client/plugins.js.map +1 -1
  46. package/dist/convex/components/backend/_generated/api.d.ts +2 -0
  47. package/dist/convex/components/backend/_generated/api.d.ts.map +1 -1
  48. package/dist/convex/components/backend/_generated/api.js.map +1 -1
  49. package/dist/convex/components/backend/_generated/component.d.ts +454 -4
  50. package/dist/convex/components/backend/_generated/component.d.ts.map +1 -1
  51. package/dist/convex/components/backend/access.d.ts +47 -6
  52. package/dist/convex/components/backend/access.d.ts.map +1 -1
  53. package/dist/convex/components/backend/access.js +108 -16
  54. package/dist/convex/components/backend/access.js.map +1 -1
  55. package/dist/convex/components/backend/account.d.ts +6 -0
  56. package/dist/convex/components/backend/account.d.ts.map +1 -1
  57. package/dist/convex/components/backend/account.js +49 -2
  58. package/dist/convex/components/backend/account.js.map +1 -1
  59. package/dist/convex/components/backend/adapter.d.ts +1 -1
  60. package/dist/convex/components/backend/adapter.d.ts.map +1 -1
  61. package/dist/convex/components/backend/adapter.js +1 -1
  62. package/dist/convex/components/backend/adapter.js.map +1 -1
  63. package/dist/convex/components/backend/billing.d.ts +22 -1
  64. package/dist/convex/components/backend/billing.d.ts.map +1 -1
  65. package/dist/convex/components/backend/billing.js +77 -12
  66. package/dist/convex/components/backend/billing.js.map +1 -1
  67. package/dist/convex/components/backend/costs.d.ts +1 -1
  68. package/dist/convex/components/backend/crons.d.ts.map +1 -1
  69. package/dist/convex/components/backend/crons.js +3 -0
  70. package/dist/convex/components/backend/crons.js.map +1 -1
  71. package/dist/convex/components/backend/funnel.d.ts +2 -2
  72. package/dist/convex/components/backend/gifts.d.ts +2 -2
  73. package/dist/convex/components/backend/gifts.js +2 -2
  74. package/dist/convex/components/backend/jobs.d.ts +53 -10
  75. package/dist/convex/components/backend/jobs.d.ts.map +1 -1
  76. package/dist/convex/components/backend/jobs.js +58 -13
  77. package/dist/convex/components/backend/jobs.js.map +1 -1
  78. package/dist/convex/components/backend/maintenance.d.ts +2 -2
  79. package/dist/convex/components/backend/maintenance.d.ts.map +1 -1
  80. package/dist/convex/components/backend/maintenance.js +11 -1
  81. package/dist/convex/components/backend/maintenance.js.map +1 -1
  82. package/dist/convex/components/backend/moderation.d.ts +94 -0
  83. package/dist/convex/components/backend/moderation.d.ts.map +1 -0
  84. package/dist/convex/components/backend/moderation.js +53 -0
  85. package/dist/convex/components/backend/moderation.js.map +1 -0
  86. package/dist/convex/components/backend/schema.d.ts +397 -24
  87. package/dist/convex/components/backend/schema.d.ts.map +1 -1
  88. package/dist/convex/components/backend/schema.js +108 -4
  89. package/dist/convex/components/backend/schema.js.map +1 -1
  90. package/dist/convex/components/backend/storage.d.ts +19 -0
  91. package/dist/convex/components/backend/storage.d.ts.map +1 -1
  92. package/dist/convex/components/backend/storage.js +57 -0
  93. package/dist/convex/components/backend/storage.js.map +1 -1
  94. package/dist/convex/components/backend/subscriptions.d.ts +1 -1
  95. package/dist/convex/components/backend/subscriptions.js +1 -1
  96. package/dist/convex/components/backend/subscriptions.js.map +1 -1
  97. package/dist/convex/constants.d.ts +19 -4
  98. package/dist/convex/constants.d.ts.map +1 -1
  99. package/dist/convex/constants.js +19 -4
  100. package/dist/convex/constants.js.map +1 -1
  101. package/dist/convex/email-templates.d.ts +56 -6
  102. package/dist/convex/email-templates.d.ts.map +1 -1
  103. package/dist/convex/email-templates.js +69 -14
  104. package/dist/convex/email-templates.js.map +1 -1
  105. package/dist/convex/emails/notification.d.ts +9 -0
  106. package/dist/convex/emails/notification.d.ts.map +1 -0
  107. package/dist/convex/emails/notification.js +21 -0
  108. package/dist/convex/emails/notification.js.map +1 -0
  109. package/dist/convex/errors.d.ts +8 -3
  110. package/dist/convex/errors.d.ts.map +1 -1
  111. package/dist/convex/errors.js +55 -7
  112. package/dist/convex/errors.js.map +1 -1
  113. package/dist/convex/events.d.ts +4 -4
  114. package/dist/convex/events.js +4 -4
  115. package/dist/convex/events.js.map +1 -1
  116. package/dist/convex/files.d.ts +30 -4
  117. package/dist/convex/files.d.ts.map +1 -1
  118. package/dist/convex/files.js +44 -6
  119. package/dist/convex/files.js.map +1 -1
  120. package/dist/convex/integrations/account.d.ts +7 -0
  121. package/dist/convex/integrations/account.d.ts.map +1 -1
  122. package/dist/convex/integrations/account.js +2 -0
  123. package/dist/convex/integrations/account.js.map +1 -1
  124. package/dist/convex/integrations/ai/chat.js +9 -9
  125. package/dist/convex/integrations/ai/chat.js.map +1 -1
  126. package/dist/convex/integrations/ai/config.d.ts +157 -37
  127. package/dist/convex/integrations/ai/config.d.ts.map +1 -1
  128. package/dist/convex/integrations/ai/context.d.ts +3 -0
  129. package/dist/convex/integrations/ai/context.d.ts.map +1 -1
  130. package/dist/convex/integrations/ai/context.js +4 -3
  131. package/dist/convex/integrations/ai/context.js.map +1 -1
  132. package/dist/convex/integrations/ai/costs.d.ts.map +1 -1
  133. package/dist/convex/integrations/ai/costs.js +49 -2
  134. package/dist/convex/integrations/ai/costs.js.map +1 -1
  135. package/dist/convex/integrations/ai/embeddings.d.ts +6 -6
  136. package/dist/convex/integrations/ai/embeddings.d.ts.map +1 -1
  137. package/dist/convex/integrations/ai/embeddings.js +17 -30
  138. package/dist/convex/integrations/ai/embeddings.js.map +1 -1
  139. package/dist/convex/integrations/ai/images.d.ts +25 -0
  140. package/dist/convex/integrations/ai/images.d.ts.map +1 -0
  141. package/dist/convex/integrations/ai/images.js +104 -0
  142. package/dist/convex/integrations/ai/images.js.map +1 -0
  143. package/dist/convex/integrations/ai/job-errors.d.ts +12 -0
  144. package/dist/convex/integrations/ai/job-errors.d.ts.map +1 -1
  145. package/dist/convex/integrations/ai/job-errors.js +18 -2
  146. package/dist/convex/integrations/ai/job-errors.js.map +1 -1
  147. package/dist/convex/integrations/ai/jobs.d.ts +176 -10
  148. package/dist/convex/integrations/ai/jobs.d.ts.map +1 -1
  149. package/dist/convex/integrations/ai/jobs.js +336 -70
  150. package/dist/convex/integrations/ai/jobs.js.map +1 -1
  151. package/dist/convex/integrations/ai/knowledge.d.ts.map +1 -1
  152. package/dist/convex/integrations/ai/knowledge.js +10 -11
  153. package/dist/convex/integrations/ai/knowledge.js.map +1 -1
  154. package/dist/convex/integrations/ai/metering.d.ts +15 -5
  155. package/dist/convex/integrations/ai/metering.d.ts.map +1 -1
  156. package/dist/convex/integrations/ai/metering.js +73 -26
  157. package/dist/convex/integrations/ai/metering.js.map +1 -1
  158. package/dist/convex/integrations/ai/model-id.d.ts +14 -1
  159. package/dist/convex/integrations/ai/model-id.d.ts.map +1 -1
  160. package/dist/convex/integrations/ai/model-id.js +24 -2
  161. package/dist/convex/integrations/ai/model-id.js.map +1 -1
  162. package/dist/convex/integrations/ai/models.d.ts +103 -20
  163. package/dist/convex/integrations/ai/models.d.ts.map +1 -1
  164. package/dist/convex/integrations/ai/models.js +220 -45
  165. package/dist/convex/integrations/ai/models.js.map +1 -1
  166. package/dist/convex/integrations/ai/moderation-providers.d.ts +136 -0
  167. package/dist/convex/integrations/ai/moderation-providers.d.ts.map +1 -0
  168. package/dist/convex/integrations/ai/moderation-providers.js +277 -0
  169. package/dist/convex/integrations/ai/moderation-providers.js.map +1 -0
  170. package/dist/convex/integrations/ai/moderation-taxonomy.d.ts +54 -0
  171. package/dist/convex/integrations/ai/moderation-taxonomy.d.ts.map +1 -0
  172. package/dist/convex/integrations/ai/moderation-taxonomy.js +141 -0
  173. package/dist/convex/integrations/ai/moderation-taxonomy.js.map +1 -0
  174. package/dist/convex/integrations/ai/moderation.d.ts +218 -19
  175. package/dist/convex/integrations/ai/moderation.d.ts.map +1 -1
  176. package/dist/convex/integrations/ai/moderation.js +359 -37
  177. package/dist/convex/integrations/ai/moderation.js.map +1 -1
  178. package/dist/convex/integrations/ai/provenance.d.ts +6 -0
  179. package/dist/convex/integrations/ai/provenance.d.ts.map +1 -1
  180. package/dist/convex/integrations/ai/provenance.js +4 -1
  181. package/dist/convex/integrations/ai/provenance.js.map +1 -1
  182. package/dist/convex/integrations/ai/setup.js +5 -5
  183. package/dist/convex/integrations/ai/setup.js.map +1 -1
  184. package/dist/convex/integrations/ai/stream.d.ts +1 -1
  185. package/dist/convex/integrations/ai/stream.d.ts.map +1 -1
  186. package/dist/convex/integrations/ai/stream.js +4 -2
  187. package/dist/convex/integrations/ai/stream.js.map +1 -1
  188. package/dist/convex/integrations/ai.d.ts +15 -8
  189. package/dist/convex/integrations/ai.d.ts.map +1 -1
  190. package/dist/convex/integrations/ai.js +4 -1
  191. package/dist/convex/integrations/ai.js.map +1 -1
  192. package/dist/convex/integrations/billing/checkout.d.ts +1 -1
  193. package/dist/convex/integrations/billing/checkout.d.ts.map +1 -1
  194. package/dist/convex/integrations/billing/checkout.js +4 -4
  195. package/dist/convex/integrations/billing/checkout.js.map +1 -1
  196. package/dist/convex/integrations/billing/context.d.ts +8 -0
  197. package/dist/convex/integrations/billing/context.d.ts.map +1 -1
  198. package/dist/convex/integrations/billing/context.js +20 -1
  199. package/dist/convex/integrations/billing/context.js.map +1 -1
  200. package/dist/convex/integrations/billing/credits.d.ts +6 -0
  201. package/dist/convex/integrations/billing/credits.d.ts.map +1 -1
  202. package/dist/convex/integrations/billing/credits.js +21 -6
  203. package/dist/convex/integrations/billing/credits.js.map +1 -1
  204. package/dist/convex/integrations/billing/features.d.ts.map +1 -1
  205. package/dist/convex/integrations/billing/free-plan.d.ts +41 -1
  206. package/dist/convex/integrations/billing/free-plan.d.ts.map +1 -1
  207. package/dist/convex/integrations/billing/free-plan.js +92 -29
  208. package/dist/convex/integrations/billing/free-plan.js.map +1 -1
  209. package/dist/convex/integrations/billing/functions.d.ts +7 -3
  210. package/dist/convex/integrations/billing/functions.d.ts.map +1 -1
  211. package/dist/convex/integrations/billing/functions.js +18 -8
  212. package/dist/convex/integrations/billing/functions.js.map +1 -1
  213. package/dist/convex/integrations/billing/gifts.d.ts +4 -0
  214. package/dist/convex/integrations/billing/gifts.d.ts.map +1 -1
  215. package/dist/convex/integrations/billing/gifts.js +37 -6
  216. package/dist/convex/integrations/billing/gifts.js.map +1 -1
  217. package/dist/convex/integrations/billing/history.d.ts.map +1 -1
  218. package/dist/convex/integrations/billing/lifecycle.d.ts +9 -3
  219. package/dist/convex/integrations/billing/lifecycle.d.ts.map +1 -1
  220. package/dist/convex/integrations/billing/lifecycle.js +15 -6
  221. package/dist/convex/integrations/billing/lifecycle.js.map +1 -1
  222. package/dist/convex/integrations/billing/passes.js +2 -2
  223. package/dist/convex/integrations/billing/pricing.d.ts +9 -2
  224. package/dist/convex/integrations/billing/pricing.d.ts.map +1 -1
  225. package/dist/convex/integrations/billing/pricing.js +38 -4
  226. package/dist/convex/integrations/billing/pricing.js.map +1 -1
  227. package/dist/convex/integrations/billing/quotas.d.ts.map +1 -1
  228. package/dist/convex/integrations/billing/rate-limit.d.ts +16 -0
  229. package/dist/convex/integrations/billing/rate-limit.d.ts.map +1 -0
  230. package/dist/convex/integrations/billing/rate-limit.js +45 -0
  231. package/dist/convex/integrations/billing/rate-limit.js.map +1 -0
  232. package/dist/convex/integrations/billing/referral-orders.d.ts +1 -1
  233. package/dist/convex/integrations/billing/referral-orders.js +1 -1
  234. package/dist/convex/integrations/billing/resync.d.ts +28 -0
  235. package/dist/convex/integrations/billing/resync.d.ts.map +1 -0
  236. package/dist/convex/integrations/billing/resync.js +139 -0
  237. package/dist/convex/integrations/billing/resync.js.map +1 -0
  238. package/dist/convex/integrations/billing/subscriptions.d.ts +1 -1
  239. package/dist/convex/integrations/billing/subscriptions.d.ts.map +1 -1
  240. package/dist/convex/integrations/billing/subscriptions.js +6 -2
  241. package/dist/convex/integrations/billing/subscriptions.js.map +1 -1
  242. package/dist/convex/integrations/billing/types/lifecycle.d.ts +1 -1
  243. package/dist/convex/integrations/billing/types/records.d.ts +68 -3
  244. package/dist/convex/integrations/billing/types/records.d.ts.map +1 -1
  245. package/dist/convex/integrations/billing/types/setup.d.ts +9 -4
  246. package/dist/convex/integrations/billing/types/setup.d.ts.map +1 -1
  247. package/dist/convex/integrations/billing/types/surface.d.ts +38 -5
  248. package/dist/convex/integrations/billing/types/surface.d.ts.map +1 -1
  249. package/dist/convex/integrations/billing/webhooks.js +2 -2
  250. package/dist/convex/integrations/billing/welcome.d.ts +16 -0
  251. package/dist/convex/integrations/billing/welcome.d.ts.map +1 -0
  252. package/dist/convex/integrations/billing/welcome.js +93 -0
  253. package/dist/convex/integrations/billing/welcome.js.map +1 -0
  254. package/dist/convex/integrations/billing.d.ts +3 -2
  255. package/dist/convex/integrations/billing.d.ts.map +1 -1
  256. package/dist/convex/integrations/billing.js +17 -5
  257. package/dist/convex/integrations/billing.js.map +1 -1
  258. package/dist/convex/integrations/email.d.ts +17 -3
  259. package/dist/convex/integrations/email.d.ts.map +1 -1
  260. package/dist/convex/integrations/email.js.map +1 -1
  261. package/dist/convex/integrations/functions.d.ts +2 -2
  262. package/dist/convex/integrations/functions.d.ts.map +1 -1
  263. package/dist/convex/integrations/functions.js +1 -1
  264. package/dist/convex/integrations/functions.js.map +1 -1
  265. package/dist/convex/integrations/launch.d.ts +108 -3
  266. package/dist/convex/integrations/launch.d.ts.map +1 -1
  267. package/dist/convex/integrations/launch.js +143 -22
  268. package/dist/convex/integrations/launch.js.map +1 -1
  269. package/dist/convex/integrations/notifications.d.ts +6 -2
  270. package/dist/convex/integrations/notifications.d.ts.map +1 -1
  271. package/dist/convex/integrations/notifications.js +13 -15
  272. package/dist/convex/integrations/notifications.js.map +1 -1
  273. package/dist/convex/integrations/rate-limit.d.ts +18 -0
  274. package/dist/convex/integrations/rate-limit.d.ts.map +1 -1
  275. package/dist/convex/integrations/rate-limit.js +18 -3
  276. package/dist/convex/integrations/rate-limit.js.map +1 -1
  277. package/dist/convex/integrations/reports.d.ts +4 -1
  278. package/dist/convex/integrations/reports.d.ts.map +1 -1
  279. package/dist/convex/integrations/reports.js +14 -3
  280. package/dist/convex/integrations/reports.js.map +1 -1
  281. package/dist/convex/integrations/retention.d.ts +42 -4
  282. package/dist/convex/integrations/retention.d.ts.map +1 -1
  283. package/dist/convex/integrations/retention.js +62 -4
  284. package/dist/convex/integrations/retention.js.map +1 -1
  285. package/dist/convex/integrations/storage.d.ts +71 -3
  286. package/dist/convex/integrations/storage.d.ts.map +1 -1
  287. package/dist/convex/integrations/storage.js +22 -4
  288. package/dist/convex/integrations/storage.js.map +1 -1
  289. package/dist/convex/label-format.d.ts +2 -2
  290. package/dist/convex/label-format.d.ts.map +1 -1
  291. package/dist/convex/label-format.js +2 -2
  292. package/dist/convex/label-format.js.map +1 -1
  293. package/dist/convex/label-groups/admin.d.ts +27 -0
  294. package/dist/convex/label-groups/admin.d.ts.map +1 -1
  295. package/dist/convex/label-groups/admin.js +28 -0
  296. package/dist/convex/label-groups/admin.js.map +1 -1
  297. package/dist/convex/label-groups/cancelFlow.d.ts +1 -1
  298. package/dist/convex/label-groups/cancelFlow.js +2 -2
  299. package/dist/convex/label-groups/cancelFlow.js.map +1 -1
  300. package/dist/convex/label-groups/email.d.ts.map +1 -1
  301. package/dist/convex/label-groups/email.js +2 -1
  302. package/dist/convex/label-groups/email.js.map +1 -1
  303. package/dist/convex/label-groups/errors.d.ts +4 -0
  304. package/dist/convex/label-groups/errors.d.ts.map +1 -1
  305. package/dist/convex/label-groups/errors.js +6 -1
  306. package/dist/convex/label-groups/errors.js.map +1 -1
  307. package/dist/convex/label-groups/gift.d.ts +2 -0
  308. package/dist/convex/label-groups/gift.d.ts.map +1 -1
  309. package/dist/convex/label-groups/gift.js +5 -2
  310. package/dist/convex/label-groups/gift.js.map +1 -1
  311. package/dist/convex/label-groups/legal.d.ts +27 -1
  312. package/dist/convex/label-groups/legal.d.ts.map +1 -1
  313. package/dist/convex/label-groups/legal.js +31 -0
  314. package/dist/convex/label-groups/legal.js.map +1 -1
  315. package/dist/convex/label-groups/notifications.d.ts +3 -1
  316. package/dist/convex/label-groups/notifications.d.ts.map +1 -1
  317. package/dist/convex/label-groups/notifications.js +5 -3
  318. package/dist/convex/label-groups/notifications.js.map +1 -1
  319. package/dist/convex/label-groups/pastDue.d.ts +1 -1
  320. package/dist/convex/label-groups/pastDue.d.ts.map +1 -1
  321. package/dist/convex/label-groups/pastDue.js +1 -1
  322. package/dist/convex/label-groups/pastDue.js.map +1 -1
  323. package/dist/convex/label-groups/pricing.d.ts +2 -0
  324. package/dist/convex/label-groups/pricing.d.ts.map +1 -1
  325. package/dist/convex/label-groups/pricing.js +4 -0
  326. package/dist/convex/label-groups/pricing.js.map +1 -1
  327. package/dist/convex/label-groups/referral.d.ts +2 -2
  328. package/dist/convex/label-groups/referral.js +2 -2
  329. package/dist/convex/label-groups/report.d.ts +8 -1
  330. package/dist/convex/label-groups/report.d.ts.map +1 -1
  331. package/dist/convex/label-groups/report.js +10 -1
  332. package/dist/convex/label-groups/report.js.map +1 -1
  333. package/dist/convex/label-groups/upload.d.ts +1 -0
  334. package/dist/convex/label-groups/upload.d.ts.map +1 -1
  335. package/dist/convex/label-groups/upload.js +2 -0
  336. package/dist/convex/label-groups/upload.js.map +1 -1
  337. package/dist/convex/label-groups/withdrawal.d.ts +1 -1
  338. package/dist/convex/label-groups/withdrawal.js +1 -1
  339. package/dist/convex/label-translations.d.ts.map +1 -1
  340. package/dist/convex/label-translations.js +94 -34
  341. package/dist/convex/label-translations.js.map +1 -1
  342. package/dist/convex/labels.d.ts +100 -1
  343. package/dist/convex/labels.d.ts.map +1 -1
  344. package/dist/convex/legal.d.ts +12 -2
  345. package/dist/convex/legal.d.ts.map +1 -1
  346. package/dist/convex/legal.js +2 -2
  347. package/dist/convex/legal.js.map +1 -1
  348. package/dist/convex/log.js +12 -1
  349. package/dist/convex/log.js.map +1 -1
  350. package/dist/convex/monitoring.d.ts +6 -4
  351. package/dist/convex/monitoring.d.ts.map +1 -1
  352. package/dist/convex/monitoring.js +6 -4
  353. package/dist/convex/monitoring.js.map +1 -1
  354. package/dist/convex/report-rules.d.ts +2 -0
  355. package/dist/convex/report-rules.d.ts.map +1 -1
  356. package/dist/convex/report-rules.js +2 -0
  357. package/dist/convex/report-rules.js.map +1 -1
  358. package/dist/convex/sensitive-actions.d.ts.map +1 -1
  359. package/dist/convex/sensitive-actions.js +1 -0
  360. package/dist/convex/sensitive-actions.js.map +1 -1
  361. package/dist/convex/test-models.d.ts +7 -0
  362. package/dist/convex/test-models.d.ts.map +1 -1
  363. package/dist/convex/test-models.js +25 -2
  364. package/dist/convex/test-models.js.map +1 -1
  365. package/dist/convex/test-moderation.d.ts +24 -0
  366. package/dist/convex/test-moderation.d.ts.map +1 -0
  367. package/dist/convex/test-moderation.js +114 -0
  368. package/dist/convex/test-moderation.js.map +1 -0
  369. package/dist/devtools-client/_nuxt/CiCAOwUc.js +5 -0
  370. package/dist/devtools-client/index.html +1 -1
  371. package/dist/env-registry.js +37 -5
  372. package/dist/module.d.ts +51 -1
  373. package/dist/module.js +2 -2
  374. package/dist/module.json +1 -1
  375. package/dist/runtime/config.d.ts +95 -14
  376. package/dist/runtime/config.js +13 -1
  377. package/dist/runtime/locales/de.json +95 -19
  378. package/dist/runtime/locales/en.json +93 -17
  379. package/dist/runtime/locales/es.json +93 -17
  380. package/dist/runtime/locales/fr.json +93 -17
  381. package/dist/runtime/locales/ru.json +93 -17
  382. package/dist/runtime/monitoring/sdk/sentry.client.config.js +2 -1
  383. package/dist/runtime/monitoring/sdk/sentry.server.config.js +6 -1
  384. package/dist/runtime/server/content-wasm.d.ts +13 -0
  385. package/dist/runtime/server/content-wasm.js +9 -0
  386. package/dist/runtime/server/csp.d.ts +17 -0
  387. package/dist/runtime/server/csp.js +18 -0
  388. package/dist/runtime/server/monitoring/csp.d.ts +12 -0
  389. package/dist/runtime/server/monitoring/csp.js +19 -0
  390. package/dist/runtime/server/protection/csp.d.ts +1 -7
  391. package/dist/runtime/server/protection/csp.js +4 -17
  392. package/dist/runtime/test-utils/aliases.d.ts +6 -4
  393. package/dist/runtime/test-utils/aliases.js +3 -9
  394. package/dist/runtime/test-utils/base-modules.d.ts +9 -13
  395. package/dist/runtime/test-utils/install.js +4 -2
  396. package/dist/runtime/vue/a11y.js +1 -1
  397. package/dist/runtime/vue/auth-client.d.ts +8 -5
  398. package/dist/runtime/vue/components/account/AccountData.vue +2 -0
  399. package/dist/runtime/vue/components/account/AccountDeletion.css +1 -1
  400. package/dist/runtime/vue/components/account/ActivationChecklist.css +1 -1
  401. package/dist/runtime/vue/components/account/ActivationChecklist.vue +1 -0
  402. package/dist/runtime/vue/components/account/ConsentPrompt.css +1 -1
  403. package/dist/runtime/vue/components/account/ConsentPromptDialog.vue +1 -0
  404. package/dist/runtime/vue/components/account/ConsentPromptStorage.vue +1 -0
  405. package/dist/runtime/vue/components/account/EmailUnsubscribe.css +1 -1
  406. package/dist/runtime/vue/components/account/EmailUnsubscribe.vue +2 -2
  407. package/dist/runtime/vue/components/account/HowDidYouHear.css +1 -1
  408. package/dist/runtime/vue/components/account/HowDidYouHear.vue +1 -0
  409. package/dist/runtime/vue/components/account/KeepAccount.css +1 -1
  410. package/dist/runtime/vue/components/account/OnboardingFlow.css +1 -1
  411. package/dist/runtime/vue/components/account/OnboardingFlow.vue +1 -0
  412. package/dist/runtime/vue/components/account/ProfileIdentity.css +1 -1
  413. package/dist/runtime/vue/components/account/ProfilePreferencesSection.css +1 -1
  414. package/dist/runtime/vue/components/account/ProfilePreferencesSection.vue +3 -1
  415. package/dist/runtime/vue/components/account/ProfileSettings.css +1 -1
  416. package/dist/runtime/vue/components/account/ProfileSettings.vue +1 -0
  417. package/dist/runtime/vue/components/account/SecurityAlerts.css +1 -1
  418. package/dist/runtime/vue/components/account/SecurityAlerts.vue +2 -1
  419. package/dist/runtime/vue/components/account/SecurityPasskeys.css +1 -1
  420. package/dist/runtime/vue/components/account/SecuritySettings.css +1 -1
  421. package/dist/runtime/vue/components/account/SecuritySettings.vue +1 -0
  422. package/dist/runtime/vue/components/account/security-alerts.d.ts +7 -0
  423. package/dist/runtime/vue/components/account/security-alerts.js +6 -2
  424. package/dist/runtime/vue/components/admin/AdminAccess.css +1 -1
  425. package/dist/runtime/vue/components/admin/AdminAccess.vue +2 -0
  426. package/dist/runtime/vue/components/admin/AdminAccessMemberTickets.d.vue.ts +7 -0
  427. package/dist/runtime/vue/components/admin/AdminAccessMemberTickets.vue +42 -0
  428. package/dist/runtime/vue/components/admin/AdminAccessMemberTickets.vue.d.ts +7 -0
  429. package/dist/runtime/vue/components/admin/AdminAnnouncements.css +1 -1
  430. package/dist/runtime/vue/components/admin/AdminBilling.css +1 -1
  431. package/dist/runtime/vue/components/admin/AdminChart.css +1 -1
  432. package/dist/runtime/vue/components/admin/AdminConsole.css +1 -1
  433. package/dist/runtime/vue/components/admin/AdminExperiments.css +1 -1
  434. package/dist/runtime/vue/components/admin/AdminFlags.css +1 -1
  435. package/dist/runtime/vue/components/admin/AdminModeration.d.vue.ts +3 -0
  436. package/dist/runtime/vue/components/admin/AdminModeration.vue +135 -0
  437. package/dist/runtime/vue/components/admin/AdminModeration.vue.d.ts +3 -0
  438. package/dist/runtime/vue/components/admin/AdminQueue.css +1 -1
  439. package/dist/runtime/vue/components/admin/AdminReferrals.css +1 -1
  440. package/dist/runtime/vue/components/admin/AdminReports.css +1 -1
  441. package/dist/runtime/vue/components/admin/AdminRevenue.css +1 -1
  442. package/dist/runtime/vue/components/admin/AdminUsers.d.vue.ts +27 -0
  443. package/dist/runtime/vue/components/admin/AdminUsers.vue +1 -0
  444. package/dist/runtime/vue/components/admin/AdminUsers.vue.d.ts +27 -0
  445. package/dist/runtime/vue/components/admin/AdminWorkspaces.d.vue.ts +27 -0
  446. package/dist/runtime/vue/components/admin/AdminWorkspaces.vue +1 -0
  447. package/dist/runtime/vue/components/admin/AdminWorkspaces.vue.d.ts +27 -0
  448. package/dist/runtime/vue/components/admin/admin-moderation-tab.d.ts +1 -0
  449. package/dist/runtime/vue/components/admin/admin-moderation-tab.js +34 -0
  450. package/dist/runtime/vue/components/admin/admin-tabs.js +2 -0
  451. package/dist/runtime/vue/components/admin/admin.css +1 -1
  452. package/dist/runtime/vue/components/auth/AuthForm.css +1 -1
  453. package/dist/runtime/vue/components/auth/AuthForm.vue +3 -2
  454. package/dist/runtime/vue/components/auth/AuthFormChoose.css +1 -1
  455. package/dist/runtime/vue/components/auth/AuthFormPasskeyOffer.css +1 -1
  456. package/dist/runtime/vue/components/auth/InviteRedeem.css +1 -1
  457. package/dist/runtime/vue/components/auth/ReauthenticateCode.css +1 -1
  458. package/dist/runtime/vue/components/auth/ReauthenticateDialog.css +1 -1
  459. package/dist/runtime/vue/components/auth/ReauthenticateDialog.vue +3 -2
  460. package/dist/runtime/vue/components/auth/WaitlistForm.css +1 -1
  461. package/dist/runtime/vue/components/auth/WaitlistForm.vue +1 -0
  462. package/dist/runtime/vue/components/auth/WaitlistPlace.css +1 -1
  463. package/dist/runtime/vue/components/auth/WaitlistShare.css +1 -1
  464. package/dist/runtime/vue/components/billing/BillingCheckoutLink.vue +2 -0
  465. package/dist/runtime/vue/components/billing/BillingHistory.css +1 -1
  466. package/dist/runtime/vue/components/billing/BillingHistory.vue +1 -0
  467. package/dist/runtime/vue/components/billing/BillingPortalLink.vue +1 -0
  468. package/dist/runtime/vue/components/billing/CancelFlow.css +1 -1
  469. package/dist/runtime/vue/components/billing/CancelFlow.vue +1 -0
  470. package/dist/runtime/vue/components/billing/CancelFlowEnd.vue +3 -1
  471. package/dist/runtime/vue/components/billing/GiftList.css +1 -1
  472. package/dist/runtime/vue/components/billing/PricingPackCard.css +1 -1
  473. package/dist/runtime/vue/components/billing/PricingPlanCard.css +1 -1
  474. package/dist/runtime/vue/components/billing/PricingPlanCard.vue +8 -1
  475. package/dist/runtime/vue/components/billing/PricingTable.css +1 -1
  476. package/dist/runtime/vue/components/billing/PricingTable.d.vue.ts +2 -0
  477. package/dist/runtime/vue/components/billing/PricingTable.vue +22 -3
  478. package/dist/runtime/vue/components/billing/PricingTable.vue.d.ts +2 -0
  479. package/dist/runtime/vue/components/billing/ReferralCard.css +1 -1
  480. package/dist/runtime/vue/components/billing/ReferralCard.vue +1 -0
  481. package/dist/runtime/vue/components/billing/ReferralLanding.css +1 -1
  482. package/dist/runtime/vue/components/billing/UpgradePrompt.css +1 -1
  483. package/dist/runtime/vue/components/billing/UpgradePrompt.vue +1 -0
  484. package/dist/runtime/vue/components/billing/UsageHistory.css +1 -1
  485. package/dist/runtime/vue/components/billing/UsageHistory.vue +1 -0
  486. package/dist/runtime/vue/components/billing/WithdrawalButton.css +1 -1
  487. package/dist/runtime/vue/components/billing/WithdrawalButton.vue +1 -0
  488. package/dist/runtime/vue/components/billing/pricing-table.d.ts +6 -0
  489. package/dist/runtime/vue/components/billing/withdrawal-button.d.ts +1 -1
  490. package/dist/runtime/vue/components/shared.css +1 -1
  491. package/dist/runtime/vue/components/shell/AccessDenied.css +1 -1
  492. package/dist/runtime/vue/components/shell/AccessDenied.vue +1 -0
  493. package/dist/runtime/vue/components/shell/AccountMenu.vue +1 -0
  494. package/dist/runtime/vue/components/shell/AiLabel.css +1 -1
  495. package/dist/runtime/vue/components/shell/AiLabel.vue +4 -1
  496. package/dist/runtime/vue/components/shell/AppShell.css +1 -1
  497. package/dist/runtime/vue/components/shell/AppShell.vue +3 -0
  498. package/dist/runtime/vue/components/shell/BackendNotices.vue +1 -0
  499. package/dist/runtime/vue/components/shell/ConfirmDialog.css +1 -1
  500. package/dist/runtime/vue/components/shell/ConnectionStatus.css +1 -1
  501. package/dist/runtime/vue/components/shell/ConnectionStatus.vue +1 -0
  502. package/dist/runtime/vue/components/shell/ContactForm.css +1 -1
  503. package/dist/runtime/vue/components/shell/ContactForm.vue +1 -0
  504. package/dist/runtime/vue/components/shell/FrameMain.vue +2 -0
  505. package/dist/runtime/vue/components/shell/Gate.css +1 -1
  506. package/dist/runtime/vue/components/shell/Gate.vue +2 -0
  507. package/dist/runtime/vue/components/shell/GateQuota.vue +1 -0
  508. package/dist/runtime/vue/components/shell/LegalCompany.d.vue.ts +3 -0
  509. package/dist/runtime/vue/components/shell/LegalCompany.vue +23 -0
  510. package/dist/runtime/vue/components/shell/LegalCompany.vue.d.ts +3 -0
  511. package/dist/runtime/vue/components/shell/LegalContactPoints.d.vue.ts +10 -0
  512. package/dist/runtime/vue/components/shell/LegalContactPoints.vue +51 -0
  513. package/dist/runtime/vue/components/shell/LegalContactPoints.vue.d.ts +10 -0
  514. package/dist/runtime/vue/components/shell/LegalDetail.d.vue.ts +11 -0
  515. package/dist/runtime/vue/components/shell/LegalDetail.vue +30 -0
  516. package/dist/runtime/vue/components/shell/LegalDetail.vue.d.ts +11 -0
  517. package/dist/runtime/vue/components/shell/LegalDocument.css +1 -1
  518. package/dist/runtime/vue/components/shell/LegalDocument.vue +49 -13
  519. package/dist/runtime/vue/components/shell/LegalModeration.d.vue.ts +8 -0
  520. package/dist/runtime/vue/components/shell/LegalModeration.vue +72 -0
  521. package/dist/runtime/vue/components/shell/LegalModeration.vue.d.ts +8 -0
  522. package/dist/runtime/vue/components/shell/LegalProcessors.d.vue.ts +3 -2
  523. package/dist/runtime/vue/components/shell/LegalProcessors.vue +46 -15
  524. package/dist/runtime/vue/components/shell/LegalProcessors.vue.d.ts +3 -2
  525. package/dist/runtime/vue/components/shell/LegalStorage.d.vue.ts +3 -2
  526. package/dist/runtime/vue/components/shell/LegalStorage.vue +49 -16
  527. package/dist/runtime/vue/components/shell/LegalStorage.vue.d.ts +3 -2
  528. package/dist/runtime/vue/components/shell/LegalVersion.d.vue.ts +10 -0
  529. package/dist/runtime/vue/components/shell/LegalVersion.vue +24 -0
  530. package/dist/runtime/vue/components/shell/LegalVersion.vue.d.ts +10 -0
  531. package/dist/runtime/vue/components/shell/NoticeAnnouncement.css +1 -1
  532. package/dist/runtime/vue/components/shell/NoticeDeletion.css +1 -1
  533. package/dist/runtime/vue/components/shell/NoticeGift.css +1 -1
  534. package/dist/runtime/vue/components/shell/NoticeGift.vue +7 -4
  535. package/dist/runtime/vue/components/shell/NoticeImpersonation.css +1 -1
  536. package/dist/runtime/vue/components/shell/NoticeLowCredits.css +1 -1
  537. package/dist/runtime/vue/components/shell/NoticeMaintenance.css +1 -1
  538. package/dist/runtime/vue/components/shell/NoticePastDue.css +1 -1
  539. package/dist/runtime/vue/components/shell/NotificationInbox.css +1 -1
  540. package/dist/runtime/vue/components/shell/NotificationInbox.vue +1 -0
  541. package/dist/runtime/vue/components/shell/ReportNotice.css +1 -1
  542. package/dist/runtime/vue/components/shell/UploadField.css +1 -1
  543. package/dist/runtime/vue/components/shell/UploadField.d.vue.ts +2 -0
  544. package/dist/runtime/vue/components/shell/UploadField.vue +16 -3
  545. package/dist/runtime/vue/components/shell/UploadField.vue.d.ts +2 -0
  546. package/dist/runtime/vue/components/shell/WorkspaceSwitcher.css +1 -1
  547. package/dist/runtime/vue/components/shell/WorkspaceSwitcher.vue +1 -0
  548. package/dist/runtime/vue/components/shell/legal.d.ts +35 -4
  549. package/dist/runtime/vue/components/shell/legal.js +126 -13
  550. package/dist/runtime/vue/components/shell/upload-field.d.ts +3 -1
  551. package/dist/runtime/vue/components/tokens.css +1 -1
  552. package/dist/runtime/vue/components/workspaces/AcceptInvitation.vue +1 -0
  553. package/dist/runtime/vue/components/workspaces/AuditLog.css +1 -1
  554. package/dist/runtime/vue/components/workspaces/AuditLog.vue +1 -0
  555. package/dist/runtime/vue/components/workspaces/WorkspaceBilling.css +1 -1
  556. package/dist/runtime/vue/components/workspaces/WorkspaceCredits.css +1 -1
  557. package/dist/runtime/vue/components/workspaces/WorkspaceList.css +1 -1
  558. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
  559. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue +1 -0
  560. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
  561. package/dist/runtime/vue/composables/use-access.d.ts +51 -6
  562. package/dist/runtime/vue/composables/use-access.js +36 -0
  563. package/dist/runtime/vue/composables/use-billing.d.ts +6 -5
  564. package/dist/runtime/vue/composables/use-email-link.d.ts +55 -4
  565. package/dist/runtime/vue/composables/use-email-link.js +9 -9
  566. package/dist/runtime/vue/composables/use-gift-list.js +3 -1
  567. package/dist/runtime/vue/composables/use-labels.js +13 -8
  568. package/dist/runtime/vue/composables/use-login-flow.js +1 -1
  569. package/dist/runtime/vue/composables/use-notifications.js +3 -0
  570. package/dist/runtime/vue/composables/use-passkeys.js +2 -2
  571. package/dist/runtime/vue/composables/use-pricing.d.ts +15 -0
  572. package/dist/runtime/vue/composables/use-pricing.js +4 -0
  573. package/dist/runtime/vue/composables/use-referral-invite.d.ts +33 -4
  574. package/dist/runtime/vue/composables/use-referral-invite.js +20 -9
  575. package/dist/runtime/vue/composables/use-report-form.d.ts +178 -0
  576. package/dist/runtime/vue/composables/use-report-form.js +278 -0
  577. package/dist/runtime/vue/composables/use-sign-in-alerts.d.ts +85 -0
  578. package/dist/runtime/vue/composables/use-sign-in-alerts.js +70 -0
  579. package/dist/runtime/vue/composables/use-upload-field.d.ts +32 -6
  580. package/dist/runtime/vue/composables/use-upload-field.js +75 -36
  581. package/dist/runtime/vue/composables/use-waitlist.d.ts +8 -1
  582. package/dist/runtime/vue/composables/use-waitlist.js +14 -1
  583. package/dist/runtime/vue/pages/gifts.vue +9 -0
  584. package/dist/runtime/vue/passkey-ceremony.d.ts +42 -0
  585. package/dist/runtime/vue/passkey-ceremony.js +37 -0
  586. package/dist/runtime/vue/passkey-client.d.ts +11 -49
  587. package/dist/runtime/vue/passkey-client.js +2 -34
  588. package/dist/runtime/vue/plugins/checkout-return.d.ts +5 -4
  589. package/dist/runtime/vue/plugins/checkout-return.js +1 -1
  590. package/dist/runtime/vue/plugins/passkey-ceremony.d.ts +3 -1
  591. package/dist/runtime/vue/plugins/passkey-ceremony.js +1 -1
  592. package/dist/runtime/vue/protection/state.d.ts +6 -0
  593. package/dist/runtime/vue/utils/auth-session.js +1 -1
  594. package/dist/runtime/vue/utils/billing-access.d.ts +1 -1
  595. package/dist/runtime/vue/utils/checkout-return.d.ts +5 -4
  596. package/dist/runtime/vue/utils/checkout-return.js +3 -3
  597. package/dist/runtime/vue/utils/login-bindings.js +1 -1
  598. package/dist/runtime/vue/utils/page-guard.js +6 -5
  599. package/dist/runtime/vue/utils/passkey-prompt.d.ts +12 -0
  600. package/dist/runtime/vue/utils/passkey-prompt.js +8 -0
  601. package/dist/runtime/vue/utils/renamed-component.js +1 -1
  602. package/dist/shared/{nuxt-backend.KEzfHO2K.mjs → nuxt-backend.Bq_mhlky.mjs} +578 -60
  603. package/dist/shared/{nuxt-backend.DXEf0rrv.mjs → nuxt-backend.D9qXcOOI.mjs} +1 -1
  604. package/dist/shared/{nuxt-backend.ikObmtHs.mjs → nuxt-backend.DmZI-QSO.mjs} +2 -2
  605. package/dist/shared/{nuxt-backend.Dm1NkY7v.mjs → nuxt-backend.G4JryO1q.mjs} +144 -32
  606. package/dist/shared/{nuxt-backend.2m535CLS.mjs → nuxt-backend.Lk2MQI2u.mjs} +1 -1
  607. package/dist/types.d.ts +1 -1
  608. package/package.json +13 -13
  609. package/skills/nuxt-backend/SKILL.md +3 -3
  610. package/skills/nuxt-backend/references/api.md +95 -25
  611. package/skills/nuxt-backend/references/renames.json +114 -2054
  612. package/skills/nuxt-backend/references/surface.json +112 -3
  613. package/skills/nuxt-backend-ai/SKILL.md +13 -6
  614. package/skills/nuxt-backend-ai/references/api.md +21 -3
  615. package/skills/nuxt-backend-auth/references/api.md +20 -3
  616. package/skills/nuxt-backend-billing/references/api.md +20 -5
  617. package/skills/nuxt-backend-data/SKILL.md +3 -3
  618. package/skills/nuxt-backend-data/references/api.md +4 -3
  619. package/skills/nuxt-backend-email/references/api.md +2 -1
  620. package/skills/nuxt-backend-growth/references/api.md +1 -0
  621. package/skills/nuxt-backend-ship/SKILL.md +14 -22
  622. package/skills/nuxt-backend-ship/references/api.md +25 -2
  623. package/skills/nuxt-backend-ship/references/operate.md +28 -0
  624. package/skills/nuxt-backend-ui/SKILL.md +6 -2
  625. package/skills/nuxt-backend-upgrade/SKILL.md +16 -11
  626. package/skills/nuxt-backend-upgrade/references/api.md +2 -2
  627. package/skills/nuxt-backend-upgrade/references/upgrade.md +37 -438
  628. package/src/convex/access-tickets.ts +30 -1
  629. package/src/convex/account-data.ts +26 -3
  630. package/src/convex/app.ts +16 -2
  631. package/src/convex/billing-launch.ts +42 -0
  632. package/src/convex/catalog.ts +16 -2
  633. package/src/convex/client/code-binding.ts +1 -1
  634. package/src/convex/client/guards.ts +3 -3
  635. package/src/convex/client/index.ts +4 -3
  636. package/src/convex/client/plugins.ts +43 -19
  637. package/src/convex/components/backend/_generated/api.ts +2 -0
  638. package/src/convex/components/backend/_generated/component.ts +1255 -242
  639. package/src/convex/components/backend/access.ts +109 -16
  640. package/src/convex/components/backend/account.ts +48 -2
  641. package/src/convex/components/backend/adapter.ts +4 -0
  642. package/src/convex/components/backend/billing.ts +75 -12
  643. package/src/convex/components/backend/crons.ts +4 -0
  644. package/src/convex/components/backend/gifts.ts +2 -2
  645. package/src/convex/components/backend/jobs.ts +58 -13
  646. package/src/convex/components/backend/maintenance.ts +14 -1
  647. package/src/convex/components/backend/moderation.ts +57 -0
  648. package/src/convex/components/backend/schema.ts +110 -4
  649. package/src/convex/components/backend/storage.ts +56 -0
  650. package/src/convex/components/backend/subscriptions.ts +1 -1
  651. package/src/convex/constants.ts +20 -4
  652. package/src/convex/email-templates.ts +124 -21
  653. package/src/convex/emails/notification.ts +22 -0
  654. package/src/convex/errors.ts +64 -8
  655. package/src/convex/events.ts +4 -4
  656. package/src/convex/files.ts +48 -6
  657. package/src/convex/integrations/account.ts +4 -0
  658. package/src/convex/integrations/ai/chat.ts +9 -9
  659. package/src/convex/integrations/ai/config.ts +147 -37
  660. package/src/convex/integrations/ai/context.ts +7 -4
  661. package/src/convex/integrations/ai/costs.ts +45 -2
  662. package/src/convex/integrations/ai/embeddings.ts +24 -39
  663. package/src/convex/integrations/ai/images.ts +141 -0
  664. package/src/convex/integrations/ai/job-errors.ts +19 -2
  665. package/src/convex/integrations/ai/jobs.ts +466 -72
  666. package/src/convex/integrations/ai/knowledge.ts +9 -10
  667. package/src/convex/integrations/ai/metering.ts +83 -28
  668. package/src/convex/integrations/ai/model-id.ts +24 -2
  669. package/src/convex/integrations/ai/models.ts +273 -58
  670. package/src/convex/integrations/ai/moderation-providers.ts +373 -0
  671. package/src/convex/integrations/ai/moderation-taxonomy.ts +174 -0
  672. package/src/convex/integrations/ai/moderation.ts +530 -47
  673. package/src/convex/integrations/ai/provenance.ts +10 -1
  674. package/src/convex/integrations/ai/setup.ts +5 -5
  675. package/src/convex/integrations/ai/stream.ts +4 -3
  676. package/src/convex/integrations/ai.ts +19 -6
  677. package/src/convex/integrations/billing/checkout.ts +4 -4
  678. package/src/convex/integrations/billing/context.ts +34 -2
  679. package/src/convex/integrations/billing/credits.ts +23 -6
  680. package/src/convex/integrations/billing/free-plan.ts +120 -24
  681. package/src/convex/integrations/billing/functions.ts +20 -8
  682. package/src/convex/integrations/billing/gifts.ts +34 -6
  683. package/src/convex/integrations/billing/lifecycle.ts +14 -6
  684. package/src/convex/integrations/billing/passes.ts +2 -2
  685. package/src/convex/integrations/billing/pricing.ts +43 -5
  686. package/src/convex/integrations/billing/rate-limit.ts +46 -0
  687. package/src/convex/integrations/billing/referral-orders.ts +1 -1
  688. package/src/convex/integrations/billing/resync.ts +187 -0
  689. package/src/convex/integrations/billing/rewards.ts +1 -1
  690. package/src/convex/integrations/billing/subscriptions.ts +4 -2
  691. package/src/convex/integrations/billing/types/lifecycle.ts +1 -1
  692. package/src/convex/integrations/billing/types/records.ts +67 -3
  693. package/src/convex/integrations/billing/types/setup.ts +6 -5
  694. package/src/convex/integrations/billing/types/surface.ts +38 -5
  695. package/src/convex/integrations/billing/webhooks.ts +2 -2
  696. package/src/convex/integrations/billing/welcome.ts +103 -0
  697. package/src/convex/integrations/billing.ts +20 -5
  698. package/src/convex/integrations/email.ts +17 -2
  699. package/src/convex/integrations/functions.ts +2 -2
  700. package/src/convex/integrations/launch.ts +247 -28
  701. package/src/convex/integrations/notifications.ts +16 -17
  702. package/src/convex/integrations/rate-limit.ts +18 -3
  703. package/src/convex/integrations/reports.ts +18 -5
  704. package/src/convex/integrations/retention.ts +73 -5
  705. package/src/convex/integrations/storage.ts +91 -6
  706. package/src/convex/label-format.ts +2 -2
  707. package/src/convex/label-groups/admin.ts +28 -0
  708. package/src/convex/label-groups/cancelFlow.ts +2 -2
  709. package/src/convex/label-groups/email.ts +2 -1
  710. package/src/convex/label-groups/errors.ts +6 -1
  711. package/src/convex/label-groups/gift.ts +5 -2
  712. package/src/convex/label-groups/legal.ts +31 -0
  713. package/src/convex/label-groups/notifications.ts +5 -3
  714. package/src/convex/label-groups/pastDue.ts +1 -1
  715. package/src/convex/label-groups/pricing.ts +4 -0
  716. package/src/convex/label-groups/referral.ts +2 -2
  717. package/src/convex/label-groups/report.ts +10 -1
  718. package/src/convex/label-groups/upload.ts +2 -0
  719. package/src/convex/label-groups/withdrawal.ts +1 -1
  720. package/src/convex/label-translations.ts +94 -34
  721. package/src/convex/labels.ts +25 -0
  722. package/src/convex/legal.ts +12 -2
  723. package/src/convex/log.ts +12 -1
  724. package/src/convex/monitoring.ts +6 -4
  725. package/src/convex/report-rules.ts +3 -0
  726. package/src/convex/sensitive-actions.ts +1 -0
  727. package/src/convex/test-models.ts +26 -2
  728. package/src/convex/test-moderation.ts +122 -0
  729. package/src/convex/test.ts +405 -8
  730. package/src/runtime/vue/components/account/AccountData.vue +2 -0
  731. package/src/runtime/vue/components/account/AccountDeletion.css +2 -1
  732. package/src/runtime/vue/components/account/ActivationChecklist.css +5 -2
  733. package/src/runtime/vue/components/account/ActivationChecklist.vue +1 -0
  734. package/src/runtime/vue/components/account/ConsentPrompt.css +8 -5
  735. package/src/runtime/vue/components/account/ConsentPromptDialog.vue +1 -0
  736. package/src/runtime/vue/components/account/ConsentPromptStorage.vue +1 -0
  737. package/src/runtime/vue/components/account/EmailUnsubscribe.css +6 -2
  738. package/src/runtime/vue/components/account/EmailUnsubscribe.vue +2 -2
  739. package/src/runtime/vue/components/account/HowDidYouHear.css +8 -3
  740. package/src/runtime/vue/components/account/HowDidYouHear.vue +1 -0
  741. package/src/runtime/vue/components/account/KeepAccount.css +3 -1
  742. package/src/runtime/vue/components/account/OnboardingFlow.css +6 -3
  743. package/src/runtime/vue/components/account/OnboardingFlow.vue +1 -0
  744. package/src/runtime/vue/components/account/ProfileIdentity.css +1 -1
  745. package/src/runtime/vue/components/account/ProfilePreferencesSection.css +3 -1
  746. package/src/runtime/vue/components/account/ProfilePreferencesSection.vue +4 -2
  747. package/src/runtime/vue/components/account/ProfileSettings.css +3 -1
  748. package/src/runtime/vue/components/account/ProfileSettings.vue +1 -0
  749. package/src/runtime/vue/components/account/SecurityAlerts.css +2 -1
  750. package/src/runtime/vue/components/account/SecurityAlerts.vue +2 -2
  751. package/src/runtime/vue/components/account/SecurityPasskeys.css +5 -3
  752. package/src/runtime/vue/components/account/SecuritySettings.css +2 -1
  753. package/src/runtime/vue/components/account/SecuritySettings.vue +1 -0
  754. package/src/runtime/vue/components/admin/AdminAccess.css +1 -1
  755. package/src/runtime/vue/components/admin/AdminAccess.vue +3 -1
  756. package/src/runtime/vue/components/admin/AdminAccessMemberTickets.vue +51 -0
  757. package/src/runtime/vue/components/admin/AdminAnnouncements.css +4 -2
  758. package/src/runtime/vue/components/admin/AdminBilling.css +1 -1
  759. package/src/runtime/vue/components/admin/AdminChart.css +2 -1
  760. package/src/runtime/vue/components/admin/AdminConsole.css +1 -0
  761. package/src/runtime/vue/components/admin/AdminExperiments.css +2 -1
  762. package/src/runtime/vue/components/admin/AdminFlags.css +4 -2
  763. package/src/runtime/vue/components/admin/AdminModeration.vue +148 -0
  764. package/src/runtime/vue/components/admin/AdminQueue.css +4 -2
  765. package/src/runtime/vue/components/admin/AdminReferrals.css +3 -1
  766. package/src/runtime/vue/components/admin/AdminReports.css +2 -1
  767. package/src/runtime/vue/components/admin/AdminRevenue.css +2 -1
  768. package/src/runtime/vue/components/admin/AdminUsers.vue +1 -0
  769. package/src/runtime/vue/components/admin/AdminWorkspaces.vue +1 -0
  770. package/src/runtime/vue/components/admin/admin.css +2 -1
  771. package/src/runtime/vue/components/auth/AuthForm.css +6 -3
  772. package/src/runtime/vue/components/auth/AuthForm.vue +4 -3
  773. package/src/runtime/vue/components/auth/AuthFormChoose.css +1 -0
  774. package/src/runtime/vue/components/auth/AuthFormPasskeyOffer.css +2 -1
  775. package/src/runtime/vue/components/auth/InviteRedeem.css +2 -0
  776. package/src/runtime/vue/components/auth/ReauthenticateCode.css +1 -1
  777. package/src/runtime/vue/components/auth/ReauthenticateDialog.css +6 -2
  778. package/src/runtime/vue/components/auth/ReauthenticateDialog.vue +3 -2
  779. package/src/runtime/vue/components/auth/WaitlistForm.css +3 -1
  780. package/src/runtime/vue/components/auth/WaitlistForm.vue +1 -0
  781. package/src/runtime/vue/components/auth/WaitlistPlace.css +3 -1
  782. package/src/runtime/vue/components/auth/WaitlistShare.css +6 -3
  783. package/src/runtime/vue/components/billing/BillingCheckoutLink.vue +2 -0
  784. package/src/runtime/vue/components/billing/BillingHistory.css +2 -1
  785. package/src/runtime/vue/components/billing/BillingHistory.vue +1 -0
  786. package/src/runtime/vue/components/billing/BillingPortalLink.vue +1 -0
  787. package/src/runtime/vue/components/billing/CancelFlow.css +8 -4
  788. package/src/runtime/vue/components/billing/CancelFlow.vue +2 -1
  789. package/src/runtime/vue/components/billing/CancelFlowEnd.vue +3 -1
  790. package/src/runtime/vue/components/billing/GiftList.css +5 -2
  791. package/src/runtime/vue/components/billing/PricingPackCard.css +2 -1
  792. package/src/runtime/vue/components/billing/PricingPlanCard.css +5 -3
  793. package/src/runtime/vue/components/billing/PricingPlanCard.vue +8 -1
  794. package/src/runtime/vue/components/billing/PricingTable.css +1 -1
  795. package/src/runtime/vue/components/billing/PricingTable.vue +23 -3
  796. package/src/runtime/vue/components/billing/ReferralCard.css +6 -3
  797. package/src/runtime/vue/components/billing/ReferralCard.vue +1 -0
  798. package/src/runtime/vue/components/billing/ReferralLanding.css +5 -2
  799. package/src/runtime/vue/components/billing/UpgradePrompt.css +6 -3
  800. package/src/runtime/vue/components/billing/UpgradePrompt.vue +1 -0
  801. package/src/runtime/vue/components/billing/UsageHistory.css +2 -1
  802. package/src/runtime/vue/components/billing/UsageHistory.vue +1 -0
  803. package/src/runtime/vue/components/billing/WithdrawalButton.css +6 -2
  804. package/src/runtime/vue/components/billing/WithdrawalButton.vue +2 -1
  805. package/src/runtime/vue/components/shared.css +24 -3
  806. package/src/runtime/vue/components/shell/AccessDenied.css +4 -1
  807. package/src/runtime/vue/components/shell/AccessDenied.vue +1 -0
  808. package/src/runtime/vue/components/shell/AccountMenu.vue +1 -0
  809. package/src/runtime/vue/components/shell/AiLabel.css +3 -2
  810. package/src/runtime/vue/components/shell/AiLabel.vue +4 -1
  811. package/src/runtime/vue/components/shell/AppShell.css +5 -3
  812. package/src/runtime/vue/components/shell/AppShell.vue +3 -0
  813. package/src/runtime/vue/components/shell/BackendNotices.vue +3 -2
  814. package/src/runtime/vue/components/shell/ConfirmDialog.css +5 -2
  815. package/src/runtime/vue/components/shell/ConnectionStatus.css +1 -1
  816. package/src/runtime/vue/components/shell/ConnectionStatus.vue +1 -0
  817. package/src/runtime/vue/components/shell/ContactForm.css +8 -1
  818. package/src/runtime/vue/components/shell/ContactForm.vue +1 -0
  819. package/src/runtime/vue/components/shell/FrameMain.vue +2 -0
  820. package/src/runtime/vue/components/shell/Gate.css +5 -2
  821. package/src/runtime/vue/components/shell/Gate.vue +2 -0
  822. package/src/runtime/vue/components/shell/GateQuota.vue +1 -0
  823. package/src/runtime/vue/components/shell/LegalCompany.vue +38 -0
  824. package/src/runtime/vue/components/shell/LegalContactPoints.vue +74 -0
  825. package/src/runtime/vue/components/shell/LegalDetail.vue +54 -0
  826. package/src/runtime/vue/components/shell/LegalDocument.css +21 -4
  827. package/src/runtime/vue/components/shell/LegalDocument.vue +54 -15
  828. package/src/runtime/vue/components/shell/LegalModeration.vue +94 -0
  829. package/src/runtime/vue/components/shell/LegalProcessors.vue +64 -22
  830. package/src/runtime/vue/components/shell/LegalStorage.vue +64 -23
  831. package/src/runtime/vue/components/shell/LegalVersion.vue +44 -0
  832. package/src/runtime/vue/components/shell/NoticeAnnouncement.css +2 -1
  833. package/src/runtime/vue/components/shell/NoticeDeletion.css +5 -2
  834. package/src/runtime/vue/components/shell/NoticeGift.css +2 -1
  835. package/src/runtime/vue/components/shell/NoticeGift.vue +8 -5
  836. package/src/runtime/vue/components/shell/NoticeImpersonation.css +2 -1
  837. package/src/runtime/vue/components/shell/NoticeLowCredits.css +6 -2
  838. package/src/runtime/vue/components/shell/NoticeMaintenance.css +2 -1
  839. package/src/runtime/vue/components/shell/NoticePastDue.css +6 -2
  840. package/src/runtime/vue/components/shell/NoticePastDue.vue +1 -1
  841. package/src/runtime/vue/components/shell/NotificationInbox.css +6 -4
  842. package/src/runtime/vue/components/shell/NotificationInbox.vue +1 -0
  843. package/src/runtime/vue/components/shell/ReportNotice.css +2 -1
  844. package/src/runtime/vue/components/shell/UploadField.css +4 -2
  845. package/src/runtime/vue/components/shell/UploadField.vue +21 -5
  846. package/src/runtime/vue/components/shell/WorkspaceSwitcher.css +4 -1
  847. package/src/runtime/vue/components/shell/WorkspaceSwitcher.vue +1 -0
  848. package/src/runtime/vue/components/tokens.css +21 -1
  849. package/src/runtime/vue/components/workspaces/AcceptInvitation.vue +1 -0
  850. package/src/runtime/vue/components/workspaces/AuditLog.css +2 -1
  851. package/src/runtime/vue/components/workspaces/AuditLog.vue +1 -0
  852. package/src/runtime/vue/components/workspaces/WorkspaceBilling.css +2 -1
  853. package/src/runtime/vue/components/workspaces/WorkspaceCredits.css +1 -0
  854. package/src/runtime/vue/components/workspaces/WorkspaceList.css +2 -1
  855. package/src/runtime/vue/components/workspaces/WorkspaceSettings.vue +1 -0
  856. package/src/runtime/vue/pages/gifts.vue +13 -2
  857. package/src/runtime/vue/pages/referral.vue +1 -2
  858. package/dist/devtools-client/_nuxt/CfQg3BRt.js +0 -5
@@ -1,12 +1,13 @@
1
1
  import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
2
2
  import { createRequire } from 'node:module';
3
3
  import { resolve, join, dirname, relative, sep } from 'node:path';
4
- import { k as executeEnvPush, f as runConvex, aL as envNames, $ as REQUIRED_DEPLOYMENT_ENV, aM as DEV_ONLY_DEPLOYMENT_ENV, l as generateAuthSecret, aN as DEV_SITE_URL, j as deploymentFlags, aO as finding, e as deployKeyType, r as readEnvFiles, g as resolveFunctionsDir, aP as parseBackendEnvironment, c as billingEnvironment, P as packageDir, aQ as proofKeys, aR as TEST_CHALLENGE_SITE_KEYS, aS as deploymentEnvId, aT as protectionTakes, ac as DEFAULT_AUTH_ROUTE, aU as TEST_CHALLENGE_SECRET_KEYS, aV as PROTECTED_AUTH_ROUTES, aW as PROOF_HEADER, aX as signProof, aY as proofAudience, b as deploymentBackendEnvironment, aZ as deploymentSiteOrigin, n as isLoopbackUrl, a6 as HEALTH_ROUTE, a3 as resolveSiteUrl, a0 as deriveDeploymentUrls, a as deploymentEnvNames, a_ as isLocalDeploymentId, A as configuredDeployment, Z as collectPreflightFindings, F as computeDeployment, a$ as applyProductionPosture, b0 as capabilityOfGroup, b1 as agentFilesFinding, O as installedVersion, _ as OPTIONAL_DEPLOYMENT_ENV, aA as BACKEND_ENV, b2 as pinnedRegion, b3 as namedModels, b4 as usesProvenance, b5 as monitoringDsnFinding, b6 as monitoringFindings, b7 as usageAlertsFinding, b8 as readUsageLimits, b9 as billingWebhookSecretHint, v as backendPathsOf, ba as BACKEND_PATH_KEYS, bb as pathOption, t as pathsSourceOf, bc as aiFeatures, bd as pathsFileFinding, be as brandFileFinding, x as appBrandOf, aC as REMOVED_DEPLOYMENT_ENV, bf as installableFinding, d as deploymentFunctionSpec, bg as mountsComponent } from '../shared/nuxt-backend.KEzfHO2K.mjs';
4
+ import { l as executeEnvPush, f as runConvex, aY as envNames, a3 as REQUIRED_DEPLOYMENT_ENV, aZ as DEV_ONLY_DEPLOYMENT_ENV, m as generateAuthSecret, a_ as DEV_SITE_URL, g as deploymentFlags, a$ as finding, e as deployKeyType, r as readEnvFiles, j as resolveFunctionsDir, b0 as parseBackendEnvironment, c as billingEnvironment, V as packageDir, b1 as proofKeys, b2 as TEST_CHALLENGE_SITE_KEYS, b3 as deploymentEnvId, b4 as protectionTakes, ak as DEFAULT_AUTH_ROUTE, b5 as TEST_CHALLENGE_SECRET_KEYS, b6 as PROTECTED_AUTH_ROUTES, b7 as PROOF_HEADER, b8 as signProof, b9 as proofAudience, b as deploymentBackendEnvironment, ba as deploymentSiteOrigin, p as isLoopbackUrl, aa as HEALTH_ROUTE, a7 as resolveSiteUrl, a4 as deriveDeploymentUrls, a as deploymentEnvNames, bb as isLocalDeploymentId, H as configuredDeployment, J as computeDeployment, a1 as collectPreflightFindings, bc as capabilityOfGroup, bd as agentFilesFinding, U as installedVersion, a2 as OPTIONAL_DEPLOYMENT_ENV, aN as BACKEND_ENV, be as chosenRoutes, bf as chosenGateways, bg as pinnedRegion, bh as namedModels, bi as usesProvenance, bj as moderationProviders, bk as monitoringDsnFinding, bl as monitoringFindings, bm as usageAlertsFinding, bn as readUsageLimits, bo as applyProductionPosture, bp as billingWebhookSecretHint, w as backendPathsOf, bq as BACKEND_PATH_KEYS, br as pathOption, u as pathsSourceOf, bs as aiFeatures, bt as pathsFileFinding, bu as brandFileFinding, y as appBrandOf, bv as labelsFileFinding, E as appLabelsOf, aP as REMOVED_DEPLOYMENT_ENV, bw as checksImages, bx as namesModerationModel, by as GATEWAY_ORDER_UNREAD, bz as routeKeyFor, bA as installableFinding, d as deploymentFunctionSpec, bB as gatewayKeyIsTheFix, bC as DEFAULT_MODERATION_MODEL, bD as mountsComponent, bE as GATEWAY_KEY_FIX } from '../shared/nuxt-backend.Bq_mhlky.mjs';
5
5
  import { defineCommand } from 'citty';
6
- import { w as withContract, f as finish, p as progress, b as devScriptFinding } from '../shared/nuxt-backend.2m535CLS.mjs';
6
+ import { w as withContract, f as finish, p as progress, b as devScriptFinding } from '../shared/nuxt-backend.Lk2MQI2u.mjs';
7
7
  import { pathToFileURL } from 'node:url';
8
8
  import { Polar } from '@polar-sh/sdk';
9
9
  import { benefitsList } from '@polar-sh/sdk/funcs/benefitsList.js';
10
+ import { checkoutLinksList } from '@polar-sh/sdk/funcs/checkoutLinksList.js';
10
11
  import { membersListMembers } from '@polar-sh/sdk/funcs/membersListMembers.js';
11
12
  import { organizationsListOrganizations } from '@polar-sh/sdk/funcs/organizationsListOrganizations.js';
12
13
  import { productsList } from '@polar-sh/sdk/funcs/productsList.js';
@@ -14,10 +15,10 @@ import { discountsCreate } from '@polar-sh/sdk/funcs/discountsCreate.js';
14
15
  import { discountsList } from '@polar-sh/sdk/funcs/discountsList.js';
15
16
  import { discountsUpdate } from '@polar-sh/sdk/funcs/discountsUpdate.js';
16
17
  import { ServerList } from '@polar-sh/sdk/lib/config.js';
18
+ import { productsUpdate } from '@polar-sh/sdk/funcs/productsUpdate.js';
17
19
  import { benefitsCreate } from '@polar-sh/sdk/funcs/benefitsCreate.js';
18
20
  import { benefitsUpdate } from '@polar-sh/sdk/funcs/benefitsUpdate.js';
19
21
  import { productsUpdateBenefits } from '@polar-sh/sdk/funcs/productsUpdateBenefits.js';
20
- import { productsUpdate } from '@polar-sh/sdk/funcs/productsUpdate.js';
21
22
  import { organizationsUpdate } from '@polar-sh/sdk/funcs/organizationsUpdate.js';
22
23
  import { webhooksListWebhookEndpoints } from '@polar-sh/sdk/funcs/webhooksListWebhookEndpoints.js';
23
24
  import { webhooksUpdateWebhookEndpoint } from '@polar-sh/sdk/funcs/webhooksUpdateWebhookEndpoint.js';
@@ -25,7 +26,7 @@ import { customersGet } from '@polar-sh/sdk/funcs/customersGet.js';
25
26
  import '@convex-dev/polar';
26
27
  import { metricsLimits } from '@polar-sh/sdk/funcs/metricsLimits.js';
27
28
  import { r as readLastRun, i as installChangedSince, a as formatSize } from './report.mjs';
28
- import { c as convexConfigFinding } from '../shared/nuxt-backend.DXEf0rrv.mjs';
29
+ import { c as convexConfigFinding } from '../shared/nuxt-backend.D9qXcOOI.mjs';
29
30
 
30
31
  const ENV_DEFAULT_TYPES = ["preview", "dev"];
31
32
  const ENV_DEFAULT_NAMES = [...REQUIRED_DEPLOYMENT_ENV, "BACKEND_ENVIRONMENT"];
@@ -74,6 +75,30 @@ async function runEnvDefaults(rootDir, options) {
74
75
  return { deployment: `defaults:${options.type}`, dev: false, deployedNames: defaultNames, results, missingRequired };
75
76
  }
76
77
 
78
+ const INVITE_LABEL_MAX = 64;
79
+ const ADMIT_BATCH_MAX = 500;
80
+ const ADMISSION_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
81
+ new TextEncoder();
82
+ function admissionEmail(address) {
83
+ return address.trim().toLowerCase();
84
+ }
85
+ const EMAIL_SHAPE = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/;
86
+ const RESERVED_DOMAINS = /(?:^|\.)(?:example\.(?:com|net|org)|example|test|invalid|localhost)$/;
87
+ function admissionProblem(address) {
88
+ if (address.length > 254 || !EMAIL_SHAPE.test(address)) return "malformed";
89
+ return RESERVED_DOMAINS.test(address.slice(address.lastIndexOf("@") + 1)) ? "reserved" : null;
90
+ }
91
+ function cleanAddresses(emails) {
92
+ const clean = [];
93
+ const skipped = [];
94
+ for (const email of emails.map(admissionEmail).filter(Boolean)) {
95
+ const problem = admissionProblem(email);
96
+ if (problem) skipped.push({ email, reason: problem });
97
+ else clean.push(email);
98
+ }
99
+ return { clean, skipped };
100
+ }
101
+
77
102
  const SCAN_LIMIT = 8e3;
78
103
  const HAS_ADMIN_QUERY = [
79
104
  "let read = 0",
@@ -110,15 +135,41 @@ function addressOf(answer) {
110
135
  return /^[^\s@]+@[^\s@]+$/.test(email) ? email : null;
111
136
  }
112
137
  const FIRST_ADMIN_ADMISSION_MS = 24 * 60 * 60 * 1e3;
113
- async function admitAddress(rootDir, email, prod) {
138
+ const CLI_ADMISSION_LABEL = "command line";
139
+ function admitRefused(prod, note) {
140
+ return { deployment: prod ? "production" : "dev", status: "refused", admitted: [], skipped: [], expiresAt: null, note };
141
+ }
142
+ async function admitAddresses(rootDir, emails, { prod, label, expiresAt }, run) {
143
+ const deployment = prod ? "production" : "dev";
144
+ const report = (status, admitted, skipped, note) => ({ deployment, status, admitted, skipped, expiresAt, ...note ? { note } : {} });
145
+ if (emails.length === 0) return report("admitted", [], []);
114
146
  try {
115
- const args = { emails: [email], source: "invitation", label: "first-administrator", expiresAt: Date.now() + FIRST_ADMIN_ADMISSION_MS };
116
- await runConvex(rootDir, ["run", ...deploymentFlags({ prod }), "--component", "backend", "access:admit", JSON.stringify(args)]);
117
- return true;
118
- } catch {
119
- return false;
147
+ const args = { emails, source: "invitation", label, expiresAt };
148
+ const { stdout } = await run(rootDir, ["run", ...deploymentFlags({ prod }), "--component", "backend", "access:admit", JSON.stringify(args)]);
149
+ const stored = JSON.parse(stdout || "null") ?? {};
150
+ return report("admitted", stored.admitted ?? [], (stored.skipped ?? []).map((row) => ({ email: row.email, reason: "account" })));
151
+ } catch (error) {
152
+ if (error?.missingFunction === true) return report("missing", [], [], `the ${deployment} deployment's backend has no launch access to admit through (access:admit): push the backend first.`);
153
+ return report("failed", [], [], `the ${deployment} deployment refused the admission (${error instanceof Error ? error.message : String(error)}).`);
120
154
  }
121
155
  }
156
+ async function admitCleaned(rootDir, emails, options, run = runConvex) {
157
+ const { clean, skipped } = cleanAddresses(emails);
158
+ const report = await admitAddresses(rootDir, clean, options, run);
159
+ return { ...report, skipped: [...skipped, ...report.skipped] };
160
+ }
161
+ function admitInputRefusal(emails, label, days) {
162
+ if (emails.length === 0) return "name at least one address: npx nuxt-backend access admit you@example.com";
163
+ if (emails.length > ADMIT_BATCH_MAX) return `at most ${ADMIT_BATCH_MAX} addresses at a time.`;
164
+ if (!label.trim() || label.trim().length > INVITE_LABEL_MAX) return `--label is 1-${INVITE_LABEL_MAX} characters.`;
165
+ if (!Number.isInteger(days) || days < 1 || days > 365) return "--days is a whole number of days from 1 to 365.";
166
+ return null;
167
+ }
168
+ const ADMISSION_DAYS = ADMISSION_TTL_MS / (24 * 60 * 60 * 1e3);
169
+ async function admitAddress(rootDir, email, prod) {
170
+ const { status, admitted } = await admitAddresses(rootDir, [email], { prod, label: "first-administrator", expiresAt: Date.now() + FIRST_ADMIN_ADMISSION_MS }, runConvex);
171
+ return status === "admitted" && admitted.includes(email);
172
+ }
122
173
  async function bootstrapAdmin(rootDir, { prod, ask, print }) {
123
174
  if (await deploymentHasAdmin(rootDir, { prod }) !== false) return null;
124
175
  const answer = await ask("[nuxt-backend] doctor --fix: no account holds the admin role. Make which account the first administrator? Its email (empty to skip): ");
@@ -962,7 +1013,7 @@ function refuseUnpricedPlans(catalog) {
962
1013
  for (const [key, plan] of Object.entries(catalog.plans ?? {})) {
963
1014
  const line = legacyPlanLine(plan);
964
1015
  if (line) {
965
- throw new Error(`[nuxt-backend] billing sync: plans.${key} has \`interval\` and \`price\`, which became \`prices: { month, year }\` \u2014 write ${line} (the Upgrade page has the rest).`);
1016
+ throw new Error(`[nuxt-backend] billing sync: plans.${key} has \`interval\` and \`price\`, which became \`prices: { month, year }\` \u2014 write ${line} (https://nuxt-backend.dev/docs/build/billing/catalog#declare has the rest).`);
966
1017
  }
967
1018
  if (pricedIntervals(plan).length === 0) {
968
1019
  throw new Error(`[nuxt-backend] billing sync: plans.${key} has no price \u2014 give it \`prices: { month }\`, \`prices: { year }\` or both.`);
@@ -1014,11 +1065,48 @@ function refuseInvalidPrices(catalog) {
1014
1065
  throw new Error(`[nuxt-backend] billing sync: ${free.join(", ")} are all free plans \u2014 a catalog has at most one, which every new billing entity starts on. Price the others, or retire them.`);
1015
1066
  }
1016
1067
  }
1068
+ function onceCreditsProblem(catalog, key, plan) {
1069
+ const grant = plan.credits;
1070
+ if (!grant?.once) return void 0;
1071
+ if (plan.retired || !isFreePlan(plan)) return `plans.${key} grants its credits \`once\`, which only the free plan does: welcome credits for every new billing entity. Drop \`once\` to grant them every cycle`;
1072
+ if (typeof grant.units !== "number" || !Number.isInteger(grant.units) || grant.units <= 0) return `plans.${key} grants its welcome credits \`once\`: \`units\` is one whole number above 0, not one per interval`;
1073
+ const meter = catalog.meters?.[grant.meter];
1074
+ if (!meter) return `plans.${key} grants its welcome credits on \`${grant.meter}\`, which is no meter of the catalog \u2014 declare it in \`meters\``;
1075
+ if (meter.aggregation === "count") return `plans.${key} grants its welcome credits on \`${grant.meter}\`, which counts events: they are given as a refund, which only a sum meter takes`;
1076
+ return void 0;
1077
+ }
1078
+ function refuseOnceCredits(catalog) {
1079
+ for (const [key, plan] of Object.entries(catalog.plans ?? {})) {
1080
+ const problem = onceCreditsProblem(catalog, key, plan);
1081
+ if (problem) throw new Error(`[nuxt-backend] billing sync: ${problem}.`);
1082
+ }
1083
+ }
1017
1084
  function refuseMissingDefaultCurrency(catalog, currency) {
1018
1085
  if (!currency || catalog.currency) return;
1019
1086
  for (const [key, plan] of Object.entries(catalog.plans ?? {})) refuseCurrencies(`plans.${key}`, planPricesByCurrency(plan, currency).map(([code]) => code), currency);
1020
1087
  for (const [key, pack] of Object.entries(catalog.packs ?? {})) refuseCurrencies(`packs.${key}`, packPricesByCurrency(pack, currency).map(([code]) => code), currency);
1021
1088
  }
1089
+ function missingOrganizationCurrency(catalog, currency, organizationCurrency) {
1090
+ if (!organizationCurrency) return [];
1091
+ const lacks = (codes) => !codes.includes(organizationCurrency);
1092
+ return [
1093
+ ...Object.entries(catalog.plans ?? {}).filter(([, plan]) => !plan.retired && !isFreePlan(plan) && lacks(planPricesByCurrency(plan, currency).map(([code]) => code))).map(([key]) => `plans.${key}`),
1094
+ ...Object.entries(catalog.packs ?? {}).filter(([, pack]) => lacks(packPricesByCurrency(pack, currency).map(([code]) => code))).map(([key]) => `packs.${key}`)
1095
+ ];
1096
+ }
1097
+ function organizationCurrencyProblem(missing, organizationCurrency) {
1098
+ return `the organization's default currency is ${organizationCurrency}, and ${missing.join(", ")} ${missing.length === 1 ? "has" : "have"} no price in it: the provider makes no product without one. Add ${organizationCurrency} to ${missing.length === 1 ? "its" : "their"} prices (\`prices: { usd: \u2026, ${organizationCurrency}: \u2026 }\`), or change the organization's default currency in the provider dashboard`;
1099
+ }
1100
+ function refuseMissingOrganizationCurrency(catalog, currency, organizationCurrency) {
1101
+ const missing = missingOrganizationCurrency(catalog, currency, organizationCurrency);
1102
+ if (missing.length > 0) throw new Error(`[nuxt-backend] billing sync: ${organizationCurrencyProblem(missing, organizationCurrency)}.`);
1103
+ }
1104
+ function zeroPrices(plan, currency, organizationCurrency) {
1105
+ const codes = planPricesByCurrency(plan, currency).map(([code]) => code);
1106
+ if (organizationCurrency && !codes.includes(organizationCurrency)) codes.push(organizationCurrency);
1107
+ const named = [...new Set(codes.filter((code) => code !== void 0))];
1108
+ return named.length > 0 ? named.map((code) => [code, 0]) : [[void 0, 0]];
1109
+ }
1022
1110
  function findPlanProduct(products, key, interval) {
1023
1111
  const tagged = (product) => product.metadata;
1024
1112
  return products.find((product) => tagged(product)?.managedBy === MANAGED_BY && tagged(product)?.key === key && tagged(product)?.interval === interval) ?? products.find((product) => tagged(product)?.managedBy === MANAGED_BY && tagged(product)?.key === key && tagged(product)?.interval === void 0 && product.recurringInterval === interval);
@@ -1276,7 +1364,7 @@ async function planBenefits(key, plan, { creditBenefitFor, planCreditKey, benefi
1276
1364
  return [...credits, ...(plan.features ?? []).flatMap((featureKey) => benefitIdByKey.get(featureKey) ?? [])];
1277
1365
  }
1278
1366
  async function syncPassProducts(catalog, context) {
1279
- const { client, ids, managedProducts, ensureProduct, price, currency, quotasByPlan, adopt, dryRun, log } = context;
1367
+ const { client, ids, managedProducts, ensureProduct, price, currency, organizationCurrency, quotasByPlan, adopt, dryRun, log } = context;
1280
1368
  for (const [key, plan, lengths] of giftablePlans(catalog)) {
1281
1369
  const trialDays = trialPassDays(plan.trial);
1282
1370
  const entry = { pass: "", months: {}, ...trialDays === void 0 ? {} : { trialDays } };
@@ -1287,8 +1375,8 @@ async function syncPassProducts(catalog, context) {
1287
1375
  name: `${plan.name} (pass)`,
1288
1376
  description: plan.description,
1289
1377
  recurringInterval: "month",
1290
- // Free is a fixed price of nothing, as the free plan's is.
1291
- prices: price([[currency, 0]], plan),
1378
+ // Free is a fixed price of nothing, as the free plan's is, in each currency of the plan and the organization's.
1379
+ prices: price(zeroPrices(plan, currency, organizationCurrency), plan),
1292
1380
  visibility: "private",
1293
1381
  metadata: { managedBy: MANAGED_BY, key: passKey, passOf: key }
1294
1382
  }), managedProducts.find((item) => isManaged(item.metadata, passKey)), (id) => {
@@ -1334,17 +1422,37 @@ function customerEmailsOff(settings) {
1334
1422
  }
1335
1423
  async function readManagedProducts(polar) {
1336
1424
  const productByKey = {};
1425
+ const keyById = /* @__PURE__ */ new Map();
1337
1426
  for (const product of await listAllPages((page) => productsList(polar, { metadata: { managedBy: MANAGED_BY }, limit: 100, page }))) {
1338
1427
  const { metadata, prices, visibility, benefits } = product;
1339
1428
  if (typeof metadata?.key !== "string") continue;
1340
1429
  const fixed = (prices ?? []).filter((price) => price.amountType === "fixed" && !price.isArchived && typeof price.priceAmount === "number");
1341
- productByKey[metadata.interval === "year" ? planProductKey(metadata.key, "year") : metadata.key] = {
1430
+ const key = metadata.interval === "year" ? planProductKey(metadata.key, "year") : metadata.key;
1431
+ const benefitKeys = (benefits ?? []).flatMap((benefit) => {
1432
+ const tag = benefit.metadata;
1433
+ return tag?.managedBy === MANAGED_BY && typeof tag.key === "string" ? [tag.key] : [];
1434
+ });
1435
+ productByKey[key] = {
1342
1436
  visibility: typeof visibility === "string" ? visibility : "",
1343
1437
  ...fixed.length > 0 ? { prices: Object.fromEntries(fixed.map((price) => [price.priceCurrency ?? "", price.priceAmount])) } : {},
1344
- benefits: benefits?.length ?? 0
1438
+ benefits: benefits?.length ?? 0,
1439
+ benefitKeys
1345
1440
  };
1441
+ keyById.set(product.id, key);
1442
+ }
1443
+ return { productByKey, keyById };
1444
+ }
1445
+ async function readCheckoutLinks(polar, keyById) {
1446
+ try {
1447
+ const links = await listAllPages((page) => checkoutLinksList(polar, { limit: 100, page }));
1448
+ return links.flatMap((link) => {
1449
+ const { label, products } = link;
1450
+ const keys = [...new Set((products ?? []).filter((product) => !product.isArchived).flatMap((product) => keyById.get(product.id) ?? []))];
1451
+ return keys.length > 0 ? [{ label: label ?? null, keys }] : [];
1452
+ });
1453
+ } catch {
1454
+ return void 0;
1346
1455
  }
1347
- return productByKey;
1348
1456
  }
1349
1457
  async function readBillingOrganizationState(options, client) {
1350
1458
  try {
@@ -1359,7 +1467,8 @@ async function readBillingOrganizationState(options, client) {
1359
1467
  benefitTypeByKey[metadata.key] = benefit.type ?? "";
1360
1468
  }
1361
1469
  const { subscriptionSettings: subscription, customerPortalSettings: portal } = organization;
1362
- const productByKey = await readManagedProducts(polar);
1470
+ const { productByKey, keyById } = await readManagedProducts(polar);
1471
+ const checkoutLinks = await readCheckoutLinks(polar, keyById);
1363
1472
  const members = await membersListMembers(polar, { limit: 1 });
1364
1473
  return {
1365
1474
  slug: organization.slug,
@@ -1369,10 +1478,12 @@ async function readBillingOrganizationState(options, client) {
1369
1478
  preventTrialAbuse: subscription.preventTrialAbuse,
1370
1479
  customerEmailsOff: customerEmailsOff(organization.customerEmailSettings),
1371
1480
  portal: { updatePlan: portal.subscription.updatePlan, pause: portal.subscription.pause ?? false },
1481
+ ...typeof organization.defaultPresentmentCurrency === "string" ? { defaultCurrency: organization.defaultPresentmentCurrency.toLowerCase() } : {},
1372
1482
  benefitTypeByKey,
1373
1483
  memberModel: organization.featureSettings?.memberModelEnabled === true,
1374
1484
  membersReadable: members.ok,
1375
- productByKey
1485
+ productByKey,
1486
+ ...checkoutLinks ? { checkoutLinks } : {}
1376
1487
  };
1377
1488
  } catch {
1378
1489
  return null;
@@ -1406,6 +1517,17 @@ function customerEmailsFinding(state) {
1406
1517
  "Turn the provider's customer emails back on in its dashboard (Settings, Customer notifications); the app never sends a copy of them."
1407
1518
  );
1408
1519
  }
1520
+ function checkoutLinksFinding(state) {
1521
+ if (!state.checkoutLinks) return [];
1522
+ if (state.checkoutLinks.length === 0) return [finding("billing-checkout-links", "pass", "No checkout link of the provider's own sells a catalog product: every purchase goes through the app's checkout.")];
1523
+ const links = state.checkoutLinks.map((link) => `${link.label ? `"${link.label}"` : "an unlabelled link"} (${link.keys.join(", ")})`);
1524
+ return [finding(
1525
+ "billing-checkout-links",
1526
+ "warn",
1527
+ `The provider also sells catalog products through checkout links of its own: ${links.join("; ")}. A purchase there names no billing entity, so the buyer pays and the app grants nothing, or a second plan lands beside the free one.`,
1528
+ "Delete those checkout links in the provider's dashboard (Products, Checkout Links), and link to the app's pricing page, whose checkout names the billing entity, instead."
1529
+ )];
1530
+ }
1409
1531
  function stackedSubscriptionsMessage(catalog, offered) {
1410
1532
  const free = freePlanOf(catalog);
1411
1533
  return free ? `The organization lets a customer hold several subscriptions at once beside the free plan (${free[0]}) \u2014 every billing entity holds it, so a checkout outside the package, which does not upgrade it in place, leaves the customer on two plans, and useBilling() reports only the first.` : `The organization lets a customer hold several subscriptions at once while the catalog offers ${offered} plan prices \u2014 someone can end up on two of them, and useBilling() reports only the first.`;
@@ -1462,6 +1584,46 @@ function passProductsFinding(plans, state) {
1462
1584
  "Run `npx nuxt-backend billing sync`: it creates the missing products. Make a public one private in the provider dashboard."
1463
1585
  );
1464
1586
  }
1587
+ function planCreditBenefit(key, plan, interval) {
1588
+ const monthly = interval === "month" || plan.meterCycle === "month";
1589
+ if (!plan.credits || plan.credits.once || planCreditUnits(plan.credits, monthly ? "month" : interval) === void 0) return void 0;
1590
+ return monthly ? `${key}-credits` : `${key}-credits-${interval}`;
1591
+ }
1592
+ function planBenefitProblems(catalog, state) {
1593
+ return Object.entries(catalog.plans ?? {}).filter(([, plan]) => !plan.retired).flatMap(([key, plan]) => pricedIntervals(plan).flatMap((interval) => {
1594
+ const productKey = planProductKey(key, interval);
1595
+ const carried = state.productByKey[productKey]?.benefitKeys;
1596
+ if (!carried) return [];
1597
+ const credits = planCreditBenefit(key, plan, interval);
1598
+ const lacks = [
1599
+ ...credits && !carried.some((name) => name === `${key}-credits` || name.startsWith(`${key}-credits-`)) ? [credits] : [],
1600
+ ...(plan.features ?? []).filter((feature) => feature in (catalog.features ?? {}) && !carried.includes(feature))
1601
+ ];
1602
+ return lacks.length > 0 ? [`product ${productKey} lacks ${lacks.join(", ")}`] : [];
1603
+ }));
1604
+ }
1605
+ function planBenefitsFinding(catalog, state) {
1606
+ const granting = Object.values(catalog.plans ?? {}).some((plan) => !plan.retired && (plan.credits && !plan.credits.once || (plan.features ?? []).length > 0));
1607
+ if (!granting) return [];
1608
+ const problems = planBenefitProblems(catalog, state);
1609
+ return [problems.length === 0 ? finding("billing-plan-benefits", "pass", "Every plan product carries the credits and features the catalog gives its plan.") : finding(
1610
+ "billing-plan-benefits",
1611
+ "warn",
1612
+ `${problems.join("; ")}: ${problems.length === 1 ? "its" : "their"} subscribers are granted none of it.`,
1613
+ "Run `npx nuxt-backend billing sync`: it attaches a missing benefit to the product that exists, and the provider grants it to the product's current subscribers too. A product that grants other credits on the same meter is drift there: swap them in the provider dashboard."
1614
+ )];
1615
+ }
1616
+ function currencyFinding(catalog, state) {
1617
+ const organization = state.defaultCurrency;
1618
+ if (!organization || !catalog.plans && !catalog.packs) return [];
1619
+ const missing = missingOrganizationCurrency(catalog, catalog.currency?.toLowerCase() ?? organization, organization);
1620
+ return [missing.length === 0 ? finding("billing-currency", "pass", `Every plan and pack has a price in ${organization}, the organization's default currency.`) : finding(
1621
+ "billing-currency",
1622
+ "warn",
1623
+ `${organizationCurrencyProblem(missing, organization)}. \`billing sync\` refuses the catalog until they do.`,
1624
+ `Add ${organization} to those prices in billing.catalog.ts and run \`npx nuxt-backend billing sync\`, or make the catalog's currency the organization's default in the provider dashboard.`
1625
+ )];
1626
+ }
1465
1627
  function passFindings(catalog, state) {
1466
1628
  const giftable = giftablePlans(catalog).map(([key, , months]) => [key, months]);
1467
1629
  return giftable.length > 0 ? [passProductsFinding(giftable, state)] : [];
@@ -1491,7 +1653,27 @@ function providerSdkFindings(rootDir) {
1491
1653
  const { version } = sdk;
1492
1654
  return [Number.parseInt(version, 10) >= 1 ? finding("billing-provider-sdk", "warn", `The billing component (@convex-dev/polar 0.9) resolves @polar-sh/sdk ${version}, but it is built on the 0.x SDK, which 1.0 rewrote: checkout, the portal and webhook parsing break on it.`, 'Pin "@polar-sh/sdk": "^0.49.0" in package.json and reinstall, until nuxt-backend supports the 1.x SDK.') : finding("billing-provider-sdk", "pass", `The billing component resolves @polar-sh/sdk ${version}, the line it is built on.`)];
1493
1655
  }
1494
- function collectBillingFindings(catalog, state, { tokenPresent }) {
1656
+ function unreadOrganizationFindings(tokenPresent, deployedToken) {
1657
+ if (tokenPresent) {
1658
+ return [finding(
1659
+ "billing-organization",
1660
+ "warn",
1661
+ "BILLING_ACCESS_TOKEN is set here but the provider would not answer with it (expired, revoked, or issued for the other environment) \u2014 the catalog cross-checks were skipped.",
1662
+ "Issue a fresh organization access token for the billing environment BACKEND_ENVIRONMENT names (the provider sandbox unless it is production), put it in .env.local, and run `npx nuxt-backend env push`."
1663
+ )];
1664
+ }
1665
+ return deployedToken ? [skippedOrganizationFinding(deployedToken.prod)] : [];
1666
+ }
1667
+ function skippedOrganizationFinding(prod) {
1668
+ const flag = prod ? " --prod" : "";
1669
+ return finding(
1670
+ "billing-organization",
1671
+ "warn",
1672
+ `The ${prod ? "production" : "dev"} deployment holds BILLING_ACCESS_TOKEN, and the env doctor reads here does not, so the checks that read the provider were skipped: its organization's settings against the catalog (subscriptions, proration, trials, portal, emails, team customers, checkout links, gift and pass products, feature benefits), the webhook endpoint and the customer mappings.`,
1673
+ `Run them with the deployment's token in the env: \`BILLING_ACCESS_TOKEN=<the deployment's token>${prod ? " BACKEND_ENVIRONMENT=production" : ""} npx nuxt-backend doctor${flag} --only billing\`, or keep it in .env.local.`
1674
+ );
1675
+ }
1676
+ function collectBillingFindings(catalog, state, { tokenPresent, deployedToken = null }) {
1495
1677
  if (!catalog) return [];
1496
1678
  const findings = [];
1497
1679
  const plans = Object.entries(catalog.plans ?? {});
@@ -1515,17 +1697,7 @@ function collectBillingFindings(catalog, state, { tokenPresent }) {
1515
1697
  ));
1516
1698
  }
1517
1699
  findings.push(...promotionLimitsFinding(catalog));
1518
- if (!state) {
1519
- if (tokenPresent) {
1520
- findings.push(finding(
1521
- "billing-organization",
1522
- "warn",
1523
- "BILLING_ACCESS_TOKEN is set here but the provider would not answer with it (expired, revoked, or issued for the other environment) \u2014 the catalog cross-checks were skipped.",
1524
- "Issue a fresh organization access token for the billing environment BACKEND_ENVIRONMENT names (the provider sandbox unless it is production), put it in .env.local, and run `npx nuxt-backend env push`."
1525
- ));
1526
- }
1527
- return findings;
1528
- }
1700
+ if (!state) return [...findings, ...unreadOrganizationFindings(tokenPresent, deployedToken)];
1529
1701
  findings.push(state.allowMultipleSubscriptions && offered > 1 ? finding(
1530
1702
  "billing-multiple-subscriptions",
1531
1703
  "warn",
@@ -1561,6 +1733,9 @@ function collectBillingFindings(catalog, state, { tokenPresent }) {
1561
1733
  findings.push(customerEmailsFinding(state));
1562
1734
  findings.push(...promotionPortalFinding(catalog, state));
1563
1735
  findings.push(teamCustomersFinding(state));
1736
+ findings.push(...checkoutLinksFinding(state));
1737
+ findings.push(...currencyFinding(catalog, state));
1738
+ findings.push(...planBenefitsFinding(catalog, state));
1564
1739
  if (packs.length > 0) findings.push(giftTwinsFinding(packs.map(([key]) => key), state));
1565
1740
  findings.push(...passFindings(catalog, state));
1566
1741
  if (features.length > 0) {
@@ -1613,7 +1788,7 @@ function missingProductionIds(catalog, ids) {
1613
1788
  const discounts = Object.entries(catalog.discounts ?? {}).filter(([key, discount]) => !discount.retired && !ids?.discounts?.[key]).map(([key]) => `discount ${key}`);
1614
1789
  return [...plans, ...packs, ...meters, ...discounts];
1615
1790
  }
1616
- async function productionCatalogFindings(rootDir, environment) {
1791
+ async function productionCatalogFindings(rootDir, environment, launched = true) {
1617
1792
  let catalog;
1618
1793
  let ids;
1619
1794
  try {
@@ -1627,7 +1802,14 @@ async function productionCatalogFindings(rootDir, environment) {
1627
1802
  if (missing.length === 0) return [finding("billing-catalog-production", "pass", "Every plan price, pack, meter and promotion of the catalog has its production id.")];
1628
1803
  const gap = `The catalog has no production id for ${missing.join(", ")}`;
1629
1804
  const hint = "Run npx nuxt-backend billing sync --env production, and commit the billing.generated.ts it writes.";
1630
- return [environment === "production" ? finding("billing-catalog-production", "fail", `${gap}: production refuses their checkout.`, hint) : finding("billing-catalog-production", "warn", `${gap}: once production bills in the production environment, their checkout is refused.`, hint)];
1805
+ if (environment !== "production") return [finding("billing-catalog-production", "warn", `${gap}: once production bills in the production environment, their checkout is refused.`, hint)];
1806
+ return [launched ? finding("billing-catalog-production", "fail", `${gap}: production refuses their checkout.`, hint) : finding("billing-catalog-production", "warn", `${gap}: billing is not launched on production yet, so nothing sells there until it has them.`, hint)];
1807
+ }
1808
+
1809
+ function billingLaunch({ environment, accessToken, products }) {
1810
+ if (!accessToken) return { launched: false, reason: "no_access_token" };
1811
+ if (Object.keys(products ?? {}).length === 0) return { launched: false, reason: "no_catalog" };
1812
+ return { launched: true };
1631
1813
  }
1632
1814
 
1633
1815
  function isProviderNotFound(error) {
@@ -1673,6 +1855,47 @@ function customerMappingFindings(read, { prod }) {
1673
1855
  )];
1674
1856
  }
1675
1857
 
1858
+ const PRELAUNCH_FINDINGS = /* @__PURE__ */ new Set([
1859
+ "billing-access",
1860
+ "deployment-billing-access-token",
1861
+ "billing-webhook-secret",
1862
+ "deployment-billing-webhook-secret",
1863
+ "billing-webhook-route",
1864
+ "billing-catalog-production"
1865
+ ]);
1866
+ async function productionBillingLaunch(rootDir, deployed) {
1867
+ try {
1868
+ if (!(await loadCatalog(rootDir))?.catalog) return null;
1869
+ const products = (await loadGenerated(rootDir)).production?.products;
1870
+ return billingLaunch({ environment: "production", accessToken: deployed.includes("BILLING_ACCESS_TOKEN"), products });
1871
+ } catch {
1872
+ return null;
1873
+ }
1874
+ }
1875
+ const NOT_LAUNCHED_BECAUSE = {
1876
+ no_access_token: "it bills in the provider's production environment and holds no BILLING_ACCESS_TOKEN",
1877
+ no_catalog: "it holds BILLING_ACCESS_TOKEN, but billing.generated.ts has no production products (billing sync --env production has not run)"
1878
+ };
1879
+ function launchSteps(reason) {
1880
+ const token = "put the live organization token in .env.local as BILLING_ACCESS_TOKEN and run `npx nuxt-backend env push --prod`; ";
1881
+ return `Once the provider has reviewed the organization: ${reason === "no_access_token" ? token : ""}run \`npx nuxt-backend billing sync --env production\` with production's deploy key, commit and deploy the billing.generated.ts it writes, then start everyone who joined meanwhile on the free plan: \`npx convex run --prod billing:startFreePlan '{}'\`.`;
1882
+ }
1883
+ function billingLaunchFinding(launch) {
1884
+ if (launch.launched) return finding("billing-launch", "pass", "Billing is launched on production: it holds BILLING_ACCESS_TOKEN and the catalog has production products, so its pricing sells.");
1885
+ return finding(
1886
+ "billing-launch",
1887
+ "warn",
1888
+ `Billing is not launched on production yet: ${NOT_LAUNCHED_BECAUSE[launch.reason]}. Its pricing reads "Plans open soon" and every sale is refused (unavailable, reason not_launched); the rest of the app runs. Until it launches, the token, webhook and production catalog findings warn rather than fail.`,
1889
+ launchSteps(launch.reason)
1890
+ );
1891
+ }
1892
+ function withBillingLaunch(findings, launch) {
1893
+ const said = launch.launched ? [...findings] : findings.map((reported) => PRELAUNCH_FINDINGS.has(reported.id) && reported.status === "warn" ? { ...reported, message: `${reported.message} (billing is not launched yet: see billing-launch)` } : reported);
1894
+ const at = said.findIndex((reported) => reported.capability === "billing");
1895
+ const led = at === -1 ? [...said, billingLaunchFinding(launch)] : [...said.slice(0, at), billingLaunchFinding(launch), ...said.slice(at)];
1896
+ return { findings: led, settled: launch.launched ? [] : [...PRELAUNCH_FINDINGS] };
1897
+ }
1898
+
1676
1899
  const CUSTOMER_EMAILS = [
1677
1900
  "orderConfirmation",
1678
1901
  "subscriptionConfirmation",
@@ -2467,20 +2690,35 @@ async function docsFinding(input, fetcher) {
2467
2690
  return [finding("agent-docs", "warn", `The app declares docs for agents (llms), and ${url} answered ${response?.status ?? "nothing"}${response?.status === 200 ? " with no text document" : ""}.`, "Check the llms options in nuxt.config, and that the build ran its module.")];
2468
2691
  }
2469
2692
  const STATES = /* @__PURE__ */ new Set(["live", "test", "missing", "failing"]);
2470
- async function healthFinding(input, fetcher) {
2471
- const url = `${input.origin}${HEALTH_ROUTE}`;
2693
+ async function readHealth(url, fetcher) {
2472
2694
  const response = await probe(url, { headers: { accept: "application/json" } }, fetcher);
2473
- if (!response) return finding("monitoring-health", "warn", `${url} did not answer.`, "Check the app host's logs.");
2474
- if (response.status === 404) return finding("monitoring-health", "warn", `${url} is not served (404): an uptime check has nothing to ask.`, "Check that the app was built with this package.");
2695
+ if (!response) return { found: finding("monitoring-health", "warn", `${url} did not answer.`, "Check the app host's logs."), answers: false };
2696
+ if (response.status === 404) return { found: finding("monitoring-health", "warn", `${url} is not served (404): an uptime check has nothing to ask.`, "Check that the app was built with this package."), answers: false };
2475
2697
  const body = response.status === 200 || response.status === 503 ? await jsonOf(response) : null;
2476
2698
  const capabilities = body?.capabilities;
2477
2699
  const shaped = body && ["ok", "degraded", "failing"].includes(body.status) && typeof capabilities === "object" && capabilities !== null && Object.values(capabilities).every((state) => STATES.has(state));
2478
- if (!shaped) return finding("monitoring-health", "warn", `${url} answered ${response.status} without the health's shape ({ status, capabilities }).`, "A route of your own shadows it, or a proxy rewrote the answer.");
2700
+ if (!shaped) return { found: finding("monitoring-health", "warn", `${url} answered ${response.status} without the health's shape ({ status, capabilities }).`, "A route of your own shadows it, or a proxy rewrote the answer."), answers: false };
2701
+ return { found: shapedHealthFinding(url, body, capabilities), answers: true };
2702
+ }
2703
+ function shapedHealthFinding(url, body, capabilities) {
2479
2704
  if ("detail" in body) return finding("monitoring-health", "fail", `${url} shows the capabilities' detail to an anonymous caller: their env names and findings.`, "Production names itself development (BACKEND_ENVIRONMENT), which shows the detail to everyone: name it production with npx nuxt-backend env push --prod --force BACKEND_ENVIRONMENT (env push leaves a value already set unless forced).");
2480
2705
  const failing = Object.entries(capabilities).filter(([, state]) => state === "failing").map(([name]) => name);
2481
2706
  if (body.status === "failing") return finding("monitoring-health", "warn", `${url} answers its public shape, and reports the app failing (${failing.join(", ") || "the backend unreachable"}).`, "npx nuxt-backend status --prod says why.");
2482
2707
  return finding("monitoring-health", "pass", `${url} answers its public shape: ${body.status}, ${Object.keys(capabilities).length} capabilities, no detail.`);
2483
2708
  }
2709
+ function uptimeFinding(url) {
2710
+ return finding(
2711
+ "monitoring-uptime",
2712
+ "pass",
2713
+ `Not checked: whether an uptime monitor asks ${url}. doctor reads no monitoring account; the endpoint answers its public shape, so a monitor has something to ask.`,
2714
+ `Without one, an outage is heard of when someone reports it. In Sentry: Monitors, Add Monitor, Uptime, at ${url}, every minute; it opens an issue after three failures in a row. Any uptime service that GETs the URL works the same way.`
2715
+ );
2716
+ }
2717
+ async function healthFindings(input, fetcher) {
2718
+ const url = `${input.origin}${HEALTH_ROUTE}`;
2719
+ const { found, answers } = await readHealth(url, fetcher);
2720
+ return answers ? [found, uptimeFinding(url)] : [found];
2721
+ }
2484
2722
  const PROBE_IDS = [["site", "site-https"], ["auth", "site-gated-page"], ["monitoring", "monitoring-health"]];
2485
2723
  function unprobedSiteFindings(why, fixHint, wants) {
2486
2724
  const first = PROBE_IDS.find(([group]) => wants(group));
@@ -2495,7 +2733,7 @@ async function siteProbeFindings(input, fetcher = fetch) {
2495
2733
  input.wants("auth") ? gatedPageFinding(input, fetcher) : [],
2496
2734
  input.wants("auth") ? authProxyFinding(input, fetcher) : [],
2497
2735
  input.wants("site") ? docsFinding(input, fetcher) : [],
2498
- input.wants("monitoring") ? healthFinding(input, fetcher) : []
2736
+ input.wants("monitoring") ? healthFindings(input, fetcher) : []
2499
2737
  ]);
2500
2738
  return results.flat();
2501
2739
  }
@@ -2524,7 +2762,8 @@ async function loadedBackendOptions(appConfig) {
2524
2762
  return config ? pathsSourceOf(config) : null;
2525
2763
  }
2526
2764
  async function generatedFileFindings(rootDir, appConfig) {
2527
- return [codegenFinding(rootDir), ...pathsFileFinding(rootDir, await loadedBackendOptions(appConfig)), ...brandFileFinding(rootDir, await appBrandOf(await appConfig()))];
2765
+ const config = await appConfig();
2766
+ return [codegenFinding(rootDir), ...pathsFileFinding(rootDir, await loadedBackendOptions(appConfig)), ...brandFileFinding(rootDir, await appBrandOf(config)), ...labelsFileFinding(rootDir, await appLabelsOf(config))];
2528
2767
  }
2529
2768
  async function installableFindings(rootDir, appConfig, { wanted, pushKeys }) {
2530
2769
  const config = wanted ? await appConfig() : null;
@@ -2534,7 +2773,9 @@ async function installableFindings(rootDir, appConfig, { wanted, pushKeys }) {
2534
2773
  return typeof name === "string" ? [name] : [];
2535
2774
  });
2536
2775
  const publicDir = join(rootDir, config.dir?.public ?? "public");
2537
- return installableFinding(publicDir, await appBrandOf(config), { modules, pushKeys });
2776
+ const options = pathsSourceOf(config).installable;
2777
+ const links = config.app?.head?.link ?? [];
2778
+ return installableFinding(publicDir, await appBrandOf(config), { modules, pushKeys, options, links });
2538
2779
  }
2539
2780
  function servesAgentDocs(config) {
2540
2781
  return config?.llms !== void 0 || (config?.modules ?? []).some((entry) => (Array.isArray(entry) ? entry[0] : entry) === "nuxt-llms");
@@ -2589,7 +2830,7 @@ async function pagePathFindings(appConfig, deployed) {
2589
2830
  "Pass the `paths` of paths.generated.ts to defineBackendAuthConfig (auth.config.ts), setupAuth (auth.ts) and setupAccount (account.ts), then let `npx convex dev` push or deploy."
2590
2831
  )];
2591
2832
  }
2592
- async function billingCatalogFindings(rootDir, env) {
2833
+ async function billingCatalogFindings(rootDir, env, { deployed, prod = false } = {}) {
2593
2834
  let catalog;
2594
2835
  try {
2595
2836
  catalog = (await loadCatalog(rootDir))?.catalog ?? null;
@@ -2600,7 +2841,8 @@ async function billingCatalogFindings(rootDir, env) {
2600
2841
  const accessToken = env.BILLING_ACCESS_TOKEN;
2601
2842
  const environment = billingEnvironment(parseBackendEnvironment(env.BACKEND_ENVIRONMENT));
2602
2843
  const state = accessToken ? await readBillingOrganizationState({ accessToken, environment }) : null;
2603
- return collectBillingFindings(catalog, state, { tokenPresent: Boolean(accessToken) });
2844
+ const deployedToken = !accessToken && (await deployed)?.includes("BILLING_ACCESS_TOKEN") ? { prod } : null;
2845
+ return collectBillingFindings(catalog, state, { tokenPresent: Boolean(accessToken), deployedToken });
2604
2846
  }
2605
2847
  async function probeWebhookRoute(url) {
2606
2848
  try {
@@ -2715,6 +2957,9 @@ function listed(names) {
2715
2957
  return names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
2716
2958
  }
2717
2959
  const CONVEX_GATEWAY_PROVIDER = "@convex-dev/ai-sdk-provider";
2960
+ const keyFix = (flag) => flag ? GATEWAY_KEY_FIX.prod : GATEWAY_KEY_FIX.dev;
2961
+ const routesNameConvex = (routes) => routes === "unread" || Object.values(routes ?? {}).some((order) => order.includes("convex"));
2962
+ const namesConvex = (order) => order === void 0 || order === "unread" || order.includes("convex");
2718
2963
  const SPENDING_LIMIT = "Cap its spend with `npx convex deployment usage-limits set` (the `aiGatewayCostDollars` limit).";
2719
2964
  function convexGatewayProviderInstalled(rootDir) {
2720
2965
  try {
@@ -2736,29 +2981,104 @@ function cloudRouteFinding(id, models, { keyed, provider, flag }) {
2736
2981
  id,
2737
2982
  "warn",
2738
2983
  `The backend names ${listed(models)}, but no model route is ready on the deployment: ${CONVEX_GATEWAY_PROVIDER} is not installed and AI_GATEWAY_API_KEY is not set, so those model calls are refused.`,
2739
- `Install ${CONVEX_GATEWAY_PROVIDER} (\`pnpm add ${CONVEX_GATEWAY_PROVIDER}\`) to use the Convex AI Gateway on a paid plan, or add AI_GATEWAY_API_KEY to .env.local and run \`npx nuxt-backend env push${flag}\`.`
2984
+ `${keyFix(flag)} Or install ${CONVEX_GATEWAY_PROVIDER} (\`pnpm add ${CONVEX_GATEWAY_PROVIDER}\`) to use the Convex AI Gateway on a paid plan.`
2740
2985
  );
2741
2986
  }
2742
- function gatewayKeyFinding(deployed, { models, local, cloud, provider, prod, region }) {
2987
+ function convexRouteFinding(id, models, { cloud, linked, local, provider, keyed, alone, flag }) {
2988
+ const how = alone ? `setupAi({ gateway: 'convex' }) sends ${listed(models)} through the Convex AI Gateway alone` : `AI_GATEWAY_API_KEY is not set on the deployment, so ${listed(models)} go through the Convex AI Gateway, next in setupAi({ gateway })`;
2989
+ const elsewhere = alone ? `Add 'vercel' to setupAi({ gateway }), then: ${keyFix(flag)}` : keyFix(flag);
2990
+ const install = `Install ${CONVEX_GATEWAY_PROVIDER} (\`pnpm add ${CONVEX_GATEWAY_PROVIDER}\`)`;
2991
+ if (!provider) {
2992
+ return finding(id, "warn", `${how}, but ${CONVEX_GATEWAY_PROVIDER} is not installed: those model calls are refused.`, alone ? `${install}, or: ${elsewhere}` : `${elsewhere} Or: ${install}.`);
2993
+ }
2994
+ if (cloud || linked) {
2995
+ const unused = alone && keyed ? " AI_GATEWAY_API_KEY is set on the deployment and never read." : "";
2996
+ const whose = cloud ? "the team" : "the team of the project this local deployment is linked to";
2997
+ return finding(id, "pass", `${how}, which bills ${whose}; a free plan refuses it (AiGatewayDisabled), and no other gateway is tried.${unused} ${SPENDING_LIMIT}`);
2998
+ }
2999
+ if (local) {
3000
+ const login = "Run `npx convex login` to link the local deployment to a project on a paid plan, then restart `npx nuxt-backend dev`.";
3001
+ return finding(id, "warn", `${how}, which an anonymous local deployment cannot reach: those model calls are refused.`, alone ? `${login} Or: ${elsewhere}` : `${elsewhere} Or: ${login}`);
3002
+ }
3003
+ return finding(id, "warn", `${how}, which a self-hosted deployment never has: those model calls are refused.`, elsewhere);
3004
+ }
3005
+ function gatewayKeyFinding(deployed, { models, local, linked, cloud, provider, prod, region, gateways = ["convex", "vercel"], routes }) {
2743
3006
  const id = deploymentEnvId("AI_GATEWAY_API_KEY");
2744
3007
  const flag = prod ? " --prod" : "";
2745
3008
  const keyed = deployed.includes("AI_GATEWAY_API_KEY");
2746
3009
  if (models.length === 0) {
2747
3010
  return finding(id, "pass", keyed ? "AI_GATEWAY_API_KEY is set on the deployment." : "AI_GATEWAY_API_KEY is not set, and no backend file names a provider/model id that needs a model route.");
2748
3011
  }
2749
- if (region) {
2750
- if (keyed) return finding(id, "pass", `AI_GATEWAY_API_KEY is set on the deployment: ${listed(models)} go through the Vercel AI Gateway, pinned to the '${region}' inference region.`);
2751
- return finding(id, "warn", `The backend pins its model calls to the '${region}' inference region, which only the Vercel AI Gateway serves, but AI_GATEWAY_API_KEY is not set on the deployment: ${listed(models)} are refused.`, `Add AI_GATEWAY_API_KEY to .env.local and run \`npx nuxt-backend env push${flag}\`.`);
2752
- }
2753
- if (cloud) return cloudRouteFinding(id, models, { keyed, provider, flag });
3012
+ if (gateways === "unread" || routes === "unread") return unreadOrderFinding(id, models, routes === "unread" ? "routes" : "gateway");
3013
+ const routeless = Object.entries(routes ?? {}).find(([, order]) => !order.includes("vercel"))?.[0];
3014
+ if (region) return regionRouteFinding(id, models, { region, keyed, vercel: gateways.includes("vercel"), routeless, flag });
3015
+ const facts = { keyed, cloud, linked, local, provider, flag };
3016
+ const groups = routedGroups(models, gateways, routes);
3017
+ if (groups.length === 1 && groups[0].key === void 0) return orderRouteFinding(id, models, { gateways, ...facts });
3018
+ return routesFinding(id, groups.map((group) => ({ group, found: orderRouteFinding(id, group.models, { gateways: group.order, ...facts }) })));
3019
+ }
3020
+ function unreadOrderFinding(id, models, option) {
3021
+ const literal = option === "gateway" ? "'convex', 'vercel' or a list of them" : "a map of quoted model ids or patterns to 'convex', 'vercel' or a list of them";
3022
+ return finding(
3023
+ id,
3024
+ "warn",
3025
+ `${GATEWAY_ORDER_UNREAD}: setupAi({ ${option} }) is no literal it reads (a variable, the shorthand { ${option} }, ${option === "gateway" ? "an empty list" : "a computed key"}, spread options, or two setupAi calls that differ), so the route of ${listed(models)} is not checked.`,
3026
+ `Write \`${option}\` in setupAi as ${literal}, in one setupAi call, then run doctor again.`
3027
+ );
3028
+ }
3029
+ function routedGroups(models, gateways, routes) {
3030
+ const groups = /* @__PURE__ */ new Map();
3031
+ for (const model of models) {
3032
+ const key = routes ? routeKeyFor(model, routes) : void 0;
3033
+ const group = groups.get(key) ?? { key, order: key === void 0 ? gateways : routes[key], models: [] };
3034
+ group.models.push(model);
3035
+ groups.set(key, group);
3036
+ }
3037
+ return [...groups.values()];
3038
+ }
3039
+ const STATUS_RANK = { pass: 0, warn: 1, fail: 2 };
3040
+ function routesFinding(id, parts) {
3041
+ const routed = (text, key) => text.replace(/setupAi\(\{ gateway(?:: '[a-z]+')? \}\)/g, `its route '${key}' in setupAi({ routes })`);
3042
+ const said = parts.map(({ group, found }) => {
3043
+ if (group.key === void 0) return { ...found, message: `Under setupAi({ gateway })'s order: ${found.message}` };
3044
+ const unread = group.order.length === 1 && group.order[0] === "convex" ? ` AI_GATEWAY_API_KEY is never read for ${listed(group.models)}.` : "";
3045
+ return { ...found, message: `Routed by '${group.key}' (${group.order.join(", then ")}): ${routed(found.message, group.key)}${unread}`, fixHint: routed(found.fixHint, group.key) };
3046
+ });
3047
+ const worst = said.reduce((a, b) => STATUS_RANK[b.status] > STATUS_RANK[a.status] ? b : a);
3048
+ const hints = [...new Set(said.map((part) => part.fixHint).filter(Boolean))].sort((a, b) => Number(gatewayKeyIsTheFix({ fixHint: b })) - Number(gatewayKeyIsTheFix({ fixHint: a })));
3049
+ return finding(id, worst.status, said.map((part) => part.message).join(" "), hints.join(" "));
3050
+ }
3051
+ function orderRouteFinding(id, models, { gateways, ...facts }) {
3052
+ const vercelFirst = gateways[0] === "vercel";
3053
+ if (!gateways.includes("convex")) return vercelRouteFinding(id, models, facts);
3054
+ if (vercelFirst && facts.keyed) return finding(id, "pass", `AI_GATEWAY_API_KEY is set on the deployment: ${listed(models)} go through the Vercel AI Gateway, first in setupAi({ gateway }).`);
3055
+ if (vercelFirst || !gateways.includes("vercel")) return convexRouteFinding(id, models, { ...facts, alone: !vercelFirst });
3056
+ return defaultRouteFinding(id, models, facts);
3057
+ }
3058
+ function vercelRouteFinding(id, models, { keyed, flag }) {
3059
+ if (keyed) return finding(id, "pass", `AI_GATEWAY_API_KEY is set on the deployment: ${listed(models)} go through the Vercel AI Gateway (setupAi({ gateway: 'vercel' })).`);
3060
+ return finding(id, "warn", `setupAi({ gateway: 'vercel' }) sends ${listed(models)} through the Vercel AI Gateway alone, but AI_GATEWAY_API_KEY is not set on the deployment: those model calls are refused.`, keyFix(flag));
3061
+ }
3062
+ function defaultRouteFinding(id, models, { cloud, linked, local, provider, keyed, flag }) {
3063
+ if (cloud || linked) return cloudRouteFinding(id, models, { keyed, provider, flag });
2754
3064
  if (keyed) return finding(id, "pass", `AI_GATEWAY_API_KEY is set on the deployment: ${listed(models)} go through the Vercel AI Gateway.`);
2755
3065
  return finding(
2756
3066
  id,
2757
3067
  "warn",
2758
- `The backend names ${listed(models)}, but AI_GATEWAY_API_KEY is not set on the deployment${local && provider ? ", so those model calls go to the Convex AI Gateway only when the deployment is linked to a team that has it, and are refused otherwise" : ": those model calls are refused"}.`,
2759
- `Add AI_GATEWAY_API_KEY to .env.local and run \`npx nuxt-backend env push${flag}\`.`
3068
+ `The backend names ${listed(models)}, but AI_GATEWAY_API_KEY is not set on the deployment${local && provider ? ", and an anonymous local deployment cannot reach the Convex AI Gateway: those model calls are refused" : ": those model calls are refused"}.`,
3069
+ local && provider ? `${keyFix(flag)} Or run \`npx convex login\` to link the local deployment to a project on a paid plan.` : keyFix(flag)
2760
3070
  );
2761
3071
  }
3072
+ function regionRouteFinding(id, models, { region, keyed, vercel, routeless, flag }) {
3073
+ if (!vercel) {
3074
+ return finding(id, "warn", `The backend pins its model calls to the '${region}' inference region, which only the Vercel AI Gateway serves, but setupAi({ gateway }) does not name 'vercel': setupAi refuses the pin, and the push fails.`, "Add 'vercel' to setupAi({ gateway }), or drop inferenceRegion.");
3075
+ }
3076
+ if (routeless) {
3077
+ return finding(id, "warn", `The backend pins its model calls to the '${region}' inference region, which only the Vercel AI Gateway serves, but the route for '${routeless}' in setupAi({ routes }) does not name 'vercel': setupAi refuses the pin, and the push fails.`, `Add 'vercel' to the route for '${routeless}', or drop inferenceRegion.`);
3078
+ }
3079
+ if (keyed) return finding(id, "pass", `AI_GATEWAY_API_KEY is set on the deployment: ${listed(models)} go through the Vercel AI Gateway, pinned to the '${region}' inference region.`);
3080
+ return finding(id, "warn", `The backend pins its model calls to the '${region}' inference region, which only the Vercel AI Gateway serves, but AI_GATEWAY_API_KEY is not set on the deployment: ${listed(models)} are refused.`, keyFix(flag));
3081
+ }
2762
3082
  function provenanceKeyFinding(name, deployed, { on, prod }) {
2763
3083
  const id = deploymentEnvId(name);
2764
3084
  if (!on) return finding(id, "pass", `${name} is not needed: no backend file turns provenance on.`);
@@ -2804,10 +3124,10 @@ function declaredFeatureFindings(rootDir, { wants, deployed, prod }) {
2804
3124
  ];
2805
3125
  }
2806
3126
  function deploymentRoute(kind, prod) {
2807
- if (prod) return { local: false, cloud: kind !== "self-hosted" };
2808
- return { local: ["local", "anonymous"].includes(kind), cloud: ["cloud-dev", "preview", "production"].includes(kind) };
3127
+ if (prod) return { local: false, linked: false, cloud: kind !== "self-hosted" };
3128
+ return { local: ["local", "anonymous"].includes(kind), linked: kind === "local", cloud: ["cloud-dev", "preview", "production"].includes(kind) };
2809
3129
  }
2810
- function deploymentEnvFindings(rootDir, deployed, { prod, local, cloud, posture }) {
3130
+ function deploymentEnvFindings(rootDir, deployed, { prod, local, linked, cloud, posture }) {
2811
3131
  const sandboxInbox = prod && posture?.environment === "sandbox" && reExportsName(rootDir, "getSandboxInbox");
2812
3132
  if (!deployed) {
2813
3133
  return [finding("deployment-env", "warn", "Could not read the deployment env (no deployment configured, or `npx convex env list` failed).", "Run `npx convex dev` once to provision, then re-run doctor.")];
@@ -2818,17 +3138,81 @@ function deploymentEnvFindings(rootDir, deployed, { prod, local, cloud, posture
2818
3138
  // A name with no finding of its own (the marketing sender, the region) reports nothing yet.
2819
3139
  // The dev inbox's opt-in reports only once it is set: unset is every app's state, and nothing to say.
2820
3140
  ...Object.entries(OPTIONAL_DEPLOYMENT_ENV).filter(([name]) => !name.startsWith("PROTECTION_") && BACKEND_ENV[name].findings.length > 0 && (name !== "EMAIL_DEV_INBOX" || deployed.includes(name) || sandboxInbox)).map(([name, degradation]) => {
2821
- if (name === "AI_GATEWAY_API_KEY") return gatewayKeyFinding(deployed, { models: namedModels(rootDir), local, cloud, provider: convexGatewayProviderInstalled(rootDir), prod, region: pinnedRegion(rootDir) });
3141
+ if (name === "AI_GATEWAY_API_KEY") return gatewayKeyFinding(deployed, { models: namedModels(rootDir), local, linked, cloud, provider: convexGatewayProviderInstalled(rootDir), prod, region: pinnedRegion(rootDir), gateways: chosenGateways(rootDir), routes: chosenRoutes(rootDir) });
2822
3142
  if (name === "PROVENANCE_PRIVATE_KEY" || name === "PROVENANCE_CERTIFICATE") return provenanceKeyFinding(name, deployed, { on: usesProvenance(rootDir), prod });
3143
+ if (isModerationKey(name)) return moderationKeyFinding(name, moderationProviders(rootDir), deployed, { prod });
2823
3144
  if (name === "MONITORING_DSN") return monitoringDsnFinding(deployed.includes(name), { prod });
2824
3145
  if (name === "EMAIL_DEV_INBOX") return devInboxFinding({ prod, posture, set: deployed.includes(name) });
2825
3146
  const valued = posture ? productionEnvFinding(name, deployed, posture) : null;
2826
3147
  if (valued) return valued;
2827
3148
  return optionalDeploymentEnvFinding(name, degradation, deployed.includes(name), { prod });
2828
3149
  }),
2829
- removedEnvFinding(deployed, { prod })
3150
+ removedEnvFinding(deployed, { prod }),
3151
+ moderationImagesFinding(rootDir, deployed, { cloud, linked, prod }),
3152
+ moderationProvidersFinding(rootDir)
2830
3153
  ];
2831
3154
  }
3155
+ const EU_AZURE_REGIONS = /* @__PURE__ */ new Set(["austriaeast", "belgiumcentral", "denmarkeast", "francecentral", "francesouth", "germanynorth", "germanywestcentral", "italynorth", "northeurope", "polandcentral", "spaincentral", "swedencentral", "swedensouth", "westeurope"]);
3156
+ function moderationProvidersFinding(rootDir) {
3157
+ const id = "ai-moderation-providers";
3158
+ const providers = moderationProviders(rootDir);
3159
+ if (providers.length === 0) return finding(id, "pass", "The backend names no moderation provider: its safety classifier checks content alone.");
3160
+ const knownAbuse = providers.some((provider) => provider.id === "arachnid-shield");
3161
+ const problems = [unmatchedImages(rootDir, knownAbuse), regionOutsideEu(rootDir, providers)].filter((problem) => problem !== void 0);
3162
+ const minors = checksImages(rootDir) ? ` ${MINORS_NOTE}` : "";
3163
+ if (problems.length === 0) return finding(id, "pass", `The backend names ${listed(providers.map((provider) => provider.id))}${knownAbuse ? ", a known-abuse match first" : ""}.${minors}`);
3164
+ return finding(id, "warn", `${problems.map((problem) => problem.message).join(" ")}${minors}`, problems.map((problem) => problem.fix).join(" "));
3165
+ }
3166
+ const MINORS_NOTE = "No image provider judges minors in an image: child sexual abuse material no hash list knows is caught as `S4` by a classifier that reads images (Llama Guard 4), and otherwise only as `sexual`, which `block` covers.";
3167
+ const MODERATION_KEYS = /* @__PURE__ */ new Set(["CONTENT_SAFETY_ENDPOINT", "CONTENT_SAFETY_KEY", "SECOND_OPINION_KEY", "KNOWN_ABUSE_KEY"]);
3168
+ function isModerationKey(name) {
3169
+ return MODERATION_KEYS.has(name);
3170
+ }
3171
+ function moderationKeyFinding(name, providers, deployed, { prod }) {
3172
+ const id = deploymentEnvId(name);
3173
+ const readers = providers.filter((provider) => provider.env.includes(name)).map((provider) => provider.id);
3174
+ if (readers.length === 0) return finding(id, "pass", `${name} is not needed: no backend file names a moderation provider that reads it.`);
3175
+ if (deployed.includes(name)) return finding(id, "pass", `${name} is set on the deployment: ${listed(readers)} can check content.`);
3176
+ return finding(
3177
+ id,
3178
+ "warn",
3179
+ `The backend names ${listed(readers)}, but ${name} is not set on the deployment: every check it is asked for is refused, and the content is refused as unchecked.`,
3180
+ `Add ${name} to .env.local and run \`npx nuxt-backend env push${prod ? " --prod" : ""}\`.`
3181
+ );
3182
+ }
3183
+ function unmatchedImages(rootDir, knownAbuse) {
3184
+ if (knownAbuse || !checksImages(rootDir)) return void 0;
3185
+ return { message: "The backend checks images with no known-abuse match: no hash list stands between an upload of known child sexual abuse material and the other providers.", fix: "Add `knownAbuse: arachnidShield()` to setupAi({ moderation }) (free once your organization is vetted)." };
3186
+ }
3187
+ function regionOutsideEu(rootDir, providers) {
3188
+ const azure = providers.find((provider) => provider.id === "azure-content-safety");
3189
+ if (pinnedRegion(rootDir) !== "eu" || azure === void 0 || EU_AZURE_REGIONS.has(azure.region ?? "")) return void 0;
3190
+ const named = azure.region ? `'${azure.region}'` : "no region";
3191
+ return { message: `The backend pins its model calls to the EU, but azureContentSafety() names ${named}, which is no EU region: images it checks are processed outside the EU.`, fix: "Create the Content Safety resource in an EU region, such as francecentral, and name it in azureContentSafety({ region })." };
3192
+ }
3193
+ function answeringGateway(order, { keyed, convex }) {
3194
+ return order.find((gateway) => gateway === "vercel" ? keyed : convex);
3195
+ }
3196
+ function moderationImagesFinding(rootDir, deployed, { cloud, linked, prod }) {
3197
+ const id = "ai-moderation-images";
3198
+ if (!checksImages(rootDir)) return finding(id, "pass", "No backend file checks images with the safety classifier.");
3199
+ if (namesModerationModel(rootDir)) return finding(id, "pass", "The backend checks images with the classifier it names in setupAi({ moderation: { model } }).");
3200
+ const order = chosenGateways(rootDir);
3201
+ const routes = chosenRoutes(rootDir);
3202
+ if (order === "unread" || routes === "unread") return finding(id, "pass", `${GATEWAY_ORDER_UNREAD}, so which classifier checks the backend's images is not known.`);
3203
+ const pinned = pinnedRegion(rootDir) !== void 0;
3204
+ const convex = (cloud || linked || prod) && convexGatewayProviderInstalled(rootDir);
3205
+ const routed = routes ? routeKeyFor(DEFAULT_MODERATION_MODEL, routes) : void 0;
3206
+ const classifierOrder = routed === void 0 ? order ?? ["convex", "vercel"] : routes[routed];
3207
+ const answers = pinned ? "vercel" : answeringGateway(classifierOrder, { keyed: deployed.includes("AI_GATEWAY_API_KEY"), convex });
3208
+ if (answers !== "vercel") return finding(id, "pass", "The backend checks images with Llama Guard 4, through the Convex AI Gateway, which reads them.");
3209
+ return finding(
3210
+ id,
3211
+ "warn",
3212
+ `The backend checks images, but its default safety classifier goes through the Vercel AI Gateway here${pinned ? " (inference is pinned to a region)" : ""}, which serves none that reads images: openai/gpt-oss-safeguard-20b reads text only, so every check with images is refused as unchecked.`,
3213
+ "Route moderation through the Convex AI Gateway (a paid Convex plan, @convex-dev/ai-sdk-provider installed, and 'convex' first in setupAi({ gateway })), or name a classifier that reads images in setupAi({ moderation: { model } })."
3214
+ );
3215
+ }
2832
3216
  async function envDefaultsFindings(rootDir) {
2833
3217
  const names = await projectEnvDefaultNames(rootDir, "preview");
2834
3218
  if (!names) return [];
@@ -2925,13 +3309,14 @@ function readSurface(rootDir, { prod, reachable, siteUrl, wants, probes }) {
2925
3309
  function productionBillsIn({ environment }) {
2926
3310
  return environment === "unset" || environment === "unread" ? environment : billingEnvironment(environment);
2927
3311
  }
2928
- async function productionPostureFindings(rootDir, posture, wants) {
3312
+ async function productionPostureFindings(rootDir, posture, wants, { launch, deployed, cloud }) {
2929
3313
  if (!posture) return [];
2930
3314
  return [
2931
3315
  ...wants("auth") ? siteOriginFinding(posture) : [],
2932
3316
  ...wants("email") ? emailPostureFindings(posture) : [],
2933
- ...wants("billing") ? await productionCatalogFindings(rootDir, productionBillsIn(posture)) : [],
2934
- ...wants("ai") ? aiSpendLimitFinding(rootDir, posture) : []
3317
+ ...wants("billing") ? await productionCatalogFindings(rootDir, productionBillsIn(posture), launch?.launched ?? true) : [],
3318
+ ...wants("ai") ? aiSpendLimitFinding(rootDir, posture) : [],
3319
+ ...wants("ai") ? aiGatewayBudgetFinding(rootDir, posture, { deployed, cloud }) : []
2935
3320
  ];
2936
3321
  }
2937
3322
  function aiSpendLimitFinding(rootDir, posture) {
@@ -2946,6 +3331,45 @@ function aiSpendLimitFinding(rootDir, posture) {
2946
3331
  "Pass `spendLimit: { usdPerDay }` to setupAi in backend/ai.ts: once a UTC day costs that much, pause_ai turns on until the day ends."
2947
3332
  )];
2948
3333
  }
3334
+ const GATEWAY_CAP = {
3335
+ convex: {
3336
+ name: "the Convex AI Gateway",
3337
+ cap: "the team's spending limit, on its billing page",
3338
+ fix: "For the Convex AI Gateway, set the team's spending limit on its billing page in the Convex dashboard."
3339
+ },
3340
+ vercel: {
3341
+ name: "the Vercel AI Gateway",
3342
+ cap: "a budget on its key, the project or the team",
3343
+ fix: "For the Vercel AI Gateway: `vercel ai-gateway budgets set api-key <the key production holds> --amount <dollars> --refresh-period monthly`."
3344
+ }
3345
+ };
3346
+ function productionGateways(rootDir, deployed, cloud) {
3347
+ const models = namedModels(rootDir);
3348
+ const order = chosenGateways(rootDir);
3349
+ const routes = chosenRoutes(rootDir);
3350
+ if (models.length === 0 || order === "unread" || routes === "unread") return [];
3351
+ const keyed = deployed.includes("AI_GATEWAY_API_KEY");
3352
+ if (pinnedRegion(rootDir) !== void 0) return keyed ? ["vercel"] : [];
3353
+ const facts = { keyed, convex: cloud && convexGatewayProviderInstalled(rootDir) };
3354
+ const answering = routedGroups(models, order ?? ["convex", "vercel"], routes).map((group) => answeringGateway(group.order, facts));
3355
+ return [...new Set(answering.filter((gateway) => gateway !== void 0))];
3356
+ }
3357
+ function aiGatewayBudgetFinding(rootDir, posture, { deployed, cloud }) {
3358
+ if (posture.environment === "sandbox") return [];
3359
+ const { setupAi, spendLimit } = aiFeatures(rootDir);
3360
+ const gateways = setupAi ? productionGateways(rootDir, deployed, cloud) : [];
3361
+ if (gateways.length === 0) return [];
3362
+ const through = `Production's model calls go through ${gateways.map((gateway) => GATEWAY_CAP[gateway].name).join(" and ")}`;
3363
+ const unchecked = `Not checked: ${gateways.map((gateway) => `${GATEWAY_CAP[gateway].name}'s own cap, ${GATEWAY_CAP[gateway].cap}`).join("; ")}, as doctor reads no account of ${gateways.length === 1 ? "it" : "theirs"}.`;
3364
+ const fixes = gateways.map((gateway) => GATEWAY_CAP[gateway].fix).join(" ");
3365
+ if (spendLimit) return [finding("ai-gateway-budget", "pass", `${through}, and setupAi's daily spendLimit pauses AI once a UTC day's spend reaches it. ${unchecked}`, fixes)];
3366
+ return [finding(
3367
+ "ai-gateway-budget",
3368
+ "warn",
3369
+ `${through}, and setupAi sets no spendLimit: nothing doctor can read caps what they cost in dollars. ${unchecked}`,
3370
+ `Pass \`spendLimit: { usdPerDay }\` to setupAi in backend/ai.ts: once a UTC day costs that much, AI pauses itself until the day ends. And cap the gateway: ${fixes}`
3371
+ )];
3372
+ }
2949
3373
  async function scaffoldFindings(rootDir, appConfig) {
2950
3374
  return [
2951
3375
  ...await generatedFileFindings(rootDir, appConfig),
@@ -2962,7 +3386,7 @@ async function localFeatureFindings(rootDir, { env, wants, deployed, prod, appCo
2962
3386
  ...wants("monitoring") ? monitoringFindings(rootDir, { env, deployed, prod }) : [],
2963
3387
  ...declaredFeatureFindings(rootDir, { wants, deployed, prod }),
2964
3388
  // Production's own usage warnings: Convex emails the team; the deployment cannot read its usage itself.
2965
- ...wants("monitoring") && prod ? [usageAlertsFinding(await readUsageLimits(rootDir), { convexGateway: convexGatewayProviderInstalled(rootDir) })] : [],
3389
+ ...wants("monitoring") && prod ? [usageAlertsFinding(await readUsageLimits(rootDir), { convexGateway: convexGatewayProviderInstalled(rootDir) && (namesConvex(chosenGateways(rootDir)) || routesNameConvex(chosenRoutes(rootDir))) })] : [],
2966
3390
  ...wants("auth") ? await consentFindings(rootDir, { prod }) : [],
2967
3391
  // The installable app iPhone and iPad take web push from: the brand and the two icons.
2968
3392
  ...await installableFindings(rootDir, appConfig, { wanted: wants("notifications"), pushKeys: Boolean(env.PUSH_PUBLIC_KEY) || (deployed ?? []).includes("PUSH_PUBLIC_KEY") })
@@ -2974,16 +3398,19 @@ async function runDoctorChecks(rootDir, { prod, only, deployedNames, posture: gi
2974
3398
  const env = { ...readEnvFiles(rootDir), ...process.env };
2975
3399
  const appConfig = appConfigLoader(rootDir);
2976
3400
  const siteUrl = resolveSiteUrl({ env, derived: deriveDeploymentUrls(rootDir, env) });
2977
- const [{ deployed, surface, posture }, catalog, metrics] = await Promise.all([
3401
+ const namesRead = deployedNames !== void 0 ? Promise.resolve(deployedNames) : deploymentEnvNames(rootDir, { prod });
3402
+ const [{ deployed, surface, posture, launch }, catalog, metrics] = await Promise.all([
2978
3403
  (async () => {
2979
- const names = deployedNames !== void 0 ? deployedNames : await deploymentEnvNames(rootDir, { prod });
3404
+ const names = await namesRead;
2980
3405
  const posture2 = given ?? (prod && names ? readProductionPosture(rootDir, names, wants) : Promise.resolve(null));
2981
3406
  const [surface2, defaults, read] = await Promise.all([
2982
3407
  deployedSurfaceFindings(rootDir, { prod, deployed: names, env, local: !prod && isLocalDeploymentId(configuredDeployment(rootDir)), siteUrl, wants, posture: posture2, appConfig }),
2983
3408
  names !== null && !prod && wants("deployment") ? envDefaultsFindings(rootDir) : [],
2984
3409
  posture2
2985
3410
  ]);
2986
- return { deployed: names, surface: [...surface2, ...defaults, ...await productionPostureFindings(rootDir, read, wants)], posture: read };
3411
+ const launch2 = read && wants("billing") && productionBillsIn(read) === "production" ? await productionBillingLaunch(rootDir, names ?? []) : null;
3412
+ const cloud = deploymentRoute(computeDeployment(rootDir, env).kind, true).cloud;
3413
+ return { deployed: names, surface: [...surface2, ...defaults, ...await productionPostureFindings(rootDir, read, wants, { launch: launch2, deployed: names ?? [], cloud })], posture: read, launch: launch2 };
2987
3414
  })(),
2988
3415
  // Billing catalog cross-checks: what backend/billing.catalog.ts declares
2989
3416
  // against the organization's own subscription + portal settings. Every
@@ -2991,7 +3418,7 @@ async function runDoctorChecks(rootDir, { prod, only, deployedNames, posture: gi
2991
3418
  // provider, only the catalog-only checks (see collectBillingFindings).
2992
3419
  // Local files and the provider only, so they run beside the deployment
2993
3420
  // reads.
2994
- wants("billing") ? billingCatalogFindings(rootDir, env) : [],
3421
+ wants("billing") ? billingCatalogFindings(rootDir, env, { deployed: namesRead, prod }) : [],
2995
3422
  // The funnel's activation kind, recorded by a backend file; then the
2996
3423
  // Revenue view's metrics read, with the token visible here (analytics).
2997
3424
  wants("analytics") ? Promise.resolve(activationFindings(rootDir)) : [],
@@ -3011,7 +3438,11 @@ async function runDoctorChecks(rootDir, { prod, only, deployedNames, posture: gi
3011
3438
  ...catalog,
3012
3439
  ...metrics
3013
3440
  ].filter((reported) => wantsCapability(reported.capability));
3014
- return prod ? applyProductionPosture(findings, posture ? /* @__PURE__ */ new Set(["deployment-backend-environment"]) : void 0) : findings;
3441
+ return prod ? productionFindings(findings, { posture, launch }) : findings;
3442
+ }
3443
+ function productionFindings(findings, { posture, launch }) {
3444
+ const launched = launch ? withBillingLaunch(findings, launch) : { findings, settled: [] };
3445
+ return applyProductionPosture(launched.findings, /* @__PURE__ */ new Set([...posture ? ["deployment-backend-environment"] : [], ...launched.settled]));
3015
3446
  }
3016
3447
 
3017
3448
  const doctor = {
@@ -3021,4 +3452,4 @@ const doctor = {
3021
3452
  runDoctorChecks: runDoctorChecks
3022
3453
  };
3023
3454
 
3024
- export { email as $, findPlanProduct as A, isUntaggedPlanProduct as B, planCreditUnits as C, planQuotasBenefits as D, providerTrialOf as E, pushPlanTrial as F, attachPlanQuotas as G, isFreePlan as H, BILLING_WEBHOOK_PROVISION_EVENTS as I, planProductKey as J, recordPlanProduct as K, loadGenerated as L, MANAGED_BY as M, renderGenerated as N, probeWebhookRoute as O, PROVIDER_COMPONENT as P, runEmailSync as Q, planSettingChanges as R, planEndpointChanges as S, applyProviderChanges as T, billingProviderTarget as U, providerClient as V, readProviderOrganization as W, readProviderEndpoint as X, emailSyncRefusal as Y, runDoctorChecks as Z, readProductionPosture as _, refuseInvalidPrices as a, runEnvDefaults as a0, bootstrapAdmin as a1, runEmailSyncCommand as a2, ENV_DEFAULT_TYPES as a3, REQUIRED_FUNCTION_EXPORTS as a4, doctor as a5, refuseInvalidGifts as b, refuseInvalidQuotas as c, refuseInvalidDiscounts as d, listAllPages as e, freePlanOf as f, refuseMissingDefaultCurrency as g, refuseUnpricedDiscounts as h, isManaged as i, ensurePlanQuotas as j, retirePlan as k, loadCatalog as l, attachRetiredPlanQuotas as m, recordQuotaKeys as n, packPricesByCurrency as o, pricedIntervals as p, syncDiscounts as q, refuseUnpricedPlans as r, syncPassProducts as s, planQuotasKeys as t, derivedPassKeys as u, droppedQuotasKeys as v, unpricedPlanProducts as w, providerClientOptions as x, planQuotasKey as y, planPricesByCurrency as z };
3455
+ export { emailSyncRefusal as $, planQuotasKey as A, planPricesByCurrency as B, findPlanProduct as C, isUntaggedPlanProduct as D, planCreditUnits as E, planQuotasBenefits as F, isFreePlan as G, zeroPrices as H, providerTrialOf as I, pushPlanTrial as J, attachPlanQuotas as K, BILLING_WEBHOOK_PROVISION_EVENTS as L, MANAGED_BY as M, planProductKey as N, recordPlanProduct as O, PROVIDER_COMPONENT as P, loadGenerated as Q, renderGenerated as R, probeWebhookRoute as S, runEmailSync as T, planSettingChanges as U, planEndpointChanges as V, applyProviderChanges as W, billingProviderTarget as X, providerClient as Y, readProviderOrganization as Z, readProviderEndpoint as _, refuseInvalidPrices as a, ADMISSION_DAYS as a0, CLI_ADMISSION_LABEL as a1, admitInputRefusal as a2, admitRefused as a3, admitCleaned as a4, runDoctorChecks as a5, readProductionPosture as a6, email as a7, runEnvDefaults as a8, bootstrapAdmin as a9, runEmailSyncCommand as aa, ENV_DEFAULT_TYPES as ab, REQUIRED_FUNCTION_EXPORTS as ac, doctor as ad, refuseOnceCredits as b, refuseInvalidGifts as c, refuseInvalidQuotas as d, refuseInvalidDiscounts as e, freePlanOf as f, listAllPages as g, refuseMissingDefaultCurrency as h, isManaged as i, refuseMissingOrganizationCurrency as j, refuseUnpricedDiscounts as k, loadCatalog as l, ensurePlanQuotas as m, retirePlan as n, attachRetiredPlanQuotas as o, pricedIntervals as p, recordQuotaKeys as q, refuseUnpricedPlans as r, packPricesByCurrency as s, syncPassProducts as t, syncDiscounts as u, planQuotasKeys as v, derivedPassKeys as w, droppedQuotasKeys as x, unpricedPlanProducts as y, providerClientOptions as z };