feat(modules): venue-module registry — entitled ∩ activated, requireModule, Setup panel
Groundwork for the Car Wash pilot (wiki/decisions/venue-modules.md, build-order
steps 1 + 3). No Car Wash code yet; validation is the first module behind the
seam, unchanged in behaviour.
- @parking/shared: MODULE_IDS, ModuleManifest, MODULES (parking required;
validation dependsOn parking), parseEntitledModules / resolveModuleActivation
/ effectiveModules as pure functions.
- DB: site_config.modules_json (migration 0026, hand-written + journal;
additive, nullable = everything entitled).
- Server: modules.ts (entitledModules from MODULES_ENTITLED env, activated
from site_config, effective set, requireModule preHandler → 403
module_disabled); modules/index.ts registers folder-based modules by
iterating the registry (modules/validation); site-config GET exposes
modules/modulesEntitled/modulesActivated, PUT takes the full desired set,
enforces entitlement + dependency rules (400 with reason) and signs one
config_change per module that actually flips; /api/auth/me carries the
effective set; validation routes guarded requireModule → requirePermission.
- Web: lib/modules.ts + modules/{index,validation}; router.tsx spreads
WEB_MODULES into nav + route tree (validate route no longer named there);
Setup → Site "Modules" panel (required shown disabled, dependencies as
hints, server refusal shown verbatim); validation sections + programs fetch
gated on the module; App invalidates the router whenever the session
changes (route-context consumers only re-read on navigation — the nav was
stale after a flip, and after every other setUser too).
- Lavazh validation station retired (STATIONS = ["bar"]; rows untouched).
- Deploy: MODULES_ENTITLED=parking,validation explicit in both booth stacks;
documented in .env.example.
- Tests: modules.test.ts (7); suite 329/329; web build clean; Playwright
round-trip on /setup/site verified live.
Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
-- Venue modules: which optional modules the site admin has ACTIVATED (JSON array of
|
||||
-- module ids, e.g. ["parking","validation"]). null = never set → everything the site is
|
||||
-- entitled to (MODULES_ENTITLED env). Effective set = entitled ∩ activated, computed server-
|
||||
-- side (apps/server/src/modules.ts); each change signs a config_change. Additive, nullable:
|
||||
-- existing deployments see no behaviour change. See wiki/decisions/venue-modules.md.
|
||||
ALTER TABLE `site_config` ADD `modules_json` text;
|
||||
@@ -183,6 +183,13 @@
|
||||
"when": 1788078414270,
|
||||
"tag": "0025_backup_last_status",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 26,
|
||||
"version": "6",
|
||||
"when": 1788596918862,
|
||||
"tag": "0026_site_modules",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +233,12 @@ export const siteConfig = sqliteTable("site_config", {
|
||||
* own price and may differ. null = no site default set. See
|
||||
* wiki/entities/subscription.md. */
|
||||
subscriptionMonthlyPriceMinor: integer("subscription_monthly_price_minor"),
|
||||
/** Venue modules the site admin has ACTIVATED (JSON array of ModuleId, e.g.
|
||||
* ["parking","validation"]). null = never set → everything the site is entitled to.
|
||||
* The effective set is entitled (MODULES_ENTITLED env) ∩ this, computed server-side
|
||||
* (apps/server/src/modules.ts); each change signs a config_change. Disabling a module
|
||||
* never deletes anything. See wiki/decisions/venue-modules.md. */
|
||||
modulesJson: text("modules_json"),
|
||||
/** When ON, the occupancy/full gate RESERVES a spot for each active subscriber's car
|
||||
* (by quantity) even when they're not parked — so transients see "full" sooner and
|
||||
* the subscriber's spot is held. When OFF (default), only cars physically inside
|
||||
|
||||
Reference in New Issue
Block a user