@antelopejs/dms-saas 0.1.8 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +262 -13
- package/dist/auth/subscription-access-gate.d.ts +1 -1
- package/dist/billing-state/index.d.ts +1 -0
- package/dist/billing-state/index.js +1 -0
- package/dist/billing-state/index.js.map +1 -1
- package/dist/billing-state/past-due-banner.d.ts +4 -0
- package/dist/billing-state/past-due-banner.js +25 -0
- package/dist/billing-state/past-due-banner.js.map +1 -0
- package/dist/config/runtime.d.ts +6 -1
- package/dist/config/runtime.js +50 -1
- package/dist/config/runtime.js.map +1 -1
- package/dist/crons/recompute-billing-state.js +4 -1
- package/dist/crons/recompute-billing-state.js.map +1 -1
- package/dist/data-api/platformOwner/index.d.ts +1 -0
- package/dist/data-api/platformOwner/index.js +1 -0
- package/dist/data-api/platformOwner/index.js.map +1 -1
- package/dist/data-api/platformOwner/invitations.d.ts +22 -0
- package/dist/data-api/platformOwner/invitations.js +121 -0
- package/dist/data-api/platformOwner/invitations.js.map +1 -0
- package/dist/data-api/platformOwner/workspaces.d.ts +3 -0
- package/dist/data-api/platformOwner/workspaces.js +64 -12
- package/dist/data-api/platformOwner/workspaces.js.map +1 -1
- package/dist/data-api/tenant/tenant-invoices.js +2 -10
- package/dist/data-api/tenant/tenant-invoices.js.map +1 -1
- package/dist/hooks/register.js +2 -1
- package/dist/hooks/register.js.map +1 -1
- package/dist/implementations/dms-saas/billing.d.ts +2 -1
- package/dist/implementations/dms-saas/billing.js +6 -0
- package/dist/implementations/dms-saas/billing.js.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/invoice-line-items/injection.d.ts +10 -0
- package/dist/invoice-line-items/injection.js +7 -3
- package/dist/invoice-line-items/injection.js.map +1 -1
- package/dist/notifications/subjects.d.ts +19 -19
- package/dist/operator-actions/index.d.ts +1 -0
- package/dist/operator-actions/index.js +1 -0
- package/dist/operator-actions/index.js.map +1 -1
- package/dist/operator-actions/invitation-commands.d.ts +12 -0
- package/dist/operator-actions/invitation-commands.js +46 -0
- package/dist/operator-actions/invitation-commands.js.map +1 -0
- package/dist/operator-actions/types.d.ts +1 -1
- package/dist/pages/platform/categories.d.ts +6 -6
- package/dist/pages/platform/credit-notes.d.ts +1 -1
- package/dist/pages/platform/dashboard.d.ts +2 -2
- package/dist/pages/platform/dashboard.js +2 -4
- package/dist/pages/platform/dashboard.js.map +1 -1
- package/dist/pages/platform/features.d.ts +1 -1
- package/dist/pages/platform/invoices.d.ts +1 -1
- package/dist/pages/platform/plans/edit.d.ts +2 -2
- package/dist/pages/platform/plans/index.d.ts +1 -1
- package/dist/pages/platform/plans/migrations.d.ts +1 -1
- package/dist/pages/platform/segments/index.d.ts +1 -1
- package/dist/pages/platform/settings.d.ts +1 -1
- package/dist/pages/platform/users/detail.d.ts +1 -1
- package/dist/pages/platform/users/index.d.ts +1 -1
- package/dist/pages/platform/workspaces/detail.d.ts +1 -1
- package/dist/pages/platform/workspaces/detail.js +40 -1
- package/dist/pages/platform/workspaces/detail.js.map +1 -1
- package/dist/pages/platform/workspaces/index.d.ts +4 -10
- package/dist/pages/platform/workspaces/index.js +27 -111
- package/dist/pages/platform/workspaces/index.js.map +1 -1
- package/dist/pages/public/legal/privacy-policy.js +2 -1
- package/dist/pages/public/legal/privacy-policy.js.map +1 -1
- package/dist/pages/public/legal/terms-and-conditions.js +2 -1
- package/dist/pages/public/legal/terms-and-conditions.js.map +1 -1
- package/dist/pages/public/legal/terms-of-use.js +2 -1
- package/dist/pages/public/legal/terms-of-use.js.map +1 -1
- package/dist/pages/tenant/billing.d.ts +1 -1
- package/dist/plans/index.d.ts +1 -0
- package/dist/plans/index.js +1 -0
- package/dist/plans/index.js.map +1 -1
- package/dist/plans/platform-support.d.ts +2 -0
- package/dist/plans/platform-support.js +19 -0
- package/dist/plans/platform-support.js.map +1 -0
- package/dist/plans/seat-capacity.d.ts +9 -2
- package/dist/plans/seat-capacity.js +59 -12
- package/dist/plans/seat-capacity.js.map +1 -1
- package/dist/plans/seat-hooks.js +34 -13
- package/dist/plans/seat-hooks.js.map +1 -1
- package/dist/routes/platformOwner/billing-settings.d.ts +2 -2
- package/dist/routes/platformOwner/dashboard.d.ts +8 -6
- package/dist/routes/platformOwner/dashboard.js +31 -17
- package/dist/routes/platformOwner/dashboard.js.map +1 -1
- package/dist/routes/platformOwner/index.d.ts +1 -0
- package/dist/routes/platformOwner/index.js +1 -0
- package/dist/routes/platformOwner/index.js.map +1 -1
- package/dist/routes/platformOwner/plan-deletion.d.ts +1 -1
- package/dist/routes/platformOwner/plans.d.ts +5 -5
- package/dist/routes/platformOwner/segments.d.ts +1 -1
- package/dist/routes/platformOwner/workspace-invitations.d.ts +13 -0
- package/dist/routes/platformOwner/workspace-invitations.js +73 -0
- package/dist/routes/platformOwner/workspace-invitations.js.map +1 -0
- package/dist/routes/public/legal-documents.d.ts +2 -2
- package/dist/routes/public/register.d.ts +7 -3
- package/dist/routes/public/register.js +42 -27
- package/dist/routes/public/register.js.map +1 -1
- package/dist/routes/tenant/tenant-billing.d.ts +7 -11
- package/dist/routes/tenant/tenant-billing.js +34 -26
- package/dist/routes/tenant/tenant-billing.js.map +1 -1
- package/dist/routes/tenant/tenant-plan.d.ts +1 -0
- package/dist/routes/tenant/tenant-plan.js +27 -2
- package/dist/routes/tenant/tenant-plan.js.map +1 -1
- package/dist/routes/tenant/tenant-seats.d.ts +2 -4
- package/dist/routes/tenant/tenant-seats.js.map +1 -1
- package/dist/routes/tenant/workspaces.d.ts +3 -1
- package/dist/routes/tenant/workspaces.js +10 -4
- package/dist/routes/tenant/workspaces.js.map +1 -1
- package/dist/stripe/upcoming-invoice.d.ts +21 -0
- package/dist/stripe/upcoming-invoice.js +42 -0
- package/dist/stripe/upcoming-invoice.js.map +1 -0
- package/dist/stripe/webhook-dispatch.js +2 -0
- package/dist/stripe/webhook-dispatch.js.map +1 -1
- package/dist/types/config.d.ts +9 -0
- package/dist/types/config.js +7 -0
- package/dist/types/config.js.map +1 -1
- package/dist/upcoming-invoice/db/preview-cache.model.d.ts +38 -0
- package/dist/upcoming-invoice/db/preview-cache.model.js +57 -0
- package/dist/upcoming-invoice/db/preview-cache.model.js.map +1 -0
- package/dist/upcoming-invoice/db/preview-cache.table.d.ts +10 -0
- package/dist/upcoming-invoice/db/preview-cache.table.js +42 -0
- package/dist/upcoming-invoice/db/preview-cache.table.js.map +1 -0
- package/dist/upcoming-invoice/eligibility.d.ts +17 -0
- package/dist/upcoming-invoice/eligibility.js +52 -0
- package/dist/upcoming-invoice/eligibility.js.map +1 -0
- package/dist/upcoming-invoice/invalidation.d.ts +2 -0
- package/dist/upcoming-invoice/invalidation.js +39 -0
- package/dist/upcoming-invoice/invalidation.js.map +1 -0
- package/dist/upcoming-invoice/mapping.d.ts +8 -0
- package/dist/upcoming-invoice/mapping.js +82 -0
- package/dist/upcoming-invoice/mapping.js.map +1 -0
- package/dist/upcoming-invoice/outcomes.d.ts +13 -0
- package/dist/upcoming-invoice/outcomes.js +15 -0
- package/dist/upcoming-invoice/outcomes.js.map +1 -0
- package/dist/upcoming-invoice/preview.d.ts +3 -0
- package/dist/upcoming-invoice/preview.js +80 -0
- package/dist/upcoming-invoice/preview.js.map +1 -0
- package/dist/upcoming-invoice/pricing.d.ts +3 -0
- package/dist/upcoming-invoice/pricing.js +84 -0
- package/dist/upcoming-invoice/pricing.js.map +1 -0
- package/dist/upcoming-invoice/usage.d.ts +14 -0
- package/dist/upcoming-invoice/usage.js +53 -0
- package/dist/upcoming-invoice/usage.js.map +1 -0
- package/dist/utils/invoice-lines-type.d.ts +1 -1
- package/dist/workspaces/billing-identity.d.ts +19 -0
- package/dist/workspaces/billing-identity.js +51 -0
- package/dist/workspaces/billing-identity.js.map +1 -0
- package/dist/workspaces/default-plan.d.ts +5 -0
- package/dist/workspaces/default-plan.js +109 -0
- package/dist/workspaces/default-plan.js.map +1 -0
- package/dist/workspaces/index.d.ts +2 -0
- package/dist/workspaces/index.js +2 -0
- package/dist/workspaces/index.js.map +1 -1
- package/dist/workspaces/invitations.d.ts +26 -0
- package/dist/workspaces/invitations.js +112 -0
- package/dist/workspaces/invitations.js.map +1 -0
- package/dist/workspaces/provisioning.d.ts +3 -3
- package/dist/workspaces/provisioning.js +39 -11
- package/dist/workspaces/provisioning.js.map +1 -1
- package/frontend-vue/app/components/BillingIdentityFields.vue +179 -0
- package/frontend-vue/app/components/PastDueBanner.vue +81 -0
- package/frontend-vue/app/components/PaymentMethodCard.vue +94 -38
- package/frontend-vue/app/components/PlanComparisonModal.vue +62 -26
- package/frontend-vue/app/components/PlanUpgradeModal.vue +181 -0
- package/frontend-vue/app/components/PlatformNotes.vue +4 -0
- package/frontend-vue/app/components/RefundButton.vue +10 -1
- package/frontend-vue/app/components/Register.vue +49 -92
- package/frontend-vue/app/components/SeatQuotaBanner.vue +28 -0
- package/frontend-vue/app/components/TenantBillingForm.vue +52 -128
- package/frontend-vue/app/components/TenantPlanCard.vue +68 -10
- package/frontend-vue/app/components/UserSummaryCard.vue +12 -10
- package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +202 -0
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +46 -9
- package/frontend-vue/app/components/WorkspaceInvitationLink.vue +106 -0
- package/frontend-vue/app/components/WorkspaceSummaryCard.vue +39 -15
- package/frontend-vue/app/components/WorkspaceSuspended.vue +3 -5
- package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +8 -5
- package/frontend-vue/app/composables/useBillingCountries.ts +25 -5
- package/frontend-vue/app/composables/useBillingIdentity.ts +141 -0
- package/frontend-vue/app/composables/useInvitationLink.ts +69 -0
- package/frontend-vue/app/composables/usePastDueBannerAction.ts +20 -0
- package/frontend-vue/app/composables/usePlanComparison.ts +15 -0
- package/frontend-vue/app/composables/usePlanFeatureFormat.ts +312 -20
- package/frontend-vue/app/composables/usePlanFeatureLabel.ts +24 -0
- package/frontend-vue/app/composables/useSaasRegistration.ts +110 -223
- package/frontend-vue/app/composables/useSeatQuota.ts +8 -0
- package/frontend-vue/app/composables/useStripePaymentElement.ts +3 -3
- package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +29 -2
- package/frontend-vue/app/composables/useWorkspaceFinalization.ts +7 -32
- package/frontend-vue/app/custom-pages/auth/no-workspace.vue +49 -194
- package/frontend-vue/app/plugins/auth-links.ts +0 -4
- package/frontend-vue/app/types/runtime-config.ts +13 -0
- package/frontend-vue/dms.frontend.ts +10 -4
- package/frontend-vue/i18n/locales/saas-en-GB.json +161 -36
- package/frontend-vue/i18n/locales/saas-fr-FR.json +162 -37
- package/frontend-vue/package.json +0 -1
- package/frontend-vue/pnpm-lock.yaml +1 -125
- package/package.json +15 -15
- package/frontend-vue/app/middleware/workspace-suspended.global.ts +0 -59
|
@@ -22,14 +22,13 @@ const page_1 = require("@antelopejs/interface-dms/page");
|
|
|
22
22
|
const auth_1 = require("@antelopejs/interface-dms/auth");
|
|
23
23
|
const db_2 = require("@antelopejs/interface-dms/auth/db");
|
|
24
24
|
const base_1 = require("@antelopejs/interface-dms/base");
|
|
25
|
-
const
|
|
25
|
+
const custom_1 = require("@antelopejs/interface-dms/base/custom");
|
|
26
26
|
const layouts_1 = require("@antelopejs/interface-dms/base/layouts");
|
|
27
27
|
const billing_state_1 = require("../../../billing-state");
|
|
28
|
-
const config_1 = require("../../../config");
|
|
29
28
|
const data_api_1 = require("../../../data-api");
|
|
30
29
|
const db_3 = require("../../../db");
|
|
31
|
-
const stripe_1 = require("../../../stripe");
|
|
32
30
|
const utils_1 = require("../../../utils");
|
|
31
|
+
const invitations_1 = require("../../../workspaces/invitations");
|
|
33
32
|
const module_1 = require("../../module");
|
|
34
33
|
const categories_1 = require("../categories");
|
|
35
34
|
const KPI_WORKSPACES = "/api/saas/dashboard/kpi/workspaces";
|
|
@@ -37,69 +36,14 @@ const KPI_ACTIVE = "/api/saas/dashboard/kpi/state-active";
|
|
|
37
36
|
const KPI_FREE = "/api/saas/dashboard/kpi/state-free";
|
|
38
37
|
const KPI_PAST_DUE = "/api/saas/dashboard/kpi/state-past-due";
|
|
39
38
|
const ACTIVE_STATUS = "active";
|
|
40
|
-
const PENDING_PAYMENT_STATUS = "pending_payment";
|
|
41
39
|
const STATUS_TAB_FILTER_KEY = "billingState";
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
{ id: "free", label: "Free" },
|
|
45
|
-
{ id: "past_due", label: "Past due" },
|
|
46
|
-
{ id: "suspended", label: "Suspended" },
|
|
47
|
-
];
|
|
48
|
-
const STATUS_TABS = STATUS_TAB_DEFS.map(({ id, label }) => ({
|
|
40
|
+
const STATUS_TAB_IDS = ["active", "free", "past_due", "suspended"];
|
|
41
|
+
const STATUS_TABS = STATUS_TAB_IDS.map((id) => ({
|
|
49
42
|
id,
|
|
50
|
-
label
|
|
43
|
+
label: `$saas.workspaces.billing_state.${id}`,
|
|
51
44
|
filters: [{ accessorKey: STATUS_TAB_FILTER_KEY, value: id, mode: "is" }],
|
|
52
45
|
}));
|
|
53
|
-
const
|
|
54
|
-
fields: [
|
|
55
|
-
{
|
|
56
|
-
id: "name",
|
|
57
|
-
label: "$saas.workspaces.admin.create.field.name",
|
|
58
|
-
description: "$saas.workspaces.admin.create.field.name_description",
|
|
59
|
-
type: new default_types_1.DefaultDataTypes.StringType({
|
|
60
|
-
placeholder: "$saas.workspaces.admin.create.placeholder.name",
|
|
61
|
-
}),
|
|
62
|
-
required: true,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
id: "planId",
|
|
66
|
-
label: "$saas.workspaces.admin.create.field.plan",
|
|
67
|
-
description: "$saas.workspaces.admin.create.field.plan_description",
|
|
68
|
-
type: new default_types_1.DefaultDataTypes.RelationType({
|
|
69
|
-
placeholder: "$saas.workspaces.admin.create.placeholder.plan",
|
|
70
|
-
dataApiController: data_api_1.plansDataAPI,
|
|
71
|
-
keyMapping: { label: "name", value: "_id" },
|
|
72
|
-
}),
|
|
73
|
-
required: true,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: "ownerEmail",
|
|
77
|
-
label: "$saas.workspaces.admin.create.field.owner_email",
|
|
78
|
-
description: "$saas.workspaces.admin.create.field.owner_email_description",
|
|
79
|
-
type: new default_types_1.DefaultDataTypes.EmailType({
|
|
80
|
-
placeholder: "$saas.workspaces.admin.create.placeholder.owner_email",
|
|
81
|
-
}),
|
|
82
|
-
required: true,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "freeWorkspace",
|
|
86
|
-
label: "$saas.workspaces.admin.create.field.free_workspace",
|
|
87
|
-
description: "$saas.workspaces.admin.create.field.free_workspace_description",
|
|
88
|
-
type: new default_types_1.DefaultDataTypes.BooleanType(),
|
|
89
|
-
defaultValue: true,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: "freeUntil",
|
|
93
|
-
label: "$saas.workspaces.admin.create.field.free_until",
|
|
94
|
-
description: "$saas.workspaces.admin.create.field.free_until_description",
|
|
95
|
-
type: new default_types_1.DefaultDataTypes.DateType(),
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
fieldsOrientation: "vertical",
|
|
99
|
-
submitUrl: "/modules/saas/customers/workspaces/create",
|
|
100
|
-
submitUrlMethod: base_1.HttpMethod.post,
|
|
101
|
-
successMessage: "$saas.workspaces.admin.create.success",
|
|
102
|
-
});
|
|
46
|
+
const workspaceCreateModal = (0, custom_1.CustomComponent)("DmsSaasWorkspaceAdminCreateModal");
|
|
103
47
|
const HTTP_BAD_REQUEST = 400;
|
|
104
48
|
function asNonEmptyString(value) {
|
|
105
49
|
return typeof value === "string" && value.trim().length > 0
|
|
@@ -110,23 +54,11 @@ function validateWorkspaceInput(body) {
|
|
|
110
54
|
const name = asNonEmptyString(body.name);
|
|
111
55
|
const planId = asNonEmptyString(body.planId);
|
|
112
56
|
const ownerEmail = asNonEmptyString(body.ownerEmail);
|
|
113
|
-
const
|
|
114
|
-
const freeUntil = freeWorkspace
|
|
115
|
-
? (0, utils_1.parseFutureDate)(body.freeUntil, "saas.workspaces.admin.create.error.free_until_past")
|
|
116
|
-
: null;
|
|
57
|
+
const freeUntil = (0, utils_1.parseFutureDate)(body.freeUntil, "saas.workspaces.admin.create.error.free_until_past");
|
|
117
58
|
(0, interface_api_util_1.assert)(name, HTTP_BAD_REQUEST, "saas.workspaces.admin.create.error.name");
|
|
118
59
|
(0, interface_api_util_1.assert)(planId, HTTP_BAD_REQUEST, "saas.workspaces.admin.create.error.plan");
|
|
119
60
|
(0, interface_api_util_1.assert)(ownerEmail, HTTP_BAD_REQUEST, "saas.workspaces.admin.create.error.owner_email");
|
|
120
|
-
return { name, planId, ownerEmail,
|
|
121
|
-
}
|
|
122
|
-
function validatePaidCheckoutInput(body, plan) {
|
|
123
|
-
const stripePriceId = plan.paymentProviderRefs?.stripePriceId ?? null;
|
|
124
|
-
(0, interface_api_util_1.assert)(stripePriceId, HTTP_BAD_REQUEST, "saas.errors.plan.not_synced_with_stripe");
|
|
125
|
-
const successUrl = asNonEmptyString(body.successUrl);
|
|
126
|
-
const cancelUrl = asNonEmptyString(body.cancelUrl);
|
|
127
|
-
(0, interface_api_util_1.assert)(successUrl && (0, config_1.isAllowedRedirectUrl)(successUrl), HTTP_BAD_REQUEST, "saas.errors.billing.invalid_return_url");
|
|
128
|
-
(0, interface_api_util_1.assert)(cancelUrl && (0, config_1.isAllowedRedirectUrl)(cancelUrl), HTTP_BAD_REQUEST, "saas.errors.billing.invalid_return_url");
|
|
129
|
-
return { stripePriceId, successUrl, cancelUrl };
|
|
61
|
+
return { name, planId, ownerEmail, freeUntil };
|
|
130
62
|
}
|
|
131
63
|
async function insertFreeSubscription(tenantId, planId, userId, now, freeUntil) {
|
|
132
64
|
await (0, interface_database_decorators_1.GetModel)(db_3.TenantSubscriptionModel, tenantId).insert([
|
|
@@ -146,7 +78,8 @@ async function insertFreeSubscription(tenantId, planId, userId, now, freeUntil)
|
|
|
146
78
|
},
|
|
147
79
|
]);
|
|
148
80
|
}
|
|
149
|
-
async function provisionTenantWithOwner(tenantModel, name, ownerEmail,
|
|
81
|
+
async function provisionTenantWithOwner(tenantModel, { name, ownerEmail, operator, now }) {
|
|
82
|
+
const ownerLanguage = operator.language;
|
|
150
83
|
const inserted = await tenantModel.insert([
|
|
151
84
|
{ name, createdAt: now, updatedAt: now },
|
|
152
85
|
]);
|
|
@@ -157,23 +90,17 @@ async function provisionTenantWithOwner(tenantModel, name, ownerEmail, ownerLang
|
|
|
157
90
|
language: ownerLanguage,
|
|
158
91
|
roleIds: [],
|
|
159
92
|
asTenantOwner: true,
|
|
160
|
-
sendEmail: true,
|
|
161
93
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
createdBy: userId,
|
|
173
|
-
createdAt: now,
|
|
174
|
-
updatedAt: now,
|
|
175
|
-
},
|
|
176
|
-
]);
|
|
94
|
+
const invitationEmail = inviteResult.kind === "invited"
|
|
95
|
+
? await (0, invitations_1.deliverInvitationEmail)({
|
|
96
|
+
email: ownerEmail,
|
|
97
|
+
token: inviteResult.token,
|
|
98
|
+
firstname: null,
|
|
99
|
+
lastname: null,
|
|
100
|
+
language: ownerLanguage,
|
|
101
|
+
}, { workspaceName: name, inviterName: (0, invitations_1.inviterNameOf)(operator) })
|
|
102
|
+
: null;
|
|
103
|
+
return { tenantId, inviteResult, invitationEmail };
|
|
177
104
|
}
|
|
178
105
|
let SaasWorkspacesListController = class SaasWorkspacesListController extends (0, page_1.PageController)("workspaces", {
|
|
179
106
|
displayName: "$saas.workspaces.title",
|
|
@@ -235,7 +162,7 @@ let SaasWorkspacesListController = class SaasWorkspacesListController extends (0
|
|
|
235
162
|
target: {
|
|
236
163
|
type: "modal",
|
|
237
164
|
size: "lg",
|
|
238
|
-
component:
|
|
165
|
+
component: workspaceCreateModal,
|
|
239
166
|
title: "$saas.workspaces.admin.create.title",
|
|
240
167
|
description: "$saas.workspaces.admin.create.description",
|
|
241
168
|
},
|
|
@@ -250,27 +177,16 @@ let SaasWorkspacesListController = class SaasWorkspacesListController extends (0
|
|
|
250
177
|
const input = validateWorkspaceInput(body);
|
|
251
178
|
const plan = await this.planModel.get(input.planId);
|
|
252
179
|
(0, interface_api_util_1.assert)(plan && !plan.isDeleted && plan.isActive, HTTP_BAD_REQUEST, "saas.errors.plan.not_available");
|
|
253
|
-
const checkoutInput = input.freeWorkspace
|
|
254
|
-
? null
|
|
255
|
-
: validatePaidCheckoutInput(body, plan);
|
|
256
180
|
const now = new Date();
|
|
257
|
-
const { tenantId, inviteResult } = await provisionTenantWithOwner(this.tenantModel,
|
|
258
|
-
|
|
259
|
-
await insertFreeSubscription(tenantId, input.planId, user._id, now, input.freeUntil);
|
|
260
|
-
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
261
|
-
return { tenantId, owner: inviteResult, checkoutUrl: null };
|
|
262
|
-
}
|
|
263
|
-
const checkout = await (0, stripe_1.createWorkspaceCheckoutSession)({
|
|
264
|
-
tenantId,
|
|
181
|
+
const { tenantId, inviteResult, invitationEmail } = await provisionTenantWithOwner(this.tenantModel, {
|
|
182
|
+
name: input.name,
|
|
265
183
|
ownerEmail: input.ownerEmail,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
successUrl: checkoutInput.successUrl,
|
|
269
|
-
cancelUrl: checkoutInput.cancelUrl,
|
|
184
|
+
operator: user,
|
|
185
|
+
now,
|
|
270
186
|
});
|
|
271
|
-
await
|
|
187
|
+
await insertFreeSubscription(tenantId, input.planId, user._id, now, input.freeUntil);
|
|
272
188
|
await (0, billing_state_1.recomputeTenantBillingState)(tenantId);
|
|
273
|
-
return { tenantId, owner: inviteResult,
|
|
189
|
+
return { tenantId, owner: inviteResult, invitationEmail };
|
|
274
190
|
}
|
|
275
191
|
};
|
|
276
192
|
exports.SaasWorkspacesListController = SaasWorkspacesListController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/pages/platform/workspaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAA2D;AAC3D,uEAAwD;AACxD,6FAA4E;AAC5E,qDAA2D;AAC3D,+DAG2C;AAC3C,yDAA8E;AAC9E,yDAA+D;AAC/D,0DAAyE;AACzE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/pages/platform/workspaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAA2D;AAC3D,uEAAwD;AACxD,6FAA4E;AAC5E,qDAA2D;AAC3D,+DAG2C;AAC3C,yDAA8E;AAC9E,yDAA+D;AAC/D,0DAAyE;AACzE,yDAKwC;AACxC,kEAAwE;AACxE,oEAAuE;AACvE,0DAAqE;AACrE,gDAAsD;AACtD,oCAAiE;AACjE,0CAAiD;AACjD,iEAIyC;AACzC,yCAA8C;AAC9C,8CAAkD;AAElD,MAAM,cAAc,GAAG,oCAAoC,CAAC;AAC5D,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAC1D,MAAM,QAAQ,GAAG,oCAAoC,CAAC;AACtD,MAAM,YAAY,GAAG,wCAAwC,CAAC;AAE9D,MAAM,aAAa,GAAG,QAAQ,CAAC;AAE/B,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAEnE,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,EAAE;IACF,KAAK,EAAE,kCAAkC,EAAE,EAAE;IAC7C,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;CACzE,CAAC,CAAC,CAAC;AAKJ,MAAM,oBAAoB,GAAG,IAAA,w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;YAChB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,IAAI;YACd,GAAG;SACJ,CAAC,CAAC;QAEL,MAAM,sBAAsB,CAC1B,QAAQ,EACR,KAAK,CAAC,MAAM,EACZ,IAAI,CAAC,GAAG,EACR,GAAG,EACH,KAAK,CAAC,SAAS,CAChB,CAAC;QACF,MAAM,IAAA,2CAA2B,EAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;IAC5D,CAAC;;AApIU,oEAA4B;AAa/B;IADP,IAAA,qCAAK,EAAC,gBAAW,CAAC;8BACE,gBAAW;iEAAC;AAGzB;IADP,IAAA,qCAAK,EAAC,cAAS,CAAC;8BACE,cAAS;+DAAC;AAGrB;IADP,IAAA,qCAAK,EAAC,cAAS,CAAC;8BACE,cAAS;+DAAC;AAmFvB;IADL,IAAA,oBAAI,EAAC,SAAS,CAAC;IAEb,WAAA,IAAA,oBAAa,GAAE,CAAA;IACf,WAAA,IAAA,wBAAQ,GAAE,CAAA;;;;mEA4BZ;uCApIU,4BAA4B;IADxC,IAAA,mBAAY,GAAE;GACF,4BAA4B,CAqIxC"}
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.SaasPrivacyPolicyPage = void 0;
|
|
10
10
|
const page_1 = require("@antelopejs/interface-dms/page");
|
|
11
11
|
const custom_1 = require("@antelopejs/interface-dms/base/custom");
|
|
12
|
+
const layouts_1 = require("@antelopejs/interface-dms/base/layouts");
|
|
12
13
|
const LEGAL_ENDPOINT = "/api/saas/legal-documents";
|
|
13
14
|
const DOCUMENT_FIELD = "privacyPolicy";
|
|
14
15
|
let SaasPrivacyPolicyPage = class SaasPrivacyPolicyPage extends (0, page_1.PageController)("privacy-policy", {
|
|
@@ -17,7 +18,7 @@ let SaasPrivacyPolicyPage = class SaasPrivacyPolicyPage extends (0, page_1.PageC
|
|
|
17
18
|
category: page_1.pagesCategory,
|
|
18
19
|
publicAccess: true,
|
|
19
20
|
hidden: true,
|
|
20
|
-
}) {
|
|
21
|
+
}, (0, layouts_1.EmptyLayout)()) {
|
|
21
22
|
static legalContent = (0, custom_1.CustomComponent)("DmsSaasLegalLayout")
|
|
22
23
|
.meta({ name: "$saas.legal.privacy_policy" })
|
|
23
24
|
.options({ endpoint: LEGAL_ENDPOINT, documentField: DOCUMENT_FIELD });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy-policy.js","sourceRoot":"","sources":["../../../../src/pages/public/legal/privacy-policy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAIwC;AACxC,kEAAwE;
|
|
1
|
+
{"version":3,"file":"privacy-policy.js","sourceRoot":"","sources":["../../../../src/pages/public/legal/privacy-policy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAIwC;AACxC,kEAAwE;AACxE,oEAAqE;AAErE,MAAM,cAAc,GAAG,2BAA2B,CAAC;AACnD,MAAM,cAAc,GAAG,eAAe,CAAC;AAKhC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,IAAA,qBAAc,EACvD,gBAAgB,EAChB;IACE,WAAW,EAAE,4BAA4B;IACzC,WAAW,EAAE,6CAA6C;IAC1D,QAAQ,EAAE,oBAAa;IACvB,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,IAAI;CACb,EACD,IAAA,qBAAW,GAAE,CACd;IACC,MAAM,CAAC,YAAY,GAAG,IAAA,wBAAe,EAAC,oBAAoB,CAAC;SACxD,IAAI,CAAC,EAAE,IAAI,EAAE,4BAA4B,EAAE,CAAC;SAC5C,OAAO,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC;;AAb7D,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAY,GAAE;GACF,qBAAqB,CAcjC"}
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.SaasTermsAndConditionsPage = void 0;
|
|
10
10
|
const page_1 = require("@antelopejs/interface-dms/page");
|
|
11
11
|
const custom_1 = require("@antelopejs/interface-dms/base/custom");
|
|
12
|
+
const layouts_1 = require("@antelopejs/interface-dms/base/layouts");
|
|
12
13
|
const LEGAL_ENDPOINT = "/api/saas/legal-documents";
|
|
13
14
|
const DOCUMENT_FIELD = "termsAndConditions";
|
|
14
15
|
let SaasTermsAndConditionsPage = class SaasTermsAndConditionsPage extends (0, page_1.PageController)("terms-and-conditions", {
|
|
@@ -17,7 +18,7 @@ let SaasTermsAndConditionsPage = class SaasTermsAndConditionsPage extends (0, pa
|
|
|
17
18
|
category: page_1.pagesCategory,
|
|
18
19
|
publicAccess: true,
|
|
19
20
|
hidden: true,
|
|
20
|
-
}) {
|
|
21
|
+
}, (0, layouts_1.EmptyLayout)()) {
|
|
21
22
|
static legalContent = (0, custom_1.CustomComponent)("DmsSaasLegalLayout")
|
|
22
23
|
.meta({ name: "$saas.legal.terms_and_conditions" })
|
|
23
24
|
.options({ endpoint: LEGAL_ENDPOINT, documentField: DOCUMENT_FIELD });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terms-and-conditions.js","sourceRoot":"","sources":["../../../../src/pages/public/legal/terms-and-conditions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAIwC;AACxC,kEAAwE;
|
|
1
|
+
{"version":3,"file":"terms-and-conditions.js","sourceRoot":"","sources":["../../../../src/pages/public/legal/terms-and-conditions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAIwC;AACxC,kEAAwE;AACxE,oEAAqE;AAErE,MAAM,cAAc,GAAG,2BAA2B,CAAC;AACnD,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAKrC,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,IAAA,qBAAc,EAC5D,sBAAsB,EACtB;IACE,WAAW,EAAE,kCAAkC;IAC/C,WAAW,EAAE,mDAAmD;IAChE,QAAQ,EAAE,oBAAa;IACvB,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,IAAI;CACb,EACD,IAAA,qBAAW,GAAE,CACd;IACC,MAAM,CAAC,YAAY,GAAG,IAAA,wBAAe,EAAC,oBAAoB,CAAC;SACxD,IAAI,CAAC,EAAE,IAAI,EAAE,kCAAkC,EAAE,CAAC;SAClD,OAAO,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC;;AAb7D,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAY,GAAE;GACF,0BAA0B,CActC"}
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.SaasTermsOfUsePage = void 0;
|
|
10
10
|
const page_1 = require("@antelopejs/interface-dms/page");
|
|
11
11
|
const custom_1 = require("@antelopejs/interface-dms/base/custom");
|
|
12
|
+
const layouts_1 = require("@antelopejs/interface-dms/base/layouts");
|
|
12
13
|
const LEGAL_ENDPOINT = "/api/saas/legal-documents";
|
|
13
14
|
const DOCUMENT_FIELD = "termsOfUse";
|
|
14
15
|
let SaasTermsOfUsePage = class SaasTermsOfUsePage extends (0, page_1.PageController)("terms-of-use", {
|
|
@@ -17,7 +18,7 @@ let SaasTermsOfUsePage = class SaasTermsOfUsePage extends (0, page_1.PageControl
|
|
|
17
18
|
category: page_1.pagesCategory,
|
|
18
19
|
publicAccess: true,
|
|
19
20
|
hidden: true,
|
|
20
|
-
}) {
|
|
21
|
+
}, (0, layouts_1.EmptyLayout)()) {
|
|
21
22
|
static legalContent = (0, custom_1.CustomComponent)("DmsSaasLegalLayout")
|
|
22
23
|
.meta({ name: "$saas.legal.terms_of_use" })
|
|
23
24
|
.options({ endpoint: LEGAL_ENDPOINT, documentField: DOCUMENT_FIELD });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terms-of-use.js","sourceRoot":"","sources":["../../../../src/pages/public/legal/terms-of-use.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAIwC;AACxC,kEAAwE;
|
|
1
|
+
{"version":3,"file":"terms-of-use.js","sourceRoot":"","sources":["../../../../src/pages/public/legal/terms-of-use.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAIwC;AACxC,kEAAwE;AACxE,oEAAqE;AAErE,MAAM,cAAc,GAAG,2BAA2B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAK7B,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,IAAA,qBAAc,EACpD,cAAc,EACd;IACE,WAAW,EAAE,0BAA0B;IACvC,WAAW,EAAE,2CAA2C;IACxD,QAAQ,EAAE,oBAAa;IACvB,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,IAAI;CACb,EACD,IAAA,qBAAW,GAAE,CACd;IACC,MAAM,CAAC,YAAY,GAAG,IAAA,wBAAe,EAAC,oBAAoB,CAAC;SACxD,IAAI,CAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC;SAC1C,OAAO,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC;;AAb7D,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAY,GAAE;GACF,kBAAkB,CAc9B"}
|
|
@@ -10,6 +10,6 @@ export declare class SaasTenantBillingController extends SaasTenantBillingContro
|
|
|
10
10
|
static paymentMethod: import("@antelopejs/interface-dms").ComponentBuilder<unknown>;
|
|
11
11
|
static billingForm: import("@antelopejs/interface-dms").ComponentBuilder<unknown>;
|
|
12
12
|
static refundButton: import("@antelopejs/interface-dms").ComponentBuilder<unknown>;
|
|
13
|
-
static table: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/
|
|
13
|
+
static table: import("@antelopejs/interface-dms").ComponentBuilder<import("@antelopejs/interface-dms/base").TableViewOptionsSerialized>;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
package/dist/plans/index.d.ts
CHANGED
package/dist/plans/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("@antelopejs/interface-dms-saas/plans"), exports);
|
|
18
|
+
__exportStar(require("./platform-support"), exports);
|
|
18
19
|
__exportStar(require("./seat-capacity"), exports);
|
|
19
20
|
__exportStar(require("./seat-hooks"), exports);
|
|
20
21
|
__exportStar(require("./seat-sync"), exports);
|
package/dist/plans/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD;AACrD,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD;AACrD,qDAAmC;AACnC,kDAAgC;AAChC,+CAA6B;AAC7B,8CAA4B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPlatformSupportEntry = isPlatformSupportEntry;
|
|
4
|
+
exports.isPlatformSupportInvite = isPlatformSupportInvite;
|
|
5
|
+
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
6
|
+
const db_1 = require("@antelopejs/interface-dms/auth/db");
|
|
7
|
+
async function isPlatformSupportEntry(userId, isTenantOwner) {
|
|
8
|
+
if (isTenantOwner)
|
|
9
|
+
return false;
|
|
10
|
+
const user = await (0, interface_database_decorators_1.GetModel)(db_1.UserModel).get(userId);
|
|
11
|
+
return user?.owner === true;
|
|
12
|
+
}
|
|
13
|
+
async function isPlatformSupportInvite(email, asTenantOwner) {
|
|
14
|
+
if (asTenantOwner)
|
|
15
|
+
return false;
|
|
16
|
+
const user = await (0, interface_database_decorators_1.GetModel)(db_1.UserModel).getByEmail(email);
|
|
17
|
+
return user?.owner === true;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=platform-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-support.js","sourceRoot":"","sources":["../../src/plans/platform-support.ts"],"names":[],"mappings":";;AAQA,wDAOC;AAMD,0DAOC;AA5BD,6FAAqE;AACrE,0DAA8D;AAOvD,KAAK,UAAU,sBAAsB,CAC1C,MAAc,EACd,aAAsB;IAEtB,IAAI,aAAa;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,IAAI,GAAG,MAAM,IAAA,wCAAQ,EAAC,cAAS,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;AAC9B,CAAC;AAMM,KAAK,UAAU,uBAAuB,CAC3C,KAAa,EACb,aAAsB;IAEtB,IAAI,aAAa;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,IAAI,GAAG,MAAM,IAAA,wCAAQ,EAAC,cAAS,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACzD,OAAO,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;AAC9B,CAAC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
export interface PlatformSupportMember {
|
|
2
|
+
userId: string;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
}
|
|
1
6
|
export interface SeatUsage {
|
|
2
7
|
members: number;
|
|
3
8
|
pendingInvites: number;
|
|
4
9
|
occupied: number;
|
|
10
|
+
platformSupport: PlatformSupportMember[];
|
|
5
11
|
}
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
12
|
+
export declare function countSeatedUsers(tenantId: string, userIds: string[]): Promise<number>;
|
|
13
|
+
export declare function getSeatUsage(tenantId: string, releasedInviteeEmail?: string): Promise<SeatUsage>;
|
|
14
|
+
export declare function countOccupiedSeats(tenantId: string, releasedInviteeEmail?: string): Promise<number>;
|
|
8
15
|
export declare function hasSeatCapacity(maxMembers: number, currentSeats: number): boolean;
|
|
9
16
|
export declare function fitsWithinSeatLimit(maxMembers: number, currentSeats: number): boolean;
|
|
@@ -1,28 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countSeatedUsers = countSeatedUsers;
|
|
3
4
|
exports.getSeatUsage = getSeatUsage;
|
|
4
5
|
exports.countOccupiedSeats = countOccupiedSeats;
|
|
5
6
|
exports.hasSeatCapacity = hasSeatCapacity;
|
|
6
7
|
exports.fitsWithinSeatLimit = fitsWithinSeatLimit;
|
|
7
8
|
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
8
9
|
const db_1 = require("@antelopejs/interface-dms/db");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const db_2 = require("@antelopejs/interface-dms/auth/db");
|
|
11
|
+
function normalizeEmail(email) {
|
|
12
|
+
return email.trim().toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
async function loadPlatformOwners() {
|
|
15
|
+
const owners = await (0, interface_database_decorators_1.GetModel)(db_2.UserModel).getOwners();
|
|
16
|
+
return {
|
|
17
|
+
byUserId: new Map(owners.map((owner) => [owner._id, owner])),
|
|
18
|
+
emails: new Set(owners.map((owner) => normalizeEmail(owner.email))),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function supportUserOf(member, owners) {
|
|
22
|
+
if (member.isTenantOwner)
|
|
23
|
+
return undefined;
|
|
24
|
+
return owners.byUserId.get(member.userId);
|
|
25
|
+
}
|
|
26
|
+
function holdsSeat(invite, owners) {
|
|
27
|
+
return (invite.asTenantOwner || !owners.emails.has(normalizeEmail(invite.email)));
|
|
28
|
+
}
|
|
29
|
+
async function countSeatedUsers(tenantId, userIds) {
|
|
30
|
+
const [members, owners] = await Promise.all([
|
|
31
|
+
(0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, tenantId).listAll(),
|
|
32
|
+
loadPlatformOwners(),
|
|
33
|
+
]);
|
|
34
|
+
const supportUserIds = new Set(members
|
|
35
|
+
.filter((member) => supportUserOf(member, owners))
|
|
36
|
+
.map((member) => member.userId));
|
|
37
|
+
return userIds.filter((userId) => !supportUserIds.has(userId)).length;
|
|
38
|
+
}
|
|
39
|
+
function toPlatformSupportMember(owner) {
|
|
40
|
+
return { userId: owner._id, name: owner.name, email: owner.email };
|
|
41
|
+
}
|
|
42
|
+
function listPlatformSupport(members, owners) {
|
|
43
|
+
return members.flatMap((member) => {
|
|
44
|
+
const owner = supportUserOf(member, owners);
|
|
45
|
+
return owner ? [toPlatformSupportMember(owner)] : [];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async function getSeatUsage(tenantId, releasedInviteeEmail) {
|
|
49
|
+
const [members, invites, owners] = await Promise.all([
|
|
50
|
+
(0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, tenantId).listAll(),
|
|
51
|
+
(0, interface_database_decorators_1.GetModel)(db_1.UserInviteModel, tenantId).getAll(),
|
|
52
|
+
loadPlatformOwners(),
|
|
15
53
|
]);
|
|
16
54
|
const nowMs = Date.now();
|
|
17
|
-
const
|
|
55
|
+
const pendingInvitees = new Set(invites
|
|
56
|
+
.filter((invite) => new Date(invite.expiresAt).getTime() > nowMs)
|
|
57
|
+
.filter((invite) => holdsSeat(invite, owners))
|
|
58
|
+
.map((invite) => normalizeEmail(invite.email)));
|
|
59
|
+
if (releasedInviteeEmail) {
|
|
60
|
+
pendingInvitees.delete(normalizeEmail(releasedInviteeEmail));
|
|
61
|
+
}
|
|
62
|
+
const platformSupport = listPlatformSupport(members, owners);
|
|
63
|
+
const seatedMembers = members.length - platformSupport.length;
|
|
18
64
|
return {
|
|
19
|
-
members:
|
|
20
|
-
pendingInvites:
|
|
21
|
-
occupied:
|
|
65
|
+
members: seatedMembers,
|
|
66
|
+
pendingInvites: pendingInvitees.size,
|
|
67
|
+
occupied: seatedMembers + pendingInvitees.size,
|
|
68
|
+
platformSupport,
|
|
22
69
|
};
|
|
23
70
|
}
|
|
24
|
-
async function countOccupiedSeats(tenantId) {
|
|
25
|
-
const usage = await getSeatUsage(tenantId);
|
|
71
|
+
async function countOccupiedSeats(tenantId, releasedInviteeEmail) {
|
|
72
|
+
const usage = await getSeatUsage(tenantId, releasedInviteeEmail);
|
|
26
73
|
return usage.occupied;
|
|
27
74
|
}
|
|
28
75
|
function hasSeatCapacity(maxMembers, currentSeats) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-capacity.js","sourceRoot":"","sources":["../../src/plans/seat-capacity.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"seat-capacity.js","sourceRoot":"","sources":["../../src/plans/seat-capacity.ts"],"names":[],"mappings":";;AAuEA,4CAcC;AA4BD,oCA2BC;AAED,gDAMC;AAED,0CAMC;AAED,kDAMC;AApKD,6FAAqE;AACrE,qDAKsC;AACtC,0DAAyE;AAyBzE,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,kBAAkB;IAC/B,MAAM,MAAM,GAAG,MAAM,IAAA,wCAAQ,EAAC,cAAS,CAAC,CAAC,SAAS,EAAE,CAAC;IACrD,OAAO;QACL,QAAQ,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5D,MAAM,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,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MAAM,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAC9D,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,cAAc,EAAE,eAAe,CAAC,IAAI;QACpC,QAAQ,EAAE,aAAa,GAAG,eAAe,CAAC,IAAI;QAC9C,eAAe;KAChB,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,QAAgB,EAChB,oBAA6B;IAE7B,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC;AAED,SAAgB,eAAe,CAC7B,UAAkB,EAClB,YAAoB;IAEpB,IAAI,UAAU,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,YAAY,GAAG,UAAU,CAAC;AACnC,CAAC;AAED,SAAgB,mBAAmB,CACjC,UAAkB,EAClB,YAAoB;IAEpB,IAAI,UAAU,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,YAAY,IAAI,UAAU,CAAC;AACpC,CAAC"}
|
package/dist/plans/seat-hooks.js
CHANGED
|
@@ -5,9 +5,14 @@ const interface_api_util_1 = require("@antelopejs/interface-api-util");
|
|
|
5
5
|
const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
|
|
6
6
|
const hooks_1 = require("@antelopejs/interface-dms/hooks");
|
|
7
7
|
const db_1 = require("../db");
|
|
8
|
+
const platform_support_1 = require("./platform-support");
|
|
8
9
|
const seat_capacity_1 = require("./seat-capacity");
|
|
9
10
|
const seat_sync_1 = require("./seat-sync");
|
|
10
11
|
const HTTP_PAYMENT_REQUIRED = 402;
|
|
12
|
+
const REISSUED_INVITE_REASONS = new Set([
|
|
13
|
+
"resent",
|
|
14
|
+
"replaced",
|
|
15
|
+
]);
|
|
11
16
|
async function getActivePlanForTenant(tenantId) {
|
|
12
17
|
const tenantSubscriptionModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantSubscriptionModel, tenantId);
|
|
13
18
|
const planModel = (0, interface_database_decorators_1.GetModel)(db_1.PlanModel);
|
|
@@ -19,14 +24,14 @@ async function getActivePlanForTenant(tenantId) {
|
|
|
19
24
|
return null;
|
|
20
25
|
return { plan, stripeSubscriptionId: subscription.stripeSubscriptionId };
|
|
21
26
|
}
|
|
22
|
-
async function enforceSeatCapacity(tenantId) {
|
|
27
|
+
async function enforceSeatCapacity(tenantId, releasedInviteeEmail) {
|
|
23
28
|
const active = await getActivePlanForTenant(tenantId);
|
|
24
29
|
if (!active)
|
|
25
30
|
return;
|
|
26
|
-
const occupied = await (0, seat_capacity_1.countOccupiedSeats)(tenantId);
|
|
31
|
+
const occupied = await (0, seat_capacity_1.countOccupiedSeats)(tenantId, releasedInviteeEmail);
|
|
27
32
|
(0, interface_api_util_1.assert)((0, seat_capacity_1.hasSeatCapacity)(active.plan.maxMembers, occupied), HTTP_PAYMENT_REQUIRED, "saas.errors.plan.seat_limit_reached");
|
|
28
33
|
}
|
|
29
|
-
async function syncSeatsAfterChange(tenantId, idempotencyKey) {
|
|
34
|
+
async function syncSeatsAfterChange(tenantId, idempotencyKey, releasedInviteeEmail) {
|
|
30
35
|
const active = await getActivePlanForTenant(tenantId);
|
|
31
36
|
if (!active)
|
|
32
37
|
return;
|
|
@@ -35,14 +40,20 @@ async function syncSeatsAfterChange(tenantId, idempotencyKey) {
|
|
|
35
40
|
plan: active.plan,
|
|
36
41
|
stripeSubscriptionId: active.stripeSubscriptionId,
|
|
37
42
|
idempotencyKey,
|
|
43
|
+
quantityOverride: releasedInviteeEmail
|
|
44
|
+
? await (0, seat_capacity_1.countOccupiedSeats)(tenantId, releasedInviteeEmail)
|
|
45
|
+
: undefined,
|
|
38
46
|
});
|
|
39
47
|
}
|
|
40
|
-
async function syncSeatsAfterRemoval(tenantId,
|
|
48
|
+
async function syncSeatsAfterRemoval(tenantId, removedUserIds, idempotencyKey) {
|
|
41
49
|
const active = await getActivePlanForTenant(tenantId);
|
|
42
50
|
if (!active)
|
|
43
51
|
return;
|
|
44
|
-
const currentOccupied = await
|
|
45
|
-
|
|
52
|
+
const [currentOccupied, removedSeats] = await Promise.all([
|
|
53
|
+
(0, seat_capacity_1.countOccupiedSeats)(tenantId),
|
|
54
|
+
(0, seat_capacity_1.countSeatedUsers)(tenantId, removedUserIds),
|
|
55
|
+
]);
|
|
56
|
+
const nextOccupied = Math.max(0, currentOccupied - removedSeats);
|
|
46
57
|
await (0, seat_sync_1.syncStripeSeatQuantity)({
|
|
47
58
|
tenantId,
|
|
48
59
|
plan: active.plan,
|
|
@@ -52,15 +63,25 @@ async function syncSeatsAfterRemoval(tenantId, removedCount, idempotencyKey) {
|
|
|
52
63
|
});
|
|
53
64
|
}
|
|
54
65
|
function registerSeatHooks() {
|
|
55
|
-
(0, hooks_1.RegisterHook)(hooks_1.Hook.MEMBER_BEING_ADDED, async ({ tenantId }) => {
|
|
66
|
+
(0, hooks_1.RegisterHook)(hooks_1.Hook.MEMBER_BEING_ADDED, async ({ tenantId, userId, isTenantOwner, deliveryId }) => {
|
|
67
|
+
if (deliveryId)
|
|
68
|
+
return undefined;
|
|
69
|
+
if (await (0, platform_support_1.isPlatformSupportEntry)(userId, isTenantOwner))
|
|
70
|
+
return undefined;
|
|
56
71
|
await enforceSeatCapacity(tenantId);
|
|
57
72
|
return undefined;
|
|
58
73
|
});
|
|
59
|
-
(0, hooks_1.RegisterHook)(hooks_1.Hook.INVITE_BEING_CREATED, async ({ tenantId }) => {
|
|
60
|
-
await
|
|
74
|
+
(0, hooks_1.RegisterHook)(hooks_1.Hook.INVITE_BEING_CREATED, async ({ tenantId, email, asTenantOwner }) => {
|
|
75
|
+
if (await (0, platform_support_1.isPlatformSupportInvite)(email, asTenantOwner))
|
|
76
|
+
return undefined;
|
|
77
|
+
await enforceSeatCapacity(tenantId, email);
|
|
61
78
|
return undefined;
|
|
62
79
|
});
|
|
63
|
-
(0, hooks_1.RegisterHook)(hooks_1.Hook.MEMBER_ADDED, async ({ tenantId, userId }) => {
|
|
80
|
+
(0, hooks_1.RegisterHook)(hooks_1.Hook.MEMBER_ADDED, async ({ tenantId, userId, isTenantOwner, deliveryId }) => {
|
|
81
|
+
if (deliveryId)
|
|
82
|
+
return undefined;
|
|
83
|
+
if (await (0, platform_support_1.isPlatformSupportEntry)(userId, isTenantOwner))
|
|
84
|
+
return undefined;
|
|
64
85
|
await syncSeatsAfterChange(tenantId, `seat-sync:member-added:${tenantId}:${userId}`);
|
|
65
86
|
return undefined;
|
|
66
87
|
});
|
|
@@ -68,12 +89,12 @@ function registerSeatHooks() {
|
|
|
68
89
|
await syncSeatsAfterChange(tenantId, `seat-sync:invite-created:${tenantId}:${inviteId}`);
|
|
69
90
|
return undefined;
|
|
70
91
|
});
|
|
71
|
-
(0, hooks_1.RegisterHook)(hooks_1.Hook.INVITE_DELETED, async ({ tenantId, inviteId }) => {
|
|
72
|
-
await syncSeatsAfterChange(tenantId, `seat-sync:invite-deleted:${tenantId}:${inviteId}
|
|
92
|
+
(0, hooks_1.RegisterHook)(hooks_1.Hook.INVITE_DELETED, async ({ tenantId, inviteId, email, reason }) => {
|
|
93
|
+
await syncSeatsAfterChange(tenantId, `seat-sync:invite-deleted:${tenantId}:${inviteId}`, REISSUED_INVITE_REASONS.has(reason) ? undefined : email);
|
|
73
94
|
return undefined;
|
|
74
95
|
});
|
|
75
96
|
(0, hooks_1.RegisterHook)(hooks_1.Hook.MEMBER_REMOVED, async ({ tenantId, userIds }) => {
|
|
76
|
-
await syncSeatsAfterRemoval(tenantId, userIds
|
|
97
|
+
await syncSeatsAfterRemoval(tenantId, userIds, `seat-sync:member-removed:${tenantId}:${userIds.join(",")}`);
|
|
77
98
|
return undefined;
|
|
78
99
|
});
|
|
79
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-hooks.js","sourceRoot":"","sources":["../../src/plans/seat-hooks.ts"],"names":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