nuxt-backend 0.5.1 → 0.6.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 (414) hide show
  1. package/README.md +5 -2
  2. package/dist/capabilities/registry.js +1 -1
  3. package/dist/chunks/catalog.mjs +1 -1
  4. package/dist/chunks/{index.mjs → devtools.mjs} +2 -2
  5. package/dist/chunks/doctor.mjs +14 -6
  6. package/dist/chunks/email-previews.mjs +1 -1
  7. package/dist/chunks/health.mjs +2 -2
  8. package/dist/chunks/install.mjs +4 -4
  9. package/dist/chunks/run.mjs +1 -1
  10. package/dist/chunks/server.mjs +15 -4
  11. package/dist/cli.mjs +24 -4
  12. package/dist/convex/access-tickets.d.ts +17 -2
  13. package/dist/convex/access-tickets.d.ts.map +1 -1
  14. package/dist/convex/account-data.d.ts +4 -4
  15. package/dist/convex/account-data.d.ts.map +1 -1
  16. package/dist/convex/account-data.js +5 -4
  17. package/dist/convex/account-data.js.map +1 -1
  18. package/dist/convex/app.d.ts +1 -0
  19. package/dist/convex/app.d.ts.map +1 -1
  20. package/dist/convex/app.js +2 -1
  21. package/dist/convex/app.js.map +1 -1
  22. package/dist/convex/client/better-auth-options.d.ts.map +1 -1
  23. package/dist/convex/client/better-auth-options.js +12 -3
  24. package/dist/convex/client/better-auth-options.js.map +1 -1
  25. package/dist/convex/client/component.d.ts +4 -0
  26. package/dist/convex/client/component.d.ts.map +1 -1
  27. package/dist/convex/client/index.d.ts +5 -0
  28. package/dist/convex/client/index.d.ts.map +1 -1
  29. package/dist/convex/client/launch-gate.d.ts.map +1 -1
  30. package/dist/convex/client/launch-gate.js +30 -1
  31. package/dist/convex/client/launch-gate.js.map +1 -1
  32. package/dist/convex/client/plugins.d.ts.map +1 -1
  33. package/dist/convex/client/plugins.js +3 -0
  34. package/dist/convex/client/plugins.js.map +1 -1
  35. package/dist/convex/client/two-factor.d.ts +7 -0
  36. package/dist/convex/client/two-factor.d.ts.map +1 -0
  37. package/dist/convex/client/two-factor.js +57 -0
  38. package/dist/convex/client/two-factor.js.map +1 -0
  39. package/dist/convex/components/backend/_generated/api.d.ts +2 -0
  40. package/dist/convex/components/backend/_generated/api.d.ts.map +1 -1
  41. package/dist/convex/components/backend/_generated/api.js.map +1 -1
  42. package/dist/convex/components/backend/_generated/component.d.ts +292 -10
  43. package/dist/convex/components/backend/_generated/component.d.ts.map +1 -1
  44. package/dist/convex/components/backend/account.d.ts +63 -17
  45. package/dist/convex/components/backend/account.d.ts.map +1 -1
  46. package/dist/convex/components/backend/account.js +24 -1
  47. package/dist/convex/components/backend/account.js.map +1 -1
  48. package/dist/convex/components/backend/adapter.d.ts.map +1 -1
  49. package/dist/convex/components/backend/adapter.js +7 -2
  50. package/dist/convex/components/backend/adapter.js.map +1 -1
  51. package/dist/convex/components/backend/ai.d.ts +1 -1
  52. package/dist/convex/components/backend/billing.d.ts +10 -0
  53. package/dist/convex/components/backend/billing.d.ts.map +1 -1
  54. package/dist/convex/components/backend/billing.js +2 -1
  55. package/dist/convex/components/backend/billing.js.map +1 -1
  56. package/dist/convex/components/backend/commerce.d.ts +229 -0
  57. package/dist/convex/components/backend/commerce.d.ts.map +1 -0
  58. package/dist/convex/components/backend/commerce.js +392 -0
  59. package/dist/convex/components/backend/commerce.js.map +1 -0
  60. package/dist/convex/components/backend/funnel.d.ts +6 -6
  61. package/dist/convex/components/backend/jobs.d.ts +1 -1
  62. package/dist/convex/components/backend/referrals.d.ts +2 -2
  63. package/dist/convex/components/backend/schema.d.ts +327 -21
  64. package/dist/convex/components/backend/schema.d.ts.map +1 -1
  65. package/dist/convex/components/backend/schema.js +108 -1
  66. package/dist/convex/components/backend/schema.js.map +1 -1
  67. package/dist/convex/components/backend/waitlist.d.ts +42 -6
  68. package/dist/convex/components/backend/waitlist.d.ts.map +1 -1
  69. package/dist/convex/components/backend/waitlist.js +142 -39
  70. package/dist/convex/components/backend/waitlist.js.map +1 -1
  71. package/dist/convex/email-templates.d.ts +12 -0
  72. package/dist/convex/email-templates.d.ts.map +1 -1
  73. package/dist/convex/email-templates.js +3 -0
  74. package/dist/convex/email-templates.js.map +1 -1
  75. package/dist/convex/emails/waitlist-friend-joined.d.ts +9 -0
  76. package/dist/convex/emails/waitlist-friend-joined.d.ts.map +1 -0
  77. package/dist/convex/emails/waitlist-friend-joined.js +22 -0
  78. package/dist/convex/emails/waitlist-friend-joined.js.map +1 -0
  79. package/dist/convex/errors.d.ts +6 -6
  80. package/dist/convex/errors.d.ts.map +1 -1
  81. package/dist/convex/errors.js +14 -2
  82. package/dist/convex/errors.js.map +1 -1
  83. package/dist/convex/events.d.ts +19 -0
  84. package/dist/convex/events.d.ts.map +1 -1
  85. package/dist/convex/events.js +14 -0
  86. package/dist/convex/events.js.map +1 -1
  87. package/dist/convex/integrations/billing/checkout.d.ts +2 -2
  88. package/dist/convex/integrations/billing/checkout.d.ts.map +1 -1
  89. package/dist/convex/integrations/billing/checkout.js +79 -11
  90. package/dist/convex/integrations/billing/checkout.js.map +1 -1
  91. package/dist/convex/integrations/billing/commerce-entitlements.d.ts +12 -0
  92. package/dist/convex/integrations/billing/commerce-entitlements.d.ts.map +1 -0
  93. package/dist/convex/integrations/billing/commerce-entitlements.js +78 -0
  94. package/dist/convex/integrations/billing/commerce-entitlements.js.map +1 -0
  95. package/dist/convex/integrations/billing/commerce-events.d.ts +15 -0
  96. package/dist/convex/integrations/billing/commerce-events.d.ts.map +1 -0
  97. package/dist/convex/integrations/billing/commerce-events.js +433 -0
  98. package/dist/convex/integrations/billing/commerce-events.js.map +1 -0
  99. package/dist/convex/integrations/billing/commerce-history.d.ts +20 -0
  100. package/dist/convex/integrations/billing/commerce-history.d.ts.map +1 -0
  101. package/dist/convex/integrations/billing/commerce-history.js +106 -0
  102. package/dist/convex/integrations/billing/commerce-history.js.map +1 -0
  103. package/dist/convex/integrations/billing/commerce-webhooks.d.ts +23 -0
  104. package/dist/convex/integrations/billing/commerce-webhooks.d.ts.map +1 -0
  105. package/dist/convex/integrations/billing/commerce-webhooks.js +49 -0
  106. package/dist/convex/integrations/billing/commerce-webhooks.js.map +1 -0
  107. package/dist/convex/integrations/billing/commerce.d.ts +100 -0
  108. package/dist/convex/integrations/billing/commerce.d.ts.map +1 -0
  109. package/dist/convex/integrations/billing/commerce.js +323 -0
  110. package/dist/convex/integrations/billing/commerce.js.map +1 -0
  111. package/dist/convex/integrations/billing/context.d.ts +8 -0
  112. package/dist/convex/integrations/billing/context.d.ts.map +1 -1
  113. package/dist/convex/integrations/billing/context.js +14 -2
  114. package/dist/convex/integrations/billing/context.js.map +1 -1
  115. package/dist/convex/integrations/billing/credits.d.ts +1 -1
  116. package/dist/convex/integrations/billing/credits.d.ts.map +1 -1
  117. package/dist/convex/integrations/billing/credits.js +49 -28
  118. package/dist/convex/integrations/billing/credits.js.map +1 -1
  119. package/dist/convex/integrations/billing/customers.d.ts +1 -1
  120. package/dist/convex/integrations/billing/customers.d.ts.map +1 -1
  121. package/dist/convex/integrations/billing/customers.js +15 -1
  122. package/dist/convex/integrations/billing/customers.js.map +1 -1
  123. package/dist/convex/integrations/billing/entitlements.d.ts +1 -1
  124. package/dist/convex/integrations/billing/entitlements.d.ts.map +1 -1
  125. package/dist/convex/integrations/billing/entitlements.js +6 -1
  126. package/dist/convex/integrations/billing/entitlements.js.map +1 -1
  127. package/dist/convex/integrations/billing/erasure.d.ts +1 -1
  128. package/dist/convex/integrations/billing/erasure.d.ts.map +1 -1
  129. package/dist/convex/integrations/billing/erasure.js +10 -5
  130. package/dist/convex/integrations/billing/erasure.js.map +1 -1
  131. package/dist/convex/integrations/billing/free-plan.d.ts +6 -1
  132. package/dist/convex/integrations/billing/free-plan.d.ts.map +1 -1
  133. package/dist/convex/integrations/billing/free-plan.js +22 -4
  134. package/dist/convex/integrations/billing/free-plan.js.map +1 -1
  135. package/dist/convex/integrations/billing/functions.d.ts +1 -1
  136. package/dist/convex/integrations/billing/functions.d.ts.map +1 -1
  137. package/dist/convex/integrations/billing/functions.js +3 -2
  138. package/dist/convex/integrations/billing/functions.js.map +1 -1
  139. package/dist/convex/integrations/billing/gifts.d.ts.map +1 -1
  140. package/dist/convex/integrations/billing/gifts.js +3 -0
  141. package/dist/convex/integrations/billing/gifts.js.map +1 -1
  142. package/dist/convex/integrations/billing/history.d.ts +1 -1
  143. package/dist/convex/integrations/billing/history.d.ts.map +1 -1
  144. package/dist/convex/integrations/billing/history.js +6 -1
  145. package/dist/convex/integrations/billing/history.js.map +1 -1
  146. package/dist/convex/integrations/billing/lifecycle.d.ts +1 -1
  147. package/dist/convex/integrations/billing/lifecycle.d.ts.map +1 -1
  148. package/dist/convex/integrations/billing/lifecycle.js +4 -1
  149. package/dist/convex/integrations/billing/lifecycle.js.map +1 -1
  150. package/dist/convex/integrations/billing/providers/capabilities.d.ts +17 -0
  151. package/dist/convex/integrations/billing/providers/capabilities.d.ts.map +1 -0
  152. package/dist/convex/integrations/billing/providers/capabilities.js +77 -0
  153. package/dist/convex/integrations/billing/providers/capabilities.js.map +1 -0
  154. package/dist/convex/integrations/billing/providers/consent.d.ts +52 -0
  155. package/dist/convex/integrations/billing/providers/consent.d.ts.map +1 -0
  156. package/dist/convex/integrations/billing/providers/consent.js +79 -0
  157. package/dist/convex/integrations/billing/providers/consent.js.map +1 -0
  158. package/dist/convex/integrations/billing/providers/creem.d.ts +22 -0
  159. package/dist/convex/integrations/billing/providers/creem.d.ts.map +1 -0
  160. package/dist/convex/integrations/billing/providers/creem.js +208 -0
  161. package/dist/convex/integrations/billing/providers/creem.js.map +1 -0
  162. package/dist/convex/integrations/billing/providers/dodo.d.ts +15 -0
  163. package/dist/convex/integrations/billing/providers/dodo.d.ts.map +1 -0
  164. package/dist/convex/integrations/billing/providers/dodo.js +197 -0
  165. package/dist/convex/integrations/billing/providers/dodo.js.map +1 -0
  166. package/dist/convex/integrations/billing/providers/http.d.ts +41 -0
  167. package/dist/convex/integrations/billing/providers/http.d.ts.map +1 -0
  168. package/dist/convex/integrations/billing/providers/http.js +146 -0
  169. package/dist/convex/integrations/billing/providers/http.js.map +1 -0
  170. package/dist/convex/integrations/billing/providers/index.d.ts +35 -0
  171. package/dist/convex/integrations/billing/providers/index.d.ts.map +1 -0
  172. package/dist/convex/integrations/billing/providers/index.js +62 -0
  173. package/dist/convex/integrations/billing/providers/index.js.map +1 -0
  174. package/dist/convex/integrations/billing/providers/stripe.d.ts +28 -0
  175. package/dist/convex/integrations/billing/providers/stripe.d.ts.map +1 -0
  176. package/dist/convex/integrations/billing/providers/stripe.js +327 -0
  177. package/dist/convex/integrations/billing/providers/stripe.js.map +1 -0
  178. package/dist/convex/integrations/billing/providers/types.d.ts +263 -0
  179. package/dist/convex/integrations/billing/providers/types.d.ts.map +1 -0
  180. package/dist/convex/integrations/billing/providers/types.js +48 -0
  181. package/dist/convex/integrations/billing/providers/types.js.map +1 -0
  182. package/dist/convex/integrations/billing/subscriptions.d.ts +1 -1
  183. package/dist/convex/integrations/billing/subscriptions.d.ts.map +1 -1
  184. package/dist/convex/integrations/billing/subscriptions.js +20 -6
  185. package/dist/convex/integrations/billing/subscriptions.js.map +1 -1
  186. package/dist/convex/integrations/billing/types/setup.d.ts +64 -1
  187. package/dist/convex/integrations/billing/types/setup.d.ts.map +1 -1
  188. package/dist/convex/integrations/billing.d.ts +4 -1
  189. package/dist/convex/integrations/billing.d.ts.map +1 -1
  190. package/dist/convex/integrations/billing.js +12 -2
  191. package/dist/convex/integrations/billing.js.map +1 -1
  192. package/dist/convex/integrations/email.d.ts +1 -1
  193. package/dist/convex/integrations/email.d.ts.map +1 -1
  194. package/dist/convex/integrations/email.js.map +1 -1
  195. package/dist/convex/integrations/launch.d.ts +27 -2
  196. package/dist/convex/integrations/launch.d.ts.map +1 -1
  197. package/dist/convex/integrations/launch.js +15 -3
  198. package/dist/convex/integrations/launch.js.map +1 -1
  199. package/dist/convex/integrations/presence.d.ts +110 -0
  200. package/dist/convex/integrations/presence.d.ts.map +1 -0
  201. package/dist/convex/integrations/presence.js +92 -0
  202. package/dist/convex/integrations/presence.js.map +1 -0
  203. package/dist/convex/integrations/waitlist.d.ts +41 -7
  204. package/dist/convex/integrations/waitlist.d.ts.map +1 -1
  205. package/dist/convex/integrations/waitlist.js +45 -6
  206. package/dist/convex/integrations/waitlist.js.map +1 -1
  207. package/dist/convex/integrations/webhook-guard.d.ts +8 -0
  208. package/dist/convex/integrations/webhook-guard.d.ts.map +1 -1
  209. package/dist/convex/integrations/webhook-guard.js +11 -4
  210. package/dist/convex/integrations/webhook-guard.js.map +1 -1
  211. package/dist/convex/label-groups/admin.d.ts +9 -0
  212. package/dist/convex/label-groups/admin.d.ts.map +1 -1
  213. package/dist/convex/label-groups/admin.js +9 -0
  214. package/dist/convex/label-groups/admin.js.map +1 -1
  215. package/dist/convex/label-groups/audit.d.ts +2 -0
  216. package/dist/convex/label-groups/audit.d.ts.map +1 -1
  217. package/dist/convex/label-groups/audit.js +2 -0
  218. package/dist/convex/label-groups/audit.js.map +1 -1
  219. package/dist/convex/label-groups/auth.d.ts +9 -0
  220. package/dist/convex/label-groups/auth.d.ts.map +1 -1
  221. package/dist/convex/label-groups/auth.js +10 -0
  222. package/dist/convex/label-groups/auth.js.map +1 -1
  223. package/dist/convex/label-groups/email.d.ts +6 -0
  224. package/dist/convex/label-groups/email.d.ts.map +1 -1
  225. package/dist/convex/label-groups/email.js +7 -0
  226. package/dist/convex/label-groups/email.js.map +1 -1
  227. package/dist/convex/label-groups/errors.d.ts +4 -0
  228. package/dist/convex/label-groups/errors.d.ts.map +1 -1
  229. package/dist/convex/label-groups/errors.js +4 -0
  230. package/dist/convex/label-groups/errors.js.map +1 -1
  231. package/dist/convex/label-groups/security.d.ts +19 -0
  232. package/dist/convex/label-groups/security.d.ts.map +1 -1
  233. package/dist/convex/label-groups/security.js +20 -0
  234. package/dist/convex/label-groups/security.js.map +1 -1
  235. package/dist/convex/label-groups/waitlist.d.ts +8 -0
  236. package/dist/convex/label-groups/waitlist.d.ts.map +1 -1
  237. package/dist/convex/label-groups/waitlist.js +9 -0
  238. package/dist/convex/label-groups/waitlist.js.map +1 -1
  239. package/dist/convex/label-translations.d.ts.map +1 -1
  240. package/dist/convex/label-translations.js +24 -0
  241. package/dist/convex/label-translations.js.map +1 -1
  242. package/dist/convex/labels.d.ts +57 -0
  243. package/dist/convex/labels.d.ts.map +1 -1
  244. package/dist/convex/log.js +2 -0
  245. package/dist/convex/log.js.map +1 -1
  246. package/dist/convex/sensitive-actions.d.ts.map +1 -1
  247. package/dist/convex/sensitive-actions.js +11 -0
  248. package/dist/convex/sensitive-actions.js.map +1 -1
  249. package/dist/convex/waitlist-rules.d.ts +63 -9
  250. package/dist/convex/waitlist-rules.d.ts.map +1 -1
  251. package/dist/convex/waitlist-rules.js +38 -7
  252. package/dist/convex/waitlist-rules.js.map +1 -1
  253. package/dist/devtools-client/_nuxt/DHNi4uhO.js +6 -0
  254. package/dist/devtools-client/index.html +1 -1
  255. package/dist/env-registry.js +9 -0
  256. package/dist/module.d.ts +14 -2
  257. package/dist/module.js +2 -2
  258. package/dist/module.json +2 -2
  259. package/dist/runtime/locales/de.json +58 -1
  260. package/dist/runtime/locales/en.json +60 -3
  261. package/dist/runtime/locales/es.json +58 -1
  262. package/dist/runtime/locales/fr.json +58 -1
  263. package/dist/runtime/locales/ru.json +58 -1
  264. package/dist/runtime/server/monitoring/backend-calls.d.ts +3 -3
  265. package/dist/runtime/server/monitoring/backend-calls.js +2 -2
  266. package/dist/runtime/server/monitoring/health.js +2 -2
  267. package/dist/runtime/vue/auth-client.d.ts +3 -2
  268. package/dist/runtime/vue/auth-client.js +2 -1
  269. package/dist/runtime/vue/components/account/SecuritySettings.d.vue.ts +25 -2
  270. package/dist/runtime/vue/components/account/SecuritySettings.vue +52 -2
  271. package/dist/runtime/vue/components/account/SecuritySettings.vue.d.ts +25 -2
  272. package/dist/runtime/vue/components/account/SecurityTwoFactor.css +1 -0
  273. package/dist/runtime/vue/components/account/SecurityTwoFactor.d.vue.ts +4 -0
  274. package/dist/runtime/vue/components/account/SecurityTwoFactor.vue +107 -0
  275. package/dist/runtime/vue/components/account/SecurityTwoFactor.vue.d.ts +4 -0
  276. package/dist/runtime/vue/components/account/security-settings.d.ts +18 -1
  277. package/dist/runtime/vue/components/admin/AdminUsers.d.vue.ts +11 -2
  278. package/dist/runtime/vue/components/admin/AdminUsers.vue.d.ts +11 -2
  279. package/dist/runtime/vue/components/admin/AdminWaitlist.css +1 -1
  280. package/dist/runtime/vue/components/admin/AdminWaitlistActions.vue +41 -1
  281. package/dist/runtime/vue/components/admin/AdminWorkspaces.d.vue.ts +9 -0
  282. package/dist/runtime/vue/components/admin/AdminWorkspaces.vue.d.ts +9 -0
  283. package/dist/runtime/vue/components/admin/admin-waitlist-tab.js +28 -0
  284. package/dist/runtime/vue/components/auth/AuthForm.d.vue.ts +9 -0
  285. package/dist/runtime/vue/components/auth/AuthForm.vue +8 -0
  286. package/dist/runtime/vue/components/auth/AuthForm.vue.d.ts +9 -0
  287. package/dist/runtime/vue/components/auth/AuthFormTwoFactor.css +1 -0
  288. package/dist/runtime/vue/components/auth/AuthFormTwoFactor.d.vue.ts +3 -0
  289. package/dist/runtime/vue/components/auth/AuthFormTwoFactor.vue +70 -0
  290. package/dist/runtime/vue/components/auth/AuthFormTwoFactor.vue.d.ts +3 -0
  291. package/dist/runtime/vue/components/auth/AuthFormWaitlisted.vue +7 -2
  292. package/dist/runtime/vue/components/auth/WaitlistForm.d.vue.ts +8 -0
  293. package/dist/runtime/vue/components/auth/WaitlistForm.vue.d.ts +8 -0
  294. package/dist/runtime/vue/components/auth/WaitlistPlace.css +1 -1
  295. package/dist/runtime/vue/components/auth/WaitlistPlace.vue +37 -0
  296. package/dist/runtime/vue/components/auth/WaitlistShare.vue +2 -2
  297. package/dist/runtime/vue/components/auth/auth-form.d.ts +2 -0
  298. package/dist/runtime/vue/components/workspaces/AuditLog.d.vue.ts +2 -0
  299. package/dist/runtime/vue/components/workspaces/AuditLog.vue.d.ts +2 -0
  300. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
  301. package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
  302. package/dist/runtime/vue/composables/use-login-flow.d.ts +19 -4
  303. package/dist/runtime/vue/composables/use-login-flow.js +31 -0
  304. package/dist/runtime/vue/composables/use-room-presence.d.ts +63 -0
  305. package/dist/runtime/vue/composables/use-room-presence.js +31 -0
  306. package/dist/runtime/vue/composables/use-two-factor.d.ts +58 -0
  307. package/dist/runtime/vue/composables/use-two-factor.js +49 -0
  308. package/dist/runtime/vue/composables/use-waitlist-admin.d.ts +5 -0
  309. package/dist/runtime/vue/composables/use-waitlist-admin.js +5 -1
  310. package/dist/runtime/vue/composables/use-waitlist.d.ts +4 -0
  311. package/dist/runtime/vue/composables/use-waitlist.js +1 -1
  312. package/dist/runtime/vue/parts.d.ts +8 -1
  313. package/dist/runtime/vue/two-factor-client.d.ts +15 -0
  314. package/dist/runtime/vue/two-factor-client.js +19 -0
  315. package/dist/runtime/vue/utils/auth-session.js +10 -1
  316. package/dist/runtime/vue/utils/login-bindings.js +1 -0
  317. package/dist/runtime/vue/utils/page-guard.d.ts +2 -2
  318. package/dist/runtime/vue/utils/page-guard.js +2 -2
  319. package/dist/shared/{nuxt-backend.BvKvJ1mo.mjs → nuxt-backend.CM_p0XQE.mjs} +1 -1
  320. package/dist/shared/{nuxt-backend.DRuHg-IQ.mjs → nuxt-backend.C_Y_BtBs.mjs} +2 -2
  321. package/dist/shared/{nuxt-backend.suXOnqOQ.mjs → nuxt-backend.ChvlbHQq.mjs} +42 -7
  322. package/dist/shared/{nuxt-backend.0r1vvS1c.mjs → nuxt-backend.D16peTIt.mjs} +56 -34
  323. package/dist/shared/{nuxt-backend.zY6UDqDu.mjs → nuxt-backend.D4JXvCP6.mjs} +3 -2
  324. package/dist/types.d.ts +1 -1
  325. package/package.json +19 -10
  326. package/skills/nuxt-backend/SKILL.md +18 -18
  327. package/skills/nuxt-backend/references/api.md +30 -5
  328. package/skills/nuxt-backend/references/install.md +1 -1
  329. package/skills/nuxt-backend/references/renames.json +8 -0
  330. package/skills/nuxt-backend/references/surface.json +62 -2
  331. package/skills/nuxt-backend-auth/SKILL.md +8 -2
  332. package/skills/nuxt-backend-auth/references/api.md +3 -1
  333. package/skills/nuxt-backend-billing/SKILL.md +15 -0
  334. package/skills/nuxt-backend-billing/references/api.md +14 -1
  335. package/skills/nuxt-backend-data/SKILL.md +1 -0
  336. package/skills/nuxt-backend-data/references/api.md +10 -1
  337. package/skills/nuxt-backend-email/references/api.md +1 -1
  338. package/skills/nuxt-backend-ship/SKILL.md +2 -1
  339. package/skills/nuxt-backend-upgrade/references/upgrade.md +6 -0
  340. package/src/convex/access-tickets.ts +10 -2
  341. package/src/convex/account-data.ts +5 -4
  342. package/src/convex/app.ts +2 -1
  343. package/src/convex/client/better-auth-options.ts +12 -3
  344. package/src/convex/client/launch-gate.ts +28 -1
  345. package/src/convex/client/plugins.ts +3 -0
  346. package/src/convex/client/two-factor.ts +66 -0
  347. package/src/convex/components/backend/_generated/api.ts +2 -0
  348. package/src/convex/components/backend/_generated/component.ts +500 -2
  349. package/src/convex/components/backend/account.ts +25 -1
  350. package/src/convex/components/backend/adapter.ts +7 -2
  351. package/src/convex/components/backend/billing.ts +2 -1
  352. package/src/convex/components/backend/commerce.ts +408 -0
  353. package/src/convex/components/backend/schema.ts +110 -1
  354. package/src/convex/components/backend/waitlist.ts +144 -40
  355. package/src/convex/email-templates.ts +16 -0
  356. package/src/convex/emails/waitlist-friend-joined.ts +23 -0
  357. package/src/convex/errors.ts +15 -2
  358. package/src/convex/events.ts +14 -0
  359. package/src/convex/integrations/billing/checkout.ts +78 -11
  360. package/src/convex/integrations/billing/commerce-entitlements.ts +92 -0
  361. package/src/convex/integrations/billing/commerce-events.ts +487 -0
  362. package/src/convex/integrations/billing/commerce-history.ts +110 -0
  363. package/src/convex/integrations/billing/commerce-webhooks.ts +69 -0
  364. package/src/convex/integrations/billing/commerce.ts +366 -0
  365. package/src/convex/integrations/billing/context.ts +19 -2
  366. package/src/convex/integrations/billing/credits.ts +47 -27
  367. package/src/convex/integrations/billing/customers.ts +15 -1
  368. package/src/convex/integrations/billing/entitlements.ts +5 -1
  369. package/src/convex/integrations/billing/erasure.ts +11 -6
  370. package/src/convex/integrations/billing/free-plan.ts +30 -5
  371. package/src/convex/integrations/billing/functions.ts +3 -2
  372. package/src/convex/integrations/billing/gifts.ts +2 -0
  373. package/src/convex/integrations/billing/history.ts +9 -0
  374. package/src/convex/integrations/billing/lifecycle.ts +3 -1
  375. package/src/convex/integrations/billing/providers/capabilities.ts +78 -0
  376. package/src/convex/integrations/billing/providers/consent.ts +94 -0
  377. package/src/convex/integrations/billing/providers/creem.ts +225 -0
  378. package/src/convex/integrations/billing/providers/dodo.ts +214 -0
  379. package/src/convex/integrations/billing/providers/http.ts +168 -0
  380. package/src/convex/integrations/billing/providers/index.ts +65 -0
  381. package/src/convex/integrations/billing/providers/stripe.ts +345 -0
  382. package/src/convex/integrations/billing/providers/types.ts +281 -0
  383. package/src/convex/integrations/billing/subscriptions.ts +20 -6
  384. package/src/convex/integrations/billing/types/setup.ts +63 -1
  385. package/src/convex/integrations/billing.ts +46 -3
  386. package/src/convex/integrations/email.ts +1 -0
  387. package/src/convex/integrations/launch.ts +45 -7
  388. package/src/convex/integrations/presence.ts +160 -0
  389. package/src/convex/integrations/waitlist.ts +84 -12
  390. package/src/convex/integrations/webhook-guard.ts +20 -4
  391. package/src/convex/label-groups/admin.ts +9 -0
  392. package/src/convex/label-groups/audit.ts +2 -0
  393. package/src/convex/label-groups/auth.ts +10 -0
  394. package/src/convex/label-groups/email.ts +7 -0
  395. package/src/convex/label-groups/errors.ts +4 -0
  396. package/src/convex/label-groups/security.ts +20 -0
  397. package/src/convex/label-groups/waitlist.ts +9 -0
  398. package/src/convex/label-translations.ts +24 -0
  399. package/src/convex/log.ts +2 -0
  400. package/src/convex/sensitive-actions.ts +11 -0
  401. package/src/convex/waitlist-rules.ts +84 -8
  402. package/src/runtime/vue/components/account/SecuritySettings.vue +58 -4
  403. package/src/runtime/vue/components/account/SecurityTwoFactor.css +68 -0
  404. package/src/runtime/vue/components/account/SecurityTwoFactor.vue +113 -0
  405. package/src/runtime/vue/components/admin/AdminWaitlist.css +1 -0
  406. package/src/runtime/vue/components/admin/AdminWaitlistActions.vue +44 -2
  407. package/src/runtime/vue/components/auth/AuthForm.vue +8 -0
  408. package/src/runtime/vue/components/auth/AuthFormTwoFactor.css +40 -0
  409. package/src/runtime/vue/components/auth/AuthFormTwoFactor.vue +75 -0
  410. package/src/runtime/vue/components/auth/AuthFormWaitlisted.vue +11 -4
  411. package/src/runtime/vue/components/auth/WaitlistPlace.css +16 -0
  412. package/src/runtime/vue/components/auth/WaitlistPlace.vue +49 -2
  413. package/src/runtime/vue/components/auth/WaitlistShare.vue +4 -3
  414. package/dist/devtools-client/_nuxt/CiCAOwUc.js +0 -5
@@ -40,6 +40,9 @@ export const tables = {
40
40
  // refuses sign-in codes, and the keyed hash of its recovery code.
41
41
  passkeyOnly: v.optional(v.union(v.null(), v.boolean())),
42
42
  recoveryCodeHash: v.optional(v.union(v.null(), v.string())),
43
+ // The authenticator app (client/two-factor.ts): whether a sign-in code
44
+ // is followed by the app's code.
45
+ twoFactorEnabled: v.optional(v.union(v.null(), v.boolean())),
43
46
  // The app shell's two marks (onboarding.ts): when the account finished
44
47
  // or skipped the first-run steps at /welcome, and when it dismissed the
45
48
  // activation checklist. Written only by the component's own functions.
@@ -104,7 +107,9 @@ export const tables = {
104
107
  updatedAt: v.number(),
105
108
  })
106
109
  .index('expiresAt', ['expiresAt'])
107
- .index('identifier', ['identifier']),
110
+ .index('identifier', ['identifier'])
111
+ // A device the authenticator app trusts holds its account's id here (`trust-device-…`): its erasure finds it by it.
112
+ .index('value', ['value']),
108
113
  rateLimit: defineTable({
109
114
  key: v.string(),
110
115
  count: v.number(),
@@ -128,6 +133,18 @@ export const tables = {
128
133
  })
129
134
  .index('credentialID', ['credentialID'])
130
135
  .index('userId', ['userId']),
136
+ // The authenticator app's secret and backup codes, both encrypted under
137
+ // the auth secret (two-factor plugin), and the lockout after wrong codes.
138
+ twoFactor: defineTable({
139
+ secret: v.string(),
140
+ backupCodes: v.string(),
141
+ userId: v.string(),
142
+ verified: v.optional(v.union(v.null(), v.boolean())),
143
+ failedVerificationCount: v.optional(v.union(v.null(), v.number())),
144
+ lockedUntil: v.optional(v.union(v.null(), v.number())),
145
+ })
146
+ .index('secret', ['secret'])
147
+ .index('userId', ['userId']),
131
148
  // JWKS table is required by the @convex-dev/better-auth convex plugin (always adds jwt plugin for Convex JWT issuance)
132
149
  jwks: defineTable({
133
150
  publicKey: v.string(),
@@ -193,6 +210,21 @@ export const tables = {
193
210
  * Intentionally NOT part of the auth-only `tables` export above, which is the
194
211
  * Better Auth adapter's schema — billing data is the component's own.
195
212
  */
213
+ /** What a paid order on an adapter provider (Stripe, Dodo, Creem) records: `billingCommerceOrders`, and the order `commerce.recordOrder` takes. */
214
+ export const commerceOrderFields = {
215
+ orderId: v.string(),
216
+ provider: v.string(),
217
+ entityId: v.string(),
218
+ productId: v.optional(v.string()),
219
+ subscriptionId: v.optional(v.string()),
220
+ amount: v.number(),
221
+ taxAmount: v.optional(v.number()),
222
+ currency: v.string(),
223
+ }
224
+
225
+ /** Where a recorded order stands: paid, refunded in part or in full, or disputed. */
226
+ export const vCommerceOrderStatus = v.union(v.literal('paid'), v.literal('refunded'), v.literal('partially_refunded'), v.literal('disputed'))
227
+
196
228
  export const vEntitlementBenefit = v.object({
197
229
  id: v.string(),
198
230
  benefitId: v.string(),
@@ -464,6 +496,68 @@ export const billingTables = {
464
496
  at: v.number(),
465
497
  })
466
498
  .index('ownerUserId', ['ownerUserId']),
499
+ // A billing entity's customer at a provider on the neutral adapters
500
+ // (Stripe Managed Payments, Dodo, Creem), which makes one at the first
501
+ // checkout: the next checkout and the portal name it, and a delivery that
502
+ // names only the customer finds its entity by it. Polar's are the
503
+ // provider component's.
504
+ billingCommerceCustomers: defineTable({
505
+ entityId: v.string(),
506
+ provider: v.string(),
507
+ customerId: v.string(),
508
+ })
509
+ .index('entityId_provider', ['entityId', 'provider'])
510
+ .index('provider_customerId', ['provider', 'customerId']),
511
+ // The orders an adapter provider delivered as paid, one row per order:
512
+ // the order history, a refund's lookup, and what a refunded order's
513
+ // credits are taken back by. The provider, the merchant of record, keeps
514
+ // the invoice and the tax.
515
+ billingCommerceOrders: defineTable({
516
+ ...commerceOrderFields,
517
+ status: vCommerceOrderStatus,
518
+ refundedAmount: v.number(),
519
+ /** The refunds counted in `refundedAmount`, by id: a redelivered refund counts once. */
520
+ refundIds: v.array(v.string()),
521
+ createdAt: v.number(),
522
+ })
523
+ .index('orderId', ['orderId'])
524
+ .index('entityId_createdAt', ['entityId', 'createdAt'])
525
+ .index('subscriptionId_createdAt', ['subscriptionId', 'createdAt']),
526
+ // A refund or a dispute that arrived before the order it names, held
527
+ // until the order's own delivery records it: the order then lands
528
+ // refunded or disputed, and its credits go back with it. One row per
529
+ // refund id (a dispute's is `dispute`), so a redelivery is held once.
530
+ billingCommerceReversals: defineTable({
531
+ orderId: v.string(),
532
+ kind: v.union(v.literal('refund'), v.literal('dispute')),
533
+ refundId: v.string(),
534
+ amount: v.optional(v.number()),
535
+ at: v.number(),
536
+ })
537
+ .index('orderId', ['orderId']),
538
+ // Each credit grant on an adapter provider, where no provider meter keeps
539
+ // the balance: once per `externalId` (an order, a free plan's month, a
540
+ // welcome, a refund), so a redelivered event grants once. A plan's grant
541
+ // that does not roll over lapses with what is left of it when the next
542
+ // one lands: `consumedAtGrant` is the meter's consumption when it was
543
+ // granted, so what was spent since is taken from it first.
544
+ billingCreditGrants: defineTable({
545
+ userId: v.string(),
546
+ meterId: v.string(),
547
+ externalId: v.string(),
548
+ amount: v.number(),
549
+ source: v.union(v.literal('plan'), v.literal('pack'), v.literal('grant')),
550
+ rollover: v.boolean(),
551
+ consumedAtGrant: v.number(),
552
+ /** Set once the grant lapsed or was taken back: what of it left the balance. */
553
+ closed: v.optional(v.number()),
554
+ /** The order that paid for it, which a refund or a dispute takes it back with: its own, or a yearly plan's month. */
555
+ orderId: v.optional(v.string()),
556
+ at: v.number(),
557
+ })
558
+ .index('externalId', ['externalId'])
559
+ .index('userId_meterId', ['userId', 'meterId'])
560
+ .index('userId_orderId', ['userId', 'orderId']),
467
561
  // What the provider's subscription carries and the synced subscriptions
468
562
  // table does not: the plan change scheduled for the next period and when a
469
563
  // paused subscription resumes. One row per subscription, written from its
@@ -1729,10 +1823,18 @@ export const waitlistTables = {
1729
1823
  mirrorAt: v.optional(v.number()),
1730
1824
  /** The entry whose link this one joined through. */
1731
1825
  referredBy: v.optional(v.id('waitlistEntries')),
1826
+ /**
1827
+ * The mailbox behind the address (`mailboxOf`: no `+label`, no dots), so
1828
+ * a second address of one mailbox earns its sharer nothing. Absent on
1829
+ * entries made before it was kept.
1830
+ */
1831
+ mailbox: v.optional(v.string()),
1732
1832
  /** Friends that count for it, up to the cap. */
1733
1833
  boost: v.number(),
1734
1834
  /** How far it moved the entry it came through up the line, in the queue key's milliseconds; taken back with it. */
1735
1835
  creditedMs: v.optional(v.number()),
1836
+ /** How far up the line it started, for coming through a friend's link, in the queue key's milliseconds. */
1837
+ welcomeMs: v.optional(v.number()),
1736
1838
  /** The key it holds in the rank aggregate while it waits. */
1737
1839
  rankKey: v.optional(v.number()),
1738
1840
  admittedAt: v.optional(v.number()),
@@ -1741,6 +1843,7 @@ export const waitlistTables = {
1741
1843
  joinedAt: v.optional(v.number()),
1742
1844
  })
1743
1845
  .index('email', ['email'])
1846
+ .index('mailbox', ['mailbox'])
1744
1847
  .index('status_verifiedAt', ['status', 'verifiedAt'])
1745
1848
  .index('mirror_mirrorAt', ['mirror', 'mirrorAt']),
1746
1849
  waitlistJoins: defineTable({
@@ -1765,6 +1868,12 @@ export const waitlistTables = {
1765
1868
  /** The provider's segment and topic for launch news, found or made on the first mirror. */
1766
1869
  segmentId: v.optional(v.string()),
1767
1870
  topicId: v.optional(v.string()),
1871
+ /**
1872
+ * The next wave an administrator planned: how many people it takes from
1873
+ * the front of the line, and when it opens if a date is set. Each
1874
+ * waiting person reads only whether they are in it, never its size.
1875
+ */
1876
+ wave: v.optional(v.object({ size: v.number(), opensAt: v.optional(v.number()) })),
1768
1877
  updatedAt: v.number(),
1769
1878
  }),
1770
1879
  }
@@ -8,13 +8,16 @@ import { LAUNCH_NEWS_KIND, LAUNCH_NEWS_VERSION } from '../../consent-rules.js'
8
8
  import { logBackend } from '../../log.js'
9
9
  import {
10
10
  domainOf,
11
+ friendsShortOf,
11
12
  mailboxOf,
12
13
  queueKey,
14
+ type WaitlistBoostRule,
13
15
  SOURCE_SIGN_IN,
14
16
  WAITLIST_CONSOLE_ROWS,
15
17
  WAITLIST_FILTER_SCAN,
16
18
  WAITLIST_NOTE_MAX,
17
19
  WAITLIST_STATUSES,
20
+ WAITLIST_WAVE_PLAN_MAX,
18
21
  type WaitlistStatus,
19
22
  waitlistEmail,
20
23
  } from '../../waitlist-rules.js'
@@ -170,15 +173,20 @@ export const stage = mutation({
170
173
  /**
171
174
  * The sharer a staged `ref` names, when sharing is allowed: the program's
172
175
  * code of an entry (referral codes are program-wide, and the same mailbox
173
- * rule refuses a person's own), waiting or admitted, under its cap. A code
174
- * that is an account's moves nobody up the line.
176
+ * rule refuses a person's own), waiting or admitted, under its cap if it
177
+ * has one. A code that is an account's moves nobody up the line, and
178
+ * neither does a second address of a mailbox already on the list.
175
179
  */
176
- async function sharerFor(ctx: MutationCtx, ref: string | undefined, email: string, boost: { cap: number, days: number }): Promise<Entry | null> {
177
- const owner = ref && boost.cap >= 1 ? await ownerOfCode(ctx, ref) : null
180
+ async function sharerFor(ctx: MutationCtx, ref: string | undefined, email: string, boost: WaitlistBoostRule): Promise<Entry | null> {
181
+ const sharing = boost.cap === null || boost.cap >= 1
182
+ const owner = ref && sharing ? await ownerOfCode(ctx, ref) : null
178
183
  const entryId = owner?.ownerKind === 'entry' ? ctx.db.normalizeId('waitlistEntries', owner.ownerId) : null
179
184
  const sharer = entryId ? await ctx.db.get('waitlistEntries', entryId) : null
180
185
  if (!sharer || (sharer.status !== 'waiting' && sharer.status !== 'admitted')) return null
181
- if (mailboxOf(sharer.email) === mailboxOf(email) || sharer.boost >= boost.cap) return null
186
+ if (mailboxOf(sharer.email) === mailboxOf(email)) return null
187
+ if (boost.cap !== null && sharer.boost >= boost.cap) return null
188
+ // One mailbox counts once: `me+2@` after `me@` brings its sharer nothing.
189
+ if (await ctx.db.query('waitlistEntries').withIndex('mailbox', q => q.eq('mailbox', mailboxOf(email))).first()) return null
182
190
  return sharer
183
191
  }
184
192
 
@@ -188,10 +196,15 @@ async function enqueueMirror(ctx: MutationCtx, entry: Entry): Promise<void> {
188
196
  await pool.enqueueAction(ctx, internal.waitlist.mirrorOne, { entryId: entry._id }, { onComplete: internal.waitlist.mirrored, context: { entryId: entry._id } })
189
197
  }
190
198
 
191
- const vEntryRef = v.object({ id: v.string(), created: v.boolean(), status: vStatus, source: v.string(), referred: v.boolean(), news: v.boolean() })
199
+ /** The sharer a new entry credited, while they wait: whom to tell, and where they stand now. */
200
+ const vCredited = v.object({ id: v.string(), email: v.string(), locale: v.union(v.null(), v.string()), friends: v.number(), credit: v.number() })
201
+
202
+ const vEntryRef = v.object({ id: v.string(), created: v.boolean(), status: vStatus, source: v.string(), referred: v.boolean(), news: v.boolean(), sharer: v.optional(vCredited) })
203
+
204
+ /** The rule as the access layer hands it over. */
205
+ const vBoost = v.object({ perFriend: v.number(), cap: v.union(v.null(), v.number()), welcome: v.number() })
192
206
 
193
207
  type Join = Doc<'waitlistJoins'>
194
- type Boost = { cap: number, days: number }
195
208
 
196
209
  /**
197
210
  * The launch-news box ticked: a consent, kept on the ledger alone (by a
@@ -212,37 +225,49 @@ async function addToEntry(ctx: MutationCtx, existing: Entry, join: Join | undefi
212
225
  if (join?.launchNews && !wantsNews(existing)) await wantNews(ctx, (await ctx.db.get('waitlistEntries', existing._id))!, join.launchNews.text)
213
226
  }
214
227
 
215
- /** A friend joined through the sharer's link: the sharer moves up, and the friend remembers by how much. */
216
- async function creditSharer(ctx: MutationCtx, friendId: Entry['_id'], sharer: Entry, boost: Boost): Promise<void> {
217
- const credited = boost.days * DAY_MS
228
+ /**
229
+ * A friend joined through the sharer's link: the sharer moves up, and the
230
+ * friend remembers by how much. Answers the sharer as they stand now, for
231
+ * the app to tell them, while they still wait.
232
+ */
233
+ async function creditSharer(ctx: MutationCtx, friendId: Entry['_id'], sharer: Entry, boost: WaitlistBoostRule): Promise<typeof vCredited.type | undefined> {
234
+ const credited = boost.perFriend
218
235
  await ctx.db.patch('waitlistEntries', friendId, { referredBy: sharer._id, creditedMs: credited })
219
236
  await ctx.db.patch('waitlistEntries', sharer._id, { boost: sharer.boost + 1 })
220
- if (sharer.rankKey === undefined) return
221
- if (sharer.status === 'waiting') await enterQueue(ctx, sharer, sharer.rankKey - credited)
222
- else await ctx.db.patch('waitlistEntries', sharer._id, { rankKey: sharer.rankKey - credited })
237
+ if (sharer.rankKey === undefined) return undefined
238
+ if (sharer.status !== 'waiting') {
239
+ await ctx.db.patch('waitlistEntries', sharer._id, { rankKey: sharer.rankKey - credited })
240
+ return undefined
241
+ }
242
+ await enterQueue(ctx, sharer, sharer.rankKey - credited)
243
+ return { id: sharer._id as string, email: sharer.email, locale: sharer.locale ?? null, friends: sharer.boost + 1, credit: sharer.verifiedAt - (sharer.rankKey - credited) }
223
244
  }
224
245
 
225
246
  /** A new entry: its row, its place in line, the friend credit and the contact for launch news. */
226
- async function createEntry(ctx: MutationCtx, input: { address: string, join: Join | undefined, source: string | undefined, locale: string | undefined, now: number, boost: Boost }): Promise<Entry['_id']> {
247
+ async function createEntry(ctx: MutationCtx, input: { address: string, join: Join | undefined, source: string | undefined, locale: string | undefined, now: number, boost: WaitlistBoostRule }): Promise<{ id: Entry['_id'], sharer?: typeof vCredited.type }> {
227
248
  const { address, join, source, locale, now, boost } = input
249
+ // Read before the insert: the new entry's own mailbox must not count against it.
228
250
  const sharer = await sharerFor(ctx, join?.ref, address, boost)
251
+ const welcome = sharer ? boost.welcome : 0
229
252
  const entryLocale = join?.locale ?? locale
230
253
  const id = await ctx.db.insert('waitlistEntries', {
231
254
  email: address,
232
255
  domain: domainOf(address),
256
+ mailbox: mailboxOf(address),
233
257
  status: 'waiting',
234
258
  source: join?.source ?? source ?? SOURCE_SIGN_IN,
235
259
  ...(join?.answers ? { answers: join.answers } : {}),
236
260
  ...(entryLocale ? { locale: entryLocale } : {}),
237
261
  verifiedAt: now,
238
262
  boost: 0,
263
+ ...(welcome ? { welcomeMs: welcome } : {}),
239
264
  })
240
265
  await ensureCode(ctx, 'entry', id)
241
266
  await adjust(ctx, 'waiting', 1)
242
- await enterQueue(ctx, (await ctx.db.get('waitlistEntries', id))!, queueKey(now, 0, boost.days))
243
- if (sharer) await creditSharer(ctx, id, sharer, boost)
267
+ await enterQueue(ctx, (await ctx.db.get('waitlistEntries', id))!, queueKey(now, welcome))
268
+ const told = sharer ? await creditSharer(ctx, id, sharer, boost) : undefined
244
269
  if (join?.launchNews) await wantNews(ctx, (await ctx.db.get('waitlistEntries', id))!, join.launchNews.text)
245
- return id
270
+ return { id, ...(told ? { sharer: told } : {}) }
246
271
  }
247
272
 
248
273
  /**
@@ -255,7 +280,7 @@ async function createEntry(ctx: MutationCtx, input: { address: string, join: Joi
255
280
  * (a later join may add launch news or answers).
256
281
  */
257
282
  export const verify = mutation({
258
- args: { email: v.string(), join: v.optional(v.string()), source: v.optional(v.string()), locale: v.optional(v.string()), boost: v.object({ cap: v.number(), days: v.number() }) },
283
+ args: { email: v.string(), join: v.optional(v.string()), source: v.optional(v.string()), locale: v.optional(v.string()), boost: vBoost },
259
284
  returns: vEntryRef,
260
285
  handler: async (ctx, { email, join, source, locale, boost }) => {
261
286
  const address = waitlistEmail(email)
@@ -266,55 +291,122 @@ export const verify = mutation({
266
291
  : []
267
292
  const existing = await ctx.db.query('waitlistEntries').withIndex('email', q => q.eq('email', address)).first()
268
293
  if (existing) await addToEntry(ctx, existing, staged[0])
269
- const entryId = existing?._id ?? await createEntry(ctx, { address, join: staged[0], source, locale, now, boost })
294
+ const made = existing ? undefined : await createEntry(ctx, { address, join: staged[0], source, locale, now, boost })
270
295
  for (const row of staged) await ctx.db.delete('waitlistJoins', row._id)
271
- const row = (await ctx.db.get('waitlistEntries', entryId))!
272
- return { id: row._id as string, created: !existing, status: row.status, source: row.source, referred: row.referredBy !== undefined, news: wantsNews(row) }
296
+ const row = (await ctx.db.get('waitlistEntries', existing?._id ?? made!.id))!
297
+ return { id: row._id as string, created: !existing, status: row.status, source: row.source, referred: row.referredBy !== undefined, news: wantsNews(row), ...(made?.sharer ? { sharer: made.sharer } : {}) }
273
298
  },
274
299
  })
275
300
 
276
301
  // ── Reading ─────────────────────────────────────────────────────────────
277
302
 
303
+ /** Where a waiting person stands against the planned wave: in it or not, never its size. */
304
+ const vWaveStanding = v.object({
305
+ opensAt: v.union(v.null(), v.number()),
306
+ included: v.boolean(),
307
+ /** Friends short of it; 0 inside it, `null` when friends cannot move anyone. */
308
+ friendsShort: v.union(v.null(), v.number()),
309
+ })
310
+
278
311
  const vPlace = v.object({
279
312
  status: vStatus,
280
- /** 1-based place among the people waiting; `null` once the person is not waiting. */
313
+ /** 1-based place among the people waiting; `null` once the person is not waiting, or when rank is not read. */
281
314
  position: v.union(v.null(), v.number()),
315
+ /** How many wait; 0 when rank is not read. */
282
316
  total: v.number(),
283
317
  boost: v.number(),
318
+ /** How far up the line friends (and a welcome) moved the entry, in ms; 0 once it stops waiting. */
319
+ credit: v.number(),
284
320
  shareCode: v.string(),
285
321
  launchNews: v.boolean(),
286
322
  verifiedAt: v.number(),
323
+ wave: v.union(v.null(), vWaveStanding),
287
324
  })
288
325
 
289
- /** An entry's standing, from the (stale) queue. `null` for an id that is no entry. */
290
- async function placeOf(ctx: QueryCtx, entry: Entry): Promise<typeof vPlace.type> {
326
+ /** The planned wave, if an administrator set one. */
327
+ async function plannedWave(ctx: QueryCtx): Promise<{ size: number, opensAt?: number } | null> {
328
+ return (await ctx.db.query('waitlistSettings').first())?.wave ?? null
329
+ }
330
+
331
+ /**
332
+ * A waiting entry against the planned wave: inside it when fewer than its
333
+ * size stand ahead, else how many friends would carry it past the last
334
+ * person inside. Read from the stale queue, like the place.
335
+ */
336
+ async function waveStanding(ctx: QueryCtx, entry: Entry, perFriend: number | null): Promise<typeof vWaveStanding.type | null> {
337
+ if (entry.status !== 'waiting' || entry.rankKey === undefined) return null
338
+ const wave = await plannedWave(ctx)
339
+ if (!wave) return null
340
+ const opensAt = wave.opensAt ?? null
341
+ const ahead = await rank.indexOf(ctx, entry.rankKey, { id: entry._id, stale: true })
342
+ if (ahead < wave.size) return { opensAt, included: true, friendsShort: 0 }
343
+ if (!perFriend) return { opensAt, included: false, friendsShort: null }
344
+ const last = await rank.at(ctx, wave.size - 1, { stale: true })
345
+ return { opensAt, included: false, friendsShort: Math.max(1, friendsShortOf(entry.rankKey, last.key, perFriend)) }
346
+ }
347
+
348
+ /**
349
+ * An entry's standing, from the (stale) queue. `rank: false` reads no
350
+ * place and no count, so nothing about the size of the list comes back.
351
+ */
352
+ async function placeOf(ctx: QueryCtx, entry: Entry, options: { rank: boolean, perFriend: number | null }): Promise<typeof vPlace.type> {
291
353
  const code = await peekOwnerCode(ctx, 'entry', entry._id)
292
- const total = await rank.count(ctx, { stale: true })
354
+ const waiting = entry.status === 'waiting' && entry.rankKey !== undefined
293
355
  let position: number | null = null
294
- if (entry.status === 'waiting' && entry.rankKey !== undefined) {
356
+ let total = 0
357
+ if (options.rank) {
358
+ total = await rank.count(ctx, { stale: true })
295
359
  // The count of people ahead needs no row for this entry: a join still
296
360
  // in the queue's backlog is placed where it will land.
297
- position = (await rank.indexOf(ctx, entry.rankKey, { id: entry._id, stale: true })) + 1
361
+ if (waiting) position = (await rank.indexOf(ctx, entry.rankKey!, { id: entry._id, stale: true })) + 1
362
+ total = Math.max(total, position ?? 0)
298
363
  }
299
364
  return {
300
365
  status: entry.status,
301
366
  position,
302
- total: Math.max(total, position ?? 0),
367
+ total,
303
368
  boost: entry.boost,
369
+ credit: waiting ? Math.max(0, entry.verifiedAt - entry.rankKey!) : 0,
304
370
  shareCode: code?.code ?? '',
305
371
  launchNews: wantsNews(entry),
306
372
  verifiedAt: entry.verifiedAt,
373
+ wave: await waveStanding(ctx, entry, options.perFriend),
307
374
  }
308
375
  }
309
376
 
310
- /** An entry's place in line, by its id (the app checked the signed link that names it). */
377
+ /**
378
+ * An entry's place in line, by its id (the app checked the signed link that
379
+ * names it). `rank: false` leaves the place and the count out; `perFriend`
380
+ * is the app's rule, for how many friends short of the wave it stands.
381
+ */
311
382
  export const place = query({
312
- args: { id: v.string() },
383
+ args: { id: v.string(), rank: v.optional(v.boolean()), perFriend: v.optional(v.union(v.null(), v.number())) },
313
384
  returns: v.union(v.null(), vPlace),
314
- handler: async (ctx, { id }) => {
385
+ handler: async (ctx, { id, rank: withRank, perFriend }) => {
315
386
  const entryId = ctx.db.normalizeId('waitlistEntries', id)
316
387
  const entry = entryId ? await ctx.db.get('waitlistEntries', entryId) : null
317
- return entry ? await placeOf(ctx, entry) : null
388
+ return entry ? await placeOf(ctx, entry, { rank: withRank !== false, perFriend: perFriend ?? null }) : null
389
+ },
390
+ })
391
+
392
+ /**
393
+ * Plan the next wave: how many people it takes from the front of the line,
394
+ * and when it opens, if a date is set. `null` clears the plan. Waiting
395
+ * people read only whether they are in it.
396
+ */
397
+ export const planWave = mutation({
398
+ args: { wave: v.union(v.null(), v.object({ size: v.number(), opensAt: v.optional(v.number()) })) },
399
+ returns: v.null(),
400
+ handler: async (ctx, { wave }) => {
401
+ if (wave && (!Number.isInteger(wave.size) || wave.size < 1 || wave.size > WAITLIST_WAVE_PLAN_MAX)) {
402
+ throw backendError('invalid_input', { field: 'size' }, `[nuxt-backend] planWaitlistWave: the size is a whole number from 1 to ${WAITLIST_WAVE_PLAN_MAX}.`)
403
+ }
404
+ if (wave?.opensAt !== undefined && !Number.isFinite(wave.opensAt)) throw backendError('invalid_input', { field: 'opensAt' }, '[nuxt-backend] planWaitlistWave: the opening date is a time in epoch ms.')
405
+ const row = await ctx.db.query('waitlistSettings').first()
406
+ const fields = { wave: wave ? { size: wave.size, ...(wave.opensAt !== undefined ? { opensAt: wave.opensAt } : {}) } : undefined, updatedAt: Date.now() }
407
+ if (row) await ctx.db.patch('waitlistSettings', row._id, fields)
408
+ else await ctx.db.insert('waitlistSettings', fields)
409
+ return null
318
410
  },
319
411
  })
320
412
 
@@ -385,6 +477,12 @@ async function filteredEntries(ctx: QueryCtx, { status, domain, source, question
385
477
  const wanted = domain?.trim().toLowerCase().replace(/^@/, '')
386
478
  const byAnswer = question && answer ? { question, answer } : null
387
479
  const filtered = Boolean(wanted || source || byAnswer)
480
+ // The waiting, unfiltered, in the order of the line: who the next wave takes.
481
+ if (!filtered && (status ?? 'waiting') === 'waiting') {
482
+ const page = await rank.paginate(ctx, { pageSize: WAITLIST_CONSOLE_ROWS, stale: true })
483
+ const rows = await Promise.all(page.page.map(item => ctx.db.get('waitlistEntries', item.id as Entry['_id'])))
484
+ return rows.filter((entry): entry is Entry => entry?.status === 'waiting')
485
+ }
388
486
  const scanned = await ctx.db.query('waitlistEntries').withIndex('status_verifiedAt', q => q.eq('status', status ?? 'waiting')).take(filtered ? WAITLIST_FILTER_SCAN : WAITLIST_CONSOLE_ROWS)
389
487
  return scanned
390
488
  .filter(entry => (!wanted || entry.domain === wanted) && (!source || entry.source === source) && (!byAnswer || entry.answers?.[byAnswer.question] === byAnswer.answer))
@@ -414,9 +512,10 @@ async function mirrorBacklog(ctx: QueryCtx): Promise<{ pending: number, drift: n
414
512
  }
415
513
 
416
514
  /**
417
- * The Waitlist tab's rows: the oldest entries of a status first, narrowed
418
- * by domain, source or an answer (a filter looks through the oldest
419
- * {@link WAITLIST_FILTER_SCAN} of the status), and a count per status.
515
+ * The Waitlist tab's rows: the people waiting in the order of the line, or
516
+ * the oldest entries of another status first, narrowed by domain, source or
517
+ * an answer (a filter looks through the oldest {@link WAITLIST_FILTER_SCAN}
518
+ * of the status), a count per status and the planned wave.
420
519
  */
421
520
  export const consoleRows = query({
422
521
  args: { status: v.optional(vStatus), domain: v.optional(v.string()), source: v.optional(v.string()), question: v.optional(v.string()), answer: v.optional(v.string()) },
@@ -424,12 +523,17 @@ export const consoleRows = query({
424
523
  counts: v.object({ waiting: v.number(), admitted: v.number(), declined: v.number(), joined: v.number() }),
425
524
  mirror: v.object({ pending: v.number(), drift: v.number() }),
426
525
  entries: v.array(vConsoleEntry),
526
+ wave: v.union(v.null(), v.object({ size: v.number(), opensAt: v.union(v.null(), v.number()) })),
427
527
  }),
428
- handler: async (ctx, filter) => ({
429
- counts: await statusCounts(ctx),
430
- mirror: await mirrorBacklog(ctx),
431
- entries: (await filteredEntries(ctx, filter)).map(consoleEntry),
432
- }),
528
+ handler: async (ctx, filter) => {
529
+ const wave = await plannedWave(ctx)
530
+ return {
531
+ counts: await statusCounts(ctx),
532
+ mirror: await mirrorBacklog(ctx),
533
+ entries: (await filteredEntries(ctx, filter)).map(consoleEntry),
534
+ wave: wave ? { size: wave.size, opensAt: wave.opensAt ?? null } : null,
535
+ }
536
+ },
433
537
  })
434
538
 
435
539
  // ── Leaving, admitting, declining ───────────────────────────────────────
@@ -20,6 +20,7 @@ import { noticeDecided } from './emails/notice-decided.js'
20
20
  import { contentRestricted } from './emails/content-restricted.js'
21
21
  import { appealDecided } from './emails/appeal-decided.js'
22
22
  import { waitlistConfirmation } from './emails/waitlist-confirmation.js'
23
+ import { waitlistFriendJoined } from './emails/waitlist-friend-joined.js'
23
24
  import { welcome } from './emails/welcome.js'
24
25
  import { withdrawalReceipt } from './emails/withdrawal-receipt.js'
25
26
  import { TRANSLATED_LOCALES } from './label-format.js'
@@ -308,6 +309,17 @@ export interface WaitlistConfirmationEmailData {
308
309
  total?: number
309
310
  }
310
311
 
312
+ /** Data for the `waitlistFriendJoined` template. */
313
+ export interface WaitlistFriendJoinedEmailData {
314
+ email: string
315
+ /** The person's status page, with its signed token in the fragment. */
316
+ statusUrl: string
317
+ /** How many friends have joined with their link so far. */
318
+ friends: number
319
+ /** How far up the line their friends moved them, in whole days. */
320
+ days: number
321
+ }
322
+
311
323
  /** Data for the `topicConfirmation` template. */
312
324
  export interface TopicConfirmationEmailData {
313
325
  email: string
@@ -459,6 +471,8 @@ export interface EmailTemplates {
459
471
  withdrawalReceipt: (data: WithdrawalReceiptEmailData, context: EmailRenderContext) => EmailMessage | Promise<EmailMessage>
460
472
  /** Sent once to a person whose sign-in code checked while the app is in early access: their place, and the link that shows it again. */
461
473
  waitlistConfirmation: (data: WaitlistConfirmationEmailData, context: EmailRenderContext) => EmailMessage | Promise<EmailMessage>
474
+ /** Sent to a waiting person, at most once a day, when a friend joins with their link (`setupAccess({ waitlist: { boost: { notify: true } } })`). */
475
+ waitlistFriendJoined: (data: WaitlistFriendJoinedEmailData, context: EmailRenderContext) => EmailMessage | Promise<EmailMessage>
462
476
  /** Sent once when an administrator admits a waitlist entry: a plain "You're in", with no token and no promotion. */
463
477
  waitlistAdmitted: (data: WaitlistAdmittedEmailData, context: EmailRenderContext) => EmailMessage | Promise<EmailMessage>
464
478
  /** A double opt-in's confirmation: one button that joins the topic the person asked for. */
@@ -725,6 +739,7 @@ export const PACKAGED_EMAIL_TEMPLATES: { [Name in EmailTemplateName]: (data: Ema
725
739
  gift: inLayout(gift),
726
740
  giftPassEnding: inLayout(giftPassEnding),
727
741
  waitlistConfirmation: inLayout(waitlistConfirmation),
742
+ waitlistFriendJoined: inLayout(waitlistFriendJoined),
728
743
  waitlistAdmitted: inLayout(waitlistAdmitted),
729
744
  topicConfirmation: inLayout(topicConfirmation),
730
745
  noticeReceived: inLayout(noticeReceived),
@@ -1001,6 +1016,7 @@ export const EMAIL_PREVIEW_SAMPLES: readonly PreviewSample[] = [
1001
1016
  { key: 'welcome', template: 'welcome', note: 'Once, right after an account is created.', data: () => ({ email: SAMPLE_EMAIL, name: SAMPLE_NAME }) } satisfies PreviewSample<'welcome'>,
1002
1017
  { key: 'invite', template: 'invite', note: 'A workspace invitation, with its accept link.', data: site => ({ email: 'grace@example.com', url: `${site}/accept-invitation?id=sample`, inviterName: SAMPLE_NAME, inviterEmail: SAMPLE_EMAIL, workspaceName: 'Analytical Engines', role: 'member' }) } satisfies PreviewSample<'invite'>,
1003
1018
  { key: 'waitlistConfirmation', template: 'waitlistConfirmation', note: 'Once, to a person whose sign-in code checked while the app is in early access.', data: site => ({ email: SAMPLE_EMAIL, statusUrl: `${site}/waitlist#sample`, position: 48, total: 1204 }) } satisfies PreviewSample<'waitlistConfirmation'>,
1019
+ { key: 'waitlistFriendJoined', template: 'waitlistFriendJoined', note: 'At most once a day, to a waiting person whose link a friend joined with, when the waitlist tells sharers.', data: site => ({ email: SAMPLE_EMAIL, statusUrl: `${site}/waitlist#sample`, friends: 3, days: 3 }) } satisfies PreviewSample<'waitlistFriendJoined'>,
1004
1020
  { key: 'waitlistAdmitted', template: 'waitlistAdmitted', note: 'Once, when an administrator admits a waitlist entry.', data: site => ({ email: SAMPLE_EMAIL, signInUrl: `${site}/login` }) } satisfies PreviewSample<'waitlistAdmitted'>,
1005
1021
  { key: 'topicConfirmation', template: 'topicConfirmation', note: 'When a person asks to join a topic with double opt-in.', data: site => ({ email: SAMPLE_EMAIL, topic: 'Product news', confirmUrl: `${site}/unsubscribe?confirm=c1.sample` }) } satisfies PreviewSample<'topicConfirmation'>,
1006
1022
  { key: 'noticeReceived', template: 'noticeReceived', note: 'To a person who sent a notice through the report page, as it arrives.', data: site => ({ email: SAMPLE_EMAIL, url: `${site}/strips/sample`, intimate: false }) } satisfies PreviewSample<'noticeReceived'>,
@@ -0,0 +1,23 @@
1
+ import type { EmailMessage, EmailRenderContext, WaitlistFriendJoinedEmailData } from '../email-templates.js'
2
+ import { linkBlocks } from '../email-helpers.js'
3
+
4
+ /**
5
+ * The `waitlistFriendJoined` email: a friend joined with the person's link,
6
+ * how many have so far, and the link that shows their place. The labels get
7
+ * `count` (the friends), `days` and `weeks` (the credit they earned), so an
8
+ * app can say it in its own unit.
9
+ */
10
+ export function waitlistFriendJoined({ email, statusUrl, friends, days }: WaitlistFriendJoinedEmailData, context: EmailRenderContext): EmailMessage {
11
+ const { t } = context
12
+ const params = { count: friends, days, weeks: Math.floor(days / 7) }
13
+ const intro = t('email.waitlistFriendJoined.intro', params)
14
+ const note = t('email.waitlistFriendJoined.note', params)
15
+ const link = context.link(statusUrl)
16
+ return {
17
+ to: email,
18
+ subject: t('email.waitlistFriendJoined.subject', params),
19
+ blocks: [{ paragraph: intro }, { paragraph: note }, ...linkBlocks(link, t('email.waitlistFriendJoined.action'), context)],
20
+ text: `${intro}\n\n${note}\n\n${link}`,
21
+ preheader: intro,
22
+ }
23
+ }
@@ -72,7 +72,7 @@ const personMessage = v.optional(v.string())
72
72
  */
73
73
  export const BACKEND_ERRORS = {
74
74
  unauthenticated: { status: 401, data: v.object({ message: personMessage }) },
75
- forbidden: { status: 403, data: v.object({ reason: v.string(), message: personMessage, phase: v.optional(v.string()), invite: v.optional(v.string()), kind: v.optional(v.string()), until: v.optional(v.number()), waitlist: v.optional(v.object({ position: v.number(), total: v.number(), token: v.string() })) }) },
75
+ forbidden: { status: 403, data: v.object({ reason: v.string(), message: personMessage, phase: v.optional(v.string()), invite: v.optional(v.string()), kind: v.optional(v.string()), until: v.optional(v.number()), waitlist: v.optional(v.object({ position: v.optional(v.number()), total: v.optional(v.number()), token: v.string() })) }) },
76
76
  reauthentication_required: { status: 403, data: v.object({ message: personMessage }) },
77
77
  no_workspace: { status: 409, data: v.object({ message: personMessage }) },
78
78
  rate_limited: {
@@ -385,6 +385,10 @@ const AUTH_INPUTS: Record<string, { field: string, reason?: string }> = {
385
385
  AUTHENTICATION_FAILED: { field: 'passkey' },
386
386
  CHALLENGE_NOT_FOUND: { field: 'passkey' },
387
387
  FAILED_TO_VERIFY_REGISTRATION: { field: 'passkey' },
388
+ INVALID_CODE: { field: 'twoFactorCode' },
389
+ INVALID_BACKUP_CODE: { field: 'twoFactorCode', reason: 'backup_code' },
390
+ INVALID_TWO_FACTOR_COOKIE: { field: 'twoFactorCode', reason: 'two_factor_expired' },
391
+ TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: { field: 'twoFactorCode', reason: 'two_factor_expired' },
388
392
  }
389
393
 
390
394
  /**
@@ -396,6 +400,15 @@ const AUTH_INPUTS: Record<string, { field: string, reason?: string }> = {
396
400
  */
397
401
  const PASSKEY_SIGN_IN_REFUSALS = ['PASSKEY_NOT_FOUND', 'AUTHENTICATION_FAILED']
398
402
 
403
+ /**
404
+ * The two-factor plugin's refusals of the second step, also sent as 401: a
405
+ * code from the app or a backup code that is not right, and a challenge
406
+ * that ended (its ten minutes passed, or it was used). Each refuses the
407
+ * code; the person signs in again only for the last, which the
408
+ * `two_factor_expired` label says.
409
+ */
410
+ const TWO_FACTOR_REFUSALS = ['INVALID_CODE', 'INVALID_BACKUP_CODE', 'INVALID_TWO_FACTOR_COOKIE']
411
+
399
412
  /**
400
413
  * Better Auth's refusals of a session whose sign-in is too old for the
401
414
  * route: `SESSION_NOT_FRESH` (403, the passkey registration and the
@@ -429,7 +442,7 @@ function fromAuthBody(body: Record<string, unknown>, status: unknown): BackendEr
429
442
  const code = typeof body.code === 'string' ? body.code : undefined
430
443
  // A route that asks for a recent sign-in, whatever status it answers it with.
431
444
  if (code && STALE_SESSION_CODES.includes(code)) return read('reauthentication_required', {})
432
- const input = code && (status === 400 || (status === 401 && PASSKEY_SIGN_IN_REFUSALS.includes(code))) ? authInput(code) : undefined
445
+ const input = code && (status === 400 || (status === 401 && (PASSKEY_SIGN_IN_REFUSALS.includes(code) || TWO_FACTOR_REFUSALS.includes(code)))) ? authInput(code) : undefined
433
446
  if (input) return read('invalid_input', input)
434
447
  if (status === 401) return read('unauthenticated', {})
435
448
  if (status === 403) return forbiddenFromAuth(code, body.message)
@@ -318,6 +318,20 @@ export const BACKEND_EVENTS = {
318
318
  description: 'An administrator (the actor) declined `count` waitlist entries; `abuse` that they were removed as abuse, which takes back what each gave the friend who shared with it.',
319
319
  recordedBy: '`waitlist:declineWaitlist` (`setupWaitlist`), from the admin console\'s Waitlist tab',
320
320
  },
321
+ 'waitlist.friend_joined': {
322
+ scope: 'account',
323
+ data: { friends: NUMBER },
324
+ channels: [],
325
+ description: 'A new waitlist entry came through a waiting person\'s share link and moved them up the line: `friends` is how many friends count for that person now. Never either address. Neither has an account, so there is no actor.',
326
+ recordedBy: 'The code check of a new address in early access (`setupAccess`\'s sign-in hooks)',
327
+ },
328
+ 'waitlist.wave_planned': {
329
+ scope: 'account',
330
+ data: { size: OPTIONAL_NUMBER, opensAt: OPTIONAL_NUMBER },
331
+ channels: [],
332
+ description: 'An administrator (the actor) planned the next wave: `size` people from the front of the line, opening at `opensAt` (epoch ms) when a date was set. No `size` means the plan was cleared.',
333
+ recordedBy: '`waitlist:planWaitlistWave` (`setupWaitlist`), from the admin console\'s Waitlist tab',
334
+ },
321
335
  'report.decided': {
322
336
  scope: 'account',
323
337
  data: { action: STRING, ground: STRING, reports: NUMBER, reason: STRING, table: OPTIONAL_STRING },