@antelopejs/dms-saas 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +61 -1003
  2. package/dist/billing-state/recovery.js +2 -2
  3. package/dist/billing-state/recovery.js.map +1 -1
  4. package/dist/operator-actions/db/lifecycle-delivery.model.d.ts +1 -0
  5. package/dist/operator-actions/db/operator-action.model.d.ts +1 -0
  6. package/dist/pages/tenant/general.js +1 -0
  7. package/dist/pages/tenant/general.js.map +1 -1
  8. package/dist/stripe/client.d.ts +3 -0
  9. package/dist/stripe/client.js +16 -1
  10. package/dist/stripe/client.js.map +1 -1
  11. package/dist/stripe/customer-billing.js +1 -1
  12. package/dist/stripe/customer-billing.js.map +1 -1
  13. package/dist/stripe/subscription-cancellation.js +1 -1
  14. package/dist/stripe/subscription-cancellation.js.map +1 -1
  15. package/dist/stripe/upcoming-invoice.js +3 -3
  16. package/dist/stripe/upcoming-invoice.js.map +1 -1
  17. package/dist/types/config.d.ts +2 -0
  18. package/dist/types/config.js.map +1 -1
  19. package/dist/upcoming-invoice/db/preview-cache.model.d.ts +1 -0
  20. package/dist/workspaces/db/provisioning-attempt.model.d.ts +1 -0
  21. package/dist/workspaces/db/trial-identity.model.d.ts +1 -0
  22. package/frontend-vue/app/build/PayInvoicePanel.vue +4 -8
  23. package/frontend-vue/app/build/PlanChangeReview.vue +3 -6
  24. package/frontend-vue/app/build/segments/useSegmentCatalog.ts +7 -12
  25. package/frontend-vue/app/build/useWorkspaceName.ts +1 -2
  26. package/frontend-vue/app/build/users/useUserDetail.ts +8 -10
  27. package/frontend-vue/app/build/workspace-detail/ComplimentaryDialog.vue +5 -3
  28. package/frontend-vue/app/build/workspace-detail/CreditDialog.vue +5 -3
  29. package/frontend-vue/app/build/workspace-detail/UpgradeDialog.vue +14 -7
  30. package/frontend-vue/app/build/workspace-detail/useWorkspaceActions.ts +11 -10
  31. package/frontend-vue/app/build/workspace-detail/useWorkspaceOverview.ts +16 -30
  32. package/frontend-vue/app/components/CustomerPortalButton.vue +6 -4
  33. package/frontend-vue/app/components/DataExport.vue +34 -54
  34. package/frontend-vue/app/components/DataExportHistory.vue +2 -7
  35. package/frontend-vue/app/components/IssueCreditNoteModal.vue +5 -4
  36. package/frontend-vue/app/components/MigrationStripeCheck.vue +11 -8
  37. package/frontend-vue/app/components/PastDueAlert.vue +8 -6
  38. package/frontend-vue/app/components/PastDueBanner.vue +4 -4
  39. package/frontend-vue/app/components/PaymentMethodCard.vue +6 -11
  40. package/frontend-vue/app/components/PlanAccessEditor.vue +31 -30
  41. package/frontend-vue/app/components/PlanCard.vue +2 -3
  42. package/frontend-vue/app/components/PlanEditorPreview.vue +27 -36
  43. package/frontend-vue/app/components/PlanUpgradeModal.vue +1 -1
  44. package/frontend-vue/app/components/PlatformNotes.vue +27 -28
  45. package/frontend-vue/app/components/Pricing.vue +16 -23
  46. package/frontend-vue/app/components/RefundButton.vue +61 -46
  47. package/frontend-vue/app/components/RetirePlanModal.vue +13 -7
  48. package/frontend-vue/app/components/SeatQuotaBanner.vue +9 -10
  49. package/frontend-vue/app/components/SegmentConditionsBuilder.vue +0 -1
  50. package/frontend-vue/app/components/SegmentRulesText.vue +1 -3
  51. package/frontend-vue/app/components/TenantBillingForm.vue +14 -19
  52. package/frontend-vue/app/components/TenantPlanCard.vue +18 -21
  53. package/frontend-vue/app/components/TrialEndingBanner.vue +5 -10
  54. package/frontend-vue/app/components/UserPlatformRoleCard.vue +8 -9
  55. package/frontend-vue/app/components/UserSegmentMatches.vue +8 -16
  56. package/frontend-vue/app/components/UserSummaryCard.vue +2 -4
  57. package/frontend-vue/app/components/WorkspaceAdminCreateModal.vue +13 -5
  58. package/frontend-vue/app/components/WorkspaceCreateModal.vue +5 -1
  59. package/frontend-vue/app/components/WorkspaceDangerZone.vue +10 -9
  60. package/frontend-vue/app/components/WorkspaceDetailHeader.vue +14 -4
  61. package/frontend-vue/app/components/WorkspaceSuspended.vue +27 -32
  62. package/frontend-vue/app/components/WorkspaceSwitcherWidget.vue +5 -18
  63. package/frontend-vue/app/composables/useBillingIdentity.ts +9 -5
  64. package/frontend-vue/app/composables/useBillingStatus.ts +8 -7
  65. package/frontend-vue/app/composables/useCurrentWorkspace.ts +6 -8
  66. package/frontend-vue/app/composables/useExportHistory.ts +67 -78
  67. package/frontend-vue/app/composables/useMountedData.ts +27 -0
  68. package/frontend-vue/app/composables/useMyWorkspaces.ts +26 -28
  69. package/frontend-vue/app/composables/useNextInvoice.ts +7 -6
  70. package/frontend-vue/app/composables/useOnDemandRead.ts +49 -0
  71. package/frontend-vue/app/composables/usePendingCheckout.ts +2 -1
  72. package/frontend-vue/app/composables/usePlanCatalog.ts +3 -9
  73. package/frontend-vue/app/composables/usePublicPricing.ts +24 -0
  74. package/frontend-vue/app/composables/useSaasRegistration.ts +2 -0
  75. package/frontend-vue/app/composables/useSeatQuota.ts +2 -6
  76. package/frontend-vue/app/composables/useTenantPlan.ts +26 -9
  77. package/frontend-vue/app/composables/useWorkspaceOverview.ts +2 -6
  78. package/frontend-vue/app/custom-pages/auth/no-workspace.vue +3 -1
  79. package/frontend-vue/dms.server.ts +22 -0
  80. package/frontend-vue/package.json +1 -1
  81. package/package.json +36 -18
  82. package/skills/dms-saas/SKILL.md +56 -0
  83. package/frontend-vue/app/composables/useServerConfirm.ts +0 -44
  84. package/frontend-vue/app/composables/useSharedRequest.ts +0 -54
  85. package/frontend-vue/app/composables/useWorkspaceAccessCache.ts +0 -52
  86. package/frontend-vue/app/composables/useWorkspaceRenamed.ts +0 -33
package/package.json CHANGED
@@ -1,15 +1,31 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-saas",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
+ "description": "SaaS module for the AntelopeJS DMS: self-service sign-up and pricing, plans that gate features, Stripe billing, workspace settings and a back office.",
5
+ "keywords": [
6
+ "antelopejs",
7
+ "billing",
8
+ "dms",
9
+ "dms-module",
10
+ "multi-tenant",
11
+ "saas",
12
+ "stripe"
13
+ ],
14
+ "homepage": "https://dms.antelopejs.com/docs/modules/saas",
15
+ "bugs": {
16
+ "url": "https://github.com/AntelopeJS/dms-saas/issues"
17
+ },
4
18
  "license": "Apache-2.0",
5
19
  "repository": {
6
20
  "type": "git",
7
- "url": "git+https://github.com/AntelopeJS/dms-saas.git"
21
+ "url": "git+https://github.com/AntelopeJS/dms-saas.git",
22
+ "directory": "packages/dms-saas"
8
23
  },
9
24
  "files": [
10
25
  "dist",
11
26
  "!dist/.tsbuildinfo",
12
27
  "frontend-vue",
28
+ "skills",
13
29
  "package.json",
14
30
  "README.md",
15
31
  "LICENSE"
@@ -29,26 +45,25 @@
29
45
  "registry": "https://registry.npmjs.org/"
30
46
  },
31
47
  "dependencies": {
32
- "@antelopejs/interface-api": ">=0.0.14 <1.0.0",
33
- "@antelopejs/interface-api-util": ">=0.1.2 <1.0.0",
34
- "@antelopejs/interface-core": ">=0.1.1 <1.0.0",
35
- "@antelopejs/interface-data-api": ">=0.2.0 <1.0.0",
36
- "@antelopejs/interface-database": ">=0.1.8 <1.0.0",
37
- "@antelopejs/interface-database-decorators": ">=0.1.7 <1.0.0",
38
- "@antelopejs/interface-dms": ">=0.6.0 <1.0.0",
39
- "@antelopejs/interface-dms-saas": ">=0.4.0 <0.5.0",
48
+ "@antelopejs/interface-api": ">=0.0.15 <1.0.0",
49
+ "@antelopejs/interface-api-util": ">=0.1.3 <1.0.0",
50
+ "@antelopejs/interface-core": ">=0.2.4 <1.0.0",
51
+ "@antelopejs/interface-data-api": ">=0.2.2 <1.0.0",
52
+ "@antelopejs/interface-database": ">=0.1.10 <1.0.0",
53
+ "@antelopejs/interface-database-decorators": ">=0.1.9 <1.0.0",
54
+ "@antelopejs/interface-dms": ">=0.7.2 <1.0.0",
40
55
  "node-cron": "^4.2.1",
41
56
  "stripe": "^22.6.2",
42
- "zod": "^3.24.4"
57
+ "zod": "^3.24.4",
58
+ "@antelopejs/interface-dms-saas": "^0.4.1"
43
59
  },
44
60
  "devDependencies": {
45
- "@antelopejs/core": "1.13.5",
46
- "@antelopejs/dms": ">=0.8.0 <0.9.0",
47
- "@antelopejs/dms-frontend": ">=0.5.6 <0.6.0",
48
- "@antelopejs/mongodb": "1.4.2",
49
- "@antelopejs/tooling-configs": ">=0.0.7 <1.0.0",
61
+ "@antelopejs/core": "1.16.0",
62
+ "@antelopejs/dms": ">=0.9.3 <1.0.0",
63
+ "@antelopejs/dms-frontend": ">=0.6.3 <0.7.0",
64
+ "@antelopejs/mongodb": "1.4.3",
65
+ "@antelopejs/tooling-configs": ">=0.0.9 <1.0.0",
50
66
  "@types/node": "^24.0.0",
51
- "@types/node-cron": "^3.0.11",
52
67
  "knip": "^6.34.0",
53
68
  "mongodb-memory-server-core": "^11.0.1",
54
69
  "oxfmt": "^0.66.0",
@@ -61,12 +76,15 @@
61
76
  "vitest": "^4.1.10"
62
77
  },
63
78
  "optionalDependencies": {
64
- "@antelopejs/interface-dms-automation": ">=0.1.1 <1.0.0"
79
+ "@antelopejs/interface-dms-automation": ">=0.2.1 <1.0.0"
65
80
  },
66
81
  "antelopeJs": {
67
82
  "baseUrl": "dist",
68
83
  "implements": [
69
84
  "@antelopejs/interface-dms-saas"
85
+ ],
86
+ "skills": [
87
+ "./skills"
70
88
  ]
71
89
  },
72
90
  "scripts": {
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: dms-saas
3
+ description: Turns an AntelopeJS DMS project into a SaaS with the @antelopejs/dms-saas module. Use when installing or configuring dms-saas (Stripe keys, webhooks, registration card policy, admission mode, default plan), gating features by plan permissions, seeding plans or features, extending it through @antelopejs/interface-dms-saas (registration extras, invoice line items, upcoming invoice preview, workspace settings pages, billing page blocks, lifecycle consumers), or debugging sign-up, checkout, plan sync or reconciliation errors.
4
+ icon: i-lucide-building-2
5
+ category: billing
6
+ tags: [saas, billing, stripe, plans, subscriptions, multi-tenant, dms-module]
7
+ ---
8
+
9
+ # dms-saas
10
+
11
+ Self-service sign-up, plans, Stripe billing, customer workspace settings and an owner back office (`/modules/saas/...`).
12
+ User docs: `docs/` of this package, published at https://dms.antelopejs.com/docs/modules/saas
13
+ (`configuration`, `extending`, `stripe`, `operations`, `faq#upgrading`).
14
+
15
+ ## Setup checklist
16
+
17
+ - dms-saas 0.6 requires `@antelopejs/dms` >=0.9 (interface-dms 0.7, renderer `@antelopejs/dms-frontend` 0.6);
18
+ 0.5 is the DMS 0.8 line.
19
+ - `ajs project modules add @antelopejs/dms-saas`; config `stripe.{secretKey,publishableKey,webhookSecret}` from env
20
+ (`envOverrides`). Placeholder keys disable Stripe calls (plan sync skipped).
21
+ - Stripe webhook endpoint → `/api/saas/webhooks/stripe`, API version `2026-08-26.dahlia`.
22
+ - Frontend server env: `DMS_AUTH_ESTABLISH_ENDPOINTS=/api/saas/register/finalize`, else sign-ups stay signed out (403).
23
+ - `allowedRedirectHosts` for Checkout / billing-portal return URLs (loopback auto-allowed in dev only).
24
+ - A free plan must exist (or `defaultPlanSlug`): registration opens it, and every workspace without a subscription gets it.
25
+ - Options: `admissionMode` (`open` | `invitation-only`), `registration.paymentMethod` (`required` default | `optional` | `none`),
26
+ `publicScreens.{register,pricing}`, `upcomingInvoicePreviewCacheTtlSeconds`, `reportingCurrency`,
27
+ `stripe.readTimeoutMs` (4000; Stripe reads a page renders) and `stripe.readMaxNetworkRetries` (0).
28
+
29
+ ## Plans gate permissions
30
+
31
+ - The `dms-saas.plan-intersection` resolver keeps, per member, roles ∩ plan; the workspace owner gets every plan
32
+ permission (never `*`). A plan grants exactly the ids it lists: list every component id, not just the page.
33
+ - New project page or block → add its permission ids to the plans that should get it, or tenants lose it.
34
+ - Seeding plans from code: write name, price, currency, interval, billing mode; leave `paymentProviderRefs` to dms-saas.
35
+ - Features: `displayName` / `tooltip` are localized (`{ en, fr }` + `.localize("*")`), never i18n keys.
36
+
37
+ ## Extension points (`@antelopejs/interface-dms-saas`)
38
+
39
+ | Need | API |
40
+ | --- | --- |
41
+ | Own registration screen | `publicScreens.register: false` + `useSaasRegistration()` composable |
42
+ | Store sign-up answers | `extras` on the payload + `Hook.TENANT_BEING_PROVISIONED` listener (throwing cancels the sign-up; return `undefined`) |
43
+ | Bill metered usage | `RegisterInvoiceLineItemsProvider({ id, resolve })` in `construct`, unregister in `stop`; stable `key`s |
44
+ | Show tax-exact next invoice | `GetUpcomingInvoicePreview({ tenantId, userId })` → `available` / `absent` / `unavailable` |
45
+ | Page in workspace settings | `category: workspaceSettingsCategory` (from `/pages`) |
46
+ | Block on the billing page | `RegisterTenantBillingPageExtension({ name, components })` anchored on `tenantBillingPage.components.*` |
47
+ | React to create/suspend/reactivate | `RegisterWorkspaceLifecycleConsumer`; dedupe by `operationId`; gate on `IsWorkspaceProvisioningCommitted` |
48
+
49
+ Pages you add stay backend-declared blocks; only the missing block is a `CustomComponent`, with `.meta({ name, description, icon })`.
50
+
51
+ ## Gotchas
52
+
53
+ - `reconciliation_required` (operator actions, migrations, webhooks) is deliberate: never delete records or replay blindly.
54
+ - Checkout errors: `422 checkout_rejected` (retry), `503 checkout_unavailable`, `409 checkout_in_progress`.
55
+ - Upgrading old databases needs manual row fixes (`isComplimentary`, `documentType`, `revision`, `paidUsagePeriods`, localized features).
56
+ - Passwords follow the DMS policy: letters, digits and `@$!%*?&` only.
@@ -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
- }
@@ -1,33 +0,0 @@
1
- import { onBeforeUnmount, onMounted } from 'vue'
2
-
3
- /** The General page's rename form, which changes the workspace's name. */
4
- const RENAME_SUBMIT_URL = '/api/saas/workspaces/current'
5
-
6
- interface FormSubmitPayload {
7
- submitUrl?: string
8
- }
9
-
10
- interface FormSubmitDetail {
11
- data?: FormSubmitPayload
12
- }
13
-
14
- /** Whether a form's success event is the rename of the current workspace. */
15
- function isWorkspaceRenameEvent(event: Event): boolean {
16
- const detail = (event as CustomEvent<FormSubmitDetail>).detail
17
- return detail?.data?.submitUrl === RENAME_SUBMIT_URL
18
- }
19
-
20
- /**
21
- * Runs `onRenamed` each time the General page's form renames the current
22
- * workspace, for as long as the calling component is mounted: whatever shows
23
- * the name (the switcher, the deletion's typed confirmation) reads it again.
24
- */
25
- export function useWorkspaceRenamed(onRenamed: () => void): void {
26
- function onFormSaved(event: Event): void {
27
- if (isWorkspaceRenameEvent(event)) onRenamed()
28
- }
29
- onMounted(() => window.addEventListener(FormEvents.SUBMIT_SUCCESS, onFormSaved))
30
- onBeforeUnmount(() =>
31
- window.removeEventListener(FormEvents.SUBMIT_SUCCESS, onFormSaved),
32
- )
33
- }