@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,301 @@
|
|
|
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.SaasWorkspacesController = 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_1 = require("@antelopejs/interface-database");
|
|
19
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
20
|
+
const db_1 = require("@antelopejs/interface-dms/db");
|
|
21
|
+
const guards_1 = require("@antelopejs/interface-dms/guards");
|
|
22
|
+
const request_tenant_1 = require("@antelopejs/interface-dms/request-tenant");
|
|
23
|
+
const tenant_ownership_1 = require("@antelopejs/interface-dms/tenant-ownership");
|
|
24
|
+
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
25
|
+
const db_2 = require("@antelopejs/interface-dms/auth/db");
|
|
26
|
+
const db_3 = require("../../db");
|
|
27
|
+
const stripe_1 = require("../../stripe");
|
|
28
|
+
const config_1 = require("../../config");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
30
|
+
const workspaces_1 = require("../../workspaces");
|
|
31
|
+
const HTTP_NOT_FOUND = 404;
|
|
32
|
+
const HTTP_CONFLICT = 409;
|
|
33
|
+
const HTTP_BAD_REQUEST = 400;
|
|
34
|
+
const CANCELLED_STATUS = "cancelled";
|
|
35
|
+
async function buildMemberRows(members, userModel) {
|
|
36
|
+
const memberUsers = await Promise.all(members.map((m) => userModel.get(m.userId)));
|
|
37
|
+
return members.map((m, i) => ({
|
|
38
|
+
_id: m._id,
|
|
39
|
+
userId: m.userId,
|
|
40
|
+
email: memberUsers[i]?.email ?? m.userId,
|
|
41
|
+
name: memberUsers[i]?.name ?? null,
|
|
42
|
+
isTenantOwner: m.isTenantOwner,
|
|
43
|
+
joinedAt: m.joinedAt,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
function sortByIssuedAtDesc(items) {
|
|
47
|
+
return items
|
|
48
|
+
.slice()
|
|
49
|
+
.sort((a, b) => +new Date(b.issuedAt) - +new Date(a.issuedAt));
|
|
50
|
+
}
|
|
51
|
+
async function loadWorkspaceRelations(tenantId, planModel) {
|
|
52
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_3.TenantSubscriptionModel, tenantId);
|
|
53
|
+
const tenantBillingInfoModel = (0, interface_database_decorators_1.GetModel)(db_3.TenantBillingInfoModel, tenantId);
|
|
54
|
+
const memberModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, tenantId);
|
|
55
|
+
const invoiceModel = (0, interface_database_decorators_1.GetModel)(db_3.InvoiceModel, tenantId);
|
|
56
|
+
const creditNoteModel = (0, interface_database_decorators_1.GetModel)(db_3.CreditNoteModel, tenantId);
|
|
57
|
+
const [subscription, billingInfo, members, invoices, creditNotes] = await Promise.all([
|
|
58
|
+
tenantSubscriptionModel.findOne(),
|
|
59
|
+
tenantBillingInfoModel.findOne(),
|
|
60
|
+
memberModel.listAll(),
|
|
61
|
+
invoiceModel.getAllInvoices(),
|
|
62
|
+
creditNoteModel.getAll(),
|
|
63
|
+
]);
|
|
64
|
+
const plan = subscription?.planId
|
|
65
|
+
? ((await planModel.get(subscription.planId)) ?? null)
|
|
66
|
+
: null;
|
|
67
|
+
return { subscription, billingInfo, members, invoices, creditNotes, plan };
|
|
68
|
+
}
|
|
69
|
+
class SaasWorkspacesController extends (0, interface_api_1.Controller)("/api/saas/workspaces") {
|
|
70
|
+
async resolveSubscriptionSummaries(tenantIds) {
|
|
71
|
+
const subscriptions = await Promise.all(tenantIds.map((tenantId) => (0, interface_database_decorators_1.GetModel)(db_3.TenantSubscriptionModel, tenantId).findOne()));
|
|
72
|
+
const plans = await Promise.all(subscriptions.map((subscription) => subscription?.planId ? this.planModel.get(subscription.planId) : null));
|
|
73
|
+
return new Map(tenantIds.map((tenantId, index) => [
|
|
74
|
+
tenantId,
|
|
75
|
+
{
|
|
76
|
+
planName: plans[index]?.name ?? null,
|
|
77
|
+
status: subscriptions[index]?.status ?? null,
|
|
78
|
+
},
|
|
79
|
+
]));
|
|
80
|
+
}
|
|
81
|
+
async listMine(user, ctx) {
|
|
82
|
+
const currentTenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
83
|
+
const memberModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, interface_database_1.CROSS_INSTANCE);
|
|
84
|
+
const memberships = await memberModel.listByUserWithTenantIds(user._id);
|
|
85
|
+
if (memberships.length === 0)
|
|
86
|
+
return [];
|
|
87
|
+
const tenants = await this.tenantModel.getMany(memberships.map((m) => m.tenantId));
|
|
88
|
+
const summaries = await this.resolveSubscriptionSummaries(tenants.map((tenant) => tenant._id));
|
|
89
|
+
return (tenants
|
|
90
|
+
.filter((tenant) => summaries.get(tenant._id)?.status !== CANCELLED_STATUS)
|
|
91
|
+
.map((tenant) => ({
|
|
92
|
+
_id: tenant._id,
|
|
93
|
+
name: tenant.name,
|
|
94
|
+
planName: summaries.get(tenant._id)?.planName ?? null,
|
|
95
|
+
isCurrent: tenant._id === currentTenantId,
|
|
96
|
+
})));
|
|
97
|
+
}
|
|
98
|
+
async createOptions(user) {
|
|
99
|
+
(0, config_1.assertAdmissionOpen)(user.owner);
|
|
100
|
+
return { freePlan: await (0, workspaces_1.resolveFreePlanAvailabilityForUser)(user._id) };
|
|
101
|
+
}
|
|
102
|
+
async setupIntent(user) {
|
|
103
|
+
(0, config_1.assertAdmissionOpen)(user.owner);
|
|
104
|
+
return (0, stripe_1.createCardSetupIntent)();
|
|
105
|
+
}
|
|
106
|
+
async prepareSelfServeCreation(user, ctx, body) {
|
|
107
|
+
(0, config_1.assertAdmissionOpen)(user.owner);
|
|
108
|
+
const workspaceName = body.workspaceName?.trim();
|
|
109
|
+
(0, interface_api_util_1.assert)(workspaceName, HTTP_BAD_REQUEST, "saas.errors.workspace.name_required");
|
|
110
|
+
(0, interface_api_util_1.assert)(body.paymentMethodId, HTTP_BAD_REQUEST, "saas.errors.workspace.payment_method_required");
|
|
111
|
+
const card = await (0, workspaces_1.resolveCardDetails)(body.paymentMethodId);
|
|
112
|
+
const billingProfile = await (0, workspaces_1.resolveBillingProfileForNewWorkspace)(user._id, card, (0, request_tenant_1.getRequestTenantId)(ctx));
|
|
113
|
+
(0, workspaces_1.assertBillingCountry)(billingProfile.address);
|
|
114
|
+
const plan = await (0, workspaces_1.ensurePlanIsAvailableForCustomer)(body.planId, billingProfile.customerType);
|
|
115
|
+
await (0, workspaces_1.assertFreePlanAllowedForCard)(plan, card.fingerprint);
|
|
116
|
+
return {
|
|
117
|
+
workspaceName,
|
|
118
|
+
paymentMethodId: body.paymentMethodId,
|
|
119
|
+
planId: body.planId,
|
|
120
|
+
card,
|
|
121
|
+
billingProfile,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async createMine(user, ctx, body) {
|
|
125
|
+
const input = await this.prepareSelfServeCreation(user, ctx, body);
|
|
126
|
+
const handles = { userId: user._id };
|
|
127
|
+
try {
|
|
128
|
+
const { tenantId } = await (0, workspaces_1.provisionWorkspace)({
|
|
129
|
+
userId: user._id,
|
|
130
|
+
payload: {
|
|
131
|
+
...input.billingProfile,
|
|
132
|
+
workspaceName: input.workspaceName,
|
|
133
|
+
planId: input.planId,
|
|
134
|
+
paymentMethodId: input.paymentMethodId,
|
|
135
|
+
},
|
|
136
|
+
stripeCustomerProfile: {
|
|
137
|
+
...input.billingProfile,
|
|
138
|
+
email: user.email,
|
|
139
|
+
fallbackName: user.name,
|
|
140
|
+
paymentMethodId: input.paymentMethodId,
|
|
141
|
+
},
|
|
142
|
+
card: input.card,
|
|
143
|
+
handles,
|
|
144
|
+
});
|
|
145
|
+
return { tenantId };
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
await (0, workspaces_1.rollbackWorkspaceProvisioning)(handles);
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async getCurrent(_user, ctx) {
|
|
153
|
+
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
154
|
+
const tenant = await this.tenantModel.get(tenantId);
|
|
155
|
+
(0, interface_api_util_1.assert)(tenant, HTTP_NOT_FOUND, "saas.errors.workspace.not_found");
|
|
156
|
+
return {
|
|
157
|
+
_id: tenant._id,
|
|
158
|
+
name: tenant.name,
|
|
159
|
+
retentionDays: await (0, workspaces_1.resolveDataRetentionDays)(),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
async renameCurrent(_user, ctx, body) {
|
|
163
|
+
const tenantId = (0, request_tenant_1.getRequestTenantId)(ctx);
|
|
164
|
+
const name = body.name?.trim();
|
|
165
|
+
(0, interface_api_util_1.assert)(name, HTTP_BAD_REQUEST, "saas.errors.workspace.name_required");
|
|
166
|
+
await this.tenantModel.update(tenantId, { name, updatedAt: new Date() });
|
|
167
|
+
return { _id: tenantId, name };
|
|
168
|
+
}
|
|
169
|
+
async deleteCurrent(_user, ctx) {
|
|
170
|
+
return (0, workspaces_1.requestWorkspaceDeletion)((0, request_tenant_1.getRequestTenantId)(ctx));
|
|
171
|
+
}
|
|
172
|
+
async getDetail(_user, id) {
|
|
173
|
+
const tenant = await this.tenantModel.get(id);
|
|
174
|
+
(0, interface_api_util_1.assert)(tenant, HTTP_NOT_FOUND, "saas.errors.workspace.not_found");
|
|
175
|
+
const { subscription, billingInfo, members, invoices, creditNotes, plan } = await loadWorkspaceRelations(id, this.planModel);
|
|
176
|
+
const memberRows = await buildMemberRows(members, this.userModel);
|
|
177
|
+
const projection = (0, utils_1.buildWorkspaceProjection)({
|
|
178
|
+
tenant,
|
|
179
|
+
subscription,
|
|
180
|
+
billingInfo,
|
|
181
|
+
plan,
|
|
182
|
+
membersCount: members.length,
|
|
183
|
+
invoices,
|
|
184
|
+
now: new Date(),
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
_id: projection._id,
|
|
188
|
+
name: projection.name,
|
|
189
|
+
createdAt: projection.createdAt,
|
|
190
|
+
status: projection.status,
|
|
191
|
+
planId: projection.planId,
|
|
192
|
+
planName: projection.planName,
|
|
193
|
+
currency: projection.currency,
|
|
194
|
+
mrr: projection.mrr,
|
|
195
|
+
membersCount: projection.membersCount,
|
|
196
|
+
subscription: subscription ?? null,
|
|
197
|
+
billingInfo: billingInfo ?? null,
|
|
198
|
+
members: memberRows,
|
|
199
|
+
invoices: sortByIssuedAtDesc(invoices),
|
|
200
|
+
creditNotes: sortByIssuedAtDesc(creditNotes),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async joinAsMember(user, id) {
|
|
204
|
+
const tenant = await this.tenantModel.get(id);
|
|
205
|
+
(0, interface_api_util_1.assert)(tenant, HTTP_NOT_FOUND, "saas.errors.workspace.not_found");
|
|
206
|
+
const memberModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, id);
|
|
207
|
+
const existing = await memberModel.getByUser(user._id);
|
|
208
|
+
(0, interface_api_util_1.assert)(!existing, HTTP_CONFLICT, "saas.workspaces.join.already_member");
|
|
209
|
+
await (0, tenant_ownership_1.applyTenantOwnership)(this.userModel, user._id, id, {
|
|
210
|
+
roleIds: [],
|
|
211
|
+
isTenantOwner: false,
|
|
212
|
+
});
|
|
213
|
+
return { joined: true };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.SaasWorkspacesController = SaasWorkspacesController;
|
|
217
|
+
__decorate([
|
|
218
|
+
(0, interface_database_decorators_1.Model)(db_1.TenantModel),
|
|
219
|
+
__metadata("design:type", db_1.TenantModel)
|
|
220
|
+
], SaasWorkspacesController.prototype, "tenantModel", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
(0, interface_database_decorators_1.Model)(db_2.UserModel),
|
|
223
|
+
__metadata("design:type", db_2.UserModel)
|
|
224
|
+
], SaasWorkspacesController.prototype, "userModel", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
(0, interface_database_decorators_1.Model)(db_3.PlanModel),
|
|
227
|
+
__metadata("design:type", db_3.PlanModel)
|
|
228
|
+
], SaasWorkspacesController.prototype, "planModel", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
(0, interface_api_1.Get)("/mine"),
|
|
231
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
232
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
233
|
+
__metadata("design:type", Function),
|
|
234
|
+
__metadata("design:paramtypes", [Function, Object]),
|
|
235
|
+
__metadata("design:returntype", Promise)
|
|
236
|
+
], SaasWorkspacesController.prototype, "listMine", null);
|
|
237
|
+
__decorate([
|
|
238
|
+
(0, interface_api_1.Get)("/create-options"),
|
|
239
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
240
|
+
__metadata("design:type", Function),
|
|
241
|
+
__metadata("design:paramtypes", [Function]),
|
|
242
|
+
__metadata("design:returntype", Promise)
|
|
243
|
+
], SaasWorkspacesController.prototype, "createOptions", null);
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, interface_api_1.Get)("/setup-intent"),
|
|
246
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
247
|
+
__metadata("design:type", Function),
|
|
248
|
+
__metadata("design:paramtypes", [Function]),
|
|
249
|
+
__metadata("design:returntype", Promise)
|
|
250
|
+
], SaasWorkspacesController.prototype, "setupIntent", null);
|
|
251
|
+
__decorate([
|
|
252
|
+
(0, interface_api_1.Post)("/"),
|
|
253
|
+
__param(0, (0, auth_1.AuthRawUser)()),
|
|
254
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
255
|
+
__param(2, (0, interface_api_1.JSONBody)()),
|
|
256
|
+
__metadata("design:type", Function),
|
|
257
|
+
__metadata("design:paramtypes", [Function, Object, Object]),
|
|
258
|
+
__metadata("design:returntype", Promise)
|
|
259
|
+
], SaasWorkspacesController.prototype, "createMine", null);
|
|
260
|
+
__decorate([
|
|
261
|
+
(0, interface_api_1.Get)("/current"),
|
|
262
|
+
__param(0, (0, guards_1.AuthTenantOwner)()),
|
|
263
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
264
|
+
__metadata("design:type", Function),
|
|
265
|
+
__metadata("design:paramtypes", [Function, Object]),
|
|
266
|
+
__metadata("design:returntype", Promise)
|
|
267
|
+
], SaasWorkspacesController.prototype, "getCurrent", null);
|
|
268
|
+
__decorate([
|
|
269
|
+
(0, interface_api_1.Put)("/current"),
|
|
270
|
+
__param(0, (0, guards_1.AuthTenantOwner)()),
|
|
271
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
272
|
+
__param(2, (0, interface_api_1.JSONBody)()),
|
|
273
|
+
__metadata("design:type", Function),
|
|
274
|
+
__metadata("design:paramtypes", [Function, Object, Object]),
|
|
275
|
+
__metadata("design:returntype", Promise)
|
|
276
|
+
], SaasWorkspacesController.prototype, "renameCurrent", null);
|
|
277
|
+
__decorate([
|
|
278
|
+
(0, interface_api_1.Delete)("/current"),
|
|
279
|
+
__param(0, (0, guards_1.AuthTenantOwner)()),
|
|
280
|
+
__param(1, (0, interface_api_1.Context)()),
|
|
281
|
+
__metadata("design:type", Function),
|
|
282
|
+
__metadata("design:paramtypes", [Function, Object]),
|
|
283
|
+
__metadata("design:returntype", Promise)
|
|
284
|
+
], SaasWorkspacesController.prototype, "deleteCurrent", null);
|
|
285
|
+
__decorate([
|
|
286
|
+
(0, interface_api_1.Get)("/:id"),
|
|
287
|
+
__param(0, (0, auth_1.AuthOwnerOnly)()),
|
|
288
|
+
__param(1, (0, interface_api_1.Parameter)("id")),
|
|
289
|
+
__metadata("design:type", Function),
|
|
290
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
291
|
+
__metadata("design:returntype", Promise)
|
|
292
|
+
], SaasWorkspacesController.prototype, "getDetail", null);
|
|
293
|
+
__decorate([
|
|
294
|
+
(0, interface_api_1.Post)("/:id/join"),
|
|
295
|
+
__param(0, (0, auth_1.AuthOwnerOnly)()),
|
|
296
|
+
__param(1, (0, interface_api_1.Parameter)("id")),
|
|
297
|
+
__metadata("design:type", Function),
|
|
298
|
+
__metadata("design:paramtypes", [Function, String]),
|
|
299
|
+
__metadata("design:returntype", Promise)
|
|
300
|
+
], SaasWorkspacesController.prototype, "joinAsMember", null);
|
|
301
|
+
//# sourceMappingURL=workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../../src/routes/tenant/workspaces.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAUmC;AACnC,uEAAwD;AACxD,uEAAgE;AAChE,6FAA4E;AAC5E,qDAIsC;AACtC,6DAAmE;AACnE,6EAA8E;AAC9E,iFAAkF;AAClF,yDAA4E;AAC5E,0DAAyE;AACzE,iCAYkB;AAClB,yCAA2E;AAC3E,yCAAmD;AACnD,uCAAuD;AAQvD,iDAW0B;AAE1B,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,gBAAgB,GAA6B,WAAW,CAAC;AA4D/D,KAAK,UAAU,eAAe,CAC5B,OAAuB,EACvB,SAAoB;IAEpB,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CACnC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAC5C,CAAC;IACF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5B,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,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I,EAAC,WAAW,CAAC;IACE,WAAA,IAAA,oBAAa,GAAE,CAAA;IAAc,WAAA,IAAA,yBAAS,EAAC,IAAI,CAAC,CAAA;;;;4DAa/D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import type { DmsSaasStripeConfig } from "../types";
|
|
3
|
+
export declare function initStripeClient(config: DmsSaasStripeConfig): void;
|
|
4
|
+
export declare function isStripeConfigured(): boolean;
|
|
5
|
+
export declare function getStripeClient(): Stripe;
|
|
6
|
+
export declare function getStripeWebhookSecret(): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
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.initStripeClient = initStripeClient;
|
|
7
|
+
exports.isStripeConfigured = isStripeConfigured;
|
|
8
|
+
exports.getStripeClient = getStripeClient;
|
|
9
|
+
exports.getStripeWebhookSecret = getStripeWebhookSecret;
|
|
10
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
11
|
+
const STRIPE_API_VERSION = "2024-11-20.acacia";
|
|
12
|
+
const SECRET_KEY_PREFIX = "sk_";
|
|
13
|
+
const PLACEHOLDER_MARKER = "placeholder";
|
|
14
|
+
let stripeClient = null;
|
|
15
|
+
let stripeWebhookSecret = null;
|
|
16
|
+
let stripeConfigured = false;
|
|
17
|
+
function isUsableSecretKey(key) {
|
|
18
|
+
return (typeof key === "string" &&
|
|
19
|
+
key.startsWith(SECRET_KEY_PREFIX) &&
|
|
20
|
+
!key.includes(PLACEHOLDER_MARKER));
|
|
21
|
+
}
|
|
22
|
+
function initStripeClient(config) {
|
|
23
|
+
stripeClient = new stripe_1.default(config.secretKey, {
|
|
24
|
+
apiVersion: STRIPE_API_VERSION,
|
|
25
|
+
});
|
|
26
|
+
stripeWebhookSecret = config.webhookSecret;
|
|
27
|
+
stripeConfigured = isUsableSecretKey(config.secretKey);
|
|
28
|
+
}
|
|
29
|
+
function isStripeConfigured() {
|
|
30
|
+
return stripeConfigured;
|
|
31
|
+
}
|
|
32
|
+
function getStripeClient() {
|
|
33
|
+
if (!stripeClient) {
|
|
34
|
+
throw new Error("Stripe client not initialized. Call initStripeClient first.");
|
|
35
|
+
}
|
|
36
|
+
return stripeClient;
|
|
37
|
+
}
|
|
38
|
+
function getStripeWebhookSecret() {
|
|
39
|
+
if (!stripeWebhookSecret) {
|
|
40
|
+
throw new Error("Stripe webhook secret not initialized.");
|
|
41
|
+
}
|
|
42
|
+
return stripeWebhookSecret;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/stripe/client.ts"],"names":[],"mappings":";;;;;AAmBA,4CAMC;AAED,gDAEC;AAED,0CAOC;AAED,wDAKC;AA7CD,oDAA4B;AAG5B,MAAM,kBAAkB,GAAG,mBAA4B,CAAC;AACxD,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEzC,IAAI,YAAY,GAAkB,IAAI,CAAC;AACvC,IAAI,mBAAmB,GAAkB,IAAI,CAAC;AAC9C,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC;QACjC,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAClC,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,MAA2B;IAC1D,YAAY,GAAG,IAAI,gBAAM,CAAC,MAAM,CAAC,SAAS,EAAE;QAC1C,UAAU,EAAE,kBAA6C;KAC1D,CAAC,CAAC;IACH,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC;IAC3C,gBAAgB,GAAG,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,sBAAsB;IACpC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AvailableStripeCustomerBalance {
|
|
2
|
+
status: "available";
|
|
3
|
+
balanceMinorUnits: number;
|
|
4
|
+
currency: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface DeletedStripeCustomerBalance {
|
|
7
|
+
status: "deleted";
|
|
8
|
+
balanceMinorUnits: null;
|
|
9
|
+
currency: null;
|
|
10
|
+
}
|
|
11
|
+
export type StripeCustomerBalanceSnapshot = AvailableStripeCustomerBalance | DeletedStripeCustomerBalance;
|
|
12
|
+
export declare function retrieveStripeCustomerBalance(customerId: string): Promise<StripeCustomerBalanceSnapshot>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retrieveStripeCustomerBalance = retrieveStripeCustomerBalance;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
async function retrieveStripeCustomerBalance(customerId) {
|
|
6
|
+
const customer = await (0, client_1.getStripeClient)().customers.retrieve(customerId);
|
|
7
|
+
if (customer.deleted) {
|
|
8
|
+
return { status: "deleted", balanceMinorUnits: null, currency: null };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
status: "available",
|
|
12
|
+
balanceMinorUnits: customer.balance,
|
|
13
|
+
currency: customer.currency ?? null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=customer-balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-balance.js","sourceRoot":"","sources":["../../src/stripe/customer-balance.ts"],"names":[],"mappings":";;AAsBA,sEAYC;AAlCD,qCAA2C;AAsBpC,KAAK,UAAU,6BAA6B,CACjD,UAAkB;IAElB,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAe,GAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACxE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxE,CAAC;IACD,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,iBAAiB,EAAE,QAAQ,CAAC,OAAO;QACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,IAAI;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { TenantBillingAddress, VatVerificationStatus } from "../db";
|
|
3
|
+
export interface CustomerBillingAddress {
|
|
4
|
+
line1?: string | null;
|
|
5
|
+
line2?: string | null;
|
|
6
|
+
postalCode?: string | null;
|
|
7
|
+
city?: string | null;
|
|
8
|
+
state?: string | null;
|
|
9
|
+
country?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface CustomerBillingProfile {
|
|
12
|
+
customerType: "individual" | "business";
|
|
13
|
+
companyName?: string | null;
|
|
14
|
+
fallbackName?: string | null;
|
|
15
|
+
billingEmail?: string | null;
|
|
16
|
+
vatNumber?: string | null;
|
|
17
|
+
address?: CustomerBillingAddress;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveTaxIdType(country: string | null | undefined): string | undefined;
|
|
20
|
+
export declare function toStripeAddress(source: CustomerBillingAddress | undefined): Stripe.AddressParam | undefined;
|
|
21
|
+
export declare function toTenantBillingAddress(source: CustomerBillingAddress | undefined): TenantBillingAddress | null;
|
|
22
|
+
export interface CardSetupIntent {
|
|
23
|
+
clientSecret: string | null;
|
|
24
|
+
}
|
|
25
|
+
export declare function createCardSetupIntent(): Promise<CardSetupIntent>;
|
|
26
|
+
export declare function syncStripeCustomerBilling(customerId: string, profile: CustomerBillingProfile): Promise<void>;
|
|
27
|
+
export declare function toVatVerificationStatus(taxId: Stripe.TaxId): VatVerificationStatus;
|
|
28
|
+
export interface TaxIdSnapshot {
|
|
29
|
+
reachable: boolean;
|
|
30
|
+
taxId: Stripe.TaxId | null;
|
|
31
|
+
}
|
|
32
|
+
export declare function fetchPrimaryTaxId(customerId: string): Promise<TaxIdSnapshot>;
|
|
33
|
+
export declare function reconcileStripeTaxId(customerId: string, profile: Pick<CustomerBillingProfile, "customerType" | "vatNumber" | "address">): Promise<VatVerificationStatus | null>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveTaxIdType = resolveTaxIdType;
|
|
4
|
+
exports.toStripeAddress = toStripeAddress;
|
|
5
|
+
exports.toTenantBillingAddress = toTenantBillingAddress;
|
|
6
|
+
exports.createCardSetupIntent = createCardSetupIntent;
|
|
7
|
+
exports.syncStripeCustomerBilling = syncStripeCustomerBilling;
|
|
8
|
+
exports.toVatVerificationStatus = toVatVerificationStatus;
|
|
9
|
+
exports.fetchPrimaryTaxId = fetchPrimaryTaxId;
|
|
10
|
+
exports.reconcileStripeTaxId = reconcileStripeTaxId;
|
|
11
|
+
const client_1 = require("./client");
|
|
12
|
+
const VAT_VERIFICATION_BY_STRIPE_STATUS = {
|
|
13
|
+
pending: "pending",
|
|
14
|
+
verified: "verified",
|
|
15
|
+
unverified: "unverified",
|
|
16
|
+
unavailable: "unverified",
|
|
17
|
+
};
|
|
18
|
+
const CARD_PAYMENT_METHOD_TYPE = "card";
|
|
19
|
+
const OFF_SESSION_USAGE = "off_session";
|
|
20
|
+
const EU_VAT_COUNTRIES = new Set([
|
|
21
|
+
"AT",
|
|
22
|
+
"BE",
|
|
23
|
+
"BG",
|
|
24
|
+
"HR",
|
|
25
|
+
"CY",
|
|
26
|
+
"CZ",
|
|
27
|
+
"DK",
|
|
28
|
+
"EE",
|
|
29
|
+
"FI",
|
|
30
|
+
"FR",
|
|
31
|
+
"DE",
|
|
32
|
+
"GR",
|
|
33
|
+
"HU",
|
|
34
|
+
"IE",
|
|
35
|
+
"IT",
|
|
36
|
+
"LV",
|
|
37
|
+
"LT",
|
|
38
|
+
"LU",
|
|
39
|
+
"MT",
|
|
40
|
+
"NL",
|
|
41
|
+
"PL",
|
|
42
|
+
"PT",
|
|
43
|
+
"RO",
|
|
44
|
+
"SK",
|
|
45
|
+
"SI",
|
|
46
|
+
"ES",
|
|
47
|
+
"SE",
|
|
48
|
+
]);
|
|
49
|
+
const NON_EU_VAT_TAX_ID_TYPES = {
|
|
50
|
+
GB: "gb_vat",
|
|
51
|
+
CH: "ch_vat",
|
|
52
|
+
NO: "no_vat",
|
|
53
|
+
AU: "au_abn",
|
|
54
|
+
NZ: "nz_gst",
|
|
55
|
+
CA: "ca_gst_hst",
|
|
56
|
+
};
|
|
57
|
+
function resolveTaxIdType(country) {
|
|
58
|
+
if (!country)
|
|
59
|
+
return undefined;
|
|
60
|
+
const code = country.trim().toUpperCase();
|
|
61
|
+
if (EU_VAT_COUNTRIES.has(code))
|
|
62
|
+
return "eu_vat";
|
|
63
|
+
return NON_EU_VAT_TAX_ID_TYPES[code];
|
|
64
|
+
}
|
|
65
|
+
function toStripeAddress(source) {
|
|
66
|
+
if (!source?.country)
|
|
67
|
+
return undefined;
|
|
68
|
+
return {
|
|
69
|
+
line1: source.line1 ?? undefined,
|
|
70
|
+
line2: source.line2 ?? undefined,
|
|
71
|
+
postal_code: source.postalCode ?? undefined,
|
|
72
|
+
city: source.city ?? undefined,
|
|
73
|
+
state: source.state ?? undefined,
|
|
74
|
+
country: source.country,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function toTenantBillingAddress(source) {
|
|
78
|
+
if (!source)
|
|
79
|
+
return null;
|
|
80
|
+
return {
|
|
81
|
+
line1: source.line1 ?? null,
|
|
82
|
+
line2: source.line2 ?? null,
|
|
83
|
+
postalCode: source.postalCode ?? null,
|
|
84
|
+
city: source.city ?? null,
|
|
85
|
+
state: source.state ?? null,
|
|
86
|
+
country: source.country ?? null,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function resolveCustomerName(profile) {
|
|
90
|
+
if (profile.customerType === "business") {
|
|
91
|
+
return profile.companyName ?? profile.fallbackName ?? undefined;
|
|
92
|
+
}
|
|
93
|
+
return profile.fallbackName ?? undefined;
|
|
94
|
+
}
|
|
95
|
+
async function createCardSetupIntent() {
|
|
96
|
+
const intent = await (0, client_1.getStripeClient)().setupIntents.create({
|
|
97
|
+
payment_method_types: [CARD_PAYMENT_METHOD_TYPE],
|
|
98
|
+
usage: OFF_SESSION_USAGE,
|
|
99
|
+
});
|
|
100
|
+
return { clientSecret: intent.client_secret };
|
|
101
|
+
}
|
|
102
|
+
async function syncStripeCustomerBilling(customerId, profile) {
|
|
103
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
104
|
+
await stripe.customers.update(customerId, {
|
|
105
|
+
name: resolveCustomerName(profile),
|
|
106
|
+
email: profile.billingEmail ?? undefined,
|
|
107
|
+
address: toStripeAddress(profile.address),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function toVatVerificationStatus(taxId) {
|
|
111
|
+
const status = taxId.verification?.status;
|
|
112
|
+
return (status && VAT_VERIFICATION_BY_STRIPE_STATUS[status]) ?? "pending";
|
|
113
|
+
}
|
|
114
|
+
async function fetchPrimaryTaxId(customerId) {
|
|
115
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
116
|
+
const taxIds = await stripe.customers
|
|
117
|
+
.listTaxIds(customerId)
|
|
118
|
+
.catch(() => null);
|
|
119
|
+
if (!taxIds)
|
|
120
|
+
return { reachable: false, taxId: null };
|
|
121
|
+
return { reachable: true, taxId: taxIds.data[0] ?? null };
|
|
122
|
+
}
|
|
123
|
+
async function reconcileStripeTaxId(customerId, profile) {
|
|
124
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
125
|
+
const existing = await stripe.customers.listTaxIds(customerId);
|
|
126
|
+
for (const taxId of existing.data) {
|
|
127
|
+
await stripe.customers.deleteTaxId(customerId, taxId.id);
|
|
128
|
+
}
|
|
129
|
+
if (profile.customerType !== "business" || !profile.vatNumber)
|
|
130
|
+
return null;
|
|
131
|
+
const type = resolveTaxIdType(profile.address?.country);
|
|
132
|
+
if (!type)
|
|
133
|
+
return null;
|
|
134
|
+
const created = await stripe.customers.createTaxId(customerId, {
|
|
135
|
+
type: type,
|
|
136
|
+
value: profile.vatNumber,
|
|
137
|
+
});
|
|
138
|
+
return toVatVerificationStatus(created);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=customer-billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-billing.js","sourceRoot":"","sources":["../../src/stripe/customer-billing.ts"],"names":[],"mappings":";;AA0EA,4CAOC;AAED,0CAYC;AAED,wDAYC;AAeD,sDAMC;AAED,8DAUC;AAED,0DAKC;AAWD,8CASC;AAUD,oDAoBC;AArMD,qCAA2C;AAI3C,MAAM,iCAAiC,GACrC;IACE,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,YAAY;CAC1B,CAAC;AAoBJ,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,iBAAiB,GAAG,aAAsB,CAAC;AAEjD,MAAM,gBA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QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE;QAC7D,IAAI,EAAE,IAAqC;QAC3C,KAAK,EAAE,OAAO,CAAC,SAAS;KACzB,CAAC,CAAC;IACH,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./client";
|
|
2
|
+
export * from "./customer-billing";
|
|
3
|
+
export * from "./plan-schedule";
|
|
4
|
+
export * from "./proration";
|
|
5
|
+
export * from "./sync-plan";
|
|
6
|
+
export * from "./webhook-dispatch";
|
|
7
|
+
export * from "./webhook-checkout";
|
|
8
|
+
export * from "./webhook-credit-notes";
|
|
9
|
+
export * from "./webhook-handlers";
|
|
10
|
+
export * from "./webhook-shared";
|
|
11
|
+
export * from "./workspace-checkout";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./customer-billing"), exports);
|
|
19
|
+
__exportStar(require("./plan-schedule"), exports);
|
|
20
|
+
__exportStar(require("./proration"), exports);
|
|
21
|
+
__exportStar(require("./sync-plan"), exports);
|
|
22
|
+
__exportStar(require("./webhook-dispatch"), exports);
|
|
23
|
+
__exportStar(require("./webhook-checkout"), exports);
|
|
24
|
+
__exportStar(require("./webhook-credit-notes"), exports);
|
|
25
|
+
__exportStar(require("./webhook-handlers"), exports);
|
|
26
|
+
__exportStar(require("./webhook-shared"), exports);
|
|
27
|
+
__exportStar(require("./workspace-checkout"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stripe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,qDAAmC;AACnC,kDAAgC;AAChC,8CAA4B;AAC5B,8CAA4B;AAC5B,qDAAmC;AACnC,qDAAmC;AACnC,yDAAuC;AACvC,qDAAmC;AACnC,mDAAiC;AACjC,uDAAqC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ScheduleDowngradeInput {
|
|
2
|
+
stripeSubscriptionId: string;
|
|
3
|
+
stripePriceId: string;
|
|
4
|
+
quantity?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function scheduleSubscriptionDowngrade(input: ScheduleDowngradeInput): Promise<Date | null>;
|
|
7
|
+
export declare function releaseSubscriptionSchedule(scheduleId: string): Promise<void>;
|
|
8
|
+
export declare function setSubscriptionCancelAtPeriodEnd(stripeSubscriptionId: string, cancelAtPeriodEnd: boolean): Promise<Date | null>;
|
|
9
|
+
export declare function resetSubscriptionPendingState(stripeSubscriptionId: string): Promise<void>;
|