@ordinatio/scheduling 0.3.0 → 0.5.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/CHANGELOG.md +51 -0
- package/README.md +179 -2
- package/dist/index.d.mts +661 -13
- package/dist/index.d.ts +661 -13
- package/dist/index.js +1737 -51
- package/dist/index.mjs +1686 -50
- package/package.json +1 -1
- package/prisma/migrations/20261027100000_waitlist/migration.sql +51 -0
- package/prisma/migrations/20261027200000_routing_forms/migration.sql +26 -0
- package/prisma/migrations/20261027300000_privacy_requests/migration.sql +18 -0
- package/prisma/migrations/20261027400000_organization_brand/migration.sql +26 -0
- package/prisma/schema.prisma +96 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as _prisma_client from '@prisma/client';
|
|
|
2
2
|
import { PrismaClient, Prisma } from '@prisma/client';
|
|
3
3
|
import * as _ordinatio_errors from '@ordinatio/errors';
|
|
4
4
|
import { ErrorRegistry } from '@ordinatio/errors';
|
|
5
|
+
import * as _prisma_client_runtime_client from '@prisma/client/runtime/client';
|
|
5
6
|
|
|
6
7
|
/** Minimal Prisma interface for scheduling operations.
|
|
7
8
|
*
|
|
@@ -10,7 +11,7 @@ import { ErrorRegistry } from '@ordinatio/errors';
|
|
|
10
11
|
* interface (minus $transaction itself) so code inside transactions
|
|
11
12
|
* is fully typed without `as any` casts.
|
|
12
13
|
*/
|
|
13
|
-
type SchedulingDb = Pick<PrismaClient, 'schedulingCalendar' | 'availabilityRule' | 'appointmentType' | 'appointmentTypeCalendar' | 'appointmentCategory' | 'appointment' | 'scheduledNotification' | 'notificationTemplate' | 'servicePackage' | 'packagePurchase' | 'couponCode' | 'recurringSeries' | 'roundRobinState' | 'webhookEndpoint' | 'webhookDelivery' | 'webhookAttempt' | 'organization' | '$transaction' | '$executeRaw' | '$queryRaw'>;
|
|
14
|
+
type SchedulingDb = Pick<PrismaClient, 'schedulingCalendar' | 'availabilityRule' | 'appointmentType' | 'appointmentTypeCalendar' | 'appointmentCategory' | 'appointment' | 'scheduledNotification' | 'notificationTemplate' | 'servicePackage' | 'packagePurchase' | 'couponCode' | 'recurringSeries' | 'roundRobinState' | 'webhookEndpoint' | 'webhookDelivery' | 'webhookAttempt' | 'waitlistEntry' | 'routingForm' | 'dataSubjectRequest' | 'organizationBrand' | 'organization' | '$transaction' | '$executeRaw' | '$queryRaw'>;
|
|
14
15
|
/**
|
|
15
16
|
* Branded subtype of SchedulingDb for transaction clients produced by withTransaction().
|
|
16
17
|
* selectCalendarForBooking() requires this type to enforce that its RoundRobinState
|
|
@@ -375,10 +376,21 @@ interface RetryConfig {
|
|
|
375
376
|
/** Base backoff in minutes — doubles each retry: 5, 10, 20 (default: 5) */
|
|
376
377
|
baseBackoffMinutes?: number;
|
|
377
378
|
}
|
|
379
|
+
/** Who a message should appear to come from. The sender may ignore what its provider cannot do. */
|
|
380
|
+
interface SenderIdentity {
|
|
381
|
+
/** The display name. */
|
|
382
|
+
name?: string;
|
|
383
|
+
/** The sending address, on a domain the host has confirmed. When absent, send from the provider's default address. */
|
|
384
|
+
email?: string;
|
|
385
|
+
/** Where replies go. */
|
|
386
|
+
replyTo?: string;
|
|
387
|
+
}
|
|
378
388
|
/** Context passed to the sender with each notification */
|
|
379
389
|
interface NotificationSenderContext {
|
|
380
390
|
/** The scheduling trigger that produced this notification */
|
|
381
391
|
trigger?: NotificationTrigger;
|
|
392
|
+
/** The organization's own sender identity, when branding is on and one is set. */
|
|
393
|
+
from?: SenderIdentity;
|
|
382
394
|
}
|
|
383
395
|
/**
|
|
384
396
|
* Returned by the sender when it deliberately does not deliver the notification.
|
|
@@ -1172,11 +1184,12 @@ declare function rescheduleAppointment(db: SchedulingDb, input: RescheduleInput,
|
|
|
1172
1184
|
/**
|
|
1173
1185
|
* Get a single appointment by ID.
|
|
1174
1186
|
*
|
|
1175
|
-
*
|
|
1176
|
-
* must already have verified ownership or be passing a
|
|
1177
|
-
* Confirmed callers today (`approve/route.ts`) already do so via `requireSchedulingAuth()`.
|
|
1187
|
+
* Pass `organizationId` and an appointment of another organization is reported as not found. Without it no organization
|
|
1188
|
+
* check is made here: the caller must already have verified ownership or be passing a database handle that holds one business.
|
|
1178
1189
|
*/
|
|
1179
|
-
declare function getAppointment(db: SchedulingDb, appointmentId: string
|
|
1190
|
+
declare function getAppointment(db: SchedulingDb, appointmentId: string, options?: {
|
|
1191
|
+
organizationId?: string;
|
|
1192
|
+
}): Promise<AppointmentWithDetails>;
|
|
1180
1193
|
/**
|
|
1181
1194
|
* List appointments with filters.
|
|
1182
1195
|
*
|
|
@@ -1189,7 +1202,9 @@ declare function getAppointment(db: SchedulingDb, appointmentId: string): Promis
|
|
|
1189
1202
|
* equivalent ownership verification) before invoking this — there is no runtime guard
|
|
1190
1203
|
* here to catch a caller that skips this.
|
|
1191
1204
|
*/
|
|
1192
|
-
declare function listAppointments(
|
|
1205
|
+
declare function listAppointments(unscopedDb: SchedulingDb, options?: {
|
|
1206
|
+
/** Only this organization's appointments. Leave it out when the database holds one business. */
|
|
1207
|
+
organizationId?: string;
|
|
1193
1208
|
calendarId?: string;
|
|
1194
1209
|
status?: string;
|
|
1195
1210
|
clientEmail?: string;
|
|
@@ -1262,6 +1277,8 @@ declare function getGroupSessions(db: SchedulingDb, params: {
|
|
|
1262
1277
|
calendarId?: string;
|
|
1263
1278
|
/** Task #83 — omitted means unrestricted, byte-identical to before. See visibility-filter.ts. */
|
|
1264
1279
|
visibleCalendarIds?: string[];
|
|
1280
|
+
/** Only this organization's classes count. Leave it out when the database holds one business. */
|
|
1281
|
+
organizationId?: string;
|
|
1265
1282
|
}): Promise<GroupSessionsResult>;
|
|
1266
1283
|
|
|
1267
1284
|
/**
|
|
@@ -1273,9 +1290,13 @@ declare function getBookingAnalytics(db: SchedulingDb, options?: {
|
|
|
1273
1290
|
calendarId?: string;
|
|
1274
1291
|
days?: number;
|
|
1275
1292
|
visibleCalendarIds?: string[];
|
|
1293
|
+
/** Only this organization's appointments count. Leave it out when the database holds one business. */
|
|
1294
|
+
organizationId?: string;
|
|
1276
1295
|
}): Promise<BookingAnalytics>;
|
|
1277
1296
|
|
|
1278
1297
|
interface DashboardQuery {
|
|
1298
|
+
/** Only this organization's appointments. Leave it out when the database holds one business. */
|
|
1299
|
+
organizationId?: string;
|
|
1279
1300
|
/** Search by client name, email, or phone */
|
|
1280
1301
|
search?: string;
|
|
1281
1302
|
/** Filter history by status */
|
|
@@ -1317,7 +1338,7 @@ interface DashboardQuery {
|
|
|
1317
1338
|
* - Upcoming (after this week, soonest first, capped)
|
|
1318
1339
|
* - Upcoming count (all of them, so a capped list can say so)
|
|
1319
1340
|
*/
|
|
1320
|
-
declare function getAppointmentDashboard(
|
|
1341
|
+
declare function getAppointmentDashboard(unscopedDb: SchedulingDb, query?: DashboardQuery): Promise<AppointmentDashboardData>;
|
|
1321
1342
|
interface AppointmentsForRangeResult {
|
|
1322
1343
|
appointments: AppointmentDashboardItem[];
|
|
1323
1344
|
/**
|
|
@@ -1333,10 +1354,14 @@ interface AppointmentsForRangeResult {
|
|
|
1333
1354
|
* Used by calendar views (day/week/month).
|
|
1334
1355
|
* Includes all statuses (cancelled shown greyed out in the UI).
|
|
1335
1356
|
*/
|
|
1336
|
-
declare function getAppointmentsForRange(
|
|
1357
|
+
declare function getAppointmentsForRange(unscopedDb: SchedulingDb, rangeStart: Date, rangeEnd: Date, options?: {
|
|
1358
|
+
organizationId?: string;
|
|
1359
|
+
}): Promise<AppointmentsForRangeResult>;
|
|
1337
1360
|
|
|
1338
1361
|
declare const USER_DAY_LIMIT = 200;
|
|
1339
1362
|
interface UserDayInput {
|
|
1363
|
+
/** Only this organization's appointments and calendars. Leave it out when the database holds one business. */
|
|
1364
|
+
organizationId?: string;
|
|
1340
1365
|
/** The staff member whose day it is (the id stored in SchedulingCalendar.userId). */
|
|
1341
1366
|
userId: string;
|
|
1342
1367
|
/** The local calendar day, 'YYYY-MM-DD', in `timezone`. */
|
|
@@ -1371,7 +1396,7 @@ interface UserDayResult {
|
|
|
1371
1396
|
/** Calendars linked to this user that the caller can see; 0 means "nothing linked", not "free day". */
|
|
1372
1397
|
linkedCalendarCount: number;
|
|
1373
1398
|
}
|
|
1374
|
-
declare function getUserDayAppointments(
|
|
1399
|
+
declare function getUserDayAppointments(unscopedDb: SchedulingDb, input: UserDayInput): Promise<UserDayResult>;
|
|
1375
1400
|
|
|
1376
1401
|
interface Clock {
|
|
1377
1402
|
now(): Date;
|
|
@@ -1382,6 +1407,8 @@ interface OutboundMessage {
|
|
|
1382
1407
|
subject: string;
|
|
1383
1408
|
body: string;
|
|
1384
1409
|
trigger?: NotificationTrigger;
|
|
1410
|
+
/** The organization's own sender identity, when it has one. An adapter that cannot send as it uses its default sender. */
|
|
1411
|
+
from?: SenderIdentity;
|
|
1385
1412
|
}
|
|
1386
1413
|
type SendResult = {
|
|
1387
1414
|
status: 'SENT';
|
|
@@ -1562,6 +1589,22 @@ declare function checkAuthContract(adapter: AuthAdapter, validHeaders?: Record<s
|
|
|
1562
1589
|
*/
|
|
1563
1590
|
declare function withCalendarVisibility(where: Record<string, unknown>, visibleCalendarIds: string[] | undefined): Record<string, unknown>;
|
|
1564
1591
|
|
|
1592
|
+
/**
|
|
1593
|
+
* Limits a Prisma `where` on appointments to one organization, through the appointment's calendar.
|
|
1594
|
+
*
|
|
1595
|
+
* The package does not assume the database handle it is given is already limited to one business: a host that keeps
|
|
1596
|
+
* several businesses in one database passes the organization here and nothing from another business can come back.
|
|
1597
|
+
* Left out, the `where` is returned unchanged (the same object), for a host that gives each business its own database.
|
|
1598
|
+
* Wrapped in `AND` so it combines with any `OR` or `calendar` condition already in the `where`.
|
|
1599
|
+
*/
|
|
1600
|
+
declare function withOrganization(where: Record<string, unknown>, organizationId: string | undefined): Record<string, unknown>;
|
|
1601
|
+
/**
|
|
1602
|
+
* The same database handle, but every appointment query is limited to one organization (through the calendar) and every
|
|
1603
|
+
* calendar query to the organization itself. For the package's read functions that run several queries, so none of them can be
|
|
1604
|
+
* left unscoped by accident. Given no organization the handle is returned as it is.
|
|
1605
|
+
*/
|
|
1606
|
+
declare function scopeToOrganization(db: SchedulingDb, organizationId: string | undefined): SchedulingDb;
|
|
1607
|
+
|
|
1565
1608
|
declare function renderTemplate(template: string, context: NotificationContext, channel?: NotificationChannel): string;
|
|
1566
1609
|
/**
|
|
1567
1610
|
* Build notification context from an appointment + related data.
|
|
@@ -1609,6 +1652,8 @@ declare function processPendingNotifications(db: SchedulingDb, sender: Notificat
|
|
|
1609
1652
|
maxOverdueMs?: number;
|
|
1610
1653
|
/** Queue a `reminder.sent` webhook for each reminder that was sent. Off by default; needs the webhook tables. */
|
|
1611
1654
|
webhooks?: boolean;
|
|
1655
|
+
/** Send each message with its organization's sender identity (name, address, reply-to). Off by default; needs the brand table. */
|
|
1656
|
+
brand?: boolean;
|
|
1612
1657
|
}): Promise<{
|
|
1613
1658
|
sent: number;
|
|
1614
1659
|
failed: number;
|
|
@@ -1622,6 +1667,7 @@ declare function processPendingNotifications(db: SchedulingDb, sender: Notificat
|
|
|
1622
1667
|
*/
|
|
1623
1668
|
declare function scheduleNotifications(db: SchedulingDb, appointmentId: string, baseUrl?: string, options?: {
|
|
1624
1669
|
excludeTriggers?: NotificationTrigger[];
|
|
1670
|
+
brand?: boolean;
|
|
1625
1671
|
}): Promise<number | undefined>;
|
|
1626
1672
|
/**
|
|
1627
1673
|
* Cancel all pending notifications for an appointment.
|
|
@@ -1638,14 +1684,18 @@ declare function cancelPendingNotifications(db: SchedulingDb, appointmentId: str
|
|
|
1638
1684
|
* Previously called sendImmediateNotification — renamed to make the
|
|
1639
1685
|
* async queue-based behavior explicit.
|
|
1640
1686
|
*/
|
|
1641
|
-
declare function queueImmediateNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string
|
|
1687
|
+
declare function queueImmediateNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string, options?: {
|
|
1688
|
+
brand?: boolean;
|
|
1689
|
+
}): Promise<void>;
|
|
1642
1690
|
/**
|
|
1643
1691
|
* Queue an immediate email notification to the calendar's staff member.
|
|
1644
1692
|
* Silently skips if: appointment not found, no staffEmail on the calendar,
|
|
1645
1693
|
* or no active STAFF templates exist for the trigger.
|
|
1646
1694
|
* Failure must NEVER block the caller — always wrap call sites in try/catch.
|
|
1647
1695
|
*/
|
|
1648
|
-
declare function queueStaffNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string
|
|
1696
|
+
declare function queueStaffNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string, options?: {
|
|
1697
|
+
brand?: boolean;
|
|
1698
|
+
}): Promise<void>;
|
|
1649
1699
|
|
|
1650
1700
|
/**
|
|
1651
1701
|
* List all notification templates for an org, sorted by channel then trigger.
|
|
@@ -1900,7 +1950,7 @@ declare function getTeamAvailableSlots(db: SchedulingDb, query: TeamAvailability
|
|
|
1900
1950
|
*/
|
|
1901
1951
|
declare function localToUTC(dateStr: string, timeStr: string, tz: string): Date;
|
|
1902
1952
|
|
|
1903
|
-
declare const WEBHOOK_EVENT_TYPES: readonly ["appointment.booked", "appointment.rescheduled", "appointment.cancelled", "appointment.no_show", "reminder.sent"];
|
|
1953
|
+
declare const WEBHOOK_EVENT_TYPES: readonly ["appointment.booked", "appointment.rescheduled", "appointment.cancelled", "appointment.no_show", "reminder.sent", "waitlist.offered"];
|
|
1904
1954
|
type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
|
|
1905
1955
|
/** Sent only by the "test" action; no endpoint subscribes to it. */
|
|
1906
1956
|
declare const WEBHOOK_TEST_EVENT = "webhook.test";
|
|
@@ -2092,4 +2142,602 @@ declare function listWebhookDeliveries(db: SchedulingDb, input: {
|
|
|
2092
2142
|
/** Puts a dead-lettered delivery back in the queue with a fresh set of tries. The log of earlier tries stays. */
|
|
2093
2143
|
declare function retryWebhookDelivery(db: SchedulingDb, organizationId: string, deliveryId: string, now?: Date): Promise<void>;
|
|
2094
2144
|
|
|
2095
|
-
|
|
2145
|
+
interface WaitlistEntryView {
|
|
2146
|
+
id: string;
|
|
2147
|
+
typeId: string;
|
|
2148
|
+
calendarId: string | null;
|
|
2149
|
+
day: string;
|
|
2150
|
+
slotStart: Date | null;
|
|
2151
|
+
clientName: string;
|
|
2152
|
+
clientEmail: string;
|
|
2153
|
+
clientPhone: string | null;
|
|
2154
|
+
status: string;
|
|
2155
|
+
offerSlotStart: Date | null;
|
|
2156
|
+
offerExpiresAt: Date | null;
|
|
2157
|
+
createdAt: Date;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
declare const MAX_WAITING_PER_TYPE_DAY = 50;
|
|
2161
|
+
interface JoinWaitlistInput {
|
|
2162
|
+
organizationId: string;
|
|
2163
|
+
typeId: string;
|
|
2164
|
+
/** Leave out to wait for any calendar that offers the type. */
|
|
2165
|
+
calendarId?: string;
|
|
2166
|
+
/** The day, YYYY-MM-DD in the calendar's timezone. */
|
|
2167
|
+
day: string;
|
|
2168
|
+
/** Leave out to wait for any time that day. */
|
|
2169
|
+
slotStart?: Date;
|
|
2170
|
+
clientName: string;
|
|
2171
|
+
clientEmail: string;
|
|
2172
|
+
clientPhone?: string | null;
|
|
2173
|
+
}
|
|
2174
|
+
declare function joinWaitlist(db: SchedulingDb, input: JoinWaitlistInput, now?: Date): Promise<{
|
|
2175
|
+
entry: WaitlistEntryView;
|
|
2176
|
+
token: string;
|
|
2177
|
+
}>;
|
|
2178
|
+
|
|
2179
|
+
declare const DEFAULT_OFFER_MINUTES = 30;
|
|
2180
|
+
interface WaitlistOffer {
|
|
2181
|
+
entry: WaitlistEntryView;
|
|
2182
|
+
/** The client's own handle; the host puts it in the link it sends. */
|
|
2183
|
+
token: string;
|
|
2184
|
+
calendarId: string;
|
|
2185
|
+
calendarName: string;
|
|
2186
|
+
typeName: string;
|
|
2187
|
+
startTime: Date;
|
|
2188
|
+
/** The timezone the client chose when they joined, for writing the time in their message. */
|
|
2189
|
+
timezone: string;
|
|
2190
|
+
expiresAt: Date;
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Offers the slot to the longest-waiting entry that fits it: same day, a calendar and type that match, the slot still
|
|
2194
|
+
* free. Returns null when nobody fits or the slot already has a live offer. The offer lasts `offerMinutes`, and never
|
|
2195
|
+
* past the start of the slot. Two callers freeing the same slot cannot both offer it: the database holds one live
|
|
2196
|
+
* offer per slot.
|
|
2197
|
+
*/
|
|
2198
|
+
declare function offerFreedSlot(db: SchedulingDb, input: {
|
|
2199
|
+
organizationId: string;
|
|
2200
|
+
calendarId: string;
|
|
2201
|
+
startTime: Date;
|
|
2202
|
+
offerMinutes?: number;
|
|
2203
|
+
now?: Date;
|
|
2204
|
+
}): Promise<WaitlistOffer | null>;
|
|
2205
|
+
/** As offerFreedSlot, but never throws: the cancellation that freed the slot is already saved. Logs a reference. */
|
|
2206
|
+
declare function tryOfferFreedSlot(db: SchedulingDb, input: Parameters<typeof offerFreedSlot>[1]): Promise<WaitlistOffer | null>;
|
|
2207
|
+
/**
|
|
2208
|
+
* Ends offers whose time ran out, and sorts out an accept that started and never finished. An accept whose booking was
|
|
2209
|
+
* saved becomes BOOKED; one whose booking never happened goes back in line. Returns the slots that came free either way
|
|
2210
|
+
* (a lapsed offer, or an accept that never booked), so the caller can offer each to the next person.
|
|
2211
|
+
*/
|
|
2212
|
+
declare function expireWaitlistOffers(db: SchedulingDb, options?: {
|
|
2213
|
+
now?: Date;
|
|
2214
|
+
acceptTimeoutMs?: number;
|
|
2215
|
+
}): Promise<{
|
|
2216
|
+
lapsed: Array<{
|
|
2217
|
+
organizationId: string;
|
|
2218
|
+
calendarId: string;
|
|
2219
|
+
startTime: Date;
|
|
2220
|
+
}>;
|
|
2221
|
+
released: number;
|
|
2222
|
+
booked: number;
|
|
2223
|
+
}>;
|
|
2224
|
+
|
|
2225
|
+
/** A slot that someone was holding an offer for and no longer is. The caller offers it to the next person. */
|
|
2226
|
+
interface FreedSlot {
|
|
2227
|
+
organizationId: string;
|
|
2228
|
+
calendarId: string;
|
|
2229
|
+
startTime: Date;
|
|
2230
|
+
}
|
|
2231
|
+
declare function listWaitlist(db: SchedulingDb, input: {
|
|
2232
|
+
organizationId: string;
|
|
2233
|
+
status?: string;
|
|
2234
|
+
limit?: number;
|
|
2235
|
+
offset?: number;
|
|
2236
|
+
}): Promise<{
|
|
2237
|
+
entries: WaitlistEntryView[];
|
|
2238
|
+
total: number;
|
|
2239
|
+
}>;
|
|
2240
|
+
/**
|
|
2241
|
+
* Removes an entry that is not mid-accept. When it held a live offer, the slot it held is returned so the caller can
|
|
2242
|
+
* offer it to the next person.
|
|
2243
|
+
*/
|
|
2244
|
+
declare function removeWaitlistEntry(db: SchedulingDb, organizationId: string, entryId: string): Promise<FreedSlot | null>;
|
|
2245
|
+
/** The client leaves by their own link. Only an entry that is waiting or holding an offer can leave; a held slot is returned. */
|
|
2246
|
+
declare function leaveWaitlist(db: SchedulingDb, token: string): Promise<FreedSlot | null>;
|
|
2247
|
+
|
|
2248
|
+
interface OfferDetails {
|
|
2249
|
+
entryId: string;
|
|
2250
|
+
organizationId: string;
|
|
2251
|
+
typeId: string;
|
|
2252
|
+
typeName: string;
|
|
2253
|
+
calendarId: string;
|
|
2254
|
+
calendarName: string;
|
|
2255
|
+
startTime: Date;
|
|
2256
|
+
timezone: string;
|
|
2257
|
+
expiresAt: Date;
|
|
2258
|
+
clientName: string;
|
|
2259
|
+
clientEmail: string;
|
|
2260
|
+
clientPhone: string | null;
|
|
2261
|
+
}
|
|
2262
|
+
/** What the offer is, for the page the client opens. Throws SCHED_1106 when there is none and SCHED_1107 when it lapsed. */
|
|
2263
|
+
declare function getWaitlistOffer(db: SchedulingDb, token: string, now?: Date): Promise<OfferDetails>;
|
|
2264
|
+
/** Claims the offer so it can be accepted once. Two clicks at the same moment: one wins, the other gets SCHED_1106. */
|
|
2265
|
+
declare function beginWaitlistAccept(db: SchedulingDb, token: string, now?: Date): Promise<OfferDetails>;
|
|
2266
|
+
declare function completeWaitlistAccept(db: SchedulingDb, entryId: string, appointmentId: string): Promise<void>;
|
|
2267
|
+
/**
|
|
2268
|
+
* What to do with an accept whose booking did not happen.
|
|
2269
|
+
* KEEP_OFFER: a temporary failure (busy, server error): the offer stays open until it expires.
|
|
2270
|
+
* BACK_IN_LINE: the slot was taken: the client keeps their place and waits for another opening.
|
|
2271
|
+
* DROP: the booking can never go through for this client (a booking rule refuses them): they come off the list and the
|
|
2272
|
+
* slot is returned, so the caller can offer it to the next person.
|
|
2273
|
+
*/
|
|
2274
|
+
type AcceptRelease = 'KEEP_OFFER' | 'BACK_IN_LINE' | 'DROP';
|
|
2275
|
+
declare function releaseWaitlistAccept(db: SchedulingDb, entryId: string, outcome?: AcceptRelease): Promise<FreedSlot | null>;
|
|
2276
|
+
interface SettledBooking {
|
|
2277
|
+
id: string;
|
|
2278
|
+
status: string;
|
|
2279
|
+
startTime: Date;
|
|
2280
|
+
endTime: Date;
|
|
2281
|
+
manageToken: string | null;
|
|
2282
|
+
clientName: string;
|
|
2283
|
+
clientEmail: string;
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Call this when an accept looks like it failed. A booking can be saved and a later step (messages, calendar sync) still
|
|
2287
|
+
* fail, so the client may already hold the slot. When they do, the entry is marked BOOKED and the booking is returned;
|
|
2288
|
+
* when they do not, this returns null and the caller releases the accept.
|
|
2289
|
+
*/
|
|
2290
|
+
declare function settleBookedAccept(db: SchedulingDb, entryId: string): Promise<SettledBooking | null>;
|
|
2291
|
+
|
|
2292
|
+
/** The calendar day an instant falls on in `timeZone`. */
|
|
2293
|
+
declare function localDay(instant: Date, timeZone: string): string;
|
|
2294
|
+
|
|
2295
|
+
type QuestionType = 'select' | 'radio' | 'checkbox' | 'text' | 'number';
|
|
2296
|
+
interface RoutingQuestion {
|
|
2297
|
+
id: string;
|
|
2298
|
+
label: string;
|
|
2299
|
+
type: QuestionType;
|
|
2300
|
+
required: boolean;
|
|
2301
|
+
/** The choices of a select, radio or checkbox question. */
|
|
2302
|
+
options?: string[];
|
|
2303
|
+
}
|
|
2304
|
+
type RoutingOperator = 'equals' | 'not_equals' | 'in' | 'contains' | 'not_contains' | 'gt' | 'gte' | 'lt' | 'lte' | 'is_answered' | 'is_empty';
|
|
2305
|
+
interface RoutingCondition {
|
|
2306
|
+
questionId: string;
|
|
2307
|
+
operator: RoutingOperator;
|
|
2308
|
+
/** A text, a number or a list of choices, depending on the operator. Not used by is_answered and is_empty. */
|
|
2309
|
+
value?: string | number | string[];
|
|
2310
|
+
}
|
|
2311
|
+
/** Where to send the client: an appointment type, a calendar, or a type on a given calendar. At least one is set. */
|
|
2312
|
+
interface RoutingDestination {
|
|
2313
|
+
typeId?: string;
|
|
2314
|
+
calendarId?: string;
|
|
2315
|
+
}
|
|
2316
|
+
interface RoutingRule {
|
|
2317
|
+
id: string;
|
|
2318
|
+
label?: string;
|
|
2319
|
+
/** `all`: every condition must hold. `any`: one is enough. */
|
|
2320
|
+
match: 'all' | 'any';
|
|
2321
|
+
conditions: RoutingCondition[];
|
|
2322
|
+
destination: RoutingDestination;
|
|
2323
|
+
}
|
|
2324
|
+
/** What happens when no rule matches: send the client somewhere anyway, or show a message. */
|
|
2325
|
+
type RoutingFallback = {
|
|
2326
|
+
kind: 'DESTINATION';
|
|
2327
|
+
destination: RoutingDestination;
|
|
2328
|
+
} | {
|
|
2329
|
+
kind: 'MESSAGE';
|
|
2330
|
+
message: string;
|
|
2331
|
+
};
|
|
2332
|
+
interface RoutingFormDefinition {
|
|
2333
|
+
questions: RoutingQuestion[];
|
|
2334
|
+
rules: RoutingRule[];
|
|
2335
|
+
fallback: RoutingFallback;
|
|
2336
|
+
}
|
|
2337
|
+
type RoutingAnswers = Record<string, string | number | string[]>;
|
|
2338
|
+
interface RoutingProblem {
|
|
2339
|
+
/** Where in the form, such as `rules[2].conditions[0].value`. */
|
|
2340
|
+
path: string;
|
|
2341
|
+
message: string;
|
|
2342
|
+
}
|
|
2343
|
+
declare const LIMITS: {
|
|
2344
|
+
readonly questions: 20;
|
|
2345
|
+
readonly rules: 50;
|
|
2346
|
+
readonly conditionsPerRule: 10;
|
|
2347
|
+
readonly options: 50;
|
|
2348
|
+
readonly label: 200;
|
|
2349
|
+
readonly option: 100;
|
|
2350
|
+
readonly message: 500;
|
|
2351
|
+
readonly textAnswer: 1000;
|
|
2352
|
+
readonly problems: 50;
|
|
2353
|
+
readonly formsPerOrganization: 50;
|
|
2354
|
+
};
|
|
2355
|
+
|
|
2356
|
+
/** Which operators each kind of question allows. */
|
|
2357
|
+
declare const OPERATORS_BY_TYPE: Record<QuestionType, RoutingOperator[]>;
|
|
2358
|
+
type StructureResult = {
|
|
2359
|
+
ok: true;
|
|
2360
|
+
value: RoutingFormDefinition;
|
|
2361
|
+
} | {
|
|
2362
|
+
ok: false;
|
|
2363
|
+
problems: RoutingProblem[];
|
|
2364
|
+
};
|
|
2365
|
+
declare function validateRoutingStructure(input: unknown): StructureResult;
|
|
2366
|
+
|
|
2367
|
+
declare function validateRoutingDestinations(db: SchedulingDb, organizationId: string, definition: RoutingFormDefinition): Promise<RoutingProblem[]>;
|
|
2368
|
+
|
|
2369
|
+
type AnswerCheck = {
|
|
2370
|
+
ok: true;
|
|
2371
|
+
answers: RoutingAnswers;
|
|
2372
|
+
} | {
|
|
2373
|
+
ok: false;
|
|
2374
|
+
problems: RoutingProblem[];
|
|
2375
|
+
};
|
|
2376
|
+
/** Checks the answers fit the questions: required ones present, choices among the options, nothing the form did not ask. */
|
|
2377
|
+
declare function checkAnswers(questions: RoutingQuestion[], input: unknown): AnswerCheck;
|
|
2378
|
+
/** Every rule the answers satisfy, in the order the rules are listed. The first is the one that wins. */
|
|
2379
|
+
declare function matchingRules(definition: Pick<RoutingFormDefinition, 'rules'>, answers: RoutingAnswers): RoutingRule[];
|
|
2380
|
+
|
|
2381
|
+
interface RoutingFormView extends RoutingFormDefinition {
|
|
2382
|
+
id: string;
|
|
2383
|
+
name: string;
|
|
2384
|
+
slug: string;
|
|
2385
|
+
description: string | null;
|
|
2386
|
+
isActive: boolean;
|
|
2387
|
+
createdAt: Date;
|
|
2388
|
+
updatedAt: Date;
|
|
2389
|
+
}
|
|
2390
|
+
interface RoutingFormSummary {
|
|
2391
|
+
id: string;
|
|
2392
|
+
name: string;
|
|
2393
|
+
slug: string;
|
|
2394
|
+
description: string | null;
|
|
2395
|
+
isActive: boolean;
|
|
2396
|
+
updatedAt: Date;
|
|
2397
|
+
}
|
|
2398
|
+
interface RoutingFormInput {
|
|
2399
|
+
name: string;
|
|
2400
|
+
slug: string;
|
|
2401
|
+
description?: string | null;
|
|
2402
|
+
isActive?: boolean;
|
|
2403
|
+
questions: unknown;
|
|
2404
|
+
rules: unknown;
|
|
2405
|
+
fallback: unknown;
|
|
2406
|
+
}
|
|
2407
|
+
declare function createRoutingForm(db: SchedulingDb, organizationId: string, input: RoutingFormInput): Promise<RoutingFormView>;
|
|
2408
|
+
declare function getRoutingForm(db: SchedulingDb, organizationId: string, id: string): Promise<RoutingFormView>;
|
|
2409
|
+
declare function listRoutingForms(db: SchedulingDb, organizationId: string): Promise<RoutingFormSummary[]>;
|
|
2410
|
+
/** Changes the given fields and checks the whole result again, since a changed question can break an existing rule. */
|
|
2411
|
+
declare function updateRoutingForm(db: SchedulingDb, organizationId: string, id: string, patch: Partial<RoutingFormInput>): Promise<RoutingFormView>;
|
|
2412
|
+
declare function deleteRoutingForm(db: SchedulingDb, organizationId: string, id: string): Promise<void>;
|
|
2413
|
+
|
|
2414
|
+
interface PublicRoutingForm {
|
|
2415
|
+
name: string;
|
|
2416
|
+
slug: string;
|
|
2417
|
+
description: string | null;
|
|
2418
|
+
questions: RoutingQuestion[];
|
|
2419
|
+
}
|
|
2420
|
+
interface ResolvedDestination {
|
|
2421
|
+
typeId: string | null;
|
|
2422
|
+
typeSlug: string | null;
|
|
2423
|
+
typeName: string | null;
|
|
2424
|
+
calendarId: string | null;
|
|
2425
|
+
calendarSlug: string | null;
|
|
2426
|
+
calendarName: string | null;
|
|
2427
|
+
}
|
|
2428
|
+
interface RoutingOutcome {
|
|
2429
|
+
/** Where to send the client, or null when the form says to show `message` instead. */
|
|
2430
|
+
destination: ResolvedDestination | null;
|
|
2431
|
+
message: string | null;
|
|
2432
|
+
/** The rule that decided it, or null when the fallback did. */
|
|
2433
|
+
matchedRuleId: string | null;
|
|
2434
|
+
usedFallback: boolean;
|
|
2435
|
+
}
|
|
2436
|
+
/** The questions only. The rules and the fallback stay on the server. */
|
|
2437
|
+
declare function getPublicRoutingForm(db: SchedulingDb, input: {
|
|
2438
|
+
organizationId: string | null;
|
|
2439
|
+
slug: string;
|
|
2440
|
+
}): Promise<PublicRoutingForm>;
|
|
2441
|
+
/** Looks the destination up now: a type or calendar switched off since the form was saved is not sent to. */
|
|
2442
|
+
declare function resolveDestination(db: SchedulingDb, organizationId: string, destination: RoutingDestination): Promise<ResolvedDestination | null>;
|
|
2443
|
+
/**
|
|
2444
|
+
* Sends a client on. The first matching rule whose destination is still live wins; if none is, the fallback decides.
|
|
2445
|
+
* A form whose fallback destination is also gone tells the client to get in touch.
|
|
2446
|
+
*/
|
|
2447
|
+
declare function routeClient(db: SchedulingDb, input: {
|
|
2448
|
+
organizationId: string | null;
|
|
2449
|
+
slug: string;
|
|
2450
|
+
answers: unknown;
|
|
2451
|
+
}): Promise<RoutingOutcome>;
|
|
2452
|
+
/** Staff trying a form with sample answers. Works on a form that is switched off, and lists every rule that matched. */
|
|
2453
|
+
declare function testRoutingForm(db: SchedulingDb, input: {
|
|
2454
|
+
organizationId: string;
|
|
2455
|
+
id: string;
|
|
2456
|
+
answers: unknown;
|
|
2457
|
+
}): Promise<RoutingOutcome & {
|
|
2458
|
+
allMatchedRuleIds: string[];
|
|
2459
|
+
}>;
|
|
2460
|
+
|
|
2461
|
+
interface ParsedSubject {
|
|
2462
|
+
email: string | null;
|
|
2463
|
+
clientId: string | null;
|
|
2464
|
+
}
|
|
2465
|
+
interface ResolvedSubject {
|
|
2466
|
+
/** Lower-case addresses, without repeats. */
|
|
2467
|
+
emails: string[];
|
|
2468
|
+
clientId: string | null;
|
|
2469
|
+
}
|
|
2470
|
+
/** Checks the request names somebody, and in a way that cannot match more than that person. */
|
|
2471
|
+
declare function parseSubject(input: {
|
|
2472
|
+
email?: unknown;
|
|
2473
|
+
clientId?: unknown;
|
|
2474
|
+
}): ParsedSubject;
|
|
2475
|
+
/** One digest per identifier, tied to the organization. The request record keeps these instead of the address itself. */
|
|
2476
|
+
declare function subjectHashes(organizationId: string, subject: ResolvedSubject): string[];
|
|
2477
|
+
/** Adds the addresses a client id stands for: those on the client's bookings and series in this organization. */
|
|
2478
|
+
declare function resolveSubject(db: SchedulingDb, organizationId: string, parsed: ParsedSubject): Promise<ResolvedSubject>;
|
|
2479
|
+
|
|
2480
|
+
declare function collectSubjectRows(db: SchedulingDb, organizationId: string, subject: ResolvedSubject): Promise<{
|
|
2481
|
+
appointments: {
|
|
2482
|
+
couponCode: string | null;
|
|
2483
|
+
startTime: Date;
|
|
2484
|
+
cancelledAt: Date | null;
|
|
2485
|
+
cancelledBy: string | null;
|
|
2486
|
+
id: string;
|
|
2487
|
+
type: {
|
|
2488
|
+
name: string;
|
|
2489
|
+
};
|
|
2490
|
+
timezone: string;
|
|
2491
|
+
location: string | null;
|
|
2492
|
+
createdAt: Date;
|
|
2493
|
+
updatedAt: Date;
|
|
2494
|
+
calendar: {
|
|
2495
|
+
name: string;
|
|
2496
|
+
};
|
|
2497
|
+
endTime: Date;
|
|
2498
|
+
duration: number;
|
|
2499
|
+
clientName: string;
|
|
2500
|
+
clientEmail: string;
|
|
2501
|
+
clientPhone: string | null;
|
|
2502
|
+
clientId: string | null;
|
|
2503
|
+
status: _prisma_client.$Enums.AppointmentStatus;
|
|
2504
|
+
cancelReason: string | null;
|
|
2505
|
+
rescheduledFrom: Date | null;
|
|
2506
|
+
rescheduleCount: number;
|
|
2507
|
+
intakeResponses: _prisma_client_runtime_client.JsonValue;
|
|
2508
|
+
paymentStatus: string | null;
|
|
2509
|
+
paymentAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2510
|
+
depositAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2511
|
+
tipAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2512
|
+
paymentProvider: string | null;
|
|
2513
|
+
paymentId: string | null;
|
|
2514
|
+
balancePaymentId: string | null;
|
|
2515
|
+
discountAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2516
|
+
cancellationFeeAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2517
|
+
refundAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2518
|
+
refundStatus: _prisma_client.$Enums.RefundStatus | null;
|
|
2519
|
+
isGroup: boolean;
|
|
2520
|
+
notes: string | null;
|
|
2521
|
+
staffNotes: string | null;
|
|
2522
|
+
meetingUrl: string | null;
|
|
2523
|
+
recurringId: string | null;
|
|
2524
|
+
recurringIndex: number | null;
|
|
2525
|
+
packagePurchaseId: string | null;
|
|
2526
|
+
}[];
|
|
2527
|
+
notifications: never[] | {
|
|
2528
|
+
id: string;
|
|
2529
|
+
createdAt: Date;
|
|
2530
|
+
status: string;
|
|
2531
|
+
appointmentId: string;
|
|
2532
|
+
channel: string;
|
|
2533
|
+
trigger: string;
|
|
2534
|
+
recipient: string;
|
|
2535
|
+
subject: string | null;
|
|
2536
|
+
body: string;
|
|
2537
|
+
scheduledFor: Date;
|
|
2538
|
+
sentAt: Date | null;
|
|
2539
|
+
}[];
|
|
2540
|
+
waitlistEntries: never[] | {
|
|
2541
|
+
id: string;
|
|
2542
|
+
timezone: string;
|
|
2543
|
+
createdAt: Date;
|
|
2544
|
+
calendarId: string | null;
|
|
2545
|
+
day: string;
|
|
2546
|
+
typeId: string;
|
|
2547
|
+
clientName: string;
|
|
2548
|
+
clientEmail: string;
|
|
2549
|
+
clientPhone: string | null;
|
|
2550
|
+
status: string;
|
|
2551
|
+
slotStart: Date | null;
|
|
2552
|
+
offerSlotStart: Date | null;
|
|
2553
|
+
offerExpiresAt: Date | null;
|
|
2554
|
+
offeredAt: Date | null;
|
|
2555
|
+
bookedAppointmentId: string | null;
|
|
2556
|
+
}[];
|
|
2557
|
+
packagePurchases: never[] | {
|
|
2558
|
+
id: string;
|
|
2559
|
+
createdAt: Date;
|
|
2560
|
+
clientName: string | null;
|
|
2561
|
+
clientEmail: string;
|
|
2562
|
+
status: _prisma_client.$Enums.PackagePurchaseStatus;
|
|
2563
|
+
paymentId: string | null;
|
|
2564
|
+
notes: string | null;
|
|
2565
|
+
expiresAt: Date | null;
|
|
2566
|
+
packageId: string;
|
|
2567
|
+
sessionsTotal: number;
|
|
2568
|
+
sessionsUsed: number;
|
|
2569
|
+
purchasedAt: Date;
|
|
2570
|
+
pricePaidCents: number | null;
|
|
2571
|
+
}[];
|
|
2572
|
+
recurringSeries: never[] | {
|
|
2573
|
+
id: string;
|
|
2574
|
+
timezone: string;
|
|
2575
|
+
createdAt: Date;
|
|
2576
|
+
calendarId: string;
|
|
2577
|
+
typeId: string;
|
|
2578
|
+
clientName: string;
|
|
2579
|
+
clientEmail: string;
|
|
2580
|
+
clientPhone: string | null;
|
|
2581
|
+
clientId: string | null;
|
|
2582
|
+
status: _prisma_client.$Enums.RecurringSeriesStatus;
|
|
2583
|
+
notes: string | null;
|
|
2584
|
+
frequency: _prisma_client.$Enums.RecurringFrequency;
|
|
2585
|
+
occurrences: number;
|
|
2586
|
+
startTimeLocal: string;
|
|
2587
|
+
durationMins: number;
|
|
2588
|
+
endsAt: Date | null;
|
|
2589
|
+
}[];
|
|
2590
|
+
webhookDeliveries: {
|
|
2591
|
+
id: string;
|
|
2592
|
+
eventId: string;
|
|
2593
|
+
eventType: string;
|
|
2594
|
+
body: string;
|
|
2595
|
+
status: string;
|
|
2596
|
+
createdAt: Date;
|
|
2597
|
+
}[];
|
|
2598
|
+
}>;
|
|
2599
|
+
type SubjectRows = Awaited<ReturnType<typeof collectSubjectRows>>;
|
|
2600
|
+
interface SubjectCounts {
|
|
2601
|
+
appointments: number;
|
|
2602
|
+
notifications: number;
|
|
2603
|
+
waitlistEntries: number;
|
|
2604
|
+
packagePurchases: number;
|
|
2605
|
+
recurringSeries: number;
|
|
2606
|
+
webhookDeliveries: number;
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
interface SubjectExport {
|
|
2610
|
+
format: 'ordinatio-scheduling-subject-export';
|
|
2611
|
+
version: 1;
|
|
2612
|
+
exportedAt: string;
|
|
2613
|
+
organizationId: string;
|
|
2614
|
+
subject: {
|
|
2615
|
+
emails: string[];
|
|
2616
|
+
clientId: string | null;
|
|
2617
|
+
};
|
|
2618
|
+
counts: SubjectCounts;
|
|
2619
|
+
appointments: Array<Omit<SubjectRows['appointments'][number], 'calendar' | 'type'> & {
|
|
2620
|
+
calendarName: string;
|
|
2621
|
+
typeName: string;
|
|
2622
|
+
}>;
|
|
2623
|
+
notifications: SubjectRows['notifications'];
|
|
2624
|
+
waitlistEntries: SubjectRows['waitlistEntries'];
|
|
2625
|
+
packagePurchases: SubjectRows['packagePurchases'];
|
|
2626
|
+
recurringSeries: SubjectRows['recurringSeries'];
|
|
2627
|
+
webhookDeliveries: SubjectRows['webhookDeliveries'];
|
|
2628
|
+
}
|
|
2629
|
+
declare function exportSubject(db: SchedulingDb, input: {
|
|
2630
|
+
organizationId: string;
|
|
2631
|
+
requestedBy: string;
|
|
2632
|
+
email?: unknown;
|
|
2633
|
+
clientId?: unknown;
|
|
2634
|
+
now?: Date;
|
|
2635
|
+
}): Promise<SubjectExport>;
|
|
2636
|
+
|
|
2637
|
+
declare const ERASED_NAME = "Erased client";
|
|
2638
|
+
declare const ERASED_EMAIL = "erased@erased.invalid";
|
|
2639
|
+
interface EraseBlockers {
|
|
2640
|
+
upcomingAppointments: number;
|
|
2641
|
+
liveWaitlistEntries: number;
|
|
2642
|
+
}
|
|
2643
|
+
interface ErasePreview {
|
|
2644
|
+
counts: SubjectCounts;
|
|
2645
|
+
blockers: EraseBlockers;
|
|
2646
|
+
canErase: boolean;
|
|
2647
|
+
warnings: string[];
|
|
2648
|
+
}
|
|
2649
|
+
/** What an erasure would remove and whether anything stops it. Changes and records nothing. */
|
|
2650
|
+
declare function previewErase(db: SchedulingDb, input: {
|
|
2651
|
+
organizationId: string;
|
|
2652
|
+
email?: unknown;
|
|
2653
|
+
clientId?: unknown;
|
|
2654
|
+
now?: Date;
|
|
2655
|
+
}): Promise<ErasePreview>;
|
|
2656
|
+
declare function eraseSubject(db: SchedulingDb, input: {
|
|
2657
|
+
organizationId: string;
|
|
2658
|
+
requestedBy: string;
|
|
2659
|
+
email?: unknown;
|
|
2660
|
+
clientId?: unknown;
|
|
2661
|
+
now?: Date;
|
|
2662
|
+
}): Promise<{
|
|
2663
|
+
counts: SubjectCounts;
|
|
2664
|
+
}>;
|
|
2665
|
+
|
|
2666
|
+
type PrivacyRequestKind = 'EXPORT' | 'ERASE';
|
|
2667
|
+
interface PrivacyRequestView {
|
|
2668
|
+
id: string;
|
|
2669
|
+
kind: string;
|
|
2670
|
+
requestedBy: string;
|
|
2671
|
+
counts: unknown;
|
|
2672
|
+
createdAt: Date;
|
|
2673
|
+
}
|
|
2674
|
+
declare function listPrivacyRequests(db: SchedulingDb, input: {
|
|
2675
|
+
organizationId: string;
|
|
2676
|
+
limit?: number;
|
|
2677
|
+
offset?: number;
|
|
2678
|
+
}): Promise<{
|
|
2679
|
+
requests: PrivacyRequestView[];
|
|
2680
|
+
total: number;
|
|
2681
|
+
}>;
|
|
2682
|
+
|
|
2683
|
+
interface BrandFields {
|
|
2684
|
+
displayName: string;
|
|
2685
|
+
logoUrl: string | null;
|
|
2686
|
+
primaryColor: string | null;
|
|
2687
|
+
accentColor: string | null;
|
|
2688
|
+
backgroundColor: string | null;
|
|
2689
|
+
textColor: string | null;
|
|
2690
|
+
fontFamily: string | null;
|
|
2691
|
+
footerText: string | null;
|
|
2692
|
+
replyToEmail: string | null;
|
|
2693
|
+
fromName: string | null;
|
|
2694
|
+
fromEmail: string | null;
|
|
2695
|
+
}
|
|
2696
|
+
interface BrandView extends BrandFields {
|
|
2697
|
+
updatedAt: Date;
|
|
2698
|
+
}
|
|
2699
|
+
/** What a visitor of the booking page may see: no email addresses. */
|
|
2700
|
+
interface PublicBrand {
|
|
2701
|
+
displayName: string;
|
|
2702
|
+
logoUrl: string | null;
|
|
2703
|
+
primaryColor: string | null;
|
|
2704
|
+
accentColor: string | null;
|
|
2705
|
+
backgroundColor: string | null;
|
|
2706
|
+
textColor: string | null;
|
|
2707
|
+
fontFamily: string | null;
|
|
2708
|
+
footerText: string | null;
|
|
2709
|
+
}
|
|
2710
|
+
interface BrandProblem {
|
|
2711
|
+
path: string;
|
|
2712
|
+
message: string;
|
|
2713
|
+
}
|
|
2714
|
+
declare const BRAND_FIELDS: readonly ["displayName", "logoUrl", "primaryColor", "accentColor", "backgroundColor", "textColor", "fontFamily", "footerText", "replyToEmail", "fromName", "fromEmail"];
|
|
2715
|
+
|
|
2716
|
+
interface ValidateBrandOptions {
|
|
2717
|
+
/**
|
|
2718
|
+
* Says whether the host may send mail from this domain (lower case). Without it no sending address is accepted: an
|
|
2719
|
+
* organization must not be able to send as a domain it does not control.
|
|
2720
|
+
*/
|
|
2721
|
+
isSendingDomainVerified?: (domain: string) => Promise<boolean>;
|
|
2722
|
+
}
|
|
2723
|
+
/** The stored form of the settings, or a SCHED_1400 error listing every problem. */
|
|
2724
|
+
declare function validateBrand(input: unknown, options: ValidateBrandOptions): Promise<BrandFields>;
|
|
2725
|
+
|
|
2726
|
+
declare function getBrand(db: SchedulingDb, organizationId: string): Promise<BrandView | null>;
|
|
2727
|
+
/**
|
|
2728
|
+
* What the booking page may show. With no organization named (a server with one organization) it is the brand of the
|
|
2729
|
+
* only organization that has one; with several, none is chosen for the visitor.
|
|
2730
|
+
*/
|
|
2731
|
+
declare function getPublicBrand(db: SchedulingDb, organizationId: string | null): Promise<PublicBrand | null>;
|
|
2732
|
+
/** Saves the whole brand, replacing what was there. Throws SCHED_1400 listing every problem. */
|
|
2733
|
+
declare function saveBrand(db: SchedulingDb, organizationId: string, input: unknown, options: ValidateBrandOptions): Promise<BrandView>;
|
|
2734
|
+
/** Removes the brand. True when there was one. */
|
|
2735
|
+
declare function deleteBrand(db: SchedulingDb, organizationId: string): Promise<boolean>;
|
|
2736
|
+
|
|
2737
|
+
/** The sender of an organization's messages, or null when there is no brand. Only what is set is included. */
|
|
2738
|
+
declare function senderIdentity(brand: BrandFields | null): SenderIdentity | null;
|
|
2739
|
+
/** Values for `{{brandName}}`, `{{brandLogoUrl}}`, `{{brandColor}}` and `{{brandFooter}}`; empty text when not set. */
|
|
2740
|
+
declare function brandTemplateFields(brand: BrandFields | null): Record<string, string>;
|
|
2741
|
+
declare function toPublicBrand(brand: BrandFields): PublicBrand;
|
|
2742
|
+
|
|
2743
|
+
export { type AcceptRelease, type AddTimeBlockInput, type AppointmentDashboardData, type AppointmentDashboardItem, type AppointmentDashboardStats, type AppointmentLocationType, type AppointmentStatus, type AppointmentWithDetails, type AssignmentStrategy, type AttemptOptions, type AuthAdapter, type AuthContext, type AvailabilityQuery, type AvailabilityResult, type AvailabilityRuleInput, BRAND_FIELDS, BlockedTargetError, type BookAppointmentInput, type BookingAnalytics, type BrandFields, type BrandProblem, type BrandView, type CalendarEvent, type CalendarEventRef, type CalendarSyncAdapter, type CalendarType, type CancelInput, type CancelRecurringScope, type CancellationFeeConfig, type CancellationFeeResult, type ChargeRequest, type ChargeResult, type Clock, type CreateAppointmentTypeInput, type CreateCalendarInput, DEFAULT_BACKOFF_SECONDS, DEFAULT_OFFER_MINUTES, type DashboardQuery, type DayAppointment, type DeliverOptions, type DeliverSummary, ERASED_EMAIL, ERASED_NAME, type EraseBlockers, type ErasePreview, type FreedSlot, type GroupCapacityResult, type GroupSession, type GroupSessionAttendee, type InMemoryClockControl, type InMemoryOptions, type InMemoryRecords, type IntakeFormField, type JoinWaitlistInput, LIMITS, MAX_ENDPOINTS_PER_ORGANIZATION, MAX_WAITING_PER_TYPE_DAY, type MarkNoShowInput, type NotificationAdapter, type NotificationChannel, type NotificationContext, type NotificationSender, type NotificationTrigger, OPERATORS_BY_TYPE, type OfferDetails, type OrgCancellationPolicy, type OutboundMessage, type ParsedSubject, type PaymentAdapter, type PaymentCheck, type PaymentContractOptions, type PaymentProcessor, type PaymentResult, type PrivacyRequestKind, type PrivacyRequestView, type PublicBrand, type PublicRoutingForm, type QuestionType, RECURRING_MAX_OCCURRENCES, LIMITS as ROUTING_LIMITS, type RecurringFrequency, type RefundOptions, type RefundResult, type RescheduleInput, type ResolvedDestination, type ResolvedSubject, type RetryConfig, type RoutingAnswers, type RoutingCondition, type RoutingDestination, type RoutingFallback, type RoutingFormDefinition, type RoutingFormInput, type RoutingFormSummary, type RoutingFormView, type RoutingOperator, type RoutingOutcome, type RoutingProblem, type RoutingQuestion, type RoutingRule, SCHEDULING_ERRORS, SIGNATURE_HEADER, type SchedulingAdapters, type SchedulingCallbacks, type SchedulingDb, SchedulingNotFoundError, SchedulingValidationError, type SendResult, type SettledBooking, type SubjectCounts, type SubjectExport, type TeamAvailabilityQuery, type TeamAvailabilityResult, type TestSendResult, type TimeSlot, type TransportRequest, USER_DAY_LIMIT, type UpdateCalendarInput, type UrlCheckOptions, type UserDayInput, type UserDayResult, type ValidateBrandOptions, WEBHOOK_EVENT_TYPES, WEBHOOK_TEST_EVENT, type WaitlistEntryView, type WaitlistOffer, type WebhookDeliveryView, type WebhookEndpointView, type WebhookEnvelope, type WebhookEventType, type WebhookTransport, adaptersToCallbacks, addDateOverride, addTimeBlock, appointmentWebhookData, archiveCalendar, beginWaitlistAccept, bookAppointment, brandTemplateFields, buildJitsiUrl, buildNotificationContext, buildOccurrenceStartTime, buildRecurringSlots, calculateCancellationFee, cancelAppointment, cancelPendingNotifications, checkAnswers, checkAuthContract, checkCalendarSyncContract, checkClockContract, checkNotificationContract, checkPaymentContract, checkWebhookUrl, completeWaitlistAccept, createAppointmentType, createCalendar, createInMemoryAdapters, createNodeTransport, createNotificationTemplate, createRoutingForm, createWebhookEndpoint, deleteBrand, deleteCalendar, deleteNotificationTemplate, deleteRoutingForm, deleteWebhookEndpoint, deliverDueWebhooks, enqueueAppointmentWebhook, enqueueReminderSent, enqueueWebhookEvent, eraseSubject, expireWaitlistOffers, exportSubject, generateOccurrenceDates, generateWebhookSecret, getAppointment, getAppointmentDashboard, getAppointmentType, getAppointmentsForRange, getAvailableDates, getAvailableSlots, getBookingAnalytics, getBrand, getCalendar, getGroupCapacity, getGroupSessions, getNotificationTemplate, getPublicBrand, getPublicRoutingForm, getRoutingForm, getTeamAvailableSlots, getUserDayAppointments, getWaitlistOffer, isPrivateAddress, isSlotAvailable, isVirtualMeeting, joinWaitlist, leaveWaitlist, listAppointmentTypes, listAppointments, listAvailabilityRules, listCalendars, listNotificationTemplates, listPrivacyRequests, listRoutingForms, listWaitlist, listWebhookDeliveries, listWebhookEndpoints, localDay, localToUTC, markNoShow, matchingRules, offerFreedSlot, parseSubject, parseTimeLocal, previewErase, processPendingNotifications, queueImmediateNotification, queueStaffNotification, releaseWaitlistAccept, removeDateOverride, removeWaitlistEntry, renderTemplate, rescheduleAppointment, resolveDestination, resolveLocation, resolveSubject, retryWebhookDelivery, routeClient, saveBrand, schedError, scheduleNotifications, scopeToOrganization, selectCalendarForBooking, sendTestWebhook, senderIdentity, setWeeklyAvailability, settleBookedAccept, signWebhook, subjectHashes, testRoutingForm, toPublicBrand, tryOfferFreedSlot, updateAppointmentType, updateCalendar, updateNotificationTemplate, updateRoutingForm, validateBrand, validateRoutingDestinations, validateRoutingStructure, verifyWebhookSignature, withCalendarVisibility, withOrganization };
|