@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,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UNCHANGED_RESULT_BASE = exports.PAST_DUE_STATUS = exports.HTTP_CONFLICT = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_FOUND = void 0;
|
|
4
|
+
exports.loadAndValidateTargetPlan = loadAndValidateTargetPlan;
|
|
5
|
+
exports.assertSeatLimit = assertSeatLimit;
|
|
6
|
+
exports.finalizeImmediateChange = finalizeImmediateChange;
|
|
7
|
+
exports.isPaidPlan = isPaidPlan;
|
|
8
|
+
exports.startPaidCheckout = startPaidCheckout;
|
|
9
|
+
exports.insertFreeSubscription = insertFreeSubscription;
|
|
10
|
+
exports.scheduleDowngrade = scheduleDowngrade;
|
|
11
|
+
exports.dropPendingChange = dropPendingChange;
|
|
12
|
+
exports.applyImmediateChange = applyImmediateChange;
|
|
13
|
+
const node_crypto_1 = require("node:crypto");
|
|
14
|
+
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
15
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
16
|
+
const tenant_lifecycle_1 = require("@antelopejs/interface-dms/tenant-lifecycle");
|
|
17
|
+
const billing_state_1 = require("../../billing-state");
|
|
18
|
+
const config_1 = require("../../config");
|
|
19
|
+
const db_1 = require("../../db");
|
|
20
|
+
const plan_changes_1 = require("../../plan-changes");
|
|
21
|
+
const plans_1 = require("../../plans");
|
|
22
|
+
const client_1 = require("../../stripe/client");
|
|
23
|
+
const workspace_checkout_1 = require("../../stripe/workspace-checkout");
|
|
24
|
+
const utils_1 = require("../../utils");
|
|
25
|
+
const workers_1 = require("../../workers");
|
|
26
|
+
const complimentary_1 = require("../../workspaces/complimentary");
|
|
27
|
+
const trial_identity_model_1 = require("../../workspaces/db/trial-identity.model");
|
|
28
|
+
exports.HTTP_NOT_FOUND = 404;
|
|
29
|
+
exports.HTTP_BAD_REQUEST = 400;
|
|
30
|
+
const HTTP_PAYMENT_REQUIRED = 402;
|
|
31
|
+
exports.HTTP_CONFLICT = 409;
|
|
32
|
+
exports.PAST_DUE_STATUS = "past_due";
|
|
33
|
+
const PRORATION_BEHAVIOR = "create_prorations";
|
|
34
|
+
const ACTIVE_STATUS = "active";
|
|
35
|
+
const PENDING_PAYMENT_STATUS = "pending_payment";
|
|
36
|
+
const PLACEHOLDER_PLAN_ID = null;
|
|
37
|
+
exports.UNCHANGED_RESULT_BASE = {
|
|
38
|
+
changed: false,
|
|
39
|
+
scheduled: false,
|
|
40
|
+
effectiveAt: null,
|
|
41
|
+
checkoutUrl: null,
|
|
42
|
+
};
|
|
43
|
+
function asNonEmptyString(value) {
|
|
44
|
+
return typeof value === "string" && value.trim().length > 0
|
|
45
|
+
? value.trim()
|
|
46
|
+
: null;
|
|
47
|
+
}
|
|
48
|
+
function validateCheckoutRedirectInput(body) {
|
|
49
|
+
const successUrl = asNonEmptyString(body.successUrl);
|
|
50
|
+
const cancelUrl = asNonEmptyString(body.cancelUrl);
|
|
51
|
+
(0, interface_api_util_1.assert)(successUrl && (0, config_1.isAllowedRedirectUrl)(successUrl), exports.HTTP_BAD_REQUEST, "saas.errors.billing.invalid_return_url");
|
|
52
|
+
(0, interface_api_util_1.assert)(cancelUrl && (0, config_1.isAllowedRedirectUrl)(cancelUrl), exports.HTTP_BAD_REQUEST, "saas.errors.billing.invalid_return_url");
|
|
53
|
+
return { successUrl, cancelUrl };
|
|
54
|
+
}
|
|
55
|
+
async function loadAndValidateTargetPlan(planModel, planId, customerType) {
|
|
56
|
+
const newPlan = await planModel.get(planId);
|
|
57
|
+
(0, interface_api_util_1.assert)(newPlan && !newPlan.isDeleted && newPlan.isActive, exports.HTTP_BAD_REQUEST, "saas.errors.plan.invalid");
|
|
58
|
+
(0, interface_api_util_1.assert)(customerType, exports.HTTP_BAD_REQUEST, "saas.errors.plan.customer_type_unknown");
|
|
59
|
+
(0, interface_api_util_1.assert)(newPlan.audience === "any" || newPlan.audience === customerType, exports.HTTP_BAD_REQUEST, "saas.errors.plan.not_available_for_customer_type");
|
|
60
|
+
(0, interface_api_util_1.assert)(newPlan.price <= 0 || !!newPlan.paymentProviderRefs?.stripePriceId, exports.HTTP_BAD_REQUEST, "saas.errors.plan.not_synced_with_stripe");
|
|
61
|
+
return newPlan;
|
|
62
|
+
}
|
|
63
|
+
async function assertSeatLimit(tenantId, plan) {
|
|
64
|
+
const occupiedSeats = await (0, plans_1.countOccupiedSeats)(tenantId);
|
|
65
|
+
(0, interface_api_util_1.assert)((0, plans_1.fitsWithinSeatLimit)(plan.maxMembers, occupiedSeats), HTTP_PAYMENT_REQUIRED, "saas.errors.plan.downgrade_exceeds_seat_limit");
|
|
66
|
+
}
|
|
67
|
+
async function applyPlanChange(subscription, newPlan, newPlanId, tenantSubscriptionModel, operationId) {
|
|
68
|
+
await syncStripePlanChange(subscription, newPlan, operationId);
|
|
69
|
+
await tenantSubscriptionModel.updateDuringTransition(subscription._id, operationId, {
|
|
70
|
+
planId: newPlanId,
|
|
71
|
+
updatedAt: new Date(),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function finalizeImmediateChange(tenantId, subscription, newPlan) {
|
|
75
|
+
await (0, workers_1.applyPlanDowngradeCleanup)(tenantId, newPlan);
|
|
76
|
+
await (0, plans_1.syncStripeSeatQuantity)({
|
|
77
|
+
tenantId,
|
|
78
|
+
plan: newPlan,
|
|
79
|
+
stripeSubscriptionId: subscription.stripeSubscriptionId,
|
|
80
|
+
idempotencyKey: `seat-sync:change-plan:${tenantId}:${subscription._id}:${newPlan._id}`,
|
|
81
|
+
});
|
|
82
|
+
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
83
|
+
}
|
|
84
|
+
async function syncStripePlanChange(subscription, newPlan, operationId) {
|
|
85
|
+
if (!subscription.stripeSubscriptionId)
|
|
86
|
+
return;
|
|
87
|
+
const stripePriceId = newPlan.paymentProviderRefs?.stripePriceId;
|
|
88
|
+
(0, interface_api_util_1.assert)(stripePriceId, exports.HTTP_BAD_REQUEST, "saas.errors.plan.no_stripe_price");
|
|
89
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
90
|
+
const stripeSubscription = await stripe.subscriptions.retrieve(subscription.stripeSubscriptionId);
|
|
91
|
+
const itemId = stripeSubscription.items.data[0]?.id;
|
|
92
|
+
(0, interface_api_util_1.assert)(itemId, exports.HTTP_BAD_REQUEST, "saas.errors.stripe.subscription_no_item");
|
|
93
|
+
await stripe.subscriptions.update(subscription.stripeSubscriptionId, {
|
|
94
|
+
items: [{ id: itemId, price: stripePriceId }],
|
|
95
|
+
proration_behavior: PRORATION_BEHAVIOR,
|
|
96
|
+
automatic_tax: { enabled: true },
|
|
97
|
+
}, {
|
|
98
|
+
idempotencyKey: `change-plan:${operationId}`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function isPaidPlan(plan) {
|
|
102
|
+
return !!plan.paymentProviderRefs?.stripePriceId;
|
|
103
|
+
}
|
|
104
|
+
async function resolveCheckoutTrialDays(newPlan, ownerEmail, tenantId) {
|
|
105
|
+
if (!newPlan.trialDays || newPlan.trialDays <= 0)
|
|
106
|
+
return 0;
|
|
107
|
+
const trialConsumptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TrialConsumptionModel);
|
|
108
|
+
const alreadyConsumed = await trialConsumptionModel.existsForIdentity((0, utils_1.hashEmail)(ownerEmail), null);
|
|
109
|
+
if (alreadyConsumed)
|
|
110
|
+
return 0;
|
|
111
|
+
const identities = (0, interface_database_decorators_1.GetModel)(trial_identity_model_1.TrialIdentityModel);
|
|
112
|
+
const id = (0, trial_identity_model_1.trialIdentityId)("email", (0, utils_1.hashEmail)(ownerEmail));
|
|
113
|
+
if ((await identities.get(id))?.tenantId)
|
|
114
|
+
return 0;
|
|
115
|
+
return (await identities.reserve(id, tenantId)) ? newPlan.trialDays : 0;
|
|
116
|
+
}
|
|
117
|
+
async function attachCheckoutSession(checkout, subscription, tenantSubscriptionModel, operationId) {
|
|
118
|
+
await tenantSubscriptionModel.updateDuringTransition(subscription._id, operationId, {
|
|
119
|
+
isComplimentary: (0, complimentary_1.isComplimentarySubscription)(subscription),
|
|
120
|
+
paidUsagePeriods: subscription.paidUsagePeriods ??
|
|
121
|
+
((0, complimentary_1.isComplimentarySubscription)(subscription) ? [] : null),
|
|
122
|
+
stripeCustomerId: checkout.customerId,
|
|
123
|
+
stripeCheckoutSessionId: checkout.sessionId,
|
|
124
|
+
updatedAt: new Date(),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async function initializeCheckoutSubscription(request) {
|
|
128
|
+
if (request.subscription)
|
|
129
|
+
return request.subscription;
|
|
130
|
+
await request.tenantSubscriptionModel.insert({
|
|
131
|
+
_id: request.tenantId,
|
|
132
|
+
planId: PLACEHOLDER_PLAN_ID,
|
|
133
|
+
status: PENDING_PAYMENT_STATUS,
|
|
134
|
+
isComplimentary: false,
|
|
135
|
+
stripeCustomerId: null,
|
|
136
|
+
stripeSubscriptionId: null,
|
|
137
|
+
stripeCheckoutSessionId: null,
|
|
138
|
+
createdBy: request.user._id,
|
|
139
|
+
createdAt: new Date(),
|
|
140
|
+
updatedAt: new Date(),
|
|
141
|
+
});
|
|
142
|
+
const subscription = await request.tenantSubscriptionModel.get(request.tenantId);
|
|
143
|
+
if (!subscription)
|
|
144
|
+
throw new Error("Checkout subscription acknowledgement requires reconciliation");
|
|
145
|
+
return subscription;
|
|
146
|
+
}
|
|
147
|
+
async function createAdmittedCheckout(request) {
|
|
148
|
+
const { tenantId, user, newPlan, body, tenantSubscriptionModel } = request;
|
|
149
|
+
const redirect = validateCheckoutRedirectInput(body);
|
|
150
|
+
const stripePriceId = newPlan.paymentProviderRefs?.stripePriceId;
|
|
151
|
+
(0, interface_api_util_1.assert)(stripePriceId, exports.HTTP_BAD_REQUEST, "saas.errors.plan.no_stripe_price");
|
|
152
|
+
const subscription = await initializeCheckoutSubscription(request);
|
|
153
|
+
const operationId = (0, node_crypto_1.randomUUID)();
|
|
154
|
+
await tenantSubscriptionModel.beginTransition(subscription, {
|
|
155
|
+
operationId,
|
|
156
|
+
kind: "checkout",
|
|
157
|
+
targetPlanId: newPlan._id,
|
|
158
|
+
requestedAt: new Date(),
|
|
159
|
+
});
|
|
160
|
+
const trialDays = await resolveCheckoutTrialDays(newPlan, user.email, tenantId);
|
|
161
|
+
const checkout = await (0, workspace_checkout_1.createWorkspaceCheckoutSession)({
|
|
162
|
+
operationId,
|
|
163
|
+
tenantId,
|
|
164
|
+
ownerEmail: user.email,
|
|
165
|
+
stripePriceId,
|
|
166
|
+
trialDays,
|
|
167
|
+
successUrl: redirect.successUrl,
|
|
168
|
+
cancelUrl: redirect.cancelUrl,
|
|
169
|
+
planId: newPlan._id,
|
|
170
|
+
existingCustomerId: subscription?.stripeCustomerId ?? undefined,
|
|
171
|
+
});
|
|
172
|
+
await attachCheckoutSession(checkout, subscription, tenantSubscriptionModel, operationId);
|
|
173
|
+
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
174
|
+
return {
|
|
175
|
+
...exports.UNCHANGED_RESULT_BASE,
|
|
176
|
+
planId: newPlan._id,
|
|
177
|
+
checkoutUrl: checkout.url,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async function startPaidCheckout(request) {
|
|
181
|
+
return (0, tenant_lifecycle_1.runTenantLifecycleOperation)(request.tenantId, () => createAdmittedCheckout(request));
|
|
182
|
+
}
|
|
183
|
+
async function insertFreeSubscription(user, newPlanId, tenantId, tenantSubscriptionModel) {
|
|
184
|
+
await (0, tenant_lifecycle_1.runTenantLifecycleOperation)(tenantId, () => tenantSubscriptionModel.insert([
|
|
185
|
+
{
|
|
186
|
+
_id: tenantId,
|
|
187
|
+
planId: newPlanId,
|
|
188
|
+
status: ACTIVE_STATUS,
|
|
189
|
+
isComplimentary: false,
|
|
190
|
+
stripeCustomerId: null,
|
|
191
|
+
stripeSubscriptionId: null,
|
|
192
|
+
stripeCheckoutSessionId: null,
|
|
193
|
+
createdBy: user._id,
|
|
194
|
+
createdAt: new Date(),
|
|
195
|
+
updatedAt: new Date(),
|
|
196
|
+
},
|
|
197
|
+
]));
|
|
198
|
+
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
199
|
+
return {
|
|
200
|
+
...exports.UNCHANGED_RESULT_BASE,
|
|
201
|
+
changed: true,
|
|
202
|
+
planId: newPlanId,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
async function scheduleDowngrade(tenantId, subscription, newPlan) {
|
|
206
|
+
const effectiveAt = await (0, plan_changes_1.scheduleDeferredPlanChange)({
|
|
207
|
+
tenantId,
|
|
208
|
+
subscription,
|
|
209
|
+
targetPlan: newPlan,
|
|
210
|
+
});
|
|
211
|
+
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
212
|
+
return {
|
|
213
|
+
...exports.UNCHANGED_RESULT_BASE,
|
|
214
|
+
scheduled: true,
|
|
215
|
+
planId: newPlan._id,
|
|
216
|
+
effectiveAt,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
async function dropPendingChange(tenantId, subscription) {
|
|
220
|
+
await (0, plan_changes_1.clearPendingPlanChange)(tenantId, subscription);
|
|
221
|
+
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
222
|
+
return {
|
|
223
|
+
...exports.UNCHANGED_RESULT_BASE,
|
|
224
|
+
changed: true,
|
|
225
|
+
planId: subscription.planId ?? "",
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
async function applyImmediateChange(tenantId, subscription, newPlan, tenantSubscriptionModel, operatorIntent) {
|
|
229
|
+
const intent = operatorIntent ??
|
|
230
|
+
{
|
|
231
|
+
operationId: (0, node_crypto_1.randomUUID)(),
|
|
232
|
+
kind: "change_plan",
|
|
233
|
+
targetPlanId: newPlan._id,
|
|
234
|
+
requestedAt: new Date(),
|
|
235
|
+
};
|
|
236
|
+
await tenantSubscriptionModel.beginTransition(subscription, intent);
|
|
237
|
+
await (0, plan_changes_1.clearPendingPlanChange)(tenantId, subscription, intent.operationId);
|
|
238
|
+
await applyPlanChange(subscription, newPlan, newPlan._id, tenantSubscriptionModel, intent.operationId);
|
|
239
|
+
await finalizeImmediateChange(tenantId, subscription, newPlan);
|
|
240
|
+
if (!operatorIntent)
|
|
241
|
+
await tenantSubscriptionModel.completeTransition(subscription._id, intent.operationId, {});
|
|
242
|
+
return { ...exports.UNCHANGED_RESULT_BASE, changed: true, planId: newPlan._id };
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=tenant-plan-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-plan-ops.js","sourceRoot":"","sources":["../../../src/routes/t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dms/db";
|
|
2
|
+
import type { User } from "@antelopejs/interface-dms/auth/db";
|
|
3
|
+
import { FeatureModel, PlanModel, TenantBillingInfoModel, TenantSubscriptionModel } from "../../db";
|
|
4
|
+
import { type ChangePlanBody, type ChangePlanResult, type CurrentPlanResult } from "./tenant-plan-ops";
|
|
5
|
+
declare const SaasTenantPlanController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
6
|
+
export declare class SaasTenantPlanController extends SaasTenantPlanController_base {
|
|
7
|
+
tenantModel: TenantModel;
|
|
8
|
+
planModel: PlanModel;
|
|
9
|
+
featureModel: FeatureModel;
|
|
10
|
+
private buildCatalog;
|
|
11
|
+
getCurrentPlan(_user: User, ctx: any, tenantSubscriptionModel: TenantSubscriptionModel): Promise<CurrentPlanResult>;
|
|
12
|
+
cancelPendingChange(user: User, ctx: any, tenantSubscriptionModel: TenantSubscriptionModel): Promise<ChangePlanResult>;
|
|
13
|
+
changePlan(user: User, body: ChangePlanBody, ctx: any, tenantSubscriptionModel: TenantSubscriptionModel, tenantBillingInfoModel: TenantBillingInfoModel): Promise<ChangePlanResult>;
|
|
14
|
+
private assertPlanChangeAllowed;
|
|
15
|
+
private resolveSamePlanRequest;
|
|
16
|
+
private routePlanChange;
|
|
17
|
+
private changeExistingSubscription;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SaasTenantPlanController = void 0;
|
|
16
|
+
const interface_api_1 = require("@antelopejs/interface-api");
|
|
17
|
+
const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
18
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
19
|
+
const db_1 = require("@antelopejs/interface-dms/db");
|
|
20
|
+
const guards_1 = require("@antelopejs/interface-dms/guards");
|
|
21
|
+
const request_tenant_1 = require("@antelopejs/interface-dms/request-tenant");
|
|
22
|
+
const tenant_scoped_model_1 = require("@antelopejs/interface-dms/tenant-scoped-model");
|
|
23
|
+
const tenant_access_1 = require("@antelopejs/interface-dms/tenant-access");
|
|
24
|
+
const db_2 = require("../../db");
|
|
25
|
+
const plan_changes_1 = require("../../plan-changes");
|
|
26
|
+
const plans_1 = require("../../plans");
|
|
27
|
+
const complimentary_1 = require("../../workspaces/complimentary");
|
|
28
|
+
const tenant_plan_ops_1 = require("./tenant-plan-ops");
|
|
29
|
+
class SaasTenantPlanController extends (0, interface_api_1.Controller)("/api/saas/tenant/plan") {
|
|
30
|
+
async buildCatalog(current) {
|
|
31
|
+
const publicPlans = await this.planModel.findPubliclyVisible();
|
|
32
|
+
const withCurrent = current && !publicPlans.some((plan) => plan._id === current._id)
|
|
33
|
+
? [...publicPlans, current]
|
|
34
|
+
: publicPlans;
|
|
35
|
+
return (0, plans_1.buildTenantPlanCatalog)(this.planModel, this.featureModel, withCurrent);
|
|
36
|
+
}
|
|
37
|
+
async getCurrentPlan(_user, ctx, tenantSubscriptionModel) {
|
|
38
|
+
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
39
|
+
const tenant = await this.tenantModel.get(tenantId);
|
|
40
|
+
(0, interface_api_util_1.assert)(tenant, tenant_plan_ops_1.HTTP_NOT_FOUND, "saas.errors.workspace.not_found");
|
|
41
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
42
|
+
const current = subscription?.planId
|
|
43
|
+
? ((await this.planModel.get(subscription.planId)) ?? null)
|
|
44
|
+
: null;
|
|
45
|
+
const pending = subscription?.pendingPlanId
|
|
46
|
+
? await this.planModel.get(subscription.pendingPlanId)
|
|
47
|
+
: null;
|
|
48
|
+
const catalog = await this.buildCatalog(current);
|
|
49
|
+
return {
|
|
50
|
+
current,
|
|
51
|
+
available: catalog.plans,
|
|
52
|
+
features: catalog.features,
|
|
53
|
+
status: subscription?.status ?? null,
|
|
54
|
+
freeUntil: subscription?.freeUntil ?? null,
|
|
55
|
+
isComplimentary: (0, complimentary_1.isComplimentarySubscription)(subscription),
|
|
56
|
+
isPlanChangeLocked: (0, complimentary_1.isComplimentaryPlanLocked)(subscription),
|
|
57
|
+
canRecoverComplimentary: (0, complimentary_1.canRecoverComplimentarySubscription)(subscription),
|
|
58
|
+
paidUsageStartedAt: subscription?.paidUsageStartedAt ?? null,
|
|
59
|
+
paidUsagePeriods: subscription?.paidUsagePeriods ?? null,
|
|
60
|
+
currentPeriodEnd: subscription?.currentPeriodEnd ?? null,
|
|
61
|
+
pendingPlan: (0, plan_changes_1.toPendingPlanChange)(subscription, pending),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async cancelPendingChange(user, ctx, tenantSubscriptionModel) {
|
|
65
|
+
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
66
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
67
|
+
this.assertPlanChangeAllowed(subscription, user);
|
|
68
|
+
(0, interface_api_util_1.assert)(subscription?.pendingPlanId, tenant_plan_ops_1.HTTP_BAD_REQUEST, "saas.errors.plan.no_pending_change");
|
|
69
|
+
return (0, tenant_plan_ops_1.dropPendingChange)(tenantId, subscription);
|
|
70
|
+
}
|
|
71
|
+
async changePlan(user, body, ctx, tenantSubscriptionModel, tenantBillingInfoModel) {
|
|
72
|
+
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
73
|
+
const tenant = await this.tenantModel.get(tenantId);
|
|
74
|
+
(0, interface_api_util_1.assert)(tenant, tenant_plan_ops_1.HTTP_NOT_FOUND, "saas.errors.workspace.not_found");
|
|
75
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
76
|
+
this.assertPlanChangeAllowed(subscription, user);
|
|
77
|
+
const isRecovery = (0, complimentary_1.canRecoverComplimentarySubscription)(subscription);
|
|
78
|
+
if (!isRecovery)
|
|
79
|
+
await (0, tenant_access_1.AssertTenantAccess)(user._id, tenantId);
|
|
80
|
+
const billingInfo = await tenantBillingInfoModel.findOne();
|
|
81
|
+
const newPlan = await (0, tenant_plan_ops_1.loadAndValidateTargetPlan)(this.planModel, body.planId, billingInfo?.customerType);
|
|
82
|
+
await (0, tenant_plan_ops_1.assertSeatLimit)(tenantId, newPlan);
|
|
83
|
+
(0, interface_api_util_1.assert)(!isRecovery || (0, tenant_plan_ops_1.isPaidPlan)(newPlan), tenant_plan_ops_1.HTTP_CONFLICT, "saas.errors.plan.paid_recovery_required");
|
|
84
|
+
if (subscription?.planId === body.planId && !isRecovery) {
|
|
85
|
+
return this.resolveSamePlanRequest(tenantId, subscription);
|
|
86
|
+
}
|
|
87
|
+
return this.routePlanChange({
|
|
88
|
+
tenantId,
|
|
89
|
+
user,
|
|
90
|
+
newPlan,
|
|
91
|
+
body,
|
|
92
|
+
subscription,
|
|
93
|
+
tenantSubscriptionModel,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
assertPlanChangeAllowed(subscription, user) {
|
|
97
|
+
(0, interface_api_util_1.assert)(user.owner || !(0, complimentary_1.isComplimentaryPlanLocked)(subscription), tenant_plan_ops_1.HTTP_CONFLICT, "saas.errors.plan.complimentary_locked");
|
|
98
|
+
}
|
|
99
|
+
async resolveSamePlanRequest(tenantId, subscription) {
|
|
100
|
+
if (subscription.pendingPlanId) {
|
|
101
|
+
return (0, tenant_plan_ops_1.dropPendingChange)(tenantId, subscription);
|
|
102
|
+
}
|
|
103
|
+
return { ...tenant_plan_ops_1.UNCHANGED_RESULT_BASE, planId: subscription.planId ?? "" };
|
|
104
|
+
}
|
|
105
|
+
async routePlanChange(request) {
|
|
106
|
+
const { tenantId, user, newPlan, subscription, tenantSubscriptionModel } = request;
|
|
107
|
+
if ((0, tenant_plan_ops_1.isPaidPlan)(newPlan) && !subscription?.stripeSubscriptionId) {
|
|
108
|
+
return (0, tenant_plan_ops_1.startPaidCheckout)(request);
|
|
109
|
+
}
|
|
110
|
+
if (!subscription) {
|
|
111
|
+
return (0, tenant_plan_ops_1.insertFreeSubscription)(user, newPlan._id, tenantId, tenantSubscriptionModel);
|
|
112
|
+
}
|
|
113
|
+
return this.changeExistingSubscription(request, subscription);
|
|
114
|
+
}
|
|
115
|
+
async changeExistingSubscription(request, subscription) {
|
|
116
|
+
const { tenantId, newPlan, tenantSubscriptionModel } = request;
|
|
117
|
+
const currentPlan = subscription.planId
|
|
118
|
+
? ((await this.planModel.get(subscription.planId)) ?? null)
|
|
119
|
+
: null;
|
|
120
|
+
const isDeferred = !!subscription.stripeSubscriptionId &&
|
|
121
|
+
(!(0, tenant_plan_ops_1.isPaidPlan)(newPlan) || (0, plans_1.isDowngrade)(currentPlan, newPlan));
|
|
122
|
+
if (isDeferred) {
|
|
123
|
+
(0, interface_api_util_1.assert)(subscription.status !== tenant_plan_ops_1.PAST_DUE_STATUS, tenant_plan_ops_1.HTTP_CONFLICT, "saas.errors.plan.unpaid_invoice_blocks_downgrade");
|
|
124
|
+
return (0, tenant_plan_ops_1.scheduleDowngrade)(tenantId, subscription, newPlan);
|
|
125
|
+
}
|
|
126
|
+
return (0, tenant_plan_ops_1.applyImmediateChange)(tenantId, subscription, newPlan, tenantSubscriptionModel);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.SaasTenantPlanController = SaasTenantPlanController;
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, interface_database_decorators_1.Model)(db_1.TenantModel),
|
|
132
|
+
__metadata("design:type", db_1.TenantModel)
|
|
133
|
+
], SaasTenantPlanController.prototype, "tenantModel", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, interface_database_decorators_1.Model)(db_2.PlanModel),
|
|
136
|
+
__metadata("design:type", db_2.PlanModel)
|
|
137
|
+
], SaasTenantPlanController.prototype, "planModel", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, interface_database_decorators_1.Model)(db_2.FeatureModel),
|
|
140
|
+
__metadata("design:type", db_2.FeatureModel)
|
|
141
|
+
], SaasTenantPlanController.prototype, "featureModel", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, interface_api_1.Get)("/"),
|
|
144
|
+
__param(0, (0, guards_1.AuthTenantMember)({ bypassTenantAccessGate: true })),
|
|
145
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
146
|
+
__param(2, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantSubscriptionModel)),
|
|
147
|
+
__metadata("design:type", Function),
|
|
148
|
+
__metadata("design:paramtypes", [Function, Object, db_2.TenantSubscriptionModel]),
|
|
149
|
+
__metadata("design:returntype", Promise)
|
|
150
|
+
], SaasTenantPlanController.prototype, "getCurrentPlan", null);
|
|
151
|
+
__decorate([
|
|
152
|
+
(0, interface_api_1.Delete)("/pending"),
|
|
153
|
+
__param(0, (0, guards_1.AuthTenantOwner)()),
|
|
154
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
155
|
+
__param(2, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantSubscriptionModel)),
|
|
156
|
+
__metadata("design:type", Function),
|
|
157
|
+
__metadata("design:paramtypes", [Function, Object, db_2.TenantSubscriptionModel]),
|
|
158
|
+
__metadata("design:returntype", Promise)
|
|
159
|
+
], SaasTenantPlanController.prototype, "cancelPendingChange", null);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, interface_api_1.Put)("/"),
|
|
162
|
+
__param(0, (0, guards_1.AuthTenantOwner)({ bypassTenantAccessGate: true })),
|
|
163
|
+
__param(1, (0, interface_api_1.JSONBody)()),
|
|
164
|
+
__param(2, (0, interface_api_1.Context)()),
|
|
165
|
+
__param(3, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantSubscriptionModel)),
|
|
166
|
+
__param(4, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantBillingInfoModel)),
|
|
167
|
+
__metadata("design:type", Function),
|
|
168
|
+
__metadata("design:paramtypes", [Function, Object, Object, db_2.TenantSubscriptionModel,
|
|
169
|
+
db_2.TenantBillingInfoModel]),
|
|
170
|
+
__metadata("design:returntype", Promise)
|
|
171
|
+
], SaasTenantPlanController.prototype, "changePlan", null);
|
|
172
|
+
//# sourceMappingURL=tenant-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-plan.js","sourceRoot":"","sources":["../../../src/routes/tenant/tenant-plan.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAOmC;AACnC,uEAAwD;AACxD,6FAAkE;AAClE,qDAA2D;AAC3D,6DAG0C;AAC1C,6EAA8E;AAC9E,uFAAkF;AAClF,2EAA6E;AAE7E,iCAOkB;AAClB,qDAAyD;AACzD,uCAAkE;AAClE,kEAIwC;AAExC,uDAkB2B;AAE3B,MAAa,wBAAyB,SAAQ,IAAA,0BAAU,EACtD,uBAAuB,CACxB;IAUS,KAAK,CAAC,YAAY,CAAC,OAAoB;QAC7C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC;QAC/D,MAAM,WAAW,GACf,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE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@antelopejs/interface-api";
|
|
2
|
+
import { TenantMemberModel } from "@antelopejs/interface-dms/db";
|
|
3
|
+
import type { User } from "@antelopejs/interface-dms/auth/db";
|
|
4
|
+
import { PlanModel, TenantSubscriptionModel } from "../../db";
|
|
5
|
+
interface SeatQuotaResult {
|
|
6
|
+
members: number;
|
|
7
|
+
pendingInvites: number;
|
|
8
|
+
occupied: number;
|
|
9
|
+
maxMembers: number | null;
|
|
10
|
+
isTenantOwner: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const SaasTenantSeatsController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
13
|
+
export declare class SaasTenantSeatsController extends SaasTenantSeatsController_base {
|
|
14
|
+
planModel: PlanModel;
|
|
15
|
+
getSeatQuota(ctx: RequestContext, user: User, tenantSubscriptionModel: TenantSubscriptionModel, tenantMemberModel: TenantMemberModel): Promise<SeatQuotaResult>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SaasTenantSeatsController = void 0;
|
|
16
|
+
const interface_api_1 = require("@antelopejs/interface-api");
|
|
17
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
18
|
+
const db_1 = require("@antelopejs/interface-dms/db");
|
|
19
|
+
const guards_1 = require("@antelopejs/interface-dms/guards");
|
|
20
|
+
const request_tenant_1 = require("@antelopejs/interface-dms/request-tenant");
|
|
21
|
+
const tenant_scoped_model_1 = require("@antelopejs/interface-dms/tenant-scoped-model");
|
|
22
|
+
const db_2 = require("../../db");
|
|
23
|
+
const plans_1 = require("../../plans");
|
|
24
|
+
class SaasTenantSeatsController extends (0, interface_api_1.Controller)("/api/saas/tenant/seats") {
|
|
25
|
+
async getSeatQuota(ctx, user, tenantSubscriptionModel, tenantMemberModel) {
|
|
26
|
+
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
27
|
+
const [usage, subscription, membership] = await Promise.all([
|
|
28
|
+
(0, plans_1.getSeatUsage)(tenantId),
|
|
29
|
+
tenantSubscriptionModel.findOne(),
|
|
30
|
+
tenantMemberModel.getByUser(user._id),
|
|
31
|
+
]);
|
|
32
|
+
const plan = subscription?.planId
|
|
33
|
+
? await this.planModel.get(subscription.planId)
|
|
34
|
+
: null;
|
|
35
|
+
return {
|
|
36
|
+
...usage,
|
|
37
|
+
maxMembers: plan?.maxMembers ?? null,
|
|
38
|
+
isTenantOwner: !!membership?.isTenantOwner,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.SaasTenantSeatsController = SaasTenantSeatsController;
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, interface_database_decorators_1.Model)(db_2.PlanModel),
|
|
45
|
+
__metadata("design:type", db_2.PlanModel)
|
|
46
|
+
], SaasTenantSeatsController.prototype, "planModel", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, interface_api_1.Get)("/"),
|
|
49
|
+
__param(0, (0, interface_api_1.Context)()),
|
|
50
|
+
__param(1, (0, guards_1.AuthTenantMember)()),
|
|
51
|
+
__param(2, (0, tenant_scoped_model_1.TenantScopedModel)(db_2.TenantSubscriptionModel)),
|
|
52
|
+
__param(3, (0, tenant_scoped_model_1.TenantScopedModel)(db_1.TenantMemberModel)),
|
|
53
|
+
__metadata("design:type", Function),
|
|
54
|
+
__metadata("design:paramtypes", [Object, Function, db_2.TenantSubscriptionModel,
|
|
55
|
+
db_1.TenantMemberModel]),
|
|
56
|
+
__metadata("design:returntype", Promise)
|
|
57
|
+
], SaasTenantSeatsController.prototype, "getSeatQuota", null);
|
|
58
|
+
//# sourceMappingURL=tenant-seats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-seats.js","sourceRoot":"","sources":["../../../src/routes/tenant/tenant-seats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAKmC;AACnC,6FAAkE;AAClE,qDAAiE;AACjE,6DAAoE;AACpE,6EAA8E;AAC9E,uFAAkF;AAElF,iCAA8D;AAC9D,uCAA2C;AAe3C,MAAa,yBAA0B,SAAQ,IAAA,0BAAU,EACvD,wBAAwB,CACzB;IAKO,AAAN,KAAK,CAAC,YAAY,CACL,GAAmB,EACV,IAAU,EAE9B,uBAAgD,EAEhD,iBAAoC;QAEpC,MAAM,QAAQ,GAAG,IAAA,mCAAkB,EAAC,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1D,IAAA,oBAAY,EAAC,QAAQ,CAAC;YACtB,uBAAuB,CAAC,OAAO,EAAE;YACjC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;SACtC,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,EAAE,MAAM;YAC/B,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;YAC/C,CAAC,CAAC,IAAI,CAAC;QACT,OAAO;YACL,GAAG,KAAK;YACR,UAAU,EAAE,IAAI,EAAE,UAAU,IAAI,IAAI;YACpC,aAAa,EAAE,CAAC,CAAC,UAAU,EAAE,aAAa;SAC3C,CAAC;IACJ,CAAC;CACF;AA9BD,8DA8BC;AA1BS;IADP,IAAA,qCAAK,EAAC,cAAS,CAAC;8BACE,cAAS;4DAAC;AAGvB;IADL,IAAA,mBAAG,EAAC,GAAG,CAAC;IAEN,WAAA,IAAA,uBAAO,GAAE,CAAA;IACT,WAAA,IAAA,yBAAgB,GAAE,CAAA;IAClB,WAAA,IAAA,uCAAiB,EAAC,4BAAuB,CAAC,CAAA;IAE1C,WAAA,IAAA,uCAAiB,EAAC,sBAAiB,CAAC,CAAA;;uDADZ,4BAAuB;QAE7B,sBAAiB;;6DAgBrC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type RequestContext } from "@antelopejs/interface-api";
|
|
2
|
+
import { TenantModel } from "@antelopejs/interface-dms/db";
|
|
3
|
+
import { type User, UserModel } from "@antelopejs/interface-dms/auth/db";
|
|
4
|
+
import { type CreditNote, type Invoice, PlanModel, type TenantBillingInfo, type TenantSubscription } from "../../db";
|
|
5
|
+
import { type CardSetupIntent } from "../../stripe";
|
|
6
|
+
import type { FreePlanAvailability, WorkspaceDeletionResult } from "../../workspaces";
|
|
7
|
+
interface MyWorkspaceRow {
|
|
8
|
+
_id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
planName: string | null;
|
|
11
|
+
isCurrent: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface WorkspaceCreateOptions {
|
|
14
|
+
freePlan: FreePlanAvailability;
|
|
15
|
+
}
|
|
16
|
+
interface WorkspaceCreateBody {
|
|
17
|
+
workspaceName?: string;
|
|
18
|
+
planId: string;
|
|
19
|
+
paymentMethodId?: string;
|
|
20
|
+
}
|
|
21
|
+
interface CreatedWorkspace {
|
|
22
|
+
tenantId: string;
|
|
23
|
+
}
|
|
24
|
+
interface CurrentWorkspace {
|
|
25
|
+
_id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
retentionDays: number;
|
|
28
|
+
}
|
|
29
|
+
interface WorkspaceRenameBody {
|
|
30
|
+
name?: string;
|
|
31
|
+
}
|
|
32
|
+
interface RenamedWorkspace {
|
|
33
|
+
_id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
}
|
|
36
|
+
interface WorkspaceMemberRow {
|
|
37
|
+
_id: string;
|
|
38
|
+
userId: string;
|
|
39
|
+
email: string;
|
|
40
|
+
name: string | null;
|
|
41
|
+
isTenantOwner: boolean;
|
|
42
|
+
joinedAt: Date;
|
|
43
|
+
}
|
|
44
|
+
declare const SaasWorkspacesController_base: import("@antelopejs/interface-api").ControllerClass<object>;
|
|
45
|
+
export declare class SaasWorkspacesController extends SaasWorkspacesController_base {
|
|
46
|
+
tenantModel: TenantModel;
|
|
47
|
+
userModel: UserModel;
|
|
48
|
+
planModel: PlanModel;
|
|
49
|
+
private resolveSubscriptionSummaries;
|
|
50
|
+
listMine(user: User, ctx: RequestContext): Promise<MyWorkspaceRow[]>;
|
|
51
|
+
createOptions(user: User): Promise<WorkspaceCreateOptions>;
|
|
52
|
+
setupIntent(user: User): Promise<CardSetupIntent>;
|
|
53
|
+
private prepareSelfServeCreation;
|
|
54
|
+
createMine(user: User, ctx: RequestContext, body: WorkspaceCreateBody): Promise<CreatedWorkspace>;
|
|
55
|
+
getCurrent(_user: User, ctx: RequestContext): Promise<CurrentWorkspace>;
|
|
56
|
+
renameCurrent(_user: User, ctx: RequestContext, body: WorkspaceRenameBody): Promise<RenamedWorkspace>;
|
|
57
|
+
deleteCurrent(_user: User, ctx: RequestContext): Promise<WorkspaceDeletionResult>;
|
|
58
|
+
getDetail(_user: User, id: string): Promise<{
|
|
59
|
+
_id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
status: "active" | "suspended" | "cancelled" | "trialing" | "past_due" | "pending_payment" | null;
|
|
63
|
+
planId: string | null;
|
|
64
|
+
planName: string | null;
|
|
65
|
+
currency: string;
|
|
66
|
+
mrr: number;
|
|
67
|
+
membersCount: number;
|
|
68
|
+
subscription: TenantSubscription | null;
|
|
69
|
+
billingInfo: TenantBillingInfo | null;
|
|
70
|
+
members: WorkspaceMemberRow[];
|
|
71
|
+
invoices: Invoice[];
|
|
72
|
+
creditNotes: CreditNote[];
|
|
73
|
+
}>;
|
|
74
|
+
joinAsMember(user: User, id: string): Promise<{
|
|
75
|
+
joined: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
export {};
|