writeonce/docs/examples/ecommerce/shared/logic/seed.wo
shoney.arickathil 9279175f26 scaffold sibling crates, multi-app ecommerce, REST + concurrency docs
- scaffold 14 placeholder crates (app, db, engine, gen, http, logic,
  policy, ql, service, sub, txn, ui, value, wal) — empty Cargo.toml +
  src/lib.rs to receive code phase-by-phase from `rt`
- restructure docs/examples/ecommerce into multi-app layout: apps/admin
  and apps/storefront, with shared/ types/logic/components, per-app
  app.wo + wo.toml, and reusable .htmlx components (layout, money,
  order-row)
- add reference/rest/{blog,ecommerce}.rest — VS Code/JetBrains HTTP
  request files driving the running prototype, including 501/404/405
  expectations for stubbed endpoints
- add docs/plan/09-concurrency-scaleout.md and docs/plan/ui/00-overview.md;
  refine docs/plan/assembly/02-writeonce-stance.md
- refresh templates (about, article, header/footer, home, layout, styles)
  and add static favicon/logo
- add infra/sync.sh and tighten .gitignore for reference/ symlinks
2026-05-04 13:39:58 +02:00

51 lines
1.7 KiB
Text

-- Idempotent demo seed + the cross-entity Admin/Ops bypass policy.
-- Both belong to the *shared* layer rather than to any one app:
-- * The seed primes the shared database so either the storefront or the
-- admin app shows something on first boot.
-- * The bypass policy applies across every type, so it has to live where
-- every app can see it.
-- Runs once when the shared `wo db serve` daemon comes up — each app connects
-- over the wire and inherits the already-seeded state.
policy admin-ops-bypass
applies_to: Order, Product, Customer, Purchase
when: $session.role == Admin or $session.role == Ops
effect: skip-row-filters
on startup
do: seed()
fn seed() {
if count(Customer{ email == "admin@shop.test" }) == 0 {
insert Customer {
email: "admin@shop.test",
name: "Ops Admin",
role: Admin
};
}
if count(Product{ sku == "SKU-WIDGET" }) == 0 {
insert Product {
sku: "SKU-WIDGET",
name: "Widget",
price: 1999,
meta: {
description: "A classic widget.",
images: ["/static/widget.jpg"],
attributes: { colour: "blue", size: "M", material: "steel" }
},
inventory: { on_hand: 50, reserved: 0, reorder_at: 10 }
};
insert Product {
sku: "SKU-GIZMO",
name: "Gizmo",
price: 4999,
meta: {
description: "A premium gizmo.",
images: ["/static/gizmo.jpg"],
attributes: { colour: "black", size: "L", material: "aluminium" }
},
inventory: { on_hand: 12, reserved: 0, reorder_at: 3 }
};
}
}