Hub 2.21.0: install the Church Website; Website storage bought in steps

- New install offers the Church Website: Accounts first when the church has
  none, at accounts.<its address> (www. dropped); the FastPanel email sends a
  www. site's bare domain to www. with a 301.
- Licence.extraStorageSteps (migration): the token sends a Website its limit
  (5 GB + steps, limits.storageBytes, contracts 1.17.0); invoices bill the
  steps bought instead of the storage reported. Edit popup field 0-99.
- A Website/App licence starts on its plan however it's made (New install too).
- Vendored @crosscode/contracts 1.17.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 00:03:21 +02:00
co-authored by Claude Opus 5.5
parent 6f8242064f
commit c6f734ab20
21 changed files with 235 additions and 36 deletions
+6
View File
@@ -54,6 +54,9 @@ async function ensureAccountsLicence(db, customerId) {
}
}
/** The plan a new licence starts on, for products with one (others: the default). */
const FIRST_PLAN = { website: 'Website', app: 'Mustard Seed' };
/**
* Generate a licence for a customer, plus its Accounts licence when this is a product other than
* Accounts and it has none yet. Returns { licence, accounts } (accounts: the licence if created now).
@@ -61,6 +64,9 @@ async function ensureAccountsLicence(db, customerId) {
async function generateLicence(db, { customerId, product = 'events', data = {}, now = new Date() }) {
// Hub 2.0, decision 3: a product added to a customer that's already billed gets its free month,
// then joins the customer's invoices (the days before its first full period prorated).
// Hub 2.21.0: a Website licence is on its one plan, an App licence on the first tier, however it's
// made (Generate or New install); the App's review moves it.
if (data.plan === undefined && FIRST_PLAN[product]) data = { ...data, plan: FIRST_PLAN[product] };
const customer = BILLABLE.includes(product) && data.billedFrom === undefined ? await db.customer?.findUnique({ where: { id: customerId } }) : null;
if (customer && customer.billingCycle && customer.billingCycle !== 'none') data = { ...data, billedFrom: addMonths(today(now), 1) };
const licence = await createLicence(db, { customerId, product, data });