@antelopejs/dms-saas 0.10.0 → 0.11.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 (46) hide show
  1. package/README.md +5 -5
  2. package/dist/data-api/platformOwner/users.js +1 -1
  3. package/dist/data-api/platformOwner/users.js.map +1 -1
  4. package/dist/metrics/directory-summary.js +8 -1
  5. package/dist/metrics/directory-summary.js.map +1 -1
  6. package/dist/operator-actions/db/lifecycle-delivery.model.js +19 -11
  7. package/dist/operator-actions/db/lifecycle-delivery.model.js.map +1 -1
  8. package/dist/pages/platform/users/index.js +1 -1
  9. package/dist/pages/platform/users/index.js.map +1 -1
  10. package/dist/plan-changes/guarded-free.js +5 -1
  11. package/dist/plan-changes/guarded-free.js.map +1 -1
  12. package/dist/plan-changes/guarded-landing.js +4 -2
  13. package/dist/plan-changes/guarded-landing.js.map +1 -1
  14. package/dist/plan-changes/guarded-state.js +2 -0
  15. package/dist/plan-changes/guarded-state.js.map +1 -1
  16. package/dist/plans/catalogue-usage.js +6 -4
  17. package/dist/plans/catalogue-usage.js.map +1 -1
  18. package/dist/plans/plan-diff.d.ts +3 -3
  19. package/dist/plans/plan-diff.js.map +1 -1
  20. package/dist/plans/plan-write.d.ts +3 -1
  21. package/dist/plans/plan-write.js +11 -2
  22. package/dist/plans/plan-write.js.map +1 -1
  23. package/dist/routes/platformOwner/plans.d.ts +9 -4
  24. package/dist/routes/platformOwner/plans.js +3 -0
  25. package/dist/routes/platformOwner/plans.js.map +1 -1
  26. package/dist/routes/platformOwner/workspaces-admin.js +24 -11
  27. package/dist/routes/platformOwner/workspaces-admin.js.map +1 -1
  28. package/dist/routes/public/register.d.ts +2 -0
  29. package/dist/routes/public/register.js +4 -0
  30. package/dist/routes/public/register.js.map +1 -1
  31. package/dist/utils/segment-matching.js +19 -10
  32. package/dist/utils/segment-matching.js.map +1 -1
  33. package/dist/utils/workspace-records.d.ts +8 -0
  34. package/dist/utils/workspace-records.js +55 -0
  35. package/dist/utils/workspace-records.js.map +1 -0
  36. package/dist/workspaces/default-plan.js +22 -15
  37. package/dist/workspaces/default-plan.js.map +1 -1
  38. package/frontend-vue/app/build/public/pricing.ts +3 -0
  39. package/frontend-vue/app/components/WorkspaceDetailHeader.vue +3 -1
  40. package/frontend-vue/app/composables/registrationCardPolicy.ts +56 -0
  41. package/frontend-vue/app/composables/useSaasRegistration.ts +14 -47
  42. package/frontend-vue/app/custom-pages/auth/no-workspace.vue +6 -4
  43. package/frontend-vue/i18n/locales/saas-en-GB.json +1 -0
  44. package/frontend-vue/i18n/locales/saas-fr-FR.json +1 -0
  45. package/package.json +7 -6
  46. package/skills/dms-saas/SKILL.md +5 -3
@@ -8,6 +8,10 @@ import {
8
8
  toValue,
9
9
  } from 'vue'
10
10
  import { REGISTER_PLAN_PARAM } from '../build/public/routes'
11
+ import {
12
+ isPaymentStepShown,
13
+ resolveRegistrationPaymentPolicy,
14
+ } from './registrationCardPolicy'
11
15
  import {
12
16
  registrationLandingPath,
13
17
  useSaasRegistrationPlan,
@@ -108,12 +112,9 @@ interface SetupIntentResponse {
108
112
  clientSecret: string | null
109
113
  }
110
114
 
111
- type PaymentStepRule = (skipsPaymentMethod: boolean) => boolean
112
-
113
115
  const SETUP_INTENT_ENDPOINT = '/api/saas/register/setup-intent'
114
116
  const REGISTER_ENDPOINT = '/api/saas/register'
115
117
  const DEFAULT_PAYMENT_ELEMENT_ID = 'dms-saas-register-payment-element'
116
- const DEFAULT_PAYMENT_POLICY: RegistrationPaymentMethodPolicy = 'required'
117
118
  const INVITATION_ONLY = 'invitation-only'
118
119
  const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
119
120
  const DEFAULT_WORKSPACE_NAME_KEY = 'saas.public.register.default_workspace_name'
@@ -121,15 +122,6 @@ const NO_PAYMENT_ERROR_KEY = 'saas.public.register.error.card_required'
121
122
  const SUBMIT_ERROR_KEY = 'saas.public.register.error.failed'
122
123
  const PASSWORD_POLICY_ERROR_KEY = 'saas.errors.registration.password_policy'
123
124
 
124
- const PAYMENT_STEP_RULES: Record<
125
- RegistrationPaymentMethodPolicy,
126
- PaymentStepRule
127
- > = {
128
- required: () => true,
129
- optional: (skipsPaymentMethod) => !skipsPaymentMethod,
130
- none: () => false,
131
- }
132
-
133
125
  /**
134
126
  * Checked in the order the visitor can act on them: the card field comes
135
127
  * before the legal checkbox on every screen.
@@ -215,36 +207,6 @@ export function registrationFieldOf(
215
207
  return (errorKey && API_ERROR_FIELDS[errorKey]) || null
216
208
  }
217
209
 
218
- /**
219
- * The card policy the deployment published, falling back to the backend's
220
- * own default when it published none.
221
- *
222
- * @param config dms-saas public runtime config
223
- * @returns The configured policy, or `required`
224
- */
225
- export function resolveRegistrationPaymentPolicy(
226
- config: DmsSaasPublicRuntimeConfig | undefined,
227
- ): RegistrationPaymentMethodPolicy {
228
- const policy = config?.registrationPaymentMethod
229
- return policy && policy in PAYMENT_STEP_RULES
230
- ? policy
231
- : DEFAULT_PAYMENT_POLICY
232
- }
233
-
234
- /**
235
- * Whether the registration still collects a card.
236
- *
237
- * @param policy Configured card policy
238
- * @param skipsPaymentMethod Whether the visitor chose to add a card later
239
- * @returns True when the card step is shown and must be completed
240
- */
241
- export function isPaymentStepShown(
242
- policy: RegistrationPaymentMethodPolicy,
243
- skipsPaymentMethod: boolean,
244
- ): boolean {
245
- return PAYMENT_STEP_RULES[policy](skipsPaymentMethod)
246
- }
247
-
248
210
  /**
249
211
  * Whether the deployment has closed public registration to invitations.
250
212
  *
@@ -336,13 +298,18 @@ export function useSaasRegistration(options: UseSaasRegistrationOptions = {}) {
336
298
 
337
299
  /** Registration by invitation only: render the closed state, not the form. */
338
300
  const isRegistrationClosed = isRegistrationClosedBy(saasConfig)
339
- const paymentMethodPolicy = resolveRegistrationPaymentPolicy(saasConfig)
301
+ /** The policy the backend applies, once the plan summary has loaded. */
302
+ const paymentMethodPolicy = computed(() =>
303
+ resolveRegistrationPaymentPolicy(saasConfig, plan.summary.value),
304
+ )
340
305
  /** Whether the screen should offer to add the card later. */
341
- const canSkipPaymentMethod = paymentMethodPolicy === 'optional'
306
+ const canSkipPaymentMethod = computed(
307
+ () => paymentMethodPolicy.value === 'optional',
308
+ )
342
309
 
343
310
  /** Bind the card field's visibility to this, with `v-show`, not `v-if`. */
344
311
  const isPaymentStepVisible = computed(() =>
345
- isPaymentStepShown(paymentMethodPolicy, form.skipsPaymentMethod),
312
+ isPaymentStepShown(paymentMethodPolicy.value, form.skipsPaymentMethod),
346
313
  )
347
314
 
348
315
  /**
@@ -542,8 +509,8 @@ export function useSaasRegistration(options: UseSaasRegistrationOptions = {}) {
542
509
  isLoading.value = false
543
510
  return
544
511
  }
545
- void plan.load()
546
- if (paymentMethodPolicy === 'none') {
512
+ await plan.load()
513
+ if (paymentMethodPolicy.value === 'none') {
547
514
  isLoading.value = false
548
515
  return
549
516
  }
@@ -65,12 +65,14 @@ const saasConfig = config.public.dmsSaas as
65
65
  | undefined
66
66
  const dmsRuntime = config.public.dms as DmsPublicRuntime
67
67
  const isRegistrationClosed = isRegistrationClosedBy(saasConfig)
68
- const paymentMethodPolicy = resolveRegistrationPaymentPolicy(saasConfig)
69
68
  const comparePlansTo = isPublicScreenServed(saasConfig, 'pricing')
70
69
  ? PRICING_PATH
71
70
  : null
72
71
 
73
72
  const plan = useSaasRegistrationPlan(readChosenPlan)
73
+ const paymentMethodPolicy = computed(() =>
74
+ resolveRegistrationPaymentPolicy(saasConfig, plan.summary.value),
75
+ )
74
76
 
75
77
  const tenantAssignmentToken = computed(() => {
76
78
  const value = route.query.token
@@ -95,7 +97,7 @@ const stripeHandle = ref<ReturnType<typeof useStripePaymentElement> | null>(
95
97
  )
96
98
 
97
99
  const isPaymentStepVisible = computed(() =>
98
- isPaymentStepShown(paymentMethodPolicy, skipsPaymentMethod.value),
100
+ isPaymentStepShown(paymentMethodPolicy.value, skipsPaymentMethod.value),
99
101
  )
100
102
 
101
103
  const entryProvider = computed<OAuthProviderOption | null>(() => {
@@ -185,7 +187,7 @@ async function createSetupIntent(): Promise<string | undefined> {
185
187
 
186
188
  async function mountPaymentElement(): Promise<void> {
187
189
  const publishableKey = saasConfig?.stripePublishableKey
188
- if (!publishableKey || paymentMethodPolicy === 'none') return
190
+ if (!publishableKey || paymentMethodPolicy.value === 'none') return
189
191
  try {
190
192
  const clientSecret = await createSetupIntent()
191
193
  if (!clientSecret) return
@@ -280,7 +282,7 @@ onMounted(async () => {
280
282
  // after a card has been entered.
281
283
  await loadPendingRegistration()
282
284
  if (entryFailure.value) return
283
- void plan.load()
285
+ await plan.load()
284
286
  await mountPaymentElement()
285
287
  })
286
288
  </script>
@@ -29,6 +29,7 @@
29
29
  "downgrade_exceeds_seat_limit": "This plan allows fewer members than the workspace currently has",
30
30
  "inheritance_cycle": "Plan inheritance would create a cycle",
31
31
  "inheritance_parent_missing": "Parent plan not found",
32
+ "invalid_billing_mode": "Plan billing mode must be Flat rate or Per seat",
32
33
  "invalid_interval": "Plan billing interval must be monthly or yearly",
33
34
  "no_stripe_price": "Plan has no Stripe price",
34
35
  "seat_limit_reached": "The plan's member limit has been reached",
@@ -29,6 +29,7 @@
29
29
  "downgrade_exceeds_seat_limit": "Cette offre autorise moins de membres que l'espace de travail n'en compte actuellement",
30
30
  "inheritance_cycle": "L'héritage d'offres créerait un cycle",
31
31
  "inheritance_parent_missing": "Offre parente introuvable",
32
+ "invalid_billing_mode": "Le mode de facturation de l'offre doit être Forfait ou Par siège",
32
33
  "invalid_interval": "L'intervalle de facturation de l'offre doit être mensuel ou annuel",
33
34
  "no_stripe_price": "L'offre n'a pas de tarif Stripe",
34
35
  "seat_limit_reached": "La limite de membres de l'offre est atteinte",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-saas",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
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
5
  "keywords": [
6
6
  "antelopejs",
@@ -46,21 +46,22 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@antelopejs/interface-api": ">=0.3.0 <1.0.0",
49
- "@antelopejs/interface-api-util": ">=0.3.0 <1.0.0",
49
+ "@antelopejs/interface-api-util": ">=0.3.2 <1.0.0",
50
50
  "@antelopejs/interface-core": ">=0.4.0 <1.0.0",
51
51
  "@antelopejs/interface-data-api": ">=0.6.1 <1.0.0",
52
52
  "@antelopejs/interface-database": ">=0.3.0 <1.0.0",
53
- "@antelopejs/interface-database-decorators": ">=0.2.0 <1.0.0",
53
+ "@antelopejs/interface-database-decorators": ">=0.3.1 <1.0.0",
54
54
  "@antelopejs/interface-dms": ">=0.12.0 <1.0.0",
55
55
  "node-cron": "^4.2.1",
56
56
  "stripe": "^22.6.2",
57
57
  "zod": "^3.24.4",
58
- "@antelopejs/interface-dms-saas": "^0.7.0"
58
+ "@antelopejs/interface-dms-saas": "^0.8.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@antelopejs/core": "1.20.0",
62
- "@antelopejs/dms": ">=0.16.1 <1.0.0",
61
+ "@antelopejs/core": "1.21.0",
62
+ "@antelopejs/dms": ">=0.17.0 <1.0.0",
63
63
  "@antelopejs/dms-frontend": ">=0.10.0 <1.0.0",
64
+ "@antelopejs/interface-mongodb": ">=0.0.6 <1.0.0",
64
65
  "@antelopejs/mongodb": "1.6.2",
65
66
  "@total-typescript/shoehorn": "^0.1.2",
66
67
  "@types/node": "^24.0.0",
@@ -23,7 +23,9 @@ User docs: `docs/` of this package, published at https://dms.antelopejs.com/docs
23
23
  `withStripeAvailability()` and, when it cannot work without Stripe, calls `assertStripeConfigured()` first
24
24
  (`503 saas.errors.stripe.not_configured`) — see `src/stripe/availability.ts`.
25
25
  - Stripe webhook endpoint → `/api/saas/webhooks/stripe`, API version `2026-08-26.dahlia`.
26
- - Frontend server env: `DMS_AUTH_ESTABLISH_ENDPOINTS=/api/saas/register/finalize`, else sign-ups stay signed out (403).
26
+ - Sign-up completion needs no frontend server env: the module declares `/api/saas/register/finalize` as an
27
+ `authEstablishEndpoints` entry of its frontend module. A `403` from `/auth/establish` (sign-ups stay signed out)
28
+ means the frontend server does not serve this module's frontend (`faq`).
27
29
  - `allowedRedirectHosts` for Checkout / billing-portal return URLs: defaults to the DMS `clientBaseUrl` host, a value replaces it (loopback auto-allowed in dev only).
28
30
  - A free plan must exist (or `defaultPlanSlug`): registration opens it, and every workspace without a subscription gets it.
29
31
  - Options: `admissionMode` (`open` | `invitation-only`), `registration.paymentMethod` (`required` default | `optional` | `none`),
@@ -38,8 +40,8 @@ User docs: `docs/` of this package, published at https://dms.antelopejs.com/docs
38
40
  only for a `*` role. Resolvers of your own keyed on the user must read the context the same way.
39
41
  - New project page or block → add its permission ids to the plans that should get it, or tenants lose it.
40
42
  - Seeding plans from code: write name, price, currency, interval, billing mode; leave `paymentProviderRefs` to dms-saas.
41
- `name`, `description` and `borderLabel` are localized (`{ en, fr }` + `.localize("*")`), never i18n keys; Stripe gets the `en` text.
42
- - Features: `displayName` / `tooltip` are localized (`{ en, fr }` + `.localize("*")`), never i18n keys.
43
+ `name`, `description` and `borderLabel` are localized (`{ en, fr }` assigned on `.localize("*", PLAN_LOCALIZED_FIELDS)`, typed `PlanInAllLocales`), never i18n keys; Stripe gets the `en` text.
44
+ - Features: `displayName` / `tooltip` are localized (`{ en, fr }` assigned on `.localize("*", FEATURE_LOCALIZED_FIELDS)`, typed `FeatureInAllLocales`), never i18n keys.
43
45
  - Plan `description` and `borderLabel` may be `$i18n.key` (translated on every screen); `name` stays plain text.
44
46
 
45
47
  ## Extension points (`@antelopejs/interface-dms-saas`)