feat(backend): module registry, manifests, enable/disable without restart
Platform v2 step 1.3 (APPS_PLATFORM §4, §5.3, D-4, D-19).
- core/modules: Module/Perm/Limit/SettingDef/DeviceApp/Mount model; registry
that discovers modules/<key>/manifest.py and validates it (keys, kinds,
dependencies and cycles, permission prefixes and roles, unique settings,
each router claimed once and importable, device_app only on apps, workers);
free_tier.py (D-5 constant, used from 1.4)
- 25 manifests (the §4.2 map) with permission keys + default roles derived
from today's perm_* meaning, limits, device apps and the 55 settings
- main.py mounts every router from the manifests; non-core routers carry
Depends(module_required(key)) -> 403 module.disabled while off
- site_modules table (revision 0004), cached enablement; disabling a module
also turns off modules that depend on it; core can't be disabled
- worker supervisor: connect_menu / connect_orders / connect_remote are now
separate workers (v1's single _connect_loop split), started and stopped as
their modules turn on and off; crashes are logged and restarted
- GET /api/platform/bootstrap (venue name/tz/language/currency, effective
modules, user, language, role-template permission keys), GET /modules,
PUT /modules/{key}
- settings API derives its key list and defaults from the manifests
- reports router split: history endpoints on history_router (`history`
module, free tier later) under the same /api/reports prefix
- tests: registry validation, mount coverage, toggle round-trip, dependency
propagation, bootstrap/catalogue shape, supervisor; pack rule CS-13
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"""Module manifest — see core/modules/model.py and APPS_PLATFORM §4."""
|
||||
from core.modules.model import Module, Mount, Perm, SettingDef
|
||||
|
||||
MODULE = Module(
|
||||
key='pricing',
|
||||
kind='feature',
|
||||
name='Pricing',
|
||||
description='Price groups, happy hours, modifiers, deals and waiter discounts.',
|
||||
depends=('ordering',),
|
||||
permissions=(
|
||||
Perm('pricing.manage', 'Set up price groups, modifiers and deals', roles=('owner', 'store_manager')),
|
||||
Perm('pricing.discounts.apply', 'Give discounts', roles=('owner', 'store_manager')),
|
||||
),
|
||||
settings=(
|
||||
SettingDef('discounts.enabled', 'true', 'Global switch for waiter discounts.', type='bool'),
|
||||
SettingDef('discounts.max_total_value_workday', '', 'Max total discount value per business day (empty = no limit).', type='str'),
|
||||
SettingDef('discounts.max_total_value_shift', '', 'Max total discount value per waiter shift (empty = no limit).', type='str'),
|
||||
SettingDef('discounts.max_items_per_shift', '', 'Max discounted items per waiter shift (empty = no limit).', type='str'),
|
||||
),
|
||||
routers=(
|
||||
Mount('routers.pricing', '/api/pricing'),
|
||||
),
|
||||
)
|
||||
Reference in New Issue
Block a user