@ordinatio/scheduling-api 0.8.0 → 0.10.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 +13 -0
- package/README.md +10 -0
- package/package.json +3 -3
- package/dist/agent/index.d.mts +0 -55
- package/dist/agent/index.d.ts +0 -55
- package/dist/agent/index.js +0 -2411
- package/dist/agent/index.mjs +0 -2381
- package/dist/chunk-X5BVCLX6.mjs +0 -488
- package/dist/index.d.mts +0 -597
- package/dist/index.d.ts +0 -597
- package/dist/index.js +0 -9491
- package/dist/index.mjs +0 -8993
- package/dist/routes-mii9tsbA.d.mts +0 -462
- package/dist/routes-mii9tsbA.d.ts +0 -462
- package/dist/schemas/index.d.mts +0 -529
- package/dist/schemas/index.d.ts +0 -529
- package/dist/schemas/index.js +0 -553
- package/dist/schemas/index.mjs +0 -84
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
import { SchedulingDb, CalendarSyncAdapter, WebhookTransport, TextProvider, PaymentAdapter } from '@ordinatio/scheduling';
|
|
2
|
-
|
|
3
|
-
/** One record a business must add at its domain host. `name` is relative to the domain, with "@" for the domain itself. */
|
|
4
|
-
interface SendingDomainRecord {
|
|
5
|
-
purpose: 'spf' | 'dkim' | 'dmarc' | 'other';
|
|
6
|
-
type: 'TXT' | 'CNAME';
|
|
7
|
-
name: string;
|
|
8
|
-
/** What the published record must say. */
|
|
9
|
-
value: string;
|
|
10
|
-
/** "contains" suits SPF, where the record may list other senders too: every term of `value` must appear as a whole term. Default: "exact". */
|
|
11
|
-
match?: 'exact' | 'contains';
|
|
12
|
-
/** A record that is not required never blocks verification. Default: true. */
|
|
13
|
-
required?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/** The records for one domain. A provider that issues a different token per domain needs the function form. */
|
|
16
|
-
type SendingDomainRecords = SendingDomainRecord[] | ((domain: string) => SendingDomainRecord[]);
|
|
17
|
-
/** The two lookups used, shaped like node:dns/promises `resolveTxt` and `resolveCname`. */
|
|
18
|
-
interface DnsResolver {
|
|
19
|
-
resolveTxt(name: string): Promise<string[][]>;
|
|
20
|
-
resolveCname(name: string): Promise<string[]>;
|
|
21
|
-
}
|
|
22
|
-
type RecordStatus = 'found' | 'missing' | 'wrong' | 'unknown';
|
|
23
|
-
interface RecordCheck {
|
|
24
|
-
record: SendingDomainRecord;
|
|
25
|
-
/** The full name to publish at, such as "s1._domainkey.mail.acme.example". */
|
|
26
|
-
host: string;
|
|
27
|
-
status: RecordStatus;
|
|
28
|
-
/** A sentence a business owner can act on. */
|
|
29
|
-
message: string;
|
|
30
|
-
}
|
|
31
|
-
interface SendingDomainCheck {
|
|
32
|
-
domain: string;
|
|
33
|
-
/** True when every required record is found. */
|
|
34
|
-
verified: boolean;
|
|
35
|
-
records: RecordCheck[];
|
|
36
|
-
}
|
|
37
|
-
/** Returns the domain in lower case, or null when it is not a plain domain name. */
|
|
38
|
-
declare function normalizeSendingDomain(raw: string): string | null;
|
|
39
|
-
/** Looks up every record. Never throws: a lookup that fails is reported as "unknown" and leaves the domain unverified. */
|
|
40
|
-
declare function checkSendingDomain(config: {
|
|
41
|
-
records: SendingDomainRecords;
|
|
42
|
-
resolver: DnsResolver;
|
|
43
|
-
}, rawDomain: string): Promise<SendingDomainCheck>;
|
|
44
|
-
|
|
45
|
-
/** Named limits. A host that counts requests maps each name to its own numbers. */
|
|
46
|
-
type RateLimitTier = 'PUBLIC_BOOKING' | 'AVAILABILITY' | 'GENERAL' | 'CREATE' | 'UPDATE' | 'DELETE' | 'PAYMENT_INTENT' | 'RESOLVE_REFUND' | 'INTERNAL' | 'SETTINGS';
|
|
47
|
-
/** What a public booking page is looked up by: a calendar slug or an appointment type slug. */
|
|
48
|
-
type PublicBookingKind = 'CALENDAR' | 'APPOINTMENT_TYPE';
|
|
49
|
-
/** The organization a public request belongs to, and the database that holds its data. */
|
|
50
|
-
interface PublicBookingContext {
|
|
51
|
-
db: SchedulingDb;
|
|
52
|
-
organizationId: string;
|
|
53
|
-
}
|
|
54
|
-
interface PublicBookingResolver {
|
|
55
|
-
/**
|
|
56
|
-
* Finds the organization and database for a public booking page. `orgSlug` is the organization named in
|
|
57
|
-
* the page address, or null for an older address that names only the calendar or type. Returns null when
|
|
58
|
-
* there is no such page. A host with several organizations supplies this; the default assumes one.
|
|
59
|
-
*/
|
|
60
|
-
resolve(input: {
|
|
61
|
-
orgSlug: string | null;
|
|
62
|
-
slug: string;
|
|
63
|
-
kind: PublicBookingKind;
|
|
64
|
-
logPrefix: string;
|
|
65
|
-
}): Promise<PublicBookingContext | null>;
|
|
66
|
-
}
|
|
67
|
-
/** The organization a request names by its slug, and the database that holds its data. */
|
|
68
|
-
interface PublicOrganization {
|
|
69
|
-
db: SchedulingDb;
|
|
70
|
-
/** The organization id every read must be scoped by, or null when the host has one organization and nothing to scope. */
|
|
71
|
-
organizationId: string | null;
|
|
72
|
-
}
|
|
73
|
-
interface PublicOrganizationResolver {
|
|
74
|
-
/**
|
|
75
|
-
* Finds the organization named by `orgSlug`, for routes that are keyed by an id and not by a slug. Returns null
|
|
76
|
-
* when there is no such active organization. A host with several organizations supplies this; the default
|
|
77
|
-
* assumes one, so it returns the public database with no organization id and the reads are not scoped.
|
|
78
|
-
*/
|
|
79
|
-
resolve(input: {
|
|
80
|
-
orgSlug: string;
|
|
81
|
-
logPrefix: string;
|
|
82
|
-
}): Promise<PublicOrganization | null>;
|
|
83
|
-
}
|
|
84
|
-
/** Stored free-slot answers, one per calendar, day and duration. */
|
|
85
|
-
interface AvailabilityCache {
|
|
86
|
-
/** The stored answer, or null when there is none or it has expired. A rejection is treated as a miss. */
|
|
87
|
-
get(calendarId: string, day: string, duration: number): Promise<unknown | null>;
|
|
88
|
-
set(calendarId: string, day: string, duration: number, value: unknown): Promise<void>;
|
|
89
|
-
/** Drops every stored answer of the calendar. Called when a booking changes its free slots. */
|
|
90
|
-
invalidate(calendarId: string): Promise<void>;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Tells the screens of an organization that an appointment changed, for example `appointment.cancelled`. It runs
|
|
94
|
-
* after the change is saved and must not throw: a rejection ends the request with a 500 although the change stands,
|
|
95
|
-
* and the steps after it are skipped.
|
|
96
|
-
*/
|
|
97
|
-
interface AppointmentEventSink {
|
|
98
|
-
emit(organizationId: string, type: string, data: Record<string, unknown>): Promise<void>;
|
|
99
|
-
}
|
|
100
|
-
interface ActivityEntry {
|
|
101
|
-
action: string;
|
|
102
|
-
description: string;
|
|
103
|
-
metadata?: Record<string, unknown>;
|
|
104
|
-
/** A key that lets a later step find this entry again. */
|
|
105
|
-
externalRef?: string;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Writes entries to the activity feed that staff read. A self-service cancellation of a paid appointment tells staff
|
|
109
|
-
* to review the refund only through the entry `scheduling.appointment_refund_pending`, so a host that supplies no log
|
|
110
|
-
* sends no alert. It runs after the change is saved and must not throw: a rejection ends the request with a 500
|
|
111
|
-
* although the change stands, and the steps after it are skipped.
|
|
112
|
-
*/
|
|
113
|
-
interface ActivityLog {
|
|
114
|
-
log(db: SchedulingDb, entry: ActivityEntry): Promise<void>;
|
|
115
|
-
/** Whether an entry with this `externalRef` exists and has not been resolved. */
|
|
116
|
-
isOpen(db: SchedulingDb, externalRef: string): Promise<boolean>;
|
|
117
|
-
/** Marks the entry with this `externalRef` resolved by the person. Does nothing when there is none. */
|
|
118
|
-
resolve(db: SchedulingDb, externalRef: string, resolvedBy: string): Promise<void>;
|
|
119
|
-
}
|
|
120
|
-
/** A filter on the calendar of an appointment, narrowing a list to the calendars a person may see. */
|
|
121
|
-
type CalendarVisibility = NonNullable<NonNullable<NonNullable<Parameters<SchedulingDb['appointment']['count']>[0]>['where']>['calendar']>;
|
|
122
|
-
/** What the balance flow needs from the payment provider beyond creating a payment. */
|
|
123
|
-
interface BalancePaymentControl {
|
|
124
|
-
/** Cancels an unpaid payment. Rejects when the provider refuses, for example because it is already paid or canceled. */
|
|
125
|
-
cancel(paymentId: string): Promise<void>;
|
|
126
|
-
/** The provider's own status word for the payment, such as "canceled" or "succeeded". Rejects when it cannot be read. */
|
|
127
|
-
statusOf(paymentId: string): Promise<string>;
|
|
128
|
-
}
|
|
129
|
-
/** A signed-in member of the organization, as the host knows them. */
|
|
130
|
-
interface StaffContext {
|
|
131
|
-
userId: string;
|
|
132
|
-
organizationId: string;
|
|
133
|
-
/** The person's role. It is only written into the error record of a refusal. */
|
|
134
|
-
role: string;
|
|
135
|
-
/** True when the role may manage scheduling for the whole organization (owner, admin, manager) and not only look up one client. */
|
|
136
|
-
isAdmin: boolean;
|
|
137
|
-
/** False when the organization has scheduling switched off; admin routes then answer 503. */
|
|
138
|
-
schedulingEnabled: boolean;
|
|
139
|
-
/** The database of the organization. */
|
|
140
|
-
db: SchedulingDb;
|
|
141
|
-
/** The calendars this person may see, or null when they may see them all. Asked only after the role check. */
|
|
142
|
-
visibleCalendars(): Promise<CalendarVisibility | null>;
|
|
143
|
-
/**
|
|
144
|
-
* The ids of the calendars this person may see, or undefined when they may see them all. Reports and group-session
|
|
145
|
-
* lists narrow to these ids, where `visibleCalendars` gives a filter for queries on appointments.
|
|
146
|
-
*/
|
|
147
|
-
visibleCalendarIds(): Promise<string[] | undefined>;
|
|
148
|
-
/** Whether this person may see one calendar. False also for a calendar that does not exist, so a hidden one looks missing. */
|
|
149
|
-
canSeeCalendar(calendarId: string): Promise<boolean>;
|
|
150
|
-
/** Whether this person may see one appointment, by the group visibility of its calendar. False also when it does not exist. */
|
|
151
|
-
canSeeAppointment(appointmentId: string): Promise<boolean>;
|
|
152
|
-
/**
|
|
153
|
-
* The place a client prefers to be seen at, or null when the client does not exist, has no preference, or is one
|
|
154
|
-
* this person may not see. A client outside the person's groups looks the same as a missing one.
|
|
155
|
-
*/
|
|
156
|
-
preferredLocationOf(clientId: string): Promise<string | null>;
|
|
157
|
-
}
|
|
158
|
-
interface StaffResolver {
|
|
159
|
-
/**
|
|
160
|
-
* The signed-in member who sent the request, or null when nobody is signed in (the route then answers 401).
|
|
161
|
-
* It may throw, for example when the person belongs to no organization; the route then answers 500.
|
|
162
|
-
*/
|
|
163
|
-
resolve(request: Request): Promise<StaffContext | null>;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Decides which client record a new booking belongs to. The booking endpoint is public, so `suppliedClientId` is
|
|
167
|
-
* untrusted: honor it only for a signed-in member of the organization who may see that client. It must not throw: a
|
|
168
|
-
* failure means the appointment is saved unlinked and can be linked later.
|
|
169
|
-
*/
|
|
170
|
-
interface BookingClientResolver {
|
|
171
|
-
resolve(request: Request, db: SchedulingDb, input: {
|
|
172
|
-
organizationId: string;
|
|
173
|
-
email: string;
|
|
174
|
-
suppliedClientId?: string;
|
|
175
|
-
}): Promise<string | null>;
|
|
176
|
-
/** Remembers the place a client prefers to be seen at. It may throw: the caller logs the failure and carries on. */
|
|
177
|
-
rememberLocation(db: SchedulingDb, clientId: string, location: string): Promise<void>;
|
|
178
|
-
}
|
|
179
|
-
/** What an organization does about a client who keeps missing appointments. */
|
|
180
|
-
interface NoShowPolicy {
|
|
181
|
-
enabled: boolean;
|
|
182
|
-
/** How many missed appointments trigger the action. */
|
|
183
|
-
threshold: number;
|
|
184
|
-
/** BLOCK_BOOKING refuses online booking; REQUIRE_APPROVAL books it as PENDING for staff to review. */
|
|
185
|
-
action: 'BLOCK_BOOKING' | 'REQUIRE_APPROVAL';
|
|
186
|
-
}
|
|
187
|
-
interface BookingPolicy {
|
|
188
|
-
/** The no-show policy of the organization, or null when it has none. */
|
|
189
|
-
noShowPrevention(organizationId: string): Promise<NoShowPolicy | null>;
|
|
190
|
-
}
|
|
191
|
-
/** Who works in the organization, for the staff picker on the calendar settings page. */
|
|
192
|
-
interface StaffDirectory {
|
|
193
|
-
/** Active members of the organization. Departed or deactivated accounts are left out so they cannot be newly linked. */
|
|
194
|
-
listActive(organizationId: string): Promise<Array<{
|
|
195
|
-
id: string;
|
|
196
|
-
name: string | null;
|
|
197
|
-
email: string;
|
|
198
|
-
}>>;
|
|
199
|
-
/** Whether the user is a member of the organization. Used before a calendar is linked to a staff member. */
|
|
200
|
-
isMember(organizationId: string, userId: string): Promise<boolean>;
|
|
201
|
-
}
|
|
202
|
-
/** A public booking page is reached by a bare slug. This index says which organization owns each slug. */
|
|
203
|
-
interface SlugDirectory {
|
|
204
|
-
/** Reserves `slug` for the organization. First claim wins. Never throws: a conflict or failure is `claimed: false` with a `ref`. */
|
|
205
|
-
claim(slug: string, kind: 'CALENDAR' | 'APPOINTMENT_TYPE', organizationId: string): Promise<{
|
|
206
|
-
claimed: boolean;
|
|
207
|
-
ref?: string;
|
|
208
|
-
}>;
|
|
209
|
-
/** Frees the slug if this organization holds it. Never throws. */
|
|
210
|
-
release(slug: string, kind: 'CALENDAR' | 'APPOINTMENT_TYPE', organizationId: string): Promise<void>;
|
|
211
|
-
}
|
|
212
|
-
interface CacheOptions {
|
|
213
|
-
/** Names the stored answer. It always contains the organization id, so two organizations never share one. */
|
|
214
|
-
key: string;
|
|
215
|
-
/** Names to drop the answer by when its data changes. */
|
|
216
|
-
tags: string[];
|
|
217
|
-
ttlSeconds: number;
|
|
218
|
-
}
|
|
219
|
-
interface SchedulingCache {
|
|
220
|
-
/** Returns the stored answer for `options.key`, or calls `load`, stores what it returns, and returns that. */
|
|
221
|
-
wrap<T>(options: CacheOptions, load: () => Promise<T>): Promise<T>;
|
|
222
|
-
/** Drops every stored answer that carries one of the tags. */
|
|
223
|
-
invalidate(tags: string[]): Promise<void>;
|
|
224
|
-
}
|
|
225
|
-
/** Decides whether a request comes from the host's own background worker and not from a person or the public. */
|
|
226
|
-
interface InternalAccess {
|
|
227
|
-
/** True only for a request that carries the worker's credential. Must be false when no credential is configured. */
|
|
228
|
-
isAuthorized(request: Request): boolean | Promise<boolean>;
|
|
229
|
-
}
|
|
230
|
-
/** Hands a command to the host's background worker, for example to remove an event from an outside calendar. */
|
|
231
|
-
interface WorkerCommands {
|
|
232
|
-
queue(action: string, data: Record<string, unknown>): Promise<void>;
|
|
233
|
-
}
|
|
234
|
-
/** What a provider's side of a calendar connection ended in. */
|
|
235
|
-
type CalendarConnectOutcome =
|
|
236
|
-
/** The connection failed; the person is sent back to the settings page with `?error=<failure>`. */
|
|
237
|
-
{
|
|
238
|
-
failure: string;
|
|
239
|
-
}
|
|
240
|
-
/** The fields to write on the connected calendar, or null when there is nothing to write. */
|
|
241
|
-
| {
|
|
242
|
-
link: Record<string, unknown> | null;
|
|
243
|
-
};
|
|
244
|
-
/** One outside calendar provider (Google, Outlook): where to send the person and what to do with the code they come back with. */
|
|
245
|
-
interface CalendarConnector {
|
|
246
|
-
/** The provider's sign-in address. `state` must be carried through unchanged. */
|
|
247
|
-
authorizationUrl(state: string): string;
|
|
248
|
-
/**
|
|
249
|
-
* Exchanges the code the provider sent back. It runs before the calendar being connected is known, so it may save
|
|
250
|
-
* account tokens of its own but must not touch the scheduling calendar. A rejection ends the connection with the
|
|
251
|
-
* provider's generic failure.
|
|
252
|
-
*/
|
|
253
|
-
exchange(code: string): Promise<CalendarConnectOutcome>;
|
|
254
|
-
}
|
|
255
|
-
interface CalendarConnectors {
|
|
256
|
-
google: CalendarConnector;
|
|
257
|
-
outlook: CalendarConnector;
|
|
258
|
-
}
|
|
259
|
-
/** Switches outbound webhooks on. A host that supplies none has them off: the routes answer 501 and nothing is queued. */
|
|
260
|
-
interface WebhookSettings {
|
|
261
|
-
/** Allows http addresses and addresses on a private network. For local development and tests only. Default: no. */
|
|
262
|
-
allowInsecureTargets?: boolean;
|
|
263
|
-
/** Sends one request. Default: Node's own http client, which refuses names that resolve to private addresses. */
|
|
264
|
-
transport?: WebhookTransport;
|
|
265
|
-
}
|
|
266
|
-
/** What the host does with a waitlist offer. Switching the waitlist on is what supplies this object. */
|
|
267
|
-
interface WaitlistSettings {
|
|
268
|
-
/** How long an offer lasts, in minutes, and never past the start of the slot. Default 30. */
|
|
269
|
-
offerMinutes?: number;
|
|
270
|
-
/**
|
|
271
|
-
* Tells the client that a slot is theirs to take: send `token` in a link to the page that calls
|
|
272
|
-
* `GET /waitlist/offer` and `POST /waitlist/offer/accept`. It runs inside the request that cancelled the booking, so it
|
|
273
|
-
* should only queue the message, not wait for it to be delivered. It must not throw; a rejection is logged and the offer
|
|
274
|
-
* stays open until it expires. Without it, only the `waitlist.offered` webhook announces the offer.
|
|
275
|
-
*/
|
|
276
|
-
notify?(offer: {
|
|
277
|
-
organizationId: string;
|
|
278
|
-
token: string;
|
|
279
|
-
clientName: string;
|
|
280
|
-
clientEmail: string;
|
|
281
|
-
clientPhone: string | null;
|
|
282
|
-
typeName: string;
|
|
283
|
-
calendarName: string;
|
|
284
|
-
startTime: Date;
|
|
285
|
-
timezone: string;
|
|
286
|
-
expiresAt: Date;
|
|
287
|
-
}): Promise<void>;
|
|
288
|
-
}
|
|
289
|
-
/** Switches routing forms on. A host that supplies none has them off: the routes answer 501. */
|
|
290
|
-
type RoutingFormSettings = Record<string, never>;
|
|
291
|
-
/**
|
|
292
|
-
* Switches organization branding on: a name, logo and colours for the booking page and messages, and a sender identity.
|
|
293
|
-
* A host that supplies none has it off: the routes answer 501 and no message carries a brand.
|
|
294
|
-
*/
|
|
295
|
-
interface BrandSettings {
|
|
296
|
-
/**
|
|
297
|
-
* Says whether the host may send mail from `domain` (lower case, such as "mail.acme.com"), usually because it has been
|
|
298
|
-
* verified with the mail provider. Without it no organization can set a sending address; it can still set a reply-to.
|
|
299
|
-
* A rejection counts as "no".
|
|
300
|
-
*/
|
|
301
|
-
isSendingDomainVerified?(domain: string, organizationId: string): boolean | Promise<boolean>;
|
|
302
|
-
/**
|
|
303
|
-
* Checks a sending domain record by record, so a setup screen can say exactly what is missing. With
|
|
304
|
-
* `createSendingDomainVerifier` pass its `check`. Without it the sending-domain check route answers 501.
|
|
305
|
-
*/
|
|
306
|
-
checkSendingDomain?(domain: string, organizationId: string): Promise<SendingDomainCheck>;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Switches per-organization text-message settings on: each organization picks a provider and a sending number. A host that
|
|
310
|
-
* supplies none has it off: the routes answer 501. The host keeps the provider accounts; nothing secret is stored per organization.
|
|
311
|
-
*/
|
|
312
|
-
interface TextMessageSettings {
|
|
313
|
-
/** The providers this server has accounts for. Default: Telnyx and Twilio. */
|
|
314
|
-
providers?: readonly TextProvider[];
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Switches API keys on: a request with `Authorization: Bearer <key>` acts as that key's organization. A host that supplies
|
|
318
|
-
* none has them off, and the routes answer 501.
|
|
319
|
-
*/
|
|
320
|
-
interface ApiKeySettings {
|
|
321
|
-
/**
|
|
322
|
-
* The database that holds the API key table, asked before the request's organization is known. It must be the same
|
|
323
|
-
* database the signed-in staff's `db` points at, because the key routes make keys through that one.
|
|
324
|
-
*/
|
|
325
|
-
db(): Promise<SchedulingDb>;
|
|
326
|
-
}
|
|
327
|
-
/** Switches data export and erasure on. A host that supplies none has them off: the routes answer 501. */
|
|
328
|
-
type PrivacySettings = Record<string, never>;
|
|
329
|
-
interface SchedulingHost {
|
|
330
|
-
/**
|
|
331
|
-
* The database for routes that have no signed-in user. Such a route reads the system database before it knows
|
|
332
|
-
* which organization the request belongs to, for example to find the organization of a calendar by its id.
|
|
333
|
-
*/
|
|
334
|
-
publicDb(): Promise<SchedulingDb>;
|
|
335
|
-
/** Finds the organization and database of a public booking page. Default: one organization in `publicDb()`. */
|
|
336
|
-
publicBooking?: PublicBookingResolver;
|
|
337
|
-
/** The web address of the host, such as https://system.example.com, used in links inside files it hands out. Default: none. */
|
|
338
|
-
appUrl?(): string | null | undefined;
|
|
339
|
-
/** The business name used in messages when a calendar has no staff name. Default: none. */
|
|
340
|
-
appName?(): string | null | undefined;
|
|
341
|
-
/** Whether scheduling is switched on for an organization, asked by public routes that know only the organization id. Default: yes. */
|
|
342
|
-
schedulingEnabledFor?(organizationId: string): Promise<boolean>;
|
|
343
|
-
/** Whether booking analytics is switched on for this installation. Default: on. */
|
|
344
|
-
bookingAnalyticsEnabled?(): boolean;
|
|
345
|
-
/** Whether the payment provider can charge in this currency (lower case, such as "usd"). Default: any currency. */
|
|
346
|
-
canChargeCurrency?(currency: string): boolean;
|
|
347
|
-
/**
|
|
348
|
-
* The database of one organization, for routes that find the organization only after reading a row, such as a
|
|
349
|
-
* manage-link token. Returns null when it cannot be reached. Default: `publicDb()`, for one organization.
|
|
350
|
-
*/
|
|
351
|
-
tenantDb?(organizationId: string, logPrefix: string): Promise<SchedulingDb | null>;
|
|
352
|
-
/** Announces appointment changes to connected screens. Default: nothing is announced. */
|
|
353
|
-
events?: AppointmentEventSink;
|
|
354
|
-
/**
|
|
355
|
-
* Keeps an outside calendar in step with an appointment. Failures are caught and reported through the activity
|
|
356
|
-
* log, never thrown. Default: nothing is synced.
|
|
357
|
-
*/
|
|
358
|
-
calendarSync?: CalendarSyncAdapter;
|
|
359
|
-
/**
|
|
360
|
-
* Turns on outbound webhooks: booking changes are queued for the organization's endpoints, and the admin routes
|
|
361
|
-
* work. Queued deliveries are sent by `deliverDueWebhooks` (or `POST /internal/webhooks/deliver`), which the host
|
|
362
|
-
* runs on a timer. Needs the webhook tables. Default: off.
|
|
363
|
-
*/
|
|
364
|
-
webhooks?: WebhookSettings | null;
|
|
365
|
-
/**
|
|
366
|
-
* Turns on the waitlist: clients can wait for a full slot or day, and a cancelled or moved booking offers its slot
|
|
367
|
-
* to the first person in line. Needs the waitlist table. Default: off, so the routes answer 501.
|
|
368
|
-
*/
|
|
369
|
-
waitlist?: WaitlistSettings | null;
|
|
370
|
-
/**
|
|
371
|
-
* Turns on routing forms: an admin defines questions and rules, and a public route sends a client to the right
|
|
372
|
-
* appointment type or calendar. Needs the routing form table. Default: off, so the routes answer 501.
|
|
373
|
-
*/
|
|
374
|
-
routingForms?: RoutingFormSettings | null;
|
|
375
|
-
/**
|
|
376
|
-
* Turns on exporting and erasing one person's data (admin only, every request recorded). Needs the data request table.
|
|
377
|
-
* Default: off, so the routes answer 501.
|
|
378
|
-
*/
|
|
379
|
-
privacy?: PrivacySettings | null;
|
|
380
|
-
/**
|
|
381
|
-
* Turns on organization branding. Needs the brand table. Messages carry the brand only if the host's message sender
|
|
382
|
-
* also asks for it (see `processPendingNotifications`' `brand` option). Default: off, so the routes answer 501.
|
|
383
|
-
*/
|
|
384
|
-
brand?: BrandSettings | null;
|
|
385
|
-
/**
|
|
386
|
-
* Turns on per-organization text-message settings. Needs the text-settings table. Default: off, so the routes answer 501.
|
|
387
|
-
*/
|
|
388
|
-
textMessages?: TextMessageSettings | null;
|
|
389
|
-
/**
|
|
390
|
-
* Turns on API keys for outside tools. Needs the API key table. Default: off, so a Bearer key is ignored and the key routes answer 501.
|
|
391
|
-
*/
|
|
392
|
-
apiKeys?: ApiKeySettings | null;
|
|
393
|
-
/** The domain used after the "@" in calendar-file event ids. Keep it unchanged once calendars have subscribed. Default: ordinatio-scheduling. */
|
|
394
|
-
icalUidDomain?(): string | null | undefined;
|
|
395
|
-
/** Records what happened in the activity feed. Default: nothing is recorded. */
|
|
396
|
-
activity?: ActivityLog;
|
|
397
|
-
/** Finds the organization named by an `orgSlug` query value. Default: one organization, nothing scoped. */
|
|
398
|
-
organizations?: PublicOrganizationResolver;
|
|
399
|
-
/** Stores free-slot answers for a minute. Default: in this process's memory. */
|
|
400
|
-
availabilityCache?: AvailabilityCache;
|
|
401
|
-
/** Stores answers that rarely change. Default: in this process's memory. */
|
|
402
|
-
cache?: SchedulingCache;
|
|
403
|
-
/**
|
|
404
|
-
* Counts one request against `key`. Returns null to let the request through, or the response to send
|
|
405
|
-
* (normally a 429). Default: an in-memory counter, which counts per process only.
|
|
406
|
-
*/
|
|
407
|
-
rateLimit?(key: string, tier: RateLimitTier): Promise<Response | null>;
|
|
408
|
-
/** Finds the signed-in member of a request, for routes only staff may call. Default: nobody is signed in, so those routes answer 401. */
|
|
409
|
-
staff?: StaffResolver;
|
|
410
|
-
/** Lists the staff of an organization. Default: nobody, so the staff picker is empty. */
|
|
411
|
-
staffDirectory?: StaffDirectory;
|
|
412
|
-
/** Bare-slug booking links across organizations. Default: none, so every claim succeeds and nothing is recorded. */
|
|
413
|
-
slugDirectory?: SlugDirectory;
|
|
414
|
-
/** Finds the client record of a new booking. Default: none, so every booking is saved unlinked. */
|
|
415
|
-
clients?: BookingClientResolver;
|
|
416
|
-
/** Per-organization booking rules. Default: none, so nobody is ever held back for missed appointments. */
|
|
417
|
-
bookingPolicy?: BookingPolicy;
|
|
418
|
-
/**
|
|
419
|
-
* Charges, checks and refunds payments. Default: none. A booking for a type that requires payment is then
|
|
420
|
-
* refused, because no payment can be verified.
|
|
421
|
-
*/
|
|
422
|
-
payments?: PaymentAdapter;
|
|
423
|
-
/**
|
|
424
|
-
* Cancels a payment that was created and then lost a race, and reads its current state. Default: none, so a
|
|
425
|
-
* payment that must be cancelled is reported as still live and staff are told to cancel it by hand.
|
|
426
|
-
*/
|
|
427
|
-
balancePayments?: BalancePaymentControl;
|
|
428
|
-
/** Who counts as the background worker, for routes only it may call. Default: nobody, so those routes answer 401. */
|
|
429
|
-
internalAccess?: InternalAccess;
|
|
430
|
-
/** Commands for the background worker. Default: they are dropped. */
|
|
431
|
-
workerCommands?: WorkerCommands;
|
|
432
|
-
/** The Google and Outlook sign-in flows. Default: neither is configured, so starting a connection answers 500 and finishing one fails. */
|
|
433
|
-
calendarConnectors?: CalendarConnectors;
|
|
434
|
-
/** Whether the short-lived sign-in cookies may only travel over https. Default: yes. */
|
|
435
|
-
secureCookies?(): boolean;
|
|
436
|
-
/** The value that clears a JSON column. Default: null. A Prisma host returns `Prisma.DbNull`, because Prisma refuses a plain null there. */
|
|
437
|
-
jsonNull?(): unknown;
|
|
438
|
-
/** CORS headers for answers to the booking widget, which runs on other websites. Default: any origin, no cookies. */
|
|
439
|
-
cors?(request?: Request): Record<string, string>;
|
|
440
|
-
}
|
|
441
|
-
/** The host with every default filled in. Handlers receive this. */
|
|
442
|
-
type ResolvedHost = Required<SchedulingHost>;
|
|
443
|
-
|
|
444
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
445
|
-
interface RouteContext {
|
|
446
|
-
host: ResolvedHost;
|
|
447
|
-
/** Values of the `[name]` segments in the route path. */
|
|
448
|
-
params: Record<string, string>;
|
|
449
|
-
}
|
|
450
|
-
type RouteHandler = (request: Request, context: RouteContext) => Promise<Response> | Response;
|
|
451
|
-
interface Route {
|
|
452
|
-
method: HttpMethod;
|
|
453
|
-
/** Relative to the base path. A `[name]` segment matches any one segment. */
|
|
454
|
-
path: string;
|
|
455
|
-
/** A public route is called from other websites, so it also answers a CORS preflight. */
|
|
456
|
-
public: boolean;
|
|
457
|
-
/** Needs a person at a browser (a consent screen, a cookie): a request made with an API key is refused with 403, whatever the key's access. */
|
|
458
|
-
personOnly?: boolean;
|
|
459
|
-
handler: RouteHandler;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
export { type AvailabilityCache as A, type BalancePaymentControl as B, type CacheOptions as C, type DnsResolver as D, type RouteContext as E, type RouteHandler as F, type RoutingFormSettings as G, type HttpMethod as H, type InternalAccess as I, type StaffDirectory as J, type WebhookSettings as K, type WorkerCommands as L, checkSendingDomain as M, type NoShowPolicy as N, normalizeSendingDomain as O, type PublicBookingResolver as P, type Route as R, type SchedulingHost as S, type WaitlistSettings as W, type RateLimitTier as a, type SchedulingCache as b, type PublicOrganizationResolver as c, type SendingDomainCheck as d, type SendingDomainRecord as e, type SendingDomainRecords as f, type StaffResolver as g, type StaffContext as h, type ActivityEntry as i, type ActivityLog as j, type ApiKeySettings as k, type AppointmentEventSink as l, type BookingClientResolver as m, type BookingPolicy as n, type BrandSettings as o, type CalendarConnectOutcome as p, type CalendarConnector as q, type CalendarConnectors as r, type CalendarVisibility as s, type PrivacySettings as t, type PublicBookingContext as u, type PublicBookingKind as v, type PublicOrganization as w, type RecordCheck as x, type RecordStatus as y, type ResolvedHost as z };
|