@aglyn/aglyn 1.10.0 → 1.12.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 (55) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/account-preferences.d.ts +15 -13
  3. package/src/lib/app-utils/account-preferences.js +20 -20
  4. package/src/lib/app-utils/account-preferences.js.map +1 -1
  5. package/src/lib/app-utils/crm.d.ts +3 -1
  6. package/src/lib/app-utils/crm.js +6 -3
  7. package/src/lib/app-utils/crm.js.map +1 -1
  8. package/src/lib/app-utils/docs-help-sections.generated.js +3 -3
  9. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  10. package/src/lib/app-utils/docs-help.generated.d.ts +2 -2
  11. package/src/lib/app-utils/docs-help.generated.js +2 -0
  12. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  13. package/src/lib/app-utils/docs-index.generated.js +76 -69
  14. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  15. package/src/lib/app-utils/full-use-cost.d.ts +28 -11
  16. package/src/lib/app-utils/full-use-cost.js +31 -15
  17. package/src/lib/app-utils/full-use-cost.js.map +1 -1
  18. package/src/lib/app-utils/markdown-lite.js +8 -1
  19. package/src/lib/app-utils/markdown-lite.js.map +1 -1
  20. package/src/lib/app-utils/org-role-grants.d.ts +6 -0
  21. package/src/lib/app-utils/org-role-grants.js +3 -1
  22. package/src/lib/app-utils/org-role-grants.js.map +1 -1
  23. package/src/lib/app-utils/person-erasure.d.ts +8 -0
  24. package/src/lib/app-utils/person-erasure.js +6 -0
  25. package/src/lib/app-utils/person-erasure.js.map +1 -1
  26. package/src/lib/app-utils/plan-entitlements.d.ts +27 -1
  27. package/src/lib/app-utils/plan-entitlements.js +44 -3
  28. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  29. package/src/lib/app-utils/site-preview.d.ts +6 -2
  30. package/src/lib/app-utils/site-preview.js +5 -3
  31. package/src/lib/app-utils/site-preview.js.map +1 -1
  32. package/src/lib/app-utils/site-unavailable.d.ts +4 -7
  33. package/src/lib/app-utils/site-unavailable.js +4 -8
  34. package/src/lib/app-utils/site-unavailable.js.map +1 -1
  35. package/src/lib/app-utils/upgrade-proposal.d.ts +17 -3
  36. package/src/lib/app-utils/upgrade-proposal.js +28 -6
  37. package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
  38. package/src/lib/foundation/definitions/org-billing.types.d.ts +22 -0
  39. package/src/lib/foundation/definitions/org-billing.types.js +2 -2
  40. package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
  41. package/src/lib/foundation/definitions/platform.types.d.ts +1 -1
  42. package/src/lib/foundation/definitions/platform.types.js.map +1 -1
  43. package/src/lib/foundation/definitions/write-deny-coverage.util.d.ts +1 -1
  44. package/src/lib/foundation/definitions/write-deny-coverage.util.js +1 -1
  45. package/src/lib/foundation/definitions/write-deny-coverage.util.js.map +1 -1
  46. package/src/lib/plugin-manager/first-party-plugins.generated.js +1 -1
  47. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  48. package/src/lib/plugin-manager/plugin-contact-capture.d.ts +18 -0
  49. package/src/lib/plugin-manager/plugin-contact-capture.js +26 -0
  50. package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
  51. package/src/lib/plugin-manager/plugin-person-erasure-notes.d.ts +61 -0
  52. package/src/lib/plugin-manager/plugin-person-erasure-notes.js +114 -0
  53. package/src/lib/plugin-manager/plugin-person-erasure-notes.js.map +1 -0
  54. package/src/lib/plugin-manager/plugin-site-starters.d.ts +7 -0
  55. package/src/lib/plugin-manager/plugin-site-starters.js.map +1 -1
@@ -1735,6 +1735,44 @@ function trimmedOrNull(value) {
1735
1735
  }
1736
1736
  return listPriceUsd;
1737
1737
  }
1738
+ /**
1739
+ * The org's BASE PLAN line, monthly (annual billing as its monthly
1740
+ * equivalent), and 0 for anyone not billing: the one line a base-price coupon
1741
+ * reaches (AGL-4161). A negotiated custom price is the whole deal, so it is
1742
+ * its own base line.
1743
+ */ export function orgBasePriceMonthlyUsd(org) {
1744
+ var _org_subscription, _org_subscription1;
1745
+ if (!isBillingSubscription(org)) return 0;
1746
+ const custom = org == null ? void 0 : (_org_subscription = org.subscription) == null ? void 0 : _org_subscription.customMonthlyUsd;
1747
+ if (typeof custom === 'number' && custom > 0) return Math.round(custom * 100) / 100;
1748
+ const pricing = PLAN_PRICING[org == null ? void 0 : org.plan];
1749
+ if (!pricing) return 0;
1750
+ return (org == null ? void 0 : (_org_subscription1 = org.subscription) == null ? void 0 : _org_subscription1.interval) === 'year' ? pricing.basePriceAnnualMonthlyUsd : pricing.basePriceMonthlyUsd;
1751
+ }
1752
+ /**
1753
+ * How much of the org's monthly list price a discount reaches (AGL-4161):
1754
+ * all of it for a whole-subscription discount; for a base-price one, the base
1755
+ * plan line, or nothing when the plans it is limited to do not include the
1756
+ * org's plan (Stripe applies it to no line then). An old mirror without the
1757
+ * fields is a whole-subscription discount.
1758
+ */ export function discountReachMonthlyUsd(org, discount, listPriceUsd = orgListPriceMonthlyUsd(org)) {
1759
+ const list = Math.max(0, listPriceUsd);
1760
+ if (!(discount == null ? void 0 : discount.basePriceOnly)) return list;
1761
+ if (Array.isArray(discount.appliesToPlans) && !discount.appliesToPlans.includes(org == null ? void 0 : org.plan)) {
1762
+ return 0;
1763
+ }
1764
+ return Math.min(list, orgBasePriceMonthlyUsd(org));
1765
+ }
1766
+ /**
1767
+ * A monthly list price net of an ORG's discount (AGL-4161): `applyDiscountUsd`
1768
+ * on the part the discount reaches, the rest at list. For a whole-subscription
1769
+ * discount that is `applyDiscountUsd` exactly; a base-price one leaves the
1770
+ * add-ons in full.
1771
+ */ export function applyOrgDiscountUsd(org, listPriceUsd, discount) {
1772
+ const reach = discountReachMonthlyUsd(org, discount, listPriceUsd);
1773
+ if (!discount || reach >= listPriceUsd) return applyDiscountUsd(listPriceUsd, discount);
1774
+ return Math.round((listPriceUsd - reach + applyDiscountUsd(reach, discount)) * 100) / 100;
1775
+ }
1738
1776
  /**
1739
1777
  * Whether an org should read as **"Enterprise"** everywhere the plan is shown.
1740
1778
  * Three ways to qualify:
@@ -1793,10 +1831,12 @@ function trimmedOrNull(value) {
1793
1831
  * (`org.discount`, AGL-1105), and 0 for anyone who is not actually billing. A
1794
1832
  * comped enterprise deal genuinely collects less, so the discount belongs in
1795
1833
  * MRR; the pre-discount sticker stays available as `orgListPriceMonthlyUsd`.
1834
+ * A base-price discount (AGL-4161) comes off the base plan line only, so the
1835
+ * add-ons an org buys count in full.
1796
1836
  */ export function orgMonthlyRevenueUsd(org) {
1797
1837
  const listPrice = orgListPriceMonthlyUsd(org);
1798
1838
  if (listPrice <= 0) return 0;
1799
- return applyDiscountUsd(listPrice, org == null ? void 0 : org.discount);
1839
+ return applyOrgDiscountUsd(org, listPrice, org == null ? void 0 : org.discount);
1800
1840
  }
1801
1841
  /**
1802
1842
  * Stripe's standard processing fee on Aglyn's OWN subscription charges
@@ -2420,7 +2460,8 @@ export const DISCOUNT_DEPTH_BLOCK_PCT = 70;
2420
2460
  * the org — `grossUsd` is always the list price (`orgListPriceMonthlyUsd`),
2421
2461
  * so this never double-counts an existing `org.discount`. A non-billing org
2422
2462
  * (list price 0) has no revenue to protect and rates `ok`.
2423
- */ export function checkDiscountMargin(org, discount, options = {}) {
2463
+ */ export function checkDiscountMargin(org, // A base-price coupon (AGL-4161) is rated on the base line it reaches.
2464
+ discount, options = {}) {
2424
2465
  var _options_measuredCogsUsd;
2425
2466
  var _org_subscription;
2426
2467
  const floorPct = NET_MARGIN_FLOOR_PCT;
@@ -2447,7 +2488,7 @@ export const DISCOUNT_DEPTH_BLOCK_PCT = 70;
2447
2488
  floorPct
2448
2489
  };
2449
2490
  }
2450
- const discountedUsd = applyDiscountUsd(grossUsd, discount);
2491
+ const discountedUsd = applyOrgDiscountUsd(org, grossUsd, discount);
2451
2492
  const annual = (org == null ? void 0 : (_org_subscription = org.subscription) == null ? void 0 : _org_subscription.interval) === 'year';
2452
2493
  const netUsd = netOfProcessorFee(discountedUsd, annual);
2453
2494
  const depthPct = Math.round((grossUsd - discountedUsd) / grossUsd * 10000) / 10000;