Widget Catalog
Component Scope
src/lib/s3-widgets.ts manages widget manifests in S3.
src/app/widgets/page.tsx is the read-only UI viewer.
Storage Keys
Under <rulesPrefix>/widgets:
index.jsontracks widget IDs and update timestamp.<widgetId>.jsonstores each widget manifest.
Runtime Behavior
- On read,
ensureDefaultWidgetsInS3guarantees allDEFAULT_WIDGETSexist in storage and inindex.json. ensureDefaultWidgetsInS3also removes deprecated defaults (price.roundUpMultiple,price.roundDownMultiple) from S3 and from index metadata.listWidgetsFromS3reads index, loads manifests, validates them, sorts by category/title, and caches results for ~10 seconds.saveWidgetToS3validates and persists a widget, then updates index if needed.
Validation Highlights
- Widget ID format:
^[A-Za-z0-9][A-Za-z0-9._-]{1,80}$. - Fields must be valid
numberorselectdescriptors. - Engine kinds supported:
multiplypercentAdjustmarginFromCostroundNearest9roundNearest5
- Widget field keys must be unique within a widget.
API Exposure
Current route surface only exposes read:
GET /api/widgets->listWidgetsFromS3
saveWidgetToS3 exists in library code but is not currently wired to a route.