nuxt-backend 0.3.0 → 0.5.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 +10 -1
- package/dist/chunks/catalog.mjs +1 -1
- package/dist/chunks/doctor.mjs +103 -9
- package/dist/chunks/email-previews.mjs +1 -1
- package/dist/chunks/health.mjs +2 -2
- package/dist/chunks/index.mjs +3 -3
- package/dist/chunks/install.mjs +8 -8
- package/dist/chunks/run.mjs +1 -1
- package/dist/chunks/server.mjs +6 -6
- package/dist/cli.mjs +290 -188
- package/dist/convex/catalog.d.ts +8 -0
- package/dist/convex/catalog.d.ts.map +1 -1
- package/dist/convex/catalog.js +16 -0
- package/dist/convex/catalog.js.map +1 -1
- package/dist/convex/components/backend/_generated/component.d.ts +21 -1
- package/dist/convex/components/backend/_generated/component.d.ts.map +1 -1
- package/dist/convex/components/backend/billing.d.ts +7 -0
- package/dist/convex/components/backend/billing.d.ts.map +1 -1
- package/dist/convex/components/backend/billing.js +20 -5
- package/dist/convex/components/backend/billing.js.map +1 -1
- package/dist/convex/components/backend/jobs.d.ts +69 -1
- package/dist/convex/components/backend/jobs.d.ts.map +1 -1
- package/dist/convex/components/backend/jobs.js +103 -5
- package/dist/convex/components/backend/jobs.js.map +1 -1
- package/dist/convex/components/backend/schema.d.ts +46 -18
- package/dist/convex/components/backend/schema.d.ts.map +1 -1
- package/dist/convex/components/backend/schema.js +11 -0
- package/dist/convex/components/backend/schema.js.map +1 -1
- package/dist/convex/components/backend/subscriptions.d.ts +3 -3
- package/dist/convex/delivery.d.ts +17 -0
- package/dist/convex/delivery.d.ts.map +1 -1
- package/dist/convex/delivery.js +26 -1
- package/dist/convex/delivery.js.map +1 -1
- package/dist/convex/emails/renewal-reminder.d.ts.map +1 -1
- package/dist/convex/emails/renewal-reminder.js +17 -1
- package/dist/convex/emails/renewal-reminder.js.map +1 -1
- package/dist/convex/errors.d.ts +7 -5
- package/dist/convex/errors.d.ts.map +1 -1
- package/dist/convex/errors.js +24 -9
- package/dist/convex/errors.js.map +1 -1
- package/dist/convex/events.d.ts +10 -0
- package/dist/convex/events.d.ts.map +1 -1
- package/dist/convex/events.js +7 -0
- package/dist/convex/events.js.map +1 -1
- package/dist/convex/integrations/ai/images.d.ts.map +1 -1
- package/dist/convex/integrations/ai/images.js +20 -7
- package/dist/convex/integrations/ai/images.js.map +1 -1
- package/dist/convex/integrations/ai/job-errors.d.ts +32 -4
- package/dist/convex/integrations/ai/job-errors.d.ts.map +1 -1
- package/dist/convex/integrations/ai/job-errors.js +55 -8
- package/dist/convex/integrations/ai/job-errors.js.map +1 -1
- package/dist/convex/integrations/ai/jobs.d.ts +128 -7
- package/dist/convex/integrations/ai/jobs.d.ts.map +1 -1
- package/dist/convex/integrations/ai/jobs.js +395 -63
- package/dist/convex/integrations/ai/jobs.js.map +1 -1
- package/dist/convex/integrations/ai/models.d.ts +1 -1
- package/dist/convex/integrations/ai/models.d.ts.map +1 -1
- package/dist/convex/integrations/ai/moderation.d.ts +9 -3
- package/dist/convex/integrations/ai/moderation.d.ts.map +1 -1
- package/dist/convex/integrations/ai/moderation.js +4 -2
- package/dist/convex/integrations/ai/moderation.js.map +1 -1
- package/dist/convex/integrations/ai.d.ts +2 -2
- package/dist/convex/integrations/ai.d.ts.map +1 -1
- package/dist/convex/integrations/ai.js +1 -1
- package/dist/convex/integrations/ai.js.map +1 -1
- package/dist/convex/integrations/billing/context.d.ts.map +1 -1
- package/dist/convex/integrations/billing/context.js +5 -2
- package/dist/convex/integrations/billing/context.js.map +1 -1
- package/dist/convex/integrations/billing/credits.d.ts +1 -0
- package/dist/convex/integrations/billing/credits.d.ts.map +1 -1
- package/dist/convex/integrations/billing/credits.js +4 -1
- package/dist/convex/integrations/billing/credits.js.map +1 -1
- package/dist/convex/integrations/billing/features.d.ts.map +1 -1
- package/dist/convex/integrations/billing/gifts.d.ts.map +1 -1
- package/dist/convex/integrations/billing/history.d.ts.map +1 -1
- package/dist/convex/integrations/billing/passes.d.ts +2 -2
- package/dist/convex/integrations/billing/passes.d.ts.map +1 -1
- package/dist/convex/integrations/billing/passes.js +3 -11
- package/dist/convex/integrations/billing/passes.js.map +1 -1
- package/dist/convex/integrations/billing/provider-failure.d.ts +17 -0
- package/dist/convex/integrations/billing/provider-failure.d.ts.map +1 -0
- package/dist/convex/integrations/billing/provider-failure.js +52 -0
- package/dist/convex/integrations/billing/provider-failure.js.map +1 -0
- package/dist/convex/integrations/billing/quotas.d.ts.map +1 -1
- package/dist/convex/integrations/billing/subscriptions.d.ts.map +1 -1
- package/dist/convex/integrations/billing/types/setup.d.ts +1 -0
- package/dist/convex/integrations/billing/types/setup.d.ts.map +1 -1
- package/dist/convex/integrations/billing/types/surface.d.ts +9 -1
- package/dist/convex/integrations/billing/types/surface.d.ts.map +1 -1
- package/dist/convex/integrations/email-sync.d.ts +24 -2
- package/dist/convex/integrations/email-sync.d.ts.map +1 -1
- package/dist/convex/integrations/email-sync.js +54 -23
- package/dist/convex/integrations/email-sync.js.map +1 -1
- package/dist/convex/integrations/inbound.d.ts +16 -7
- package/dist/convex/integrations/inbound.d.ts.map +1 -1
- package/dist/convex/integrations/inbound.js +21 -10
- package/dist/convex/integrations/inbound.js.map +1 -1
- package/dist/convex/integrations/launch.d.ts +17 -1
- package/dist/convex/integrations/launch.d.ts.map +1 -1
- package/dist/convex/integrations/launch.js +32 -3
- package/dist/convex/integrations/launch.js.map +1 -1
- package/dist/convex/integrations/referrals.d.ts +20 -0
- package/dist/convex/integrations/referrals.d.ts.map +1 -1
- package/dist/convex/integrations/referrals.js +14 -9
- package/dist/convex/integrations/referrals.js.map +1 -1
- package/dist/convex/integrations/storage.d.ts +67 -0
- package/dist/convex/integrations/storage.d.ts.map +1 -1
- package/dist/convex/integrations/storage.js +42 -1
- package/dist/convex/integrations/storage.js.map +1 -1
- package/dist/convex/label-groups/admin.d.ts +3 -0
- package/dist/convex/label-groups/admin.d.ts.map +1 -1
- package/dist/convex/label-groups/admin.js +3 -0
- package/dist/convex/label-groups/admin.js.map +1 -1
- package/dist/convex/label-groups/audit.d.ts +1 -0
- package/dist/convex/label-groups/audit.d.ts.map +1 -1
- package/dist/convex/label-groups/audit.js +1 -0
- package/dist/convex/label-groups/audit.js.map +1 -1
- package/dist/convex/label-groups/auth.d.ts +7 -0
- package/dist/convex/label-groups/auth.d.ts.map +1 -1
- package/dist/convex/label-groups/auth.js +7 -0
- package/dist/convex/label-groups/auth.js.map +1 -1
- package/dist/convex/label-groups/errors.d.ts +9 -0
- package/dist/convex/label-groups/errors.d.ts.map +1 -1
- package/dist/convex/label-groups/errors.js +12 -0
- package/dist/convex/label-groups/errors.js.map +1 -1
- package/dist/convex/label-groups/gift.d.ts +24 -0
- package/dist/convex/label-groups/gift.d.ts.map +1 -1
- package/dist/convex/label-groups/gift.js +27 -0
- package/dist/convex/label-groups/gift.js.map +1 -1
- package/dist/convex/label-groups/legal.d.ts +1 -1
- package/dist/convex/label-groups/pricing.d.ts +15 -0
- package/dist/convex/label-groups/pricing.d.ts.map +1 -1
- package/dist/convex/label-groups/pricing.js +20 -0
- package/dist/convex/label-groups/pricing.js.map +1 -1
- package/dist/convex/label-groups/referral.d.ts +4 -0
- package/dist/convex/label-groups/referral.d.ts.map +1 -1
- package/dist/convex/label-groups/referral.js +4 -0
- package/dist/convex/label-groups/referral.js.map +1 -1
- package/dist/convex/label-groups/settings.d.ts +34 -0
- package/dist/convex/label-groups/settings.d.ts.map +1 -1
- package/dist/convex/label-groups/settings.js +39 -0
- package/dist/convex/label-groups/settings.js.map +1 -1
- package/dist/convex/label-groups/waitlist.d.ts +5 -0
- package/dist/convex/label-groups/waitlist.d.ts.map +1 -1
- package/dist/convex/label-groups/waitlist.js +7 -2
- package/dist/convex/label-groups/waitlist.js.map +1 -1
- package/dist/convex/labels.d.ts +103 -1
- package/dist/convex/labels.d.ts.map +1 -1
- package/dist/convex/legal.d.ts +18 -1
- package/dist/convex/legal.d.ts.map +1 -1
- package/dist/convex/legal.js +17 -2
- package/dist/convex/legal.js.map +1 -1
- package/dist/convex/log.js +8 -0
- package/dist/convex/log.js.map +1 -1
- package/dist/convex/money.d.ts +10 -0
- package/dist/convex/money.d.ts.map +1 -0
- package/dist/convex/money.js +37 -0
- package/dist/convex/money.js.map +1 -0
- package/dist/convex/report-rules.d.ts +6 -0
- package/dist/convex/report-rules.d.ts.map +1 -1
- package/dist/convex/report-rules.js +15 -0
- package/dist/convex/report-rules.js.map +1 -1
- package/dist/convex/test-billing.d.ts +83 -0
- package/dist/convex/test-billing.d.ts.map +1 -0
- package/dist/convex/test-billing.js +131 -0
- package/dist/convex/test-billing.js.map +1 -0
- package/dist/convex/test-models.d.ts +14 -2
- package/dist/convex/test-models.d.ts.map +1 -1
- package/dist/convex/test-models.js +61 -4
- package/dist/convex/test-models.js.map +1 -1
- package/dist/devtools-client/index.html +1 -1
- package/dist/eslint.d.mts +2 -1
- package/dist/eslint.mjs +2 -1
- package/dist/module.d.ts +45 -2
- package/dist/module.js +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/chunk-recovery.d.ts +13 -0
- package/dist/runtime/chunk-recovery.js +1 -0
- package/dist/runtime/locales/de.json +113 -7
- package/dist/runtime/locales/en.json +114 -8
- package/dist/runtime/locales/es.json +113 -7
- package/dist/runtime/locales/fr.json +113 -7
- package/dist/runtime/locales/ru.json +113 -7
- package/dist/runtime/server/chunk-recovery.d.ts +49 -0
- package/dist/runtime/server/chunk-recovery.js +44 -0
- package/dist/runtime/server/csp.d.ts +7 -2
- package/dist/runtime/server/csp.js +2 -2
- package/dist/runtime/server/photo-decoder-csp.d.ts +17 -0
- package/dist/runtime/server/photo-decoder-csp.js +9 -0
- package/dist/runtime/vue/components/account/AccountDeletion.css +1 -1
- package/dist/runtime/vue/components/account/ActivationChecklist.css +1 -1
- package/dist/runtime/vue/components/account/ConsentPrompt.css +1 -1
- package/dist/runtime/vue/components/account/EmailUnsubscribe.css +1 -1
- package/dist/runtime/vue/components/account/HowDidYouHear.css +1 -1
- package/dist/runtime/vue/components/account/KeepAccount.css +1 -1
- package/dist/runtime/vue/components/account/OnboardingFlow.css +1 -1
- package/dist/runtime/vue/components/account/ProfileIdentity.css +1 -1
- package/dist/runtime/vue/components/account/ProfilePreferencesSection.css +1 -1
- package/dist/runtime/vue/components/account/ProfileSettings.css +1 -1
- package/dist/runtime/vue/components/account/SecurityAlerts.css +1 -1
- package/dist/runtime/vue/components/account/SecurityPasskeys.css +1 -1
- package/dist/runtime/vue/components/account/SecuritySessions.css +1 -1
- package/dist/runtime/vue/components/account/SecuritySettings.css +1 -1
- package/dist/runtime/vue/components/admin/AdminAccess.css +1 -1
- package/dist/runtime/vue/components/admin/AdminAnnouncements.css +1 -1
- package/dist/runtime/vue/components/admin/AdminBilling.css +1 -1
- package/dist/runtime/vue/components/admin/AdminChart.css +1 -1
- package/dist/runtime/vue/components/admin/AdminConsole.css +1 -1
- package/dist/runtime/vue/components/admin/AdminExperiments.css +1 -1
- package/dist/runtime/vue/components/admin/AdminFlags.css +1 -1
- package/dist/runtime/vue/components/admin/AdminQueue.css +1 -1
- package/dist/runtime/vue/components/admin/AdminQueueJob.vue +5 -2
- package/dist/runtime/vue/components/admin/AdminReferrals.css +1 -1
- package/dist/runtime/vue/components/admin/AdminReports.css +1 -1
- package/dist/runtime/vue/components/admin/AdminRevenue.css +1 -1
- package/dist/runtime/vue/components/admin/AdminUsers.d.vue.ts +3 -0
- package/dist/runtime/vue/components/admin/AdminUsers.vue.d.ts +3 -0
- package/dist/runtime/vue/components/admin/AdminWorkspaces.d.vue.ts +3 -0
- package/dist/runtime/vue/components/admin/AdminWorkspaces.vue.d.ts +3 -0
- package/dist/runtime/vue/components/admin/admin-access-tab.js +2 -1
- package/dist/runtime/vue/components/admin/admin-revenue-tab.js +4 -1
- package/dist/runtime/vue/components/admin/admin.css +1 -1
- package/dist/runtime/vue/components/auth/AuthForm.css +1 -1
- package/dist/runtime/vue/components/auth/AuthForm.d.vue.ts +7 -0
- package/dist/runtime/vue/components/auth/AuthForm.vue +1 -2
- package/dist/runtime/vue/components/auth/AuthForm.vue.d.ts +7 -0
- package/dist/runtime/vue/components/auth/AuthFormChoose.css +1 -1
- package/dist/runtime/vue/components/auth/AuthFormHeader.css +1 -1
- package/dist/runtime/vue/components/auth/AuthFormPasskeyOffer.css +1 -1
- package/dist/runtime/vue/components/auth/InviteRedeem.css +1 -1
- package/dist/runtime/vue/components/auth/InviteRedeem.vue +79 -10
- package/dist/runtime/vue/components/auth/ReauthenticateCode.css +1 -1
- package/dist/runtime/vue/components/auth/ReauthenticateDialog.css +1 -1
- package/dist/runtime/vue/components/auth/ReauthenticatePasskey.css +1 -1
- package/dist/runtime/vue/components/auth/WaitlistForm.css +1 -1
- package/dist/runtime/vue/components/auth/WaitlistForm.d.vue.ts +5 -0
- package/dist/runtime/vue/components/auth/WaitlistForm.vue +3 -5
- package/dist/runtime/vue/components/auth/WaitlistForm.vue.d.ts +5 -0
- package/dist/runtime/vue/components/auth/WaitlistPlace.css +1 -1
- package/dist/runtime/vue/components/auth/WaitlistShare.css +1 -1
- package/dist/runtime/vue/components/auth/WaitlistShare.vue +1 -7
- package/dist/runtime/vue/components/auth/WaitlistStatus.css +1 -1
- package/dist/runtime/vue/components/auth/WaitlistStatus.vue +116 -29
- package/dist/runtime/vue/components/auth/auth-form.d.ts +1 -1
- package/dist/runtime/vue/components/auth/waitlist-form.js +1 -1
- package/dist/runtime/vue/components/billing/BillingHistory.css +1 -1
- package/dist/runtime/vue/components/billing/BillingHistoryOrder.css +1 -1
- package/dist/runtime/vue/components/billing/CancelConfirmGroup.vue +2 -7
- package/dist/runtime/vue/components/billing/CancelFlow.css +1 -1
- package/dist/runtime/vue/components/billing/GiftForm.css +1 -0
- package/dist/runtime/vue/components/billing/GiftForm.d.vue.ts +105 -0
- package/dist/runtime/vue/components/billing/GiftForm.vue +228 -0
- package/dist/runtime/vue/components/billing/GiftForm.vue.d.ts +105 -0
- package/dist/runtime/vue/components/billing/GiftList.css +1 -1
- package/dist/runtime/vue/components/billing/GiftList.d.vue.ts +87 -2
- package/dist/runtime/vue/components/billing/GiftList.vue +7 -4
- package/dist/runtime/vue/components/billing/GiftList.vue.d.ts +87 -2
- package/dist/runtime/vue/components/billing/GiftReceived.vue +11 -3
- package/dist/runtime/vue/components/billing/PlanChangeConfirmGroup.d.vue.ts +7 -0
- package/dist/runtime/vue/components/billing/PlanChangeConfirmGroup.vue +50 -0
- package/dist/runtime/vue/components/billing/PlanChangeConfirmGroup.vue.d.ts +7 -0
- package/dist/runtime/vue/components/billing/PricingChangeConfirm.d.vue.ts +4 -0
- package/dist/runtime/vue/components/billing/PricingChangeConfirm.vue +17 -0
- package/dist/runtime/vue/components/billing/PricingChangeConfirm.vue.d.ts +4 -0
- package/dist/runtime/vue/components/billing/PricingPackCard.css +1 -1
- package/dist/runtime/vue/components/billing/PricingPlanCard.css +1 -1
- package/dist/runtime/vue/components/billing/PricingPlanCard.vue +15 -0
- package/dist/runtime/vue/components/billing/PricingTable.css +1 -1
- package/dist/runtime/vue/components/billing/PricingTable.d.vue.ts +24 -2
- package/dist/runtime/vue/components/billing/PricingTable.vue +70 -37
- package/dist/runtime/vue/components/billing/PricingTable.vue.d.ts +24 -2
- package/dist/runtime/vue/components/billing/ReferralCard.css +1 -1
- package/dist/runtime/vue/components/billing/ReferralCard.d.vue.ts +4 -0
- package/dist/runtime/vue/components/billing/ReferralCard.vue.d.ts +4 -0
- package/dist/runtime/vue/components/billing/ReferralLanding.css +1 -1
- package/dist/runtime/vue/components/billing/ReferralLanding.vue +43 -2
- package/dist/runtime/vue/components/billing/UpgradePrompt.css +1 -1
- package/dist/runtime/vue/components/billing/UsageHistory.css +1 -1
- package/dist/runtime/vue/components/billing/WithdrawalButton.css +1 -1
- package/dist/runtime/vue/components/billing/cancel-flow.js +2 -1
- package/dist/runtime/vue/components/billing/pricing-table.d.ts +10 -0
- package/dist/runtime/vue/components/billing/withdrawal-button.d.ts +3 -2
- package/dist/runtime/vue/components/billing/withdrawal-button.js +13 -33
- package/dist/runtime/vue/components/shared.css +1 -1
- package/dist/runtime/vue/components/shell/AccessDenied.css +1 -1
- package/dist/runtime/vue/components/shell/AiLabel.css +1 -1
- package/dist/runtime/vue/components/shell/AppShell.css +1 -1
- package/dist/runtime/vue/components/shell/ConfirmDialog.css +1 -1
- package/dist/runtime/vue/components/shell/ConnectionStatus.css +1 -1
- package/dist/runtime/vue/components/shell/ContactForm.css +1 -1
- package/dist/runtime/vue/components/shell/Gate.css +1 -1
- package/dist/runtime/vue/components/shell/LegalDocument.css +1 -1
- package/dist/runtime/vue/components/shell/NoticeAnnouncement.css +1 -1
- package/dist/runtime/vue/components/shell/NoticeDeletion.css +1 -1
- package/dist/runtime/vue/components/shell/NoticeGift.css +1 -1
- package/dist/runtime/vue/components/shell/NoticeImpersonation.css +1 -1
- package/dist/runtime/vue/components/shell/NoticeLowCredits.css +1 -1
- package/dist/runtime/vue/components/shell/NoticeMaintenance.css +1 -1
- package/dist/runtime/vue/components/shell/NoticePastDue.css +1 -1
- package/dist/runtime/vue/components/shell/NotificationInbox.css +1 -1
- package/dist/runtime/vue/components/shell/ReportAppeal.vue +16 -13
- package/dist/runtime/vue/components/shell/ReportNotice.css +1 -1
- package/dist/runtime/vue/components/shell/UploadField.css +1 -1
- package/dist/runtime/vue/components/shell/WorkspaceSwitcher.css +1 -1
- package/dist/runtime/vue/components/shell/report-form.js +1 -44
- package/dist/runtime/vue/components/tokens.css +1 -1
- package/dist/runtime/vue/components/workspaces/AuditLog.css +1 -1
- package/dist/runtime/vue/components/workspaces/AuditLog.d.vue.ts +1 -0
- package/dist/runtime/vue/components/workspaces/AuditLog.vue.d.ts +1 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceBilling.css +1 -1
- package/dist/runtime/vue/components/workspaces/WorkspaceBilling.vue +34 -58
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingPause.d.vue.ts +3 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingPause.vue +68 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingPause.vue.d.ts +3 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingSwitch.d.vue.ts +3 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingSwitch.vue +54 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingSwitch.vue.d.ts +3 -0
- package/dist/runtime/vue/components/workspaces/WorkspaceCredits.css +1 -1
- package/dist/runtime/vue/components/workspaces/WorkspaceList.css +1 -1
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +40 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue +20 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +40 -2
- package/dist/runtime/vue/components/workspaces/workspace-billing.d.ts +46 -13
- package/dist/runtime/vue/components/workspaces/workspace-billing.js +93 -16
- package/dist/runtime/vue/components/workspaces/workspace-settings.d.ts +4 -0
- package/dist/runtime/vue/composables/billing-format.d.ts +9 -4
- package/dist/runtime/vue/composables/billing-format.js +17 -9
- package/dist/runtime/vue/composables/billing-provider.js +3 -2
- package/dist/runtime/vue/composables/prepare-photo.d.ts +75 -0
- package/dist/runtime/vue/composables/prepare-photo.js +223 -0
- package/dist/runtime/vue/composables/use-access.d.ts +41 -2
- package/dist/runtime/vue/composables/use-access.js +54 -8
- package/dist/runtime/vue/composables/use-billing-section.d.ts +115 -0
- package/dist/runtime/vue/composables/use-billing-section.js +76 -0
- package/dist/runtime/vue/composables/use-billing.d.ts +76 -5
- package/dist/runtime/vue/composables/use-billing.js +48 -0
- package/dist/runtime/vue/composables/use-gift-form.d.ts +123 -0
- package/dist/runtime/vue/composables/use-gift-form.js +152 -0
- package/dist/runtime/vue/composables/use-gift-list.d.ts +62 -5
- package/dist/runtime/vue/composables/use-gift-list.js +17 -6
- package/dist/runtime/vue/composables/use-install-prompt.d.ts +71 -0
- package/dist/runtime/vue/composables/use-install-prompt.js +53 -0
- package/dist/runtime/vue/composables/use-labels.js +17 -23
- package/dist/runtime/vue/composables/use-login-flow.d.ts +9 -0
- package/dist/runtime/vue/composables/use-login-flow.js +7 -0
- package/dist/runtime/vue/composables/use-orders.d.ts +1 -1
- package/dist/runtime/vue/composables/use-plan-change.d.ts +148 -0
- package/dist/runtime/vue/composables/use-plan-change.js +130 -0
- package/dist/runtime/vue/composables/use-pricing.d.ts +83 -5
- package/dist/runtime/vue/composables/use-pricing.js +83 -17
- package/dist/runtime/vue/composables/use-push-subscription.js +1 -7
- package/dist/runtime/vue/composables/use-referral-invite.d.ts +24 -2
- package/dist/runtime/vue/composables/use-referral-invite.js +14 -2
- package/dist/runtime/vue/composables/use-referrals.js +2 -1
- package/dist/runtime/vue/composables/use-report-appeal.d.ts +86 -0
- package/dist/runtime/vue/composables/use-report-appeal.js +61 -0
- package/dist/runtime/vue/composables/use-return-path.d.ts +5 -4
- package/dist/runtime/vue/composables/use-return-path.js +16 -2
- package/dist/runtime/vue/composables/use-waitlist.d.ts +31 -1
- package/dist/runtime/vue/composables/use-waitlist.js +39 -4
- package/dist/runtime/vue/composables/use-withdrawal.d.ts +63 -0
- package/dist/runtime/vue/composables/use-withdrawal.js +38 -0
- package/dist/runtime/vue/middleware/page-access.js +2 -2
- package/dist/runtime/vue/pages/gifts.vue +2 -0
- package/dist/runtime/vue/pages/login.vue +5 -7
- package/dist/runtime/vue/pages/pricing.vue +1 -2
- package/dist/runtime/vue/pages/report.vue +2 -3
- package/dist/runtime/vue/parts.d.ts +5 -0
- package/dist/runtime/vue/plugins/checkout-return.js +9 -2
- package/dist/runtime/vue/plugins/chunk-recovery.client.d.ts +10 -0
- package/dist/runtime/vue/plugins/chunk-recovery.client.js +10 -0
- package/dist/runtime/vue/plugins/install-banner.client.d.ts +7 -0
- package/dist/runtime/vue/plugins/install-banner.client.js +5 -0
- package/dist/runtime/vue/plugins/install-prompt.client.d.ts +7 -0
- package/dist/runtime/vue/plugins/install-prompt.client.js +6 -0
- package/dist/runtime/vue/plugins/session-ended.js +2 -3
- package/dist/runtime/vue/utils/active-locale.js +8 -0
- package/dist/runtime/vue/utils/checkout-return.d.ts +11 -1
- package/dist/runtime/vue/utils/checkout-return.js +6 -2
- package/dist/runtime/vue/utils/confirm-group.d.ts +18 -0
- package/dist/runtime/vue/utils/confirm-group.js +17 -0
- package/dist/runtime/vue/utils/display-mode.d.ts +8 -0
- package/dist/runtime/vue/utils/display-mode.js +11 -0
- package/dist/runtime/vue/utils/gift-days.d.ts +20 -0
- package/dist/runtime/vue/utils/gift-days.js +32 -0
- package/dist/runtime/vue/utils/heic-absent.d.ts +2 -0
- package/dist/runtime/vue/utils/heic-absent.js +3 -0
- package/dist/runtime/vue/utils/intl.d.ts +12 -4
- package/dist/runtime/vue/utils/intl.js +13 -2
- package/dist/runtime/vue/utils/kept-invite.js +6 -29
- package/dist/runtime/vue/utils/namespace.js +7 -2
- package/dist/runtime/vue/utils/page-open.d.ts +1 -0
- package/dist/runtime/vue/utils/page-open.js +12 -0
- package/dist/runtime/vue/utils/page-origin.d.ts +15 -0
- package/dist/runtime/vue/utils/page-origin.js +8 -0
- package/dist/runtime/vue/utils/page-rules.d.ts +9 -0
- package/dist/runtime/vue/utils/page-rules.js +3 -0
- package/dist/runtime/vue/utils/plan-change-confirm.d.ts +88 -0
- package/dist/runtime/vue/utils/plan-change-confirm.js +48 -0
- package/dist/runtime/vue/utils/pricing-bindings.d.ts +7 -1
- package/dist/runtime/vue/utils/pricing-bindings.js +21 -0
- package/dist/runtime/vue/utils/pricing-checkout.d.ts +39 -0
- package/dist/runtime/vue/utils/pricing-checkout.js +22 -0
- package/dist/runtime/vue/utils/pricing-seo.js +4 -2
- package/dist/runtime/vue/utils/tab-keep.d.ts +19 -0
- package/dist/runtime/vue/utils/tab-keep.js +46 -0
- package/dist/shared/{nuxt-backend.G4JryO1q.mjs → nuxt-backend.BqXAZChe.mjs} +277 -51
- package/dist/shared/{nuxt-backend.Lk2MQI2u.mjs → nuxt-backend.CBvrM7pG.mjs} +26 -2
- package/dist/shared/{nuxt-backend.D9qXcOOI.mjs → nuxt-backend.DH1Ya3uB.mjs} +1 -1
- package/dist/shared/{nuxt-backend.Bq_mhlky.mjs → nuxt-backend.DbaXvH__.mjs} +55 -10
- package/dist/shared/{nuxt-backend.DmZI-QSO.mjs → nuxt-backend.Dikfaocl.mjs} +54 -30
- package/package.json +6 -1
- package/skills/nuxt-backend/references/api.md +28 -10
- package/skills/nuxt-backend/references/install.md +4 -1
- package/skills/nuxt-backend/references/renames.json +112 -0
- package/skills/nuxt-backend/references/surface.json +32 -2
- package/skills/nuxt-backend-ai/references/api.md +2 -1
- package/skills/nuxt-backend-auth/references/api.md +1 -1
- package/skills/nuxt-backend-billing/SKILL.md +9 -0
- package/skills/nuxt-backend-billing/references/api.md +4 -0
- package/skills/nuxt-backend-data/references/api.md +4 -1
- package/skills/nuxt-backend-email/SKILL.md +5 -2
- package/skills/nuxt-backend-email/references/api.md +1 -0
- package/skills/nuxt-backend-growth/references/api.md +4 -0
- package/skills/nuxt-backend-ship/SKILL.md +1 -1
- package/skills/nuxt-backend-ship/references/api.md +9 -5
- package/skills/nuxt-backend-ui/SKILL.md +10 -5
- package/skills/nuxt-backend-upgrade/SKILL.md +4 -3
- package/skills/nuxt-backend-upgrade/references/upgrade.md +49 -0
- package/src/convex/catalog.ts +17 -0
- package/src/convex/components/backend/_generated/component.ts +30 -2
- package/src/convex/components/backend/billing.ts +19 -5
- package/src/convex/components/backend/jobs.ts +102 -5
- package/src/convex/components/backend/schema.ts +11 -0
- package/src/convex/delivery.ts +26 -1
- package/src/convex/emails/renewal-reminder.ts +19 -1
- package/src/convex/errors.ts +23 -9
- package/src/convex/events.ts +7 -0
- package/src/convex/integrations/ai/images.ts +22 -8
- package/src/convex/integrations/ai/job-errors.ts +64 -9
- package/src/convex/integrations/ai/jobs.ts +509 -64
- package/src/convex/integrations/ai/models.ts +1 -1
- package/src/convex/integrations/ai/moderation.ts +10 -5
- package/src/convex/integrations/ai.ts +6 -1
- package/src/convex/integrations/billing/context.ts +6 -3
- package/src/convex/integrations/billing/credits.ts +4 -1
- package/src/convex/integrations/billing/passes.ts +3 -11
- package/src/convex/integrations/billing/provider-failure.ts +56 -0
- package/src/convex/integrations/billing/types/setup.ts +1 -1
- package/src/convex/integrations/billing/types/surface.ts +9 -2
- package/src/convex/integrations/email-sync.ts +74 -26
- package/src/convex/integrations/inbound.ts +32 -16
- package/src/convex/integrations/launch.ts +52 -5
- package/src/convex/integrations/referrals.ts +25 -7
- package/src/convex/integrations/storage.ts +107 -1
- package/src/convex/label-groups/admin.ts +3 -0
- package/src/convex/label-groups/audit.ts +1 -0
- package/src/convex/label-groups/auth.ts +7 -0
- package/src/convex/label-groups/errors.ts +12 -0
- package/src/convex/label-groups/gift.ts +27 -0
- package/src/convex/label-groups/pricing.ts +20 -0
- package/src/convex/label-groups/referral.ts +4 -0
- package/src/convex/label-groups/settings.ts +39 -0
- package/src/convex/label-groups/waitlist.ts +7 -2
- package/src/convex/legal.ts +23 -2
- package/src/convex/log.ts +8 -0
- package/src/convex/money.ts +40 -0
- package/src/convex/report-rules.ts +16 -0
- package/src/convex/test-billing.ts +189 -0
- package/src/convex/test-models.ts +59 -4
- package/src/convex/test.ts +95 -8
- package/src/runtime/vue/components/account/AccountDeletion.css +1 -1
- package/src/runtime/vue/components/account/ActivationChecklist.css +5 -3
- package/src/runtime/vue/components/account/ConsentPrompt.css +7 -5
- package/src/runtime/vue/components/account/EmailUnsubscribe.css +8 -4
- package/src/runtime/vue/components/account/HowDidYouHear.css +9 -5
- package/src/runtime/vue/components/account/KeepAccount.css +4 -2
- package/src/runtime/vue/components/account/OnboardingFlow.css +6 -4
- package/src/runtime/vue/components/account/ProfileIdentity.css +1 -1
- package/src/runtime/vue/components/account/ProfilePreferencesSection.css +4 -2
- package/src/runtime/vue/components/account/ProfileSettings.css +4 -2
- package/src/runtime/vue/components/account/SecurityAlerts.css +1 -1
- package/src/runtime/vue/components/account/SecurityPasskeys.css +3 -3
- package/src/runtime/vue/components/account/SecuritySessions.css +1 -1
- package/src/runtime/vue/components/account/SecuritySettings.css +1 -1
- package/src/runtime/vue/components/admin/AdminAccess.css +1 -1
- package/src/runtime/vue/components/admin/AdminAnnouncements.css +2 -2
- package/src/runtime/vue/components/admin/AdminBilling.css +1 -1
- package/src/runtime/vue/components/admin/AdminChart.css +1 -1
- package/src/runtime/vue/components/admin/AdminConsole.css +1 -0
- package/src/runtime/vue/components/admin/AdminExperiments.css +1 -1
- package/src/runtime/vue/components/admin/AdminFlags.css +2 -2
- package/src/runtime/vue/components/admin/AdminQueue.css +5 -3
- package/src/runtime/vue/components/admin/AdminQueueJob.vue +6 -2
- package/src/runtime/vue/components/admin/AdminReferrals.css +4 -2
- package/src/runtime/vue/components/admin/AdminReports.css +1 -1
- package/src/runtime/vue/components/admin/AdminRevenue.css +1 -1
- package/src/runtime/vue/components/admin/admin.css +3 -3
- package/src/runtime/vue/components/auth/AuthForm.css +7 -4
- package/src/runtime/vue/components/auth/AuthForm.vue +1 -2
- package/src/runtime/vue/components/auth/AuthFormChoose.css +2 -1
- package/src/runtime/vue/components/auth/AuthFormHeader.css +1 -1
- package/src/runtime/vue/components/auth/AuthFormPasskeyOffer.css +1 -1
- package/src/runtime/vue/components/auth/InviteRedeem.css +56 -2
- package/src/runtime/vue/components/auth/InviteRedeem.vue +92 -12
- package/src/runtime/vue/components/auth/ReauthenticateCode.css +1 -1
- package/src/runtime/vue/components/auth/ReauthenticateDialog.css +6 -3
- package/src/runtime/vue/components/auth/ReauthenticatePasskey.css +1 -1
- package/src/runtime/vue/components/auth/WaitlistForm.css +4 -2
- package/src/runtime/vue/components/auth/WaitlistForm.vue +5 -6
- package/src/runtime/vue/components/auth/WaitlistPlace.css +4 -2
- package/src/runtime/vue/components/auth/WaitlistShare.css +6 -4
- package/src/runtime/vue/components/auth/WaitlistShare.vue +2 -8
- package/src/runtime/vue/components/auth/WaitlistStatus.css +27 -1
- package/src/runtime/vue/components/auth/WaitlistStatus.vue +149 -36
- package/src/runtime/vue/components/billing/BillingHistory.css +2 -2
- package/src/runtime/vue/components/billing/BillingHistoryOrder.css +1 -1
- package/src/runtime/vue/components/billing/CancelConfirmGroup.vue +2 -8
- package/src/runtime/vue/components/billing/CancelFlow.css +6 -4
- package/src/runtime/vue/components/billing/GiftForm.css +89 -0
- package/src/runtime/vue/components/billing/GiftForm.vue +251 -0
- package/src/runtime/vue/components/billing/GiftList.css +5 -3
- package/src/runtime/vue/components/billing/GiftList.vue +21 -9
- package/src/runtime/vue/components/billing/GiftReceived.vue +11 -3
- package/src/runtime/vue/components/billing/PlanChangeConfirmGroup.vue +59 -0
- package/src/runtime/vue/components/billing/PricingChangeConfirm.vue +22 -0
- package/src/runtime/vue/components/billing/PricingPackCard.css +1 -1
- package/src/runtime/vue/components/billing/PricingPlanCard.css +31 -4
- package/src/runtime/vue/components/billing/PricingPlanCard.vue +17 -2
- package/src/runtime/vue/components/billing/PricingTable.css +2 -2
- package/src/runtime/vue/components/billing/PricingTable.vue +122 -66
- package/src/runtime/vue/components/billing/ReferralCard.css +6 -4
- package/src/runtime/vue/components/billing/ReferralLanding.css +14 -3
- package/src/runtime/vue/components/billing/ReferralLanding.vue +53 -3
- package/src/runtime/vue/components/billing/UpgradePrompt.css +6 -4
- package/src/runtime/vue/components/billing/UsageHistory.css +2 -2
- package/src/runtime/vue/components/billing/WithdrawalButton.css +5 -3
- package/src/runtime/vue/components/shared.css +62 -9
- package/src/runtime/vue/components/shell/AccessDenied.css +5 -3
- package/src/runtime/vue/components/shell/AiLabel.css +2 -2
- package/src/runtime/vue/components/shell/AppShell.css +5 -3
- package/src/runtime/vue/components/shell/ConfirmDialog.css +5 -3
- package/src/runtime/vue/components/shell/ConnectionStatus.css +1 -1
- package/src/runtime/vue/components/shell/ContactForm.css +4 -2
- package/src/runtime/vue/components/shell/Gate.css +5 -3
- package/src/runtime/vue/components/shell/LegalDocument.css +1 -1
- package/src/runtime/vue/components/shell/NoticeAnnouncement.css +1 -1
- package/src/runtime/vue/components/shell/NoticeDeletion.css +5 -3
- package/src/runtime/vue/components/shell/NoticeGift.css +1 -1
- package/src/runtime/vue/components/shell/NoticeImpersonation.css +1 -1
- package/src/runtime/vue/components/shell/NoticeLowCredits.css +6 -3
- package/src/runtime/vue/components/shell/NoticeMaintenance.css +1 -1
- package/src/runtime/vue/components/shell/NoticePastDue.css +5 -3
- package/src/runtime/vue/components/shell/NotificationInbox.css +6 -4
- package/src/runtime/vue/components/shell/ReportAppeal.vue +17 -14
- package/src/runtime/vue/components/shell/ReportNotice.css +1 -1
- package/src/runtime/vue/components/shell/UploadField.css +5 -3
- package/src/runtime/vue/components/shell/WorkspaceSwitcher.css +5 -3
- package/src/runtime/vue/components/tokens.css +30 -0
- package/src/runtime/vue/components/workspaces/AuditLog.css +2 -2
- package/src/runtime/vue/components/workspaces/WorkspaceBilling.css +75 -2
- package/src/runtime/vue/components/workspaces/WorkspaceBilling.vue +51 -63
- package/src/runtime/vue/components/workspaces/WorkspaceBillingPause.vue +78 -0
- package/src/runtime/vue/components/workspaces/WorkspaceBillingSwitch.vue +63 -0
- package/src/runtime/vue/components/workspaces/WorkspaceCredits.css +1 -0
- package/src/runtime/vue/components/workspaces/WorkspaceList.css +2 -2
- package/src/runtime/vue/components/workspaces/WorkspaceSettings.vue +35 -5
- package/src/runtime/vue/pages/gifts.vue +12 -7
- package/src/runtime/vue/pages/invite.vue +4 -2
- package/src/runtime/vue/pages/login.vue +8 -8
- package/src/runtime/vue/pages/pricing.vue +1 -4
- package/src/runtime/vue/pages/report.vue +2 -3
- package/src/runtime/vue/pages/waitlist.vue +8 -5
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
import type { BackendError } from '../utils/backend-error.js';
|
|
3
|
+
import { type CheckoutOptions, type PlanChangePreview } from './use-billing.js';
|
|
4
|
+
import { type LabelGroupOverrides } from './use-labels.js';
|
|
5
|
+
import { type PricingInterval, type UsePricingReturn } from './use-pricing.js';
|
|
6
|
+
/** A price a subscription's switch moves to, as its confirmation names it. */
|
|
7
|
+
export interface PlanChangeTarget {
|
|
8
|
+
/** The product to switch to: one price of a plan. */
|
|
9
|
+
productId: string;
|
|
10
|
+
/** The plan as the confirmation names it: `Team`, `Pro, billed yearly`. */
|
|
11
|
+
plan: string;
|
|
12
|
+
/** Its price with its period, formatted: `$29/mo`. */
|
|
13
|
+
price: string;
|
|
14
|
+
/** Who opened the confirmation, to tell two openers apart: a plan card's key. Default: `productId`. */
|
|
15
|
+
key?: string;
|
|
16
|
+
}
|
|
17
|
+
/** One price the subscription can switch to, in its own currency ({@link UsePlanChangeReturn.targets}). */
|
|
18
|
+
export interface PlanSwitchTarget extends Required<PlanChangeTarget> {
|
|
19
|
+
/** Its plan's catalog key (`'team'`). */
|
|
20
|
+
key: string;
|
|
21
|
+
/** The plan's own name, as the provider lists it. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** The interval the price bills at. */
|
|
24
|
+
interval: PricingInterval;
|
|
25
|
+
/** What one interval costs, in the currency's smallest unit. */
|
|
26
|
+
amount: number;
|
|
27
|
+
/** Lower-case ISO 4217 code: the subscription's own, where it is known. */
|
|
28
|
+
currency: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* How a switch goes: `'now'` at once, `'period_end'` when the paid year
|
|
32
|
+
* runs out (`useBilling().changeOf` says which), `'checkout'` for a gifted
|
|
33
|
+
* plan's holder, whose switch is a checkout of the plan that ends the gift.
|
|
34
|
+
*/
|
|
35
|
+
export type PlanChangeApplies = PlanChangePreview['applies'] | 'checkout';
|
|
36
|
+
/** Options for {@link usePlanChange}. */
|
|
37
|
+
export interface UsePlanChangeOptions {
|
|
38
|
+
/** Copy for the confirmation, over `appConfig.backend.labels.pricing` and the translations. */
|
|
39
|
+
labels?: MaybeRefOrGetter<LabelGroupOverrides<'pricing'> | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* The pricing your page reads already (`usePricing()`): its prices stand
|
|
42
|
+
* for the switch's wherever they are in the subscription's currency, so
|
|
43
|
+
* no second pricing is read for a page in it. A page in another currency
|
|
44
|
+
* still reads the subscription's. Its `currencies` and `error` count
|
|
45
|
+
* too where it has them: a gifted plan's checkout pays in the currency
|
|
46
|
+
* its card shows where the catalog prices more than one, and a failed
|
|
47
|
+
* read ends the wait.
|
|
48
|
+
*/
|
|
49
|
+
pricing?: Pick<UsePricingReturn, 'plans' | 'currency'> & Partial<Pick<UsePricingReturn, 'currencies' | 'error'>>;
|
|
50
|
+
/** While this is `false` no pricing is read for the switch, and nothing is a target (default `true`). */
|
|
51
|
+
enabled?: MaybeRefOrGetter<boolean>;
|
|
52
|
+
}
|
|
53
|
+
/** What {@link usePlanChange} returns. */
|
|
54
|
+
export interface UsePlanChangeReturn {
|
|
55
|
+
/**
|
|
56
|
+
* Every price the subscription can switch to: each plan on sale at each
|
|
57
|
+
* interval in the subscription's own currency, which the provider keeps
|
|
58
|
+
* on a switch, the plan's own other period included. Never the price it
|
|
59
|
+
* is on, the free plan, a retired plan, an archived price, the price a
|
|
60
|
+
* scheduled change moves to (`scheduledFor`), nor one with no price in
|
|
61
|
+
* that currency, which the provider would refuse. For a gifted plan's
|
|
62
|
+
* holder, whose switch is a checkout, every paid plan's price as the
|
|
63
|
+
* pricing shows it. `[]` without a plan to switch from (none, the free
|
|
64
|
+
* plan, still loading); `undefined` while the prices are read.
|
|
65
|
+
*/
|
|
66
|
+
targets: ComputedRef<PlanSwitchTarget[] | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* The target for one plan's card: the price of the plan `key` at
|
|
69
|
+
* `interval`, as `targets` lists it. `null` while its price in the
|
|
70
|
+
* subscription's currency is read; `undefined` when there is no switch
|
|
71
|
+
* to it, which a card shows no switch button for.
|
|
72
|
+
*/
|
|
73
|
+
targetFor: (key: string, interval: PricingInterval) => PlanSwitchTarget | null | undefined;
|
|
74
|
+
/** When a change scheduled for the period's end moves the subscription to `productId`, else `null`: say when, rather than offer it again. */
|
|
75
|
+
scheduledFor: (productId: string) => Date | null;
|
|
76
|
+
/** The switch waiting on the person's confirmation, `null` while none is open. */
|
|
77
|
+
target: Ref<Required<PlanChangeTarget> | null>;
|
|
78
|
+
/** What that switch would do (`useBilling().changeOf`); `null` while none is open, for a gifted plan's, and for one there is nothing to preview. */
|
|
79
|
+
preview: ComputedRef<PlanChangePreview | null>;
|
|
80
|
+
/** How that switch goes; `null` while none is open, or for one there is nothing to say about. */
|
|
81
|
+
applies: ComputedRef<PlanChangeApplies | null>;
|
|
82
|
+
/** The confirmation's question, "Switch to Team?"; `''` while none is open. */
|
|
83
|
+
title: ComputedRef<string>;
|
|
84
|
+
/**
|
|
85
|
+
* When the switch happens and how the period's difference is settled, in
|
|
86
|
+
* the reader's words: at once with the difference settled now, when the
|
|
87
|
+
* paid year runs out, and in a trial, whether it carries over, ends with
|
|
88
|
+
* a first payment, or waits for its end; for a gifted plan's holder, that
|
|
89
|
+
* the checkout ends the gift. What the switch `confirm` makes does. `''`
|
|
90
|
+
* while none is open.
|
|
91
|
+
*/
|
|
92
|
+
when: ComputedRef<string>;
|
|
93
|
+
/** Ask about a switch: `target`, `preview` and the words follow it. */
|
|
94
|
+
open: (target: PlanChangeTarget) => void;
|
|
95
|
+
/** Close the confirmation without switching. */
|
|
96
|
+
close: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Make the switch the confirmation is open for, then close it: a
|
|
99
|
+
* subscriber's `changePlan(productId, { proration: 'invoice' })`, so the
|
|
100
|
+
* difference settles now as `when` says, whatever the organization's
|
|
101
|
+
* default; a gifted plan's holder's checkout of the plan, which ends the
|
|
102
|
+
* gift, with the address's campaign (its code and attribution, a refused
|
|
103
|
+
* code dropped) and in the currency its price shows where the catalog
|
|
104
|
+
* prices more than one, as `<PricingTable>` checks it out (`options` go
|
|
105
|
+
* with it, over those, `{ redirect: true }` by default). Rejects
|
|
106
|
+
* with what the call threw, `error` holds it too, and the confirmation
|
|
107
|
+
* stays open.
|
|
108
|
+
*/
|
|
109
|
+
confirm: (options?: CheckoutOptions) => Promise<void>;
|
|
110
|
+
/** Switch to `productId` at once, past any confirmation, settling the period's difference now (`proration: 'invoice'`): the switch `changeOf` describes. */
|
|
111
|
+
switchTo: (productId: string) => Promise<void>;
|
|
112
|
+
/** `true` until the switch's prices are known (`false` without a plan to switch from, and once the read failed). */
|
|
113
|
+
isLoading: ComputedRef<boolean>;
|
|
114
|
+
/** `true` while a switch or a gifted plan's checkout is on its way. */
|
|
115
|
+
isPending: ComputedRef<boolean>;
|
|
116
|
+
/** Why the last switch failed, else why the prices could not be read, else `null`. */
|
|
117
|
+
error: ComputedRef<BackendError | null>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A subscriber's switch to another plan or billing period, without its
|
|
121
|
+
* markup: the prices it can move to, in the subscription's own currency,
|
|
122
|
+
* and one confirmation that says what the switch does before it does it —
|
|
123
|
+
* the price, when it happens (a yearly price left for a monthly one waits
|
|
124
|
+
* for the paid year's end) and how the period's difference is settled, or,
|
|
125
|
+
* in a trial, what becomes of it — then the switch itself, settling that
|
|
126
|
+
* difference at once (`proration: 'invoice'`), so the words stay true
|
|
127
|
+
* whatever the organization's default. A gifted plan's holder is asked
|
|
128
|
+
* too: their switch is a checkout of the new plan, which ends the gift.
|
|
129
|
+
* What `<PricingTable>` and the billing section of `/settings` confirm.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```vue
|
|
133
|
+
* <script setup lang="ts">
|
|
134
|
+
* const change = usePlanChange()
|
|
135
|
+
* </script>
|
|
136
|
+
* <template>
|
|
137
|
+
* <button v-for="target in change.targets.value" :key="target.productId" @click="change.open(target)">
|
|
138
|
+
* {{ target.plan }} · {{ target.price }}
|
|
139
|
+
* </button>
|
|
140
|
+
* <div v-if="change.target.value" role="group" :aria-label="change.title.value">
|
|
141
|
+
* <p>{{ change.title.value }} {{ change.when.value }}</p>
|
|
142
|
+
* <button :aria-disabled="change.isPending.value || undefined" @click="change.confirm()">Confirm switch</button>
|
|
143
|
+
* <button @click="change.close()">Not now</button>
|
|
144
|
+
* </div>
|
|
145
|
+
* </template>
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function usePlanChange(options?: UsePlanChangeOptions): UsePlanChangeReturn;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { computed, ref, toValue } from "vue";
|
|
2
|
+
import { CATALOG_INTERVALS } from "../../../convex/catalog.js";
|
|
3
|
+
import { useActionState } from "../utils/action-state.js";
|
|
4
|
+
import { CONFIRMED_PRORATION, planChangeWhen } from "../utils/plan-change-confirm.js";
|
|
5
|
+
import { pricingCheckout } from "../utils/pricing-checkout.js";
|
|
6
|
+
import { formatBillingAmount, formatBillingDate } from "./billing-format.js";
|
|
7
|
+
import { useBilling } from "./use-billing.js";
|
|
8
|
+
import { useCampaign } from "./use-campaign.js";
|
|
9
|
+
import { useLabels } from "./use-labels.js";
|
|
10
|
+
import { usePricing } from "./use-pricing.js";
|
|
11
|
+
export function usePlanChange(options = {}) {
|
|
12
|
+
const billing = useBilling();
|
|
13
|
+
const { t, locale } = useLabels("pricing", () => toValue(options.labels));
|
|
14
|
+
const enabled = () => toValue(options.enabled) !== false;
|
|
15
|
+
const shown = options.pricing;
|
|
16
|
+
const gifted = computed(() => billing.pass.value !== null);
|
|
17
|
+
const currency = computed(() => {
|
|
18
|
+
const code = billing.subscription.value?.currency;
|
|
19
|
+
return !gifted.value && typeof code === "string" && code !== "" ? code.toLowerCase() : void 0;
|
|
20
|
+
});
|
|
21
|
+
const own = usePricing({
|
|
22
|
+
server: false,
|
|
23
|
+
actions: false,
|
|
24
|
+
currency: () => currency.value,
|
|
25
|
+
enabled: () => enabled() && billing.isSubscribed.value && (shown === void 0 || currency.value !== void 0 && shown.currency.value !== void 0 && shown.currency.value !== currency.value)
|
|
26
|
+
});
|
|
27
|
+
const plans = computed(() => (shown ?? own).plans.value);
|
|
28
|
+
function priceAt(key, interval) {
|
|
29
|
+
const page = shown?.plans.value;
|
|
30
|
+
if (shown && page === void 0) return null;
|
|
31
|
+
const offered = page?.find((plan) => plan.key === key)?.prices[interval];
|
|
32
|
+
if (shown) {
|
|
33
|
+
if (!offered) return void 0;
|
|
34
|
+
if (currency.value === void 0 || offered.currency === currency.value) return offered;
|
|
35
|
+
if (shown.currency.value === currency.value) return void 0;
|
|
36
|
+
}
|
|
37
|
+
const read = own.plans.value;
|
|
38
|
+
if (read === void 0) return null;
|
|
39
|
+
const at = read.find((plan) => plan.key === key)?.prices[interval];
|
|
40
|
+
return at && (currency.value === void 0 || at.currency === currency.value) && (!offered || at.productId === offered.productId) ? at : void 0;
|
|
41
|
+
}
|
|
42
|
+
const pending = computed(() => billing.pendingChange.value);
|
|
43
|
+
const ownPlan = (plan) => Object.values(plan.prices).some((price) => price?.productId === billing.subscription.value?.productId);
|
|
44
|
+
function targetOf(plan, interval, price) {
|
|
45
|
+
if (plan.free || plan.retired || price.archived) return void 0;
|
|
46
|
+
if (price.productId === billing.subscription.value?.productId || price.productId === pending.value?.productId) return void 0;
|
|
47
|
+
return {
|
|
48
|
+
key: plan.key,
|
|
49
|
+
productId: price.productId,
|
|
50
|
+
name: plan.name,
|
|
51
|
+
// Its own plan at the other period is named with it: "Pro, billed yearly".
|
|
52
|
+
plan: ownPlan(plan) ? t(`billedAt.${interval}`, { plan: plan.name }) : plan.name,
|
|
53
|
+
price: `${formatBillingAmount(price.amount, price.currency, locale.value)}${t(`period.${interval}`)}`,
|
|
54
|
+
interval,
|
|
55
|
+
amount: price.amount,
|
|
56
|
+
currency: price.currency
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const switches = () => enabled() && billing.isSubscribed.value;
|
|
60
|
+
const targets = computed(() => {
|
|
61
|
+
if (!switches()) return [];
|
|
62
|
+
const list = plans.value;
|
|
63
|
+
if (list === void 0) return void 0;
|
|
64
|
+
const found = [];
|
|
65
|
+
for (const plan of list) {
|
|
66
|
+
if (plan.free || plan.retired) continue;
|
|
67
|
+
for (const interval of CATALOG_INTERVALS) {
|
|
68
|
+
if (!plan.prices[interval]) continue;
|
|
69
|
+
const price = priceAt(plan.key, interval);
|
|
70
|
+
if (price === null) return void 0;
|
|
71
|
+
const target2 = price && targetOf(plan, interval, price);
|
|
72
|
+
if (target2) found.push(target2);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return found;
|
|
76
|
+
});
|
|
77
|
+
const target = ref(null);
|
|
78
|
+
const preview = computed(() => target.value ? billing.changeOf(target.value.productId) : null);
|
|
79
|
+
const applies = computed(() => target.value === null ? null : gifted.value ? "checkout" : preview.value?.applies ?? null);
|
|
80
|
+
const { isPending, failure, run } = useActionState();
|
|
81
|
+
const { payIn, withCampaign } = pricingCheckout({
|
|
82
|
+
campaign: useCampaign(),
|
|
83
|
+
asked: () => void 0,
|
|
84
|
+
active: () => void 0,
|
|
85
|
+
currencies: () => shown?.currencies?.value ?? own.currencies.value
|
|
86
|
+
});
|
|
87
|
+
const currencyOf = (productId) => plans.value?.flatMap((entry) => Object.values(entry.prices)).find((price) => price?.productId === productId)?.currency;
|
|
88
|
+
const switchTo = (productId) => run(() => billing.changePlan(productId, { proration: CONFIRMED_PRORATION }), { silent: true });
|
|
89
|
+
return {
|
|
90
|
+
targets,
|
|
91
|
+
targetFor: (key, interval) => {
|
|
92
|
+
if (!switches()) return void 0;
|
|
93
|
+
const plan = plans.value?.find((entry) => entry.key === key);
|
|
94
|
+
if (!plan?.prices[interval]) return plans.value === void 0 ? null : void 0;
|
|
95
|
+
if (plan.free || plan.retired) return void 0;
|
|
96
|
+
const price = priceAt(key, interval);
|
|
97
|
+
return price === null ? null : price && targetOf(plan, interval, price);
|
|
98
|
+
},
|
|
99
|
+
scheduledFor: (productId) => pending.value?.productId === productId ? pending.value.appliesAt : null,
|
|
100
|
+
target,
|
|
101
|
+
preview,
|
|
102
|
+
applies,
|
|
103
|
+
title: computed(() => target.value ? t("changeTitle", { plan: target.value.plan }) : ""),
|
|
104
|
+
when: computed(() => target.value ? planChangeWhen({
|
|
105
|
+
applies: applies.value,
|
|
106
|
+
preview: preview.value,
|
|
107
|
+
price: target.value.price,
|
|
108
|
+
gifted: t("changeGifted", { price: target.value.price }),
|
|
109
|
+
t,
|
|
110
|
+
date: (value) => formatBillingDate(value, { dateStyle: "medium" }, locale.value) || null
|
|
111
|
+
}) : ""),
|
|
112
|
+
open: (next) => {
|
|
113
|
+
target.value = { ...next, key: next.key ?? next.productId };
|
|
114
|
+
},
|
|
115
|
+
close: () => {
|
|
116
|
+
target.value = null;
|
|
117
|
+
},
|
|
118
|
+
confirm: async (checkout = {}) => {
|
|
119
|
+
const chosen = target.value;
|
|
120
|
+
if (!chosen) return;
|
|
121
|
+
if (gifted.value) await run(() => withCampaign(false, (campaign) => billing.checkout(chosen.productId, { redirect: true, ...payIn(currencyOf(chosen.productId)), ...campaign, ...checkout })), { silent: true });
|
|
122
|
+
else await switchTo(chosen.productId);
|
|
123
|
+
if (target.value === chosen) target.value = null;
|
|
124
|
+
},
|
|
125
|
+
switchTo,
|
|
126
|
+
isLoading: computed(() => switches() && targets.value === void 0 && own.error.value === null && (shown?.error?.value ?? null) === null),
|
|
127
|
+
isPending,
|
|
128
|
+
error: computed(() => failure.value ?? own.error.value ?? shown?.error?.value ?? null)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -4,10 +4,24 @@ import { type CatalogInterval } from '../../../convex/catalog.js';
|
|
|
4
4
|
import type { PricedPack, PricedPlan, PricedPromotion, Pricing } from '../../../convex/integrations/billing/types/records.js';
|
|
5
5
|
import { type BackendError } from '../utils/backend-error.js';
|
|
6
6
|
import { type PricingBindings } from '../utils/pricing-bindings.js';
|
|
7
|
+
import { type CheckoutOptions } from './use-billing.js';
|
|
7
8
|
export type { PricingBindings } from '../utils/pricing-bindings.js';
|
|
8
9
|
export type { PricedCredits, PricedOffer, PricedPack, PricedPlan, PricedPlanPrice, PricedPromotion, PricedTrial, Pricing } from '../../../convex/integrations/billing/types/records.js';
|
|
9
10
|
/** A billing interval a plan is priced at. */
|
|
10
11
|
export type PricingInterval = CatalogInterval;
|
|
12
|
+
/**
|
|
13
|
+
* Where a checkout returns once paid: a path on the site (`/settings`) or a
|
|
14
|
+
* full URL on its own origin, or a function of what was bought that answers
|
|
15
|
+
* one (`plan => '/welcome?plan=' + plan.key`).
|
|
16
|
+
*/
|
|
17
|
+
export type PricingSuccessUrl<Item> = string | ((item: Item) => string);
|
|
18
|
+
/** Where each kind of checkout returns to ({@link UsePricingOptions.successUrl}). */
|
|
19
|
+
export interface PricingSuccessUrls {
|
|
20
|
+
/** A plan's checkout. Default: back to the page it started on. */
|
|
21
|
+
plan?: PricingSuccessUrl<PricedPlan>;
|
|
22
|
+
/** A credit pack's checkout. Default: back to the page it started on. */
|
|
23
|
+
pack?: PricingSuccessUrl<PricedPack>;
|
|
24
|
+
}
|
|
11
25
|
/** Options for {@link usePricing}. */
|
|
12
26
|
export interface UsePricingOptions {
|
|
13
27
|
/** Override the injected `api.billing.getPricing` reference. */
|
|
@@ -45,6 +59,13 @@ export interface UsePricingOptions {
|
|
|
45
59
|
* banner that shows only while the balance is low.
|
|
46
60
|
*/
|
|
47
61
|
enabled?: MaybeRefOrGetter<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Where a checkout returns once paid, per kind: a plan's to a welcome
|
|
64
|
+
* page, a pack's to the credits, say. A path is on the site. Read by
|
|
65
|
+
* `bind.planAction`'s checkout and answered by `successUrlFor` for a
|
|
66
|
+
* checkout of your own. Default: back to the page it started on.
|
|
67
|
+
*/
|
|
68
|
+
successUrl?: PricingSuccessUrls;
|
|
48
69
|
}
|
|
49
70
|
/** What {@link usePricing} returns. */
|
|
50
71
|
export interface UsePricingReturn {
|
|
@@ -72,10 +93,31 @@ export interface UsePricingReturn {
|
|
|
72
93
|
currencies: ComputedRef<string[]>;
|
|
73
94
|
/**
|
|
74
95
|
* The promotion asked for (`discount`) with its real terms and dates;
|
|
75
|
-
* `undefined` without one
|
|
76
|
-
*
|
|
96
|
+
* `undefined` without one, whether it runs now or not: `activePromotion`
|
|
97
|
+
* is the one that does.
|
|
77
98
|
*/
|
|
78
99
|
promotion: ComputedRef<PricedPromotion | undefined>;
|
|
100
|
+
/**
|
|
101
|
+
* The promotion asked for, while it runs: from its `startsAt` to its
|
|
102
|
+
* `endsAt`, by the page's clock — the moment the page rendered on the
|
|
103
|
+
* server while the browser hydrates it, so the server's HTML and the
|
|
104
|
+
* hydration agree on it, then the browser's own time once the page is on
|
|
105
|
+
* screen, and the time a client-side visit enters the page at. `undefined`
|
|
106
|
+
* before it starts, after it ends, and without one.
|
|
107
|
+
*/
|
|
108
|
+
activePromotion: ComputedRef<PricedPromotion | undefined>;
|
|
109
|
+
/**
|
|
110
|
+
* The plan the address asks for (`?plan=<key>`, as `<UpgradePrompt>`
|
|
111
|
+
* links to it), when the pricing has a plan by that key: the card to mark
|
|
112
|
+
* and bring into view. `undefined` without one.
|
|
113
|
+
*/
|
|
114
|
+
requested: ComputedRef<string | undefined>;
|
|
115
|
+
/**
|
|
116
|
+
* Where a checkout of this kind returns, as an absolute URL on the site:
|
|
117
|
+
* the `successUrl` option's for it, else `undefined` (the checkout's
|
|
118
|
+
* own default, the current page). Pass it as `checkout`'s `successUrl`.
|
|
119
|
+
*/
|
|
120
|
+
successUrlFor: (kind: 'plan' | 'pack', key: string) => string | undefined;
|
|
79
121
|
/**
|
|
80
122
|
* Whether billing sells on this deployment yet: `false` on a production
|
|
81
123
|
* deployment whose billing is not launched (no provider token, or no
|
|
@@ -107,7 +149,39 @@ export interface UsePricingReturn {
|
|
|
107
149
|
packFor: (units: number, meter?: string) => PricedPack | undefined;
|
|
108
150
|
/** Read the pricing again. It is live already; this is for a retry after a failure. */
|
|
109
151
|
refresh: () => Promise<void>;
|
|
110
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Check a plan out, at the price its card shows (the `interval` shown,
|
|
154
|
+
* else the one it sells at), or a credit pack, the way `<PricingTable>`
|
|
155
|
+
* does: with the address's campaign (`useCampaign`), the promotion this
|
|
156
|
+
* pricing shows (`discount`) in the place of the campaign link's code on
|
|
157
|
+
* a price it is offered on, one discount per checkout, and, when the
|
|
158
|
+
* server refuses that discount, once more without it, so a dead code never
|
|
159
|
+
* blocks the purchase; in the currency the price shows in where the
|
|
160
|
+
* catalog prices more than one; back where `successUrl` says. A plan's
|
|
161
|
+
* promotion is not offered to a paying subscriber, whose plan changes
|
|
162
|
+
* rather than checks out (`usePlanChange`). `options` go with it, over
|
|
163
|
+
* what it picks; a discount of their own goes in the campaign's place.
|
|
164
|
+
* Resolves the checkout's URL, opened in this tab unless `options` say
|
|
165
|
+
* `redirect: false`. Rejects with what the call threw, and as
|
|
166
|
+
* `invalid_input` (`field` `plan` or `pack`) for a key nothing on
|
|
167
|
+
* sale has. A visitor signs in first: `bind.planAction` takes them there.
|
|
168
|
+
*/
|
|
169
|
+
checkout: (kind: 'plan' | 'pack', key: string, options?: CheckoutOptions) => Promise<string>;
|
|
170
|
+
/**
|
|
171
|
+
* The plans and packs on sale as schema.org `Product`s with an `Offer`
|
|
172
|
+
* per price, for a `<script type="application/ld+json">` of a pricing
|
|
173
|
+
* page of your own: each price in the currency's main unit with its own
|
|
174
|
+
* digits (19.99 USD, 1999 JPY), a plan's with its billing period. A
|
|
175
|
+
* retired plan and an archived price are left out, since nobody new can
|
|
176
|
+
* buy them. What the packaged `/pricing` page carries with an SEO module
|
|
177
|
+
* installed. `undefined` until the pricing loads.
|
|
178
|
+
*/
|
|
179
|
+
structuredData: ComputedRef<Record<string, unknown> | undefined>;
|
|
180
|
+
/**
|
|
181
|
+
* The interval the plans show: the address's `?interval=` when a plan
|
|
182
|
+
* sells at it, else monthly when a plan is priced by the month, until
|
|
183
|
+
* `setInterval` picks another.
|
|
184
|
+
*/
|
|
111
185
|
interval: Ref<PricingInterval>;
|
|
112
186
|
/** Show the plans at another interval. */
|
|
113
187
|
setInterval: (interval: PricingInterval) => void;
|
|
@@ -117,7 +191,11 @@ export interface UsePricingReturn {
|
|
|
117
191
|
* Attribute and handler bags for markup of your own: `periodSwitch`,
|
|
118
192
|
* `planCard(plan)`, `planAction(plan)` and `packCard(pack)`. Spread
|
|
119
193
|
* each with `v-bind`; they carry the accessibility attributes and the
|
|
120
|
-
* actions the packaged table has.
|
|
194
|
+
* actions the packaged table has. `planAction` asks nothing first: a
|
|
195
|
+
* subscriber's press switches at once with `proration: 'invoice'`,
|
|
196
|
+
* the switch `useBilling().changeOf` describes and the packaged
|
|
197
|
+
* confirmations make, so a step of your own before it can say what it
|
|
198
|
+
* does; a gifted plan's holder checks the plan out, which ends the gift.
|
|
121
199
|
*/
|
|
122
200
|
bind: PricingBindings;
|
|
123
201
|
}
|
|
@@ -143,7 +221,7 @@ export interface UsePricingReturn {
|
|
|
143
221
|
* <template>
|
|
144
222
|
* <article v-for="plan in plans?.filter(plan => !plan.retired)" :key="plan.key">
|
|
145
223
|
* <h3>{{ plan.name }}</h3>
|
|
146
|
-
* <p v-if="plan.prices[interval]">{{ plan.prices[interval].amount
|
|
224
|
+
* <p v-if="plan.prices[interval]">{{ formatBillingAmount(plan.prices[interval].amount, plan.prices[interval].currency) }}</p>
|
|
147
225
|
* </article>
|
|
148
226
|
* </template>
|
|
149
227
|
* ```
|
|
@@ -2,13 +2,17 @@ import { computed, ref, toValue } from "vue";
|
|
|
2
2
|
import { navigateTo, useRequestHeaders, useRoute, useState } from "#imports";
|
|
3
3
|
import { useAsyncQuery } from "nuxt-convex-module/app";
|
|
4
4
|
import { CATALOG_INTERVALS } from "../../../convex/catalog.js";
|
|
5
|
+
import { backendError } from "../../../convex/errors.js";
|
|
5
6
|
import { failureOf } from "../utils/backend-error.js";
|
|
6
7
|
import { useActiveLocale } from "../utils/active-locale.js";
|
|
7
8
|
import { currencyCode, visitorCurrency } from "../utils/currency.js";
|
|
8
9
|
import { diagnostics } from "../utils/live-query.js";
|
|
9
10
|
import { useBackendNamespace } from "../utils/namespace.js";
|
|
10
|
-
import { pricingBindings, shownInterval } from "../utils/pricing-bindings.js";
|
|
11
|
+
import { askedInterval, onSite, pricingBindings, promotionRuns, shownInterval, usePageClock } from "../utils/pricing-bindings.js";
|
|
11
12
|
import { useAuthSession } from "../utils/auth-session.js";
|
|
13
|
+
import { CONFIRMED_PRORATION } from "../utils/plan-change-confirm.js";
|
|
14
|
+
import { pricingCheckout } from "../utils/pricing-checkout.js";
|
|
15
|
+
import { pricingStructuredData } from "../utils/pricing-seo.js";
|
|
12
16
|
import { useBilling } from "./use-billing.js";
|
|
13
17
|
import { useCampaign } from "./use-campaign.js";
|
|
14
18
|
import { useBackendPagePath } from "./use-backend-page-path.js";
|
|
@@ -38,6 +42,9 @@ export function usePricing(options = {}) {
|
|
|
38
42
|
currency: computed(() => void 0),
|
|
39
43
|
currencies: computed(() => []),
|
|
40
44
|
promotion: computed(() => void 0),
|
|
45
|
+
activePromotion: computed(() => void 0),
|
|
46
|
+
requested: computed(() => void 0),
|
|
47
|
+
successUrlFor: () => void 0,
|
|
41
48
|
launched: computed(() => void 0),
|
|
42
49
|
welcome: computed(() => void 0),
|
|
43
50
|
setCurrency: () => {
|
|
@@ -47,7 +54,9 @@ export function usePricing(options = {}) {
|
|
|
47
54
|
packFor: () => void 0,
|
|
48
55
|
refresh: async () => {
|
|
49
56
|
},
|
|
50
|
-
|
|
57
|
+
checkout: async (kind, key) => offSale(kind, key),
|
|
58
|
+
structuredData: computed(() => void 0),
|
|
59
|
+
...intervalState(computed(() => []), () => void 0),
|
|
51
60
|
bind: pricingBindings({ interval: ref("month"), setInterval: () => {
|
|
52
61
|
}, pending: ref(null), manages: () => false, act: () => {
|
|
53
62
|
} })
|
|
@@ -67,13 +76,37 @@ export function usePricing(options = {}) {
|
|
|
67
76
|
const read = useAsyncQuery(billing.getPricing, args, options.server === false ? { server: false, lazy: true, key: "backend:pricing:client" } : {});
|
|
68
77
|
const plans = computed(() => read.data.value?.plans);
|
|
69
78
|
const intervals = computed(() => CATALOG_INTERVALS.filter((interval) => (plans.value ?? []).some((plan) => !plan.retired && plan.prices[interval] && !plan.prices[interval].archived)));
|
|
70
|
-
const state = intervalState(intervals);
|
|
79
|
+
const state = intervalState(intervals, () => route.query.interval);
|
|
80
|
+
const now = usePageClock();
|
|
81
|
+
const promotion = computed(() => read.data.value?.promotion);
|
|
82
|
+
const activePromotion = computed(() => promotion.value && promotionRuns(promotion.value, now.value) ? promotion.value : void 0);
|
|
83
|
+
const successUrlFor = (kind, key) => {
|
|
84
|
+
const wanted2 = options.successUrl?.[kind];
|
|
85
|
+
if (wanted2 === void 0) return void 0;
|
|
86
|
+
const item = kind === "plan" ? plans.value?.find((entry) => entry.key === key) : read.data.value?.packs.find((entry) => entry.key === key);
|
|
87
|
+
if (!item) return void 0;
|
|
88
|
+
const url = typeof wanted2 === "string" ? wanted2 : wanted2(item);
|
|
89
|
+
return onSite(url);
|
|
90
|
+
};
|
|
91
|
+
const packs = computed(() => read.data.value?.packs);
|
|
92
|
+
const actions = options.actions === false ? null : planActions(state, plans, packs, {
|
|
93
|
+
asked: () => toValue(options.discount)?.trim() || void 0,
|
|
94
|
+
active: () => activePromotion.value,
|
|
95
|
+
currencies: () => read.data.value?.currencies ?? [],
|
|
96
|
+
successUrl: successUrlFor
|
|
97
|
+
});
|
|
71
98
|
return {
|
|
72
99
|
plans,
|
|
73
|
-
packs
|
|
100
|
+
packs,
|
|
74
101
|
currency: computed(() => read.data.value?.currency),
|
|
75
102
|
currencies: computed(() => read.data.value?.currencies ?? []),
|
|
76
|
-
promotion
|
|
103
|
+
promotion,
|
|
104
|
+
activePromotion,
|
|
105
|
+
requested: computed(() => {
|
|
106
|
+
const key = route.query.plan;
|
|
107
|
+
return typeof key === "string" && (plans.value ?? []).some((plan) => plan.key === key) ? key : void 0;
|
|
108
|
+
}),
|
|
109
|
+
successUrlFor,
|
|
77
110
|
launched: computed(() => read.data.value ? read.data.value.launched !== false : void 0),
|
|
78
111
|
welcome: computed(() => plans.value?.find((plan) => plan.free)?.welcome),
|
|
79
112
|
setCurrency: (currency) => {
|
|
@@ -85,15 +118,26 @@ export function usePricing(options = {}) {
|
|
|
85
118
|
error: computed(() => read.error.value ? failureOf(read.error.value) : null),
|
|
86
119
|
packFor: (units, meter) => smallestCovering(read.data.value?.packs ?? [], units, meter),
|
|
87
120
|
refresh: () => read.refresh(),
|
|
121
|
+
checkout: actions?.checkout ?? (async () => {
|
|
122
|
+
throw new Error("[nuxt-backend] usePricing({ actions: false }): this pricing builds no checkout.");
|
|
123
|
+
}),
|
|
124
|
+
structuredData: computed(() => read.data.value ? pricingStructuredData(read.data.value) : void 0),
|
|
88
125
|
...state,
|
|
89
|
-
bind:
|
|
90
|
-
} })
|
|
126
|
+
bind: actions?.bind ?? pricingBindings({ ...state, manages: () => false, act: () => {
|
|
127
|
+
} })
|
|
91
128
|
};
|
|
92
129
|
}
|
|
93
|
-
function
|
|
130
|
+
function offSale(kind, key) {
|
|
131
|
+
throw backendError("invalid_input", { field: kind }, `[nuxt-backend] usePricing().checkout: the pricing has no ${kind} '${key}' on sale.`);
|
|
132
|
+
}
|
|
133
|
+
function intervalState(intervals, query) {
|
|
94
134
|
const picked = ref(null);
|
|
135
|
+
const asked = () => {
|
|
136
|
+
const wanted = askedInterval(query());
|
|
137
|
+
return wanted && intervals.value.includes(wanted) ? wanted : void 0;
|
|
138
|
+
};
|
|
95
139
|
const interval = computed({
|
|
96
|
-
get: () => picked.value ?? (intervals.value.includes("month") ? "month" : intervals.value[0] ?? "month"),
|
|
140
|
+
get: () => picked.value ?? asked() ?? (intervals.value.includes("month") ? "month" : intervals.value[0] ?? "month"),
|
|
97
141
|
set: (next) => {
|
|
98
142
|
picked.value = next;
|
|
99
143
|
}
|
|
@@ -103,7 +147,7 @@ function intervalState(intervals) {
|
|
|
103
147
|
};
|
|
104
148
|
return { interval, setInterval, pending: ref(null) };
|
|
105
149
|
}
|
|
106
|
-
function planActions(state, plans,
|
|
150
|
+
function planActions(state, plans, packs, sale) {
|
|
107
151
|
const billing = useBilling();
|
|
108
152
|
const campaign = useCampaign();
|
|
109
153
|
const auth = useAuthSession();
|
|
@@ -115,6 +159,15 @@ function planActions(state, plans, discount) {
|
|
|
115
159
|
const at = shownInterval(plan, state.interval.value, billing.subscription.value?.productId);
|
|
116
160
|
return at && plan.prices[at];
|
|
117
161
|
};
|
|
162
|
+
const { payIn, withCampaign } = pricingCheckout({ campaign, asked: sale.asked, active: sale.active, currencies: sale.currencies });
|
|
163
|
+
const start = (kind, key, price, offered2, options) => {
|
|
164
|
+
const back = sale.successUrl(kind, key);
|
|
165
|
+
const open = (campaignOptions) => billing.checkout(price.productId, { redirect: true, ...payIn(price.currency), ...back ? { successUrl: back } : {}, ...campaignOptions, ...options });
|
|
166
|
+
if (options.discount === void 0 && options.discountCode === void 0) return withCampaign(offered2, open);
|
|
167
|
+
const { discountCode: _code, ...attribution } = campaign.checkoutOptions.value;
|
|
168
|
+
return open(attribution);
|
|
169
|
+
};
|
|
170
|
+
const offered = (kind, price) => price.promotion !== void 0 && sale.active() !== void 0 && (kind === "pack" || !billing.isSubscribed.value);
|
|
118
171
|
const act = async ({ key }) => {
|
|
119
172
|
if (!auth.isAuthenticated.value) {
|
|
120
173
|
if (login.value) await navigateTo(`${login.value}?redirect=${encodeURIComponent(route.fullPath)}`);
|
|
@@ -124,16 +177,29 @@ function planActions(state, plans, discount) {
|
|
|
124
177
|
if (!price || state.pending.value !== null) return;
|
|
125
178
|
state.pending.value = key;
|
|
126
179
|
try {
|
|
127
|
-
if (billing.isSubscribed.value) await billing.changePlan(price.productId);
|
|
128
|
-
else await
|
|
180
|
+
if (billing.isSubscribed.value && billing.pass.value === null) await billing.changePlan(price.productId, { proration: CONFIRMED_PRORATION });
|
|
181
|
+
else await checkout("plan", key);
|
|
129
182
|
} catch {
|
|
130
183
|
} finally {
|
|
131
184
|
state.pending.value = null;
|
|
132
185
|
}
|
|
133
186
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
187
|
+
const checkout = async (kind, key, options = {}) => {
|
|
188
|
+
if (kind === "pack") {
|
|
189
|
+
const pack = packs.value?.find((entry) => entry.key === key);
|
|
190
|
+
if (!pack) offSale(kind, key);
|
|
191
|
+
return start(kind, key, pack, offered(kind, pack), options);
|
|
192
|
+
}
|
|
193
|
+
const price = priceOf(key);
|
|
194
|
+
if (!price) offSale(kind, key);
|
|
195
|
+
return start(kind, key, price, offered(kind, price), options);
|
|
196
|
+
};
|
|
197
|
+
return {
|
|
198
|
+
checkout,
|
|
199
|
+
bind: pricingBindings({
|
|
200
|
+
...state,
|
|
201
|
+
manages: () => !auth.isAuthenticated.value || billing.canManage.value,
|
|
202
|
+
act
|
|
203
|
+
})
|
|
204
|
+
};
|
|
139
205
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { computed, getCurrentInstance, inject, onMounted, ref, watch } from "vue";
|
|
2
2
|
import { ConvexAuthStateKey, useMutation } from "nuxt-convex-module/client";
|
|
3
3
|
import { useActionState } from "../utils/action-state.js";
|
|
4
|
+
import { isAppleMobile, isInstalled } from "../utils/display-mode.js";
|
|
4
5
|
import { absentQuery, useLiveQuery } from "../utils/live-query.js";
|
|
5
6
|
import { useBackendNamespace } from "../utils/namespace.js";
|
|
6
7
|
import { devicePushManager, pushDevice, PUSH_WORKER_SCOPE, PUSH_WORKER_URL, subscriptionFor, watchDevicePushSignOut } from "../utils/push-device.js";
|
|
7
|
-
function isAppleMobile() {
|
|
8
|
-
const { userAgent, maxTouchPoints } = navigator;
|
|
9
|
-
return /iPhone|iPad|iPod/.test(userAgent) || /Macintosh/.test(userAgent) && maxTouchPoints > 1;
|
|
10
|
-
}
|
|
11
|
-
function isInstalled() {
|
|
12
|
-
return navigator.standalone === true || window.matchMedia?.("(display-mode:standalone)").matches === true;
|
|
13
|
-
}
|
|
14
8
|
export function usePushSubscription(options = {}) {
|
|
15
9
|
const api = useBackendNamespace("notifications", "usePushSubscription", options.api);
|
|
16
10
|
const auth = inject(ConvexAuthStateKey, null);
|
|
@@ -22,6 +22,26 @@ export interface UseReferralInviteReturn {
|
|
|
22
22
|
isPending: ComputedRef<boolean>;
|
|
23
23
|
/** Where the sign-in page sends a visitor, who is returned to this page to claim. `null` with the sign-in page turned off. */
|
|
24
24
|
signInTo: ComputedRef<string | null>;
|
|
25
|
+
/**
|
|
26
|
+
* The invite page for a visitor who holds an invite while the app is
|
|
27
|
+
* `closed`: `/invite?ref=<code>`, so the sign-in it leads to comes back
|
|
28
|
+
* here to claim (`useInvite().signInTo`). `null` with the invite page
|
|
29
|
+
* turned off.
|
|
30
|
+
*/
|
|
31
|
+
inviteTo: ComputedRef<string | null>;
|
|
32
|
+
/**
|
|
33
|
+
* `true` while the app is not public (`useAccessPhase`): a new account
|
|
34
|
+
* needs a ticket first, an invite or an admitted place on the waitlist,
|
|
35
|
+
* so signing up here without one only joins the waitlist. An account
|
|
36
|
+
* claims within a day of its sign-up, so it comes back to the link then.
|
|
37
|
+
* `false` once the app is public, for an app without `backend/access.ts`,
|
|
38
|
+
* and when the phase could not be read (the sign-up's own check still
|
|
39
|
+
* holds a visitor without a ticket to the waitlist). `undefined` while
|
|
40
|
+
* the phase loads, so a page offers neither the sign-up nor the ways to a
|
|
41
|
+
* ticket before it knows which one applies; a phase still unread after
|
|
42
|
+
* five seconds reads as `false`, as one that could not be read.
|
|
43
|
+
*/
|
|
44
|
+
closed: ComputedRef<boolean | undefined>;
|
|
25
45
|
/** Claim the referral for the signed-in account: the explicit step. Never rejects: a code that cannot be used is `ignored`. */
|
|
26
46
|
claim: () => Promise<void>;
|
|
27
47
|
/** Why the claim failed, or else why the link could not be read. */
|
|
@@ -41,7 +61,9 @@ export interface UseReferralInviteReturn {
|
|
|
41
61
|
* and stays live in the browser. The server renders nobody as signed in, so
|
|
42
62
|
* `state` starts at `ready` there, and the claim only ever runs in the
|
|
43
63
|
* browser. A link that cannot be read reads as `invalid`, with the reason in
|
|
44
|
-
* `error`.
|
|
64
|
+
* `error`. While the app is not public, `closed` says a visitor needs a
|
|
65
|
+
* ticket before the sign-up can make them an account; it is `undefined`
|
|
66
|
+
* until the phase is read.
|
|
45
67
|
*
|
|
46
68
|
* @example
|
|
47
69
|
* ```vue
|
|
@@ -50,7 +72,7 @@ export interface UseReferralInviteReturn {
|
|
|
50
72
|
* </script>
|
|
51
73
|
* <template>
|
|
52
74
|
* <p v-if="preview">{{ preview.inviter ?? 'A friend' }} invited you.</p>
|
|
53
|
-
* <NuxtLink v-if="state === 'ready' && signInTo" :to="signInTo">Sign up to claim</NuxtLink>
|
|
75
|
+
* <NuxtLink v-if="state === 'ready' && closed === false && signInTo" :to="signInTo">Sign up to claim</NuxtLink>
|
|
54
76
|
* <button v-else-if="state === 'claimable'" @click="claim()">Claim</button>
|
|
55
77
|
* </template>
|
|
56
78
|
* ```
|