@ordinatio/scheduling 0.2.1 → 0.4.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 +54 -0
- package/README.md +233 -2
- package/dist/index.d.mts +817 -4
- package/dist/index.d.ts +817 -4
- package/dist/index.js +2332 -27
- package/dist/index.mjs +2253 -29
- package/package.json +1 -1
- package/prisma/migrations/20261027000000_webhooks/migration.sql +75 -0
- 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 +158 -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' | '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.
|
|
@@ -1382,6 +1394,8 @@ interface OutboundMessage {
|
|
|
1382
1394
|
subject: string;
|
|
1383
1395
|
body: string;
|
|
1384
1396
|
trigger?: NotificationTrigger;
|
|
1397
|
+
/** The organization's own sender identity, when it has one. An adapter that cannot send as it uses its default sender. */
|
|
1398
|
+
from?: SenderIdentity;
|
|
1385
1399
|
}
|
|
1386
1400
|
type SendResult = {
|
|
1387
1401
|
status: 'SENT';
|
|
@@ -1607,6 +1621,10 @@ declare function processPendingNotifications(db: SchedulingDb, sender: Notificat
|
|
|
1607
1621
|
workerId?: string;
|
|
1608
1622
|
staleThresholdMs?: number;
|
|
1609
1623
|
maxOverdueMs?: number;
|
|
1624
|
+
/** Queue a `reminder.sent` webhook for each reminder that was sent. Off by default; needs the webhook tables. */
|
|
1625
|
+
webhooks?: boolean;
|
|
1626
|
+
/** Send each message with its organization's sender identity (name, address, reply-to). Off by default; needs the brand table. */
|
|
1627
|
+
brand?: boolean;
|
|
1610
1628
|
}): Promise<{
|
|
1611
1629
|
sent: number;
|
|
1612
1630
|
failed: number;
|
|
@@ -1620,6 +1638,7 @@ declare function processPendingNotifications(db: SchedulingDb, sender: Notificat
|
|
|
1620
1638
|
*/
|
|
1621
1639
|
declare function scheduleNotifications(db: SchedulingDb, appointmentId: string, baseUrl?: string, options?: {
|
|
1622
1640
|
excludeTriggers?: NotificationTrigger[];
|
|
1641
|
+
brand?: boolean;
|
|
1623
1642
|
}): Promise<number | undefined>;
|
|
1624
1643
|
/**
|
|
1625
1644
|
* Cancel all pending notifications for an appointment.
|
|
@@ -1636,14 +1655,18 @@ declare function cancelPendingNotifications(db: SchedulingDb, appointmentId: str
|
|
|
1636
1655
|
* Previously called sendImmediateNotification — renamed to make the
|
|
1637
1656
|
* async queue-based behavior explicit.
|
|
1638
1657
|
*/
|
|
1639
|
-
declare function queueImmediateNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string
|
|
1658
|
+
declare function queueImmediateNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string, options?: {
|
|
1659
|
+
brand?: boolean;
|
|
1660
|
+
}): Promise<void>;
|
|
1640
1661
|
/**
|
|
1641
1662
|
* Queue an immediate email notification to the calendar's staff member.
|
|
1642
1663
|
* Silently skips if: appointment not found, no staffEmail on the calendar,
|
|
1643
1664
|
* or no active STAFF templates exist for the trigger.
|
|
1644
1665
|
* Failure must NEVER block the caller — always wrap call sites in try/catch.
|
|
1645
1666
|
*/
|
|
1646
|
-
declare function queueStaffNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string
|
|
1667
|
+
declare function queueStaffNotification(db: SchedulingDb, appointmentId: string, trigger: NotificationTrigger, baseUrl?: string, options?: {
|
|
1668
|
+
brand?: boolean;
|
|
1669
|
+
}): Promise<void>;
|
|
1647
1670
|
|
|
1648
1671
|
/**
|
|
1649
1672
|
* List all notification templates for an org, sorted by channel then trigger.
|
|
@@ -1898,4 +1921,794 @@ declare function getTeamAvailableSlots(db: SchedulingDb, query: TeamAvailability
|
|
|
1898
1921
|
*/
|
|
1899
1922
|
declare function localToUTC(dateStr: string, timeStr: string, tz: string): Date;
|
|
1900
1923
|
|
|
1901
|
-
|
|
1924
|
+
declare const WEBHOOK_EVENT_TYPES: readonly ["appointment.booked", "appointment.rescheduled", "appointment.cancelled", "appointment.no_show", "reminder.sent", "waitlist.offered"];
|
|
1925
|
+
type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
|
|
1926
|
+
/** Sent only by the "test" action; no endpoint subscribes to it. */
|
|
1927
|
+
declare const WEBHOOK_TEST_EVENT = "webhook.test";
|
|
1928
|
+
interface WebhookEnvelope {
|
|
1929
|
+
id: string;
|
|
1930
|
+
type: string;
|
|
1931
|
+
createdAt: string;
|
|
1932
|
+
organizationId: string;
|
|
1933
|
+
data: Record<string, unknown>;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
declare const SIGNATURE_HEADER = "x-scheduling-signature";
|
|
1937
|
+
declare function generateWebhookSecret(): string;
|
|
1938
|
+
/** The header value: `t=<unix seconds>,v1=<hex hmac-sha256 of "<t>.<body>">`. */
|
|
1939
|
+
declare function signWebhook(args: {
|
|
1940
|
+
secret: string;
|
|
1941
|
+
body: string;
|
|
1942
|
+
now: Date;
|
|
1943
|
+
}): string;
|
|
1944
|
+
/**
|
|
1945
|
+
* True only when the header was made with this secret for exactly this body, and its timestamp is within
|
|
1946
|
+
* `toleranceSeconds` of now (default 5 minutes, both directions). Never throws on a malformed header.
|
|
1947
|
+
*/
|
|
1948
|
+
declare function verifyWebhookSignature(args: {
|
|
1949
|
+
secret: string;
|
|
1950
|
+
header: string | null | undefined;
|
|
1951
|
+
body: string;
|
|
1952
|
+
toleranceSeconds?: number;
|
|
1953
|
+
now?: Date;
|
|
1954
|
+
}): boolean;
|
|
1955
|
+
|
|
1956
|
+
interface UrlCheckOptions {
|
|
1957
|
+
/** Allows http and addresses on this machine or a private network. For local development and tests only. */
|
|
1958
|
+
allowInsecureTargets?: boolean;
|
|
1959
|
+
}
|
|
1960
|
+
type UrlCheck = {
|
|
1961
|
+
ok: true;
|
|
1962
|
+
url: URL;
|
|
1963
|
+
} | {
|
|
1964
|
+
ok: false;
|
|
1965
|
+
reason: string;
|
|
1966
|
+
};
|
|
1967
|
+
/** True for loopback, private, link-local, carrier-grade NAT, multicast and unspecified addresses. */
|
|
1968
|
+
declare function isPrivateAddress(ip: string): boolean;
|
|
1969
|
+
declare function checkWebhookUrl(raw: string, options?: UrlCheckOptions): UrlCheck;
|
|
1970
|
+
|
|
1971
|
+
interface TransportRequest {
|
|
1972
|
+
url: URL;
|
|
1973
|
+
headers: Record<string, string>;
|
|
1974
|
+
body: string;
|
|
1975
|
+
timeoutMs: number;
|
|
1976
|
+
}
|
|
1977
|
+
/** The status the receiver answered with. Rejects on a network failure, a timeout or a blocked target. */
|
|
1978
|
+
type WebhookTransport = (request: TransportRequest) => Promise<{
|
|
1979
|
+
status: number;
|
|
1980
|
+
}>;
|
|
1981
|
+
declare class BlockedTargetError extends Error {
|
|
1982
|
+
constructor(hostname: string);
|
|
1983
|
+
}
|
|
1984
|
+
declare function createNodeTransport(options?: {
|
|
1985
|
+
allowInsecureTargets?: boolean;
|
|
1986
|
+
}): WebhookTransport;
|
|
1987
|
+
|
|
1988
|
+
declare const MAX_ENDPOINTS_PER_ORGANIZATION = 20;
|
|
1989
|
+
/** An endpoint as the outside world sees it. The secret is never part of it. */
|
|
1990
|
+
interface WebhookEndpointView {
|
|
1991
|
+
id: string;
|
|
1992
|
+
url: string;
|
|
1993
|
+
description: string | null;
|
|
1994
|
+
eventTypes: string[];
|
|
1995
|
+
isActive: boolean;
|
|
1996
|
+
createdAt: Date;
|
|
1997
|
+
}
|
|
1998
|
+
declare function createWebhookEndpoint(db: SchedulingDb, input: {
|
|
1999
|
+
organizationId: string;
|
|
2000
|
+
url: string;
|
|
2001
|
+
eventTypes: unknown;
|
|
2002
|
+
description?: string | null;
|
|
2003
|
+
}, options?: UrlCheckOptions): Promise<{
|
|
2004
|
+
endpoint: WebhookEndpointView;
|
|
2005
|
+
secret: string;
|
|
2006
|
+
}>;
|
|
2007
|
+
declare function listWebhookEndpoints(db: SchedulingDb, organizationId: string): Promise<WebhookEndpointView[]>;
|
|
2008
|
+
/** Removes the endpoint and, with it, its deliveries and their log. */
|
|
2009
|
+
declare function deleteWebhookEndpoint(db: SchedulingDb, organizationId: string, endpointId: string): Promise<void>;
|
|
2010
|
+
|
|
2011
|
+
/** What a receiver is told about an appointment. Payment details are left out on purpose. */
|
|
2012
|
+
declare function appointmentWebhookData(db: SchedulingDb, organizationId: string, appointmentId: string): Promise<Record<string, unknown>>;
|
|
2013
|
+
/** Queues the event for every active endpoint of the organization that subscribes to it. Returns how many were queued. */
|
|
2014
|
+
declare function enqueueWebhookEvent(db: SchedulingDb, input: {
|
|
2015
|
+
organizationId: string;
|
|
2016
|
+
type: string;
|
|
2017
|
+
data: Record<string, unknown>;
|
|
2018
|
+
eventId?: string;
|
|
2019
|
+
now?: Date;
|
|
2020
|
+
}): Promise<{
|
|
2021
|
+
queued: number;
|
|
2022
|
+
}>;
|
|
2023
|
+
/**
|
|
2024
|
+
* Queues an event for an appointment and never throws: the booking is already saved, and a webhook problem must
|
|
2025
|
+
* not undo or hide that. The failure is logged with a reference.
|
|
2026
|
+
*/
|
|
2027
|
+
declare function enqueueAppointmentWebhook(db: SchedulingDb, input: {
|
|
2028
|
+
organizationId: string;
|
|
2029
|
+
type: string;
|
|
2030
|
+
appointmentId: string;
|
|
2031
|
+
extra?: Record<string, unknown>;
|
|
2032
|
+
eventId?: string;
|
|
2033
|
+
}): Promise<void>;
|
|
2034
|
+
/** Queues `reminder.sent` for a reminder the engine just sent. The organization comes from the appointment's calendar. */
|
|
2035
|
+
declare function enqueueReminderSent(db: SchedulingDb, notification: {
|
|
2036
|
+
id: string;
|
|
2037
|
+
appointmentId: string;
|
|
2038
|
+
channel: string;
|
|
2039
|
+
trigger: string;
|
|
2040
|
+
}): Promise<void>;
|
|
2041
|
+
|
|
2042
|
+
/** Seconds to wait after the 1st, 2nd, ... failed try. The delivery goes to the dead-letter list after one more failure. */
|
|
2043
|
+
declare const DEFAULT_BACKOFF_SECONDS: number[];
|
|
2044
|
+
interface AttemptOptions {
|
|
2045
|
+
transport?: WebhookTransport;
|
|
2046
|
+
now?: () => Date;
|
|
2047
|
+
timeoutMs?: number;
|
|
2048
|
+
backoffSeconds?: number[];
|
|
2049
|
+
/** Tries before dead-letter. Default: one more than the back-off list is long (6). */
|
|
2050
|
+
maxAttempts?: number;
|
|
2051
|
+
allowInsecureTargets?: boolean;
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
interface DeliverOptions extends AttemptOptions {
|
|
2055
|
+
/** How many deliveries one call picks up. Default 20. */
|
|
2056
|
+
batchSize?: number;
|
|
2057
|
+
/** How many are sent at the same moment. Default 5. */
|
|
2058
|
+
concurrency?: number;
|
|
2059
|
+
workerId?: string;
|
|
2060
|
+
/** A claim older than this is taken to belong to a crashed worker and is reclaimed. Default 5 minutes. */
|
|
2061
|
+
staleClaimMs?: number;
|
|
2062
|
+
}
|
|
2063
|
+
interface DeliverSummary {
|
|
2064
|
+
succeeded: number;
|
|
2065
|
+
retried: number;
|
|
2066
|
+
deadLettered: number;
|
|
2067
|
+
/** Deliveries another worker finished first. */
|
|
2068
|
+
lostClaim: number;
|
|
2069
|
+
}
|
|
2070
|
+
declare function deliverDueWebhooks(db: SchedulingDb, options?: DeliverOptions): Promise<DeliverSummary>;
|
|
2071
|
+
|
|
2072
|
+
interface TestSendResult {
|
|
2073
|
+
deliveryId: string;
|
|
2074
|
+
ok: boolean;
|
|
2075
|
+
statusCode: number | null;
|
|
2076
|
+
error: string | null;
|
|
2077
|
+
}
|
|
2078
|
+
declare function sendTestWebhook(db: SchedulingDb, input: {
|
|
2079
|
+
organizationId: string;
|
|
2080
|
+
endpointId: string;
|
|
2081
|
+
}, options?: AttemptOptions): Promise<TestSendResult>;
|
|
2082
|
+
|
|
2083
|
+
interface WebhookDeliveryView {
|
|
2084
|
+
id: string;
|
|
2085
|
+
endpointId: string;
|
|
2086
|
+
eventId: string;
|
|
2087
|
+
eventType: string;
|
|
2088
|
+
status: string;
|
|
2089
|
+
attempts: number;
|
|
2090
|
+
nextAttemptAt: Date;
|
|
2091
|
+
lastStatusCode: number | null;
|
|
2092
|
+
lastError: string | null;
|
|
2093
|
+
deliveredAt: Date | null;
|
|
2094
|
+
createdAt: Date;
|
|
2095
|
+
attemptLog: Array<{
|
|
2096
|
+
attemptNumber: number;
|
|
2097
|
+
statusCode: number | null;
|
|
2098
|
+
error: string | null;
|
|
2099
|
+
durationMs: number;
|
|
2100
|
+
createdAt: Date;
|
|
2101
|
+
}>;
|
|
2102
|
+
}
|
|
2103
|
+
declare function listWebhookDeliveries(db: SchedulingDb, input: {
|
|
2104
|
+
organizationId: string;
|
|
2105
|
+
endpointId?: string;
|
|
2106
|
+
status?: string;
|
|
2107
|
+
limit?: number;
|
|
2108
|
+
offset?: number;
|
|
2109
|
+
}): Promise<{
|
|
2110
|
+
deliveries: WebhookDeliveryView[];
|
|
2111
|
+
total: number;
|
|
2112
|
+
}>;
|
|
2113
|
+
/** Puts a dead-lettered delivery back in the queue with a fresh set of tries. The log of earlier tries stays. */
|
|
2114
|
+
declare function retryWebhookDelivery(db: SchedulingDb, organizationId: string, deliveryId: string, now?: Date): Promise<void>;
|
|
2115
|
+
|
|
2116
|
+
interface WaitlistEntryView {
|
|
2117
|
+
id: string;
|
|
2118
|
+
typeId: string;
|
|
2119
|
+
calendarId: string | null;
|
|
2120
|
+
day: string;
|
|
2121
|
+
slotStart: Date | null;
|
|
2122
|
+
clientName: string;
|
|
2123
|
+
clientEmail: string;
|
|
2124
|
+
clientPhone: string | null;
|
|
2125
|
+
status: string;
|
|
2126
|
+
offerSlotStart: Date | null;
|
|
2127
|
+
offerExpiresAt: Date | null;
|
|
2128
|
+
createdAt: Date;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
declare const MAX_WAITING_PER_TYPE_DAY = 50;
|
|
2132
|
+
interface JoinWaitlistInput {
|
|
2133
|
+
organizationId: string;
|
|
2134
|
+
typeId: string;
|
|
2135
|
+
/** Leave out to wait for any calendar that offers the type. */
|
|
2136
|
+
calendarId?: string;
|
|
2137
|
+
/** The day, YYYY-MM-DD in the calendar's timezone. */
|
|
2138
|
+
day: string;
|
|
2139
|
+
/** Leave out to wait for any time that day. */
|
|
2140
|
+
slotStart?: Date;
|
|
2141
|
+
clientName: string;
|
|
2142
|
+
clientEmail: string;
|
|
2143
|
+
clientPhone?: string | null;
|
|
2144
|
+
}
|
|
2145
|
+
declare function joinWaitlist(db: SchedulingDb, input: JoinWaitlistInput, now?: Date): Promise<{
|
|
2146
|
+
entry: WaitlistEntryView;
|
|
2147
|
+
token: string;
|
|
2148
|
+
}>;
|
|
2149
|
+
|
|
2150
|
+
declare const DEFAULT_OFFER_MINUTES = 30;
|
|
2151
|
+
interface WaitlistOffer {
|
|
2152
|
+
entry: WaitlistEntryView;
|
|
2153
|
+
/** The client's own handle; the host puts it in the link it sends. */
|
|
2154
|
+
token: string;
|
|
2155
|
+
calendarId: string;
|
|
2156
|
+
calendarName: string;
|
|
2157
|
+
typeName: string;
|
|
2158
|
+
startTime: Date;
|
|
2159
|
+
/** The timezone the client chose when they joined, for writing the time in their message. */
|
|
2160
|
+
timezone: string;
|
|
2161
|
+
expiresAt: Date;
|
|
2162
|
+
}
|
|
2163
|
+
/**
|
|
2164
|
+
* Offers the slot to the longest-waiting entry that fits it: same day, a calendar and type that match, the slot still
|
|
2165
|
+
* free. Returns null when nobody fits or the slot already has a live offer. The offer lasts `offerMinutes`, and never
|
|
2166
|
+
* past the start of the slot. Two callers freeing the same slot cannot both offer it: the database holds one live
|
|
2167
|
+
* offer per slot.
|
|
2168
|
+
*/
|
|
2169
|
+
declare function offerFreedSlot(db: SchedulingDb, input: {
|
|
2170
|
+
organizationId: string;
|
|
2171
|
+
calendarId: string;
|
|
2172
|
+
startTime: Date;
|
|
2173
|
+
offerMinutes?: number;
|
|
2174
|
+
now?: Date;
|
|
2175
|
+
}): Promise<WaitlistOffer | null>;
|
|
2176
|
+
/** As offerFreedSlot, but never throws: the cancellation that freed the slot is already saved. Logs a reference. */
|
|
2177
|
+
declare function tryOfferFreedSlot(db: SchedulingDb, input: Parameters<typeof offerFreedSlot>[1]): Promise<WaitlistOffer | null>;
|
|
2178
|
+
/**
|
|
2179
|
+
* Ends offers whose time ran out, and sorts out an accept that started and never finished. An accept whose booking was
|
|
2180
|
+
* saved becomes BOOKED; one whose booking never happened goes back in line. Returns the slots that came free either way
|
|
2181
|
+
* (a lapsed offer, or an accept that never booked), so the caller can offer each to the next person.
|
|
2182
|
+
*/
|
|
2183
|
+
declare function expireWaitlistOffers(db: SchedulingDb, options?: {
|
|
2184
|
+
now?: Date;
|
|
2185
|
+
acceptTimeoutMs?: number;
|
|
2186
|
+
}): Promise<{
|
|
2187
|
+
lapsed: Array<{
|
|
2188
|
+
organizationId: string;
|
|
2189
|
+
calendarId: string;
|
|
2190
|
+
startTime: Date;
|
|
2191
|
+
}>;
|
|
2192
|
+
released: number;
|
|
2193
|
+
booked: number;
|
|
2194
|
+
}>;
|
|
2195
|
+
|
|
2196
|
+
/** A slot that someone was holding an offer for and no longer is. The caller offers it to the next person. */
|
|
2197
|
+
interface FreedSlot {
|
|
2198
|
+
organizationId: string;
|
|
2199
|
+
calendarId: string;
|
|
2200
|
+
startTime: Date;
|
|
2201
|
+
}
|
|
2202
|
+
declare function listWaitlist(db: SchedulingDb, input: {
|
|
2203
|
+
organizationId: string;
|
|
2204
|
+
status?: string;
|
|
2205
|
+
limit?: number;
|
|
2206
|
+
offset?: number;
|
|
2207
|
+
}): Promise<{
|
|
2208
|
+
entries: WaitlistEntryView[];
|
|
2209
|
+
total: number;
|
|
2210
|
+
}>;
|
|
2211
|
+
/**
|
|
2212
|
+
* Removes an entry that is not mid-accept. When it held a live offer, the slot it held is returned so the caller can
|
|
2213
|
+
* offer it to the next person.
|
|
2214
|
+
*/
|
|
2215
|
+
declare function removeWaitlistEntry(db: SchedulingDb, organizationId: string, entryId: string): Promise<FreedSlot | null>;
|
|
2216
|
+
/** The client leaves by their own link. Only an entry that is waiting or holding an offer can leave; a held slot is returned. */
|
|
2217
|
+
declare function leaveWaitlist(db: SchedulingDb, token: string): Promise<FreedSlot | null>;
|
|
2218
|
+
|
|
2219
|
+
interface OfferDetails {
|
|
2220
|
+
entryId: string;
|
|
2221
|
+
organizationId: string;
|
|
2222
|
+
typeId: string;
|
|
2223
|
+
typeName: string;
|
|
2224
|
+
calendarId: string;
|
|
2225
|
+
calendarName: string;
|
|
2226
|
+
startTime: Date;
|
|
2227
|
+
timezone: string;
|
|
2228
|
+
expiresAt: Date;
|
|
2229
|
+
clientName: string;
|
|
2230
|
+
clientEmail: string;
|
|
2231
|
+
clientPhone: string | null;
|
|
2232
|
+
}
|
|
2233
|
+
/** What the offer is, for the page the client opens. Throws SCHED_1106 when there is none and SCHED_1107 when it lapsed. */
|
|
2234
|
+
declare function getWaitlistOffer(db: SchedulingDb, token: string, now?: Date): Promise<OfferDetails>;
|
|
2235
|
+
/** Claims the offer so it can be accepted once. Two clicks at the same moment: one wins, the other gets SCHED_1106. */
|
|
2236
|
+
declare function beginWaitlistAccept(db: SchedulingDb, token: string, now?: Date): Promise<OfferDetails>;
|
|
2237
|
+
declare function completeWaitlistAccept(db: SchedulingDb, entryId: string, appointmentId: string): Promise<void>;
|
|
2238
|
+
/**
|
|
2239
|
+
* What to do with an accept whose booking did not happen.
|
|
2240
|
+
* KEEP_OFFER: a temporary failure (busy, server error): the offer stays open until it expires.
|
|
2241
|
+
* BACK_IN_LINE: the slot was taken: the client keeps their place and waits for another opening.
|
|
2242
|
+
* DROP: the booking can never go through for this client (a booking rule refuses them): they come off the list and the
|
|
2243
|
+
* slot is returned, so the caller can offer it to the next person.
|
|
2244
|
+
*/
|
|
2245
|
+
type AcceptRelease = 'KEEP_OFFER' | 'BACK_IN_LINE' | 'DROP';
|
|
2246
|
+
declare function releaseWaitlistAccept(db: SchedulingDb, entryId: string, outcome?: AcceptRelease): Promise<FreedSlot | null>;
|
|
2247
|
+
interface SettledBooking {
|
|
2248
|
+
id: string;
|
|
2249
|
+
status: string;
|
|
2250
|
+
startTime: Date;
|
|
2251
|
+
endTime: Date;
|
|
2252
|
+
manageToken: string | null;
|
|
2253
|
+
clientName: string;
|
|
2254
|
+
clientEmail: string;
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Call this when an accept looks like it failed. A booking can be saved and a later step (messages, calendar sync) still
|
|
2258
|
+
* fail, so the client may already hold the slot. When they do, the entry is marked BOOKED and the booking is returned;
|
|
2259
|
+
* when they do not, this returns null and the caller releases the accept.
|
|
2260
|
+
*/
|
|
2261
|
+
declare function settleBookedAccept(db: SchedulingDb, entryId: string): Promise<SettledBooking | null>;
|
|
2262
|
+
|
|
2263
|
+
/** The calendar day an instant falls on in `timeZone`. */
|
|
2264
|
+
declare function localDay(instant: Date, timeZone: string): string;
|
|
2265
|
+
|
|
2266
|
+
type QuestionType = 'select' | 'radio' | 'checkbox' | 'text' | 'number';
|
|
2267
|
+
interface RoutingQuestion {
|
|
2268
|
+
id: string;
|
|
2269
|
+
label: string;
|
|
2270
|
+
type: QuestionType;
|
|
2271
|
+
required: boolean;
|
|
2272
|
+
/** The choices of a select, radio or checkbox question. */
|
|
2273
|
+
options?: string[];
|
|
2274
|
+
}
|
|
2275
|
+
type RoutingOperator = 'equals' | 'not_equals' | 'in' | 'contains' | 'not_contains' | 'gt' | 'gte' | 'lt' | 'lte' | 'is_answered' | 'is_empty';
|
|
2276
|
+
interface RoutingCondition {
|
|
2277
|
+
questionId: string;
|
|
2278
|
+
operator: RoutingOperator;
|
|
2279
|
+
/** A text, a number or a list of choices, depending on the operator. Not used by is_answered and is_empty. */
|
|
2280
|
+
value?: string | number | string[];
|
|
2281
|
+
}
|
|
2282
|
+
/** Where to send the client: an appointment type, a calendar, or a type on a given calendar. At least one is set. */
|
|
2283
|
+
interface RoutingDestination {
|
|
2284
|
+
typeId?: string;
|
|
2285
|
+
calendarId?: string;
|
|
2286
|
+
}
|
|
2287
|
+
interface RoutingRule {
|
|
2288
|
+
id: string;
|
|
2289
|
+
label?: string;
|
|
2290
|
+
/** `all`: every condition must hold. `any`: one is enough. */
|
|
2291
|
+
match: 'all' | 'any';
|
|
2292
|
+
conditions: RoutingCondition[];
|
|
2293
|
+
destination: RoutingDestination;
|
|
2294
|
+
}
|
|
2295
|
+
/** What happens when no rule matches: send the client somewhere anyway, or show a message. */
|
|
2296
|
+
type RoutingFallback = {
|
|
2297
|
+
kind: 'DESTINATION';
|
|
2298
|
+
destination: RoutingDestination;
|
|
2299
|
+
} | {
|
|
2300
|
+
kind: 'MESSAGE';
|
|
2301
|
+
message: string;
|
|
2302
|
+
};
|
|
2303
|
+
interface RoutingFormDefinition {
|
|
2304
|
+
questions: RoutingQuestion[];
|
|
2305
|
+
rules: RoutingRule[];
|
|
2306
|
+
fallback: RoutingFallback;
|
|
2307
|
+
}
|
|
2308
|
+
type RoutingAnswers = Record<string, string | number | string[]>;
|
|
2309
|
+
interface RoutingProblem {
|
|
2310
|
+
/** Where in the form, such as `rules[2].conditions[0].value`. */
|
|
2311
|
+
path: string;
|
|
2312
|
+
message: string;
|
|
2313
|
+
}
|
|
2314
|
+
declare const LIMITS: {
|
|
2315
|
+
readonly questions: 20;
|
|
2316
|
+
readonly rules: 50;
|
|
2317
|
+
readonly conditionsPerRule: 10;
|
|
2318
|
+
readonly options: 50;
|
|
2319
|
+
readonly label: 200;
|
|
2320
|
+
readonly option: 100;
|
|
2321
|
+
readonly message: 500;
|
|
2322
|
+
readonly textAnswer: 1000;
|
|
2323
|
+
readonly problems: 50;
|
|
2324
|
+
readonly formsPerOrganization: 50;
|
|
2325
|
+
};
|
|
2326
|
+
|
|
2327
|
+
/** Which operators each kind of question allows. */
|
|
2328
|
+
declare const OPERATORS_BY_TYPE: Record<QuestionType, RoutingOperator[]>;
|
|
2329
|
+
type StructureResult = {
|
|
2330
|
+
ok: true;
|
|
2331
|
+
value: RoutingFormDefinition;
|
|
2332
|
+
} | {
|
|
2333
|
+
ok: false;
|
|
2334
|
+
problems: RoutingProblem[];
|
|
2335
|
+
};
|
|
2336
|
+
declare function validateRoutingStructure(input: unknown): StructureResult;
|
|
2337
|
+
|
|
2338
|
+
declare function validateRoutingDestinations(db: SchedulingDb, organizationId: string, definition: RoutingFormDefinition): Promise<RoutingProblem[]>;
|
|
2339
|
+
|
|
2340
|
+
type AnswerCheck = {
|
|
2341
|
+
ok: true;
|
|
2342
|
+
answers: RoutingAnswers;
|
|
2343
|
+
} | {
|
|
2344
|
+
ok: false;
|
|
2345
|
+
problems: RoutingProblem[];
|
|
2346
|
+
};
|
|
2347
|
+
/** Checks the answers fit the questions: required ones present, choices among the options, nothing the form did not ask. */
|
|
2348
|
+
declare function checkAnswers(questions: RoutingQuestion[], input: unknown): AnswerCheck;
|
|
2349
|
+
/** Every rule the answers satisfy, in the order the rules are listed. The first is the one that wins. */
|
|
2350
|
+
declare function matchingRules(definition: Pick<RoutingFormDefinition, 'rules'>, answers: RoutingAnswers): RoutingRule[];
|
|
2351
|
+
|
|
2352
|
+
interface RoutingFormView extends RoutingFormDefinition {
|
|
2353
|
+
id: string;
|
|
2354
|
+
name: string;
|
|
2355
|
+
slug: string;
|
|
2356
|
+
description: string | null;
|
|
2357
|
+
isActive: boolean;
|
|
2358
|
+
createdAt: Date;
|
|
2359
|
+
updatedAt: Date;
|
|
2360
|
+
}
|
|
2361
|
+
interface RoutingFormSummary {
|
|
2362
|
+
id: string;
|
|
2363
|
+
name: string;
|
|
2364
|
+
slug: string;
|
|
2365
|
+
description: string | null;
|
|
2366
|
+
isActive: boolean;
|
|
2367
|
+
updatedAt: Date;
|
|
2368
|
+
}
|
|
2369
|
+
interface RoutingFormInput {
|
|
2370
|
+
name: string;
|
|
2371
|
+
slug: string;
|
|
2372
|
+
description?: string | null;
|
|
2373
|
+
isActive?: boolean;
|
|
2374
|
+
questions: unknown;
|
|
2375
|
+
rules: unknown;
|
|
2376
|
+
fallback: unknown;
|
|
2377
|
+
}
|
|
2378
|
+
declare function createRoutingForm(db: SchedulingDb, organizationId: string, input: RoutingFormInput): Promise<RoutingFormView>;
|
|
2379
|
+
declare function getRoutingForm(db: SchedulingDb, organizationId: string, id: string): Promise<RoutingFormView>;
|
|
2380
|
+
declare function listRoutingForms(db: SchedulingDb, organizationId: string): Promise<RoutingFormSummary[]>;
|
|
2381
|
+
/** Changes the given fields and checks the whole result again, since a changed question can break an existing rule. */
|
|
2382
|
+
declare function updateRoutingForm(db: SchedulingDb, organizationId: string, id: string, patch: Partial<RoutingFormInput>): Promise<RoutingFormView>;
|
|
2383
|
+
declare function deleteRoutingForm(db: SchedulingDb, organizationId: string, id: string): Promise<void>;
|
|
2384
|
+
|
|
2385
|
+
interface PublicRoutingForm {
|
|
2386
|
+
name: string;
|
|
2387
|
+
slug: string;
|
|
2388
|
+
description: string | null;
|
|
2389
|
+
questions: RoutingQuestion[];
|
|
2390
|
+
}
|
|
2391
|
+
interface ResolvedDestination {
|
|
2392
|
+
typeId: string | null;
|
|
2393
|
+
typeSlug: string | null;
|
|
2394
|
+
typeName: string | null;
|
|
2395
|
+
calendarId: string | null;
|
|
2396
|
+
calendarSlug: string | null;
|
|
2397
|
+
calendarName: string | null;
|
|
2398
|
+
}
|
|
2399
|
+
interface RoutingOutcome {
|
|
2400
|
+
/** Where to send the client, or null when the form says to show `message` instead. */
|
|
2401
|
+
destination: ResolvedDestination | null;
|
|
2402
|
+
message: string | null;
|
|
2403
|
+
/** The rule that decided it, or null when the fallback did. */
|
|
2404
|
+
matchedRuleId: string | null;
|
|
2405
|
+
usedFallback: boolean;
|
|
2406
|
+
}
|
|
2407
|
+
/** The questions only. The rules and the fallback stay on the server. */
|
|
2408
|
+
declare function getPublicRoutingForm(db: SchedulingDb, input: {
|
|
2409
|
+
organizationId: string | null;
|
|
2410
|
+
slug: string;
|
|
2411
|
+
}): Promise<PublicRoutingForm>;
|
|
2412
|
+
/** Looks the destination up now: a type or calendar switched off since the form was saved is not sent to. */
|
|
2413
|
+
declare function resolveDestination(db: SchedulingDb, organizationId: string, destination: RoutingDestination): Promise<ResolvedDestination | null>;
|
|
2414
|
+
/**
|
|
2415
|
+
* Sends a client on. The first matching rule whose destination is still live wins; if none is, the fallback decides.
|
|
2416
|
+
* A form whose fallback destination is also gone tells the client to get in touch.
|
|
2417
|
+
*/
|
|
2418
|
+
declare function routeClient(db: SchedulingDb, input: {
|
|
2419
|
+
organizationId: string | null;
|
|
2420
|
+
slug: string;
|
|
2421
|
+
answers: unknown;
|
|
2422
|
+
}): Promise<RoutingOutcome>;
|
|
2423
|
+
/** Staff trying a form with sample answers. Works on a form that is switched off, and lists every rule that matched. */
|
|
2424
|
+
declare function testRoutingForm(db: SchedulingDb, input: {
|
|
2425
|
+
organizationId: string;
|
|
2426
|
+
id: string;
|
|
2427
|
+
answers: unknown;
|
|
2428
|
+
}): Promise<RoutingOutcome & {
|
|
2429
|
+
allMatchedRuleIds: string[];
|
|
2430
|
+
}>;
|
|
2431
|
+
|
|
2432
|
+
interface ParsedSubject {
|
|
2433
|
+
email: string | null;
|
|
2434
|
+
clientId: string | null;
|
|
2435
|
+
}
|
|
2436
|
+
interface ResolvedSubject {
|
|
2437
|
+
/** Lower-case addresses, without repeats. */
|
|
2438
|
+
emails: string[];
|
|
2439
|
+
clientId: string | null;
|
|
2440
|
+
}
|
|
2441
|
+
/** Checks the request names somebody, and in a way that cannot match more than that person. */
|
|
2442
|
+
declare function parseSubject(input: {
|
|
2443
|
+
email?: unknown;
|
|
2444
|
+
clientId?: unknown;
|
|
2445
|
+
}): ParsedSubject;
|
|
2446
|
+
/** One digest per identifier, tied to the organization. The request record keeps these instead of the address itself. */
|
|
2447
|
+
declare function subjectHashes(organizationId: string, subject: ResolvedSubject): string[];
|
|
2448
|
+
/** Adds the addresses a client id stands for: those on the client's bookings and series in this organization. */
|
|
2449
|
+
declare function resolveSubject(db: SchedulingDb, organizationId: string, parsed: ParsedSubject): Promise<ResolvedSubject>;
|
|
2450
|
+
|
|
2451
|
+
declare function collectSubjectRows(db: SchedulingDb, organizationId: string, subject: ResolvedSubject): Promise<{
|
|
2452
|
+
appointments: {
|
|
2453
|
+
couponCode: string | null;
|
|
2454
|
+
startTime: Date;
|
|
2455
|
+
cancelledAt: Date | null;
|
|
2456
|
+
cancelledBy: string | null;
|
|
2457
|
+
id: string;
|
|
2458
|
+
type: {
|
|
2459
|
+
name: string;
|
|
2460
|
+
};
|
|
2461
|
+
timezone: string;
|
|
2462
|
+
location: string | null;
|
|
2463
|
+
createdAt: Date;
|
|
2464
|
+
updatedAt: Date;
|
|
2465
|
+
calendar: {
|
|
2466
|
+
name: string;
|
|
2467
|
+
};
|
|
2468
|
+
endTime: Date;
|
|
2469
|
+
duration: number;
|
|
2470
|
+
clientName: string;
|
|
2471
|
+
clientEmail: string;
|
|
2472
|
+
clientPhone: string | null;
|
|
2473
|
+
clientId: string | null;
|
|
2474
|
+
status: _prisma_client.$Enums.AppointmentStatus;
|
|
2475
|
+
cancelReason: string | null;
|
|
2476
|
+
rescheduledFrom: Date | null;
|
|
2477
|
+
rescheduleCount: number;
|
|
2478
|
+
intakeResponses: _prisma_client_runtime_client.JsonValue;
|
|
2479
|
+
paymentStatus: string | null;
|
|
2480
|
+
paymentAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2481
|
+
depositAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2482
|
+
tipAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2483
|
+
paymentProvider: string | null;
|
|
2484
|
+
paymentId: string | null;
|
|
2485
|
+
balancePaymentId: string | null;
|
|
2486
|
+
discountAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2487
|
+
cancellationFeeAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2488
|
+
refundAmount: _prisma_client_runtime_client.Decimal | null;
|
|
2489
|
+
refundStatus: _prisma_client.$Enums.RefundStatus | null;
|
|
2490
|
+
isGroup: boolean;
|
|
2491
|
+
notes: string | null;
|
|
2492
|
+
staffNotes: string | null;
|
|
2493
|
+
meetingUrl: string | null;
|
|
2494
|
+
recurringId: string | null;
|
|
2495
|
+
recurringIndex: number | null;
|
|
2496
|
+
packagePurchaseId: string | null;
|
|
2497
|
+
}[];
|
|
2498
|
+
notifications: never[] | {
|
|
2499
|
+
id: string;
|
|
2500
|
+
createdAt: Date;
|
|
2501
|
+
status: string;
|
|
2502
|
+
appointmentId: string;
|
|
2503
|
+
channel: string;
|
|
2504
|
+
trigger: string;
|
|
2505
|
+
recipient: string;
|
|
2506
|
+
subject: string | null;
|
|
2507
|
+
body: string;
|
|
2508
|
+
scheduledFor: Date;
|
|
2509
|
+
sentAt: Date | null;
|
|
2510
|
+
}[];
|
|
2511
|
+
waitlistEntries: never[] | {
|
|
2512
|
+
id: string;
|
|
2513
|
+
timezone: string;
|
|
2514
|
+
createdAt: Date;
|
|
2515
|
+
calendarId: string | null;
|
|
2516
|
+
day: string;
|
|
2517
|
+
typeId: string;
|
|
2518
|
+
clientName: string;
|
|
2519
|
+
clientEmail: string;
|
|
2520
|
+
clientPhone: string | null;
|
|
2521
|
+
status: string;
|
|
2522
|
+
slotStart: Date | null;
|
|
2523
|
+
offerSlotStart: Date | null;
|
|
2524
|
+
offerExpiresAt: Date | null;
|
|
2525
|
+
offeredAt: Date | null;
|
|
2526
|
+
bookedAppointmentId: string | null;
|
|
2527
|
+
}[];
|
|
2528
|
+
packagePurchases: never[] | {
|
|
2529
|
+
id: string;
|
|
2530
|
+
createdAt: Date;
|
|
2531
|
+
clientName: string | null;
|
|
2532
|
+
clientEmail: string;
|
|
2533
|
+
status: _prisma_client.$Enums.PackagePurchaseStatus;
|
|
2534
|
+
paymentId: string | null;
|
|
2535
|
+
notes: string | null;
|
|
2536
|
+
expiresAt: Date | null;
|
|
2537
|
+
packageId: string;
|
|
2538
|
+
sessionsTotal: number;
|
|
2539
|
+
sessionsUsed: number;
|
|
2540
|
+
purchasedAt: Date;
|
|
2541
|
+
pricePaidCents: number | null;
|
|
2542
|
+
}[];
|
|
2543
|
+
recurringSeries: never[] | {
|
|
2544
|
+
id: string;
|
|
2545
|
+
timezone: string;
|
|
2546
|
+
createdAt: Date;
|
|
2547
|
+
calendarId: string;
|
|
2548
|
+
typeId: string;
|
|
2549
|
+
clientName: string;
|
|
2550
|
+
clientEmail: string;
|
|
2551
|
+
clientPhone: string | null;
|
|
2552
|
+
clientId: string | null;
|
|
2553
|
+
status: _prisma_client.$Enums.RecurringSeriesStatus;
|
|
2554
|
+
notes: string | null;
|
|
2555
|
+
frequency: _prisma_client.$Enums.RecurringFrequency;
|
|
2556
|
+
occurrences: number;
|
|
2557
|
+
startTimeLocal: string;
|
|
2558
|
+
durationMins: number;
|
|
2559
|
+
endsAt: Date | null;
|
|
2560
|
+
}[];
|
|
2561
|
+
webhookDeliveries: {
|
|
2562
|
+
id: string;
|
|
2563
|
+
eventId: string;
|
|
2564
|
+
eventType: string;
|
|
2565
|
+
body: string;
|
|
2566
|
+
status: string;
|
|
2567
|
+
createdAt: Date;
|
|
2568
|
+
}[];
|
|
2569
|
+
}>;
|
|
2570
|
+
type SubjectRows = Awaited<ReturnType<typeof collectSubjectRows>>;
|
|
2571
|
+
interface SubjectCounts {
|
|
2572
|
+
appointments: number;
|
|
2573
|
+
notifications: number;
|
|
2574
|
+
waitlistEntries: number;
|
|
2575
|
+
packagePurchases: number;
|
|
2576
|
+
recurringSeries: number;
|
|
2577
|
+
webhookDeliveries: number;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
interface SubjectExport {
|
|
2581
|
+
format: 'ordinatio-scheduling-subject-export';
|
|
2582
|
+
version: 1;
|
|
2583
|
+
exportedAt: string;
|
|
2584
|
+
organizationId: string;
|
|
2585
|
+
subject: {
|
|
2586
|
+
emails: string[];
|
|
2587
|
+
clientId: string | null;
|
|
2588
|
+
};
|
|
2589
|
+
counts: SubjectCounts;
|
|
2590
|
+
appointments: Array<Omit<SubjectRows['appointments'][number], 'calendar' | 'type'> & {
|
|
2591
|
+
calendarName: string;
|
|
2592
|
+
typeName: string;
|
|
2593
|
+
}>;
|
|
2594
|
+
notifications: SubjectRows['notifications'];
|
|
2595
|
+
waitlistEntries: SubjectRows['waitlistEntries'];
|
|
2596
|
+
packagePurchases: SubjectRows['packagePurchases'];
|
|
2597
|
+
recurringSeries: SubjectRows['recurringSeries'];
|
|
2598
|
+
webhookDeliveries: SubjectRows['webhookDeliveries'];
|
|
2599
|
+
}
|
|
2600
|
+
declare function exportSubject(db: SchedulingDb, input: {
|
|
2601
|
+
organizationId: string;
|
|
2602
|
+
requestedBy: string;
|
|
2603
|
+
email?: unknown;
|
|
2604
|
+
clientId?: unknown;
|
|
2605
|
+
now?: Date;
|
|
2606
|
+
}): Promise<SubjectExport>;
|
|
2607
|
+
|
|
2608
|
+
declare const ERASED_NAME = "Erased client";
|
|
2609
|
+
declare const ERASED_EMAIL = "erased@erased.invalid";
|
|
2610
|
+
interface EraseBlockers {
|
|
2611
|
+
upcomingAppointments: number;
|
|
2612
|
+
liveWaitlistEntries: number;
|
|
2613
|
+
}
|
|
2614
|
+
interface ErasePreview {
|
|
2615
|
+
counts: SubjectCounts;
|
|
2616
|
+
blockers: EraseBlockers;
|
|
2617
|
+
canErase: boolean;
|
|
2618
|
+
warnings: string[];
|
|
2619
|
+
}
|
|
2620
|
+
/** What an erasure would remove and whether anything stops it. Changes and records nothing. */
|
|
2621
|
+
declare function previewErase(db: SchedulingDb, input: {
|
|
2622
|
+
organizationId: string;
|
|
2623
|
+
email?: unknown;
|
|
2624
|
+
clientId?: unknown;
|
|
2625
|
+
now?: Date;
|
|
2626
|
+
}): Promise<ErasePreview>;
|
|
2627
|
+
declare function eraseSubject(db: SchedulingDb, input: {
|
|
2628
|
+
organizationId: string;
|
|
2629
|
+
requestedBy: string;
|
|
2630
|
+
email?: unknown;
|
|
2631
|
+
clientId?: unknown;
|
|
2632
|
+
now?: Date;
|
|
2633
|
+
}): Promise<{
|
|
2634
|
+
counts: SubjectCounts;
|
|
2635
|
+
}>;
|
|
2636
|
+
|
|
2637
|
+
type PrivacyRequestKind = 'EXPORT' | 'ERASE';
|
|
2638
|
+
interface PrivacyRequestView {
|
|
2639
|
+
id: string;
|
|
2640
|
+
kind: string;
|
|
2641
|
+
requestedBy: string;
|
|
2642
|
+
counts: unknown;
|
|
2643
|
+
createdAt: Date;
|
|
2644
|
+
}
|
|
2645
|
+
declare function listPrivacyRequests(db: SchedulingDb, input: {
|
|
2646
|
+
organizationId: string;
|
|
2647
|
+
limit?: number;
|
|
2648
|
+
offset?: number;
|
|
2649
|
+
}): Promise<{
|
|
2650
|
+
requests: PrivacyRequestView[];
|
|
2651
|
+
total: number;
|
|
2652
|
+
}>;
|
|
2653
|
+
|
|
2654
|
+
interface BrandFields {
|
|
2655
|
+
displayName: string;
|
|
2656
|
+
logoUrl: string | null;
|
|
2657
|
+
primaryColor: string | null;
|
|
2658
|
+
accentColor: string | null;
|
|
2659
|
+
backgroundColor: string | null;
|
|
2660
|
+
textColor: string | null;
|
|
2661
|
+
fontFamily: string | null;
|
|
2662
|
+
footerText: string | null;
|
|
2663
|
+
replyToEmail: string | null;
|
|
2664
|
+
fromName: string | null;
|
|
2665
|
+
fromEmail: string | null;
|
|
2666
|
+
}
|
|
2667
|
+
interface BrandView extends BrandFields {
|
|
2668
|
+
updatedAt: Date;
|
|
2669
|
+
}
|
|
2670
|
+
/** What a visitor of the booking page may see: no email addresses. */
|
|
2671
|
+
interface PublicBrand {
|
|
2672
|
+
displayName: string;
|
|
2673
|
+
logoUrl: string | null;
|
|
2674
|
+
primaryColor: string | null;
|
|
2675
|
+
accentColor: string | null;
|
|
2676
|
+
backgroundColor: string | null;
|
|
2677
|
+
textColor: string | null;
|
|
2678
|
+
fontFamily: string | null;
|
|
2679
|
+
footerText: string | null;
|
|
2680
|
+
}
|
|
2681
|
+
interface BrandProblem {
|
|
2682
|
+
path: string;
|
|
2683
|
+
message: string;
|
|
2684
|
+
}
|
|
2685
|
+
declare const BRAND_FIELDS: readonly ["displayName", "logoUrl", "primaryColor", "accentColor", "backgroundColor", "textColor", "fontFamily", "footerText", "replyToEmail", "fromName", "fromEmail"];
|
|
2686
|
+
|
|
2687
|
+
interface ValidateBrandOptions {
|
|
2688
|
+
/**
|
|
2689
|
+
* Says whether the host may send mail from this domain (lower case). Without it no sending address is accepted: an
|
|
2690
|
+
* organization must not be able to send as a domain it does not control.
|
|
2691
|
+
*/
|
|
2692
|
+
isSendingDomainVerified?: (domain: string) => Promise<boolean>;
|
|
2693
|
+
}
|
|
2694
|
+
/** The stored form of the settings, or a SCHED_1400 error listing every problem. */
|
|
2695
|
+
declare function validateBrand(input: unknown, options: ValidateBrandOptions): Promise<BrandFields>;
|
|
2696
|
+
|
|
2697
|
+
declare function getBrand(db: SchedulingDb, organizationId: string): Promise<BrandView | null>;
|
|
2698
|
+
/**
|
|
2699
|
+
* What the booking page may show. With no organization named (a server with one organization) it is the brand of the
|
|
2700
|
+
* only organization that has one; with several, none is chosen for the visitor.
|
|
2701
|
+
*/
|
|
2702
|
+
declare function getPublicBrand(db: SchedulingDb, organizationId: string | null): Promise<PublicBrand | null>;
|
|
2703
|
+
/** Saves the whole brand, replacing what was there. Throws SCHED_1400 listing every problem. */
|
|
2704
|
+
declare function saveBrand(db: SchedulingDb, organizationId: string, input: unknown, options: ValidateBrandOptions): Promise<BrandView>;
|
|
2705
|
+
/** Removes the brand. True when there was one. */
|
|
2706
|
+
declare function deleteBrand(db: SchedulingDb, organizationId: string): Promise<boolean>;
|
|
2707
|
+
|
|
2708
|
+
/** The sender of an organization's messages, or null when there is no brand. Only what is set is included. */
|
|
2709
|
+
declare function senderIdentity(brand: BrandFields | null): SenderIdentity | null;
|
|
2710
|
+
/** Values for `{{brandName}}`, `{{brandLogoUrl}}`, `{{brandColor}}` and `{{brandFooter}}`; empty text when not set. */
|
|
2711
|
+
declare function brandTemplateFields(brand: BrandFields | null): Record<string, string>;
|
|
2712
|
+
declare function toPublicBrand(brand: BrandFields): PublicBrand;
|
|
2713
|
+
|
|
2714
|
+
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, selectCalendarForBooking, sendTestWebhook, senderIdentity, setWeeklyAvailability, settleBookedAccept, signWebhook, subjectHashes, testRoutingForm, toPublicBrand, tryOfferFreedSlot, updateAppointmentType, updateCalendar, updateNotificationTemplate, updateRoutingForm, validateBrand, validateRoutingDestinations, validateRoutingStructure, verifyWebhookSignature, withCalendarVisibility };
|