riverbankcms 0.37.0 → 0.38.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/dist/acceptance/matrix.mjs +3 -3
- package/dist/cli/index.mjs +5406 -2692
- package/dist/cli/init-docs/content/getting-started.md +10 -10
- package/dist/{entryCommands-CXGj-eca.mjs → entryCommands-Db_o9w2r.mjs} +3695 -603
- package/dist/{eventUpsertInputSchema-DZdxyRB6.mjs → eventUpsertInputSchema-CHMFsN8M.mjs} +2 -2
- package/dist/load-config-CkNUO_cn.mjs +4 -0
- package/dist/{load-config-Bhh-kYhx.mjs → load-config-aVpLIpK_.mjs} +2 -2
- package/dist/{plan-FPq8qKNu.mjs → plan-CNisrgzZ.mjs} +9 -12
- package/dist/scaffold/index.mjs +2 -2
- package/dist/{sdk-event-upsert-BL6uAz53.mjs → sdk-event-upsert-CLqEh-D2.mjs} +56 -25
- package/dist/{src-ClX_VLD6.mjs → src-CE4CDO3T.mjs} +233 -34
- package/dist/testing.mjs +4 -4
- package/package.json +1 -1
- package/dist/load-config-DTT9jeYi.mjs +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $n as
|
|
3
|
-
import { $ as
|
|
4
|
-
import { n as CliSdkPeerError, t as loadConfigFile } from "./load-config-
|
|
2
|
+
import { $n as footerLookIdValues, At as getMimeType, Bt as footerPreferencesSchema, Cn as eventBookingOfferIntentSchema, Cr as asPageFlowPresetId, Dr as bookingQuestionAttachmentSchema, Er as compareEntrySlug, Et as slugifyMediaIdentifier, Fn as RESOLVED_INTERNAL_LINK_ENTITY_TYPES, Ft as MAX_MANAGEMENT_MEDIA_UPLOAD_BYTES, Gn as ICON_PICKER_PRESETS, Hr as slugPart, I as footerModeSchema, Jn as SUPPORTED_LOADER_ENDPOINTS, Mr as createContentEntryRef, Mt as normalizeAmbiguousStoragePathForSite, Pt as FILE_SIZE_LIMITS, Sn as require_dist, St as buildMediaIdentifierFromFilename, Tr as makeBoundaryId, Tt as resolveMediaIdentifier, V as themeSchema, Xn as asHeaderLayoutId, Yn as asFooterLookId, Zn as asHeaderStyleId, Zt as buttonStyleSelectionSchema, ar as SYSTEM_BLOCK_KINDS, at as parseAspectRatioValue, b as getSiteCommandMetadata, bt as mediaTypeDiscriminants, ct as getDirectImageUrlForSiteScopedPath, er as headerLayoutIdValues, h as parseAndPlanCommandBatchForTypes, jr as createCommandRef, k as headerPreferencesSchema, kt as getExtensionForMimeType, l as resolvePageUpsertSeo, m as createDryRunReport, mr as asAppearancePresetId, n as sdkCourseBookingSettingsSchema, p as stableStringify, r as sdkEventOccurrenceInputSchema, s as eventVisibilitySchema, tr as headerStyleIdValues, v as evaluateSiteCommandBatchExposure, vr as asDesignBlockId, vt as PUBLIC_FILE_FIELD_KINDS, w as entryIdentifierForCommand, wr as asSiteStyleId, y as evaluateSiteCommandExposure, yr as asDesignBoundaryId, yt as isDisplayMediaKind, zr as createSiteCommandSiteRef } from "./sdk-event-upsert-CLqEh-D2.mjs";
|
|
3
|
+
import { $n as parseCustomerId, A as getPublicReadCachePolicy, At as validateBookingPaymentOptionKinds, Bn as unsafeAsNonNegativeCents, Br as parseRetiredCourseId, Bt as scheduleBookingReasonCodes, C as DEFAULT_EVENT_TYPE_PRESETS, Cr as parseOrderId, Dr as unsafeAsOrderPaymentPlanId, E as SURFACE_EVENT_PRESET_VALUES, Er as unsafeAsOrderFlexibleBalanceContractId, Fn as isNonNegativeWholeCents$1, Gr as unsafeAsPricingOptionId, H as exposeSecret, Hn as formatCurrencyAmount, Hr as unsafeAsEventOfferingId, Ht as resolveFlexibleBalanceInitialPaymentCents, In as parseNonNegativeCents, Kr as err, Ln as parsePositiveCents, Lr as parseAttendeeId, Lt as omitZeroAmountFutureRows, M as publicReadBatchFreshnessSeconds, Mn as fromArray, Mr as parseApiKeyId, Mt as addIntervalPreservingMonthAnchor, N as publicReadFreshnessSeconds, Nr as parseSiteId, Nt as clampConfiguredAmount, O as PUBLIC_AVAILABILITY_FRESHNESS_SECONDS, Or as unsafeAsOrderPaymentReceiptId, Pr as parseUserId, Pt as getBookingInstalmentDepositRefundability, Qn as unsafeAsStaffMemberId, Rn as toCents, Rr as parseEventSeriesId, Rt as splitAmountWithRemainderInFirst, S as resolveSiteVerticalBookingConfig, St as publicLocationSchema, Tr as unsafeAsCheckoutLineId, Tt as trimmedStringOrNull, U as parseManagementKey, Un as parseCurrencyCode, Ur as unsafeAsEventSeriesId, V as createSecret, Vn as unsafeAsPositiveCents, Vt as resolveFlexibleBalanceDueAt, Wn as assertNever, Wr as unsafeAsOccurrenceId, Xn as parseClientArrangementId, Yn as parseAppointmentId, Yt as formatDate, Zn as unsafeAsAppointmentResourceId, _n as resolveBookingTimeZoneId, ar as parseDatedOfferingCapacityHoldAuditRef, b as parseVerticalId, dt as assertAllowedPublicUrl, er as parseSiteTermsVersionId, et as parseMailingListProviderScope, fn as parseBookingLocalDate, g as withBookingModulesForSelectionChange, h as resolveEventCatalogue, hn as toUtcIsoDateTimeString, ht as stableJsonStringify, i as committedWriteProofSchema, in as addLocalScheduleDays, ir as unsafeAsPassId, j as isPublicReadEndpoint, jt as isLiveOrderInstalmentPlanStatus, k as PUBLIC_CONTENT_FRESHNESS_SECONDS, kr as parseEditorSessionGeneration, ln as getLocalScheduleDate, lr as parseMediaAssetId, m as planTurningOnCourses, n as OFFLINE_PAYMENT_METHODS, nr as parseMembershipId, on as formatLocalScheduleDate, or as parseDatedOfferingCapacityHoldId, qr as ok, r as bookingContextId, s as APPOINTMENT_REQUEST_OUTCOME_VALUES, sr as parseWaitlistEntryId, tr as parseEntitlementId, tt as parseFooterCompositionV1, u as STAFF_OPERATIONAL_CAPABILITIES, v as areConfiguredBookingVerticalConfigsEqual, vt as locationValueSchema, w as EVENT_PRESET_VALUES, wr as parseOrderPaymentReceiptId, x as parseVerticalPresetId, y as canonicalizeConfiguredBookingVerticalConfig, zn as toNonNegativeCents, zr as parseEventSeriesRegistrationId, zt as businessCancellationRefusalCodes } from "./src-CE4CDO3T.mjs";
|
|
4
|
+
import { n as CliSdkPeerError, t as loadConfigFile } from "./load-config-aVpLIpK_.mjs";
|
|
5
5
|
import { safeParse, z } from "zod";
|
|
6
6
|
import { Argument, Command, Option } from "commander";
|
|
7
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -906,7 +906,7 @@ const reasonMessages = {
|
|
|
906
906
|
paused: "Editing is paused for maintenance. You can keep viewing the site.",
|
|
907
907
|
"session-stale": "This editing session has ended. Refresh the page to continue.",
|
|
908
908
|
"lease-lost": "Editing moved to another tab. Open editing here to continue.",
|
|
909
|
-
"authority-denied": "You
|
|
909
|
+
"authority-denied": "You don’t have permission to make this change on this site.",
|
|
910
910
|
"stale-preimage": "This page changed before your save. Refresh the page before making that change again.",
|
|
911
911
|
"stale-revision": "This page changed before your save. Refresh the page before making that change again.",
|
|
912
912
|
"obsolete-schedule": "This publication schedule changed. Check the current schedule before continuing.",
|
|
@@ -2537,7 +2537,11 @@ const APPOINTMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
2537
2537
|
method: "DELETE",
|
|
2538
2538
|
auth: "user",
|
|
2539
2539
|
responseKind: "json",
|
|
2540
|
-
errors: [
|
|
2540
|
+
errors: [
|
|
2541
|
+
"resource:not_found",
|
|
2542
|
+
"resource:conflict",
|
|
2543
|
+
"server:internal_error"
|
|
2544
|
+
]
|
|
2541
2545
|
},
|
|
2542
2546
|
getAppointmentSetup: {
|
|
2543
2547
|
path: "/sites/{siteId}/bookings/appointment-setup",
|
|
@@ -4104,6 +4108,11 @@ const eventCalendarListLayoutCompatibleDisplayModeValues = ["combined", "list"];
|
|
|
4104
4108
|
//#region ../site-contracts/src/siteData/eventCheckoutTypes.ts
|
|
4105
4109
|
/** The most dates or runs one booking request may name; the block stops ticking at the same number. */
|
|
4106
4110
|
const MAX_EVENT_BOOKING_SELECTION_ITEMS = 20;
|
|
4111
|
+
/**
|
|
4112
|
+
* The most earlier bookings one request may name as its own. A tab holds one place at a time, so the
|
|
4113
|
+
* few are that booking and the attempts that might have replaced it.
|
|
4114
|
+
*/
|
|
4115
|
+
const MAX_REPLACED_REGISTRATION_COMMAND_IDS = 3;
|
|
4107
4116
|
|
|
4108
4117
|
//#endregion
|
|
4109
4118
|
//#region ../site-contracts/src/siteData/eventSelectionFunding.ts
|
|
@@ -4143,7 +4152,7 @@ const uncoveredReason = z.enum([
|
|
|
4143
4152
|
"already_used_on_date",
|
|
4144
4153
|
"no_credits_left"
|
|
4145
4154
|
]);
|
|
4146
|
-
const cents$
|
|
4155
|
+
const cents$3 = z.number().int().nonnegative();
|
|
4147
4156
|
const credits = z.object({
|
|
4148
4157
|
used: z.number().int().nonnegative(),
|
|
4149
4158
|
leftAfter: z.number().int().nonnegative()
|
|
@@ -4166,7 +4175,7 @@ const entitlementSchema = z.discriminatedUnion("kind", [
|
|
|
4166
4175
|
kind: z.literal("buyPass"),
|
|
4167
4176
|
productId: id,
|
|
4168
4177
|
name: z.string(),
|
|
4169
|
-
priceCents: cents$
|
|
4178
|
+
priceCents: cents$3,
|
|
4170
4179
|
credits: credits.extend({ total: z.number().int().positive() }),
|
|
4171
4180
|
expiresAt: z.string().nullable()
|
|
4172
4181
|
}),
|
|
@@ -4174,15 +4183,15 @@ const entitlementSchema = z.discriminatedUnion("kind", [
|
|
|
4174
4183
|
kind: z.literal("buyMembership"),
|
|
4175
4184
|
productId: id,
|
|
4176
4185
|
name: z.string(),
|
|
4177
|
-
priceCents: cents$
|
|
4186
|
+
priceCents: cents$3,
|
|
4178
4187
|
interval: z.enum(["month", "year"])
|
|
4179
4188
|
})
|
|
4180
4189
|
]);
|
|
4181
4190
|
const moneySchema = z.object({
|
|
4182
|
-
totalCents: cents$
|
|
4191
|
+
totalCents: cents$3,
|
|
4183
4192
|
currency: z.string().min(1)
|
|
4184
4193
|
});
|
|
4185
|
-
const optionSchema = z.discriminatedUnion("kind", [z.object({
|
|
4194
|
+
const optionSchema$2 = z.discriminatedUnion("kind", [z.object({
|
|
4186
4195
|
kind: z.literal("money"),
|
|
4187
4196
|
moneyDates: ids,
|
|
4188
4197
|
money: moneySchema
|
|
@@ -4197,7 +4206,7 @@ const optionSchema = z.discriminatedUnion("kind", [z.object({
|
|
|
4197
4206
|
money: moneySchema
|
|
4198
4207
|
})]);
|
|
4199
4208
|
const eventSelectionFundingSchema = z.object({
|
|
4200
|
-
options: z.tuple([optionSchema]).rest(optionSchema).readonly(),
|
|
4209
|
+
options: z.tuple([optionSchema$2]).rest(optionSchema$2).readonly(),
|
|
4201
4210
|
selected: eventSelectionFundingPickSchema,
|
|
4202
4211
|
entitlementNote: z.enum(["none", "severalPlaces"])
|
|
4203
4212
|
});
|
|
@@ -4813,32 +4822,38 @@ function repriceBookingCollectionOptions(input) {
|
|
|
4813
4822
|
}
|
|
4814
4823
|
/** The same admission is used for the offer and the submitted selection. */
|
|
4815
4824
|
function canOfferBookingCollectionOption(option, currency, deadline = option.bookingStartAt) {
|
|
4825
|
+
return collectionDatesOpen(option, deadline) && laterCollectionsChargeable(option, currency);
|
|
4826
|
+
}
|
|
4827
|
+
/** The one date rule: whether an option's due dates still fall between now and the booking (or the owner's deadline). */
|
|
4828
|
+
function collectionDatesOpen(option, deadline) {
|
|
4816
4829
|
if (option.kind === "upfront" || option.kind === "deferred_manual") return true;
|
|
4817
4830
|
const window$1 = bookingCollectionWindow(option);
|
|
4818
4831
|
if (!window$1) return false;
|
|
4819
|
-
const { now, start } = window$1;
|
|
4820
4832
|
if (option.kind === "flexible_balance") {
|
|
4821
|
-
|
|
4833
|
+
const localDay = (at) => formatLocalScheduleDate(getLocalScheduleDate(new Date(at), option.timeZone));
|
|
4834
|
+
return option.balanceDueDay >= localDay(window$1.now) && option.balanceDueDay < localDay(window$1.start);
|
|
4822
4835
|
}
|
|
4823
4836
|
return deadline !== null && canInstalmentPlanCompleteBefore({
|
|
4824
4837
|
now: option.anchorAt,
|
|
4825
4838
|
deadline,
|
|
4826
4839
|
schedule: option.schedule
|
|
4827
|
-
}) &&
|
|
4840
|
+
}) && option.schedule.every((row) => row.stateAtBooking !== "scheduled" || Date.parse(row.dueAt) > window$1.now);
|
|
4828
4841
|
}
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
+
/** The amount rule: every later collection is big enough to charge to a card. */
|
|
4843
|
+
function laterCollectionsChargeable(option, currency) {
|
|
4844
|
+
switch (option.kind) {
|
|
4845
|
+
case "upfront":
|
|
4846
|
+
case "deferred_manual": return true;
|
|
4847
|
+
case "flexible_balance": return !isStripeChargeBelowMinimum({
|
|
4848
|
+
amountCents: option.remainingBalanceCents,
|
|
4849
|
+
currency
|
|
4850
|
+
});
|
|
4851
|
+
case "instalment_plan": return option.schedule.every((row) => row.stateAtBooking !== "scheduled" || !isStripeChargeBelowMinimum({
|
|
4852
|
+
amountCents: row.amountCents,
|
|
4853
|
+
currency
|
|
4854
|
+
}));
|
|
4855
|
+
default: return assertNever$3(option);
|
|
4856
|
+
}
|
|
4842
4857
|
}
|
|
4843
4858
|
function bookingCollectionWindow(option) {
|
|
4844
4859
|
const now = Date.parse(option.anchorAt);
|
|
@@ -4859,33 +4874,18 @@ const SCHEDULE_DATES_TOTAL_CENTS = 1e9;
|
|
|
4859
4874
|
*/
|
|
4860
4875
|
function bookingCollectionDatesOpen(option, dates) {
|
|
4861
4876
|
if (option.kind === "upfront" || option.kind === "deferred_manual") return true;
|
|
4862
|
-
|
|
4877
|
+
if (!bookingCollectionWindow({
|
|
4863
4878
|
anchorAt: dates.nowIso,
|
|
4864
4879
|
bookingStartAt: dates.bookingStartAt
|
|
4880
|
+
})) return false;
|
|
4881
|
+
const resolved = resolveBookingCollectionOptionFacts({
|
|
4882
|
+
option,
|
|
4883
|
+
totalCents: SCHEDULE_DATES_TOTAL_CENTS,
|
|
4884
|
+
anchorAt: dates.nowIso,
|
|
4885
|
+
bookingStartAt: dates.bookingStartAt,
|
|
4886
|
+
timeZone: dates.timeZone
|
|
4865
4887
|
});
|
|
4866
|
-
|
|
4867
|
-
switch (option.kind) {
|
|
4868
|
-
case "flexible_balance": {
|
|
4869
|
-
const due = flexibleBalanceDueDay(option.config, dates.bookingStartAt, dates.timeZone);
|
|
4870
|
-
const localDay = (at) => formatLocalScheduleDate(getLocalScheduleDate(new Date(at), dates.timeZone));
|
|
4871
|
-
return due >= localDay(window$1.now) && due < localDay(window$1.start);
|
|
4872
|
-
}
|
|
4873
|
-
case "instalment_plan": {
|
|
4874
|
-
const deadline = dates.instalmentCollectionDeadlineAt === undefined ? dates.bookingStartAt : dates.instalmentCollectionDeadlineAt;
|
|
4875
|
-
if (deadline === null) return false;
|
|
4876
|
-
const schedule = buildBookingInstalmentSchedule({
|
|
4877
|
-
anchorAt: dates.nowIso,
|
|
4878
|
-
totalAmountCents: SCHEDULE_DATES_TOTAL_CENTS,
|
|
4879
|
-
plan: option.plan
|
|
4880
|
-
});
|
|
4881
|
-
return canInstalmentPlanCompleteBefore({
|
|
4882
|
-
now: dates.nowIso,
|
|
4883
|
-
deadline,
|
|
4884
|
-
schedule
|
|
4885
|
-
}) && schedule.every((row) => row.stateAtBooking !== "scheduled" || Date.parse(row.dueAt) > window$1.now);
|
|
4886
|
-
}
|
|
4887
|
-
default: return assertNever$3(option);
|
|
4888
|
-
}
|
|
4888
|
+
return collectionDatesOpen(resolved, dates.instalmentCollectionDeadlineAt === undefined ? dates.bookingStartAt : dates.instalmentCollectionDeadlineAt);
|
|
4889
4889
|
}
|
|
4890
4890
|
/** Mirrors private.flexible_balance_due_day: fixed civil date, or local start minus calendar days. */
|
|
4891
4891
|
function flexibleBalanceDueDay(config, bookingStartAt, timeZone) {
|
|
@@ -5971,8 +5971,8 @@ const settledBalanceSchema = z.object({ kind: z.literal("settled") });
|
|
|
5971
5971
|
const dueBalanceSchema = z.object({
|
|
5972
5972
|
kind: z.literal("due"),
|
|
5973
5973
|
amountCents: z.number().int().positive().transform((value, ctx) => {
|
|
5974
|
-
const cents$
|
|
5975
|
-
if (cents$
|
|
5974
|
+
const cents$4 = parsePositiveCents(value);
|
|
5975
|
+
if (cents$4.ok) return cents$4.value;
|
|
5976
5976
|
ctx.addIssue({
|
|
5977
5977
|
code: "custom",
|
|
5978
5978
|
message: "Expected positive whole cents"
|
|
@@ -6056,6 +6056,18 @@ const submissionPaymentSchema = z.object({
|
|
|
6056
6056
|
|
|
6057
6057
|
//#endregion
|
|
6058
6058
|
//#region ../commerce/src/purchase/orderPaymentState.ts
|
|
6059
|
+
/**
|
|
6060
|
+
* When the whole remaining balance falls due, or null when no single date covers it.
|
|
6061
|
+
* An instalment plan's next date only covers the balance when that instalment is the last.
|
|
6062
|
+
*/
|
|
6063
|
+
function wholeBalanceDueAt(terms, outstandingCents) {
|
|
6064
|
+
switch (terms.kind) {
|
|
6065
|
+
case "immediate":
|
|
6066
|
+
case "manual": return null;
|
|
6067
|
+
case "flexible_balance": return terms.dueAt;
|
|
6068
|
+
case "instalment_plan": return terms.nextDueAmountCents !== null && terms.nextDueAmountCents >= outstandingCents ? terms.nextDueAt : null;
|
|
6069
|
+
}
|
|
6070
|
+
}
|
|
6059
6071
|
/** Amount arithmetic shared by strict payment evidence and tolerant email snapshots.
|
|
6060
6072
|
* Snapshots historically clamp overcollection to zero; the strict decision below
|
|
6061
6073
|
* checks collectability before using the same calculation.
|
|
@@ -6089,15 +6101,6 @@ function resolveOnlineOrderCheckoutMode(order) {
|
|
|
6089
6101
|
|
|
6090
6102
|
//#endregion
|
|
6091
6103
|
//#region ../commerce/src/purchase/confirmationPayment.ts
|
|
6092
|
-
function termsDueAt(terms) {
|
|
6093
|
-
switch (terms.kind) {
|
|
6094
|
-
case "immediate":
|
|
6095
|
-
case "manual": return null;
|
|
6096
|
-
case "flexible_balance": return terms.dueAt;
|
|
6097
|
-
case "instalment_plan": return terms.nextDueAt;
|
|
6098
|
-
default: return assertNever$3(terms);
|
|
6099
|
-
}
|
|
6100
|
-
}
|
|
6101
6104
|
function decideMonetaryPayment(input) {
|
|
6102
6105
|
const outstanding = calculateOrderBalanceDueCents({
|
|
6103
6106
|
grandTotalCents: input.cashDueCents,
|
|
@@ -6123,7 +6126,7 @@ function decideMonetaryPayment(input) {
|
|
|
6123
6126
|
const balance = {
|
|
6124
6127
|
kind: "due",
|
|
6125
6128
|
amountCents: positive.value,
|
|
6126
|
-
dueAt:
|
|
6129
|
+
dueAt: wholeBalanceDueAt(input.terms, positive.value)
|
|
6127
6130
|
};
|
|
6128
6131
|
if (input.terms.kind === "flexible_balance" || input.terms.kind === "instalment_plan") {
|
|
6129
6132
|
return ok({
|
|
@@ -7712,6 +7715,432 @@ function planUnappliedOrderPaymentReceiptAllocations(input) {
|
|
|
7712
7715
|
return attributedCents === input.amountCents ? ok(allocations) : err({ kind: "allocation_invariant_failed" });
|
|
7713
7716
|
}
|
|
7714
7717
|
|
|
7718
|
+
//#endregion
|
|
7719
|
+
//#region ../commerce/src/purchase/orderPaymentPosition.ts
|
|
7720
|
+
const cents$2 = z.number().int().nonnegative().transform(toNonNegativeCents);
|
|
7721
|
+
const orderPaymentAdmissionSchema = z.discriminatedUnion("kind", [
|
|
7722
|
+
z.object({ kind: z.literal("admitted") }),
|
|
7723
|
+
z.object({ kind: z.literal("requires_provider_check") }),
|
|
7724
|
+
z.object({
|
|
7725
|
+
kind: z.literal("refused"),
|
|
7726
|
+
reason: z.enum([
|
|
7727
|
+
"in_progress",
|
|
7728
|
+
"cancelled",
|
|
7729
|
+
"disputed",
|
|
7730
|
+
"identity",
|
|
7731
|
+
"amounts",
|
|
7732
|
+
"conflicting_terms",
|
|
7733
|
+
"provider_reconciliation",
|
|
7734
|
+
"missing_instalments",
|
|
7735
|
+
"nothing_owed",
|
|
7736
|
+
"not_committed",
|
|
7737
|
+
"unsupported_payment_method",
|
|
7738
|
+
"live_terms",
|
|
7739
|
+
"not_applicable",
|
|
7740
|
+
"terms_closed",
|
|
7741
|
+
"refunded",
|
|
7742
|
+
"partly_cancelled",
|
|
7743
|
+
"retired",
|
|
7744
|
+
"retirement_pending",
|
|
7745
|
+
"cancelled_non_payment",
|
|
7746
|
+
"non_monetary",
|
|
7747
|
+
"settled",
|
|
7748
|
+
"checkout_failed",
|
|
7749
|
+
"archived",
|
|
7750
|
+
"recurring_collection_active",
|
|
7751
|
+
"below_card_minimum"
|
|
7752
|
+
])
|
|
7753
|
+
})
|
|
7754
|
+
]).readonly();
|
|
7755
|
+
const orderPaymentOperationKeys = [
|
|
7756
|
+
"manualReceipt",
|
|
7757
|
+
"waiver",
|
|
7758
|
+
"paymentLink",
|
|
7759
|
+
"demand",
|
|
7760
|
+
"partialRefund",
|
|
7761
|
+
"closeBalance",
|
|
7762
|
+
"instalmentSetup",
|
|
7763
|
+
"cashlessCompletion",
|
|
7764
|
+
"initialCheckout",
|
|
7765
|
+
"checkoutResume",
|
|
7766
|
+
"providerReceipt",
|
|
7767
|
+
"recovery",
|
|
7768
|
+
"closePlan",
|
|
7769
|
+
"partialManualReceipt",
|
|
7770
|
+
"expiryRelease",
|
|
7771
|
+
"manualReceiptPreparation",
|
|
7772
|
+
"waiverPreparation",
|
|
7773
|
+
"paymentLinkPreparation",
|
|
7774
|
+
"priceChange",
|
|
7775
|
+
"bookingRestore",
|
|
7776
|
+
"staffCancellation"
|
|
7777
|
+
];
|
|
7778
|
+
const retirementScope = z.discriminatedUnion("kind", [
|
|
7779
|
+
z.object({ kind: z.literal("pending") }),
|
|
7780
|
+
z.object({ kind: z.literal("whole_order") }),
|
|
7781
|
+
z.object({ kind: z.literal("terms_only") }),
|
|
7782
|
+
z.object({
|
|
7783
|
+
kind: z.literal("items"),
|
|
7784
|
+
itemIds: z.array(z.string().uuid()).readonly()
|
|
7785
|
+
})
|
|
7786
|
+
]).readonly();
|
|
7787
|
+
const orderRefundProtectionSchema = z.object({
|
|
7788
|
+
subject: z.discriminatedUnion("kind", [z.object({ kind: z.literal("none") }), z.object({
|
|
7789
|
+
kind: z.literal("protected_deposit"),
|
|
7790
|
+
sourceKind: z.enum(["flexible_balance", "instalment_plan"]),
|
|
7791
|
+
protectedDepositAmountCents: cents$2,
|
|
7792
|
+
depositRefundability: z.enum(["refundable", "non_refundable"])
|
|
7793
|
+
})]).readonly(),
|
|
7794
|
+
funding: z.array(z.object({
|
|
7795
|
+
orderItemId: z.string().uuid(),
|
|
7796
|
+
paymentReceiptId: z.string().uuid().nullable(),
|
|
7797
|
+
originalCents: cents$2,
|
|
7798
|
+
totalRemainingRefundableCents: cents$2,
|
|
7799
|
+
policyRefundableCents: cents$2,
|
|
7800
|
+
protectedDepositRemainingCents: cents$2
|
|
7801
|
+
}).readonly()).readonly()
|
|
7802
|
+
}).readonly();
|
|
7803
|
+
/**
|
|
7804
|
+
* What each item owes and has had. Refunds don't reopen debt, and held credit isn't collected yet.
|
|
7805
|
+
* Cash outstanding is what the database lets a payment or a waiver take: outstanding less held credit.
|
|
7806
|
+
* `live` is false once the item's booking is cancelled. Unless a contract or plan holds the balance,
|
|
7807
|
+
* only live items can be paid, and the order's remainder is what they still owe.
|
|
7808
|
+
*/
|
|
7809
|
+
const orderMoneyItemSchema = z.object({
|
|
7810
|
+
orderItemId: z.string().uuid(),
|
|
7811
|
+
dueCents: cents$2,
|
|
7812
|
+
collectedCents: cents$2,
|
|
7813
|
+
waivedCents: cents$2,
|
|
7814
|
+
outstandingCents: cents$2,
|
|
7815
|
+
creditHeldCents: cents$2,
|
|
7816
|
+
cashOutstandingCents: cents$2,
|
|
7817
|
+
refundedToCustomerCents: cents$2,
|
|
7818
|
+
live: z.boolean()
|
|
7819
|
+
}).readonly();
|
|
7820
|
+
/** Money a refund can come from. A waiver never appears here, so nothing can name one as a source. */
|
|
7821
|
+
const orderFundingLineSchema = z.object({
|
|
7822
|
+
allocationId: z.string().uuid(),
|
|
7823
|
+
orderItemId: z.string().uuid(),
|
|
7824
|
+
source: z.discriminatedUnion("kind", [z.object({
|
|
7825
|
+
kind: z.literal("receipt"),
|
|
7826
|
+
receiptId: z.string().uuid().transform(unsafeAsOrderPaymentReceiptId),
|
|
7827
|
+
disputed: z.boolean()
|
|
7828
|
+
}), z.object({
|
|
7829
|
+
kind: z.literal("credit_debit"),
|
|
7830
|
+
creditTransactionId: z.string().uuid()
|
|
7831
|
+
})]).readonly(),
|
|
7832
|
+
amountCents: cents$2,
|
|
7833
|
+
taxCents: cents$2,
|
|
7834
|
+
settledCents: cents$2,
|
|
7835
|
+
heldCents: cents$2,
|
|
7836
|
+
refundableCents: cents$2
|
|
7837
|
+
}).readonly();
|
|
7838
|
+
/** SQL owns the decision. This schema only parses its closed result. */
|
|
7839
|
+
const orderPaymentPositionSchema = z.object({
|
|
7840
|
+
orderStatus: z.enum([
|
|
7841
|
+
"pending",
|
|
7842
|
+
"paid",
|
|
7843
|
+
"partially_refunded",
|
|
7844
|
+
"refunded",
|
|
7845
|
+
"cancelled",
|
|
7846
|
+
"failed"
|
|
7847
|
+
]),
|
|
7848
|
+
refundProtection: orderRefundProtectionSchema,
|
|
7849
|
+
items: z.array(orderMoneyItemSchema).readonly(),
|
|
7850
|
+
funding: z.array(orderFundingLineSchema).readonly(),
|
|
7851
|
+
amounts: z.object({
|
|
7852
|
+
totalCents: cents$2,
|
|
7853
|
+
collectedCents: cents$2,
|
|
7854
|
+
refundedCents: cents$2,
|
|
7855
|
+
waivedCents: cents$2,
|
|
7856
|
+
remainderCents: cents$2
|
|
7857
|
+
}).readonly(),
|
|
7858
|
+
lifecycle: z.discriminatedUnion("kind", [
|
|
7859
|
+
z.object({ kind: z.literal("open") }),
|
|
7860
|
+
z.object({
|
|
7861
|
+
kind: z.literal("retired"),
|
|
7862
|
+
scope: retirementScope,
|
|
7863
|
+
reason: z.enum([
|
|
7864
|
+
"staff",
|
|
7865
|
+
"checkout_failed",
|
|
7866
|
+
"abandoned_failed",
|
|
7867
|
+
"abandoned_cancelled",
|
|
7868
|
+
"dispute_lost",
|
|
7869
|
+
"booking_cancelled"
|
|
7870
|
+
])
|
|
7871
|
+
}),
|
|
7872
|
+
z.object({ kind: z.literal("cancelled_non_payment") })
|
|
7873
|
+
]).readonly(),
|
|
7874
|
+
openDispute: z.boolean(),
|
|
7875
|
+
termsLive: z.boolean(),
|
|
7876
|
+
admissions: z.object({
|
|
7877
|
+
bookingRestore: orderPaymentAdmissionSchema,
|
|
7878
|
+
staffCancellation: orderPaymentAdmissionSchema,
|
|
7879
|
+
manualReceipt: orderPaymentAdmissionSchema,
|
|
7880
|
+
waiver: orderPaymentAdmissionSchema,
|
|
7881
|
+
paymentLink: orderPaymentAdmissionSchema,
|
|
7882
|
+
demand: orderPaymentAdmissionSchema,
|
|
7883
|
+
partialRefund: orderPaymentAdmissionSchema,
|
|
7884
|
+
closeBalance: orderPaymentAdmissionSchema,
|
|
7885
|
+
instalmentSetup: orderPaymentAdmissionSchema,
|
|
7886
|
+
cashlessCompletion: orderPaymentAdmissionSchema,
|
|
7887
|
+
initialCheckout: orderPaymentAdmissionSchema,
|
|
7888
|
+
checkoutResume: orderPaymentAdmissionSchema,
|
|
7889
|
+
providerReceipt: orderPaymentAdmissionSchema,
|
|
7890
|
+
recovery: orderPaymentAdmissionSchema,
|
|
7891
|
+
closePlan: orderPaymentAdmissionSchema,
|
|
7892
|
+
partialManualReceipt: orderPaymentAdmissionSchema,
|
|
7893
|
+
expiryRelease: orderPaymentAdmissionSchema,
|
|
7894
|
+
manualReceiptPreparation: orderPaymentAdmissionSchema,
|
|
7895
|
+
waiverPreparation: orderPaymentAdmissionSchema,
|
|
7896
|
+
paymentLinkPreparation: orderPaymentAdmissionSchema,
|
|
7897
|
+
priceChange: orderPaymentAdmissionSchema
|
|
7898
|
+
}).readonly(),
|
|
7899
|
+
paymentSelection: z.object({
|
|
7900
|
+
kind: z.enum(["full", "custom"]),
|
|
7901
|
+
minimumCents: cents$2,
|
|
7902
|
+
maximumCents: cents$2,
|
|
7903
|
+
maximumCustomCents: cents$2,
|
|
7904
|
+
reason: z.enum(["overdue", "dust_balance"])
|
|
7905
|
+
}).readonly(),
|
|
7906
|
+
collection: z.discriminatedUnion("kind", [
|
|
7907
|
+
z.object({ kind: z.literal("available") }),
|
|
7908
|
+
z.object({ kind: z.literal("in_progress") }),
|
|
7909
|
+
z.object({
|
|
7910
|
+
kind: z.literal("closed"),
|
|
7911
|
+
reason: z.enum([
|
|
7912
|
+
"archived",
|
|
7913
|
+
"partly_cancelled",
|
|
7914
|
+
"retired",
|
|
7915
|
+
"retirement_pending",
|
|
7916
|
+
"cancelled_non_payment",
|
|
7917
|
+
"disputed",
|
|
7918
|
+
"non_monetary",
|
|
7919
|
+
"settled",
|
|
7920
|
+
"terms_closed",
|
|
7921
|
+
"refunded",
|
|
7922
|
+
"not_committed",
|
|
7923
|
+
"checkout_failed"
|
|
7924
|
+
])
|
|
7925
|
+
}),
|
|
7926
|
+
z.object({
|
|
7927
|
+
kind: z.literal("unresolved"),
|
|
7928
|
+
reason: z.enum([
|
|
7929
|
+
"identity",
|
|
7930
|
+
"amounts",
|
|
7931
|
+
"conflicting_terms",
|
|
7932
|
+
"provider_reconciliation",
|
|
7933
|
+
"missing_instalments"
|
|
7934
|
+
])
|
|
7935
|
+
})
|
|
7936
|
+
]).readonly(),
|
|
7937
|
+
deadline: z.discriminatedUnion("kind", [
|
|
7938
|
+
z.object({ kind: z.literal("none") }),
|
|
7939
|
+
z.object({
|
|
7940
|
+
kind: z.literal("not_yet_due"),
|
|
7941
|
+
dueAt: z.string().datetime({ offset: true }),
|
|
7942
|
+
dueDay: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
7943
|
+
timezone: z.string().optional()
|
|
7944
|
+
}),
|
|
7945
|
+
z.object({
|
|
7946
|
+
kind: z.literal("overdue"),
|
|
7947
|
+
dueAt: z.string().datetime({ offset: true }),
|
|
7948
|
+
dueDay: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
7949
|
+
timezone: z.string().optional()
|
|
7950
|
+
})
|
|
7951
|
+
]).readonly(),
|
|
7952
|
+
terms: z.discriminatedUnion("kind", [
|
|
7953
|
+
z.object({ kind: z.literal("immediate") }),
|
|
7954
|
+
z.object({ kind: z.literal("manual") }),
|
|
7955
|
+
z.object({
|
|
7956
|
+
kind: z.literal("flexible_balance"),
|
|
7957
|
+
contractId: z.string().uuid().transform(unsafeAsOrderFlexibleBalanceContractId),
|
|
7958
|
+
upfrontAmountCents: cents$2
|
|
7959
|
+
}),
|
|
7960
|
+
z.object({
|
|
7961
|
+
kind: z.literal("instalment_plan"),
|
|
7962
|
+
paymentPlanId: z.string().uuid().transform(unsafeAsOrderPaymentPlanId),
|
|
7963
|
+
nextDueAmountCents: cents$2.nullable(),
|
|
7964
|
+
collectionStopped: z.boolean(),
|
|
7965
|
+
state: z.object({ kind: z.enum([
|
|
7966
|
+
"active",
|
|
7967
|
+
"payment_failed",
|
|
7968
|
+
"pending_initial_payment",
|
|
7969
|
+
"reconciliation_required",
|
|
7970
|
+
"cancelled",
|
|
7971
|
+
"refunded",
|
|
7972
|
+
"completed"
|
|
7973
|
+
]) }).readonly()
|
|
7974
|
+
})
|
|
7975
|
+
]).readonly(),
|
|
7976
|
+
paymentMethod: z.enum([
|
|
7977
|
+
"free",
|
|
7978
|
+
"waived",
|
|
7979
|
+
"pass_redemption",
|
|
7980
|
+
"membership_access",
|
|
7981
|
+
"stripe",
|
|
7982
|
+
"store_credit",
|
|
7983
|
+
"mixed",
|
|
7984
|
+
"manual"
|
|
7985
|
+
]),
|
|
7986
|
+
currency: z.string().transform((value, ctx) => {
|
|
7987
|
+
const currency = parseCurrencyCode(value);
|
|
7988
|
+
if (currency) return currency;
|
|
7989
|
+
ctx.addIssue({
|
|
7990
|
+
code: "custom",
|
|
7991
|
+
message: "Invalid currency code"
|
|
7992
|
+
});
|
|
7993
|
+
return z.NEVER;
|
|
7994
|
+
})
|
|
7995
|
+
}).superRefine((position, ctx) => {
|
|
7996
|
+
const { collectedCents, refundedCents, remainderCents } = position.amounts;
|
|
7997
|
+
if (remainderCents !== decidedRemainderCents(position)) ctx.addIssue({
|
|
7998
|
+
code: "custom",
|
|
7999
|
+
path: ["amounts", "remainderCents"],
|
|
8000
|
+
message: "Payment remainder does not match its facts"
|
|
8001
|
+
});
|
|
8002
|
+
if (refundedCents > collectedCents) ctx.addIssue({
|
|
8003
|
+
code: "custom",
|
|
8004
|
+
path: ["amounts", "refundedCents"],
|
|
8005
|
+
message: "Refund exceeds collection"
|
|
8006
|
+
});
|
|
8007
|
+
if (position.collection.kind === "available" && !orderOwesForLiveBookings(position)) ctx.addIssue({
|
|
8008
|
+
code: "custom",
|
|
8009
|
+
path: ["collection"],
|
|
8010
|
+
message: "Available collection requires an open undisputed order"
|
|
8011
|
+
});
|
|
8012
|
+
if (position.deadline.kind !== "none" && position.terms.kind !== "flexible_balance" && position.terms.kind !== "instalment_plan") ctx.addIssue({
|
|
8013
|
+
code: "custom",
|
|
8014
|
+
path: ["deadline"],
|
|
8015
|
+
message: "A deadline requires agreed payment terms"
|
|
8016
|
+
});
|
|
8017
|
+
}).readonly();
|
|
8018
|
+
/** Without a contract or plan holding the balance, a cancelled booking's unpaid share isn't collectable. */
|
|
8019
|
+
function decidedRemainderCents(position) {
|
|
8020
|
+
const { totalCents, collectedCents, waivedCents } = position.amounts;
|
|
8021
|
+
const cancelledShareCents = balanceFollowsLiveBookings(position.terms) ? position.items.filter((item) => !item.live).reduce((sum, item) => sum + item.outstandingCents, 0) : 0;
|
|
8022
|
+
return Math.max(0, totalCents - collectedCents - waivedCents - cancelledShareCents);
|
|
8023
|
+
}
|
|
8024
|
+
/**
|
|
8025
|
+
* Whether the order still owes for bookings that stand: an open undisputed order, or one with some
|
|
8026
|
+
* bookings cancelled that collects for the live ones. Collection may then be available or, while a
|
|
8027
|
+
* payment is running, in progress; either way what's owed is the canonical remainder.
|
|
8028
|
+
*/
|
|
8029
|
+
function orderOwesForLiveBookings(position) {
|
|
8030
|
+
if (position.openDispute) return false;
|
|
8031
|
+
const { lifecycle } = position;
|
|
8032
|
+
return lifecycle.kind === "open" || lifecycle.kind === "retired" && lifecycle.scope.kind === "items" && balanceFollowsLiveBookings(position.terms);
|
|
8033
|
+
}
|
|
8034
|
+
/**
|
|
8035
|
+
* Whether only live bookings owe and can be paid. A flexible balance or instalment plan keeps its
|
|
8036
|
+
* own balance; otherwise (paying directly, or by card once a pay-directly order is paid online)
|
|
8037
|
+
* a cancelled booking's unpaid share leaves the remainder. The database decides by the same rule.
|
|
8038
|
+
*/
|
|
8039
|
+
function balanceFollowsLiveBookings(terms) {
|
|
8040
|
+
return terms.kind === "manual" || terms.kind === "immediate";
|
|
8041
|
+
}
|
|
8042
|
+
const parseOrderPaymentPosition = (value) => orderPaymentPositionSchema.parse(value);
|
|
8043
|
+
/** History snapshots have totals, not live collection evidence. Never reopen them. */
|
|
8044
|
+
function parseArchivedOrderPaymentPosition(snapshot) {
|
|
8045
|
+
return parseOrderPaymentPosition({
|
|
8046
|
+
orderStatus: snapshot.status,
|
|
8047
|
+
amounts: {
|
|
8048
|
+
...snapshot,
|
|
8049
|
+
remainderCents: calculateOutstandingOrderAmountCents({
|
|
8050
|
+
totalCents: snapshot.totalCents,
|
|
8051
|
+
settledCents: snapshot.collectedCents + snapshot.waivedCents
|
|
8052
|
+
})
|
|
8053
|
+
},
|
|
8054
|
+
lifecycle: snapshot.status === "cancelled" ? {
|
|
8055
|
+
kind: "retired",
|
|
8056
|
+
scope: { kind: "whole_order" },
|
|
8057
|
+
reason: "booking_cancelled"
|
|
8058
|
+
} : snapshot.status === "failed" ? {
|
|
8059
|
+
kind: "retired",
|
|
8060
|
+
scope: { kind: "terms_only" },
|
|
8061
|
+
reason: "checkout_failed"
|
|
8062
|
+
} : { kind: "open" },
|
|
8063
|
+
termsLive: false,
|
|
8064
|
+
admissions: Object.fromEntries(orderPaymentOperationKeys.map((key) => [key, {
|
|
8065
|
+
kind: "refused",
|
|
8066
|
+
reason: "archived"
|
|
8067
|
+
}])),
|
|
8068
|
+
refundProtection: {
|
|
8069
|
+
subject: { kind: "none" },
|
|
8070
|
+
funding: []
|
|
8071
|
+
},
|
|
8072
|
+
items: [],
|
|
8073
|
+
funding: [],
|
|
8074
|
+
paymentSelection: {
|
|
8075
|
+
kind: "full",
|
|
8076
|
+
minimumCents: 0,
|
|
8077
|
+
maximumCents: 0,
|
|
8078
|
+
maximumCustomCents: 0,
|
|
8079
|
+
reason: "dust_balance"
|
|
8080
|
+
},
|
|
8081
|
+
openDispute: false,
|
|
8082
|
+
collection: {
|
|
8083
|
+
kind: "closed",
|
|
8084
|
+
reason: "archived"
|
|
8085
|
+
},
|
|
8086
|
+
deadline: { kind: "none" },
|
|
8087
|
+
terms: { kind: snapshot.paymentMethod === "manual" ? "manual" : "immediate" },
|
|
8088
|
+
paymentMethod: snapshot.paymentMethod,
|
|
8089
|
+
currency: snapshot.currency
|
|
8090
|
+
});
|
|
8091
|
+
}
|
|
8092
|
+
/** The credit paying for an item, whether it's still held or already spent. */
|
|
8093
|
+
function orderItemCreditCents(position, orderItemId) {
|
|
8094
|
+
return (position.items.find((item) => item.orderItemId === orderItemId)?.creditHeldCents ?? 0) + position.funding.filter((line) => line.orderItemId === orderItemId && line.source.kind === "credit_debit").reduce((sum, line) => sum + line.amountCents, 0);
|
|
8095
|
+
}
|
|
8096
|
+
/** Money on this item that can still go back to the customer: not settled, not held for a refund in flight. */
|
|
8097
|
+
function orderItemRefundableCents(position, orderItemId) {
|
|
8098
|
+
return position.funding.filter((line) => line.orderItemId === orderItemId).reduce((total, line) => total + line.refundableCents, 0);
|
|
8099
|
+
}
|
|
8100
|
+
/** Money receipts have put on an item. Applied receipts only: the position leaves out the rest. */
|
|
8101
|
+
function orderItemReceiptCents(position, orderItemId) {
|
|
8102
|
+
return position.funding.filter((line) => line.orderItemId === orderItemId && line.source.kind === "receipt").reduce((sum, line) => sum + line.amountCents, 0);
|
|
8103
|
+
}
|
|
8104
|
+
/** Retain per-item SQL caps alongside their source totals; allocators never rebuild them. */
|
|
8105
|
+
function projectOrderRefundExposure(protection, paymentReceiptId, orderItemIds) {
|
|
8106
|
+
const funding = protection.funding.filter((line) => line.paymentReceiptId === paymentReceiptId && orderItemIds.includes(line.orderItemId));
|
|
8107
|
+
return {
|
|
8108
|
+
subject: protection.subject,
|
|
8109
|
+
policyLineRemaining: funding.map((line) => ({
|
|
8110
|
+
orderItemId: line.orderItemId,
|
|
8111
|
+
remainingCents: line.policyRefundableCents
|
|
8112
|
+
})),
|
|
8113
|
+
unrestrictedLineRemaining: funding.map((line) => ({
|
|
8114
|
+
orderItemId: line.orderItemId,
|
|
8115
|
+
remainingCents: line.totalRemainingRefundableCents
|
|
8116
|
+
})),
|
|
8117
|
+
totalRemainingRefundableCents: toNonNegativeCents(funding.reduce((sum, line) => sum + line.totalRemainingRefundableCents, 0)),
|
|
8118
|
+
policyRefundableCents: toNonNegativeCents(funding.reduce((sum, line) => sum + line.policyRefundableCents, 0)),
|
|
8119
|
+
protectedDepositRemainingCents: toNonNegativeCents(funding.reduce((sum, line) => sum + line.protectedDepositRemainingCents, 0))
|
|
8120
|
+
};
|
|
8121
|
+
}
|
|
8122
|
+
/** Applied credit is separate from receipts; credit reservations are never passed here. */
|
|
8123
|
+
function collectedPaymentSource(receipt, amounts) {
|
|
8124
|
+
if (amounts.creditCents <= 0) return {
|
|
8125
|
+
...receipt,
|
|
8126
|
+
amountCents: amounts.receiptCents
|
|
8127
|
+
};
|
|
8128
|
+
return amounts.receiptCents > 0 ? {
|
|
8129
|
+
kind: "mixed",
|
|
8130
|
+
receipt: {
|
|
8131
|
+
...receipt,
|
|
8132
|
+
amountCents: amounts.receiptCents
|
|
8133
|
+
},
|
|
8134
|
+
creditCents: amounts.creditCents
|
|
8135
|
+
} : {
|
|
8136
|
+
kind: "credit",
|
|
8137
|
+
amountCents: amounts.creditCents
|
|
8138
|
+
};
|
|
8139
|
+
}
|
|
8140
|
+
function collectedPaymentCents(source) {
|
|
8141
|
+
return source.kind === "mixed" ? source.receipt.amountCents + source.creditCents : source.amountCents;
|
|
8142
|
+
}
|
|
8143
|
+
|
|
7715
8144
|
//#endregion
|
|
7716
8145
|
//#region ../commerce/src/purchase/orderPaymentPositionDisplay.ts
|
|
7717
8146
|
function settlementFlags(position) {
|
|
@@ -7756,6 +8185,19 @@ function paymentPositionDisplayTerms(position) {
|
|
|
7756
8185
|
};
|
|
7757
8186
|
}
|
|
7758
8187
|
}
|
|
8188
|
+
/** Collecting, or a payment for it in progress, for bookings that still stand. */
|
|
8189
|
+
function isCollecting(position) {
|
|
8190
|
+
const { kind } = position.collection;
|
|
8191
|
+
return (kind === "available" || kind === "in_progress") && orderOwesForLiveBookings(position);
|
|
8192
|
+
}
|
|
8193
|
+
/**
|
|
8194
|
+
* What the order still owes. While it collects, or a payment is in progress, that's the canonical
|
|
8195
|
+
* remainder; whether another payment may start is the admissions' call, not this amount's.
|
|
8196
|
+
* Once collection has closed, a cancelled, refunded, waived or not-required order owes nothing.
|
|
8197
|
+
*/
|
|
8198
|
+
function orderBalanceDueCents(position) {
|
|
8199
|
+
return isCollecting(position) ? position.amounts.remainderCents : paymentPositionForDisplay(position).outstandingCents;
|
|
8200
|
+
}
|
|
7759
8201
|
/** The old union survives only at presentation and wire boundaries for the stable customer wire. */
|
|
7760
8202
|
function paymentPositionForDisplay(position) {
|
|
7761
8203
|
const { totalCents, collectedCents, refundedCents, waivedCents, remainderCents } = position.amounts;
|
|
@@ -7767,13 +8209,14 @@ function paymentPositionForDisplay(position) {
|
|
|
7767
8209
|
};
|
|
7768
8210
|
const terms = paymentPositionDisplayTerms(position);
|
|
7769
8211
|
const zero = toNonNegativeCents(0);
|
|
7770
|
-
|
|
8212
|
+
const collecting = isCollecting(position);
|
|
8213
|
+
if (!collecting && settlementFlags(position).refunded) return {
|
|
7771
8214
|
kind: "refunded",
|
|
7772
8215
|
...amounts,
|
|
7773
8216
|
outstandingCents: zero,
|
|
7774
8217
|
terms
|
|
7775
8218
|
};
|
|
7776
|
-
const retiredKind = retiredPaymentDisplayKind(position.lifecycle);
|
|
8219
|
+
const retiredKind = collecting ? null : retiredPaymentDisplayKind(position.lifecycle);
|
|
7777
8220
|
if (retiredKind) return {
|
|
7778
8221
|
kind: retiredKind,
|
|
7779
8222
|
...amounts,
|
|
@@ -8269,7 +8712,14 @@ function ensureStripeCheckoutSessionIdInReturnUrl(returnUrl) {
|
|
|
8269
8712
|
* would have put it.
|
|
8270
8713
|
*/
|
|
8271
8714
|
function completedStripeCheckoutReturnUrl(presentation, sessionId) {
|
|
8272
|
-
|
|
8715
|
+
return stripeCheckoutReturnUrlForSession(presentation.mode === "hosted" ? presentation.successUrl : presentation.returnUrl, sessionId);
|
|
8716
|
+
}
|
|
8717
|
+
/**
|
|
8718
|
+
* A checkout's return URL for one session, as Stripe would fill it in: the
|
|
8719
|
+
* page that opened the checkout, which checks that session when it loads.
|
|
8720
|
+
*/
|
|
8721
|
+
function stripeCheckoutReturnUrlForSession(returnUrl, sessionId) {
|
|
8722
|
+
const url = new URL(returnUrl);
|
|
8273
8723
|
url.searchParams.set("session_id", sessionId);
|
|
8274
8724
|
return url.toString();
|
|
8275
8725
|
}
|
|
@@ -8367,6 +8817,39 @@ function orderRefundNeedsReconciliation(refund) {
|
|
|
8367
8817
|
return !orderRefundEffectsComplete(refund.entitlementActionStatus) || refund.status === "reconciliation_needed" || refund.status === "failed";
|
|
8368
8818
|
}
|
|
8369
8819
|
|
|
8820
|
+
//#endregion
|
|
8821
|
+
//#region ../commerce/src/purchase/eventCheckoutRecoveryWindow.ts
|
|
8822
|
+
const EVENT_CHECKOUT_HOLD_DURATION_MS = 35 * 60 * 1e3;
|
|
8823
|
+
/** The crons that release lapsed holds run every five minutes, so a place can stay held this much longer. */
|
|
8824
|
+
const EVENT_CHECKOUT_HOLD_SWEEP_ALLOWANCE_MS = 5 * 60 * 1e3;
|
|
8825
|
+
/**
|
|
8826
|
+
* How long after an unfinished checkout starts its places are free again, in whole minutes. Copy that
|
|
8827
|
+
* tells a booker when to try again reads this ("about 40 minutes"), so it follows the hold if that changes.
|
|
8828
|
+
*/
|
|
8829
|
+
const EVENT_CHECKOUT_PLACES_FREE_AFTER_MINUTES = Math.ceil((EVENT_CHECKOUT_HOLD_DURATION_MS + EVENT_CHECKOUT_HOLD_SWEEP_ALLOWANCE_MS) / 6e4);
|
|
8830
|
+
const EVENT_CHECKOUT_RECOVERY_GRACE_MS = 24 * 60 * 60 * 1e3;
|
|
8831
|
+
/** Admission deadlines close new bookings; an admitted payment gets the full hold window. */
|
|
8832
|
+
function eventCheckoutPaymentDeadlineEpoch(deadlineEpoch, nowMs) {
|
|
8833
|
+
return Math.max(deadlineEpoch, Math.floor((nowMs + EVENT_CHECKOUT_HOLD_DURATION_MS) / 1e3));
|
|
8834
|
+
}
|
|
8835
|
+
function validInstant(value) {
|
|
8836
|
+
const instant = Date.parse(value);
|
|
8837
|
+
return Number.isFinite(instant) ? instant : null;
|
|
8838
|
+
}
|
|
8839
|
+
function eventCheckoutProvisionalRecoverableUntil(now) {
|
|
8840
|
+
return new Date(now.getTime() + EVENT_CHECKOUT_HOLD_DURATION_MS + EVENT_CHECKOUT_RECOVERY_GRACE_MS).toISOString();
|
|
8841
|
+
}
|
|
8842
|
+
function eventCheckoutRecoverableUntil(input) {
|
|
8843
|
+
const holdExpiresAt = validInstant(input.holdExpiresAt);
|
|
8844
|
+
const sessionExpiresAt = input.sessionExpiresAtEpochSeconds * 1e3;
|
|
8845
|
+
if (holdExpiresAt === null || !Number.isFinite(sessionExpiresAt)) return null;
|
|
8846
|
+
return new Date(Math.max(holdExpiresAt, sessionExpiresAt) + EVENT_CHECKOUT_RECOVERY_GRACE_MS).toISOString();
|
|
8847
|
+
}
|
|
8848
|
+
function eventCheckoutRecoveryIsDiscoverable(recoverableUntil, now) {
|
|
8849
|
+
const instant = validInstant(recoverableUntil);
|
|
8850
|
+
return instant !== null && instant > now.getTime();
|
|
8851
|
+
}
|
|
8852
|
+
|
|
8370
8853
|
//#endregion
|
|
8371
8854
|
//#region ../commerce/src/purchase/roomWords.ts
|
|
8372
8855
|
const PEOPLE_WORD = {
|
|
@@ -8449,6 +8932,22 @@ const fundingChangedMessages = {
|
|
|
8449
8932
|
pass: "Your pass changed since you chose it. Check how you’d like to pay and try again.",
|
|
8450
8933
|
membership: "Your membership changed since you chose it. Check how you’d like to pay and try again."
|
|
8451
8934
|
};
|
|
8935
|
+
/**
|
|
8936
|
+
* Said to a booker whose earlier unfinished booking this one can't replace, because nothing shows the
|
|
8937
|
+
* earlier one is theirs (#1832). They aren't where that booking is, so it can't ask them to pay for it
|
|
8938
|
+
* or cancel it here: it sends them back to where they started, or tells them when the places free up.
|
|
8939
|
+
*/
|
|
8940
|
+
function earlierBookingUnpaid(subject, otherwise = "") {
|
|
8941
|
+
const booking = subject === null ? "a booking" : `a booking for ${subject}`;
|
|
8942
|
+
return `You’ve already started ${booking} that isn’t paid yet. Go back to where you started it to pay, ${otherwise}or try again in about ${EVENT_CHECKOUT_PLACES_FREE_AFTER_MINUTES} minutes.`;
|
|
8943
|
+
}
|
|
8944
|
+
/** The server picks one of these, since it knows the date and what else was chosen; the form shows it as sent. */
|
|
8945
|
+
const earlierBookingUnpaidMessages = {
|
|
8946
|
+
oneDate: (date) => earlierBookingUnpaid(date),
|
|
8947
|
+
amongDates: (date) => earlierBookingUnpaid(date, "untick that date, "),
|
|
8948
|
+
thisDate: earlierBookingUnpaid("this date"),
|
|
8949
|
+
run: earlierBookingUnpaid("this run")
|
|
8950
|
+
};
|
|
8452
8951
|
const eventRegistrationErrors = {
|
|
8453
8952
|
invalidAnswers: {
|
|
8454
8953
|
endsCommand: false,
|
|
@@ -8575,12 +9074,42 @@ const eventRegistrationErrors = {
|
|
|
8575
9074
|
message: "You’ve already started booking this event. Please finish in the other tab if it’s still open, or check your booking status before starting again.",
|
|
8576
9075
|
action: "portal"
|
|
8577
9076
|
},
|
|
9077
|
+
earlierBookingUnpaid: {
|
|
9078
|
+
endsCommand: false,
|
|
9079
|
+
message: earlierBookingUnpaid(null),
|
|
9080
|
+
action: "retry"
|
|
9081
|
+
},
|
|
9082
|
+
bookOneAtATime: {
|
|
9083
|
+
endsCommand: false,
|
|
9084
|
+
message: "These can’t be booked together. Untick all but one, then book the others separately.",
|
|
9085
|
+
action: "places"
|
|
9086
|
+
},
|
|
8578
9087
|
invalidCommitInput: {
|
|
8579
9088
|
endsCommand: false,
|
|
8580
9089
|
message: "We couldn’t accept your booking details. Please check the information you entered and try again. If this keeps happening, contact the organiser for help.",
|
|
8581
9090
|
action: "details"
|
|
8582
9091
|
}
|
|
8583
9092
|
};
|
|
9093
|
+
/**
|
|
9094
|
+
* The refusals said in the server's own words, because only the server knows what to name. The public
|
|
9095
|
+
* route sends a refusal's reason and never its service tag, so the reason is all a form has to go on.
|
|
9096
|
+
*
|
|
9097
|
+
* - An earlier unpaid booking: the words name the date or run, and say whether there's a date to untick.
|
|
9098
|
+
* - Several chosen where one is allowed: the words say whether it's dates or runs.
|
|
9099
|
+
* - A date or run that filled up while several were being booked: the words name it, so the booker
|
|
9100
|
+
* knows which to untick. One booking has nothing to name, so it keeps the reason's own message.
|
|
9101
|
+
*/
|
|
9102
|
+
const serverWordedRefusals = {
|
|
9103
|
+
earlierBookingUnpaid: "always",
|
|
9104
|
+
bookOneAtATime: "always",
|
|
9105
|
+
capacityChanged: "several_bookings"
|
|
9106
|
+
};
|
|
9107
|
+
/** What a refusal says: the server's words where they say more, and the reason's own otherwise or when none came. */
|
|
9108
|
+
function eventRegistrationRefusalMessage(reason, serverMessage, bookings) {
|
|
9109
|
+
const worded = serverWordedRefusals[reason];
|
|
9110
|
+
const saysServerWords = worded === "always" || worded === "several_bookings" && bookings === "several";
|
|
9111
|
+
return saysServerWords && serverMessage.trim().length > 0 ? serverMessage : eventRegistrationErrors[reason].message;
|
|
9112
|
+
}
|
|
8584
9113
|
function parseEventRegistrationErrorReason(value) {
|
|
8585
9114
|
return typeof value === "string" && Object.prototype.hasOwnProperty.call(eventRegistrationErrors, value) ? value : null;
|
|
8586
9115
|
}
|
|
@@ -8590,32 +9119,6 @@ function eventRegistrationErrorEndsCommand(value) {
|
|
|
8590
9119
|
return reason !== null && eventRegistrationErrors[reason].endsCommand;
|
|
8591
9120
|
}
|
|
8592
9121
|
|
|
8593
|
-
//#endregion
|
|
8594
|
-
//#region ../commerce/src/purchase/eventCheckoutRecoveryWindow.ts
|
|
8595
|
-
const EVENT_CHECKOUT_HOLD_DURATION_MS = 35 * 60 * 1e3;
|
|
8596
|
-
const EVENT_CHECKOUT_RECOVERY_GRACE_MS = 24 * 60 * 60 * 1e3;
|
|
8597
|
-
/** Admission deadlines close new bookings; an admitted payment gets the full hold window. */
|
|
8598
|
-
function eventCheckoutPaymentDeadlineEpoch(deadlineEpoch, nowMs) {
|
|
8599
|
-
return Math.max(deadlineEpoch, Math.floor((nowMs + EVENT_CHECKOUT_HOLD_DURATION_MS) / 1e3));
|
|
8600
|
-
}
|
|
8601
|
-
function validInstant(value) {
|
|
8602
|
-
const instant = Date.parse(value);
|
|
8603
|
-
return Number.isFinite(instant) ? instant : null;
|
|
8604
|
-
}
|
|
8605
|
-
function eventCheckoutProvisionalRecoverableUntil(now) {
|
|
8606
|
-
return new Date(now.getTime() + EVENT_CHECKOUT_HOLD_DURATION_MS + EVENT_CHECKOUT_RECOVERY_GRACE_MS).toISOString();
|
|
8607
|
-
}
|
|
8608
|
-
function eventCheckoutRecoverableUntil(input) {
|
|
8609
|
-
const holdExpiresAt = validInstant(input.holdExpiresAt);
|
|
8610
|
-
const sessionExpiresAt = input.sessionExpiresAtEpochSeconds * 1e3;
|
|
8611
|
-
if (holdExpiresAt === null || !Number.isFinite(sessionExpiresAt)) return null;
|
|
8612
|
-
return new Date(Math.max(holdExpiresAt, sessionExpiresAt) + EVENT_CHECKOUT_RECOVERY_GRACE_MS).toISOString();
|
|
8613
|
-
}
|
|
8614
|
-
function eventCheckoutRecoveryIsDiscoverable(recoverableUntil, now) {
|
|
8615
|
-
const instant = validInstant(recoverableUntil);
|
|
8616
|
-
return instant !== null && instant > now.getTime();
|
|
8617
|
-
}
|
|
8618
|
-
|
|
8619
9122
|
//#endregion
|
|
8620
9123
|
//#region ../commerce/src/purchase/checkoutPresentation.ts
|
|
8621
9124
|
function publishableKeyMode(publishableKey) {
|
|
@@ -9652,411 +10155,12 @@ function flexibleBalanceCollectionIsAvailable(collection) {
|
|
|
9652
10155
|
const flexibleBalanceUnavailableCopy = "You can’t pay this balance online at the moment. Please contact us to arrange payment.";
|
|
9653
10156
|
const flexibleBalanceProcessingCopy = "A payment for this booking is already being processed. Please check back in a few minutes.";
|
|
9654
10157
|
|
|
9655
|
-
//#endregion
|
|
9656
|
-
//#region ../commerce/src/purchase/orderPaymentPosition.ts
|
|
9657
|
-
const cents = z.number().int().nonnegative().transform(toNonNegativeCents);
|
|
9658
|
-
const orderPaymentAdmissionSchema = z.discriminatedUnion("kind", [
|
|
9659
|
-
z.object({ kind: z.literal("admitted") }),
|
|
9660
|
-
z.object({ kind: z.literal("requires_provider_check") }),
|
|
9661
|
-
z.object({
|
|
9662
|
-
kind: z.literal("refused"),
|
|
9663
|
-
reason: z.enum([
|
|
9664
|
-
"in_progress",
|
|
9665
|
-
"cancelled",
|
|
9666
|
-
"disputed",
|
|
9667
|
-
"identity",
|
|
9668
|
-
"amounts",
|
|
9669
|
-
"conflicting_terms",
|
|
9670
|
-
"provider_reconciliation",
|
|
9671
|
-
"missing_instalments",
|
|
9672
|
-
"nothing_owed",
|
|
9673
|
-
"not_committed",
|
|
9674
|
-
"unsupported_payment_method",
|
|
9675
|
-
"live_terms",
|
|
9676
|
-
"not_applicable",
|
|
9677
|
-
"terms_closed",
|
|
9678
|
-
"refunded",
|
|
9679
|
-
"partly_cancelled",
|
|
9680
|
-
"retired",
|
|
9681
|
-
"retirement_pending",
|
|
9682
|
-
"cancelled_non_payment",
|
|
9683
|
-
"non_monetary",
|
|
9684
|
-
"settled",
|
|
9685
|
-
"checkout_failed",
|
|
9686
|
-
"archived",
|
|
9687
|
-
"recurring_collection_active",
|
|
9688
|
-
"below_card_minimum"
|
|
9689
|
-
])
|
|
9690
|
-
})
|
|
9691
|
-
]).readonly();
|
|
9692
|
-
const orderPaymentOperationKeys = [
|
|
9693
|
-
"manualReceipt",
|
|
9694
|
-
"waiver",
|
|
9695
|
-
"paymentLink",
|
|
9696
|
-
"demand",
|
|
9697
|
-
"partialRefund",
|
|
9698
|
-
"closeBalance",
|
|
9699
|
-
"instalmentSetup",
|
|
9700
|
-
"cashlessCompletion",
|
|
9701
|
-
"initialCheckout",
|
|
9702
|
-
"checkoutResume",
|
|
9703
|
-
"providerReceipt",
|
|
9704
|
-
"recovery",
|
|
9705
|
-
"closePlan",
|
|
9706
|
-
"partialManualReceipt",
|
|
9707
|
-
"expiryRelease",
|
|
9708
|
-
"manualReceiptPreparation",
|
|
9709
|
-
"waiverPreparation",
|
|
9710
|
-
"paymentLinkPreparation",
|
|
9711
|
-
"priceChange",
|
|
9712
|
-
"bookingRestore",
|
|
9713
|
-
"staffCancellation"
|
|
9714
|
-
];
|
|
9715
|
-
const retirementScope = z.discriminatedUnion("kind", [
|
|
9716
|
-
z.object({ kind: z.literal("pending") }),
|
|
9717
|
-
z.object({ kind: z.literal("whole_order") }),
|
|
9718
|
-
z.object({ kind: z.literal("terms_only") }),
|
|
9719
|
-
z.object({
|
|
9720
|
-
kind: z.literal("items"),
|
|
9721
|
-
itemIds: z.array(z.string().uuid()).readonly()
|
|
9722
|
-
})
|
|
9723
|
-
]).readonly();
|
|
9724
|
-
const orderRefundProtectionSchema = z.object({
|
|
9725
|
-
subject: z.discriminatedUnion("kind", [z.object({ kind: z.literal("none") }), z.object({
|
|
9726
|
-
kind: z.literal("protected_deposit"),
|
|
9727
|
-
sourceKind: z.enum(["flexible_balance", "instalment_plan"]),
|
|
9728
|
-
protectedDepositAmountCents: cents,
|
|
9729
|
-
depositRefundability: z.enum(["refundable", "non_refundable"])
|
|
9730
|
-
})]).readonly(),
|
|
9731
|
-
funding: z.array(z.object({
|
|
9732
|
-
orderItemId: z.string().uuid(),
|
|
9733
|
-
paymentReceiptId: z.string().uuid().nullable(),
|
|
9734
|
-
originalCents: cents,
|
|
9735
|
-
totalRemainingRefundableCents: cents,
|
|
9736
|
-
policyRefundableCents: cents,
|
|
9737
|
-
protectedDepositRemainingCents: cents
|
|
9738
|
-
}).readonly()).readonly()
|
|
9739
|
-
}).readonly();
|
|
9740
|
-
/**
|
|
9741
|
-
* What each item owes and has had. Refunds don't reopen debt, and held credit isn't collected yet.
|
|
9742
|
-
* Cash outstanding is what the database lets a payment or a waiver take: outstanding less held credit.
|
|
9743
|
-
*/
|
|
9744
|
-
const orderMoneyItemSchema = z.object({
|
|
9745
|
-
orderItemId: z.string().uuid(),
|
|
9746
|
-
dueCents: cents,
|
|
9747
|
-
collectedCents: cents,
|
|
9748
|
-
waivedCents: cents,
|
|
9749
|
-
outstandingCents: cents,
|
|
9750
|
-
creditHeldCents: cents,
|
|
9751
|
-
cashOutstandingCents: cents,
|
|
9752
|
-
refundedToCustomerCents: cents
|
|
9753
|
-
}).readonly();
|
|
9754
|
-
/** Money a refund can come from. A waiver never appears here, so nothing can name one as a source. */
|
|
9755
|
-
const orderFundingLineSchema = z.object({
|
|
9756
|
-
allocationId: z.string().uuid(),
|
|
9757
|
-
orderItemId: z.string().uuid(),
|
|
9758
|
-
source: z.discriminatedUnion("kind", [z.object({
|
|
9759
|
-
kind: z.literal("receipt"),
|
|
9760
|
-
receiptId: z.string().uuid().transform(unsafeAsOrderPaymentReceiptId),
|
|
9761
|
-
disputed: z.boolean()
|
|
9762
|
-
}), z.object({
|
|
9763
|
-
kind: z.literal("credit_debit"),
|
|
9764
|
-
creditTransactionId: z.string().uuid()
|
|
9765
|
-
})]).readonly(),
|
|
9766
|
-
amountCents: cents,
|
|
9767
|
-
taxCents: cents,
|
|
9768
|
-
settledCents: cents,
|
|
9769
|
-
heldCents: cents,
|
|
9770
|
-
refundableCents: cents
|
|
9771
|
-
}).readonly();
|
|
9772
|
-
/** SQL owns the decision. This schema only parses its closed result. */
|
|
9773
|
-
const orderPaymentPositionSchema = z.object({
|
|
9774
|
-
orderStatus: z.enum([
|
|
9775
|
-
"pending",
|
|
9776
|
-
"paid",
|
|
9777
|
-
"partially_refunded",
|
|
9778
|
-
"refunded",
|
|
9779
|
-
"cancelled",
|
|
9780
|
-
"failed"
|
|
9781
|
-
]),
|
|
9782
|
-
refundProtection: orderRefundProtectionSchema,
|
|
9783
|
-
items: z.array(orderMoneyItemSchema).readonly(),
|
|
9784
|
-
funding: z.array(orderFundingLineSchema).readonly(),
|
|
9785
|
-
amounts: z.object({
|
|
9786
|
-
totalCents: cents,
|
|
9787
|
-
collectedCents: cents,
|
|
9788
|
-
refundedCents: cents,
|
|
9789
|
-
waivedCents: cents,
|
|
9790
|
-
remainderCents: cents
|
|
9791
|
-
}).readonly(),
|
|
9792
|
-
lifecycle: z.discriminatedUnion("kind", [
|
|
9793
|
-
z.object({ kind: z.literal("open") }),
|
|
9794
|
-
z.object({
|
|
9795
|
-
kind: z.literal("retired"),
|
|
9796
|
-
scope: retirementScope,
|
|
9797
|
-
reason: z.enum([
|
|
9798
|
-
"staff",
|
|
9799
|
-
"checkout_failed",
|
|
9800
|
-
"abandoned_failed",
|
|
9801
|
-
"abandoned_cancelled",
|
|
9802
|
-
"dispute_lost",
|
|
9803
|
-
"booking_cancelled"
|
|
9804
|
-
])
|
|
9805
|
-
}),
|
|
9806
|
-
z.object({ kind: z.literal("cancelled_non_payment") })
|
|
9807
|
-
]).readonly(),
|
|
9808
|
-
openDispute: z.boolean(),
|
|
9809
|
-
termsLive: z.boolean(),
|
|
9810
|
-
admissions: z.object({
|
|
9811
|
-
bookingRestore: orderPaymentAdmissionSchema,
|
|
9812
|
-
staffCancellation: orderPaymentAdmissionSchema,
|
|
9813
|
-
manualReceipt: orderPaymentAdmissionSchema,
|
|
9814
|
-
waiver: orderPaymentAdmissionSchema,
|
|
9815
|
-
paymentLink: orderPaymentAdmissionSchema,
|
|
9816
|
-
demand: orderPaymentAdmissionSchema,
|
|
9817
|
-
partialRefund: orderPaymentAdmissionSchema,
|
|
9818
|
-
closeBalance: orderPaymentAdmissionSchema,
|
|
9819
|
-
instalmentSetup: orderPaymentAdmissionSchema,
|
|
9820
|
-
cashlessCompletion: orderPaymentAdmissionSchema,
|
|
9821
|
-
initialCheckout: orderPaymentAdmissionSchema,
|
|
9822
|
-
checkoutResume: orderPaymentAdmissionSchema,
|
|
9823
|
-
providerReceipt: orderPaymentAdmissionSchema,
|
|
9824
|
-
recovery: orderPaymentAdmissionSchema,
|
|
9825
|
-
closePlan: orderPaymentAdmissionSchema,
|
|
9826
|
-
partialManualReceipt: orderPaymentAdmissionSchema,
|
|
9827
|
-
expiryRelease: orderPaymentAdmissionSchema,
|
|
9828
|
-
manualReceiptPreparation: orderPaymentAdmissionSchema,
|
|
9829
|
-
waiverPreparation: orderPaymentAdmissionSchema,
|
|
9830
|
-
paymentLinkPreparation: orderPaymentAdmissionSchema,
|
|
9831
|
-
priceChange: orderPaymentAdmissionSchema
|
|
9832
|
-
}).readonly(),
|
|
9833
|
-
paymentSelection: z.object({
|
|
9834
|
-
kind: z.enum(["full", "custom"]),
|
|
9835
|
-
minimumCents: cents,
|
|
9836
|
-
maximumCents: cents,
|
|
9837
|
-
maximumCustomCents: cents,
|
|
9838
|
-
reason: z.enum(["overdue", "dust_balance"])
|
|
9839
|
-
}).readonly(),
|
|
9840
|
-
collection: z.discriminatedUnion("kind", [
|
|
9841
|
-
z.object({ kind: z.literal("available") }),
|
|
9842
|
-
z.object({ kind: z.literal("in_progress") }),
|
|
9843
|
-
z.object({
|
|
9844
|
-
kind: z.literal("closed"),
|
|
9845
|
-
reason: z.enum([
|
|
9846
|
-
"archived",
|
|
9847
|
-
"partly_cancelled",
|
|
9848
|
-
"retired",
|
|
9849
|
-
"retirement_pending",
|
|
9850
|
-
"cancelled_non_payment",
|
|
9851
|
-
"disputed",
|
|
9852
|
-
"non_monetary",
|
|
9853
|
-
"settled",
|
|
9854
|
-
"terms_closed",
|
|
9855
|
-
"refunded",
|
|
9856
|
-
"not_committed",
|
|
9857
|
-
"checkout_failed"
|
|
9858
|
-
])
|
|
9859
|
-
}),
|
|
9860
|
-
z.object({
|
|
9861
|
-
kind: z.literal("unresolved"),
|
|
9862
|
-
reason: z.enum([
|
|
9863
|
-
"identity",
|
|
9864
|
-
"amounts",
|
|
9865
|
-
"conflicting_terms",
|
|
9866
|
-
"provider_reconciliation",
|
|
9867
|
-
"missing_instalments"
|
|
9868
|
-
])
|
|
9869
|
-
})
|
|
9870
|
-
]).readonly(),
|
|
9871
|
-
deadline: z.discriminatedUnion("kind", [
|
|
9872
|
-
z.object({ kind: z.literal("none") }),
|
|
9873
|
-
z.object({
|
|
9874
|
-
kind: z.literal("not_yet_due"),
|
|
9875
|
-
dueAt: z.string().datetime({ offset: true }),
|
|
9876
|
-
dueDay: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
9877
|
-
timezone: z.string().optional()
|
|
9878
|
-
}),
|
|
9879
|
-
z.object({
|
|
9880
|
-
kind: z.literal("overdue"),
|
|
9881
|
-
dueAt: z.string().datetime({ offset: true }),
|
|
9882
|
-
dueDay: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
9883
|
-
timezone: z.string().optional()
|
|
9884
|
-
})
|
|
9885
|
-
]).readonly(),
|
|
9886
|
-
terms: z.discriminatedUnion("kind", [
|
|
9887
|
-
z.object({ kind: z.literal("immediate") }),
|
|
9888
|
-
z.object({ kind: z.literal("manual") }),
|
|
9889
|
-
z.object({
|
|
9890
|
-
kind: z.literal("flexible_balance"),
|
|
9891
|
-
contractId: z.string().uuid().transform(unsafeAsOrderFlexibleBalanceContractId),
|
|
9892
|
-
upfrontAmountCents: cents
|
|
9893
|
-
}),
|
|
9894
|
-
z.object({
|
|
9895
|
-
kind: z.literal("instalment_plan"),
|
|
9896
|
-
paymentPlanId: z.string().uuid().transform(unsafeAsOrderPaymentPlanId),
|
|
9897
|
-
nextDueAmountCents: cents.nullable(),
|
|
9898
|
-
collectionStopped: z.boolean(),
|
|
9899
|
-
state: z.object({ kind: z.enum([
|
|
9900
|
-
"active",
|
|
9901
|
-
"payment_failed",
|
|
9902
|
-
"pending_initial_payment",
|
|
9903
|
-
"reconciliation_required",
|
|
9904
|
-
"cancelled",
|
|
9905
|
-
"refunded",
|
|
9906
|
-
"completed"
|
|
9907
|
-
]) }).readonly()
|
|
9908
|
-
})
|
|
9909
|
-
]).readonly(),
|
|
9910
|
-
paymentMethod: z.enum([
|
|
9911
|
-
"free",
|
|
9912
|
-
"waived",
|
|
9913
|
-
"pass_redemption",
|
|
9914
|
-
"membership_access",
|
|
9915
|
-
"stripe",
|
|
9916
|
-
"store_credit",
|
|
9917
|
-
"mixed",
|
|
9918
|
-
"manual"
|
|
9919
|
-
]),
|
|
9920
|
-
currency: z.string().transform((value, ctx) => {
|
|
9921
|
-
const currency = parseCurrencyCode(value);
|
|
9922
|
-
if (currency) return currency;
|
|
9923
|
-
ctx.addIssue({
|
|
9924
|
-
code: "custom",
|
|
9925
|
-
message: "Invalid currency code"
|
|
9926
|
-
});
|
|
9927
|
-
return z.NEVER;
|
|
9928
|
-
})
|
|
9929
|
-
}).superRefine((position, ctx) => {
|
|
9930
|
-
const { totalCents, collectedCents, waivedCents, refundedCents, remainderCents } = position.amounts;
|
|
9931
|
-
if (remainderCents !== Math.max(0, totalCents - collectedCents - waivedCents)) ctx.addIssue({
|
|
9932
|
-
code: "custom",
|
|
9933
|
-
path: ["amounts", "remainderCents"],
|
|
9934
|
-
message: "Payment remainder does not match its facts"
|
|
9935
|
-
});
|
|
9936
|
-
if (refundedCents > collectedCents) ctx.addIssue({
|
|
9937
|
-
code: "custom",
|
|
9938
|
-
path: ["amounts", "refundedCents"],
|
|
9939
|
-
message: "Refund exceeds collection"
|
|
9940
|
-
});
|
|
9941
|
-
if (position.collection.kind === "available" && (position.lifecycle.kind !== "open" || position.openDispute)) ctx.addIssue({
|
|
9942
|
-
code: "custom",
|
|
9943
|
-
path: ["collection"],
|
|
9944
|
-
message: "Available collection requires an open undisputed order"
|
|
9945
|
-
});
|
|
9946
|
-
if (position.deadline.kind !== "none" && position.terms.kind !== "flexible_balance" && position.terms.kind !== "instalment_plan") ctx.addIssue({
|
|
9947
|
-
code: "custom",
|
|
9948
|
-
path: ["deadline"],
|
|
9949
|
-
message: "A deadline requires agreed payment terms"
|
|
9950
|
-
});
|
|
9951
|
-
}).readonly();
|
|
9952
|
-
const parseOrderPaymentPosition = (value) => orderPaymentPositionSchema.parse(value);
|
|
9953
|
-
/** History snapshots have totals, not live collection evidence. Never reopen them. */
|
|
9954
|
-
function parseArchivedOrderPaymentPosition(snapshot) {
|
|
9955
|
-
return parseOrderPaymentPosition({
|
|
9956
|
-
orderStatus: snapshot.status,
|
|
9957
|
-
amounts: {
|
|
9958
|
-
...snapshot,
|
|
9959
|
-
remainderCents: calculateOutstandingOrderAmountCents({
|
|
9960
|
-
totalCents: snapshot.totalCents,
|
|
9961
|
-
settledCents: snapshot.collectedCents + snapshot.waivedCents
|
|
9962
|
-
})
|
|
9963
|
-
},
|
|
9964
|
-
lifecycle: snapshot.status === "cancelled" ? {
|
|
9965
|
-
kind: "retired",
|
|
9966
|
-
scope: { kind: "whole_order" },
|
|
9967
|
-
reason: "booking_cancelled"
|
|
9968
|
-
} : snapshot.status === "failed" ? {
|
|
9969
|
-
kind: "retired",
|
|
9970
|
-
scope: { kind: "terms_only" },
|
|
9971
|
-
reason: "checkout_failed"
|
|
9972
|
-
} : { kind: "open" },
|
|
9973
|
-
termsLive: false,
|
|
9974
|
-
admissions: Object.fromEntries(orderPaymentOperationKeys.map((key) => [key, {
|
|
9975
|
-
kind: "refused",
|
|
9976
|
-
reason: "archived"
|
|
9977
|
-
}])),
|
|
9978
|
-
refundProtection: {
|
|
9979
|
-
subject: { kind: "none" },
|
|
9980
|
-
funding: []
|
|
9981
|
-
},
|
|
9982
|
-
items: [],
|
|
9983
|
-
funding: [],
|
|
9984
|
-
paymentSelection: {
|
|
9985
|
-
kind: "full",
|
|
9986
|
-
minimumCents: 0,
|
|
9987
|
-
maximumCents: 0,
|
|
9988
|
-
maximumCustomCents: 0,
|
|
9989
|
-
reason: "dust_balance"
|
|
9990
|
-
},
|
|
9991
|
-
openDispute: false,
|
|
9992
|
-
collection: {
|
|
9993
|
-
kind: "closed",
|
|
9994
|
-
reason: "archived"
|
|
9995
|
-
},
|
|
9996
|
-
deadline: { kind: "none" },
|
|
9997
|
-
terms: { kind: snapshot.paymentMethod === "manual" ? "manual" : "immediate" },
|
|
9998
|
-
paymentMethod: snapshot.paymentMethod,
|
|
9999
|
-
currency: snapshot.currency
|
|
10000
|
-
});
|
|
10001
|
-
}
|
|
10002
|
-
/** The credit paying for an item, whether it's still held or already spent. */
|
|
10003
|
-
function orderItemCreditCents(position, orderItemId) {
|
|
10004
|
-
return (position.items.find((item) => item.orderItemId === orderItemId)?.creditHeldCents ?? 0) + position.funding.filter((line) => line.orderItemId === orderItemId && line.source.kind === "credit_debit").reduce((sum, line) => sum + line.amountCents, 0);
|
|
10005
|
-
}
|
|
10006
|
-
/** Money on this item that can still go back to the customer: not settled, not held for a refund in flight. */
|
|
10007
|
-
function orderItemRefundableCents(position, orderItemId) {
|
|
10008
|
-
return position.funding.filter((line) => line.orderItemId === orderItemId).reduce((total, line) => total + line.refundableCents, 0);
|
|
10009
|
-
}
|
|
10010
|
-
/** Money receipts have put on an item. Applied receipts only: the position leaves out the rest. */
|
|
10011
|
-
function orderItemReceiptCents(position, orderItemId) {
|
|
10012
|
-
return position.funding.filter((line) => line.orderItemId === orderItemId && line.source.kind === "receipt").reduce((sum, line) => sum + line.amountCents, 0);
|
|
10013
|
-
}
|
|
10014
|
-
/** Retain per-item SQL caps alongside their source totals; allocators never rebuild them. */
|
|
10015
|
-
function projectOrderRefundExposure(protection, paymentReceiptId, orderItemIds) {
|
|
10016
|
-
const funding = protection.funding.filter((line) => line.paymentReceiptId === paymentReceiptId && orderItemIds.includes(line.orderItemId));
|
|
10017
|
-
return {
|
|
10018
|
-
subject: protection.subject,
|
|
10019
|
-
policyLineRemaining: funding.map((line) => ({
|
|
10020
|
-
orderItemId: line.orderItemId,
|
|
10021
|
-
remainingCents: line.policyRefundableCents
|
|
10022
|
-
})),
|
|
10023
|
-
unrestrictedLineRemaining: funding.map((line) => ({
|
|
10024
|
-
orderItemId: line.orderItemId,
|
|
10025
|
-
remainingCents: line.totalRemainingRefundableCents
|
|
10026
|
-
})),
|
|
10027
|
-
totalRemainingRefundableCents: toNonNegativeCents(funding.reduce((sum, line) => sum + line.totalRemainingRefundableCents, 0)),
|
|
10028
|
-
policyRefundableCents: toNonNegativeCents(funding.reduce((sum, line) => sum + line.policyRefundableCents, 0)),
|
|
10029
|
-
protectedDepositRemainingCents: toNonNegativeCents(funding.reduce((sum, line) => sum + line.protectedDepositRemainingCents, 0))
|
|
10030
|
-
};
|
|
10031
|
-
}
|
|
10032
|
-
/** Applied credit is separate from receipts; credit reservations are never passed here. */
|
|
10033
|
-
function collectedPaymentSource(receipt, amounts) {
|
|
10034
|
-
if (amounts.creditCents <= 0) return {
|
|
10035
|
-
...receipt,
|
|
10036
|
-
amountCents: amounts.receiptCents
|
|
10037
|
-
};
|
|
10038
|
-
return amounts.receiptCents > 0 ? {
|
|
10039
|
-
kind: "mixed",
|
|
10040
|
-
receipt: {
|
|
10041
|
-
...receipt,
|
|
10042
|
-
amountCents: amounts.receiptCents
|
|
10043
|
-
},
|
|
10044
|
-
creditCents: amounts.creditCents
|
|
10045
|
-
} : {
|
|
10046
|
-
kind: "credit",
|
|
10047
|
-
amountCents: amounts.creditCents
|
|
10048
|
-
};
|
|
10049
|
-
}
|
|
10050
|
-
function collectedPaymentCents(source) {
|
|
10051
|
-
return source.kind === "mixed" ? source.receipt.amountCents + source.creditCents : source.amountCents;
|
|
10052
|
-
}
|
|
10053
|
-
|
|
10054
10158
|
//#endregion
|
|
10055
10159
|
//#region ../commerce/src/purchase/orderPaymentLabels.ts
|
|
10056
10160
|
const NEEDS_CHECKING_OWNER_HINT = "We couldn't work out what's still owed on this booking, so we've paused payment requests. Contact us and we'll sort it out.";
|
|
10057
10161
|
function orderPaymentLabelFormatters(currency, context) {
|
|
10058
10162
|
return {
|
|
10059
|
-
money: (cents$
|
|
10163
|
+
money: (cents$4) => formatCurrencyAmount(cents$4, currency, { decimals: "auto" }),
|
|
10060
10164
|
day: (day) => formatDate(day, context, {
|
|
10061
10165
|
date: "short",
|
|
10062
10166
|
year: "omit"
|
|
@@ -10072,7 +10176,13 @@ function effectiveDueDay(deadline) {
|
|
|
10072
10176
|
value: toUtcIsoDateTimeString(new Date(deadline.dueAt).toISOString())
|
|
10073
10177
|
};
|
|
10074
10178
|
}
|
|
10075
|
-
|
|
10179
|
+
/** Some of the order's bookings are cancelled and the rest stand, whether or not they still owe. */
|
|
10180
|
+
function partlyCancelled({ lifecycle, collection, items }) {
|
|
10181
|
+
if (collection.kind === "closed" && collection.reason === "partly_cancelled") return true;
|
|
10182
|
+
return lifecycle.kind === "retired" && lifecycle.scope.kind === "items" && lifecycle.scope.itemIds.length < items.length;
|
|
10183
|
+
}
|
|
10184
|
+
function decideBookingOutcome(position) {
|
|
10185
|
+
const { lifecycle, collection } = position;
|
|
10076
10186
|
switch (lifecycle.kind) {
|
|
10077
10187
|
case "open": return collection.kind === "closed" && (collection.reason === "checkout_failed" || collection.reason === "not_committed") ? "checkout_not_finished" : "booked";
|
|
10078
10188
|
case "cancelled_non_payment": return "cancelled_non_payment";
|
|
@@ -10084,21 +10194,25 @@ function decideBookingOutcome({ lifecycle, collection }) {
|
|
|
10084
10194
|
case "abandoned_cancelled": return "checkout_not_finished";
|
|
10085
10195
|
case "dispute_lost": return "dispute_lost";
|
|
10086
10196
|
case "staff":
|
|
10087
|
-
case "booking_cancelled": return
|
|
10197
|
+
case "booking_cancelled": return partlyCancelled(position) ? "partly_cancelled" : "cancelled";
|
|
10088
10198
|
default: return assertNever(lifecycle.reason);
|
|
10089
10199
|
}
|
|
10090
10200
|
default: return assertNever(lifecycle);
|
|
10091
10201
|
}
|
|
10092
10202
|
}
|
|
10093
|
-
function decideStillToPay(
|
|
10094
|
-
|
|
10095
|
-
|
|
10203
|
+
function decideStillToPay(position) {
|
|
10204
|
+
return position.collection.kind === "available" ? remainderToPay(position) : { kind: "nothing" };
|
|
10205
|
+
}
|
|
10206
|
+
/** What's left on the order and by when, whether or not a payment for it has started. */
|
|
10207
|
+
function remainderToPay({ amounts, deadline }) {
|
|
10208
|
+
if (amounts.remainderCents === 0) return { kind: "nothing" };
|
|
10209
|
+
const cents$4 = amounts.remainderCents;
|
|
10096
10210
|
return deadline.kind === "none" ? {
|
|
10097
10211
|
kind: "no_deadline",
|
|
10098
|
-
cents: cents$
|
|
10212
|
+
cents: cents$4
|
|
10099
10213
|
} : {
|
|
10100
10214
|
kind: deadline.kind,
|
|
10101
|
-
cents: cents$
|
|
10215
|
+
cents: cents$4,
|
|
10102
10216
|
day: effectiveDueDay(deadline)
|
|
10103
10217
|
};
|
|
10104
10218
|
}
|
|
@@ -10130,17 +10244,15 @@ function decideInstalmentStanding(position) {
|
|
|
10130
10244
|
const { terms, deadline, collection, amounts } = position;
|
|
10131
10245
|
if (terms.kind !== "instalment_plan" || collection.kind !== "available") return null;
|
|
10132
10246
|
switch (terms.state.kind) {
|
|
10133
|
-
case "payment_failed": return {
|
|
10134
|
-
kind: "instalment_failed",
|
|
10135
|
-
canPayNow: position.admissions.paymentLink.kind === "admitted"
|
|
10136
|
-
};
|
|
10247
|
+
case "payment_failed": return { kind: "instalment_failed" };
|
|
10137
10248
|
case "active":
|
|
10138
|
-
if (amounts.collectedCents === 0
|
|
10249
|
+
if (amounts.collectedCents === 0) return null;
|
|
10139
10250
|
return {
|
|
10140
10251
|
kind: "instalments_running",
|
|
10141
|
-
next: deadline.kind
|
|
10252
|
+
next: deadline.kind !== "none" && terms.nextDueAmountCents !== null ? {
|
|
10142
10253
|
cents: terms.nextDueAmountCents,
|
|
10143
|
-
day: effectiveDueDay(deadline)
|
|
10254
|
+
day: effectiveDueDay(deadline),
|
|
10255
|
+
passed: deadline.kind === "overdue"
|
|
10144
10256
|
} : null
|
|
10145
10257
|
};
|
|
10146
10258
|
case "pending_initial_payment":
|
|
@@ -10192,6 +10304,7 @@ const OWNER_COPY = {
|
|
|
10192
10304
|
paidOffline: "Paid offline",
|
|
10193
10305
|
inProgress: "Payment in progress",
|
|
10194
10306
|
firstInstalmentPending: "Waiting for the first payment",
|
|
10307
|
+
firstPaymentToPay: (amount) => `First payment of ${amount} not paid yet`,
|
|
10195
10308
|
instalmentFailed: "A payment didn't go through",
|
|
10196
10309
|
waived: (amount) => `${amount} waived`,
|
|
10197
10310
|
dueNoDeadline: (amount) => `${amount} due`,
|
|
@@ -10200,7 +10313,7 @@ const OWNER_COPY = {
|
|
|
10200
10313
|
instalments: ({ paid, refunded, next }) => [
|
|
10201
10314
|
paid,
|
|
10202
10315
|
refunded,
|
|
10203
|
-
next && `next ${next.amount} on ${next.day}`
|
|
10316
|
+
next && (next.passed ? `next ${next.amount} was due ${next.day}, not taken yet` : `next ${next.amount} on ${next.day}`)
|
|
10204
10317
|
].filter((part) => part !== null).join(" · ")
|
|
10205
10318
|
};
|
|
10206
10319
|
const CUSTOMER_COPY = {
|
|
@@ -10212,6 +10325,7 @@ const CUSTOMER_COPY = {
|
|
|
10212
10325
|
paidOnline: "Paid",
|
|
10213
10326
|
paidOffline: "Paid",
|
|
10214
10327
|
inProgress: "Your payment is being processed",
|
|
10328
|
+
firstPaymentToPay: (amount) => `Your first payment of ${amount} is still to pay`,
|
|
10215
10329
|
firstInstalmentPending: "Your first payment is being processed",
|
|
10216
10330
|
instalmentFailed: "A payment didn't go through.",
|
|
10217
10331
|
waived: () => null,
|
|
@@ -10221,7 +10335,7 @@ const CUSTOMER_COPY = {
|
|
|
10221
10335
|
instalments: ({ paid, refunded, next }) => [
|
|
10222
10336
|
paid,
|
|
10223
10337
|
refunded,
|
|
10224
|
-
next && `Next payment of ${next.amount} on ${next.day}`
|
|
10338
|
+
next && (next.passed ? `Your next payment of ${next.amount} was due on ${next.day} and hasn't been taken yet` : `Next payment of ${next.amount} on ${next.day}`)
|
|
10225
10339
|
].filter((part) => part !== null).join(". ") + (next || refunded ? "." : "")
|
|
10226
10340
|
};
|
|
10227
10341
|
function moneySegments(position, outcome, copy, format, stillToPay) {
|
|
@@ -10263,7 +10377,8 @@ function moneyLine(standing, position, outcome, audience, format) {
|
|
|
10263
10377
|
case "needs_checking": return needsCheckingMoneyLine(position, outcome, audience, copy, format);
|
|
10264
10378
|
case "first_instalment_pending": return copy.firstInstalmentPending;
|
|
10265
10379
|
case "in_progress": return copy.inProgress;
|
|
10266
|
-
case "
|
|
10380
|
+
case "checkout_unfinished": return standing.firstPaymentCents !== null ? copy.firstPaymentToPay(format.money(standing.firstPaymentCents)) : amountsLine(position, outcome, copy, format, standing.owed);
|
|
10381
|
+
case "instalment_failed": return copy.instalmentFailed;
|
|
10267
10382
|
case "instalments_running": {
|
|
10268
10383
|
const { collectedCents, refundedCents, totalCents } = position.amounts;
|
|
10269
10384
|
return copy.instalments({
|
|
@@ -10271,7 +10386,8 @@ function moneyLine(standing, position, outcome, audience, format) {
|
|
|
10271
10386
|
refunded: refundedCents > 0 ? `${format.money(refundedCents)} refunded` : null,
|
|
10272
10387
|
next: standing.next && {
|
|
10273
10388
|
amount: format.money(standing.next.cents),
|
|
10274
|
-
day: format.day(standing.next.day)
|
|
10389
|
+
day: format.day(standing.next.day),
|
|
10390
|
+
passed: standing.next.passed
|
|
10275
10391
|
}
|
|
10276
10392
|
});
|
|
10277
10393
|
}
|
|
@@ -10280,30 +10396,35 @@ function moneyLine(standing, position, outcome, audience, format) {
|
|
|
10280
10396
|
credit: copy.credit,
|
|
10281
10397
|
offline: copy.paidOffline
|
|
10282
10398
|
}[standing.via];
|
|
10283
|
-
case "amounts":
|
|
10284
|
-
const segments = moneySegments(position, outcome, copy, format, standing.stillToPay);
|
|
10285
|
-
if (segments.length > 0) return segments.join(" · ");
|
|
10286
|
-
return position.amounts.remainderCents === 0 ? copy.noPaymentDue : copy.nothingPaid;
|
|
10287
|
-
}
|
|
10399
|
+
case "amounts": return amountsLine(position, outcome, copy, format, standing.stillToPay);
|
|
10288
10400
|
default: return assertNever(standing);
|
|
10289
10401
|
}
|
|
10290
10402
|
}
|
|
10403
|
+
function amountsLine(position, outcome, copy, format, stillToPay) {
|
|
10404
|
+
const segments = moneySegments(position, outcome, copy, format, stillToPay);
|
|
10405
|
+
if (segments.length > 0) return segments.join(" · ");
|
|
10406
|
+
return position.amounts.remainderCents === 0 ? copy.noPaymentDue : copy.nothingPaid;
|
|
10407
|
+
}
|
|
10408
|
+
function stillToPayTone(stillToPay) {
|
|
10409
|
+
switch (stillToPay.kind) {
|
|
10410
|
+
case "overdue": return "problem";
|
|
10411
|
+
case "not_yet_due":
|
|
10412
|
+
case "no_deadline": return "attention";
|
|
10413
|
+
case "nothing": return null;
|
|
10414
|
+
default: return assertNever(stillToPay);
|
|
10415
|
+
}
|
|
10416
|
+
}
|
|
10291
10417
|
function moneyTone(standing, position, outcome) {
|
|
10292
10418
|
switch (standing.kind) {
|
|
10293
10419
|
case "needs_checking":
|
|
10294
10420
|
case "instalment_failed": return "problem";
|
|
10295
10421
|
case "paid_in_full": return "success";
|
|
10296
10422
|
case "instalments_running": return "attention";
|
|
10423
|
+
case "checkout_unfinished": return standing.firstPaymentCents !== null ? "attention" : stillToPayTone(standing.owed) ?? "attention";
|
|
10297
10424
|
case "covered":
|
|
10298
10425
|
case "first_instalment_pending":
|
|
10299
10426
|
case "in_progress": return "neutral";
|
|
10300
|
-
case "amounts":
|
|
10301
|
-
case "overdue": return "problem";
|
|
10302
|
-
case "not_yet_due":
|
|
10303
|
-
case "no_deadline": return "attention";
|
|
10304
|
-
case "nothing": return outcome === "booked" && position.amounts.remainderCents === 0 && position.amounts.collectedCents > position.amounts.refundedCents ? "success" : "neutral";
|
|
10305
|
-
default: return assertNever(standing.stillToPay);
|
|
10306
|
-
}
|
|
10427
|
+
case "amounts": return stillToPayTone(standing.stillToPay) ?? (outcome === "booked" && position.amounts.remainderCents === 0 && position.amounts.collectedCents > position.amounts.refundedCents ? "success" : "neutral");
|
|
10307
10428
|
default: return assertNever(standing);
|
|
10308
10429
|
}
|
|
10309
10430
|
}
|
|
@@ -10327,19 +10448,272 @@ function bookingLine(position, outcome, audience) {
|
|
|
10327
10448
|
].filter((part) => part !== null);
|
|
10328
10449
|
return parts.length > 0 ? parts.join(" · ") : null;
|
|
10329
10450
|
}
|
|
10451
|
+
/**
|
|
10452
|
+
* Only a standing booking asks for money, or a partly cancelled one whose live
|
|
10453
|
+
* bookings still owe what's left (paid directly, so the rest keeps collecting;
|
|
10454
|
+
* SQL admits resuming a checkout for it only while they do).
|
|
10455
|
+
*/
|
|
10456
|
+
function asksForMoney(position, outcome, standing) {
|
|
10457
|
+
if (outcome === "booked") return true;
|
|
10458
|
+
if (outcome !== "partly_cancelled") return false;
|
|
10459
|
+
return standing.kind === "amounts" || standing.kind === "in_progress" && position.admissions.checkoutResume.kind === "admitted";
|
|
10460
|
+
}
|
|
10461
|
+
/** A payment started and not yet landed: the plan's first payment, or any other while what's left is still owed. */
|
|
10462
|
+
function startedPayment(position) {
|
|
10463
|
+
const cents$4 = position.amounts.remainderCents;
|
|
10464
|
+
const planCollecting = position.terms.kind === "instalment_plan" && position.terms.state.kind === "active";
|
|
10465
|
+
return cents$4 === 0 || planCollecting ? { kind: "nothing" } : {
|
|
10466
|
+
kind: "payment_started",
|
|
10467
|
+
cents: cents$4,
|
|
10468
|
+
deadline: payDeadline(position)
|
|
10469
|
+
};
|
|
10470
|
+
}
|
|
10471
|
+
function decideCustomerPaymentObligation(position) {
|
|
10472
|
+
const outcome = decideBookingOutcome(position);
|
|
10473
|
+
const standing = decideMoneyStanding(position, outcome);
|
|
10474
|
+
if (standing.kind === "needs_checking") return { kind: "checking" };
|
|
10475
|
+
if (!asksForMoney(position, outcome, standing)) return { kind: "nothing" };
|
|
10476
|
+
const restCents = position.amounts.remainderCents;
|
|
10477
|
+
switch (standing.kind) {
|
|
10478
|
+
case "instalment_failed": return {
|
|
10479
|
+
kind: "instalment_failed",
|
|
10480
|
+
cents: restCents
|
|
10481
|
+
};
|
|
10482
|
+
case "instalments_running": {
|
|
10483
|
+
const { next } = standing;
|
|
10484
|
+
const { deadline } = position;
|
|
10485
|
+
return {
|
|
10486
|
+
kind: "plan_running",
|
|
10487
|
+
restCents,
|
|
10488
|
+
next: next && deadline.kind !== "none" ? {
|
|
10489
|
+
cents: next.cents,
|
|
10490
|
+
dueAt: deadline.dueAt,
|
|
10491
|
+
passed: next.passed
|
|
10492
|
+
} : null
|
|
10493
|
+
};
|
|
10494
|
+
}
|
|
10495
|
+
case "amounts": return standing.stillToPay.kind === "nothing" ? { kind: "nothing" } : {
|
|
10496
|
+
kind: "pay",
|
|
10497
|
+
cents: standing.stillToPay.cents,
|
|
10498
|
+
deadline: payDeadline(position)
|
|
10499
|
+
};
|
|
10500
|
+
case "first_instalment_pending":
|
|
10501
|
+
case "in_progress": return startedPayment(position);
|
|
10502
|
+
case "checkout_unfinished": return startedPayment(position);
|
|
10503
|
+
case "covered":
|
|
10504
|
+
case "paid_in_full": return { kind: "nothing" };
|
|
10505
|
+
default: return assertNever(standing);
|
|
10506
|
+
}
|
|
10507
|
+
}
|
|
10508
|
+
/** Only which kind of obligation an order has, for loaders that pick which orders to read in full before they know how each is paid. */
|
|
10509
|
+
function customerPaymentObligationKind(position) {
|
|
10510
|
+
return decideCustomerPaymentObligation(position).kind;
|
|
10511
|
+
}
|
|
10512
|
+
/**
|
|
10513
|
+
* Whether a started payment is theirs to go back into: their checkout is open,
|
|
10514
|
+
* still in time, and SQL admits resuming it (SQL refuses a second payment
|
|
10515
|
+
* beside it). Otherwise it's on its way. A checkout past its time counts as on
|
|
10516
|
+
* its way too: it may have ended unpaid, or Stripe may still be confirming an
|
|
10517
|
+
* async payment, and only the sweep (within minutes) or a press finds out.
|
|
10518
|
+
*/
|
|
10519
|
+
function resumable(position, facts) {
|
|
10520
|
+
const { checkout } = facts;
|
|
10521
|
+
return facts.history === "live" && checkout.kind === "open" && position.admissions.checkoutResume.kind === "admitted" && Date.parse(facts.now) < Date.parse(checkout.resumableUntil);
|
|
10522
|
+
}
|
|
10523
|
+
/** A plan's first payment is all its checkout takes, when the plan says how much that is. */
|
|
10524
|
+
function firstPaymentCents(position) {
|
|
10525
|
+
const { terms } = position;
|
|
10526
|
+
return terms.kind === "instalment_plan" && terms.state.kind === "pending_initial_payment" ? terms.nextDueAmountCents : null;
|
|
10527
|
+
}
|
|
10528
|
+
/** A started payment they can go back into: Continue when the site takes cards, otherwise who to ask. */
|
|
10529
|
+
function resumablePayment(position, started, site) {
|
|
10530
|
+
const first = firstPaymentCents(position);
|
|
10531
|
+
const cents$4 = first ?? started.cents;
|
|
10532
|
+
switch (site) {
|
|
10533
|
+
case "accepts": return {
|
|
10534
|
+
kind: "finish_paying",
|
|
10535
|
+
cents: cents$4,
|
|
10536
|
+
deadline: started.deadline,
|
|
10537
|
+
firstPayment: first !== null
|
|
10538
|
+
};
|
|
10539
|
+
case "unchecked": return {
|
|
10540
|
+
kind: "pay",
|
|
10541
|
+
cents: cents$4,
|
|
10542
|
+
deadline: started.deadline,
|
|
10543
|
+
online: { kind: "unchecked" }
|
|
10544
|
+
};
|
|
10545
|
+
case "refuses": return {
|
|
10546
|
+
kind: "pay",
|
|
10547
|
+
cents: cents$4,
|
|
10548
|
+
deadline: started.deadline,
|
|
10549
|
+
online: { kind: "not_offered" }
|
|
10550
|
+
};
|
|
10551
|
+
default: return assertNever(site);
|
|
10552
|
+
}
|
|
10553
|
+
}
|
|
10554
|
+
/** One rule for paying online: a live order, a payment on its way, the order's own payment path, the site, then what the terms allow. */
|
|
10555
|
+
function decidePayOnline(position, facts) {
|
|
10556
|
+
if (facts.history !== "live") return { kind: "not_offered" };
|
|
10557
|
+
if (facts.checkout.kind === "open" || position.collection.kind === "in_progress") return { kind: "in_progress" };
|
|
10558
|
+
if (!hasOnlineOrderPaymentPath({ position })) return { kind: "not_offered" };
|
|
10559
|
+
if (facts.site === "unchecked") return { kind: "unchecked" };
|
|
10560
|
+
if (facts.site === "refuses") return { kind: "not_offered" };
|
|
10561
|
+
if (position.terms.kind !== "flexible_balance") return {
|
|
10562
|
+
kind: "available",
|
|
10563
|
+
cents: position.amounts.remainderCents,
|
|
10564
|
+
custom: null
|
|
10565
|
+
};
|
|
10566
|
+
const eligibility = paymentPositionFlexibleEligibility(position);
|
|
10567
|
+
switch (eligibility.kind) {
|
|
10568
|
+
case "unavailable": return eligibility.reason === "payment_pending" ? { kind: "in_progress" } : { kind: "not_offered" };
|
|
10569
|
+
case "full_balance_only": return {
|
|
10570
|
+
kind: "available",
|
|
10571
|
+
cents: eligibility.remainingBalanceCents,
|
|
10572
|
+
custom: null
|
|
10573
|
+
};
|
|
10574
|
+
case "eligible": return {
|
|
10575
|
+
kind: "available",
|
|
10576
|
+
cents: eligibility.suggestedPayFullAmountCents,
|
|
10577
|
+
custom: eligibility.maximumCustomAmountCents >= eligibility.minimumAmountCents ? {
|
|
10578
|
+
minimumCents: eligibility.minimumAmountCents,
|
|
10579
|
+
maximumCents: eligibility.maximumCustomAmountCents
|
|
10580
|
+
} : null
|
|
10581
|
+
};
|
|
10582
|
+
default: return assertNever(eligibility);
|
|
10583
|
+
}
|
|
10584
|
+
}
|
|
10585
|
+
function payDeadline(position) {
|
|
10586
|
+
const { deadline } = position;
|
|
10587
|
+
return deadline.kind === "none" ? { kind: "none" } : {
|
|
10588
|
+
kind: deadline.kind,
|
|
10589
|
+
dueAt: deadline.dueAt
|
|
10590
|
+
};
|
|
10591
|
+
}
|
|
10592
|
+
function decideCustomerPayment(position, online) {
|
|
10593
|
+
const obligation = decideCustomerPaymentObligation(position);
|
|
10594
|
+
switch (obligation.kind) {
|
|
10595
|
+
case "nothing":
|
|
10596
|
+
case "checking": return {
|
|
10597
|
+
toDo: obligation,
|
|
10598
|
+
resumable: false
|
|
10599
|
+
};
|
|
10600
|
+
case "payment_started": return resumable(position, online) ? {
|
|
10601
|
+
toDo: resumablePayment(position, obligation, online.site),
|
|
10602
|
+
resumable: true
|
|
10603
|
+
} : {
|
|
10604
|
+
toDo: {
|
|
10605
|
+
kind: "payment_underway",
|
|
10606
|
+
cents: obligation.cents
|
|
10607
|
+
},
|
|
10608
|
+
resumable: false
|
|
10609
|
+
};
|
|
10610
|
+
case "plan_running":
|
|
10611
|
+
case "pay":
|
|
10612
|
+
case "instalment_failed": return {
|
|
10613
|
+
toDo: {
|
|
10614
|
+
...obligation,
|
|
10615
|
+
online: decidePayOnline(position, online)
|
|
10616
|
+
},
|
|
10617
|
+
resumable: false
|
|
10618
|
+
};
|
|
10619
|
+
default: return assertNever(obligation);
|
|
10620
|
+
}
|
|
10621
|
+
}
|
|
10622
|
+
/** The order's obligation, with whether and how it can be paid online wherever money is asked for or could be paid early. */
|
|
10623
|
+
function decideCustomerPaymentToDo(position, online) {
|
|
10624
|
+
return decideCustomerPayment(position, online).toDo;
|
|
10625
|
+
}
|
|
10330
10626
|
/** The one owner of how a payment position reads, for site owners and their customers. */
|
|
10331
10627
|
function describeOrderPayment(position, audience, format) {
|
|
10628
|
+
return describeStanding(position, audience, format, false);
|
|
10629
|
+
}
|
|
10630
|
+
/**
|
|
10631
|
+
* A customer's order as they see it once its online-payment facts are known:
|
|
10632
|
+
* the to-do, and the money line worded from the same decision. A payment they
|
|
10633
|
+
* started and can go back into reads as what's still to pay, beside the
|
|
10634
|
+
* button that resumes it, never as "being processed".
|
|
10635
|
+
*/
|
|
10636
|
+
function describeCustomerOrderPayment(position, input, format) {
|
|
10637
|
+
const decision = decideCustomerPayment(position, input.online);
|
|
10638
|
+
return {
|
|
10639
|
+
toDo: decision.toDo,
|
|
10640
|
+
labels: describeStanding(position, {
|
|
10641
|
+
audience: "customer",
|
|
10642
|
+
siteName: input.siteName
|
|
10643
|
+
}, format, decision.resumable)
|
|
10644
|
+
};
|
|
10645
|
+
}
|
|
10646
|
+
/** A started payment they can go back into reads as what's owed, as any amount to pay does. */
|
|
10647
|
+
function withResumableCheckout(standing, position, resumable$1) {
|
|
10648
|
+
if (!resumable$1 || standing.kind !== "in_progress" && standing.kind !== "first_instalment_pending") return standing;
|
|
10649
|
+
return {
|
|
10650
|
+
kind: "checkout_unfinished",
|
|
10651
|
+
owed: remainderToPay(position),
|
|
10652
|
+
firstPaymentCents: firstPaymentCents(position)
|
|
10653
|
+
};
|
|
10654
|
+
}
|
|
10655
|
+
function describeStanding(position, audience, format, resumable$1) {
|
|
10332
10656
|
const outcome = decideBookingOutcome(position);
|
|
10333
|
-
const standing = decideMoneyStanding(position, outcome);
|
|
10657
|
+
const standing = withResumableCheckout(decideMoneyStanding(position, outcome), position, resumable$1);
|
|
10334
10658
|
const disputeShown = audience.audience === "owner" && (position.openDispute || outcome === "dispute_lost");
|
|
10659
|
+
const money$1 = moneyLine(standing, position, outcome, audience, format);
|
|
10335
10660
|
return {
|
|
10336
10661
|
booking: bookingLine(position, outcome, audience.audience),
|
|
10337
|
-
money:
|
|
10662
|
+
money: audience.audience === "customer" && !money$1.endsWith(".") ? `${money$1}.` : money$1,
|
|
10338
10663
|
tone: disputeShown ? "problem" : moneyTone(standing, position, outcome),
|
|
10339
10664
|
ownerHint: audience.audience === "owner" && standing.kind === "needs_checking" ? NEEDS_CHECKING_OWNER_HINT : null
|
|
10340
10665
|
};
|
|
10341
10666
|
}
|
|
10342
10667
|
|
|
10668
|
+
//#endregion
|
|
10669
|
+
//#region ../commerce/src/purchase/orderMoneyBreakdown.ts
|
|
10670
|
+
/** Discount, postage, tax added on top, then whatever the lines and those don't explain. */
|
|
10671
|
+
function breakdownAdjustments(facts, taxAdded, unexplained) {
|
|
10672
|
+
return [
|
|
10673
|
+
...facts.discountCents > 0 ? [{
|
|
10674
|
+
kind: "discount",
|
|
10675
|
+
cents: facts.discountCents,
|
|
10676
|
+
effect: "takes_off"
|
|
10677
|
+
}] : [],
|
|
10678
|
+
...facts.shippingCents > 0 ? [{
|
|
10679
|
+
kind: "postage",
|
|
10680
|
+
cents: facts.shippingCents,
|
|
10681
|
+
effect: "adds"
|
|
10682
|
+
}] : [],
|
|
10683
|
+
...taxAdded ? [{
|
|
10684
|
+
kind: "tax",
|
|
10685
|
+
cents: facts.taxCents,
|
|
10686
|
+
effect: "adds"
|
|
10687
|
+
}] : [],
|
|
10688
|
+
...unexplained !== 0 ? [{
|
|
10689
|
+
kind: "price_change",
|
|
10690
|
+
cents: Math.abs(unexplained),
|
|
10691
|
+
effect: unexplained > 0 ? "adds" : "takes_off"
|
|
10692
|
+
}] : []
|
|
10693
|
+
];
|
|
10694
|
+
}
|
|
10695
|
+
/** Tax was added on top when the total is exactly what comes before tax, plus the tax. */
|
|
10696
|
+
function isTaxAdded(facts, beforeTax) {
|
|
10697
|
+
return facts.taxCents > 0 && beforeTax !== facts.grandTotalCents && beforeTax + facts.taxCents === facts.grandTotalCents;
|
|
10698
|
+
}
|
|
10699
|
+
function decideOrderMoneyBreakdown(facts) {
|
|
10700
|
+
const lines = facts.items.map((item) => ({
|
|
10701
|
+
id: item.id,
|
|
10702
|
+
cents: item.unitPriceCents * item.quantity
|
|
10703
|
+
}));
|
|
10704
|
+
const listed = lines.reduce((sum, line) => sum + line.cents, 0);
|
|
10705
|
+
const beforeTax = listed - facts.discountCents + facts.shippingCents;
|
|
10706
|
+
const taxAdded = isTaxAdded(facts, beforeTax);
|
|
10707
|
+
const unexplained = facts.grandTotalCents - beforeTax - (taxAdded ? facts.taxCents : 0);
|
|
10708
|
+
return {
|
|
10709
|
+
lines,
|
|
10710
|
+
adjustments: breakdownAdjustments(facts, taxAdded, unexplained),
|
|
10711
|
+
totalCents: facts.grandTotalCents,
|
|
10712
|
+
taxIncludedCents: facts.taxCents > 0 && !taxAdded ? facts.taxCents : null,
|
|
10713
|
+
creditCents: Math.min(facts.creditCents, facts.grandTotalCents)
|
|
10714
|
+
};
|
|
10715
|
+
}
|
|
10716
|
+
|
|
10343
10717
|
//#endregion
|
|
10344
10718
|
//#region ../site-contracts/src/siteData/eventCheckout.ts
|
|
10345
10719
|
/**
|
|
@@ -10630,6 +11004,2505 @@ function identityMatchesSubject(identity, subject) {
|
|
|
10630
11004
|
return identity.scope === subject.scope && identity.submissionId === subject.submissionId && (identity.scope !== "occurrence" || subject.scope !== "occurrence" || identity.attendeeId === subject.attendeeId);
|
|
10631
11005
|
}
|
|
10632
11006
|
|
|
11007
|
+
//#endregion
|
|
11008
|
+
//#region ../site-contracts/src/siteData/wireSchema.ts
|
|
11009
|
+
/**
|
|
11010
|
+
* Admits a wire decoder only when it matches its contract type `T` in this
|
|
11011
|
+
* build: what it decodes is a `T`, and it accepts the input side of every
|
|
11012
|
+
* `T`. A schema stricter than its type would refuse real responses (a member
|
|
11013
|
+
* the type has but the schema forgot), and a looser one would let unchecked
|
|
11014
|
+
* shapes through, so both directions are checked where the type is declared.
|
|
11015
|
+
*
|
|
11016
|
+
* It is a compile-time check against today's type and nothing more. It can't
|
|
11017
|
+
* know what a newer server will send a client built from an older contract
|
|
11018
|
+
* (SDK sites run pinned builds), so a value the type later gains is still
|
|
11019
|
+
* refused by an old decoder. Where that has to keep working, the contract
|
|
11020
|
+
* names the point as extensible and decodes it with {@link evolvingSchema}.
|
|
11021
|
+
*
|
|
11022
|
+
* Mirror the type's arrays: `z.array(x).readonly()` for a `readonly` array,
|
|
11023
|
+
* plain `z.array(x)` for a mutable one.
|
|
11024
|
+
*/
|
|
11025
|
+
function exactSchema() {
|
|
11026
|
+
return evolvingSchema();
|
|
11027
|
+
}
|
|
11028
|
+
/**
|
|
11029
|
+
* A decoder at a named extensible point of a contract: it reads every `TWire`
|
|
11030
|
+
* the server sends today, and decodes anything a newer server might add there
|
|
11031
|
+
* to the closed fallback inside `TDecoded` (an `unsupported` state the client
|
|
11032
|
+
* renders safely: shown, but with nothing to act on). Known variants stay
|
|
11033
|
+
* strict, so a broken known value is still an error rather than a fallback.
|
|
11034
|
+
*/
|
|
11035
|
+
function evolvingSchema() {
|
|
11036
|
+
return (schema) => schema;
|
|
11037
|
+
}
|
|
11038
|
+
/** Anything at an extensible point whose `kind` this build doesn't know. */
|
|
11039
|
+
function unknownKind(known) {
|
|
11040
|
+
return z.object({ kind: z.string().refine((kind) => !known.includes(kind), "a known kind failed to decode") });
|
|
11041
|
+
}
|
|
11042
|
+
/** The same for a point discriminated by `tag` (a booking reference), whose `tag` this build doesn't know. */
|
|
11043
|
+
function unknownTag(known) {
|
|
11044
|
+
return z.object({ tag: z.string().refine((tag) => !known.includes(tag), "a known tag failed to decode") });
|
|
11045
|
+
}
|
|
11046
|
+
|
|
11047
|
+
//#endregion
|
|
11048
|
+
//#region ../site-contracts/src/siteData/portalAccounts.ts
|
|
11049
|
+
const customerProfileSchema = exactSchema()(z.object({
|
|
11050
|
+
id: z.string(),
|
|
11051
|
+
email: z.string(),
|
|
11052
|
+
name: z.string(),
|
|
11053
|
+
phone: z.string().nullable()
|
|
11054
|
+
}));
|
|
11055
|
+
const enabledModulesSchema = exactSchema()(z.object({
|
|
11056
|
+
appointments: z.boolean(),
|
|
11057
|
+
events: z.boolean()
|
|
11058
|
+
}));
|
|
11059
|
+
const eventTicketBreakdownLineSchema = exactSchema()(z.object({
|
|
11060
|
+
pricingOptionId: z.string().nullable(),
|
|
11061
|
+
label: z.string(),
|
|
11062
|
+
quantity: z.number()
|
|
11063
|
+
}));
|
|
11064
|
+
const portalJoiningDetailsSchema = exactSchema()(z.object({
|
|
11065
|
+
joinUrl: z.string(),
|
|
11066
|
+
accessCode: z.string().nullable(),
|
|
11067
|
+
notes: z.string().nullable()
|
|
11068
|
+
}));
|
|
11069
|
+
const eventGuestSchema = exactSchema()(z.object({
|
|
11070
|
+
id: z.string(),
|
|
11071
|
+
name: z.string(),
|
|
11072
|
+
phone: z.string().nullable(),
|
|
11073
|
+
guestIndex: z.number()
|
|
11074
|
+
}));
|
|
11075
|
+
|
|
11076
|
+
//#endregion
|
|
11077
|
+
//#region ../site-contracts/src/siteData/portalCredits.ts
|
|
11078
|
+
const passCreditHistoryEntrySchema = exactSchema()(z.object({
|
|
11079
|
+
id: z.string(),
|
|
11080
|
+
kind: z.enum(["redemption", "restoration"]),
|
|
11081
|
+
credits: z.number(),
|
|
11082
|
+
subjectKind: z.enum(["event_attendee", "appointment"]),
|
|
11083
|
+
subjectId: z.string(),
|
|
11084
|
+
occurredAt: z.string(),
|
|
11085
|
+
bookingStartsAt: z.string().nullable(),
|
|
11086
|
+
actorKind: z.enum([
|
|
11087
|
+
"customer",
|
|
11088
|
+
"admin",
|
|
11089
|
+
"system"
|
|
11090
|
+
]).nullable(),
|
|
11091
|
+
reason: z.string().nullable()
|
|
11092
|
+
}));
|
|
11093
|
+
/** The pieces a booking's payment reuses when it names the pass or membership that paid. */
|
|
11094
|
+
const customerPassUseCaseSchema = exactSchema()(z.enum(["event_pass", "appointment_package"]));
|
|
11095
|
+
const customerMembershipStatusSchema = exactSchema()(z.enum([
|
|
11096
|
+
"active",
|
|
11097
|
+
"paused",
|
|
11098
|
+
"canceled",
|
|
11099
|
+
"past_due",
|
|
11100
|
+
"trialing"
|
|
11101
|
+
]));
|
|
11102
|
+
const customerPassSchema = exactSchema()(z.object({
|
|
11103
|
+
id: z.string(),
|
|
11104
|
+
heldWithStaffMemberId: z.string().nullable(),
|
|
11105
|
+
passId: z.string(),
|
|
11106
|
+
productUseCase: customerPassUseCaseSchema,
|
|
11107
|
+
passName: z.string(),
|
|
11108
|
+
passDescription: z.string().nullable(),
|
|
11109
|
+
creditsHeld: z.number(),
|
|
11110
|
+
creditsRemaining: z.number(),
|
|
11111
|
+
creditsTotal: z.number(),
|
|
11112
|
+
purchasedAt: z.string(),
|
|
11113
|
+
expiresAt: z.string().nullable(),
|
|
11114
|
+
status: z.enum([
|
|
11115
|
+
"active",
|
|
11116
|
+
"exhausted",
|
|
11117
|
+
"expired",
|
|
11118
|
+
"refunded"
|
|
11119
|
+
]),
|
|
11120
|
+
creditHistory: z.array(passCreditHistoryEntrySchema).readonly()
|
|
11121
|
+
}));
|
|
11122
|
+
const customerMembershipSchema = exactSchema()(z.object({
|
|
11123
|
+
id: z.string(),
|
|
11124
|
+
membershipId: z.string(),
|
|
11125
|
+
membershipName: z.string(),
|
|
11126
|
+
membershipDescription: z.string().nullable(),
|
|
11127
|
+
billingInterval: z.enum(["month", "year"]),
|
|
11128
|
+
status: customerMembershipStatusSchema,
|
|
11129
|
+
currentPeriodStart: z.string().nullable(),
|
|
11130
|
+
currentPeriodEnd: z.string().nullable(),
|
|
11131
|
+
cancelAtPeriodEnd: z.boolean(),
|
|
11132
|
+
pausedAt: z.string().nullable(),
|
|
11133
|
+
canceledAt: z.string().nullable(),
|
|
11134
|
+
renews: z.boolean(),
|
|
11135
|
+
canCancel: z.boolean(),
|
|
11136
|
+
canResume: z.boolean(),
|
|
11137
|
+
endedAt: z.string().nullable()
|
|
11138
|
+
}));
|
|
11139
|
+
const creditSummarySchema = exactSchema()(z.object({
|
|
11140
|
+
currency: z.string(),
|
|
11141
|
+
balanceCents: z.number(),
|
|
11142
|
+
reservedCents: z.number(),
|
|
11143
|
+
availableCents: z.number()
|
|
11144
|
+
}));
|
|
11145
|
+
const creditTransactionSchema = exactSchema()(z.object({
|
|
11146
|
+
id: z.string(),
|
|
11147
|
+
amountCents: z.number(),
|
|
11148
|
+
currency: z.string(),
|
|
11149
|
+
type: z.string(),
|
|
11150
|
+
createdAt: z.string(),
|
|
11151
|
+
reason: z.string().nullable()
|
|
11152
|
+
}));
|
|
11153
|
+
const portalCreditSchema = exactSchema()(z.object({
|
|
11154
|
+
summary: creditSummarySchema,
|
|
11155
|
+
transactions: z.array(creditTransactionSchema)
|
|
11156
|
+
}));
|
|
11157
|
+
|
|
11158
|
+
//#endregion
|
|
11159
|
+
//#region ../site-contracts/src/siteData/portalQuestions.ts
|
|
11160
|
+
const optionSchema$1 = exactSchema()(z.object({
|
|
11161
|
+
value: z.string(),
|
|
11162
|
+
label: z.string()
|
|
11163
|
+
}));
|
|
11164
|
+
const scalarFieldSchema = exactSchema()(z.object({
|
|
11165
|
+
id: z.string().min(1),
|
|
11166
|
+
label: z.string(),
|
|
11167
|
+
type: z.enum([
|
|
11168
|
+
"text",
|
|
11169
|
+
"email",
|
|
11170
|
+
"textarea",
|
|
11171
|
+
"select",
|
|
11172
|
+
"radio",
|
|
11173
|
+
"checkbox",
|
|
11174
|
+
"tel",
|
|
11175
|
+
"url",
|
|
11176
|
+
"number",
|
|
11177
|
+
"date",
|
|
11178
|
+
"time"
|
|
11179
|
+
]),
|
|
11180
|
+
required: z.boolean().optional(),
|
|
11181
|
+
placeholder: z.string().optional(),
|
|
11182
|
+
helpText: z.string().optional(),
|
|
11183
|
+
options: z.array(optionSchema$1).readonly().optional(),
|
|
11184
|
+
multiple: z.boolean().optional(),
|
|
11185
|
+
minLength: z.number().optional(),
|
|
11186
|
+
maxLength: z.number().optional(),
|
|
11187
|
+
pattern: z.string().optional(),
|
|
11188
|
+
min: z.number().optional(),
|
|
11189
|
+
max: z.number().optional()
|
|
11190
|
+
}));
|
|
11191
|
+
const documentFieldSchema = exactSchema()(z.object({
|
|
11192
|
+
id: z.string().min(1),
|
|
11193
|
+
label: z.string(),
|
|
11194
|
+
type: z.literal("document_upload"),
|
|
11195
|
+
required: z.boolean().optional(),
|
|
11196
|
+
placeholder: z.string().optional(),
|
|
11197
|
+
helpText: z.string().optional(),
|
|
11198
|
+
allowedFileTypes: z.array(z.enum([
|
|
11199
|
+
"pdf",
|
|
11200
|
+
"image",
|
|
11201
|
+
"docx"
|
|
11202
|
+
])).readonly(),
|
|
11203
|
+
maxBytes: z.number()
|
|
11204
|
+
}));
|
|
11205
|
+
const bookingQuestionsFieldSchema = exactSchema()(z.union([scalarFieldSchema, documentFieldSchema]));
|
|
11206
|
+
const bookingQuestionsSectionSchema = exactSchema()(z.object({
|
|
11207
|
+
id: z.string(),
|
|
11208
|
+
title: z.string(),
|
|
11209
|
+
description: z.string().optional(),
|
|
11210
|
+
items: z.array(bookingQuestionsFieldSchema).readonly()
|
|
11211
|
+
}));
|
|
11212
|
+
const FIELD_TYPES = [
|
|
11213
|
+
"text",
|
|
11214
|
+
"email",
|
|
11215
|
+
"textarea",
|
|
11216
|
+
"select",
|
|
11217
|
+
"radio",
|
|
11218
|
+
"checkbox",
|
|
11219
|
+
"tel",
|
|
11220
|
+
"url",
|
|
11221
|
+
"number",
|
|
11222
|
+
"date",
|
|
11223
|
+
"time",
|
|
11224
|
+
"document_upload"
|
|
11225
|
+
];
|
|
11226
|
+
/**
|
|
11227
|
+
* The portal's questions, read at their extensible point: a type this build
|
|
11228
|
+
* doesn't know decodes to `unsupported` with its id, label and required flag;
|
|
11229
|
+
* a known type that's malformed is still an error.
|
|
11230
|
+
*/
|
|
11231
|
+
const unsupportedFieldSchema = z.object({
|
|
11232
|
+
id: z.string().min(1),
|
|
11233
|
+
label: z.string(),
|
|
11234
|
+
type: z.string().refine((type) => !FIELD_TYPES.includes(type), "a known question type failed to decode"),
|
|
11235
|
+
required: z.boolean().optional()
|
|
11236
|
+
}).transform((field) => ({
|
|
11237
|
+
id: field.id,
|
|
11238
|
+
label: field.label,
|
|
11239
|
+
type: "unsupported",
|
|
11240
|
+
required: field.required ?? false
|
|
11241
|
+
}));
|
|
11242
|
+
const bookingQuestionsFieldViewSchema = evolvingSchema()(z.union([
|
|
11243
|
+
scalarFieldSchema,
|
|
11244
|
+
documentFieldSchema,
|
|
11245
|
+
unsupportedFieldSchema
|
|
11246
|
+
]));
|
|
11247
|
+
const bookingQuestionsSectionViewSchema = evolvingSchema()(z.object({
|
|
11248
|
+
id: z.string(),
|
|
11249
|
+
title: z.string(),
|
|
11250
|
+
description: z.string().optional(),
|
|
11251
|
+
items: z.array(bookingQuestionsFieldViewSchema).readonly()
|
|
11252
|
+
}));
|
|
11253
|
+
const bookingQuestionsDocumentAnswerValueSchema = exactSchema()(z.object({
|
|
11254
|
+
kind: z.literal("document_upload"),
|
|
11255
|
+
fileName: z.string(),
|
|
11256
|
+
mimeType: z.string(),
|
|
11257
|
+
bytes: z.number(),
|
|
11258
|
+
uploadId: z.string().optional()
|
|
11259
|
+
}));
|
|
11260
|
+
/** One answer as a booking flow holds it; also what drafts kept across a sign-in or payment return parse. */
|
|
11261
|
+
const bookingQuestionsAnswerValueSchema = exactSchema()(z.union([
|
|
11262
|
+
z.string(),
|
|
11263
|
+
z.number(),
|
|
11264
|
+
z.boolean(),
|
|
11265
|
+
z.null(),
|
|
11266
|
+
z.array(z.string()),
|
|
11267
|
+
bookingQuestionsDocumentAnswerValueSchema
|
|
11268
|
+
]));
|
|
11269
|
+
const bookingQuestionsAnswersSchema = z.record(z.string(), bookingQuestionsAnswerValueSchema);
|
|
11270
|
+
const taskStatusSchema = z.enum([
|
|
11271
|
+
"complete",
|
|
11272
|
+
"incomplete",
|
|
11273
|
+
"overdue"
|
|
11274
|
+
]);
|
|
11275
|
+
const beforeYouComeTaskSummarySchema = exactSchema()(z.object({
|
|
11276
|
+
status: taskStatusSchema,
|
|
11277
|
+
dueAt: z.string(),
|
|
11278
|
+
completedAt: z.string().nullable(),
|
|
11279
|
+
prefillAvailable: z.boolean()
|
|
11280
|
+
}));
|
|
11281
|
+
const portalBeforeYouComeTaskSchema = exactSchema()(z.union([beforeYouComeTaskSummarySchema, z.object({ kind: z.literal("unavailable") })]));
|
|
11282
|
+
const capturedAnswerSchema = exactSchema()(z.union([z.object({
|
|
11283
|
+
fieldId: z.string(),
|
|
11284
|
+
label: z.string(),
|
|
11285
|
+
kind: z.literal("scalar"),
|
|
11286
|
+
valueSummary: z.string()
|
|
11287
|
+
}), z.object({
|
|
11288
|
+
fieldId: z.string(),
|
|
11289
|
+
label: z.string(),
|
|
11290
|
+
kind: z.literal("document"),
|
|
11291
|
+
fileName: z.string(),
|
|
11292
|
+
bytes: z.number()
|
|
11293
|
+
})]));
|
|
11294
|
+
const ANSWERING_KINDS = ["open", "sent"];
|
|
11295
|
+
const bookingQuestionsAnsweringSchema = evolvingSchema()(z.union([
|
|
11296
|
+
z.object({
|
|
11297
|
+
kind: z.literal("open"),
|
|
11298
|
+
late: z.boolean()
|
|
11299
|
+
}),
|
|
11300
|
+
z.object({
|
|
11301
|
+
kind: z.literal("sent"),
|
|
11302
|
+
changeNote: z.string()
|
|
11303
|
+
}),
|
|
11304
|
+
unknownKind(ANSWERING_KINDS).transform(() => ({ kind: "unsupported" }))
|
|
11305
|
+
]));
|
|
11306
|
+
const bookingQuestionsTaskDetailSchema = evolvingSchema()(z.object({
|
|
11307
|
+
completedAnswers: z.array(capturedAnswerSchema).readonly().optional(),
|
|
11308
|
+
timeZone: z.string(),
|
|
11309
|
+
isOnline: z.boolean().nullable(),
|
|
11310
|
+
requirementId: z.string(),
|
|
11311
|
+
title: z.string(),
|
|
11312
|
+
introTitle: z.string().nullable(),
|
|
11313
|
+
introBody: z.string().nullable(),
|
|
11314
|
+
shape: z.enum(["short-form", "detailed-questionnaire"]),
|
|
11315
|
+
status: taskStatusSchema,
|
|
11316
|
+
dueAt: z.string(),
|
|
11317
|
+
completedAt: z.string().nullable(),
|
|
11318
|
+
prefillAvailable: z.boolean(),
|
|
11319
|
+
answering: bookingQuestionsAnsweringSchema,
|
|
11320
|
+
answers: bookingQuestionsAnswersSchema,
|
|
11321
|
+
sections: z.array(bookingQuestionsSectionViewSchema).readonly()
|
|
11322
|
+
}));
|
|
11323
|
+
|
|
11324
|
+
//#endregion
|
|
11325
|
+
//#region ../site-contracts/src/siteData/portalMoney.ts
|
|
11326
|
+
const portalMoneySchema = exactSchema()(z.object({
|
|
11327
|
+
amountCents: z.number(),
|
|
11328
|
+
currency: z.string()
|
|
11329
|
+
}));
|
|
11330
|
+
const portalDeadlineSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11331
|
+
z.object({ kind: z.literal("none") }),
|
|
11332
|
+
z.object({
|
|
11333
|
+
kind: z.literal("due"),
|
|
11334
|
+
at: z.string()
|
|
11335
|
+
}),
|
|
11336
|
+
z.object({
|
|
11337
|
+
kind: z.literal("overdue"),
|
|
11338
|
+
at: z.string()
|
|
11339
|
+
})
|
|
11340
|
+
]));
|
|
11341
|
+
const portalPayOnlineSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11342
|
+
z.object({
|
|
11343
|
+
kind: z.literal("available"),
|
|
11344
|
+
amount: portalMoneySchema,
|
|
11345
|
+
custom: z.object({
|
|
11346
|
+
min: portalMoneySchema,
|
|
11347
|
+
max: portalMoneySchema
|
|
11348
|
+
}).nullable()
|
|
11349
|
+
}),
|
|
11350
|
+
z.object({ kind: z.literal("in_progress") }),
|
|
11351
|
+
z.object({ kind: z.literal("not_offered") }),
|
|
11352
|
+
z.object({ kind: z.literal("unchecked") })
|
|
11353
|
+
]));
|
|
11354
|
+
const payDue = z.object({
|
|
11355
|
+
kind: z.literal("pay"),
|
|
11356
|
+
amount: portalMoneySchema,
|
|
11357
|
+
deadline: portalDeadlineSchema,
|
|
11358
|
+
online: portalPayOnlineSchema
|
|
11359
|
+
});
|
|
11360
|
+
const instalmentFailed = z.object({
|
|
11361
|
+
kind: z.literal("instalment_failed"),
|
|
11362
|
+
amount: portalMoneySchema,
|
|
11363
|
+
online: portalPayOnlineSchema
|
|
11364
|
+
});
|
|
11365
|
+
const finishPaying = z.object({
|
|
11366
|
+
kind: z.literal("finish_paying"),
|
|
11367
|
+
amount: portalMoneySchema,
|
|
11368
|
+
deadline: portalDeadlineSchema,
|
|
11369
|
+
firstPayment: z.boolean()
|
|
11370
|
+
});
|
|
11371
|
+
const paymentUnderway = z.object({
|
|
11372
|
+
kind: z.literal("payment_underway"),
|
|
11373
|
+
amount: portalMoneySchema
|
|
11374
|
+
});
|
|
11375
|
+
const portalPaymentDueSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11376
|
+
payDue,
|
|
11377
|
+
instalmentFailed,
|
|
11378
|
+
finishPaying,
|
|
11379
|
+
paymentUnderway
|
|
11380
|
+
]));
|
|
11381
|
+
const portalPaymentToDoSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11382
|
+
z.object({ kind: z.literal("nothing") }),
|
|
11383
|
+
z.object({ kind: z.literal("checking") }),
|
|
11384
|
+
z.object({
|
|
11385
|
+
kind: z.literal("plan_running"),
|
|
11386
|
+
rest: portalMoneySchema,
|
|
11387
|
+
next: z.object({
|
|
11388
|
+
amount: portalMoneySchema,
|
|
11389
|
+
dueAt: z.string(),
|
|
11390
|
+
passed: z.boolean()
|
|
11391
|
+
}).nullable(),
|
|
11392
|
+
online: portalPayOnlineSchema
|
|
11393
|
+
}),
|
|
11394
|
+
payDue,
|
|
11395
|
+
instalmentFailed,
|
|
11396
|
+
finishPaying,
|
|
11397
|
+
paymentUnderway
|
|
11398
|
+
]));
|
|
11399
|
+
const portalOrderNameSchema = exactSchema()(z.object({
|
|
11400
|
+
orderId: z.string(),
|
|
11401
|
+
orderNumber: z.string(),
|
|
11402
|
+
firstItem: z.string().nullable(),
|
|
11403
|
+
otherItems: z.number()
|
|
11404
|
+
}));
|
|
11405
|
+
const portalOrderBreakdownSchema = exactSchema()(z.object({
|
|
11406
|
+
lines: z.array(z.object({
|
|
11407
|
+
key: z.string(),
|
|
11408
|
+
label: z.string(),
|
|
11409
|
+
quantity: z.number(),
|
|
11410
|
+
unitPrice: portalMoneySchema,
|
|
11411
|
+
amount: portalMoneySchema,
|
|
11412
|
+
refunded: portalMoneySchema.nullable()
|
|
11413
|
+
})).readonly(),
|
|
11414
|
+
adjustments: z.array(z.object({
|
|
11415
|
+
kind: z.enum([
|
|
11416
|
+
"discount",
|
|
11417
|
+
"postage",
|
|
11418
|
+
"tax",
|
|
11419
|
+
"price_change"
|
|
11420
|
+
]),
|
|
11421
|
+
amount: portalMoneySchema,
|
|
11422
|
+
effect: z.enum(["adds", "takes_off"])
|
|
11423
|
+
})).readonly(),
|
|
11424
|
+
total: portalMoneySchema,
|
|
11425
|
+
taxIncluded: portalMoneySchema.nullable(),
|
|
11426
|
+
credit: portalMoneySchema.nullable()
|
|
11427
|
+
}));
|
|
11428
|
+
|
|
11429
|
+
//#endregion
|
|
11430
|
+
//#region ../site-contracts/src/siteData/coreWireSchemas.ts
|
|
11431
|
+
/**
|
|
11432
|
+
* Decoders for the core-owned types the portal wire carries. Core keeps the
|
|
11433
|
+
* types; these schemas are checked against them both ways, so a change to a
|
|
11434
|
+
* core union shows up here as a compile error rather than as a refused
|
|
11435
|
+
* response.
|
|
11436
|
+
*/
|
|
11437
|
+
/** A branded id on the wire, refused unless core's parser accepts it. */
|
|
11438
|
+
function brandedId(parse$1, label) {
|
|
11439
|
+
return z.string().transform((value, ctx) => {
|
|
11440
|
+
const parsed = parse$1(value);
|
|
11441
|
+
if (parsed.ok) return parsed.value;
|
|
11442
|
+
ctx.addIssue({
|
|
11443
|
+
code: "custom",
|
|
11444
|
+
message: `Invalid ${label}`
|
|
11445
|
+
});
|
|
11446
|
+
return z.NEVER;
|
|
11447
|
+
});
|
|
11448
|
+
}
|
|
11449
|
+
const BOOKING_ACTION_REASONS = [
|
|
11450
|
+
"not_wired",
|
|
11451
|
+
"course_booking",
|
|
11452
|
+
"storage_convergence",
|
|
11453
|
+
"switched_off",
|
|
11454
|
+
"checked_in",
|
|
11455
|
+
"cancelled",
|
|
11456
|
+
"waitlisted",
|
|
11457
|
+
"past",
|
|
11458
|
+
"date_missing",
|
|
11459
|
+
"payment_pending",
|
|
11460
|
+
"not_owner",
|
|
11461
|
+
"not_authorized",
|
|
11462
|
+
"pass_or_membership_backed",
|
|
11463
|
+
"already_cancelled",
|
|
11464
|
+
"already_started",
|
|
11465
|
+
"payment_in_progress",
|
|
11466
|
+
"invalid_start_time",
|
|
11467
|
+
"not_cancelled",
|
|
11468
|
+
"completed",
|
|
11469
|
+
"hand_added",
|
|
11470
|
+
"self_serve_refund",
|
|
11471
|
+
"no_refund_link",
|
|
11472
|
+
"check_in_unavailable",
|
|
11473
|
+
"refunded",
|
|
11474
|
+
"refund_pending",
|
|
11475
|
+
"order_cancelled",
|
|
11476
|
+
"order_cancelling",
|
|
11477
|
+
"already_booked",
|
|
11478
|
+
"has_room",
|
|
11479
|
+
"no_ticket_choice",
|
|
11480
|
+
"single_place"
|
|
11481
|
+
];
|
|
11482
|
+
const bookingActionAvailabilitySchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11483
|
+
z.object({
|
|
11484
|
+
kind: z.literal("available"),
|
|
11485
|
+
until: z.string().nullable()
|
|
11486
|
+
}),
|
|
11487
|
+
z.object({
|
|
11488
|
+
kind: z.literal("closed"),
|
|
11489
|
+
closedAt: z.string()
|
|
11490
|
+
}),
|
|
11491
|
+
z.object({
|
|
11492
|
+
kind: z.literal("not_offered"),
|
|
11493
|
+
reason: z.enum(BOOKING_ACTION_REASONS)
|
|
11494
|
+
})
|
|
11495
|
+
]));
|
|
11496
|
+
const cancellationMoneySchema = z.object({
|
|
11497
|
+
amountCents: z.number(),
|
|
11498
|
+
currency: z.string()
|
|
11499
|
+
});
|
|
11500
|
+
const cancellationKeepReasonSchema = z.discriminatedUnion("kind", [
|
|
11501
|
+
z.object({
|
|
11502
|
+
kind: z.literal("cutoff_passed"),
|
|
11503
|
+
cutoffHours: z.number()
|
|
11504
|
+
}),
|
|
11505
|
+
z.object({ kind: z.literal("never_refunded") }),
|
|
11506
|
+
z.object({ kind: z.literal("non_refundable_deposit") }),
|
|
11507
|
+
z.object({ kind: z.literal("already_started") })
|
|
11508
|
+
]);
|
|
11509
|
+
const refundDestinationKindSchema = exactSchema()(z.enum([
|
|
11510
|
+
"card",
|
|
11511
|
+
"site_credit",
|
|
11512
|
+
"card_and_site_credit"
|
|
11513
|
+
]));
|
|
11514
|
+
const refundRecipientSchema = exactSchema()(z.enum(["you", "original_buyer"]));
|
|
11515
|
+
const cancellationMoneyOutcomeSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11516
|
+
z.object({ kind: z.literal("nothing_to_return") }),
|
|
11517
|
+
z.object({
|
|
11518
|
+
kind: z.literal("refund"),
|
|
11519
|
+
money: cancellationMoneySchema,
|
|
11520
|
+
to: refundDestinationKindSchema,
|
|
11521
|
+
keptDeposit: cancellationMoneySchema.optional(),
|
|
11522
|
+
until: z.string().optional()
|
|
11523
|
+
}),
|
|
11524
|
+
z.object({
|
|
11525
|
+
kind: z.literal("credit_back"),
|
|
11526
|
+
credits: z.number(),
|
|
11527
|
+
until: z.string().optional()
|
|
11528
|
+
}),
|
|
11529
|
+
z.object({
|
|
11530
|
+
kind: z.literal("keep_money"),
|
|
11531
|
+
money: cancellationMoneySchema,
|
|
11532
|
+
reason: cancellationKeepReasonSchema
|
|
11533
|
+
}),
|
|
11534
|
+
z.object({
|
|
11535
|
+
kind: z.literal("keep_credit"),
|
|
11536
|
+
credits: z.number(),
|
|
11537
|
+
reason: cancellationKeepReasonSchema
|
|
11538
|
+
}),
|
|
11539
|
+
z.object({
|
|
11540
|
+
kind: z.literal("contact_business"),
|
|
11541
|
+
money: cancellationMoneySchema
|
|
11542
|
+
})
|
|
11543
|
+
]));
|
|
11544
|
+
/** What a cancellation did with the money, as the server decided it once it happened. */
|
|
11545
|
+
const cancelledMoneySchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11546
|
+
z.object({
|
|
11547
|
+
kind: z.literal("refunded"),
|
|
11548
|
+
amount: cancellationMoneySchema.nullable(),
|
|
11549
|
+
to: refundDestinationKindSchema,
|
|
11550
|
+
recipient: refundRecipientSchema
|
|
11551
|
+
}),
|
|
11552
|
+
z.object({ kind: z.literal("credit_restored") }),
|
|
11553
|
+
z.object({ kind: z.literal("refund_failed") }),
|
|
11554
|
+
z.object({ kind: z.literal("none") })
|
|
11555
|
+
]));
|
|
11556
|
+
const appointmentRefSchema = exactSchema()(z.object({
|
|
11557
|
+
tag: z.literal("appointment"),
|
|
11558
|
+
appointmentId: brandedId(parseAppointmentId, "appointment id")
|
|
11559
|
+
}));
|
|
11560
|
+
const eventAttendeeRefSchema = exactSchema()(z.object({
|
|
11561
|
+
tag: z.literal("event_attendee"),
|
|
11562
|
+
attendeeId: brandedId(parseAttendeeId, "booking id")
|
|
11563
|
+
}));
|
|
11564
|
+
const courseRegistrationRefSchema = exactSchema()(z.object({
|
|
11565
|
+
tag: z.literal("event_series_registration"),
|
|
11566
|
+
registrationId: brandedId(parseEventSeriesRegistrationId, "course booking id")
|
|
11567
|
+
}));
|
|
11568
|
+
const bookingContextRefSchema = exactSchema()(z.discriminatedUnion("tag", [
|
|
11569
|
+
appointmentRefSchema,
|
|
11570
|
+
eventAttendeeRefSchema,
|
|
11571
|
+
courseRegistrationRefSchema
|
|
11572
|
+
]));
|
|
11573
|
+
const appointmentRequestOutcomeSchema = exactSchema()(z.enum(APPOINTMENT_REQUEST_OUTCOME_VALUES));
|
|
11574
|
+
const verifiedSiteTermsAcceptanceSchema = exactSchema()(z.object({
|
|
11575
|
+
versionId: z.string().uuid().pipe(brandedId(parseSiteTermsVersionId, "site terms version")),
|
|
11576
|
+
alreadyAgreed: z.boolean()
|
|
11577
|
+
}));
|
|
11578
|
+
const orderInstalmentSummarySchema = exactSchema()(z.object({
|
|
11579
|
+
status: z.enum([
|
|
11580
|
+
"pending_initial_payment",
|
|
11581
|
+
"active",
|
|
11582
|
+
"completed",
|
|
11583
|
+
"payment_failed",
|
|
11584
|
+
"cancelled",
|
|
11585
|
+
"cancelled_as_paid_early",
|
|
11586
|
+
"refunded",
|
|
11587
|
+
"reconciliation_required"
|
|
11588
|
+
]),
|
|
11589
|
+
remainingBalanceCents: z.number(),
|
|
11590
|
+
nextDueAt: z.string().nullable(),
|
|
11591
|
+
nextDueAmountCents: z.number().nullable(),
|
|
11592
|
+
rows: z.array(z.object({
|
|
11593
|
+
id: z.string(),
|
|
11594
|
+
sequence: z.number(),
|
|
11595
|
+
phaseKind: z.enum(["initial", "scheduled"]),
|
|
11596
|
+
dueAt: z.string(),
|
|
11597
|
+
amountCents: z.number(),
|
|
11598
|
+
status: z.enum([
|
|
11599
|
+
"pending_initial_payment",
|
|
11600
|
+
"scheduled",
|
|
11601
|
+
"paid",
|
|
11602
|
+
"failed",
|
|
11603
|
+
"waived",
|
|
11604
|
+
"cancelled",
|
|
11605
|
+
"cancelled_as_paid_early",
|
|
11606
|
+
"refunded"
|
|
11607
|
+
])
|
|
11608
|
+
})).readonly()
|
|
11609
|
+
}));
|
|
11610
|
+
const flexibleBalanceContractStatusSchema = exactSchema()(z.enum([
|
|
11611
|
+
"active",
|
|
11612
|
+
"payment_pending",
|
|
11613
|
+
"overdue",
|
|
11614
|
+
"completed",
|
|
11615
|
+
"waived",
|
|
11616
|
+
"cancelled_due_to_non_payment",
|
|
11617
|
+
"refunded",
|
|
11618
|
+
"closed_order_failed"
|
|
11619
|
+
]));
|
|
11620
|
+
const flexibleBalancePaymentEligibilitySchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
11621
|
+
z.object({
|
|
11622
|
+
kind: z.literal("eligible"),
|
|
11623
|
+
minimumAmountCents: z.number(),
|
|
11624
|
+
maximumCustomAmountCents: z.number(),
|
|
11625
|
+
suggestedPayFullAmountCents: z.number()
|
|
11626
|
+
}),
|
|
11627
|
+
z.object({
|
|
11628
|
+
kind: z.literal("full_balance_only"),
|
|
11629
|
+
remainingBalanceCents: z.number(),
|
|
11630
|
+
reason: z.enum(["overdue", "dust_balance"])
|
|
11631
|
+
}),
|
|
11632
|
+
z.object({
|
|
11633
|
+
kind: z.literal("unavailable"),
|
|
11634
|
+
reason: z.enum([
|
|
11635
|
+
"already_settled",
|
|
11636
|
+
"payment_pending",
|
|
11637
|
+
"cancelled_due_to_non_payment",
|
|
11638
|
+
"refunded",
|
|
11639
|
+
"waived",
|
|
11640
|
+
"order_failed",
|
|
11641
|
+
"booking_cancelled",
|
|
11642
|
+
"unresolved",
|
|
11643
|
+
"below_card_minimum"
|
|
11644
|
+
])
|
|
11645
|
+
})
|
|
11646
|
+
]));
|
|
11647
|
+
|
|
11648
|
+
//#endregion
|
|
11649
|
+
//#region ../site-contracts/src/siteData/portalOrders.ts
|
|
11650
|
+
const ORDER_FILTERS = [
|
|
11651
|
+
"all",
|
|
11652
|
+
"products",
|
|
11653
|
+
"bookings",
|
|
11654
|
+
"passes",
|
|
11655
|
+
"memberships"
|
|
11656
|
+
];
|
|
11657
|
+
const orderItemSchema = exactSchema()(z.object({
|
|
11658
|
+
id: z.string(),
|
|
11659
|
+
kind: z.enum([
|
|
11660
|
+
"product",
|
|
11661
|
+
"event_ticket",
|
|
11662
|
+
"event_series_registration",
|
|
11663
|
+
"pass",
|
|
11664
|
+
"membership",
|
|
11665
|
+
"appointment"
|
|
11666
|
+
]),
|
|
11667
|
+
displayName: z.string(),
|
|
11668
|
+
quantity: z.number(),
|
|
11669
|
+
unitPriceCents: z.number(),
|
|
11670
|
+
totalCents: z.number(),
|
|
11671
|
+
refundedCents: z.number(),
|
|
11672
|
+
refundableRemainingCents: z.number()
|
|
11673
|
+
}));
|
|
11674
|
+
const orderRefundSchema = exactSchema()(z.object({
|
|
11675
|
+
id: z.string(),
|
|
11676
|
+
status: z.enum([
|
|
11677
|
+
"pending",
|
|
11678
|
+
"succeeded",
|
|
11679
|
+
"failed",
|
|
11680
|
+
"reconciliation_needed"
|
|
11681
|
+
]),
|
|
11682
|
+
amountCents: z.number(),
|
|
11683
|
+
createdAt: z.string()
|
|
11684
|
+
}));
|
|
11685
|
+
const moneyTotals = {
|
|
11686
|
+
collectedCents: z.number(),
|
|
11687
|
+
refundedCents: z.number()
|
|
11688
|
+
};
|
|
11689
|
+
const customerOrderPaymentStateSchema = exactSchema()(z.union([
|
|
11690
|
+
z.object({
|
|
11691
|
+
kind: z.literal("not_required"),
|
|
11692
|
+
reason: z.enum([
|
|
11693
|
+
"free",
|
|
11694
|
+
"waived",
|
|
11695
|
+
"pass",
|
|
11696
|
+
"membership"
|
|
11697
|
+
]),
|
|
11698
|
+
...moneyTotals,
|
|
11699
|
+
outstandingCents: z.number()
|
|
11700
|
+
}),
|
|
11701
|
+
z.object({
|
|
11702
|
+
kind: z.enum([
|
|
11703
|
+
"unpaid",
|
|
11704
|
+
"partially_paid",
|
|
11705
|
+
"collection_failed"
|
|
11706
|
+
]),
|
|
11707
|
+
...moneyTotals,
|
|
11708
|
+
outstandingCents: z.number()
|
|
11709
|
+
}),
|
|
11710
|
+
z.object({
|
|
11711
|
+
kind: z.literal("waived"),
|
|
11712
|
+
collectedCents: z.number(),
|
|
11713
|
+
waivedCents: z.number(),
|
|
11714
|
+
refundedCents: z.number(),
|
|
11715
|
+
outstandingCents: z.literal(0)
|
|
11716
|
+
}),
|
|
11717
|
+
z.object({
|
|
11718
|
+
kind: z.literal("paid"),
|
|
11719
|
+
...moneyTotals,
|
|
11720
|
+
outstandingCents: z.literal(0),
|
|
11721
|
+
settledVia: z.enum([
|
|
11722
|
+
"stripe",
|
|
11723
|
+
"store_credit",
|
|
11724
|
+
"mixed",
|
|
11725
|
+
"pass_redemption",
|
|
11726
|
+
"membership_access",
|
|
11727
|
+
"free",
|
|
11728
|
+
"manual"
|
|
11729
|
+
])
|
|
11730
|
+
}),
|
|
11731
|
+
z.object({
|
|
11732
|
+
kind: z.literal("refunded"),
|
|
11733
|
+
...moneyTotals,
|
|
11734
|
+
outstandingCents: z.number()
|
|
11735
|
+
}),
|
|
11736
|
+
z.object({
|
|
11737
|
+
kind: z.literal("cancelled"),
|
|
11738
|
+
...moneyTotals,
|
|
11739
|
+
outstandingCents: z.number()
|
|
11740
|
+
})
|
|
11741
|
+
]));
|
|
11742
|
+
const customerOrderFlexibleBalanceSchema = exactSchema()(z.object({
|
|
11743
|
+
paymentEligibility: flexibleBalancePaymentEligibilitySchema.optional(),
|
|
11744
|
+
status: flexibleBalanceContractStatusSchema,
|
|
11745
|
+
dueAt: z.string(),
|
|
11746
|
+
remainingBalanceCents: z.number(),
|
|
11747
|
+
upfrontAmountCents: z.number()
|
|
11748
|
+
}));
|
|
11749
|
+
const customerOrderPaymentLabelsSchema = exactSchema()(z.object({
|
|
11750
|
+
booking: z.string().nullable(),
|
|
11751
|
+
money: z.string(),
|
|
11752
|
+
tone: z.enum([
|
|
11753
|
+
"success",
|
|
11754
|
+
"attention",
|
|
11755
|
+
"problem",
|
|
11756
|
+
"neutral"
|
|
11757
|
+
])
|
|
11758
|
+
}));
|
|
11759
|
+
const customerOrderSchema = exactSchema()(z.object({
|
|
11760
|
+
id: z.string(),
|
|
11761
|
+
siteId: z.string(),
|
|
11762
|
+
customerId: z.string(),
|
|
11763
|
+
orderNumber: z.string(),
|
|
11764
|
+
createdAt: z.string(),
|
|
11765
|
+
status: z.enum([
|
|
11766
|
+
"pending",
|
|
11767
|
+
"paid",
|
|
11768
|
+
"partially_refunded",
|
|
11769
|
+
"refunded",
|
|
11770
|
+
"failed",
|
|
11771
|
+
"cancelled"
|
|
11772
|
+
]),
|
|
11773
|
+
paymentMethod: z.enum([
|
|
11774
|
+
"stripe",
|
|
11775
|
+
"store_credit",
|
|
11776
|
+
"mixed",
|
|
11777
|
+
"pass_redemption",
|
|
11778
|
+
"membership_access",
|
|
11779
|
+
"free",
|
|
11780
|
+
"manual",
|
|
11781
|
+
"waived"
|
|
11782
|
+
]),
|
|
11783
|
+
currency: z.string(),
|
|
11784
|
+
subtotalCents: z.number(),
|
|
11785
|
+
discountCents: z.number(),
|
|
11786
|
+
creditCents: z.number(),
|
|
11787
|
+
taxCents: z.number(),
|
|
11788
|
+
shippingCents: z.number(),
|
|
11789
|
+
paidCents: z.number(),
|
|
11790
|
+
refundedCents: z.number(),
|
|
11791
|
+
grandTotalCents: z.number(),
|
|
11792
|
+
balanceDueCents: z.number(),
|
|
11793
|
+
paymentState: customerOrderPaymentStateSchema,
|
|
11794
|
+
paymentLabels: customerOrderPaymentLabelsSchema,
|
|
11795
|
+
toDo: portalPaymentToDoSchema,
|
|
11796
|
+
instalmentPlan: orderInstalmentSummarySchema.nullable(),
|
|
11797
|
+
flexibleBalance: customerOrderFlexibleBalanceSchema.nullable(),
|
|
11798
|
+
filters: z.array(z.enum(ORDER_FILTERS)),
|
|
11799
|
+
items: z.array(orderItemSchema),
|
|
11800
|
+
refunds: z.array(orderRefundSchema)
|
|
11801
|
+
}));
|
|
11802
|
+
|
|
11803
|
+
//#endregion
|
|
11804
|
+
//#region ../site-contracts/src/siteData/portalDigitalProducts.ts
|
|
11805
|
+
const jsonValueSchema = z.lazy(() => z.union([
|
|
11806
|
+
z.string(),
|
|
11807
|
+
z.number(),
|
|
11808
|
+
z.boolean(),
|
|
11809
|
+
z.null(),
|
|
11810
|
+
z.array(jsonValueSchema),
|
|
11811
|
+
z.record(z.string(), z.optional(jsonValueSchema))
|
|
11812
|
+
]));
|
|
11813
|
+
const digitalProductBase = {
|
|
11814
|
+
entitlementId: z.string(),
|
|
11815
|
+
productId: z.string(),
|
|
11816
|
+
productTitle: z.string(),
|
|
11817
|
+
productDescription: z.nullable(jsonValueSchema),
|
|
11818
|
+
accessState: z.enum(["active", "revoked"]),
|
|
11819
|
+
revokedReason: z.string().nullable(),
|
|
11820
|
+
lastEmailSentAt: z.string().nullable()
|
|
11821
|
+
};
|
|
11822
|
+
const digitalProductFileSchema = exactSchema()(z.object({
|
|
11823
|
+
assetId: z.string(),
|
|
11824
|
+
label: z.string(),
|
|
11825
|
+
filename: z.string(),
|
|
11826
|
+
bytes: z.number().nullable(),
|
|
11827
|
+
downloadPath: z.string()
|
|
11828
|
+
}));
|
|
11829
|
+
const portalDigitalProductSchema = exactSchema()(z.discriminatedUnion("fulfillmentMode", [
|
|
11830
|
+
z.object({
|
|
11831
|
+
...digitalProductBase,
|
|
11832
|
+
fulfillmentMode: z.literal("email")
|
|
11833
|
+
}),
|
|
11834
|
+
z.object({
|
|
11835
|
+
...digitalProductBase,
|
|
11836
|
+
fulfillmentMode: z.literal("guarded_url"),
|
|
11837
|
+
accessPath: z.string()
|
|
11838
|
+
}),
|
|
11839
|
+
z.object({
|
|
11840
|
+
...digitalProductBase,
|
|
11841
|
+
fulfillmentMode: z.literal("file_download"),
|
|
11842
|
+
accessPath: z.string(),
|
|
11843
|
+
files: z.array(digitalProductFileSchema)
|
|
11844
|
+
})
|
|
11845
|
+
]));
|
|
11846
|
+
|
|
11847
|
+
//#endregion
|
|
11848
|
+
//#region ../site-contracts/src/siteData/portalWaitlists.ts
|
|
11849
|
+
const customerPortalWaitlistSubjectSchema = exactSchema()(z.discriminatedUnion("kind", [z.object({
|
|
11850
|
+
kind: z.literal("occurrence"),
|
|
11851
|
+
occurrenceId: z.string(),
|
|
11852
|
+
eventSeriesId: z.string(),
|
|
11853
|
+
startsAt: z.string(),
|
|
11854
|
+
endsAt: z.string(),
|
|
11855
|
+
timeZone: z.string(),
|
|
11856
|
+
isOnline: z.boolean()
|
|
11857
|
+
}), z.object({
|
|
11858
|
+
kind: z.literal("wholeSeries"),
|
|
11859
|
+
timeZone: z.string(),
|
|
11860
|
+
isOnline: z.boolean(),
|
|
11861
|
+
eventSeriesId: z.string(),
|
|
11862
|
+
scheduleSummary: z.string().nullable()
|
|
11863
|
+
})]));
|
|
11864
|
+
const OFFER_PRICE_KINDS = [
|
|
11865
|
+
"total",
|
|
11866
|
+
"free",
|
|
11867
|
+
"chosen_at_booking",
|
|
11868
|
+
"not_known"
|
|
11869
|
+
];
|
|
11870
|
+
const knownOfferPriceSchema = z.discriminatedUnion("kind", [
|
|
11871
|
+
z.object({
|
|
11872
|
+
kind: z.literal("total"),
|
|
11873
|
+
amount: z.object({
|
|
11874
|
+
amountCents: z.number(),
|
|
11875
|
+
currency: z.string()
|
|
11876
|
+
})
|
|
11877
|
+
}),
|
|
11878
|
+
z.object({ kind: z.literal("free") }),
|
|
11879
|
+
z.object({ kind: z.literal("chosen_at_booking") }),
|
|
11880
|
+
z.object({ kind: z.literal("not_known") })
|
|
11881
|
+
]);
|
|
11882
|
+
/** A kind this build doesn't know reads as not known, never as a failed list. */
|
|
11883
|
+
const unknownOfferPriceSchema = z.object({ kind: z.string().refine((kind) => !OFFER_PRICE_KINDS.includes(kind), "a known price failed to decode") }).transform(() => ({ kind: "not_known" }));
|
|
11884
|
+
const portalWaitlistOfferPriceSchema = evolvingSchema()(z.union([knownOfferPriceSchema, unknownOfferPriceSchema]));
|
|
11885
|
+
const waitlistEntryBase = {
|
|
11886
|
+
id: z.string(),
|
|
11887
|
+
subject: customerPortalWaitlistSubjectSchema,
|
|
11888
|
+
eventTitle: z.string(),
|
|
11889
|
+
eventPath: z.string().nullable(),
|
|
11890
|
+
requestedPlaces: z.number(),
|
|
11891
|
+
joinedAt: z.string()
|
|
11892
|
+
};
|
|
11893
|
+
const customerPortalWaitlistEntrySchema = exactSchema()(z.discriminatedUnion("status", [
|
|
11894
|
+
z.object({
|
|
11895
|
+
...waitlistEntryBase,
|
|
11896
|
+
status: z.literal("waiting"),
|
|
11897
|
+
queuePosition: z.number().nullable(),
|
|
11898
|
+
canLeave: z.literal(true)
|
|
11899
|
+
}),
|
|
11900
|
+
z.object({
|
|
11901
|
+
...waitlistEntryBase,
|
|
11902
|
+
status: z.literal("placeAvailable"),
|
|
11903
|
+
claimExpiresAt: z.string(),
|
|
11904
|
+
claimPath: z.string().nullable(),
|
|
11905
|
+
offerPrice: portalWaitlistOfferPriceSchema,
|
|
11906
|
+
canLeave: z.literal(true)
|
|
11907
|
+
}),
|
|
11908
|
+
z.object({
|
|
11909
|
+
...waitlistEntryBase,
|
|
11910
|
+
status: z.literal("offerExpired"),
|
|
11911
|
+
claimExpiredAt: z.string(),
|
|
11912
|
+
canLeave: z.literal(false)
|
|
11913
|
+
})
|
|
11914
|
+
]));
|
|
11915
|
+
|
|
11916
|
+
//#endregion
|
|
11917
|
+
//#region ../site-contracts/src/siteData/portalRegularSessions.ts
|
|
11918
|
+
const weekdaySchema = z.literal([
|
|
11919
|
+
0,
|
|
11920
|
+
1,
|
|
11921
|
+
2,
|
|
11922
|
+
3,
|
|
11923
|
+
4,
|
|
11924
|
+
5,
|
|
11925
|
+
6
|
|
11926
|
+
]);
|
|
11927
|
+
const portalRegularSessionCadenceSchema = exactSchema()(z.discriminatedUnion("kind", [z.object({
|
|
11928
|
+
kind: z.literal("weekly"),
|
|
11929
|
+
everyWeeks: z.literal([1, 2]),
|
|
11930
|
+
weekday: weekdaySchema
|
|
11931
|
+
}), z.object({
|
|
11932
|
+
kind: z.literal("monthly"),
|
|
11933
|
+
weekday: weekdaySchema,
|
|
11934
|
+
nth: z.literal([
|
|
11935
|
+
1,
|
|
11936
|
+
2,
|
|
11937
|
+
3,
|
|
11938
|
+
4,
|
|
11939
|
+
"last"
|
|
11940
|
+
])
|
|
11941
|
+
})]));
|
|
11942
|
+
const dateSchema = exactSchema()(z.union([
|
|
11943
|
+
z.object({
|
|
11944
|
+
state: z.literal("booked"),
|
|
11945
|
+
occurrence: z.string(),
|
|
11946
|
+
appointmentId: brandedId(parseAppointmentId, "appointment id"),
|
|
11947
|
+
startAt: z.string(),
|
|
11948
|
+
endAt: z.string()
|
|
11949
|
+
}),
|
|
11950
|
+
z.object({
|
|
11951
|
+
state: z.enum([
|
|
11952
|
+
"held",
|
|
11953
|
+
"open",
|
|
11954
|
+
"trainer_away"
|
|
11955
|
+
]),
|
|
11956
|
+
occurrence: z.string(),
|
|
11957
|
+
startAt: z.string(),
|
|
11958
|
+
endAt: z.string()
|
|
11959
|
+
}),
|
|
11960
|
+
z.object({
|
|
11961
|
+
state: z.literal("away"),
|
|
11962
|
+
occurrence: z.string()
|
|
11963
|
+
})
|
|
11964
|
+
]));
|
|
11965
|
+
const portalRegularSessionSchema = exactSchema()(z.object({
|
|
11966
|
+
arrangementId: brandedId(parseClientArrangementId, "regular sessions id"),
|
|
11967
|
+
timezone: z.string(),
|
|
11968
|
+
schedule: z.object({
|
|
11969
|
+
effectiveFrom: z.string(),
|
|
11970
|
+
cadence: portalRegularSessionCadenceSchema,
|
|
11971
|
+
localStart: z.string()
|
|
11972
|
+
}),
|
|
11973
|
+
trainerName: z.string().nullable(),
|
|
11974
|
+
serviceName: z.string().nullable(),
|
|
11975
|
+
holdsTime: z.boolean(),
|
|
11976
|
+
payment: z.union([z.object({
|
|
11977
|
+
kind: z.literal("package"),
|
|
11978
|
+
name: z.string().nullable(),
|
|
11979
|
+
sessionsLeft: z.number()
|
|
11980
|
+
}), z.object({ kind: z.enum(["owed", "payment_link"]) })]),
|
|
11981
|
+
dates: z.array(dateSchema).readonly()
|
|
11982
|
+
}));
|
|
11983
|
+
const portalRegularSessionsResponseSchema = exactSchema()(z.object({ arrangements: z.array(portalRegularSessionSchema).readonly() }));
|
|
11984
|
+
|
|
11985
|
+
//#endregion
|
|
11986
|
+
//#region ../site-contracts/src/siteData/portalBookings.ts
|
|
11987
|
+
/**
|
|
11988
|
+
* One booking model for the customer portal, from GET /api/portal/bookings and
|
|
11989
|
+
* GET /api/portal/bookings/{kind}/{id}. Every kind shares the fields a card and
|
|
11990
|
+
* a booking page need, and its own extras ride in `detail`. The server decides
|
|
11991
|
+
* every fact and action here, including whether the booking is over; the
|
|
11992
|
+
* portal only words them.
|
|
11993
|
+
*
|
|
11994
|
+
* Wire evolution (pinned SDK clients): decoding is strict for the variants
|
|
11995
|
+
* this build knows. Three points are extensible, and a value a newer server
|
|
11996
|
+
* adds there decodes to a closed `unsupported` state instead of failing the
|
|
11997
|
+
* page: the booking kind (the booking still shows, with nothing to act on), an
|
|
11998
|
+
* action's state (the action is disabled), and the money a cancellation would
|
|
11999
|
+
* return (cancel is disabled, so the portal never guesses a refund).
|
|
12000
|
+
* Explanations of why an action isn't offered come from the server as text,
|
|
12001
|
+
* so new reasons need no client change.
|
|
12002
|
+
*/
|
|
12003
|
+
const PORTAL_BOOKING_KINDS = [
|
|
12004
|
+
"event",
|
|
12005
|
+
"course",
|
|
12006
|
+
"appointment"
|
|
12007
|
+
];
|
|
12008
|
+
/** The one map from a booking's reference to its URL words. */
|
|
12009
|
+
function portalBookingPath(ref) {
|
|
12010
|
+
return {
|
|
12011
|
+
kind: portalBookingKind(ref),
|
|
12012
|
+
bookingId: bookingContextId(ref)
|
|
12013
|
+
};
|
|
12014
|
+
}
|
|
12015
|
+
function portalBookingKind(ref) {
|
|
12016
|
+
switch (ref.tag) {
|
|
12017
|
+
case "event_attendee": return "event";
|
|
12018
|
+
case "event_series_registration": return "course";
|
|
12019
|
+
case "appointment": return "appointment";
|
|
12020
|
+
}
|
|
12021
|
+
}
|
|
12022
|
+
function brandedBookingId(parse$1) {
|
|
12023
|
+
return z.string().transform((value, ctx) => {
|
|
12024
|
+
const parsed = parse$1(value);
|
|
12025
|
+
if (parsed.ok) return parsed.value;
|
|
12026
|
+
ctx.addIssue({
|
|
12027
|
+
code: "custom",
|
|
12028
|
+
message: "Invalid booking ID"
|
|
12029
|
+
});
|
|
12030
|
+
return z.NEVER;
|
|
12031
|
+
});
|
|
12032
|
+
}
|
|
12033
|
+
/**
|
|
12034
|
+
* The URL words back to the booking's reference, refusing anything that isn't
|
|
12035
|
+
* a real id of that kind. The route's params, the client router and
|
|
12036
|
+
* `parsePortalBookingRef` all read bookings through this.
|
|
12037
|
+
*/
|
|
12038
|
+
const portalBookingPathSchema = z.union([
|
|
12039
|
+
z.object({
|
|
12040
|
+
kind: z.literal("event"),
|
|
12041
|
+
bookingId: brandedBookingId(parseAttendeeId)
|
|
12042
|
+
}).transform(({ bookingId }) => ({
|
|
12043
|
+
tag: "event_attendee",
|
|
12044
|
+
attendeeId: bookingId
|
|
12045
|
+
})),
|
|
12046
|
+
z.object({
|
|
12047
|
+
kind: z.literal("course"),
|
|
12048
|
+
bookingId: brandedBookingId(parseEventSeriesRegistrationId)
|
|
12049
|
+
}).transform(({ bookingId }) => ({
|
|
12050
|
+
tag: "event_series_registration",
|
|
12051
|
+
registrationId: bookingId
|
|
12052
|
+
})),
|
|
12053
|
+
z.object({
|
|
12054
|
+
kind: z.literal("appointment"),
|
|
12055
|
+
bookingId: brandedBookingId(parseAppointmentId)
|
|
12056
|
+
}).transform(({ bookingId }) => ({
|
|
12057
|
+
tag: "appointment",
|
|
12058
|
+
appointmentId: bookingId
|
|
12059
|
+
}))
|
|
12060
|
+
]);
|
|
12061
|
+
/** Past bookings sent when the query names no limit, and the most one page may ask for. */
|
|
12062
|
+
const PORTAL_PAST_PAGE_DEFAULT = 10;
|
|
12063
|
+
const PORTAL_PAST_PAGE_MAX = 50;
|
|
12064
|
+
/** The listed values must cover the union, so a new member here is a compile error, not a silent fallback. */
|
|
12065
|
+
function allOf() {
|
|
12066
|
+
return (values) => values;
|
|
12067
|
+
}
|
|
12068
|
+
const unsupported$1 = (known) => unknownKind(known).transform(() => ({ kind: "unsupported" }));
|
|
12069
|
+
const whenSchema = exactSchema()(z.object({
|
|
12070
|
+
startsAt: z.string(),
|
|
12071
|
+
endsAt: z.string().nullable(),
|
|
12072
|
+
timeZone: z.string()
|
|
12073
|
+
}));
|
|
12074
|
+
const venueSchema = exactSchema()(z.object({
|
|
12075
|
+
name: z.string().nullable(),
|
|
12076
|
+
address: z.discriminatedUnion("kind", [
|
|
12077
|
+
z.object({
|
|
12078
|
+
kind: z.literal("shown"),
|
|
12079
|
+
address: z.string().nullable(),
|
|
12080
|
+
doorNote: z.string().nullable(),
|
|
12081
|
+
directions: z.string().nullable()
|
|
12082
|
+
}),
|
|
12083
|
+
z.object({
|
|
12084
|
+
kind: z.literal("after_booking"),
|
|
12085
|
+
area: z.string().nullable()
|
|
12086
|
+
}),
|
|
12087
|
+
z.object({ kind: z.literal("not_given") })
|
|
12088
|
+
])
|
|
12089
|
+
}));
|
|
12090
|
+
const whereSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12091
|
+
z.object({
|
|
12092
|
+
kind: z.literal("venue"),
|
|
12093
|
+
venue: venueSchema
|
|
12094
|
+
}),
|
|
12095
|
+
z.object({
|
|
12096
|
+
kind: z.literal("online"),
|
|
12097
|
+
joining: portalJoiningDetailsSchema.nullable()
|
|
12098
|
+
}),
|
|
12099
|
+
z.object({
|
|
12100
|
+
kind: z.literal("hybrid"),
|
|
12101
|
+
venue: venueSchema,
|
|
12102
|
+
joining: portalJoiningDetailsSchema.nullable()
|
|
12103
|
+
}),
|
|
12104
|
+
z.object({ kind: z.literal("not_given") })
|
|
12105
|
+
]));
|
|
12106
|
+
const standingSchema$1 = exactSchema()(z.discriminatedUnion("kind", [
|
|
12107
|
+
z.object({ kind: z.literal("booked") }),
|
|
12108
|
+
z.object({ kind: z.literal("awaiting_payment") }),
|
|
12109
|
+
z.object({ kind: z.literal("requested") }),
|
|
12110
|
+
z.object({
|
|
12111
|
+
kind: z.literal("waitlisted"),
|
|
12112
|
+
position: z.number().nullable()
|
|
12113
|
+
}),
|
|
12114
|
+
z.object({ kind: z.literal("cancelled") }),
|
|
12115
|
+
z.object({
|
|
12116
|
+
kind: z.literal("request_not_accepted"),
|
|
12117
|
+
outcome: z.enum([
|
|
12118
|
+
"declined",
|
|
12119
|
+
"lapsed",
|
|
12120
|
+
"withdrawn"
|
|
12121
|
+
])
|
|
12122
|
+
}),
|
|
12123
|
+
z.object({ kind: z.literal("missed") }),
|
|
12124
|
+
z.object({ kind: z.literal("given_away") })
|
|
12125
|
+
]));
|
|
12126
|
+
const peopleSchema = exactSchema()(z.object({
|
|
12127
|
+
places: z.number(),
|
|
12128
|
+
guests: z.array(z.object({
|
|
12129
|
+
place: z.number(),
|
|
12130
|
+
name: z.string().nullable(),
|
|
12131
|
+
email: z.string().nullable(),
|
|
12132
|
+
phone: z.string().nullable()
|
|
12133
|
+
})).readonly(),
|
|
12134
|
+
namesMissing: z.number()
|
|
12135
|
+
}));
|
|
12136
|
+
const ticketLineSchema = exactSchema()(z.object({
|
|
12137
|
+
label: z.string(),
|
|
12138
|
+
quantity: z.number(),
|
|
12139
|
+
unitPrice: portalMoneySchema.nullable()
|
|
12140
|
+
}));
|
|
12141
|
+
const orderSchema = exactSchema()(z.object({
|
|
12142
|
+
orderId: z.string(),
|
|
12143
|
+
orderNumber: z.string(),
|
|
12144
|
+
total: portalMoneySchema,
|
|
12145
|
+
paidWithCredit: portalMoneySchema.nullable(),
|
|
12146
|
+
paidSoFar: portalMoneySchema,
|
|
12147
|
+
paymentLabels: customerOrderPaymentLabelsSchema,
|
|
12148
|
+
toDo: portalPaymentToDoSchema,
|
|
12149
|
+
bookingCount: z.number().int().positive()
|
|
12150
|
+
}));
|
|
12151
|
+
const paymentSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12152
|
+
z.object({ kind: z.literal("free") }),
|
|
12153
|
+
z.object({ kind: z.literal("not_decided") }),
|
|
12154
|
+
z.object({
|
|
12155
|
+
kind: z.literal("pass"),
|
|
12156
|
+
pass: z.object({
|
|
12157
|
+
customerPassId: z.string(),
|
|
12158
|
+
name: z.string(),
|
|
12159
|
+
useCase: customerPassUseCaseSchema,
|
|
12160
|
+
creditsRemaining: z.number(),
|
|
12161
|
+
expiresAt: z.string().nullable()
|
|
12162
|
+
}).nullable()
|
|
12163
|
+
}),
|
|
12164
|
+
z.object({
|
|
12165
|
+
kind: z.literal("membership"),
|
|
12166
|
+
membership: z.object({
|
|
12167
|
+
customerMembershipId: z.string(),
|
|
12168
|
+
name: z.string(),
|
|
12169
|
+
status: customerMembershipStatusSchema
|
|
12170
|
+
}).nullable()
|
|
12171
|
+
}),
|
|
12172
|
+
z.object({
|
|
12173
|
+
kind: z.literal("order"),
|
|
12174
|
+
order: orderSchema
|
|
12175
|
+
}),
|
|
12176
|
+
z.object({
|
|
12177
|
+
kind: z.literal("owed"),
|
|
12178
|
+
amount: portalMoneySchema.nullable()
|
|
12179
|
+
}),
|
|
12180
|
+
z.object({ kind: z.literal("unavailable") })
|
|
12181
|
+
]));
|
|
12182
|
+
const ACTION_KINDS = allOf()([
|
|
12183
|
+
"available",
|
|
12184
|
+
"closed",
|
|
12185
|
+
"not_offered"
|
|
12186
|
+
]);
|
|
12187
|
+
const closedActionSchema = z.object({
|
|
12188
|
+
kind: z.literal("closed"),
|
|
12189
|
+
closedAt: z.string()
|
|
12190
|
+
});
|
|
12191
|
+
const notOfferedActionSchema = z.object({
|
|
12192
|
+
kind: z.literal("not_offered"),
|
|
12193
|
+
explanation: z.string().nullable()
|
|
12194
|
+
});
|
|
12195
|
+
const knownActionSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12196
|
+
z.object({
|
|
12197
|
+
kind: z.literal("available"),
|
|
12198
|
+
until: z.string().nullable()
|
|
12199
|
+
}),
|
|
12200
|
+
closedActionSchema,
|
|
12201
|
+
notOfferedActionSchema
|
|
12202
|
+
]));
|
|
12203
|
+
const portalBookingActionSchema = evolvingSchema()(z.union([knownActionSchema, unsupported$1(ACTION_KINDS)]));
|
|
12204
|
+
const RESCHEDULE_KINDS = allOf()([
|
|
12205
|
+
"available",
|
|
12206
|
+
"closed",
|
|
12207
|
+
"not_offered",
|
|
12208
|
+
"single_run"
|
|
12209
|
+
]);
|
|
12210
|
+
const knownRescheduleSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12211
|
+
z.object({
|
|
12212
|
+
kind: z.literal("available"),
|
|
12213
|
+
until: z.string().nullable()
|
|
12214
|
+
}),
|
|
12215
|
+
closedActionSchema,
|
|
12216
|
+
notOfferedActionSchema,
|
|
12217
|
+
z.object({ kind: z.literal("single_run") })
|
|
12218
|
+
]));
|
|
12219
|
+
/** An event's reschedule: a reason this build doesn't know decodes to `unsupported`, as every action's does. */
|
|
12220
|
+
const portalRescheduleActionSchema = evolvingSchema()(z.union([knownRescheduleSchema, unsupported$1(RESCHEDULE_KINDS)]));
|
|
12221
|
+
const MONEY_KINDS = allOf()([
|
|
12222
|
+
"nothing_to_return",
|
|
12223
|
+
"refund",
|
|
12224
|
+
"credit_back",
|
|
12225
|
+
"keep_money",
|
|
12226
|
+
"keep_credit",
|
|
12227
|
+
"contact_business",
|
|
12228
|
+
"not_known"
|
|
12229
|
+
]);
|
|
12230
|
+
const cancelMoneySchema = exactSchema()(z.union([cancellationMoneyOutcomeSchema, z.object({ kind: z.literal("not_known") })]));
|
|
12231
|
+
const knownCancelSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12232
|
+
z.object({
|
|
12233
|
+
kind: z.literal("available"),
|
|
12234
|
+
until: z.string().nullable(),
|
|
12235
|
+
money: cancelMoneySchema,
|
|
12236
|
+
recipient: refundRecipientSchema,
|
|
12237
|
+
termsApply: z.boolean()
|
|
12238
|
+
}),
|
|
12239
|
+
closedActionSchema,
|
|
12240
|
+
notOfferedActionSchema
|
|
12241
|
+
]));
|
|
12242
|
+
/** Open, but with money this build can't read: cancel is withheld rather than offered without its outcome. */
|
|
12243
|
+
const cancelWithUnknownMoney = z.object({
|
|
12244
|
+
kind: z.literal("available"),
|
|
12245
|
+
money: unknownKind(MONEY_KINDS)
|
|
12246
|
+
}).transform(() => ({ kind: "unsupported" }));
|
|
12247
|
+
const portalCancelActionSchema = evolvingSchema()(z.union([
|
|
12248
|
+
knownCancelSchema,
|
|
12249
|
+
cancelWithUnknownMoney,
|
|
12250
|
+
unsupported$1(ACTION_KINDS)
|
|
12251
|
+
]));
|
|
12252
|
+
const sharedActionsShape = {
|
|
12253
|
+
cancel: portalCancelActionSchema,
|
|
12254
|
+
rebook: portalBookingActionSchema,
|
|
12255
|
+
editGuests: portalBookingActionSchema,
|
|
12256
|
+
showTicket: portalBookingActionSchema
|
|
12257
|
+
};
|
|
12258
|
+
const eventActionsSchema = evolvingSchema()(z.object({
|
|
12259
|
+
...sharedActionsShape,
|
|
12260
|
+
transfer: portalBookingActionSchema,
|
|
12261
|
+
reschedule: portalRescheduleActionSchema
|
|
12262
|
+
}));
|
|
12263
|
+
const courseActionsSchema = evolvingSchema()(z.object(sharedActionsShape));
|
|
12264
|
+
const appointmentActionsSchema = evolvingSchema()(z.object({
|
|
12265
|
+
...sharedActionsShape,
|
|
12266
|
+
reschedule: portalBookingActionSchema
|
|
12267
|
+
}));
|
|
12268
|
+
const baseShape = {
|
|
12269
|
+
title: z.string(),
|
|
12270
|
+
timing: z.enum(["upcoming", "over"]),
|
|
12271
|
+
where: whereSchema,
|
|
12272
|
+
standing: standingSchema$1,
|
|
12273
|
+
bookedAt: z.string().nullable(),
|
|
12274
|
+
people: peopleSchema,
|
|
12275
|
+
questions: portalBeforeYouComeTaskSchema.nullable(),
|
|
12276
|
+
payment: paymentSchema
|
|
12277
|
+
};
|
|
12278
|
+
const eventDetailSchema = exactSchema()(z.object({
|
|
12279
|
+
occurrenceId: z.string(),
|
|
12280
|
+
seriesName: z.string().nullable(),
|
|
12281
|
+
eventPath: z.string().nullable(),
|
|
12282
|
+
occurrencePath: z.string().nullable(),
|
|
12283
|
+
ticketLines: z.array(ticketLineSchema).readonly(),
|
|
12284
|
+
transfer: z.discriminatedUnion("kind", [
|
|
12285
|
+
z.object({ kind: z.literal("none") }),
|
|
12286
|
+
z.object({
|
|
12287
|
+
kind: z.literal("received"),
|
|
12288
|
+
from: z.string().nullable(),
|
|
12289
|
+
at: z.string().nullable()
|
|
12290
|
+
}),
|
|
12291
|
+
z.object({
|
|
12292
|
+
kind: z.literal("given"),
|
|
12293
|
+
to: z.string().nullable(),
|
|
12294
|
+
at: z.string().nullable()
|
|
12295
|
+
})
|
|
12296
|
+
]),
|
|
12297
|
+
rooms: z.array(z.object({
|
|
12298
|
+
name: z.string(),
|
|
12299
|
+
sleeps: z.number(),
|
|
12300
|
+
bookedAs: z.enum(["private", "shared"]),
|
|
12301
|
+
people: z.array(z.string()).readonly()
|
|
12302
|
+
})).readonly(),
|
|
12303
|
+
guestNamesRequired: z.boolean()
|
|
12304
|
+
}));
|
|
12305
|
+
const courseDetailSchema = exactSchema()(z.object({
|
|
12306
|
+
eventPath: z.string().nullable(),
|
|
12307
|
+
sessions: z.array(whenSchema).readonly(),
|
|
12308
|
+
nextSessionAt: z.string().nullable(),
|
|
12309
|
+
ticketLines: z.array(ticketLineSchema).readonly()
|
|
12310
|
+
}));
|
|
12311
|
+
const appointmentDetailSchema = exactSchema()(z.object({
|
|
12312
|
+
serviceName: z.string(),
|
|
12313
|
+
serviceId: z.string(),
|
|
12314
|
+
resourceId: z.string().nullable(),
|
|
12315
|
+
withName: z.string().nullable(),
|
|
12316
|
+
request: z.object({
|
|
12317
|
+
requestedAt: z.string().nullable(),
|
|
12318
|
+
decidedAt: z.string().nullable()
|
|
12319
|
+
}).nullable(),
|
|
12320
|
+
regularSession: z.object({
|
|
12321
|
+
cadence: portalRegularSessionCadenceSchema,
|
|
12322
|
+
localStart: z.string()
|
|
12323
|
+
}).nullable()
|
|
12324
|
+
}));
|
|
12325
|
+
const knownBookingSchema = evolvingSchema()(z.discriminatedUnion("kind", [
|
|
12326
|
+
z.object({
|
|
12327
|
+
kind: z.literal("event"),
|
|
12328
|
+
ref: eventAttendeeRefSchema,
|
|
12329
|
+
...baseShape,
|
|
12330
|
+
when: whenSchema,
|
|
12331
|
+
actions: eventActionsSchema,
|
|
12332
|
+
detail: eventDetailSchema
|
|
12333
|
+
}),
|
|
12334
|
+
z.object({
|
|
12335
|
+
kind: z.literal("course"),
|
|
12336
|
+
ref: courseRegistrationRefSchema,
|
|
12337
|
+
...baseShape,
|
|
12338
|
+
when: whenSchema.nullable(),
|
|
12339
|
+
actions: courseActionsSchema,
|
|
12340
|
+
detail: courseDetailSchema
|
|
12341
|
+
}),
|
|
12342
|
+
z.object({
|
|
12343
|
+
kind: z.literal("appointment"),
|
|
12344
|
+
ref: appointmentRefSchema,
|
|
12345
|
+
...baseShape,
|
|
12346
|
+
when: whenSchema,
|
|
12347
|
+
actions: appointmentActionsSchema,
|
|
12348
|
+
detail: appointmentDetailSchema
|
|
12349
|
+
})
|
|
12350
|
+
]));
|
|
12351
|
+
/** A newer kind's reference, read only far enough to key the card on it. */
|
|
12352
|
+
const unknownRefKey = z.record(z.string(), z.unknown()).catch({}).transform((ref) => Object.values(ref).filter((value) => typeof value === "string").join(":"));
|
|
12353
|
+
const unsupportedBookingSchema = unknownKind(PORTAL_BOOKING_KINDS).extend({
|
|
12354
|
+
title: z.string(),
|
|
12355
|
+
when: whenSchema.nullable().catch(null),
|
|
12356
|
+
ref: unknownRefKey
|
|
12357
|
+
}).transform((booking) => ({
|
|
12358
|
+
kind: "unsupported",
|
|
12359
|
+
key: `${booking.kind}:${booking.ref}`,
|
|
12360
|
+
title: booking.title,
|
|
12361
|
+
when: booking.when
|
|
12362
|
+
}));
|
|
12363
|
+
const portalBookingViewSchema = evolvingSchema()(z.union([knownBookingSchema, unsupportedBookingSchema]));
|
|
12364
|
+
const portalBookingsResponseSchema = evolvingSchema()(z.object({
|
|
12365
|
+
waitlist: z.array(customerPortalWaitlistEntrySchema).readonly(),
|
|
12366
|
+
comingUp: z.array(portalBookingViewSchema).readonly(),
|
|
12367
|
+
cancelled: z.array(portalBookingViewSchema).readonly(),
|
|
12368
|
+
past: z.array(portalBookingViewSchema).readonly(),
|
|
12369
|
+
nextPastCursor: z.string().nullable()
|
|
12370
|
+
}));
|
|
12371
|
+
const portalBookingResponseSchema = evolvingSchema()(z.object({ booking: knownBookingSchema }));
|
|
12372
|
+
|
|
12373
|
+
//#endregion
|
|
12374
|
+
//#region ../site-contracts/src/siteData/portalHome.ts
|
|
12375
|
+
const TASK_KINDS = [
|
|
12376
|
+
"answer_questions",
|
|
12377
|
+
"add_guest_names",
|
|
12378
|
+
"take_waitlist_place",
|
|
12379
|
+
"pay",
|
|
12380
|
+
"membership_payment_failed"
|
|
12381
|
+
];
|
|
12382
|
+
const deadlineSchema = portalDeadlineSchema;
|
|
12383
|
+
const BOOKING_REF_TAGS = [
|
|
12384
|
+
"appointment",
|
|
12385
|
+
"event_attendee",
|
|
12386
|
+
"event_series_registration"
|
|
12387
|
+
];
|
|
12388
|
+
const portalBookingRefViewSchema = evolvingSchema()(z.union([bookingContextRefSchema, unknownTag(BOOKING_REF_TAGS).transform(() => ({ kind: "unsupported" }))]));
|
|
12389
|
+
const PAYMENT_FOR_KINDS = ["booking", "order"];
|
|
12390
|
+
const portalPaymentForViewSchema = evolvingSchema()(z.union([
|
|
12391
|
+
z.object({
|
|
12392
|
+
kind: z.literal("booking"),
|
|
12393
|
+
ref: portalBookingRefViewSchema,
|
|
12394
|
+
title: z.string()
|
|
12395
|
+
}),
|
|
12396
|
+
z.object({
|
|
12397
|
+
kind: z.literal("order"),
|
|
12398
|
+
order: portalOrderNameSchema
|
|
12399
|
+
}),
|
|
12400
|
+
unknownKind(PAYMENT_FOR_KINDS).transform(() => ({ kind: "unsupported" }))
|
|
12401
|
+
]));
|
|
12402
|
+
const taskBase = {
|
|
12403
|
+
key: z.string(),
|
|
12404
|
+
urgent: z.boolean()
|
|
12405
|
+
};
|
|
12406
|
+
const knownTaskSchema = evolvingSchema()(z.discriminatedUnion("kind", [
|
|
12407
|
+
z.object({
|
|
12408
|
+
...taskBase,
|
|
12409
|
+
kind: z.literal("answer_questions"),
|
|
12410
|
+
ref: portalBookingRefViewSchema,
|
|
12411
|
+
bookingTitle: z.string(),
|
|
12412
|
+
deadline: deadlineSchema
|
|
12413
|
+
}),
|
|
12414
|
+
z.object({
|
|
12415
|
+
...taskBase,
|
|
12416
|
+
kind: z.literal("add_guest_names"),
|
|
12417
|
+
ref: eventAttendeeRefSchema,
|
|
12418
|
+
bookingTitle: z.string(),
|
|
12419
|
+
startsAt: z.string(),
|
|
12420
|
+
timeZone: z.string(),
|
|
12421
|
+
namesMissing: z.number()
|
|
12422
|
+
}),
|
|
12423
|
+
z.object({
|
|
12424
|
+
...taskBase,
|
|
12425
|
+
kind: z.literal("take_waitlist_place"),
|
|
12426
|
+
entryId: z.string(),
|
|
12427
|
+
eventTitle: z.string(),
|
|
12428
|
+
requestedPlaces: z.number(),
|
|
12429
|
+
claimExpiresAt: z.string(),
|
|
12430
|
+
claimPath: z.string().nullable(),
|
|
12431
|
+
offerPrice: portalWaitlistOfferPriceSchema
|
|
12432
|
+
}),
|
|
12433
|
+
z.object({
|
|
12434
|
+
...taskBase,
|
|
12435
|
+
kind: z.literal("pay"),
|
|
12436
|
+
orderId: z.string(),
|
|
12437
|
+
for: portalPaymentForViewSchema,
|
|
12438
|
+
due: portalPaymentDueSchema,
|
|
12439
|
+
moneyLine: z.string()
|
|
12440
|
+
}),
|
|
12441
|
+
z.object({
|
|
12442
|
+
...taskBase,
|
|
12443
|
+
kind: z.literal("membership_payment_failed"),
|
|
12444
|
+
customerMembershipId: z.string(),
|
|
12445
|
+
membershipName: z.string(),
|
|
12446
|
+
failed: portalMoneySchema.nullable(),
|
|
12447
|
+
overdueSince: z.string().nullable(),
|
|
12448
|
+
nextAttemptAt: z.string().nullable()
|
|
12449
|
+
})
|
|
12450
|
+
]));
|
|
12451
|
+
const unsupportedTaskSchema = unknownKind(TASK_KINDS).extend({
|
|
12452
|
+
key: z.string(),
|
|
12453
|
+
urgent: z.boolean().catch(false)
|
|
12454
|
+
}).transform((task) => ({
|
|
12455
|
+
kind: "unsupported",
|
|
12456
|
+
key: task.key,
|
|
12457
|
+
urgent: task.urgent
|
|
12458
|
+
}));
|
|
12459
|
+
const portalTaskViewSchema = evolvingSchema()(z.union([knownTaskSchema, unsupportedTaskSchema]));
|
|
12460
|
+
const taskSourceSchema = exactSchema()(z.enum([
|
|
12461
|
+
"bookings",
|
|
12462
|
+
"questions",
|
|
12463
|
+
"payments",
|
|
12464
|
+
"memberships"
|
|
12465
|
+
]));
|
|
12466
|
+
const portalTaskListSchema = evolvingSchema()(z.discriminatedUnion("kind", [z.object({
|
|
12467
|
+
kind: z.literal("checked"),
|
|
12468
|
+
tasks: z.array(portalTaskViewSchema).readonly()
|
|
12469
|
+
}), z.object({
|
|
12470
|
+
kind: z.literal("partly_checked"),
|
|
12471
|
+
tasks: z.array(portalTaskViewSchema).readonly(),
|
|
12472
|
+
unchecked: z.array(taskSourceSchema).readonly()
|
|
12473
|
+
})]));
|
|
12474
|
+
const notChecked$3 = z.object({ kind: z.literal("not_checked") });
|
|
12475
|
+
const comingUpSchema = evolvingSchema()(z.discriminatedUnion("kind", [z.object({
|
|
12476
|
+
kind: z.literal("shown"),
|
|
12477
|
+
next: z.array(portalBookingViewSchema).readonly(),
|
|
12478
|
+
total: z.number()
|
|
12479
|
+
}), notChecked$3]));
|
|
12480
|
+
const summariesSchema = exactSchema()(z.object({
|
|
12481
|
+
bookings: z.discriminatedUnion("kind", [z.object({
|
|
12482
|
+
kind: z.literal("shown"),
|
|
12483
|
+
comingUp: z.number(),
|
|
12484
|
+
placesOffered: z.number()
|
|
12485
|
+
}), notChecked$3]),
|
|
12486
|
+
passes: z.discriminatedUnion("kind", [z.object({
|
|
12487
|
+
kind: z.literal("shown"),
|
|
12488
|
+
passes: z.array(z.object({
|
|
12489
|
+
name: z.string(),
|
|
12490
|
+
useCase: customerPassUseCaseSchema,
|
|
12491
|
+
creditsRemaining: z.number()
|
|
12492
|
+
})).readonly(),
|
|
12493
|
+
memberships: z.array(z.object({
|
|
12494
|
+
name: z.string(),
|
|
12495
|
+
paymentFailed: z.boolean()
|
|
12496
|
+
})).readonly()
|
|
12497
|
+
}), notChecked$3]),
|
|
12498
|
+
payments: z.discriminatedUnion("kind", [z.object({
|
|
12499
|
+
kind: z.literal("shown"),
|
|
12500
|
+
toPay: z.number(),
|
|
12501
|
+
first: z.string().nullable(),
|
|
12502
|
+
checking: z.number()
|
|
12503
|
+
}), notChecked$3]),
|
|
12504
|
+
downloads: z.discriminatedUnion("kind", [z.object({
|
|
12505
|
+
kind: z.literal("shown"),
|
|
12506
|
+
titles: z.array(z.string()).readonly()
|
|
12507
|
+
}), notChecked$3])
|
|
12508
|
+
}));
|
|
12509
|
+
const portalBusinessContactSchema = exactSchema()(z.object({
|
|
12510
|
+
email: z.string().nullable(),
|
|
12511
|
+
phone: z.string().nullable()
|
|
12512
|
+
}));
|
|
12513
|
+
const portalHomeResponseSchema = evolvingSchema()(z.object({
|
|
12514
|
+
tasks: portalTaskListSchema,
|
|
12515
|
+
comingUp: comingUpSchema,
|
|
12516
|
+
summaries: summariesSchema,
|
|
12517
|
+
contact: portalBusinessContactSchema
|
|
12518
|
+
}));
|
|
12519
|
+
|
|
12520
|
+
//#endregion
|
|
12521
|
+
//#region ../site-contracts/src/siteData/portalHoldings.ts
|
|
12522
|
+
const unsupported = (known) => unknownKind(known).transform(() => ({ kind: "unsupported" }));
|
|
12523
|
+
const STANDING_KINDS = [
|
|
12524
|
+
"renewing",
|
|
12525
|
+
"ending",
|
|
12526
|
+
"set_period",
|
|
12527
|
+
"paused",
|
|
12528
|
+
"ended"
|
|
12529
|
+
];
|
|
12530
|
+
const knownStandingSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12531
|
+
z.object({
|
|
12532
|
+
kind: z.literal("renewing"),
|
|
12533
|
+
nextPaymentAt: z.string().nullable()
|
|
12534
|
+
}),
|
|
12535
|
+
z.object({
|
|
12536
|
+
kind: z.literal("ending"),
|
|
12537
|
+
endsAt: z.string().nullable()
|
|
12538
|
+
}),
|
|
12539
|
+
z.object({
|
|
12540
|
+
kind: z.literal("set_period"),
|
|
12541
|
+
endsAt: z.string().nullable()
|
|
12542
|
+
}),
|
|
12543
|
+
z.object({ kind: z.literal("paused") }),
|
|
12544
|
+
z.object({
|
|
12545
|
+
kind: z.literal("ended"),
|
|
12546
|
+
endedAt: z.string().nullable()
|
|
12547
|
+
})
|
|
12548
|
+
]));
|
|
12549
|
+
const standingSchema = evolvingSchema()(z.union([knownStandingSchema, unsupported(STANDING_KINDS)]));
|
|
12550
|
+
const membershipSchema = evolvingSchema()(z.object({
|
|
12551
|
+
id: z.string(),
|
|
12552
|
+
name: z.string(),
|
|
12553
|
+
description: z.string().nullable(),
|
|
12554
|
+
price: portalMoneySchema.nullable(),
|
|
12555
|
+
interval: z.enum(["month", "year"]),
|
|
12556
|
+
since: z.string(),
|
|
12557
|
+
standing: standingSchema,
|
|
12558
|
+
paymentTrouble: exactSchema()(z.object({
|
|
12559
|
+
failed: portalMoneySchema.nullable(),
|
|
12560
|
+
overdueSince: z.string().nullable(),
|
|
12561
|
+
nextAttemptAt: z.string().nullable()
|
|
12562
|
+
})).nullable(),
|
|
12563
|
+
actions: z.object({
|
|
12564
|
+
cancel: z.boolean(),
|
|
12565
|
+
keep: z.boolean()
|
|
12566
|
+
})
|
|
12567
|
+
}));
|
|
12568
|
+
const useBookingSchema = exactSchema()(z.object({
|
|
12569
|
+
ref: bookingContextRefSchema,
|
|
12570
|
+
title: z.string(),
|
|
12571
|
+
startsAt: z.string().nullable(),
|
|
12572
|
+
timeZone: z.string().nullable()
|
|
12573
|
+
}));
|
|
12574
|
+
const useBookingReadSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12575
|
+
z.object({
|
|
12576
|
+
kind: z.literal("found"),
|
|
12577
|
+
booking: useBookingSchema
|
|
12578
|
+
}),
|
|
12579
|
+
z.object({ kind: z.literal("not_in_account") }),
|
|
12580
|
+
z.object({ kind: z.literal("not_checked") })
|
|
12581
|
+
]));
|
|
12582
|
+
const useBase = {
|
|
12583
|
+
key: z.string(),
|
|
12584
|
+
credits: z.number(),
|
|
12585
|
+
at: z.string(),
|
|
12586
|
+
booking: useBookingReadSchema
|
|
12587
|
+
};
|
|
12588
|
+
const knownUseSchema = exactSchema()(z.discriminatedUnion("kind", [z.object({
|
|
12589
|
+
...useBase,
|
|
12590
|
+
kind: z.literal("used"),
|
|
12591
|
+
cancelled: z.enum(["given_back", "kept"]).optional()
|
|
12592
|
+
}), z.object({
|
|
12593
|
+
...useBase,
|
|
12594
|
+
kind: z.literal("given_back"),
|
|
12595
|
+
by: z.enum([
|
|
12596
|
+
"you",
|
|
12597
|
+
"business",
|
|
12598
|
+
"automatically"
|
|
12599
|
+
])
|
|
12600
|
+
})]));
|
|
12601
|
+
const USE_KINDS = ["used", "given_back"];
|
|
12602
|
+
const useSchema = evolvingSchema()(z.union([knownUseSchema, unknownKind(USE_KINDS).extend({ key: z.string() }).transform((use) => ({
|
|
12603
|
+
kind: "unsupported",
|
|
12604
|
+
key: use.key
|
|
12605
|
+
}))]));
|
|
12606
|
+
const passSchema = evolvingSchema()(z.object({
|
|
12607
|
+
id: z.string(),
|
|
12608
|
+
name: z.string(),
|
|
12609
|
+
description: z.string().nullable(),
|
|
12610
|
+
useCase: z.discriminatedUnion("kind", [z.object({ kind: z.literal("event_pass") }), z.object({
|
|
12611
|
+
kind: z.literal("appointment_package"),
|
|
12612
|
+
with: z.string().nullable()
|
|
12613
|
+
})]),
|
|
12614
|
+
price: portalMoneySchema.nullable(),
|
|
12615
|
+
boughtAt: z.string(),
|
|
12616
|
+
expiresAt: z.string().nullable(),
|
|
12617
|
+
credits: z.object({
|
|
12618
|
+
remaining: z.number(),
|
|
12619
|
+
total: z.number(),
|
|
12620
|
+
held: z.number()
|
|
12621
|
+
}),
|
|
12622
|
+
standing: z.enum([
|
|
12623
|
+
"active",
|
|
12624
|
+
"used_up",
|
|
12625
|
+
"expired",
|
|
12626
|
+
"refunded"
|
|
12627
|
+
]),
|
|
12628
|
+
uses: z.array(useSchema).readonly()
|
|
12629
|
+
}));
|
|
12630
|
+
const creditOrderSchema = portalOrderNameSchema;
|
|
12631
|
+
const REASON_KINDS = [
|
|
12632
|
+
"spent",
|
|
12633
|
+
"refunded_as_credit",
|
|
12634
|
+
"given_back",
|
|
12635
|
+
"gift_card",
|
|
12636
|
+
"business_cancelled",
|
|
12637
|
+
"added_by_business",
|
|
12638
|
+
"taken_off_by_business",
|
|
12639
|
+
"paid_out"
|
|
12640
|
+
];
|
|
12641
|
+
const knownReasonSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12642
|
+
z.object({
|
|
12643
|
+
kind: z.literal("spent"),
|
|
12644
|
+
order: creditOrderSchema.nullable()
|
|
12645
|
+
}),
|
|
12646
|
+
z.object({
|
|
12647
|
+
kind: z.literal("refunded_as_credit"),
|
|
12648
|
+
order: creditOrderSchema.nullable()
|
|
12649
|
+
}),
|
|
12650
|
+
z.object({
|
|
12651
|
+
kind: z.literal("given_back"),
|
|
12652
|
+
order: creditOrderSchema.nullable()
|
|
12653
|
+
}),
|
|
12654
|
+
z.object({ kind: z.literal("gift_card") }),
|
|
12655
|
+
z.object({ kind: z.literal("business_cancelled") }),
|
|
12656
|
+
z.object({ kind: z.literal("added_by_business") }),
|
|
12657
|
+
z.object({ kind: z.literal("taken_off_by_business") }),
|
|
12658
|
+
z.object({ kind: z.literal("paid_out") })
|
|
12659
|
+
]));
|
|
12660
|
+
const reasonSchema = evolvingSchema()(z.union([knownReasonSchema, unsupported(REASON_KINDS)]));
|
|
12661
|
+
const creditAccountSchema = evolvingSchema()(z.object({
|
|
12662
|
+
available: portalMoneySchema,
|
|
12663
|
+
setAside: portalMoneySchema,
|
|
12664
|
+
history: z.array(z.object({
|
|
12665
|
+
key: z.string(),
|
|
12666
|
+
amount: portalMoneySchema,
|
|
12667
|
+
at: z.string(),
|
|
12668
|
+
reason: reasonSchema
|
|
12669
|
+
})).readonly()
|
|
12670
|
+
}));
|
|
12671
|
+
const notChecked$2 = z.object({ kind: z.literal("not_checked") });
|
|
12672
|
+
const portalHoldingsResponseSchema = evolvingSchema()(z.object({
|
|
12673
|
+
memberships: z.discriminatedUnion("kind", [z.object({
|
|
12674
|
+
kind: z.literal("shown"),
|
|
12675
|
+
memberships: z.array(membershipSchema).readonly()
|
|
12676
|
+
}), notChecked$2]),
|
|
12677
|
+
passes: z.discriminatedUnion("kind", [z.object({
|
|
12678
|
+
kind: z.literal("shown"),
|
|
12679
|
+
passes: z.array(passSchema).readonly()
|
|
12680
|
+
}), notChecked$2]),
|
|
12681
|
+
credit: z.discriminatedUnion("kind", [z.object({
|
|
12682
|
+
kind: z.literal("shown"),
|
|
12683
|
+
account: creditAccountSchema.nullable()
|
|
12684
|
+
}), notChecked$2]),
|
|
12685
|
+
contact: portalBusinessContactSchema
|
|
12686
|
+
}));
|
|
12687
|
+
|
|
12688
|
+
//#endregion
|
|
12689
|
+
//#region ../site-contracts/src/siteData/portalPayments.ts
|
|
12690
|
+
const ENTRY_KINDS = ["payment", "refund"];
|
|
12691
|
+
const purposeSchema = exactSchema()(z.enum([
|
|
12692
|
+
"paid_in_full",
|
|
12693
|
+
"deposit",
|
|
12694
|
+
"balance",
|
|
12695
|
+
"instalment",
|
|
12696
|
+
"rest_of_plan",
|
|
12697
|
+
"renewal"
|
|
12698
|
+
]));
|
|
12699
|
+
const paidHowSchema = exactSchema()(z.discriminatedUnion("kind", [z.object({ kind: z.literal("card") }), z.object({
|
|
12700
|
+
kind: z.literal("in_person"),
|
|
12701
|
+
method: z.enum(OFFLINE_PAYMENT_METHODS).nullable()
|
|
12702
|
+
})]));
|
|
12703
|
+
const refundToSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
12704
|
+
z.object({
|
|
12705
|
+
kind: z.literal("card"),
|
|
12706
|
+
last4: z.string().nullable()
|
|
12707
|
+
}),
|
|
12708
|
+
z.object({ kind: z.literal("site_credit") }),
|
|
12709
|
+
z.object({ kind: z.literal("business") })
|
|
12710
|
+
]));
|
|
12711
|
+
const refundFields = {
|
|
12712
|
+
refundId: z.string(),
|
|
12713
|
+
at: z.string(),
|
|
12714
|
+
amount: portalMoneySchema,
|
|
12715
|
+
to: refundToSchema,
|
|
12716
|
+
standing: z.enum([
|
|
12717
|
+
"sent",
|
|
12718
|
+
"sending",
|
|
12719
|
+
"failed",
|
|
12720
|
+
"checking"
|
|
12721
|
+
]),
|
|
12722
|
+
sentAt: z.string().nullable()
|
|
12723
|
+
};
|
|
12724
|
+
const refundSchema = exactSchema()(z.object(refundFields));
|
|
12725
|
+
const paymentOrderSchema = portalOrderNameSchema;
|
|
12726
|
+
const knownEntrySchema = exactSchema()(z.discriminatedUnion("kind", [z.object({
|
|
12727
|
+
kind: z.literal("payment"),
|
|
12728
|
+
key: z.string(),
|
|
12729
|
+
receiptId: z.string(),
|
|
12730
|
+
at: z.string(),
|
|
12731
|
+
amount: portalMoneySchema,
|
|
12732
|
+
order: paymentOrderSchema,
|
|
12733
|
+
purpose: purposeSchema,
|
|
12734
|
+
how: paidHowSchema,
|
|
12735
|
+
refunded: portalMoneySchema.nullable(),
|
|
12736
|
+
checking: z.boolean()
|
|
12737
|
+
}), z.object({
|
|
12738
|
+
kind: z.literal("refund"),
|
|
12739
|
+
key: z.string(),
|
|
12740
|
+
order: paymentOrderSchema,
|
|
12741
|
+
...refundFields
|
|
12742
|
+
})]));
|
|
12743
|
+
const unsupportedEntrySchema = unknownKind(ENTRY_KINDS).extend({
|
|
12744
|
+
key: z.string(),
|
|
12745
|
+
at: z.string()
|
|
12746
|
+
}).transform((entry) => ({
|
|
12747
|
+
kind: "unsupported",
|
|
12748
|
+
key: entry.key,
|
|
12749
|
+
at: entry.at
|
|
12750
|
+
}));
|
|
12751
|
+
const portalPaymentEntryViewSchema = evolvingSchema()(z.union([knownEntrySchema, unsupportedEntrySchema]));
|
|
12752
|
+
const notChecked$1 = z.object({ kind: z.literal("not_checked") });
|
|
12753
|
+
const instalmentSchema = exactSchema()(z.object({
|
|
12754
|
+
key: z.string(),
|
|
12755
|
+
dueAt: z.string(),
|
|
12756
|
+
amount: portalMoneySchema,
|
|
12757
|
+
standing: z.enum([
|
|
12758
|
+
"paid",
|
|
12759
|
+
"paid_early",
|
|
12760
|
+
"to_come",
|
|
12761
|
+
"not_taken_yet",
|
|
12762
|
+
"failed",
|
|
12763
|
+
"waived",
|
|
12764
|
+
"cancelled"
|
|
12765
|
+
]),
|
|
12766
|
+
receiptId: z.string().nullable()
|
|
12767
|
+
}));
|
|
12768
|
+
const planSchema = evolvingSchema()(z.object({
|
|
12769
|
+
orderId: z.string(),
|
|
12770
|
+
orderNumber: z.string(),
|
|
12771
|
+
for: portalPaymentForViewSchema,
|
|
12772
|
+
total: portalMoneySchema,
|
|
12773
|
+
paid: portalMoneySchema,
|
|
12774
|
+
moneyLine: z.string(),
|
|
12775
|
+
instalments: z.array(instalmentSchema).readonly(),
|
|
12776
|
+
toDo: portalPaymentToDoSchema
|
|
12777
|
+
}));
|
|
12778
|
+
const portalPaymentsResponseSchema = evolvingSchema()(z.object({
|
|
12779
|
+
toPay: portalTaskListSchema,
|
|
12780
|
+
checking: z.number(),
|
|
12781
|
+
plans: z.discriminatedUnion("kind", [z.object({
|
|
12782
|
+
kind: z.literal("shown"),
|
|
12783
|
+
plans: z.array(planSchema).readonly()
|
|
12784
|
+
}), notChecked$1]),
|
|
12785
|
+
history: z.discriminatedUnion("kind", [z.object({
|
|
12786
|
+
kind: z.literal("shown"),
|
|
12787
|
+
entries: z.array(portalPaymentEntryViewSchema).readonly(),
|
|
12788
|
+
nextCursor: z.string().nullable()
|
|
12789
|
+
}), notChecked$1]),
|
|
12790
|
+
otherOrders: z.discriminatedUnion("kind", [z.object({
|
|
12791
|
+
kind: z.literal("shown"),
|
|
12792
|
+
orders: z.array(z.object({
|
|
12793
|
+
order: portalOrderNameSchema,
|
|
12794
|
+
at: z.string(),
|
|
12795
|
+
total: portalMoneySchema,
|
|
12796
|
+
moneyLine: z.string()
|
|
12797
|
+
})).readonly()
|
|
12798
|
+
}), notChecked$1]),
|
|
12799
|
+
contact: portalBusinessContactSchema
|
|
12800
|
+
}));
|
|
12801
|
+
const portalReceiptResponseSchema = exactSchema()(z.object({ receipt: z.object({
|
|
12802
|
+
receiptId: z.string(),
|
|
12803
|
+
paidAt: z.string(),
|
|
12804
|
+
amount: portalMoneySchema,
|
|
12805
|
+
purpose: purposeSchema,
|
|
12806
|
+
how: paidHowSchema,
|
|
12807
|
+
tax: portalMoneySchema.nullable(),
|
|
12808
|
+
seller: z.object({
|
|
12809
|
+
name: z.string(),
|
|
12810
|
+
address: z.string().nullable(),
|
|
12811
|
+
email: z.string().nullable(),
|
|
12812
|
+
phone: z.string().nullable()
|
|
12813
|
+
}),
|
|
12814
|
+
paidBy: z.object({
|
|
12815
|
+
name: z.string().nullable(),
|
|
12816
|
+
email: z.string()
|
|
12817
|
+
}),
|
|
12818
|
+
order: z.object({
|
|
12819
|
+
orderId: z.string(),
|
|
12820
|
+
orderNumber: z.string(),
|
|
12821
|
+
breakdown: portalOrderBreakdownSchema,
|
|
12822
|
+
toDo: portalPaymentToDoSchema
|
|
12823
|
+
}),
|
|
12824
|
+
refunds: z.array(refundSchema).readonly(),
|
|
12825
|
+
checking: z.boolean()
|
|
12826
|
+
}) }));
|
|
12827
|
+
const shipmentSchema = exactSchema()(z.object({
|
|
12828
|
+
key: z.string(),
|
|
12829
|
+
sentAt: z.string(),
|
|
12830
|
+
carrier: z.string().nullable(),
|
|
12831
|
+
trackingUrl: z.string().nullable(),
|
|
12832
|
+
items: z.array(z.object({
|
|
12833
|
+
label: z.string(),
|
|
12834
|
+
quantity: z.number()
|
|
12835
|
+
})).readonly()
|
|
12836
|
+
}));
|
|
12837
|
+
const portalOrderResponseSchema = evolvingSchema()(z.object({ order: z.object({
|
|
12838
|
+
order: customerOrderSchema,
|
|
12839
|
+
breakdown: portalOrderBreakdownSchema,
|
|
12840
|
+
plan: planSchema.nullable(),
|
|
12841
|
+
payments: z.array(z.object({
|
|
12842
|
+
receiptId: z.string(),
|
|
12843
|
+
at: z.string(),
|
|
12844
|
+
amount: portalMoneySchema,
|
|
12845
|
+
purpose: purposeSchema,
|
|
12846
|
+
how: paidHowSchema
|
|
12847
|
+
})).readonly(),
|
|
12848
|
+
refunds: z.array(refundSchema).readonly(),
|
|
12849
|
+
postage: z.discriminatedUnion("kind", [z.object({ kind: z.literal("nothing_to_post") }), z.object({
|
|
12850
|
+
kind: z.literal("posted"),
|
|
12851
|
+
standing: z.enum([
|
|
12852
|
+
"not_sent",
|
|
12853
|
+
"partly_sent",
|
|
12854
|
+
"sent"
|
|
12855
|
+
]),
|
|
12856
|
+
shipments: z.array(shipmentSchema).readonly()
|
|
12857
|
+
})]),
|
|
12858
|
+
contact: portalBusinessContactSchema
|
|
12859
|
+
}) }));
|
|
12860
|
+
|
|
12861
|
+
//#endregion
|
|
12862
|
+
//#region ../site-contracts/src/siteData/portalDetails.ts
|
|
12863
|
+
const SIMPLE_NEWSLETTER_KINDS = [
|
|
12864
|
+
"not_offered",
|
|
12865
|
+
"elsewhere",
|
|
12866
|
+
"not_subscribed",
|
|
12867
|
+
"awaiting_confirmation",
|
|
12868
|
+
"cannot_send"
|
|
12869
|
+
];
|
|
12870
|
+
const NEWSLETTER_KINDS = [...SIMPLE_NEWSLETTER_KINDS, "choices"];
|
|
12871
|
+
const knownNewsletterSchema = exactSchema()(z.discriminatedUnion("kind", [z.object({ kind: z.enum(SIMPLE_NEWSLETTER_KINDS) }), z.object({
|
|
12872
|
+
kind: z.literal("choices"),
|
|
12873
|
+
general: z.boolean(),
|
|
12874
|
+
topics: z.array(z.object({
|
|
12875
|
+
id: z.string(),
|
|
12876
|
+
name: z.string(),
|
|
12877
|
+
description: z.string().nullable(),
|
|
12878
|
+
selected: z.boolean()
|
|
12879
|
+
})).readonly()
|
|
12880
|
+
})]));
|
|
12881
|
+
const portalNewsletterSchema = evolvingSchema()(z.union([knownNewsletterSchema, unknownKind(NEWSLETTER_KINDS).transform(() => ({ kind: "unsupported" }))]));
|
|
12882
|
+
const notChecked = z.object({ kind: z.literal("not_checked") });
|
|
12883
|
+
const termsAgreementSchema = exactSchema()(z.object({
|
|
12884
|
+
versionNumber: z.number().int().positive(),
|
|
12885
|
+
agreedAt: z.string(),
|
|
12886
|
+
href: z.string().nullable()
|
|
12887
|
+
}));
|
|
12888
|
+
const portalDetailsResponseSchema = evolvingSchema()(z.object({
|
|
12889
|
+
profile: customerProfileSchema,
|
|
12890
|
+
terms: z.union([z.object({
|
|
12891
|
+
kind: z.literal("shown"),
|
|
12892
|
+
agreement: termsAgreementSchema.nullable()
|
|
12893
|
+
}), notChecked]),
|
|
12894
|
+
newsletter: z.union([z.object({
|
|
12895
|
+
kind: z.literal("shown"),
|
|
12896
|
+
newsletter: portalNewsletterSchema
|
|
12897
|
+
}), notChecked]),
|
|
12898
|
+
contact: portalBusinessContactSchema
|
|
12899
|
+
}));
|
|
12900
|
+
const portalNewsletterUpdateRequestSchema = exactSchema()(z.object({
|
|
12901
|
+
general: z.boolean(),
|
|
12902
|
+
topicIds: z.array(z.string().uuid()).max(100).readonly()
|
|
12903
|
+
}));
|
|
12904
|
+
const portalNewsletterUpdateResponseSchema = evolvingSchema()(z.object({ newsletter: portalNewsletterSchema }));
|
|
12905
|
+
|
|
12906
|
+
//#endregion
|
|
12907
|
+
//#region ../site-contracts/src/siteData/portalOccurrenceBookings.ts
|
|
12908
|
+
const portalOccurrenceBookingSchema = exactSchema()(z.object({
|
|
12909
|
+
id: z.string(),
|
|
12910
|
+
occurrenceId: z.string(),
|
|
12911
|
+
ticketsCount: z.number().int().nonnegative(),
|
|
12912
|
+
ticketBreakdown: z.string().nullable()
|
|
12913
|
+
}));
|
|
12914
|
+
const portalOccurrenceBookingsResponseSchema = exactSchema()(z.object({ bookings: z.array(portalOccurrenceBookingSchema).readonly() }));
|
|
12915
|
+
|
|
12916
|
+
//#endregion
|
|
12917
|
+
//#region ../site-contracts/src/siteData/portalRoutes.ts
|
|
12918
|
+
/**
|
|
12919
|
+
* Pages the server renders on its own: Continue (before any session), tickets
|
|
12920
|
+
* and downloads. Every other page is the client portal's. The hosts' renderer
|
|
12921
|
+
* and the client's navigation both read this split, so neither can disagree
|
|
12922
|
+
* about who draws a page.
|
|
12923
|
+
*/
|
|
12924
|
+
const SERVER_PORTAL_PAGES = [
|
|
12925
|
+
"continue",
|
|
12926
|
+
"ticket",
|
|
12927
|
+
"download",
|
|
12928
|
+
"download_file"
|
|
12929
|
+
];
|
|
12930
|
+
function isServerPortalTarget(target) {
|
|
12931
|
+
return SERVER_PORTAL_PAGES.includes(target.page);
|
|
12932
|
+
}
|
|
12933
|
+
const CUSTOMER_PORTAL_PATH = "/portal";
|
|
12934
|
+
const NOT_FOUND = { page: "not_found" };
|
|
12935
|
+
const ARRIVAL_PARAMS = {
|
|
12936
|
+
signed_in: ["portal_login", "success"],
|
|
12937
|
+
order_paid: ["order", "success"],
|
|
12938
|
+
order_checkout_left: ["order", "cancelled"]
|
|
12939
|
+
};
|
|
12940
|
+
const ENTRY_REASON_PARAMS = {
|
|
12941
|
+
none: [],
|
|
12942
|
+
opened: [["entry", "1"]],
|
|
12943
|
+
stale: [["entry", "1"], ["stale", "1"]],
|
|
12944
|
+
link_sent: [["link", "sent"]],
|
|
12945
|
+
link_limited: [["link", "limited"]],
|
|
12946
|
+
demo_refused: [["link", "demo"]]
|
|
12947
|
+
};
|
|
12948
|
+
/** The query a page's own data puts in its address. */
|
|
12949
|
+
function targetParams(target) {
|
|
12950
|
+
return target.page === "continue" ? ENTRY_REASON_PARAMS[target.reason] : [];
|
|
12951
|
+
}
|
|
12952
|
+
function withQuery(path$3, params) {
|
|
12953
|
+
const query = new URLSearchParams(params.map(([name, value]) => [name, value])).toString();
|
|
12954
|
+
return query ? `${path$3}?${query}` : path$3;
|
|
12955
|
+
}
|
|
12956
|
+
function bookingPath(ref) {
|
|
12957
|
+
const { kind, bookingId } = portalBookingPath(ref);
|
|
12958
|
+
return `${CUSTOMER_PORTAL_PATH}/bookings/${kind}/${bookingId}`;
|
|
12959
|
+
}
|
|
12960
|
+
function targetPath(target) {
|
|
12961
|
+
const base = CUSTOMER_PORTAL_PATH;
|
|
12962
|
+
switch (target.page) {
|
|
12963
|
+
case "home": return base;
|
|
12964
|
+
case "bookings": return `${base}/bookings`;
|
|
12965
|
+
case "booking": return bookingPath(target.ref);
|
|
12966
|
+
case "booking_questions": return `${bookingPath(target.ref)}/questions`;
|
|
12967
|
+
case "booking_cancel": return `${bookingPath(target.ref)}/cancel`;
|
|
12968
|
+
case "booking_transfer": return `${bookingPath(target.ref)}/transfer`;
|
|
12969
|
+
case "booking_reschedule": return `${bookingPath(target.ref)}/reschedule`;
|
|
12970
|
+
case "ticket": return `${bookingPath(target.ref)}/ticket`;
|
|
12971
|
+
case "waitlist_offer": return `${base}/bookings/waitlist/${target.entryId}`;
|
|
12972
|
+
case "passes": return `${base}/passes`;
|
|
12973
|
+
case "payments": return `${base}/payments`;
|
|
12974
|
+
case "order": return `${base}/payments/orders/${target.orderId}`;
|
|
12975
|
+
case "receipt": return `${base}/payments/receipts/${target.receiptId}`;
|
|
12976
|
+
case "downloads": return `${base}/downloads`;
|
|
12977
|
+
case "download": return `${base}/downloads/${target.entitlementId}`;
|
|
12978
|
+
case "download_file": return `${base}/downloads/${target.entitlementId}/files/${target.assetId}`;
|
|
12979
|
+
case "details": return `${base}/details`;
|
|
12980
|
+
case "sign_in": return `${base}/sign-in`;
|
|
12981
|
+
case "continue": return `${base}/continue`;
|
|
12982
|
+
}
|
|
12983
|
+
}
|
|
12984
|
+
/** The site-relative path of a portal page, optionally carrying an arrival outcome. */
|
|
12985
|
+
function portalPath(target, options = {}) {
|
|
12986
|
+
const arrival = options.arrival ? [ARRIVAL_PARAMS[options.arrival]] : [];
|
|
12987
|
+
return withQuery(targetPath(target), [...targetParams(target), ...arrival]);
|
|
12988
|
+
}
|
|
12989
|
+
/**
|
|
12990
|
+
* A destination marked with an arrival outcome (the callback marks where sign-in
|
|
12991
|
+
* lands), keeping its own query: a checkout outcome already on it stays.
|
|
12992
|
+
*/
|
|
12993
|
+
function withPortalArrival(destination, arrival) {
|
|
12994
|
+
const marked = new URL(destination);
|
|
12995
|
+
const [name, value] = ARRIVAL_PARAMS[arrival];
|
|
12996
|
+
marked.searchParams.set(name, value);
|
|
12997
|
+
return marked;
|
|
12998
|
+
}
|
|
12999
|
+
/** Query parameters the portal reads and removes: the old link shapes and the arrival outcomes. */
|
|
13000
|
+
const CONSUMED_PARAMS = [
|
|
13001
|
+
"portal_tab",
|
|
13002
|
+
"portal_task",
|
|
13003
|
+
"portal_order",
|
|
13004
|
+
"portal_login",
|
|
13005
|
+
"order"
|
|
13006
|
+
];
|
|
13007
|
+
/** Continue's own query, which only Continue reads. */
|
|
13008
|
+
const ENTRY_PARAMS = [
|
|
13009
|
+
"entry",
|
|
13010
|
+
"stale",
|
|
13011
|
+
"link"
|
|
13012
|
+
];
|
|
13013
|
+
function parsePortalLocation(url) {
|
|
13014
|
+
const signedIn = cleanParam(url.searchParams, "portal_login") === "success";
|
|
13015
|
+
const checkout = parseCheckoutArrival(url.searchParams);
|
|
13016
|
+
const arrivals = [...signedIn ? ["signed_in"] : [], ...checkout ? [checkout] : []];
|
|
13017
|
+
const segments = portalSegments(url.pathname);
|
|
13018
|
+
if (segments === null) return {
|
|
13019
|
+
route: NOT_FOUND,
|
|
13020
|
+
arrivals,
|
|
13021
|
+
rewrite: null
|
|
13022
|
+
};
|
|
13023
|
+
const route = (segments.length === 0 ? legacyQueryRoute(url.searchParams, checkout) : null) ?? routeFromSegments(segments, url.searchParams);
|
|
13024
|
+
return {
|
|
13025
|
+
route,
|
|
13026
|
+
arrivals,
|
|
13027
|
+
rewrite: rewriteFor(url, route)
|
|
13028
|
+
};
|
|
13029
|
+
}
|
|
13030
|
+
function parseCheckoutArrival(params) {
|
|
13031
|
+
const order = cleanParam(params, "order");
|
|
13032
|
+
return order === "success" ? "order_paid" : order === "cancelled" ? "order_checkout_left" : null;
|
|
13033
|
+
}
|
|
13034
|
+
function parseEntryReason(params) {
|
|
13035
|
+
const link$1 = params.get("link");
|
|
13036
|
+
if (link$1 === "sent") return "link_sent";
|
|
13037
|
+
if (link$1 === "limited") return "link_limited";
|
|
13038
|
+
if (link$1 === "demo") return "demo_refused";
|
|
13039
|
+
if (params.get("entry") !== "1") return "none";
|
|
13040
|
+
return params.get("stale") === "1" ? "stale" : "opened";
|
|
13041
|
+
}
|
|
13042
|
+
/** Whether a path is under the portal at all, whatever page it names. */
|
|
13043
|
+
function isPortalPathname(pathname) {
|
|
13044
|
+
return pathname === CUSTOMER_PORTAL_PATH || pathname.startsWith(`${CUSTOMER_PORTAL_PATH}/`);
|
|
13045
|
+
}
|
|
13046
|
+
/** The path below `/portal`, decoded; null when the path isn't the portal's. */
|
|
13047
|
+
function portalSegments(pathname) {
|
|
13048
|
+
if (!isPortalPathname(pathname)) return null;
|
|
13049
|
+
try {
|
|
13050
|
+
return pathname.slice(CUSTOMER_PORTAL_PATH.length).split("/").filter((part) => part !== "").map(decodeURIComponent);
|
|
13051
|
+
} catch {
|
|
13052
|
+
return null;
|
|
13053
|
+
}
|
|
13054
|
+
}
|
|
13055
|
+
function rewriteFor(url, route) {
|
|
13056
|
+
if (route.page === "not_found") return null;
|
|
13057
|
+
const kept = new URLSearchParams(url.searchParams);
|
|
13058
|
+
[...CONSUMED_PARAMS, ...route.page === "continue" ? ENTRY_PARAMS : []].forEach((name) => kept.delete(name));
|
|
13059
|
+
const canonical = withQuery(targetPath(route), [...targetParams(route), ...kept.entries()]);
|
|
13060
|
+
const visited = url.searchParams.toString();
|
|
13061
|
+
const current = `${url.pathname}${visited ? `?${visited}` : ""}`;
|
|
13062
|
+
return canonical === current ? null : canonical;
|
|
13063
|
+
}
|
|
13064
|
+
function cleanParam(params, name) {
|
|
13065
|
+
const value = params.get(name)?.trim();
|
|
13066
|
+
return value ? value : null;
|
|
13067
|
+
}
|
|
13068
|
+
const only = (rest, route) => rest.length === 0 ? route : NOT_FOUND;
|
|
13069
|
+
function routeFromSegments(segments, params) {
|
|
13070
|
+
const [first, ...rest] = segments;
|
|
13071
|
+
switch (first) {
|
|
13072
|
+
case undefined: return { page: "home" };
|
|
13073
|
+
case "bookings": return bookingsRoute(rest);
|
|
13074
|
+
case "passes": return only(rest, { page: "passes" });
|
|
13075
|
+
case "payments": return paymentsRoute(rest);
|
|
13076
|
+
case "downloads":
|
|
13077
|
+
case "digital-products": return downloadsRoute(rest);
|
|
13078
|
+
case "tickets": return rest.length === 1 ? ticketRoute(parseBookingRef("event", rest[0])) : NOT_FOUND;
|
|
13079
|
+
case "details": return only(rest, { page: "details" });
|
|
13080
|
+
case "sign-in": return only(rest, { page: "sign_in" });
|
|
13081
|
+
case "continue": return only(rest, {
|
|
13082
|
+
page: "continue",
|
|
13083
|
+
reason: parseEntryReason(params)
|
|
13084
|
+
});
|
|
13085
|
+
default: return NOT_FOUND;
|
|
13086
|
+
}
|
|
13087
|
+
}
|
|
13088
|
+
function parseBookingRef(kind, bookingId) {
|
|
13089
|
+
const parsed = portalBookingPathSchema.safeParse({
|
|
13090
|
+
kind,
|
|
13091
|
+
bookingId
|
|
13092
|
+
});
|
|
13093
|
+
return parsed.success ? parsed.data : null;
|
|
13094
|
+
}
|
|
13095
|
+
function ticketRoute(ref) {
|
|
13096
|
+
return ref?.tag === "event_attendee" ? {
|
|
13097
|
+
page: "ticket",
|
|
13098
|
+
ref
|
|
13099
|
+
} : NOT_FOUND;
|
|
13100
|
+
}
|
|
13101
|
+
function bookingsRoute(rest) {
|
|
13102
|
+
const [kind, id$1, action, ...extra] = rest;
|
|
13103
|
+
if (kind === undefined) return { page: "bookings" };
|
|
13104
|
+
if (kind === "waitlist") {
|
|
13105
|
+
const entryId = parseWaitlistEntryId(id$1);
|
|
13106
|
+
return entryId.ok && action === undefined ? {
|
|
13107
|
+
page: "waitlist_offer",
|
|
13108
|
+
entryId: entryId.value
|
|
13109
|
+
} : NOT_FOUND;
|
|
13110
|
+
}
|
|
13111
|
+
const ref = parseBookingRef(kind, id$1);
|
|
13112
|
+
if (!ref || extra.length > 0) return NOT_FOUND;
|
|
13113
|
+
return bookingActionRoute(ref, action);
|
|
13114
|
+
}
|
|
13115
|
+
function bookingActionRoute(ref, action) {
|
|
13116
|
+
switch (action) {
|
|
13117
|
+
case undefined: return {
|
|
13118
|
+
page: "booking",
|
|
13119
|
+
ref
|
|
13120
|
+
};
|
|
13121
|
+
case "questions": return {
|
|
13122
|
+
page: "booking_questions",
|
|
13123
|
+
ref
|
|
13124
|
+
};
|
|
13125
|
+
case "cancel": return {
|
|
13126
|
+
page: "booking_cancel",
|
|
13127
|
+
ref
|
|
13128
|
+
};
|
|
13129
|
+
case "transfer": return ref.tag === "event_attendee" ? {
|
|
13130
|
+
page: "booking_transfer",
|
|
13131
|
+
ref
|
|
13132
|
+
} : NOT_FOUND;
|
|
13133
|
+
case "reschedule": return ref.tag === "event_series_registration" ? NOT_FOUND : {
|
|
13134
|
+
page: "booking_reschedule",
|
|
13135
|
+
ref
|
|
13136
|
+
};
|
|
13137
|
+
case "ticket": return ticketRoute(ref);
|
|
13138
|
+
default: return NOT_FOUND;
|
|
13139
|
+
}
|
|
13140
|
+
}
|
|
13141
|
+
function paymentsRoute(rest) {
|
|
13142
|
+
const [what, id$1, ...extra] = rest;
|
|
13143
|
+
if (what === undefined) return { page: "payments" };
|
|
13144
|
+
if (extra.length > 0) return NOT_FOUND;
|
|
13145
|
+
if (what === "orders") {
|
|
13146
|
+
const orderId = parseOrderId(id$1);
|
|
13147
|
+
return orderId.ok ? {
|
|
13148
|
+
page: "order",
|
|
13149
|
+
orderId: orderId.value
|
|
13150
|
+
} : NOT_FOUND;
|
|
13151
|
+
}
|
|
13152
|
+
if (what === "receipts") {
|
|
13153
|
+
const receiptId = parseOrderPaymentReceiptId(id$1);
|
|
13154
|
+
return receiptId.ok ? {
|
|
13155
|
+
page: "receipt",
|
|
13156
|
+
receiptId: receiptId.value
|
|
13157
|
+
} : NOT_FOUND;
|
|
13158
|
+
}
|
|
13159
|
+
return NOT_FOUND;
|
|
13160
|
+
}
|
|
13161
|
+
function downloadsRoute(rest) {
|
|
13162
|
+
const [id$1, files, asset, ...extra] = rest;
|
|
13163
|
+
if (id$1 === undefined) return { page: "downloads" };
|
|
13164
|
+
const entitlementId = parseEntitlementId(id$1);
|
|
13165
|
+
if (!entitlementId.ok || extra.length > 0) return NOT_FOUND;
|
|
13166
|
+
if (files === undefined) return {
|
|
13167
|
+
page: "download",
|
|
13168
|
+
entitlementId: entitlementId.value
|
|
13169
|
+
};
|
|
13170
|
+
const assetId = parseMediaAssetId(asset);
|
|
13171
|
+
return files === "files" && assetId.ok ? {
|
|
13172
|
+
page: "download_file",
|
|
13173
|
+
entitlementId: entitlementId.value,
|
|
13174
|
+
assetId: assetId.value
|
|
13175
|
+
} : NOT_FOUND;
|
|
13176
|
+
}
|
|
13177
|
+
/**
|
|
13178
|
+
* `/portal?…` as emails and pages wrote it before the portal had paths. A task
|
|
13179
|
+
* link wins, then an order, then a tab; a part that doesn't parse is ignored,
|
|
13180
|
+
* as the old portal ignored it. Coming back from paying lands on payments.
|
|
13181
|
+
*/
|
|
13182
|
+
function legacyQueryRoute(params, checkout) {
|
|
13183
|
+
return legacyTaskRoute(cleanParam(params, "portal_task")) ?? legacyOrderRoute(cleanParam(params, "portal_order")) ?? legacyTabRoute(cleanParam(params, "portal_tab")) ?? (checkout ? { page: "payments" } : null);
|
|
13184
|
+
}
|
|
13185
|
+
/** `portal_task` named the questions task of a booking, or a waitlist offer. */
|
|
13186
|
+
const LEGACY_TASK_KINDS = new Map([
|
|
13187
|
+
["appointment", "appointment"],
|
|
13188
|
+
["event", "event"],
|
|
13189
|
+
["event_series_registration", "course"]
|
|
13190
|
+
]);
|
|
13191
|
+
function legacyTaskRoute(value) {
|
|
13192
|
+
const [kind, id$1, ...rest] = value?.split(":") ?? [];
|
|
13193
|
+
if (!kind || !id$1 || rest.length > 0) return null;
|
|
13194
|
+
if (kind === "waitlist") {
|
|
13195
|
+
const entryId = parseWaitlistEntryId(id$1);
|
|
13196
|
+
return entryId.ok ? {
|
|
13197
|
+
page: "waitlist_offer",
|
|
13198
|
+
entryId: entryId.value
|
|
13199
|
+
} : null;
|
|
13200
|
+
}
|
|
13201
|
+
const bookingKind = LEGACY_TASK_KINDS.get(kind);
|
|
13202
|
+
const ref = bookingKind ? parseBookingRef(bookingKind, id$1) : null;
|
|
13203
|
+
return ref ? {
|
|
13204
|
+
page: "booking_questions",
|
|
13205
|
+
ref
|
|
13206
|
+
} : null;
|
|
13207
|
+
}
|
|
13208
|
+
function legacyOrderRoute(value) {
|
|
13209
|
+
if (value === null) return null;
|
|
13210
|
+
const orderId = parseOrderId(value);
|
|
13211
|
+
return orderId.ok ? {
|
|
13212
|
+
page: "order",
|
|
13213
|
+
orderId: orderId.value
|
|
13214
|
+
} : { page: "payments" };
|
|
13215
|
+
}
|
|
13216
|
+
const LEGACY_TABS = new Map([
|
|
13217
|
+
["events", { page: "bookings" }],
|
|
13218
|
+
["appointments", { page: "bookings" }],
|
|
13219
|
+
["orders", { page: "payments" }],
|
|
13220
|
+
["digital-products", { page: "downloads" }],
|
|
13221
|
+
["passes-memberships", { page: "passes" }],
|
|
13222
|
+
["credit", { page: "passes" }],
|
|
13223
|
+
["profile", { page: "details" }]
|
|
13224
|
+
]);
|
|
13225
|
+
function legacyTabRoute(value) {
|
|
13226
|
+
return value === null ? null : LEGACY_TABS.get(value) ?? null;
|
|
13227
|
+
}
|
|
13228
|
+
|
|
13229
|
+
//#endregion
|
|
13230
|
+
//#region ../site-contracts/src/siteData/portalActions.ts
|
|
13231
|
+
const portalMeResponseSchema = exactSchema()(z.object({
|
|
13232
|
+
siteTermsAcceptance: verifiedSiteTermsAcceptanceSchema.nullable(),
|
|
13233
|
+
profile: customerProfileSchema,
|
|
13234
|
+
modules: enabledModulesSchema
|
|
13235
|
+
}));
|
|
13236
|
+
/** What asking for a sign-in link answers: sent by email, or (on a demo site) the link itself. */
|
|
13237
|
+
const magicLinkResponseSchema = exactSchema()(z.union([z.object({ demoSignInUrl: z.string() }), z.object({ message: z.string() })]));
|
|
13238
|
+
const portalMeUpdateResponseSchema = exactSchema()(z.object({
|
|
13239
|
+
profile: customerProfileSchema,
|
|
13240
|
+
modules: enabledModulesSchema
|
|
13241
|
+
}));
|
|
13242
|
+
const portalCreditResponseSchema = exactSchema()(z.object({ credit: portalCreditSchema.nullable() }));
|
|
13243
|
+
const portalPassesResponseSchema = exactSchema()(z.object({ passes: z.array(customerPassSchema) }));
|
|
13244
|
+
const portalMembershipsResponseSchema = exactSchema()(z.object({ memberships: z.array(customerMembershipSchema) }));
|
|
13245
|
+
const portalOrdersResponseSchema = exactSchema()(z.object({ orders: z.array(customerOrderSchema) }));
|
|
13246
|
+
const portalOrderCheckoutResponseSchema = exactSchema()(z.object({
|
|
13247
|
+
checkoutUrl: z.string(),
|
|
13248
|
+
sessionId: z.string()
|
|
13249
|
+
}));
|
|
13250
|
+
const portalEventGuestsResponseSchema = exactSchema()(z.object({ guests: z.array(eventGuestSchema) }));
|
|
13251
|
+
const portalEventTicketSchema = exactSchema()(z.object({
|
|
13252
|
+
ticketUrl: z.string(),
|
|
13253
|
+
qrImageUrl: z.string(),
|
|
13254
|
+
fallbackCode: z.string(),
|
|
13255
|
+
registration: z.object({
|
|
13256
|
+
id: z.string(),
|
|
13257
|
+
eventTitle: z.string(),
|
|
13258
|
+
seriesName: z.string().nullable(),
|
|
13259
|
+
startsAt: z.string(),
|
|
13260
|
+
endsAt: z.string(),
|
|
13261
|
+
timeZone: z.string(),
|
|
13262
|
+
isOnline: z.boolean(),
|
|
13263
|
+
venueName: z.string().nullable(),
|
|
13264
|
+
venueAddress: z.string().nullable(),
|
|
13265
|
+
ticketsCount: z.number(),
|
|
13266
|
+
ticketLines: z.array(eventTicketBreakdownLineSchema),
|
|
13267
|
+
ticketBreakdown: z.string().nullable()
|
|
13268
|
+
})
|
|
13269
|
+
}));
|
|
13270
|
+
const portalEventTicketResponseSchema = exactSchema()(z.object({ ticket: portalEventTicketSchema }));
|
|
13271
|
+
const portalDigitalProductsResponseSchema = exactSchema()(z.object({
|
|
13272
|
+
tabLabel: z.string(),
|
|
13273
|
+
products: z.array(portalDigitalProductSchema)
|
|
13274
|
+
}));
|
|
13275
|
+
const portalDigitalProductAccessResponseSchema = exactSchema()(z.object({
|
|
13276
|
+
product: portalDigitalProductSchema,
|
|
13277
|
+
guardedHref: z.string().nullable()
|
|
13278
|
+
}));
|
|
13279
|
+
const portalDigitalProductDownloadUrlResponseSchema = exactSchema()(z.object({
|
|
13280
|
+
signedUrl: z.string(),
|
|
13281
|
+
filename: z.string()
|
|
13282
|
+
}));
|
|
13283
|
+
const portalBookingQuestionsTaskResponseSchema = evolvingSchema()(z.object({ task: bookingQuestionsTaskDetailSchema }));
|
|
13284
|
+
const portalBookingQuestionsUploadUrlResponseSchema = exactSchema()(z.object({
|
|
13285
|
+
uploadId: z.string(),
|
|
13286
|
+
signedUrl: z.string()
|
|
13287
|
+
}));
|
|
13288
|
+
const portalBookingQuestionsFinalizeUploadResponseSchema = exactSchema()(z.object({ answer: bookingQuestionsDocumentAnswerValueSchema }));
|
|
13289
|
+
const portalRefundInfoSchema = exactSchema()(z.object({
|
|
13290
|
+
status: z.enum([
|
|
13291
|
+
"succeeded",
|
|
13292
|
+
"failed",
|
|
13293
|
+
"skipped"
|
|
13294
|
+
]),
|
|
13295
|
+
amountCents: z.number().nullable(),
|
|
13296
|
+
currency: z.string().nullable(),
|
|
13297
|
+
paymentLast4: z.string().nullable(),
|
|
13298
|
+
stripeRefundId: z.string().nullable(),
|
|
13299
|
+
errorMessage: z.string().optional(),
|
|
13300
|
+
errorCode: z.string().optional()
|
|
13301
|
+
}));
|
|
13302
|
+
const CANCELLED_MONEY_KINDS = [
|
|
13303
|
+
"refunded",
|
|
13304
|
+
"credit_restored",
|
|
13305
|
+
"refund_failed",
|
|
13306
|
+
"none"
|
|
13307
|
+
];
|
|
13308
|
+
const portalCancelledMoneySchema = evolvingSchema()(z.union([cancelledMoneySchema, unknownKind(CANCELLED_MONEY_KINDS).transform(() => ({ kind: "unsupported" }))]));
|
|
13309
|
+
const cancelResultFields = {
|
|
13310
|
+
cancelled: z.boolean(),
|
|
13311
|
+
refunded: z.boolean(),
|
|
13312
|
+
refund: portalRefundInfoSchema.optional(),
|
|
13313
|
+
requiresCancelWithoutRefundConfirmation: z.boolean().optional(),
|
|
13314
|
+
followUp: z.string().nullable(),
|
|
13315
|
+
message: z.string()
|
|
13316
|
+
};
|
|
13317
|
+
/** The fields of every kind's cancel answer that the new portal reads, money decoded with its fallback. */
|
|
13318
|
+
const cancelAnswerSchema = z.object({
|
|
13319
|
+
cancelled: z.boolean(),
|
|
13320
|
+
requiresCancelWithoutRefundConfirmation: z.boolean().optional(),
|
|
13321
|
+
money: portalCancelledMoneySchema,
|
|
13322
|
+
followUp: z.string().nullable(),
|
|
13323
|
+
message: z.string()
|
|
13324
|
+
});
|
|
13325
|
+
const portalCancelEventRegistrationResultSchema = exactSchema()(z.object({
|
|
13326
|
+
...cancelResultFields,
|
|
13327
|
+
money: cancelledMoneySchema
|
|
13328
|
+
}));
|
|
13329
|
+
const portalCancelWholeSeriesRegistrationResultSchema = exactSchema()(z.object({
|
|
13330
|
+
...cancelResultFields,
|
|
13331
|
+
money: cancelledMoneySchema
|
|
13332
|
+
}));
|
|
13333
|
+
const portalCancelAppointmentResultSchema = exactSchema()(z.object({
|
|
13334
|
+
...cancelResultFields,
|
|
13335
|
+
money: cancelledMoneySchema
|
|
13336
|
+
}));
|
|
13337
|
+
function portalCancelOutcome(answer) {
|
|
13338
|
+
if (answer.requiresCancelWithoutRefundConfirmation) return {
|
|
13339
|
+
kind: "needs_confirmation",
|
|
13340
|
+
message: answer.message
|
|
13341
|
+
};
|
|
13342
|
+
if (!answer.cancelled) return {
|
|
13343
|
+
kind: "not_cancelled",
|
|
13344
|
+
message: answer.message
|
|
13345
|
+
};
|
|
13346
|
+
return {
|
|
13347
|
+
kind: "cancelled",
|
|
13348
|
+
money: answer.money,
|
|
13349
|
+
followUp: answer.followUp,
|
|
13350
|
+
message: answer.message
|
|
13351
|
+
};
|
|
13352
|
+
}
|
|
13353
|
+
/** Any kind's cancel answer, read as a `PortalCancelOutcome`. */
|
|
13354
|
+
const portalCancelOutcomeSchema = z.object({ result: cancelAnswerSchema }).transform(({ result }) => portalCancelOutcome(result));
|
|
13355
|
+
const portalRescheduleAppointmentResponseSchema = exactSchema()(z.object({ appointment: z.object({
|
|
13356
|
+
id: z.string(),
|
|
13357
|
+
status: z.string(),
|
|
13358
|
+
startAt: z.string(),
|
|
13359
|
+
endAt: z.string(),
|
|
13360
|
+
resourceId: z.string()
|
|
13361
|
+
}) }));
|
|
13362
|
+
const portalTransferEventRegistrationResultSchema = exactSchema()(z.object({
|
|
13363
|
+
transferred: z.boolean(),
|
|
13364
|
+
message: z.string(),
|
|
13365
|
+
transferId: z.string().optional()
|
|
13366
|
+
}));
|
|
13367
|
+
const portalCancelMembershipAtPeriodEndResultSchema = exactSchema()(z.object({
|
|
13368
|
+
cancelled: z.boolean(),
|
|
13369
|
+
message: z.string(),
|
|
13370
|
+
outcome: z.discriminatedUnion("kind", [
|
|
13371
|
+
z.object({ kind: z.literal("changed") }),
|
|
13372
|
+
z.object({
|
|
13373
|
+
kind: z.literal("unchanged"),
|
|
13374
|
+
reason: z.enum([
|
|
13375
|
+
"already_so",
|
|
13376
|
+
"already_ended",
|
|
13377
|
+
"does_not_renew",
|
|
13378
|
+
"cannot_change_online"
|
|
13379
|
+
])
|
|
13380
|
+
}),
|
|
13381
|
+
z.object({ kind: z.literal("settling") })
|
|
13382
|
+
])
|
|
13383
|
+
}));
|
|
13384
|
+
const portalWaitlistCancellationResultSchema = exactSchema()(z.object({ outcome: z.enum([
|
|
13385
|
+
"cancelled",
|
|
13386
|
+
"alreadyClosed",
|
|
13387
|
+
"notFound"
|
|
13388
|
+
]) }));
|
|
13389
|
+
const attendanceModeSchema = z.enum(["in_person", "online"]);
|
|
13390
|
+
const rescheduleBookingSchema = exactSchema()(z.object({
|
|
13391
|
+
customerId: z.string(),
|
|
13392
|
+
ticketLines: z.array(z.object({
|
|
13393
|
+
ticketLineId: z.string(),
|
|
13394
|
+
pricingOptionId: z.string().nullable(),
|
|
13395
|
+
quantity: z.number(),
|
|
13396
|
+
unitPriceCents: z.number(),
|
|
13397
|
+
currency: z.string()
|
|
13398
|
+
})).readonly()
|
|
13399
|
+
}));
|
|
13400
|
+
const rescheduleNoticeSchema = exactSchema()(z.discriminatedUnion("kind", [z.object({
|
|
13401
|
+
kind: z.literal("attendance_mode_changed"),
|
|
13402
|
+
from: attendanceModeSchema,
|
|
13403
|
+
to: attendanceModeSchema
|
|
13404
|
+
}), z.object({
|
|
13405
|
+
kind: z.literal("venue_changed"),
|
|
13406
|
+
from: z.string().nullable(),
|
|
13407
|
+
to: z.string().nullable()
|
|
13408
|
+
})]));
|
|
13409
|
+
const rescheduleAssessmentSchema = exactSchema()(z.discriminatedUnion("kind", [
|
|
13410
|
+
z.object({
|
|
13411
|
+
kind: z.literal("selectable"),
|
|
13412
|
+
notices: z.array(rescheduleNoticeSchema).readonly()
|
|
13413
|
+
}),
|
|
13414
|
+
z.object({
|
|
13415
|
+
kind: z.literal("needs_ticket_choice"),
|
|
13416
|
+
ticketLineIds: z.array(z.string()).readonly()
|
|
13417
|
+
}),
|
|
13418
|
+
z.object({
|
|
13419
|
+
kind: z.literal("needs_capacity_override"),
|
|
13420
|
+
booked: z.number(),
|
|
13421
|
+
capacity: z.number()
|
|
13422
|
+
}),
|
|
13423
|
+
z.object({
|
|
13424
|
+
kind: z.literal("blocked"),
|
|
13425
|
+
reason: z.enum([
|
|
13426
|
+
"full",
|
|
13427
|
+
"not_enough_room",
|
|
13428
|
+
"ticket_not_usable",
|
|
13429
|
+
"tickets_collide",
|
|
13430
|
+
"pass_not_accepted",
|
|
13431
|
+
"already_booked",
|
|
13432
|
+
"not_bookable"
|
|
13433
|
+
])
|
|
13434
|
+
})
|
|
13435
|
+
]));
|
|
13436
|
+
const rescheduleDateSchema = exactSchema()(z.object({
|
|
13437
|
+
occurrenceId: z.string(),
|
|
13438
|
+
title: z.string(),
|
|
13439
|
+
startsAt: z.string(),
|
|
13440
|
+
endsAt: z.string(),
|
|
13441
|
+
timeZone: z.string(),
|
|
13442
|
+
venueId: z.string().nullable(),
|
|
13443
|
+
venueName: z.string().nullable(),
|
|
13444
|
+
attendanceMode: attendanceModeSchema,
|
|
13445
|
+
assessment: rescheduleAssessmentSchema,
|
|
13446
|
+
capacity: z.discriminatedUnion("kind", [z.object({ kind: z.literal("unbounded") }), z.object({
|
|
13447
|
+
kind: z.literal("bounded"),
|
|
13448
|
+
booked: z.number(),
|
|
13449
|
+
capacity: z.number(),
|
|
13450
|
+
availableSeats: z.number()
|
|
13451
|
+
})])
|
|
13452
|
+
}));
|
|
13453
|
+
const portalEventRescheduleDatesSchema = exactSchema()(z.object({
|
|
13454
|
+
source: z.discriminatedUnion("kind", [
|
|
13455
|
+
z.object({
|
|
13456
|
+
kind: z.literal("available"),
|
|
13457
|
+
until: z.string().nullable()
|
|
13458
|
+
}),
|
|
13459
|
+
z.object({
|
|
13460
|
+
kind: z.literal("closed"),
|
|
13461
|
+
closedAt: z.string()
|
|
13462
|
+
}),
|
|
13463
|
+
z.object({
|
|
13464
|
+
kind: z.literal("not_offered"),
|
|
13465
|
+
reason: z.enum([
|
|
13466
|
+
"switched_off",
|
|
13467
|
+
"course_booking",
|
|
13468
|
+
"checked_in",
|
|
13469
|
+
"cancelled",
|
|
13470
|
+
"waitlisted",
|
|
13471
|
+
"past",
|
|
13472
|
+
"date_missing",
|
|
13473
|
+
"payment_pending",
|
|
13474
|
+
"not_owner",
|
|
13475
|
+
"has_room"
|
|
13476
|
+
])
|
|
13477
|
+
})
|
|
13478
|
+
]),
|
|
13479
|
+
booking: rescheduleBookingSchema.nullable(),
|
|
13480
|
+
dates: z.array(rescheduleDateSchema).readonly(),
|
|
13481
|
+
nextPage: z.object({
|
|
13482
|
+
afterStartsAt: z.string(),
|
|
13483
|
+
afterId: z.string()
|
|
13484
|
+
}).nullable()
|
|
13485
|
+
}));
|
|
13486
|
+
const portalEventRescheduleResultSchema = exactSchema()(z.union([z.object({
|
|
13487
|
+
moved: z.literal(true),
|
|
13488
|
+
moveId: z.string(),
|
|
13489
|
+
effects: z.enum(["settled", "pending"])
|
|
13490
|
+
}), z.object({
|
|
13491
|
+
moved: z.literal(false),
|
|
13492
|
+
reason: z.enum([
|
|
13493
|
+
"not_found",
|
|
13494
|
+
"source_changed",
|
|
13495
|
+
"source_unavailable",
|
|
13496
|
+
"target_full",
|
|
13497
|
+
"target_not_bookable",
|
|
13498
|
+
"target_changed",
|
|
13499
|
+
"already_booked_on_target",
|
|
13500
|
+
"ticket_not_usable",
|
|
13501
|
+
"has_room"
|
|
13502
|
+
]),
|
|
13503
|
+
message: z.string()
|
|
13504
|
+
})]));
|
|
13505
|
+
|
|
10633
13506
|
//#endregion
|
|
10634
13507
|
//#region ../site-contracts/src/siteData/bookingQuestions.ts
|
|
10635
13508
|
/**
|
|
@@ -10655,10 +13528,10 @@ function decideSelectionAttendance(items) {
|
|
|
10655
13528
|
const [first, ...rest] = items;
|
|
10656
13529
|
if (!first) return { kind: "none" };
|
|
10657
13530
|
const common = rest.reduce((modes, item) => modes.filter((mode) => offeredModes(item).includes(mode)), offeredModes(first));
|
|
10658
|
-
const [only, ...others] = common;
|
|
10659
|
-
if (!items.every(isHybrid)) return only && others.length === 0 ? {
|
|
13531
|
+
const [only$1, ...others] = common;
|
|
13532
|
+
if (!items.every(isHybrid)) return only$1 && others.length === 0 ? {
|
|
10660
13533
|
kind: "fixed",
|
|
10661
|
-
mode: only
|
|
13534
|
+
mode: only$1
|
|
10662
13535
|
} : { kind: "incompatible" };
|
|
10663
13536
|
return rest.length > 0 && common.length === 0 ? { kind: "incompatible" } : {
|
|
10664
13537
|
kind: "choose",
|
|
@@ -10703,6 +13576,46 @@ function requirementsKey(view) {
|
|
|
10703
13576
|
});
|
|
10704
13577
|
}
|
|
10705
13578
|
|
|
13579
|
+
//#endregion
|
|
13580
|
+
//#region ../site-contracts/src/siteData/eventSelectionPayment.ts
|
|
13581
|
+
const cents = z.number().int().nonnegative();
|
|
13582
|
+
const collectionSchema = z.object({
|
|
13583
|
+
kind: z.enum([
|
|
13584
|
+
"upfront",
|
|
13585
|
+
"deferred_manual",
|
|
13586
|
+
"instalment_plan",
|
|
13587
|
+
"flexible_balance"
|
|
13588
|
+
]),
|
|
13589
|
+
amountCents: cents,
|
|
13590
|
+
currency: z.string().min(1),
|
|
13591
|
+
bookings: z.array(z.object({
|
|
13592
|
+
itemId: z.string().min(1),
|
|
13593
|
+
amountCents: cents
|
|
13594
|
+
}).readonly()).readonly().optional()
|
|
13595
|
+
}).readonly();
|
|
13596
|
+
const optionSchema = z.object({
|
|
13597
|
+
funding: eventSelectionFundingPickSchema,
|
|
13598
|
+
collect: z.discriminatedUnion("kind", [z.object({ kind: z.literal("nothing") }), z.object({
|
|
13599
|
+
kind: z.literal("money"),
|
|
13600
|
+
collections: z.tuple([collectionSchema]).rest(collectionSchema).readonly()
|
|
13601
|
+
})])
|
|
13602
|
+
});
|
|
13603
|
+
const eventSelectionPaymentSchema = z.discriminatedUnion("kind", [
|
|
13604
|
+
z.object({
|
|
13605
|
+
kind: z.literal("bookable"),
|
|
13606
|
+
options: z.tuple([optionSchema]).rest(optionSchema).readonly()
|
|
13607
|
+
}),
|
|
13608
|
+
z.object({ kind: z.literal("bookSeparately") }),
|
|
13609
|
+
z.object({
|
|
13610
|
+
kind: z.literal("cannotBookOnline"),
|
|
13611
|
+
organiserContact: z.object({
|
|
13612
|
+
email: z.string().nullable(),
|
|
13613
|
+
phone: z.string().nullable()
|
|
13614
|
+
}).nullable()
|
|
13615
|
+
}),
|
|
13616
|
+
z.object({ kind: z.literal("noPaymentOption") })
|
|
13617
|
+
]);
|
|
13618
|
+
|
|
10706
13619
|
//#endregion
|
|
10707
13620
|
//#region ../api/src/publicEventEndpointDefinitions.ts
|
|
10708
13621
|
const PUBLIC_EVENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
@@ -14988,7 +17901,7 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
14988
17901
|
],
|
|
14989
17902
|
auth: "public",
|
|
14990
17903
|
responseKind: "json",
|
|
14991
|
-
errors: ["
|
|
17904
|
+
errors: ["server:internal_error"]
|
|
14992
17905
|
},
|
|
14993
17906
|
resolveRouteDecision: {
|
|
14994
17907
|
path: "/sites/{siteId}/route-decision",
|
|
@@ -15000,7 +17913,7 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
15000
17913
|
],
|
|
15001
17914
|
auth: "public",
|
|
15002
17915
|
responseKind: "json",
|
|
15003
|
-
errors: ["
|
|
17916
|
+
errors: ["server:internal_error"]
|
|
15004
17917
|
},
|
|
15005
17918
|
getPageByPath: {
|
|
15006
17919
|
path: "/sites/{siteId}/pages",
|
|
@@ -15551,7 +18464,7 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
15551
18464
|
tags: ["backup"],
|
|
15552
18465
|
auth: "user",
|
|
15553
18466
|
responseKind: "json",
|
|
15554
|
-
errors: ["
|
|
18467
|
+
errors: ["server:internal_error"]
|
|
15555
18468
|
},
|
|
15556
18469
|
deleteBackupUpload: {
|
|
15557
18470
|
path: "/backup/upload",
|
|
@@ -16187,7 +19100,7 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
16187
19100
|
auth: "user",
|
|
16188
19101
|
responseKind: "json",
|
|
16189
19102
|
demoMutation: DEMO_MUTATION_BLOCKED_DISABLED,
|
|
16190
|
-
errors: ["
|
|
19103
|
+
errors: ["server:internal_error"]
|
|
16191
19104
|
},
|
|
16192
19105
|
getBookingPass: {
|
|
16193
19106
|
path: "/sites/{siteId}/bookings/passes/{passId}",
|
|
@@ -16265,7 +19178,7 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
16265
19178
|
auth: "user",
|
|
16266
19179
|
responseKind: "json",
|
|
16267
19180
|
demoMutation: DEMO_MUTATION_BLOCKED_DISABLED,
|
|
16268
|
-
errors: ["
|
|
19181
|
+
errors: ["server:internal_error"]
|
|
16269
19182
|
},
|
|
16270
19183
|
getBookingMembership: {
|
|
16271
19184
|
path: "/sites/{siteId}/bookings/memberships/{membershipId}",
|
|
@@ -17515,18 +20428,23 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
17515
20428
|
auth: "public",
|
|
17516
20429
|
responseKind: "json"
|
|
17517
20430
|
},
|
|
17518
|
-
|
|
17519
|
-
path: "/portal/
|
|
20431
|
+
portalGetDetails: {
|
|
20432
|
+
path: "/portal/details",
|
|
17520
20433
|
method: "GET",
|
|
17521
20434
|
auth: "public",
|
|
17522
|
-
responseKind: "json"
|
|
20435
|
+
responseKind: "json",
|
|
20436
|
+
errors: ["server:internal_error"]
|
|
17523
20437
|
},
|
|
17524
|
-
|
|
17525
|
-
path: "/portal/
|
|
17526
|
-
method: "
|
|
17527
|
-
errors: [],
|
|
20438
|
+
portalUpdateNewsletter: {
|
|
20439
|
+
path: "/portal/details/newsletter",
|
|
20440
|
+
method: "PATCH",
|
|
17528
20441
|
auth: "public",
|
|
17529
|
-
responseKind: "json"
|
|
20442
|
+
responseKind: "json",
|
|
20443
|
+
errors: [
|
|
20444
|
+
"validation:invalid_input",
|
|
20445
|
+
"resource:conflict",
|
|
20446
|
+
"server:internal_error"
|
|
20447
|
+
]
|
|
17530
20448
|
},
|
|
17531
20449
|
portalCreateOrderCheckout: {
|
|
17532
20450
|
path: "/portal/orders/{orderId}/checkout",
|
|
@@ -17567,42 +20485,74 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
17567
20485
|
auth: "public",
|
|
17568
20486
|
responseKind: "json"
|
|
17569
20487
|
},
|
|
17570
|
-
|
|
17571
|
-
path: "/portal/
|
|
20488
|
+
portalGetEventTicket: {
|
|
20489
|
+
path: "/portal/events/{registrationId}/ticket",
|
|
17572
20490
|
method: "GET",
|
|
17573
20491
|
auth: "public",
|
|
17574
20492
|
responseKind: "json"
|
|
17575
20493
|
},
|
|
17576
|
-
|
|
17577
|
-
path: "/portal/
|
|
20494
|
+
portalGetRegularSessions: {
|
|
20495
|
+
path: "/portal/appointments/regular-sessions",
|
|
17578
20496
|
method: "GET",
|
|
17579
20497
|
auth: "public",
|
|
17580
|
-
responseKind: "json"
|
|
20498
|
+
responseKind: "json",
|
|
20499
|
+
errors: ["server:internal_error"]
|
|
17581
20500
|
},
|
|
17582
|
-
|
|
17583
|
-
path: "/portal/
|
|
20501
|
+
portalGetBookings: {
|
|
20502
|
+
path: "/portal/bookings",
|
|
17584
20503
|
method: "GET",
|
|
17585
20504
|
auth: "public",
|
|
17586
|
-
responseKind: "json"
|
|
20505
|
+
responseKind: "json",
|
|
20506
|
+
errors: ["server:internal_error"]
|
|
17587
20507
|
},
|
|
17588
|
-
|
|
17589
|
-
path: "/portal/
|
|
20508
|
+
portalGetHome: {
|
|
20509
|
+
path: "/portal/home",
|
|
17590
20510
|
method: "GET",
|
|
17591
20511
|
auth: "public",
|
|
17592
|
-
responseKind: "json"
|
|
20512
|
+
responseKind: "json",
|
|
20513
|
+
errors: ["server:internal_error"]
|
|
17593
20514
|
},
|
|
17594
|
-
|
|
17595
|
-
path: "/portal/
|
|
20515
|
+
portalGetOccurrenceBookings: {
|
|
20516
|
+
path: "/portal/occurrences/{occurrenceId}/bookings",
|
|
17596
20517
|
method: "GET",
|
|
17597
20518
|
auth: "public",
|
|
17598
20519
|
responseKind: "json",
|
|
17599
20520
|
errors: ["server:internal_error"]
|
|
17600
20521
|
},
|
|
17601
|
-
|
|
17602
|
-
path: "/portal/
|
|
20522
|
+
portalGetHoldings: {
|
|
20523
|
+
path: "/portal/holdings",
|
|
17603
20524
|
method: "GET",
|
|
17604
20525
|
auth: "public",
|
|
17605
|
-
responseKind: "json"
|
|
20526
|
+
responseKind: "json",
|
|
20527
|
+
errors: ["server:internal_error"]
|
|
20528
|
+
},
|
|
20529
|
+
portalGetPayments: {
|
|
20530
|
+
path: "/portal/payments",
|
|
20531
|
+
method: "GET",
|
|
20532
|
+
auth: "public",
|
|
20533
|
+
responseKind: "json",
|
|
20534
|
+
errors: ["server:internal_error"]
|
|
20535
|
+
},
|
|
20536
|
+
portalGetReceipt: {
|
|
20537
|
+
path: "/portal/payments/receipts/{receiptId}",
|
|
20538
|
+
method: "GET",
|
|
20539
|
+
auth: "public",
|
|
20540
|
+
responseKind: "json",
|
|
20541
|
+
errors: ["resource:not_found", "server:internal_error"]
|
|
20542
|
+
},
|
|
20543
|
+
portalGetOrder: {
|
|
20544
|
+
path: "/portal/orders/{orderId}",
|
|
20545
|
+
method: "GET",
|
|
20546
|
+
auth: "public",
|
|
20547
|
+
responseKind: "json",
|
|
20548
|
+
errors: ["resource:not_found", "server:internal_error"]
|
|
20549
|
+
},
|
|
20550
|
+
portalGetBooking: {
|
|
20551
|
+
path: "/portal/bookings/{kind}/{bookingId}",
|
|
20552
|
+
method: "GET",
|
|
20553
|
+
auth: "public",
|
|
20554
|
+
responseKind: "json",
|
|
20555
|
+
errors: ["resource:not_found", "server:internal_error"]
|
|
17606
20556
|
},
|
|
17607
20557
|
portalGetAppointmentBookingQuestions: {
|
|
17608
20558
|
path: "/portal/appointments/{appointmentId}/booking-questions",
|
|
@@ -17703,13 +20653,6 @@ const ENDPOINT_DEFINITIONS = {
|
|
|
17703
20653
|
"server:internal_error"
|
|
17704
20654
|
]
|
|
17705
20655
|
},
|
|
17706
|
-
portalGetWholeSeriesRegistrations: {
|
|
17707
|
-
path: "/portal/dated-offerings/whole-series",
|
|
17708
|
-
method: "GET",
|
|
17709
|
-
auth: "public",
|
|
17710
|
-
responseKind: "json",
|
|
17711
|
-
errors: ["server:internal_error"]
|
|
17712
|
-
},
|
|
17713
20656
|
portalGetWholeSeriesBookingQuestions: {
|
|
17714
20657
|
path: "/portal/dated-offerings/whole-series/{registrationId}/booking-questions",
|
|
17715
20658
|
method: "GET",
|
|
@@ -21462,6 +24405,13 @@ const dataScopeSchema = z.object({
|
|
|
21462
24405
|
from: bindingSchema
|
|
21463
24406
|
});
|
|
21464
24407
|
const nodePropsSchema = z.record(z.string(), z.unknown()).default({});
|
|
24408
|
+
/**
|
|
24409
|
+
* A plain `z.object`, so a key it does not list is stripped from the parsed
|
|
24410
|
+
* node. For custom-block layouts that strip is part of the protection (issue
|
|
24411
|
+
* 1185): the renderer treats unknown top-level keys as props, and only the
|
|
24412
|
+
* parsed value has been through the layout gate. Store and render the parsed
|
|
24413
|
+
* value, never the raw manifest.
|
|
24414
|
+
*/
|
|
21465
24415
|
const nodeSchema = z.object({
|
|
21466
24416
|
type: z.string().min(1, "Node type is required"),
|
|
21467
24417
|
key: z.string().optional(),
|
|
@@ -21472,6 +24422,73 @@ const nodeSchema = z.object({
|
|
|
21472
24422
|
$when: conditionSchema.optional(),
|
|
21473
24423
|
$scopes: dataScopeSchema.array().optional()
|
|
21474
24424
|
});
|
|
24425
|
+
/**
|
|
24426
|
+
* How large a custom-block layout may be. The system blocks reach 12 levels
|
|
24427
|
+
* and 153 nodes and the manifest generator writes 6 levels, so these leave
|
|
24428
|
+
* room while keeping a pathological tree from running a recursive walk (the
|
|
24429
|
+
* schema's own included) out of stack.
|
|
24430
|
+
*/
|
|
24431
|
+
const MAX_CUSTOM_LAYOUT_DEPTH = 24;
|
|
24432
|
+
const MAX_CUSTOM_LAYOUT_NODES = 1e3;
|
|
24433
|
+
const NODE_KEYS = new Set([
|
|
24434
|
+
"type",
|
|
24435
|
+
"key",
|
|
24436
|
+
"props",
|
|
24437
|
+
"children",
|
|
24438
|
+
"$bind",
|
|
24439
|
+
"$repeat",
|
|
24440
|
+
"$when",
|
|
24441
|
+
"$scopes"
|
|
24442
|
+
]);
|
|
24443
|
+
const isRawNode = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24444
|
+
const rawChildren = (node) => isRawNode(node) && Array.isArray(node.children) ? node.children : [];
|
|
24445
|
+
/** Whether the tree nests deeper than `levels`, looking no further down than that. */
|
|
24446
|
+
const nestsDeeperThan = (node, levels) => levels === 0 ? isRawNode(node) : rawChildren(node).some((child) => nestsDeeperThan(child, levels - 1));
|
|
24447
|
+
/** Nodes in a tree already known to be no deeper than the limit. */
|
|
24448
|
+
const countNodes = (node) => rawChildren(node).reduce((total, child) => total + countNodes(child), 1);
|
|
24449
|
+
/** Why a custom-block layout is too large to check or render, or null. Safe to call on any value. */
|
|
24450
|
+
function customLayoutSizeProblem(layout) {
|
|
24451
|
+
if (nestsDeeperThan(layout, MAX_CUSTOM_LAYOUT_DEPTH)) {
|
|
24452
|
+
return `The layout nests more than ${MAX_CUSTOM_LAYOUT_DEPTH} levels deep. Flatten it.`;
|
|
24453
|
+
}
|
|
24454
|
+
const count = countNodes(layout);
|
|
24455
|
+
return count > MAX_CUSTOM_LAYOUT_NODES ? `The layout has ${count} nodes, and a custom block takes at most ${MAX_CUSTOM_LAYOUT_NODES}. Use a repeater for repeated items.` : null;
|
|
24456
|
+
}
|
|
24457
|
+
/** Keys on a node (or any node below it) that `nodeSchema` would strip. */
|
|
24458
|
+
function unknownNodeKeys(node, path$3) {
|
|
24459
|
+
if (!isRawNode(node)) return [];
|
|
24460
|
+
return [...Object.keys(node).filter((key) => !NODE_KEYS.has(key)).map((key) => ({
|
|
24461
|
+
path: [...path$3, key],
|
|
24462
|
+
key
|
|
24463
|
+
})), ...rawChildren(node).flatMap((child, index) => unknownNodeKeys(child, [
|
|
24464
|
+
...path$3,
|
|
24465
|
+
"children",
|
|
24466
|
+
index
|
|
24467
|
+
]))];
|
|
24468
|
+
}
|
|
24469
|
+
function reportRawLayoutShape(layout, ctx) {
|
|
24470
|
+
const sizeProblem = customLayoutSizeProblem(layout);
|
|
24471
|
+
if (sizeProblem !== null) {
|
|
24472
|
+
ctx.addIssue({
|
|
24473
|
+
code: "custom",
|
|
24474
|
+
message: sizeProblem,
|
|
24475
|
+
continue: false
|
|
24476
|
+
});
|
|
24477
|
+
return;
|
|
24478
|
+
}
|
|
24479
|
+
unknownNodeKeys(layout, []).forEach(({ path: path$3, key }) => ctx.addIssue({
|
|
24480
|
+
code: "custom",
|
|
24481
|
+
path: [...path$3],
|
|
24482
|
+
message: `"${key}" is not part of a node, so it would be dropped. A node has type, key, props, children, $bind, $repeat, $when and $scopes; put "${key}" under props.`
|
|
24483
|
+
}));
|
|
24484
|
+
}
|
|
24485
|
+
/**
|
|
24486
|
+
* A custom-block layout as its author wrote it. `nodeSchema` strips keys it
|
|
24487
|
+
* does not know, which is safe but silent: an author who writes `style` beside
|
|
24488
|
+
* `type` loses it without being told. This reports those keys, and refuses a
|
|
24489
|
+
* tree too large to walk, before `nodeSchema` parses it.
|
|
24490
|
+
*/
|
|
24491
|
+
const customBlockLayoutSchema = z.unknown().superRefine(reportRawLayoutShape).pipe(nodeSchema);
|
|
21475
24492
|
const nodeTreeSchema = z.union([z.array(nodeSchema), nodeSchema]);
|
|
21476
24493
|
const NodeSchema = nodeSchema;
|
|
21477
24494
|
const NodeTreeSchema = nodeTreeSchema;
|
|
@@ -21479,7 +24496,7 @@ const NodeTreeSchema = nodeTreeSchema;
|
|
|
21479
24496
|
//#endregion
|
|
21480
24497
|
//#region ../site-contracts/src/blocks/sdkDeclaration.ts
|
|
21481
24498
|
const sdkBlockPresentationShape = {
|
|
21482
|
-
variants: z.record(z.string().min(1),
|
|
24499
|
+
variants: z.record(z.string().min(1), customBlockLayoutSchema).optional(),
|
|
21483
24500
|
defaultVariant: z.string().min(1).optional(),
|
|
21484
24501
|
variantOptions: z.record(z.string().min(1), z.object({
|
|
21485
24502
|
label: z.string().min(1).optional(),
|
|
@@ -21731,7 +24748,7 @@ const sdkCustomBlockInputSchema = z.object({
|
|
|
21731
24748
|
tags: z.array(z.string()).optional(),
|
|
21732
24749
|
fields: z.array(fieldDefinitionInputSchema).min(1),
|
|
21733
24750
|
dataLoaders: sdkDataLoadersSchema,
|
|
21734
|
-
layout: z.optional(
|
|
24751
|
+
layout: z.optional(customBlockLayoutSchema),
|
|
21735
24752
|
...sdkBlockPresentationShape,
|
|
21736
24753
|
...blockSectionDeclarationShape
|
|
21737
24754
|
}).superRefine(validateManifestLookField).superRefine(validateSdkBlockDeclaration);
|
|
@@ -24598,6 +27615,15 @@ function sharedRead(read) {
|
|
|
24598
27615
|
cachedAt: Date.now()
|
|
24599
27616
|
}));
|
|
24600
27617
|
}
|
|
27618
|
+
/**
|
|
27619
|
+
* Next prints an `unstable_cache` key in plain text when a refresh fails ("revalidating cache with key: …"),
|
|
27620
|
+
* and the request identity carries the site's secret API key. Only its SHA-256 digest reaches the framework,
|
|
27621
|
+
* which keeps one entry per URL and credential without the credential itself.
|
|
27622
|
+
*/
|
|
27623
|
+
async function frameworkCacheKey(request) {
|
|
27624
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(request));
|
|
27625
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
27626
|
+
}
|
|
24601
27627
|
async function cachePageReadResponse(input) {
|
|
24602
27628
|
if (!input.cache || input.maxAge !== undefined && input.maxAge <= 0) return input.read();
|
|
24603
27629
|
const maxAge = input.maxAge;
|
|
@@ -24605,9 +27631,10 @@ async function cachePageReadResponse(input) {
|
|
|
24605
27631
|
const policy = buildPageReadCachePolicy(input.siteId, dependencies).revalidate;
|
|
24606
27632
|
return maxAge === undefined ? policy : Math.min(policy, maxAge);
|
|
24607
27633
|
};
|
|
27634
|
+
const key = await frameworkCacheKey(input.key);
|
|
24608
27635
|
const result = await runPlan({
|
|
24609
27636
|
cache: input.cache,
|
|
24610
|
-
key
|
|
27637
|
+
key,
|
|
24611
27638
|
siteId: input.siteId,
|
|
24612
27639
|
live: sharedRead(input.read),
|
|
24613
27640
|
budgetSeconds
|
|
@@ -27693,10 +30720,17 @@ function isDemoDashboardUiRestricted(mode) {
|
|
|
27693
30720
|
const DASHBOARD_SITE_NAV_DESCRIPTORS = [
|
|
27694
30721
|
{
|
|
27695
30722
|
id: "site.overview",
|
|
27696
|
-
label: "
|
|
30723
|
+
label: "Home",
|
|
27697
30724
|
stage: "ga",
|
|
27698
30725
|
minRole: "editor"
|
|
27699
30726
|
},
|
|
30727
|
+
{
|
|
30728
|
+
id: "site.websiteOverview",
|
|
30729
|
+
label: "Overview",
|
|
30730
|
+
stage: "ga",
|
|
30731
|
+
minRole: "editor",
|
|
30732
|
+
featureFlag: "websiteEditingVisible"
|
|
30733
|
+
},
|
|
27700
30734
|
{
|
|
27701
30735
|
id: "site.appearance",
|
|
27702
30736
|
label: "Appearance",
|
|
@@ -27776,6 +30810,7 @@ const DASHBOARD_SITE_NAV_DESCRIPTORS = [
|
|
|
27776
30810
|
const hiddenDemoSiteNavSurfaceIds = ["site.newsletter"];
|
|
27777
30811
|
const hiddenDemoSiteNavIds = new Set(hiddenDemoSiteNavSurfaceIds);
|
|
27778
30812
|
const websiteSurfaceIds = [
|
|
30813
|
+
"site.websiteOverview",
|
|
27779
30814
|
"site.content",
|
|
27780
30815
|
"site.footerBlocks",
|
|
27781
30816
|
"site.navigation",
|
|
@@ -27798,10 +30833,7 @@ const bookingPageSurfaceOrder = [
|
|
|
27798
30833
|
"site.performance",
|
|
27799
30834
|
"site.settings"
|
|
27800
30835
|
];
|
|
27801
|
-
const bookingPageLabels = {
|
|
27802
|
-
"site.overview": "Home",
|
|
27803
|
-
"site.appearance": "Your page"
|
|
27804
|
-
};
|
|
30836
|
+
const bookingPageLabels = { "site.appearance": "Your page" };
|
|
27805
30837
|
function isFeatureEnabled$1(ctx, flag) {
|
|
27806
30838
|
if (flag === "websiteEditingVisible") {
|
|
27807
30839
|
return ctx.websiteEditingVisible !== false;
|
|
@@ -27814,16 +30846,53 @@ function isDemoSiteNavSurfaceVisible(mode, surfaceId) {
|
|
|
27814
30846
|
function shouldGroupWebsiteLinks(input) {
|
|
27815
30847
|
return input.bookingsVisible && (input.websiteLinks.length >= 2 || input.websiteLinks.length >= 1 && input.otherLinks.length >= 1);
|
|
27816
30848
|
}
|
|
27817
|
-
|
|
30849
|
+
/**
|
|
30850
|
+
* Whether the site's Home is the bookings glance (#1813). A booking page's
|
|
30851
|
+
* always is. A website's is once it's live and Bookings is in its menu; before
|
|
30852
|
+
* then Home is its Launch page. An SDK site has no Launch page, so its Home
|
|
30853
|
+
* is the glance whenever Bookings is in its menu.
|
|
30854
|
+
*/
|
|
30855
|
+
function homeIsGlance(input) {
|
|
30856
|
+
if (input.isSdkSite) return input.bookingsListed;
|
|
30857
|
+
if (input.publicExperience === "hosted_booking") return true;
|
|
30858
|
+
return input.launched && input.bookingsListed;
|
|
30859
|
+
}
|
|
30860
|
+
function visibleSiteNavDescriptors(ctx) {
|
|
27818
30861
|
const visibility = extractSdkDashboardNavVisibilityConfigForRole(ctx.sdkConfig, "siteNav", ctx.role);
|
|
27819
|
-
|
|
30862
|
+
return DASHBOARD_SITE_NAV_DESCRIPTORS.filter((entry) => isFeatureEnabled$1(ctx, entry.featureFlag)).filter((entry) => isDemoSiteNavSurfaceVisible(ctx.demoUiMode ?? "standard", entry.id)).filter((entry) => isNavItemVisible({
|
|
27820
30863
|
id: entry.id,
|
|
27821
30864
|
role: ctx.role ?? null,
|
|
27822
30865
|
stage: entry.stage,
|
|
27823
30866
|
minRole: entry.minRole ?? null,
|
|
27824
30867
|
config: visibility
|
|
27825
30868
|
}));
|
|
27826
|
-
|
|
30869
|
+
}
|
|
30870
|
+
/**
|
|
30871
|
+
* The site's menu and whether its Home is the glance. Where it is, the content
|
|
30872
|
+
* overview moves to Website › Overview, except on an SDK site, whose pages
|
|
30873
|
+
* aren't edited here.
|
|
30874
|
+
*/
|
|
30875
|
+
function planDashboardSiteNav(ctx) {
|
|
30876
|
+
const candidates = visibleSiteNavDescriptors(ctx);
|
|
30877
|
+
const bookingsListed = candidates.some((entry) => entry.id === "site.bookings");
|
|
30878
|
+
const isSdkSite = ctx.isSdkSite === true;
|
|
30879
|
+
const glance = homeIsGlance({
|
|
30880
|
+
publicExperience: ctx.publicExperience ?? "website",
|
|
30881
|
+
isSdkSite,
|
|
30882
|
+
launched: ctx.launched,
|
|
30883
|
+
bookingsListed
|
|
30884
|
+
});
|
|
30885
|
+
const websiteOverviewAllowed = glance && !isSdkSite;
|
|
30886
|
+
const visible = candidates.filter((entry) => entry.id !== "site.websiteOverview" || websiteOverviewAllowed);
|
|
30887
|
+
const items = ctx.publicExperience === "hosted_booking" ? arrangeBookingPageNav(visible) : arrangeWebsiteNav(visible, ctx.bookingsVisible === true);
|
|
30888
|
+
return {
|
|
30889
|
+
items,
|
|
30890
|
+
homeIsGlance: glance,
|
|
30891
|
+
websiteOverviewListed: items.flatMap((item) => item.kind === "group" ? item.items : [item]).some((link$1) => link$1.id === "site.websiteOverview")
|
|
30892
|
+
};
|
|
30893
|
+
}
|
|
30894
|
+
function buildDashboardSiteNavPlan(ctx) {
|
|
30895
|
+
return planDashboardSiteNav(ctx).items;
|
|
27827
30896
|
}
|
|
27828
30897
|
function arrangeBookingPageNav(visible) {
|
|
27829
30898
|
return bookingPageSurfaceOrder.flatMap((id$1) => {
|
|
@@ -28872,7 +31941,7 @@ function resolveDashboardBookingsNavPolicy(modules, ctx) {
|
|
|
28872
31941
|
}
|
|
28873
31942
|
return {
|
|
28874
31943
|
kind: "full",
|
|
28875
|
-
appointments:
|
|
31944
|
+
appointments: { kind: "hidden" }
|
|
28876
31945
|
};
|
|
28877
31946
|
}
|
|
28878
31947
|
function buildDashboardBookingsNavPlan(modules, ctx, catalogue) {
|
|
@@ -28881,7 +31950,7 @@ function buildDashboardBookingsNavPlan(modules, ctx, catalogue) {
|
|
|
28881
31950
|
return buildStaffScopedBookingsNavPlan(policy);
|
|
28882
31951
|
}
|
|
28883
31952
|
const hasEnabledModules = modules.appointments || modules.events;
|
|
28884
|
-
const groups = glanceGroups(hasEnabledModules, ctx.
|
|
31953
|
+
const groups = glanceGroups(hasEnabledModules, ctx.homeIsGlance);
|
|
28885
31954
|
groups.push({
|
|
28886
31955
|
label: "Events",
|
|
28887
31956
|
items: modules.events ? [
|
|
@@ -28963,6 +32032,45 @@ function listedBookingsNavGroups(groups) {
|
|
|
28963
32032
|
items: group.items.filter((item) => !item.unlisted)
|
|
28964
32033
|
})).filter((group) => group.items.length > 0);
|
|
28965
32034
|
}
|
|
32035
|
+
/**
|
|
32036
|
+
* A listed item's identity: where it leads, with the preset, section or
|
|
32037
|
+
* resource that tells two items of one kind apart. Labels vary by site
|
|
32038
|
+
* ("Events" and "All events", "My Clients" and "People"), so nothing matches on them.
|
|
32039
|
+
*/
|
|
32040
|
+
function bookingsNavItemKey(destination) {
|
|
32041
|
+
switch (destination.kind) {
|
|
32042
|
+
case "events_preset": return `${destination.kind}:${destination.preset}`;
|
|
32043
|
+
case "booking_settings": return `${destination.kind}:${destination.section}`;
|
|
32044
|
+
case "appointment_resource_availability":
|
|
32045
|
+
case "appointment_resource_calendar": return `${destination.kind}:${destination.resourceId}`;
|
|
32046
|
+
case "bookings_dashboard":
|
|
32047
|
+
case "timetable":
|
|
32048
|
+
case "appointments_calendar":
|
|
32049
|
+
case "appointment_services":
|
|
32050
|
+
case "appointment_resources":
|
|
32051
|
+
case "booking_forms":
|
|
32052
|
+
case "events_all":
|
|
32053
|
+
case "events_other":
|
|
32054
|
+
case "events_page_sections":
|
|
32055
|
+
case "venues":
|
|
32056
|
+
case "ops_site_events":
|
|
32057
|
+
case "booking_products":
|
|
32058
|
+
case "gift_cards_vouchers":
|
|
32059
|
+
case "discounts":
|
|
32060
|
+
case "booking_people":
|
|
32061
|
+
case "booking_closures": return destination.kind;
|
|
32062
|
+
}
|
|
32063
|
+
}
|
|
32064
|
+
/**
|
|
32065
|
+
* The pages a phone shows as Bookings tabs when the sidebar lists them, by item
|
|
32066
|
+
* key. The dashboard's area contribution picks the tabs from these.
|
|
32067
|
+
*/
|
|
32068
|
+
const BOOKINGS_PHONE_TAB_PRIORITY = [
|
|
32069
|
+
bookingsNavItemKey({ kind: "timetable" }),
|
|
32070
|
+
bookingsNavItemKey({ kind: "appointments_calendar" }),
|
|
32071
|
+
bookingsNavItemKey({ kind: "booking_people" }),
|
|
32072
|
+
bookingsNavItemKey({ kind: "events_all" })
|
|
32073
|
+
];
|
|
28966
32074
|
const BOOKING_SETTINGS_SECTION_KEYWORDS = {
|
|
28967
32075
|
basics: [
|
|
28968
32076
|
"defaults",
|
|
@@ -29021,25 +32129,6 @@ function buildBookingSettingsNavItem(modules) {
|
|
|
29021
32129
|
}
|
|
29022
32130
|
function buildAppointmentsNavGroup(policy, soloSite) {
|
|
29023
32131
|
if (policy.kind === "hidden") return null;
|
|
29024
|
-
if (policy.kind === "owner_setup") {
|
|
29025
|
-
return {
|
|
29026
|
-
label: "Appointments",
|
|
29027
|
-
items: [{
|
|
29028
|
-
label: "Enable appointments",
|
|
29029
|
-
destination: {
|
|
29030
|
-
kind: "booking_settings",
|
|
29031
|
-
section: "basics"
|
|
29032
|
-
},
|
|
29033
|
-
keywords: [
|
|
29034
|
-
"enable",
|
|
29035
|
-
"setup",
|
|
29036
|
-
"activate",
|
|
29037
|
-
"appointments",
|
|
29038
|
-
"get started"
|
|
29039
|
-
]
|
|
29040
|
-
}]
|
|
29041
|
-
};
|
|
29042
|
-
}
|
|
29043
32132
|
return {
|
|
29044
32133
|
label: "Appointments",
|
|
29045
32134
|
items: [
|
|
@@ -29115,16 +32204,19 @@ function closuresNavItem(solo) {
|
|
|
29115
32204
|
]
|
|
29116
32205
|
};
|
|
29117
32206
|
}
|
|
29118
|
-
/**
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
|
|
32207
|
+
/**
|
|
32208
|
+
* At a glance: the bookings Overview, and the Timetable once anything can be
|
|
32209
|
+
* booked. Where the glance is Home and there are no modules, there's nothing
|
|
32210
|
+
* here, so the group goes rather than sitting empty.
|
|
32211
|
+
*/
|
|
32212
|
+
function glanceGroups(hasEnabledModules, homeIsGlance$1) {
|
|
32213
|
+
const group = buildOverviewNavGroup(hasEnabledModules, homeIsGlance$1);
|
|
29122
32214
|
return group.items.length > 0 ? [group] : [];
|
|
29123
32215
|
}
|
|
29124
|
-
function buildOverviewNavGroup(hasEnabledModules,
|
|
32216
|
+
function buildOverviewNavGroup(hasEnabledModules, homeIsGlance$1) {
|
|
29125
32217
|
return {
|
|
29126
32218
|
label: "At a glance",
|
|
29127
|
-
items: [...
|
|
32219
|
+
items: [...homeIsGlance$1 ? [] : [{
|
|
29128
32220
|
label: "Overview",
|
|
29129
32221
|
destination: { kind: "bookings_dashboard" },
|
|
29130
32222
|
keywords: [
|
|
@@ -29285,7 +32377,7 @@ function buildPageSectionsNavItems(ctx) {
|
|
|
29285
32377
|
"event template",
|
|
29286
32378
|
"faq"
|
|
29287
32379
|
],
|
|
29288
|
-
|
|
32380
|
+
unlisted: true
|
|
29289
32381
|
}];
|
|
29290
32382
|
}
|
|
29291
32383
|
function buildEventSeriesPresetNavItem(entry) {
|
|
@@ -35687,4 +38779,4 @@ function optionalTitle(data) {
|
|
|
35687
38779
|
}
|
|
35688
38780
|
|
|
35689
38781
|
//#endregion
|
|
35690
|
-
export { walkLocalContentMedia as $,
|
|
38782
|
+
export { walkLocalContentMedia as $, ManagementApiError as $n, eventCalendarDisplayModeValues as $r, commandContexts as $t, formatDiffSummary as A, isLocalConfigured as An, roomOccupancySchema as Ar, navigationIdentityMap as At, formatFieldChange as B, customLayoutSizeProblem as Bn, unsafeAsPositiveCheckoutQuantity as Br, ACCOUNT_SITE_SEARCH_MAX_LENGTH as Bt, reportFromOutcomes as C, ErrorCodes as Cn, roomsOfferSharing as Cr, listFiles as Ct, calculateDiff as D, createOutput as Dn, reviewedStay as Dr, isMediaValue as Dt, createEmptySyncResult as E, CliExit as En, placeBooking as Er, writeJsonFileAtomic as Et, buildJsonDiff as F, cardListKnobBlocks as Fn, eventRegistrationErrors as Fr, createBearerAccountApi as Ft, applyLocalMediaPush as G, fieldSchema as Gn, isBookingCollectionEquivalentToUpfront as Gr, createPushConfigCommand as Gt, revalidateLocalMediaPushPlan as H, blockCategoryEnum as Hn, planFlexibleBalanceCreditFirst as Hr, navigationCommandItemToManagementInput as Ht, hasPageOperations as I, lookKnobBlocks as In, placementProblemText as Ir, ACCOUNT_SITE_CURSOR_MAX_LENGTH as It, readStableBinaryFile as J, parseRepeaterGridInteger as Jn, resolveBookingCollectionOptionFacts as Jr, revalidatePushConfigPlan as Jt, prepareLocalMediaForPush as K, MAX_REPEATER_GRID_COLUMNS as Kn, repriceBookingCollectionOptions as Kr, loadPushConfigTarget as Kt, pageMetadataForUpsert as L, NodeSchema as Ln, stayLineText as Lr, ACCOUNT_SITE_LIST_LIMIT_DEFAULT as Lt, findChangedFieldsWithValues as M, loadSdkEnvironment as Mn, sharedRoomArrangementSchema as Mr, convertPulledNavigationToLocal as Mt, formatHumanDiff as N, cardListBlockParts as Nn, nextCombinationHint as Nr, convertPulledPagesToLocal as Nt, calculateFooterDiff as O, getEnvPrefix as On, reviewedRoomsSchema as Or, duplicateNavigationIdentityMessage as Ot, calculatePullDiff as P, cardListFamilyBlocks as Pn, planSelectionCombinationPrices as Pr, AccountApiMalformedResponseError as Pt, normalizeMediaValueToIdentifierOnly as Q, visibilityLevels as Qn, eventCalendarDefaultViewValues as Qr, CommandFailure as Qt, calculateEntryDiffs as R, NodeTreeSchema as Rn, stayNoteText as Rr, ACCOUNT_SITE_LIST_LIMIT_MAX as Rt, planCliCommandBatchForBindings as S, withRiverbankEnv as Sn, roomKindOptions as Sr, fileExists$1 as St, executeResidualSettingsSyncPlan as T, transportSuggestion as Tn, countSoFar as Tr, writeJsonFile$1 as Tt, syncLocalMediaForPush as U, blockContentSourceSchema as Un, bookingCollectionDatesOpen as Ur, normalizeNavigationConfigItemForCommand as Ut, formatFieldPath as V, DEFAULT_MEDIA_FIELD_KINDS as Vn, planCheckoutPaymentFlow as Vr, ACCOUNT_SITE_TITLE_MAX_LENGTH as Vt, syncLocalMediaForPull as W, blockRequiredFeatureSchema as Wn, flexibleBalanceDueDay as Wr, applyPushConfigPlan as Wt, sha256 as X, resolveRepeaterGridRowFieldId as Xn, getBookingLaterInstalments as Xr, deriveCmsApiUrlFromDashboardUrl as Xt, writeBinaryFileAtomic as Y, resolveRepeaterGridColumnFieldId as Yn, getStripeMinimumChargeRequirement as Yr, createBearerAPIClient as Yt, normalizeMediaIdentifierInput as Z, resolveRepeaterGridSpanFieldId as Zn, MAX_EVENT_BOOKING_SELECTION_ITEMS as Zr, mapEnvironmentExecutionOutcomesJson as Zt, commandExecutionToReport as _, normalizeCalendarFilterId as _i, executeEnvironmentPlan as _n, bookingQuestionsAnswerValueSchema as _r, metadataTargetFromEnvironment as _t, executeEntryCommandPlanAsReport as a, publicPassProductSchema as ai, confirmAction as an, sdkSettingsUpdateSchema as ar, readAllMeta as at, executeCompiledCliCommandPlanAsReport as b, unwrapResponse as bi, planEnvironmentWriteAuthorization as bn, checkoutStatusArms as br, writeMetadataRecordMap as bt, titleFromEntryData as c, purchasablePublicPassProductSchema as ci, formatDateShort as cn, pageDesignDecisionsV2Schema as cr, readFooterMeta as ct, unsafeAsCliEntryIdentifier as d, calendarMonthWindowSchema as di, managementClientFor as dn, API_ENDPOINTS as dr, readPagesMeta as dt, eventCalendarListLayoutCompatibleDisplayModeValues as ei, defineCommand as en, extractApiErrorMessage as er, buildStorageUrl as et, unsafeAsCliFormSlug as f, calendarSourceCursorSchema as fi, mapEntryForOutput as fn, areEventBookingRequirementsIdentical as fr, readSettingsMeta as ft, commandCompileFailureToReport as g, monthNumber as gi, runWithInvocation as gn, resolveSelectionAttendanceMode as gr, metadataFilePath as gt, mutationCounterForEffect as h, eventSurfaceScopeValues as hi, resolveCommandPath as hn, decideSelectionAttendance as hr, ensureMetadataDir as ht, entrySiteCommandTypes as i, publicMembershipProductSchema as ii, bindRequestTimeout as in, sdkEventScheduleSchema as ir, readEntries as it, hasPendingChanges as j, isRemoteConfigured as jn, roomSetupSchema as jr, convertPulledFooterToLocal as jt, formatDiffDetail as k, getEnvironmentDebugInfo as kn, roomChoicesSchema as kr, navigationIdentity as kt, unsafeAsCliBlockIdentifier as l, CALENDAR_SSR_PAGE_SIZE as li, handleCommandError as ln, pageDesignIntentSchemaVersion as lr, readFormsMeta as lt, commandReportToSyncResult as m, eventSurfacePresetValues as mi, parseJsonData as mn, INCOMPATIBLE_ATTENDANCE_MESSAGE as mr, writeMediaManifest as mt, entryCommandCompileErrorToReport as n, publicMapLocationResultSchema as ni, registerCommand as nn, isRecord$5 as nr, extractMediaIdentifiers as nt, executeEntryCommandPlanAsSyncResult as o, publicProductSchema as oi, createOutputForCommand as on, linkPayloadSchema as or, readEventCategoriesMeta as ot, unsafeAsCliPageIdentifier as p, eventScheduleScopeValues as pi, parseJsonArray as pn, eventBookingConsentContentKey as pr, readVenuesMeta as pt, admitBinaryWriteDestination as q, isAcceptedRepeaterGridSpan as qn, resolveAvailableBookingCollectionOptions as qr, preparePushConfigTarget as qt, entryCommandReportToSyncResult as r, publicVenueMapLocationSchema as ri, renderedByOwner as rn, ApiRequestError as rr, findLegacyEntryFiles as rt, syncResultForEntryCommandCompileError as s, purchasablePublicMembershipProductSchema as si, currentInvocationEnvelope as sn, portablePageDesignSchema as sr, readEventsMeta as st, compileEntryPushCommands as t, eventCalendarListLayoutValues as ti, defineCommandGroup as tn, normalizeApiError as tr, downloadMedia as tt, unsafeAsCliContentTypeKey as u, calendarMonthDate as ui, loadManagementTarget as un, sdkConfiguredBookingVerticalConfigSchema as ur, readNavigationMeta as ut, commandReportHasFailures as v, publicEventLoaderQuerySchemaShape as vi, parseEnvironmentSelection as vn, bookingQuestionsAnswersSchema as vr, readMetadataFile as vt, mergeManySyncResults as w, formatError as wn, sameRoomOption as wr, readJsonFile as wt, formatManagementError as x, requireEnvironmentWriteAuthorization as xn, placesLeftText as xr, ensureDir$1 as xt, executeCliCommandPlan as y, ApiEnvelopeError as yi, planEnvironmentExecution as yn, bookingQuestionsSectionSchema as yr, writeMetadataFile as yt, buildFieldChanges as z, bindingSchema as zn, checkoutCopy as zr, ACCOUNT_SITE_LIST_LIMIT_MIN as zt };
|