@antelopejs/dms-saas 0.0.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/LICENSE +190 -0
- package/README.md +658 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +20 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth-entry.d.ts +5 -0
- package/dist/auth/oauth-entry.js +10 -0
- package/dist/auth/oauth-entry.js.map +1 -0
- package/dist/auth/plan-permissions-resolver.d.ts +1 -0
- package/dist/auth/plan-permissions-resolver.js +44 -0
- package/dist/auth/plan-permissions-resolver.js.map +1 -0
- package/dist/auth/subscription-access-gate.d.ts +8 -0
- package/dist/auth/subscription-access-gate.js +38 -0
- package/dist/auth/subscription-access-gate.js.map +1 -0
- package/dist/automation/index.d.ts +44 -0
- package/dist/automation/index.js +209 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/billing-state/index.d.ts +5 -0
- package/dist/billing-state/index.js +58 -0
- package/dist/billing-state/index.js.map +1 -0
- package/dist/billing-state/recovery.d.ts +22 -0
- package/dist/billing-state/recovery.js +81 -0
- package/dist/billing-state/recovery.js.map +1 -0
- package/dist/config/dev-mode.d.ts +3 -0
- package/dist/config/dev-mode.js +27 -0
- package/dist/config/dev-mode.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +19 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/runtime.d.ts +6 -0
- package/dist/config/runtime.js +54 -0
- package/dist/config/runtime.js.map +1 -0
- package/dist/crons/auto-suspend-past-due.d.ts +2 -0
- package/dist/crons/auto-suspend-past-due.js +43 -0
- package/dist/crons/auto-suspend-past-due.js.map +1 -0
- package/dist/crons/cleanup-stripe-webhook-events.d.ts +2 -0
- package/dist/crons/cleanup-stripe-webhook-events.js +27 -0
- package/dist/crons/cleanup-stripe-webhook-events.js.map +1 -0
- package/dist/crons/expire-free-workspaces.d.ts +2 -0
- package/dist/crons/expire-free-workspaces.js +36 -0
- package/dist/crons/expire-free-workspaces.js.map +1 -0
- package/dist/crons/hard-delete-cancelled.d.ts +2 -0
- package/dist/crons/hard-delete-cancelled.js +55 -0
- package/dist/crons/hard-delete-cancelled.js.map +1 -0
- package/dist/crons/index.d.ts +8 -0
- package/dist/crons/index.js +25 -0
- package/dist/crons/index.js.map +1 -0
- package/dist/crons/notify-free-workspaces-ending-soon.d.ts +2 -0
- package/dist/crons/notify-free-workspaces-ending-soon.js +69 -0
- package/dist/crons/notify-free-workspaces-ending-soon.js.map +1 -0
- package/dist/crons/recompute-billing-state.d.ts +2 -0
- package/dist/crons/recompute-billing-state.js +19 -0
- package/dist/crons/recompute-billing-state.js.map +1 -0
- package/dist/crons/recompute-segments.d.ts +2 -0
- package/dist/crons/recompute-segments.js +19 -0
- package/dist/crons/recompute-segments.js.map +1 -0
- package/dist/crons/reconcile-workspace-lifecycle.d.ts +2 -0
- package/dist/crons/reconcile-workspace-lifecycle.js +19 -0
- package/dist/crons/reconcile-workspace-lifecycle.js.map +1 -0
- package/dist/crons/register.d.ts +2 -0
- package/dist/crons/register.js +24 -0
- package/dist/crons/register.js.map +1 -0
- package/dist/crons/subscription-notifications.d.ts +2 -0
- package/dist/crons/subscription-notifications.js +55 -0
- package/dist/crons/subscription-notifications.js.map +1 -0
- package/dist/data-api/index.d.ts +2 -0
- package/dist/data-api/index.js +19 -0
- package/dist/data-api/index.js.map +1 -0
- package/dist/data-api/platformOwner/admin-user-invoices.d.ts +27 -0
- package/dist/data-api/platformOwner/admin-user-invoices.js +158 -0
- package/dist/data-api/platformOwner/admin-user-invoices.js.map +1 -0
- package/dist/data-api/platformOwner/admin-user-workspaces.d.ts +22 -0
- package/dist/data-api/platformOwner/admin-user-workspaces.js +97 -0
- package/dist/data-api/platformOwner/admin-user-workspaces.js.map +1 -0
- package/dist/data-api/platformOwner/credit-notes.d.ts +24 -0
- package/dist/data-api/platformOwner/credit-notes.js +133 -0
- package/dist/data-api/platformOwner/credit-notes.js.map +1 -0
- package/dist/data-api/platformOwner/features.d.ts +30 -0
- package/dist/data-api/platformOwner/features.js +141 -0
- package/dist/data-api/platformOwner/features.js.map +1 -0
- package/dist/data-api/platformOwner/hidden-filter.d.ts +1 -0
- package/dist/data-api/platformOwner/hidden-filter.js +18 -0
- package/dist/data-api/platformOwner/hidden-filter.js.map +1 -0
- package/dist/data-api/platformOwner/index.d.ts +12 -0
- package/dist/data-api/platformOwner/index.js +29 -0
- package/dist/data-api/platformOwner/index.js.map +1 -0
- package/dist/data-api/platformOwner/invoice-options.d.ts +7 -0
- package/dist/data-api/platformOwner/invoice-options.js +14 -0
- package/dist/data-api/platformOwner/invoice-options.js.map +1 -0
- package/dist/data-api/platformOwner/invoices.d.ts +26 -0
- package/dist/data-api/platformOwner/invoices.js +147 -0
- package/dist/data-api/platformOwner/invoices.js.map +1 -0
- package/dist/data-api/platformOwner/members.d.ts +24 -0
- package/dist/data-api/platformOwner/members.js +125 -0
- package/dist/data-api/platformOwner/members.js.map +1 -0
- package/dist/data-api/platformOwner/plan-migrations.d.ts +24 -0
- package/dist/data-api/platformOwner/plan-migrations.js +138 -0
- package/dist/data-api/platformOwner/plan-migrations.js.map +1 -0
- package/dist/data-api/platformOwner/plans.d.ts +30 -0
- package/dist/data-api/platformOwner/plans.js +228 -0
- package/dist/data-api/platformOwner/plans.js.map +1 -0
- package/dist/data-api/platformOwner/segments.d.ts +29 -0
- package/dist/data-api/platformOwner/segments.js +223 -0
- package/dist/data-api/platformOwner/segments.js.map +1 -0
- package/dist/data-api/platformOwner/support.d.ts +58 -0
- package/dist/data-api/platformOwner/support.js +111 -0
- package/dist/data-api/platformOwner/support.js.map +1 -0
- package/dist/data-api/platformOwner/users.d.ts +22 -0
- package/dist/data-api/platformOwner/users.js +128 -0
- package/dist/data-api/platformOwner/users.js.map +1 -0
- package/dist/data-api/platformOwner/workspaces.d.ts +22 -0
- package/dist/data-api/platformOwner/workspaces.js +153 -0
- package/dist/data-api/platformOwner/workspaces.js.map +1 -0
- package/dist/data-api/support-fields.d.ts +49 -0
- package/dist/data-api/support-fields.js +166 -0
- package/dist/data-api/support-fields.js.map +1 -0
- package/dist/data-api/support-routes.d.ts +10 -0
- package/dist/data-api/support-routes.js +71 -0
- package/dist/data-api/support-routes.js.map +1 -0
- package/dist/data-api/tenant/index.d.ts +2 -0
- package/dist/data-api/tenant/index.js +19 -0
- package/dist/data-api/tenant/index.js.map +1 -0
- package/dist/data-api/tenant/support.d.ts +39 -0
- package/dist/data-api/tenant/support.js +53 -0
- package/dist/data-api/tenant/support.js.map +1 -0
- package/dist/data-api/tenant/tenant-invoices.d.ts +37 -0
- package/dist/data-api/tenant/tenant-invoices.js +242 -0
- package/dist/data-api/tenant/tenant-invoices.js.map +1 -0
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +18 -0
- package/dist/db/index.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +20 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/register.d.ts +1 -0
- package/dist/hooks/register.js +57 -0
- package/dist/hooks/register.js.map +1 -0
- package/dist/hooks/tenant-export.d.ts +2 -0
- package/dist/hooks/tenant-export.js +64 -0
- package/dist/hooks/tenant-export.js.map +1 -0
- package/dist/hooks/tenant-provisioning.d.ts +3 -0
- package/dist/hooks/tenant-provisioning.js +12 -0
- package/dist/hooks/tenant-provisioning.js.map +1 -0
- package/dist/implementations/dms-saas/billing.d.ts +2 -0
- package/dist/implementations/dms-saas/billing.js +49 -0
- package/dist/implementations/dms-saas/billing.js.map +1 -0
- package/dist/implementations/dms-saas/invoice-line-items.d.ts +11 -0
- package/dist/implementations/dms-saas/invoice-line-items.js +24 -0
- package/dist/implementations/dms-saas/invoice-line-items.js.map +1 -0
- package/dist/implementations/dms-saas/pages.d.ts +3 -0
- package/dist/implementations/dms-saas/pages.js +12 -0
- package/dist/implementations/dms-saas/pages.js.map +1 -0
- package/dist/implementations/dms-saas/workspace-lifecycle.d.ts +2 -0
- package/dist/implementations/dms-saas/workspace-lifecycle.js +23 -0
- package/dist/implementations/dms-saas/workspace-lifecycle.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/invoice-line-items/billing-window.d.ts +3 -0
- package/dist/invoice-line-items/billing-window.js +19 -0
- package/dist/invoice-line-items/billing-window.js.map +1 -0
- package/dist/invoice-line-items/index.d.ts +1 -0
- package/dist/invoice-line-items/index.js +18 -0
- package/dist/invoice-line-items/index.js.map +1 -0
- package/dist/invoice-line-items/injection.d.ts +2 -0
- package/dist/invoice-line-items/injection.js +171 -0
- package/dist/invoice-line-items/injection.js.map +1 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +19 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/recipients.d.ts +14 -0
- package/dist/notifications/recipients.js +87 -0
- package/dist/notifications/recipients.js.map +1 -0
- package/dist/notifications/subjects.d.ts +21 -0
- package/dist/notifications/subjects.js +121 -0
- package/dist/notifications/subjects.js.map +1 -0
- package/dist/operator-actions/commands.d.ts +41 -0
- package/dist/operator-actions/commands.js +233 -0
- package/dist/operator-actions/commands.js.map +1 -0
- package/dist/operator-actions/db/index.d.ts +4 -0
- package/dist/operator-actions/db/index.js +21 -0
- package/dist/operator-actions/db/index.js.map +1 -0
- package/dist/operator-actions/db/lifecycle-delivery.model.d.ts +29 -0
- package/dist/operator-actions/db/lifecycle-delivery.model.js +85 -0
- package/dist/operator-actions/db/lifecycle-delivery.model.js.map +1 -0
- package/dist/operator-actions/db/lifecycle-delivery.table.d.ts +26 -0
- package/dist/operator-actions/db/lifecycle-delivery.table.js +107 -0
- package/dist/operator-actions/db/lifecycle-delivery.table.js.map +1 -0
- package/dist/operator-actions/db/operator-action.model.d.ts +33 -0
- package/dist/operator-actions/db/operator-action.model.js +63 -0
- package/dist/operator-actions/db/operator-action.model.js.map +1 -0
- package/dist/operator-actions/db/operator-action.table.d.ts +21 -0
- package/dist/operator-actions/db/operator-action.table.js +95 -0
- package/dist/operator-actions/db/operator-action.table.js.map +1 -0
- package/dist/operator-actions/index.d.ts +3 -0
- package/dist/operator-actions/index.js +20 -0
- package/dist/operator-actions/index.js.map +1 -0
- package/dist/operator-actions/journal.d.ts +22 -0
- package/dist/operator-actions/journal.js +183 -0
- package/dist/operator-actions/journal.js.map +1 -0
- package/dist/operator-actions/lifecycle-consumers.d.ts +12 -0
- package/dist/operator-actions/lifecycle-consumers.js +28 -0
- package/dist/operator-actions/lifecycle-consumers.js.map +1 -0
- package/dist/operator-actions/lifecycle-outbox.d.ts +19 -0
- package/dist/operator-actions/lifecycle-outbox.js +229 -0
- package/dist/operator-actions/lifecycle-outbox.js.map +1 -0
- package/dist/operator-actions/types.d.ts +11 -0
- package/dist/operator-actions/types.js +3 -0
- package/dist/operator-actions/types.js.map +1 -0
- package/dist/pages/definitions.d.ts +1 -0
- package/dist/pages/definitions.js +18 -0
- package/dist/pages/definitions.js.map +1 -0
- package/dist/pages/index.d.ts +4 -0
- package/dist/pages/index.js +21 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/module.d.ts +5 -0
- package/dist/pages/module.js +15 -0
- package/dist/pages/module.js.map +1 -0
- package/dist/pages/platform/categories.d.ts +6 -0
- package/dist/pages/platform/categories.js +48 -0
- package/dist/pages/platform/categories.js.map +1 -0
- package/dist/pages/platform/credit-notes.d.ts +9 -0
- package/dist/pages/platform/credit-notes.js +40 -0
- package/dist/pages/platform/credit-notes.js.map +1 -0
- package/dist/pages/platform/dashboard.d.ts +10 -0
- package/dist/pages/platform/dashboard.js +95 -0
- package/dist/pages/platform/dashboard.js.map +1 -0
- package/dist/pages/platform/features.d.ts +9 -0
- package/dist/pages/platform/features.js +42 -0
- package/dist/pages/platform/features.js.map +1 -0
- package/dist/pages/platform/index.d.ts +15 -0
- package/dist/pages/platform/index.js +32 -0
- package/dist/pages/platform/index.js.map +1 -0
- package/dist/pages/platform/invoices.d.ts +9 -0
- package/dist/pages/platform/invoices.js +63 -0
- package/dist/pages/platform/invoices.js.map +1 -0
- package/dist/pages/platform/plans/edit.d.ts +17 -0
- package/dist/pages/platform/plans/edit.js +213 -0
- package/dist/pages/platform/plans/edit.js.map +1 -0
- package/dist/pages/platform/plans/index.d.ts +9 -0
- package/dist/pages/platform/plans/index.js +99 -0
- package/dist/pages/platform/plans/index.js.map +1 -0
- package/dist/pages/platform/plans/migrations.d.ts +9 -0
- package/dist/pages/platform/plans/migrations.js +38 -0
- package/dist/pages/platform/plans/migrations.js.map +1 -0
- package/dist/pages/platform/segments/index.d.ts +9 -0
- package/dist/pages/platform/segments/index.js +59 -0
- package/dist/pages/platform/segments/index.js.map +1 -0
- package/dist/pages/platform/settings.d.ts +9 -0
- package/dist/pages/platform/settings.js +147 -0
- package/dist/pages/platform/settings.js.map +1 -0
- package/dist/pages/platform/support.d.ts +9 -0
- package/dist/pages/platform/support.js +29 -0
- package/dist/pages/platform/support.js.map +1 -0
- package/dist/pages/platform/users/detail.d.ts +9 -0
- package/dist/pages/platform/users/detail.js +78 -0
- package/dist/pages/platform/users/detail.js.map +1 -0
- package/dist/pages/platform/users/index.d.ts +9 -0
- package/dist/pages/platform/users/index.js +77 -0
- package/dist/pages/platform/users/index.js.map +1 -0
- package/dist/pages/platform/workspaces/detail.d.ts +9 -0
- package/dist/pages/platform/workspaces/detail.js +120 -0
- package/dist/pages/platform/workspaces/detail.js.map +1 -0
- package/dist/pages/platform/workspaces/index.d.ts +35 -0
- package/dist/pages/platform/workspaces/index.js +300 -0
- package/dist/pages/platform/workspaces/index.js.map +1 -0
- package/dist/pages/public/auth/index.d.ts +1 -0
- package/dist/pages/public/auth/index.js +18 -0
- package/dist/pages/public/auth/index.js.map +1 -0
- package/dist/pages/public/auth/no-workspace.d.ts +9 -0
- package/dist/pages/public/auth/no-workspace.js +26 -0
- package/dist/pages/public/auth/no-workspace.js.map +1 -0
- package/dist/pages/public/index.d.ts +3 -0
- package/dist/pages/public/index.js +20 -0
- package/dist/pages/public/index.js.map +1 -0
- package/dist/pages/public/legal/index.d.ts +3 -0
- package/dist/pages/public/legal/index.js +20 -0
- package/dist/pages/public/legal/index.js.map +1 -0
- package/dist/pages/public/legal/privacy-policy.d.ts +9 -0
- package/dist/pages/public/legal/privacy-policy.js +29 -0
- package/dist/pages/public/legal/privacy-policy.js.map +1 -0
- package/dist/pages/public/legal/terms-and-conditions.d.ts +9 -0
- package/dist/pages/public/legal/terms-and-conditions.js +29 -0
- package/dist/pages/public/legal/terms-and-conditions.js.map +1 -0
- package/dist/pages/public/legal/terms-of-use.d.ts +9 -0
- package/dist/pages/public/legal/terms-of-use.js +29 -0
- package/dist/pages/public/legal/terms-of-use.js.map +1 -0
- package/dist/pages/public/register.d.ts +9 -0
- package/dist/pages/public/register.js +29 -0
- package/dist/pages/public/register.js.map +1 -0
- package/dist/pages/public/screens.d.ts +3 -0
- package/dist/pages/public/screens.js +50 -0
- package/dist/pages/public/screens.js.map +1 -0
- package/dist/pages/tenant/billing.d.ts +15 -0
- package/dist/pages/tenant/billing.js +87 -0
- package/dist/pages/tenant/billing.js.map +1 -0
- package/dist/pages/tenant/data-export.d.ts +10 -0
- package/dist/pages/tenant/data-export.js +32 -0
- package/dist/pages/tenant/data-export.js.map +1 -0
- package/dist/pages/tenant/general.d.ts +10 -0
- package/dist/pages/tenant/general.js +33 -0
- package/dist/pages/tenant/general.js.map +1 -0
- package/dist/pages/tenant/index.d.ts +6 -0
- package/dist/pages/tenant/index.js +23 -0
- package/dist/pages/tenant/index.js.map +1 -0
- package/dist/pages/tenant/members-seat-quota.d.ts +3 -0
- package/dist/pages/tenant/members-seat-quota.js +25 -0
- package/dist/pages/tenant/members-seat-quota.js.map +1 -0
- package/dist/pages/tenant/support.d.ts +9 -0
- package/dist/pages/tenant/support.js +27 -0
- package/dist/pages/tenant/support.js.map +1 -0
- package/dist/pages/tenant/workspace-suspended.d.ts +9 -0
- package/dist/pages/tenant/workspace-suspended.js +26 -0
- package/dist/pages/tenant/workspace-suspended.js.map +1 -0
- package/dist/plan-changes/deferred.d.ts +18 -0
- package/dist/plan-changes/deferred.js +225 -0
- package/dist/plan-changes/deferred.js.map +1 -0
- package/dist/plan-changes/index.d.ts +1 -0
- package/dist/plan-changes/index.js +18 -0
- package/dist/plan-changes/index.js.map +1 -0
- package/dist/plans/index.d.ts +4 -0
- package/dist/plans/index.js +21 -0
- package/dist/plans/index.js.map +1 -0
- package/dist/plans/seat-capacity.d.ts +9 -0
- package/dist/plans/seat-capacity.js +38 -0
- package/dist/plans/seat-capacity.js.map +1 -0
- package/dist/plans/seat-hooks.d.ts +1 -0
- package/dist/plans/seat-hooks.js +80 -0
- package/dist/plans/seat-hooks.js.map +1 -0
- package/dist/plans/seat-sync.d.ts +10 -0
- package/dist/plans/seat-sync.js +23 -0
- package/dist/plans/seat-sync.js.map +1 -0
- package/dist/routes/index.d.ts +3 -0
- package/dist/routes/index.js +20 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/platformOwner/billing-settings.d.ts +20 -0
- package/dist/routes/platformOwner/billing-settings.js +98 -0
- package/dist/routes/platformOwner/billing-settings.js.map +1 -0
- package/dist/routes/platformOwner/credit-notes-issue.d.ts +16 -0
- package/dist/routes/platformOwner/credit-notes-issue.js +56 -0
- package/dist/routes/platformOwner/credit-notes-issue.js.map +1 -0
- package/dist/routes/platformOwner/dashboard.d.ts +62 -0
- package/dist/routes/platformOwner/dashboard.js +310 -0
- package/dist/routes/platformOwner/dashboard.js.map +1 -0
- package/dist/routes/platformOwner/index.d.ts +12 -0
- package/dist/routes/platformOwner/index.js +29 -0
- package/dist/routes/platformOwner/index.js.map +1 -0
- package/dist/routes/platformOwner/plan-deletion.d.ts +30 -0
- package/dist/routes/platformOwner/plan-deletion.js +156 -0
- package/dist/routes/platformOwner/plan-deletion.js.map +1 -0
- package/dist/routes/platformOwner/plans.d.ts +99 -0
- package/dist/routes/platformOwner/plans.js +376 -0
- package/dist/routes/platformOwner/plans.js.map +1 -0
- package/dist/routes/platformOwner/platform-notes.d.ts +36 -0
- package/dist/routes/platformOwner/platform-notes.js +149 -0
- package/dist/routes/platformOwner/platform-notes.js.map +1 -0
- package/dist/routes/platformOwner/platform-owners.d.ts +12 -0
- package/dist/routes/platformOwner/platform-owners.js +77 -0
- package/dist/routes/platformOwner/platform-owners.js.map +1 -0
- package/dist/routes/platformOwner/segments.d.ts +24 -0
- package/dist/routes/platformOwner/segments.js +174 -0
- package/dist/routes/platformOwner/segments.js.map +1 -0
- package/dist/routes/platformOwner/support.d.ts +21 -0
- package/dist/routes/platformOwner/support.js +180 -0
- package/dist/routes/platformOwner/support.js.map +1 -0
- package/dist/routes/platformOwner/users-detail.d.ts +26 -0
- package/dist/routes/platformOwner/users-detail.js +82 -0
- package/dist/routes/platformOwner/users-detail.js.map +1 -0
- package/dist/routes/platformOwner/workspace-operator-actions.d.ts +34 -0
- package/dist/routes/platformOwner/workspace-operator-actions.js +183 -0
- package/dist/routes/platformOwner/workspace-operator-actions.js.map +1 -0
- package/dist/routes/platformOwner/workspaces-admin.d.ts +27 -0
- package/dist/routes/platformOwner/workspaces-admin.js +140 -0
- package/dist/routes/platformOwner/workspaces-admin.js.map +1 -0
- package/dist/routes/public/index.d.ts +3 -0
- package/dist/routes/public/index.js +20 -0
- package/dist/routes/public/index.js.map +1 -0
- package/dist/routes/public/legal-documents.d.ts +15 -0
- package/dist/routes/public/legal-documents.js +72 -0
- package/dist/routes/public/legal-documents.js.map +1 -0
- package/dist/routes/public/register.d.ts +48 -0
- package/dist/routes/public/register.js +193 -0
- package/dist/routes/public/register.js.map +1 -0
- package/dist/routes/public/webhooks/index.d.ts +1 -0
- package/dist/routes/public/webhooks/index.js +18 -0
- package/dist/routes/public/webhooks/index.js.map +1 -0
- package/dist/routes/public/webhooks/stripe.d.ts +7 -0
- package/dist/routes/public/webhooks/stripe.js +41 -0
- package/dist/routes/public/webhooks/stripe.js.map +1 -0
- package/dist/routes/tenant/billing-portal.d.ts +31 -0
- package/dist/routes/tenant/billing-portal.js +117 -0
- package/dist/routes/tenant/billing-portal.js.map +1 -0
- package/dist/routes/tenant/billing-self-refund.d.ts +18 -0
- package/dist/routes/tenant/billing-self-refund.js +199 -0
- package/dist/routes/tenant/billing-self-refund.js.map +1 -0
- package/dist/routes/tenant/data-export.d.ts +16 -0
- package/dist/routes/tenant/data-export.js +102 -0
- package/dist/routes/tenant/data-export.js.map +1 -0
- package/dist/routes/tenant/index.d.ts +9 -0
- package/dist/routes/tenant/index.js +26 -0
- package/dist/routes/tenant/index.js.map +1 -0
- package/dist/routes/tenant/support.d.ts +27 -0
- package/dist/routes/tenant/support.js +185 -0
- package/dist/routes/tenant/support.js.map +1 -0
- package/dist/routes/tenant/tenant-billing.d.ts +26 -0
- package/dist/routes/tenant/tenant-billing.js +148 -0
- package/dist/routes/tenant/tenant-billing.js.map +1 -0
- package/dist/routes/tenant/tenant-plan-ops.d.ts +57 -0
- package/dist/routes/tenant/tenant-plan-ops.js +244 -0
- package/dist/routes/tenant/tenant-plan-ops.js.map +1 -0
- package/dist/routes/tenant/tenant-plan.d.ts +19 -0
- package/dist/routes/tenant/tenant-plan.js +172 -0
- package/dist/routes/tenant/tenant-plan.js.map +1 -0
- package/dist/routes/tenant/tenant-seats.d.ts +17 -0
- package/dist/routes/tenant/tenant-seats.js +58 -0
- package/dist/routes/tenant/tenant-seats.js.map +1 -0
- package/dist/routes/tenant/workspaces.d.ts +78 -0
- package/dist/routes/tenant/workspaces.js +301 -0
- package/dist/routes/tenant/workspaces.js.map +1 -0
- package/dist/stripe/client.d.ts +6 -0
- package/dist/stripe/client.js +44 -0
- package/dist/stripe/client.js.map +1 -0
- package/dist/stripe/customer-balance.d.ts +12 -0
- package/dist/stripe/customer-balance.js +16 -0
- package/dist/stripe/customer-balance.js.map +1 -0
- package/dist/stripe/customer-billing.d.ts +33 -0
- package/dist/stripe/customer-billing.js +140 -0
- package/dist/stripe/customer-billing.js.map +1 -0
- package/dist/stripe/index.d.ts +11 -0
- package/dist/stripe/index.js +28 -0
- package/dist/stripe/index.js.map +1 -0
- package/dist/stripe/plan-schedule.d.ts +9 -0
- package/dist/stripe/plan-schedule.js +83 -0
- package/dist/stripe/plan-schedule.js.map +1 -0
- package/dist/stripe/proration.d.ts +2 -0
- package/dist/stripe/proration.js +19 -0
- package/dist/stripe/proration.js.map +1 -0
- package/dist/stripe/sync-plan.d.ts +2 -0
- package/dist/stripe/sync-plan.js +66 -0
- package/dist/stripe/sync-plan.js.map +1 -0
- package/dist/stripe/webhook-checkout.d.ts +3 -0
- package/dist/stripe/webhook-checkout.js +157 -0
- package/dist/stripe/webhook-checkout.js.map +1 -0
- package/dist/stripe/webhook-credit-notes.d.ts +3 -0
- package/dist/stripe/webhook-credit-notes.js +192 -0
- package/dist/stripe/webhook-credit-notes.js.map +1 -0
- package/dist/stripe/webhook-dispatch.d.ts +2 -0
- package/dist/stripe/webhook-dispatch.js +45 -0
- package/dist/stripe/webhook-dispatch.js.map +1 -0
- package/dist/stripe/webhook-handlers.d.ts +11 -0
- package/dist/stripe/webhook-handlers.js +318 -0
- package/dist/stripe/webhook-handlers.js.map +1 -0
- package/dist/stripe/webhook-shared.d.ts +28 -0
- package/dist/stripe/webhook-shared.js +126 -0
- package/dist/stripe/webhook-shared.js.map +1 -0
- package/dist/stripe/workspace-checkout.d.ts +29 -0
- package/dist/stripe/workspace-checkout.js +106 -0
- package/dist/stripe/workspace-checkout.js.map +1 -0
- package/dist/support/admissions.d.ts +36 -0
- package/dist/support/admissions.js +136 -0
- package/dist/support/admissions.js.map +1 -0
- package/dist/support/attachments.d.ts +12 -0
- package/dist/support/attachments.js +56 -0
- package/dist/support/attachments.js.map +1 -0
- package/dist/support/config.d.ts +19 -0
- package/dist/support/config.js +75 -0
- package/dist/support/config.js.map +1 -0
- package/dist/support/index.d.ts +6 -0
- package/dist/support/index.js +23 -0
- package/dist/support/index.js.map +1 -0
- package/dist/support/operations.d.ts +51 -0
- package/dist/support/operations.js +109 -0
- package/dist/support/operations.js.map +1 -0
- package/dist/support/plans.d.ts +6 -0
- package/dist/support/plans.js +130 -0
- package/dist/support/plans.js.map +1 -0
- package/dist/support/publications.d.ts +8 -0
- package/dist/support/publications.js +106 -0
- package/dist/support/publications.js.map +1 -0
- package/dist/support/recovery.d.ts +7 -0
- package/dist/support/recovery.js +43 -0
- package/dist/support/recovery.js.map +1 -0
- package/dist/support/service.d.ts +51 -0
- package/dist/support/service.js +143 -0
- package/dist/support/service.js.map +1 -0
- package/dist/support/transitions.d.ts +4 -0
- package/dist/support/transitions.js +29 -0
- package/dist/support/transitions.js.map +1 -0
- package/dist/support/uploads.d.ts +39 -0
- package/dist/support/uploads.js +115 -0
- package/dist/support/uploads.js.map +1 -0
- package/dist/support/validation.d.ts +15 -0
- package/dist/support/validation.js +54 -0
- package/dist/support/validation.js.map +1 -0
- package/dist/types/config.d.ts +16 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/billing-document-type.d.ts +3 -0
- package/dist/utils/billing-document-type.js +18 -0
- package/dist/utils/billing-document-type.js.map +1 -0
- package/dist/utils/billing-period-type.d.ts +3 -0
- package/dist/utils/billing-period-type.js +18 -0
- package/dist/utils/billing-period-type.js.map +1 -0
- package/dist/utils/email-hash.d.ts +1 -0
- package/dist/utils/email-hash.js +8 -0
- package/dist/utils/email-hash.js.map +1 -0
- package/dist/utils/export-dataset-stream.d.ts +19 -0
- package/dist/utils/export-dataset-stream.js +40 -0
- package/dist/utils/export-dataset-stream.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +32 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/invoice-lines-type.d.ts +27 -0
- package/dist/utils/invoice-lines-type.js +34 -0
- package/dist/utils/invoice-lines-type.js.map +1 -0
- package/dist/utils/money-cents-type.d.ts +3 -0
- package/dist/utils/money-cents-type.js +18 -0
- package/dist/utils/money-cents-type.js.map +1 -0
- package/dist/utils/pagination.d.ts +22 -0
- package/dist/utils/pagination.js +35 -0
- package/dist/utils/pagination.js.map +1 -0
- package/dist/utils/parse-future-date.d.ts +1 -0
- package/dist/utils/parse-future-date.js +15 -0
- package/dist/utils/parse-future-date.js.map +1 -0
- package/dist/utils/row-instance.d.ts +1 -0
- package/dist/utils/row-instance.js +8 -0
- package/dist/utils/row-instance.js.map +1 -0
- package/dist/utils/segment-conditions-type.d.ts +33 -0
- package/dist/utils/segment-conditions-type.js +86 -0
- package/dist/utils/segment-conditions-type.js.map +1 -0
- package/dist/utils/segment-evaluator.d.ts +3 -0
- package/dist/utils/segment-evaluator.js +117 -0
- package/dist/utils/segment-evaluator.js.map +1 -0
- package/dist/utils/segment-fields.d.ts +19 -0
- package/dist/utils/segment-fields.js +212 -0
- package/dist/utils/segment-fields.js.map +1 -0
- package/dist/utils/segment-matching.d.ts +56 -0
- package/dist/utils/segment-matching.js +200 -0
- package/dist/utils/segment-matching.js.map +1 -0
- package/dist/utils/segment-name-cache.d.ts +2 -0
- package/dist/utils/segment-name-cache.js +22 -0
- package/dist/utils/segment-name-cache.js.map +1 -0
- package/dist/utils/time.d.ts +3 -0
- package/dist/utils/time.js +10 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/workers/index.d.ts +1 -0
- package/dist/workers/index.js +18 -0
- package/dist/workers/index.js.map +1 -0
- package/dist/workers/plan-migration.d.ts +4 -0
- package/dist/workers/plan-migration.js +206 -0
- package/dist/workers/plan-migration.js.map +1 -0
- package/dist/workspaces/billing-profile.d.ts +3 -0
- package/dist/workspaces/billing-profile.js +55 -0
- package/dist/workspaces/billing-profile.js.map +1 -0
- package/dist/workspaces/complimentary.d.ts +7 -0
- package/dist/workspaces/complimentary.js +47 -0
- package/dist/workspaces/complimentary.js.map +1 -0
- package/dist/workspaces/db/card-capacity.model.d.ts +30 -0
- package/dist/workspaces/db/card-capacity.model.js +98 -0
- package/dist/workspaces/db/card-capacity.model.js.map +1 -0
- package/dist/workspaces/db/card-capacity.table.d.ts +11 -0
- package/dist/workspaces/db/card-capacity.table.js +34 -0
- package/dist/workspaces/db/card-capacity.table.js.map +1 -0
- package/dist/workspaces/db/provisioning-attempt.model.d.ts +24 -0
- package/dist/workspaces/db/provisioning-attempt.model.js +33 -0
- package/dist/workspaces/db/provisioning-attempt.model.js.map +1 -0
- package/dist/workspaces/db/provisioning-attempt.table.d.ts +18 -0
- package/dist/workspaces/db/provisioning-attempt.table.js +77 -0
- package/dist/workspaces/db/provisioning-attempt.table.js.map +1 -0
- package/dist/workspaces/db/trial-identity.model.d.ts +25 -0
- package/dist/workspaces/db/trial-identity.model.js +62 -0
- package/dist/workspaces/db/trial-identity.model.js.map +1 -0
- package/dist/workspaces/db/trial-identity.table.d.ts +7 -0
- package/dist/workspaces/db/trial-identity.table.js +34 -0
- package/dist/workspaces/db/trial-identity.table.js.map +1 -0
- package/dist/workspaces/deletion.d.ts +8 -0
- package/dist/workspaces/deletion.js +75 -0
- package/dist/workspaces/deletion.js.map +1 -0
- package/dist/workspaces/free-workspace-guard.d.ts +11 -0
- package/dist/workspaces/free-workspace-guard.js +96 -0
- package/dist/workspaces/free-workspace-guard.js.map +1 -0
- package/dist/workspaces/index.d.ts +6 -0
- package/dist/workspaces/index.js +23 -0
- package/dist/workspaces/index.js.map +1 -0
- package/dist/workspaces/provisioning-rollback.d.ts +2 -0
- package/dist/workspaces/provisioning-rollback.js +78 -0
- package/dist/workspaces/provisioning-rollback.js.map +1 -0
- package/dist/workspaces/provisioning-state.d.ts +6 -0
- package/dist/workspaces/provisioning-state.js +91 -0
- package/dist/workspaces/provisioning-state.js.map +1 -0
- package/dist/workspaces/provisioning.d.ts +49 -0
- package/dist/workspaces/provisioning.js +263 -0
- package/dist/workspaces/provisioning.js.map +1 -0
- package/dist/workspaces/registration-extras.d.ts +1 -0
- package/dist/workspaces/registration-extras.js +50 -0
- package/dist/workspaces/registration-extras.js.map +1 -0
- package/dist/workspaces/suspension.d.ts +13 -0
- package/dist/workspaces/suspension.js +124 -0
- package/dist/workspaces/suspension.js.map +1 -0
- package/frontend-vue/.editorconfig +12 -0
- package/frontend-vue/.prettierrc +11 -0
- package/frontend-vue/app/build/.gitkeep +0 -0
- package/frontend-vue/app/components/CardGrid.vue +77 -0
- package/frontend-vue/app/components/CustomerPortalButton.vue +45 -0
- package/frontend-vue/app/components/DataExport.vue +300 -0
- package/frontend-vue/app/components/DeletePlanModal.vue +223 -0
- package/frontend-vue/app/components/FreeAccessBanner.vue +70 -0
- package/frontend-vue/app/components/InvoiceLines.vue +57 -0
- package/frontend-vue/app/components/IssueCreditNoteModal.vue +128 -0
- package/frontend-vue/app/components/LegalLayout.vue +63 -0
- package/frontend-vue/app/components/LoadFailure.vue +25 -0
- package/frontend-vue/app/components/PastDueAlert.vue +96 -0
- package/frontend-vue/app/components/PaymentMethodCard.vue +86 -0
- package/frontend-vue/app/components/PlanCard.vue +294 -0
- package/frontend-vue/app/components/PlanCardPublic.vue +59 -0
- package/frontend-vue/app/components/PlanCardsDisplay.vue +127 -0
- package/frontend-vue/app/components/PlanComparisonModal.vue +213 -0
- package/frontend-vue/app/components/PlanInheritancePicker.vue +329 -0
- package/frontend-vue/app/components/PlatformNotes.vue +281 -0
- package/frontend-vue/app/components/PlatformSupport.vue +461 -0
- package/frontend-vue/app/components/RecentActivity.vue +72 -0
- package/frontend-vue/app/components/RefundButton.vue +126 -0
- package/frontend-vue/app/components/Register.vue +174 -0
- package/frontend-vue/app/components/RegistrationClosed.vue +15 -0
- package/frontend-vue/app/components/SeatQuotaBanner.vue +78 -0
- package/frontend-vue/app/components/SegmentConditionsBuilder.vue +176 -0
- package/frontend-vue/app/components/SegmentConditionsGroup.vue +494 -0
- package/frontend-vue/app/components/SupportAttachmentUpload.vue +140 -0
- package/frontend-vue/app/components/SupportThreadHistory.vue +139 -0
- package/frontend-vue/app/components/TenantBillingForm.vue +208 -0
- package/frontend-vue/app/components/TenantPlanCard.vue +223 -0
- package/frontend-vue/app/components/TenantSupport.vue +415 -0
- package/frontend-vue/app/components/UserSummaryCard.vue +166 -0
- package/frontend-vue/app/components/WorkspaceBillingInfo.vue +68 -0
- package/frontend-vue/app/components/WorkspaceCompAccessButton.vue +198 -0
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +256 -0
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +146 -0
- package/frontend-vue/app/components/WorkspaceDetailHeader.vue +24 -0
- package/frontend-vue/app/components/WorkspaceIdentity.vue +99 -0
- package/frontend-vue/app/components/WorkspaceJoinButton.vue +50 -0
- package/frontend-vue/app/components/WorkspaceOperatorActions.vue +340 -0
- package/frontend-vue/app/components/WorkspaceSummaryCard.vue +161 -0
- package/frontend-vue/app/components/WorkspaceSuspendButton.vue +167 -0
- package/frontend-vue/app/components/WorkspaceSuspended.vue +164 -0
- package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +247 -0
- package/frontend-vue/app/composables/useApiErrorMessage.ts +35 -0
- package/frontend-vue/app/composables/useBillingCountries.ts +54 -0
- package/frontend-vue/app/composables/useBillingDocumentType.ts +7 -0
- package/frontend-vue/app/composables/useBillingStatus.ts +39 -0
- package/frontend-vue/app/composables/useCurrentWorkspace.ts +43 -0
- package/frontend-vue/app/composables/useDetailRefresh.ts +17 -0
- package/frontend-vue/app/composables/useExportHistory.ts +143 -0
- package/frontend-vue/app/composables/useInvoiceLines.ts +22 -0
- package/frontend-vue/app/composables/useMoneyFormat.ts +49 -0
- package/frontend-vue/app/composables/useMyWorkspaces.ts +47 -0
- package/frontend-vue/app/composables/usePlanFeatureFormat.ts +60 -0
- package/frontend-vue/app/composables/usePlanIntervalLabel.ts +30 -0
- package/frontend-vue/app/composables/useSaasRegistration.ts +522 -0
- package/frontend-vue/app/composables/useSeatQuota.ts +18 -0
- package/frontend-vue/app/composables/useSharedRequest.ts +54 -0
- package/frontend-vue/app/composables/useStripePaymentElement.ts +74 -0
- package/frontend-vue/app/composables/useSubscriptionAccess.ts +12 -0
- package/frontend-vue/app/composables/useSupportRequest.ts +74 -0
- package/frontend-vue/app/composables/useTenantPlan.ts +95 -0
- package/frontend-vue/app/composables/useTenantSwitch.ts +22 -0
- package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +25 -0
- package/frontend-vue/app/custom-pages/auth/no-workspace.vue +495 -0
- package/frontend-vue/app/middleware/workspace-suspended.global.ts +56 -0
- package/frontend-vue/app/plugins/auth-links.ts +24 -0
- package/frontend-vue/app/plugins/billing-data-types.ts +62 -0
- package/frontend-vue/app/plugins/footer-links.ts +36 -0
- package/frontend-vue/app/plugins/plan-cards-display.client.ts +16 -0
- package/frontend-vue/app/plugins/segment-conditions-data-type.client.ts +122 -0
- package/frontend-vue/app/plugins/sidebar-widgets.ts +13 -0
- package/frontend-vue/app/types/support.ts +123 -0
- package/frontend-vue/dms.frontend.ts +68 -0
- package/frontend-vue/eslint.config.mjs +13 -0
- package/frontend-vue/i18n/locales/saas-en-GB.json +1285 -0
- package/frontend-vue/i18n/locales/saas-fr-FR.json +1285 -0
- package/frontend-vue/package.json +27 -0
- package/frontend-vue/pnpm-lock.yaml +4948 -0
- package/frontend-vue/pnpm-workspace.yaml +2 -0
- package/frontend-vue/server/routes/auth/finalize-workspace.post.ts +61 -0
- package/package.json +91 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
export declare function handleInvoiceCreated(event: Stripe.Event): Promise<void>;
|
|
3
|
+
export declare function handleInvoiceFinalized(event: Stripe.Event): Promise<void>;
|
|
4
|
+
export declare function handleInvoicePaid(event: Stripe.Event): Promise<void>;
|
|
5
|
+
export declare function handleInvoiceVoided(event: Stripe.Event): Promise<void>;
|
|
6
|
+
export declare function handleInvoicePaymentFailed(event: Stripe.Event): Promise<void>;
|
|
7
|
+
export declare function handleSubscriptionDeleted(event: Stripe.Event): Promise<void>;
|
|
8
|
+
export declare function handleTrialWillEnd(event: Stripe.Event): Promise<void>;
|
|
9
|
+
export declare function handleSubscriptionUpdated(event: Stripe.Event): Promise<void>;
|
|
10
|
+
export declare function handleCustomerUpdated(event: Stripe.Event): Promise<void>;
|
|
11
|
+
export declare function handleChargeRefundUpdated(event: Stripe.Event): Promise<void>;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleInvoiceCreated = handleInvoiceCreated;
|
|
4
|
+
exports.handleInvoiceFinalized = handleInvoiceFinalized;
|
|
5
|
+
exports.handleInvoicePaid = handleInvoicePaid;
|
|
6
|
+
exports.handleInvoiceVoided = handleInvoiceVoided;
|
|
7
|
+
exports.handleInvoicePaymentFailed = handleInvoicePaymentFailed;
|
|
8
|
+
exports.handleSubscriptionDeleted = handleSubscriptionDeleted;
|
|
9
|
+
exports.handleTrialWillEnd = handleTrialWillEnd;
|
|
10
|
+
exports.handleSubscriptionUpdated = handleSubscriptionUpdated;
|
|
11
|
+
exports.handleCustomerUpdated = handleCustomerUpdated;
|
|
12
|
+
exports.handleChargeRefundUpdated = handleChargeRefundUpdated;
|
|
13
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
14
|
+
const automation_1 = require("../automation");
|
|
15
|
+
const db_1 = require("../db");
|
|
16
|
+
const invoice_line_items_1 = require("../invoice-line-items");
|
|
17
|
+
const notifications_1 = require("../notifications");
|
|
18
|
+
const plan_changes_1 = require("../plan-changes");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const client_1 = require("./client");
|
|
21
|
+
const customer_billing_1 = require("./customer-billing");
|
|
22
|
+
const proration_1 = require("./proration");
|
|
23
|
+
const webhook_shared_1 = require("./webhook-shared");
|
|
24
|
+
const BUSINESS_CUSTOMER_TYPE = "business";
|
|
25
|
+
const SUSPENDED_STATUS = "suspended";
|
|
26
|
+
const CANCELLED_STATUS = "cancelled";
|
|
27
|
+
const REACTIVATABLE_STATUSES = new Set([
|
|
28
|
+
webhook_shared_1.PAST_DUE_STATUS,
|
|
29
|
+
SUSPENDED_STATUS,
|
|
30
|
+
]);
|
|
31
|
+
const PAYMENT_FAILED_ICON = "i-ph-x-circle";
|
|
32
|
+
const REFUND_ICON = "i-ph-arrow-counter-clockwise";
|
|
33
|
+
const SUBSCRIPTION_CANCELLED_ICON = "i-ph-x";
|
|
34
|
+
const TRIAL_ENDING_ICON = "i-ph-hourglass";
|
|
35
|
+
const TRIAL_ENDED_BLOCKED_ICON = "i-ph-prohibit";
|
|
36
|
+
const SINGLE_INVOICE_FETCH_LIMIT = 1;
|
|
37
|
+
const AUTO_PRORATA_METADATA_KEY = "saasAutoProrataOf";
|
|
38
|
+
const TRIAL_BLOCKED_STRIPE_STATUSES = new Set([
|
|
39
|
+
"past_due",
|
|
40
|
+
"unpaid",
|
|
41
|
+
"incomplete_expired",
|
|
42
|
+
]);
|
|
43
|
+
async function handleInvoiceCreated(event) {
|
|
44
|
+
const mirrored = await (0, webhook_shared_1.mirrorInvoiceFromEvent)(event);
|
|
45
|
+
if (!mirrored)
|
|
46
|
+
return;
|
|
47
|
+
await (0, invoice_line_items_1.injectProvidedInvoiceLineItems)(mirrored.invoice, mirrored.tenantId, mirrored.customerId);
|
|
48
|
+
}
|
|
49
|
+
async function handleInvoiceFinalized(event) {
|
|
50
|
+
await (0, webhook_shared_1.mirrorInvoiceFromEvent)(event);
|
|
51
|
+
}
|
|
52
|
+
async function handleInvoicePaid(event) {
|
|
53
|
+
const invoice = event.data.object;
|
|
54
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(invoice.customer);
|
|
55
|
+
if (!customerId)
|
|
56
|
+
return;
|
|
57
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
58
|
+
if (!tenant)
|
|
59
|
+
return;
|
|
60
|
+
await (0, webhook_shared_1.upsertInvoice)(invoice, tenant._id);
|
|
61
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenant._id);
|
|
62
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
63
|
+
if (subscription && REACTIVATABLE_STATUSES.has(subscription.status)) {
|
|
64
|
+
const invoiceModel = (0, interface_database_decorators_1.GetModel)(db_1.InvoiceModel, tenant._id);
|
|
65
|
+
const stillOpen = await invoiceModel.findLatestOpen();
|
|
66
|
+
if (!stillOpen) {
|
|
67
|
+
await (0, webhook_shared_1.updateSubscriptionStatus)(tenant._id, webhook_shared_1.ACTIVE_STATUS);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function handleInvoiceVoided(event) {
|
|
72
|
+
const invoice = event.data.object;
|
|
73
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(invoice.customer);
|
|
74
|
+
if (!customerId)
|
|
75
|
+
return;
|
|
76
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
77
|
+
if (!tenant)
|
|
78
|
+
return;
|
|
79
|
+
await (0, webhook_shared_1.upsertInvoice)(invoice, tenant._id);
|
|
80
|
+
}
|
|
81
|
+
async function handleInvoicePaymentFailed(event) {
|
|
82
|
+
const invoice = event.data.object;
|
|
83
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(invoice.customer);
|
|
84
|
+
if (!customerId)
|
|
85
|
+
return;
|
|
86
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
87
|
+
if (!tenant)
|
|
88
|
+
return;
|
|
89
|
+
await (0, webhook_shared_1.upsertInvoice)(invoice, tenant._id);
|
|
90
|
+
const localSubscription = await (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenant._id).findOne();
|
|
91
|
+
if (localSubscription?.status === CANCELLED_STATUS)
|
|
92
|
+
return;
|
|
93
|
+
await (0, webhook_shared_1.updateSubscriptionStatus)(tenant._id, webhook_shared_1.PAST_DUE_STATUS);
|
|
94
|
+
(0, automation_1.emitAutomationEvent)("saas.payment-failed", {
|
|
95
|
+
tenantId: tenant._id,
|
|
96
|
+
invoiceId: invoice.id,
|
|
97
|
+
invoiceNumber: invoice.number ?? null,
|
|
98
|
+
amountDue: invoice.amount_due,
|
|
99
|
+
currency: invoice.currency,
|
|
100
|
+
at: new Date().toISOString(),
|
|
101
|
+
});
|
|
102
|
+
await (0, notifications_1.notifyTenantOwners)(tenant._id, notifications_1.paymentFailedSubject, {
|
|
103
|
+
icon: PAYMENT_FAILED_ICON,
|
|
104
|
+
title: "Payment failed",
|
|
105
|
+
description: `Invoice ${invoice.number ?? invoice.id} failed (${(0, webhook_shared_1.formatAmount)(invoice.amount_due, invoice.currency)}).`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function applyAutoProrataIfEnabled(customerId, tenantId, subscription) {
|
|
109
|
+
const billingSettingsModel = (0, interface_database_decorators_1.GetModel)(db_1.BillingSettingsModel);
|
|
110
|
+
const settings = await billingSettingsModel.get(db_1.BILLING_SETTINGS_SINGLETON_ID);
|
|
111
|
+
if (!settings?.autoProrataOnCancelEnabled)
|
|
112
|
+
return;
|
|
113
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenantId);
|
|
114
|
+
const localSubscription = await tenantSubscriptionModel.findOne();
|
|
115
|
+
if (localSubscription?.refundRequestedAt)
|
|
116
|
+
return;
|
|
117
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
118
|
+
const invoices = await stripe.invoices.list({
|
|
119
|
+
customer: customerId,
|
|
120
|
+
status: "paid",
|
|
121
|
+
limit: SINGLE_INVOICE_FETCH_LIMIT,
|
|
122
|
+
});
|
|
123
|
+
const lastInvoice = invoices.data[0];
|
|
124
|
+
if (!lastInvoice?.id)
|
|
125
|
+
return;
|
|
126
|
+
const existingNotes = await stripe.creditNotes.list({
|
|
127
|
+
invoice: lastInvoice.id,
|
|
128
|
+
});
|
|
129
|
+
const alreadyIssued = existingNotes.data.some((note) => note.metadata?.[AUTO_PRORATA_METADATA_KEY] === subscription.id);
|
|
130
|
+
if (alreadyIssued)
|
|
131
|
+
return;
|
|
132
|
+
const remaining = (0, proration_1.computeUnusedPortionCents)(lastInvoice.amount_paid, subscription.current_period_start, subscription.current_period_end, subscription.ended_at ?? (0, proration_1.nowInStripeSeconds)());
|
|
133
|
+
if (remaining <= 0)
|
|
134
|
+
return;
|
|
135
|
+
await stripe.creditNotes.create({
|
|
136
|
+
invoice: lastInvoice.id,
|
|
137
|
+
amount: remaining,
|
|
138
|
+
refund_amount: remaining,
|
|
139
|
+
reason: "order_change",
|
|
140
|
+
memo: "Automatic prorated refund on cancellation",
|
|
141
|
+
metadata: { [AUTO_PRORATA_METADATA_KEY]: subscription.id },
|
|
142
|
+
}, { idempotencyKey: `auto-prorata:${subscription.id}` });
|
|
143
|
+
}
|
|
144
|
+
async function handleSubscriptionDeleted(event) {
|
|
145
|
+
const subscription = event.data.object;
|
|
146
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(subscription.customer);
|
|
147
|
+
if (!customerId)
|
|
148
|
+
return;
|
|
149
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
150
|
+
if (!tenant)
|
|
151
|
+
return;
|
|
152
|
+
if (await (0, plan_changes_1.applyPendingFreePlanOnCancellation)(tenant._id))
|
|
153
|
+
return;
|
|
154
|
+
await (0, webhook_shared_1.updateSubscriptionStatus)(tenant._id, CANCELLED_STATUS);
|
|
155
|
+
await applyAutoProrataIfEnabled(customerId, tenant._id, subscription);
|
|
156
|
+
(0, automation_1.emitAutomationEvent)("saas.subscription-cancelled", {
|
|
157
|
+
tenantId: tenant._id,
|
|
158
|
+
stripeSubscriptionId: subscription.id,
|
|
159
|
+
at: new Date().toISOString(),
|
|
160
|
+
});
|
|
161
|
+
await (0, notifications_1.notifyTenantOwners)(tenant._id, notifications_1.subscriptionCancelledSubject, {
|
|
162
|
+
icon: SUBSCRIPTION_CANCELLED_ICON,
|
|
163
|
+
title: "Subscription cancelled",
|
|
164
|
+
description: "Your subscription has been cancelled.",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
async function handleTrialWillEnd(event) {
|
|
168
|
+
const subscription = event.data.object;
|
|
169
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(subscription.customer);
|
|
170
|
+
if (!customerId)
|
|
171
|
+
return;
|
|
172
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
173
|
+
if (!tenant)
|
|
174
|
+
return;
|
|
175
|
+
await (0, notifications_1.notifyTenantMembers)(tenant._id, notifications_1.trialEndingSoonSubject, {
|
|
176
|
+
icon: TRIAL_ENDING_ICON,
|
|
177
|
+
title: "Trial ending soon",
|
|
178
|
+
description: "Your trial ends in 3 days.",
|
|
179
|
+
});
|
|
180
|
+
(0, automation_1.emitAutomationEvent)("saas.trial-ending", {
|
|
181
|
+
tenantId: tenant._id,
|
|
182
|
+
trialEndsAt: subscription.trial_end
|
|
183
|
+
? ((0, utils_1.stripeSecondsToDate)(subscription.trial_end)?.toISOString() ?? null)
|
|
184
|
+
: null,
|
|
185
|
+
at: new Date().toISOString(),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
async function persistSubscriptionPeriod(tenantId, subscription) {
|
|
189
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenantId);
|
|
190
|
+
const local = await tenantSubscriptionModel.findOne();
|
|
191
|
+
if (!local)
|
|
192
|
+
return;
|
|
193
|
+
const currentPeriodEnd = (0, utils_1.stripeSecondsToDate)(subscription.current_period_end);
|
|
194
|
+
if (local.currentPeriodEnd?.getTime() === currentPeriodEnd?.getTime())
|
|
195
|
+
return;
|
|
196
|
+
await tenantSubscriptionModel.update(local._id, { currentPeriodEnd });
|
|
197
|
+
}
|
|
198
|
+
async function handleTrialTransition(tenantId, subscription) {
|
|
199
|
+
if (TRIAL_BLOCKED_STRIPE_STATUSES.has(subscription.status)) {
|
|
200
|
+
await (0, webhook_shared_1.updateSubscriptionStatus)(tenantId, webhook_shared_1.PAST_DUE_STATUS);
|
|
201
|
+
await (0, notifications_1.notifyTenantOwners)(tenantId, notifications_1.trialEndedBlockedSubject, {
|
|
202
|
+
icon: TRIAL_ENDED_BLOCKED_ICON,
|
|
203
|
+
title: "Trial ended",
|
|
204
|
+
description: "Your trial has ended and access is blocked. Update your payment method to restore access.",
|
|
205
|
+
});
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (subscription.status === "active") {
|
|
209
|
+
await (0, webhook_shared_1.updateSubscriptionStatus)(tenantId, webhook_shared_1.ACTIVE_STATUS);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async function handleSubscriptionUpdated(event) {
|
|
213
|
+
const subscription = event.data.object;
|
|
214
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(subscription.customer);
|
|
215
|
+
if (!customerId)
|
|
216
|
+
return;
|
|
217
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
218
|
+
if (!tenant)
|
|
219
|
+
return;
|
|
220
|
+
await persistSubscriptionPeriod(tenant._id, subscription);
|
|
221
|
+
await (0, plan_changes_1.applyPendingPlanChangeIfEntered)(tenant._id, subscription);
|
|
222
|
+
await (0, plan_changes_1.reconcilePendingWithStripe)(tenant._id, subscription);
|
|
223
|
+
const previousAttributes = event.data.previous_attributes;
|
|
224
|
+
if (previousAttributes?.status !== "trialing")
|
|
225
|
+
return;
|
|
226
|
+
await handleTrialTransition(tenant._id, subscription);
|
|
227
|
+
}
|
|
228
|
+
function stripeAddressToTenant(address) {
|
|
229
|
+
if (!address)
|
|
230
|
+
return null;
|
|
231
|
+
return {
|
|
232
|
+
line1: address.line1 ?? null,
|
|
233
|
+
line2: address.line2 ?? null,
|
|
234
|
+
postalCode: address.postal_code ?? null,
|
|
235
|
+
city: address.city ?? null,
|
|
236
|
+
state: address.state ?? null,
|
|
237
|
+
country: address.country ?? null,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
async function handleCustomerUpdated(event) {
|
|
241
|
+
const customer = event.data.object;
|
|
242
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customer.id);
|
|
243
|
+
if (!tenant)
|
|
244
|
+
return;
|
|
245
|
+
const billingInfoModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantBillingInfoModel, tenant._id);
|
|
246
|
+
const existing = await billingInfoModel.findOne();
|
|
247
|
+
if (!existing)
|
|
248
|
+
return;
|
|
249
|
+
const isBusiness = existing.customerType === BUSINESS_CUSTOMER_TYPE;
|
|
250
|
+
const snapshot = await (0, customer_billing_1.fetchPrimaryTaxId)(customer.id);
|
|
251
|
+
const vat = resolveVatFields(existing, isBusiness, snapshot);
|
|
252
|
+
await billingInfoModel.update(existing._id, {
|
|
253
|
+
address: stripeAddressToTenant(customer.address),
|
|
254
|
+
...vat,
|
|
255
|
+
billingEmail: customer.email ?? existing.billingEmail,
|
|
256
|
+
companyName: isBusiness
|
|
257
|
+
? (customer.name ?? existing.companyName)
|
|
258
|
+
: existing.companyName,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function resolveVatFields(existing, isBusiness, snapshot) {
|
|
262
|
+
if (!isBusiness)
|
|
263
|
+
return { vatNumber: null, vatVerificationStatus: null };
|
|
264
|
+
if (!snapshot.reachable) {
|
|
265
|
+
return {
|
|
266
|
+
vatNumber: existing.vatNumber,
|
|
267
|
+
vatVerificationStatus: existing.vatVerificationStatus ?? null,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
vatNumber: snapshot.taxId?.value ?? null,
|
|
272
|
+
vatVerificationStatus: snapshot.taxId
|
|
273
|
+
? (0, customer_billing_1.toVatVerificationStatus)(snapshot.taxId)
|
|
274
|
+
: null,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
async function handleChargeRefundUpdated(event) {
|
|
278
|
+
const refund = event.data.object;
|
|
279
|
+
const chargeId = (0, webhook_shared_1.asCustomerId)(refund.charge);
|
|
280
|
+
if (!chargeId)
|
|
281
|
+
return;
|
|
282
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
283
|
+
const charge = await stripe.charges.retrieve(chargeId);
|
|
284
|
+
const customerId = (0, webhook_shared_1.asCustomerId)(charge.customer);
|
|
285
|
+
if (!customerId)
|
|
286
|
+
return;
|
|
287
|
+
const tenant = await (0, webhook_shared_1.findTenantByCustomerId)(customerId);
|
|
288
|
+
if (!tenant)
|
|
289
|
+
return;
|
|
290
|
+
const refundModel = (0, interface_database_decorators_1.GetModel)(db_1.RefundModel, tenant._id);
|
|
291
|
+
const existing = await refundModel.findOneByStripeRefund(refund.id);
|
|
292
|
+
const payload = {
|
|
293
|
+
creditNoteId: existing?.creditNoteId ?? "",
|
|
294
|
+
stripeRefundId: refund.id,
|
|
295
|
+
amount: refund.amount,
|
|
296
|
+
currency: refund.currency,
|
|
297
|
+
status: (refund.status ?? "pending"),
|
|
298
|
+
failureReason: refund.failure_reason ?? null,
|
|
299
|
+
updatedAt: new Date(),
|
|
300
|
+
};
|
|
301
|
+
if (existing) {
|
|
302
|
+
await refundModel.update(existing._id, payload);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
await refundModel.insert({
|
|
306
|
+
...payload,
|
|
307
|
+
createdAt: new Date(),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (refund.status === "succeeded") {
|
|
311
|
+
await (0, notifications_1.notifyTenantOwners)(tenant._id, notifications_1.refundProcessedSubject, {
|
|
312
|
+
icon: REFUND_ICON,
|
|
313
|
+
title: "Refund processed",
|
|
314
|
+
description: `Refund of ${(0, webhook_shared_1.formatAmount)(refund.amount, refund.currency)} processed.`,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=webhook-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-handlers.js","sourceRoot":"","sources":["../../src/stripe/webhook-handlers.ts"],"names":[],"mappings":";;AA2EA,oDA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ACV,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,IAAA,kCAAkB,EAAC,MAAM,CAAC,GAAG,EAAE,sCAAsB,EAAE;YAC3D,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,aAAa,IAAA,6BAAY,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,aAAa;SACpF,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { InvoiceLine, TenantSubscriptionStatus } from "../db";
|
|
3
|
+
export declare const ACTIVE_STATUS: TenantSubscriptionStatus;
|
|
4
|
+
export declare const TRIALING_STATUS: TenantSubscriptionStatus;
|
|
5
|
+
export declare const PAST_DUE_STATUS: TenantSubscriptionStatus;
|
|
6
|
+
export declare const CENTS_PER_UNIT = 100;
|
|
7
|
+
export interface TenantRef {
|
|
8
|
+
_id: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function findTenantByCustomerId(customerId: string): Promise<TenantRef | null>;
|
|
11
|
+
export declare function updateSubscriptionStatus(tenantId: string, status: TenantSubscriptionStatus): Promise<void>;
|
|
12
|
+
export declare function formatAmount(amountInCents: number, currency: string): string;
|
|
13
|
+
export declare function asCustomerId(field: unknown): string | null;
|
|
14
|
+
export declare const INVOICE_LINES_PAGE_SIZE = 100;
|
|
15
|
+
export declare function toInvoiceLine(line: Stripe.InvoiceLineItem): InvoiceLine;
|
|
16
|
+
export declare function resolveInvoiceLines(invoice: Stripe.Invoice): Promise<InvoiceLine[]>;
|
|
17
|
+
export declare function upsertInvoice(invoice: Stripe.Invoice, tenantId: string): Promise<void>;
|
|
18
|
+
export interface MirroredInvoice {
|
|
19
|
+
invoice: Stripe.Invoice;
|
|
20
|
+
customerId: string;
|
|
21
|
+
tenantId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MirroredCreditNote {
|
|
24
|
+
creditNote: Stripe.CreditNote;
|
|
25
|
+
tenantId: string;
|
|
26
|
+
isCurrent: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function mirrorInvoiceFromEvent(event: Stripe.Event): Promise<MirroredInvoice | null>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INVOICE_LINES_PAGE_SIZE = exports.CENTS_PER_UNIT = exports.PAST_DUE_STATUS = exports.TRIALING_STATUS = exports.ACTIVE_STATUS = void 0;
|
|
4
|
+
exports.findTenantByCustomerId = findTenantByCustomerId;
|
|
5
|
+
exports.updateSubscriptionStatus = updateSubscriptionStatus;
|
|
6
|
+
exports.formatAmount = formatAmount;
|
|
7
|
+
exports.asCustomerId = asCustomerId;
|
|
8
|
+
exports.toInvoiceLine = toInvoiceLine;
|
|
9
|
+
exports.resolveInvoiceLines = resolveInvoiceLines;
|
|
10
|
+
exports.upsertInvoice = upsertInvoice;
|
|
11
|
+
exports.mirrorInvoiceFromEvent = mirrorInvoiceFromEvent;
|
|
12
|
+
const interface_database_1 = require("@antelopejs/interface-database");
|
|
13
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
14
|
+
const billing_state_1 = require("../billing-state");
|
|
15
|
+
const db_1 = require("../db");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const client_1 = require("./client");
|
|
18
|
+
exports.ACTIVE_STATUS = "active";
|
|
19
|
+
exports.TRIALING_STATUS = "trialing";
|
|
20
|
+
exports.PAST_DUE_STATUS = "past_due";
|
|
21
|
+
exports.CENTS_PER_UNIT = 100;
|
|
22
|
+
async function findTenantByCustomerId(customerId) {
|
|
23
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, interface_database_1.CROSS_INSTANCE);
|
|
24
|
+
const sub = await tenantSubscriptionModel.findOneByStripeCustomer(customerId);
|
|
25
|
+
if (!sub)
|
|
26
|
+
return null;
|
|
27
|
+
return { _id: (0, utils_1.getRowInstance)(sub) };
|
|
28
|
+
}
|
|
29
|
+
async function updateSubscriptionStatus(tenantId, status) {
|
|
30
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenantId);
|
|
31
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
32
|
+
if (!subscription)
|
|
33
|
+
return;
|
|
34
|
+
const patch = {
|
|
35
|
+
status,
|
|
36
|
+
updatedAt: new Date(),
|
|
37
|
+
};
|
|
38
|
+
if (status === exports.PAST_DUE_STATUS) {
|
|
39
|
+
patch.pastDueSince = subscription.pastDueSince ?? new Date();
|
|
40
|
+
}
|
|
41
|
+
await tenantSubscriptionModel.update(subscription._id, patch);
|
|
42
|
+
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
43
|
+
}
|
|
44
|
+
function formatAmount(amountInCents, currency) {
|
|
45
|
+
return `${(amountInCents / exports.CENTS_PER_UNIT).toFixed(2)} ${currency.toUpperCase()}`;
|
|
46
|
+
}
|
|
47
|
+
function asCustomerId(field) {
|
|
48
|
+
if (typeof field === "string")
|
|
49
|
+
return field;
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
exports.INVOICE_LINES_PAGE_SIZE = 100;
|
|
53
|
+
const INVOICE_LINES_HARD_CAP = 1000;
|
|
54
|
+
function toInvoiceLine(line) {
|
|
55
|
+
return {
|
|
56
|
+
description: line.description ?? "",
|
|
57
|
+
quantity: line.quantity,
|
|
58
|
+
amount: line.amount,
|
|
59
|
+
currency: line.currency,
|
|
60
|
+
periodStart: (0, utils_1.stripeSecondsToDate)(line.period?.start),
|
|
61
|
+
periodEnd: (0, utils_1.stripeSecondsToDate)(line.period?.end),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function resolveInvoiceLines(invoice) {
|
|
65
|
+
if (!invoice.lines.has_more)
|
|
66
|
+
return invoice.lines.data.map(toInvoiceLine);
|
|
67
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
68
|
+
const lines = await stripe.invoices
|
|
69
|
+
.listLineItems(invoice.id, { limit: exports.INVOICE_LINES_PAGE_SIZE })
|
|
70
|
+
.autoPagingToArray({ limit: INVOICE_LINES_HARD_CAP });
|
|
71
|
+
return lines.map(toInvoiceLine);
|
|
72
|
+
}
|
|
73
|
+
async function upsertInvoice(invoice, tenantId) {
|
|
74
|
+
const invoiceModel = (0, interface_database_decorators_1.GetModel)(db_1.InvoiceModel, tenantId);
|
|
75
|
+
const existing = await invoiceModel.findOneByStripeInvoice(invoice.id);
|
|
76
|
+
const lines = await resolveInvoiceLines(invoice);
|
|
77
|
+
const payload = {
|
|
78
|
+
documentType: "invoice",
|
|
79
|
+
stripeInvoiceId: invoice.id,
|
|
80
|
+
stripeCreditNoteId: null,
|
|
81
|
+
number: invoice.number ?? null,
|
|
82
|
+
parentInvoiceNumber: null,
|
|
83
|
+
amount: invoice.amount_due,
|
|
84
|
+
subtotal: invoice.subtotal,
|
|
85
|
+
tax: invoice.tax ?? 0,
|
|
86
|
+
total: invoice.total,
|
|
87
|
+
currency: invoice.currency,
|
|
88
|
+
status: (invoice.status ?? "open"),
|
|
89
|
+
creditNoteReason: null,
|
|
90
|
+
creditNoteType: null,
|
|
91
|
+
memo: null,
|
|
92
|
+
hostedInvoiceUrl: invoice.hosted_invoice_url ?? null,
|
|
93
|
+
invoicePdfUrl: invoice.invoice_pdf ?? null,
|
|
94
|
+
metadata: invoice.metadata ?? {},
|
|
95
|
+
periodStart: (0, utils_1.stripeSecondsToDate)(invoice.period_start),
|
|
96
|
+
periodEnd: (0, utils_1.stripeSecondsToDate)(invoice.period_end),
|
|
97
|
+
lines,
|
|
98
|
+
paidAt: invoice.status === "paid" && invoice.status_transitions.paid_at
|
|
99
|
+
? (0, utils_1.stripeSecondsToDate)(invoice.status_transitions.paid_at)
|
|
100
|
+
: null,
|
|
101
|
+
voidedAt: null,
|
|
102
|
+
issuedAt: (0, utils_1.stripeSecondsToDate)(invoice.created) ?? new Date(),
|
|
103
|
+
updatedAt: new Date(),
|
|
104
|
+
};
|
|
105
|
+
if (existing) {
|
|
106
|
+
await invoiceModel.update(existing._id, payload);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
await invoiceModel.insert({
|
|
110
|
+
...payload,
|
|
111
|
+
createdAt: new Date(),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function mirrorInvoiceFromEvent(event) {
|
|
116
|
+
const invoice = event.data.object;
|
|
117
|
+
const customerId = asCustomerId(invoice.customer);
|
|
118
|
+
if (!customerId)
|
|
119
|
+
return null;
|
|
120
|
+
const tenant = await findTenantByCustomerId(customerId);
|
|
121
|
+
if (!tenant)
|
|
122
|
+
return null;
|
|
123
|
+
await upsertInvoice(invoice, tenant._id);
|
|
124
|
+
return { invoice, customerId, tenantId: tenant._id };
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=webhook-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-shared.js","sourceRoot":"","sources":["../../src/stripe/webhook-shared.ts"],"names":[],"mappings":";;;AA+BA,wDAUC;AAED,4DAkBC;AAED,oCAEC;AAED,oCAGC;AAKD,sCASC;AAQD,kDASC;AAED,sCA4CC;AAcD,wDAUC;AAtKD,uEAAgE;AAChE,6FAAqE;AAErE,oDAA+D;AAO/D,8BAA8D;AAC9D,oCAGkB;AAClB,qCAA2C;AAE9B,QAAA,aAAa,GAA6B,QAAQ,CAAC;AACnD,QAAA,eAAe,GAA6B,UAAU,CAAC;AACvD,QAAA,eAAe,GAA6B,UAAU,CAAC;AACvD,QAAA,cAAc,GAAG,GAAG,CAAC;AAM3B,KAAK,UAAU,sBAAsB,CAC1C,UAAkB;IAElB,MAAM,uBAAuB,GAAG,IAA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Y,CAAC,MAAM,CAAC;YACxB,GAAG,OAAO;YACV,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAcM,KAAK,UAAU,sBAAsB,CAC1C,KAAmB;IAEnB,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAwB,CAAC;IACpD,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACzC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface WorkspaceCheckoutSessionInput {
|
|
2
|
+
operationId?: string;
|
|
3
|
+
tenantId: string;
|
|
4
|
+
ownerEmail: string;
|
|
5
|
+
stripePriceId: string;
|
|
6
|
+
trialDays?: number;
|
|
7
|
+
successUrl: string;
|
|
8
|
+
cancelUrl: string;
|
|
9
|
+
planId?: string;
|
|
10
|
+
existingCustomerId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkspaceCheckoutSession {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
url: string;
|
|
15
|
+
customerId: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class UnusableCheckoutSessionError extends Error {
|
|
18
|
+
readonly sessionId: string;
|
|
19
|
+
constructor(sessionId: string);
|
|
20
|
+
}
|
|
21
|
+
export interface TenantCheckoutCustomerInput {
|
|
22
|
+
operationId?: string;
|
|
23
|
+
tenantId: string;
|
|
24
|
+
ownerEmail: string;
|
|
25
|
+
companyName?: string | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function createTenantCheckoutCustomer(input: TenantCheckoutCustomerInput): Promise<string>;
|
|
28
|
+
export declare function deleteStripeCustomerIfExists(customerId: string): Promise<void>;
|
|
29
|
+
export declare function createWorkspaceCheckoutSession(input: WorkspaceCheckoutSessionInput): Promise<WorkspaceCheckoutSession>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UnusableCheckoutSessionError = void 0;
|
|
7
|
+
exports.createTenantCheckoutCustomer = createTenantCheckoutCustomer;
|
|
8
|
+
exports.deleteStripeCustomerIfExists = deleteStripeCustomerIfExists;
|
|
9
|
+
exports.createWorkspaceCheckoutSession = createWorkspaceCheckoutSession;
|
|
10
|
+
const logging_1 = require("@antelopejs/interface-core/logging");
|
|
11
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
12
|
+
const client_1 = require("./client");
|
|
13
|
+
const MISSING_RESOURCE_CODE = "resource_missing";
|
|
14
|
+
class UnusableCheckoutSessionError extends Error {
|
|
15
|
+
sessionId;
|
|
16
|
+
constructor(sessionId) {
|
|
17
|
+
super("Stripe Checkout did not return a redirect URL");
|
|
18
|
+
this.sessionId = sessionId;
|
|
19
|
+
this.name = "UnusableCheckoutSessionError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UnusableCheckoutSessionError = UnusableCheckoutSessionError;
|
|
23
|
+
async function createTenantCheckoutCustomer(input) {
|
|
24
|
+
const customer = await (0, client_1.getStripeClient)().customers.create({
|
|
25
|
+
email: input.ownerEmail,
|
|
26
|
+
name: input.companyName ?? undefined,
|
|
27
|
+
metadata: { tenantId: input.tenantId },
|
|
28
|
+
}, input.operationId
|
|
29
|
+
? { idempotencyKey: `checkout-customer:${input.operationId}` }
|
|
30
|
+
: undefined);
|
|
31
|
+
return customer.id;
|
|
32
|
+
}
|
|
33
|
+
function isMissingResourceError(error) {
|
|
34
|
+
return (error instanceof stripe_1.default.errors.StripeInvalidRequestError &&
|
|
35
|
+
error.code === MISSING_RESOURCE_CODE);
|
|
36
|
+
}
|
|
37
|
+
async function deleteStripeCustomerIfExists(customerId) {
|
|
38
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
39
|
+
const customer = await stripe.customers
|
|
40
|
+
.retrieve(customerId)
|
|
41
|
+
.catch((error) => {
|
|
42
|
+
if (isMissingResourceError(error))
|
|
43
|
+
return null;
|
|
44
|
+
throw error;
|
|
45
|
+
});
|
|
46
|
+
if (!customer || customer.deleted)
|
|
47
|
+
return;
|
|
48
|
+
await stripe.customers.del(customerId);
|
|
49
|
+
}
|
|
50
|
+
async function resolveCheckoutCustomerId(input) {
|
|
51
|
+
if (input.existingCustomerId)
|
|
52
|
+
return input.existingCustomerId;
|
|
53
|
+
return createTenantCheckoutCustomer({
|
|
54
|
+
operationId: input.operationId,
|
|
55
|
+
tenantId: input.tenantId,
|
|
56
|
+
ownerEmail: input.ownerEmail,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function buildCheckoutSubscriptionData(metadata, trialDays) {
|
|
60
|
+
const subscriptionData = {
|
|
61
|
+
metadata,
|
|
62
|
+
};
|
|
63
|
+
if (trialDays && trialDays > 0) {
|
|
64
|
+
subscriptionData.trial_period_days = trialDays;
|
|
65
|
+
}
|
|
66
|
+
return subscriptionData;
|
|
67
|
+
}
|
|
68
|
+
async function createWorkspaceCheckoutSession(input) {
|
|
69
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
70
|
+
const customerId = await resolveCheckoutCustomerId(input);
|
|
71
|
+
const sessionMetadata = { tenantId: input.tenantId };
|
|
72
|
+
if (input.planId)
|
|
73
|
+
sessionMetadata.planId = input.planId;
|
|
74
|
+
if (input.operationId)
|
|
75
|
+
sessionMetadata.operationId = input.operationId;
|
|
76
|
+
const session = await stripe.checkout.sessions.create({
|
|
77
|
+
mode: "subscription",
|
|
78
|
+
customer: customerId,
|
|
79
|
+
line_items: [{ price: input.stripePriceId, quantity: 1 }],
|
|
80
|
+
success_url: input.successUrl,
|
|
81
|
+
cancel_url: input.cancelUrl,
|
|
82
|
+
subscription_data: buildCheckoutSubscriptionData(sessionMetadata, input.trialDays),
|
|
83
|
+
metadata: sessionMetadata,
|
|
84
|
+
automatic_tax: { enabled: true },
|
|
85
|
+
tax_id_collection: { enabled: true },
|
|
86
|
+
billing_address_collection: "required",
|
|
87
|
+
customer_update: { address: "auto", name: "auto" },
|
|
88
|
+
}, input.operationId
|
|
89
|
+
? { idempotencyKey: `checkout-session:${input.operationId}` }
|
|
90
|
+
: undefined);
|
|
91
|
+
if (!session.url) {
|
|
92
|
+
if (input.operationId)
|
|
93
|
+
throw new UnusableCheckoutSessionError(session.id);
|
|
94
|
+
await stripe.checkout.sessions.expire(session.id).catch(() => { });
|
|
95
|
+
if (!input.existingCustomerId) {
|
|
96
|
+
await deleteStripeCustomerIfExists(customerId).catch((error) => logging_1.Logging.Warn(`[dms-saas] failed to delete Stripe customer ${customerId} after unusable checkout session`, error));
|
|
97
|
+
}
|
|
98
|
+
throw new UnusableCheckoutSessionError(session.id);
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
sessionId: session.id,
|
|
102
|
+
url: session.url,
|
|
103
|
+
customerId,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=workspace-checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-checkout.js","sourceRoot":"","sources":["../../src/stripe/workspace-checkout.ts"],"names":[],"mappings":";;;;;;AAsDA,oEAcC;AAcD,oEAYC;AAqCD,wEAuDC;AA1LD,gEAA6D;AAC7D,oDAA4B;AAC5B,qCAA2C;AAE3C,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAyBjD,MAAa,4B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