@antelopejs/dms-saas 0.5.1 → 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 +6 -0
- package/dist/billing-state/recovery.js +2 -2
- package/dist/billing-state/recovery.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/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 +6 -11
- 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 +61 -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 +18 -21
- 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/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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { computed, type ComputedRef } from 'vue'
|
|
2
|
+
|
|
1
3
|
/** One workspace of the switcher, as `GET /api/saas/workspaces/mine` answers it. */
|
|
2
4
|
export interface MyWorkspace {
|
|
3
5
|
_id: string
|
|
@@ -15,42 +17,37 @@ export interface MyWorkspace {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
const WORKSPACES_ENDPOINT = '/api/saas/workspaces/mine'
|
|
18
|
-
const STATE_KEY = 'saas-my-workspaces'
|
|
19
20
|
|
|
20
21
|
interface MyWorkspacesHandle {
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
/** Empty until the list is in, and for a visitor without a session. */
|
|
23
|
+
workspaces: ComputedRef<MyWorkspace[]>
|
|
24
|
+
isLoaded: ComputedRef<boolean>
|
|
25
|
+
/** The last read failed; the entries already on screen stay. */
|
|
26
|
+
hasFailed: ComputedRef<boolean>
|
|
23
27
|
refresh: () => Promise<void>
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
27
31
|
* Shared between the sidebar switcher and the screens that change what it
|
|
28
32
|
* displays (a rename, a deletion), so a change never waits for a page reload.
|
|
33
|
+
* Nothing is read without a session: the public layouts mount the switcher's
|
|
34
|
+
* readers too.
|
|
29
35
|
*/
|
|
30
36
|
export function useMyWorkspaces(): MyWorkspacesHandle {
|
|
31
|
-
const {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} catch (error) {
|
|
47
|
-
// Only the initial load may empty the list — a failed refresh keeps
|
|
48
|
-
// the entries already on screen rather than making the switcher
|
|
49
|
-
// disappear.
|
|
50
|
-
if (!isLoaded.value) workspaces.value = []
|
|
51
|
-
throw error
|
|
52
|
-
}
|
|
37
|
+
const { loggedIn } = useDmsUserSession()
|
|
38
|
+
const { data, status, refresh } = useApiData<MyWorkspace[]>(() =>
|
|
39
|
+
loggedIn.value ? WORKSPACES_ENDPOINT : null,
|
|
40
|
+
)
|
|
41
|
+
const workspaces = computed(() => data.value ?? [])
|
|
42
|
+
return {
|
|
43
|
+
workspaces,
|
|
44
|
+
isLoaded: computed(
|
|
45
|
+
() =>
|
|
46
|
+
!loggedIn.value ||
|
|
47
|
+
status.value === 'success' ||
|
|
48
|
+
workspaces.value.length > 0,
|
|
49
|
+
),
|
|
50
|
+
hasFailed: computed(() => status.value === 'error'),
|
|
51
|
+
refresh: () => refresh(),
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
return { workspaces, isLoaded, refresh }
|
|
56
53
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ApiReadOptions } from './useMountedData'
|
|
2
|
+
|
|
1
3
|
const NEXT_INVOICE_ENDPOINT = '/api/saas/tenant/upcoming-invoice'
|
|
2
|
-
const NEXT_INVOICE_STATE_KEY = 'saas-next-invoice'
|
|
3
4
|
|
|
4
5
|
/** The figures of Stripe's next-invoice preview that cards quote. */
|
|
5
6
|
export interface NextInvoiceSummary {
|
|
@@ -11,10 +12,10 @@ export interface NextInvoiceSummary {
|
|
|
11
12
|
/**
|
|
12
13
|
* Stripe's preview of the next invoice, shared by the cards quoting its total
|
|
13
14
|
* (plan card, trial strip); the "Next invoice" block reads the full rows.
|
|
15
|
+
* The trial strip reads it with `server: false` (see `useMountedData`).
|
|
14
16
|
*/
|
|
15
|
-
export function useNextInvoice(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
17
|
+
export function useNextInvoice(
|
|
18
|
+
options: ApiReadOptions = {},
|
|
19
|
+
): ApiDataResult<NextInvoiceSummary> {
|
|
20
|
+
return useApiData<NextInvoiceSummary>(NEXT_INVOICE_ENDPOINT, options)
|
|
20
21
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** A backend URL to read, or nothing to read while it is null or undefined. */
|
|
4
|
+
export type OnDemandUrl = () => string | null | undefined
|
|
5
|
+
|
|
6
|
+
/** Query parameters of an on-demand read, read again for each request. */
|
|
7
|
+
export type OnDemandQuery = MaybeRefOrGetter<Record<string, unknown> | undefined>
|
|
8
|
+
|
|
9
|
+
export interface OnDemandReadOptions {
|
|
10
|
+
query?: OnDemandQuery
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface OnDemandRead<T> {
|
|
14
|
+
/** The last answer to the current URL, null until one came. */
|
|
15
|
+
data: Readonly<Ref<T | null>>
|
|
16
|
+
pending: Readonly<Ref<boolean>>
|
|
17
|
+
/** Reads the URL now; rejects with the failure. */
|
|
18
|
+
read: () => Promise<T>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What makes a read wait for `read()`: never on a server, never on its own. */
|
|
22
|
+
const ON_DEMAND = {
|
|
23
|
+
immediate: false,
|
|
24
|
+
server: false,
|
|
25
|
+
watch: false,
|
|
26
|
+
refreshOnPageRefresh: false,
|
|
27
|
+
} as const
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A read a component makes when it needs it (a dialog or a drawer opening, a
|
|
31
|
+
* lookup, a preview), through `useApiData` as every read of the module: in
|
|
32
|
+
* the browser only, outside the page's refreshes, and afresh on each `read()`.
|
|
33
|
+
* The URL and the query may change between reads: each `read()` asks for the
|
|
34
|
+
* current ones.
|
|
35
|
+
*/
|
|
36
|
+
export function useOnDemandRead<T>(
|
|
37
|
+
url: OnDemandUrl,
|
|
38
|
+
options: OnDemandReadOptions = {},
|
|
39
|
+
): OnDemandRead<T> {
|
|
40
|
+
const request = useApiData<T>(url, { query: options.query, ...ON_DEMAND })
|
|
41
|
+
|
|
42
|
+
async function read(): Promise<T> {
|
|
43
|
+
await request.execute()
|
|
44
|
+
if (request.status.value === 'error') throw request.error.value
|
|
45
|
+
return request.data.value as T
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { data: request.data, pending: request.pending, read }
|
|
49
|
+
}
|
|
@@ -30,7 +30,8 @@ export function usePendingCheckout() {
|
|
|
30
30
|
)
|
|
31
31
|
const route = useDmsRoute()
|
|
32
32
|
const router = useDmsRouter()
|
|
33
|
-
const { loadPendingCheckout, cancelCheckout, changePlan } =
|
|
33
|
+
const { loadPendingCheckout, cancelCheckout, changePlan } =
|
|
34
|
+
useTenantPlanChanges()
|
|
34
35
|
|
|
35
36
|
/** Raises the prompt when `error` is a pending-checkout refusal. */
|
|
36
37
|
async function offerFor(error: unknown, planId: string): Promise<boolean> {
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { type PlanCatalog, PLANS_ENDPOINT } from '../build/plan-catalog'
|
|
2
2
|
|
|
3
|
-
const PLAN_CATALOG_STATE_KEY = 'saas-plan-catalog'
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* The plans, features and new-plan permissions of the catalogue, read once
|
|
7
5
|
* for every block of a page: the plan cards, the editor's access matrix and
|
|
8
|
-
* preview, the retire dialog. `
|
|
9
|
-
* `refresh` reads the catalogue as it stands now.
|
|
6
|
+
* preview, the retire dialog. `refresh` reads the catalogue as it stands now.
|
|
10
7
|
*/
|
|
11
|
-
export function usePlanCatalog():
|
|
12
|
-
|
|
13
|
-
return useSharedRequest(PLAN_CATALOG_STATE_KEY, () =>
|
|
14
|
-
$authFetch<PlanCatalog>(`${PLANS_ENDPOINT}/catalog`),
|
|
15
|
-
)
|
|
8
|
+
export function usePlanCatalog(): ApiDataResult<PlanCatalog> {
|
|
9
|
+
return useApiData<PlanCatalog>(`${PLANS_ENDPOINT}/catalog`)
|
|
16
10
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PublicPricing } from '../build/public/pricing'
|
|
2
|
+
|
|
3
|
+
const PRICING_ENDPOINT = '/api/saas/pricing'
|
|
4
|
+
const PRICING_KEY = 'saas:public-pricing'
|
|
5
|
+
const CONTENT_LANGUAGE_HEADER = 'x-content-language'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The plans on sale and the billing rules the pricing page shows, read with
|
|
9
|
+
* the page: a server render hands them over in the visitor's language. The
|
|
10
|
+
* key names that language, so a switch reads them again in the new one (the
|
|
11
|
+
* API localizes feature names and units). The language goes with each
|
|
12
|
+
* request: `$authFetch` keeps the one it was created in.
|
|
13
|
+
*/
|
|
14
|
+
export function usePublicPricing() {
|
|
15
|
+
const { locale } = useI18n()
|
|
16
|
+
return useApiData<PublicPricing>(
|
|
17
|
+
() => `${PRICING_KEY}:${locale.value}`,
|
|
18
|
+
({ $authFetch, signal }) =>
|
|
19
|
+
$authFetch<PublicPricing>(PRICING_ENDPOINT, {
|
|
20
|
+
signal,
|
|
21
|
+
headers: { [CONTENT_LANGUAGE_HEADER]: locale.value },
|
|
22
|
+
}),
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -463,6 +463,8 @@ export function useSaasRegistration(options: UseSaasRegistrationOptions = {}) {
|
|
|
463
463
|
async function mountPaymentElement(): Promise<void> {
|
|
464
464
|
const publishableKey = saasConfig?.stripePublishableKey
|
|
465
465
|
if (!publishableKey) return
|
|
466
|
+
// Not a `useApiData` read: each call creates a SetupIntent, whose client
|
|
467
|
+
// secret is the card form's alone, never cached nor shared.
|
|
466
468
|
const setup = await $authFetch<SetupIntentResponse>(SETUP_INTENT_ENDPOINT)
|
|
467
469
|
if (!setup.clientSecret) return
|
|
468
470
|
stripeHandle.value = useStripePaymentElement({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const SEAT_QUOTA_ENDPOINT = '/api/saas/tenant/seats'
|
|
2
|
-
const SEAT_QUOTA_STATE_KEY = 'saas-seat-quota'
|
|
3
2
|
|
|
4
3
|
export interface PlatformSupportMember {
|
|
5
4
|
userId: string
|
|
@@ -28,9 +27,6 @@ export interface SeatQuotaResponse {
|
|
|
28
27
|
platformSupport: PlatformSupportMember[]
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
export function useSeatQuota():
|
|
32
|
-
|
|
33
|
-
return useSharedRequest(SEAT_QUOTA_STATE_KEY, () =>
|
|
34
|
-
$authFetch<SeatQuotaResponse>(SEAT_QUOTA_ENDPOINT),
|
|
35
|
-
)
|
|
30
|
+
export function useSeatQuota(): ApiDataResult<SeatQuotaResponse> {
|
|
31
|
+
return useApiData<SeatQuotaResponse>(SEAT_QUOTA_ENDPOINT)
|
|
36
32
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { PlanInterval } from './usePlanIntervalLabel'
|
|
2
2
|
|
|
3
3
|
const TENANT_PLAN_ENDPOINT = '/api/saas/tenant/plan'
|
|
4
|
-
const TENANT_PLAN_STATE_KEY = 'saas-tenant-plan'
|
|
5
4
|
const TENANT_CHECKOUT_ENDPOINT = `${TENANT_PLAN_ENDPOINT}/checkout`
|
|
6
5
|
const TENANT_PREVIEW_ENDPOINT = `${TENANT_PLAN_ENDPOINT}/preview`
|
|
7
6
|
const TENANT_CANCELLATION_ENDPOINT = `${TENANT_PLAN_ENDPOINT}/cancellation`
|
|
@@ -188,11 +187,31 @@ function currentPageUrl(): string {
|
|
|
188
187
|
|
|
189
188
|
/** The payload resolves inheritance for every public plan and carries the
|
|
190
189
|
* features catalogue, so the plan card and the free-access banner share it. */
|
|
191
|
-
|
|
190
|
+
/** What a change's preview is asked for: the plan, and the country to tax. */
|
|
191
|
+
type PreviewQuery = {
|
|
192
|
+
planId: string
|
|
193
|
+
country?: string
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function useTenantPlan(): ApiDataResult<TenantPlanResponse> {
|
|
197
|
+
return useApiData<TenantPlanResponse>(TENANT_PLAN_ENDPOINT)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* What changes the workspace's plan, and the reads a dialog makes on a click
|
|
202
|
+
* (a change's preview, the checkout left pending). The plan itself is
|
|
203
|
+
* `useTenantPlan`'s: refresh it once a change went through.
|
|
204
|
+
*/
|
|
205
|
+
export function useTenantPlanChanges() {
|
|
192
206
|
const { $authFetch } = useAuthFetch()
|
|
193
207
|
const { authenticateUpgrade } = useUpgradeAuthentication()
|
|
194
|
-
const
|
|
195
|
-
|
|
208
|
+
const previewQuery = shallowRef<PreviewQuery | null>(null)
|
|
209
|
+
const previewRead = useOnDemandRead<PlanChangePreview>(
|
|
210
|
+
() => (previewQuery.value ? TENANT_PREVIEW_ENDPOINT : null),
|
|
211
|
+
{ query: () => previewQuery.value ?? undefined },
|
|
212
|
+
)
|
|
213
|
+
const checkoutRead = useOnDemandRead<PendingCheckoutResult>(
|
|
214
|
+
() => TENANT_CHECKOUT_ENDPOINT,
|
|
196
215
|
)
|
|
197
216
|
|
|
198
217
|
/**
|
|
@@ -223,9 +242,8 @@ export function useTenantPlan() {
|
|
|
223
242
|
planId: string,
|
|
224
243
|
country?: string | null,
|
|
225
244
|
): Promise<PlanChangePreview> {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
})
|
|
245
|
+
previewQuery.value = country ? { planId, country } : { planId }
|
|
246
|
+
return previewRead.read()
|
|
229
247
|
}
|
|
230
248
|
|
|
231
249
|
function cancelPendingChange(): Promise<ChangePlanResult> {
|
|
@@ -247,7 +265,7 @@ export function useTenantPlan() {
|
|
|
247
265
|
}
|
|
248
266
|
|
|
249
267
|
function loadPendingCheckout(): Promise<PendingCheckoutResult> {
|
|
250
|
-
return
|
|
268
|
+
return checkoutRead.read()
|
|
251
269
|
}
|
|
252
270
|
|
|
253
271
|
/** Without an operation id, gives up on whatever checkout is pending. */
|
|
@@ -259,7 +277,6 @@ export function useTenantPlan() {
|
|
|
259
277
|
}
|
|
260
278
|
|
|
261
279
|
return {
|
|
262
|
-
...shared,
|
|
263
280
|
changePlan,
|
|
264
281
|
previewChange,
|
|
265
282
|
cancelPendingChange,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const OVERVIEW_ENDPOINT = '/api/saas/workspaces/current/overview'
|
|
2
|
-
const OVERVIEW_STATE_KEY = 'saas-workspace-overview'
|
|
3
2
|
|
|
4
3
|
/** Seats as the members page counts them; `maxMembers` null when unlimited. */
|
|
5
4
|
export interface WorkspaceSeatsOverview {
|
|
@@ -50,9 +49,6 @@ export interface WorkspaceOverview {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/** What the General page's danger zone states about deleting the workspace. */
|
|
53
|
-
export function useWorkspaceOverview():
|
|
54
|
-
|
|
55
|
-
return useSharedRequest(OVERVIEW_STATE_KEY, () =>
|
|
56
|
-
$authFetch<WorkspaceOverview>(OVERVIEW_ENDPOINT),
|
|
57
|
-
)
|
|
52
|
+
export function useWorkspaceOverview(): ApiDataResult<WorkspaceOverview> {
|
|
53
|
+
return useApiData<WorkspaceOverview>(OVERVIEW_ENDPOINT)
|
|
58
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms-saas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@antelopejs/interface-data-api": ">=0.2.0 <1.0.0",
|
|
36
36
|
"@antelopejs/interface-database": ">=0.1.8 <1.0.0",
|
|
37
37
|
"@antelopejs/interface-database-decorators": ">=0.1.7 <1.0.0",
|
|
38
|
-
"@antelopejs/interface-dms": ">=0.
|
|
38
|
+
"@antelopejs/interface-dms": ">=0.7.0 <1.0.0",
|
|
39
39
|
"@antelopejs/interface-dms-saas": ">=0.4.0 <0.5.0",
|
|
40
40
|
"node-cron": "^4.2.1",
|
|
41
41
|
"stripe": "^22.6.2",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@antelopejs/core": "1.13.5",
|
|
46
|
-
"@antelopejs/dms": ">=0.
|
|
47
|
-
"@antelopejs/dms-frontend": ">=0.
|
|
46
|
+
"@antelopejs/dms": ">=0.9.0 <1.0.0",
|
|
47
|
+
"@antelopejs/dms-frontend": ">=0.6.0 <0.7.0",
|
|
48
48
|
"@antelopejs/mongodb": "1.4.2",
|
|
49
49
|
"@antelopejs/tooling-configs": ">=0.0.7 <1.0.0",
|
|
50
50
|
"@types/node": "^24.0.0",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Asks a confirmation the server words (what a DMS action's `confirm: { from }`
|
|
3
|
-
* fetches) for a button the DMS does not draw itself: the dialog's texts are
|
|
4
|
-
* worded with its params and `onConfirm` runs from inside it. Resolves whether
|
|
5
|
-
* the user confirmed; a dialog that cannot be fetched rejects.
|
|
6
|
-
*/
|
|
7
|
-
export function useServerConfirm() {
|
|
8
|
-
const { $authFetch } = useAuthFetch()
|
|
9
|
-
const { processI18n } = useTranslation()
|
|
10
|
-
const { confirm } = useConfirm()
|
|
11
|
-
|
|
12
|
-
function word(
|
|
13
|
-
text: string | undefined,
|
|
14
|
-
params: Record<string, unknown>,
|
|
15
|
-
): string | undefined {
|
|
16
|
-
return text ? processI18n(text, params) : undefined
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function confirmFrom(
|
|
20
|
-
url: string,
|
|
21
|
-
onConfirm: () => Promise<unknown>,
|
|
22
|
-
): Promise<boolean> {
|
|
23
|
-
const dialog = await $authFetch<ConfirmDialog>(url)
|
|
24
|
-
const params = dialog.params ?? {}
|
|
25
|
-
return confirm({
|
|
26
|
-
title: processI18n(dialog.title, params),
|
|
27
|
-
description: word(dialog.description, params),
|
|
28
|
-
icon: dialog.icon,
|
|
29
|
-
color: dialog.color,
|
|
30
|
-
confirmLabel: word(dialog.confirmLabel, params),
|
|
31
|
-
cancelLabel: word(dialog.cancelLabel, params),
|
|
32
|
-
blocked: dialog.blocked,
|
|
33
|
-
impact: dialog.impact?.map((entry) => ({
|
|
34
|
-
...entry,
|
|
35
|
-
label: processI18n(entry.label, params),
|
|
36
|
-
})),
|
|
37
|
-
onConfirm: async () => {
|
|
38
|
-
await onConfirm()
|
|
39
|
-
},
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return { confirmFrom }
|
|
44
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Ref } from "vue";
|
|
2
|
-
|
|
3
|
-
export interface SharedRequest<T> {
|
|
4
|
-
data: Ref<T | null>;
|
|
5
|
-
error: Ref<boolean>;
|
|
6
|
-
load: () => Promise<T | null>;
|
|
7
|
-
refresh: () => Promise<T | null>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* One payload, many blocks. Page-level surfaces are assembled from independent
|
|
12
|
-
* components that mount together, so a plain per-component fetch multiplies
|
|
13
|
-
* the same request. This keeps the response, the failure flag and the
|
|
14
|
-
* in-flight promise in shared state: `load` serves whatever is already there,
|
|
15
|
-
* `refresh` forces a re-fetch. Failures never reject — they set `error` so
|
|
16
|
-
* every consumer can render the shared failure state and offer a retry
|
|
17
|
-
* instead of silently disappearing.
|
|
18
|
-
*/
|
|
19
|
-
export function useSharedRequest<T>(
|
|
20
|
-
key: string,
|
|
21
|
-
fetcher: () => Promise<T>,
|
|
22
|
-
): SharedRequest<T> {
|
|
23
|
-
const data = useDmsState<T | null>(key, () => null);
|
|
24
|
-
const error = useDmsState(`${key}-error`, () => false);
|
|
25
|
-
const inFlight = useDmsState<Promise<T | null> | null>(
|
|
26
|
-
`${key}-request`,
|
|
27
|
-
() => null,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
function refresh(): Promise<T | null> {
|
|
31
|
-
if (inFlight.value) return inFlight.value;
|
|
32
|
-
const request = fetcher()
|
|
33
|
-
.then((response) => {
|
|
34
|
-
data.value = response;
|
|
35
|
-
error.value = false;
|
|
36
|
-
return response as T | null;
|
|
37
|
-
})
|
|
38
|
-
.catch(() => {
|
|
39
|
-
error.value = true;
|
|
40
|
-
return null;
|
|
41
|
-
})
|
|
42
|
-
.finally(() => {
|
|
43
|
-
inFlight.value = null;
|
|
44
|
-
});
|
|
45
|
-
inFlight.value = request;
|
|
46
|
-
return request;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function load(): Promise<T | null> {
|
|
50
|
-
return data.value ? Promise.resolve(data.value) : refresh();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return { data, error, load, refresh };
|
|
54
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export interface WorkspaceAccess {
|
|
2
|
-
blocked: boolean;
|
|
3
|
-
status?: string;
|
|
4
|
-
isTenantOwner: boolean;
|
|
5
|
-
/** Owner-only, and only while blocked: what the suspended screen offers to
|
|
6
|
-
* settle. Members and unblocked workspaces get null. */
|
|
7
|
-
unpaidInvoice: UnpaidInvoiceRef | null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface CachedWorkspaceAccess {
|
|
11
|
-
tenantId: string;
|
|
12
|
-
access: WorkspaceAccess;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Per-session cache of the current workspace's subscription access, shared
|
|
17
|
-
* between its readers (the refund card) and the suspended screen (invalidator
|
|
18
|
-
* once the workspace unblocks).
|
|
19
|
-
*/
|
|
20
|
-
export function useWorkspaceAccessCache() {
|
|
21
|
-
return useDmsState<CachedWorkspaceAccess | null>(
|
|
22
|
-
"saas-workspace-access",
|
|
23
|
-
() => null,
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const ACCESS_ENDPOINT = "/api/saas/billing/access";
|
|
28
|
-
const FALLBACK_TENANT_ID = "default";
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The active workspace's access, served from the cache while it still belongs
|
|
32
|
-
* to the active tenant and fetched otherwise.
|
|
33
|
-
*
|
|
34
|
-
* @returns The access, or null on a transport error — callers fail open, the
|
|
35
|
-
* backend gate still denies every tenant surface
|
|
36
|
-
*/
|
|
37
|
-
export async function loadWorkspaceAccess(): Promise<WorkspaceAccess | null> {
|
|
38
|
-
const { session } = useUserSession();
|
|
39
|
-
const tenantId =
|
|
40
|
-
(session.value as { activeTenantId?: string } | null)?.activeTenantId ??
|
|
41
|
-
FALLBACK_TENANT_ID;
|
|
42
|
-
const cached = useWorkspaceAccessCache();
|
|
43
|
-
if (cached.value?.tenantId === tenantId) return cached.value.access;
|
|
44
|
-
const { $authFetch } = useAuthFetch();
|
|
45
|
-
try {
|
|
46
|
-
const access = await $authFetch<WorkspaceAccess>(ACCESS_ENDPOINT);
|
|
47
|
-
cached.value = { tenantId, access };
|
|
48
|
-
return access;
|
|
49
|
-
} catch {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|