Demo mode and seed data generation.
Demo mode replaces real PII with sample data for safe previewing. Seeds populate the database with realistic test listings and attendees.
Replace form field values with demo data when demo mode is active. Only replaces fields that are present and non-empty in the form. Mutates and returns the same URLSearchParams for chaining.
Create seed listings and attendees using efficient batch writes. Encrypts all data before inserting, matching production behavior. Assigns random ticket quantities (1-4) per attendee without overselling.
Check if demo mode is enabled
Apply demo-mode overrides to the form, then run the loader — the shared prelude of the attendee submit handlers, which 404 when the loader finds nothing (a stale id racing a delete).
Pick a random element from an array
Reset cached demo mode value (for testing and cache invalidation)
Explicitly set demo mode on or off (for testing). Bypasses Deno.env to avoid races between parallel test workers.
Wrap a named resource so create/update apply demo overrides to the form
Maps form field names to arrays of possible demo values
Attendee PII fields
Demo addresses
Demo email addresses
Demo group descriptions
Demo group names
Demo holiday names
Demo listing descriptions — rock-themed gig blurbs assembled from word pools. Like the names above, the list is procedurally generated but seeded so it stays deterministic across runs.
Demo listing locations — pretend rock-venue / festival listings. Procedurally generated from the venue word pools using a seeded PRNG.
Demo listing names — pretend rock/heavy-metal band listings. Generated procedurally from a seeded PRNG so the list stays deterministic across runs (tests rely on this) but offers far more variety than a hand-curated list while staying on-theme.
Demo attendee names (full names for demo mode overrides)
Demo page text (homepage / contact)
Demo phone numbers (UK format)
Demo servicing-event names (a reason/job for a capacity hold, not a person)
Demo special instructions
Demo terms and conditions
Demo website titles
Group name and description fields
Holiday name field
Listing metadata fields
Attendee Logistics tab fields: the address is masked like the attendee form's, and the pinned latitude/longitude are cleared outright — an exact real-world location is PII even beside a masked address.
Max attendees per seeded listing
Servicing-event fields — name only, and a servicing reason rather than a person's name, so demo mode doesn't turn "Boiler Service" into "Bob Smith".
Site contact page fields
Site homepage fields
Terms and conditions field
Usage
import * as mod from "docs/demo.ts";