@peektravel/app-utilities 0.5.1 → 0.5.2
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.cjs +36 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +256 -231
- package/dist/index.d.ts +256 -231
- package/dist/index.js +36 -4
- package/dist/index.js.map +1 -1
- package/llms.txt +58 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,247 @@ declare class GraphQLClient {
|
|
|
52
52
|
private buildHeaders;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The clean data model for Peek Pro pricing engines and pricing overrides.
|
|
57
|
+
*
|
|
58
|
+
* A **pricing engine** is a named container Peek Pro applies at checkout. A
|
|
59
|
+
* caller creates one lazily, stores its id, then repeatedly **upserts pricing
|
|
60
|
+
* overrides** onto it for a given date range. Overrides adjust ticket prices
|
|
61
|
+
* (fixed replacement or percentage adjustment) for an activity, optionally
|
|
62
|
+
* gated by how many spots are already taken and/or a start-time window.
|
|
63
|
+
*
|
|
64
|
+
* Scope note: this package is a thin wrapper over the Peek GraphQL primitives.
|
|
65
|
+
* It does **not** own the domain logic that decides *what* the overrides should
|
|
66
|
+
* be — segmenting an activity across time windows, ordering overrides by tier,
|
|
67
|
+
* or computing the `spotsTaken` bounds. The caller builds an
|
|
68
|
+
* {@link UpsertOverridesInput} and the service sends it faithfully; the service
|
|
69
|
+
* only maps between these clean shapes and the raw GraphQL payload.
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* A monetary value on a pricing override.
|
|
73
|
+
*
|
|
74
|
+
* `amount` is intentionally a **string** (e.g. `"50.00"`), never a number — the
|
|
75
|
+
* Peek API rejects floats here, and stringly-typed money avoids precision loss.
|
|
76
|
+
*/
|
|
77
|
+
interface PricingMoney {
|
|
78
|
+
/** Numeric amount as a decimal string (e.g. `"50.00"`). */
|
|
79
|
+
amount: string;
|
|
80
|
+
/** ISO 4217 currency code (e.g. `"USD"`). */
|
|
81
|
+
currency: string;
|
|
82
|
+
/**
|
|
83
|
+
* Human-formatted display string for the amount (e.g. `"$50.00"`), as
|
|
84
|
+
* rendered by the Peek gateway.
|
|
85
|
+
*
|
|
86
|
+
* Populated on values **read back** from the gateway (resolved overrides,
|
|
87
|
+
* product ticket price ranges). It is optional and purely informational —
|
|
88
|
+
* omit it when *building* an override input; the gateway derives it from
|
|
89
|
+
* `amount`/`currency`.
|
|
90
|
+
*/
|
|
91
|
+
displayPrice?: string;
|
|
92
|
+
}
|
|
93
|
+
/** An `{ id, name }` reference to a Peek entity echoed back in a response. */
|
|
94
|
+
interface PricingNamedRef {
|
|
95
|
+
/** Stable Peek identifier. */
|
|
96
|
+
id: string;
|
|
97
|
+
/** Human-readable display name. */
|
|
98
|
+
name: string;
|
|
99
|
+
}
|
|
100
|
+
/** Input for creating a pricing engine. */
|
|
101
|
+
interface CreateEngineInput {
|
|
102
|
+
/** Display name for the engine. */
|
|
103
|
+
name: string;
|
|
104
|
+
/**
|
|
105
|
+
* Optional list of activity ids the engine is scoped to. Omit (or pass an
|
|
106
|
+
* empty array) to create an unfiltered engine that applies to all activities.
|
|
107
|
+
*/
|
|
108
|
+
activityIds?: string[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The result of creating a pricing engine.
|
|
112
|
+
*
|
|
113
|
+
* The create mutation returns only the new engine's id; store it as the
|
|
114
|
+
* schedule's `source_refid` for subsequent override upserts.
|
|
115
|
+
*/
|
|
116
|
+
interface CreatedPricingEngine {
|
|
117
|
+
/** The new engine's id. */
|
|
118
|
+
id: string;
|
|
119
|
+
}
|
|
120
|
+
/** Input for updating a pricing engine's name and/or activity scope. */
|
|
121
|
+
interface UpdateEngineInput {
|
|
122
|
+
/** The engine to update. */
|
|
123
|
+
engineId: string;
|
|
124
|
+
/** New display name. */
|
|
125
|
+
name: string;
|
|
126
|
+
/**
|
|
127
|
+
* Activity ids the engine should be scoped to. An empty array (or omitting
|
|
128
|
+
* the field) **clears** the filter so the engine applies to all activities.
|
|
129
|
+
*/
|
|
130
|
+
activityIds?: string[];
|
|
131
|
+
}
|
|
132
|
+
/** A pricing engine reference as echoed back by the API. */
|
|
133
|
+
interface PricingEngine {
|
|
134
|
+
/** Engine id. */
|
|
135
|
+
id: string;
|
|
136
|
+
/** Engine display name. */
|
|
137
|
+
name: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A single ticket (resourceOption) price override, discriminated by `mode`.
|
|
141
|
+
*
|
|
142
|
+
* - `fixed` — replace the ticket price outright with {@link PricingMoney}.
|
|
143
|
+
* - `percentage` — adjust the ticket price by a percentage. The adjustment is a
|
|
144
|
+
* decimal **string** (e.g. `"-25"` for 25% off) and must be greater than
|
|
145
|
+
* `-100`.
|
|
146
|
+
*/
|
|
147
|
+
type ResourceOptionOverride = {
|
|
148
|
+
/** The Peek resourceOption (ticket) id being overridden. */
|
|
149
|
+
id: string;
|
|
150
|
+
mode: "fixed";
|
|
151
|
+
/** The replacement price. */
|
|
152
|
+
price: PricingMoney;
|
|
153
|
+
} | {
|
|
154
|
+
/** The Peek resourceOption (ticket) id being overridden. */
|
|
155
|
+
id: string;
|
|
156
|
+
mode: "percentage";
|
|
157
|
+
/** Percentage adjustment as a decimal string, e.g. `"-25"`. Must be > -100. */
|
|
158
|
+
percentageAdjustment: string;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* A filter gating when an override applies. Both variants are optional and an
|
|
162
|
+
* override may carry zero, one, or both.
|
|
163
|
+
*/
|
|
164
|
+
type PricingOverrideFilter = {
|
|
165
|
+
/**
|
|
166
|
+
* Restricts the override by how many spots are already taken.
|
|
167
|
+
*
|
|
168
|
+
* `minSpots`/`maxSpots` are **zero-indexed spots-taken counts**, not
|
|
169
|
+
* ticket counts — e.g. "applies from the 5th ticket onward" is
|
|
170
|
+
* `{ minSpots: 4 }`. The caller is responsible for this off-by-one
|
|
171
|
+
* conversion from ticket-count ranges.
|
|
172
|
+
*/
|
|
173
|
+
spotsTaken: {
|
|
174
|
+
/** Lower bound (inclusive) on spots already taken. Omit for no lower bound. */
|
|
175
|
+
minSpots?: number;
|
|
176
|
+
/** Upper bound (inclusive) on spots already taken. Omit for no upper bound. */
|
|
177
|
+
maxSpots?: number;
|
|
178
|
+
};
|
|
179
|
+
} | {
|
|
180
|
+
/**
|
|
181
|
+
* Restricts the override to a start-time window, as a PostgreSQL-style
|
|
182
|
+
* inclusive range string `"[HH:MM:SS,HH:MM:SS]"`.
|
|
183
|
+
*/
|
|
184
|
+
startTimeRange: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* One override entry for an activity: which tickets it adjusts, in what order,
|
|
188
|
+
* under which filters.
|
|
189
|
+
*/
|
|
190
|
+
interface PricingOverride {
|
|
191
|
+
/**
|
|
192
|
+
* The override's precedence index (0-based). The caller assigns this — Peek
|
|
193
|
+
* evaluates lower `order` values first, so higher-discount / more-specific
|
|
194
|
+
* tiers should get lower numbers.
|
|
195
|
+
*/
|
|
196
|
+
order: number;
|
|
197
|
+
/** The per-ticket price overrides applied by this entry. */
|
|
198
|
+
resourceOptions: ResourceOptionOverride[];
|
|
199
|
+
/** Zero or more filters gating when this entry applies. */
|
|
200
|
+
filters: PricingOverrideFilter[];
|
|
201
|
+
}
|
|
202
|
+
/** The set of overrides to apply for a single activity. */
|
|
203
|
+
interface ActivityOverrides {
|
|
204
|
+
/** The Peek activity id these overrides apply to. */
|
|
205
|
+
activityId: string;
|
|
206
|
+
/**
|
|
207
|
+
* The overrides for this activity. Pass an **empty array to clear** all
|
|
208
|
+
* overrides for the activity — never omit the activity to clear it.
|
|
209
|
+
*/
|
|
210
|
+
overrides: PricingOverride[];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* The full input for upserting pricing overrides onto an engine.
|
|
214
|
+
*
|
|
215
|
+
* Mirrors the Peek `upsertPricingOverridesActivityContexts` input verbatim. The
|
|
216
|
+
* caller owns all segmentation and ordering; the service sends this as-is.
|
|
217
|
+
*/
|
|
218
|
+
interface UpsertOverridesInput {
|
|
219
|
+
/** The engine to write overrides to (its {@link CreatedPricingEngine.id}). */
|
|
220
|
+
engineId: string;
|
|
221
|
+
/**
|
|
222
|
+
* The date range the overrides apply to, as a PostgreSQL-style inclusive
|
|
223
|
+
* range string. For a single day, both ends are the same: `"[2025-07-04,2025-07-04]"`.
|
|
224
|
+
*/
|
|
225
|
+
dateRange: string;
|
|
226
|
+
/** One entry per activity being written (or cleared). */
|
|
227
|
+
activities: ActivityOverrides[];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Convenience input for clearing all overrides across a set of activities for a
|
|
231
|
+
* date range. Equivalent to an {@link UpsertOverridesInput} whose every
|
|
232
|
+
* activity carries `overrides: []`.
|
|
233
|
+
*/
|
|
234
|
+
interface ClearOverridesInput {
|
|
235
|
+
/** The engine to clear overrides on. */
|
|
236
|
+
engineId: string;
|
|
237
|
+
/** The date range to clear, same format as {@link UpsertOverridesInput.dateRange}. */
|
|
238
|
+
dateRange: string;
|
|
239
|
+
/** The activity ids to clear. Recover these from a prior sync's payload. */
|
|
240
|
+
activityIds: string[];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A ticket price override as **resolved** by Peek, discriminated by `mode`.
|
|
244
|
+
*
|
|
245
|
+
* This normalizes Peek's GraphQL union (a `price` object vs a bare
|
|
246
|
+
* `percentageAdjustment`) into the same `mode`-tagged shape used on input.
|
|
247
|
+
*/
|
|
248
|
+
type ResolvedOverride = {
|
|
249
|
+
mode: "fixed";
|
|
250
|
+
/** The resolved replacement price. */
|
|
251
|
+
price: PricingMoney;
|
|
252
|
+
} | {
|
|
253
|
+
mode: "percentage";
|
|
254
|
+
/** The resolved percentage adjustment as a decimal string. */
|
|
255
|
+
percentageAdjustment: string;
|
|
256
|
+
};
|
|
257
|
+
/** A single ticket's resolved override within a returned context. */
|
|
258
|
+
interface ResolvedResourceOption {
|
|
259
|
+
/** The ticket (resourceOption) this override resolved for. */
|
|
260
|
+
resourceOption: PricingNamedRef;
|
|
261
|
+
/** The resolved fixed or percentage override. */
|
|
262
|
+
override: ResolvedOverride;
|
|
263
|
+
}
|
|
264
|
+
/** A single resolved override entry within a returned activity context. */
|
|
265
|
+
interface ResolvedPricingOverride {
|
|
266
|
+
/** The override's precedence index as stored by Peek. */
|
|
267
|
+
order: number;
|
|
268
|
+
/** The resolved per-ticket overrides. */
|
|
269
|
+
resourceOptions: ResolvedResourceOption[];
|
|
270
|
+
/**
|
|
271
|
+
* The filters gating this override, normalized to the same shape as the
|
|
272
|
+
* {@link PricingOverrideFilter} used on input.
|
|
273
|
+
*/
|
|
274
|
+
filters: PricingOverrideFilter[];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* The resolved pricing state for one activity on one date, as returned by an
|
|
278
|
+
* upsert or clear. Useful as an audit record of exactly what Peek stored.
|
|
279
|
+
*/
|
|
280
|
+
interface PricingActivityContext {
|
|
281
|
+
/** The date the context applies to (ISO `YYYY-MM-DD`). */
|
|
282
|
+
date: string;
|
|
283
|
+
/** The activity the overrides belong to. */
|
|
284
|
+
activity: PricingNamedRef;
|
|
285
|
+
/** The engine the overrides live under. */
|
|
286
|
+
engine: PricingNamedRef;
|
|
287
|
+
/** The resolved overrides (empty when the date was cleared). */
|
|
288
|
+
overrides: ResolvedPricingOverride[];
|
|
289
|
+
}
|
|
290
|
+
/** The result of an upsert or clear: the resolved contexts Peek returned. */
|
|
291
|
+
interface UpsertOverridesResult {
|
|
292
|
+
/** One entry per activity written or cleared in the request. */
|
|
293
|
+
activityContexts: PricingActivityContext[];
|
|
294
|
+
}
|
|
295
|
+
|
|
55
296
|
/**
|
|
56
297
|
* The clean, transport-agnostic data model for a Peek Pro product.
|
|
57
298
|
*
|
|
@@ -59,6 +300,7 @@ declare class GraphQLClient {
|
|
|
59
300
|
* decoupled from the underlying Peek GraphQL schema — the raw GraphQL types and
|
|
60
301
|
* the conversion logic live inside the package and are never exposed here.
|
|
61
302
|
*/
|
|
303
|
+
|
|
62
304
|
/**
|
|
63
305
|
* A bookable product in a Peek Pro account.
|
|
64
306
|
*
|
|
@@ -117,6 +359,20 @@ interface ProductTicket {
|
|
|
117
359
|
id: string;
|
|
118
360
|
/** Human-readable name of the ticket / option. */
|
|
119
361
|
name: string;
|
|
362
|
+
/**
|
|
363
|
+
* Lowest price this ticket can be sold at, across its price range.
|
|
364
|
+
*
|
|
365
|
+
* Populated for activity/rental resource options that expose a price range;
|
|
366
|
+
* `null` for add-on options (which carry no range) and when Peek reports none.
|
|
367
|
+
*/
|
|
368
|
+
minPrice: PricingMoney | null;
|
|
369
|
+
/**
|
|
370
|
+
* Highest price this ticket can be sold at, across its price range.
|
|
371
|
+
*
|
|
372
|
+
* Populated for activity/rental resource options that expose a price range;
|
|
373
|
+
* `null` for add-on options (which carry no range) and when Peek reports none.
|
|
374
|
+
*/
|
|
375
|
+
maxPrice: PricingMoney | null;
|
|
120
376
|
}
|
|
121
377
|
/** {@link Product.type} for standard bookable activities. */
|
|
122
378
|
declare const ACTIVITY_PRODUCT_TYPE = "ACTIVITY";
|
|
@@ -1008,237 +1264,6 @@ interface AvailabilityTimesQuery {
|
|
|
1008
1264
|
resourceOptionQuantities: ResourceOptionQuantity[];
|
|
1009
1265
|
}
|
|
1010
1266
|
|
|
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
|
-
|
|
1242
1267
|
/**
|
|
1243
1268
|
* The clean data model for Peek Pro promo codes.
|
|
1244
1269
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2766,6 +2766,14 @@ function normalizeDate(date) {
|
|
|
2766
2766
|
return date.split("T")[0] ?? date;
|
|
2767
2767
|
}
|
|
2768
2768
|
|
|
2769
|
+
// src/internal/peek/money.ts
|
|
2770
|
+
function toPricingMoney(raw) {
|
|
2771
|
+
if (!raw) return null;
|
|
2772
|
+
const money = { amount: raw.amount, currency: raw.currency };
|
|
2773
|
+
if (raw.formatted != null) money.displayPrice = raw.formatted;
|
|
2774
|
+
return money;
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2769
2777
|
// src/internal/peek/products/product-converter.ts
|
|
2770
2778
|
var ADD_ON_COLOR = "#FFFFFF";
|
|
2771
2779
|
function fromActivities(activities) {
|
|
@@ -2781,7 +2789,9 @@ function fromActivity(activity) {
|
|
|
2781
2789
|
currency: activity.currency || "",
|
|
2782
2790
|
tickets: (activity.resourceOptions ?? []).map((option) => ({
|
|
2783
2791
|
id: option.id,
|
|
2784
|
-
name: option.name
|
|
2792
|
+
name: option.name,
|
|
2793
|
+
minPrice: toPricingMoney(option.priceRange?.min),
|
|
2794
|
+
maxPrice: toPricingMoney(option.priceRange?.max)
|
|
2785
2795
|
}))
|
|
2786
2796
|
};
|
|
2787
2797
|
}
|
|
@@ -2802,7 +2812,12 @@ function fromItemOptionNodes(nodes) {
|
|
|
2802
2812
|
};
|
|
2803
2813
|
grouped.set(itemId, product);
|
|
2804
2814
|
}
|
|
2805
|
-
product.tickets.push({
|
|
2815
|
+
product.tickets.push({
|
|
2816
|
+
id: node.id,
|
|
2817
|
+
name: node.name,
|
|
2818
|
+
minPrice: null,
|
|
2819
|
+
maxPrice: null
|
|
2820
|
+
});
|
|
2806
2821
|
}
|
|
2807
2822
|
return Array.from(grouped.values());
|
|
2808
2823
|
}
|
|
@@ -2821,6 +2836,18 @@ var PRODUCTS_QUERY = `
|
|
|
2821
2836
|
resourceOptions {
|
|
2822
2837
|
id
|
|
2823
2838
|
name
|
|
2839
|
+
priceRange {
|
|
2840
|
+
min {
|
|
2841
|
+
currency
|
|
2842
|
+
amount
|
|
2843
|
+
formatted
|
|
2844
|
+
}
|
|
2845
|
+
max {
|
|
2846
|
+
currency
|
|
2847
|
+
amount
|
|
2848
|
+
formatted
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2824
2851
|
}
|
|
2825
2852
|
}
|
|
2826
2853
|
}
|
|
@@ -3124,6 +3151,7 @@ var UPSERT_PRICING_OVERRIDES_MUTATION = `
|
|
|
3124
3151
|
price {
|
|
3125
3152
|
amount
|
|
3126
3153
|
currency
|
|
3154
|
+
formatted
|
|
3127
3155
|
}
|
|
3128
3156
|
}
|
|
3129
3157
|
... on PricingOverridesActivityContextResourceOptionPercentageAdjustmentOverride {
|
|
@@ -3172,7 +3200,11 @@ function buildUpsertInput(input) {
|
|
|
3172
3200
|
overrides: activity.overrides.map((override) => ({
|
|
3173
3201
|
order: override.order,
|
|
3174
3202
|
resourceOptions: override.resourceOptions.map(
|
|
3175
|
-
(option) => option.mode === "fixed" ? {
|
|
3203
|
+
(option) => option.mode === "fixed" ? {
|
|
3204
|
+
id: option.id,
|
|
3205
|
+
// Send only the wire fields — `displayPrice` is read-only.
|
|
3206
|
+
price: { amount: option.price.amount, currency: option.price.currency }
|
|
3207
|
+
} : { id: option.id, percentageAdjustment: option.percentageAdjustment }
|
|
3176
3208
|
),
|
|
3177
3209
|
filters: override.filters
|
|
3178
3210
|
}))
|
|
@@ -3219,7 +3251,7 @@ function fromResourceOption(option) {
|
|
|
3219
3251
|
};
|
|
3220
3252
|
}
|
|
3221
3253
|
function fromResolvedOverride(override) {
|
|
3222
|
-
return "price" in override ? { mode: "fixed", price: override.price } : { mode: "percentage", percentageAdjustment: override.percentageAdjustment };
|
|
3254
|
+
return "price" in override ? { mode: "fixed", price: toPricingMoney(override.price) } : { mode: "percentage", percentageAdjustment: override.percentageAdjustment };
|
|
3223
3255
|
}
|
|
3224
3256
|
function fromFilter(filter) {
|
|
3225
3257
|
if (filter.__typename === SPOTS_TAKEN_FILTER_TYPENAME) {
|