nuxt-backend 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/dist/chunks/catalog.mjs +1 -1
  2. package/dist/chunks/doctor.mjs +71 -12
  3. package/dist/chunks/email-previews.mjs +1 -1
  4. package/dist/chunks/health.mjs +2 -2
  5. package/dist/chunks/index.mjs +3 -3
  6. package/dist/chunks/install.mjs +4 -4
  7. package/dist/chunks/run.mjs +1 -1
  8. package/dist/chunks/server.mjs +7 -5
  9. package/dist/cli.mjs +122 -23
  10. package/dist/convex/account-data.d.ts +0 -2
  11. package/dist/convex/account-data.d.ts.map +1 -1
  12. package/dist/convex/account-data.js +0 -4
  13. package/dist/convex/account-data.js.map +1 -1
  14. package/dist/convex/catalog.d.ts +22 -0
  15. package/dist/convex/catalog.d.ts.map +1 -1
  16. package/dist/convex/catalog.js.map +1 -1
  17. package/dist/convex/client/better-auth-options.d.ts.map +1 -1
  18. package/dist/convex/client/better-auth-options.js +11 -1
  19. package/dist/convex/client/better-auth-options.js.map +1 -1
  20. package/dist/convex/client/client-address.d.ts +21 -0
  21. package/dist/convex/client/client-address.d.ts.map +1 -0
  22. package/dist/convex/client/client-address.js +37 -0
  23. package/dist/convex/client/client-address.js.map +1 -0
  24. package/dist/convex/client/index.d.ts +34 -2
  25. package/dist/convex/client/index.d.ts.map +1 -1
  26. package/dist/convex/components/backend/_generated/component.d.ts +6 -0
  27. package/dist/convex/components/backend/_generated/component.d.ts.map +1 -1
  28. package/dist/convex/components/backend/account.d.ts +6 -6
  29. package/dist/convex/components/backend/account.d.ts.map +1 -1
  30. package/dist/convex/components/backend/account.js +6 -2
  31. package/dist/convex/components/backend/account.js.map +1 -1
  32. package/dist/convex/components/backend/adapter.d.ts.map +1 -1
  33. package/dist/convex/components/backend/adapter.js +4 -1
  34. package/dist/convex/components/backend/adapter.js.map +1 -1
  35. package/dist/convex/components/backend/ai.d.ts +11 -3
  36. package/dist/convex/components/backend/ai.d.ts.map +1 -1
  37. package/dist/convex/components/backend/ai.js +18 -52
  38. package/dist/convex/components/backend/ai.js.map +1 -1
  39. package/dist/convex/components/backend/billing.d.ts.map +1 -1
  40. package/dist/convex/components/backend/billing.js +12 -32
  41. package/dist/convex/components/backend/billing.js.map +1 -1
  42. package/dist/convex/components/backend/consents.d.ts.map +1 -1
  43. package/dist/convex/components/backend/consents.js +2 -1
  44. package/dist/convex/components/backend/consents.js.map +1 -1
  45. package/dist/convex/components/backend/gifts.d.ts +1 -1
  46. package/dist/convex/components/backend/gifts.d.ts.map +1 -1
  47. package/dist/convex/components/backend/gifts.js +9 -4
  48. package/dist/convex/components/backend/gifts.js.map +1 -1
  49. package/dist/convex/components/backend/lifecycle.d.ts.map +1 -1
  50. package/dist/convex/components/backend/lifecycle.js +18 -14
  51. package/dist/convex/components/backend/lifecycle.js.map +1 -1
  52. package/dist/convex/components/backend/notifications.d.ts +13 -0
  53. package/dist/convex/components/backend/notifications.d.ts.map +1 -1
  54. package/dist/convex/components/backend/notifications.js +21 -0
  55. package/dist/convex/components/backend/notifications.js.map +1 -1
  56. package/dist/convex/components/backend/referrals.d.ts.map +1 -1
  57. package/dist/convex/components/backend/referrals.js +13 -16
  58. package/dist/convex/components/backend/referrals.js.map +1 -1
  59. package/dist/convex/components/backend/reports.js +7 -7
  60. package/dist/convex/components/backend/reports.js.map +1 -1
  61. package/dist/convex/components/backend/schema.d.ts +151 -35
  62. package/dist/convex/components/backend/schema.d.ts.map +1 -1
  63. package/dist/convex/components/backend/schema.js +127 -153
  64. package/dist/convex/components/backend/schema.js.map +1 -1
  65. package/dist/convex/components/backend/storage.d.ts.map +1 -1
  66. package/dist/convex/components/backend/storage.js +10 -10
  67. package/dist/convex/components/backend/storage.js.map +1 -1
  68. package/dist/convex/components/backend/subscriptions.d.ts +3 -3
  69. package/dist/convex/components/backend/subscriptions.d.ts.map +1 -1
  70. package/dist/convex/components/backend/subscriptions.js +6 -35
  71. package/dist/convex/components/backend/subscriptions.js.map +1 -1
  72. package/dist/convex/components/backend/waitlist.d.ts +1 -1
  73. package/dist/convex/components/backend/webhooks.d.ts +0 -1
  74. package/dist/convex/components/backend/webhooks.d.ts.map +1 -1
  75. package/dist/convex/components/backend/webhooks.js +1 -1
  76. package/dist/convex/components/backend/webhooks.js.map +1 -1
  77. package/dist/convex/consent-rules.d.ts +0 -2
  78. package/dist/convex/consent-rules.d.ts.map +1 -1
  79. package/dist/convex/consent-rules.js.map +1 -1
  80. package/dist/convex/constants.d.ts +0 -1
  81. package/dist/convex/constants.d.ts.map +1 -1
  82. package/dist/convex/constants.js +0 -1
  83. package/dist/convex/constants.js.map +1 -1
  84. package/dist/convex/email-templates.d.ts +0 -1
  85. package/dist/convex/email-templates.d.ts.map +1 -1
  86. package/dist/convex/email-templates.js +0 -1
  87. package/dist/convex/email-templates.js.map +1 -1
  88. package/dist/convex/integrations/admin.d.ts +2 -1
  89. package/dist/convex/integrations/admin.d.ts.map +1 -1
  90. package/dist/convex/integrations/admin.js.map +1 -1
  91. package/dist/convex/integrations/ai/job-errors.d.ts +7 -0
  92. package/dist/convex/integrations/ai/job-errors.d.ts.map +1 -1
  93. package/dist/convex/integrations/ai/job-errors.js +22 -0
  94. package/dist/convex/integrations/ai/job-errors.js.map +1 -1
  95. package/dist/convex/integrations/ai/metering.d.ts +12 -0
  96. package/dist/convex/integrations/ai/metering.d.ts.map +1 -1
  97. package/dist/convex/integrations/ai/metering.js +19 -10
  98. package/dist/convex/integrations/ai/metering.js.map +1 -1
  99. package/dist/convex/integrations/ai/models.d.ts.map +1 -1
  100. package/dist/convex/integrations/ai/models.js +3 -1
  101. package/dist/convex/integrations/ai/models.js.map +1 -1
  102. package/dist/convex/integrations/ai/moderation.d.ts +2 -0
  103. package/dist/convex/integrations/ai/moderation.d.ts.map +1 -1
  104. package/dist/convex/integrations/ai/moderation.js +29 -2
  105. package/dist/convex/integrations/ai/moderation.js.map +1 -1
  106. package/dist/convex/integrations/ai/stream.d.ts +1 -1
  107. package/dist/convex/integrations/ai/stream.d.ts.map +1 -1
  108. package/dist/convex/integrations/ai/stream.js +3 -11
  109. package/dist/convex/integrations/ai/stream.js.map +1 -1
  110. package/dist/convex/integrations/billing/context.d.ts +0 -1
  111. package/dist/convex/integrations/billing/context.d.ts.map +1 -1
  112. package/dist/convex/integrations/billing/context.js +1 -4
  113. package/dist/convex/integrations/billing/context.js.map +1 -1
  114. package/dist/convex/integrations/billing/credits.d.ts.map +1 -1
  115. package/dist/convex/integrations/billing/customers.d.ts.map +1 -1
  116. package/dist/convex/integrations/billing/customers.js +25 -5
  117. package/dist/convex/integrations/billing/customers.js.map +1 -1
  118. package/dist/convex/integrations/billing/features.d.ts.map +1 -1
  119. package/dist/convex/integrations/billing/free-plan.d.ts +1 -1
  120. package/dist/convex/integrations/billing/free-plan.d.ts.map +1 -1
  121. package/dist/convex/integrations/billing/free-plan.js +18 -4
  122. package/dist/convex/integrations/billing/free-plan.js.map +1 -1
  123. package/dist/convex/integrations/billing/functions.d.ts +5 -1
  124. package/dist/convex/integrations/billing/functions.d.ts.map +1 -1
  125. package/dist/convex/integrations/billing/functions.js +16 -5
  126. package/dist/convex/integrations/billing/functions.js.map +1 -1
  127. package/dist/convex/integrations/billing/gifts.d.ts.map +1 -1
  128. package/dist/convex/integrations/billing/gifts.js +2 -2
  129. package/dist/convex/integrations/billing/gifts.js.map +1 -1
  130. package/dist/convex/integrations/billing/history.d.ts.map +1 -1
  131. package/dist/convex/integrations/billing/history.js +3 -1
  132. package/dist/convex/integrations/billing/history.js.map +1 -1
  133. package/dist/convex/integrations/billing/lifecycle.d.ts +4 -1
  134. package/dist/convex/integrations/billing/lifecycle.d.ts.map +1 -1
  135. package/dist/convex/integrations/billing/lifecycle.js +33 -2
  136. package/dist/convex/integrations/billing/lifecycle.js.map +1 -1
  137. package/dist/convex/integrations/billing/passes.d.ts +0 -2
  138. package/dist/convex/integrations/billing/passes.d.ts.map +1 -1
  139. package/dist/convex/integrations/billing/passes.js +2 -3
  140. package/dist/convex/integrations/billing/passes.js.map +1 -1
  141. package/dist/convex/integrations/billing/pricing.d.ts +4 -1
  142. package/dist/convex/integrations/billing/pricing.d.ts.map +1 -1
  143. package/dist/convex/integrations/billing/pricing.js +11 -9
  144. package/dist/convex/integrations/billing/pricing.js.map +1 -1
  145. package/dist/convex/integrations/billing/purchase.d.ts.map +1 -1
  146. package/dist/convex/integrations/billing/purchase.js +1 -2
  147. package/dist/convex/integrations/billing/purchase.js.map +1 -1
  148. package/dist/convex/integrations/billing/quotas.d.ts.map +1 -1
  149. package/dist/convex/integrations/billing/subscriptions.d.ts.map +1 -1
  150. package/dist/convex/integrations/billing/types/lifecycle.d.ts +12 -0
  151. package/dist/convex/integrations/billing/types/lifecycle.d.ts.map +1 -1
  152. package/dist/convex/integrations/billing/types/options.d.ts +4 -1
  153. package/dist/convex/integrations/billing/types/options.d.ts.map +1 -1
  154. package/dist/convex/integrations/billing/types/records.d.ts +7 -1
  155. package/dist/convex/integrations/billing/types/records.d.ts.map +1 -1
  156. package/dist/convex/integrations/billing/types/surface.d.ts +5 -1
  157. package/dist/convex/integrations/billing/types/surface.d.ts.map +1 -1
  158. package/dist/convex/integrations/billing.d.ts +2 -2
  159. package/dist/convex/integrations/billing.d.ts.map +1 -1
  160. package/dist/convex/integrations/billing.js +1 -0
  161. package/dist/convex/integrations/billing.js.map +1 -1
  162. package/dist/convex/integrations/email-preferences.d.ts +1 -1
  163. package/dist/convex/integrations/email-preferences.d.ts.map +1 -1
  164. package/dist/convex/integrations/email-sync.d.ts.map +1 -1
  165. package/dist/convex/integrations/email-sync.js +43 -1
  166. package/dist/convex/integrations/email-sync.js.map +1 -1
  167. package/dist/convex/integrations/notifications.d.ts +24 -4
  168. package/dist/convex/integrations/notifications.d.ts.map +1 -1
  169. package/dist/convex/integrations/notifications.js +30 -14
  170. package/dist/convex/integrations/notifications.js.map +1 -1
  171. package/dist/convex/integrations/rate-limit.d.ts +6 -5
  172. package/dist/convex/integrations/rate-limit.d.ts.map +1 -1
  173. package/dist/convex/integrations/rate-limit.js +6 -5
  174. package/dist/convex/integrations/rate-limit.js.map +1 -1
  175. package/dist/convex/integrations/reports.d.ts +1 -1
  176. package/dist/convex/integrations/reports.d.ts.map +1 -1
  177. package/dist/convex/integrations/reports.js +0 -11
  178. package/dist/convex/integrations/reports.js.map +1 -1
  179. package/dist/convex/integrations/webhooks.d.ts +1 -3
  180. package/dist/convex/integrations/webhooks.d.ts.map +1 -1
  181. package/dist/convex/integrations/webhooks.js.map +1 -1
  182. package/dist/convex/label-groups/cancelFlow.d.ts +3 -0
  183. package/dist/convex/label-groups/cancelFlow.d.ts.map +1 -1
  184. package/dist/convex/label-groups/cancelFlow.js +5 -0
  185. package/dist/convex/label-groups/cancelFlow.js.map +1 -1
  186. package/dist/convex/label-groups/credits.d.ts +14 -1
  187. package/dist/convex/label-groups/credits.d.ts.map +1 -1
  188. package/dist/convex/label-groups/credits.js +17 -2
  189. package/dist/convex/label-groups/credits.js.map +1 -1
  190. package/dist/convex/label-groups/notifications.d.ts +19 -2
  191. package/dist/convex/label-groups/notifications.d.ts.map +1 -1
  192. package/dist/convex/label-groups/notifications.js +19 -15
  193. package/dist/convex/label-groups/notifications.js.map +1 -1
  194. package/dist/convex/label-groups/pricing.js +8 -8
  195. package/dist/convex/label-groups/pricing.js.map +1 -1
  196. package/dist/convex/label-groups/settings.d.ts.map +1 -1
  197. package/dist/convex/label-groups/settings.js +4 -3
  198. package/dist/convex/label-groups/settings.js.map +1 -1
  199. package/dist/convex/label-groups/usage.d.ts +1 -1
  200. package/dist/convex/label-groups/usage.d.ts.map +1 -1
  201. package/dist/convex/label-groups/usage.js +2 -2
  202. package/dist/convex/label-groups/usage.js.map +1 -1
  203. package/dist/convex/label-translations.d.ts.map +1 -1
  204. package/dist/convex/label-translations.js +52 -0
  205. package/dist/convex/label-translations.js.map +1 -1
  206. package/dist/convex/labels.d.ts +23 -0
  207. package/dist/convex/labels.d.ts.map +1 -1
  208. package/dist/convex/log.js +2 -0
  209. package/dist/convex/log.js.map +1 -1
  210. package/dist/convex/notifications.d.ts +77 -0
  211. package/dist/convex/notifications.d.ts.map +1 -1
  212. package/dist/convex/notifications.js +64 -13
  213. package/dist/convex/notifications.js.map +1 -1
  214. package/dist/convex/proof.d.ts +25 -0
  215. package/dist/convex/proof.d.ts.map +1 -1
  216. package/dist/convex/proof.js +39 -0
  217. package/dist/convex/proof.js.map +1 -1
  218. package/dist/convex/referral-rules.d.ts +0 -2
  219. package/dist/convex/referral-rules.d.ts.map +1 -1
  220. package/dist/convex/referral-rules.js +0 -2
  221. package/dist/convex/referral-rules.js.map +1 -1
  222. package/dist/convex/waitlist-rules.d.ts +1 -13
  223. package/dist/convex/waitlist-rules.d.ts.map +1 -1
  224. package/dist/convex/waitlist-rules.js +2 -14
  225. package/dist/convex/waitlist-rules.js.map +1 -1
  226. package/dist/devtools-client/index.html +1 -1
  227. package/dist/module.js +2 -2
  228. package/dist/module.json +1 -1
  229. package/dist/runtime/locales/de.json +47 -24
  230. package/dist/runtime/locales/en.json +47 -24
  231. package/dist/runtime/locales/es.json +47 -24
  232. package/dist/runtime/locales/fr.json +47 -24
  233. package/dist/runtime/locales/ru.json +47 -24
  234. package/dist/runtime/server/protection/gate.d.ts +4 -2
  235. package/dist/runtime/server/protection/gate.js +14 -4
  236. package/dist/runtime/vue/admin-client.d.ts +18 -0
  237. package/dist/runtime/vue/admin-client.js +32 -0
  238. package/dist/runtime/vue/auth-client.d.ts +16 -11
  239. package/dist/runtime/vue/auth-client.js +3 -1
  240. package/dist/runtime/vue/components/admin/AdminUsers.d.vue.ts +1 -1
  241. package/dist/runtime/vue/components/admin/AdminUsers.vue.d.ts +1 -1
  242. package/dist/runtime/vue/components/billing/BillingCheckoutLink.d.vue.ts +1 -1
  243. package/dist/runtime/vue/components/billing/BillingCheckoutLink.vue.d.ts +1 -1
  244. package/dist/runtime/vue/components/billing/CancelFlow.css +1 -1
  245. package/dist/runtime/vue/components/billing/CancelFlow.d.vue.ts +3 -0
  246. package/dist/runtime/vue/components/billing/CancelFlow.vue +10 -3
  247. package/dist/runtime/vue/components/billing/CancelFlow.vue.d.ts +3 -0
  248. package/dist/runtime/vue/components/billing/CancelFlowConfirm.d.vue.ts +3 -0
  249. package/dist/runtime/vue/components/billing/CancelFlowConfirm.vue +34 -0
  250. package/dist/runtime/vue/components/billing/CancelFlowConfirm.vue.d.ts +3 -0
  251. package/dist/runtime/vue/components/billing/CancelFlowQuestion.vue +2 -1
  252. package/dist/runtime/vue/components/billing/GiftSent.d.vue.ts +2 -2
  253. package/dist/runtime/vue/components/billing/GiftSent.vue.d.ts +2 -2
  254. package/dist/runtime/vue/components/billing/PricingPackCard.vue +6 -3
  255. package/dist/runtime/vue/components/billing/PricingPlanCard.vue +3 -1
  256. package/dist/runtime/vue/components/billing/PricingTable.d.vue.ts +2 -2
  257. package/dist/runtime/vue/components/billing/PricingTable.vue +3 -1
  258. package/dist/runtime/vue/components/billing/PricingTable.vue.d.ts +2 -2
  259. package/dist/runtime/vue/components/billing/UsageHistoryEvent.vue +3 -1
  260. package/dist/runtime/vue/components/billing/cancel-flow.d.ts +28 -7
  261. package/dist/runtime/vue/components/billing/cancel-flow.js +25 -2
  262. package/dist/runtime/vue/components/shell/NoticeLowCredits.vue +3 -1
  263. package/dist/runtime/vue/components/tokens.css +1 -1
  264. package/dist/runtime/vue/components/workspaces/WorkspaceCredits.vue +6 -3
  265. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
  266. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
  267. package/dist/runtime/vue/composables/use-auth.d.ts +13 -1
  268. package/dist/runtime/vue/composables/use-auth.js +4 -1
  269. package/dist/runtime/vue/composables/use-billing.d.ts +10 -2
  270. package/dist/runtime/vue/composables/use-credits.d.ts +3 -0
  271. package/dist/runtime/vue/composables/use-credits.js +1 -0
  272. package/dist/runtime/vue/composables/use-notifications.d.ts +5 -1
  273. package/dist/runtime/vue/composables/use-notifications.js +12 -4
  274. package/dist/runtime/vue/composables/use-webhook-log.d.ts +4 -2
  275. package/dist/runtime/vue/organization-client.d.ts +15 -0
  276. package/dist/runtime/vue/organization-client.js +65 -0
  277. package/dist/runtime/vue/parts.d.ts +2 -1
  278. package/dist/runtime/vue/plugins/checkout-return.d.ts +3 -2
  279. package/dist/runtime/vue/plugins/checkout-return.js +2 -4
  280. package/dist/runtime/vue/plugins/first-touch.js +2 -4
  281. package/dist/runtime/vue/utils/checkout-return.d.ts +9 -2
  282. package/dist/runtime/vue/utils/checkout-return.js +2 -1
  283. package/dist/runtime/vue/utils/every-page.d.ts +10 -0
  284. package/dist/runtime/vue/utils/every-page.js +6 -0
  285. package/dist/runtime/vue/utils/meter-unit.d.ts +14 -0
  286. package/dist/runtime/vue/utils/meter-unit.js +18 -0
  287. package/dist/shared/{nuxt-backend.2YoiKo8j.mjs → nuxt-backend.2m535CLS.mjs} +6 -2
  288. package/dist/shared/{nuxt-backend.CPq101Wi.mjs → nuxt-backend.DXEf0rrv.mjs} +1 -1
  289. package/dist/shared/{nuxt-backend.-uB5CGw-.mjs → nuxt-backend.Dm1NkY7v.mjs} +1 -1
  290. package/dist/shared/{nuxt-backend.OQMX-0U7.mjs → nuxt-backend.KEzfHO2K.mjs} +6 -3
  291. package/dist/shared/{nuxt-backend.S5C2b-4I.mjs → nuxt-backend.ikObmtHs.mjs} +2 -2
  292. package/package.json +2 -2
  293. package/skills/nuxt-backend/references/api.md +13 -3
  294. package/skills/nuxt-backend/references/surface.json +12 -0
  295. package/skills/nuxt-backend-auth/SKILL.md +2 -1
  296. package/skills/nuxt-backend-billing/SKILL.md +7 -0
  297. package/skills/nuxt-backend-billing/references/api.md +12 -2
  298. package/skills/nuxt-backend-data/SKILL.md +4 -1
  299. package/skills/nuxt-backend-email/SKILL.md +4 -0
  300. package/skills/nuxt-backend-email/references/api.md +1 -1
  301. package/skills/nuxt-backend-ui/SKILL.md +6 -5
  302. package/src/convex/account-data.ts +0 -5
  303. package/src/convex/catalog.ts +23 -0
  304. package/src/convex/client/better-auth-options.ts +11 -1
  305. package/src/convex/client/client-address.ts +37 -0
  306. package/src/convex/components/backend/_generated/component.ts +12 -0
  307. package/src/convex/components/backend/account.ts +7 -2
  308. package/src/convex/components/backend/adapter.ts +4 -1
  309. package/src/convex/components/backend/ai.ts +20 -54
  310. package/src/convex/components/backend/billing.ts +14 -33
  311. package/src/convex/components/backend/consents.ts +2 -1
  312. package/src/convex/components/backend/gifts.ts +11 -5
  313. package/src/convex/components/backend/lifecycle.ts +17 -12
  314. package/src/convex/components/backend/notifications.ts +22 -0
  315. package/src/convex/components/backend/referrals.ts +14 -16
  316. package/src/convex/components/backend/reports.ts +7 -7
  317. package/src/convex/components/backend/schema.ts +143 -161
  318. package/src/convex/components/backend/storage.ts +11 -10
  319. package/src/convex/components/backend/subscriptions.ts +7 -35
  320. package/src/convex/components/backend/webhooks.ts +1 -10
  321. package/src/convex/consent-rules.ts +0 -3
  322. package/src/convex/constants.ts +0 -1
  323. package/src/convex/email-templates.ts +0 -1
  324. package/src/convex/integrations/admin.ts +2 -1
  325. package/src/convex/integrations/ai/job-errors.ts +21 -0
  326. package/src/convex/integrations/ai/metering.ts +24 -10
  327. package/src/convex/integrations/ai/models.ts +3 -1
  328. package/src/convex/integrations/ai/moderation.ts +31 -2
  329. package/src/convex/integrations/ai/stream.ts +3 -11
  330. package/src/convex/integrations/billing/context.ts +1 -9
  331. package/src/convex/integrations/billing/customers.ts +28 -5
  332. package/src/convex/integrations/billing/free-plan.ts +20 -5
  333. package/src/convex/integrations/billing/functions.ts +17 -5
  334. package/src/convex/integrations/billing/gifts.ts +2 -2
  335. package/src/convex/integrations/billing/history.ts +2 -1
  336. package/src/convex/integrations/billing/lifecycle.ts +30 -3
  337. package/src/convex/integrations/billing/passes.ts +2 -4
  338. package/src/convex/integrations/billing/pricing.ts +14 -10
  339. package/src/convex/integrations/billing/purchase.ts +1 -2
  340. package/src/convex/integrations/billing/types/lifecycle.ts +13 -0
  341. package/src/convex/integrations/billing/types/options.ts +4 -1
  342. package/src/convex/integrations/billing/types/records.ts +7 -1
  343. package/src/convex/integrations/billing/types/surface.ts +3 -1
  344. package/src/convex/integrations/billing.ts +3 -2
  345. package/src/convex/integrations/email-preferences.ts +1 -1
  346. package/src/convex/integrations/email-sync.ts +44 -1
  347. package/src/convex/integrations/notifications.ts +65 -16
  348. package/src/convex/integrations/rate-limit.ts +6 -5
  349. package/src/convex/integrations/reports.ts +1 -1
  350. package/src/convex/integrations/webhooks.ts +1 -4
  351. package/src/convex/label-groups/cancelFlow.ts +5 -0
  352. package/src/convex/label-groups/credits.ts +17 -2
  353. package/src/convex/label-groups/notifications.ts +19 -15
  354. package/src/convex/label-groups/pricing.ts +8 -8
  355. package/src/convex/label-groups/settings.ts +4 -3
  356. package/src/convex/label-groups/usage.ts +2 -2
  357. package/src/convex/label-translations.ts +52 -0
  358. package/src/convex/log.ts +2 -0
  359. package/src/convex/notifications.ts +99 -13
  360. package/src/convex/proof.ts +43 -0
  361. package/src/convex/referral-rules.ts +0 -2
  362. package/src/convex/waitlist-rules.ts +2 -22
  363. package/src/runtime/vue/components/billing/CancelFlow.css +16 -0
  364. package/src/runtime/vue/components/billing/CancelFlow.vue +16 -6
  365. package/src/runtime/vue/components/billing/CancelFlowConfirm.vue +35 -0
  366. package/src/runtime/vue/components/billing/CancelFlowQuestion.vue +8 -2
  367. package/src/runtime/vue/components/billing/PricingPackCard.vue +6 -3
  368. package/src/runtime/vue/components/billing/PricingPlanCard.vue +3 -1
  369. package/src/runtime/vue/components/billing/PricingTable.vue +3 -1
  370. package/src/runtime/vue/components/billing/UsageHistoryEvent.vue +3 -1
  371. package/src/runtime/vue/components/shell/NoticeLowCredits.vue +3 -1
  372. package/src/runtime/vue/components/tokens.css +19 -15
  373. package/src/runtime/vue/components/workspaces/WorkspaceCredits.vue +6 -3
@@ -0,0 +1,34 @@
1
+ <script setup>
2
+ defineOptions({ name: "CancelFlowConfirm" });
3
+ const props = defineProps({
4
+ flow: { type: Object, required: true }
5
+ });
6
+ const { t } = props.flow.labels;
7
+ </script>
8
+
9
+ <template>
10
+ <div
11
+ data-cancel-flow="confirm"
12
+ role="group"
13
+ :aria-labelledby="flow.id('title')"
14
+ >
15
+ <p data-cancel-flow="confirm-ends">
16
+ {{ t("confirmEnds") }}
17
+ </p>
18
+ <button
19
+ data-cancel-flow="confirm-cancel"
20
+ type="button"
21
+ v-bind="flow.busy('cancel')"
22
+ @click="flow.cancelNow()"
23
+ >
24
+ {{ flow.running.value === "cancel" ? t("canceling") : t("confirmCancel") }}
25
+ </button>
26
+ <button
27
+ data-cancel-flow="back"
28
+ type="button"
29
+ @click="flow.back()"
30
+ >
31
+ {{ t("back") }}
32
+ </button>
33
+ </div>
34
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<import("../../parts.js").CancelFlowPartProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../../parts.js").CancelFlowPartProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -43,9 +43,10 @@ const { t } = props.flow.labels;
43
43
  <button
44
44
  data-cancel-flow="continue"
45
45
  type="submit"
46
+ :data-intent="flow.offers.value ? void 0 : 'cancel'"
46
47
  v-bind="flow.busy('continue')"
47
48
  >
48
- {{ flow.running.value === "continue" ? t("canceling") : t("continue") }}
49
+ {{ flow.running.value === "continue" ? t("canceling") : flow.offers.value ? t("continue") : t("cancel") }}
49
50
  </button>
50
51
  </form>
51
52
  </template>
@@ -17,11 +17,11 @@ type __VLS_Props = {
17
17
  t: UseLabelsReturn<'gift'>['t'];
18
18
  };
19
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
- resend: () => any;
21
20
  cancel: () => any;
21
+ resend: () => any;
22
22
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
23
- onResend?: (() => any) | undefined;
24
23
  onCancel?: (() => any) | undefined;
24
+ onResend?: (() => any) | undefined;
25
25
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
26
  declare const _default: typeof __VLS_export;
27
27
  export default _default;
@@ -17,11 +17,11 @@ type __VLS_Props = {
17
17
  t: UseLabelsReturn<'gift'>['t'];
18
18
  };
19
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
- resend: () => any;
21
20
  cancel: () => any;
21
+ resend: () => any;
22
22
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
23
- onResend?: (() => any) | undefined;
24
23
  onCancel?: (() => any) | undefined;
24
+ onResend?: (() => any) | undefined;
25
25
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
26
  declare const _default: typeof __VLS_export;
27
27
  export default _default;
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { busyAttributes } from "../../a11y";
4
+ import { useMeterUnit } from "../../utils/meter-unit";
4
5
  import { usePricingView } from "./pricing-table";
5
6
  import PricingPromotion from "./PricingPromotion.vue";
6
7
  defineOptions({ name: "PricingPackCard" });
@@ -13,6 +14,8 @@ const { t } = view.labels;
13
14
  const nameId = computed(() => view.nameId("pack", props.pack.key));
14
15
  const busy = computed(() => props.pricing.pending.value === props.pack.key);
15
16
  const promotion = computed(() => view.packPromotion(props.pack));
17
+ const unit = useMeterUnit();
18
+ const meterUnit = computed(() => props.pack.offer.credits?.unit);
16
19
  </script>
17
20
 
18
21
  <template>
@@ -42,16 +45,16 @@ const promotion = computed(() => view.packPromotion(props.pack));
42
45
  v-if="pack.credits !== void 0"
43
46
  data-pricing="pack-credits"
44
47
  >
45
- {{ t("packCredits", { count: pack.credits }) }}
48
+ {{ t("packCredits", { count: pack.credits, unit: unit.word(meterUnit, pack.credits) }) }}
46
49
  </p>
47
50
  <p
48
51
  v-if="pack.perCredit !== void 0"
49
52
  data-pricing="pack-per-credit"
50
53
  >
51
- {{ t("perCredit", { price: pack.perCredit }) }}<span
54
+ {{ t("perCredit", { price: pack.perCredit, unit: unit.word(meterUnit, 1) }) }}<span
52
55
  v-if="pack.lessPerCredit !== void 0"
53
56
  data-pricing="pack-saving"
54
- >{{ t("lessPerCredit", { percent: pack.lessPerCredit }) }}</span>
57
+ >{{ t("lessPerCredit", { percent: pack.lessPerCredit, unit: unit.word(meterUnit, 1) }) }}</span>
55
58
  </p>
56
59
  <p
57
60
  v-if="pack.blurb"
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { busyAttributes } from "../../a11y";
4
+ import { useMeterUnit } from "../../utils/meter-unit";
4
5
  import { VNodes } from "../../utils/vnodes";
5
6
  import { usePricingView } from "./pricing-table";
6
7
  import PricingPromotion from "./PricingPromotion.vue";
@@ -17,6 +18,7 @@ const busy = computed(() => props.pricing.pending.value === props.plan.key);
17
18
  const canceling = computed(() => props.plan.isCurrentPrice && view.context.value.billing.cancelAtPeriodEnd.value);
18
19
  const period = computed(() => t(`period.${props.plan.interval}`));
19
20
  const promotion = computed(() => view.planPromotion(props.plan));
21
+ const unit = useMeterUnit();
20
22
  </script>
21
23
 
22
24
  <template>
@@ -78,7 +80,7 @@ const promotion = computed(() => view.planPromotion(props.plan));
78
80
  data-pricing="plan-feature"
79
81
  data-feature="credits"
80
82
  >
81
- {{ t(`credits.${plan.interval}`, { count: plan.credits.units }) }}
83
+ {{ t(`credits.${plan.interval}`, { count: plan.credits.units, unit: unit.word(plan.credits.unit, plan.credits.units) }) }}
82
84
  </li>
83
85
  <li
84
86
  v-for="feature in plan.features ?? []"
@@ -41,18 +41,18 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
41
41
  error: (_message: string) => void;
42
42
  canceled: () => void;
43
43
  checkout: (_url: string) => void;
44
- "topped-up": (_key: string) => void;
45
44
  "update:interval": (_interval: import("../../../../convex/catalog.js").CatalogInterval) => void;
46
45
  "plan-changed": (_key: string) => void;
47
46
  uncanceled: () => void;
47
+ "topped-up": (_key: string) => void;
48
48
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
49
49
  onError?: ((_message: string) => any) | undefined;
50
50
  onCanceled?: (() => any) | undefined;
51
51
  onCheckout?: ((_url: string) => any) | undefined;
52
- "onTopped-up"?: ((_key: string) => any) | undefined;
53
52
  "onUpdate:interval"?: ((_interval: import("../../../../convex/catalog.js").CatalogInterval) => any) | undefined;
54
53
  "onPlan-changed"?: ((_key: string) => any) | undefined;
55
54
  onUncanceled?: (() => any) | undefined;
55
+ "onTopped-up"?: ((_key: string) => any) | undefined;
56
56
  }>, {
57
57
  redirect: boolean;
58
58
  title: string;
@@ -15,6 +15,7 @@ import { useAuthSession } from "../../utils/auth-session";
15
15
  import { getBackendError } from "../../utils/backend-error";
16
16
  import { createCancelConfirm } from "../../utils/cancel-confirm";
17
17
  import { returnFocus } from "../../utils/focus-return";
18
+ import { useMeterUnit } from "../../utils/meter-unit";
18
19
  import { pricingBindings, shownInterval } from "../../utils/pricing-bindings";
19
20
  import { providePricingView } from "./pricing-table";
20
21
  defineOptions({ name: "PricingTable" });
@@ -51,6 +52,7 @@ const { isAuthenticated } = useAuthSession();
51
52
  const config = useBackendConfig();
52
53
  const labels = useLabels("pricing", () => props.labels);
53
54
  const { t, locale } = labels;
55
+ const unit = useMeterUnit();
54
56
  const login = useBackendPagePath("login");
55
57
  const uid = useId();
56
58
  const pending = ref(null);
@@ -469,7 +471,7 @@ const statusText = computed(() => progress.value?.() ?? (billing.isFinishingChec
469
471
  data-pricing="managed"
470
472
  role="note"
471
473
  >
472
- {{ t("managed") }}
474
+ {{ t("managed", { unit: unit.word(credits.unit.value ?? resolvedPacks[0]?.offer.credits?.unit) }) }}
473
475
  </p>
474
476
  <template v-if="showPacks && resolvedPacks.length > 0">
475
477
  <slot
@@ -41,18 +41,18 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
41
41
  error: (_message: string) => void;
42
42
  canceled: () => void;
43
43
  checkout: (_url: string) => void;
44
- "topped-up": (_key: string) => void;
45
44
  "update:interval": (_interval: import("../../../../convex/catalog.js").CatalogInterval) => void;
46
45
  "plan-changed": (_key: string) => void;
47
46
  uncanceled: () => void;
47
+ "topped-up": (_key: string) => void;
48
48
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
49
49
  onError?: ((_message: string) => any) | undefined;
50
50
  onCanceled?: (() => any) | undefined;
51
51
  onCheckout?: ((_url: string) => any) | undefined;
52
- "onTopped-up"?: ((_key: string) => any) | undefined;
53
52
  "onUpdate:interval"?: ((_interval: import("../../../../convex/catalog.js").CatalogInterval) => any) | undefined;
54
53
  "onPlan-changed"?: ((_key: string) => any) | undefined;
55
54
  onUncanceled?: (() => any) | undefined;
55
+ "onTopped-up"?: ((_key: string) => any) | undefined;
56
56
  }>, {
57
57
  redirect: boolean;
58
58
  title: string;
@@ -1,12 +1,14 @@
1
1
  <script setup>
2
2
  import { formatBillingDate } from "../../composables/billing-format";
3
3
  import { useLabels } from "../../composables/use-labels";
4
+ import { useMeterUnit } from "../../utils/meter-unit";
4
5
  import { useUsageLabels } from "./usage-history";
5
6
  defineOptions({ name: "UsageHistoryEvent" });
6
7
  defineProps({
7
8
  event: { type: Object, required: true }
8
9
  });
9
10
  const { t, locale } = useUsageLabels() ?? useLabels("usage");
11
+ const unit = useMeterUnit();
10
12
  </script>
11
13
 
12
14
  <template>
@@ -17,6 +19,6 @@ const { t, locale } = useUsageLabels() ?? useLabels("usage");
17
19
  <span
18
20
  v-if="typeof event.units === 'number'"
19
21
  data-usage="event-units"
20
- >{{ t("units", { count: event.units }) }}</span>
22
+ >{{ t("units", { count: event.units, unit: unit.word(event.unit, event.units) }) }}</span>
21
23
  </article>
22
24
  </template>
@@ -6,8 +6,12 @@ import { type BackendLabels, type LabelOverrides, type UseLabelsReturn } from '.
6
6
  * asks them: the ones a save offer most often answers first.
7
7
  */
8
8
  export declare const CANCELLATION_REASONS: readonly CancellationReason[];
9
- /** Where `<CancelFlow>` stands: the optional question, the one offer, the end, or the plan kept. */
10
- export type CancelFlowStep = 'question' | 'offer' | 'ended' | 'kept';
9
+ /**
10
+ * Where `<CancelFlow>` stands: the optional question, the one offer, the
11
+ * confirmation (when no offer can stand, so "Cancel my plan" ends the plan),
12
+ * the end, or the plan kept.
13
+ */
14
+ export type CancelFlowStep = 'question' | 'offer' | 'confirm' | 'ended' | 'kept';
11
15
  /** What `<CancelFlow>` is told by its owner. */
12
16
  export interface CancelFlowOptions {
13
17
  /** Copy for this flow, over `appConfig.backend.labels.cancelFlow`. */
@@ -23,10 +27,12 @@ export interface CancelFlowOptions {
23
27
  }
24
28
  /** `<CancelFlow>`'s slots: each step, handed the flow. */
25
29
  export interface CancelFlowSlots {
26
- /** The optional question: the reasons, the comment and "Continue". */
30
+ /** The optional question: the reasons, the comment and "Continue" (or "Cancel my plan", when no offer can stand). */
27
31
  question: (flow: UseCancelFlowReturn) => unknown;
28
32
  /** The one offer and the button that accepts it. */
29
33
  offer: (flow: UseCancelFlowReturn) => unknown;
34
+ /** What cancelling ends, the button that confirms it and "Back". */
35
+ confirm: (flow: UseCancelFlowReturn) => unknown;
30
36
  /** The end: when the plan ends and "Keep my plan", or that it stays. */
31
37
  end: (flow: UseCancelFlowReturn) => unknown;
32
38
  }
@@ -40,6 +46,17 @@ export interface UseCancelFlowReturn {
40
46
  comment: Ref<string>;
41
47
  /** The offer the server made for the reason, once it made one. */
42
48
  offer: Ref<SaveOffer | null>;
49
+ /**
50
+ * Whether a save offer can stand for the reason picked (`getCancelFlow`),
51
+ * so the question's button reads "Continue". `false` inside the
52
+ * withdrawal period, on a past-due plan or a trial, after an offer in the
53
+ * last 12 months, with none configured for the reason, or with no reason
54
+ * picked: the button then
55
+ * reads "Cancel my plan", carries `data-intent="cancel"`, and `submit`
56
+ * asks to confirm first. `true` until the read lands, and with a backend
57
+ * that does not export `getCancelFlow`.
58
+ */
59
+ offers: ComputedRef<boolean>;
43
60
  /** When the plan ends, epoch ms, once it is canceled (`null` when the server did not say). */
44
61
  endsAt: Ref<number | null>;
45
62
  /** Which action runs: `continue`, `cancel`, `accept` or `keep`. */
@@ -57,10 +74,12 @@ export interface UseCancelFlowReturn {
57
74
  acceptText: ComputedRef<string>;
58
75
  /** When the plan ends, in the reader's words. */
59
76
  endText: ComputedRef<string>;
60
- /** Answer the question (or skip it): the server answers with an offer, or cancels. */
77
+ /** Answer the question (or skip it): the server answers with an offer, or cancels; with `offers` false, the confirmation first. */
61
78
  submit: () => Promise<void>;
62
- /** "Cancel my plan", on every screen: cancels at once, past any offer. */
79
+ /** "Cancel my plan", beside the question and the offer, and the confirmation's own button: cancels at once, past any offer. */
63
80
  cancelNow: () => Promise<void>;
81
+ /** Back from the confirmation to the question. */
82
+ back: () => void;
64
83
  /** Accept the offer the server made. */
65
84
  accept: () => Promise<void>;
66
85
  /** Undo the cancellation before the plan ends: "Keep my plan". */
@@ -75,7 +94,9 @@ export interface UseCancelFlowReturn {
75
94
  /**
76
95
  * The headless cancel flow `<CancelFlow>` renders: one optional question,
77
96
  * then at most one offer, then the end, with "Cancel my plan" on every
78
- * screen. Every rule that keeps an offer lawful is the server's
79
- * (`useBilling().cancel`): this only shows what it answered.
97
+ * screen. When no offer can stand, the question's button is "Cancel my
98
+ * plan" itself, and a confirmation comes before the plan ends. Every rule
99
+ * that keeps an offer lawful is the server's (`useBilling().cancel`, read
100
+ * ahead by `getCancelFlow`): this only shows what it answered.
80
101
  */
81
102
  export declare function useCancelFlow(options?: CancelFlowOptions): UseCancelFlowReturn;
@@ -1,13 +1,20 @@
1
- import { computed, nextTick, ref, useId } from "vue";
1
+ import { computed, inject, nextTick, ref, useId } from "vue";
2
+ import { ConvexAuthStateKey } from "nuxt-convex-module/client";
2
3
  import { busyAttributes } from "../../a11y.js";
3
4
  import { useBilling } from "../../composables/use-billing.js";
4
5
  import { refusalText, useLabels } from "../../composables/use-labels.js";
6
+ import { useLiveQuery } from "../../utils/live-query.js";
7
+ import { useBackendNamespace } from "../../utils/namespace.js";
5
8
  export const CANCELLATION_REASONS = ["too_expensive", "unused", "missing_features", "switched_service", "too_complex", "low_quality", "customer_service", "other"];
6
9
  function money(amount, currency, locale) {
7
10
  return new Intl.NumberFormat(locale, { style: "currency", currency: currency.toUpperCase() }).format(amount / 100);
8
11
  }
9
12
  export function useCancelFlow(options = {}) {
10
13
  const billing = useBilling();
14
+ const api = useBackendNamespace("billing", "CancelFlow");
15
+ const auth = inject(ConvexAuthStateKey, null);
16
+ const signedOut = computed(() => auth != null && !auth.isAuthenticated.value);
17
+ const read = api.getCancelFlow ? useLiveQuery(api.getCancelFlow, () => signedOut.value ? "skip" : { subscriptionId: options.subscriptionId?.() }) : null;
11
18
  const labels = useLabels("cancelFlow", () => options.labels?.());
12
19
  const { t, locale } = labels;
13
20
  const base = useId();
@@ -50,6 +57,11 @@ export function useCancelFlow(options = {}) {
50
57
  await nextTick();
51
58
  options.onCanceled?.(outcome.endsAt);
52
59
  };
60
+ const offers = computed(() => {
61
+ const state = read?.data.value;
62
+ if (!state || read?.error.value) return true;
63
+ return reason.value === void 0 ? false : state.reasons.includes(reason.value);
64
+ });
53
65
  const offerText = computed(() => {
54
66
  const current = offer.value;
55
67
  if (!current) return "";
@@ -71,6 +83,7 @@ export function useCancelFlow(options = {}) {
71
83
  reason,
72
84
  comment,
73
85
  offer,
86
+ offers,
74
87
  endsAt,
75
88
  running,
76
89
  error,
@@ -78,8 +91,18 @@ export function useCancelFlow(options = {}) {
78
91
  offerText,
79
92
  acceptText,
80
93
  endText: computed(() => endsAt.value === null ? t("endsPeriod") : t("endsOn", { date: date(endsAt.value) })),
81
- submit: () => run("continue", () => send(false)),
94
+ submit: async () => {
95
+ if (offers.value) return run("continue", () => send(false));
96
+ if (running.value) return;
97
+ error.value = null;
98
+ step.value = "confirm";
99
+ },
82
100
  cancelNow: () => run("cancel", () => send(true)),
101
+ back: () => {
102
+ if (running.value) return;
103
+ error.value = null;
104
+ step.value = "question";
105
+ },
83
106
  accept: () => run("accept", async () => {
84
107
  await billing.acceptOffer(offer.value);
85
108
  step.value = "kept";
@@ -10,6 +10,7 @@ import { useCredits } from "../../composables/use-credits";
10
10
  import { refusalText, useLabels } from "../../composables/use-labels";
11
11
  import { usePricing } from "../../composables/use-pricing";
12
12
  import { holdsFocus, returnFocus } from "../../utils/focus-return";
13
+ import { useMeterUnit } from "../../utils/meter-unit";
13
14
  import { VNodes } from "../../utils/vnodes";
14
15
  import { turnedOff } from "./notices";
15
16
  defineOptions({ name: "NoticeLowCredits" });
@@ -35,6 +36,7 @@ const billing = useBilling();
35
36
  const config = useBackendConfig();
36
37
  const labels = useLabels("credits");
37
38
  const { t, rich } = labels;
39
+ const unit = useMeterUnit();
38
40
  const pricingPath = useBackendPagePath("pricing");
39
41
  const dismissed = ref(false);
40
42
  const pending = ref(false);
@@ -81,7 +83,7 @@ const context = computed(() => {
81
83
  if (!confirmed.value || balance === void 0 || dismissed.value || !isShort(balance)) return null;
82
84
  return { credits, balance, threshold: threshold.value, pricingPath: pricingPath.value ?? "", preselected: preselected.value, pending: pending.value, topUp, dismiss };
83
85
  });
84
- const message = computed(() => context.value ? rich("low", { balance: h("span", { "data-credits": "balance" }, String(context.value.balance)), count: context.value.balance }) : []);
86
+ const message = computed(() => context.value ? rich("low", { balance: h("span", { "data-credits": "balance" }, String(context.value.balance)), count: context.value.balance, unit: unit.word(credits.unit.value, context.value.balance) }) : []);
85
87
  </script>
86
88
 
87
89
  <template>
@@ -1 +1 @@
1
- @layer theme, base, reset, nuxt-backend;@layer nuxt-backend{:root{--bk-accent:light-dark(#116632,#4ade80);--bk-on-accent:light-dark(#fff,#052912);--bk-ink:currentColor;--bk-muted:color-mix(in srgb,currentColor 55%,transparent);--bk-edge:color-mix(in srgb,currentColor 18%,transparent);--bk-surface:color-mix(in srgb,currentColor 5%,transparent);--bk-error:light-dark(#a1302d,#f87171);--bk-ok:light-dark(#116632,#4ade80);--bk-warn:light-dark(#6d5600,#facc15);--bk-radius:8px;--bk-radius-control:9999px}@media (color-gamut:p3){@supports (color:color(display-p3 0 0 0)){:root{--bk-accent:light-dark(color(display-p3 0.0431 0.4148 0.1546),color(display-p3 0.1468 0.9102 0.3985));--bk-ok:light-dark(color(display-p3 0.0431 0.4148 0.1546),color(display-p3 0.1468 0.9102 0.3985));--bk-warn:light-dark(color(display-p3 0.4201 0.3386 0.0346),color(display-p3 0.9683 0.8021 0.1389));--bk-error:light-dark(color(display-p3 0.6572 0.0638 0.0969),color(display-p3 0.9873 0.3890 0.3935))}}}@media (color-gamut:rec2020){@supports (color:color(rec2020 0 0 0)){:root{--bk-accent:light-dark(color(rec2020 0.0472 0.3714 0.0115),color(rec2020 0.1584 0.9331 0.0651));--bk-ok:light-dark(color(rec2020 0.0472 0.3714 0.0115),color(rec2020 0.1584 0.9331 0.0651));--bk-warn:light-dark(color(rec2020 0.3406 0.2817 0.0119),color(rec2020 0.9099 0.7830 0.0764));--bk-error:light-dark(color(rec2020 0.5544 0.0597 0.0131),color(rec2020 0.9849 0.2196 0.1954))}}}}@layer theme.backend{:where(:root){--lightningcss-light:initial;--lightningcss-dark: }}
1
+ @layer nuxt-backend-tokens, theme, base, reset, nuxt-backend;@layer nuxt-backend-tokens{:root{--bk-accent:light-dark(#116632,#4ade80);--bk-on-accent:light-dark(#fff,#052912);--bk-ink:currentColor;--bk-muted:color-mix(in srgb,currentColor 55%,transparent);--bk-edge:color-mix(in srgb,currentColor 18%,transparent);--bk-surface:color-mix(in srgb,currentColor 5%,transparent);--bk-error:light-dark(#a1302d,#f87171);--bk-ok:light-dark(#116632,#4ade80);--bk-warn:light-dark(#6d5600,#facc15);--bk-radius:8px;--bk-radius-control:9999px}@media (color-gamut:p3){@supports (color:color(display-p3 0 0 0)){:root{--bk-accent:light-dark(color(display-p3 0.0431 0.4148 0.1546),color(display-p3 0.1468 0.9102 0.3985));--bk-ok:light-dark(color(display-p3 0.0431 0.4148 0.1546),color(display-p3 0.1468 0.9102 0.3985));--bk-warn:light-dark(color(display-p3 0.4201 0.3386 0.0346),color(display-p3 0.9683 0.8021 0.1389));--bk-error:light-dark(color(display-p3 0.6572 0.0638 0.0969),color(display-p3 0.9873 0.3890 0.3935))}}}@media (color-gamut:rec2020){@supports (color:color(rec2020 0 0 0)){:root{--bk-accent:light-dark(color(rec2020 0.0472 0.3714 0.0115),color(rec2020 0.1584 0.9331 0.0651));--bk-ok:light-dark(color(rec2020 0.0472 0.3714 0.0115),color(rec2020 0.1584 0.9331 0.0651));--bk-warn:light-dark(color(rec2020 0.3406 0.2817 0.0119),color(rec2020 0.9099 0.7830 0.0764));--bk-error:light-dark(color(rec2020 0.5544 0.0597 0.0131),color(rec2020 0.9849 0.2196 0.1954))}}}}@layer nuxt-backend-tokens{:where(:root){--lightningcss-light:initial;--lightningcss-dark: }}
@@ -1,12 +1,15 @@
1
1
  <script setup>
2
2
  import { busyAttributes } from "../../a11y";
3
+ import { useMeterUnit } from "../../utils/meter-unit";
3
4
  import { useWorkspaceSettingsView } from "./workspace-settings";
4
5
  defineOptions({ name: "WorkspaceCredits" });
5
- defineProps({
6
+ const props = defineProps({
6
7
  credits: { type: Object, required: true }
7
8
  });
8
9
  const view = useWorkspaceSettingsView("WorkspaceCredits");
9
10
  const { t } = view.labels;
11
+ const unit = useMeterUnit();
12
+ const meterUnit = () => props.credits.unit.value;
10
13
  const pending = (key) => view.context.value.pending === key;
11
14
  </script>
12
15
 
@@ -16,10 +19,10 @@ const pending = (key) => view.context.value.pending === key;
16
19
  :aria-busy="credits.isLoading.value ? 'true' : void 0"
17
20
  >
18
21
  <h3 data-settings="section-title">
19
- {{ t("credits") }}
22
+ {{ t("credits", { unit: unit.title(meterUnit()) }) }}
20
23
  </h3>
21
24
  <p data-settings="balance">
22
- {{ credits.balance.value === void 0 ? t("balanceUnknown") : t("balance", { count: credits.balance.value }) }}
25
+ {{ credits.balance.value === void 0 ? t("balanceUnknown", { unit: unit.word(meterUnit()) }) : t("balance", { count: credits.balance.value, unit: unit.word(meterUnit(), credits.balance.value) }) }}
23
26
  </p>
24
27
  <p data-settings="usage">
25
28
  <span data-settings="credited">{{ t("credited", { count: credits.credited.value ?? "\u2014" }) }}</span>
@@ -12,21 +12,21 @@ type __VLS_Slots = WorkspaceSettingsSlots;
12
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
13
  error: (_message: string) => void;
14
14
  "workspace-created": (_workspace: Workspace) => void;
15
+ "topped-up": (_key: string) => void;
15
16
  "plan-canceled": () => void;
16
17
  "plan-uncanceled": () => void;
17
18
  "plan-resumed": () => void;
18
19
  "change-canceled": () => void;
19
20
  "workspace-switched": (_id: string) => void;
20
- "topped-up": (_key: string) => void;
21
21
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
22
22
  onError?: ((_message: string) => any) | undefined;
23
23
  "onWorkspace-created"?: ((_workspace: Workspace) => any) | undefined;
24
+ "onTopped-up"?: ((_key: string) => any) | undefined;
24
25
  "onPlan-canceled"?: (() => any) | undefined;
25
26
  "onPlan-uncanceled"?: (() => any) | undefined;
26
27
  "onPlan-resumed"?: (() => any) | undefined;
27
28
  "onChange-canceled"?: (() => any) | undefined;
28
29
  "onWorkspace-switched"?: ((_id: string) => any) | undefined;
29
- "onTopped-up"?: ((_key: string) => any) | undefined;
30
30
  }>, {
31
31
  labels: LabelOverrides<{
32
32
  title: string;
@@ -12,21 +12,21 @@ type __VLS_Slots = WorkspaceSettingsSlots;
12
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
13
  error: (_message: string) => void;
14
14
  "workspace-created": (_workspace: Workspace) => void;
15
+ "topped-up": (_key: string) => void;
15
16
  "plan-canceled": () => void;
16
17
  "plan-uncanceled": () => void;
17
18
  "plan-resumed": () => void;
18
19
  "change-canceled": () => void;
19
20
  "workspace-switched": (_id: string) => void;
20
- "topped-up": (_key: string) => void;
21
21
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
22
22
  onError?: ((_message: string) => any) | undefined;
23
23
  "onWorkspace-created"?: ((_workspace: Workspace) => any) | undefined;
24
+ "onTopped-up"?: ((_key: string) => any) | undefined;
24
25
  "onPlan-canceled"?: (() => any) | undefined;
25
26
  "onPlan-uncanceled"?: (() => any) | undefined;
26
27
  "onPlan-resumed"?: (() => any) | undefined;
27
28
  "onChange-canceled"?: (() => any) | undefined;
28
29
  "onWorkspace-switched"?: ((_id: string) => any) | undefined;
29
- "onTopped-up"?: ((_key: string) => any) | undefined;
30
30
  }>, {
31
31
  labels: LabelOverrides<{
32
32
  title: string;
@@ -19,6 +19,16 @@ export interface UseAuthReturn {
19
19
  hasRole: (role: string | string[]) => boolean;
20
20
  /** Whether someone is signed in, read from the base module's auth state. */
21
21
  isSignedIn: ComputedRef<boolean>;
22
+ /**
23
+ * Whether a signed-in read can go: someone is signed in, and the backend
24
+ * connection holds their token. On every page load `isSignedIn` turns
25
+ * `true` a moment sooner, from the session, while the token is still on
26
+ * its way, and a query of a signed-in tier (`authed`, `workspace`,
27
+ * `admin`) started in that moment is refused `unauthenticated`. Skip
28
+ * such a query until this is `true`:
29
+ * `useQuery(api.strips.list, () => (isReady.value ? {} : 'skip'))`.
30
+ */
31
+ isReady: ComputedRef<boolean>;
22
32
  /** `true` while the session is still resolving. */
23
33
  isLoading: ComputedRef<boolean>;
24
34
  /**
@@ -44,7 +54,9 @@ export interface UseAuthReturn {
44
54
  * @example
45
55
  * ```vue
46
56
  * <script setup lang="ts">
47
- * const { user, isSignedIn, hasRole, signOut } = useAuth()
57
+ * const { user, isSignedIn, isReady, hasRole, signOut } = useAuth()
58
+ * // A read of your own signed-in functions waits for the backend to hold the token.
59
+ * const strips = useQuery(api.strips.list, () => (isReady.value ? {} : 'skip'))
48
60
  * </script>
49
61
  *
50
62
  * <template>
@@ -1,13 +1,16 @@
1
- import { computed } from "vue";
1
+ import { computed, inject } from "vue";
2
+ import { ConvexAuthStateKey } from "nuxt-convex-module/client";
2
3
  import { useAuthSession } from "../utils/auth-session.js";
3
4
  export function useAuth() {
4
5
  const auth = useAuthSession();
6
+ const connection = inject(ConvexAuthStateKey, null);
5
7
  return {
6
8
  user: computed(() => auth.user.value),
7
9
  session: computed(() => auth.session.value.data?.session ?? null),
8
10
  role: auth.role,
9
11
  hasRole: auth.hasRole,
10
12
  isSignedIn: auth.isAuthenticated,
13
+ isReady: computed(() => auth.isAuthenticated.value && (connection ? connection.isAuthenticated.value : !auth.isLoading.value)),
11
14
  isLoading: auth.isLoading,
12
15
  impersonating: auth.isImpersonating,
13
16
  signOut: auth.signOut
@@ -1,9 +1,10 @@
1
1
  import type { FunctionReference } from 'convex/server';
2
2
  import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
3
3
  import type { BackendError } from '../utils/backend-error.js';
4
+ import type { MeterUnit } from '../../../convex/catalog.js';
4
5
  import type { QuotaUsage } from '../../../convex/integrations/billing/types/records.js';
5
- import type { CancelOutcome, SaveOffer, WithdrawalPeriod } from '../../../convex/integrations/billing/types/lifecycle.js';
6
- export type { CancelOutcome, SaveOffer, WithdrawalPeriod };
6
+ import type { CancelFlowState, CancelOutcome, SaveOffer, WithdrawalPeriod } from '../../../convex/integrations/billing/types/lifecycle.js';
7
+ export type { CancelFlowState, CancelOutcome, SaveOffer, WithdrawalPeriod };
7
8
  export { formatBillingAmount, toBillingDate } from './billing-format.js';
8
9
  export { createCheckout, createProviderPager } from './billing-provider.js';
9
10
  /** A billing-provider product (loose — the provider owns the full shape; cast as needed). */
@@ -69,6 +70,8 @@ export type UsageEvent = {
69
70
  /** The ingested event name (the one the meter filters on). */
70
71
  name: string;
71
72
  units?: number;
73
+ /** What the meter counts, beside `units` when the catalog names its unit. */
74
+ unit?: MeterUnit;
72
75
  metadata?: Record<string, string | number | boolean>;
73
76
  } & Record<string, unknown>;
74
77
  /**
@@ -145,6 +148,8 @@ export interface EntitlementMeter {
145
148
  meterId: string;
146
149
  /** The configured friendly name (`setupBilling({ credits })` / catalog key). */
147
150
  name?: string;
151
+ /** What the meter counts, when the catalog names its unit (`meters.<key>.unit`). */
152
+ unit?: MeterUnit;
148
153
  consumedUnits: number;
149
154
  creditedUnits: number;
150
155
  balance: number;
@@ -270,6 +275,9 @@ export interface BillingApi {
270
275
  comment?: string;
271
276
  offer?: false;
272
277
  }, CancelOutcome | null>;
278
+ getCancelFlow?: FunctionReference<'query', 'public', {
279
+ subscriptionId?: string;
280
+ }, CancelFlowState | null>;
273
281
  acceptSaveOffer?: FunctionReference<'action', 'public', {
274
282
  offerId: string;
275
283
  }, null>;
@@ -1,4 +1,5 @@
1
1
  import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
2
+ import type { MeterUnit } from '../../../convex/catalog.js';
2
3
  import type { BackendError } from '../utils/backend-error.js';
3
4
  import { type BillingApi, type CheckoutOptions } from './use-billing.js';
4
5
  /** The billing period a meter's credited units belong to. */
@@ -52,6 +53,8 @@ export interface UseCreditsReturn {
52
53
  expiresAtCycleEnd: ComputedRef<boolean | undefined>;
53
54
  /** The resolved meter id (the one read above) — pass it to your server-side spend. */
54
55
  meterId: ComputedRef<string | undefined>;
56
+ /** What the meter counts, as the catalog's `meters.<key>.unit` names it; `undefined` without one, or while loading (the packaged labels then say "credits"). */
57
+ unit: ComputedRef<MeterUnit | undefined>;
55
58
  /** `true` until credit balances have loaded (`false` once the read failed). */
56
59
  isLoading: ComputedRef<boolean>;
57
60
  /** `true` while `topUp` or `refresh` runs. */
@@ -55,6 +55,7 @@ export function useCredits(options = {}) {
55
55
  return m?.rollover === false && m.cycleEnd !== void 0;
56
56
  }),
57
57
  meterId: computed(() => meter.value?.meterId),
58
+ unit: computed(() => meter.value?.unit),
58
59
  isLoading: read.isLoading,
59
60
  isPending,
60
61
  error: computed(() => failure.value ?? read.error.value),
@@ -28,6 +28,8 @@ export interface NotificationItem {
28
28
  id: string;
29
29
  name: string | null;
30
30
  } | null;
31
+ /** Whose plan, credits or gift a billing kind is about: `account` the reader's own, `workspace` the one named; `null` for any other kind. */
32
+ entity: NotificationEntry['entity'];
31
33
  /** The kind's own fields. */
32
34
  data: NotificationEntry['data'];
33
35
  }
@@ -90,7 +92,9 @@ export interface UseNotificationsReturn {
90
92
  * with `loadMore`, with the unread count and the actions that mark them
91
93
  * read. The words are labels, so each item reads in the active language
92
94
  * (`backend.notifications.<kind>.title` and `.body`, the package's for its
93
- * own kinds and yours for the kinds of your own).
95
+ * own kinds and yours for the kinds of your own). A billing kind about the
96
+ * reader's own account (`billTo: 'user'`) reads `.titleYours` and
97
+ * `.bodyYours` where the kind has them.
94
98
  *
95
99
  * @example
96
100
  * ```vue