@peektravel/app-utilities 0.5.0 → 0.5.1

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/index.d.cts CHANGED
@@ -95,6 +95,14 @@ interface Product {
95
95
  * Add-ons default to white (`"#FFFFFF"`). Empty string when no color is set.
96
96
  */
97
97
  color: string;
98
+ /**
99
+ * ISO 4217 currency code the activity prices in (e.g. `"USD"`).
100
+ *
101
+ * Populated for activities and rentals; empty string for add-ons (which carry
102
+ * no currency of their own) and when Peek reports none. Consumers building
103
+ * pricing overrides use this to set the currency on fixed-price adjustments.
104
+ */
105
+ currency: string;
98
106
  /**
99
107
  * The bookable sub-options of this product.
100
108
  *
@@ -1000,6 +1008,237 @@ interface AvailabilityTimesQuery {
1000
1008
  resourceOptionQuantities: ResourceOptionQuantity[];
1001
1009
  }
1002
1010
 
1011
+ /**
1012
+ * The clean data model for Peek Pro pricing engines and pricing overrides.
1013
+ *
1014
+ * A **pricing engine** is a named container Peek Pro applies at checkout. A
1015
+ * caller creates one lazily, stores its id, then repeatedly **upserts pricing
1016
+ * overrides** onto it for a given date range. Overrides adjust ticket prices
1017
+ * (fixed replacement or percentage adjustment) for an activity, optionally
1018
+ * gated by how many spots are already taken and/or a start-time window.
1019
+ *
1020
+ * Scope note: this package is a thin wrapper over the Peek GraphQL primitives.
1021
+ * It does **not** own the domain logic that decides *what* the overrides should
1022
+ * be — segmenting an activity across time windows, ordering overrides by tier,
1023
+ * or computing the `spotsTaken` bounds. The caller builds an
1024
+ * {@link UpsertOverridesInput} and the service sends it faithfully; the service
1025
+ * only maps between these clean shapes and the raw GraphQL payload.
1026
+ */
1027
+ /**
1028
+ * A monetary value on a pricing override.
1029
+ *
1030
+ * `amount` is intentionally a **string** (e.g. `"50.00"`), never a number — the
1031
+ * Peek API rejects floats here, and stringly-typed money avoids precision loss.
1032
+ */
1033
+ interface PricingMoney {
1034
+ /** Numeric amount as a decimal string (e.g. `"50.00"`). */
1035
+ amount: string;
1036
+ /** ISO 4217 currency code (e.g. `"USD"`). */
1037
+ currency: string;
1038
+ }
1039
+ /** An `{ id, name }` reference to a Peek entity echoed back in a response. */
1040
+ interface PricingNamedRef {
1041
+ /** Stable Peek identifier. */
1042
+ id: string;
1043
+ /** Human-readable display name. */
1044
+ name: string;
1045
+ }
1046
+ /** Input for creating a pricing engine. */
1047
+ interface CreateEngineInput {
1048
+ /** Display name for the engine. */
1049
+ name: string;
1050
+ /**
1051
+ * Optional list of activity ids the engine is scoped to. Omit (or pass an
1052
+ * empty array) to create an unfiltered engine that applies to all activities.
1053
+ */
1054
+ activityIds?: string[];
1055
+ }
1056
+ /**
1057
+ * The result of creating a pricing engine.
1058
+ *
1059
+ * The create mutation returns only the new engine's id; store it as the
1060
+ * schedule's `source_refid` for subsequent override upserts.
1061
+ */
1062
+ interface CreatedPricingEngine {
1063
+ /** The new engine's id. */
1064
+ id: string;
1065
+ }
1066
+ /** Input for updating a pricing engine's name and/or activity scope. */
1067
+ interface UpdateEngineInput {
1068
+ /** The engine to update. */
1069
+ engineId: string;
1070
+ /** New display name. */
1071
+ name: string;
1072
+ /**
1073
+ * Activity ids the engine should be scoped to. An empty array (or omitting
1074
+ * the field) **clears** the filter so the engine applies to all activities.
1075
+ */
1076
+ activityIds?: string[];
1077
+ }
1078
+ /** A pricing engine reference as echoed back by the API. */
1079
+ interface PricingEngine {
1080
+ /** Engine id. */
1081
+ id: string;
1082
+ /** Engine display name. */
1083
+ name: string;
1084
+ }
1085
+ /**
1086
+ * A single ticket (resourceOption) price override, discriminated by `mode`.
1087
+ *
1088
+ * - `fixed` — replace the ticket price outright with {@link PricingMoney}.
1089
+ * - `percentage` — adjust the ticket price by a percentage. The adjustment is a
1090
+ * decimal **string** (e.g. `"-25"` for 25% off) and must be greater than
1091
+ * `-100`.
1092
+ */
1093
+ type ResourceOptionOverride = {
1094
+ /** The Peek resourceOption (ticket) id being overridden. */
1095
+ id: string;
1096
+ mode: "fixed";
1097
+ /** The replacement price. */
1098
+ price: PricingMoney;
1099
+ } | {
1100
+ /** The Peek resourceOption (ticket) id being overridden. */
1101
+ id: string;
1102
+ mode: "percentage";
1103
+ /** Percentage adjustment as a decimal string, e.g. `"-25"`. Must be > -100. */
1104
+ percentageAdjustment: string;
1105
+ };
1106
+ /**
1107
+ * A filter gating when an override applies. Both variants are optional and an
1108
+ * override may carry zero, one, or both.
1109
+ */
1110
+ type PricingOverrideFilter = {
1111
+ /**
1112
+ * Restricts the override by how many spots are already taken.
1113
+ *
1114
+ * `minSpots`/`maxSpots` are **zero-indexed spots-taken counts**, not
1115
+ * ticket counts — e.g. "applies from the 5th ticket onward" is
1116
+ * `{ minSpots: 4 }`. The caller is responsible for this off-by-one
1117
+ * conversion from ticket-count ranges.
1118
+ */
1119
+ spotsTaken: {
1120
+ /** Lower bound (inclusive) on spots already taken. Omit for no lower bound. */
1121
+ minSpots?: number;
1122
+ /** Upper bound (inclusive) on spots already taken. Omit for no upper bound. */
1123
+ maxSpots?: number;
1124
+ };
1125
+ } | {
1126
+ /**
1127
+ * Restricts the override to a start-time window, as a PostgreSQL-style
1128
+ * inclusive range string `"[HH:MM:SS,HH:MM:SS]"`.
1129
+ */
1130
+ startTimeRange: string;
1131
+ };
1132
+ /**
1133
+ * One override entry for an activity: which tickets it adjusts, in what order,
1134
+ * under which filters.
1135
+ */
1136
+ interface PricingOverride {
1137
+ /**
1138
+ * The override's precedence index (0-based). The caller assigns this — Peek
1139
+ * evaluates lower `order` values first, so higher-discount / more-specific
1140
+ * tiers should get lower numbers.
1141
+ */
1142
+ order: number;
1143
+ /** The per-ticket price overrides applied by this entry. */
1144
+ resourceOptions: ResourceOptionOverride[];
1145
+ /** Zero or more filters gating when this entry applies. */
1146
+ filters: PricingOverrideFilter[];
1147
+ }
1148
+ /** The set of overrides to apply for a single activity. */
1149
+ interface ActivityOverrides {
1150
+ /** The Peek activity id these overrides apply to. */
1151
+ activityId: string;
1152
+ /**
1153
+ * The overrides for this activity. Pass an **empty array to clear** all
1154
+ * overrides for the activity — never omit the activity to clear it.
1155
+ */
1156
+ overrides: PricingOverride[];
1157
+ }
1158
+ /**
1159
+ * The full input for upserting pricing overrides onto an engine.
1160
+ *
1161
+ * Mirrors the Peek `upsertPricingOverridesActivityContexts` input verbatim. The
1162
+ * caller owns all segmentation and ordering; the service sends this as-is.
1163
+ */
1164
+ interface UpsertOverridesInput {
1165
+ /** The engine to write overrides to (its {@link CreatedPricingEngine.id}). */
1166
+ engineId: string;
1167
+ /**
1168
+ * The date range the overrides apply to, as a PostgreSQL-style inclusive
1169
+ * range string. For a single day, both ends are the same: `"[2025-07-04,2025-07-04]"`.
1170
+ */
1171
+ dateRange: string;
1172
+ /** One entry per activity being written (or cleared). */
1173
+ activities: ActivityOverrides[];
1174
+ }
1175
+ /**
1176
+ * Convenience input for clearing all overrides across a set of activities for a
1177
+ * date range. Equivalent to an {@link UpsertOverridesInput} whose every
1178
+ * activity carries `overrides: []`.
1179
+ */
1180
+ interface ClearOverridesInput {
1181
+ /** The engine to clear overrides on. */
1182
+ engineId: string;
1183
+ /** The date range to clear, same format as {@link UpsertOverridesInput.dateRange}. */
1184
+ dateRange: string;
1185
+ /** The activity ids to clear. Recover these from a prior sync's payload. */
1186
+ activityIds: string[];
1187
+ }
1188
+ /**
1189
+ * A ticket price override as **resolved** by Peek, discriminated by `mode`.
1190
+ *
1191
+ * This normalizes Peek's GraphQL union (a `price` object vs a bare
1192
+ * `percentageAdjustment`) into the same `mode`-tagged shape used on input.
1193
+ */
1194
+ type ResolvedOverride = {
1195
+ mode: "fixed";
1196
+ /** The resolved replacement price. */
1197
+ price: PricingMoney;
1198
+ } | {
1199
+ mode: "percentage";
1200
+ /** The resolved percentage adjustment as a decimal string. */
1201
+ percentageAdjustment: string;
1202
+ };
1203
+ /** A single ticket's resolved override within a returned context. */
1204
+ interface ResolvedResourceOption {
1205
+ /** The ticket (resourceOption) this override resolved for. */
1206
+ resourceOption: PricingNamedRef;
1207
+ /** The resolved fixed or percentage override. */
1208
+ override: ResolvedOverride;
1209
+ }
1210
+ /** A single resolved override entry within a returned activity context. */
1211
+ interface ResolvedPricingOverride {
1212
+ /** The override's precedence index as stored by Peek. */
1213
+ order: number;
1214
+ /** The resolved per-ticket overrides. */
1215
+ resourceOptions: ResolvedResourceOption[];
1216
+ /**
1217
+ * The filters gating this override, normalized to the same shape as the
1218
+ * {@link PricingOverrideFilter} used on input.
1219
+ */
1220
+ filters: PricingOverrideFilter[];
1221
+ }
1222
+ /**
1223
+ * The resolved pricing state for one activity on one date, as returned by an
1224
+ * upsert or clear. Useful as an audit record of exactly what Peek stored.
1225
+ */
1226
+ interface PricingActivityContext {
1227
+ /** The date the context applies to (ISO `YYYY-MM-DD`). */
1228
+ date: string;
1229
+ /** The activity the overrides belong to. */
1230
+ activity: PricingNamedRef;
1231
+ /** The engine the overrides live under. */
1232
+ engine: PricingNamedRef;
1233
+ /** The resolved overrides (empty when the date was cleared). */
1234
+ overrides: ResolvedPricingOverride[];
1235
+ }
1236
+ /** The result of an upsert or clear: the resolved contexts Peek returned. */
1237
+ interface UpsertOverridesResult {
1238
+ /** One entry per activity written or cleared in the request. */
1239
+ activityContexts: PricingActivityContext[];
1240
+ }
1241
+
1003
1242
  /**
1004
1243
  * The clean data model for Peek Pro promo codes.
1005
1244
  */
@@ -1469,6 +1708,39 @@ declare class PromoCodeService {
1469
1708
  create(input: CreatePromoCodeInput): Promise<CreatedPromoCode>;
1470
1709
  }
1471
1710
 
1711
+ declare class PricingService {
1712
+ private readonly client;
1713
+ constructor(client: GraphQLClient);
1714
+ /**
1715
+ * Creates a pricing engine. Store the returned id and reuse it on every
1716
+ * subsequent override upsert. Throws on an InvalidDataError from Peek.
1717
+ */
1718
+ createEngine(input: CreateEngineInput): Promise<CreatedPricingEngine>;
1719
+ /**
1720
+ * Updates a pricing engine's name and/or activity scope. Throws on an
1721
+ * InvalidDataError or NotFoundError from Peek.
1722
+ */
1723
+ updateEngine(input: UpdateEngineInput): Promise<PricingEngine>;
1724
+ /**
1725
+ * Deletes a pricing engine. Idempotent — resolves whether the engine existed
1726
+ * or was already gone (Peek's NotFoundError is treated as success).
1727
+ */
1728
+ deleteEngine(engineId: string): Promise<void>;
1729
+ /**
1730
+ * Upserts pricing overrides for the engine and date range in `input`. Returns
1731
+ * the resolved contexts Peek stored. Throws on an InvalidDataError from Peek.
1732
+ */
1733
+ upsertOverrides(input: UpsertOverridesInput): Promise<UpsertOverridesResult>;
1734
+ /**
1735
+ * Clears all overrides for the given activities across a date range. This is
1736
+ * an upsert with empty overrides — never clear by omitting an activity.
1737
+ */
1738
+ clearOverrides(input: ClearOverridesInput): Promise<UpsertOverridesResult>;
1739
+ private sendUpsert;
1740
+ private validateUpsertInput;
1741
+ private validateResourceOption;
1742
+ }
1743
+
1472
1744
  /**
1473
1745
  * Platform that embedded the app for this session. Verification is
1474
1746
  * brand-agnostic — one peek-auth JWT is minted for every platform — so this
@@ -1557,6 +1829,7 @@ declare class PeekAccessService {
1557
1829
  private timeslotService?;
1558
1830
  private resellerService?;
1559
1831
  private promoCodeService?;
1832
+ private pricingService?;
1560
1833
  private dailyNoteService?;
1561
1834
  private availabilityService?;
1562
1835
  private membershipService?;
@@ -1613,6 +1886,11 @@ declare class PeekAccessService {
1613
1886
  * authenticated transport. The instance is created lazily and reused.
1614
1887
  */
1615
1888
  getPromoCodeService(): PromoCodeService;
1889
+ /**
1890
+ * Returns the {@link PricingService} for this install, bound to the shared
1891
+ * authenticated transport. The instance is created lazily and reused.
1892
+ */
1893
+ getPricingService(): PricingService;
1616
1894
  /**
1617
1895
  * Returns the {@link DailyNoteService} for this install, bound to the shared
1618
1896
  * authenticated transport. The instance is created lazily and reused.
@@ -1668,6 +1946,16 @@ declare class PeekAccessService {
1668
1946
  getAllPromoCodes(): Promise<PromoCode[]>;
1669
1947
  /** Create a promo code. Delegates to {@link PromoCodeService.create}. */
1670
1948
  createPromoCode(input: CreatePromoCodeInput): Promise<CreatedPromoCode>;
1949
+ /** Create a pricing engine. Delegates to {@link PricingService.createEngine}. */
1950
+ createPricingEngine(input: CreateEngineInput): Promise<CreatedPricingEngine>;
1951
+ /** Update a pricing engine. Delegates to {@link PricingService.updateEngine}. */
1952
+ updatePricingEngine(input: UpdateEngineInput): Promise<PricingEngine>;
1953
+ /** Delete a pricing engine (idempotent). Delegates to {@link PricingService.deleteEngine}. */
1954
+ deletePricingEngine(engineId: string): Promise<void>;
1955
+ /** Upsert pricing overrides. Delegates to {@link PricingService.upsertOverrides}. */
1956
+ upsertPricingOverrides(input: UpsertOverridesInput): Promise<UpsertOverridesResult>;
1957
+ /** Clear pricing overrides for a set of activities. Delegates to {@link PricingService.clearOverrides}. */
1958
+ clearPricingOverrides(input: ClearOverridesInput): Promise<UpsertOverridesResult>;
1671
1959
  /** Today's daily note. Delegates to {@link DailyNoteService.getToday}. */
1672
1960
  getDailyNoteToday(): Promise<DailyNote | null>;
1673
1961
  /** Update today's daily note. Delegates to {@link DailyNoteService.update}. */
@@ -2129,4 +2417,4 @@ declare class AcmeApiError extends Error {
2129
2417
  constructor(statusCode: number, body: unknown, message?: string);
2130
2418
  }
2131
2419
 
2132
- export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, type AccessOptions, type AccountUser, AccountUserService, type AccountUserServiceOptions, AcmeAccessService, type AcmeAccessServiceConfig, type AcmeActivity, type AcmeActivityTicket, AcmeApiError, AcmeProductService, type Activity, type ActivityTicket, type AddAddonInput, AdminAccountRequiredError, type Agent, type AssignGuideResult, type AssignedActivity, type AssignedResource, type Availability, AvailabilityService, type AvailabilityTime, type AvailabilityTimesQuery, type Booking, type BookingAddon, type BookingAddonMoney, type BookingAddonOption, type BookingAddons, type BookingAddonsMutationResult, type BookingPaymentsOnFile, type BookingReadOptions, type BookingSearchBy, BookingService, type BookingServiceOptions, type BookingTimeRangeSearch, type CancelBookingResult, type Channel, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreatePromoCodeInput, type CreatedBooking, type CreatedPromoCode, type CustomQuestionAnswer, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, type InvoiceLinkResult, type Logger, type MakePaymentInput, type MakePaymentResult, type Membership, type MembershipPurchaseInput, MembershipService, type NoteMode, type Payment, type PaymentSource, PeekAccessService, type PeekAccessServiceConfig, type PeekAuthTokenClaims, type PeekAuthTokenUser, PeekGraphQLError, type PeekPlatform, PiiAccessDisabledError, type Price, type Product, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type Resource, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateTimeslotResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };
2420
+ export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, type AccessOptions, type AccountUser, AccountUserService, type AccountUserServiceOptions, AcmeAccessService, type AcmeAccessServiceConfig, type AcmeActivity, type AcmeActivityTicket, AcmeApiError, AcmeProductService, type Activity, type ActivityOverrides, type ActivityTicket, type AddAddonInput, AdminAccountRequiredError, type Agent, type AssignGuideResult, type AssignedActivity, type AssignedResource, type Availability, AvailabilityService, type AvailabilityTime, type AvailabilityTimesQuery, type Booking, type BookingAddon, type BookingAddonMoney, type BookingAddonOption, type BookingAddons, type BookingAddonsMutationResult, type BookingPaymentsOnFile, type BookingReadOptions, type BookingSearchBy, BookingService, type BookingServiceOptions, type BookingTimeRangeSearch, type CancelBookingResult, type Channel, type ClearOverridesInput, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreateEngineInput, type CreatePromoCodeInput, type CreatedBooking, type CreatedPricingEngine, type CreatedPromoCode, type CustomQuestionAnswer, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, type InvoiceLinkResult, type Logger, type MakePaymentInput, type MakePaymentResult, type Membership, type MembershipPurchaseInput, MembershipService, type NoteMode, type Payment, type PaymentSource, PeekAccessService, type PeekAccessServiceConfig, type PeekAuthTokenClaims, type PeekAuthTokenUser, PeekGraphQLError, type PeekPlatform, PiiAccessDisabledError, type Price, type PricingActivityContext, type PricingEngine, type PricingMoney, type PricingNamedRef, type PricingOverride, type PricingOverrideFilter, PricingService, type Product, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type ResolvedOverride, type ResolvedPricingOverride, type ResolvedResourceOption, type Resource, type ResourceOptionOverride, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateEngineInput, type UpdateTimeslotResult, type UpsertOverridesInput, type UpsertOverridesResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };
package/dist/index.d.ts CHANGED
@@ -95,6 +95,14 @@ interface Product {
95
95
  * Add-ons default to white (`"#FFFFFF"`). Empty string when no color is set.
96
96
  */
97
97
  color: string;
98
+ /**
99
+ * ISO 4217 currency code the activity prices in (e.g. `"USD"`).
100
+ *
101
+ * Populated for activities and rentals; empty string for add-ons (which carry
102
+ * no currency of their own) and when Peek reports none. Consumers building
103
+ * pricing overrides use this to set the currency on fixed-price adjustments.
104
+ */
105
+ currency: string;
98
106
  /**
99
107
  * The bookable sub-options of this product.
100
108
  *
@@ -1000,6 +1008,237 @@ interface AvailabilityTimesQuery {
1000
1008
  resourceOptionQuantities: ResourceOptionQuantity[];
1001
1009
  }
1002
1010
 
1011
+ /**
1012
+ * The clean data model for Peek Pro pricing engines and pricing overrides.
1013
+ *
1014
+ * A **pricing engine** is a named container Peek Pro applies at checkout. A
1015
+ * caller creates one lazily, stores its id, then repeatedly **upserts pricing
1016
+ * overrides** onto it for a given date range. Overrides adjust ticket prices
1017
+ * (fixed replacement or percentage adjustment) for an activity, optionally
1018
+ * gated by how many spots are already taken and/or a start-time window.
1019
+ *
1020
+ * Scope note: this package is a thin wrapper over the Peek GraphQL primitives.
1021
+ * It does **not** own the domain logic that decides *what* the overrides should
1022
+ * be — segmenting an activity across time windows, ordering overrides by tier,
1023
+ * or computing the `spotsTaken` bounds. The caller builds an
1024
+ * {@link UpsertOverridesInput} and the service sends it faithfully; the service
1025
+ * only maps between these clean shapes and the raw GraphQL payload.
1026
+ */
1027
+ /**
1028
+ * A monetary value on a pricing override.
1029
+ *
1030
+ * `amount` is intentionally a **string** (e.g. `"50.00"`), never a number — the
1031
+ * Peek API rejects floats here, and stringly-typed money avoids precision loss.
1032
+ */
1033
+ interface PricingMoney {
1034
+ /** Numeric amount as a decimal string (e.g. `"50.00"`). */
1035
+ amount: string;
1036
+ /** ISO 4217 currency code (e.g. `"USD"`). */
1037
+ currency: string;
1038
+ }
1039
+ /** An `{ id, name }` reference to a Peek entity echoed back in a response. */
1040
+ interface PricingNamedRef {
1041
+ /** Stable Peek identifier. */
1042
+ id: string;
1043
+ /** Human-readable display name. */
1044
+ name: string;
1045
+ }
1046
+ /** Input for creating a pricing engine. */
1047
+ interface CreateEngineInput {
1048
+ /** Display name for the engine. */
1049
+ name: string;
1050
+ /**
1051
+ * Optional list of activity ids the engine is scoped to. Omit (or pass an
1052
+ * empty array) to create an unfiltered engine that applies to all activities.
1053
+ */
1054
+ activityIds?: string[];
1055
+ }
1056
+ /**
1057
+ * The result of creating a pricing engine.
1058
+ *
1059
+ * The create mutation returns only the new engine's id; store it as the
1060
+ * schedule's `source_refid` for subsequent override upserts.
1061
+ */
1062
+ interface CreatedPricingEngine {
1063
+ /** The new engine's id. */
1064
+ id: string;
1065
+ }
1066
+ /** Input for updating a pricing engine's name and/or activity scope. */
1067
+ interface UpdateEngineInput {
1068
+ /** The engine to update. */
1069
+ engineId: string;
1070
+ /** New display name. */
1071
+ name: string;
1072
+ /**
1073
+ * Activity ids the engine should be scoped to. An empty array (or omitting
1074
+ * the field) **clears** the filter so the engine applies to all activities.
1075
+ */
1076
+ activityIds?: string[];
1077
+ }
1078
+ /** A pricing engine reference as echoed back by the API. */
1079
+ interface PricingEngine {
1080
+ /** Engine id. */
1081
+ id: string;
1082
+ /** Engine display name. */
1083
+ name: string;
1084
+ }
1085
+ /**
1086
+ * A single ticket (resourceOption) price override, discriminated by `mode`.
1087
+ *
1088
+ * - `fixed` — replace the ticket price outright with {@link PricingMoney}.
1089
+ * - `percentage` — adjust the ticket price by a percentage. The adjustment is a
1090
+ * decimal **string** (e.g. `"-25"` for 25% off) and must be greater than
1091
+ * `-100`.
1092
+ */
1093
+ type ResourceOptionOverride = {
1094
+ /** The Peek resourceOption (ticket) id being overridden. */
1095
+ id: string;
1096
+ mode: "fixed";
1097
+ /** The replacement price. */
1098
+ price: PricingMoney;
1099
+ } | {
1100
+ /** The Peek resourceOption (ticket) id being overridden. */
1101
+ id: string;
1102
+ mode: "percentage";
1103
+ /** Percentage adjustment as a decimal string, e.g. `"-25"`. Must be > -100. */
1104
+ percentageAdjustment: string;
1105
+ };
1106
+ /**
1107
+ * A filter gating when an override applies. Both variants are optional and an
1108
+ * override may carry zero, one, or both.
1109
+ */
1110
+ type PricingOverrideFilter = {
1111
+ /**
1112
+ * Restricts the override by how many spots are already taken.
1113
+ *
1114
+ * `minSpots`/`maxSpots` are **zero-indexed spots-taken counts**, not
1115
+ * ticket counts — e.g. "applies from the 5th ticket onward" is
1116
+ * `{ minSpots: 4 }`. The caller is responsible for this off-by-one
1117
+ * conversion from ticket-count ranges.
1118
+ */
1119
+ spotsTaken: {
1120
+ /** Lower bound (inclusive) on spots already taken. Omit for no lower bound. */
1121
+ minSpots?: number;
1122
+ /** Upper bound (inclusive) on spots already taken. Omit for no upper bound. */
1123
+ maxSpots?: number;
1124
+ };
1125
+ } | {
1126
+ /**
1127
+ * Restricts the override to a start-time window, as a PostgreSQL-style
1128
+ * inclusive range string `"[HH:MM:SS,HH:MM:SS]"`.
1129
+ */
1130
+ startTimeRange: string;
1131
+ };
1132
+ /**
1133
+ * One override entry for an activity: which tickets it adjusts, in what order,
1134
+ * under which filters.
1135
+ */
1136
+ interface PricingOverride {
1137
+ /**
1138
+ * The override's precedence index (0-based). The caller assigns this — Peek
1139
+ * evaluates lower `order` values first, so higher-discount / more-specific
1140
+ * tiers should get lower numbers.
1141
+ */
1142
+ order: number;
1143
+ /** The per-ticket price overrides applied by this entry. */
1144
+ resourceOptions: ResourceOptionOverride[];
1145
+ /** Zero or more filters gating when this entry applies. */
1146
+ filters: PricingOverrideFilter[];
1147
+ }
1148
+ /** The set of overrides to apply for a single activity. */
1149
+ interface ActivityOverrides {
1150
+ /** The Peek activity id these overrides apply to. */
1151
+ activityId: string;
1152
+ /**
1153
+ * The overrides for this activity. Pass an **empty array to clear** all
1154
+ * overrides for the activity — never omit the activity to clear it.
1155
+ */
1156
+ overrides: PricingOverride[];
1157
+ }
1158
+ /**
1159
+ * The full input for upserting pricing overrides onto an engine.
1160
+ *
1161
+ * Mirrors the Peek `upsertPricingOverridesActivityContexts` input verbatim. The
1162
+ * caller owns all segmentation and ordering; the service sends this as-is.
1163
+ */
1164
+ interface UpsertOverridesInput {
1165
+ /** The engine to write overrides to (its {@link CreatedPricingEngine.id}). */
1166
+ engineId: string;
1167
+ /**
1168
+ * The date range the overrides apply to, as a PostgreSQL-style inclusive
1169
+ * range string. For a single day, both ends are the same: `"[2025-07-04,2025-07-04]"`.
1170
+ */
1171
+ dateRange: string;
1172
+ /** One entry per activity being written (or cleared). */
1173
+ activities: ActivityOverrides[];
1174
+ }
1175
+ /**
1176
+ * Convenience input for clearing all overrides across a set of activities for a
1177
+ * date range. Equivalent to an {@link UpsertOverridesInput} whose every
1178
+ * activity carries `overrides: []`.
1179
+ */
1180
+ interface ClearOverridesInput {
1181
+ /** The engine to clear overrides on. */
1182
+ engineId: string;
1183
+ /** The date range to clear, same format as {@link UpsertOverridesInput.dateRange}. */
1184
+ dateRange: string;
1185
+ /** The activity ids to clear. Recover these from a prior sync's payload. */
1186
+ activityIds: string[];
1187
+ }
1188
+ /**
1189
+ * A ticket price override as **resolved** by Peek, discriminated by `mode`.
1190
+ *
1191
+ * This normalizes Peek's GraphQL union (a `price` object vs a bare
1192
+ * `percentageAdjustment`) into the same `mode`-tagged shape used on input.
1193
+ */
1194
+ type ResolvedOverride = {
1195
+ mode: "fixed";
1196
+ /** The resolved replacement price. */
1197
+ price: PricingMoney;
1198
+ } | {
1199
+ mode: "percentage";
1200
+ /** The resolved percentage adjustment as a decimal string. */
1201
+ percentageAdjustment: string;
1202
+ };
1203
+ /** A single ticket's resolved override within a returned context. */
1204
+ interface ResolvedResourceOption {
1205
+ /** The ticket (resourceOption) this override resolved for. */
1206
+ resourceOption: PricingNamedRef;
1207
+ /** The resolved fixed or percentage override. */
1208
+ override: ResolvedOverride;
1209
+ }
1210
+ /** A single resolved override entry within a returned activity context. */
1211
+ interface ResolvedPricingOverride {
1212
+ /** The override's precedence index as stored by Peek. */
1213
+ order: number;
1214
+ /** The resolved per-ticket overrides. */
1215
+ resourceOptions: ResolvedResourceOption[];
1216
+ /**
1217
+ * The filters gating this override, normalized to the same shape as the
1218
+ * {@link PricingOverrideFilter} used on input.
1219
+ */
1220
+ filters: PricingOverrideFilter[];
1221
+ }
1222
+ /**
1223
+ * The resolved pricing state for one activity on one date, as returned by an
1224
+ * upsert or clear. Useful as an audit record of exactly what Peek stored.
1225
+ */
1226
+ interface PricingActivityContext {
1227
+ /** The date the context applies to (ISO `YYYY-MM-DD`). */
1228
+ date: string;
1229
+ /** The activity the overrides belong to. */
1230
+ activity: PricingNamedRef;
1231
+ /** The engine the overrides live under. */
1232
+ engine: PricingNamedRef;
1233
+ /** The resolved overrides (empty when the date was cleared). */
1234
+ overrides: ResolvedPricingOverride[];
1235
+ }
1236
+ /** The result of an upsert or clear: the resolved contexts Peek returned. */
1237
+ interface UpsertOverridesResult {
1238
+ /** One entry per activity written or cleared in the request. */
1239
+ activityContexts: PricingActivityContext[];
1240
+ }
1241
+
1003
1242
  /**
1004
1243
  * The clean data model for Peek Pro promo codes.
1005
1244
  */
@@ -1469,6 +1708,39 @@ declare class PromoCodeService {
1469
1708
  create(input: CreatePromoCodeInput): Promise<CreatedPromoCode>;
1470
1709
  }
1471
1710
 
1711
+ declare class PricingService {
1712
+ private readonly client;
1713
+ constructor(client: GraphQLClient);
1714
+ /**
1715
+ * Creates a pricing engine. Store the returned id and reuse it on every
1716
+ * subsequent override upsert. Throws on an InvalidDataError from Peek.
1717
+ */
1718
+ createEngine(input: CreateEngineInput): Promise<CreatedPricingEngine>;
1719
+ /**
1720
+ * Updates a pricing engine's name and/or activity scope. Throws on an
1721
+ * InvalidDataError or NotFoundError from Peek.
1722
+ */
1723
+ updateEngine(input: UpdateEngineInput): Promise<PricingEngine>;
1724
+ /**
1725
+ * Deletes a pricing engine. Idempotent — resolves whether the engine existed
1726
+ * or was already gone (Peek's NotFoundError is treated as success).
1727
+ */
1728
+ deleteEngine(engineId: string): Promise<void>;
1729
+ /**
1730
+ * Upserts pricing overrides for the engine and date range in `input`. Returns
1731
+ * the resolved contexts Peek stored. Throws on an InvalidDataError from Peek.
1732
+ */
1733
+ upsertOverrides(input: UpsertOverridesInput): Promise<UpsertOverridesResult>;
1734
+ /**
1735
+ * Clears all overrides for the given activities across a date range. This is
1736
+ * an upsert with empty overrides — never clear by omitting an activity.
1737
+ */
1738
+ clearOverrides(input: ClearOverridesInput): Promise<UpsertOverridesResult>;
1739
+ private sendUpsert;
1740
+ private validateUpsertInput;
1741
+ private validateResourceOption;
1742
+ }
1743
+
1472
1744
  /**
1473
1745
  * Platform that embedded the app for this session. Verification is
1474
1746
  * brand-agnostic — one peek-auth JWT is minted for every platform — so this
@@ -1557,6 +1829,7 @@ declare class PeekAccessService {
1557
1829
  private timeslotService?;
1558
1830
  private resellerService?;
1559
1831
  private promoCodeService?;
1832
+ private pricingService?;
1560
1833
  private dailyNoteService?;
1561
1834
  private availabilityService?;
1562
1835
  private membershipService?;
@@ -1613,6 +1886,11 @@ declare class PeekAccessService {
1613
1886
  * authenticated transport. The instance is created lazily and reused.
1614
1887
  */
1615
1888
  getPromoCodeService(): PromoCodeService;
1889
+ /**
1890
+ * Returns the {@link PricingService} for this install, bound to the shared
1891
+ * authenticated transport. The instance is created lazily and reused.
1892
+ */
1893
+ getPricingService(): PricingService;
1616
1894
  /**
1617
1895
  * Returns the {@link DailyNoteService} for this install, bound to the shared
1618
1896
  * authenticated transport. The instance is created lazily and reused.
@@ -1668,6 +1946,16 @@ declare class PeekAccessService {
1668
1946
  getAllPromoCodes(): Promise<PromoCode[]>;
1669
1947
  /** Create a promo code. Delegates to {@link PromoCodeService.create}. */
1670
1948
  createPromoCode(input: CreatePromoCodeInput): Promise<CreatedPromoCode>;
1949
+ /** Create a pricing engine. Delegates to {@link PricingService.createEngine}. */
1950
+ createPricingEngine(input: CreateEngineInput): Promise<CreatedPricingEngine>;
1951
+ /** Update a pricing engine. Delegates to {@link PricingService.updateEngine}. */
1952
+ updatePricingEngine(input: UpdateEngineInput): Promise<PricingEngine>;
1953
+ /** Delete a pricing engine (idempotent). Delegates to {@link PricingService.deleteEngine}. */
1954
+ deletePricingEngine(engineId: string): Promise<void>;
1955
+ /** Upsert pricing overrides. Delegates to {@link PricingService.upsertOverrides}. */
1956
+ upsertPricingOverrides(input: UpsertOverridesInput): Promise<UpsertOverridesResult>;
1957
+ /** Clear pricing overrides for a set of activities. Delegates to {@link PricingService.clearOverrides}. */
1958
+ clearPricingOverrides(input: ClearOverridesInput): Promise<UpsertOverridesResult>;
1671
1959
  /** Today's daily note. Delegates to {@link DailyNoteService.getToday}. */
1672
1960
  getDailyNoteToday(): Promise<DailyNote | null>;
1673
1961
  /** Update today's daily note. Delegates to {@link DailyNoteService.update}. */
@@ -2129,4 +2417,4 @@ declare class AcmeApiError extends Error {
2129
2417
  constructor(statusCode: number, body: unknown, message?: string);
2130
2418
  }
2131
2419
 
2132
- export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, type AccessOptions, type AccountUser, AccountUserService, type AccountUserServiceOptions, AcmeAccessService, type AcmeAccessServiceConfig, type AcmeActivity, type AcmeActivityTicket, AcmeApiError, AcmeProductService, type Activity, type ActivityTicket, type AddAddonInput, AdminAccountRequiredError, type Agent, type AssignGuideResult, type AssignedActivity, type AssignedResource, type Availability, AvailabilityService, type AvailabilityTime, type AvailabilityTimesQuery, type Booking, type BookingAddon, type BookingAddonMoney, type BookingAddonOption, type BookingAddons, type BookingAddonsMutationResult, type BookingPaymentsOnFile, type BookingReadOptions, type BookingSearchBy, BookingService, type BookingServiceOptions, type BookingTimeRangeSearch, type CancelBookingResult, type Channel, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreatePromoCodeInput, type CreatedBooking, type CreatedPromoCode, type CustomQuestionAnswer, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, type InvoiceLinkResult, type Logger, type MakePaymentInput, type MakePaymentResult, type Membership, type MembershipPurchaseInput, MembershipService, type NoteMode, type Payment, type PaymentSource, PeekAccessService, type PeekAccessServiceConfig, type PeekAuthTokenClaims, type PeekAuthTokenUser, PeekGraphQLError, type PeekPlatform, PiiAccessDisabledError, type Price, type Product, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type Resource, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateTimeslotResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };
2420
+ export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, type AccessOptions, type AccountUser, AccountUserService, type AccountUserServiceOptions, AcmeAccessService, type AcmeAccessServiceConfig, type AcmeActivity, type AcmeActivityTicket, AcmeApiError, AcmeProductService, type Activity, type ActivityOverrides, type ActivityTicket, type AddAddonInput, AdminAccountRequiredError, type Agent, type AssignGuideResult, type AssignedActivity, type AssignedResource, type Availability, AvailabilityService, type AvailabilityTime, type AvailabilityTimesQuery, type Booking, type BookingAddon, type BookingAddonMoney, type BookingAddonOption, type BookingAddons, type BookingAddonsMutationResult, type BookingPaymentsOnFile, type BookingReadOptions, type BookingSearchBy, BookingService, type BookingServiceOptions, type BookingTimeRangeSearch, type CancelBookingResult, type Channel, type ClearOverridesInput, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreateEngineInput, type CreatePromoCodeInput, type CreatedBooking, type CreatedPricingEngine, type CreatedPromoCode, type CustomQuestionAnswer, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, type InvoiceLinkResult, type Logger, type MakePaymentInput, type MakePaymentResult, type Membership, type MembershipPurchaseInput, MembershipService, type NoteMode, type Payment, type PaymentSource, PeekAccessService, type PeekAccessServiceConfig, type PeekAuthTokenClaims, type PeekAuthTokenUser, PeekGraphQLError, type PeekPlatform, PiiAccessDisabledError, type Price, type PricingActivityContext, type PricingEngine, type PricingMoney, type PricingNamedRef, type PricingOverride, type PricingOverrideFilter, PricingService, type Product, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type ResolvedOverride, type ResolvedPricingOverride, type ResolvedResourceOption, type Resource, type ResourceOptionOverride, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateEngineInput, type UpdateTimeslotResult, type UpsertOverridesInput, type UpsertOverridesResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };