Commit graph

15 commits

Author SHA1 Message Date
dc8c58f4c2 Schema: explicit size limits on JSON fields
pb_schema.json had six JSON field limits under `options.maxSize`, which
PocketBase ignores since 0.23, so those fields used PocketBase's default.
That default dropped to 1MB in 0.29: on 0.40 a 1.5MB page that 0.23
saved is refused. Move the limits to the field's top level and add a
migration that sets them on existing installs (pages/email blocks 2MB,
globals 1MB, event categories 200KB, customer details 100KB).

Tested on 0.40.6: existing install (migration applied, 1.5MB page saves,
2.5MB refused at 2MB) and fresh install + pb_schema.json import; both
end with identical schemas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gX7xH4zwYTr5vE7mf8
2026-11-03 09:43:49 +00:00
f86c2251dc Visual text editor; Cards, FAQ and HTML blocks; block anchors
The text editor (Tiptap) only produces simple HTML: headings, bold,
italic, strikethrough, links, lists, pull quotes, lines. Layouts that
were hand-written HTML in text blocks get their own blocks (Cards with
pictures or numbered steps, FAQ), one-offs and embeds go in an HTML
block, and every block can have an anchor for #links. Text blocks get
alignment and a small (footnote) size.

Existing text blocks the editor can't represent become HTML blocks that
render exactly as before (migration, and backup import for old files);
text that is only centred becomes centred text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-26 12:58:15 +00:00
338aef9e01 Bundles: keep parts from being deleted out from under them
Bundle parts are JSON, so deleting a service left bundles pointing at
nothing (shown as "Item" in the shop). An onRecordDelete hook on items
now refuses while a bundle contains it or a usable code still has
sessions of it to book. A bundle with an inactive part is no longer sold
or issued; the admin items list marks it "Not on sale" and shows how many
codes are waiting on an inactive service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-26 09:04:35 +00:00
32984ac01d Stock: items.trackStock, so an empty stock really means unlimited
PocketBase 0.23 can't store an empty number (it reads back as 0), so a
product saved with "Unlimited when empty" stock was sold out — on main
too. trackStock says whether stock counts; existing products get it on,
so nothing that sells today changes. The shop maps untracked stock to
null (unlimited), as the UI always assumed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-25 21:39:51 +00:00
e30e1d3beb Shop hooks: bundles, codes (passes) and orders paid with codes
A bundle (items.type `bundle`) has its own price, parts (a service at a
length × count, or a product × count) and a validity in months. Buying one
creates a pass with an 8-character code; its parts are snapshotted with
their share of the price. Applying a code to a basket covers matching
bookings (same service and length) while places are left — counted from
order lines and live holds, never stored. A fully covered basket is
confirmed without Stripe.

Admin routes list, void/extend and issue codes; GDPR export, correction,
erasure and retention cover passes (erasure keeps the code working).

orders.total, orders.stripePaymentIntentId and order_lines.price are no
longer required: PocketBase treats 0 / '' as blank, and a code-paid order
has neither a payment nor a price.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-25 21:25:04 +00:00
ce3866550a Windows: choose the start-time step (10–60 min, default 30)
A window on fixed steps now has gridMinutes; the admin picks it when
creating or generating windows, and copies keep it. Added to the
(unmerged, undeployed) time-windows migration and pb_schema.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-25 21:03:40 +00:00
23df2ceced Shop hooks: a slot lookup by id returns all of that slot's bookings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-25 20:12:46 +00:00
b3ecc1722b Shop hooks: several durations per service, slots become time windows
A service now has `durations` ([{ minutes, price }]) instead of one
duration and price. A slot is either a `window` (a stretch of time with the
services that can be booked in it, start times every 30 min or only at the
edges of the free time) or a `session` (one service, fixed time, places —
the old group slot). Basket and order lines carry their own start and
minutes, so availability is computed from bookings alone.

The migration keeps paid bookings blocking their time (order lines get
minutes from their slot), then deletes the old slots — agreed: start fresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
2026-10-25 19:59:00 +00:00
971efebcdb Customers page: export, correct and erase personal data; automatic retention
Admin /customers finds a customer by name, email, phone or notes (orders and unpaid checkouts), exports everything stored as JSON, corrects details on every record, and erases them — anonymising orders (amounts, services and dates stay for the accounts) and deleting unpaid checkouts. A daily cron (and PocketBase start) deletes unpaid checkouts after N days and, when set, anonymises orders after M months, skipping orders with a booking ahead. A paid basket's copy of the details is cleared when its order is created. All writes are in pocketbase/pb_hooks/privacy (orders and baskets are superuser-only); migration 1793000000 makes orders.email optional and adds orders.anonymisedAt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
2026-10-24 10:44:45 +00:00
021d06d3e4 Checkout: reservation countdown, 'keep it 10 more minutes', and a message when a hold runs out
Basket changes that free or take places reload the page data, so places
removed from the basket show up in the shop again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
2026-10-24 09:32:56 +00:00
d7765fe605 Shop: places per slot, and bookings block overlapping slots
Slots get a capacity (items.capacity is the service default). Booking
state is no longer stored on the slot: slotStates() in the shop hooks
counts places from paid order lines and live basket holds (heldUntil
moves to the basket line), and a slot with any place taken blocks every
overlapping slot of any service, including get-ready time.

GET /api/shop/slots lists bookable slots (public) or full detail for a
signed-in admin. add_slot takes seats and adds to an existing line;
group lines can change quantity. Checks and writes share one
transaction. Migration moves existing holds, drops the unique index and
slot status/heldUntil/order, and makes slots signed-in only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
2026-10-24 08:26:37 +00:00
1a71c9db73 Services: per-service get-ready time (items.bufferMinutes)
Migration adds the field to existing databases; pb_schema.json mirrors it
in the 0.23 top-level format (min/onlyInt under "options" is ignored).
Edited next to Duration in Services & products.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
2026-10-24 07:41:17 +00:00
773fecc090 Shop: move commerce logic into PocketBase hooks; public app unprivileged
The public (internet-facing) app logged in as the PocketBase superuser and
held the Stripe secret key, so any bug in it could become full control of
the database. Baskets, slot holds, Stripe PaymentIntents, the webhook that
creates orders, and the payment-result lookup now run in PocketBase JS
hooks (pocketbase/pb_hooks/shop, routes under /api/shop/*, plus a cron
that releases expired holds every minute).

The public app's routes keep their URLs but only proxy to those routes and
manage the basket cookie; it has no PocketBase or Stripe secret. Booking
emails are still rendered and sent by the public app (same renderer as the
admin preview) from order data the webhook hook returns; it records the
outcome via a narrow endpoint guarded by INTERNAL_API_SECRET.

Also: slot add and order creation are now transactional; shop listings
load anonymously (already public via API rules); shop API errors always
reach the browser as JSON; the superuser client and stripe package are
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
2026-10-06 12:34:58 +00:00
1f929c68ca Lock order_lines writes (they were public)
order_lines had empty create/update/delete rules, so anyone could forge,
edit or delete the line items of real orders through the REST API. Writes
are now superuser-only (migration + pb_schema.json).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
2026-10-06 12:34:51 +00:00
9264289813 PocketBase: close public sign-up, lock commerce writes, add dates/unique keys
Security:
- PocketBase's default `users` collection allows anonymous sign-up, and
  every CMS rule only checks "signed in" (the admin login also accepts
  `users`). Anyone could register via the public API and edit the site,
  read orders/customer details, or log into the admin. Sign-up is now
  superuser-only.
- orders.create, baskets.create/update and basket_lines.create/update/
  delete were open to anonymous requests, allowing forged "paid" orders in
  the admin and basket tampering. The public app performs all of these
  server-side with the admin client, so they are now superuser-only
  (basket add-item/add-slot verified still working).

Data:
- created/updated autodate fields on all app collections; orders are now
  listed newest-first by date (ids are random, '-id' was not chronological).
- Unique indexes on pages.slug and globals.key (skipped with a log line if
  existing data has duplicates, so PocketBase still starts).

Delivered as a JS migration in pocketbase/pb_migrations, mounted into the
container (the image already passes --migrationsDir=/pb_migrations), so it
applies once on the next start. pb_schema.json carries the same changes for
fresh installs, where the migration runs before the schema is imported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
2026-10-06 10:55:12 +00:00