@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,20 @@
|
|
|
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("./oauth-entry"), exports);
|
|
18
|
+
__exportStar(require("./plan-permissions-resolver"), exports);
|
|
19
|
+
__exportStar(require("./subscription-access-gate"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8DAA4C;AAC5C,6DAA2C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveEntryProvider = resolveEntryProvider;
|
|
4
|
+
function resolveEntryProvider(identities) {
|
|
5
|
+
const mostRecent = identities.reduce((latest, identity) => !latest || +new Date(identity.lastLoginAt) > +new Date(latest.lastLoginAt)
|
|
6
|
+
? identity
|
|
7
|
+
: latest, undefined);
|
|
8
|
+
return mostRecent?.provider ?? null;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=oauth-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-entry.js","sourceRoot":"","sources":["../../src/auth/oauth-entry.ts"],"names":[],"mappings":";;AAyBA,oDAWC;AAXD,SAAgB,oBAAoB,CAClC,UAA4C;IAE5C,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAClC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CACnB,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACxE,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,MAAM,EACZ,SAAS,CACV,CAAC;IACF,OAAO,UAAU,EAAE,QAAQ,IAAI,IAAI,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerPlanPermissionsResolver(): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPlanPermissionsResolver = registerPlanPermissionsResolver;
|
|
4
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
5
|
+
const db_1 = require("@antelopejs/interface-dms/db");
|
|
6
|
+
const permissions_resolver_1 = require("@antelopejs/interface-dms/permissions-resolver");
|
|
7
|
+
const db_2 = require("../db");
|
|
8
|
+
const RESOLVER_ID = "dms-saas.plan-intersection";
|
|
9
|
+
const RESOLVER_ORDER = 100;
|
|
10
|
+
const ALL_PERMISSIONS = "*";
|
|
11
|
+
async function intersectWithPlan(userId, tenantId, current) {
|
|
12
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_2.TenantSubscriptionModel, tenantId);
|
|
13
|
+
const planModel = (0, interface_database_decorators_1.GetModel)(db_2.PlanModel);
|
|
14
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
15
|
+
if (!subscription?.planId)
|
|
16
|
+
return current;
|
|
17
|
+
const plan = await planModel.get(subscription.planId);
|
|
18
|
+
if (!plan)
|
|
19
|
+
return current;
|
|
20
|
+
const resolved = await planModel.resolveInheritance(plan);
|
|
21
|
+
const allowed = new Set(resolved.permissions);
|
|
22
|
+
if (!current.has(ALL_PERMISSIONS)) {
|
|
23
|
+
const member = await (0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, tenantId).getByUser(userId);
|
|
24
|
+
if (member?.isTenantOwner) {
|
|
25
|
+
allowed.delete(ALL_PERMISSIONS);
|
|
26
|
+
return allowed;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const result = new Set();
|
|
30
|
+
for (const permission of current) {
|
|
31
|
+
if (permission === ALL_PERMISSIONS || allowed.has(permission)) {
|
|
32
|
+
result.add(permission);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function registerPlanPermissionsResolver() {
|
|
38
|
+
(0, permissions_resolver_1.RegisterPermissionsResolver)({
|
|
39
|
+
id: RESOLVER_ID,
|
|
40
|
+
order: RESOLVER_ORDER,
|
|
41
|
+
resolver: intersectWithPlan,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=plan-permissions-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-permissions-resolver.js","sourceRoot":"","sources":["../../src/auth/plan-permissions-resolver.ts"],"names":[],"mappings":";;AA+CA,0EAMC;AArDD,6FAAqE;AACrE,qDAAiE;AACjE,yFAA6F;AAC7F,8BAA2D;AAE3D,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACjD,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,eAAe,GAAG,GAAG,CAAC;AAM5B,KAAK,UAAU,iBAAiB,CAC9B,MAAc,EACd,QAAgB,EAChB,OAAoB;IAEpB,MAAM,uBAAuB,GAAG,IAAA,wCAAQ,EAAC,4BAAuB,EAAE,QAAQ,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,IAAA,wCAAQ,EAAC,cAAS,CAAC,CAAC;IAEtC,MAAM,YAAY,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,CAAC;IAC7D,IAAI,CAAC,YAAY,EAAE,MAAM;QAAE,OAAO,OAAO,CAAC;IAC1C,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,CAAC,IAAI;QAAE,OAAO,OAAO,CAAC;IAE1B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,IAAA,wCAAQ,EAAC,sBAAiB,EAAE,QAAQ,CAAC,CAAC,SAAS,CAClE,MAAM,CACP,CAAC;QACF,IAAI,MAAM,EAAE,aAAa,EAAE,CAAC;YAC1B,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAChC,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;QACjC,IAAI,UAAU,KAAK,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9D,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAGD,SAAgB,+BAA+B;IAC7C,IAAA,kDAA2B,EAAC;QAC1B,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TenantSubscriptionStatus } from "../db";
|
|
2
|
+
export declare const BLOCKING_STATUSES: Set<"active" | "suspended" | "cancelled" | "trialing" | "past_due" | "pending_payment">;
|
|
3
|
+
export declare const WORKSPACE_ACCESS_BLOCKED_CODE = "saas.errors.workspace.access_blocked";
|
|
4
|
+
export declare function isTenantSubscriptionBlocked(tenantId: string): Promise<{
|
|
5
|
+
blocked: boolean;
|
|
6
|
+
status?: TenantSubscriptionStatus;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function registerSubscriptionAccessGate(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WORKSPACE_ACCESS_BLOCKED_CODE = exports.BLOCKING_STATUSES = void 0;
|
|
4
|
+
exports.isTenantSubscriptionBlocked = isTenantSubscriptionBlocked;
|
|
5
|
+
exports.registerSubscriptionAccessGate = registerSubscriptionAccessGate;
|
|
6
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
7
|
+
const tenant_access_1 = require("@antelopejs/interface-dms/tenant-access");
|
|
8
|
+
const db_1 = require("../db");
|
|
9
|
+
const GATE_ID = "dms-saas.subscription-status";
|
|
10
|
+
const GATE_ORDER = 100;
|
|
11
|
+
exports.BLOCKING_STATUSES = new Set([
|
|
12
|
+
"pending_payment",
|
|
13
|
+
"suspended",
|
|
14
|
+
"cancelled",
|
|
15
|
+
]);
|
|
16
|
+
exports.WORKSPACE_ACCESS_BLOCKED_CODE = "saas.errors.workspace.access_blocked";
|
|
17
|
+
async function isTenantSubscriptionBlocked(tenantId) {
|
|
18
|
+
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenantId);
|
|
19
|
+
const subscription = await tenantSubscriptionModel.findOne();
|
|
20
|
+
if (subscription && exports.BLOCKING_STATUSES.has(subscription.status)) {
|
|
21
|
+
return { blocked: true, status: subscription.status };
|
|
22
|
+
}
|
|
23
|
+
return { blocked: false, status: subscription?.status };
|
|
24
|
+
}
|
|
25
|
+
function registerSubscriptionAccessGate() {
|
|
26
|
+
(0, tenant_access_1.RegisterTenantAccessGate)({
|
|
27
|
+
id: GATE_ID,
|
|
28
|
+
order: GATE_ORDER,
|
|
29
|
+
gate: async (_userId, tenantId) => {
|
|
30
|
+
const { blocked } = await isTenantSubscriptionBlocked(tenantId);
|
|
31
|
+
if (blocked) {
|
|
32
|
+
return { allowed: false, code: exports.WORKSPACE_ACCESS_BLOCKED_CODE };
|
|
33
|
+
}
|
|
34
|
+
return { allowed: true };
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=subscription-access-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-access-gate.js","sourceRoot":"","sources":["../../src/auth/subscription-access-gate.ts"],"names":[],"mappings":";;;AAsBA,kEASC;AAED,wEAYC;AA7CD,6FAAqE;AACrE,2EAAmF;AAEnF,8BAAgD;AAEhD,MAAM,OAAO,GAAG,8BAA8B,CAAC;AAC/C,MAAM,UAAU,GAAG,GAAG,CAAC;AAEV,QAAA,iBAAiB,GAAG,IAAI,GAAG,CAA2B;IACjE,iBAAiB;IACjB,WAAW;IACX,WAAW;CACZ,CAAC,CAAC;AAOU,QAAA,6BAA6B,GACxC,sCAAsC,CAAC;AAElC,KAAK,UAAU,2BAA2B,CAC/C,QAAgB;IAEhB,MAAM,uBAAuB,GAAG,IAAA,wCAAQ,EAAC,4BAAuB,EAAE,QAAQ,CAAC,CAAC;IAC5E,MAAM,YAAY,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,CAAC;IAC7D,IAAI,YAAY,IAAI,yBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AAC1D,CAAC;AAED,SAAgB,8BAA8B;IAC5C,IAAA,wCAAwB,EAAC;QACvB,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;YAChC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,2BAA2B,CAAC,QAAQ,CAAC,CAAC;YAChE,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,qCAA6B,EAAE,CAAC;YACjE,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface SubscriptionStartedEvent {
|
|
2
|
+
tenantId: string;
|
|
3
|
+
planId: string | null;
|
|
4
|
+
status: string;
|
|
5
|
+
stripeSubscriptionId: string;
|
|
6
|
+
trialConsumptionRecorded: boolean;
|
|
7
|
+
at: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SubscriptionCancelledEvent {
|
|
10
|
+
tenantId: string;
|
|
11
|
+
stripeSubscriptionId: string;
|
|
12
|
+
at: string;
|
|
13
|
+
}
|
|
14
|
+
export interface PaymentFailedEvent {
|
|
15
|
+
tenantId: string;
|
|
16
|
+
invoiceId: string;
|
|
17
|
+
invoiceNumber: string | null;
|
|
18
|
+
amountDue: number;
|
|
19
|
+
currency: string;
|
|
20
|
+
at: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TrialEndingEvent {
|
|
23
|
+
tenantId: string;
|
|
24
|
+
trialEndsAt: string | null;
|
|
25
|
+
at: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TenantDeletedEvent {
|
|
28
|
+
tenantId: string;
|
|
29
|
+
at: string;
|
|
30
|
+
operationId?: string;
|
|
31
|
+
}
|
|
32
|
+
interface AutomationEventPayloads {
|
|
33
|
+
"saas.subscription-started": SubscriptionStartedEvent;
|
|
34
|
+
"saas.subscription-cancelled": SubscriptionCancelledEvent;
|
|
35
|
+
"saas.payment-failed": PaymentFailedEvent;
|
|
36
|
+
"saas.trial-ending": TrialEndingEvent;
|
|
37
|
+
"saas.tenant-deleted": TenantDeletedEvent;
|
|
38
|
+
}
|
|
39
|
+
export type AutomationEventName = keyof AutomationEventPayloads;
|
|
40
|
+
export declare function emitAutomationEvent<E extends AutomationEventName>(event: E, payload: AutomationEventPayloads[E]): void;
|
|
41
|
+
export declare function emitTenantDeletedEvent(payload: TenantDeletedEvent): Promise<void>;
|
|
42
|
+
export declare function registerAutomationNodes(): void;
|
|
43
|
+
export declare function unregisterAutomationNodes(): void;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitAutomationEvent = emitAutomationEvent;
|
|
4
|
+
exports.emitTenantDeletedEvent = emitTenantDeletedEvent;
|
|
5
|
+
exports.registerAutomationNodes = registerAutomationNodes;
|
|
6
|
+
exports.unregisterAutomationNodes = unregisterAutomationNodes;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const interface_dms_automation_1 = require("@antelopejs/interface-dms-automation");
|
|
9
|
+
const notifications_1 = require("../notifications");
|
|
10
|
+
const operator_actions_1 = require("../operator-actions");
|
|
11
|
+
const eventListeners = new Map();
|
|
12
|
+
function listenersFor(event) {
|
|
13
|
+
const existing = eventListeners.get(event);
|
|
14
|
+
if (existing)
|
|
15
|
+
return existing;
|
|
16
|
+
const created = new Set();
|
|
17
|
+
eventListeners.set(event, created);
|
|
18
|
+
return created;
|
|
19
|
+
}
|
|
20
|
+
function emitAutomationEvent(event, payload) {
|
|
21
|
+
for (const listener of listenersFor(event)) {
|
|
22
|
+
try {
|
|
23
|
+
void Promise.resolve(listener(payload)).catch(() => undefined);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function emitTenantDeletedEvent(payload) {
|
|
30
|
+
for (const listener of listenersFor("saas.tenant-deleted"))
|
|
31
|
+
await listener(payload);
|
|
32
|
+
}
|
|
33
|
+
const EMPTY_CONFIG_SCHEMA = { type: "object", properties: {} };
|
|
34
|
+
const TENANT_ID_PROPERTY = { type: "string" };
|
|
35
|
+
const AT_PROPERTY = { type: "string" };
|
|
36
|
+
function createEventTrigger(spec) {
|
|
37
|
+
return {
|
|
38
|
+
id: spec.event,
|
|
39
|
+
name: spec.name,
|
|
40
|
+
description: spec.description,
|
|
41
|
+
icon: spec.icon,
|
|
42
|
+
cluster: "replicated",
|
|
43
|
+
configSchema: EMPTY_CONFIG_SCHEMA,
|
|
44
|
+
outputSchema: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
tenantId: TENANT_ID_PROPERTY,
|
|
48
|
+
...spec.outputProperties,
|
|
49
|
+
at: AT_PROPERTY,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
async activate(_config, emit) {
|
|
53
|
+
const listener = (payload) => emit(payload);
|
|
54
|
+
listenersFor(spec.event).add(listener);
|
|
55
|
+
return listener;
|
|
56
|
+
},
|
|
57
|
+
async deactivate(handle) {
|
|
58
|
+
listenersFor(spec.event).delete(handle);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const TRIGGERS = [
|
|
63
|
+
createEventTrigger({
|
|
64
|
+
event: "saas.subscription-started",
|
|
65
|
+
name: "Subscription started",
|
|
66
|
+
description: "Fires when a Stripe checkout completes and a workspace subscription becomes active or trialing",
|
|
67
|
+
icon: "i-ph-rocket-launch",
|
|
68
|
+
outputProperties: {
|
|
69
|
+
planId: { type: ["string", "null"] },
|
|
70
|
+
status: { type: "string" },
|
|
71
|
+
stripeSubscriptionId: { type: "string" },
|
|
72
|
+
trialConsumptionRecorded: { type: "boolean" },
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
createEventTrigger({
|
|
76
|
+
event: "saas.subscription-cancelled",
|
|
77
|
+
name: "Subscription cancelled",
|
|
78
|
+
description: "Fires when a workspace subscription is cancelled in Stripe",
|
|
79
|
+
icon: "i-ph-x-circle",
|
|
80
|
+
outputProperties: {
|
|
81
|
+
stripeSubscriptionId: { type: "string" },
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
createEventTrigger({
|
|
85
|
+
event: "saas.payment-failed",
|
|
86
|
+
name: "Payment failed",
|
|
87
|
+
description: "Fires when an invoice payment fails and the workspace goes past due",
|
|
88
|
+
icon: "i-ph-warning-circle",
|
|
89
|
+
outputProperties: {
|
|
90
|
+
invoiceId: { type: "string" },
|
|
91
|
+
invoiceNumber: { type: ["string", "null"] },
|
|
92
|
+
amountDue: { type: "number" },
|
|
93
|
+
currency: { type: "string" },
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
createEventTrigger({
|
|
97
|
+
event: "saas.trial-ending",
|
|
98
|
+
name: "Trial ending",
|
|
99
|
+
description: "Fires when a workspace trial is about to end",
|
|
100
|
+
icon: "i-ph-hourglass",
|
|
101
|
+
outputProperties: {
|
|
102
|
+
trialEndsAt: { type: ["string", "null"] },
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
createEventTrigger({
|
|
106
|
+
event: "saas.tenant-deleted",
|
|
107
|
+
name: "Workspace deleted",
|
|
108
|
+
description: "Fires when a workspace is deleted",
|
|
109
|
+
icon: "i-ph-trash",
|
|
110
|
+
outputProperties: { operationId: { type: "string" } },
|
|
111
|
+
}),
|
|
112
|
+
];
|
|
113
|
+
function automationOperationId(runId, nodeId) {
|
|
114
|
+
const fingerprint = (0, node_crypto_1.createHash)("sha256")
|
|
115
|
+
.update(`${runId}\u0000${nodeId}`)
|
|
116
|
+
.digest("hex")
|
|
117
|
+
.slice(0, 48);
|
|
118
|
+
return `automation-${fingerprint}`;
|
|
119
|
+
}
|
|
120
|
+
const suspendWorkspaceAction = {
|
|
121
|
+
id: "saas.suspend-workspace",
|
|
122
|
+
name: "Suspend workspace",
|
|
123
|
+
description: "Suspend a workspace (pause Stripe collection) or reactivate it when suspended is false",
|
|
124
|
+
icon: "i-ph-prohibit",
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
tenantId: { type: "string" },
|
|
129
|
+
suspended: { type: "boolean", default: true },
|
|
130
|
+
},
|
|
131
|
+
required: ["tenantId"],
|
|
132
|
+
},
|
|
133
|
+
outputSchema: {
|
|
134
|
+
type: "object",
|
|
135
|
+
properties: {
|
|
136
|
+
tenantId: { type: "string" },
|
|
137
|
+
suspended: { type: "boolean" },
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
async execute(input, ctx) {
|
|
141
|
+
const suspended = input.suspended ?? true;
|
|
142
|
+
const transition = suspended ? "suspending" : "reactivating";
|
|
143
|
+
ctx.log("info", `${transition} workspace ${input.tenantId}`);
|
|
144
|
+
const command = {
|
|
145
|
+
tenantId: input.tenantId,
|
|
146
|
+
operationId: automationOperationId(ctx.runId, ctx.nodeId),
|
|
147
|
+
actor: {
|
|
148
|
+
id: `automation:${ctx.procedureId}`,
|
|
149
|
+
email: "automation@system.invalid",
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
await (suspended
|
|
153
|
+
? (0, operator_actions_1.suspendWorkspaceCommand)(command)
|
|
154
|
+
: (0, operator_actions_1.reactivateWorkspaceCommand)(command));
|
|
155
|
+
return { tenantId: input.tenantId, suspended };
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const DEFAULT_NOTIFICATION_ICON = "i-ph-bell";
|
|
159
|
+
const notifyTenantOwnersAction = {
|
|
160
|
+
id: "saas.notify-tenant-owners",
|
|
161
|
+
name: "Notify workspace owners",
|
|
162
|
+
description: "Send an in-app notification to all owners of a workspace",
|
|
163
|
+
icon: DEFAULT_NOTIFICATION_ICON,
|
|
164
|
+
inputSchema: {
|
|
165
|
+
type: "object",
|
|
166
|
+
properties: {
|
|
167
|
+
tenantId: { type: "string" },
|
|
168
|
+
title: { type: "string" },
|
|
169
|
+
description: { type: "string" },
|
|
170
|
+
icon: { type: "string" },
|
|
171
|
+
linkTo: { type: "string" },
|
|
172
|
+
},
|
|
173
|
+
required: ["tenantId", "title", "description"],
|
|
174
|
+
},
|
|
175
|
+
outputSchema: {
|
|
176
|
+
type: "object",
|
|
177
|
+
properties: { ok: { type: "boolean" } },
|
|
178
|
+
},
|
|
179
|
+
async execute(input) {
|
|
180
|
+
await (0, notifications_1.notifyTenantOwners)(input.tenantId, notifications_1.automationNotificationSubject, {
|
|
181
|
+
icon: input.icon ?? DEFAULT_NOTIFICATION_ICON,
|
|
182
|
+
title: input.title,
|
|
183
|
+
description: input.description,
|
|
184
|
+
linkTo: input.linkTo,
|
|
185
|
+
});
|
|
186
|
+
return { ok: true };
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
const ACTIONS = [
|
|
190
|
+
suspendWorkspaceAction,
|
|
191
|
+
notifyTenantOwnersAction,
|
|
192
|
+
];
|
|
193
|
+
function registerAutomationNodes() {
|
|
194
|
+
for (const trigger of TRIGGERS) {
|
|
195
|
+
(0, interface_dms_automation_1.RegisterTriggerType)(trigger);
|
|
196
|
+
}
|
|
197
|
+
for (const action of ACTIONS) {
|
|
198
|
+
(0, interface_dms_automation_1.RegisterActionType)(action);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function unregisterAutomationNodes() {
|
|
202
|
+
for (const trigger of TRIGGERS) {
|
|
203
|
+
(0, interface_dms_automation_1.UnregisterTriggerType)(trigger.id);
|
|
204
|
+
}
|
|
205
|
+
for (const action of ACTIONS) {
|
|
206
|
+
(0, interface_dms_automation_1.UnregisterActionType)(action.id);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/automation/index.ts"],"names":[],"mappings":";;AA6FA,kDAWC;AAGD,wDAKC;AAkND,0DAOC;AAED,8DAOC;AAlVD,6CAAyC;AACzC,mFAQ8C;AAC9C,oDAG0B;AAC1B,0DAG6B;AAwD7B,MAAM,cAAc,GAAG,IAAI,GAAG,EAG3B,CAAC;AAEJ,SAAS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AC;IAC7B,CAAC;AACH,CAAC;AAED,SAAgB,yBAAyB;IACvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAA,gDAAqB,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAA,+CAAoB,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type BillingState, type TenantSubscription } from "../db";
|
|
2
|
+
export * from "./recovery";
|
|
3
|
+
export declare function deriveBillingState(subscription: TenantSubscription | undefined): BillingState;
|
|
4
|
+
export declare function recomputeTenantBillingState(tenantId: string): Promise<void>;
|
|
5
|
+
export declare function recomputeAllTenantBillingStates(): Promise<void>;
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
exports.deriveBillingState = deriveBillingState;
|
|
18
|
+
exports.recomputeTenantBillingState = recomputeTenantBillingState;
|
|
19
|
+
exports.recomputeAllTenantBillingStates = recomputeAllTenantBillingStates;
|
|
20
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
21
|
+
const db_1 = require("@antelopejs/interface-dms/db");
|
|
22
|
+
const db_2 = require("../db");
|
|
23
|
+
__exportStar(require("./recovery"), exports);
|
|
24
|
+
const ACTIVE_STATUS = "active";
|
|
25
|
+
const FREE_STATE = "free";
|
|
26
|
+
const PUBLICATION_ATTEMPTS = 3;
|
|
27
|
+
function deriveBillingState(subscription) {
|
|
28
|
+
if (!subscription)
|
|
29
|
+
return FREE_STATE;
|
|
30
|
+
if (subscription.status === ACTIVE_STATUS &&
|
|
31
|
+
!subscription.stripeSubscriptionId) {
|
|
32
|
+
return FREE_STATE;
|
|
33
|
+
}
|
|
34
|
+
return subscription.status;
|
|
35
|
+
}
|
|
36
|
+
async function recomputeTenantBillingState(tenantId) {
|
|
37
|
+
const model = (0, interface_database_decorators_1.GetModel)(db_2.TenantBillingStateModel);
|
|
38
|
+
for (let attempt = 0; attempt < PUBLICATION_ATTEMPTS; attempt++) {
|
|
39
|
+
const existing = await model.findByTenant(tenantId);
|
|
40
|
+
if (existing?.deletedAt)
|
|
41
|
+
return;
|
|
42
|
+
const subscription = await (0, interface_database_decorators_1.GetModel)(db_2.TenantSubscriptionModel, tenantId).findOne();
|
|
43
|
+
if (subscription?.deletionStartedAt)
|
|
44
|
+
return;
|
|
45
|
+
if (await model.upsertForTenant(tenantId, deriveBillingState(subscription), existing))
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Billing recomputation conflicted with a concurrent publication");
|
|
49
|
+
}
|
|
50
|
+
async function recomputeAllTenantBillingStates() {
|
|
51
|
+
const tenants = await (0, interface_database_decorators_1.GetModel)(db_1.TenantModel).table.pluck("_id").run();
|
|
52
|
+
for (const tenant of tenants) {
|
|
53
|
+
if (!tenant._id)
|
|
54
|
+
continue;
|
|
55
|
+
await recomputeTenantBillingState(tenant._id);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ACD,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,+BAA+B;IACnD,MAAM,OAAO,GAAG,MAAM,IAAA,wCAAQ,EAAC,gBAAW,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;IACrE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG;YAAE,SAAS;QAC1B,MAAM,2BAA2B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Invoice, type TenantSubscription } from "../db";
|
|
2
|
+
export interface PaymentMethodSummary {
|
|
3
|
+
brand: string;
|
|
4
|
+
last4: string;
|
|
5
|
+
expMonth: number;
|
|
6
|
+
expYear: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UnpaidInvoiceRef {
|
|
9
|
+
number: string | null;
|
|
10
|
+
amount: number;
|
|
11
|
+
currency: string;
|
|
12
|
+
hostedInvoiceUrl: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface UnpaidInvoiceSummary extends UnpaidInvoiceRef {
|
|
15
|
+
failedAt: Date | null;
|
|
16
|
+
nextRetryAt: Date | null;
|
|
17
|
+
suspendAt: Date | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function fetchDefaultPaymentMethod(stripeCustomerId: string): Promise<PaymentMethodSummary | null>;
|
|
20
|
+
export declare function toUnpaidInvoiceRef(invoice: Invoice): UnpaidInvoiceRef;
|
|
21
|
+
export declare function buildUnpaidInvoiceRef(tenantId: string): Promise<UnpaidInvoiceRef | null>;
|
|
22
|
+
export declare function buildUnpaidInvoiceSummary(tenantId: string, subscription: TenantSubscription): Promise<UnpaidInvoiceSummary | null>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchDefaultPaymentMethod = fetchDefaultPaymentMethod;
|
|
4
|
+
exports.toUnpaidInvoiceRef = toUnpaidInvoiceRef;
|
|
5
|
+
exports.buildUnpaidInvoiceRef = buildUnpaidInvoiceRef;
|
|
6
|
+
exports.buildUnpaidInvoiceSummary = buildUnpaidInvoiceSummary;
|
|
7
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
8
|
+
const db_1 = require("../db");
|
|
9
|
+
const client_1 = require("../stripe/client");
|
|
10
|
+
const time_1 = require("../utils/time");
|
|
11
|
+
function toCardSummary(paymentMethod) {
|
|
12
|
+
const card = paymentMethod?.card;
|
|
13
|
+
if (!card)
|
|
14
|
+
return null;
|
|
15
|
+
return {
|
|
16
|
+
brand: card.brand,
|
|
17
|
+
last4: card.last4,
|
|
18
|
+
expMonth: card.exp_month,
|
|
19
|
+
expYear: card.exp_year,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function fetchDefaultPaymentMethod(stripeCustomerId) {
|
|
23
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
24
|
+
const customer = await stripe.customers
|
|
25
|
+
.retrieve(stripeCustomerId, {
|
|
26
|
+
expand: ["invoice_settings.default_payment_method"],
|
|
27
|
+
})
|
|
28
|
+
.catch(() => null);
|
|
29
|
+
if (!customer || customer.deleted)
|
|
30
|
+
return null;
|
|
31
|
+
const defaultMethod = customer.invoice_settings?.default_payment_method;
|
|
32
|
+
if (!defaultMethod || typeof defaultMethod === "string")
|
|
33
|
+
return null;
|
|
34
|
+
return toCardSummary(defaultMethod);
|
|
35
|
+
}
|
|
36
|
+
async function resolveSuspendAt(pastDueSince) {
|
|
37
|
+
if (!pastDueSince)
|
|
38
|
+
return null;
|
|
39
|
+
const billingSettingsModel = (0, interface_database_decorators_1.GetModel)(db_1.BillingSettingsModel);
|
|
40
|
+
const settings = await billingSettingsModel.get(db_1.BILLING_SETTINGS_SINGLETON_ID);
|
|
41
|
+
if (!settings?.autoSuspendEnabled)
|
|
42
|
+
return null;
|
|
43
|
+
const delayDays = settings.autoSuspendDelayDays ?? db_1.DEFAULT_AUTO_SUSPEND_DELAY_DAYS;
|
|
44
|
+
return new Date(pastDueSince.getTime() + delayDays * time_1.MS_PER_DAY);
|
|
45
|
+
}
|
|
46
|
+
async function fetchNextRetryAt(stripeInvoiceId) {
|
|
47
|
+
const stripe = (0, client_1.getStripeClient)();
|
|
48
|
+
const invoice = await stripe.invoices
|
|
49
|
+
.retrieve(stripeInvoiceId)
|
|
50
|
+
.catch(() => null);
|
|
51
|
+
return (0, time_1.stripeSecondsToDate)(invoice?.next_payment_attempt);
|
|
52
|
+
}
|
|
53
|
+
function toUnpaidInvoiceRef(invoice) {
|
|
54
|
+
return {
|
|
55
|
+
number: invoice.number,
|
|
56
|
+
amount: invoice.total || invoice.amount,
|
|
57
|
+
currency: invoice.currency,
|
|
58
|
+
hostedInvoiceUrl: invoice.hostedInvoiceUrl,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function buildUnpaidInvoiceRef(tenantId) {
|
|
62
|
+
const invoice = await (0, interface_database_decorators_1.GetModel)(db_1.InvoiceModel, tenantId).findLatestOpen();
|
|
63
|
+
return invoice ? toUnpaidInvoiceRef(invoice) : null;
|
|
64
|
+
}
|
|
65
|
+
async function buildUnpaidInvoiceSummary(tenantId, subscription) {
|
|
66
|
+
const invoiceModel = (0, interface_database_decorators_1.GetModel)(db_1.InvoiceModel, tenantId);
|
|
67
|
+
const invoice = await invoiceModel.findLatestOpen();
|
|
68
|
+
if (!invoice)
|
|
69
|
+
return null;
|
|
70
|
+
const [nextRetryAt, suspendAt] = await Promise.all([
|
|
71
|
+
fetchNextRetryAt(invoice.stripeInvoiceId),
|
|
72
|
+
resolveSuspendAt(subscription.pastDueSince ?? null),
|
|
73
|
+
]);
|
|
74
|
+
return {
|
|
75
|
+
...toUnpaidInvoiceRef(invoice),
|
|
76
|
+
failedAt: subscription.pastDueSince ?? null,
|
|
77
|
+
nextRetryAt,
|
|
78
|
+
suspendAt,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery.js","sourceRoot":"","sources":["../../src/billing-state/recovery.ts"],"names":[],"mappings":";;AAmDA,8DAaC;AAwBD,gDASC;AAMD,sDAKC;AAMD,8DAiBC;AAnID,6FAAqE;AAErE,8BAOe;AACf,6CAAmD;AACnD,wCAAgE;AAsBhE,SAAS,aAAa,CACpB,aAA0C;IAE1C,MAAM,IAAI,GAAG,aAAa,EAAE,IAAI,CAAC;IACjC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,SAAS;QACxB,OAAO,EAAE,IAAI,CAAC,QAAQ;KACvB,CAAC;AACJ,CAAC;AAOM,KAAK,UAAU,yBAAyB,CAC7C,gBAAwB;IAExB,MAAM,MAAM,GAAG,IAAA,wBAAe,GAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS;SACpC,QAAQ,CAAC,gBAAgB,EAAE;QAC1B,MAAM,EAAE,CAAC,yCAAyC,CAAC;KACpD,CAAC;SACD,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC/C,MAAM,aAAa,GAAG,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;IACxE,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACrE,OAAO,aAAa,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,YAA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AMM,KAAK,UAAU,yBAAyB,CAC7C,QAAgB,EAChB,YAAgC;IAEhC,MAAM,YAAY,GAAG,IAAA,wCAAQ,EAAC,iBAAY,EAAE,QAAQ,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,cAAc,EAAE,CAAC;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACjD,gBAAgB,CAAC,OAAO,CAAC,eAAe,CAAC;QACzC,gBAAgB,CAAC,YAAY,CAAC,YAAY,IAAI,IAAI,CAAC;KACpD,CAAC,CAAC;IACH,OAAO;QACL,GAAG,kBAAkB,CAAC,OAAO,CAAC;QAC9B,QAAQ,EAAE,YAAY,CAAC,YAAY,IAAI,IAAI;QAC3C,WAAW;QACX,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDevMode = isDevMode;
|
|
4
|
+
exports.setDevMode = setDevMode;
|
|
5
|
+
exports.resolveDevMode = resolveDevMode;
|
|
6
|
+
const logging_1 = require("@antelopejs/interface-core/logging");
|
|
7
|
+
const runtime_1 = require("@antelopejs/interface-core/runtime");
|
|
8
|
+
const DEFAULT_DEV_MODE = false;
|
|
9
|
+
let devMode = DEFAULT_DEV_MODE;
|
|
10
|
+
function isDevMode() {
|
|
11
|
+
return devMode;
|
|
12
|
+
}
|
|
13
|
+
function setDevMode(enabled) {
|
|
14
|
+
devMode = enabled;
|
|
15
|
+
}
|
|
16
|
+
async function resolveDevMode() {
|
|
17
|
+
try {
|
|
18
|
+
const runtimeInfo = await (0, runtime_1.GetRuntimeInfo)();
|
|
19
|
+
setDevMode(runtimeInfo.dev);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23
|
+
logging_1.Logging.Warn(`Unable to resolve the development runtime flag: ${message}`);
|
|
24
|
+
setDevMode(DEFAULT_DEV_MODE);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dev-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-mode.js","sourceRoot":"","sources":["../../src/config/dev-mode.ts"],"names":[],"mappings":";;AAYA,8BAEC;AAKD,gCAEC;AAKD,wCASC;AAnCD,gEAA6D;AAC7D,gEAAoE;AAEpE,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,IAAI,OAAO,GAAG,gBAAgB,CAAC;AAO/B,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC;AACjB,CAAC;AAKD,SAAgB,UAAU,CAAC,OAAgB;IACzC,OAAO,GAAG,OAAO,CAAC;AACpB,CAAC;AAKM,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAc,GAAE,CAAC;QAC3C,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,iBAAO,CAAC,IAAI,CAAC,mDAAmD,OAAO,EAAE,CAAC,CAAC;QAC3E,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|