@peektravel/app-utilities 0.5.1 → 0.5.3
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/README.md +69 -14
- package/dist/index.cjs +138 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +332 -236
- package/dist/index.d.ts +332 -236
- package/dist/index.js +137 -44
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +35 -1
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +35 -1
- package/dist/ui/index.js.map +1 -1
- package/docs/ui.md +26 -2
- package/docs/webhooks.md +80 -9
- package/llms.txt +86 -18
- package/package.json +1 -1
package/dist/index.d.cts
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
|
*/
|
|
@@ -1772,6 +1797,36 @@ interface PeekAuthTokenClaims {
|
|
|
1772
1797
|
/** Authenticated user context. */
|
|
1773
1798
|
user: PeekAuthTokenUser;
|
|
1774
1799
|
}
|
|
1800
|
+
/** The Peek account an install belongs to, as reported on an install webhook. */
|
|
1801
|
+
interface InstallWebhookAccount {
|
|
1802
|
+
/** Peek account ID that owns the install. */
|
|
1803
|
+
id: string;
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Claims returned by `verifyInstallWebhook` — the decoded, signature-verified
|
|
1807
|
+
* install-status webhook token.
|
|
1808
|
+
*
|
|
1809
|
+
* Shares the `app_registry_v2` token family with {@link PeekAuthTokenClaims},
|
|
1810
|
+
* but is emitted by the app registry itself for install lifecycle events
|
|
1811
|
+
* (installed / uninstalled / status changed) rather than for a user session —
|
|
1812
|
+
* so {@link InstallWebhookClaims.user} is `null` for system-initiated events
|
|
1813
|
+
* that no user triggered.
|
|
1814
|
+
*/
|
|
1815
|
+
interface InstallWebhookClaims {
|
|
1816
|
+
/** Install ID — the JWT subject (`sub`). Peek-assigned UUID. */
|
|
1817
|
+
installId: string;
|
|
1818
|
+
/** The account the install belongs to. */
|
|
1819
|
+
account: InstallWebhookAccount;
|
|
1820
|
+
/** Install lifecycle status (e.g. `"installed"`, `"uninstalled"`). */
|
|
1821
|
+
status: string;
|
|
1822
|
+
/** App display version at time of issuance. Empty string when absent. */
|
|
1823
|
+
displayVersion: string;
|
|
1824
|
+
/**
|
|
1825
|
+
* The user that triggered the event, or `null` for system-initiated events
|
|
1826
|
+
* (the whole point of a distinct type from {@link PeekAuthTokenClaims}).
|
|
1827
|
+
*/
|
|
1828
|
+
user: PeekAuthTokenUser | null;
|
|
1829
|
+
}
|
|
1775
1830
|
|
|
1776
1831
|
/**
|
|
1777
1832
|
* Configuration for a {@link PeekAccessService} instance. Extends the shared
|
|
@@ -2029,8 +2084,6 @@ declare class RestClient$1 {
|
|
|
2029
2084
|
* @throws {CngApiError} on any other non-2xx response
|
|
2030
2085
|
*/
|
|
2031
2086
|
get<T>(path: string): Promise<T>;
|
|
2032
|
-
/** Reads the response body as JSON, falling back to raw text when unparseable. */
|
|
2033
|
-
private parseBody;
|
|
2034
2087
|
private endpoint;
|
|
2035
2088
|
private buildHeaders;
|
|
2036
2089
|
}
|
|
@@ -2158,8 +2211,6 @@ declare class RestClient {
|
|
|
2158
2211
|
* @throws {AcmeApiError} on any other non-2xx response
|
|
2159
2212
|
*/
|
|
2160
2213
|
get<T>(path: string): Promise<T>;
|
|
2161
|
-
/** Reads the response body as JSON, falling back to raw text when unparseable. */
|
|
2162
|
-
private parseBody;
|
|
2163
2214
|
private endpoint;
|
|
2164
2215
|
private buildHeaders;
|
|
2165
2216
|
}
|
|
@@ -2341,6 +2392,29 @@ interface Waiver {
|
|
|
2341
2392
|
*/
|
|
2342
2393
|
declare function parseWaiverWebhook(payload: unknown, options?: AccessOptions): Waiver;
|
|
2343
2394
|
|
|
2395
|
+
/**
|
|
2396
|
+
* Verifies an install-status webhook token and returns its clean claims.
|
|
2397
|
+
*
|
|
2398
|
+
* Validates the HMAC signature (with `secret`), the token expiry, the
|
|
2399
|
+
* `"app_registry_v2"` issuer, and the `"Joken"` audience — the same checks as
|
|
2400
|
+
* {@link PeekAccessService.verifyPeekAuthToken} — then maps the payload to
|
|
2401
|
+
* {@link InstallWebhookClaims}, tolerating a `null` `user` (system events).
|
|
2402
|
+
* Throws from the `jsonwebtoken` library on any verification failure, so callers
|
|
2403
|
+
* can branch on the error kind:
|
|
2404
|
+
*
|
|
2405
|
+
* - `JsonWebTokenError` — signature invalid, wrong issuer/audience, or malformed
|
|
2406
|
+
* - `TokenExpiredError` — past `exp`
|
|
2407
|
+
* - `NotBeforeError` — before `nbf`
|
|
2408
|
+
*
|
|
2409
|
+
* @param token the raw JWT delivered by the install webhook (no `Bearer` prefix)
|
|
2410
|
+
* @param secret the app's HMAC signing secret (the `jwtSecret` you construct
|
|
2411
|
+
* `PeekAccessService` with)
|
|
2412
|
+
* @throws {JsonWebTokenError} signature invalid or token malformed
|
|
2413
|
+
* @throws {TokenExpiredError} token has expired
|
|
2414
|
+
* @throws {NotBeforeError} token not yet valid
|
|
2415
|
+
*/
|
|
2416
|
+
declare function verifyInstallWebhook(token: string, secret: string): InstallWebhookClaims;
|
|
2417
|
+
|
|
2344
2418
|
/**
|
|
2345
2419
|
* Typed errors thrown by the package. Each mirrors a failure mode of the Peek
|
|
2346
2420
|
* GraphQL gateway (or the CNG REST gateway) so callers can branch on the error
|
|
@@ -2377,6 +2451,28 @@ declare class PeekGraphQLError extends Error {
|
|
|
2377
2451
|
readonly graphqlErrors: unknown[];
|
|
2378
2452
|
constructor(graphqlErrors: unknown[], message?: string);
|
|
2379
2453
|
}
|
|
2454
|
+
/**
|
|
2455
|
+
* Thrown when the Peek GraphQL gateway returns a non-2xx HTTP response that is
|
|
2456
|
+
* not one of the specifically-handled statuses (418/429) and does not carry a
|
|
2457
|
+
* GraphQL `errors` array. This is the transport-level failure — a `401`
|
|
2458
|
+
* (auth/secret wrong), `404` (wrong app id / not provisioned), `5xx`, etc. —
|
|
2459
|
+
* as opposed to {@link PeekGraphQLError}, which is a resolver-level failure
|
|
2460
|
+
* reported inside an otherwise-successful HTTP response.
|
|
2461
|
+
*
|
|
2462
|
+
* The offending status is preserved on {@link PeekHttpError.statusCode}, the
|
|
2463
|
+
* request URL on {@link PeekHttpError.url}, and the raw response body (parsed
|
|
2464
|
+
* JSON when possible, otherwise the raw text) on {@link PeekHttpError.body} — so
|
|
2465
|
+
* callers can tell "which config is wrong" without disassembling the bundle.
|
|
2466
|
+
*/
|
|
2467
|
+
declare class PeekHttpError extends Error {
|
|
2468
|
+
/** The HTTP status that triggered this error. */
|
|
2469
|
+
readonly statusCode: number;
|
|
2470
|
+
/** The request URL that produced the failing response. */
|
|
2471
|
+
readonly url: string;
|
|
2472
|
+
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
2473
|
+
readonly body: unknown;
|
|
2474
|
+
constructor(statusCode: number, url: string, body: unknown, message?: string);
|
|
2475
|
+
}
|
|
2380
2476
|
/**
|
|
2381
2477
|
* Thrown when a payment or booking-modification operation is called on an
|
|
2382
2478
|
* access service that was constructed without `fullCustomerAccess` (PII access
|
|
@@ -2417,4 +2513,4 @@ declare class AcmeApiError extends Error {
|
|
|
2417
2513
|
constructor(statusCode: number, body: unknown, message?: string);
|
|
2418
2514
|
}
|
|
2419
2515
|
|
|
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 };
|
|
2516
|
+
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 InstallWebhookAccount, type InstallWebhookClaims, 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, PeekHttpError, 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, verifyInstallWebhook };
|