nuxt-backend 0.4.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 +2 -0
- package/dist/chunks/catalog.mjs +1 -1
- package/dist/chunks/doctor.mjs +4 -4
- package/dist/chunks/email-previews.mjs +1 -1
- package/dist/chunks/health.mjs +2 -2
- package/dist/chunks/index.mjs +2 -2
- package/dist/chunks/install.mjs +8 -8
- package/dist/chunks/run.mjs +1 -1
- package/dist/chunks/server.mjs +4 -4
- package/dist/cli.mjs +9 -52
- package/dist/devtools-client/index.html +1 -1
- package/dist/module.js +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/vue/components/auth/InviteRedeem.vue +4 -22
- package/dist/runtime/vue/components/auth/WaitlistStatus.vue +7 -17
- package/dist/runtime/vue/components/billing/PricingTable.vue +17 -51
- package/dist/runtime/vue/components/billing/ReferralLanding.vue +1 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceBilling.vue +15 -18
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingPause.vue +1 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue +9 -22
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
- package/dist/runtime/vue/components/workspaces/workspace-billing.d.ts +12 -16
- package/dist/runtime/vue/components/workspaces/workspace-billing.js +22 -37
- package/dist/runtime/vue/composables/use-access.d.ts +18 -0
- package/dist/runtime/vue/composables/use-access.js +33 -6
- 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-gift-form.js +7 -24
- package/dist/runtime/vue/composables/use-gift-list.d.ts +18 -1
- package/dist/runtime/vue/composables/use-gift-list.js +6 -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 +29 -0
- package/dist/runtime/vue/composables/use-pricing.js +53 -14
- package/dist/runtime/vue/composables/use-referral-invite.d.ts +7 -0
- package/dist/runtime/vue/composables/use-referral-invite.js +4 -1
- package/dist/runtime/vue/composables/use-waitlist.d.ts +18 -0
- package/dist/runtime/vue/composables/use-waitlist.js +24 -0
- package/dist/runtime/vue/pages/pricing.vue +1 -2
- package/dist/runtime/vue/plugins/checkout-return.js +9 -2
- 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/gift-days.d.ts +20 -0
- package/dist/runtime/vue/utils/gift-days.js +32 -0
- 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/plan-change-confirm.d.ts +38 -26
- package/dist/runtime/vue/utils/plan-change-confirm.js +25 -16
- 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/tab-keep.d.ts +3 -1
- package/dist/runtime/vue/utils/tab-keep.js +1 -1
- package/dist/shared/{nuxt-backend.CbR37s_c.mjs → nuxt-backend.BqXAZChe.mjs} +23 -3
- package/dist/shared/{nuxt-backend.BjQoqNIu.mjs → nuxt-backend.CBvrM7pG.mjs} +1 -1
- package/dist/shared/{nuxt-backend.Baxb382E.mjs → nuxt-backend.DH1Ya3uB.mjs} +1 -1
- package/dist/shared/{nuxt-backend.9IVxzzft.mjs → nuxt-backend.DbaXvH__.mjs} +1 -1
- package/dist/shared/{nuxt-backend.BCjeoX0x.mjs → nuxt-backend.Dikfaocl.mjs} +56 -8
- package/package.json +1 -1
- package/skills/nuxt-backend/references/api.md +2 -0
- package/skills/nuxt-backend/references/install.md +4 -1
- package/skills/nuxt-backend/references/renames.json +8 -0
- package/skills/nuxt-backend/references/surface.json +2 -0
- package/skills/nuxt-backend-billing/SKILL.md +9 -0
- package/skills/nuxt-backend-billing/references/api.md +2 -0
- package/skills/nuxt-backend-upgrade/references/upgrade.md +6 -0
- package/src/runtime/vue/components/auth/InviteRedeem.vue +5 -26
- package/src/runtime/vue/components/auth/WaitlistStatus.vue +11 -20
- package/src/runtime/vue/components/billing/PricingTable.vue +25 -82
- package/src/runtime/vue/components/billing/ReferralLanding.vue +1 -2
- package/src/runtime/vue/components/workspaces/WorkspaceBilling.vue +21 -25
- package/src/runtime/vue/components/workspaces/WorkspaceBillingPause.vue +1 -2
- package/src/runtime/vue/components/workspaces/WorkspaceSettings.vue +16 -29
- package/src/runtime/vue/pages/pricing.vue +1 -4
|
@@ -3,6 +3,7 @@ import { computed, resolveComponent, type Ref } from 'vue'
|
|
|
3
3
|
import { busyAttributes } from '../../a11y'
|
|
4
4
|
import { valueLabel } from '../../composables/use-labels'
|
|
5
5
|
import type { EntitlementBenefit } from '../../composables/use-billing'
|
|
6
|
+
import type { BillingSectionAction } from '../../composables/use-billing-section'
|
|
6
7
|
import type { WorkspaceBillingProps } from '../../parts'
|
|
7
8
|
import CancelConfirmGroup from '../billing/CancelConfirmGroup.vue'
|
|
8
9
|
import { IN_PORTAL, type PlanState } from './workspace-billing'
|
|
@@ -57,21 +58,17 @@ const words = computed(() => (section.state.value ? STATE_WORDS[section.state.va
|
|
|
57
58
|
// Busy until the plan is known (its name reads "—" until then), unless the
|
|
58
59
|
// read failed, and while a return from checkout is being finished.
|
|
59
60
|
const finishing = computed(() => props.billing.isFinishingCheckout.value)
|
|
60
|
-
const loading =
|
|
61
|
-
const failed = computed(() =>
|
|
61
|
+
const loading = section.plan.isLoading
|
|
62
|
+
const failed = computed(() => section.plan.state.value === 'error')
|
|
62
63
|
const managing = computed(() => props.billing.canManage.value)
|
|
63
64
|
|
|
64
65
|
/** A button of the section: busy while its own action runs, and keeping focus through it. */
|
|
65
66
|
const pending = (key: string) => view.context.value.pending === key
|
|
66
67
|
const press = (key: string, action: () => unknown) => (pending(key) ? undefined : action())
|
|
67
68
|
|
|
68
|
-
const gifted = computed(() => section.state.value === 'gifted')
|
|
69
|
-
const keepOffered = computed(() => gifted.value && managing.value)
|
|
70
69
|
// A gifted plan has no card to cancel: the one offer is to keep it.
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const portalFirst = computed(() => section.state.value === 'past_due')
|
|
74
|
-
const portalLast = computed(() => !portalFirst.value && !gifted.value)
|
|
70
|
+
const keepOffered = computed(() => section.actions.value.includes('keep-gifted'))
|
|
71
|
+
const cancellable = section.plan.cancellable
|
|
75
72
|
/**
|
|
76
73
|
* What "Cancel plan" opens: the one-step group, or, with save offers on,
|
|
77
74
|
* `<CancelFlow>` (one optional question and at most one offer, "Cancel my
|
|
@@ -82,9 +79,6 @@ const cancelling = computed(() => {
|
|
|
82
79
|
if (!section.confirm.isOpen.value) return { is: () => null, props: {} }
|
|
83
80
|
return { is: resolveComponent('CancelFlow'), props: { id: view.partId('cancel', 'confirm'), onClose: () => section.confirm.close(), onCanceled: section.flowCanceled, onKept: section.flowKept } }
|
|
84
81
|
})
|
|
85
|
-
/** A scheduled plan change can be cancelled, unless the plan is set to end. */
|
|
86
|
-
const changeCancellable = computed(() => props.billing.pendingChange.value !== null && !props.billing.cancelAtPeriodEnd.value)
|
|
87
|
-
|
|
88
82
|
/** One button of the plan's row: its hook, what it carries and what it says, and where a group it opens gives focus back. */
|
|
89
83
|
interface PlanButton { hook: string, attributes: Record<string, unknown>, text: string, element?: Ref<HTMLElement | null> }
|
|
90
84
|
/** A button that opens and closes a group: the group's toggle, its element kept for the focus coming back. */
|
|
@@ -98,22 +92,24 @@ const runs = (hook: string, key: string, idle: string, busy: string, action: ()
|
|
|
98
92
|
attributes: { ...busyAttributes(pending(key)), onClick: () => press(key, action) },
|
|
99
93
|
text: pending(key) ? busy : idle,
|
|
100
94
|
})
|
|
95
|
+
/** Each button of the plan's row, by what it offers; keeping a gifted plan has a row of its own. */
|
|
96
|
+
const BUTTONS: Record<Exclude<BillingSectionAction, 'keep-gifted'>, () => PlanButton> = {
|
|
97
|
+
// A failed payment's portal button says what it is for.
|
|
98
|
+
'portal': () => runs('portal', 'portal', section.state.value === 'past_due' ? t('updatePayment') : t('portal'), t('openingPortal'), section.openPortal),
|
|
99
|
+
'resume': () => runs('resume', 'resume', t('resume'), t('resuming'), section.resumePlan),
|
|
100
|
+
'uncancel': () => runs('uncancel', 'uncancel', t('keepPlan'), t('keeping'), section.keepPlan),
|
|
101
|
+
'cancel-change': () => runs('cancel-change', 'cancel-change', t('cancelChange'), t('cancelingChange'), section.cancelChange),
|
|
102
|
+
'change-plan': () => opens('change-plan', t('changePlan'), section.switchToggleProps()),
|
|
103
|
+
'pause': () => opens('pause', t('pause'), section.pauseToggleProps()),
|
|
104
|
+
'cancel': () => opens('cancel', t('cancel'), section.confirm.toggleProps()),
|
|
105
|
+
}
|
|
101
106
|
/**
|
|
102
|
-
* The plan's buttons, in order.
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* whatever else holds.
|
|
107
|
+
* The plan's buttons, in the order `useBillingSection().actions` offers
|
|
108
|
+
* them. What they offer follows the subscription, not only the state its
|
|
109
|
+
* line reads as: a plan set to cancel offers Keep plan, and one with a
|
|
110
|
+
* change scheduled offers to cancel the change, whatever else holds.
|
|
106
111
|
*/
|
|
107
|
-
const actions = computed<PlanButton[]>(() => [
|
|
108
|
-
portalFirst.value && runs('portal', 'portal', t('updatePayment'), t('openingPortal'), section.openPortal),
|
|
109
|
-
props.billing.isPaused.value && runs('resume', 'resume', t('resume'), t('resuming'), section.resumePlan),
|
|
110
|
-
props.billing.cancelAtPeriodEnd.value && runs('uncancel', 'uncancel', t('keepPlan'), t('keeping'), section.keepPlan),
|
|
111
|
-
changeCancellable.value && runs('cancel-change', 'cancel-change', t('cancelChange'), t('cancelingChange'), section.cancelChange),
|
|
112
|
-
portalLast.value && runs('portal', 'portal', t('portal'), t('openingPortal'), section.openPortal),
|
|
113
|
-
section.switchable.value && opens('change-plan', t('changePlan'), section.switchToggleProps()),
|
|
114
|
-
section.pausable.value && opens('pause', t('pause'), section.pauseToggleProps()),
|
|
115
|
-
cancellable.value && opens('cancel', t('cancel'), section.confirm.toggleProps()),
|
|
116
|
-
].filter((button): button is PlanButton => button !== false))
|
|
112
|
+
const actions = computed<PlanButton[]>(() => section.actions.value.flatMap(action => (action === 'keep-gifted' ? [] : [BUTTONS[action]()])))
|
|
117
113
|
|
|
118
114
|
/** One benefit: its name (else what it gives), what it gives, and what it holds. */
|
|
119
115
|
const kind = (benefit: EntitlementBenefit) => valueLabel(labels, 'settings', 'benefitKinds', benefit.kind ?? 'other')
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import { busyAttributes } from '../../a11y'
|
|
4
4
|
import { closesOnEscape } from '../../utils/confirm-group'
|
|
5
|
-
import { PAUSE_MONTHS } from './workspace-billing'
|
|
6
5
|
import { useWorkspaceSettingsView } from './workspace-settings'
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -46,7 +45,7 @@ const busy = computed(() => view.context.value.pending === 'pause')
|
|
|
46
45
|
{{ t('pauseFor') }}
|
|
47
46
|
</legend>
|
|
48
47
|
<label
|
|
49
|
-
v-for="months in
|
|
48
|
+
v-for="months in section.plan.pauseLengths"
|
|
50
49
|
:key="months"
|
|
51
50
|
data-settings="pause-length"
|
|
52
51
|
>
|
|
@@ -4,10 +4,10 @@ import { useBackendConfig } from '../../composables/use-backend-config'
|
|
|
4
4
|
import { useBackendPagePath } from '../../composables/use-backend-page-path'
|
|
5
5
|
import { formatBillingAmount } from '../../composables/billing-format'
|
|
6
6
|
import { useBilling } from '../../composables/use-billing'
|
|
7
|
+
import { useBillingSection } from '../../composables/use-billing-section'
|
|
7
8
|
import { useCredits } from '../../composables/use-credits'
|
|
8
9
|
import { useFeatures } from '../../composables/use-features'
|
|
9
10
|
import { refusalText, useLabels, type BackendLabels, type LabelKey, type LabelOverrides } from '../../composables/use-labels'
|
|
10
|
-
import { usePricing } from '../../composables/use-pricing'
|
|
11
11
|
import { useWorkspace, type Workspace } from '../../composables/use-workspace'
|
|
12
12
|
import { inLocale } from '../../utils/intl'
|
|
13
13
|
import { useSettingsMessage } from '../../utils/settings-message'
|
|
@@ -61,14 +61,11 @@ const workspace = useWorkspace()
|
|
|
61
61
|
const billing = useBilling()
|
|
62
62
|
const credits = useCredits()
|
|
63
63
|
const features = useFeatures()
|
|
64
|
-
// The
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return typeof currency === 'string' ? currency : undefined
|
|
70
|
-
}
|
|
71
|
-
const pricing = usePricing({ server: false, actions: false, currency: subscriptionCurrency, enabled: () => props.sections.includes('billing') })
|
|
64
|
+
// The plan's state and its rules. The prices it can switch to are read in the
|
|
65
|
+
// browser only, only when the plan section shows, and in the subscription's own
|
|
66
|
+
// currency: the provider keeps it on a plan change, so a subscriber who pays in
|
|
67
|
+
// dollars is shown dollars wherever they are.
|
|
68
|
+
const plan = useBillingSection({ enabled: () => props.sections.includes('billing') })
|
|
72
69
|
const config = useBackendConfig()
|
|
73
70
|
const labels = useLabels('settings', () => props.labels)
|
|
74
71
|
const { t, locale } = labels
|
|
@@ -161,38 +158,28 @@ const packs = computed<CreditPack[]>(() => config.billing.packs.length > 0
|
|
|
161
158
|
: Object.entries(products.value).flatMap(([key, product]) => product?.isRecurring === false && product.isArchived !== true ? [{ key }] : []))
|
|
162
159
|
|
|
163
160
|
/**
|
|
164
|
-
* Every price on sale the plan can switch to
|
|
165
|
-
*
|
|
166
|
-
* subscription's currency
|
|
167
|
-
* provider would refuse to switch to.
|
|
161
|
+
* Every price on sale the plan can switch to (`useBillingSection().change.targets`),
|
|
162
|
+
* in the section's words: each named with its period, priced in the
|
|
163
|
+
* subscription's currency.
|
|
168
164
|
*/
|
|
169
165
|
function switchOptions(): PlanSwitchOption[] {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (!price || price.archived || price.productId === current || (currency !== undefined && price.currency !== currency)) return []
|
|
177
|
-
return [{
|
|
178
|
-
key: price.productId,
|
|
179
|
-
productId: price.productId,
|
|
180
|
-
plan: t(`billedAt.${interval}` as LabelKey<BackendLabels['settings']>, { plan: plan.name }),
|
|
181
|
-
price: `${formatBillingAmount(price.amount, price.currency, locale.value)}${t(`period.${interval}` as LabelKey<BackendLabels['settings']>)}`,
|
|
182
|
-
}]
|
|
183
|
-
})
|
|
184
|
-
})
|
|
166
|
+
return (plan.change.targets.value ?? []).map(target => ({
|
|
167
|
+
key: target.productId,
|
|
168
|
+
productId: target.productId,
|
|
169
|
+
plan: t(`billedAt.${target.interval}` as LabelKey<BackendLabels['settings']>, { plan: target.name }),
|
|
170
|
+
price: `${formatBillingAmount(target.amount, target.currency, locale.value)}${t(`period.${target.interval}` as LabelKey<BackendLabels['settings']>)}`,
|
|
171
|
+
}))
|
|
185
172
|
}
|
|
186
173
|
|
|
187
174
|
const section = createBillingSection({
|
|
188
175
|
billing,
|
|
176
|
+
plan,
|
|
189
177
|
features,
|
|
190
178
|
labels,
|
|
191
179
|
pending,
|
|
192
180
|
run,
|
|
193
181
|
partId,
|
|
194
182
|
productName,
|
|
195
|
-
giftedProduct: plan => products.value[plan]?.id,
|
|
196
183
|
switchOptions,
|
|
197
184
|
// One event per outcome; the union reads as each of them.
|
|
198
185
|
notify: (event, argument) => (emit as (event: string, ...args: unknown[]) => void)(event, ...(argument === undefined ? [] : [argument])),
|
|
@@ -3,7 +3,6 @@ import { useHead, useRuntimeConfig, useSeoMeta } from '#imports'
|
|
|
3
3
|
import PageFrame from '../components/shell/PageFrame.vue'
|
|
4
4
|
import { useLabels } from '../composables/use-labels'
|
|
5
5
|
import { usePricing } from '../composables/use-pricing'
|
|
6
|
-
import { pricingStructuredData } from '../utils/pricing-seo'
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* The ready-made public pricing page, registered by the module at `/pricing`
|
|
@@ -31,9 +30,7 @@ if (seo) {
|
|
|
31
30
|
key: 'backend-pricing',
|
|
32
31
|
type: 'application/ld+json',
|
|
33
32
|
// An object: the head manager serializes it, and escapes what could end the script early.
|
|
34
|
-
innerHTML: () =>
|
|
35
|
-
? pricingStructuredData({ plans: pricing.plans.value, packs: pricing.packs.value })
|
|
36
|
-
: ''),
|
|
33
|
+
innerHTML: () => pricing.structuredData.value ?? '',
|
|
37
34
|
}],
|
|
38
35
|
})
|
|
39
36
|
}
|