@antelopejs/dms-saas 0.3.11 → 0.3.13

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.
Files changed (48) hide show
  1. package/dist/operator-actions/db/lifecycle-delivery.model.d.ts +2 -0
  2. package/dist/operator-actions/db/lifecycle-delivery.model.js +38 -5
  3. package/dist/operator-actions/db/lifecycle-delivery.model.js.map +1 -1
  4. package/dist/operator-actions/db/lifecycle-delivery.table.d.ts +2 -0
  5. package/dist/operator-actions/db/lifecycle-delivery.table.js +8 -0
  6. package/dist/operator-actions/db/lifecycle-delivery.table.js.map +1 -1
  7. package/dist/operator-actions/lifecycle-outbox.js +11 -5
  8. package/dist/operator-actions/lifecycle-outbox.js.map +1 -1
  9. package/dist/pages/platform/settings.js +0 -6
  10. package/dist/pages/platform/settings.js.map +1 -1
  11. package/dist/routes/platformOwner/billing-settings.d.ts +24 -3
  12. package/dist/routes/platformOwner/billing-settings.js +0 -3
  13. package/dist/routes/platformOwner/billing-settings.js.map +1 -1
  14. package/dist/routes/tenant/workspaces.d.ts +2 -5
  15. package/dist/routes/tenant/workspaces.js +8 -4
  16. package/dist/routes/tenant/workspaces.js.map +1 -1
  17. package/dist/upcoming-invoice/eligibility.js +2 -2
  18. package/dist/upcoming-invoice/eligibility.js.map +1 -1
  19. package/dist/workers/plan-migration.js +24 -4
  20. package/dist/workers/plan-migration.js.map +1 -1
  21. package/dist/workspaces/db/provisioning-attempt.table.d.ts +0 -1
  22. package/dist/workspaces/db/provisioning-attempt.table.js +0 -4
  23. package/dist/workspaces/db/provisioning-attempt.table.js.map +1 -1
  24. package/dist/workspaces/default-plan.js +2 -2
  25. package/dist/workspaces/default-plan.js.map +1 -1
  26. package/dist/workspaces/free-plan.d.ts +2 -0
  27. package/dist/workspaces/free-plan.js +8 -0
  28. package/dist/workspaces/free-plan.js.map +1 -0
  29. package/dist/workspaces/index.d.ts +1 -1
  30. package/dist/workspaces/index.js +1 -1
  31. package/dist/workspaces/index.js.map +1 -1
  32. package/dist/workspaces/provisioning-state.js +0 -19
  33. package/dist/workspaces/provisioning-state.js.map +1 -1
  34. package/dist/workspaces/provisioning.js +2 -2
  35. package/dist/workspaces/provisioning.js.map +1 -1
  36. package/frontend-vue/app/components/WorkspaceCreateModal.vue +60 -60
  37. package/frontend-vue/i18n/locales/saas-en-GB.json +1 -6
  38. package/frontend-vue/i18n/locales/saas-fr-FR.json +1 -6
  39. package/package.json +2 -2
  40. package/dist/workspaces/db/card-capacity.model.d.ts +0 -30
  41. package/dist/workspaces/db/card-capacity.model.js +0 -98
  42. package/dist/workspaces/db/card-capacity.model.js.map +0 -1
  43. package/dist/workspaces/db/card-capacity.table.d.ts +0 -11
  44. package/dist/workspaces/db/card-capacity.table.js +0 -34
  45. package/dist/workspaces/db/card-capacity.table.js.map +0 -1
  46. package/dist/workspaces/free-workspace-guard.d.ts +0 -11
  47. package/dist/workspaces/free-workspace-guard.js +0 -96
  48. package/dist/workspaces/free-workspace-guard.js.map +0 -1
@@ -1,11 +0,0 @@
1
- import { Table } from "@antelopejs/interface-database-decorators";
2
- export interface CardCapacityAllocation {
3
- tenantId: string;
4
- state: "reserved" | "confirmed" | "reconciliation_required";
5
- }
6
- export declare const cardCapacitiesTableName = "saas_card_capacities";
7
- export declare class CardCapacity extends Table {
8
- _id: string;
9
- revision: string;
10
- allocations: CardCapacityAllocation[];
11
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CardCapacity = exports.cardCapacitiesTableName = void 0;
13
- const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
14
- const constants_1 = require("@antelopejs/interface-dms/constants");
15
- exports.cardCapacitiesTableName = "saas_card_capacities";
16
- let CardCapacity = class CardCapacity extends interface_database_decorators_1.Table {
17
- };
18
- exports.CardCapacity = CardCapacity;
19
- __decorate([
20
- (0, interface_database_decorators_1.Field)("string"),
21
- __metadata("design:type", String)
22
- ], CardCapacity.prototype, "_id", void 0);
23
- __decorate([
24
- (0, interface_database_decorators_1.Field)("string"),
25
- __metadata("design:type", String)
26
- ], CardCapacity.prototype, "revision", void 0);
27
- __decorate([
28
- (0, interface_database_decorators_1.Field)("any"),
29
- __metadata("design:type", Array)
30
- ], CardCapacity.prototype, "allocations", void 0);
31
- exports.CardCapacity = CardCapacity = __decorate([
32
- (0, interface_database_decorators_1.RegisterTable)(exports.cardCapacitiesTableName, constants_1.CORE_SCHEMA_NAME)
33
- ], CardCapacity);
34
- //# sourceMappingURL=card-capacity.table.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-capacity.table.js","sourceRoot":"","sources":["../../../src/workspaces/db/card-capacity.table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6FAImD;AACnD,mEAAuE;AAQ1D,QAAA,uBAAuB,GAAG,sBAAsB,CAAC;AAIvD,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,qCAAK;CAStC,CAAA;AATY,oCAAY;AAEf;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;yCACI;AAGZ;IADP,IAAA,qCAAK,EAAC,QAAQ,CAAC;;8CACS;AAGjB;IADP,IAAA,qCAAK,EAAC,KAAK,CAAC;;iDACiC;uBARnC,YAAY;IADxB,IAAA,6CAAa,EAAC,+BAAuB,EAAE,4BAAgB,CAAC;GAC5C,YAAY,CASxB"}
@@ -1,11 +0,0 @@
1
- import type { Plan } from "../db";
2
- export interface FreePlanAvailability {
3
- isAvailable: boolean;
4
- blockingWorkspaceName: string | null;
5
- }
6
- export declare function isFreePlan(plan: Plan): boolean;
7
- export declare function resolveMaxFreeWorkspacesPerCard(): Promise<number>;
8
- export declare function findFreeWorkspaceIdsBackedByCard(cardFingerprint: string): Promise<string[]>;
9
- export declare function assertFreePlanAllowedForCard(plan: Plan, cardFingerprint: string | null): Promise<void>;
10
- export declare function resolveFreePlanAvailability(freeWorkspaceNamesPerCard: string[][], limit: number): FreePlanAvailability;
11
- export declare function resolveFreePlanAvailabilityForUser(userId: string): Promise<FreePlanAvailability>;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFreePlan = isFreePlan;
4
- exports.resolveMaxFreeWorkspacesPerCard = resolveMaxFreeWorkspacesPerCard;
5
- exports.findFreeWorkspaceIdsBackedByCard = findFreeWorkspaceIdsBackedByCard;
6
- exports.assertFreePlanAllowedForCard = assertFreePlanAllowedForCard;
7
- exports.resolveFreePlanAvailability = resolveFreePlanAvailability;
8
- exports.resolveFreePlanAvailabilityForUser = resolveFreePlanAvailabilityForUser;
9
- const interface_api_util_1 = require("@antelopejs/interface-api-util");
10
- const interface_database_1 = require("@antelopejs/interface-database");
11
- const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
12
- const db_1 = require("@antelopejs/interface-dms/db");
13
- const db_2 = require("../db");
14
- const utils_1 = require("../utils");
15
- const HTTP_CONFLICT = 409;
16
- const FREE_PLAN_PRICE = 0;
17
- function isFreePlan(plan) {
18
- return plan.price <= FREE_PLAN_PRICE;
19
- }
20
- async function resolveMaxFreeWorkspacesPerCard() {
21
- const settings = await (0, interface_database_decorators_1.GetModel)(db_2.BillingSettingsModel).get(db_2.BILLING_SETTINGS_SINGLETON_ID);
22
- return (settings?.maxFreeWorkspacesPerCard ?? db_2.DEFAULT_MAX_FREE_WORKSPACES_PER_CARD);
23
- }
24
- async function keepFreeSubscriptions(subscriptions) {
25
- const planIds = [
26
- ...new Set(subscriptions
27
- .map((sub) => sub.planId)
28
- .filter((planId) => !!planId)),
29
- ];
30
- if (planIds.length === 0)
31
- return [];
32
- const planModel = (0, interface_database_decorators_1.GetModel)(db_2.PlanModel);
33
- const plans = await Promise.all(planIds.map((planId) => planModel.get(planId)));
34
- const freePlanIds = new Set(plans
35
- .filter((plan) => !!plan && isFreePlan(plan))
36
- .map((plan) => plan._id));
37
- return subscriptions.filter((sub) => sub.planId && freePlanIds.has(sub.planId));
38
- }
39
- async function resolveWorkspaceNames(subscriptions) {
40
- const tenantIds = subscriptions.map((sub) => (0, utils_1.getRowInstance)(sub));
41
- const tenants = await (0, interface_database_decorators_1.GetModel)(db_1.TenantModel).getMany(tenantIds);
42
- return tenants.map((tenant) => tenant.name);
43
- }
44
- async function findFreeWorkspacesBackedByCard(cardFingerprint) {
45
- const subscriptions = await (0, interface_database_decorators_1.GetModel)(db_2.TenantSubscriptionModel, interface_database_1.CROSS_INSTANCE).findByCardFingerprint(cardFingerprint);
46
- const freeSubscriptions = await keepFreeSubscriptions(subscriptions);
47
- if (freeSubscriptions.length === 0)
48
- return [];
49
- return resolveWorkspaceNames(freeSubscriptions);
50
- }
51
- async function findFreeWorkspaceIdsBackedByCard(cardFingerprint) {
52
- const subscriptions = await (0, interface_database_decorators_1.GetModel)(db_2.TenantSubscriptionModel, interface_database_1.CROSS_INSTANCE).findByCardFingerprint(cardFingerprint);
53
- const freeSubscriptions = await keepFreeSubscriptions(subscriptions);
54
- return [
55
- ...new Set(freeSubscriptions.map((subscription) => (0, utils_1.getRowInstance)(subscription))),
56
- ];
57
- }
58
- async function assertFreePlanAllowedForCard(plan, cardFingerprint) {
59
- if (!isFreePlan(plan) || !cardFingerprint)
60
- return;
61
- const [limit, workspaceNames] = await Promise.all([
62
- resolveMaxFreeWorkspacesPerCard(),
63
- findFreeWorkspacesBackedByCard(cardFingerprint),
64
- ]);
65
- (0, interface_api_util_1.assert)(workspaceNames.length < limit, HTTP_CONFLICT, "saas.errors.workspace.free_limit_reached");
66
- }
67
- async function collectUserCardFingerprints(userId) {
68
- const memberships = await (0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, interface_database_1.CROSS_INSTANCE).listByUserWithTenantIds(userId);
69
- const subscriptions = await Promise.all(memberships.map((membership) => (0, interface_database_decorators_1.GetModel)(db_2.TenantSubscriptionModel, membership.tenantId).findOne()));
70
- const fingerprints = subscriptions
71
- .map((subscription) => subscription?.cardFingerprint)
72
- .filter((fingerprint) => !!fingerprint);
73
- return new Set(fingerprints);
74
- }
75
- function resolveFreePlanAvailability(freeWorkspaceNamesPerCard, limit) {
76
- if (freeWorkspaceNamesPerCard.length === 0) {
77
- return { isAvailable: true, blockingWorkspaceName: null };
78
- }
79
- const hasCardWithRoom = freeWorkspaceNamesPerCard.some((workspaceNames) => workspaceNames.length < limit);
80
- if (hasCardWithRoom) {
81
- return { isAvailable: true, blockingWorkspaceName: null };
82
- }
83
- return {
84
- isAvailable: false,
85
- blockingWorkspaceName: freeWorkspaceNamesPerCard.flat()[0] ?? null,
86
- };
87
- }
88
- async function resolveFreePlanAvailabilityForUser(userId) {
89
- const fingerprints = await collectUserCardFingerprints(userId);
90
- const [limit, usages] = await Promise.all([
91
- resolveMaxFreeWorkspacesPerCard(),
92
- Promise.all([...fingerprints].map((fingerprint) => findFreeWorkspacesBackedByCard(fingerprint))),
93
- ]);
94
- return resolveFreePlanAvailability(usages, limit);
95
- }
96
- //# sourceMappingURL=free-workspace-guard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"free-workspace-guard.js","sourceRoot":"","sources":["../../src/workspaces/free-workspace-guard.ts"],"names":[],"mappings":";;AAsBA,gCAEC;AAED,0EAOC;AAgDD,4EAaC;AAOD,oEAcC;AAyBD,kEAiBC;AAED,gFAaC;AA5KD,uEAAwD;AACxD,uEAAgE;AAChE,6FAAqE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