@ordinatio/scheduling 0.7.0 → 0.8.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0 (prepared 2026-11-19)
4
+
5
+ - **New: gift certificates.** Two new tables, `GiftCertificate` and `GiftCertificateTransaction` (migration `20261119000000_gift_certificates`, or `20261119000000_scheduling_gift_certificates` in the host database package; apply it before using certificates). A certificate is prepaid value in whole cents with a 12-character code (an alphabet without look-alikes, drawn with a cryptographic generator, stored upper case without hyphens, shown in groups of four with `formatGiftCode`). `issueGiftCertificate(db, organizationId, { amountCents, currency?, expiresAt?, recipientName?, recipientEmail?, purchaserName?, purchaserEmail?, message?, paymentId?, notes? }, createdByUserId?)` makes one worth 100 to 1,000,000 cents; the caller cannot choose the code or the balance. `listGiftCertificates`, `getGiftCertificate` (with its history) and `voidGiftCertificate` are scoped to the business. `checkGiftCertificate(db, organizationId, code)` tells a code holder only the balance, currency, expiry and state (`ACTIVE`, `VOID`, `EXPIRED`, `USED_UP`), and answers null for a malformed, unknown or another business's code, so codes cannot be probed.
6
+ - **Spending is safe at the same moment.** `redeemGiftCertificate(db, organizationId, code, { maxCents, currency, appointmentId?, note? })` takes the smaller of the balance and `maxCents` (so a certificate worth more than the bill keeps the rest) and returns what it took, the balance left and the currency. `currency` is the currency of the bill: a certificate only pays a bill in its own (`SCHED_1708`). Every spend and every refund first takes the certificate's row lock (a write to it that also moves its ledger counter on by one), so the checks that read its history cannot be overtaken and each ledger line gets its own number; a void takes the same lock through its own update. The balance is then written only if it still holds the value that was read, as a last fence (`SCHED_1703`, nothing taken), with its ledger line in the same transaction. Spending a certificate twice on one appointment is refused (`SCHED_1707`) unless the first spend was given back in full. `restoreGiftCertificate(db, organizationId, certificateId, { amountCents, appointmentId?, note? })` gives money back for a cancelled or refunded booking: with an appointment, no more than was spent on it and not yet returned, so a repeated refund returns nothing more; without one, never above the issued amount. A void certificate takes nothing back, and so does one with a status this version does not know; an expired one does, and its expiry is not extended. A database CHECK keeps a balance between zero and the issued amount, and a unique index keeps ledger line numbers from repeating, whatever the application does. The functions run on the Prisma client or on the client a transaction callback receives; any other handle is refused (`SCHED_1711`), and an error from them must abort a transaction the caller opened.
7
+ - **The history is in order.** Each ledger line has a `seq` (1 is the issue; each change is one higher), assigned under the lock, so the history reads in the order the balance actually changed. `getGiftCertificate` returns the first 1000 lines in `seq` order, with `truncated: true` when there were more. New columns: `GiftCertificate.ledgerSeq` and `GiftCertificateTransaction.seq`.
8
+ - **A payment that is reported twice makes one certificate.** `paymentId` is unique within a business (`@@unique([organizationId, paymentId])`): issuing again with a `paymentId` already used, for the same amount and currency, returns the first certificate, including when two requests race; asking for a different amount or currency is `SCHED_1710`. `issueGiftCertificateOnce` returns `{ certificate, created }`, so a caller can tell a repeat from a new sale and not record or announce it twice; `issueGiftCertificate` returns just the certificate.
9
+ - **Request text is checked.** An appointment id, note or currency that is not plain, bounded text is `SCHED_1709`; ids that are not text are "not found" (`SCHED_1712`). Emails are stored lower-case.
10
+ - Errors `SCHED_1700` to `SCHED_1712`. Redemption is not yet wired into booking or payment, and this release adds no routes; those come with the API and widget releases. The two read functions that take a code are not rate limited here: the host must limit them.
11
+
3
12
  ## 0.7.0 (prepared 2026-11-18)
4
13
 
5
14
  - **New: API keys, so an outside tool can act for one business.** A new table, `OrganizationApiKey` (`name`, `access`, a short `prefix`, `keyHash`, `createdByUserId`, `lastUsedAt`, `revokedAt`; migration `20261118000000_organization_api_keys`, or `20261118000000_scheduling_organization_api_keys` in the host database package; apply it before using keys). `createApiKey(db, organizationId, { name, access }, createdByUserId?)` returns `{ key, view }`: the secret (`osk_` and 43 characters) is in the result once and only its SHA-256 is stored. `access` is `READ` or `FULL`; a business may have 25 live keys (`SCHED_1601` beyond that; two requests at the same moment can pass the check together). `listApiKeys` never returns a hash, `revokeApiKey` answers whether it revoked a live key of that business, and `verifyApiKey(db, secret)` returns who a live key acts as or null (it never throws for a bad secret, and records "last used" at most every ten minutes without ever refusing a valid key if that write fails). A key whose stored access level is not `READ` or `FULL` is refused. Bad requests are `SCHED_1600` with every problem at once; a failed "last used" write is logged as `SCHED_1602`. Also exported: `validateApiKeyRequest`, `looksLikeApiKey`, `MAX_ACTIVE_API_KEYS`.
package/dist/index.d.mts CHANGED
@@ -11,7 +11,7 @@ import * as _prisma_client_runtime_client from '@prisma/client/runtime/client';
11
11
  * interface (minus $transaction itself) so code inside transactions
12
12
  * is fully typed without `as any` casts.
13
13
  */
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' | 'organizationTextSettings' | 'organizationApiKey' | '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' | 'organizationTextSettings' | 'organizationApiKey' | 'giftCertificate' | 'giftCertificateTransaction' | 'organization' | '$transaction' | '$executeRaw' | '$queryRaw'>;
15
15
  /**
16
16
  * Branded subtype of SchedulingDb for transaction clients produced by withTransaction().
17
17
  * selectCalendarForBooking() requires this type to enforce that its RoundRobinState
@@ -2832,4 +2832,159 @@ declare function revokeApiKey(db: SchedulingDb, organizationId: string, id: stri
2832
2832
  /** Who a secret acts as, or null when it is not a live key. Never throws for a bad secret. */
2833
2833
  declare function verifyApiKey(db: SchedulingDb, secret: string): Promise<VerifiedApiKey | null>;
2834
2834
 
2835
- export { API_KEY_ACCESS, API_KEY_FIELDS, API_KEY_NAME_MAX, type AcceptRelease, type AddTimeBlockInput, type ApiKeyAccess, type ApiKeyFields, type ApiKeyView, 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, type CreatedApiKey, 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_ACTIVE_API_KEYS, 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, TEXT_PROVIDERS, TEXT_SETTINGS_FIELDS, type TeamAvailabilityQuery, type TeamAvailabilityResult, type TestSendResult, type TextProvider, type TextSettingsFields, type TextSettingsProblem, type TextSettingsView, type TimeSlot, type TransportRequest, USER_DAY_LIMIT, type UpdateCalendarInput, type UrlCheckOptions, type UserDayInput, type UserDayResult, type ValidateBrandOptions, type ValidateTextSettingsOptions, type VerifiedApiKey, 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, createApiKey, createAppointmentType, createCalendar, createInMemoryAdapters, createNodeTransport, createNotificationTemplate, createRoutingForm, createWebhookEndpoint, deleteBrand, deleteCalendar, deleteNotificationTemplate, deleteRoutingForm, deleteTextSettings, 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, getTextSettings, getUserDayAppointments, getWaitlistOffer, isPrivateAddress, isSlotAvailable, isVirtualMeeting, joinWaitlist, leaveWaitlist, listApiKeys, listAppointmentTypes, listAppointments, listAvailabilityRules, listCalendars, listNotificationTemplates, listPrivacyRequests, listRoutingForms, listWaitlist, listWebhookDeliveries, listWebhookEndpoints, localDay, localToUTC, looksLikeApiKey, markNoShow, matchingRules, normalizeTextNumber, offerFreedSlot, parseSubject, parseTimeLocal, previewErase, processPendingNotifications, queueImmediateNotification, queueStaffNotification, releaseWaitlistAccept, removeDateOverride, removeWaitlistEntry, renderTemplate, rescheduleAppointment, resolveDestination, resolveLocation, resolveSubject, retryWebhookDelivery, revokeApiKey, routeClient, saveBrand, saveTextSettings, schedError, scheduleNotifications, scopeToOrganization, selectCalendarForBooking, sendTestWebhook, senderIdentity, setWeeklyAvailability, settleBookedAccept, signWebhook, subjectHashes, testRoutingForm, toPublicBrand, tryOfferFreedSlot, updateAppointmentType, updateCalendar, updateNotificationTemplate, updateRoutingForm, validateApiKeyRequest, validateBrand, validateRoutingDestinations, validateRoutingStructure, validateTextSettings, verifyApiKey, verifyWebhookSignature, withCalendarVisibility, withOrganization };
2835
+ declare const GIFT_CERTIFICATE_STATUS: readonly ["ACTIVE", "VOID"];
2836
+ type GiftCertificateStatus = (typeof GIFT_CERTIFICATE_STATUS)[number];
2837
+ /** What a certificate is in practice: "expired" and "used up" follow from the expiry and the balance. */
2838
+ type GiftCertificateState = GiftCertificateStatus | 'EXPIRED' | 'USED_UP';
2839
+ declare const GIFT_TRANSACTION_TYPES: readonly ["ISSUE", "REDEEM", "RESTORE", "VOID"];
2840
+ type GiftTransactionType = (typeof GIFT_TRANSACTION_TYPES)[number];
2841
+ declare const GIFT_CERTIFICATE_FIELDS: readonly ["amountCents", "currency", "expiresAt", "recipientName", "recipientEmail", "purchaserName", "purchaserEmail", "message", "paymentId", "notes"];
2842
+ declare const MIN_GIFT_CENTS = 100;
2843
+ declare const MAX_GIFT_CENTS = 1000000;
2844
+ interface GiftCertificateFields {
2845
+ amountCents: number;
2846
+ /** Lower-case ISO 4217 code such as "usd". */
2847
+ currency: string;
2848
+ expiresAt: Date | null;
2849
+ recipientName: string | null;
2850
+ recipientEmail: string | null;
2851
+ purchaserName: string | null;
2852
+ purchaserEmail: string | null;
2853
+ message: string | null;
2854
+ paymentId: string | null;
2855
+ notes: string | null;
2856
+ }
2857
+ /** A certificate as staff see it. The code is shown because staff resend it; treat it like cash. */
2858
+ interface GiftCertificateView {
2859
+ id: string;
2860
+ /** The code as stored: upper case, no hyphens. Use formatGiftCode to show it. */
2861
+ code: string;
2862
+ status: GiftCertificateStatus;
2863
+ currency: string;
2864
+ initialCents: number;
2865
+ balanceCents: number;
2866
+ expiresAt: Date | null;
2867
+ recipientName: string | null;
2868
+ recipientEmail: string | null;
2869
+ purchaserName: string | null;
2870
+ purchaserEmail: string | null;
2871
+ message: string | null;
2872
+ notes: string | null;
2873
+ paymentId: string | null;
2874
+ createdByUserId: string | null;
2875
+ createdAt: Date;
2876
+ }
2877
+ interface GiftCertificateTransactionView {
2878
+ id: string;
2879
+ /** The line's place in the history: 1 is the issue, and each later change has a higher number. */
2880
+ seq: number;
2881
+ type: GiftTransactionType;
2882
+ amountCents: number;
2883
+ balanceAfterCents: number;
2884
+ appointmentId: string | null;
2885
+ note: string | null;
2886
+ createdByUserId: string | null;
2887
+ createdAt: Date;
2888
+ }
2889
+ /** What anyone holding a code may learn about it: no names, no history. */
2890
+ interface GiftCertificateCheck {
2891
+ currency: string;
2892
+ balanceCents: number;
2893
+ expiresAt: Date | null;
2894
+ state: GiftCertificateState;
2895
+ }
2896
+ interface GiftRedemption {
2897
+ certificateId: string;
2898
+ transactionId: string;
2899
+ currency: string;
2900
+ /** What was taken: the smaller of the balance and the amount asked for. */
2901
+ appliedCents: number;
2902
+ balanceCents: number;
2903
+ }
2904
+ interface GiftRestoration {
2905
+ certificateId: string;
2906
+ transactionId: string;
2907
+ restoredCents: number;
2908
+ balanceCents: number;
2909
+ }
2910
+
2911
+ /** The stored form of whatever a person typed: upper case, spaces and hyphens removed. Not checked for shape. */
2912
+ declare function normalizeGiftCode(input: string): string;
2913
+ /** True when the text, once normalized, has the shape of a code this package makes. */
2914
+ declare function looksLikeGiftCode(input: string): boolean;
2915
+ /** "ABCD-EFGH-JKMN" for a stored code. */
2916
+ declare function formatGiftCode(code: string): string;
2917
+
2918
+ /** What a certificate is right now: voided, expired, used up, or active. A void one stays void whatever its balance, and a status this version does not know counts as void, so it can never be spent. */
2919
+ declare function giftCertificateState(certificate: {
2920
+ status: string;
2921
+ balanceCents: number;
2922
+ expiresAt: Date | null;
2923
+ }, now?: Date): GiftCertificateState;
2924
+
2925
+ /** The cleaned-up request for a new certificate, or a SCHED_1700 error listing every problem. */
2926
+ declare function validateGiftCertificateRequest(input: unknown, now?: Date): GiftCertificateFields;
2927
+
2928
+ declare const DEFAULT_LIST_LIMIT = 100;
2929
+ declare const MAX_LIST_LIMIT = 500;
2930
+ declare const MAX_HISTORY_LINES = 1000;
2931
+ /**
2932
+ * Makes a certificate worth `amountCents`. Throws SCHED_1700 for a bad request. The code is drawn at random; a clash with
2933
+ * an existing code is retried, and SCHED_1705 follows only if that fails five times in a row. A request that carries a
2934
+ * `paymentId` already used by this business returns that first certificate instead of making a second, so a payment notice
2935
+ * that is delivered twice cannot make two. `created` says which happened, for a caller that must not record or announce a
2936
+ * repeat as a new sale.
2937
+ */
2938
+ declare function issueGiftCertificateOnce(db: SchedulingDb, organizationId: string, input: unknown, createdByUserId?: string): Promise<{
2939
+ certificate: GiftCertificateView;
2940
+ created: boolean;
2941
+ }>;
2942
+ /** Like `issueGiftCertificateOnce`, for a caller that only wants the certificate. */
2943
+ declare function issueGiftCertificate(db: SchedulingDb, organizationId: string, input: unknown, createdByUserId?: string): Promise<GiftCertificateView>;
2944
+ /** The business's certificates, newest first. */
2945
+ declare function listGiftCertificates(db: SchedulingDb, organizationId: string, options?: {
2946
+ status?: GiftCertificateStatus;
2947
+ limit?: number;
2948
+ }): Promise<GiftCertificateView[]>;
2949
+ /**
2950
+ * One certificate with its history in order, oldest line first. At most the first 1000 lines come back, and `truncated` says
2951
+ * when there were more. SCHED_1712 for an unknown or other business's certificate.
2952
+ */
2953
+ declare function getGiftCertificate(db: SchedulingDb, organizationId: string, id: string): Promise<{
2954
+ certificate: GiftCertificateView;
2955
+ transactions: GiftCertificateTransactionView[];
2956
+ truncated: boolean;
2957
+ }>;
2958
+ /** Stops a certificate from being spent; its balance and history stay. True when it was active, false for an unknown, other-business or already void one. */
2959
+ declare function voidGiftCertificate(db: SchedulingDb, organizationId: string, id: string, userId?: string): Promise<boolean>;
2960
+
2961
+ /** What a code holder may learn about it, or null when no certificate of this business has that code. Never throws for a bad code. */
2962
+ declare function checkGiftCertificate(db: SchedulingDb, organizationId: string, code: string, now?: Date): Promise<GiftCertificateCheck | null>;
2963
+ /**
2964
+ * Takes up to `maxCents` from the certificate with this code: the smaller of the balance and the amount asked for, so a
2965
+ * certificate worth more than the bill pays it all and keeps the rest. `currency` is the currency of the bill; a certificate
2966
+ * only pays a bill in its own (SCHED_1708). Throws SCHED_1712 when no certificate of this business has the code, SCHED_1702
2967
+ * when it is void, expired or used up, SCHED_1707 when it was already spent on this appointment and not given back in
2968
+ * full, SCHED_1706 for a bad amount, SCHED_1709 for bad text, SCHED_1711 for a handle that is not a client or a transaction,
2969
+ * and SCHED_1703 if the balance changed after the lock was taken, which should not happen. `now` is for tests: a host must
2970
+ * not take it from a caller, since it decides whether a certificate has expired.
2971
+ */
2972
+ declare function redeemGiftCertificate(db: SchedulingDb | TxClient, organizationId: string, code: string, input: {
2973
+ maxCents: number;
2974
+ currency: string;
2975
+ appointmentId?: string;
2976
+ note?: string;
2977
+ }, now?: Date): Promise<GiftRedemption>;
2978
+ /**
2979
+ * Gives money back to a certificate, for a cancelled or refunded booking. With an appointment, no more can be given back
2980
+ * than was spent on it and not yet returned, so a repeated refund adds nothing (SCHED_1704). Without one (a staff
2981
+ * correction), the balance may not rise above what the certificate was issued for. A void certificate takes nothing back
2982
+ * (SCHED_1702); an expired one does, and its expiry is not extended.
2983
+ */
2984
+ declare function restoreGiftCertificate(db: SchedulingDb | TxClient, organizationId: string, certificateId: string, input: {
2985
+ amountCents: number;
2986
+ appointmentId?: string;
2987
+ note?: string;
2988
+ }, userId?: string): Promise<GiftRestoration>;
2989
+
2990
+ export { API_KEY_ACCESS, API_KEY_FIELDS, API_KEY_NAME_MAX, type AcceptRelease, type AddTimeBlockInput, type ApiKeyAccess, type ApiKeyFields, type ApiKeyView, 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, type CreatedApiKey, DEFAULT_BACKOFF_SECONDS, DEFAULT_LIST_LIMIT, DEFAULT_OFFER_MINUTES, type DashboardQuery, type DayAppointment, type DeliverOptions, type DeliverSummary, ERASED_EMAIL, ERASED_NAME, type EraseBlockers, type ErasePreview, type FreedSlot, GIFT_CERTIFICATE_FIELDS, GIFT_CERTIFICATE_STATUS, GIFT_TRANSACTION_TYPES, type GiftCertificateCheck, type GiftCertificateFields, type GiftCertificateState, type GiftCertificateStatus, type GiftCertificateTransactionView, type GiftCertificateView, type GiftRedemption, type GiftRestoration, type GiftTransactionType, type GroupCapacityResult, type GroupSession, type GroupSessionAttendee, type InMemoryClockControl, type InMemoryOptions, type InMemoryRecords, type IntakeFormField, type JoinWaitlistInput, LIMITS, MAX_ACTIVE_API_KEYS, MAX_ENDPOINTS_PER_ORGANIZATION, MAX_GIFT_CENTS, MAX_HISTORY_LINES, MAX_LIST_LIMIT, MAX_WAITING_PER_TYPE_DAY, MIN_GIFT_CENTS, 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, TEXT_PROVIDERS, TEXT_SETTINGS_FIELDS, type TeamAvailabilityQuery, type TeamAvailabilityResult, type TestSendResult, type TextProvider, type TextSettingsFields, type TextSettingsProblem, type TextSettingsView, type TimeSlot, type TransportRequest, USER_DAY_LIMIT, type UpdateCalendarInput, type UrlCheckOptions, type UserDayInput, type UserDayResult, type ValidateBrandOptions, type ValidateTextSettingsOptions, type VerifiedApiKey, 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, checkGiftCertificate, checkNotificationContract, checkPaymentContract, checkWebhookUrl, completeWaitlistAccept, createApiKey, createAppointmentType, createCalendar, createInMemoryAdapters, createNodeTransport, createNotificationTemplate, createRoutingForm, createWebhookEndpoint, deleteBrand, deleteCalendar, deleteNotificationTemplate, deleteRoutingForm, deleteTextSettings, deleteWebhookEndpoint, deliverDueWebhooks, enqueueAppointmentWebhook, enqueueReminderSent, enqueueWebhookEvent, eraseSubject, expireWaitlistOffers, exportSubject, formatGiftCode, generateOccurrenceDates, generateWebhookSecret, getAppointment, getAppointmentDashboard, getAppointmentType, getAppointmentsForRange, getAvailableDates, getAvailableSlots, getBookingAnalytics, getBrand, getCalendar, getGiftCertificate, getGroupCapacity, getGroupSessions, getNotificationTemplate, getPublicBrand, getPublicRoutingForm, getRoutingForm, getTeamAvailableSlots, getTextSettings, getUserDayAppointments, getWaitlistOffer, giftCertificateState, isPrivateAddress, isSlotAvailable, isVirtualMeeting, issueGiftCertificate, issueGiftCertificateOnce, joinWaitlist, leaveWaitlist, listApiKeys, listAppointmentTypes, listAppointments, listAvailabilityRules, listCalendars, listGiftCertificates, listNotificationTemplates, listPrivacyRequests, listRoutingForms, listWaitlist, listWebhookDeliveries, listWebhookEndpoints, localDay, localToUTC, looksLikeApiKey, looksLikeGiftCode, markNoShow, matchingRules, normalizeGiftCode, normalizeTextNumber, offerFreedSlot, parseSubject, parseTimeLocal, previewErase, processPendingNotifications, queueImmediateNotification, queueStaffNotification, redeemGiftCertificate, releaseWaitlistAccept, removeDateOverride, removeWaitlistEntry, renderTemplate, rescheduleAppointment, resolveDestination, resolveLocation, resolveSubject, restoreGiftCertificate, retryWebhookDelivery, revokeApiKey, routeClient, saveBrand, saveTextSettings, schedError, scheduleNotifications, scopeToOrganization, selectCalendarForBooking, sendTestWebhook, senderIdentity, setWeeklyAvailability, settleBookedAccept, signWebhook, subjectHashes, testRoutingForm, toPublicBrand, tryOfferFreedSlot, updateAppointmentType, updateCalendar, updateNotificationTemplate, updateRoutingForm, validateApiKeyRequest, validateBrand, validateGiftCertificateRequest, validateRoutingDestinations, validateRoutingStructure, validateTextSettings, verifyApiKey, verifyWebhookSignature, voidGiftCertificate, withCalendarVisibility, withOrganization };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import * as _prisma_client_runtime_client from '@prisma/client/runtime/client';
11
11
  * interface (minus $transaction itself) so code inside transactions
12
12
  * is fully typed without `as any` casts.
13
13
  */
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' | 'organizationTextSettings' | 'organizationApiKey' | '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' | 'organizationTextSettings' | 'organizationApiKey' | 'giftCertificate' | 'giftCertificateTransaction' | 'organization' | '$transaction' | '$executeRaw' | '$queryRaw'>;
15
15
  /**
16
16
  * Branded subtype of SchedulingDb for transaction clients produced by withTransaction().
17
17
  * selectCalendarForBooking() requires this type to enforce that its RoundRobinState
@@ -2832,4 +2832,159 @@ declare function revokeApiKey(db: SchedulingDb, organizationId: string, id: stri
2832
2832
  /** Who a secret acts as, or null when it is not a live key. Never throws for a bad secret. */
2833
2833
  declare function verifyApiKey(db: SchedulingDb, secret: string): Promise<VerifiedApiKey | null>;
2834
2834
 
2835
- export { API_KEY_ACCESS, API_KEY_FIELDS, API_KEY_NAME_MAX, type AcceptRelease, type AddTimeBlockInput, type ApiKeyAccess, type ApiKeyFields, type ApiKeyView, 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, type CreatedApiKey, 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_ACTIVE_API_KEYS, 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, TEXT_PROVIDERS, TEXT_SETTINGS_FIELDS, type TeamAvailabilityQuery, type TeamAvailabilityResult, type TestSendResult, type TextProvider, type TextSettingsFields, type TextSettingsProblem, type TextSettingsView, type TimeSlot, type TransportRequest, USER_DAY_LIMIT, type UpdateCalendarInput, type UrlCheckOptions, type UserDayInput, type UserDayResult, type ValidateBrandOptions, type ValidateTextSettingsOptions, type VerifiedApiKey, 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, createApiKey, createAppointmentType, createCalendar, createInMemoryAdapters, createNodeTransport, createNotificationTemplate, createRoutingForm, createWebhookEndpoint, deleteBrand, deleteCalendar, deleteNotificationTemplate, deleteRoutingForm, deleteTextSettings, 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, getTextSettings, getUserDayAppointments, getWaitlistOffer, isPrivateAddress, isSlotAvailable, isVirtualMeeting, joinWaitlist, leaveWaitlist, listApiKeys, listAppointmentTypes, listAppointments, listAvailabilityRules, listCalendars, listNotificationTemplates, listPrivacyRequests, listRoutingForms, listWaitlist, listWebhookDeliveries, listWebhookEndpoints, localDay, localToUTC, looksLikeApiKey, markNoShow, matchingRules, normalizeTextNumber, offerFreedSlot, parseSubject, parseTimeLocal, previewErase, processPendingNotifications, queueImmediateNotification, queueStaffNotification, releaseWaitlistAccept, removeDateOverride, removeWaitlistEntry, renderTemplate, rescheduleAppointment, resolveDestination, resolveLocation, resolveSubject, retryWebhookDelivery, revokeApiKey, routeClient, saveBrand, saveTextSettings, schedError, scheduleNotifications, scopeToOrganization, selectCalendarForBooking, sendTestWebhook, senderIdentity, setWeeklyAvailability, settleBookedAccept, signWebhook, subjectHashes, testRoutingForm, toPublicBrand, tryOfferFreedSlot, updateAppointmentType, updateCalendar, updateNotificationTemplate, updateRoutingForm, validateApiKeyRequest, validateBrand, validateRoutingDestinations, validateRoutingStructure, validateTextSettings, verifyApiKey, verifyWebhookSignature, withCalendarVisibility, withOrganization };
2835
+ declare const GIFT_CERTIFICATE_STATUS: readonly ["ACTIVE", "VOID"];
2836
+ type GiftCertificateStatus = (typeof GIFT_CERTIFICATE_STATUS)[number];
2837
+ /** What a certificate is in practice: "expired" and "used up" follow from the expiry and the balance. */
2838
+ type GiftCertificateState = GiftCertificateStatus | 'EXPIRED' | 'USED_UP';
2839
+ declare const GIFT_TRANSACTION_TYPES: readonly ["ISSUE", "REDEEM", "RESTORE", "VOID"];
2840
+ type GiftTransactionType = (typeof GIFT_TRANSACTION_TYPES)[number];
2841
+ declare const GIFT_CERTIFICATE_FIELDS: readonly ["amountCents", "currency", "expiresAt", "recipientName", "recipientEmail", "purchaserName", "purchaserEmail", "message", "paymentId", "notes"];
2842
+ declare const MIN_GIFT_CENTS = 100;
2843
+ declare const MAX_GIFT_CENTS = 1000000;
2844
+ interface GiftCertificateFields {
2845
+ amountCents: number;
2846
+ /** Lower-case ISO 4217 code such as "usd". */
2847
+ currency: string;
2848
+ expiresAt: Date | null;
2849
+ recipientName: string | null;
2850
+ recipientEmail: string | null;
2851
+ purchaserName: string | null;
2852
+ purchaserEmail: string | null;
2853
+ message: string | null;
2854
+ paymentId: string | null;
2855
+ notes: string | null;
2856
+ }
2857
+ /** A certificate as staff see it. The code is shown because staff resend it; treat it like cash. */
2858
+ interface GiftCertificateView {
2859
+ id: string;
2860
+ /** The code as stored: upper case, no hyphens. Use formatGiftCode to show it. */
2861
+ code: string;
2862
+ status: GiftCertificateStatus;
2863
+ currency: string;
2864
+ initialCents: number;
2865
+ balanceCents: number;
2866
+ expiresAt: Date | null;
2867
+ recipientName: string | null;
2868
+ recipientEmail: string | null;
2869
+ purchaserName: string | null;
2870
+ purchaserEmail: string | null;
2871
+ message: string | null;
2872
+ notes: string | null;
2873
+ paymentId: string | null;
2874
+ createdByUserId: string | null;
2875
+ createdAt: Date;
2876
+ }
2877
+ interface GiftCertificateTransactionView {
2878
+ id: string;
2879
+ /** The line's place in the history: 1 is the issue, and each later change has a higher number. */
2880
+ seq: number;
2881
+ type: GiftTransactionType;
2882
+ amountCents: number;
2883
+ balanceAfterCents: number;
2884
+ appointmentId: string | null;
2885
+ note: string | null;
2886
+ createdByUserId: string | null;
2887
+ createdAt: Date;
2888
+ }
2889
+ /** What anyone holding a code may learn about it: no names, no history. */
2890
+ interface GiftCertificateCheck {
2891
+ currency: string;
2892
+ balanceCents: number;
2893
+ expiresAt: Date | null;
2894
+ state: GiftCertificateState;
2895
+ }
2896
+ interface GiftRedemption {
2897
+ certificateId: string;
2898
+ transactionId: string;
2899
+ currency: string;
2900
+ /** What was taken: the smaller of the balance and the amount asked for. */
2901
+ appliedCents: number;
2902
+ balanceCents: number;
2903
+ }
2904
+ interface GiftRestoration {
2905
+ certificateId: string;
2906
+ transactionId: string;
2907
+ restoredCents: number;
2908
+ balanceCents: number;
2909
+ }
2910
+
2911
+ /** The stored form of whatever a person typed: upper case, spaces and hyphens removed. Not checked for shape. */
2912
+ declare function normalizeGiftCode(input: string): string;
2913
+ /** True when the text, once normalized, has the shape of a code this package makes. */
2914
+ declare function looksLikeGiftCode(input: string): boolean;
2915
+ /** "ABCD-EFGH-JKMN" for a stored code. */
2916
+ declare function formatGiftCode(code: string): string;
2917
+
2918
+ /** What a certificate is right now: voided, expired, used up, or active. A void one stays void whatever its balance, and a status this version does not know counts as void, so it can never be spent. */
2919
+ declare function giftCertificateState(certificate: {
2920
+ status: string;
2921
+ balanceCents: number;
2922
+ expiresAt: Date | null;
2923
+ }, now?: Date): GiftCertificateState;
2924
+
2925
+ /** The cleaned-up request for a new certificate, or a SCHED_1700 error listing every problem. */
2926
+ declare function validateGiftCertificateRequest(input: unknown, now?: Date): GiftCertificateFields;
2927
+
2928
+ declare const DEFAULT_LIST_LIMIT = 100;
2929
+ declare const MAX_LIST_LIMIT = 500;
2930
+ declare const MAX_HISTORY_LINES = 1000;
2931
+ /**
2932
+ * Makes a certificate worth `amountCents`. Throws SCHED_1700 for a bad request. The code is drawn at random; a clash with
2933
+ * an existing code is retried, and SCHED_1705 follows only if that fails five times in a row. A request that carries a
2934
+ * `paymentId` already used by this business returns that first certificate instead of making a second, so a payment notice
2935
+ * that is delivered twice cannot make two. `created` says which happened, for a caller that must not record or announce a
2936
+ * repeat as a new sale.
2937
+ */
2938
+ declare function issueGiftCertificateOnce(db: SchedulingDb, organizationId: string, input: unknown, createdByUserId?: string): Promise<{
2939
+ certificate: GiftCertificateView;
2940
+ created: boolean;
2941
+ }>;
2942
+ /** Like `issueGiftCertificateOnce`, for a caller that only wants the certificate. */
2943
+ declare function issueGiftCertificate(db: SchedulingDb, organizationId: string, input: unknown, createdByUserId?: string): Promise<GiftCertificateView>;
2944
+ /** The business's certificates, newest first. */
2945
+ declare function listGiftCertificates(db: SchedulingDb, organizationId: string, options?: {
2946
+ status?: GiftCertificateStatus;
2947
+ limit?: number;
2948
+ }): Promise<GiftCertificateView[]>;
2949
+ /**
2950
+ * One certificate with its history in order, oldest line first. At most the first 1000 lines come back, and `truncated` says
2951
+ * when there were more. SCHED_1712 for an unknown or other business's certificate.
2952
+ */
2953
+ declare function getGiftCertificate(db: SchedulingDb, organizationId: string, id: string): Promise<{
2954
+ certificate: GiftCertificateView;
2955
+ transactions: GiftCertificateTransactionView[];
2956
+ truncated: boolean;
2957
+ }>;
2958
+ /** Stops a certificate from being spent; its balance and history stay. True when it was active, false for an unknown, other-business or already void one. */
2959
+ declare function voidGiftCertificate(db: SchedulingDb, organizationId: string, id: string, userId?: string): Promise<boolean>;
2960
+
2961
+ /** What a code holder may learn about it, or null when no certificate of this business has that code. Never throws for a bad code. */
2962
+ declare function checkGiftCertificate(db: SchedulingDb, organizationId: string, code: string, now?: Date): Promise<GiftCertificateCheck | null>;
2963
+ /**
2964
+ * Takes up to `maxCents` from the certificate with this code: the smaller of the balance and the amount asked for, so a
2965
+ * certificate worth more than the bill pays it all and keeps the rest. `currency` is the currency of the bill; a certificate
2966
+ * only pays a bill in its own (SCHED_1708). Throws SCHED_1712 when no certificate of this business has the code, SCHED_1702
2967
+ * when it is void, expired or used up, SCHED_1707 when it was already spent on this appointment and not given back in
2968
+ * full, SCHED_1706 for a bad amount, SCHED_1709 for bad text, SCHED_1711 for a handle that is not a client or a transaction,
2969
+ * and SCHED_1703 if the balance changed after the lock was taken, which should not happen. `now` is for tests: a host must
2970
+ * not take it from a caller, since it decides whether a certificate has expired.
2971
+ */
2972
+ declare function redeemGiftCertificate(db: SchedulingDb | TxClient, organizationId: string, code: string, input: {
2973
+ maxCents: number;
2974
+ currency: string;
2975
+ appointmentId?: string;
2976
+ note?: string;
2977
+ }, now?: Date): Promise<GiftRedemption>;
2978
+ /**
2979
+ * Gives money back to a certificate, for a cancelled or refunded booking. With an appointment, no more can be given back
2980
+ * than was spent on it and not yet returned, so a repeated refund adds nothing (SCHED_1704). Without one (a staff
2981
+ * correction), the balance may not rise above what the certificate was issued for. A void certificate takes nothing back
2982
+ * (SCHED_1702); an expired one does, and its expiry is not extended.
2983
+ */
2984
+ declare function restoreGiftCertificate(db: SchedulingDb | TxClient, organizationId: string, certificateId: string, input: {
2985
+ amountCents: number;
2986
+ appointmentId?: string;
2987
+ note?: string;
2988
+ }, userId?: string): Promise<GiftRestoration>;
2989
+
2990
+ export { API_KEY_ACCESS, API_KEY_FIELDS, API_KEY_NAME_MAX, type AcceptRelease, type AddTimeBlockInput, type ApiKeyAccess, type ApiKeyFields, type ApiKeyView, 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, type CreatedApiKey, DEFAULT_BACKOFF_SECONDS, DEFAULT_LIST_LIMIT, DEFAULT_OFFER_MINUTES, type DashboardQuery, type DayAppointment, type DeliverOptions, type DeliverSummary, ERASED_EMAIL, ERASED_NAME, type EraseBlockers, type ErasePreview, type FreedSlot, GIFT_CERTIFICATE_FIELDS, GIFT_CERTIFICATE_STATUS, GIFT_TRANSACTION_TYPES, type GiftCertificateCheck, type GiftCertificateFields, type GiftCertificateState, type GiftCertificateStatus, type GiftCertificateTransactionView, type GiftCertificateView, type GiftRedemption, type GiftRestoration, type GiftTransactionType, type GroupCapacityResult, type GroupSession, type GroupSessionAttendee, type InMemoryClockControl, type InMemoryOptions, type InMemoryRecords, type IntakeFormField, type JoinWaitlistInput, LIMITS, MAX_ACTIVE_API_KEYS, MAX_ENDPOINTS_PER_ORGANIZATION, MAX_GIFT_CENTS, MAX_HISTORY_LINES, MAX_LIST_LIMIT, MAX_WAITING_PER_TYPE_DAY, MIN_GIFT_CENTS, 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, TEXT_PROVIDERS, TEXT_SETTINGS_FIELDS, type TeamAvailabilityQuery, type TeamAvailabilityResult, type TestSendResult, type TextProvider, type TextSettingsFields, type TextSettingsProblem, type TextSettingsView, type TimeSlot, type TransportRequest, USER_DAY_LIMIT, type UpdateCalendarInput, type UrlCheckOptions, type UserDayInput, type UserDayResult, type ValidateBrandOptions, type ValidateTextSettingsOptions, type VerifiedApiKey, 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, checkGiftCertificate, checkNotificationContract, checkPaymentContract, checkWebhookUrl, completeWaitlistAccept, createApiKey, createAppointmentType, createCalendar, createInMemoryAdapters, createNodeTransport, createNotificationTemplate, createRoutingForm, createWebhookEndpoint, deleteBrand, deleteCalendar, deleteNotificationTemplate, deleteRoutingForm, deleteTextSettings, deleteWebhookEndpoint, deliverDueWebhooks, enqueueAppointmentWebhook, enqueueReminderSent, enqueueWebhookEvent, eraseSubject, expireWaitlistOffers, exportSubject, formatGiftCode, generateOccurrenceDates, generateWebhookSecret, getAppointment, getAppointmentDashboard, getAppointmentType, getAppointmentsForRange, getAvailableDates, getAvailableSlots, getBookingAnalytics, getBrand, getCalendar, getGiftCertificate, getGroupCapacity, getGroupSessions, getNotificationTemplate, getPublicBrand, getPublicRoutingForm, getRoutingForm, getTeamAvailableSlots, getTextSettings, getUserDayAppointments, getWaitlistOffer, giftCertificateState, isPrivateAddress, isSlotAvailable, isVirtualMeeting, issueGiftCertificate, issueGiftCertificateOnce, joinWaitlist, leaveWaitlist, listApiKeys, listAppointmentTypes, listAppointments, listAvailabilityRules, listCalendars, listGiftCertificates, listNotificationTemplates, listPrivacyRequests, listRoutingForms, listWaitlist, listWebhookDeliveries, listWebhookEndpoints, localDay, localToUTC, looksLikeApiKey, looksLikeGiftCode, markNoShow, matchingRules, normalizeGiftCode, normalizeTextNumber, offerFreedSlot, parseSubject, parseTimeLocal, previewErase, processPendingNotifications, queueImmediateNotification, queueStaffNotification, redeemGiftCertificate, releaseWaitlistAccept, removeDateOverride, removeWaitlistEntry, renderTemplate, rescheduleAppointment, resolveDestination, resolveLocation, resolveSubject, restoreGiftCertificate, retryWebhookDelivery, revokeApiKey, routeClient, saveBrand, saveTextSettings, schedError, scheduleNotifications, scopeToOrganization, selectCalendarForBooking, sendTestWebhook, senderIdentity, setWeeklyAvailability, settleBookedAccept, signWebhook, subjectHashes, testRoutingForm, toPublicBrand, tryOfferFreedSlot, updateAppointmentType, updateCalendar, updateNotificationTemplate, updateRoutingForm, validateApiKeyRequest, validateBrand, validateGiftCertificateRequest, validateRoutingDestinations, validateRoutingStructure, validateTextSettings, verifyApiKey, verifyWebhookSignature, voidGiftCertificate, withCalendarVisibility, withOrganization };