@semics-tech/emdash-events 0.0.0-bootstrap.0 → 1.0.0-rc.0
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/LICENSE +21 -0
- package/README.md +82 -2
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +392 -0
- package/dist/manifest.json +401 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.mjs +7 -0
- package/dist/ts/astro/lib/call.d.ts +54 -0
- package/dist/ts/astro/lib/call.js +121 -0
- package/dist/ts/integration/index.d.ts +48 -0
- package/dist/ts/integration/index.js +76 -0
- package/dist/ts/ui/index.d.ts +6 -0
- package/dist/ts/ui/index.js +46 -0
- package/emdash-plugin.jsonc +206 -0
- package/package.json +79 -10
- package/src/astro/AddToCalendar.astro +47 -0
- package/src/astro/BookingBlock.astro +30 -0
- package/src/astro/BookingPage.astro +193 -0
- package/src/astro/BookingStatus.astro +106 -0
- package/src/astro/BookingWidget.astro +581 -0
- package/src/astro/CheckIn.astro +186 -0
- package/src/astro/DoorSignPage.astro +62 -0
- package/src/astro/EventCard.astro +81 -0
- package/src/astro/EventList.astro +83 -0
- package/src/astro/OptOutPage.astro +58 -0
- package/src/astro/PaymentReturn.astro +96 -0
- package/src/astro/TicketPass.astro +95 -0
- package/src/astro/checkout-endpoint.ts +11 -0
- package/src/astro/index.js +18 -0
- package/src/astro/lib/call.ts +185 -0
- package/src/astro/lib/checkout-form.ts +271 -0
- package/src/astro/lib/list.ts +99 -0
- package/src/astro/lib/opt-out.ts +49 -0
- package/src/astro/lib/pass.ts +35 -0
- package/src/astro/lib/payment.ts +73 -0
- package/src/astro/lib/promo.ts +162 -0
- package/src/astro/lib/questions.ts +107 -0
- package/src/astro/lib/receipt.ts +132 -0
- package/src/astro/lib/waitlist.ts +72 -0
- package/src/astro/lib/widget.ts +278 -0
- package/src/astro/promo-endpoint.ts +11 -0
- package/src/astro/virtual.d.ts +16 -0
- package/src/astro/waitlist-endpoint.ts +12 -0
- package/src/client/booking.ts +188 -0
- package/src/client/checkin.ts +260 -0
- package/src/client/payment.ts +76 -0
- package/src/client/receipt.ts +75 -0
- package/src/i18n/ar.ts +213 -0
- package/src/i18n/en.ts +219 -0
- package/src/i18n/index.ts +121 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { definePlugin } from "emdash";
|
|
2
|
+
const ID = "semics-events-ui";
|
|
3
|
+
const VERSION = "0.1.0";
|
|
4
|
+
/** Native UI plugin descriptor. Add to `plugins: [eventsUi()]` beside the sandboxed core. */
|
|
5
|
+
export function eventsUi() {
|
|
6
|
+
return {
|
|
7
|
+
id: ID,
|
|
8
|
+
version: VERSION,
|
|
9
|
+
entrypoint: "@semics-tech/emdash-events/ui",
|
|
10
|
+
componentsEntry: "@semics-tech/emdash-events/astro",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Runtime entry: no capabilities, storage, hooks or routes; it registers editor blocks only. */
|
|
14
|
+
export function createPlugin() {
|
|
15
|
+
return definePlugin({
|
|
16
|
+
id: ID,
|
|
17
|
+
version: VERSION,
|
|
18
|
+
admin: {
|
|
19
|
+
portableTextBlocks: [
|
|
20
|
+
{
|
|
21
|
+
type: "events-booking",
|
|
22
|
+
label: "Book an event",
|
|
23
|
+
icon: "code",
|
|
24
|
+
description: "A booking form for one event",
|
|
25
|
+
category: "Events",
|
|
26
|
+
fields: [
|
|
27
|
+
{ type: "text_input", action_id: "event", label: "Event (entry ID or slug)" },
|
|
28
|
+
{ type: "text_input", action_id: "heading", label: "Heading", initial_value: "Book tickets" },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "events-list",
|
|
33
|
+
label: "Events list",
|
|
34
|
+
icon: "code",
|
|
35
|
+
description: "A list of upcoming events",
|
|
36
|
+
category: "Events",
|
|
37
|
+
fields: [
|
|
38
|
+
{ type: "text_input", action_id: "heading", label: "Heading", initial_value: "Upcoming events" },
|
|
39
|
+
{ type: "number_input", action_id: "limit", label: "Number of events", initial_value: 3, min: 1, max: 20 },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export default createPlugin;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@emdash-cms/plugin-cli/schemas/emdash-plugin.schema.json",
|
|
3
|
+
|
|
4
|
+
"slug": "semics-events",
|
|
5
|
+
"publisher": "did:plc:mire6xkehfirmoj5pmpqgpvq",
|
|
6
|
+
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": { "name": "semics", "url": "https://semics.co.uk" },
|
|
9
|
+
"security": { "email": "security@semics.co.uk" },
|
|
10
|
+
"description": "Events bookings and ticketing for EmDash",
|
|
11
|
+
"repo": "https://github.com/semics-uk/emdash-plugins",
|
|
12
|
+
|
|
13
|
+
// Registry listing (T103): the package page's text and images. Not part of the trust contract.
|
|
14
|
+
// The images are made by apps/playground/e2e/t103-screenshots.spec.ts (T103_WRITE=1).
|
|
15
|
+
"name": "semics Events",
|
|
16
|
+
"keywords": ["events", "tickets", "bookings", "rsvp", "waitlist"],
|
|
17
|
+
"sections": {
|
|
18
|
+
"description": { "file": "listing/description.md" },
|
|
19
|
+
"installation": { "file": "listing/installation.md" },
|
|
20
|
+
"faq": { "file": "listing/faq.md" },
|
|
21
|
+
"security": { "file": "listing/security.md" }
|
|
22
|
+
},
|
|
23
|
+
"release": {
|
|
24
|
+
"requires": { "env:emdash": ">=1.2.0 <2" },
|
|
25
|
+
"artifacts": {
|
|
26
|
+
"icon": { "file": "listing/icon.png" },
|
|
27
|
+
"banner": { "file": "listing/banner.png" },
|
|
28
|
+
"screenshots": [
|
|
29
|
+
{ "file": "listing/screenshots/1-booking-form.png" },
|
|
30
|
+
{ "file": "listing/screenshots/2-events-list.png" }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// Trust contract (Free edition, BUILD-PLAN 3.1 and 13). Changing these between releases
|
|
36
|
+
// requires a version bump because installed users have consented to the old contract.
|
|
37
|
+
// content:read resolve events, and veto deleting an event that has bookings (spike S9)
|
|
38
|
+
// schema:read validate the collection field mapping
|
|
39
|
+
// email:send booking confirmations, reminders, waitlist offers
|
|
40
|
+
// network:request Cloudflare Turnstile verification, and nothing else
|
|
41
|
+
// Deliberately not requested: content:write, users:read.
|
|
42
|
+
"capabilities": ["content:read", "schema:read", "email:send", "network:request"],
|
|
43
|
+
"allowedHosts": ["challenges.cloudflare.com"],
|
|
44
|
+
|
|
45
|
+
// Keep in step with src/storage/schema.ts (a test compares them).
|
|
46
|
+
"storage": {
|
|
47
|
+
"event_configs": { "indexes": ["status", "salesEnd"] },
|
|
48
|
+
"occurrences": { "indexes": [["eventId", "startsAt"], "startsAt", "status"] },
|
|
49
|
+
"ticket_types": { "indexes": ["eventId"] },
|
|
50
|
+
"bookings": {
|
|
51
|
+
// ["ipHash", "createdAt"]: checkout's rate limit counts recent bookings per hashed IP (T047).
|
|
52
|
+
"indexes": [
|
|
53
|
+
"eventId",
|
|
54
|
+
"status",
|
|
55
|
+
"email",
|
|
56
|
+
"createdAt",
|
|
57
|
+
["status", "holdExpiresAt"],
|
|
58
|
+
["eventId", "status"],
|
|
59
|
+
["ipHash", "createdAt"]
|
|
60
|
+
],
|
|
61
|
+
"uniqueIndexes": ["ref"]
|
|
62
|
+
},
|
|
63
|
+
// id = "<provider>:<sessionId>", which gives webhook idempotency; no unique index needed.
|
|
64
|
+
"payments": { "indexes": ["bookingId"] },
|
|
65
|
+
"attendees": {
|
|
66
|
+
"indexes": ["bookingId", "eventId", "email", ["eventId", "checkedInAt"]],
|
|
67
|
+
"uniqueIndexes": ["code"]
|
|
68
|
+
},
|
|
69
|
+
// "email": deletion on request finds a person's waitlist entries (T081).
|
|
70
|
+
"waitlist": { "indexes": [["eventId", "status"], "offerExpiresAt", "email"] },
|
|
71
|
+
"promo_codes": { "indexes": ["eventId"], "uniqueIndexes": ["code"] },
|
|
72
|
+
"outbox": { "indexes": [["status", "nextAttemptAt"], "to"] }
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
"admin": {
|
|
76
|
+
// Block Kit pages and widget, answered by the private `admin` route (src/admin/pages.ts).
|
|
77
|
+
"pages": [
|
|
78
|
+
{ "path": "/bookings", "label": "Bookings", "icon": "ticket" },
|
|
79
|
+
{ "path": "/attendees", "label": "Attendees", "icon": "users" },
|
|
80
|
+
{ "path": "/events", "label": "Event editor", "icon": "calendar" },
|
|
81
|
+
{ "path": "/setup", "label": "Setup check", "icon": "gear" }
|
|
82
|
+
],
|
|
83
|
+
"widgets": [{ "id": "sales", "title": "Ticket sales", "size": "half" }],
|
|
84
|
+
// "Tickets & booking" panel on saved event entries (T043), answered by the private editor/tickets route.
|
|
85
|
+
// Scoped to the default events collection; it reads and writes plugin storage only, never the entry.
|
|
86
|
+
"editorPanels": [
|
|
87
|
+
{ "id": "tickets", "title": "Tickets & booking", "route": "editor/tickets", "collections": ["events"] }
|
|
88
|
+
],
|
|
89
|
+
// Secret fields are encrypted with EMDASH_ENCRYPTION_KEY (spike S8); saving one without it fails.
|
|
90
|
+
"settingsSchema": {
|
|
91
|
+
"eventsCollection": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"label": "Events collection",
|
|
94
|
+
"description": "Slug of the collection that holds your events.",
|
|
95
|
+
"default": "events"
|
|
96
|
+
},
|
|
97
|
+
"fieldStartsAt": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"label": "Start field",
|
|
100
|
+
"description": "Field that holds the start date and time.",
|
|
101
|
+
"default": "starts_at"
|
|
102
|
+
},
|
|
103
|
+
"fieldEndsAt": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"label": "End field",
|
|
106
|
+
"description": "Field that holds the end date and time.",
|
|
107
|
+
"default": "ends_at"
|
|
108
|
+
},
|
|
109
|
+
"fieldTimezone": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"label": "Timezone field",
|
|
112
|
+
"description": "Field that holds the IANA timezone, for example Europe/London.",
|
|
113
|
+
"default": "timezone"
|
|
114
|
+
},
|
|
115
|
+
"fieldVenue": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"label": "Venue field",
|
|
118
|
+
"description": "Field that holds the venue name or address.",
|
|
119
|
+
"default": "venue"
|
|
120
|
+
},
|
|
121
|
+
"holdMinutesFree": {
|
|
122
|
+
"type": "number",
|
|
123
|
+
"label": "Hold time, free tickets (minutes)",
|
|
124
|
+
"description": "How long a seat is held while a buyer completes a free checkout.",
|
|
125
|
+
"default": 15,
|
|
126
|
+
"min": 5,
|
|
127
|
+
"max": 60
|
|
128
|
+
},
|
|
129
|
+
"holdMinutesPaid": {
|
|
130
|
+
"type": "number",
|
|
131
|
+
"label": "Hold time, paid tickets (minutes)",
|
|
132
|
+
"description": "How long a seat is held during a paid checkout. Card processors need at least 30 minutes.",
|
|
133
|
+
"default": 35,
|
|
134
|
+
"min": 30,
|
|
135
|
+
"max": 60
|
|
136
|
+
},
|
|
137
|
+
"holdCeilingMinutes": {
|
|
138
|
+
"type": "number",
|
|
139
|
+
"label": "Maximum total hold (minutes)",
|
|
140
|
+
"description": "Each checkout step extends the hold, but never beyond this many minutes from the first hold.",
|
|
141
|
+
"default": 60,
|
|
142
|
+
"min": 15,
|
|
143
|
+
"max": 120
|
|
144
|
+
},
|
|
145
|
+
"cancelCutoffHours": {
|
|
146
|
+
"type": "number",
|
|
147
|
+
"label": "Self-service cancel cutoff (hours before start)",
|
|
148
|
+
"description": "Buyers can cancel a confirmed booking up to this many hours before the event starts.",
|
|
149
|
+
"default": 24,
|
|
150
|
+
"min": 0,
|
|
151
|
+
"max": 720
|
|
152
|
+
},
|
|
153
|
+
"currency": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"label": "Default currency",
|
|
156
|
+
"description": "Three-letter ISO 4217 code, for example GBP.",
|
|
157
|
+
"default": "GBP"
|
|
158
|
+
},
|
|
159
|
+
"turnstileSiteKey": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"label": "Turnstile site key",
|
|
162
|
+
"description": "Public site key of your Cloudflare Turnstile widget."
|
|
163
|
+
},
|
|
164
|
+
"turnstileSecretKey": {
|
|
165
|
+
"type": "secret",
|
|
166
|
+
"label": "Turnstile secret key",
|
|
167
|
+
"description": "Secret key used to verify bot checks. Stored encrypted."
|
|
168
|
+
},
|
|
169
|
+
"esignPairing": {
|
|
170
|
+
"type": "secret",
|
|
171
|
+
"label": "E-sign pairing string",
|
|
172
|
+
"description": "Pairing string from the e-sign plugin, for events that require signed waivers. Stored encrypted."
|
|
173
|
+
},
|
|
174
|
+
// Secrets an Events Pro build stores (T067). Declared here so a site switched back to Free can
|
|
175
|
+
// still read its settings: EmDash refuses to list an encrypted value the manifest does not
|
|
176
|
+
// declare as a secret. Free never reads them.
|
|
177
|
+
"licenceKey": {
|
|
178
|
+
"type": "secret",
|
|
179
|
+
"label": "Licence key (Pro)",
|
|
180
|
+
"description": "Used by Events Pro only; the Free edition ignores it. Stored encrypted."
|
|
181
|
+
},
|
|
182
|
+
"stripeSecretKey": {
|
|
183
|
+
"type": "secret",
|
|
184
|
+
"label": "Stripe secret key (Pro)",
|
|
185
|
+
"description": "Used by Events Pro only, for paid tickets; the Free edition ignores it. Stored encrypted."
|
|
186
|
+
},
|
|
187
|
+
"stripeWebhookSecret": {
|
|
188
|
+
"type": "secret",
|
|
189
|
+
"label": "Stripe webhook signing secret (Pro)",
|
|
190
|
+
"description": "Used by Events Pro only, for paid tickets; the Free edition ignores it. Stored encrypted."
|
|
191
|
+
},
|
|
192
|
+
"retentionDays": {
|
|
193
|
+
"type": "number",
|
|
194
|
+
"label": "Keep booking data (days)",
|
|
195
|
+
"description": "Personal data of past events is erased after this many days.",
|
|
196
|
+
"default": 365,
|
|
197
|
+
"min": 30
|
|
198
|
+
},
|
|
199
|
+
"emailSenderName": {
|
|
200
|
+
"type": "string",
|
|
201
|
+
"label": "Email sender name",
|
|
202
|
+
"description": "Name shown on booking emails. Defaults to the site name."
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "@semics-tech/emdash-events",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.mjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.mts"
|
|
10
|
+
},
|
|
11
|
+
"./sandbox": "./dist/plugin.mjs",
|
|
12
|
+
"./ui": {
|
|
13
|
+
"import": "./dist/ts/ui/index.js",
|
|
14
|
+
"types": "./dist/ts/ui/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./integration": {
|
|
17
|
+
"import": "./dist/ts/integration/index.js",
|
|
18
|
+
"types": "./dist/ts/integration/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./astro": "./src/astro/index.js",
|
|
21
|
+
"./astro/checkout-endpoint": "./src/astro/checkout-endpoint.ts",
|
|
22
|
+
"./astro/promo-endpoint": "./src/astro/promo-endpoint.ts",
|
|
23
|
+
"./astro/waitlist-endpoint": "./src/astro/waitlist-endpoint.ts",
|
|
24
|
+
"./astro/lib/*": "./src/astro/lib/*.ts",
|
|
25
|
+
"./i18n": "./src/i18n/index.ts",
|
|
26
|
+
"./client/*": "./src/client/*.ts",
|
|
27
|
+
"./astro/BookingPage.astro": "./src/astro/BookingPage.astro",
|
|
28
|
+
"./astro/DoorSignPage.astro": "./src/astro/DoorSignPage.astro",
|
|
29
|
+
"./astro/CheckIn.astro": "./src/astro/CheckIn.astro",
|
|
30
|
+
"./astro/OptOutPage.astro": "./src/astro/OptOutPage.astro",
|
|
31
|
+
"./astro/BookingWidget.astro": "./src/astro/BookingWidget.astro",
|
|
32
|
+
"./astro/BookingBlock.astro": "./src/astro/BookingBlock.astro",
|
|
33
|
+
"./astro/EventList.astro": "./src/astro/EventList.astro",
|
|
34
|
+
"./astro/EventCard.astro": "./src/astro/EventCard.astro",
|
|
35
|
+
"./astro/BookingStatus.astro": "./src/astro/BookingStatus.astro",
|
|
36
|
+
"./astro/PaymentReturn.astro": "./src/astro/PaymentReturn.astro",
|
|
37
|
+
"./astro/TicketPass.astro": "./src/astro/TicketPass.astro",
|
|
38
|
+
"./astro/AddToCalendar.astro": "./src/astro/AddToCalendar.astro"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"src/astro",
|
|
43
|
+
"src/i18n",
|
|
44
|
+
"src/client",
|
|
45
|
+
"emdash-plugin.jsonc"
|
|
46
|
+
],
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"emdash": ">=1.2.0 <2"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@emdash-cms/plugin-cli": "0.13.3",
|
|
52
|
+
"@emdash-cms/plugin-test": "0.2.8",
|
|
53
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
54
|
+
"emdash": "1.2.0",
|
|
55
|
+
"typescript": "^5.9.0",
|
|
56
|
+
"vitest": "^4.1.12",
|
|
57
|
+
"zod": "4.6.5",
|
|
58
|
+
"@semics-tech/shared": "0.0.1-rc.0"
|
|
59
|
+
},
|
|
60
|
+
"description": "Events bookings and ticketing for EmDash",
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "https://github.com/semics-uk/emdash-plugins",
|
|
65
|
+
"directory": "packages/events"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"validate": "emdash-plugin validate",
|
|
69
|
+
"build": "emdash-plugin build && tsc -p tsconfig.ui.json",
|
|
70
|
+
"dev": "emdash-plugin dev",
|
|
71
|
+
"typecheck": "tsc --noEmit",
|
|
72
|
+
"test:coverage": "vitest run --coverage --reporter=dot",
|
|
73
|
+
"test:verify": "vitest run --reporter=dot ${CI:+--coverage}",
|
|
74
|
+
"verify": "pnpm run validate && pnpm run typecheck && pnpm run test:verify && pnpm run build",
|
|
75
|
+
"test": "emdash-plugin validate && vitest run",
|
|
76
|
+
"bundle": "emdash-plugin bundle",
|
|
77
|
+
"login": "emdash-plugin login",
|
|
78
|
+
"release:setup": "emdash-plugin release setup"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <AddToCalendar>: a link to the core's calendar file (EU-FR-08). For a booking, pass the
|
|
3
|
+
// short-lived signed query the core issued (`signedQuery`); the access token is never in the URL,
|
|
4
|
+
// and an unsigned or expired query renders nothing. For an event, pass `event` (public data, no
|
|
5
|
+
// signature). The download is a plain link, so it works without JavaScript.
|
|
6
|
+
import { pluginId } from "virtual:semics-events/config";
|
|
7
|
+
|
|
8
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
9
|
+
import { bookingCalendarHref, eventCalendarHref } from "./lib/widget";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
signedQuery?: string;
|
|
13
|
+
event?: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
locale?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { signedQuery, event } = Astro.props;
|
|
19
|
+
const { t, lang, dir } = translator(pickLocale(Astro.props.locale, Astro.currentLocale));
|
|
20
|
+
const label = Astro.props.label ?? t("calendar.add");
|
|
21
|
+
const href = signedQuery
|
|
22
|
+
? bookingCalendarHref({ pluginId, query: signedQuery, now: Date.now() })
|
|
23
|
+
: event
|
|
24
|
+
? eventCalendarHref(pluginId, event)
|
|
25
|
+
: undefined;
|
|
26
|
+
---
|
|
27
|
+
{
|
|
28
|
+
href && (
|
|
29
|
+
<a class="semics-events semics-add-to-calendar" lang={lang} dir={dir} href={href} download="event.ics" rel="nofollow" data-testid="add-to-calendar">
|
|
30
|
+
{label} <span class="semics-ics-hint">{t("calendar.hint")}</span>
|
|
31
|
+
</a>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.semics-add-to-calendar {
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: 0.25rem;
|
|
40
|
+
min-block-size: 2.75rem;
|
|
41
|
+
color: var(--events-accent, #0b57d0);
|
|
42
|
+
text-decoration: underline;
|
|
43
|
+
}
|
|
44
|
+
.semics-ics-hint {
|
|
45
|
+
color: var(--events-muted, #4a4a4a);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
// The `events-booking` Portable Text block (BUILD-PLAN 3.3): renders <BookingWidget> for the event
|
|
3
|
+
// the editor picked. The block's `event` is the event entry's id or its slug; a slug is resolved to the
|
|
4
|
+
// entry id. A block with no event renders nothing.
|
|
5
|
+
import { getEmDashEntry } from "emdash";
|
|
6
|
+
|
|
7
|
+
import BookingWidget from "./BookingWidget.astro";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
node?: { event?: string; heading?: string };
|
|
11
|
+
event?: string;
|
|
12
|
+
heading?: string;
|
|
13
|
+
locale?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const props = Astro.props as Props;
|
|
17
|
+
const ref = (props.node?.event ?? props.event ?? "").trim();
|
|
18
|
+
const heading = props.node?.heading ?? props.heading;
|
|
19
|
+
let eventId = ref;
|
|
20
|
+
if (ref) {
|
|
21
|
+
try {
|
|
22
|
+
const { entry } = await getEmDashEntry("events", ref);
|
|
23
|
+
const id = (entry?.data as { id?: unknown } | undefined)?.id;
|
|
24
|
+
if (typeof id === "string" && id) eventId = id;
|
|
25
|
+
} catch {
|
|
26
|
+
// Not a slug of a known entry: treat the value as the entry id.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
---
|
|
30
|
+
{eventId && <BookingWidget event={eventId} heading={heading || undefined} locale={props.locale} />}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Injected at `/booking` by the integration. The booking ref is in the URL; the access token is
|
|
3
|
+
// only ever in the HttpOnly cookie the checkout endpoint set, and goes to the core in POST bodies.
|
|
4
|
+
// The emailed link (`?ref=&k=<one-time code>`, R34) renders an "Open my booking" button and
|
|
5
|
+
// redeems nothing: only its POST swaps the code for a token, sets the cookie and redirects to
|
|
6
|
+
// `?ref=` without `k`, so mail scanners that prefetch links cannot use the code up.
|
|
7
|
+
// It is also the waiver return page (EV-FR-12): e-sign sends the signer back to `?ref=#receipt=`;
|
|
8
|
+
// `src/client/receipt.ts` clears the fragment and posts the receipt here, which forwards it to the
|
|
9
|
+
// core's `signatures/receipt` (no access token needed: the receipt is HMAC-signed) and redirects to
|
|
10
|
+
// `?ref=&waiver=<outcome>`.
|
|
11
|
+
import { esignPluginId, pluginId, reconcile } from "virtual:semics-events/config";
|
|
12
|
+
|
|
13
|
+
import { type MessageKey, pickLocale, translator } from "../i18n/index";
|
|
14
|
+
import AddToCalendar from "./AddToCalendar.astro";
|
|
15
|
+
import BookingStatus from "./BookingStatus.astro";
|
|
16
|
+
import PaymentReturn from "./PaymentReturn.astro";
|
|
17
|
+
import { callPublicRoute } from "./lib/call";
|
|
18
|
+
import {
|
|
19
|
+
bookingCookieName,
|
|
20
|
+
bookingCookieOptions,
|
|
21
|
+
claimOfferLink,
|
|
22
|
+
crossSiteResponse,
|
|
23
|
+
isCrossSiteRequest,
|
|
24
|
+
LINK_INVALID,
|
|
25
|
+
OFFER_INVALID,
|
|
26
|
+
redeemBookingLink,
|
|
27
|
+
resumePayment,
|
|
28
|
+
} from "./lib/checkout-form";
|
|
29
|
+
import { paymentView } from "./lib/payment";
|
|
30
|
+
import { forwardReceipt } from "./lib/receipt";
|
|
31
|
+
import type { BookingView } from "./lib/widget";
|
|
32
|
+
import TicketPass from "./TicketPass.astro";
|
|
33
|
+
|
|
34
|
+
export const prerender = false;
|
|
35
|
+
|
|
36
|
+
Astro.response.headers.set("Referrer-Policy", "no-referrer");
|
|
37
|
+
Astro.response.headers.set("Cache-Control", "private, no-store");
|
|
38
|
+
|
|
39
|
+
// The page's language is the site's (Astro i18n), else British English (T102).
|
|
40
|
+
const locale = pickLocale(Astro.currentLocale);
|
|
41
|
+
const { t, lang, dir } = translator(locale);
|
|
42
|
+
const CODES = [
|
|
43
|
+
"SOLD_OUT",
|
|
44
|
+
"SALES_CLOSED",
|
|
45
|
+
"HOLD_EXPIRED",
|
|
46
|
+
"PAYMENT_FAILED",
|
|
47
|
+
"CANCEL_NOT_ALLOWED",
|
|
48
|
+
"BAD_REQUEST",
|
|
49
|
+
LINK_INVALID,
|
|
50
|
+
OFFER_INVALID,
|
|
51
|
+
];
|
|
52
|
+
const WAIVER_OUTCOMES = ["signed", "declined", "voided", "expired", "failed"];
|
|
53
|
+
const errorText = (code: string, fallback: MessageKey) =>
|
|
54
|
+
CODES.includes(code) ? t(`booking.error.${code}` as MessageKey) : t(fallback);
|
|
55
|
+
|
|
56
|
+
const url = Astro.url;
|
|
57
|
+
const rawRef = url.searchParams.get("ref") ?? "";
|
|
58
|
+
const ref = /^[0-9A-HJKMNP-TV-Z]{10}$/.test(rawRef) ? rawRef : "";
|
|
59
|
+
const errorCode = url.searchParams.get("error") ?? "";
|
|
60
|
+
const waiver = url.searchParams.get("waiver") ?? "";
|
|
61
|
+
const waiverNotice = WAIVER_OUTCOMES.includes(waiver) ? t(`booking.waiver.${waiver}` as MessageKey) : "";
|
|
62
|
+
let notice = errorCode ? errorText(errorCode, "booking.error.INTERNAL") : waiverNotice;
|
|
63
|
+
const code = url.searchParams.get("k") ?? "";
|
|
64
|
+
const ctx = { locals: Astro.locals, url, request: Astro.request };
|
|
65
|
+
// The cancel and redeem forms post here: refuse another site's posts (CSRF) before reading them.
|
|
66
|
+
if (isCrossSiteRequest(Astro.request, url)) return crossSiteResponse();
|
|
67
|
+
const form = Astro.request.method === "POST" ? await Astro.request.formData().catch(() => new FormData()) : undefined;
|
|
68
|
+
|
|
69
|
+
if (form?.get("intent") === "receipt") {
|
|
70
|
+
const result = await forwardReceipt(ctx, { ref: rawRef, receipt: form.get("receipt") }, { pluginId, esignPluginId });
|
|
71
|
+
return Astro.redirect(result.location, 303);
|
|
72
|
+
}
|
|
73
|
+
if (form?.get("intent") === "redeem") {
|
|
74
|
+
const k = form.get("k");
|
|
75
|
+
const result = await redeemBookingLink(ctx, { ref: rawRef, code: typeof k === "string" ? k : "" }, { pluginId });
|
|
76
|
+
if (result.cookie) Astro.cookies.set(result.cookie.name, result.cookie.value, bookingCookieOptions(url));
|
|
77
|
+
return Astro.redirect(result.location, 303);
|
|
78
|
+
}
|
|
79
|
+
if (form?.get("intent") === "claim") {
|
|
80
|
+
// A waitlist offer (T081): claimed only from this POST, like the booking link above.
|
|
81
|
+
const k = form.get("k");
|
|
82
|
+
const result = await claimOfferLink(ctx, { ref: rawRef, code: typeof k === "string" ? k : "" }, { pluginId });
|
|
83
|
+
if (result.cookie) Astro.cookies.set(result.cookie.name, result.cookie.value, bookingCookieOptions(url));
|
|
84
|
+
return Astro.redirect(result.location, 303);
|
|
85
|
+
}
|
|
86
|
+
if (form?.get("intent") === "resume") {
|
|
87
|
+
// "Pay now": the token is the cookie's, never a field; nothing Stripe appends to the URL is read.
|
|
88
|
+
const token = ref ? (Astro.cookies.get(bookingCookieName(ref))?.value ?? "") : "";
|
|
89
|
+
const result = await resumePayment(ctx, { ref: rawRef, token }, { pluginId });
|
|
90
|
+
return Astro.redirect(result.location, 303);
|
|
91
|
+
}
|
|
92
|
+
// An emailed link: show the button and touch nothing else (GET must not redeem).
|
|
93
|
+
const opening = Boolean(ref && code);
|
|
94
|
+
const offer = url.searchParams.get("offer") === "1";
|
|
95
|
+
const token = ref && !opening ? (Astro.cookies.get(bookingCookieName(ref))?.value ?? "") : "";
|
|
96
|
+
|
|
97
|
+
let cancelled = false;
|
|
98
|
+
if (ref && token && form) {
|
|
99
|
+
if (form.get("intent") === "cancel") {
|
|
100
|
+
const result = await callPublicRoute(ctx, {
|
|
101
|
+
method: "POST",
|
|
102
|
+
path: "public/booking/cancel",
|
|
103
|
+
pluginId,
|
|
104
|
+
body: { bookingRef: ref, accessToken: token },
|
|
105
|
+
});
|
|
106
|
+
if (result.ok) cancelled = true;
|
|
107
|
+
else notice = errorText(result.error.code, "booking.cancelFailed");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let booking: BookingView | undefined;
|
|
112
|
+
let missing = false;
|
|
113
|
+
if (ref && token) {
|
|
114
|
+
const result = await callPublicRoute<BookingView>(ctx, {
|
|
115
|
+
method: "POST",
|
|
116
|
+
path: "public/booking",
|
|
117
|
+
pluginId,
|
|
118
|
+
body: { bookingRef: ref, accessToken: token },
|
|
119
|
+
});
|
|
120
|
+
if (result.ok) booking = result.data;
|
|
121
|
+
else missing = true;
|
|
122
|
+
// A booking waiting for signatures is reconciled with e-sign (the suite supplies `reconcile`): a signer who
|
|
123
|
+
// closed the tab or signed by email has a receipt this page forwards, then it shows the booking afresh.
|
|
124
|
+
if (booking?.waiver?.lookups && reconcile && esignPluginId) {
|
|
125
|
+
const done = await reconcile(ctx, { booking, pluginId, esignPluginId });
|
|
126
|
+
if (done.forwarded > 0) {
|
|
127
|
+
const fresh = await callPublicRoute<BookingView>(ctx, {
|
|
128
|
+
method: "POST",
|
|
129
|
+
path: "public/booking",
|
|
130
|
+
pluginId,
|
|
131
|
+
body: { bookingRef: ref, accessToken: token },
|
|
132
|
+
});
|
|
133
|
+
if (fresh.ok) booking = fresh.data;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} else if (ref && !opening) {
|
|
137
|
+
missing = true;
|
|
138
|
+
}
|
|
139
|
+
const payment = booking && !cancelled ? paymentView(booking, locale) : null;
|
|
140
|
+
const passes = booking && !cancelled && booking.status === "confirmed" ? booking.attendees.filter((a) => a.code) : [];
|
|
141
|
+
---
|
|
142
|
+
<!doctype html>
|
|
143
|
+
<html lang={lang} dir={dir}>
|
|
144
|
+
<head>
|
|
145
|
+
<meta charset="utf-8" />
|
|
146
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
147
|
+
<meta name="robots" content="noindex" />
|
|
148
|
+
<meta name="referrer" content="no-referrer" />
|
|
149
|
+
<title>{t("booking.title")}</title>
|
|
150
|
+
</head>
|
|
151
|
+
<body>
|
|
152
|
+
<main class="semics-booking" data-testid="booking-page">
|
|
153
|
+
<h1>{t("booking.title")}</h1>
|
|
154
|
+
<form method="post" action={ref ? `/booking?ref=${ref}` : "/booking"} data-semics-fragment="receipt" hidden>
|
|
155
|
+
<input type="hidden" name="intent" value="receipt" />
|
|
156
|
+
<input type="hidden" name="receipt" value="" />
|
|
157
|
+
</form>
|
|
158
|
+
{notice && <p role="alert" data-testid="booking-notice" data-code={errorCode}>{notice}</p>}
|
|
159
|
+
{
|
|
160
|
+
opening ? (
|
|
161
|
+
<form method="post" action={`/booking?ref=${ref}`} class="semics-events semics-booking-open" data-testid="booking-open">
|
|
162
|
+
<input type="hidden" name="intent" value={offer ? "claim" : "redeem"} />
|
|
163
|
+
<input type="hidden" name="k" value={code} />
|
|
164
|
+
<p>{offer ? t("booking.offer.intro") : t("booking.open.intro")}</p>
|
|
165
|
+
<button type="submit">{offer ? t("booking.offer.button") : t("booking.open.button")}</button>
|
|
166
|
+
</form>
|
|
167
|
+
) : booking ? (
|
|
168
|
+
<>
|
|
169
|
+
<BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} locale={locale} />
|
|
170
|
+
{payment && <PaymentReturn view={payment} bookingRef={ref} action={`/booking?ref=${ref}`} locale={locale} />}
|
|
171
|
+
{passes.length > 0 && (
|
|
172
|
+
<section aria-labelledby="semics-passes-title">
|
|
173
|
+
<h2 id="semics-passes-title">{t("booking.passes")}</h2>
|
|
174
|
+
{passes.map((a) => (
|
|
175
|
+
<TicketPass name={a.name} code={a.code ?? ""} status={a.status} qr={a.qr} locale={locale} />
|
|
176
|
+
))}
|
|
177
|
+
</section>
|
|
178
|
+
)}
|
|
179
|
+
{!cancelled && booking.status === "confirmed" && <AddToCalendar signedQuery={booking.calendar?.query} locale={locale} />}
|
|
180
|
+
</>
|
|
181
|
+
) : missing ? (
|
|
182
|
+
<p data-testid="booking-missing">{t("booking.missing")}</p>
|
|
183
|
+
) : !notice ? (
|
|
184
|
+
<p data-testid="booking-empty">{t("booking.empty")}</p>
|
|
185
|
+
) : null
|
|
186
|
+
}
|
|
187
|
+
</main>
|
|
188
|
+
<script>
|
|
189
|
+
import "../client/receipt.ts";
|
|
190
|
+
import "../client/payment.ts";
|
|
191
|
+
</script>
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|