nuxt-backend 0.5.0 → 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.
- package/README.md +8 -4
- package/dist/capabilities/registry.js +1 -1
- package/dist/chunks/catalog.mjs +1 -1
- package/dist/chunks/{index.mjs → devtools.mjs} +2 -2
- package/dist/chunks/doctor.mjs +14 -6
- package/dist/chunks/email-previews.mjs +1 -1
- package/dist/chunks/health.mjs +2 -2
- package/dist/chunks/install.mjs +4 -4
- package/dist/chunks/run.mjs +1 -1
- package/dist/chunks/server.mjs +15 -4
- package/dist/cli.mjs +28 -8
- package/dist/convex/access-tickets.d.ts +17 -2
- package/dist/convex/access-tickets.d.ts.map +1 -1
- package/dist/convex/account-data.d.ts +4 -4
- package/dist/convex/account-data.d.ts.map +1 -1
- package/dist/convex/account-data.js +5 -4
- package/dist/convex/account-data.js.map +1 -1
- package/dist/convex/app.d.ts +1 -0
- package/dist/convex/app.d.ts.map +1 -1
- package/dist/convex/app.js +2 -1
- package/dist/convex/app.js.map +1 -1
- package/dist/convex/client/better-auth-options.d.ts.map +1 -1
- package/dist/convex/client/better-auth-options.js +12 -3
- package/dist/convex/client/better-auth-options.js.map +1 -1
- package/dist/convex/client/component.d.ts +4 -0
- package/dist/convex/client/component.d.ts.map +1 -1
- package/dist/convex/client/index.d.ts +5 -0
- package/dist/convex/client/index.d.ts.map +1 -1
- package/dist/convex/client/launch-gate.d.ts.map +1 -1
- package/dist/convex/client/launch-gate.js +30 -1
- package/dist/convex/client/launch-gate.js.map +1 -1
- package/dist/convex/client/plugins.d.ts.map +1 -1
- package/dist/convex/client/plugins.js +3 -0
- package/dist/convex/client/plugins.js.map +1 -1
- package/dist/convex/client/two-factor.d.ts +7 -0
- package/dist/convex/client/two-factor.d.ts.map +1 -0
- package/dist/convex/client/two-factor.js +57 -0
- package/dist/convex/client/two-factor.js.map +1 -0
- package/dist/convex/components/backend/_generated/api.d.ts +2 -0
- package/dist/convex/components/backend/_generated/api.d.ts.map +1 -1
- package/dist/convex/components/backend/_generated/api.js.map +1 -1
- package/dist/convex/components/backend/_generated/component.d.ts +292 -10
- package/dist/convex/components/backend/_generated/component.d.ts.map +1 -1
- package/dist/convex/components/backend/account.d.ts +63 -17
- package/dist/convex/components/backend/account.d.ts.map +1 -1
- package/dist/convex/components/backend/account.js +24 -1
- package/dist/convex/components/backend/account.js.map +1 -1
- package/dist/convex/components/backend/adapter.d.ts.map +1 -1
- package/dist/convex/components/backend/adapter.js +7 -2
- package/dist/convex/components/backend/adapter.js.map +1 -1
- package/dist/convex/components/backend/ai.d.ts +1 -1
- package/dist/convex/components/backend/billing.d.ts +10 -0
- package/dist/convex/components/backend/billing.d.ts.map +1 -1
- package/dist/convex/components/backend/billing.js +2 -1
- package/dist/convex/components/backend/billing.js.map +1 -1
- package/dist/convex/components/backend/commerce.d.ts +229 -0
- package/dist/convex/components/backend/commerce.d.ts.map +1 -0
- package/dist/convex/components/backend/commerce.js +392 -0
- package/dist/convex/components/backend/commerce.js.map +1 -0
- package/dist/convex/components/backend/funnel.d.ts +6 -6
- package/dist/convex/components/backend/jobs.d.ts +1 -1
- package/dist/convex/components/backend/referrals.d.ts +2 -2
- package/dist/convex/components/backend/schema.d.ts +327 -21
- package/dist/convex/components/backend/schema.d.ts.map +1 -1
- package/dist/convex/components/backend/schema.js +108 -1
- package/dist/convex/components/backend/schema.js.map +1 -1
- package/dist/convex/components/backend/waitlist.d.ts +42 -6
- package/dist/convex/components/backend/waitlist.d.ts.map +1 -1
- package/dist/convex/components/backend/waitlist.js +142 -39
- package/dist/convex/components/backend/waitlist.js.map +1 -1
- package/dist/convex/email-templates.d.ts +12 -0
- package/dist/convex/email-templates.d.ts.map +1 -1
- package/dist/convex/email-templates.js +3 -0
- package/dist/convex/email-templates.js.map +1 -1
- package/dist/convex/emails/waitlist-friend-joined.d.ts +9 -0
- package/dist/convex/emails/waitlist-friend-joined.d.ts.map +1 -0
- package/dist/convex/emails/waitlist-friend-joined.js +22 -0
- package/dist/convex/emails/waitlist-friend-joined.js.map +1 -0
- package/dist/convex/errors.d.ts +6 -6
- package/dist/convex/errors.d.ts.map +1 -1
- package/dist/convex/errors.js +14 -2
- package/dist/convex/errors.js.map +1 -1
- package/dist/convex/events.d.ts +19 -0
- package/dist/convex/events.d.ts.map +1 -1
- package/dist/convex/events.js +14 -0
- package/dist/convex/events.js.map +1 -1
- package/dist/convex/integrations/billing/checkout.d.ts +2 -2
- package/dist/convex/integrations/billing/checkout.d.ts.map +1 -1
- package/dist/convex/integrations/billing/checkout.js +79 -11
- package/dist/convex/integrations/billing/checkout.js.map +1 -1
- package/dist/convex/integrations/billing/commerce-entitlements.d.ts +12 -0
- package/dist/convex/integrations/billing/commerce-entitlements.d.ts.map +1 -0
- package/dist/convex/integrations/billing/commerce-entitlements.js +78 -0
- package/dist/convex/integrations/billing/commerce-entitlements.js.map +1 -0
- package/dist/convex/integrations/billing/commerce-events.d.ts +15 -0
- package/dist/convex/integrations/billing/commerce-events.d.ts.map +1 -0
- package/dist/convex/integrations/billing/commerce-events.js +433 -0
- package/dist/convex/integrations/billing/commerce-events.js.map +1 -0
- package/dist/convex/integrations/billing/commerce-history.d.ts +20 -0
- package/dist/convex/integrations/billing/commerce-history.d.ts.map +1 -0
- package/dist/convex/integrations/billing/commerce-history.js +106 -0
- package/dist/convex/integrations/billing/commerce-history.js.map +1 -0
- package/dist/convex/integrations/billing/commerce-webhooks.d.ts +23 -0
- package/dist/convex/integrations/billing/commerce-webhooks.d.ts.map +1 -0
- package/dist/convex/integrations/billing/commerce-webhooks.js +49 -0
- package/dist/convex/integrations/billing/commerce-webhooks.js.map +1 -0
- package/dist/convex/integrations/billing/commerce.d.ts +100 -0
- package/dist/convex/integrations/billing/commerce.d.ts.map +1 -0
- package/dist/convex/integrations/billing/commerce.js +323 -0
- package/dist/convex/integrations/billing/commerce.js.map +1 -0
- package/dist/convex/integrations/billing/context.d.ts +8 -0
- package/dist/convex/integrations/billing/context.d.ts.map +1 -1
- package/dist/convex/integrations/billing/context.js +14 -2
- package/dist/convex/integrations/billing/context.js.map +1 -1
- package/dist/convex/integrations/billing/credits.d.ts +1 -1
- package/dist/convex/integrations/billing/credits.d.ts.map +1 -1
- package/dist/convex/integrations/billing/credits.js +49 -28
- package/dist/convex/integrations/billing/credits.js.map +1 -1
- package/dist/convex/integrations/billing/customers.d.ts +1 -1
- package/dist/convex/integrations/billing/customers.d.ts.map +1 -1
- package/dist/convex/integrations/billing/customers.js +15 -1
- package/dist/convex/integrations/billing/customers.js.map +1 -1
- package/dist/convex/integrations/billing/entitlements.d.ts +1 -1
- package/dist/convex/integrations/billing/entitlements.d.ts.map +1 -1
- package/dist/convex/integrations/billing/entitlements.js +6 -1
- package/dist/convex/integrations/billing/entitlements.js.map +1 -1
- package/dist/convex/integrations/billing/erasure.d.ts +1 -1
- package/dist/convex/integrations/billing/erasure.d.ts.map +1 -1
- package/dist/convex/integrations/billing/erasure.js +10 -5
- package/dist/convex/integrations/billing/erasure.js.map +1 -1
- package/dist/convex/integrations/billing/free-plan.d.ts +6 -1
- package/dist/convex/integrations/billing/free-plan.d.ts.map +1 -1
- package/dist/convex/integrations/billing/free-plan.js +22 -4
- package/dist/convex/integrations/billing/free-plan.js.map +1 -1
- package/dist/convex/integrations/billing/functions.d.ts +1 -1
- package/dist/convex/integrations/billing/functions.d.ts.map +1 -1
- package/dist/convex/integrations/billing/functions.js +3 -2
- package/dist/convex/integrations/billing/functions.js.map +1 -1
- package/dist/convex/integrations/billing/gifts.d.ts.map +1 -1
- package/dist/convex/integrations/billing/gifts.js +3 -0
- package/dist/convex/integrations/billing/gifts.js.map +1 -1
- package/dist/convex/integrations/billing/history.d.ts +1 -1
- package/dist/convex/integrations/billing/history.d.ts.map +1 -1
- package/dist/convex/integrations/billing/history.js +6 -1
- package/dist/convex/integrations/billing/history.js.map +1 -1
- package/dist/convex/integrations/billing/lifecycle.d.ts +1 -1
- package/dist/convex/integrations/billing/lifecycle.d.ts.map +1 -1
- package/dist/convex/integrations/billing/lifecycle.js +4 -1
- package/dist/convex/integrations/billing/lifecycle.js.map +1 -1
- package/dist/convex/integrations/billing/providers/capabilities.d.ts +17 -0
- package/dist/convex/integrations/billing/providers/capabilities.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/capabilities.js +77 -0
- package/dist/convex/integrations/billing/providers/capabilities.js.map +1 -0
- package/dist/convex/integrations/billing/providers/consent.d.ts +52 -0
- package/dist/convex/integrations/billing/providers/consent.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/consent.js +79 -0
- package/dist/convex/integrations/billing/providers/consent.js.map +1 -0
- package/dist/convex/integrations/billing/providers/creem.d.ts +22 -0
- package/dist/convex/integrations/billing/providers/creem.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/creem.js +208 -0
- package/dist/convex/integrations/billing/providers/creem.js.map +1 -0
- package/dist/convex/integrations/billing/providers/dodo.d.ts +15 -0
- package/dist/convex/integrations/billing/providers/dodo.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/dodo.js +197 -0
- package/dist/convex/integrations/billing/providers/dodo.js.map +1 -0
- package/dist/convex/integrations/billing/providers/http.d.ts +41 -0
- package/dist/convex/integrations/billing/providers/http.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/http.js +146 -0
- package/dist/convex/integrations/billing/providers/http.js.map +1 -0
- package/dist/convex/integrations/billing/providers/index.d.ts +35 -0
- package/dist/convex/integrations/billing/providers/index.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/index.js +62 -0
- package/dist/convex/integrations/billing/providers/index.js.map +1 -0
- package/dist/convex/integrations/billing/providers/stripe.d.ts +28 -0
- package/dist/convex/integrations/billing/providers/stripe.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/stripe.js +327 -0
- package/dist/convex/integrations/billing/providers/stripe.js.map +1 -0
- package/dist/convex/integrations/billing/providers/types.d.ts +263 -0
- package/dist/convex/integrations/billing/providers/types.d.ts.map +1 -0
- package/dist/convex/integrations/billing/providers/types.js +48 -0
- package/dist/convex/integrations/billing/providers/types.js.map +1 -0
- package/dist/convex/integrations/billing/subscriptions.d.ts +1 -1
- package/dist/convex/integrations/billing/subscriptions.d.ts.map +1 -1
- package/dist/convex/integrations/billing/subscriptions.js +20 -6
- package/dist/convex/integrations/billing/subscriptions.js.map +1 -1
- package/dist/convex/integrations/billing/types/setup.d.ts +64 -1
- package/dist/convex/integrations/billing/types/setup.d.ts.map +1 -1
- package/dist/convex/integrations/billing.d.ts +4 -1
- package/dist/convex/integrations/billing.d.ts.map +1 -1
- package/dist/convex/integrations/billing.js +12 -2
- package/dist/convex/integrations/billing.js.map +1 -1
- package/dist/convex/integrations/email.d.ts +1 -1
- package/dist/convex/integrations/email.d.ts.map +1 -1
- package/dist/convex/integrations/email.js.map +1 -1
- package/dist/convex/integrations/launch.d.ts +27 -2
- package/dist/convex/integrations/launch.d.ts.map +1 -1
- package/dist/convex/integrations/launch.js +15 -3
- package/dist/convex/integrations/launch.js.map +1 -1
- package/dist/convex/integrations/presence.d.ts +110 -0
- package/dist/convex/integrations/presence.d.ts.map +1 -0
- package/dist/convex/integrations/presence.js +92 -0
- package/dist/convex/integrations/presence.js.map +1 -0
- package/dist/convex/integrations/waitlist.d.ts +41 -7
- package/dist/convex/integrations/waitlist.d.ts.map +1 -1
- package/dist/convex/integrations/waitlist.js +45 -6
- package/dist/convex/integrations/waitlist.js.map +1 -1
- package/dist/convex/integrations/webhook-guard.d.ts +8 -0
- package/dist/convex/integrations/webhook-guard.d.ts.map +1 -1
- package/dist/convex/integrations/webhook-guard.js +11 -4
- package/dist/convex/integrations/webhook-guard.js.map +1 -1
- package/dist/convex/label-groups/admin.d.ts +9 -0
- package/dist/convex/label-groups/admin.d.ts.map +1 -1
- package/dist/convex/label-groups/admin.js +9 -0
- package/dist/convex/label-groups/admin.js.map +1 -1
- package/dist/convex/label-groups/audit.d.ts +2 -0
- package/dist/convex/label-groups/audit.d.ts.map +1 -1
- package/dist/convex/label-groups/audit.js +2 -0
- package/dist/convex/label-groups/audit.js.map +1 -1
- package/dist/convex/label-groups/auth.d.ts +9 -0
- package/dist/convex/label-groups/auth.d.ts.map +1 -1
- package/dist/convex/label-groups/auth.js +10 -0
- package/dist/convex/label-groups/auth.js.map +1 -1
- package/dist/convex/label-groups/email.d.ts +6 -0
- package/dist/convex/label-groups/email.d.ts.map +1 -1
- package/dist/convex/label-groups/email.js +7 -0
- package/dist/convex/label-groups/email.js.map +1 -1
- package/dist/convex/label-groups/errors.d.ts +4 -0
- package/dist/convex/label-groups/errors.d.ts.map +1 -1
- package/dist/convex/label-groups/errors.js +4 -0
- package/dist/convex/label-groups/errors.js.map +1 -1
- package/dist/convex/label-groups/security.d.ts +19 -0
- package/dist/convex/label-groups/security.d.ts.map +1 -1
- package/dist/convex/label-groups/security.js +20 -0
- package/dist/convex/label-groups/security.js.map +1 -1
- package/dist/convex/label-groups/waitlist.d.ts +8 -0
- package/dist/convex/label-groups/waitlist.d.ts.map +1 -1
- package/dist/convex/label-groups/waitlist.js +9 -0
- package/dist/convex/label-groups/waitlist.js.map +1 -1
- package/dist/convex/label-translations.d.ts.map +1 -1
- package/dist/convex/label-translations.js +24 -0
- package/dist/convex/label-translations.js.map +1 -1
- package/dist/convex/labels.d.ts +57 -0
- package/dist/convex/labels.d.ts.map +1 -1
- package/dist/convex/log.js +2 -0
- package/dist/convex/log.js.map +1 -1
- package/dist/convex/sensitive-actions.d.ts.map +1 -1
- package/dist/convex/sensitive-actions.js +11 -0
- package/dist/convex/sensitive-actions.js.map +1 -1
- package/dist/convex/waitlist-rules.d.ts +63 -9
- package/dist/convex/waitlist-rules.d.ts.map +1 -1
- package/dist/convex/waitlist-rules.js +38 -7
- package/dist/convex/waitlist-rules.js.map +1 -1
- package/dist/devtools-client/_nuxt/DHNi4uhO.js +6 -0
- package/dist/devtools-client/index.html +1 -1
- package/dist/env-registry.js +9 -0
- package/dist/module.d.ts +14 -2
- package/dist/module.js +2 -2
- package/dist/module.json +2 -2
- package/dist/runtime/locales/de.json +58 -1
- package/dist/runtime/locales/en.json +60 -3
- package/dist/runtime/locales/es.json +58 -1
- package/dist/runtime/locales/fr.json +58 -1
- package/dist/runtime/locales/ru.json +58 -1
- package/dist/runtime/server/monitoring/backend-calls.d.ts +3 -3
- package/dist/runtime/server/monitoring/backend-calls.js +2 -2
- package/dist/runtime/server/monitoring/health.js +2 -2
- package/dist/runtime/vue/auth-client.d.ts +3 -2
- package/dist/runtime/vue/auth-client.js +2 -1
- package/dist/runtime/vue/components/account/SecuritySettings.d.vue.ts +25 -2
- package/dist/runtime/vue/components/account/SecuritySettings.vue +52 -2
- package/dist/runtime/vue/components/account/SecuritySettings.vue.d.ts +25 -2
- package/dist/runtime/vue/components/account/SecurityTwoFactor.css +1 -0
- package/dist/runtime/vue/components/account/SecurityTwoFactor.d.vue.ts +4 -0
- package/dist/runtime/vue/components/account/SecurityTwoFactor.vue +107 -0
- package/dist/runtime/vue/components/account/SecurityTwoFactor.vue.d.ts +4 -0
- package/dist/runtime/vue/components/account/security-settings.d.ts +18 -1
- package/dist/runtime/vue/components/admin/AdminUsers.d.vue.ts +11 -2
- package/dist/runtime/vue/components/admin/AdminUsers.vue.d.ts +11 -2
- package/dist/runtime/vue/components/admin/AdminWaitlist.css +1 -1
- package/dist/runtime/vue/components/admin/AdminWaitlistActions.vue +41 -1
- package/dist/runtime/vue/components/admin/AdminWorkspaces.d.vue.ts +9 -0
- package/dist/runtime/vue/components/admin/AdminWorkspaces.vue.d.ts +9 -0
- package/dist/runtime/vue/components/admin/admin-waitlist-tab.js +28 -0
- package/dist/runtime/vue/components/auth/AuthForm.d.vue.ts +9 -0
- package/dist/runtime/vue/components/auth/AuthForm.vue +8 -0
- package/dist/runtime/vue/components/auth/AuthForm.vue.d.ts +9 -0
- package/dist/runtime/vue/components/auth/AuthFormTwoFactor.css +1 -0
- package/dist/runtime/vue/components/auth/AuthFormTwoFactor.d.vue.ts +3 -0
- package/dist/runtime/vue/components/auth/AuthFormTwoFactor.vue +70 -0
- package/dist/runtime/vue/components/auth/AuthFormTwoFactor.vue.d.ts +3 -0
- package/dist/runtime/vue/components/auth/AuthFormWaitlisted.vue +7 -2
- package/dist/runtime/vue/components/auth/WaitlistForm.d.vue.ts +8 -0
- package/dist/runtime/vue/components/auth/WaitlistForm.vue.d.ts +8 -0
- package/dist/runtime/vue/components/auth/WaitlistPlace.css +1 -1
- package/dist/runtime/vue/components/auth/WaitlistPlace.vue +37 -0
- package/dist/runtime/vue/components/auth/WaitlistShare.vue +2 -2
- package/dist/runtime/vue/components/auth/auth-form.d.ts +2 -0
- package/dist/runtime/vue/components/workspaces/AuditLog.d.vue.ts +2 -0
- package/dist/runtime/vue/components/workspaces/AuditLog.vue.d.ts +2 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
- package/dist/runtime/vue/composables/use-login-flow.d.ts +19 -4
- package/dist/runtime/vue/composables/use-login-flow.js +31 -0
- package/dist/runtime/vue/composables/use-room-presence.d.ts +63 -0
- package/dist/runtime/vue/composables/use-room-presence.js +31 -0
- package/dist/runtime/vue/composables/use-two-factor.d.ts +58 -0
- package/dist/runtime/vue/composables/use-two-factor.js +49 -0
- package/dist/runtime/vue/composables/use-waitlist-admin.d.ts +5 -0
- package/dist/runtime/vue/composables/use-waitlist-admin.js +5 -1
- package/dist/runtime/vue/composables/use-waitlist.d.ts +4 -0
- package/dist/runtime/vue/composables/use-waitlist.js +1 -1
- package/dist/runtime/vue/parts.d.ts +8 -1
- package/dist/runtime/vue/two-factor-client.d.ts +15 -0
- package/dist/runtime/vue/two-factor-client.js +19 -0
- package/dist/runtime/vue/utils/auth-session.js +10 -1
- package/dist/runtime/vue/utils/login-bindings.js +1 -0
- package/dist/runtime/vue/utils/page-guard.d.ts +2 -2
- package/dist/runtime/vue/utils/page-guard.js +2 -2
- package/dist/shared/{nuxt-backend.CBvrM7pG.mjs → nuxt-backend.CM_p0XQE.mjs} +1 -1
- package/dist/shared/{nuxt-backend.Dikfaocl.mjs → nuxt-backend.C_Y_BtBs.mjs} +128 -5
- package/dist/shared/{nuxt-backend.DbaXvH__.mjs → nuxt-backend.ChvlbHQq.mjs} +203 -9
- package/dist/shared/{nuxt-backend.BqXAZChe.mjs → nuxt-backend.D16peTIt.mjs} +57 -35
- package/dist/shared/{nuxt-backend.DH1Ya3uB.mjs → nuxt-backend.D4JXvCP6.mjs} +3 -2
- package/dist/types.d.ts +1 -1
- package/package.json +19 -10
- package/skills/nuxt-backend/SKILL.md +18 -18
- package/skills/nuxt-backend/references/api.md +31 -6
- package/skills/nuxt-backend/references/install.md +9 -6
- package/skills/nuxt-backend/references/renames.json +8 -0
- package/skills/nuxt-backend/references/surface.json +62 -2
- package/skills/nuxt-backend-auth/SKILL.md +8 -2
- package/skills/nuxt-backend-auth/references/api.md +3 -1
- package/skills/nuxt-backend-billing/SKILL.md +15 -0
- package/skills/nuxt-backend-billing/references/api.md +14 -1
- package/skills/nuxt-backend-data/SKILL.md +1 -0
- package/skills/nuxt-backend-data/references/api.md +10 -1
- package/skills/nuxt-backend-email/references/api.md +1 -1
- package/skills/nuxt-backend-ship/SKILL.md +2 -1
- package/skills/nuxt-backend-upgrade/references/upgrade.md +6 -0
- package/src/convex/access-tickets.ts +10 -2
- package/src/convex/account-data.ts +5 -4
- package/src/convex/app.ts +2 -1
- package/src/convex/client/better-auth-options.ts +12 -3
- package/src/convex/client/launch-gate.ts +28 -1
- package/src/convex/client/plugins.ts +3 -0
- package/src/convex/client/two-factor.ts +66 -0
- package/src/convex/components/backend/_generated/api.ts +2 -0
- package/src/convex/components/backend/_generated/component.ts +500 -2
- package/src/convex/components/backend/account.ts +25 -1
- package/src/convex/components/backend/adapter.ts +7 -2
- package/src/convex/components/backend/billing.ts +2 -1
- package/src/convex/components/backend/commerce.ts +408 -0
- package/src/convex/components/backend/schema.ts +110 -1
- package/src/convex/components/backend/waitlist.ts +144 -40
- package/src/convex/email-templates.ts +16 -0
- package/src/convex/emails/waitlist-friend-joined.ts +23 -0
- package/src/convex/errors.ts +15 -2
- package/src/convex/events.ts +14 -0
- package/src/convex/integrations/billing/checkout.ts +78 -11
- package/src/convex/integrations/billing/commerce-entitlements.ts +92 -0
- package/src/convex/integrations/billing/commerce-events.ts +487 -0
- package/src/convex/integrations/billing/commerce-history.ts +110 -0
- package/src/convex/integrations/billing/commerce-webhooks.ts +69 -0
- package/src/convex/integrations/billing/commerce.ts +366 -0
- package/src/convex/integrations/billing/context.ts +19 -2
- package/src/convex/integrations/billing/credits.ts +47 -27
- package/src/convex/integrations/billing/customers.ts +15 -1
- package/src/convex/integrations/billing/entitlements.ts +5 -1
- package/src/convex/integrations/billing/erasure.ts +11 -6
- package/src/convex/integrations/billing/free-plan.ts +30 -5
- package/src/convex/integrations/billing/functions.ts +3 -2
- package/src/convex/integrations/billing/gifts.ts +2 -0
- package/src/convex/integrations/billing/history.ts +9 -0
- package/src/convex/integrations/billing/lifecycle.ts +3 -1
- package/src/convex/integrations/billing/providers/capabilities.ts +78 -0
- package/src/convex/integrations/billing/providers/consent.ts +94 -0
- package/src/convex/integrations/billing/providers/creem.ts +225 -0
- package/src/convex/integrations/billing/providers/dodo.ts +214 -0
- package/src/convex/integrations/billing/providers/http.ts +168 -0
- package/src/convex/integrations/billing/providers/index.ts +65 -0
- package/src/convex/integrations/billing/providers/stripe.ts +345 -0
- package/src/convex/integrations/billing/providers/types.ts +281 -0
- package/src/convex/integrations/billing/subscriptions.ts +20 -6
- package/src/convex/integrations/billing/types/setup.ts +63 -1
- package/src/convex/integrations/billing.ts +46 -3
- package/src/convex/integrations/email.ts +1 -0
- package/src/convex/integrations/launch.ts +45 -7
- package/src/convex/integrations/presence.ts +160 -0
- package/src/convex/integrations/waitlist.ts +84 -12
- package/src/convex/integrations/webhook-guard.ts +20 -4
- package/src/convex/label-groups/admin.ts +9 -0
- package/src/convex/label-groups/audit.ts +2 -0
- package/src/convex/label-groups/auth.ts +10 -0
- package/src/convex/label-groups/email.ts +7 -0
- package/src/convex/label-groups/errors.ts +4 -0
- package/src/convex/label-groups/security.ts +20 -0
- package/src/convex/label-groups/waitlist.ts +9 -0
- package/src/convex/label-translations.ts +24 -0
- package/src/convex/log.ts +2 -0
- package/src/convex/sensitive-actions.ts +11 -0
- package/src/convex/waitlist-rules.ts +84 -8
- package/src/runtime/vue/components/account/SecuritySettings.vue +58 -4
- package/src/runtime/vue/components/account/SecurityTwoFactor.css +68 -0
- package/src/runtime/vue/components/account/SecurityTwoFactor.vue +113 -0
- package/src/runtime/vue/components/admin/AdminWaitlist.css +1 -0
- package/src/runtime/vue/components/admin/AdminWaitlistActions.vue +44 -2
- package/src/runtime/vue/components/auth/AuthForm.vue +8 -0
- package/src/runtime/vue/components/auth/AuthFormTwoFactor.css +40 -0
- package/src/runtime/vue/components/auth/AuthFormTwoFactor.vue +75 -0
- package/src/runtime/vue/components/auth/AuthFormWaitlisted.vue +11 -4
- package/src/runtime/vue/components/auth/WaitlistPlace.css +16 -0
- package/src/runtime/vue/components/auth/WaitlistPlace.vue +49 -2
- package/src/runtime/vue/components/auth/WaitlistShare.vue +4 -3
- package/dist/devtools-client/_nuxt/CiCAOwUc.js +0 -5
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { WebhookEventHandlers } from '@convex-dev/polar'
|
|
2
|
+
import type { ComponentApi } from '../../../components/backend/_generated/component.js'
|
|
2
3
|
import type { Auth, FunctionReference, GenericActionCtx, GenericDataModel } from 'convex/server'
|
|
3
|
-
import type { CatalogInterval } from '../../../catalog.js'
|
|
4
|
+
import type { BillingCatalog, CatalogInterval } from '../../../catalog.js'
|
|
5
|
+
import type { NeutralBillingEvent } from '../providers/types.js'
|
|
4
6
|
import type { CallerRule } from '../../access.js'
|
|
5
7
|
import type { ShardedCounter } from '@convex-dev/sharded-counter'
|
|
6
8
|
import type { Workpool } from '@convex-dev/workpool'
|
|
@@ -232,6 +234,12 @@ export interface BillingComponents {
|
|
|
232
234
|
consents: {
|
|
233
235
|
latest: FunctionReference<'query', 'internal', { userId: string, kind: string }, { kind: string, version: string, granted: boolean, at: number } | null>
|
|
234
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* The records of a provider on the neutral adapters (`BILLING_PROVIDER`
|
|
239
|
+
* stripe, dodo or creem): customers, orders and credit grants. Absent on
|
|
240
|
+
* a component built before them, which sells through Polar only.
|
|
241
|
+
*/
|
|
242
|
+
commerce?: ComponentApi['commerce']
|
|
235
243
|
/**
|
|
236
244
|
* What the storage module counts by billing quota key (a holder's files
|
|
237
245
|
* and bytes): a quota read adds it to the count the app claims itself,
|
|
@@ -335,6 +343,32 @@ export interface BillingEntityCtx {
|
|
|
335
343
|
* user (`billTo: 'user'`) — so {@link SetupBillingConfig.resolveEntity} is an
|
|
336
344
|
* override, not required wiring.
|
|
337
345
|
*/
|
|
346
|
+
/**
|
|
347
|
+
* What billing sells through a provider on the neutral adapters: see
|
|
348
|
+
* {@link SetupBillingConfig.commerce}.
|
|
349
|
+
*
|
|
350
|
+
* @experimental
|
|
351
|
+
*/
|
|
352
|
+
export interface CommerceConfig {
|
|
353
|
+
/** The catalog, as `billing.catalog.ts` defines it. */
|
|
354
|
+
definition: BillingCatalog
|
|
355
|
+
/**
|
|
356
|
+
* Catalog key → the provider's id for what its checkout sells (a product
|
|
357
|
+
* id, or a price id where the provider sells prices), per billing
|
|
358
|
+
* environment: packs by their key, a plan's monthly price
|
|
359
|
+
* by the plan's key and its yearly one as `<plan>:year`. The free plan
|
|
360
|
+
* needs none: it is the app's own.
|
|
361
|
+
*/
|
|
362
|
+
products: Partial<Record<'sandbox' | 'production', Record<string, string>>>
|
|
363
|
+
/**
|
|
364
|
+
* What the app does with each verified event, in neutral words, after
|
|
365
|
+
* the package kept its records: the place for the app's own reaction to
|
|
366
|
+
* a paid order or a subscription's change. It must be idempotent: a
|
|
367
|
+
* provider sends an event again until it gets a 2xx.
|
|
368
|
+
*/
|
|
369
|
+
onEvent?: (ctx: RunWriteCtx, event: NeutralBillingEvent, delivery: { id: string }) => Promise<void>
|
|
370
|
+
}
|
|
371
|
+
|
|
338
372
|
export interface SetupBillingConfig {
|
|
339
373
|
/**
|
|
340
374
|
* The app's `setupEmail` instance. A gift's recipient hears of it through
|
|
@@ -538,6 +572,34 @@ export interface SetupBillingConfig {
|
|
|
538
572
|
* generated file. Explicit `products`/`credits` config wins.
|
|
539
573
|
*/
|
|
540
574
|
catalog?: Partial<Record<'sandbox' | 'production', BillingCatalogIds | undefined>>
|
|
575
|
+
/**
|
|
576
|
+
* What billing sells through a provider on the neutral adapters, read
|
|
577
|
+
* when `BILLING_PROVIDER` is `stripe`, `dodo` or `creem` (and refused
|
|
578
|
+
* without it there): the catalog itself (`billing.catalog.ts`'s default
|
|
579
|
+
* export), whose plans, packs, features, quotas and credit grants the app
|
|
580
|
+
* keeps where no provider holds them, and the provider's id for each of
|
|
581
|
+
* its products, by catalog key and billing environment. `billing sync`
|
|
582
|
+
* writes Polar's ids only: create the products in the provider's
|
|
583
|
+
* dashboard and name them here.
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```ts
|
|
587
|
+
* import definition from './billing.catalog'
|
|
588
|
+
*
|
|
589
|
+
* setupBilling(components, {
|
|
590
|
+
* email,
|
|
591
|
+
* commerce: {
|
|
592
|
+
* definition,
|
|
593
|
+
* products: {
|
|
594
|
+
* sandbox: { 'studio': 'price_123', 'studio:year': 'price_456', 'credits100': 'price_789' },
|
|
595
|
+
* },
|
|
596
|
+
* },
|
|
597
|
+
* })
|
|
598
|
+
* ```
|
|
599
|
+
*
|
|
600
|
+
* @experimental
|
|
601
|
+
*/
|
|
602
|
+
commerce?: CommerceConfig
|
|
541
603
|
/**
|
|
542
604
|
* The billing lifecycle beyond the provider's own: save offers
|
|
543
605
|
* by cancellation reason for the cancel flow, the abandoned-checkout
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCheckout } from './billing/checkout.js'
|
|
2
|
+
import { createCommerceEvents } from './billing/commerce-events.js'
|
|
2
3
|
import { BILLING_METERS, BILLING_TO, createBillingContext } from './billing/context.js'
|
|
3
4
|
import { createCredits } from './billing/credits.js'
|
|
4
5
|
import { createCustomers } from './billing/customers.js'
|
|
@@ -79,7 +80,7 @@ export type {
|
|
|
79
80
|
Pricing,
|
|
80
81
|
QuotaUsage,
|
|
81
82
|
} from './billing/types/records.js'
|
|
82
|
-
export type { BillingWebhookEventHandlers, SaveOfferTerms, BillingComponents, BillingEmail, BillingEntity, BillingAccessRule, BillingEntityCtx, EntityProfile, SetupBillingConfig } from './billing/types/setup.js'
|
|
83
|
+
export type { BillingWebhookEventHandlers, SaveOfferTerms, BillingComponents, BillingEmail, BillingEntity, BillingAccessRule, BillingEntityCtx, EntityProfile, SetupBillingConfig, CommerceConfig } from './billing/types/setup.js'
|
|
83
84
|
export type { AccountBillingErasure, AccountBillingErasureInput, AccountBillingExport, AccountBillingRecord, Billing } from './billing/types/surface.js'
|
|
84
85
|
export type { BillingAudit } from './billing/activity.js'
|
|
85
86
|
export type { BillingLifecycle, CancelFlowState, CancelOutcome, BillingConsole, SaveOffer, SaveOfferRule, WithdrawalPeriod } from './billing/types/lifecycle.js'
|
|
@@ -88,6 +89,45 @@ export type { MeterUsage, RevenueCancellations, RevenueInterval, RevenueMetric,
|
|
|
88
89
|
// Catalog-as-code authoring surface (billing.catalog.ts / `billing sync`).
|
|
89
90
|
export { type BillingCatalog, type CatalogCreditGrant, type CatalogCurrencyPrices, type CatalogDiscount, type CatalogDiscountDuration, type CatalogDiscountProducts, type CatalogDiscountTerms, type CatalogFeature, type CatalogInterval, type CatalogMeter, type CatalogPack, type CatalogPackPrices, type CatalogPlan, type CatalogPlanCreditGrant, type CatalogPlanGift, type CatalogPlanPrices, type CatalogQuota, defineBillingCatalog, type MeterUnit } from '../catalog.js'
|
|
90
91
|
export { ALL_BILLING_EVENTS } from './billing/events.js'
|
|
92
|
+
|
|
93
|
+
// The other merchants of record (Stripe Managed Payments, Dodo Payments,
|
|
94
|
+
// Creem), on the provider-neutral adapters: checkout, portal, plan changes,
|
|
95
|
+
// cancellation, refunds, invoices and the guarded webhook route.
|
|
96
|
+
export {
|
|
97
|
+
billingProviderName,
|
|
98
|
+
commerceProviderFromEnv,
|
|
99
|
+
consentFromMetadata,
|
|
100
|
+
consentMetadata,
|
|
101
|
+
createCommerceProvider,
|
|
102
|
+
DIGITAL_CONTENT_CONSENT_TEXT,
|
|
103
|
+
DIGITAL_CONTENT_CONSENT_VERSION,
|
|
104
|
+
PROVIDER_CAPABILITIES,
|
|
105
|
+
ProviderHttpError,
|
|
106
|
+
ProviderUnsupportedError,
|
|
107
|
+
recordDigitalContentConsent,
|
|
108
|
+
webhookSecretsFromEnv,
|
|
109
|
+
} from './billing/providers/index.js'
|
|
110
|
+
export type {
|
|
111
|
+
BillingProviderName,
|
|
112
|
+
ChangePlanRequest,
|
|
113
|
+
CheckoutCustomer,
|
|
114
|
+
CheckoutRequest,
|
|
115
|
+
CheckoutSession,
|
|
116
|
+
CommerceProvider,
|
|
117
|
+
DigitalContentConsent,
|
|
118
|
+
InvoiceAnswer,
|
|
119
|
+
NeutralBillingEvent,
|
|
120
|
+
NeutralOrder,
|
|
121
|
+
NeutralRefund,
|
|
122
|
+
NeutralSubscription,
|
|
123
|
+
NeutralSubscriptionStatus,
|
|
124
|
+
ProviderCapabilities,
|
|
125
|
+
ProviderEnvironment,
|
|
126
|
+
ProviderOptions,
|
|
127
|
+
RefundRequest,
|
|
128
|
+
VerifiedDelivery,
|
|
129
|
+
} from './billing/providers/index.js'
|
|
130
|
+
export { createCommerceWebhookHandler, type CommerceEventHandler, type CommerceWebhookOptions } from './billing/commerce-webhooks.js'
|
|
91
131
|
export type { BillingLaunch, BillingLaunchReason } from '../billing-launch.js'
|
|
92
132
|
|
|
93
133
|
// The referral program, set up in its own backend file beside billing.
|
|
@@ -177,7 +217,10 @@ export function setupBilling(
|
|
|
177
217
|
const { giftCheckout, claimGift, getReceivedGifts, getSentGifts, resendGift, changeGiftRecipient, rescheduleGift, cancelGift, runGiftSweep } = gifts
|
|
178
218
|
const functions = createBillingFunctions(context, entitlements, subscriptions, history, customers, quotas, freePlan, lifecycle, revenue, gifts)
|
|
179
219
|
const { resyncEntitlements } = createResync(context, entitlements)
|
|
180
|
-
|
|
220
|
+
// Adapter mode: the provider's neutral events and the credit cycle it does not run.
|
|
221
|
+
const commerceEvents = context.commerce ? createCommerceEvents(context, entitlements, customers, freePlan) : null
|
|
222
|
+
if (commerceEvents) freePlan.hooks.localStart = commerceEvents.cycle
|
|
223
|
+
const { webhookEvents, webhookHandler: polarWebhookHandler } = createWebhooks(context, entitlements, gifts, customers, subscriptions, freePlan, lifecycle, createReferralOrders(context, rewards))
|
|
181
224
|
const { hasFeature, requireFeature, activePlans } = createFeatures(context, pricing)
|
|
182
225
|
// The counts first: they are found by the grants the cache still holds.
|
|
183
226
|
const forgetBillingEntity: Billing['forgetEntity'] = async (ctx, userId) => {
|
|
@@ -231,7 +274,7 @@ export function setupBilling(
|
|
|
231
274
|
getRevenue: functions.getRevenueFn,
|
|
232
275
|
},
|
|
233
276
|
webhookEvents,
|
|
234
|
-
webhookHandler,
|
|
277
|
+
webhookHandler: commerceEvents ? commerceEvents.webhookHandler : polarWebhookHandler,
|
|
235
278
|
getCustomerState,
|
|
236
279
|
checkout,
|
|
237
280
|
portal: customers.portal,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
newLinkToken,
|
|
23
23
|
} from '../access-tickets.js'
|
|
24
24
|
import { DEFAULT_ADMIN_ROLES, IMPERSONATED_BY_CLAIM } from '../constants.js'
|
|
25
|
-
import {
|
|
25
|
+
import { checkedWaitlistRule, statusToken, type WaitlistBoostRule, type WaitlistOptions, type WaitlistRule } from '../waitlist-rules.js'
|
|
26
26
|
import { readEnv } from '../delivery.js'
|
|
27
27
|
import { authSecrets, liveSecrets } from '../auth-secrets.js'
|
|
28
28
|
import { backendError } from '../errors.js'
|
|
@@ -296,6 +296,8 @@ export interface Access {
|
|
|
296
296
|
/** Whether the caller is an administrator now (a read: no recent sign-in asked). */
|
|
297
297
|
is: (ctx: AccessCtx, what: string) => Promise<boolean>
|
|
298
298
|
}
|
|
299
|
+
/** The waitlist's rule, checked (`setupAccess({ waitlist })`): the sign-in gate and setupWaitlist read it. */
|
|
300
|
+
waitlistRule: WaitlistRule
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
303
|
|
|
@@ -347,6 +349,30 @@ export interface SetupAccessOptions {
|
|
|
347
349
|
email?: AccessEmail
|
|
348
350
|
/** The paths the Nuxt module writes to `paths.generated.ts`: an invitation email links to the sign-in page and the privacy policy there. */
|
|
349
351
|
paths?: Partial<BackendPaths>
|
|
352
|
+
/**
|
|
353
|
+
* The rule the waitlist's line runs on, in early access. It lives here,
|
|
354
|
+
* not on `setupWaitlist`, because the sign-in page records entries
|
|
355
|
+
* through this access, in code that never loads `backend/waitlist.ts`.
|
|
356
|
+
*
|
|
357
|
+
* - `boost`: how sharing moves people. Each friend who joins through a
|
|
358
|
+
* person's link moves them `perFriend` up the line (ms, a day by
|
|
359
|
+
* default), for up to `cap` friends (10 by default, `null` for no
|
|
360
|
+
* limit); the friend starts `welcome` up (0 by default); `notify` emails
|
|
361
|
+
* the person when a friend joins, at most once a day. `false` turns
|
|
362
|
+
* sharing off.
|
|
363
|
+
* - `place`: `{ rank: false }` keeps a person's position and the size of
|
|
364
|
+
* the list to the administrators: the status page, the sign-in page and
|
|
365
|
+
* the confirmation email show the day they joined, the credit their
|
|
366
|
+
* friends earned and the next wave instead.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* import { DAY } from 'nuxt-backend/rate-limit'
|
|
371
|
+
*
|
|
372
|
+
* waitlist: { boost: { perFriend: 7 * DAY, cap: null, welcome: 7 * DAY, notify: true }, place: { rank: false } }
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
waitlist?: WaitlistOptions
|
|
350
376
|
}
|
|
351
377
|
|
|
352
378
|
/** What "Email them" needs of `setupEmail`'s instance: the layout and words, and the sending rules. */
|
|
@@ -388,8 +414,8 @@ interface AccessRefs {
|
|
|
388
414
|
consoleRows: FunctionReference<'query', 'internal', Record<string, never>, { invites: AccessInvite[], memberTickets: AccessMemberTicket[], admissions: AccessAdmission[] }>
|
|
389
415
|
}
|
|
390
416
|
waitlist: {
|
|
391
|
-
verify: FunctionReference<'mutation', 'internal', { email: string, join?: string, locale?: string, boost: {
|
|
392
|
-
place: FunctionReference<'query', 'internal', { id: string }, { position: number | null, total: number, shareCode: string } | null>
|
|
417
|
+
verify: FunctionReference<'mutation', 'internal', { email: string, join?: string, locale?: string, boost: WaitlistBoostRule }, { id: string, created: boolean, status: string, source: string, referred: boolean, news: boolean, sharer?: { id: string, email: string, locale: string | null, friends: number, credit: number } }>
|
|
418
|
+
place: FunctionReference<'query', 'internal', { id: string, rank?: boolean }, { position: number | null, total: number, shareCode: string } | null>
|
|
393
419
|
}
|
|
394
420
|
adapter: { findOne: AdapterFindOne }
|
|
395
421
|
email: { send: FunctionReference<'mutation', 'internal', Record<string, unknown>, string | null> }
|
|
@@ -482,6 +508,8 @@ const usedTicket = (row: { ticket: string, label?: string }): { ticket: AccessTi
|
|
|
482
508
|
export function setupAccess(components: AccessComponents, options: SetupAccessOptions): Access {
|
|
483
509
|
const refs = components.backend as AccessRefs
|
|
484
510
|
const phases = [...(options.phases ?? ACCESS_PHASES)]
|
|
511
|
+
// Checked once, here: the sign-in gate and setupWaitlist both read it.
|
|
512
|
+
const waitlistRule = checkedWaitlistRule(options.waitlist)
|
|
485
513
|
const domains = options.domains ?? []
|
|
486
514
|
// A workspace invitation's share of sign-ups per inviter; 0 turns them off as tickets.
|
|
487
515
|
const perInviter = options.workspaceInvitations === false ? 0 : (options.workspaceInvitations ?? WORKSPACE_INVITATIONS)
|
|
@@ -636,17 +664,26 @@ export function setupAccess(components: AccessComponents, options: SetupAccessOp
|
|
|
636
664
|
|
|
637
665
|
const waitlist: AccessGate['waitlist'] = phases.includes('early-access')
|
|
638
666
|
? async (ctx, { email, locale, join }) => {
|
|
639
|
-
const
|
|
640
|
-
const
|
|
667
|
+
const rule = waitlistRule
|
|
668
|
+
const entry = await ctx.runMutation(refs.waitlist.verify, { email: admissionEmail(email), ...(join ? { join } : {}), ...(locale ? { locale } : {}), boost: rule.boost })
|
|
669
|
+
const waiting = entry.status === 'waiting'
|
|
670
|
+
// A private rank is never read, so nothing about the list's size leaves here.
|
|
671
|
+
const place = waiting && rule.rank ? await ctx.runQuery(refs.waitlist.place, { id: entry.id }) : null
|
|
672
|
+
// The event records every credited friend; `notify` decides only the email.
|
|
673
|
+
const sharer = entry.sharer
|
|
674
|
+
? { email: entry.sharer.email, locale: entry.sharer.locale, friends: entry.sharer.friends, credit: entry.sharer.credit, token: await statusToken(secret(), entry.sharer.id), notify: rule.notify }
|
|
675
|
+
: undefined
|
|
641
676
|
return {
|
|
642
677
|
id: entry.id,
|
|
643
678
|
created: entry.created,
|
|
679
|
+
waiting,
|
|
644
680
|
position: place?.position ?? null,
|
|
645
681
|
total: place?.total ?? 0,
|
|
646
682
|
token: await statusToken(secret(), entry.id),
|
|
647
683
|
source: entry.source,
|
|
648
684
|
referred: entry.referred,
|
|
649
685
|
news: entry.news,
|
|
686
|
+
...(sharer ? { sharer } : {}),
|
|
650
687
|
}
|
|
651
688
|
}
|
|
652
689
|
: undefined
|
|
@@ -869,12 +906,13 @@ export function setupAccess(components: AccessComponents, options: SetupAccessOp
|
|
|
869
906
|
require: requireAdministrator,
|
|
870
907
|
is: (ctx, what) => isAdministratorNow(ctx, reads, administrators, what),
|
|
871
908
|
},
|
|
909
|
+
waitlistRule,
|
|
872
910
|
},
|
|
873
911
|
}
|
|
874
912
|
}
|
|
875
913
|
|
|
876
914
|
export { setupWaitlist } from './waitlist.js'
|
|
877
|
-
export type { SetupWaitlistOptions, Waitlist, WaitlistApi, WaitlistCaps, WaitlistConsole, WaitlistEntryRow, WaitlistPlace, WaitlistStatusView } from './waitlist.js'
|
|
878
|
-
export type { WaitlistQuestions, WaitlistStatus } from '../waitlist-rules.js'
|
|
915
|
+
export type { SetupWaitlistOptions, Waitlist, WaitlistApi, WaitlistCaps, WaitlistConsole, WaitlistEntryRow, WaitlistPlace, WaitlistStatusView, WaitlistWaveStanding } from './waitlist.js'
|
|
916
|
+
export type { WaitlistBoostOptions, WaitlistBoostRule, WaitlistOptions, WaitlistQuestions, WaitlistRule, WaitlistStatus } from '../waitlist-rules.js'
|
|
879
917
|
export { ACCESS_PHASES } from '../access-tickets.js'
|
|
880
918
|
export type { AccessPhase, AccessTicket, InviteKind, InviteStatus } from '../access-tickets.js'
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who is here: Convex's presence component, behind the backend's sign-in.
|
|
3
|
+
* A heartbeat counts the signed-in account, never an id the browser names;
|
|
4
|
+
* the room token it hands back is what lists the room, so only someone the
|
|
5
|
+
* room let in reads who else is there, by name.
|
|
6
|
+
*
|
|
7
|
+
* Experimental: it follows the presence component's pre-1.0 shapes, so this
|
|
8
|
+
* entry's shape may change in a minor release.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
import { Presence } from '@convex-dev/presence'
|
|
14
|
+
import { v } from 'convex/values'
|
|
15
|
+
import { type FunctionReference, type GenericMutationCtx, type GenericDataModel, mutationGeneric, queryGeneric, type RegisteredMutation, type RegisteredQuery } from 'convex/server'
|
|
16
|
+
import { backendError } from '../errors.js'
|
|
17
|
+
import { ownCaller } from './access.js'
|
|
18
|
+
|
|
19
|
+
/** The presence component's handle, `components.presence`. */
|
|
20
|
+
type PresenceComponent = ConstructorParameters<typeof Presence>[0]
|
|
21
|
+
|
|
22
|
+
/** The component handles `setupPresence` reads: pass the whole generated `components` object. */
|
|
23
|
+
export interface PresenceComponents {
|
|
24
|
+
presence: PresenceComponent
|
|
25
|
+
backend: { adapter: { findOne: FunctionReference<'query', 'internal'> } }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Who a room may let in, asked on every heartbeat. */
|
|
29
|
+
export interface PresenceRoomCheck {
|
|
30
|
+
/** The room the browser names, as `useRoomPresence` was given it. */
|
|
31
|
+
roomId: string
|
|
32
|
+
/** The signed-in account. */
|
|
33
|
+
userId: string
|
|
34
|
+
/** Its identity claims: its role, its active workspace (`activeOrganizationId`) and the rest. */
|
|
35
|
+
claims: Record<string, unknown>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Options for {@link setupPresence}. */
|
|
39
|
+
export interface SetupPresenceOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Whether a signed-in account may join a room, with the mutation's `ctx` to read your tables by. Unset, every signed-in
|
|
42
|
+
* account may join any room; refuse one by returning `false`, and the
|
|
43
|
+
* heartbeat answers `forbidden`. Rooms are the app's own strings: a
|
|
44
|
+
* document's id, `workspace:<id>`. It runs on heartbeats only, so it lets
|
|
45
|
+
* people in but never takes anyone out: the mutation that takes access away
|
|
46
|
+
* (a member removed from a workspace) also calls `presence.removeRoomUser`.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* canJoin: ({ roomId, claims }) => !roomId.startsWith('workspace:') || roomId === `workspace:${claims.activeOrganizationId}`
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
canJoin?: (room: PresenceRoomCheck, ctx: GenericMutationCtx<GenericDataModel>) => boolean | Promise<boolean>
|
|
54
|
+
/** How many people a room lists at most. Default 50. */
|
|
55
|
+
limit?: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** One person in a room, as `useRoomPresence` and the base module's `<FacePile>` read it. */
|
|
59
|
+
export interface RoomMember {
|
|
60
|
+
userId: string
|
|
61
|
+
online: boolean
|
|
62
|
+
lastDisconnected: number
|
|
63
|
+
/** Their name, when the account has one. */
|
|
64
|
+
name?: string
|
|
65
|
+
/** Their picture, when the account has one. */
|
|
66
|
+
image?: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** What {@link setupPresence} returns: the three functions `backend/presence.ts` exports, and the component's own client. */
|
|
70
|
+
export interface PresenceSetup {
|
|
71
|
+
/**
|
|
72
|
+
* The room's people, by the room token a heartbeat handed back: who is online first, as the component orders them.
|
|
73
|
+
* Signed out, as an administrator acting as someone, or once `removeRoomUser` took the caller out of the room, it lists nobody and refuses.
|
|
74
|
+
*/
|
|
75
|
+
list: RegisteredQuery<'public', { roomToken: string }, Promise<RoomMember[]>>
|
|
76
|
+
/** Keep the signed-in account in a room. The browser's `userId` is checked against the account, never trusted. */
|
|
77
|
+
heartbeat: RegisteredMutation<'public', { roomId: string, userId: string, sessionId: string, interval: number }, Promise<{ roomToken: string, sessionToken: string }>>
|
|
78
|
+
/** Leave the room the session token names, as a tab closes. */
|
|
79
|
+
disconnect: RegisteredMutation<'public', { sessionToken: string }, Promise<null>>
|
|
80
|
+
/**
|
|
81
|
+
* The component's client, for a room of your own (`listRoom`, `removeRoomUser`, `removeRoom`), which checks no sign-in.
|
|
82
|
+
* A refused heartbeat leaves the person in the room, with a room token that still lists it: `removeRoomUser`, called from the mutation that takes their access away, takes them out, and `list` then refuses them.
|
|
83
|
+
*/
|
|
84
|
+
presence: Presence
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The fewest and most heartbeat intervals the server accepts, in milliseconds. */
|
|
88
|
+
const INTERVAL = { min: 1_000, max: 5 * 60_000 }
|
|
89
|
+
/** The longest room id: a document's id or a key of the app's own. */
|
|
90
|
+
const ROOM_ID_MAX = 256
|
|
91
|
+
/** The most people `list` reads to find the caller in a room fuller than its `limit`. */
|
|
92
|
+
const MEMBER_CHECK_MAX = 1_000
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Who is here, for a page, a document or a workspace: Convex's presence
|
|
96
|
+
* component (`@convex-dev/presence`, mounted as `presence` in
|
|
97
|
+
* `convex.config.ts`) behind the backend's sign-in. Export what it returns
|
|
98
|
+
* from `backend/presence.ts`, and `useRoomPresence(roomId)` keeps the
|
|
99
|
+
* signed-in person in the room and lists who else is there.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts [backend/presence.ts]
|
|
103
|
+
* import { setupPresence } from 'nuxt-backend/presence'
|
|
104
|
+
* import { components } from './_generated/api'
|
|
105
|
+
*
|
|
106
|
+
* export const { list, heartbeat, disconnect } = setupPresence(components)
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export function setupPresence(components: PresenceComponents, options: SetupPresenceOptions = {}): PresenceSetup {
|
|
110
|
+
const presence = new Presence(components.presence)
|
|
111
|
+
const limit = options.limit ?? 50
|
|
112
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 200) throw new TypeError('[nuxt-backend] setupPresence({ limit }): a whole number from 1 to 200.')
|
|
113
|
+
const findUser = components.backend.adapter.findOne
|
|
114
|
+
|
|
115
|
+
const heartbeat = mutationGeneric({
|
|
116
|
+
args: { roomId: v.string(), userId: v.string(), sessionId: v.string(), interval: v.number() },
|
|
117
|
+
handler: async (ctx, { roomId, userId, sessionId, interval }) => {
|
|
118
|
+
const caller = await ownCaller(ctx, 'presence:heartbeat')
|
|
119
|
+
if (userId !== caller) throw backendError('forbidden', { reason: 'presence_user' }, '[nuxt-backend] presence:heartbeat: a heartbeat counts the signed-in account only.')
|
|
120
|
+
if (!roomId || roomId.length > ROOM_ID_MAX) throw backendError('invalid_input', { field: 'roomId' }, `[nuxt-backend] presence:heartbeat: a room id of 1 to ${ROOM_ID_MAX} characters.`)
|
|
121
|
+
if (!sessionId || sessionId.length > 128) throw backendError('invalid_input', { field: 'sessionId' }, '[nuxt-backend] presence:heartbeat: a session id of 1 to 128 characters.')
|
|
122
|
+
if (options.canJoin) {
|
|
123
|
+
const claims = await ctx.auth.getUserIdentity() as unknown as Record<string, unknown>
|
|
124
|
+
if (!await options.canJoin({ roomId, userId: caller, claims }, ctx)) throw backendError('forbidden', { reason: 'presence_room' }, `[nuxt-backend] presence:heartbeat: ${JSON.stringify(roomId)} does not let this account in.`)
|
|
125
|
+
}
|
|
126
|
+
return presence.heartbeat(ctx, roomId, caller, sessionId, Math.min(INTERVAL.max, Math.max(INTERVAL.min, interval)))
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
const list = queryGeneric({
|
|
131
|
+
args: { roomToken: v.string() },
|
|
132
|
+
handler: async (ctx, { roomToken }): Promise<RoomMember[]> => {
|
|
133
|
+
// A token outlives the sign-in that earned it: names and pictures go to a signed-in caller only.
|
|
134
|
+
const caller = await ownCaller(ctx, 'presence:list')
|
|
135
|
+
// The token is the room's, shared by everyone in it, and outlives a removal: the caller must still be in the room.
|
|
136
|
+
const people = await presence.list(ctx, roomToken, limit)
|
|
137
|
+
const inRoom = (rows: typeof people) => rows.some(row => row.userId === caller)
|
|
138
|
+
if (!inRoom(people) && (people.length < limit || !inRoom(await presence.list(ctx, roomToken, MEMBER_CHECK_MAX)))) {
|
|
139
|
+
throw backendError('forbidden', { reason: 'presence_room' }, '[nuxt-backend] presence:list: the caller is not in this room.')
|
|
140
|
+
}
|
|
141
|
+
return Promise.all(people.map(async ({ userId, online, lastDisconnected }) => {
|
|
142
|
+
const user = await ctx.runQuery(findUser, { model: 'user', where: [{ field: '_id', value: userId }] }) as { name?: unknown, image?: unknown } | null
|
|
143
|
+
return {
|
|
144
|
+
userId,
|
|
145
|
+
online,
|
|
146
|
+
lastDisconnected,
|
|
147
|
+
...(typeof user?.name === 'string' && user.name ? { name: user.name } : {}),
|
|
148
|
+
...(typeof user?.image === 'string' && user.image ? { image: user.image } : {}),
|
|
149
|
+
}
|
|
150
|
+
}))
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const disconnect = mutationGeneric({
|
|
155
|
+
args: { sessionToken: v.string() },
|
|
156
|
+
handler: async (ctx, { sessionToken }) => presence.disconnect(ctx, sessionToken),
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
return { list, heartbeat, disconnect, presence }
|
|
160
|
+
}
|
|
@@ -12,13 +12,14 @@ import {
|
|
|
12
12
|
addressDigest,
|
|
13
13
|
answersProblem,
|
|
14
14
|
checkedQuestions,
|
|
15
|
-
DEFAULT_BOOST,
|
|
16
15
|
readStatusToken,
|
|
17
16
|
SOURCE_FORM,
|
|
18
17
|
WAITLIST_SOURCE_MAX,
|
|
19
18
|
WAITLIST_STATUSES,
|
|
20
19
|
WAITLIST_WAVE_MAX,
|
|
20
|
+
WAITLIST_WAVE_PLAN_MAX,
|
|
21
21
|
type WaitlistQuestions,
|
|
22
|
+
type WaitlistRule,
|
|
22
23
|
type WaitlistStatus,
|
|
23
24
|
} from '../waitlist-rules.js'
|
|
24
25
|
import type { Email } from './email.js'
|
|
@@ -34,17 +35,35 @@ import { DEFAULT_LIMITS } from './rate-limit.js'
|
|
|
34
35
|
// what the app serves: the join, a place by its signed link, leaving, and
|
|
35
36
|
// the Waitlist tab's functions.
|
|
36
37
|
|
|
38
|
+
/** Where a waiting person stands against the next wave an administrator planned: in it or not, never its size. */
|
|
39
|
+
export interface WaitlistWaveStanding {
|
|
40
|
+
/** When the wave opens, epoch ms; `null` when no date is set. */
|
|
41
|
+
opensAt: number | null
|
|
42
|
+
/** Whether the person is in it now (a later friend of someone else may still move them out). */
|
|
43
|
+
included: boolean
|
|
44
|
+
/** How many more friends would put them in it: 0 when in it, `null` when sharing is off or the friend cap leaves no room for that many. */
|
|
45
|
+
friendsShort: number | null
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
/** One person's standing, as their status page reads it. */
|
|
38
49
|
export interface WaitlistStatusView {
|
|
39
50
|
status: WaitlistStatus
|
|
40
|
-
/** The place among the people waiting, 1-based; `null` once the person is no longer waiting. */
|
|
51
|
+
/** The place among the people waiting, 1-based; `null` once the person is no longer waiting, and always where rank is private (`place: { rank: false }`). */
|
|
41
52
|
position: number | null
|
|
42
|
-
/** How many people wait. */
|
|
53
|
+
/** How many people wait; 0 where rank is private. */
|
|
43
54
|
total: number
|
|
44
|
-
/**
|
|
55
|
+
/** When the code proved the address, epoch ms: the date the line goes by. Friends never move it; they move the place. 0 on `useWaitlist`'s stand-in before the live status answers. */
|
|
56
|
+
joinedAt: number
|
|
57
|
+
/** The friends who joined through their link and count. */
|
|
45
58
|
friends: number
|
|
46
|
-
/** The most friends that count for one person. */
|
|
47
|
-
cap: number
|
|
59
|
+
/** The most friends that count for one person; `null` for no limit, 0 when sharing is off. */
|
|
60
|
+
cap: number | null
|
|
61
|
+
/** How far up the line friends (and a friend's welcome) moved them, in ms; 0 once they stop waiting. */
|
|
62
|
+
credit: number
|
|
63
|
+
/** How far each friend moves them, in ms; 0 when sharing is off. */
|
|
64
|
+
perFriend: number
|
|
65
|
+
/** Where they stand against the planned wave; `null` when none is planned or they no longer wait. */
|
|
66
|
+
wave: WaitlistWaveStanding | null
|
|
48
67
|
/** The code of their share link: `?ref=<shareCode>` on the page that holds the form. */
|
|
49
68
|
shareCode: string
|
|
50
69
|
/** Whether they asked for launch news. */
|
|
@@ -87,6 +106,8 @@ export interface WaitlistConsole {
|
|
|
87
106
|
entries: WaitlistEntryRow[]
|
|
88
107
|
/** The questions the app asks, with their choices: the filter's. */
|
|
89
108
|
questions: WaitlistQuestions
|
|
109
|
+
/** The next wave as planned: how many from the front of the line, and when it opens; `null` when none is planned. */
|
|
110
|
+
wave: { size: number, opensAt: number | null } | null
|
|
90
111
|
}
|
|
91
112
|
|
|
92
113
|
/** The room a wave has, read from the services that bound it. */
|
|
@@ -124,12 +145,21 @@ export interface WaitlistApi {
|
|
|
124
145
|
noteWaitlist: RegisteredMutation<'public', { id: string, note: string }, Promise<null>>
|
|
125
146
|
/** The room a wave has. `null` for anyone who is not an administrator now. */
|
|
126
147
|
getWaitlistCaps: RegisteredAction<'public', Record<string, never>, Promise<WaitlistCaps | null>>
|
|
148
|
+
/**
|
|
149
|
+
* Plan the next wave: `size` people from the front of the line, opening at
|
|
150
|
+
* `opensAt` (epoch ms) if a date is set; `size: null` clears the plan.
|
|
151
|
+
* Each waiting person then reads whether they are in it, never its size.
|
|
152
|
+
* An administrator's, in person, with a recent sign-in.
|
|
153
|
+
*/
|
|
154
|
+
planWaitlistWave: RegisteredMutation<'public', { size: number | null, opensAt?: number | null }, Promise<null>>
|
|
127
155
|
}
|
|
128
156
|
|
|
129
157
|
/** The app's waitlist, from {@link setupWaitlist}. */
|
|
130
158
|
export interface Waitlist {
|
|
131
159
|
/** The questions asked beside the address. */
|
|
132
160
|
questions: WaitlistQuestions
|
|
161
|
+
/** The rule the line runs on, from `setupAccess({ waitlist })`: how sharing moves people, and whether a person reads their rank. */
|
|
162
|
+
rule: WaitlistRule
|
|
133
163
|
/** The public functions `backend/waitlist.ts` re-exports. */
|
|
134
164
|
api: WaitlistApi
|
|
135
165
|
/**
|
|
@@ -164,7 +194,8 @@ export interface SetupWaitlistOptions {
|
|
|
164
194
|
interface WaitlistRefs {
|
|
165
195
|
waitlist: {
|
|
166
196
|
stage: FunctionReference<'mutation', 'internal', { email: string, key: string, answers?: Record<string, string>, launchNews?: { text: string }, source: string, ref?: string, locale?: string }, null>
|
|
167
|
-
place: FunctionReference<'query', 'internal', { id: string }, { status: WaitlistStatus, position: number | null, total: number, boost: number, shareCode: string, launchNews: boolean } | null>
|
|
197
|
+
place: FunctionReference<'query', 'internal', { id: string, rank?: boolean, perFriend?: number | null }, { status: WaitlistStatus, position: number | null, total: number, boost: number, credit: number, shareCode: string, launchNews: boolean, verifiedAt: number, wave: WaitlistWaveStanding | null } | null>
|
|
198
|
+
planWave: FunctionReference<'mutation', 'internal', { wave: { size: number, opensAt?: number } | null }, null>
|
|
168
199
|
leave: FunctionReference<'mutation', 'internal', { id: string }, null>
|
|
169
200
|
queue: FunctionReference<'query', 'internal', { limit: number }, string[]>
|
|
170
201
|
admit: FunctionReference<'mutation', 'internal', { ids: string[], max?: number, label?: string, createdBy?: string }, Array<{ id: string, email: string, locale: string | null }>>
|
|
@@ -184,6 +215,14 @@ function checkedWave(ids: string[] | undefined, next: number | undefined): void
|
|
|
184
215
|
if (!ids && next === undefined) throw backendError('invalid_input', { field: 'ids' }, '[nuxt-backend] admitWaitlist: pass the entries (`ids`) or how many are next (`next`).')
|
|
185
216
|
}
|
|
186
217
|
|
|
218
|
+
/** The plan `planWaitlistWave` takes, checked: a size within a planned wave's bounds, and a date that is a time. */
|
|
219
|
+
function checkedPlan(size: number | null, opensAt: number | null | undefined): { size: number, opensAt?: number } | null {
|
|
220
|
+
if (size === null) return null
|
|
221
|
+
if (!Number.isInteger(size) || size < 1 || size > WAITLIST_WAVE_PLAN_MAX) throw backendError('invalid_input', { field: 'size' }, `[nuxt-backend] planWaitlistWave: the size is a whole number from 1 to ${WAITLIST_WAVE_PLAN_MAX}.`)
|
|
222
|
+
if (opensAt !== undefined && opensAt !== null && !Number.isFinite(opensAt)) throw backendError('invalid_input', { field: 'opensAt' }, '[nuxt-backend] planWaitlistWave: the opening date is a time in epoch milliseconds.')
|
|
223
|
+
return { size, ...(typeof opensAt === 'number' ? { opensAt } : {}) }
|
|
224
|
+
}
|
|
225
|
+
|
|
187
226
|
/** The words of the launch-news box the person agreed to, kept with the time as the record of consent: the form sends the ones it showed, else these. */
|
|
188
227
|
const LAUNCH_NEWS_TEXT = 'Email me when it launches'
|
|
189
228
|
|
|
@@ -220,7 +259,7 @@ const siteUrl = (): string | undefined => readEnv('SITE_URL')?.replace(/\/+$/, '
|
|
|
220
259
|
* questions: { role: ['Writer', 'Illustrator', 'Reader'] },
|
|
221
260
|
* })
|
|
222
261
|
*
|
|
223
|
-
* export const { getWaitlistQuestions, joinWaitlist, waitlistStatus, leaveWaitlist, getWaitlistConsole, admitWaitlist, declineWaitlist, noteWaitlist, getWaitlistCaps } = waitlist.api
|
|
262
|
+
* export const { getWaitlistQuestions, joinWaitlist, waitlistStatus, leaveWaitlist, getWaitlistConsole, admitWaitlist, declineWaitlist, noteWaitlist, getWaitlistCaps, planWaitlistWave } = waitlist.api
|
|
224
263
|
* ```
|
|
225
264
|
*/
|
|
226
265
|
export function setupWaitlist(components: AccessComponents, options: SetupWaitlistOptions): Waitlist {
|
|
@@ -232,6 +271,8 @@ export function setupWaitlist(components: AccessComponents, options: SetupWaitli
|
|
|
232
271
|
}
|
|
233
272
|
const { access, email } = options
|
|
234
273
|
const questions = checkedQuestions(options.questions)
|
|
274
|
+
// The rule is the access's (setupAccess({ waitlist })): the sign-in page records entries by it too.
|
|
275
|
+
const rule: WaitlistRule = access.internals.waitlistRule
|
|
235
276
|
// Where an admitted person signs up: the sign-in page, wherever nuxt.config moves it.
|
|
236
277
|
const signInPath = resolveBackendPaths(options.paths, 'setupWaitlist').login
|
|
237
278
|
const refs = access.internals.refs as WaitlistRefs & Record<string, unknown>
|
|
@@ -245,11 +286,29 @@ export function setupWaitlist(components: AccessComponents, options: SetupWaitli
|
|
|
245
286
|
/** The entry a status token names, if the token was signed here. */
|
|
246
287
|
const entryOf = async (token: string): Promise<string | null> => firstVerified(secrets(), value => readStatusToken(value, token))
|
|
247
288
|
|
|
248
|
-
|
|
289
|
+
const sharing = rule.boost.cap === null || rule.boost.cap > 0
|
|
290
|
+
|
|
291
|
+
/** A wave's friends-short count only where the cap leaves room for that many more friends. */
|
|
292
|
+
const reachable = (wave: WaitlistWaveStanding, friends: number): WaitlistWaveStanding =>
|
|
293
|
+
wave.friendsShort !== null && rule.boost.cap !== null && wave.friendsShort > rule.boost.cap - friends ? { ...wave, friendsShort: null } : wave
|
|
294
|
+
|
|
295
|
+
/** An entry's standing, as its status page reads it: the place and the count only where rank is shown. */
|
|
249
296
|
async function placeFor(ctx: Pick<AccessCtx, 'runQuery'>, id: string): Promise<WaitlistStatusView | null> {
|
|
250
|
-
const place = await ctx.runQuery(refs.waitlist.place, { id })
|
|
297
|
+
const place = await ctx.runQuery(refs.waitlist.place, { id, rank: rule.rank, perFriend: sharing ? rule.boost.perFriend : null })
|
|
251
298
|
if (!place) return null
|
|
252
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
status: place.status,
|
|
301
|
+
position: place.position,
|
|
302
|
+
total: place.total,
|
|
303
|
+
joinedAt: place.verifiedAt,
|
|
304
|
+
friends: place.boost,
|
|
305
|
+
cap: rule.boost.cap,
|
|
306
|
+
credit: place.credit,
|
|
307
|
+
perFriend: sharing ? rule.boost.perFriend : 0,
|
|
308
|
+
wave: place.wave && reachable(place.wave, place.boost),
|
|
309
|
+
shareCode: place.shareCode,
|
|
310
|
+
launchNews: place.launchNews,
|
|
311
|
+
}
|
|
253
312
|
}
|
|
254
313
|
|
|
255
314
|
const getWaitlistQuestions = queryGeneric({ args: {}, handler: async (): Promise<WaitlistQuestions> => questions })
|
|
@@ -388,10 +447,23 @@ export function setupWaitlist(components: AccessComponents, options: SetupWaitli
|
|
|
388
447
|
},
|
|
389
448
|
})
|
|
390
449
|
|
|
450
|
+
const planWaitlistWave = mutationGeneric({
|
|
451
|
+
args: { size: v.union(v.null(), v.number()), opensAt: v.optional(v.union(v.null(), v.number())) },
|
|
452
|
+
returns: v.null(),
|
|
453
|
+
handler: async (ctx, { size, opensAt }) => {
|
|
454
|
+
await administrators.require(ctx, 'planWaitlistWave')
|
|
455
|
+
const wave = checkedPlan(size, opensAt)
|
|
456
|
+
await ctx.runMutation(refs.waitlist.planWave, { wave })
|
|
457
|
+
await audit.recordBackendEvent(ctx, { type: 'waitlist.wave_planned', data: wave ? { size: wave.size, ...(wave.opensAt !== undefined ? { opensAt: wave.opensAt } : {}) } : {} })
|
|
458
|
+
return null
|
|
459
|
+
},
|
|
460
|
+
})
|
|
461
|
+
|
|
391
462
|
return {
|
|
392
463
|
questions,
|
|
464
|
+
rule,
|
|
393
465
|
launchAudience: ctx => ctx.runQuery(refs.waitlist.audience, {}),
|
|
394
|
-
api: { getWaitlistQuestions, joinWaitlist, waitlistStatus, leaveWaitlist, getWaitlistConsole, admitWaitlist, declineWaitlist, noteWaitlist, getWaitlistCaps } as unknown as WaitlistApi,
|
|
466
|
+
api: { getWaitlistQuestions, joinWaitlist, waitlistStatus, leaveWaitlist, getWaitlistConsole, admitWaitlist, declineWaitlist, noteWaitlist, getWaitlistCaps, planWaitlistWave } as unknown as WaitlistApi,
|
|
395
467
|
}
|
|
396
468
|
}
|
|
397
469
|
|