@antelopejs/dms-saas 0.5.0 → 0.6.0
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 +12 -1
- package/dist/billing-state/recovery.js +2 -2
- package/dist/billing-state/recovery.js.map +1 -1
- package/dist/pages/platform/credit-notes.js +1 -1
- package/dist/pages/platform/credit-notes.js.map +1 -1
- package/dist/pages/platform/features.js +3 -1
- package/dist/pages/platform/features.js.map +1 -1
- package/dist/pages/platform/invoices.js +2 -2
- package/dist/pages/platform/invoices.js.map +1 -1
- package/dist/pages/platform/plans/index.js +15 -9
- package/dist/pages/platform/plans/index.js.map +1 -1
- package/dist/pages/platform/plans/migrations.js +2 -2
- package/dist/pages/platform/plans/migrations.js.map +1 -1
- package/dist/pages/platform/segments/index.js +1 -1
- package/dist/pages/platform/segments/index.js.map +1 -1
- package/dist/pages/platform/users/detail.js +11 -3
- package/dist/pages/platform/users/detail.js.map +1 -1
- package/dist/pages/platform/users/index.js +1 -1
- package/dist/pages/platform/users/index.js.map +1 -1
- package/dist/pages/platform/workspaces/detail.js +1 -1
- package/dist/pages/platform/workspaces/detail.js.map +1 -1
- package/dist/pages/platform/workspaces/index.js +2 -2
- package/dist/pages/platform/workspaces/index.js.map +1 -1
- package/dist/pages/tenant/billing.js +2 -2
- package/dist/pages/tenant/billing.js.map +1 -1
- package/dist/stripe/client.d.ts +3 -0
- package/dist/stripe/client.js +16 -1
- package/dist/stripe/client.js.map +1 -1
- package/dist/stripe/customer-billing.js +1 -1
- package/dist/stripe/customer-billing.js.map +1 -1
- package/dist/stripe/subscription-cancellation.js +1 -1
- package/dist/stripe/subscription-cancellation.js.map +1 -1
- package/dist/stripe/upcoming-invoice.js +3 -3
- package/dist/stripe/upcoming-invoice.js.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.js.map +1 -1
- package/frontend-vue/app/build/PayInvoicePanel.vue +4 -8
- package/frontend-vue/app/build/PlanChangeReview.vue +3 -6
- package/frontend-vue/app/build/public/RegistrationCardField.vue +6 -3
- package/frontend-vue/app/build/segments/useSegmentCatalog.ts +7 -12
- package/frontend-vue/app/build/useWorkspaceName.ts +1 -2
- package/frontend-vue/app/build/users/useUserDetail.ts +8 -10
- package/frontend-vue/app/build/workspace-detail/ComplimentaryDialog.vue +5 -3
- package/frontend-vue/app/build/workspace-detail/CreditDialog.vue +5 -3
- package/frontend-vue/app/build/workspace-detail/UpgradeDialog.vue +14 -7
- package/frontend-vue/app/build/workspace-detail/useWorkspaceActions.ts +11 -10
- package/frontend-vue/app/build/workspace-detail/useWorkspaceOverview.ts +16 -30
- package/frontend-vue/app/components/CustomerPortalButton.vue +6 -4
- package/frontend-vue/app/components/DataExport.vue +34 -54
- package/frontend-vue/app/components/DataExportHistory.vue +2 -7
- package/frontend-vue/app/components/IssueCreditNoteModal.vue +5 -4
- package/frontend-vue/app/components/MigrationStripeCheck.vue +11 -8
- package/frontend-vue/app/components/PastDueAlert.vue +8 -6
- package/frontend-vue/app/components/PastDueBanner.vue +4 -4
- package/frontend-vue/app/components/PaymentMethodCard.vue +7 -12
- package/frontend-vue/app/components/PlanAccessEditor.vue +31 -30
- package/frontend-vue/app/components/PlanCard.vue +2 -3
- package/frontend-vue/app/components/PlanEditorPreview.vue +27 -36
- package/frontend-vue/app/components/PlanUpgradeModal.vue +1 -1
- package/frontend-vue/app/components/PlatformNotes.vue +27 -28
- package/frontend-vue/app/components/Pricing.vue +16 -23
- package/frontend-vue/app/components/RefundButton.vue +62 -46
- package/frontend-vue/app/components/RetirePlanModal.vue +13 -7
- package/frontend-vue/app/components/SeatQuotaBanner.vue +9 -10
- package/frontend-vue/app/components/SegmentConditionsBuilder.vue +0 -1
- package/frontend-vue/app/components/SegmentRulesText.vue +1 -3
- package/frontend-vue/app/components/TenantBillingForm.vue +14 -19
- package/frontend-vue/app/components/TenantPlanCard.vue +19 -22
- package/frontend-vue/app/components/TrialEndingBanner.vue +5 -10
- package/frontend-vue/app/components/UserPlatformRoleCard.vue +8 -9
- package/frontend-vue/app/components/UserSegmentMatches.vue +8 -16
- package/frontend-vue/app/components/UserSummaryCard.vue +2 -4
- package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +13 -5
- package/frontend-vue/app/components/WorkspaceCreateModal.vue +5 -1
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +8 -7
- package/frontend-vue/app/components/WorkspaceDetailHeader.vue +14 -4
- package/frontend-vue/app/components/WorkspaceSuspended.vue +27 -32
- package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +5 -16
- package/frontend-vue/app/composables/useBillingIdentity.ts +9 -5
- package/frontend-vue/app/composables/useBillingStatus.ts +8 -7
- package/frontend-vue/app/composables/useCurrentWorkspace.ts +6 -8
- package/frontend-vue/app/composables/useExportHistory.ts +67 -78
- package/frontend-vue/app/composables/useMountedData.ts +27 -0
- package/frontend-vue/app/composables/useMyWorkspaces.ts +24 -27
- package/frontend-vue/app/composables/useNextInvoice.ts +7 -6
- package/frontend-vue/app/composables/useOnDemandRead.ts +49 -0
- package/frontend-vue/app/composables/usePendingCheckout.ts +2 -1
- package/frontend-vue/app/composables/usePlanCatalog.ts +3 -9
- package/frontend-vue/app/composables/usePublicPricing.ts +24 -0
- package/frontend-vue/app/composables/useSaasRegistration.ts +2 -0
- package/frontend-vue/app/composables/useSeatQuota.ts +2 -6
- package/frontend-vue/app/composables/useTenantPlan.ts +26 -9
- package/frontend-vue/app/composables/useWorkspaceOverview.ts +2 -6
- package/frontend-vue/i18n/locales/saas-public-en-GB.json +1 -0
- package/frontend-vue/i18n/locales/saas-public-fr-FR.json +1 -0
- package/frontend-vue/package.json +1 -1
- package/package.json +4 -4
- package/frontend-vue/app/composables/useServerConfirm.ts +0 -44
- package/frontend-vue/app/composables/useSharedRequest.ts +0 -54
- package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +0 -52
package/dist/stripe/client.js
CHANGED
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.STRIPE_API_VERSION = void 0;
|
|
6
|
+
exports.DEFAULT_STRIPE_READ_MAX_NETWORK_RETRIES = exports.DEFAULT_STRIPE_READ_TIMEOUT_MS = exports.STRIPE_API_VERSION = void 0;
|
|
7
7
|
exports.initStripeClient = initStripeClient;
|
|
8
8
|
exports.stripeDashboardUrl = stripeDashboardUrl;
|
|
9
9
|
exports.isStripeConfigured = isStripeConfigured;
|
|
10
10
|
exports.getStripeClient = getStripeClient;
|
|
11
|
+
exports.getStripeReadClient = getStripeReadClient;
|
|
11
12
|
exports.getStripeWebhookSecret = getStripeWebhookSecret;
|
|
12
13
|
const stripe_1 = __importDefault(require("stripe"));
|
|
13
14
|
exports.STRIPE_API_VERSION = "2026-08-26.dahlia";
|
|
@@ -16,7 +17,10 @@ const PLACEHOLDER_MARKER = "placeholder";
|
|
|
16
17
|
const TEST_MODE_MARKER = "_test_";
|
|
17
18
|
const STRIPE_DASHBOARD_URL = "https://dashboard.stripe.com";
|
|
18
19
|
const TEST_MODE_DASHBOARD_PATH = "/test";
|
|
20
|
+
exports.DEFAULT_STRIPE_READ_TIMEOUT_MS = 4000;
|
|
21
|
+
exports.DEFAULT_STRIPE_READ_MAX_NETWORK_RETRIES = 0;
|
|
19
22
|
let stripeClient = null;
|
|
23
|
+
let stripeReadClient = null;
|
|
20
24
|
let stripeWebhookSecret = null;
|
|
21
25
|
let stripeConfigured = false;
|
|
22
26
|
let stripeTestMode = false;
|
|
@@ -29,6 +33,11 @@ function initStripeClient(config) {
|
|
|
29
33
|
stripeClient = new stripe_1.default(config.secretKey, {
|
|
30
34
|
apiVersion: exports.STRIPE_API_VERSION,
|
|
31
35
|
});
|
|
36
|
+
stripeReadClient = new stripe_1.default(config.secretKey, {
|
|
37
|
+
apiVersion: exports.STRIPE_API_VERSION,
|
|
38
|
+
timeout: config.readTimeoutMs ?? exports.DEFAULT_STRIPE_READ_TIMEOUT_MS,
|
|
39
|
+
maxNetworkRetries: config.readMaxNetworkRetries ?? exports.DEFAULT_STRIPE_READ_MAX_NETWORK_RETRIES,
|
|
40
|
+
});
|
|
32
41
|
stripeWebhookSecret = config.webhookSecret;
|
|
33
42
|
stripeConfigured = isUsableSecretKey(config.secretKey);
|
|
34
43
|
stripeTestMode = config.secretKey.includes(TEST_MODE_MARKER);
|
|
@@ -47,6 +56,12 @@ function getStripeClient() {
|
|
|
47
56
|
}
|
|
48
57
|
return stripeClient;
|
|
49
58
|
}
|
|
59
|
+
function getStripeReadClient() {
|
|
60
|
+
if (!stripeReadClient) {
|
|
61
|
+
throw new Error("Stripe client not initialized. Call initStripeClient first.");
|
|
62
|
+
}
|
|
63
|
+
return stripeReadClient;
|
|
64
|
+
}
|
|
50
65
|
function getStripeWebhookSecret() {
|
|
51
66
|
if (!stripeWebhookSecret) {
|
|
52
67
|
throw new Error("Stripe webhook secret not initialized.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/stripe/client.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/stripe/client.ts"],"names":[],"mappings":";;;;;;AA6CA,4CAaC;AAQD,gDAIC;AAED,gDAEC;AAED,0CAOC;AAQD,kDAOC;AAED,wDAKC;AAzGD,oDAA4B;AAUf,QAAA,kBAAkB,GAA4B,mBAAmB,CAAC;AAE/E,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AACzC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAC5D,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAM5B,QAAA,8BAA8B,GAAG,IAAI,CAAC;AAKtC,QAAA,uCAAuC,GAAG,CAAC,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GAAG,SAAS,GAAG,IAAI,EAAE,CAAC;AAC7D,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAQD,SAAgB,mBAAmB;IACjC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAgB,sBAAsB;IACpC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -112,7 +112,7 @@ function toVatVerificationStatus(taxId) {
|
|
|
112
112
|
return (status && VAT_VERIFICATION_BY_STRIPE_STATUS[status]) ?? "pending";
|
|
113
113
|
}
|
|
114
114
|
async function fetchPrimaryTaxId(customerId) {
|
|
115
|
-
const stripe = (0, client_1.
|
|
115
|
+
const stripe = (0, client_1.getStripeReadClient)();
|
|
116
116
|
const taxIds = await stripe.customers
|
|
117
117
|
.listTaxIds(customerId)
|
|
118
118
|
.catch(() => null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer-billing.js","sourceRoot":"","sources":["../../src/stripe/customer-billing.ts"],"names":[],"mappings":";;AA0EA,4CAOC;AAED,0CAYC;AAED,wDAYC;AAqBD,sDAMC;AAED,8DAUC;AAED,0DAKC;AAWD,8CASC;AAUD,oDAoBC;AA3MD,
|
|
1
|
+
{"version":3,"file":"customer-billing.js","sourceRoot":"","sources":["../../src/stripe/customer-billing.ts"],"names":[],"mappings":";;AA0EA,4CAOC;AAED,0CAYC;AAED,w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IAAI,EAAE,CAAC;QAClC,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,OAAO,CAAC,YAAY,KAAK,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3E,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE;QAC7D,IAAI,EAAE,IAAqC;QAC3C,KAAK,EAAE,OAAO,CAAC,SAAS;KACzB,CAAC,CAAC;IACH,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -15,7 +15,7 @@ function readScheduledCancellation(subscription) {
|
|
|
15
15
|
}
|
|
16
16
|
async function fetchScheduledCancellation(stripeSubscriptionId) {
|
|
17
17
|
try {
|
|
18
|
-
const subscription = await (0, client_1.
|
|
18
|
+
const subscription = await (0, client_1.getStripeReadClient)().subscriptions.retrieve(stripeSubscriptionId);
|
|
19
19
|
return readScheduledCancellation(subscription);
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-cancellation.js","sourceRoot":"","sources":["../../src/stripe/subscription-cancellation.ts"],"names":[],"mappings":";;AAeA,8DAOC;AASD,gEAcC;AA7CD,gEAA6D;AAE7D,wCAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"subscription-cancellation.js","sourceRoot":"","sources":["../../src/stripe/subscription-cancellation.ts"],"names":[],"mappings":";;AAeA,8DAOC;AASD,gEAcC;AA7CD,gEAA6D;AAE7D,wCAAoD;AACpD,qCAA+C;AAC/C,qDAA6D;AAE7D,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAS7C,SAAgB,yBAAyB,CACvC,YAAiC;IAEjC,IAAI,YAAY,CAAC,oBAAoB,EAAE,CAAC;QACtC,OAAO,IAAA,0CAAyB,EAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,IAAA,0BAAmB,EAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACrD,CAAC;AASM,KAAK,UAAU,0BAA0B,CAC9C,oBAA4B;IAE5B,IAAI,CAAC;QACH,MAAM,YAAY,GAChB,MAAM,IAAA,4BAAmB,GAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;QAC3E,OAAO,yBAAyB,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iBAAO,CAAC,IAAI,CACV,GAAG,UAAU,gCAAgC,oBAAoB,EAAE,EACnE,KAAK,CACN,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -26,7 +26,7 @@ function toPreviewInvoiceItem(currency, item) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
async function retrieveStripeSubscriptionCycle(subscriptionId) {
|
|
29
|
-
const subscription = await (0, client_1.
|
|
29
|
+
const subscription = await (0, client_1.getStripeReadClient)().subscriptions.retrieve(subscriptionId);
|
|
30
30
|
const period = (0, payload_shapes_1.readSubscriptionPeriod)(subscription);
|
|
31
31
|
if (period.start === null || period.end === null)
|
|
32
32
|
throw new Error(`Stripe subscription ${subscriptionId} has no billing period`);
|
|
@@ -43,12 +43,12 @@ function collectTaxRateIds(invoice) {
|
|
|
43
43
|
return [...new Set(ids)];
|
|
44
44
|
}
|
|
45
45
|
async function retrieveTaxRates(ids) {
|
|
46
|
-
const stripe = (0, client_1.
|
|
46
|
+
const stripe = (0, client_1.getStripeReadClient)();
|
|
47
47
|
const rates = await Promise.all(ids.map((id) => stripe.taxRates.retrieve(id)));
|
|
48
48
|
return new Map(rates.map((rate) => [rate.id, rate]));
|
|
49
49
|
}
|
|
50
50
|
async function previewStripeInvoice(params) {
|
|
51
|
-
const invoice = await (0, client_1.
|
|
51
|
+
const invoice = await (0, client_1.getStripeReadClient)().invoices.createPreview(params);
|
|
52
52
|
const taxRates = await retrieveTaxRates(collectTaxRateIds(invoice));
|
|
53
53
|
return { invoice, taxRates };
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upcoming-invoice.js","sourceRoot":"","sources":["../../src/stripe/upcoming-invoice.ts"],"names":[],"mappings":";;AAgEA,0EAeC;AAwBD,oDAMC;AAMD,oEAUC;AAkBD,4DAYC;AA1JD,
|
|
1
|
+
{"version":3,"file":"upcoming-invoice.js","sourceRoot":"","sources":["../../src/stripe/upcoming-invoice.ts"],"names":[],"mappings":";;AAgEA,0EAeC;AAwBD,oDAMC;AAMD,oEAUC;AAkBD,4DAYC;AA1JD,qCAA+C;AAC/C,qDAA0D;AAE1D,MAAM,aAAa,GAAG,IAAI,CAAC;AAmC3B,SAAS,eAAe,CAAC,IAAU;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe;IACxC,OAAO,IAAI,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,oBAAoB,CAC3B,QAAgB,EAChB,IAAuB;IAEvB,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,gBAAgB;QAC7B,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE;YACN,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC;YACxC,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC;SACrC;QACD,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC;AACJ,CAAC;AAGM,KAAK,UAAU,+BAA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I,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC;AAOM,KAAK,UAAU,oBAAoB,CACxC,MAAyC;IAEzC,MAAM,OAAO,GAAG,MAAM,IAAA,4BAAmB,GAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3E,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAMM,KAAK,UAAU,4BAA4B,CAChD,OAAsC;IAEtC,OAAO,oBAAoB,CAAC;QAC1B,QAAQ,EAAE,OAAO,CAAC,UAAU;QAC5B,YAAY,EAAE,OAAO,CAAC,cAAc;QACpC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC9C,oBAAoB,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAC7C;KACF,CAAC,CAAC;AACL,CAAC;AAkBM,KAAK,UAAU,wBAAwB,CAC5C,OAAkC;IAElC,OAAO,oBAAoB,CAAC;QAC1B,QAAQ,EAAE,OAAO,CAAC,UAAU;QAC5B,YAAY,EAAE,OAAO,CAAC,cAAc;QACpC,oBAAoB,EAAE;YACpB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;YACvD,kBAAkB,EAAE,mBAAmB;YACvC,cAAc,EAAE,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC;SACvD;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
package/dist/types/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":";;;AAgCa,QAAA,oCAAoC,GAAG;IAClD,UAAU;IACV,UAAU;IACV,MAAM;CACE,CAAC;AAME,QAAA,0CAA0C,GACrD,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
|
|
4
4
|
type PaymentChoice = 'default_card' | 'other_card'
|
|
5
5
|
|
|
@@ -21,7 +21,6 @@ const { resolveApiError } = useApiErrorMessage()
|
|
|
21
21
|
const { formatMinorUnits } = useMoneyFormat()
|
|
22
22
|
const { payWithDefaultCard } = usePayInvoice()
|
|
23
23
|
const billingStatus = useBillingStatus()
|
|
24
|
-
const tenantPlan = useTenantPlan()
|
|
25
24
|
|
|
26
25
|
const choice = ref<PaymentChoice>('default_card')
|
|
27
26
|
const isPaying = ref(false)
|
|
@@ -66,7 +65,8 @@ async function payWithCard(): Promise<void> {
|
|
|
66
65
|
color: 'success',
|
|
67
66
|
icon: 'i-ph-check-circle',
|
|
68
67
|
})
|
|
69
|
-
|
|
68
|
+
// The invoice shows its new state before the panel reports it paid.
|
|
69
|
+
await refreshPageBlocks()
|
|
70
70
|
emit('paid')
|
|
71
71
|
} catch (error) {
|
|
72
72
|
failure.value = resolveApiError(error, `${KEY_PREFIX}.error`)
|
|
@@ -83,10 +83,6 @@ function confirm(): void {
|
|
|
83
83
|
}
|
|
84
84
|
void payWithCard()
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
onMounted(() => {
|
|
88
|
-
void billingStatus.load()
|
|
89
|
-
})
|
|
90
86
|
</script>
|
|
91
87
|
|
|
92
88
|
<template>
|
|
@@ -164,7 +160,7 @@ onMounted(() => {
|
|
|
164
160
|
</template>
|
|
165
161
|
|
|
166
162
|
<UAlert
|
|
167
|
-
v-else-if="billingStatus.
|
|
163
|
+
v-else-if="billingStatus.status.value === 'error'"
|
|
168
164
|
color="error"
|
|
169
165
|
variant="subtle"
|
|
170
166
|
icon="i-ph-warning-circle"
|
|
@@ -27,11 +27,11 @@ const KEY_PREFIX = 'saas.tenant_billing.plan_change.review'
|
|
|
27
27
|
const { t, locale } = useI18n()
|
|
28
28
|
const toast = useToast()
|
|
29
29
|
const { resolveApiError } = useApiErrorMessage()
|
|
30
|
-
const { previewChange, changePlan } =
|
|
30
|
+
const { previewChange, changePlan } = useTenantPlanChanges()
|
|
31
31
|
const { offerFor: offerPendingCheckout } = usePendingCheckout()
|
|
32
32
|
const { formatMinorUnits, formatMajorUnits } = useMoneyFormat()
|
|
33
33
|
const { formatFeatureValue } = usePlanFeatureFormat()
|
|
34
|
-
const { data: billingStatus
|
|
34
|
+
const { data: billingStatus } = useBillingStatus()
|
|
35
35
|
const planIntervalLabel = usePlanIntervalLabel('saas.workspace.plan.interval')
|
|
36
36
|
|
|
37
37
|
const preview = ref<PlanChangePreview | null>(null)
|
|
@@ -215,10 +215,7 @@ async function confirm(): Promise<void> {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
onMounted(() =>
|
|
219
|
-
void loadBillingStatus()
|
|
220
|
-
void loadPreview()
|
|
221
|
-
})
|
|
218
|
+
onMounted(() => void loadPreview())
|
|
222
219
|
</script>
|
|
223
220
|
|
|
224
221
|
<template>
|
|
@@ -32,10 +32,13 @@ const badge = computed(() =>
|
|
|
32
32
|
: t('saas.public.card.required'),
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
+
// Zero turns the per-card rule off: the card then backs no count to explain.
|
|
35
36
|
const reason = computed(() =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
props.maxFreeWorkspacesPerCard
|
|
38
|
+
? t('saas.public.card.reason', {
|
|
39
|
+
count: String(props.maxFreeWorkspacesPerCard),
|
|
40
|
+
})
|
|
41
|
+
: t('saas.public.card.reason_secured'),
|
|
39
42
|
)
|
|
40
43
|
</script>
|
|
41
44
|
|
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
} from './types'
|
|
7
7
|
|
|
8
8
|
export const SEGMENT_FIELDS_URL = '/api/saas/segments/fields'
|
|
9
|
-
const CATALOG_STATE_KEY = 'saas-segment-fields'
|
|
10
9
|
|
|
11
10
|
const EMPTY_CATALOG: SegmentFieldsCatalog = {
|
|
12
11
|
fields: [],
|
|
@@ -17,9 +16,8 @@ const EMPTY_CATALOG: SegmentFieldsCatalog = {
|
|
|
17
16
|
export interface SegmentCatalog {
|
|
18
17
|
catalog: ComputedRef<SegmentFieldsCatalog>
|
|
19
18
|
isLoading: ComputedRef<boolean>
|
|
20
|
-
error: Ref<
|
|
21
|
-
|
|
22
|
-
refresh: () => Promise<unknown>
|
|
19
|
+
error: Ref<unknown>
|
|
20
|
+
refresh: () => Promise<void>
|
|
23
21
|
fieldsOf: (scope: SegmentScope) => SegmentFieldDefinition[]
|
|
24
22
|
findField: (
|
|
25
23
|
scope: SegmentScope,
|
|
@@ -34,11 +32,7 @@ export interface SegmentCatalog {
|
|
|
34
32
|
export function useSegmentCatalog(
|
|
35
33
|
url: string = SEGMENT_FIELDS_URL,
|
|
36
34
|
): SegmentCatalog {
|
|
37
|
-
const
|
|
38
|
-
const request = useSharedRequest<SegmentFieldsCatalog>(
|
|
39
|
-
`${CATALOG_STATE_KEY}:${url}`,
|
|
40
|
-
() => $authFetch<SegmentFieldsCatalog>(url),
|
|
41
|
-
)
|
|
35
|
+
const request = useApiData<SegmentFieldsCatalog>(url)
|
|
42
36
|
const catalog = computed(() => request.data.value ?? EMPTY_CATALOG)
|
|
43
37
|
|
|
44
38
|
function fieldsOf(scope: SegmentScope): SegmentFieldDefinition[] {
|
|
@@ -47,10 +41,11 @@ export function useSegmentCatalog(
|
|
|
47
41
|
|
|
48
42
|
return {
|
|
49
43
|
catalog,
|
|
50
|
-
isLoading: computed(
|
|
44
|
+
isLoading: computed(
|
|
45
|
+
() => !request.data.value && request.status.value !== 'error',
|
|
46
|
+
),
|
|
51
47
|
error: request.error,
|
|
52
|
-
|
|
53
|
-
refresh: request.refresh,
|
|
48
|
+
refresh: () => request.refresh(),
|
|
54
49
|
fieldsOf,
|
|
55
50
|
findField: (scope, fieldId) =>
|
|
56
51
|
fieldsOf(scope).find((field) => field.id === fieldId),
|
|
@@ -6,8 +6,7 @@ import { computed, type ComputedRef } from 'vue'
|
|
|
6
6
|
* Empty until the list is loaded.
|
|
7
7
|
*/
|
|
8
8
|
export function useWorkspaceName(): ComputedRef<string> {
|
|
9
|
-
const { workspaces
|
|
10
|
-
if (!isLoaded.value) void refresh().catch(() => undefined)
|
|
9
|
+
const { workspaces } = useMyWorkspaces()
|
|
11
10
|
return computed(
|
|
12
11
|
() => workspaces.value.find((workspace) => workspace.isCurrent)?.name ?? '',
|
|
13
12
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, type ComputedRef } from 'vue'
|
|
2
|
-
import type {
|
|
2
|
+
import type { DmsAsyncData } from '#dms/frontend-module'
|
|
3
3
|
|
|
4
4
|
/** A workspace of the user, with their place in it. */
|
|
5
5
|
export interface UserWorkspace {
|
|
@@ -47,30 +47,28 @@ export interface UserDetail {
|
|
|
47
47
|
security: UserSecurity
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export interface UserDetailRequest extends
|
|
50
|
+
export interface UserDetailRequest extends DmsAsyncData<UserDetail> {
|
|
51
51
|
userId: ComputedRef<string>
|
|
52
52
|
isLoading: ComputedRef<boolean>
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const STATE_KEY = 'saas-user-detail'
|
|
56
|
-
|
|
57
55
|
/**
|
|
58
56
|
* The user a platform admin's user page shows, fetched once for the header
|
|
59
|
-
* and the platform role card.
|
|
57
|
+
* and the platform role card, and again when the page moves to another user.
|
|
60
58
|
*/
|
|
61
59
|
export function useUserDetail(
|
|
62
60
|
routeParams: () => Record<string, string> | undefined,
|
|
63
61
|
): UserDetailRequest {
|
|
64
|
-
const { $authFetch } = useAuthFetch()
|
|
65
62
|
const userId = computed(() => routeParams()?.id ?? '')
|
|
66
|
-
const request =
|
|
67
|
-
|
|
68
|
-
() => $authFetch<UserDetail>(`/api/saas/users/${userId.value}`),
|
|
63
|
+
const request = useApiData<UserDetail>(() =>
|
|
64
|
+
userId.value ? `/api/saas/users/${userId.value}` : null,
|
|
69
65
|
)
|
|
70
66
|
return {
|
|
71
67
|
...request,
|
|
72
68
|
userId,
|
|
73
|
-
isLoading: computed(
|
|
69
|
+
isLoading: computed(
|
|
70
|
+
() => !request.data.value && request.status.value !== 'error',
|
|
71
|
+
),
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
|
|
@@ -84,12 +84,14 @@ const submitLabel = computed(() => {
|
|
|
84
84
|
: t(`${D}.submit`)
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
+
const impactRead = useOnDemandRead<ComplimentaryImpact>(
|
|
88
|
+
() => `/api/saas/workspaces/${props.tenantId}/complimentary-impact`,
|
|
89
|
+
)
|
|
90
|
+
|
|
87
91
|
async function load(): Promise<void> {
|
|
88
92
|
loadError.value = null
|
|
89
93
|
try {
|
|
90
|
-
impact.value = await
|
|
91
|
-
`/api/saas/workspaces/${props.tenantId}/complimentary-impact`,
|
|
92
|
-
)
|
|
94
|
+
impact.value = await impactRead.read()
|
|
93
95
|
planId.value = impact.value.currentPlanId ?? impact.value.plans[0]?.id
|
|
94
96
|
freeUntil.value = impact.value.freeUntil?.slice(0, 10) ?? ''
|
|
95
97
|
} catch (error) {
|
|
@@ -73,12 +73,14 @@ const outcome = computed(() => {
|
|
|
73
73
|
return `${credit} ${t(`${D}.outcome_invoice`, { date, amount: dropsTo })}`
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
const optionsRead = useOnDemandRead<OperatorOptions>(
|
|
77
|
+
() => `/api/saas/workspaces/${props.tenantId}/operator-options`,
|
|
78
|
+
)
|
|
79
|
+
|
|
76
80
|
async function load(): Promise<void> {
|
|
77
81
|
loadError.value = null
|
|
78
82
|
try {
|
|
79
|
-
options.value = await
|
|
80
|
-
`/api/saas/workspaces/${props.tenantId}/operator-options`,
|
|
81
|
-
)
|
|
83
|
+
options.value = await optionsRead.read()
|
|
82
84
|
} catch (error) {
|
|
83
85
|
loadError.value = resolveApiError(error, `${D}.load_error`)
|
|
84
86
|
}
|
|
@@ -64,28 +64,35 @@ const submitLabel = computed(() => {
|
|
|
64
64
|
: t(`${D}.submit_next_invoice`, { date: day(figures.billingDate) })
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
+
const optionsRead = useOnDemandRead<OperatorOptions>(
|
|
68
|
+
() => `/api/saas/workspaces/${props.tenantId}/operator-options`,
|
|
69
|
+
)
|
|
70
|
+
|
|
67
71
|
async function load(): Promise<void> {
|
|
68
72
|
loadError.value = null
|
|
69
73
|
try {
|
|
70
|
-
options.value = await
|
|
71
|
-
`/api/saas/workspaces/${props.tenantId}/operator-options`,
|
|
72
|
-
)
|
|
74
|
+
options.value = await optionsRead.read()
|
|
73
75
|
planId.value = plans.value[0]?.id
|
|
74
76
|
} catch (error) {
|
|
75
77
|
loadError.value = resolveApiError(error, `${D}.load_error`)
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
const previewRead = useOnDemandRead<UpgradePreview>(
|
|
82
|
+
() =>
|
|
83
|
+
planId.value
|
|
84
|
+
? `/api/saas/workspaces/${props.tenantId}/upgrade-preview`
|
|
85
|
+
: null,
|
|
86
|
+
{ query: () => ({ planId: planId.value }) },
|
|
87
|
+
)
|
|
88
|
+
|
|
79
89
|
async function loadPreview(): Promise<void> {
|
|
80
90
|
if (!planId.value) return
|
|
81
91
|
isPreviewing.value = true
|
|
82
92
|
previewError.value = null
|
|
83
93
|
preview.value = null
|
|
84
94
|
try {
|
|
85
|
-
preview.value = await
|
|
86
|
-
`/api/saas/workspaces/${props.tenantId}/upgrade-preview`,
|
|
87
|
-
{ query: { planId: planId.value } },
|
|
88
|
-
)
|
|
95
|
+
preview.value = await previewRead.read()
|
|
89
96
|
} catch (error) {
|
|
90
97
|
previewError.value = resolveApiError(error, `${D}.preview_error`)
|
|
91
98
|
} finally {
|
|
@@ -20,10 +20,13 @@ export function useWorkspaceActions(tenantId: string) {
|
|
|
20
20
|
const { $authFetch } = useAuthFetch()
|
|
21
21
|
const { t, locale } = useI18n()
|
|
22
22
|
const { confirm } = useConfirm()
|
|
23
|
-
const { confirmFrom } =
|
|
23
|
+
const { confirmFrom } = useConfirmFrom()
|
|
24
24
|
const toast = useToast()
|
|
25
25
|
const { resolveApiError } = useApiErrorMessage()
|
|
26
26
|
const base = `/api/saas/workspaces/${tenantId}`
|
|
27
|
+
const impactRead = useOnDemandRead<SuspensionImpact>(
|
|
28
|
+
() => `${base}/suspension-impact`,
|
|
29
|
+
)
|
|
27
30
|
|
|
28
31
|
function day(value: string): string {
|
|
29
32
|
return formatDate(value, locale.value, { dateStyle: 'medium' }) ?? value
|
|
@@ -53,9 +56,11 @@ export function useWorkspaceActions(tenantId: string) {
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
function confirmJoin(): Promise<boolean> {
|
|
56
|
-
return confirmFrom(`${base}/join-confirmation`,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
return confirmFrom(`${base}/join-confirmation`, {
|
|
60
|
+
onConfirm: async () => {
|
|
61
|
+
await $authFetch(`${base}/join`, { method: 'POST' })
|
|
62
|
+
},
|
|
63
|
+
})
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
function suspensionImpact(impact: SuspensionImpact): ImpactEntry[] {
|
|
@@ -98,9 +103,7 @@ export function useWorkspaceActions(tenantId: string) {
|
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
async function confirmSuspend(): Promise<boolean> {
|
|
101
|
-
const impact = await
|
|
102
|
-
`${base}/suspension-impact`,
|
|
103
|
-
)
|
|
106
|
+
const impact = await impactRead.read()
|
|
104
107
|
const operationId = crypto.randomUUID()
|
|
105
108
|
return confirm({
|
|
106
109
|
title: t(`${D}.suspend.title`, { name: impact.workspaceName }),
|
|
@@ -144,9 +147,7 @@ export function useWorkspaceActions(tenantId: string) {
|
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
async function confirmReactivate(): Promise<boolean> {
|
|
147
|
-
const impact = await
|
|
148
|
-
`${base}/suspension-impact`,
|
|
149
|
-
)
|
|
150
|
+
const impact = await impactRead.read()
|
|
150
151
|
const operationId = crypto.randomUUID()
|
|
151
152
|
return confirm({
|
|
152
153
|
title: t(`${D}.reactivate.title`, { name: impact.workspaceName }),
|
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, type ComputedRef, type Ref } from 'vue'
|
|
2
2
|
import type { WorkspaceOverview } from './types'
|
|
3
3
|
|
|
4
4
|
/** The workspace an operator looks at, refreshed after each action on it. */
|
|
5
5
|
export interface WorkspaceOverviewState {
|
|
6
6
|
overview: Ref<WorkspaceOverview | null>
|
|
7
|
-
isLoading:
|
|
8
|
-
hasError:
|
|
7
|
+
isLoading: ComputedRef<boolean>
|
|
8
|
+
hasError: ComputedRef<boolean>
|
|
9
9
|
load: () => Promise<void>
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Reads the header of a workspace's detail page, again each time the page
|
|
14
|
-
* refreshes its blocks after an operator action
|
|
14
|
+
* refreshes its blocks after an operator action (as every `useApiData` read
|
|
15
|
+
* of the page does). The header, the operator card and the suspend button
|
|
16
|
+
* share one read.
|
|
15
17
|
*/
|
|
16
18
|
export function useWorkspaceOverview(tenantId: string): WorkspaceOverviewState {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
`/api/saas/workspaces/${tenantId}/overview`,
|
|
28
|
-
)
|
|
29
|
-
hasError.value = false
|
|
30
|
-
} catch {
|
|
31
|
-
hasError.value = true
|
|
32
|
-
} finally {
|
|
33
|
-
isLoading.value = false
|
|
34
|
-
}
|
|
19
|
+
const { data, status, refresh } = useApiData<WorkspaceOverview>(
|
|
20
|
+
tenantId ? `/api/saas/workspaces/${tenantId}/overview` : null,
|
|
21
|
+
)
|
|
22
|
+
return {
|
|
23
|
+
overview: data,
|
|
24
|
+
isLoading: computed(
|
|
25
|
+
() => status.value === 'pending' || status.value === 'idle',
|
|
26
|
+
),
|
|
27
|
+
hasError: computed(() => status.value === 'error'),
|
|
28
|
+
load: () => refresh(),
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
let stopRefresh: (() => void) | undefined
|
|
38
|
-
onMounted(() => {
|
|
39
|
-
void load()
|
|
40
|
-
stopRefresh = onPageBlocksRefresh(() => void load())
|
|
41
|
-
})
|
|
42
|
-
onBeforeUnmount(() => stopRefresh?.())
|
|
43
|
-
return { overview, isLoading, hasError, load }
|
|
44
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
import type { ButtonProps } from '@nuxt/ui'
|
|
4
4
|
|
|
5
5
|
const props = withDefaults(
|
|
@@ -10,6 +10,8 @@ const props = withDefaults(
|
|
|
10
10
|
variant?: ButtonProps['variant']
|
|
11
11
|
size?: ButtonProps['size']
|
|
12
12
|
icon?: string
|
|
13
|
+
/** Read the billing status in the browser, as a layout strip does. */
|
|
14
|
+
isDeferred?: boolean
|
|
13
15
|
}>(),
|
|
14
16
|
{
|
|
15
17
|
labelKey: 'saas.tenant_billing.portal.open',
|
|
@@ -17,6 +19,7 @@ const props = withDefaults(
|
|
|
17
19
|
variant: 'subtle',
|
|
18
20
|
size: 'md',
|
|
19
21
|
icon: 'i-ph-arrow-square-out',
|
|
22
|
+
isDeferred: false,
|
|
20
23
|
},
|
|
21
24
|
)
|
|
22
25
|
|
|
@@ -28,7 +31,8 @@ interface PortalSession {
|
|
|
28
31
|
|
|
29
32
|
const { $authFetch } = useAuthFetch()
|
|
30
33
|
const { resolveApiError } = useApiErrorMessage()
|
|
31
|
-
const {
|
|
34
|
+
const billingStatus = useBillingStatus({ server: !props.isDeferred }).data
|
|
35
|
+
const data = props.isDeferred ? useMountedData(billingStatus) : billingStatus
|
|
32
36
|
const isLoading = ref(false)
|
|
33
37
|
const failure = ref<string | null>(null)
|
|
34
38
|
|
|
@@ -52,8 +56,6 @@ async function openCustomerPortal(): Promise<void> {
|
|
|
52
56
|
isLoading.value = false
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
onMounted(load)
|
|
57
59
|
</script>
|
|
58
60
|
|
|
59
61
|
<template>
|