@mccaskie-labs/workbench-bookings 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -0
- package/dist/ui.d.ts +4 -1
- package/dist/ui.js +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-bookings
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `bookingAction` and `ownerBookingAction` no longer put the database's or the settings check's own words in the answer they hand back. For `store_failed` and `bad_config` the body's `message` is now a fixed line, so an app that sends `body` to the browser as JSON (the documented use) can't show a visitor a constraint name or a Postgres error code. The full error is on the new `ActionResult.cause`, for the app's own log. `text`, `error`, `field` and the status are unchanged.
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ const tz = BOOKING_CONFIG.time_zone
|
|
|
56
56
|
renderSlotPicker(days, { endpoint: '/book/details', service: 'appointment', title: 'Appointment', timeZone: tz, more: '/book?from=2026-12-07' })
|
|
57
57
|
renderBookingForm({ endpoint: '/book', service, title, start, timeZone: tz, ask: BOOKING_CONFIG.ask, confirm: BOOKING_CONFIG.confirm })
|
|
58
58
|
const r = await bookingAction(bookings, fields, { account }) // after Turnstile; r.body.text and r.body.field when it didn't go through
|
|
59
|
+
// r.body is safe to send as JSON as it is. When r.cause is set, log it: for store_failed and bad_config the detail is only there.
|
|
59
60
|
renderBookingDone(r.body.booking, { title, timeZone: tz, manage: `/b/${r.body.token}`, ics: `/b/${r.body.token}.ics` })
|
|
60
61
|
renderBookingManage(booking, { endpoint: '/book', token, title, timeZone: tz, changeable: bookings.changeable(booking), move: `/b/${token}/move` })
|
|
61
62
|
// Behind the owner's sign-in:
|
package/dist/ui.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Bookings } from "./bookings.ts";
|
|
2
|
-
import { type BookingsErrorCode } from "./errors.ts";
|
|
2
|
+
import { BookingsError, type BookingsErrorCode } from "./errors.ts";
|
|
3
3
|
import { type Words } from "./format.ts";
|
|
4
4
|
import type { Booking, BookingConfig, SlotDay } from "./types.ts";
|
|
5
5
|
interface Common {
|
|
@@ -94,6 +94,7 @@ export interface MineOptions extends Common {
|
|
|
94
94
|
export declare function renderMyBookings(bookings: readonly Booking[], o: MineOptions): string;
|
|
95
95
|
export interface ActionResult {
|
|
96
96
|
status: number;
|
|
97
|
+
/** What to answer with, as JSON. Safe to send as it is: it never holds the database's or the settings file's own words. */
|
|
97
98
|
body: {
|
|
98
99
|
ok: true;
|
|
99
100
|
action: string;
|
|
@@ -106,6 +107,8 @@ export interface ActionResult {
|
|
|
106
107
|
text: string;
|
|
107
108
|
field?: FormField;
|
|
108
109
|
};
|
|
110
|
+
/** The error behind a refusal, for the app's own log. Never send it: for store_failed and bad_config its message is the database's or the settings check's. */
|
|
111
|
+
cause?: BookingsError;
|
|
109
112
|
}
|
|
110
113
|
/**
|
|
111
114
|
* The customer's posts, on the booking page: `book` (service, start, name,
|
package/dist/ui.js
CHANGED
|
@@ -120,6 +120,8 @@ export function renderMyBookings(bookings, o) {
|
|
|
120
120
|
};
|
|
121
121
|
return `<section class="wb-booking-mine">${head}<ul class="wb-booking-items">${bookings.map(item).join("")}</ul>${book}</section>`;
|
|
122
122
|
}
|
|
123
|
+
/** Failures whose message is the database's or the settings check's own words: for the app's log, never for the page. */
|
|
124
|
+
const INTERNAL = new Set(["store_failed", "bad_config"]);
|
|
123
125
|
const STATUS = {
|
|
124
126
|
bad_config: 500,
|
|
125
127
|
bad_input: 400,
|
|
@@ -144,7 +146,8 @@ function failed(e, o) {
|
|
|
144
146
|
: e.code === "too_many"
|
|
145
147
|
? say("error.too_many", { max: o.max ?? 3 })
|
|
146
148
|
: say("error.failed");
|
|
147
|
-
|
|
149
|
+
const message = INTERNAL.has(e.code) ? "bookings: it failed on the app's side (the detail is in ActionResult.cause, for the log)" : e.message;
|
|
150
|
+
return { status: STATUS[e.code], body: { ok: false, error: e.code, message, text, ...(field ? { field } : {}) }, cause: e };
|
|
148
151
|
}
|
|
149
152
|
const str = (v) => (typeof v === "string" ? v : "");
|
|
150
153
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-bookings",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A bookings calendar for Workbench apps: customers pick a free time, book it with their name and email, and get a confirmation email with a calendar file, reminders before it starts and a private link to change or cancel. The owner gets an email for each booking, a list in the app and a calendar feed. Stored in the app's own database, with tick() from the app's cron for reminders. No AI.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|