@peektravel/app-utilities 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +101 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -63
- package/dist/index.d.ts +88 -63
- package/dist/index.js +101 -61
- package/dist/index.js.map +1 -1
- package/llms.txt +14 -6
- package/package.json +1 -2
- package/docs/ui.md +0 -1175
package/dist/index.js
CHANGED
|
@@ -185,6 +185,13 @@ function resolveAccessOptions(options) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
// src/errors.ts
|
|
188
|
+
var FORBIDDEN_STATUS = 403;
|
|
189
|
+
var PERMISSION_MESSAGE_PREFIX = "CNG request forbidden: the app is missing the required permission";
|
|
190
|
+
var PERMISSION_MESSAGE_UNKNOWN = "CNG request forbidden: the app is missing a required permission";
|
|
191
|
+
function buildPermissionMessage(permissions) {
|
|
192
|
+
if (permissions.length === 0) return PERMISSION_MESSAGE_UNKNOWN;
|
|
193
|
+
return `${PERMISSION_MESSAGE_PREFIX}${permissions.length > 1 ? "s" : ""}: ${permissions.join(", ")}`;
|
|
194
|
+
}
|
|
188
195
|
var AdminAccountRequiredError = class extends Error {
|
|
189
196
|
/** The HTTP status that triggered this error. */
|
|
190
197
|
statusCode = 418;
|
|
@@ -248,6 +255,23 @@ var CngApiError = class extends Error {
|
|
|
248
255
|
this.body = body;
|
|
249
256
|
}
|
|
250
257
|
};
|
|
258
|
+
var CngPermissionError = class extends Error {
|
|
259
|
+
/** The HTTP status that triggered this error. */
|
|
260
|
+
statusCode = FORBIDDEN_STATUS;
|
|
261
|
+
/**
|
|
262
|
+
* The permissions the gateway reported as missing, e.g. `["products:read"]`.
|
|
263
|
+
* Empty when the response body did not name any.
|
|
264
|
+
*/
|
|
265
|
+
permissions;
|
|
266
|
+
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
267
|
+
body;
|
|
268
|
+
constructor(permissions, body, message) {
|
|
269
|
+
super(message ?? buildPermissionMessage(permissions));
|
|
270
|
+
this.name = "CngPermissionError";
|
|
271
|
+
this.permissions = permissions;
|
|
272
|
+
this.body = body;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
251
275
|
var AcmeApiError = class extends Error {
|
|
252
276
|
/** The HTTP status that triggered this error. */
|
|
253
277
|
statusCode;
|
|
@@ -2100,6 +2124,12 @@ async function requestWithRetry(http, url, init, label, onResponse) {
|
|
|
2100
2124
|
throw new RateLimitError();
|
|
2101
2125
|
}
|
|
2102
2126
|
|
|
2127
|
+
// src/internal/sdk-headers.ts
|
|
2128
|
+
var SDK_HEADER_NAME = "x-peek-sdk";
|
|
2129
|
+
var SDK_PLATFORM = "js";
|
|
2130
|
+
var SDK_VERSION = "0.9.0";
|
|
2131
|
+
var SDK_HEADER_VALUE = `${SDK_PLATFORM}-${SDK_VERSION}`;
|
|
2132
|
+
|
|
2103
2133
|
// src/internal/peek/graphql-client.ts
|
|
2104
2134
|
var isObject = (value) => typeof value === "object" && value !== null;
|
|
2105
2135
|
var GraphQLClient = class {
|
|
@@ -2153,7 +2183,8 @@ var GraphQLClient = class {
|
|
|
2153
2183
|
buildHeaders() {
|
|
2154
2184
|
const headers = {
|
|
2155
2185
|
"X-Peek-Auth": `Bearer ${this.options.getToken()}`,
|
|
2156
|
-
"Content-Type": "application/json"
|
|
2186
|
+
"Content-Type": "application/json",
|
|
2187
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE
|
|
2157
2188
|
};
|
|
2158
2189
|
if (this.options.gatewayKey) {
|
|
2159
2190
|
headers["pk-api-key"] = this.options.gatewayKey;
|
|
@@ -3951,182 +3982,182 @@ var PeekAccessService = class {
|
|
|
3951
3982
|
return this.reviewService;
|
|
3952
3983
|
}
|
|
3953
3984
|
// ─── Product short-forms ─────────────────────────────────────────────────
|
|
3954
|
-
/** All products (activities + add-ons).
|
|
3985
|
+
/** All products (activities + add-ons). @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllProducts}. */
|
|
3955
3986
|
getAllProducts() {
|
|
3956
3987
|
return this.getProductService().getAllProducts();
|
|
3957
3988
|
}
|
|
3958
|
-
/** All activity products (excludes add-ons).
|
|
3989
|
+
/** All activity products (excludes add-ons). @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllActivities}. */
|
|
3959
3990
|
getAllActivities() {
|
|
3960
3991
|
return this.getProductService().getAllActivities();
|
|
3961
3992
|
}
|
|
3962
|
-
/** All rental products.
|
|
3993
|
+
/** All rental products. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllRentals}. */
|
|
3963
3994
|
getAllRentals() {
|
|
3964
3995
|
return this.getProductService().getAllRentals();
|
|
3965
3996
|
}
|
|
3966
|
-
/** All add-on products.
|
|
3997
|
+
/** All add-on products. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllAddons}. */
|
|
3967
3998
|
getAllAddons() {
|
|
3968
3999
|
return this.getProductService().getAllAddons();
|
|
3969
4000
|
}
|
|
3970
|
-
/** An activity's custom questions.
|
|
4001
|
+
/** An activity's custom questions. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getCustomQuestions}. */
|
|
3971
4002
|
getCustomQuestions(productId) {
|
|
3972
4003
|
return this.getProductService().getCustomQuestions(productId);
|
|
3973
4004
|
}
|
|
3974
4005
|
// ─── Account-user short-forms ─────────────────────────────────────────────
|
|
3975
|
-
/** All active account users.
|
|
4006
|
+
/** All active account users. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AccountUserService.getAll}. */
|
|
3976
4007
|
getAllAccountUsers() {
|
|
3977
4008
|
return this.getAccountUserService().getAll();
|
|
3978
4009
|
}
|
|
3979
|
-
/** Account user by id, or null.
|
|
4010
|
+
/** Account user by id, or null. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AccountUserService.getById}. */
|
|
3980
4011
|
getAccountUserById(userId) {
|
|
3981
4012
|
return this.getAccountUserService().getById(userId);
|
|
3982
4013
|
}
|
|
3983
4014
|
// ─── Resource-pool short-forms ────────────────────────────────────────────
|
|
3984
|
-
/** All resource pools.
|
|
4015
|
+
/** All resource pools. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ResourcePoolService.getAll}. */
|
|
3985
4016
|
getAllResourcePools(mode) {
|
|
3986
4017
|
return this.getResourcePoolService().getAll(mode);
|
|
3987
4018
|
}
|
|
3988
4019
|
// ─── Timeslot short-forms ─────────────────────────────────────────────────
|
|
3989
|
-
/** Timeslots for an activity on a given date.
|
|
4020
|
+
/** Timeslots for an activity on a given date. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.getForDay}. */
|
|
3990
4021
|
getTimeslotsForDay(productId, date, filter) {
|
|
3991
4022
|
return this.getTimeslotService().getForDay(productId, date, filter);
|
|
3992
4023
|
}
|
|
3993
|
-
/** Single timeslot by id.
|
|
4024
|
+
/** Single timeslot by id. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.getById}. */
|
|
3994
4025
|
getTimeslotById(timeslotId) {
|
|
3995
4026
|
return this.getTimeslotService().getById(timeslotId);
|
|
3996
4027
|
}
|
|
3997
|
-
/** Set timeslot status.
|
|
4028
|
+
/** Set timeslot status. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.setAvailability}. */
|
|
3998
4029
|
setTimeslotAvailability(timeslotId, status) {
|
|
3999
4030
|
return this.getTimeslotService().setAvailability(timeslotId, status);
|
|
4000
4031
|
}
|
|
4001
|
-
/** Set timeslot manifest notes.
|
|
4032
|
+
/** Set timeslot manifest notes. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.setNotes}. */
|
|
4002
4033
|
setTimeslotNotes(timeslotId, manifestNotes) {
|
|
4003
4034
|
return this.getTimeslotService().setNotes(timeslotId, manifestNotes);
|
|
4004
4035
|
}
|
|
4005
|
-
/** Assign or unassign guides on timeslots.
|
|
4036
|
+
/** Assign or unassign guides on timeslots. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.assignGuide}. */
|
|
4006
4037
|
assignTimeslotGuide(assignment) {
|
|
4007
4038
|
return this.getTimeslotService().assignGuide(assignment);
|
|
4008
4039
|
}
|
|
4009
4040
|
// ─── Reseller short-forms ─────────────────────────────────────────────────
|
|
4010
|
-
/** All reseller channels.
|
|
4041
|
+
/** All reseller channels. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ResellerService.getAllChannels}. */
|
|
4011
4042
|
getAllChannels(agentsPerChannel) {
|
|
4012
4043
|
return this.getResellerService().getAllChannels(agentsPerChannel);
|
|
4013
4044
|
}
|
|
4014
4045
|
// ─── Promo-code short-forms ───────────────────────────────────────────────
|
|
4015
|
-
/** All promo codes.
|
|
4046
|
+
/** All promo codes. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PromoCodeService.getAll}. */
|
|
4016
4047
|
getAllPromoCodes() {
|
|
4017
4048
|
return this.getPromoCodeService().getAll();
|
|
4018
4049
|
}
|
|
4019
|
-
/** Create a promo code.
|
|
4050
|
+
/** Create a promo code. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PromoCodeService.create}. */
|
|
4020
4051
|
createPromoCode(input) {
|
|
4021
4052
|
return this.getPromoCodeService().create(input);
|
|
4022
4053
|
}
|
|
4023
4054
|
// ─── Pricing short-forms ──────────────────────────────────────────────────
|
|
4024
|
-
/** Create a pricing engine.
|
|
4055
|
+
/** Create a pricing engine. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.createEngine}. */
|
|
4025
4056
|
createPricingEngine(input) {
|
|
4026
4057
|
return this.getPricingService().createEngine(input);
|
|
4027
4058
|
}
|
|
4028
|
-
/** Update a pricing engine.
|
|
4059
|
+
/** Update a pricing engine. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.updateEngine}. */
|
|
4029
4060
|
updatePricingEngine(input) {
|
|
4030
4061
|
return this.getPricingService().updateEngine(input);
|
|
4031
4062
|
}
|
|
4032
|
-
/** Delete a pricing engine (idempotent).
|
|
4063
|
+
/** Delete a pricing engine (idempotent). @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.deleteEngine}. */
|
|
4033
4064
|
deletePricingEngine(engineId) {
|
|
4034
4065
|
return this.getPricingService().deleteEngine(engineId);
|
|
4035
4066
|
}
|
|
4036
|
-
/** Upsert pricing overrides.
|
|
4067
|
+
/** Upsert pricing overrides. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.upsertOverrides}. */
|
|
4037
4068
|
upsertPricingOverrides(input) {
|
|
4038
4069
|
return this.getPricingService().upsertOverrides(input);
|
|
4039
4070
|
}
|
|
4040
|
-
/** Clear pricing overrides for a set of activities.
|
|
4071
|
+
/** Clear pricing overrides for a set of activities. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.clearOverrides}. */
|
|
4041
4072
|
clearPricingOverrides(input) {
|
|
4042
4073
|
return this.getPricingService().clearOverrides(input);
|
|
4043
4074
|
}
|
|
4044
4075
|
// ─── Daily-note short-forms ───────────────────────────────────────────────
|
|
4045
|
-
/** Today's daily note.
|
|
4076
|
+
/** Today's daily note. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link DailyNoteService.getToday}. */
|
|
4046
4077
|
getDailyNoteToday() {
|
|
4047
4078
|
return this.getDailyNoteService().getToday();
|
|
4048
4079
|
}
|
|
4049
|
-
/** Update today's daily note.
|
|
4080
|
+
/** Update today's daily note. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link DailyNoteService.update}. */
|
|
4050
4081
|
updateDailyNote(note) {
|
|
4051
4082
|
return this.getDailyNoteService().update(note);
|
|
4052
4083
|
}
|
|
4053
4084
|
// ─── Availability short-forms ─────────────────────────────────────────────
|
|
4054
|
-
/** Availability times for an activity.
|
|
4085
|
+
/** Availability times for an activity. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AvailabilityService.getAvailabilityTimes}. */
|
|
4055
4086
|
getAvailabilityTimes(query) {
|
|
4056
4087
|
return this.getAvailabilityService().getAvailabilityTimes(query);
|
|
4057
4088
|
}
|
|
4058
4089
|
// ─── Membership short-forms ───────────────────────────────────────────────
|
|
4059
|
-
/** All memberships.
|
|
4090
|
+
/** All memberships. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link MembershipService.getAll}. */
|
|
4060
4091
|
getAllMemberships() {
|
|
4061
4092
|
return this.getMembershipService().getAll();
|
|
4062
4093
|
}
|
|
4063
|
-
/** Purchase a membership.
|
|
4094
|
+
/** Purchase a membership. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link MembershipService.purchase}. */
|
|
4064
4095
|
purchaseMembership(input) {
|
|
4065
4096
|
return this.getMembershipService().purchase(input);
|
|
4066
4097
|
}
|
|
4067
4098
|
// ─── Booking short-forms ──────────────────────────────────────────────────
|
|
4068
|
-
/** Booking by id.
|
|
4099
|
+
/** Booking by id. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.getById}. */
|
|
4069
4100
|
getBookingById(bookingId, options) {
|
|
4070
4101
|
return this.getBookingService().getById(bookingId, options);
|
|
4071
4102
|
}
|
|
4072
|
-
/** Bookings by time range.
|
|
4103
|
+
/** Bookings by time range. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.searchByTimeRange}. */
|
|
4073
4104
|
searchBookingsByTimeRange(input) {
|
|
4074
4105
|
return this.getBookingService().searchByTimeRange(input);
|
|
4075
4106
|
}
|
|
4076
|
-
/** Bookings on a timeslot.
|
|
4107
|
+
/** Bookings on a timeslot. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.searchByTimeslot}. */
|
|
4077
4108
|
searchBookingsByTimeslot(timeslotId, options) {
|
|
4078
4109
|
return this.getBookingService().searchByTimeslot(timeslotId, options);
|
|
4079
4110
|
}
|
|
4080
|
-
/** Guests on a booking.
|
|
4111
|
+
/** Guests on a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.getGuests}. */
|
|
4081
4112
|
getBookingGuests(bookingId) {
|
|
4082
4113
|
return this.getBookingService().getGuests(bookingId);
|
|
4083
4114
|
}
|
|
4084
|
-
/** Payments on file for a booking.
|
|
4115
|
+
/** Payments on file for a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.getPaymentsOnFile}. */
|
|
4085
4116
|
getBookingPaymentsOnFile(bookingId) {
|
|
4086
4117
|
return this.getBookingService().getPaymentsOnFile(bookingId);
|
|
4087
4118
|
}
|
|
4088
|
-
/** Append or overwrite operator notes.
|
|
4119
|
+
/** Append or overwrite operator notes. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.appendNote}. */
|
|
4089
4120
|
appendBookingNote(bookingId, note, mode) {
|
|
4090
4121
|
return this.getBookingService().appendNote(bookingId, note, mode);
|
|
4091
4122
|
}
|
|
4092
|
-
/** Set booking check-in status.
|
|
4123
|
+
/** Set booking check-in status. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.setCheckinStatus}. */
|
|
4093
4124
|
setBookingCheckinStatus(bookingId, checkedIn) {
|
|
4094
4125
|
return this.getBookingService().setCheckinStatus(bookingId, checkedIn);
|
|
4095
4126
|
}
|
|
4096
|
-
/** Cancel a booking.
|
|
4127
|
+
/** Cancel a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.cancel}. */
|
|
4097
4128
|
cancelBooking(bookingId, notes) {
|
|
4098
4129
|
return this.getBookingService().cancel(bookingId, notes);
|
|
4099
4130
|
}
|
|
4100
|
-
/** Charge a booking.
|
|
4131
|
+
/** Charge a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.makePayment}. */
|
|
4101
4132
|
makeBookingPayment(input) {
|
|
4102
4133
|
return this.getBookingService().makePayment(input);
|
|
4103
4134
|
}
|
|
4104
|
-
/** Refund a booking payment.
|
|
4135
|
+
/** Refund a booking payment. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.refund}. */
|
|
4105
4136
|
refundBooking(input) {
|
|
4106
4137
|
return this.getBookingService().refund(input);
|
|
4107
4138
|
}
|
|
4108
|
-
/** Create an invoice link.
|
|
4139
|
+
/** Create an invoice link. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.createInvoiceLink}. */
|
|
4109
4140
|
createBookingInvoiceLink(bookingId) {
|
|
4110
4141
|
return this.getBookingService().createInvoiceLink(bookingId);
|
|
4111
4142
|
}
|
|
4112
|
-
/** List add-ons on a booking.
|
|
4143
|
+
/** List add-ons on a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.listAddons}. */
|
|
4113
4144
|
listBookingAddons(bookingId) {
|
|
4114
4145
|
return this.getBookingService().listAddons(bookingId);
|
|
4115
4146
|
}
|
|
4116
|
-
/** Add an add-on to a booking.
|
|
4147
|
+
/** Add an add-on to a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.addAddon}. */
|
|
4117
4148
|
addBookingAddon(bookingId, input) {
|
|
4118
4149
|
return this.getBookingService().addAddon(bookingId, input);
|
|
4119
4150
|
}
|
|
4120
|
-
/** Remove an add-on from a booking.
|
|
4151
|
+
/** Remove an add-on from a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.removeAddon}. */
|
|
4121
4152
|
removeBookingAddon(bookingId, input) {
|
|
4122
4153
|
return this.getBookingService().removeAddon(bookingId, input);
|
|
4123
4154
|
}
|
|
4124
|
-
/** Create a booking.
|
|
4155
|
+
/** Create a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.create}. */
|
|
4125
4156
|
createBooking(input) {
|
|
4126
4157
|
return this.getBookingService().create(input);
|
|
4127
4158
|
}
|
|
4128
4159
|
// ─── Review short-forms ───────────────────────────────────────────────────
|
|
4129
|
-
/** Reviews for an activity.
|
|
4160
|
+
/** Reviews for an activity. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ReviewService.getReviews}. */
|
|
4130
4161
|
getReviews(productId, reviewCount, reviewOffset) {
|
|
4131
4162
|
return this.getReviewService().getReviews(productId, reviewCount, reviewOffset);
|
|
4132
4163
|
}
|
|
@@ -4134,7 +4165,7 @@ var PeekAccessService = class {
|
|
|
4134
4165
|
|
|
4135
4166
|
// src/internal/cng/endpoints.ts
|
|
4136
4167
|
var CNG_EXTENDABLE_SLUG = "cng_backoffice_api-v1";
|
|
4137
|
-
var PRODUCTS_PATH = "api/v2/
|
|
4168
|
+
var PRODUCTS_PATH = "api/v2/app-registry/products?active=1";
|
|
4138
4169
|
|
|
4139
4170
|
// src/models/cng/product.ts
|
|
4140
4171
|
var ACTIVITY_PRODUCT_TYPE2 = "ACTIVITY";
|
|
@@ -4145,14 +4176,11 @@ function fromProductNodes(nodes) {
|
|
|
4145
4176
|
}
|
|
4146
4177
|
function fromProductNode(node) {
|
|
4147
4178
|
return {
|
|
4148
|
-
productId: node.id
|
|
4179
|
+
productId: node.id == null ? "" : String(node.id),
|
|
4149
4180
|
name: node.name || "",
|
|
4150
|
-
type:
|
|
4151
|
-
color: node.
|
|
4152
|
-
tickets:
|
|
4153
|
-
id: ticket.id,
|
|
4154
|
-
name: ticket.name
|
|
4155
|
-
}))
|
|
4181
|
+
type: ACTIVITY_PRODUCT_TYPE2,
|
|
4182
|
+
color: node.access_control_color_hex || "",
|
|
4183
|
+
tickets: []
|
|
4156
4184
|
};
|
|
4157
4185
|
}
|
|
4158
4186
|
|
|
@@ -4171,15 +4199,13 @@ var CngProductService = class {
|
|
|
4171
4199
|
* ```
|
|
4172
4200
|
*/
|
|
4173
4201
|
async getAllActivities() {
|
|
4174
|
-
const body = await this.client.get(
|
|
4175
|
-
|
|
4176
|
-
);
|
|
4177
|
-
const nodes = Array.isArray(body) ? body : body?.products ?? [];
|
|
4178
|
-
return fromProductNodes(nodes ?? []);
|
|
4202
|
+
const body = await this.client.get(PRODUCTS_PATH);
|
|
4203
|
+
return fromProductNodes(body?.data ?? []);
|
|
4179
4204
|
}
|
|
4180
4205
|
};
|
|
4181
4206
|
|
|
4182
4207
|
// src/internal/cng/rest-client.ts
|
|
4208
|
+
var PERMISSION_SEPARATOR = ": ";
|
|
4183
4209
|
var RestClient = class {
|
|
4184
4210
|
constructor(options) {
|
|
4185
4211
|
this.options = options;
|
|
@@ -4192,6 +4218,7 @@ var RestClient = class {
|
|
|
4192
4218
|
*
|
|
4193
4219
|
* @throws {AdminAccountRequiredError} on HTTP 418
|
|
4194
4220
|
* @throws {RateLimitError} on HTTP 429 after retries are exhausted
|
|
4221
|
+
* @throws {CngPermissionError} on HTTP 403 (app missing a permission)
|
|
4195
4222
|
* @throws {CngApiError} on any other non-2xx response
|
|
4196
4223
|
*/
|
|
4197
4224
|
async get(path) {
|
|
@@ -4205,6 +4232,11 @@ var RestClient = class {
|
|
|
4205
4232
|
path,
|
|
4206
4233
|
async (response) => {
|
|
4207
4234
|
const body = await parseBody(response);
|
|
4235
|
+
if (response.status === FORBIDDEN_STATUS) {
|
|
4236
|
+
const permissions = extractMissingPermissions(body);
|
|
4237
|
+
logger.warn(`Missing permission for ${path} (HTTP 403)`, { url, permissions });
|
|
4238
|
+
throw new CngPermissionError(permissions, body);
|
|
4239
|
+
}
|
|
4208
4240
|
if (!response.ok) {
|
|
4209
4241
|
logger.error(`CNG request failed with HTTP ${response.status}`, { url });
|
|
4210
4242
|
throw new CngApiError(response.status, body);
|
|
@@ -4221,10 +4253,17 @@ var RestClient = class {
|
|
|
4221
4253
|
buildHeaders() {
|
|
4222
4254
|
return {
|
|
4223
4255
|
"X-Peek-Auth": `Bearer ${this.options.getToken()}`,
|
|
4224
|
-
"Content-Type": "application/json"
|
|
4256
|
+
"Content-Type": "application/json",
|
|
4257
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE
|
|
4225
4258
|
};
|
|
4226
4259
|
}
|
|
4227
4260
|
};
|
|
4261
|
+
function extractMissingPermissions(body) {
|
|
4262
|
+
if (typeof body !== "object" || body === null) return [];
|
|
4263
|
+
const raw = body.errors?.permission;
|
|
4264
|
+
if (!Array.isArray(raw)) return [];
|
|
4265
|
+
return raw.filter((entry) => typeof entry === "string").map((entry) => entry.split(PERMISSION_SEPARATOR).pop().trim()).filter((permission) => permission.length > 0);
|
|
4266
|
+
}
|
|
4228
4267
|
|
|
4229
4268
|
// src/cng-access-service.ts
|
|
4230
4269
|
var DEFAULT_BASE_URL2 = "https://app-registry.peeklabs.com/installations-api";
|
|
@@ -4260,7 +4299,7 @@ var CngAccessService = class {
|
|
|
4260
4299
|
}
|
|
4261
4300
|
return this.productService;
|
|
4262
4301
|
}
|
|
4263
|
-
/** All activities.
|
|
4302
|
+
/** All activities. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link CngProductService.getAllActivities}. */
|
|
4264
4303
|
getAllActivities() {
|
|
4265
4304
|
return this.getProductService().getAllActivities();
|
|
4266
4305
|
}
|
|
@@ -4355,7 +4394,8 @@ var RestClient2 = class {
|
|
|
4355
4394
|
buildHeaders() {
|
|
4356
4395
|
return {
|
|
4357
4396
|
"X-Peek-Auth": `Bearer ${this.options.getToken()}`,
|
|
4358
|
-
"Content-Type": "application/json"
|
|
4397
|
+
"Content-Type": "application/json",
|
|
4398
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE
|
|
4359
4399
|
};
|
|
4360
4400
|
}
|
|
4361
4401
|
};
|
|
@@ -4394,7 +4434,7 @@ var AcmeAccessService = class {
|
|
|
4394
4434
|
}
|
|
4395
4435
|
return this.productService;
|
|
4396
4436
|
}
|
|
4397
|
-
/** All activities.
|
|
4437
|
+
/** All activities. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AcmeProductService.getAllActivities}. */
|
|
4398
4438
|
getAllActivities() {
|
|
4399
4439
|
return this.getProductService().getAllActivities();
|
|
4400
4440
|
}
|
|
@@ -4569,6 +4609,6 @@ function verifyInstallWebhook(token, secret) {
|
|
|
4569
4609
|
};
|
|
4570
4610
|
}
|
|
4571
4611
|
|
|
4572
|
-
export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, AccountUserService, AcmeAccessService, AcmeApiError, AcmeProductService, AdminAccountRequiredError, AvailabilityService, BookingService, CngAccessService, CngApiError, CngProductService, DailyNoteService, INSTALL_STATUSES, MembershipService, PeekAccessService, PeekGraphQLError, PeekHttpError, PiiAccessDisabledError, PricingService, ProductService, PromoCodeService, RENTAL_PRODUCT_TYPE, RateLimitError, ResellerService, ResourcePoolService, ReviewService, TimeslotService, createAccessServiceForInstall, noopLogger, parseBookingWebhook, parseInstallWebhook, parseWaiverWebhook, verifyInstallWebhook };
|
|
4612
|
+
export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, AccountUserService, AcmeAccessService, AcmeApiError, AcmeProductService, AdminAccountRequiredError, AvailabilityService, BookingService, CngAccessService, CngApiError, CngPermissionError, CngProductService, DailyNoteService, INSTALL_STATUSES, MembershipService, PeekAccessService, PeekGraphQLError, PeekHttpError, PiiAccessDisabledError, PricingService, ProductService, PromoCodeService, RENTAL_PRODUCT_TYPE, RateLimitError, ResellerService, ResourcePoolService, ReviewService, TimeslotService, createAccessServiceForInstall, noopLogger, parseBookingWebhook, parseInstallWebhook, parseWaiverWebhook, verifyInstallWebhook };
|
|
4573
4613
|
//# sourceMappingURL=index.js.map
|
|
4574
4614
|
//# sourceMappingURL=index.js.map
|