nuxt-backend 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/catalog.mjs +1 -1
- package/dist/chunks/doctor.mjs +71 -12
- 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 +4 -4
- package/dist/chunks/run.mjs +1 -1
- package/dist/chunks/server.mjs +7 -5
- package/dist/cli.mjs +122 -23
- package/dist/convex/account-data.d.ts +0 -2
- package/dist/convex/account-data.d.ts.map +1 -1
- package/dist/convex/account-data.js +0 -4
- package/dist/convex/account-data.js.map +1 -1
- package/dist/convex/catalog.d.ts +22 -0
- package/dist/convex/catalog.d.ts.map +1 -1
- package/dist/convex/catalog.js.map +1 -1
- package/dist/convex/client/better-auth-options.d.ts.map +1 -1
- package/dist/convex/client/better-auth-options.js +11 -1
- package/dist/convex/client/better-auth-options.js.map +1 -1
- package/dist/convex/client/client-address.d.ts +21 -0
- package/dist/convex/client/client-address.d.ts.map +1 -0
- package/dist/convex/client/client-address.js +37 -0
- package/dist/convex/client/client-address.js.map +1 -0
- package/dist/convex/client/index.d.ts +34 -2
- package/dist/convex/client/index.d.ts.map +1 -1
- package/dist/convex/components/backend/_generated/component.d.ts +6 -0
- package/dist/convex/components/backend/_generated/component.d.ts.map +1 -1
- package/dist/convex/components/backend/account.d.ts +6 -6
- package/dist/convex/components/backend/account.d.ts.map +1 -1
- package/dist/convex/components/backend/account.js +6 -2
- package/dist/convex/components/backend/account.js.map +1 -1
- package/dist/convex/components/backend/adapter.d.ts.map +1 -1
- package/dist/convex/components/backend/adapter.js +4 -1
- package/dist/convex/components/backend/adapter.js.map +1 -1
- package/dist/convex/components/backend/ai.d.ts +11 -3
- package/dist/convex/components/backend/ai.d.ts.map +1 -1
- package/dist/convex/components/backend/ai.js +18 -52
- package/dist/convex/components/backend/ai.js.map +1 -1
- package/dist/convex/components/backend/billing.d.ts.map +1 -1
- package/dist/convex/components/backend/billing.js +12 -32
- package/dist/convex/components/backend/billing.js.map +1 -1
- package/dist/convex/components/backend/consents.d.ts.map +1 -1
- package/dist/convex/components/backend/consents.js +2 -1
- package/dist/convex/components/backend/consents.js.map +1 -1
- package/dist/convex/components/backend/gifts.d.ts +1 -1
- package/dist/convex/components/backend/gifts.d.ts.map +1 -1
- package/dist/convex/components/backend/gifts.js +9 -4
- package/dist/convex/components/backend/gifts.js.map +1 -1
- package/dist/convex/components/backend/lifecycle.d.ts.map +1 -1
- package/dist/convex/components/backend/lifecycle.js +18 -14
- package/dist/convex/components/backend/lifecycle.js.map +1 -1
- package/dist/convex/components/backend/notifications.d.ts +13 -0
- package/dist/convex/components/backend/notifications.d.ts.map +1 -1
- package/dist/convex/components/backend/notifications.js +21 -0
- package/dist/convex/components/backend/notifications.js.map +1 -1
- package/dist/convex/components/backend/referrals.d.ts.map +1 -1
- package/dist/convex/components/backend/referrals.js +13 -16
- package/dist/convex/components/backend/referrals.js.map +1 -1
- package/dist/convex/components/backend/reports.js +7 -7
- package/dist/convex/components/backend/reports.js.map +1 -1
- package/dist/convex/components/backend/schema.d.ts +151 -35
- package/dist/convex/components/backend/schema.d.ts.map +1 -1
- package/dist/convex/components/backend/schema.js +127 -153
- package/dist/convex/components/backend/schema.js.map +1 -1
- package/dist/convex/components/backend/storage.d.ts.map +1 -1
- package/dist/convex/components/backend/storage.js +10 -10
- package/dist/convex/components/backend/storage.js.map +1 -1
- package/dist/convex/components/backend/subscriptions.d.ts +3 -3
- package/dist/convex/components/backend/subscriptions.d.ts.map +1 -1
- package/dist/convex/components/backend/subscriptions.js +6 -35
- package/dist/convex/components/backend/subscriptions.js.map +1 -1
- package/dist/convex/components/backend/waitlist.d.ts +1 -1
- package/dist/convex/components/backend/webhooks.d.ts +0 -1
- package/dist/convex/components/backend/webhooks.d.ts.map +1 -1
- package/dist/convex/components/backend/webhooks.js +1 -1
- package/dist/convex/components/backend/webhooks.js.map +1 -1
- package/dist/convex/consent-rules.d.ts +0 -2
- package/dist/convex/consent-rules.d.ts.map +1 -1
- package/dist/convex/consent-rules.js.map +1 -1
- package/dist/convex/constants.d.ts +0 -1
- package/dist/convex/constants.d.ts.map +1 -1
- package/dist/convex/constants.js +0 -1
- package/dist/convex/constants.js.map +1 -1
- package/dist/convex/email-templates.d.ts +0 -1
- package/dist/convex/email-templates.d.ts.map +1 -1
- package/dist/convex/email-templates.js +0 -1
- package/dist/convex/email-templates.js.map +1 -1
- package/dist/convex/integrations/admin.d.ts +2 -1
- package/dist/convex/integrations/admin.d.ts.map +1 -1
- package/dist/convex/integrations/admin.js.map +1 -1
- package/dist/convex/integrations/ai/job-errors.d.ts +7 -0
- package/dist/convex/integrations/ai/job-errors.d.ts.map +1 -1
- package/dist/convex/integrations/ai/job-errors.js +22 -0
- package/dist/convex/integrations/ai/job-errors.js.map +1 -1
- package/dist/convex/integrations/ai/metering.d.ts +12 -0
- package/dist/convex/integrations/ai/metering.d.ts.map +1 -1
- package/dist/convex/integrations/ai/metering.js +19 -10
- package/dist/convex/integrations/ai/metering.js.map +1 -1
- package/dist/convex/integrations/ai/models.d.ts.map +1 -1
- package/dist/convex/integrations/ai/models.js +3 -1
- package/dist/convex/integrations/ai/models.js.map +1 -1
- package/dist/convex/integrations/ai/moderation.d.ts +2 -0
- package/dist/convex/integrations/ai/moderation.d.ts.map +1 -1
- package/dist/convex/integrations/ai/moderation.js +29 -2
- package/dist/convex/integrations/ai/moderation.js.map +1 -1
- package/dist/convex/integrations/ai/stream.d.ts +1 -1
- package/dist/convex/integrations/ai/stream.d.ts.map +1 -1
- package/dist/convex/integrations/ai/stream.js +3 -11
- package/dist/convex/integrations/ai/stream.js.map +1 -1
- package/dist/convex/integrations/billing/context.d.ts +0 -1
- package/dist/convex/integrations/billing/context.d.ts.map +1 -1
- package/dist/convex/integrations/billing/context.js +1 -4
- package/dist/convex/integrations/billing/context.js.map +1 -1
- package/dist/convex/integrations/billing/credits.d.ts.map +1 -1
- package/dist/convex/integrations/billing/customers.d.ts.map +1 -1
- package/dist/convex/integrations/billing/customers.js +25 -5
- package/dist/convex/integrations/billing/customers.js.map +1 -1
- package/dist/convex/integrations/billing/features.d.ts.map +1 -1
- package/dist/convex/integrations/billing/free-plan.d.ts +1 -1
- package/dist/convex/integrations/billing/free-plan.d.ts.map +1 -1
- package/dist/convex/integrations/billing/free-plan.js +18 -4
- package/dist/convex/integrations/billing/free-plan.js.map +1 -1
- package/dist/convex/integrations/billing/functions.d.ts +5 -1
- package/dist/convex/integrations/billing/functions.d.ts.map +1 -1
- package/dist/convex/integrations/billing/functions.js +16 -5
- package/dist/convex/integrations/billing/functions.js.map +1 -1
- package/dist/convex/integrations/billing/gifts.d.ts.map +1 -1
- package/dist/convex/integrations/billing/gifts.js +2 -2
- package/dist/convex/integrations/billing/gifts.js.map +1 -1
- package/dist/convex/integrations/billing/history.d.ts.map +1 -1
- package/dist/convex/integrations/billing/history.js +3 -1
- package/dist/convex/integrations/billing/history.js.map +1 -1
- package/dist/convex/integrations/billing/lifecycle.d.ts +4 -1
- package/dist/convex/integrations/billing/lifecycle.d.ts.map +1 -1
- package/dist/convex/integrations/billing/lifecycle.js +33 -2
- package/dist/convex/integrations/billing/lifecycle.js.map +1 -1
- package/dist/convex/integrations/billing/passes.d.ts +0 -2
- package/dist/convex/integrations/billing/passes.d.ts.map +1 -1
- package/dist/convex/integrations/billing/passes.js +2 -3
- package/dist/convex/integrations/billing/passes.js.map +1 -1
- package/dist/convex/integrations/billing/pricing.d.ts +4 -1
- package/dist/convex/integrations/billing/pricing.d.ts.map +1 -1
- package/dist/convex/integrations/billing/pricing.js +11 -9
- package/dist/convex/integrations/billing/pricing.js.map +1 -1
- package/dist/convex/integrations/billing/purchase.d.ts.map +1 -1
- package/dist/convex/integrations/billing/purchase.js +1 -2
- package/dist/convex/integrations/billing/purchase.js.map +1 -1
- 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/lifecycle.d.ts +12 -0
- package/dist/convex/integrations/billing/types/lifecycle.d.ts.map +1 -1
- package/dist/convex/integrations/billing/types/options.d.ts +4 -1
- package/dist/convex/integrations/billing/types/options.d.ts.map +1 -1
- package/dist/convex/integrations/billing/types/records.d.ts +7 -1
- package/dist/convex/integrations/billing/types/records.d.ts.map +1 -1
- package/dist/convex/integrations/billing/types/surface.d.ts +5 -1
- package/dist/convex/integrations/billing/types/surface.d.ts.map +1 -1
- package/dist/convex/integrations/billing.d.ts +2 -2
- package/dist/convex/integrations/billing.d.ts.map +1 -1
- package/dist/convex/integrations/billing.js +1 -0
- package/dist/convex/integrations/billing.js.map +1 -1
- package/dist/convex/integrations/email-preferences.d.ts +1 -1
- package/dist/convex/integrations/email-preferences.d.ts.map +1 -1
- package/dist/convex/integrations/email-sync.d.ts.map +1 -1
- package/dist/convex/integrations/email-sync.js +43 -1
- package/dist/convex/integrations/email-sync.js.map +1 -1
- package/dist/convex/integrations/notifications.d.ts +24 -4
- package/dist/convex/integrations/notifications.d.ts.map +1 -1
- package/dist/convex/integrations/notifications.js +30 -14
- package/dist/convex/integrations/notifications.js.map +1 -1
- package/dist/convex/integrations/rate-limit.d.ts +6 -5
- package/dist/convex/integrations/rate-limit.d.ts.map +1 -1
- package/dist/convex/integrations/rate-limit.js +6 -5
- package/dist/convex/integrations/rate-limit.js.map +1 -1
- package/dist/convex/integrations/reports.d.ts +1 -1
- package/dist/convex/integrations/reports.d.ts.map +1 -1
- package/dist/convex/integrations/reports.js +0 -11
- package/dist/convex/integrations/reports.js.map +1 -1
- package/dist/convex/integrations/webhooks.d.ts +1 -3
- package/dist/convex/integrations/webhooks.d.ts.map +1 -1
- package/dist/convex/integrations/webhooks.js.map +1 -1
- package/dist/convex/label-groups/cancelFlow.d.ts +3 -0
- package/dist/convex/label-groups/cancelFlow.d.ts.map +1 -1
- package/dist/convex/label-groups/cancelFlow.js +5 -0
- package/dist/convex/label-groups/cancelFlow.js.map +1 -1
- package/dist/convex/label-groups/credits.d.ts +14 -1
- package/dist/convex/label-groups/credits.d.ts.map +1 -1
- package/dist/convex/label-groups/credits.js +17 -2
- package/dist/convex/label-groups/credits.js.map +1 -1
- package/dist/convex/label-groups/notifications.d.ts +19 -2
- package/dist/convex/label-groups/notifications.d.ts.map +1 -1
- package/dist/convex/label-groups/notifications.js +19 -15
- package/dist/convex/label-groups/notifications.js.map +1 -1
- package/dist/convex/label-groups/pricing.js +8 -8
- package/dist/convex/label-groups/pricing.js.map +1 -1
- package/dist/convex/label-groups/settings.d.ts.map +1 -1
- package/dist/convex/label-groups/settings.js +4 -3
- package/dist/convex/label-groups/settings.js.map +1 -1
- package/dist/convex/label-groups/usage.d.ts +1 -1
- package/dist/convex/label-groups/usage.d.ts.map +1 -1
- package/dist/convex/label-groups/usage.js +2 -2
- package/dist/convex/label-groups/usage.js.map +1 -1
- package/dist/convex/label-translations.d.ts.map +1 -1
- package/dist/convex/label-translations.js +52 -0
- package/dist/convex/label-translations.js.map +1 -1
- package/dist/convex/labels.d.ts +23 -0
- package/dist/convex/labels.d.ts.map +1 -1
- package/dist/convex/log.js +2 -0
- package/dist/convex/log.js.map +1 -1
- package/dist/convex/notifications.d.ts +77 -0
- package/dist/convex/notifications.d.ts.map +1 -1
- package/dist/convex/notifications.js +64 -13
- package/dist/convex/notifications.js.map +1 -1
- package/dist/convex/proof.d.ts +25 -0
- package/dist/convex/proof.d.ts.map +1 -1
- package/dist/convex/proof.js +39 -0
- package/dist/convex/proof.js.map +1 -1
- package/dist/convex/referral-rules.d.ts +0 -2
- package/dist/convex/referral-rules.d.ts.map +1 -1
- package/dist/convex/referral-rules.js +0 -2
- package/dist/convex/referral-rules.js.map +1 -1
- package/dist/convex/waitlist-rules.d.ts +1 -13
- package/dist/convex/waitlist-rules.d.ts.map +1 -1
- package/dist/convex/waitlist-rules.js +2 -14
- package/dist/convex/waitlist-rules.js.map +1 -1
- package/dist/devtools-client/index.html +1 -1
- package/dist/module.js +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/locales/de.json +47 -24
- package/dist/runtime/locales/en.json +47 -24
- package/dist/runtime/locales/es.json +47 -24
- package/dist/runtime/locales/fr.json +47 -24
- package/dist/runtime/locales/ru.json +47 -24
- package/dist/runtime/server/protection/gate.d.ts +4 -2
- package/dist/runtime/server/protection/gate.js +14 -4
- package/dist/runtime/vue/admin-client.d.ts +18 -0
- package/dist/runtime/vue/admin-client.js +32 -0
- package/dist/runtime/vue/auth-client.d.ts +16 -11
- package/dist/runtime/vue/auth-client.js +3 -1
- package/dist/runtime/vue/components/admin/AdminUsers.d.vue.ts +1 -1
- package/dist/runtime/vue/components/admin/AdminUsers.vue.d.ts +1 -1
- package/dist/runtime/vue/components/billing/BillingCheckoutLink.d.vue.ts +1 -1
- package/dist/runtime/vue/components/billing/BillingCheckoutLink.vue.d.ts +1 -1
- package/dist/runtime/vue/components/billing/CancelFlow.css +1 -1
- package/dist/runtime/vue/components/billing/CancelFlow.d.vue.ts +3 -0
- package/dist/runtime/vue/components/billing/CancelFlow.vue +10 -3
- package/dist/runtime/vue/components/billing/CancelFlow.vue.d.ts +3 -0
- package/dist/runtime/vue/components/billing/CancelFlowConfirm.d.vue.ts +3 -0
- package/dist/runtime/vue/components/billing/CancelFlowConfirm.vue +34 -0
- package/dist/runtime/vue/components/billing/CancelFlowConfirm.vue.d.ts +3 -0
- package/dist/runtime/vue/components/billing/CancelFlowQuestion.vue +2 -1
- package/dist/runtime/vue/components/billing/GiftSent.d.vue.ts +2 -2
- package/dist/runtime/vue/components/billing/GiftSent.vue.d.ts +2 -2
- package/dist/runtime/vue/components/billing/PricingPackCard.vue +6 -3
- package/dist/runtime/vue/components/billing/PricingPlanCard.vue +3 -1
- package/dist/runtime/vue/components/billing/PricingTable.d.vue.ts +2 -2
- package/dist/runtime/vue/components/billing/PricingTable.vue +3 -1
- package/dist/runtime/vue/components/billing/PricingTable.vue.d.ts +2 -2
- package/dist/runtime/vue/components/billing/UsageHistoryEvent.vue +3 -1
- package/dist/runtime/vue/components/billing/cancel-flow.d.ts +28 -7
- package/dist/runtime/vue/components/billing/cancel-flow.js +25 -2
- package/dist/runtime/vue/components/shell/NoticeLowCredits.vue +3 -1
- package/dist/runtime/vue/components/tokens.css +1 -1
- package/dist/runtime/vue/components/workspaces/WorkspaceCredits.vue +6 -3
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
- package/dist/runtime/vue/composables/use-auth.d.ts +13 -1
- package/dist/runtime/vue/composables/use-auth.js +4 -1
- package/dist/runtime/vue/composables/use-billing.d.ts +10 -2
- package/dist/runtime/vue/composables/use-credits.d.ts +3 -0
- package/dist/runtime/vue/composables/use-credits.js +1 -0
- package/dist/runtime/vue/composables/use-notifications.d.ts +5 -1
- package/dist/runtime/vue/composables/use-notifications.js +12 -4
- package/dist/runtime/vue/composables/use-webhook-log.d.ts +4 -2
- package/dist/runtime/vue/organization-client.d.ts +15 -0
- package/dist/runtime/vue/organization-client.js +65 -0
- package/dist/runtime/vue/parts.d.ts +2 -1
- package/dist/runtime/vue/plugins/checkout-return.d.ts +3 -2
- package/dist/runtime/vue/plugins/checkout-return.js +2 -4
- package/dist/runtime/vue/plugins/first-touch.js +2 -4
- package/dist/runtime/vue/utils/checkout-return.d.ts +9 -2
- package/dist/runtime/vue/utils/checkout-return.js +2 -1
- package/dist/runtime/vue/utils/every-page.d.ts +10 -0
- package/dist/runtime/vue/utils/every-page.js +6 -0
- package/dist/runtime/vue/utils/meter-unit.d.ts +14 -0
- package/dist/runtime/vue/utils/meter-unit.js +18 -0
- package/dist/shared/{nuxt-backend.2YoiKo8j.mjs → nuxt-backend.2m535CLS.mjs} +6 -2
- package/dist/shared/{nuxt-backend.CPq101Wi.mjs → nuxt-backend.DXEf0rrv.mjs} +1 -1
- package/dist/shared/{nuxt-backend.-uB5CGw-.mjs → nuxt-backend.Dm1NkY7v.mjs} +1 -1
- package/dist/shared/{nuxt-backend.OQMX-0U7.mjs → nuxt-backend.KEzfHO2K.mjs} +6 -3
- package/dist/shared/{nuxt-backend.S5C2b-4I.mjs → nuxt-backend.ikObmtHs.mjs} +2 -2
- package/package.json +2 -2
- package/skills/nuxt-backend/references/api.md +13 -3
- package/skills/nuxt-backend/references/surface.json +12 -0
- package/skills/nuxt-backend-auth/SKILL.md +2 -1
- package/skills/nuxt-backend-billing/SKILL.md +7 -0
- package/skills/nuxt-backend-billing/references/api.md +12 -2
- package/skills/nuxt-backend-data/SKILL.md +4 -1
- package/skills/nuxt-backend-email/SKILL.md +4 -0
- package/skills/nuxt-backend-email/references/api.md +1 -1
- package/skills/nuxt-backend-ui/SKILL.md +6 -5
- package/src/convex/account-data.ts +0 -5
- package/src/convex/catalog.ts +23 -0
- package/src/convex/client/better-auth-options.ts +11 -1
- package/src/convex/client/client-address.ts +37 -0
- package/src/convex/components/backend/_generated/component.ts +12 -0
- package/src/convex/components/backend/account.ts +7 -2
- package/src/convex/components/backend/adapter.ts +4 -1
- package/src/convex/components/backend/ai.ts +20 -54
- package/src/convex/components/backend/billing.ts +14 -33
- package/src/convex/components/backend/consents.ts +2 -1
- package/src/convex/components/backend/gifts.ts +11 -5
- package/src/convex/components/backend/lifecycle.ts +17 -12
- package/src/convex/components/backend/notifications.ts +22 -0
- package/src/convex/components/backend/referrals.ts +14 -16
- package/src/convex/components/backend/reports.ts +7 -7
- package/src/convex/components/backend/schema.ts +143 -161
- package/src/convex/components/backend/storage.ts +11 -10
- package/src/convex/components/backend/subscriptions.ts +7 -35
- package/src/convex/components/backend/webhooks.ts +1 -10
- package/src/convex/consent-rules.ts +0 -3
- package/src/convex/constants.ts +0 -1
- package/src/convex/email-templates.ts +0 -1
- package/src/convex/integrations/admin.ts +2 -1
- package/src/convex/integrations/ai/job-errors.ts +21 -0
- package/src/convex/integrations/ai/metering.ts +24 -10
- package/src/convex/integrations/ai/models.ts +3 -1
- package/src/convex/integrations/ai/moderation.ts +31 -2
- package/src/convex/integrations/ai/stream.ts +3 -11
- package/src/convex/integrations/billing/context.ts +1 -9
- package/src/convex/integrations/billing/customers.ts +28 -5
- package/src/convex/integrations/billing/free-plan.ts +20 -5
- package/src/convex/integrations/billing/functions.ts +17 -5
- package/src/convex/integrations/billing/gifts.ts +2 -2
- package/src/convex/integrations/billing/history.ts +2 -1
- package/src/convex/integrations/billing/lifecycle.ts +30 -3
- package/src/convex/integrations/billing/passes.ts +2 -4
- package/src/convex/integrations/billing/pricing.ts +14 -10
- package/src/convex/integrations/billing/purchase.ts +1 -2
- package/src/convex/integrations/billing/types/lifecycle.ts +13 -0
- package/src/convex/integrations/billing/types/options.ts +4 -1
- package/src/convex/integrations/billing/types/records.ts +7 -1
- package/src/convex/integrations/billing/types/surface.ts +3 -1
- package/src/convex/integrations/billing.ts +3 -2
- package/src/convex/integrations/email-preferences.ts +1 -1
- package/src/convex/integrations/email-sync.ts +44 -1
- package/src/convex/integrations/notifications.ts +65 -16
- package/src/convex/integrations/rate-limit.ts +6 -5
- package/src/convex/integrations/reports.ts +1 -1
- package/src/convex/integrations/webhooks.ts +1 -4
- package/src/convex/label-groups/cancelFlow.ts +5 -0
- package/src/convex/label-groups/credits.ts +17 -2
- package/src/convex/label-groups/notifications.ts +19 -15
- package/src/convex/label-groups/pricing.ts +8 -8
- package/src/convex/label-groups/settings.ts +4 -3
- package/src/convex/label-groups/usage.ts +2 -2
- package/src/convex/label-translations.ts +52 -0
- package/src/convex/log.ts +2 -0
- package/src/convex/notifications.ts +99 -13
- package/src/convex/proof.ts +43 -0
- package/src/convex/referral-rules.ts +0 -2
- package/src/convex/waitlist-rules.ts +2 -22
- package/src/runtime/vue/components/billing/CancelFlow.css +16 -0
- package/src/runtime/vue/components/billing/CancelFlow.vue +16 -6
- package/src/runtime/vue/components/billing/CancelFlowConfirm.vue +35 -0
- package/src/runtime/vue/components/billing/CancelFlowQuestion.vue +8 -2
- package/src/runtime/vue/components/billing/PricingPackCard.vue +6 -3
- package/src/runtime/vue/components/billing/PricingPlanCard.vue +3 -1
- package/src/runtime/vue/components/billing/PricingTable.vue +3 -1
- package/src/runtime/vue/components/billing/UsageHistoryEvent.vue +3 -1
- package/src/runtime/vue/components/shell/NoticeLowCredits.vue +3 -1
- package/src/runtime/vue/components/tokens.css +19 -15
- package/src/runtime/vue/components/workspaces/WorkspaceCredits.vue +6 -3
|
@@ -216,6 +216,19 @@ export const track = mutation({
|
|
|
216
216
|
},
|
|
217
217
|
})
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Send one event to the email provider. Answers `true` when a rate limit
|
|
221
|
+
* asks for another try, with attempts left; any other failure is logged
|
|
222
|
+
* with what not sending it again means (`unsent`), and not tried again.
|
|
223
|
+
*/
|
|
224
|
+
async function sendProviderEvent(key: string | undefined, args: { event: string, email: string, payload?: Record<string, unknown>, attempt: number }, unsent: string): Promise<boolean> {
|
|
225
|
+
const { error } = await new Resend(key).events.send({ event: args.event, email: args.email, ...(args.payload ? { payload: args.payload } : {}) })
|
|
226
|
+
if (!error) return false
|
|
227
|
+
if (rateLimited(error) && args.attempt < SEND_ATTEMPTS) return true
|
|
228
|
+
logBackend('warn', 'email.event_unsent', `The ${args.event} event failed at the email provider; it is not sent again, so ${unsent}.`, error)
|
|
229
|
+
return false
|
|
230
|
+
}
|
|
231
|
+
|
|
219
232
|
/** One event to the provider; a rate limit is waited out with backoff, a few times, and any other failure is not tried again. */
|
|
220
233
|
export const sendEvent = internalAction({
|
|
221
234
|
args: { event: v.string(), email: v.string(), payload: v.optional(v.record(v.string(), v.any())), attempt: v.number() },
|
|
@@ -223,13 +236,9 @@ export const sendEvent = internalAction({
|
|
|
223
236
|
handler: async (ctx, args) => {
|
|
224
237
|
const key = env.EMAIL_API_KEY
|
|
225
238
|
if (!key) return null
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (!rateLimited(error) || args.attempt >= SEND_ATTEMPTS) {
|
|
229
|
-
logBackend('warn', 'email.event_unsent', `The ${args.event} event failed at the email provider; it is not sent again, so the automations listening for it start at most once.`, error)
|
|
230
|
-
return null
|
|
239
|
+
if (await sendProviderEvent(key, args, 'the automations listening for it start at most once')) {
|
|
240
|
+
await ctx.scheduler.runAfter(2 ** args.attempt * 1000, internal.lifecycle.sendEvent, { ...args, attempt: args.attempt + 1 })
|
|
231
241
|
}
|
|
232
|
-
await ctx.scheduler.runAfter(2 ** args.attempt * 1000, internal.lifecycle.sendEvent, { ...args, attempt: args.attempt + 1 })
|
|
233
242
|
return null
|
|
234
243
|
},
|
|
235
244
|
})
|
|
@@ -315,13 +324,9 @@ export const deliver = internalAction({
|
|
|
315
324
|
logBackend('warn', 'email.undeliverable', `A lifecycle email (${args.event}) was not sent: ${reason}.`)
|
|
316
325
|
return null
|
|
317
326
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (!rateLimited(error) || args.attempt >= SEND_ATTEMPTS) {
|
|
321
|
-
logBackend('warn', 'email.event_unsent', `The ${args.event} event failed at the email provider; it is not sent again, so its lifecycle email goes at most once.`, error)
|
|
322
|
-
return null
|
|
327
|
+
if (await sendProviderEvent(env.EMAIL_API_KEY, args, 'its lifecycle email goes at most once')) {
|
|
328
|
+
await ctx.scheduler.runAfter(2 ** args.attempt * 1000, internal.lifecycle.deliver, { ...args, attempt: args.attempt + 1 })
|
|
323
329
|
}
|
|
324
|
-
await ctx.scheduler.runAfter(2 ** args.attempt * 1000, internal.lifecycle.deliver, { ...args, attempt: args.attempt + 1 })
|
|
325
330
|
return null
|
|
326
331
|
},
|
|
327
332
|
})
|
|
@@ -401,6 +401,28 @@ export const listChoices = query({
|
|
|
401
401
|
.map(({ type, channel, enabled }) => ({ type, channel, enabled })),
|
|
402
402
|
})
|
|
403
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Which billing features this deployment has used, so the channel list
|
|
406
|
+
* leaves out the kinds of one it never has: a gift someone bought, a plan
|
|
407
|
+
* pass of any kind, a reverse trial, a referral. One row each answers it.
|
|
408
|
+
* A reverse trial and a reward pass have no purchaser (`purchaserUserId`
|
|
409
|
+
* is empty), and a pass carries its end date from the day it starts.
|
|
410
|
+
*/
|
|
411
|
+
export const features = query({
|
|
412
|
+
args: {},
|
|
413
|
+
returns: v.object({ gifts: v.boolean(), passes: v.boolean(), trialPasses: v.boolean(), referrals: v.boolean() }),
|
|
414
|
+
handler: async (ctx) => {
|
|
415
|
+
const gifts = () => ctx.db.query('billingGifts')
|
|
416
|
+
const passRunning = await gifts().withIndex('passEndedAt_passEndsAt', q => q.eq('passEndedAt', undefined).gte('passEndsAt', 0)).first()
|
|
417
|
+
return {
|
|
418
|
+
gifts: await gifts().withIndex('purchaserUserId_createdAt', q => q.gt('purchaserUserId', '')).first() !== null,
|
|
419
|
+
passes: passRunning !== null || await gifts().withIndex('passEndedAt_passEndsAt', q => q.gte('passEndedAt', 0)).first() !== null,
|
|
420
|
+
trialPasses: await gifts().withIndex('status', q => q.eq('status', 'trial')).first() !== null,
|
|
421
|
+
referrals: await ctx.db.query('referrals').first() !== null,
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
})
|
|
425
|
+
|
|
404
426
|
/**
|
|
405
427
|
* Turn one channel of one kind on or off for a person. The caller, the
|
|
406
428
|
* app's `setNotificationChannel`, checks the kind allows the channel.
|
|
@@ -381,6 +381,12 @@ const vDue = v.object({
|
|
|
381
381
|
})
|
|
382
382
|
|
|
383
383
|
/** Whether a held referral may be rewarded at `now`: its hold is over and no flag waits for an administrator. */
|
|
384
|
+
/** A referral by the id the app holds, or `null` for one that is gone or never was. */
|
|
385
|
+
async function referralOf(ctx: QueryCtx, id: string): Promise<Referral | null> {
|
|
386
|
+
const rowId = ctx.db.normalizeId('referrals', id)
|
|
387
|
+
return rowId ? await ctx.db.get('referrals', rowId) : null
|
|
388
|
+
}
|
|
389
|
+
|
|
384
390
|
function rewardable(row: Referral, now: number): boolean {
|
|
385
391
|
return row.state === 'held' && row.holdUntil !== undefined && row.holdUntil <= now && !inReview(row)
|
|
386
392
|
}
|
|
@@ -407,8 +413,7 @@ export const get = query({
|
|
|
407
413
|
args: { id: v.string() },
|
|
408
414
|
returns: v.union(v.null(), vDue),
|
|
409
415
|
handler: async (ctx, { id }) => {
|
|
410
|
-
const
|
|
411
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
416
|
+
const row = await referralOf(ctx, id)
|
|
412
417
|
if (!row?.orderId || !row.entityId) return null
|
|
413
418
|
return { id: row._id as string, referrerId: row.referrerId, referredId: row.referredId, orderId: row.orderId, entityId: row.entityId, terms: row.terms, state: row.state, ...(row.grant ? { grant: row.grant } : {}) }
|
|
414
419
|
},
|
|
@@ -480,8 +485,7 @@ export const beginReward = mutation({
|
|
|
480
485
|
args: { id: v.string(), now: v.number() },
|
|
481
486
|
returns: v.union(v.literal('grant'), v.literal('capped'), v.literal('skip')),
|
|
482
487
|
handler: async (ctx, { id, now }) => {
|
|
483
|
-
const
|
|
484
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
488
|
+
const row = await referralOf(ctx, id)
|
|
485
489
|
if (!row || !rewardable(row, now)) return 'skip'
|
|
486
490
|
if (row.reservedMonth) return 'grant'
|
|
487
491
|
const { perReferrer, perMonth } = row.terms.caps
|
|
@@ -503,8 +507,7 @@ export const noteGrant = mutation({
|
|
|
503
507
|
args: { id: v.string(), grant: v.object({ discountId: v.optional(v.string()), endsAt: v.optional(v.number()), done: v.optional(v.boolean()) }) },
|
|
504
508
|
returns: v.null(),
|
|
505
509
|
handler: async (ctx, { id, grant }) => {
|
|
506
|
-
const
|
|
507
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
510
|
+
const row = await referralOf(ctx, id)
|
|
508
511
|
if (row) await patchReferral(ctx, row, { grant: { ...row.grant, ...grant } })
|
|
509
512
|
return null
|
|
510
513
|
},
|
|
@@ -515,8 +518,7 @@ export const finishReward = mutation({
|
|
|
515
518
|
args: { id: v.string() },
|
|
516
519
|
returns: v.boolean(),
|
|
517
520
|
handler: async (ctx, { id }) => {
|
|
518
|
-
const
|
|
519
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
521
|
+
const row = await referralOf(ctx, id)
|
|
520
522
|
if (row?.state !== 'held') return false
|
|
521
523
|
await patchReferral(ctx, row, { state: 'rewarded', rewardedAt: Date.now(), dueAt: undefined })
|
|
522
524
|
return true
|
|
@@ -528,8 +530,7 @@ export const deferReward = mutation({
|
|
|
528
530
|
args: { id: v.string(), until: v.number() },
|
|
529
531
|
returns: v.null(),
|
|
530
532
|
handler: async (ctx, { id, until }) => {
|
|
531
|
-
const
|
|
532
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
533
|
+
const row = await referralOf(ctx, id)
|
|
533
534
|
if (row?.state === 'held' && row.dueAt !== undefined) await patchReferral(ctx, row, { dueAt: until })
|
|
534
535
|
return null
|
|
535
536
|
},
|
|
@@ -544,8 +545,7 @@ export const closeUnrewarded = mutation({
|
|
|
544
545
|
args: { id: v.string(), now: v.number() },
|
|
545
546
|
returns: v.boolean(),
|
|
546
547
|
handler: async (ctx, { id, now }) => {
|
|
547
|
-
const
|
|
548
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
548
|
+
const row = await referralOf(ctx, id)
|
|
549
549
|
if (!row || !rewardable(row, now)) return false
|
|
550
550
|
await releaseSlot(ctx, row)
|
|
551
551
|
await patchReferral(ctx, row, { state: 'claimed', unrewarded: true, dueAt: undefined })
|
|
@@ -558,8 +558,7 @@ export const voidReferral = mutation({
|
|
|
558
558
|
args: { id: v.string(), reason: v.union(v.literal('refunded'), v.literal('administrator'), v.literal('account_erased')) },
|
|
559
559
|
returns: v.boolean(),
|
|
560
560
|
handler: async (ctx, { id, reason }) => {
|
|
561
|
-
const
|
|
562
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
561
|
+
const row = await referralOf(ctx, id)
|
|
563
562
|
return row ? await voidRow(ctx, row, reason) : false
|
|
564
563
|
},
|
|
565
564
|
})
|
|
@@ -651,8 +650,7 @@ export const resolveFlag = mutation({
|
|
|
651
650
|
args: { id: v.string(), resolution: v.union(v.literal('release'), v.literal('void')) },
|
|
652
651
|
returns: v.boolean(),
|
|
653
652
|
handler: async (ctx, { id, resolution }) => {
|
|
654
|
-
const
|
|
655
|
-
const row = rowId ? await ctx.db.get('referrals', rowId) : null
|
|
653
|
+
const row = await referralOf(ctx, id)
|
|
656
654
|
if (!row?.flags?.length || (row.state !== 'claimed' && row.state !== 'held')) return false
|
|
657
655
|
if (resolution === 'void') return await voidRow(ctx, row, 'administrator')
|
|
658
656
|
// A held referral goes back to the sweep, due from the end of its hold.
|
|
@@ -3,7 +3,7 @@ import type { Doc, Id } from './_generated/dataModel.js'
|
|
|
3
3
|
import { mutation, type MutationCtx, query, type QueryCtx } from './_generated/server.js'
|
|
4
4
|
import { APPEAL_WINDOW_MS } from '../../constants.js'
|
|
5
5
|
import { ERASED_PREFIX } from './parties.js'
|
|
6
|
-
import { vReportReason } from './schema.js'
|
|
6
|
+
import { vDecisionAction, vDecisionGround, vReportReason } from './schema.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Content duties: the component's half of `setupAdmin({ reports })`. One
|
|
@@ -209,7 +209,7 @@ export const reportsConsole = query({
|
|
|
209
209
|
id: v.string(),
|
|
210
210
|
text: v.string(),
|
|
211
211
|
createdAt: v.number(),
|
|
212
|
-
decision: v.object({ action:
|
|
212
|
+
decision: v.object({ action: vDecisionAction, reason: v.string(), at: v.number(), authorId: v.union(v.string(), v.null()) }),
|
|
213
213
|
subject: v.union(vSubject, v.null()),
|
|
214
214
|
})),
|
|
215
215
|
}),
|
|
@@ -313,9 +313,9 @@ export const decide = mutation({
|
|
|
313
313
|
notice: v.optional(v.string()),
|
|
314
314
|
/** Open notices sent without their thing that the app placed on this one: closed with it. */
|
|
315
315
|
notices: v.optional(v.array(v.string())),
|
|
316
|
-
action:
|
|
316
|
+
action: vDecisionAction,
|
|
317
317
|
reason: v.string(),
|
|
318
|
-
ground:
|
|
318
|
+
ground: vDecisionGround,
|
|
319
319
|
by: v.string(),
|
|
320
320
|
authorId: v.optional(v.string()),
|
|
321
321
|
appealTokenHash: v.optional(v.string()),
|
|
@@ -359,9 +359,9 @@ export const flagCrime = mutation({
|
|
|
359
359
|
|
|
360
360
|
const vAppealable = v.object({
|
|
361
361
|
decisionId: v.string(),
|
|
362
|
-
action:
|
|
362
|
+
action: vDecisionAction,
|
|
363
363
|
reason: v.string(),
|
|
364
|
-
ground:
|
|
364
|
+
ground: vDecisionGround,
|
|
365
365
|
at: v.number(),
|
|
366
366
|
until: v.number(),
|
|
367
367
|
subject: v.union(vSubject, v.null()),
|
|
@@ -432,7 +432,7 @@ async function actedOnSince(ctx: QueryCtx, subject: Doc<'reportSubjects'> | null
|
|
|
432
432
|
export const decideAppeal = mutation({
|
|
433
433
|
args: { appeal: v.string(), outcome: v.union(v.literal('upheld'), v.literal('reversed')), reason: v.string(), by: v.string() },
|
|
434
434
|
returns: v.union(v.object({
|
|
435
|
-
action:
|
|
435
|
+
action: vDecisionAction,
|
|
436
436
|
subject: v.union(vSubject, v.null()),
|
|
437
437
|
authorId: v.union(v.string(), v.null()),
|
|
438
438
|
/** Whether the app shows the content again: a removal reversed, and nothing reported or hidden since. */
|
|
@@ -267,52 +267,95 @@ export const vPendingSpend = v.object({
|
|
|
267
267
|
* recipient — identified by email — receives. Created at gift checkout, marked
|
|
268
268
|
* `paid` by the billing webhook, and `claimed` once the entitlement is attached
|
|
269
269
|
* to the recipient's billing entity (automatically when the recipient already
|
|
270
|
-
* has an account, otherwise on their first sign-in).
|
|
270
|
+
* has an account, otherwise on their first sign-in). The `billingGifts` row.
|
|
271
271
|
*/
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
const vGiftRow = v.object({
|
|
273
|
+
// Stored lowercased; matched case-insensitively against the claimant's email.
|
|
274
274
|
recipientEmail: v.string(),
|
|
275
275
|
purchaserUserId: v.string(),
|
|
276
276
|
purchaserEmail: v.optional(v.string()),
|
|
277
277
|
purchaserName: v.optional(v.string()),
|
|
278
|
+
// The credit pack the recipient receives: its provider product.
|
|
278
279
|
productIds: v.array(v.string()),
|
|
280
|
+
// Plain text, shown only inside the app once the recipient signs in.
|
|
279
281
|
message: v.optional(v.string()),
|
|
282
|
+
// 'pending' (checkout created) → 'paid' (the purchase order is paid and
|
|
283
|
+
// its claim discount minted) → 'claimed' (the recipient's $0 order is
|
|
284
|
+
// paid), or 'refunded' (the purchase was refunded before the claim).
|
|
280
285
|
status: v.string(),
|
|
286
|
+
// Before 0.2: the provider customer keyed by the recipient's email,
|
|
287
|
+
// which the purchase was billed to. Gifts are billed to the purchaser now.
|
|
281
288
|
billingCustomerId: v.optional(v.string()),
|
|
289
|
+
// The purchase order, paid by the purchaser's own billing entity.
|
|
282
290
|
billingOrderId: v.optional(v.string()),
|
|
283
291
|
purchaserEntityId: v.optional(v.string()),
|
|
292
|
+
// The pack's catalog key, and the private gift product the purchaser bought.
|
|
284
293
|
pack: v.optional(v.string()),
|
|
285
294
|
giftProductId: v.optional(v.string()),
|
|
295
|
+
// What the purchase order charged, in the currency's smallest unit.
|
|
286
296
|
amount: v.optional(v.number()),
|
|
287
297
|
currency: v.optional(v.string()),
|
|
298
|
+
// The single-use 100% discount the recipient claims the pack with.
|
|
288
299
|
discountId: v.optional(v.string()),
|
|
300
|
+
// The claim checkout in flight: who opened it, for which entity. A plan
|
|
301
|
+
// pass's claim holds the gift until `claimingUntil`, while it switches the
|
|
302
|
+
// workspace at the provider.
|
|
289
303
|
claimingEntityId: v.optional(v.string()),
|
|
290
304
|
claimingUserId: v.optional(v.string()),
|
|
305
|
+
claimingUntil: v.optional(v.number()),
|
|
306
|
+
// The purchaser's cancellation in flight, until then: no claim starts meanwhile.
|
|
307
|
+
cancelingUntil: v.optional(v.number()),
|
|
291
308
|
claimOrderId: v.optional(v.string()),
|
|
292
309
|
claimedByUserId: v.optional(v.string()),
|
|
310
|
+
// The entity the credits landed on: workspace id or user id.
|
|
293
311
|
claimedEntityId: v.optional(v.string()),
|
|
294
312
|
createdAt: v.number(),
|
|
295
313
|
paidAt: v.optional(v.number()),
|
|
296
314
|
notifiedAt: v.optional(v.number()),
|
|
297
315
|
claimedAt: v.optional(v.number()),
|
|
298
316
|
refundedAt: v.optional(v.number()),
|
|
317
|
+
// A plan pass (the gift is a plan for `months` months, not a pack): the
|
|
318
|
+
// plan's catalog key and the length the purchaser paid for.
|
|
299
319
|
plan: v.optional(v.string()),
|
|
300
320
|
months: v.optional(v.number()),
|
|
321
|
+
// When the notice goes out: set when the purchase is paid (the moment
|
|
322
|
+
// it is paid, or the date the purchaser chose). The gift is the
|
|
323
|
+
// recipient's to see and claim once `deliveredAt` is stamped; a row
|
|
324
|
+
// with neither is a gift paid before delivery dates, delivered when paid.
|
|
301
325
|
deliverAt: v.optional(v.number()),
|
|
302
326
|
deliveredAt: v.optional(v.number()),
|
|
327
|
+
// The last notice sent (the first, a reminder or a resend), and how many.
|
|
303
328
|
noticedAt: v.optional(v.number()),
|
|
304
329
|
noticeCount: v.optional(v.number()),
|
|
330
|
+
// How many times the purchaser changed the address: each address's notices carry their own idempotency keys.
|
|
305
331
|
recipientChanges: v.optional(v.number()),
|
|
332
|
+
// The one reminder, a week after delivery.
|
|
306
333
|
remindedAt: v.optional(v.number()),
|
|
334
|
+
// A pass once claimed: the free subscription it switched, when it began
|
|
335
|
+
// and ends (the package keeps the end date), the scheduled return to the
|
|
336
|
+
// free plan, the ending notice and the end itself.
|
|
307
337
|
passSubscriptionId: v.optional(v.string()),
|
|
308
338
|
passStartedAt: v.optional(v.number()),
|
|
309
339
|
passEndsAt: v.optional(v.number()),
|
|
340
|
+
// From when the return may be booked: once the pass's last billing cycle began.
|
|
341
|
+
passReturnFrom: v.optional(v.number()),
|
|
310
342
|
passReturnScheduledAt: v.optional(v.number()),
|
|
311
343
|
passNoticedAt: v.optional(v.number()),
|
|
312
344
|
passEndedAt: v.optional(v.number()),
|
|
345
|
+
// A reverse trial (LIFECYCLE): the pass a new workspace started on,
|
|
346
|
+
// with no purchaser (`status` 'trial'). `recipientEmail` holds its
|
|
347
|
+
// owner's address with plus tags and dots taken out, so an address
|
|
348
|
+
// starts one.
|
|
313
349
|
reverseTrial: v.optional(v.boolean()),
|
|
350
|
+
// A referral reward (REF): the pass a referrer on the free plan got for
|
|
351
|
+
// free months, with no purchaser (`status` 'reward'). `rewardId` is the
|
|
352
|
+
// referral it came from; `recipientEmail` is empty.
|
|
353
|
+
rewardId: v.optional(v.string()),
|
|
314
354
|
})
|
|
315
355
|
|
|
356
|
+
/** A gift as the component's reads return it: its id, without the claim and cancel holds or the reward it came from. */
|
|
357
|
+
export const vGift = vGiftRow.omit('claimingUntil', 'cancelingUntil', 'passReturnFrom', 'rewardId').extend({ id: v.string() })
|
|
358
|
+
|
|
316
359
|
/** A save offer's terms, as the cancel flow made it (LIFECYCLE). */
|
|
317
360
|
export const vSaveOfferTerms = v.object({
|
|
318
361
|
kind: v.union(v.literal('pause'), v.literal('downgrade'), v.literal('discount')),
|
|
@@ -323,6 +366,22 @@ export const vSaveOfferTerms = v.object({
|
|
|
323
366
|
discount: v.optional(v.string()),
|
|
324
367
|
})
|
|
325
368
|
|
|
369
|
+
/** A renewing checkout's consent proof, as the `billingRenewalConsents` table stores it. */
|
|
370
|
+
export const vRenewalConsent = v.object({
|
|
371
|
+
checkoutId: v.string(),
|
|
372
|
+
entityId: v.string(),
|
|
373
|
+
userId: v.optional(v.string()),
|
|
374
|
+
productId: v.string(),
|
|
375
|
+
amount: v.number(),
|
|
376
|
+
currency: v.string(),
|
|
377
|
+
interval: v.string(),
|
|
378
|
+
intervalCount: v.number(),
|
|
379
|
+
termsVersion: v.optional(v.string()),
|
|
380
|
+
createdAt: v.number(),
|
|
381
|
+
subscriptionId: v.optional(v.string()),
|
|
382
|
+
consentedAt: v.optional(v.number()),
|
|
383
|
+
})
|
|
384
|
+
|
|
326
385
|
export const billingTables = {
|
|
327
386
|
billingEntitlements: defineTable({
|
|
328
387
|
// The billing entity id — the workspace id (billTo: 'workspace', the
|
|
@@ -411,89 +470,7 @@ export const billingTables = {
|
|
|
411
470
|
})
|
|
412
471
|
.index('entityId', ['entityId'])
|
|
413
472
|
.index('at', ['at']),
|
|
414
|
-
billingGifts: defineTable(
|
|
415
|
-
// Stored lowercased; matched case-insensitively against the claimant's email.
|
|
416
|
-
recipientEmail: v.string(),
|
|
417
|
-
purchaserUserId: v.string(),
|
|
418
|
-
purchaserEmail: v.optional(v.string()),
|
|
419
|
-
purchaserName: v.optional(v.string()),
|
|
420
|
-
// The credit pack the recipient receives: its provider product.
|
|
421
|
-
productIds: v.array(v.string()),
|
|
422
|
-
// Plain text, shown only inside the app once the recipient signs in.
|
|
423
|
-
message: v.optional(v.string()),
|
|
424
|
-
// 'pending' (checkout created) → 'paid' (the purchase order is paid and
|
|
425
|
-
// its claim discount minted) → 'claimed' (the recipient's $0 order is
|
|
426
|
-
// paid), or 'refunded' (the purchase was refunded before the claim).
|
|
427
|
-
status: v.string(),
|
|
428
|
-
// Before 0.2: the provider customer keyed by the recipient's email,
|
|
429
|
-
// which the purchase was billed to. Gifts are billed to the purchaser now.
|
|
430
|
-
billingCustomerId: v.optional(v.string()),
|
|
431
|
-
// The purchase order, paid by the purchaser's own billing entity.
|
|
432
|
-
billingOrderId: v.optional(v.string()),
|
|
433
|
-
purchaserEntityId: v.optional(v.string()),
|
|
434
|
-
// The pack's catalog key, and the private gift product the purchaser bought.
|
|
435
|
-
pack: v.optional(v.string()),
|
|
436
|
-
giftProductId: v.optional(v.string()),
|
|
437
|
-
// What the purchase order charged, in the currency's smallest unit.
|
|
438
|
-
amount: v.optional(v.number()),
|
|
439
|
-
currency: v.optional(v.string()),
|
|
440
|
-
// The single-use 100% discount the recipient claims the pack with.
|
|
441
|
-
discountId: v.optional(v.string()),
|
|
442
|
-
// The claim checkout in flight: who opened it, for which entity. A plan
|
|
443
|
-
// pass's claim holds the gift until `claimingUntil`, while it switches the
|
|
444
|
-
// workspace at the provider.
|
|
445
|
-
claimingEntityId: v.optional(v.string()),
|
|
446
|
-
claimingUserId: v.optional(v.string()),
|
|
447
|
-
claimingUntil: v.optional(v.number()),
|
|
448
|
-
// The purchaser's cancellation in flight, until then: no claim starts meanwhile.
|
|
449
|
-
cancelingUntil: v.optional(v.number()),
|
|
450
|
-
claimOrderId: v.optional(v.string()),
|
|
451
|
-
claimedByUserId: v.optional(v.string()),
|
|
452
|
-
// The entity the credits landed on: workspace id or user id.
|
|
453
|
-
claimedEntityId: v.optional(v.string()),
|
|
454
|
-
createdAt: v.number(),
|
|
455
|
-
paidAt: v.optional(v.number()),
|
|
456
|
-
notifiedAt: v.optional(v.number()),
|
|
457
|
-
claimedAt: v.optional(v.number()),
|
|
458
|
-
refundedAt: v.optional(v.number()),
|
|
459
|
-
// A plan pass (the gift is a plan for `months` months, not a pack): the
|
|
460
|
-
// plan's catalog key and the length the purchaser paid for.
|
|
461
|
-
plan: v.optional(v.string()),
|
|
462
|
-
months: v.optional(v.number()),
|
|
463
|
-
// When the notice goes out: set when the purchase is paid (the moment
|
|
464
|
-
// it is paid, or the date the purchaser chose). The gift is the
|
|
465
|
-
// recipient's to see and claim once `deliveredAt` is stamped; a row
|
|
466
|
-
// with neither is a gift paid before delivery dates, delivered when paid.
|
|
467
|
-
deliverAt: v.optional(v.number()),
|
|
468
|
-
deliveredAt: v.optional(v.number()),
|
|
469
|
-
// The last notice sent (the first, a reminder or a resend), and how many.
|
|
470
|
-
noticedAt: v.optional(v.number()),
|
|
471
|
-
noticeCount: v.optional(v.number()),
|
|
472
|
-
// How many times the purchaser changed the address: each address's notices carry their own idempotency keys.
|
|
473
|
-
recipientChanges: v.optional(v.number()),
|
|
474
|
-
// The one reminder, a week after delivery.
|
|
475
|
-
remindedAt: v.optional(v.number()),
|
|
476
|
-
// A pass once claimed: the free subscription it switched, when it began
|
|
477
|
-
// and ends (the package keeps the end date), the scheduled return to the
|
|
478
|
-
// free plan, the ending notice and the end itself.
|
|
479
|
-
passSubscriptionId: v.optional(v.string()),
|
|
480
|
-
passStartedAt: v.optional(v.number()),
|
|
481
|
-
passEndsAt: v.optional(v.number()),
|
|
482
|
-
// From when the return may be booked: once the pass's last billing cycle began.
|
|
483
|
-
passReturnFrom: v.optional(v.number()),
|
|
484
|
-
passReturnScheduledAt: v.optional(v.number()),
|
|
485
|
-
passNoticedAt: v.optional(v.number()),
|
|
486
|
-
passEndedAt: v.optional(v.number()),
|
|
487
|
-
// A reverse trial (LIFECYCLE): the pass a new workspace started on,
|
|
488
|
-
// with no purchaser (`status` 'trial'). `recipientEmail` holds its
|
|
489
|
-
// owner's address with plus tags and dots taken out, so an address
|
|
490
|
-
// starts one.
|
|
491
|
-
reverseTrial: v.optional(v.boolean()),
|
|
492
|
-
// A referral reward (REF): the pass a referrer on the free plan got for
|
|
493
|
-
// free months, with no purchaser (`status` 'reward'). `rewardId` is the
|
|
494
|
-
// referral it came from; `recipientEmail` is empty.
|
|
495
|
-
rewardId: v.optional(v.string()),
|
|
496
|
-
})
|
|
473
|
+
billingGifts: defineTable(vGiftRow)
|
|
497
474
|
.index('recipientEmail', ['recipientEmail'])
|
|
498
475
|
.index('recipientEmail_status', ['recipientEmail', 'status'])
|
|
499
476
|
.index('recipientEmail_createdAt', ['recipientEmail', 'createdAt'])
|
|
@@ -540,20 +517,7 @@ export const billingTables = {
|
|
|
540
517
|
// (what it showed: the plan, the price and its interval, the terms
|
|
541
518
|
// version, who), confirmed when the subscription it started arrives, and
|
|
542
519
|
// deleted three years after. An unconfirmed row goes after two days.
|
|
543
|
-
billingRenewalConsents: defineTable(
|
|
544
|
-
checkoutId: v.string(),
|
|
545
|
-
entityId: v.string(),
|
|
546
|
-
userId: v.optional(v.string()),
|
|
547
|
-
productId: v.string(),
|
|
548
|
-
amount: v.number(),
|
|
549
|
-
currency: v.string(),
|
|
550
|
-
interval: v.string(),
|
|
551
|
-
intervalCount: v.number(),
|
|
552
|
-
termsVersion: v.optional(v.string()),
|
|
553
|
-
createdAt: v.number(),
|
|
554
|
-
subscriptionId: v.optional(v.string()),
|
|
555
|
-
consentedAt: v.optional(v.number()),
|
|
556
|
-
})
|
|
520
|
+
billingRenewalConsents: defineTable(vRenewalConsent)
|
|
557
521
|
.index('checkoutId', ['checkoutId'])
|
|
558
522
|
.index('entityId', ['entityId'])
|
|
559
523
|
.index('userId', ['userId'])
|
|
@@ -584,6 +548,44 @@ export const billingTables = {
|
|
|
584
548
|
.index('at', ['at']),
|
|
585
549
|
}
|
|
586
550
|
|
|
551
|
+
/** A metered stream's request, as the `aiRequests` table stores it. */
|
|
552
|
+
export const vAiRequest = v.object({
|
|
553
|
+
streamId: v.string(),
|
|
554
|
+
/** Which `ai.stream({ name })` definition drives this request. */
|
|
555
|
+
name: v.string(),
|
|
556
|
+
/** The billing entity (workspace/user) the credits reserve against. */
|
|
557
|
+
entityId: v.string(),
|
|
558
|
+
/** The signed-in caller (for member attribution inside workspaces). */
|
|
559
|
+
userId: v.string(),
|
|
560
|
+
/** JSON-encoded handler args. */
|
|
561
|
+
args: v.string(),
|
|
562
|
+
meterId: v.optional(v.string()),
|
|
563
|
+
cost: v.number(),
|
|
564
|
+
externalId: v.string(),
|
|
565
|
+
status: v.union(v.literal('reserved'), v.literal('streaming'), v.literal('settled'), v.literal('released')),
|
|
566
|
+
createdAt: v.number(),
|
|
567
|
+
})
|
|
568
|
+
|
|
569
|
+
/** A knowledge document, as the `aiDocuments` table stores it. */
|
|
570
|
+
export const vAiDocument = v.object({
|
|
571
|
+
/** The knowledge store: its embedding model and dimension. */
|
|
572
|
+
store: v.string(),
|
|
573
|
+
/** The namespace: the billing entity whose members find it, or `app`. */
|
|
574
|
+
owner: v.string(),
|
|
575
|
+
/** The member who added it; empty for the app's own. */
|
|
576
|
+
addedBy: v.string(),
|
|
577
|
+
title: v.string(),
|
|
578
|
+
key: v.optional(v.string()),
|
|
579
|
+
status: v.union(v.literal('pending'), v.literal('ready'), v.literal('failed')),
|
|
580
|
+
entryId: v.optional(v.string()),
|
|
581
|
+
characters: v.number(),
|
|
582
|
+
createdAt: v.number(),
|
|
583
|
+
remove: v.string(),
|
|
584
|
+
read: v.string(),
|
|
585
|
+
namespaces: v.optional(v.string()),
|
|
586
|
+
removeNamespace: v.optional(v.string()),
|
|
587
|
+
})
|
|
588
|
+
|
|
587
589
|
/**
|
|
588
590
|
* Metered-stream request plumbing for `setupAi().stream` — the HTTP stream
|
|
589
591
|
* endpoint can't carry Convex args, so `start` records the request (args,
|
|
@@ -595,22 +597,7 @@ export const billingTables = {
|
|
|
595
597
|
* prune.
|
|
596
598
|
*/
|
|
597
599
|
export const aiTables = {
|
|
598
|
-
aiRequests: defineTable(
|
|
599
|
-
streamId: v.string(),
|
|
600
|
-
/** Which `ai.stream({ name })` definition drives this request. */
|
|
601
|
-
name: v.string(),
|
|
602
|
-
/** The billing entity (workspace/user) the credits reserve against. */
|
|
603
|
-
entityId: v.string(),
|
|
604
|
-
/** The signed-in caller (for member attribution inside workspaces). */
|
|
605
|
-
userId: v.string(),
|
|
606
|
-
/** JSON-encoded handler args. */
|
|
607
|
-
args: v.string(),
|
|
608
|
-
meterId: v.optional(v.string()),
|
|
609
|
-
cost: v.number(),
|
|
610
|
-
externalId: v.string(),
|
|
611
|
-
status: v.union(v.literal('reserved'), v.literal('streaming'), v.literal('settled'), v.literal('released')),
|
|
612
|
-
createdAt: v.number(),
|
|
613
|
-
})
|
|
600
|
+
aiRequests: defineTable(vAiRequest)
|
|
614
601
|
.index('streamId', ['streamId'])
|
|
615
602
|
// Maintenance: finished requests past their window.
|
|
616
603
|
.index('status_createdAt', ['status', 'createdAt'])
|
|
@@ -649,24 +636,7 @@ export const aiTables = {
|
|
|
649
636
|
* `namespaces` and `removeNamespace` find its owner's namespace there
|
|
650
637
|
* and delete it, passages and all, when the owner goes.
|
|
651
638
|
*/
|
|
652
|
-
aiDocuments: defineTable(
|
|
653
|
-
/** The knowledge store: its embedding model and dimension. */
|
|
654
|
-
store: v.string(),
|
|
655
|
-
/** The namespace: the billing entity whose members find it, or `app`. */
|
|
656
|
-
owner: v.string(),
|
|
657
|
-
/** The member who added it; empty for the app's own. */
|
|
658
|
-
addedBy: v.string(),
|
|
659
|
-
title: v.string(),
|
|
660
|
-
key: v.optional(v.string()),
|
|
661
|
-
status: v.union(v.literal('pending'), v.literal('ready'), v.literal('failed')),
|
|
662
|
-
entryId: v.optional(v.string()),
|
|
663
|
-
characters: v.number(),
|
|
664
|
-
createdAt: v.number(),
|
|
665
|
-
remove: v.string(),
|
|
666
|
-
read: v.string(),
|
|
667
|
-
namespaces: v.optional(v.string()),
|
|
668
|
-
removeNamespace: v.optional(v.string()),
|
|
669
|
-
})
|
|
639
|
+
aiDocuments: defineTable(vAiDocument)
|
|
670
640
|
.index('store_owner_createdAt', ['store', 'owner', 'createdAt'])
|
|
671
641
|
.index('store_owner_key', ['store', 'owner', 'key'])
|
|
672
642
|
.index('owner', ['owner'])
|
|
@@ -737,6 +707,17 @@ export const aiTables = {
|
|
|
737
707
|
.index('by_day_and_shard', ['day', 'shard']),
|
|
738
708
|
}
|
|
739
709
|
|
|
710
|
+
/** How a webhook delivery ended, as the delivery log records it. */
|
|
711
|
+
export const vDeliveryOutcome = v.union(
|
|
712
|
+
v.literal('ok'),
|
|
713
|
+
v.literal('invalid_signature'),
|
|
714
|
+
v.literal('unknown_type'),
|
|
715
|
+
v.literal('handler_error'),
|
|
716
|
+
v.literal('duplicate'),
|
|
717
|
+
v.literal('oversized'),
|
|
718
|
+
v.literal('missing_secret'),
|
|
719
|
+
)
|
|
720
|
+
|
|
740
721
|
/**
|
|
741
722
|
* The webhook delivery log (see `webhooks.ts`) — powers redelivery dedupe and
|
|
742
723
|
* the DevTools Webhooks page, never a source of truth. A delivery whose
|
|
@@ -752,15 +733,7 @@ export const webhookTables = {
|
|
|
752
733
|
type: v.optional(v.string()),
|
|
753
734
|
// The tallied outcomes stay in the union for rows written before they
|
|
754
735
|
// were tallied; the trim ages them out with the rest.
|
|
755
|
-
outcome:
|
|
756
|
-
v.literal('ok'),
|
|
757
|
-
v.literal('invalid_signature'),
|
|
758
|
-
v.literal('unknown_type'),
|
|
759
|
-
v.literal('handler_error'),
|
|
760
|
-
v.literal('duplicate'),
|
|
761
|
-
v.literal('oversized'),
|
|
762
|
-
v.literal('missing_secret'),
|
|
763
|
-
),
|
|
736
|
+
outcome: vDeliveryOutcome,
|
|
764
737
|
note: v.optional(v.string()),
|
|
765
738
|
receivedAt: v.number(),
|
|
766
739
|
/** When an administrator last asked the provider to send this delivery again (`replayWebhookDelivery`). */
|
|
@@ -1202,6 +1175,12 @@ export const storageTables = {
|
|
|
1202
1175
|
.index('sharedBy', ['sharedBy']),
|
|
1203
1176
|
}
|
|
1204
1177
|
|
|
1178
|
+
/** What a report decision did to the content. */
|
|
1179
|
+
export const vDecisionAction = v.union(v.literal('hidden'), v.literal('dismissed'))
|
|
1180
|
+
|
|
1181
|
+
/** What a report decision rests on: the law, or the app's terms. */
|
|
1182
|
+
export const vDecisionGround = v.union(v.literal('illegal'), v.literal('terms'))
|
|
1183
|
+
|
|
1205
1184
|
/** Why someone reported content: the one-click reasons, and the notice form's legal ones. */
|
|
1206
1185
|
export const vReportReason = v.union(
|
|
1207
1186
|
v.literal('abuse'),
|
|
@@ -1289,11 +1268,11 @@ export const reportTables = {
|
|
|
1289
1268
|
subject: v.optional(v.id('reportSubjects')),
|
|
1290
1269
|
/** The notice decided, for one the app could not place. */
|
|
1291
1270
|
notice: v.optional(v.id('reports')),
|
|
1292
|
-
action:
|
|
1271
|
+
action: vDecisionAction,
|
|
1293
1272
|
/** The facts and the term or law it rests on, as the administrator wrote them. */
|
|
1294
1273
|
reason: v.string(),
|
|
1295
1274
|
/** Whether the content broke the law or the app's terms. */
|
|
1296
|
-
ground:
|
|
1275
|
+
ground: vDecisionGround,
|
|
1297
1276
|
/** The administrator who decided. */
|
|
1298
1277
|
by: v.string(),
|
|
1299
1278
|
at: v.number(),
|
|
@@ -1498,6 +1477,24 @@ export const monitoringTables = {
|
|
|
1498
1477
|
.index('by_at', ['at']),
|
|
1499
1478
|
}
|
|
1500
1479
|
|
|
1480
|
+
/** A consent decision, as the `consents` table stores it. */
|
|
1481
|
+
export const vConsent = v.object({
|
|
1482
|
+
userId: v.optional(v.string()),
|
|
1483
|
+
/** SHA-256 of the lower-cased address, for a decision given before the account existed. */
|
|
1484
|
+
emailHash: v.optional(v.string()),
|
|
1485
|
+
kind: v.string(),
|
|
1486
|
+
version: v.string(),
|
|
1487
|
+
/** `true` a grant, `false` a withdrawal. */
|
|
1488
|
+
granted: v.boolean(),
|
|
1489
|
+
at: v.number(),
|
|
1490
|
+
/** Where it came from: `sign-up`, `prompt`, `settings`, `waitlist` or `topic`. */
|
|
1491
|
+
source: v.string(),
|
|
1492
|
+
/** The words the person agreed to, when the form showed its own (the launch-news box). */
|
|
1493
|
+
text: v.optional(v.string()),
|
|
1494
|
+
/** What the decision came with: `checkout:<id>` for a topic's soft opt-in at checkout. */
|
|
1495
|
+
reference: v.optional(v.string()),
|
|
1496
|
+
})
|
|
1497
|
+
|
|
1501
1498
|
/**
|
|
1502
1499
|
* The consent ledger (see `consents.ts`): one row per decision, a grant or a
|
|
1503
1500
|
* withdrawal, of one kind at one version, never overwritten, so the history
|
|
@@ -1506,22 +1503,7 @@ export const monitoringTables = {
|
|
|
1506
1503
|
* signs up.
|
|
1507
1504
|
*/
|
|
1508
1505
|
export const consentTables = {
|
|
1509
|
-
consents: defineTable(
|
|
1510
|
-
userId: v.optional(v.string()),
|
|
1511
|
-
/** SHA-256 of the lower-cased address, for a decision given before the account existed. */
|
|
1512
|
-
emailHash: v.optional(v.string()),
|
|
1513
|
-
kind: v.string(),
|
|
1514
|
-
version: v.string(),
|
|
1515
|
-
/** `true` a grant, `false` a withdrawal. */
|
|
1516
|
-
granted: v.boolean(),
|
|
1517
|
-
at: v.number(),
|
|
1518
|
-
/** Where it came from: `sign-up`, `prompt`, `settings`, `waitlist` or `topic`. */
|
|
1519
|
-
source: v.string(),
|
|
1520
|
-
/** The words the person agreed to, when the form showed its own (the launch-news box). */
|
|
1521
|
-
text: v.optional(v.string()),
|
|
1522
|
-
/** What the decision came with: `checkout:<id>` for a topic's soft opt-in at checkout. */
|
|
1523
|
-
reference: v.optional(v.string()),
|
|
1524
|
-
})
|
|
1506
|
+
consents: defineTable(vConsent)
|
|
1525
1507
|
.index('userId_kind_at', ['userId', 'kind', 'at'])
|
|
1526
1508
|
.index('userId_at', ['userId', 'at'])
|
|
1527
1509
|
.index('emailHash_at', ['emailHash', 'at']),
|