@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.
Files changed (100) hide show
  1. package/README.md +12 -1
  2. package/dist/billing-state/recovery.js +2 -2
  3. package/dist/billing-state/recovery.js.map +1 -1
  4. package/dist/pages/platform/credit-notes.js +1 -1
  5. package/dist/pages/platform/credit-notes.js.map +1 -1
  6. package/dist/pages/platform/features.js +3 -1
  7. package/dist/pages/platform/features.js.map +1 -1
  8. package/dist/pages/platform/invoices.js +2 -2
  9. package/dist/pages/platform/invoices.js.map +1 -1
  10. package/dist/pages/platform/plans/index.js +15 -9
  11. package/dist/pages/platform/plans/index.js.map +1 -1
  12. package/dist/pages/platform/plans/migrations.js +2 -2
  13. package/dist/pages/platform/plans/migrations.js.map +1 -1
  14. package/dist/pages/platform/segments/index.js +1 -1
  15. package/dist/pages/platform/segments/index.js.map +1 -1
  16. package/dist/pages/platform/users/detail.js +11 -3
  17. package/dist/pages/platform/users/detail.js.map +1 -1
  18. package/dist/pages/platform/users/index.js +1 -1
  19. package/dist/pages/platform/users/index.js.map +1 -1
  20. package/dist/pages/platform/workspaces/detail.js +1 -1
  21. package/dist/pages/platform/workspaces/detail.js.map +1 -1
  22. package/dist/pages/platform/workspaces/index.js +2 -2
  23. package/dist/pages/platform/workspaces/index.js.map +1 -1
  24. package/dist/pages/tenant/billing.js +2 -2
  25. package/dist/pages/tenant/billing.js.map +1 -1
  26. package/dist/stripe/client.d.ts +3 -0
  27. package/dist/stripe/client.js +16 -1
  28. package/dist/stripe/client.js.map +1 -1
  29. package/dist/stripe/customer-billing.js +1 -1
  30. package/dist/stripe/customer-billing.js.map +1 -1
  31. package/dist/stripe/subscription-cancellation.js +1 -1
  32. package/dist/stripe/subscription-cancellation.js.map +1 -1
  33. package/dist/stripe/upcoming-invoice.js +3 -3
  34. package/dist/stripe/upcoming-invoice.js.map +1 -1
  35. package/dist/types/config.d.ts +2 -0
  36. package/dist/types/config.js.map +1 -1
  37. package/frontend-vue/app/build/PayInvoicePanel.vue +4 -8
  38. package/frontend-vue/app/build/PlanChangeReview.vue +3 -6
  39. package/frontend-vue/app/build/public/RegistrationCardField.vue +6 -3
  40. package/frontend-vue/app/build/segments/useSegmentCatalog.ts +7 -12
  41. package/frontend-vue/app/build/useWorkspaceName.ts +1 -2
  42. package/frontend-vue/app/build/users/useUserDetail.ts +8 -10
  43. package/frontend-vue/app/build/workspace-detail/ComplimentaryDialog.vue +5 -3
  44. package/frontend-vue/app/build/workspace-detail/CreditDialog.vue +5 -3
  45. package/frontend-vue/app/build/workspace-detail/UpgradeDialog.vue +14 -7
  46. package/frontend-vue/app/build/workspace-detail/useWorkspaceActions.ts +11 -10
  47. package/frontend-vue/app/build/workspace-detail/useWorkspaceOverview.ts +16 -30
  48. package/frontend-vue/app/components/CustomerPortalButton.vue +6 -4
  49. package/frontend-vue/app/components/DataExport.vue +34 -54
  50. package/frontend-vue/app/components/DataExportHistory.vue +2 -7
  51. package/frontend-vue/app/components/IssueCreditNoteModal.vue +5 -4
  52. package/frontend-vue/app/components/MigrationStripeCheck.vue +11 -8
  53. package/frontend-vue/app/components/PastDueAlert.vue +8 -6
  54. package/frontend-vue/app/components/PastDueBanner.vue +4 -4
  55. package/frontend-vue/app/components/PaymentMethodCard.vue +7 -12
  56. package/frontend-vue/app/components/PlanAccessEditor.vue +31 -30
  57. package/frontend-vue/app/components/PlanCard.vue +2 -3
  58. package/frontend-vue/app/components/PlanEditorPreview.vue +27 -36
  59. package/frontend-vue/app/components/PlanUpgradeModal.vue +1 -1
  60. package/frontend-vue/app/components/PlatformNotes.vue +27 -28
  61. package/frontend-vue/app/components/Pricing.vue +16 -23
  62. package/frontend-vue/app/components/RefundButton.vue +62 -46
  63. package/frontend-vue/app/components/RetirePlanModal.vue +13 -7
  64. package/frontend-vue/app/components/SeatQuotaBanner.vue +9 -10
  65. package/frontend-vue/app/components/SegmentConditionsBuilder.vue +0 -1
  66. package/frontend-vue/app/components/SegmentRulesText.vue +1 -3
  67. package/frontend-vue/app/components/TenantBillingForm.vue +14 -19
  68. package/frontend-vue/app/components/TenantPlanCard.vue +19 -22
  69. package/frontend-vue/app/components/TrialEndingBanner.vue +5 -10
  70. package/frontend-vue/app/components/UserPlatformRoleCard.vue +8 -9
  71. package/frontend-vue/app/components/UserSegmentMatches.vue +8 -16
  72. package/frontend-vue/app/components/UserSummaryCard.vue +2 -4
  73. package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +13 -5
  74. package/frontend-vue/app/components/WorkspaceCreateModal.vue +5 -1
  75. package/frontend-vue/app/components/WorkspaceDangerZone.vue +8 -7
  76. package/frontend-vue/app/components/WorkspaceDetailHeader.vue +14 -4
  77. package/frontend-vue/app/components/WorkspaceSuspended.vue +27 -32
  78. package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +5 -16
  79. package/frontend-vue/app/composables/useBillingIdentity.ts +9 -5
  80. package/frontend-vue/app/composables/useBillingStatus.ts +8 -7
  81. package/frontend-vue/app/composables/useCurrentWorkspace.ts +6 -8
  82. package/frontend-vue/app/composables/useExportHistory.ts +67 -78
  83. package/frontend-vue/app/composables/useMountedData.ts +27 -0
  84. package/frontend-vue/app/composables/useMyWorkspaces.ts +24 -27
  85. package/frontend-vue/app/composables/useNextInvoice.ts +7 -6
  86. package/frontend-vue/app/composables/useOnDemandRead.ts +49 -0
  87. package/frontend-vue/app/composables/usePendingCheckout.ts +2 -1
  88. package/frontend-vue/app/composables/usePlanCatalog.ts +3 -9
  89. package/frontend-vue/app/composables/usePublicPricing.ts +24 -0
  90. package/frontend-vue/app/composables/useSaasRegistration.ts +2 -0
  91. package/frontend-vue/app/composables/useSeatQuota.ts +2 -6
  92. package/frontend-vue/app/composables/useTenantPlan.ts +26 -9
  93. package/frontend-vue/app/composables/useWorkspaceOverview.ts +2 -6
  94. package/frontend-vue/i18n/locales/saas-public-en-GB.json +1 -0
  95. package/frontend-vue/i18n/locales/saas-public-fr-FR.json +1 -0
  96. package/frontend-vue/package.json +1 -1
  97. package/package.json +4 -4
  98. package/frontend-vue/app/composables/useServerConfirm.ts +0 -44
  99. package/frontend-vue/app/composables/useSharedRequest.ts +0 -54
  100. package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +0 -52
@@ -0,0 +1,27 @@
1
+ import {
2
+ computed,
3
+ onMounted,
4
+ shallowRef,
5
+ type ComputedRef,
6
+ type Ref,
7
+ } from 'vue'
8
+
9
+ /** Where a read runs: `server: false` leaves it to the browser. */
10
+ export interface ApiReadOptions {
11
+ server?: boolean
12
+ }
13
+
14
+ /**
15
+ * Data a layout strip shows, kept null until the strip is mounted. A strip
16
+ * reads Stripe-backed data with `server: false`, so a slow Stripe never holds
17
+ * the server render of the whole page; the server then renders the strip
18
+ * without it, and the browser's first render must match that HTML, even when
19
+ * the page read the same request on the server and handed its data over.
20
+ */
21
+ export function useMountedData<T>(data: Ref<T | null>): ComputedRef<T | null> {
22
+ const isMounted = shallowRef(false)
23
+ onMounted(() => {
24
+ isMounted.value = true
25
+ })
26
+ return computed(() => (isMounted.value ? data.value : null))
27
+ }
@@ -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
- workspaces: Ref<MyWorkspace[]>
22
- isLoaded: Ref<boolean>
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 { $authFetch } = useAuthFetch()
32
- const { loggedIn } = useUserSession()
33
- const workspaces = useDmsState<MyWorkspace[]>(STATE_KEY, () => [])
34
- const isLoaded = useDmsState<boolean>(`${STATE_KEY}-loaded`, () => false)
35
-
36
- async function refresh(): Promise<void> {
37
- if (!loggedIn.value) {
38
- workspaces.value = []
39
- isLoaded.value = true
40
- return
41
- }
42
-
43
- try {
44
- workspaces.value = await $authFetch<MyWorkspace[]>(WORKSPACES_ENDPOINT)
45
- isLoaded.value = true
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(): SharedRequest<NextInvoiceSummary> {
16
- const { $authFetch } = useAuthFetch()
17
- return useSharedRequest(NEXT_INVOICE_STATE_KEY, () =>
18
- $authFetch<NextInvoiceSummary>(NEXT_INVOICE_ENDPOINT),
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 } = useTenantPlan()
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. `load` serves what a block already read,
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(): SharedRequest<PlanCatalog> {
12
- const { $authFetch } = useAuthFetch()
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(): SharedRequest<SeatQuotaResponse> {
32
- const { $authFetch } = useAuthFetch()
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
- export function useTenantPlan() {
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 shared = useSharedRequest(TENANT_PLAN_STATE_KEY, () =>
195
- $authFetch<TenantPlanResponse>(TENANT_PLAN_ENDPOINT),
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
- return $authFetch<PlanChangePreview>(TENANT_PREVIEW_ENDPOINT, {
227
- query: country ? { planId, country } : { planId },
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 $authFetch<PendingCheckoutResult>(TENANT_CHECKOUT_ENDPOINT)
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(): SharedRequest<WorkspaceOverview> {
54
- const { $authFetch } = useAuthFetch()
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
  }
@@ -48,6 +48,7 @@
48
48
  "optional": "Optional on {plan}",
49
49
  "free_plan": "the free plan",
50
50
  "reason": "Saved securely by Stripe. Nothing is charged on the free plan: the card confirms one person behind each free workspace ({count} per card).",
51
+ "reason_secured": "Saved securely by Stripe. Nothing is charged on the free plan.",
51
52
  "later": "Add a card later",
52
53
  "later_hint": "You'll be asked for one before moving to a paid plan."
53
54
  },
@@ -48,6 +48,7 @@
48
48
  "optional": "Facultative sur {plan}",
49
49
  "free_plan": "l'offre gratuite",
50
50
  "reason": "Enregistrée de façon sécurisée par Stripe. Rien n'est débité sur l'offre gratuite : la carte confirme une personne derrière chaque espace gratuit ({count} par carte).",
51
+ "reason_secured": "Enregistrée de façon sécurisée par Stripe. Rien n'est débité sur l'offre gratuite.",
51
52
  "later": "Ajouter une carte plus tard",
52
53
  "later_hint": "Elle vous sera demandée avant de passer à une offre payante."
53
54
  },
@@ -6,7 +6,7 @@
6
6
  "license": "Apache-2.0",
7
7
  "packageManager": "pnpm@10.6.5",
8
8
  "engines": {
9
- "@antelopejs/dms-frontend": ">=0.5.2 <0.6.0"
9
+ "@antelopejs/dms-frontend": ">=0.6.0 <0.7.0"
10
10
  },
11
11
  "scripts": {
12
12
  "format": "prettier --write .",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-saas",
3
- "version": "0.5.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.5.5 <1.0.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.7.9 <0.8.0",
47
- "@antelopejs/dms-frontend": ">=0.5.2 <0.6.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
- }