@peektravel/app-utilities 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -2
- package/dist/index.cjs +165 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +165 -105
- package/dist/index.js.map +1 -1
- package/docs/webhooks.md +9 -1
- package/llms.txt +19 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -181,6 +181,73 @@ var AvailabilityService = class {
|
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
+
// src/access-options.ts
|
|
185
|
+
function resolveAccessOptions(options) {
|
|
186
|
+
return { fullCustomerAccess: options?.fullCustomerAccess ?? false };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/errors.ts
|
|
190
|
+
var AdminAccountRequiredError = class extends Error {
|
|
191
|
+
/** The HTTP status that triggered this error. */
|
|
192
|
+
statusCode = 418;
|
|
193
|
+
constructor(message = "Admin account required") {
|
|
194
|
+
super(message);
|
|
195
|
+
this.name = "AdminAccountRequiredError";
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
var RateLimitError = class extends Error {
|
|
199
|
+
/** The HTTP status that triggered this error. */
|
|
200
|
+
statusCode = 429;
|
|
201
|
+
constructor(message = "Rate limit exceeded") {
|
|
202
|
+
super(message);
|
|
203
|
+
this.name = "RateLimitError";
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var PeekGraphQLError = class extends Error {
|
|
207
|
+
/** The raw `errors` array returned by the GraphQL endpoint. */
|
|
208
|
+
graphqlErrors;
|
|
209
|
+
constructor(graphqlErrors, message = "GraphQL request failed") {
|
|
210
|
+
super(message);
|
|
211
|
+
this.name = "PeekGraphQLError";
|
|
212
|
+
this.graphqlErrors = graphqlErrors;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var PiiAccessDisabledError = class extends Error {
|
|
216
|
+
/** The name of the operation that was blocked (e.g. `"makePayment"`). */
|
|
217
|
+
operation;
|
|
218
|
+
constructor(operation) {
|
|
219
|
+
super(
|
|
220
|
+
`"${operation}" is disabled because this access service was created without "fullCustomerAccess"; enable it to allow payment and booking-modification operations`
|
|
221
|
+
);
|
|
222
|
+
this.name = "PiiAccessDisabledError";
|
|
223
|
+
this.operation = operation;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var CngApiError = class extends Error {
|
|
227
|
+
/** The HTTP status that triggered this error. */
|
|
228
|
+
statusCode;
|
|
229
|
+
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
230
|
+
body;
|
|
231
|
+
constructor(statusCode, body, message) {
|
|
232
|
+
super(message ?? `CNG request failed with HTTP ${statusCode}`);
|
|
233
|
+
this.name = "CngApiError";
|
|
234
|
+
this.statusCode = statusCode;
|
|
235
|
+
this.body = body;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var AcmeApiError = class extends Error {
|
|
239
|
+
/** The HTTP status that triggered this error. */
|
|
240
|
+
statusCode;
|
|
241
|
+
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
242
|
+
body;
|
|
243
|
+
constructor(statusCode, body, message) {
|
|
244
|
+
super(message ?? `ACME request failed with HTTP ${statusCode}`);
|
|
245
|
+
this.name = "AcmeApiError";
|
|
246
|
+
this.statusCode = statusCode;
|
|
247
|
+
this.body = body;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
184
251
|
// src/models/peek/product.ts
|
|
185
252
|
var ACTIVITY_PRODUCT_TYPE = "ACTIVITY";
|
|
186
253
|
var RENTAL_PRODUCT_TYPE = "RENTAL";
|
|
@@ -192,17 +259,8 @@ var SEARCH_BY_ACTIVITY_DATE = "activityDate";
|
|
|
192
259
|
function normalizeBookingId(bookingId) {
|
|
193
260
|
return bookingId.toLowerCase().replace(/-/g, "_");
|
|
194
261
|
}
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
name
|
|
198
|
-
country
|
|
199
|
-
dateOfBirth
|
|
200
|
-
email
|
|
201
|
-
isGdpr
|
|
202
|
-
isParticipant
|
|
203
|
-
optinSms
|
|
204
|
-
optinMarketing
|
|
205
|
-
phone
|
|
262
|
+
var GUEST_IDENTITY_PII_FIELDS = "name country dateOfBirth email isGdpr";
|
|
263
|
+
var GUEST_CONTACT_PII_FIELDS = `phone
|
|
206
264
|
postalCode
|
|
207
265
|
fieldResponses {
|
|
208
266
|
id
|
|
@@ -212,9 +270,20 @@ var guestFields = `
|
|
|
212
270
|
name
|
|
213
271
|
}
|
|
214
272
|
}
|
|
215
|
-
}
|
|
273
|
+
}`;
|
|
274
|
+
function buildGuestFields(fullCustomerAccess) {
|
|
275
|
+
return `
|
|
276
|
+
id
|
|
277
|
+
${fullCustomerAccess ? GUEST_IDENTITY_PII_FIELDS : ""}
|
|
278
|
+
isParticipant
|
|
279
|
+
optinSms
|
|
280
|
+
optinMarketing
|
|
281
|
+
${fullCustomerAccess ? GUEST_CONTACT_PII_FIELDS : ""}
|
|
216
282
|
`;
|
|
217
|
-
|
|
283
|
+
}
|
|
284
|
+
function buildBookingGuestsFields(fullCustomerAccess) {
|
|
285
|
+
const guestFields = buildGuestFields(fullCustomerAccess);
|
|
286
|
+
return `
|
|
218
287
|
bookingGuests {
|
|
219
288
|
${guestFields}
|
|
220
289
|
}
|
|
@@ -222,10 +291,9 @@ var bookingGuestsFields = `
|
|
|
222
291
|
${guestFields}
|
|
223
292
|
}
|
|
224
293
|
`;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
primaryGuest {
|
|
294
|
+
}
|
|
295
|
+
var bookingGuestsFields = buildBookingGuestsFields(true);
|
|
296
|
+
var BOOKING_PRIMARY_GUEST_PII_FIELDS = `primaryGuest {
|
|
229
297
|
name
|
|
230
298
|
email
|
|
231
299
|
phone
|
|
@@ -233,7 +301,26 @@ var bookingQueryFields = `
|
|
|
233
301
|
optinSms
|
|
234
302
|
isGdpr
|
|
235
303
|
postalCode
|
|
304
|
+
}`;
|
|
305
|
+
var BOOKING_QUESTION_ANSWERS_PII_FIELDS = `questionAnswers {
|
|
306
|
+
answer
|
|
307
|
+
questionText
|
|
308
|
+
questionLocationSnapshot {
|
|
309
|
+
latitude
|
|
310
|
+
longitude
|
|
311
|
+
}
|
|
236
312
|
}
|
|
313
|
+
tickets {
|
|
314
|
+
questionAnswers {
|
|
315
|
+
answer
|
|
316
|
+
questionText
|
|
317
|
+
}
|
|
318
|
+
}`;
|
|
319
|
+
function buildBookingQueryFields(fullCustomerAccess) {
|
|
320
|
+
return `
|
|
321
|
+
displayId
|
|
322
|
+
id
|
|
323
|
+
${fullCustomerAccess ? BOOKING_PRIMARY_GUEST_PII_FIELDS : ""}
|
|
237
324
|
activitySnapshot {
|
|
238
325
|
type
|
|
239
326
|
name
|
|
@@ -263,7 +350,7 @@ var bookingQueryFields = `
|
|
|
263
350
|
endsAt
|
|
264
351
|
endsAtUtc
|
|
265
352
|
availabilityTimeId
|
|
266
|
-
bookingPortalUrl
|
|
353
|
+
${fullCustomerAccess ? "bookingPortalUrl" : ""}
|
|
267
354
|
operatorNotes
|
|
268
355
|
value {
|
|
269
356
|
total {
|
|
@@ -305,20 +392,7 @@ var bookingQueryFields = `
|
|
|
305
392
|
}
|
|
306
393
|
}
|
|
307
394
|
}
|
|
308
|
-
|
|
309
|
-
answer
|
|
310
|
-
questionText
|
|
311
|
-
questionLocationSnapshot {
|
|
312
|
-
latitude
|
|
313
|
-
longitude
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
tickets {
|
|
317
|
-
questionAnswers {
|
|
318
|
-
answer
|
|
319
|
-
questionText
|
|
320
|
-
}
|
|
321
|
-
}
|
|
395
|
+
${fullCustomerAccess ? BOOKING_QUESTION_ANSWERS_PII_FIELDS : ""}
|
|
322
396
|
resourcePoolAssignments {
|
|
323
397
|
quantity
|
|
324
398
|
resourcePool {
|
|
@@ -336,6 +410,8 @@ var bookingQueryFields = `
|
|
|
336
410
|
}
|
|
337
411
|
}
|
|
338
412
|
`;
|
|
413
|
+
}
|
|
414
|
+
var bookingQueryFields = buildBookingQueryFields(true);
|
|
339
415
|
var PRICE_BREAKDOWN_FIELDS = `
|
|
340
416
|
convenienceFee { amount formatted }
|
|
341
417
|
deposit { amount formatted }
|
|
@@ -354,9 +430,10 @@ var TICKET_VALUE_FIELDS = `
|
|
|
354
430
|
total { amount formatted }
|
|
355
431
|
}
|
|
356
432
|
`;
|
|
357
|
-
function buildBookingsListingQuery(includeGuests, includePriceBreakdown) {
|
|
358
|
-
const guestsSection = includeGuests ?
|
|
359
|
-
const
|
|
433
|
+
function buildBookingsListingQuery(includeGuests, includePriceBreakdown, fullCustomerAccess = true) {
|
|
434
|
+
const guestsSection = includeGuests ? buildBookingGuestsFields(fullCustomerAccess) : "";
|
|
435
|
+
const baseFields = buildBookingQueryFields(fullCustomerAccess);
|
|
436
|
+
const fields = includePriceBreakdown ? baseFields.replace("value {", `value { ${PRICE_BREAKDOWN_FIELDS}`).replace("ticketQuantities {", `ticketQuantities { ${TICKET_VALUE_FIELDS}`) : baseFields;
|
|
360
437
|
return `
|
|
361
438
|
query Sales($after: String, $first: Int, $filter: SalesFilter!, $orderBy: SalesOrdering) {
|
|
362
439
|
sales(after: $after, first: $first, filter: $filter, orderBy: $orderBy) {
|
|
@@ -373,7 +450,8 @@ function buildBookingsListingQuery(includeGuests, includePriceBreakdown) {
|
|
|
373
450
|
}
|
|
374
451
|
`;
|
|
375
452
|
}
|
|
376
|
-
|
|
453
|
+
function buildBookingGuestsQuery(fullCustomerAccess) {
|
|
454
|
+
return `
|
|
377
455
|
query Sales($after: String, $first: Int, $filter: SalesFilter!, $orderBy: SalesOrdering) {
|
|
378
456
|
sales(after: $after, first: $first, filter: $filter, orderBy: $orderBy) {
|
|
379
457
|
pageInfo { endCursor hasNextPage }
|
|
@@ -382,13 +460,14 @@ var BOOKING_GUESTS_QUERY = `
|
|
|
382
460
|
... on Booking {
|
|
383
461
|
displayId
|
|
384
462
|
id
|
|
385
|
-
${
|
|
463
|
+
${buildBookingGuestsFields(fullCustomerAccess)}
|
|
386
464
|
}
|
|
387
465
|
}
|
|
388
466
|
}
|
|
389
467
|
}
|
|
390
468
|
}
|
|
391
469
|
`;
|
|
470
|
+
}
|
|
392
471
|
var BOOKING_PAYMENTS_ON_FILE_QUERY = `
|
|
393
472
|
query Sales($after: String, $first: Int, $filter: SalesFilter!, $orderBy: SalesOrdering) {
|
|
394
473
|
sales(after: $after, first: $first, filter: $filter, orderBy: $orderBy) {
|
|
@@ -974,10 +1053,23 @@ var BookingService = class {
|
|
|
974
1053
|
this.client = client;
|
|
975
1054
|
this.deps = deps;
|
|
976
1055
|
this.pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE2;
|
|
1056
|
+
this.fullCustomerAccess = resolveAccessOptions(options.accessOptions).fullCustomerAccess;
|
|
977
1057
|
}
|
|
978
1058
|
client;
|
|
979
1059
|
deps;
|
|
980
1060
|
pageSize;
|
|
1061
|
+
/** Whether customer PII is requested and payment operations are allowed. */
|
|
1062
|
+
fullCustomerAccess;
|
|
1063
|
+
/**
|
|
1064
|
+
* Throws a {@link PiiAccessDisabledError} for `operation` when this service was
|
|
1065
|
+
* created without `fullCustomerAccess` — used to gate payment and booking-modification
|
|
1066
|
+
* operations that touch customer financial data.
|
|
1067
|
+
*/
|
|
1068
|
+
assertPiiEnabled(operation) {
|
|
1069
|
+
if (!this.fullCustomerAccess) {
|
|
1070
|
+
throw new PiiAccessDisabledError(operation);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
981
1073
|
/**
|
|
982
1074
|
* Returns a single booking by id, or null when not found. The `bookingId` is
|
|
983
1075
|
* normalized internally (lowercased, `-` → `_`), so `B-ABC123` and `b_abc123`
|
|
@@ -999,7 +1091,7 @@ var BookingService = class {
|
|
|
999
1091
|
const includePriceBreakdown = options.includePriceBreakdown ?? false;
|
|
1000
1092
|
const body = await this.client.request(
|
|
1001
1093
|
SALES_ENDPOINT,
|
|
1002
|
-
buildBookingsListingQuery(includeGuests, includePriceBreakdown),
|
|
1094
|
+
buildBookingsListingQuery(includeGuests, includePriceBreakdown, this.fullCustomerAccess),
|
|
1003
1095
|
buildBookingsVariables({
|
|
1004
1096
|
pageSize: this.pageSize,
|
|
1005
1097
|
after: null,
|
|
@@ -1017,7 +1109,7 @@ var BookingService = class {
|
|
|
1017
1109
|
const includeGuests = input.includeGuests ?? false;
|
|
1018
1110
|
const includePriceBreakdown = input.includePriceBreakdown ?? false;
|
|
1019
1111
|
return this.fetchPaginated(
|
|
1020
|
-
buildBookingsListingQuery(includeGuests, includePriceBreakdown),
|
|
1112
|
+
buildBookingsListingQuery(includeGuests, includePriceBreakdown, this.fullCustomerAccess),
|
|
1021
1113
|
{
|
|
1022
1114
|
startDateTime: input.start,
|
|
1023
1115
|
endDateTime: input.end,
|
|
@@ -1035,7 +1127,7 @@ var BookingService = class {
|
|
|
1035
1127
|
const includeGuests = options.includeGuests ?? false;
|
|
1036
1128
|
const includePriceBreakdown = options.includePriceBreakdown ?? false;
|
|
1037
1129
|
return this.fetchPaginated(
|
|
1038
|
-
buildBookingsListingQuery(includeGuests, includePriceBreakdown),
|
|
1130
|
+
buildBookingsListingQuery(includeGuests, includePriceBreakdown, this.fullCustomerAccess),
|
|
1039
1131
|
{ timeslotId },
|
|
1040
1132
|
includeGuests,
|
|
1041
1133
|
includePriceBreakdown
|
|
@@ -1046,7 +1138,7 @@ var BookingService = class {
|
|
|
1046
1138
|
assertBookingId(bookingId);
|
|
1047
1139
|
const body = await this.client.request(
|
|
1048
1140
|
SALES_ENDPOINT,
|
|
1049
|
-
|
|
1141
|
+
buildBookingGuestsQuery(this.fullCustomerAccess),
|
|
1050
1142
|
buildBookingsVariables({
|
|
1051
1143
|
pageSize: this.pageSize,
|
|
1052
1144
|
after: null,
|
|
@@ -1057,6 +1149,7 @@ var BookingService = class {
|
|
|
1057
1149
|
}
|
|
1058
1150
|
/** Returns the payments on file for a booking, or null when not found. */
|
|
1059
1151
|
async getPaymentsOnFile(bookingId) {
|
|
1152
|
+
this.assertPiiEnabled("getPaymentsOnFile");
|
|
1060
1153
|
assertBookingId(bookingId);
|
|
1061
1154
|
const normalized = normalizeBookingId(bookingId);
|
|
1062
1155
|
const body = await this.client.request(
|
|
@@ -1141,6 +1234,7 @@ ${note}`;
|
|
|
1141
1234
|
* charge fails.
|
|
1142
1235
|
*/
|
|
1143
1236
|
async makePayment(input) {
|
|
1237
|
+
this.assertPiiEnabled("makePayment");
|
|
1144
1238
|
this.validatePaymentInput(input);
|
|
1145
1239
|
const normalized = normalizeBookingId(input.bookingId);
|
|
1146
1240
|
const onFile = await this.getPaymentsOnFile(normalized);
|
|
@@ -1183,6 +1277,7 @@ ${note}`;
|
|
|
1183
1277
|
* payments-on-file, then applies the refund.
|
|
1184
1278
|
*/
|
|
1185
1279
|
async refund(input) {
|
|
1280
|
+
this.assertPiiEnabled("refund");
|
|
1186
1281
|
this.validateRefundInput(input);
|
|
1187
1282
|
const normalized = normalizeBookingId(input.bookingId);
|
|
1188
1283
|
const onFile = await this.getPaymentsOnFile(normalized);
|
|
@@ -1223,6 +1318,7 @@ ${note}`;
|
|
|
1223
1318
|
}
|
|
1224
1319
|
/** Creates an invoice link for a booking's order. */
|
|
1225
1320
|
async createInvoiceLink(bookingId) {
|
|
1321
|
+
this.assertPiiEnabled("createInvoiceLink");
|
|
1226
1322
|
assertBookingId(bookingId);
|
|
1227
1323
|
const normalized = normalizeBookingId(bookingId);
|
|
1228
1324
|
const booking = await this.getById(normalized);
|
|
@@ -1278,6 +1374,7 @@ ${note}`;
|
|
|
1278
1374
|
* the underlying quote/order mutations fail.
|
|
1279
1375
|
*/
|
|
1280
1376
|
async addAddon(bookingId, input) {
|
|
1377
|
+
this.assertPiiEnabled("addAddon");
|
|
1281
1378
|
assertBookingId(bookingId);
|
|
1282
1379
|
const addonOptionId = (input?.addonOptionId || input?.addonId || "").trim();
|
|
1283
1380
|
if (!addonOptionId) {
|
|
@@ -1331,6 +1428,7 @@ ${note}`;
|
|
|
1331
1428
|
* variables. Returns the booking's add-ons after the change.
|
|
1332
1429
|
*/
|
|
1333
1430
|
async removeAddon(bookingId, input) {
|
|
1431
|
+
this.assertPiiEnabled("removeAddon");
|
|
1334
1432
|
assertBookingId(bookingId);
|
|
1335
1433
|
const addonOptionId = (input?.addonOptionId || input?.addonId || "").trim();
|
|
1336
1434
|
if (!addonOptionId) {
|
|
@@ -1820,57 +1918,6 @@ function createTokenManager(config) {
|
|
|
1820
1918
|
});
|
|
1821
1919
|
}
|
|
1822
1920
|
|
|
1823
|
-
// src/errors.ts
|
|
1824
|
-
var AdminAccountRequiredError = class extends Error {
|
|
1825
|
-
/** The HTTP status that triggered this error. */
|
|
1826
|
-
statusCode = 418;
|
|
1827
|
-
constructor(message = "Admin account required") {
|
|
1828
|
-
super(message);
|
|
1829
|
-
this.name = "AdminAccountRequiredError";
|
|
1830
|
-
}
|
|
1831
|
-
};
|
|
1832
|
-
var RateLimitError = class extends Error {
|
|
1833
|
-
/** The HTTP status that triggered this error. */
|
|
1834
|
-
statusCode = 429;
|
|
1835
|
-
constructor(message = "Rate limit exceeded") {
|
|
1836
|
-
super(message);
|
|
1837
|
-
this.name = "RateLimitError";
|
|
1838
|
-
}
|
|
1839
|
-
};
|
|
1840
|
-
var PeekGraphQLError = class extends Error {
|
|
1841
|
-
/** The raw `errors` array returned by the GraphQL endpoint. */
|
|
1842
|
-
graphqlErrors;
|
|
1843
|
-
constructor(graphqlErrors, message = "GraphQL request failed") {
|
|
1844
|
-
super(message);
|
|
1845
|
-
this.name = "PeekGraphQLError";
|
|
1846
|
-
this.graphqlErrors = graphqlErrors;
|
|
1847
|
-
}
|
|
1848
|
-
};
|
|
1849
|
-
var CngApiError = class extends Error {
|
|
1850
|
-
/** The HTTP status that triggered this error. */
|
|
1851
|
-
statusCode;
|
|
1852
|
-
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
1853
|
-
body;
|
|
1854
|
-
constructor(statusCode, body, message) {
|
|
1855
|
-
super(message ?? `CNG request failed with HTTP ${statusCode}`);
|
|
1856
|
-
this.name = "CngApiError";
|
|
1857
|
-
this.statusCode = statusCode;
|
|
1858
|
-
this.body = body;
|
|
1859
|
-
}
|
|
1860
|
-
};
|
|
1861
|
-
var AcmeApiError = class extends Error {
|
|
1862
|
-
/** The HTTP status that triggered this error. */
|
|
1863
|
-
statusCode;
|
|
1864
|
-
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
1865
|
-
body;
|
|
1866
|
-
constructor(statusCode, body, message) {
|
|
1867
|
-
super(message ?? `ACME request failed with HTTP ${statusCode}`);
|
|
1868
|
-
this.name = "AcmeApiError";
|
|
1869
|
-
this.statusCode = statusCode;
|
|
1870
|
-
this.body = body;
|
|
1871
|
-
}
|
|
1872
|
-
};
|
|
1873
|
-
|
|
1874
1921
|
// src/internal/http-transport.ts
|
|
1875
1922
|
var RATE_LIMIT_STATUS = 429;
|
|
1876
1923
|
var ADMIN_ACCOUNT_REQUIRED_STATUS = 418;
|
|
@@ -2289,7 +2336,8 @@ function encodeCursor(offset, pageSize) {
|
|
|
2289
2336
|
}
|
|
2290
2337
|
|
|
2291
2338
|
// src/internal/peek/reviews/review-queries.ts
|
|
2292
|
-
|
|
2339
|
+
function buildReviewsQuery(fullCustomerAccess) {
|
|
2340
|
+
return `
|
|
2293
2341
|
query Reviews($first: Int, $filter: ReviewFilter, $after: String) {
|
|
2294
2342
|
reviews(first: $first, filter: $filter, after: $after) {
|
|
2295
2343
|
edges {
|
|
@@ -2303,8 +2351,7 @@ var REVIEWS_QUERY = `
|
|
|
2303
2351
|
name
|
|
2304
2352
|
}
|
|
2305
2353
|
id
|
|
2306
|
-
name
|
|
2307
|
-
email
|
|
2354
|
+
${fullCustomerAccess ? "name\n email" : ""}
|
|
2308
2355
|
rating
|
|
2309
2356
|
comment
|
|
2310
2357
|
reviewedAt
|
|
@@ -2315,6 +2362,7 @@ var REVIEWS_QUERY = `
|
|
|
2315
2362
|
}
|
|
2316
2363
|
}
|
|
2317
2364
|
`;
|
|
2365
|
+
}
|
|
2318
2366
|
function buildReviewsVariables(params) {
|
|
2319
2367
|
return {
|
|
2320
2368
|
first: params.first,
|
|
@@ -2331,10 +2379,13 @@ var ERROR_PRODUCT_ID_REQUIRED = "productId is required";
|
|
|
2331
2379
|
var ERROR_INVALID_REVIEW_COUNT = `reviewCount must be an integer between ${MIN_REVIEW_COUNT} and ${MAX_REVIEW_COUNT}`;
|
|
2332
2380
|
var ERROR_INVALID_REVIEW_OFFSET = "reviewOffset must be a non-negative integer";
|
|
2333
2381
|
var ReviewService = class {
|
|
2334
|
-
constructor(client) {
|
|
2382
|
+
constructor(client, accessOptions) {
|
|
2335
2383
|
this.client = client;
|
|
2384
|
+
this.fullCustomerAccess = resolveAccessOptions(accessOptions).fullCustomerAccess;
|
|
2336
2385
|
}
|
|
2337
2386
|
client;
|
|
2387
|
+
/** Whether reviewer PII (name/email) is requested. */
|
|
2388
|
+
fullCustomerAccess;
|
|
2338
2389
|
/**
|
|
2339
2390
|
* Returns up to `reviewCount` reviews for an activity in **descending order
|
|
2340
2391
|
* by review date (newest first)**, skipping the `reviewOffset` newest reviews
|
|
@@ -2365,7 +2416,7 @@ var ReviewService = class {
|
|
|
2365
2416
|
const after = reviewOffset > 0 ? encodeCursor(reviewOffset - 1, reviewCount) : null;
|
|
2366
2417
|
const body = await this.client.request(
|
|
2367
2418
|
SALES_ENDPOINT,
|
|
2368
|
-
|
|
2419
|
+
buildReviewsQuery(this.fullCustomerAccess),
|
|
2369
2420
|
buildReviewsVariables({ activityId: productId, first: reviewCount, after })
|
|
2370
2421
|
);
|
|
2371
2422
|
const edges = body.data?.reviews?.edges ?? [];
|
|
@@ -3007,6 +3058,7 @@ var PEEK_TOKEN_ISSUER = "app_registry_v2";
|
|
|
3007
3058
|
var PeekAccessService = class {
|
|
3008
3059
|
client;
|
|
3009
3060
|
productServiceOptions;
|
|
3061
|
+
accessOptions;
|
|
3010
3062
|
jwtSecret;
|
|
3011
3063
|
productService;
|
|
3012
3064
|
accountUserService;
|
|
@@ -3043,6 +3095,7 @@ var PeekAccessService = class {
|
|
|
3043
3095
|
this.productServiceOptions = {
|
|
3044
3096
|
itemOptionsPageSize: config.itemOptionsPageSize
|
|
3045
3097
|
};
|
|
3098
|
+
this.accessOptions = resolveAccessOptions(config.accessOptions);
|
|
3046
3099
|
}
|
|
3047
3100
|
/**
|
|
3048
3101
|
* Verifies a Peek auth token issued by the app registry and returns the
|
|
@@ -3183,9 +3236,11 @@ var PeekAccessService = class {
|
|
|
3183
3236
|
*/
|
|
3184
3237
|
getBookingService() {
|
|
3185
3238
|
if (!this.bookingService) {
|
|
3186
|
-
this.bookingService = new BookingService(
|
|
3187
|
-
|
|
3188
|
-
|
|
3239
|
+
this.bookingService = new BookingService(
|
|
3240
|
+
this.client,
|
|
3241
|
+
{ productService: this.getProductService() },
|
|
3242
|
+
{ accessOptions: this.accessOptions }
|
|
3243
|
+
);
|
|
3189
3244
|
}
|
|
3190
3245
|
return this.bookingService;
|
|
3191
3246
|
}
|
|
@@ -3195,7 +3250,7 @@ var PeekAccessService = class {
|
|
|
3195
3250
|
*/
|
|
3196
3251
|
getReviewService() {
|
|
3197
3252
|
if (!this.reviewService) {
|
|
3198
|
-
this.reviewService = new ReviewService(this.client);
|
|
3253
|
+
this.reviewService = new ReviewService(this.client, this.accessOptions);
|
|
3199
3254
|
}
|
|
3200
3255
|
return this.reviewService;
|
|
3201
3256
|
}
|
|
@@ -3497,7 +3552,7 @@ var CngAccessService = class {
|
|
|
3497
3552
|
};
|
|
3498
3553
|
|
|
3499
3554
|
// src/internal/acme/endpoints.ts
|
|
3500
|
-
var ACME_EXTENDABLE_SLUG = "acme_backoffice_api
|
|
3555
|
+
var ACME_EXTENDABLE_SLUG = "acme_backoffice_api-v1";
|
|
3501
3556
|
var TEMPLATES_PATH = "v2/b2b/event/templates/names?pageSize=-1&page=1";
|
|
3502
3557
|
|
|
3503
3558
|
// src/models/acme/product.ts
|
|
@@ -3688,8 +3743,13 @@ function hasPriceBreakdown(node) {
|
|
|
3688
3743
|
|
|
3689
3744
|
// src/internal/peek/waivers/waiver-webhook.ts
|
|
3690
3745
|
var PAYLOAD_WAIVER_KEY = "waiver";
|
|
3691
|
-
function parseWaiverWebhook(payload) {
|
|
3692
|
-
|
|
3746
|
+
function parseWaiverWebhook(payload, options) {
|
|
3747
|
+
const waiver = fromWaiverNode(extractWaiverNode(payload));
|
|
3748
|
+
if (!resolveAccessOptions(options).fullCustomerAccess) {
|
|
3749
|
+
waiver.guestName = null;
|
|
3750
|
+
waiver.fileUrl = "";
|
|
3751
|
+
}
|
|
3752
|
+
return waiver;
|
|
3693
3753
|
}
|
|
3694
3754
|
function fromWaiverNode(node) {
|
|
3695
3755
|
const data = node ?? {};
|
|
@@ -3721,6 +3781,6 @@ function extractWaiverNode(payload) {
|
|
|
3721
3781
|
return record;
|
|
3722
3782
|
}
|
|
3723
3783
|
|
|
3724
|
-
export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, AccountUserService, AcmeAccessService, AcmeApiError, AcmeProductService, AdminAccountRequiredError, AvailabilityService, BookingService, CngAccessService, CngApiError, CngProductService, DailyNoteService, MembershipService, PeekAccessService, PeekGraphQLError, ProductService, PromoCodeService, RENTAL_PRODUCT_TYPE, RateLimitError, ResellerService, ResourcePoolService, ReviewService, TimeslotService, noopLogger, parseBookingWebhook, parseWaiverWebhook };
|
|
3784
|
+
export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, AccountUserService, AcmeAccessService, AcmeApiError, AcmeProductService, AdminAccountRequiredError, AvailabilityService, BookingService, CngAccessService, CngApiError, CngProductService, DailyNoteService, MembershipService, PeekAccessService, PeekGraphQLError, PiiAccessDisabledError, ProductService, PromoCodeService, RENTAL_PRODUCT_TYPE, RateLimitError, ResellerService, ResourcePoolService, ReviewService, TimeslotService, noopLogger, parseBookingWebhook, parseWaiverWebhook };
|
|
3725
3785
|
//# sourceMappingURL=index.js.map
|
|
3726
3786
|
//# sourceMappingURL=index.js.map
|