@aglyn/plugins-bookings 1.0.0-beta.264 → 1.0.0-beta.268
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-bookings",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.268",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,21 +25,21 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-snackstack": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-util-email": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-util-timestamp": "1.0.0-beta.
|
|
35
|
-
"@aglyn/tenant-data-admin": "1.0.0-beta.
|
|
36
|
-
"@aglyn/tenant-feature-instance": "1.0.0-beta.
|
|
37
|
-
"@aglyn/tenant-runtime": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.268",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.268",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.268",
|
|
31
|
+
"@aglyn/shared-ui-snackstack": "1.0.0-beta.268",
|
|
32
|
+
"@aglyn/shared-util-email": "1.0.0-beta.268",
|
|
33
|
+
"@aglyn/shared-util-http": "1.0.0-beta.268",
|
|
34
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.268",
|
|
35
|
+
"@aglyn/tenant-data-admin": "1.0.0-beta.268",
|
|
36
|
+
"@aglyn/tenant-feature-instance": "1.0.0-beta.268",
|
|
37
|
+
"@aglyn/tenant-runtime": "1.0.0-beta.268",
|
|
38
38
|
"@swc/helpers": "0.5.23"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@mui/material": "^9.3.1",
|
|
42
|
-
"firebase": "^
|
|
42
|
+
"firebase": "^13.0.0",
|
|
43
43
|
"firebase-admin": "^14.3.0",
|
|
44
44
|
"next": "^16.3.3",
|
|
45
45
|
"react": "^19.2.8"
|
|
@@ -16,6 +16,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/ import { hostRoleCanWrite } from "@aglyn/aglyn/app-utils/organizations";
|
|
18
18
|
import { checkEntitlement, checkQuota } from "@aglyn/aglyn/app-utils/plan-entitlements";
|
|
19
|
+
import { countLiveDocuments } from "@aglyn/aglyn/app-utils/live-document-count";
|
|
19
20
|
import { registerPluginResourceDraftWriter } from "@aglyn/aglyn/plugin-manager/plugin-resource-drafts";
|
|
20
21
|
import { isValidTimeZone } from "@aglyn/shared-util-timestamp/zoned-time";
|
|
21
22
|
import { firebaseAdmin } from "@aglyn/tenant-data-admin";
|
|
@@ -240,7 +241,7 @@ export function createBookingServiceDraftWriter(deps = {}) {
|
|
|
240
241
|
};
|
|
241
242
|
const early = (_roleRefusal = roleRefusal(host, context.uid)) != null ? _roleRefusal : planRefusal(context.org);
|
|
242
243
|
if (early) return early;
|
|
243
|
-
const used =
|
|
244
|
+
const used = await countLiveDocuments(hostRef.collection('services'));
|
|
244
245
|
return roomRefusal(context.org, Number(used) || 0);
|
|
245
246
|
},
|
|
246
247
|
check: (content)=>checkBookingServiceContent(content),
|
|
@@ -284,7 +285,7 @@ export function createBookingServiceDraftWriter(deps = {}) {
|
|
|
284
285
|
if (early) return _extends({
|
|
285
286
|
ok: false
|
|
286
287
|
}, early);
|
|
287
|
-
const used =
|
|
288
|
+
const used = await countLiveDocuments(servicesRef, (aggregate)=>tx.get(aggregate));
|
|
288
289
|
const room = roomRefusal(request.org, Number(used) || 0);
|
|
289
290
|
if (room) return _extends({
|
|
290
291
|
ok: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/server/booking-service-drafts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { hostRoleCanWrite } from '@aglyn/aglyn/app-utils/organizations'\nimport { checkEntitlement, checkQuota } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport {\n registerPluginResourceDraftWriter,\n type PluginDraftCheck,\n type PluginDraftContext,\n type PluginDraftRecord,\n type PluginDraftRefusal,\n type PluginDraftWrite,\n type PluginResourceDraftWriter,\n} from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts'\nimport { isValidTimeZone } from '@aglyn/shared-util-timestamp/zoned-time'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { BOOKING_FIELD_ASKS, type BookingFieldAsk } from '../model/booking-contact-fields'\nimport {\n BOOKING_PRICE_DISPLAYS,\n type BookingPriceDisplay,\n bookingPriceText,\n} from '../model/booking-price'\nimport {\n BOOKING_MAX_DURATION_MINUTES,\n BOOKING_MIN_DURATION_MINUTES,\n type HostBookingService,\n} from '../model/bookings'\n\n/**\n * A BOOKING SERVICE ANOTHER PLUGIN ASKS FOR (AGL-3616).\n *\n * The draft writer this plugin registers for the `booking-service` resource\n * on the core's resource-drafts seam. A plugin that sets a site up from a\n * brief asks for the writer by name and gets this plugin's rules:\n *\n * - THE DOCUMENT is a `hosts/{hostId}/services/{id}` service in the shape\n * the console's service dialog saves, born `status: 'draft'`. A draft is\n * offered nowhere — not in the Booking block's list, not by its slots, not\n * by the booking route — until a person activates it on the Bookings page.\n * - THE ROOM is the `servicesPerHost` allowance, counted the way the\n * resources route counts it and inside the transaction that creates, so\n * two writes at once cannot both take the last slot. Free includes none.\n * - THE PLAN is the `bookings` feature, and THE ROLE is a member who may\n * write the site's content — the resources route's two gates, refused in\n * its words.\n * - THE PRICE is a label (`contact`, `varies`, `estimate`) unless the\n * content states a fixed price, so nothing the caller did not say is\n * charged. No price stated and no label asked for is `contact`.\n *\n * Nothing is published or charged. The writer touches the one new document.\n */\n\ntype Firestore = FirebaseFirestore.Firestore\n\n/** The resource name this writer is registered under. */\nexport const BOOKING_SERVICE_DRAFT_RESOURCE = 'booking-service'\n\n/** The longest name the console's dialog keeps. */\nexport const BOOKING_SERVICE_NAME_MAX = 80\n/** The longest description the console's dialog keeps. */\nexport const BOOKING_SERVICE_DESCRIPTION_MAX = 500\n/** The most open intervals one weekday holds. */\nexport const BOOKING_SERVICE_WINDOWS_PER_DAY_MAX = 12\n/** The highest fixed price a draft may state, in whole dollars. */\nexport const BOOKING_SERVICE_PRICE_MAX_USD = 100_000\n\n/** The resources route's refusal for a member who may not write the site. */\nexport const BOOKING_SERVICE_ROLE_REFUSAL = 'Editing requires the editor role'\n/** The resources route's refusal for a plan without the feature. */\nexport const BOOKING_SERVICE_PLAN_REFUSAL =\n 'This feature is not included in your plan — see Billing'\n\n/** The resources route's refusal at the plan's allowance. */\nexport function bookingServiceLimitRefusal(limit: number): string {\n return `Your plan includes ${limit} ${limit === 1 ? 'service' : 'services'} — ` +\n 'upgrade in Billing for more'\n}\n\n/**\n * What a caller sends as `content`. `windows` is keyed by weekday\n * (0 = Sunday … 6 = Saturday), each a list of `{ start, end }` in minutes\n * since midnight in `timezone`. `priceUsd` is read only with\n * `priceDisplay: 'fixed'`, which needs it.\n */\nexport interface BookingServiceDraftContent {\n name: string\n durationMinutes: number\n description?: string\n windows: Partial<Record<number, Array<{ start: number; end: number }>>>\n timezone: string\n priceDisplay?: BookingPriceDisplay\n priceUsd?: number\n askPhone?: BookingFieldAsk\n askAddress?: BookingFieldAsk\n crmFollowUpTask?: boolean\n crmMeetingActivity?: boolean\n}\n\n/** The service document's editable fields, as the writer stores them. */\nexport type BookingServiceDraftFields = Required<\n Pick<HostBookingService, 'name' | 'durationMinutes' | 'windows' | 'timezone' | 'priceDisplay' | 'priceUsd' | 'askPhone' | 'askAddress' | 'crmFollowUpTask' | 'crmMeetingActivity'>\n> &\n Pick<HostBookingService, 'description'>\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Text on one line: controls and runs of space folded to one space. */\nfunction line(value: unknown): string {\n return typeof value === 'string' ? value.replace(/[\\p{Cc}\\s]+/gu, ' ').trim() : ''\n}\n\n/** The weekly windows, or what is wrong with them. */\nfunction readWindows(\n value: unknown,\n problems: string[],\n): BookingServiceDraftFields['windows'] {\n const windows: BookingServiceDraftFields['windows'] = {}\n if (!isRecord(value)) {\n problems.push('The service needs weekly hours: at least one open window on one weekday')\n return windows\n }\n for (const [key, raw] of Object.entries(value)) {\n const weekday = Number(key)\n if (!/^[0-6]$/.test(key) || !Number.isInteger(weekday)) {\n problems.push(`\"${key}\" is not a weekday: weekdays are 0 (Sunday) to 6 (Saturday)`)\n continue\n }\n if (!Array.isArray(raw)) {\n problems.push(`The hours for weekday ${key} are not a list of windows`)\n continue\n }\n if (!raw.length) continue\n if (raw.length > BOOKING_SERVICE_WINDOWS_PER_DAY_MAX) {\n problems.push(`Weekday ${key} has more than ${BOOKING_SERVICE_WINDOWS_PER_DAY_MAX} windows`)\n continue\n }\n const day: Array<{ start: number; end: number }> = []\n for (const window of raw) {\n const start = isRecord(window) ? window['start'] : undefined\n const end = isRecord(window) ? window['end'] : undefined\n if (\n typeof start !== 'number' ||\n typeof end !== 'number' ||\n !Number.isInteger(start) ||\n !Number.isInteger(end) ||\n start < 0 ||\n end > 24 * 60 ||\n end <= start\n ) {\n problems.push(\n `A window on weekday ${key} is not a start before its end, in whole minutes from 0 to 1440`,\n )\n continue\n }\n day.push({ start, end })\n }\n day.sort((a, b) => a.start - b.start)\n if (day.some((window, index) => index > 0 && window.start < day[index - 1].end)) {\n problems.push(`Two windows on weekday ${key} overlap`)\n }\n if (day.length) windows[weekday] = day\n }\n if (!Object.keys(windows).length && !problems.length) {\n problems.push('The service needs weekly hours: at least one open window on one weekday')\n }\n return windows\n}\n\nfunction readAsk(label: string, value: unknown, problems: string[]): BookingFieldAsk {\n if (value === undefined) return 'off'\n if ((BOOKING_FIELD_ASKS as readonly unknown[]).includes(value)) return value as BookingFieldAsk\n problems.push(`Asking for ${label} is off, optional or required`)\n return 'off'\n}\n\nfunction readSwitch(label: string, value: unknown, fallback: boolean, problems: string[]): boolean {\n if (value === undefined) return fallback\n if (typeof value === 'boolean') return value\n problems.push(`${label} is on or off`)\n return fallback\n}\n\nexport type BookingServiceContentRead =\n | { ok: true; value: BookingServiceDraftFields }\n | { ok: false; problems: string[] }\n\n/** The content as the writer stores it, or every problem that stops it. */\nexport function readBookingServiceContent(\n content: Readonly<Record<string, unknown>>,\n): BookingServiceContentRead {\n const problems: string[] = []\n const name = line(content['name'])\n if (!name) problems.push('The service needs a name')\n else if (name.length > BOOKING_SERVICE_NAME_MAX) {\n problems.push(`The name is longer than ${BOOKING_SERVICE_NAME_MAX} characters`)\n }\n const duration = content['durationMinutes']\n if (\n typeof duration !== 'number' ||\n !Number.isInteger(duration) ||\n duration < BOOKING_MIN_DURATION_MINUTES ||\n duration > BOOKING_MAX_DURATION_MINUTES\n ) {\n problems.push(\n `The length is whole minutes from ${BOOKING_MIN_DURATION_MINUTES} to ${BOOKING_MAX_DURATION_MINUTES}`,\n )\n }\n const rawDescription = content['description']\n const description = typeof rawDescription === 'string' ? rawDescription.trim() : ''\n if (rawDescription !== undefined && typeof rawDescription !== 'string') {\n problems.push('The description is text')\n } else if (description.length > BOOKING_SERVICE_DESCRIPTION_MAX) {\n problems.push(`The description is longer than ${BOOKING_SERVICE_DESCRIPTION_MAX} characters`)\n }\n const timezone = line(content['timezone'])\n if (!isValidTimeZone(timezone)) {\n problems.push('The time zone is an IANA zone, such as America/Chicago')\n }\n const windows = readWindows(content['windows'], problems)\n\n // No price stated and no label asked for is \"Contact for price\": a draft\n // never charges what the caller did not say.\n const rawPrice = content['priceUsd']\n const askedDisplay = content['priceDisplay']\n let priceDisplay: BookingPriceDisplay = 'contact'\n let priceUsd = 0\n if (askedDisplay !== undefined) {\n if ((BOOKING_PRICE_DISPLAYS as readonly unknown[]).includes(askedDisplay)) {\n priceDisplay = askedDisplay as BookingPriceDisplay\n } else {\n problems.push('The price is stated as fixed, varies, estimate or contact')\n }\n } else if (rawPrice !== undefined) {\n priceDisplay = 'fixed'\n }\n if (priceDisplay === 'fixed') {\n if (\n typeof rawPrice !== 'number' ||\n !Number.isInteger(rawPrice) ||\n rawPrice < 0 ||\n rawPrice > BOOKING_SERVICE_PRICE_MAX_USD\n ) {\n problems.push(\n `A fixed price is whole dollars from 0 to ${BOOKING_SERVICE_PRICE_MAX_USD}; ` +\n 'state it, or say the price varies, is a free estimate, or is on request',\n )\n } else {\n priceUsd = rawPrice\n }\n }\n const askPhone = readAsk('a phone number', content['askPhone'], problems)\n const askAddress = readAsk('an address', content['askAddress'], problems)\n // The model's defaults: a booking files a meeting, and owes no follow-up.\n const crmMeetingActivity = readSwitch('Filing a meeting', content['crmMeetingActivity'], true, problems)\n const crmFollowUpTask = readSwitch('A follow-up task', content['crmFollowUpTask'], false, problems)\n if (problems.length) return { ok: false, problems: [...new Set(problems)] }\n return {\n ok: true,\n value: {\n name,\n durationMinutes: duration as number,\n ...(description ? { description } : {}),\n windows,\n timezone,\n priceDisplay,\n priceUsd,\n askPhone,\n askAddress,\n crmMeetingActivity,\n crmFollowUpTask,\n },\n }\n}\n\n/** What a caller is told about a service, written or about to be. */\nfunction factsOf(value: Pick<HostBookingService, 'durationMinutes' | 'priceUsd' | 'priceDisplay' | 'timezone' | 'windows'>) {\n return {\n status: 'draft',\n durationMinutes: value.durationMinutes,\n priceDisplay: value.priceDisplay ?? 'fixed',\n priceText: bookingPriceText(value),\n timezone: value.timezone ?? 'UTC',\n openWeekdays: Object.keys(value.windows ?? {})\n .map(Number)\n .sort((a, b) => a - b),\n }\n}\n\n/** Whether content is a service this plugin would store, with what it says about it. Pure. */\nexport function checkBookingServiceContent(\n content: Readonly<Record<string, unknown>>,\n): PluginDraftCheck {\n const read = readBookingServiceContent(content)\n if (read.ok === false) return read\n return { ok: true, facts: factsOf(read.value) }\n}\n\nfunction recordOf(service: FirebaseFirestore.DocumentSnapshot): PluginDraftRecord {\n const data = (service.data() ?? {}) as HostBookingService\n return {\n id: service.id,\n name: String(data.name ?? ''),\n versionId: null,\n facts: { ...factsOf(data), status: data.status === 'draft' ? 'draft' : 'active' },\n }\n}\n\nfunction roleRefusal(host: FirebaseFirestore.DocumentSnapshot, uid: string): PluginDraftRefusal | null {\n const role = (host.get('memberRoles') ?? {})[uid]\n return hostRoleCanWrite(role) ? null : { status: 403, error: BOOKING_SERVICE_ROLE_REFUSAL }\n}\n\nfunction planRefusal(org: PluginDraftContext['org']): PluginDraftRefusal | null {\n return checkEntitlement(org as never, 'bookings')\n ? null\n : { status: 403, error: BOOKING_SERVICE_PLAN_REFUSAL }\n}\n\n/**\n * The allowance, counted as `/api/hosts/resources` counts a service create:\n * every document in the collection.\n */\nfunction roomRefusal(org: PluginDraftContext['org'], used: number): PluginDraftRefusal | null {\n const quota = checkQuota(org as never, 'servicesPerHost', used)\n return quota.allowed ? null : { status: 403, error: bookingServiceLimitRefusal(quota.limit) }\n}\n\nexport interface BookingServiceDraftWriterDeps {\n /** The Admin SDK handle; specs hand in a double. */\n firestore?: () => Firestore\n}\n\nexport function createBookingServiceDraftWriter(\n deps: BookingServiceDraftWriterDeps = {},\n): PluginResourceDraftWriter {\n const firestore = deps.firestore ?? (() => firebaseAdmin.app().firestore() as unknown as Firestore)\n return {\n refusal: async (context) => {\n const hostRef = firestore().collection('hosts').doc(context.hostId)\n const host = await hostRef.get()\n if (!host.exists) return { status: 404, error: 'Unknown site' }\n const early = roleRefusal(host, context.uid) ?? planRefusal(context.org)\n if (early) return early\n const used = (await hostRef.collection('services').count().get()).data().count\n return roomRefusal(context.org, Number(used) || 0)\n },\n\n check: (content) => checkBookingServiceContent(content),\n\n read: async ({ hostId, id }) => {\n const service = await firestore()\n .collection('hosts')\n .doc(hostId)\n .collection('services')\n .doc(id)\n .get()\n return service.exists ? recordOf(service) : null\n },\n\n write: async (request): Promise<PluginDraftWrite> => {\n // The request's name is the one asked for; the content's stands in.\n const asked = line(request.name)\n const read = readBookingServiceContent(asked ? { ...request.content, name: asked } : request.content)\n if (read.ok === false) return { ok: false, status: 400, error: read.problems[0] }\n const db = firestore()\n const hostRef = db.collection('hosts').doc(request.hostId)\n const servicesRef = hostRef.collection('services')\n const serviceRef = servicesRef.doc(request.id)\n return db.runTransaction(async (tx): Promise<PluginDraftWrite> => {\n // Every read before any write, which Firestore requires.\n const [host, existing] = await Promise.all([tx.get(hostRef), tx.get(serviceRef)])\n if (!host.exists) return { ok: false, status: 404, error: 'Unknown site' }\n // Asked again under the same id: the draft it already wrote.\n if (existing.exists) return { ok: true, replayed: true, ...recordOf(existing) }\n const early = roleRefusal(host, request.uid) ?? planRefusal(request.org)\n if (early) return { ok: false, ...early }\n const used = (await tx.get(servicesRef.count())).data().count\n const room = roomRefusal(request.org, Number(used) || 0)\n if (room) return { ok: false, ...room }\n tx.create(serviceRef, {\n ...read.value,\n status: 'draft',\n createdAt: request.now,\n updatedAt: request.now,\n createdBy: request.uid,\n })\n return {\n ok: true,\n replayed: false,\n id: request.id,\n name: read.value.name,\n versionId: null,\n facts: factsOf(read.value),\n }\n })\n },\n }\n}\n\nexport const bookingServiceDraftWriter = createBookingServiceDraftWriter()\n\n/**\n * Registers the writer; the console surface calls it, since only the console\n * runs AI jobs (AGL-3026). Idempotent: a second call replaces the first.\n */\nexport function registerBookingServiceDraftWriter(): void {\n registerPluginResourceDraftWriter(BOOKING_SERVICE_DRAFT_RESOURCE, bookingServiceDraftWriter, {\n pluginId: BUNDLE_ID,\n })\n}\n"],"names":["hostRoleCanWrite","checkEntitlement","checkQuota","registerPluginResourceDraftWriter","isValidTimeZone","firebaseAdmin","BUNDLE_ID","BOOKING_FIELD_ASKS","BOOKING_PRICE_DISPLAYS","bookingPriceText","BOOKING_MAX_DURATION_MINUTES","BOOKING_MIN_DURATION_MINUTES","BOOKING_SERVICE_DRAFT_RESOURCE","BOOKING_SERVICE_NAME_MAX","BOOKING_SERVICE_DESCRIPTION_MAX","BOOKING_SERVICE_WINDOWS_PER_DAY_MAX","BOOKING_SERVICE_PRICE_MAX_USD","BOOKING_SERVICE_ROLE_REFUSAL","BOOKING_SERVICE_PLAN_REFUSAL","bookingServiceLimitRefusal","limit","isRecord","value","Array","isArray","line","replace","trim","readWindows","problems","windows","push","key","raw","Object","entries","weekday","Number","test","isInteger","length","day","window","start","undefined","end","sort","a","b","some","index","keys","readAsk","label","includes","readSwitch","fallback","readBookingServiceContent","content","name","duration","rawDescription","description","timezone","rawPrice","askedDisplay","priceDisplay","priceUsd","askPhone","askAddress","crmMeetingActivity","crmFollowUpTask","ok","Set","durationMinutes","factsOf","status","priceText","openWeekdays","map","checkBookingServiceContent","read","facts","recordOf","service","data","id","String","versionId","roleRefusal","host","uid","role","get","error","planRefusal","org","roomRefusal","used","quota","allowed","createBookingServiceDraftWriter","deps","firestore","app","refusal","context","hostRef","collection","doc","hostId","exists","early","count","check","write","request","asked","db","servicesRef","serviceRef","runTransaction","tx","existing","Promise","all","replayed","room","create","createdAt","now","updatedAt","createdBy","bookingServiceDraftWriter","registerBookingServiceDraftWriter","pluginId"],"mappings":";AAAA;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Ae;gBACzE,6DAA6D;gBAC7D,IAAI6B,SAASZ,MAAM,EAAE,OAAO;oBAAEvC,IAAI;oBAAMsD,UAAU;mBAAS3C,SAASwC;gBACpE,MAAMX,SAAQvB,eAAAA,YAAYC,MAAM0B,QAAQzB,GAAG,aAA7BF,eAAkCM,YAAYqB,QAAQpB,GAAG;gBACvE,IAAIgB,OAAO,OAAO;oBAAExC,IAAI;mBAAUwC;gBAClC,MAAMd,OAAO,AAAC,CAAA,MAAMwB,GAAG7B,GAAG,CAAC0B,YAAYN,KAAK,GAAE,EAAG5B,IAAI,GAAG4B,KAAK;gBAC7D,MAAMc,OAAO9B,YAAYmB,QAAQpB,GAAG,EAAE3D,OAAO6D,SAAS;gBACtD,IAAI6B,MAAM,OAAO;oBAAEvD,IAAI;mBAAUuD;gBACjCL,GAAGM,MAAM,CAACR,YAAY,aACjBvC,KAAK3D,KAAK;oBACbsD,QAAQ;oBACRqD,WAAWb,QAAQc,GAAG;oBACtBC,WAAWf,QAAQc,GAAG;oBACtBE,WAAWhB,QAAQzB,GAAG;;gBAExB,OAAO;oBACLnB,IAAI;oBACJsD,UAAU;oBACVxC,IAAI8B,QAAQ9B,EAAE;oBACd3B,MAAMsB,KAAK3D,KAAK,CAACqC,IAAI;oBACrB6B,WAAW;oBACXN,OAAOP,QAAQM,KAAK3D,KAAK;gBAC3B;YACF;QACF;IACF;AACF;AAEA,OAAO,MAAM+G,4BAA4BhC,kCAAiC;AAE1E;;;CAGC,GACD,OAAO,SAASiC;IACdnI,kCAAkCS,gCAAgCyH,2BAA2B;QAC3FE,UAAUjI;IACZ;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/bookings/src/lib/server/booking-service-drafts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { hostRoleCanWrite } from '@aglyn/aglyn/app-utils/organizations'\nimport { checkEntitlement, checkQuota } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport { countLiveDocuments } from '@aglyn/aglyn/app-utils/live-document-count'\nimport {\n registerPluginResourceDraftWriter,\n type PluginDraftCheck,\n type PluginDraftContext,\n type PluginDraftRecord,\n type PluginDraftRefusal,\n type PluginDraftWrite,\n type PluginResourceDraftWriter,\n} from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts'\nimport { isValidTimeZone } from '@aglyn/shared-util-timestamp/zoned-time'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { BOOKING_FIELD_ASKS, type BookingFieldAsk } from '../model/booking-contact-fields'\nimport {\n BOOKING_PRICE_DISPLAYS,\n type BookingPriceDisplay,\n bookingPriceText,\n} from '../model/booking-price'\nimport {\n BOOKING_MAX_DURATION_MINUTES,\n BOOKING_MIN_DURATION_MINUTES,\n type HostBookingService,\n} from '../model/bookings'\n\n/**\n * A BOOKING SERVICE ANOTHER PLUGIN ASKS FOR (AGL-3616).\n *\n * The draft writer this plugin registers for the `booking-service` resource\n * on the core's resource-drafts seam. A plugin that sets a site up from a\n * brief asks for the writer by name and gets this plugin's rules:\n *\n * - THE DOCUMENT is a `hosts/{hostId}/services/{id}` service in the shape\n * the console's service dialog saves, born `status: 'draft'`. A draft is\n * offered nowhere — not in the Booking block's list, not by its slots, not\n * by the booking route — until a person activates it on the Bookings page.\n * - THE ROOM is the `servicesPerHost` allowance, counted the way the\n * resources route counts it and inside the transaction that creates, so\n * two writes at once cannot both take the last slot. Free includes none.\n * - THE PLAN is the `bookings` feature, and THE ROLE is a member who may\n * write the site's content — the resources route's two gates, refused in\n * its words.\n * - THE PRICE is a label (`contact`, `varies`, `estimate`) unless the\n * content states a fixed price, so nothing the caller did not say is\n * charged. No price stated and no label asked for is `contact`.\n *\n * Nothing is published or charged. The writer touches the one new document.\n */\n\ntype Firestore = FirebaseFirestore.Firestore\n\n/** The resource name this writer is registered under. */\nexport const BOOKING_SERVICE_DRAFT_RESOURCE = 'booking-service'\n\n/** The longest name the console's dialog keeps. */\nexport const BOOKING_SERVICE_NAME_MAX = 80\n/** The longest description the console's dialog keeps. */\nexport const BOOKING_SERVICE_DESCRIPTION_MAX = 500\n/** The most open intervals one weekday holds. */\nexport const BOOKING_SERVICE_WINDOWS_PER_DAY_MAX = 12\n/** The highest fixed price a draft may state, in whole dollars. */\nexport const BOOKING_SERVICE_PRICE_MAX_USD = 100_000\n\n/** The resources route's refusal for a member who may not write the site. */\nexport const BOOKING_SERVICE_ROLE_REFUSAL = 'Editing requires the editor role'\n/** The resources route's refusal for a plan without the feature. */\nexport const BOOKING_SERVICE_PLAN_REFUSAL =\n 'This feature is not included in your plan — see Billing'\n\n/** The resources route's refusal at the plan's allowance. */\nexport function bookingServiceLimitRefusal(limit: number): string {\n return `Your plan includes ${limit} ${limit === 1 ? 'service' : 'services'} — ` +\n 'upgrade in Billing for more'\n}\n\n/**\n * What a caller sends as `content`. `windows` is keyed by weekday\n * (0 = Sunday … 6 = Saturday), each a list of `{ start, end }` in minutes\n * since midnight in `timezone`. `priceUsd` is read only with\n * `priceDisplay: 'fixed'`, which needs it.\n */\nexport interface BookingServiceDraftContent {\n name: string\n durationMinutes: number\n description?: string\n windows: Partial<Record<number, Array<{ start: number; end: number }>>>\n timezone: string\n priceDisplay?: BookingPriceDisplay\n priceUsd?: number\n askPhone?: BookingFieldAsk\n askAddress?: BookingFieldAsk\n crmFollowUpTask?: boolean\n crmMeetingActivity?: boolean\n}\n\n/** The service document's editable fields, as the writer stores them. */\nexport type BookingServiceDraftFields = Required<\n Pick<HostBookingService, 'name' | 'durationMinutes' | 'windows' | 'timezone' | 'priceDisplay' | 'priceUsd' | 'askPhone' | 'askAddress' | 'crmFollowUpTask' | 'crmMeetingActivity'>\n> &\n Pick<HostBookingService, 'description'>\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Text on one line: controls and runs of space folded to one space. */\nfunction line(value: unknown): string {\n return typeof value === 'string' ? value.replace(/[\\p{Cc}\\s]+/gu, ' ').trim() : ''\n}\n\n/** The weekly windows, or what is wrong with them. */\nfunction readWindows(\n value: unknown,\n problems: string[],\n): BookingServiceDraftFields['windows'] {\n const windows: BookingServiceDraftFields['windows'] = {}\n if (!isRecord(value)) {\n problems.push('The service needs weekly hours: at least one open window on one weekday')\n return windows\n }\n for (const [key, raw] of Object.entries(value)) {\n const weekday = Number(key)\n if (!/^[0-6]$/.test(key) || !Number.isInteger(weekday)) {\n problems.push(`\"${key}\" is not a weekday: weekdays are 0 (Sunday) to 6 (Saturday)`)\n continue\n }\n if (!Array.isArray(raw)) {\n problems.push(`The hours for weekday ${key} are not a list of windows`)\n continue\n }\n if (!raw.length) continue\n if (raw.length > BOOKING_SERVICE_WINDOWS_PER_DAY_MAX) {\n problems.push(`Weekday ${key} has more than ${BOOKING_SERVICE_WINDOWS_PER_DAY_MAX} windows`)\n continue\n }\n const day: Array<{ start: number; end: number }> = []\n for (const window of raw) {\n const start = isRecord(window) ? window['start'] : undefined\n const end = isRecord(window) ? window['end'] : undefined\n if (\n typeof start !== 'number' ||\n typeof end !== 'number' ||\n !Number.isInteger(start) ||\n !Number.isInteger(end) ||\n start < 0 ||\n end > 24 * 60 ||\n end <= start\n ) {\n problems.push(\n `A window on weekday ${key} is not a start before its end, in whole minutes from 0 to 1440`,\n )\n continue\n }\n day.push({ start, end })\n }\n day.sort((a, b) => a.start - b.start)\n if (day.some((window, index) => index > 0 && window.start < day[index - 1].end)) {\n problems.push(`Two windows on weekday ${key} overlap`)\n }\n if (day.length) windows[weekday] = day\n }\n if (!Object.keys(windows).length && !problems.length) {\n problems.push('The service needs weekly hours: at least one open window on one weekday')\n }\n return windows\n}\n\nfunction readAsk(label: string, value: unknown, problems: string[]): BookingFieldAsk {\n if (value === undefined) return 'off'\n if ((BOOKING_FIELD_ASKS as readonly unknown[]).includes(value)) return value as BookingFieldAsk\n problems.push(`Asking for ${label} is off, optional or required`)\n return 'off'\n}\n\nfunction readSwitch(label: string, value: unknown, fallback: boolean, problems: string[]): boolean {\n if (value === undefined) return fallback\n if (typeof value === 'boolean') return value\n problems.push(`${label} is on or off`)\n return fallback\n}\n\nexport type BookingServiceContentRead =\n | { ok: true; value: BookingServiceDraftFields }\n | { ok: false; problems: string[] }\n\n/** The content as the writer stores it, or every problem that stops it. */\nexport function readBookingServiceContent(\n content: Readonly<Record<string, unknown>>,\n): BookingServiceContentRead {\n const problems: string[] = []\n const name = line(content['name'])\n if (!name) problems.push('The service needs a name')\n else if (name.length > BOOKING_SERVICE_NAME_MAX) {\n problems.push(`The name is longer than ${BOOKING_SERVICE_NAME_MAX} characters`)\n }\n const duration = content['durationMinutes']\n if (\n typeof duration !== 'number' ||\n !Number.isInteger(duration) ||\n duration < BOOKING_MIN_DURATION_MINUTES ||\n duration > BOOKING_MAX_DURATION_MINUTES\n ) {\n problems.push(\n `The length is whole minutes from ${BOOKING_MIN_DURATION_MINUTES} to ${BOOKING_MAX_DURATION_MINUTES}`,\n )\n }\n const rawDescription = content['description']\n const description = typeof rawDescription === 'string' ? rawDescription.trim() : ''\n if (rawDescription !== undefined && typeof rawDescription !== 'string') {\n problems.push('The description is text')\n } else if (description.length > BOOKING_SERVICE_DESCRIPTION_MAX) {\n problems.push(`The description is longer than ${BOOKING_SERVICE_DESCRIPTION_MAX} characters`)\n }\n const timezone = line(content['timezone'])\n if (!isValidTimeZone(timezone)) {\n problems.push('The time zone is an IANA zone, such as America/Chicago')\n }\n const windows = readWindows(content['windows'], problems)\n\n // No price stated and no label asked for is \"Contact for price\": a draft\n // never charges what the caller did not say.\n const rawPrice = content['priceUsd']\n const askedDisplay = content['priceDisplay']\n let priceDisplay: BookingPriceDisplay = 'contact'\n let priceUsd = 0\n if (askedDisplay !== undefined) {\n if ((BOOKING_PRICE_DISPLAYS as readonly unknown[]).includes(askedDisplay)) {\n priceDisplay = askedDisplay as BookingPriceDisplay\n } else {\n problems.push('The price is stated as fixed, varies, estimate or contact')\n }\n } else if (rawPrice !== undefined) {\n priceDisplay = 'fixed'\n }\n if (priceDisplay === 'fixed') {\n if (\n typeof rawPrice !== 'number' ||\n !Number.isInteger(rawPrice) ||\n rawPrice < 0 ||\n rawPrice > BOOKING_SERVICE_PRICE_MAX_USD\n ) {\n problems.push(\n `A fixed price is whole dollars from 0 to ${BOOKING_SERVICE_PRICE_MAX_USD}; ` +\n 'state it, or say the price varies, is a free estimate, or is on request',\n )\n } else {\n priceUsd = rawPrice\n }\n }\n const askPhone = readAsk('a phone number', content['askPhone'], problems)\n const askAddress = readAsk('an address', content['askAddress'], problems)\n // The model's defaults: a booking files a meeting, and owes no follow-up.\n const crmMeetingActivity = readSwitch('Filing a meeting', content['crmMeetingActivity'], true, problems)\n const crmFollowUpTask = readSwitch('A follow-up task', content['crmFollowUpTask'], false, problems)\n if (problems.length) return { ok: false, problems: [...new Set(problems)] }\n return {\n ok: true,\n value: {\n name,\n durationMinutes: duration as number,\n ...(description ? { description } : {}),\n windows,\n timezone,\n priceDisplay,\n priceUsd,\n askPhone,\n askAddress,\n crmMeetingActivity,\n crmFollowUpTask,\n },\n }\n}\n\n/** What a caller is told about a service, written or about to be. */\nfunction factsOf(value: Pick<HostBookingService, 'durationMinutes' | 'priceUsd' | 'priceDisplay' | 'timezone' | 'windows'>) {\n return {\n status: 'draft',\n durationMinutes: value.durationMinutes,\n priceDisplay: value.priceDisplay ?? 'fixed',\n priceText: bookingPriceText(value),\n timezone: value.timezone ?? 'UTC',\n openWeekdays: Object.keys(value.windows ?? {})\n .map(Number)\n .sort((a, b) => a - b),\n }\n}\n\n/** Whether content is a service this plugin would store, with what it says about it. Pure. */\nexport function checkBookingServiceContent(\n content: Readonly<Record<string, unknown>>,\n): PluginDraftCheck {\n const read = readBookingServiceContent(content)\n if (read.ok === false) return read\n return { ok: true, facts: factsOf(read.value) }\n}\n\nfunction recordOf(service: FirebaseFirestore.DocumentSnapshot): PluginDraftRecord {\n const data = (service.data() ?? {}) as HostBookingService\n return {\n id: service.id,\n name: String(data.name ?? ''),\n versionId: null,\n facts: { ...factsOf(data), status: data.status === 'draft' ? 'draft' : 'active' },\n }\n}\n\nfunction roleRefusal(host: FirebaseFirestore.DocumentSnapshot, uid: string): PluginDraftRefusal | null {\n const role = (host.get('memberRoles') ?? {})[uid]\n return hostRoleCanWrite(role) ? null : { status: 403, error: BOOKING_SERVICE_ROLE_REFUSAL }\n}\n\nfunction planRefusal(org: PluginDraftContext['org']): PluginDraftRefusal | null {\n return checkEntitlement(org as never, 'bookings')\n ? null\n : { status: 403, error: BOOKING_SERVICE_PLAN_REFUSAL }\n}\n\n/**\n * The allowance, counted as `/api/hosts/resources` counts a service create:\n * every document in the collection.\n */\nfunction roomRefusal(org: PluginDraftContext['org'], used: number): PluginDraftRefusal | null {\n const quota = checkQuota(org as never, 'servicesPerHost', used)\n return quota.allowed ? null : { status: 403, error: bookingServiceLimitRefusal(quota.limit) }\n}\n\nexport interface BookingServiceDraftWriterDeps {\n /** The Admin SDK handle; specs hand in a double. */\n firestore?: () => Firestore\n}\n\nexport function createBookingServiceDraftWriter(\n deps: BookingServiceDraftWriterDeps = {},\n): PluginResourceDraftWriter {\n const firestore = deps.firestore ?? (() => firebaseAdmin.app().firestore() as unknown as Firestore)\n return {\n refusal: async (context) => {\n const hostRef = firestore().collection('hosts').doc(context.hostId)\n const host = await hostRef.get()\n if (!host.exists) return { status: 404, error: 'Unknown site' }\n const early = roleRefusal(host, context.uid) ?? planRefusal(context.org)\n if (early) return early\n const used = await countLiveDocuments(hostRef.collection('services'))\n return roomRefusal(context.org, Number(used) || 0)\n },\n\n check: (content) => checkBookingServiceContent(content),\n\n read: async ({ hostId, id }) => {\n const service = await firestore()\n .collection('hosts')\n .doc(hostId)\n .collection('services')\n .doc(id)\n .get()\n return service.exists ? recordOf(service) : null\n },\n\n write: async (request): Promise<PluginDraftWrite> => {\n // The request's name is the one asked for; the content's stands in.\n const asked = line(request.name)\n const read = readBookingServiceContent(asked ? { ...request.content, name: asked } : request.content)\n if (read.ok === false) return { ok: false, status: 400, error: read.problems[0] }\n const db = firestore()\n const hostRef = db.collection('hosts').doc(request.hostId)\n const servicesRef = hostRef.collection('services')\n const serviceRef = servicesRef.doc(request.id)\n return db.runTransaction(async (tx): Promise<PluginDraftWrite> => {\n // Every read before any write, which Firestore requires.\n const [host, existing] = await Promise.all([tx.get(hostRef), tx.get(serviceRef)])\n if (!host.exists) return { ok: false, status: 404, error: 'Unknown site' }\n // Asked again under the same id: the draft it already wrote.\n if (existing.exists) return { ok: true, replayed: true, ...recordOf(existing) }\n const early = roleRefusal(host, request.uid) ?? planRefusal(request.org)\n if (early) return { ok: false, ...early }\n const used = await countLiveDocuments(servicesRef, (aggregate) => tx.get(aggregate))\n const room = roomRefusal(request.org, Number(used) || 0)\n if (room) return { ok: false, ...room }\n tx.create(serviceRef, {\n ...read.value,\n status: 'draft',\n createdAt: request.now,\n updatedAt: request.now,\n createdBy: request.uid,\n })\n return {\n ok: true,\n replayed: false,\n id: request.id,\n name: read.value.name,\n versionId: null,\n facts: factsOf(read.value),\n }\n })\n },\n }\n}\n\nexport const bookingServiceDraftWriter = createBookingServiceDraftWriter()\n\n/**\n * Registers the writer; the console surface calls it, since only the console\n * runs AI jobs (AGL-3026). Idempotent: a second call replaces the first.\n */\nexport function registerBookingServiceDraftWriter(): void {\n registerPluginResourceDraftWriter(BOOKING_SERVICE_DRAFT_RESOURCE, bookingServiceDraftWriter, {\n pluginId: BUNDLE_ID,\n })\n}\n"],"names":["hostRoleCanWrite","checkEntitlement","checkQuota","countLiveDocuments","registerPluginResourceDraftWriter","isValidTimeZone","firebaseAdmin","BUNDLE_ID","BOOKING_FIELD_ASKS","BOOKING_PRICE_DISPLAYS","bookingPriceText","BOOKING_MAX_DURATION_MINUTES","BOOKING_MIN_DURATION_MINUTES","BOOKING_SERVICE_DRAFT_RESOURCE","BOOKING_SERVICE_NAME_MAX","BOOKING_SERVICE_DESCRIPTION_MAX","BOOKING_SERVICE_WINDOWS_PER_DAY_MAX","BOOKING_SERVICE_PRICE_MAX_USD","BOOKING_SERVICE_ROLE_REFUSAL","BOOKING_SERVICE_PLAN_REFUSAL","bookingServiceLimitRefusal","limit","isRecord","value","Array","isArray","line","replace","trim","readWindows","problems","windows","push","key","raw","Object","entries","weekday","Number","test","isInteger","length","day","window","start","undefined","end","sort","a","b","some","index","keys","readAsk","label","includes","readSwitch","fallback","readBookingServiceContent","content","name","duration","rawDescription","description","timezone","rawPrice","askedDisplay","priceDisplay","priceUsd","askPhone","askAddress","crmMeetingActivity","crmFollowUpTask","ok","Set","durationMinutes","factsOf","status","priceText","openWeekdays","map","checkBookingServiceContent","read","facts","recordOf","service","data","id","String","versionId","roleRefusal","host","uid","role","get","error","planRefusal","org","roomRefusal","used","quota","allowed","createBookingServiceDraftWriter","deps","firestore","app","refusal","context","hostRef","collection","doc","hostId","exists","early","check","write","request","asked","db","servicesRef","serviceRef","runTransaction","tx","existing","Promise","all","replayed","aggregate","room","create","createdAt","now","updatedAt","createdBy","bookingServiceDraftWriter","registerBookingServiceDraftWriter","pluginId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,2CAA0C;AACvF,SAASC,kBAAkB,QAAQ,6CAA4C;AAC/E,SACEC,iCAAiC,QAO5B,qDAAoD;AAC3D,SAASC,eAAe,QAAQ,0CAAyC;AACzE,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,kBAAkB,QAA8B,qCAAiC;AA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MC,OAAO9B,YAAYkB,QAAQnB,GAAG,EAAE3D,OAAO6D,SAAS;gBACtD,IAAI6B,MAAM,OAAO;oBAAEvD,IAAI;mBAAUuD;gBACjCN,GAAGO,MAAM,CAACT,YAAY,aACjBtC,KAAK3D,KAAK;oBACbsD,QAAQ;oBACRqD,WAAWd,QAAQe,GAAG;oBACtBC,WAAWhB,QAAQe,GAAG;oBACtBE,WAAWjB,QAAQxB,GAAG;;gBAExB,OAAO;oBACLnB,IAAI;oBACJqD,UAAU;oBACVvC,IAAI6B,QAAQ7B,EAAE;oBACd3B,MAAMsB,KAAK3D,KAAK,CAACqC,IAAI;oBACrB6B,WAAW;oBACXN,OAAOP,QAAQM,KAAK3D,KAAK;gBAC3B;YACF;QACF;IACF;AACF;AAEA,OAAO,MAAM+G,4BAA4BhC,kCAAiC;AAE1E;;;CAGC,GACD,OAAO,SAASiC;IACdnI,kCAAkCS,gCAAgCyH,2BAA2B;QAC3FE,UAAUjI;IACZ;AACF"}
|
package/src/lib/tenant-emails.js
CHANGED
|
@@ -68,14 +68,24 @@
|
|
|
68
68
|
defaultBody: [
|
|
69
69
|
{
|
|
70
70
|
block: 'text',
|
|
71
|
-
text: 'Booking
|
|
71
|
+
text: '{{host.businessName}} · Booking',
|
|
72
|
+
variant: 'eyebrow'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
block: 'text',
|
|
76
|
+
text: 'You’re booked: {{service.name}}',
|
|
72
77
|
variant: 'heading'
|
|
73
78
|
},
|
|
74
79
|
{
|
|
75
80
|
block: 'text',
|
|
76
|
-
text: 'Hi {{name}}, your booking with {{host.businessName}} is
|
|
81
|
+
text: 'Hi {{name}}, your booking with {{host.businessName}} is confirmed. Here are the details to keep.',
|
|
77
82
|
variant: 'body'
|
|
78
83
|
},
|
|
84
|
+
{
|
|
85
|
+
block: 'text',
|
|
86
|
+
text: 'Service: {{service.name}}\nWhen: {{when}} ({{timezone}})\nReference: {{booking.ref}}',
|
|
87
|
+
variant: 'details'
|
|
88
|
+
},
|
|
79
89
|
{
|
|
80
90
|
block: 'text',
|
|
81
91
|
text: '{{booking.payment}}',
|
|
@@ -83,7 +93,7 @@
|
|
|
83
93
|
},
|
|
84
94
|
{
|
|
85
95
|
block: 'text',
|
|
86
|
-
text: '
|
|
96
|
+
text: 'Need to change it? Reply to this email and {{host.businessName}} will help.',
|
|
87
97
|
variant: 'caption'
|
|
88
98
|
}
|
|
89
99
|
],
|
|
@@ -122,8 +132,28 @@
|
|
|
122
132
|
defaultBody: [
|
|
123
133
|
{
|
|
124
134
|
block: 'text',
|
|
125
|
-
text: '
|
|
135
|
+
text: '{{host.businessName}} · Booking',
|
|
136
|
+
variant: 'eyebrow'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
block: 'text',
|
|
140
|
+
text: 'Your booking is coming up',
|
|
141
|
+
variant: 'heading'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
block: 'text',
|
|
145
|
+
text: 'Hi {{name}}, this is a reminder of your booking with {{host.businessName}}.',
|
|
126
146
|
variant: 'body'
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
block: 'text',
|
|
150
|
+
text: 'Service: {{service.name}}\nWhen: {{when}} ({{timezone}})',
|
|
151
|
+
variant: 'details'
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
block: 'text',
|
|
155
|
+
text: 'Can no longer make it? Reply to this email so {{host.businessName}} can offer the time to someone else.',
|
|
156
|
+
variant: 'caption'
|
|
127
157
|
}
|
|
128
158
|
],
|
|
129
159
|
footerReason: 'You’re receiving this because you have a booking with {{host.businessName}}.'
|
|
@@ -169,6 +199,11 @@
|
|
|
169
199
|
}
|
|
170
200
|
],
|
|
171
201
|
defaultBody: [
|
|
202
|
+
{
|
|
203
|
+
block: 'text',
|
|
204
|
+
text: '{{host.businessName}} · Booking',
|
|
205
|
+
variant: 'eyebrow'
|
|
206
|
+
},
|
|
172
207
|
{
|
|
173
208
|
block: 'text',
|
|
174
209
|
text: 'Your booking has a new time',
|
|
@@ -176,12 +211,17 @@
|
|
|
176
211
|
},
|
|
177
212
|
{
|
|
178
213
|
block: 'text',
|
|
179
|
-
text: 'Hi {{name}}, your booking with {{host.businessName}}
|
|
214
|
+
text: 'Hi {{name}}, your booking with {{host.businessName}} moved. The new time is below; the old one no longer applies.',
|
|
180
215
|
variant: 'body'
|
|
181
216
|
},
|
|
182
217
|
{
|
|
183
218
|
block: 'text',
|
|
184
|
-
text: '
|
|
219
|
+
text: 'Service: {{service.name}}\nNew time: {{when}} ({{timezone}})\nWas: {{previousWhen}}\nReference: {{booking.ref}}',
|
|
220
|
+
variant: 'details'
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
block: 'text',
|
|
224
|
+
text: 'Does the new time not work? Reply to this email and {{host.businessName}} will help.',
|
|
185
225
|
variant: 'caption'
|
|
186
226
|
}
|
|
187
227
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/bookings/src/lib/tenant-emails.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TenantEmailEntry } from '@aglyn/shared-util-email'\n\n/**\n * The emails a site sends its own customers through Bookings (AGL-769/770).\n *\n * Declared here, by the plugin that sends them, and compiled into the\n * platform's tenant email catalog (`TENANT_EMAILS` in\n * `@aglyn/shared-util-email`) by `tools/scripts/generate-plugin-manifests.mjs`\n * (AGL-3080): the catalog's readers include the send path, which loads no\n * plugin code, so a runtime registry it had not filled would quietly send\n * the text card in place of the site's designed email. Regenerate after\n * changing an entry; `--check` refuses a stale catalog.\n */\nexport function bookingsTenantEmails(): readonly TenantEmailEntry[] {\n return [\n {\n key: 'booking-confirmed',\n name: 'Booking confirmed',\n description: 'Confirms a booking to the customer, for paid and free services.',\n pluginId: 'bookings',\n plugin: 'Bookings',\n control: 'besigner',\n defaultSubject: 'Booking confirmed: {{service.name}}',\n mergeTokens: [\n { name: 'name', description: \"The customer's name\", sample: 'Alex' },\n {\n name: 'service.name',\n description: 'The booked service',\n sample: 'Consultation',\n },\n {\n name: 'when',\n description: 'Formatted date and time of the booking',\n sample: 'Monday, June 1, 2026 at 9:00 AM',\n },\n {\n name: 'timezone',\n description: 'Timezone the time is shown in',\n sample: 'America/Chicago',\n },\n {\n name: 'booking.payment',\n description:\n 'What a paid booking charged, as a sentence; empty for a free booking',\n sample: 'You paid $95.00.',\n },\n {\n name: 'booking.ref',\n description: 'Booking reference id',\n sample: 'bk_123',\n },\n ],\n defaultBody: [\n { block: 'text', text: 'Booking
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/bookings/src/lib/tenant-emails.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TenantEmailEntry } from '@aglyn/shared-util-email'\n\n/**\n * The emails a site sends its own customers through Bookings (AGL-769/770).\n *\n * Declared here, by the plugin that sends them, and compiled into the\n * platform's tenant email catalog (`TENANT_EMAILS` in\n * `@aglyn/shared-util-email`) by `tools/scripts/generate-plugin-manifests.mjs`\n * (AGL-3080): the catalog's readers include the send path, which loads no\n * plugin code, so a runtime registry it had not filled would quietly send\n * the text card in place of the site's designed email. Regenerate after\n * changing an entry; `--check` refuses a stale catalog.\n */\nexport function bookingsTenantEmails(): readonly TenantEmailEntry[] {\n return [\n {\n key: 'booking-confirmed',\n name: 'Booking confirmed',\n description: 'Confirms a booking to the customer, for paid and free services.',\n pluginId: 'bookings',\n plugin: 'Bookings',\n control: 'besigner',\n defaultSubject: 'Booking confirmed: {{service.name}}',\n mergeTokens: [\n { name: 'name', description: \"The customer's name\", sample: 'Alex' },\n {\n name: 'service.name',\n description: 'The booked service',\n sample: 'Consultation',\n },\n {\n name: 'when',\n description: 'Formatted date and time of the booking',\n sample: 'Monday, June 1, 2026 at 9:00 AM',\n },\n {\n name: 'timezone',\n description: 'Timezone the time is shown in',\n sample: 'America/Chicago',\n },\n {\n name: 'booking.payment',\n description:\n 'What a paid booking charged, as a sentence; empty for a free booking',\n sample: 'You paid $95.00.',\n },\n {\n name: 'booking.ref',\n description: 'Booking reference id',\n sample: 'bk_123',\n },\n ],\n defaultBody: [\n { block: 'text', text: '{{host.businessName}} · Booking', variant: 'eyebrow' },\n { block: 'text', text: 'You’re booked: {{service.name}}', variant: 'heading' },\n { block: 'text', text: 'Hi {{name}}, your booking with {{host.businessName}} is confirmed. Here are the details to keep.', variant: 'body' },\n { block: 'text', text: 'Service: {{service.name}}\\nWhen: {{when}} ({{timezone}})\\nReference: {{booking.ref}}', variant: 'details' },\n { block: 'text', text: '{{booking.payment}}', variant: 'body' },\n { block: 'text', text: 'Need to change it? Reply to this email and {{host.businessName}} will help.', variant: 'caption' },\n ],\n footerReason:\n 'You’re receiving this because you booked with {{host.businessName}}.',\n },\n {\n key: 'booking-reminder',\n name: 'Booking reminder',\n description: 'Reminds the customer of an upcoming booking.',\n pluginId: 'bookings',\n plugin: 'Bookings',\n control: 'besigner',\n defaultSubject: 'Reminder: {{service.name}} is coming up',\n mergeTokens: [\n { name: 'name', description: \"The customer's name\", sample: 'Alex' },\n {\n name: 'service.name',\n description: 'The booked service',\n sample: 'Consultation',\n },\n {\n name: 'when',\n description: 'Formatted date and time of the booking',\n sample: 'Tuesday, June 2, 2026 at 9:00 AM',\n },\n {\n name: 'timezone',\n description: 'Timezone the time is shown in',\n sample: 'America/Chicago',\n },\n ],\n defaultBody: [\n { block: 'text', text: '{{host.businessName}} · Booking', variant: 'eyebrow' },\n { block: 'text', text: 'Your booking is coming up', variant: 'heading' },\n { block: 'text', text: 'Hi {{name}}, this is a reminder of your booking with {{host.businessName}}.', variant: 'body' },\n { block: 'text', text: 'Service: {{service.name}}\\nWhen: {{when}} ({{timezone}})', variant: 'details' },\n { block: 'text', text: 'Can no longer make it? Reply to this email so {{host.businessName}} can offer the time to someone else.', variant: 'caption' },\n ],\n footerReason:\n 'You’re receiving this because you have a booking with {{host.businessName}}.',\n },\n {\n key: 'booking-rescheduled',\n name: 'Booking rescheduled',\n description: 'Tells the customer their booking moved to a new time.',\n pluginId: 'bookings',\n plugin: 'Bookings',\n control: 'besigner',\n defaultSubject: 'New time for {{service.name}}',\n mergeTokens: [\n { name: 'name', description: \"The customer's name\", sample: 'Alex' },\n {\n name: 'service.name',\n description: 'The booked service',\n sample: 'Consultation',\n },\n {\n name: 'when',\n description: 'The new date and time of the booking',\n sample: 'Wednesday, June 3, 2026 at 10:30 AM',\n },\n {\n name: 'previousWhen',\n description: 'The date and time the booking moved from',\n sample: 'Monday, June 1, 2026 at 9:00 AM',\n },\n {\n name: 'timezone',\n description: 'Timezone the times are shown in',\n sample: 'America/Chicago',\n },\n {\n name: 'booking.ref',\n description: 'Booking reference id',\n sample: 'bk_123',\n },\n ],\n defaultBody: [\n { block: 'text', text: '{{host.businessName}} · Booking', variant: 'eyebrow' },\n { block: 'text', text: 'Your booking has a new time', variant: 'heading' },\n { block: 'text', text: 'Hi {{name}}, your booking with {{host.businessName}} moved. The new time is below; the old one no longer applies.', variant: 'body' },\n { block: 'text', text: 'Service: {{service.name}}\\nNew time: {{when}} ({{timezone}})\\nWas: {{previousWhen}}\\nReference: {{booking.ref}}', variant: 'details' },\n { block: 'text', text: 'Does the new time not work? Reply to this email and {{host.businessName}} will help.', variant: 'caption' },\n ],\n footerReason:\n 'You’re receiving this because you have a booking with {{host.businessName}}.',\n },\n ]\n}\n"],"names":["bookingsTenantEmails","key","name","description","pluginId","plugin","control","defaultSubject","mergeTokens","sample","defaultBody","block","text","variant","footerReason"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;CAUC,GACD,OAAO,SAASA;IACd,OAAO;QACL;YACEC,KAAK;YACLC,MAAM;YACNC,aAAa;YACbC,UAAU;YACVC,QAAQ;YACRC,SAAS;YACTC,gBAAgB;YAChBC,aAAa;gBACX;oBAAEN,MAAM;oBAAQC,aAAa;oBAAuBM,QAAQ;gBAAO;gBACnE;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aACE;oBACFM,QAAQ;gBACV;gBACA;oBACEP,MAAM;oBACNC,aAAa;oBACbM,QAAQ;gBACV;aACD;YACDC,aAAa;gBACX;oBAAEC,OAAO;oBAAQC,MAAM;oBAAmCC,SAAS;gBAAU;gBAC7E;oBAAEF,OAAO;oBAAQC,MAAM;oBAAmCC,SAAS;gBAAU;gBAC7E;oBAAEF,OAAO;oBAAQC,MAAM;oBAAoGC,SAAS;gBAAO;gBAC3I;oBAAEF,OAAO;oBAAQC,MAAM;oBAAwFC,SAAS;gBAAU;gBAClI;oBAAEF,OAAO;oBAAQC,MAAM;oBAAuBC,SAAS;gBAAO;gBAC9D;oBAAEF,OAAO;oBAAQC,MAAM;oBAA+EC,SAAS;gBAAU;aAC1H;YACDC,cACE;QACJ;QACA;YACEb,KAAK;YACLC,MAAM;YACNC,aAAa;YACbC,UAAU;YACVC,QAAQ;YACRC,SAAS;YACTC,gBAAgB;YAChBC,aAAa;gBACX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