@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.cjs
CHANGED
|
@@ -207,6 +207,13 @@ function resolveAccessOptions(options) {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// src/errors.ts
|
|
210
|
+
var FORBIDDEN_STATUS = 403;
|
|
211
|
+
var PERMISSION_MESSAGE_PREFIX = "CNG request forbidden: the app is missing the required permission";
|
|
212
|
+
var PERMISSION_MESSAGE_UNKNOWN = "CNG request forbidden: the app is missing a required permission";
|
|
213
|
+
function buildPermissionMessage(permissions) {
|
|
214
|
+
if (permissions.length === 0) return PERMISSION_MESSAGE_UNKNOWN;
|
|
215
|
+
return `${PERMISSION_MESSAGE_PREFIX}${permissions.length > 1 ? "s" : ""}: ${permissions.join(", ")}`;
|
|
216
|
+
}
|
|
210
217
|
var AdminAccountRequiredError = class extends Error {
|
|
211
218
|
/** The HTTP status that triggered this error. */
|
|
212
219
|
statusCode = 418;
|
|
@@ -270,6 +277,23 @@ var CngApiError = class extends Error {
|
|
|
270
277
|
this.body = body;
|
|
271
278
|
}
|
|
272
279
|
};
|
|
280
|
+
var CngPermissionError = class extends Error {
|
|
281
|
+
/** The HTTP status that triggered this error. */
|
|
282
|
+
statusCode = FORBIDDEN_STATUS;
|
|
283
|
+
/**
|
|
284
|
+
* The permissions the gateway reported as missing, e.g. `["products:read"]`.
|
|
285
|
+
* Empty when the response body did not name any.
|
|
286
|
+
*/
|
|
287
|
+
permissions;
|
|
288
|
+
/** The raw response body (parsed JSON when possible, otherwise text). */
|
|
289
|
+
body;
|
|
290
|
+
constructor(permissions, body, message) {
|
|
291
|
+
super(message ?? buildPermissionMessage(permissions));
|
|
292
|
+
this.name = "CngPermissionError";
|
|
293
|
+
this.permissions = permissions;
|
|
294
|
+
this.body = body;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
273
297
|
var AcmeApiError = class extends Error {
|
|
274
298
|
/** The HTTP status that triggered this error. */
|
|
275
299
|
statusCode;
|
|
@@ -2122,6 +2146,12 @@ async function requestWithRetry(http, url, init, label, onResponse) {
|
|
|
2122
2146
|
throw new RateLimitError();
|
|
2123
2147
|
}
|
|
2124
2148
|
|
|
2149
|
+
// src/internal/sdk-headers.ts
|
|
2150
|
+
var SDK_HEADER_NAME = "x-peek-sdk";
|
|
2151
|
+
var SDK_PLATFORM = "js";
|
|
2152
|
+
var SDK_VERSION = "0.9.0";
|
|
2153
|
+
var SDK_HEADER_VALUE = `${SDK_PLATFORM}-${SDK_VERSION}`;
|
|
2154
|
+
|
|
2125
2155
|
// src/internal/peek/graphql-client.ts
|
|
2126
2156
|
var isObject = (value) => typeof value === "object" && value !== null;
|
|
2127
2157
|
var GraphQLClient = class {
|
|
@@ -2175,7 +2205,8 @@ var GraphQLClient = class {
|
|
|
2175
2205
|
buildHeaders() {
|
|
2176
2206
|
const headers = {
|
|
2177
2207
|
"X-Peek-Auth": `Bearer ${this.options.getToken()}`,
|
|
2178
|
-
"Content-Type": "application/json"
|
|
2208
|
+
"Content-Type": "application/json",
|
|
2209
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE
|
|
2179
2210
|
};
|
|
2180
2211
|
if (this.options.gatewayKey) {
|
|
2181
2212
|
headers["pk-api-key"] = this.options.gatewayKey;
|
|
@@ -3973,182 +4004,182 @@ var PeekAccessService = class {
|
|
|
3973
4004
|
return this.reviewService;
|
|
3974
4005
|
}
|
|
3975
4006
|
// ─── Product short-forms ─────────────────────────────────────────────────
|
|
3976
|
-
/** All products (activities + add-ons).
|
|
4007
|
+
/** All products (activities + add-ons). @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllProducts}. */
|
|
3977
4008
|
getAllProducts() {
|
|
3978
4009
|
return this.getProductService().getAllProducts();
|
|
3979
4010
|
}
|
|
3980
|
-
/** All activity products (excludes add-ons).
|
|
4011
|
+
/** 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}. */
|
|
3981
4012
|
getAllActivities() {
|
|
3982
4013
|
return this.getProductService().getAllActivities();
|
|
3983
4014
|
}
|
|
3984
|
-
/** All rental products.
|
|
4015
|
+
/** All rental products. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllRentals}. */
|
|
3985
4016
|
getAllRentals() {
|
|
3986
4017
|
return this.getProductService().getAllRentals();
|
|
3987
4018
|
}
|
|
3988
|
-
/** All add-on products.
|
|
4019
|
+
/** All add-on products. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllAddons}. */
|
|
3989
4020
|
getAllAddons() {
|
|
3990
4021
|
return this.getProductService().getAllAddons();
|
|
3991
4022
|
}
|
|
3992
|
-
/** An activity's custom questions.
|
|
4023
|
+
/** An activity's custom questions. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getCustomQuestions}. */
|
|
3993
4024
|
getCustomQuestions(productId) {
|
|
3994
4025
|
return this.getProductService().getCustomQuestions(productId);
|
|
3995
4026
|
}
|
|
3996
4027
|
// ─── Account-user short-forms ─────────────────────────────────────────────
|
|
3997
|
-
/** All active account users.
|
|
4028
|
+
/** All active account users. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AccountUserService.getAll}. */
|
|
3998
4029
|
getAllAccountUsers() {
|
|
3999
4030
|
return this.getAccountUserService().getAll();
|
|
4000
4031
|
}
|
|
4001
|
-
/** Account user by id, or null.
|
|
4032
|
+
/** 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}. */
|
|
4002
4033
|
getAccountUserById(userId) {
|
|
4003
4034
|
return this.getAccountUserService().getById(userId);
|
|
4004
4035
|
}
|
|
4005
4036
|
// ─── Resource-pool short-forms ────────────────────────────────────────────
|
|
4006
|
-
/** All resource pools.
|
|
4037
|
+
/** All resource pools. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ResourcePoolService.getAll}. */
|
|
4007
4038
|
getAllResourcePools(mode) {
|
|
4008
4039
|
return this.getResourcePoolService().getAll(mode);
|
|
4009
4040
|
}
|
|
4010
4041
|
// ─── Timeslot short-forms ─────────────────────────────────────────────────
|
|
4011
|
-
/** Timeslots for an activity on a given date.
|
|
4042
|
+
/** 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}. */
|
|
4012
4043
|
getTimeslotsForDay(productId, date, filter) {
|
|
4013
4044
|
return this.getTimeslotService().getForDay(productId, date, filter);
|
|
4014
4045
|
}
|
|
4015
|
-
/** Single timeslot by id.
|
|
4046
|
+
/** Single timeslot by id. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.getById}. */
|
|
4016
4047
|
getTimeslotById(timeslotId) {
|
|
4017
4048
|
return this.getTimeslotService().getById(timeslotId);
|
|
4018
4049
|
}
|
|
4019
|
-
/** Set timeslot status.
|
|
4050
|
+
/** Set timeslot status. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.setAvailability}. */
|
|
4020
4051
|
setTimeslotAvailability(timeslotId, status) {
|
|
4021
4052
|
return this.getTimeslotService().setAvailability(timeslotId, status);
|
|
4022
4053
|
}
|
|
4023
|
-
/** Set timeslot manifest notes.
|
|
4054
|
+
/** Set timeslot manifest notes. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link TimeslotService.setNotes}. */
|
|
4024
4055
|
setTimeslotNotes(timeslotId, manifestNotes) {
|
|
4025
4056
|
return this.getTimeslotService().setNotes(timeslotId, manifestNotes);
|
|
4026
4057
|
}
|
|
4027
|
-
/** Assign or unassign guides on timeslots.
|
|
4058
|
+
/** 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}. */
|
|
4028
4059
|
assignTimeslotGuide(assignment) {
|
|
4029
4060
|
return this.getTimeslotService().assignGuide(assignment);
|
|
4030
4061
|
}
|
|
4031
4062
|
// ─── Reseller short-forms ─────────────────────────────────────────────────
|
|
4032
|
-
/** All reseller channels.
|
|
4063
|
+
/** All reseller channels. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ResellerService.getAllChannels}. */
|
|
4033
4064
|
getAllChannels(agentsPerChannel) {
|
|
4034
4065
|
return this.getResellerService().getAllChannels(agentsPerChannel);
|
|
4035
4066
|
}
|
|
4036
4067
|
// ─── Promo-code short-forms ───────────────────────────────────────────────
|
|
4037
|
-
/** All promo codes.
|
|
4068
|
+
/** All promo codes. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PromoCodeService.getAll}. */
|
|
4038
4069
|
getAllPromoCodes() {
|
|
4039
4070
|
return this.getPromoCodeService().getAll();
|
|
4040
4071
|
}
|
|
4041
|
-
/** Create a promo code.
|
|
4072
|
+
/** Create a promo code. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PromoCodeService.create}. */
|
|
4042
4073
|
createPromoCode(input) {
|
|
4043
4074
|
return this.getPromoCodeService().create(input);
|
|
4044
4075
|
}
|
|
4045
4076
|
// ─── Pricing short-forms ──────────────────────────────────────────────────
|
|
4046
|
-
/** Create a pricing engine.
|
|
4077
|
+
/** Create a pricing engine. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.createEngine}. */
|
|
4047
4078
|
createPricingEngine(input) {
|
|
4048
4079
|
return this.getPricingService().createEngine(input);
|
|
4049
4080
|
}
|
|
4050
|
-
/** Update a pricing engine.
|
|
4081
|
+
/** Update a pricing engine. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.updateEngine}. */
|
|
4051
4082
|
updatePricingEngine(input) {
|
|
4052
4083
|
return this.getPricingService().updateEngine(input);
|
|
4053
4084
|
}
|
|
4054
|
-
/** Delete a pricing engine (idempotent).
|
|
4085
|
+
/** Delete a pricing engine (idempotent). @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.deleteEngine}. */
|
|
4055
4086
|
deletePricingEngine(engineId) {
|
|
4056
4087
|
return this.getPricingService().deleteEngine(engineId);
|
|
4057
4088
|
}
|
|
4058
|
-
/** Upsert pricing overrides.
|
|
4089
|
+
/** Upsert pricing overrides. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link PricingService.upsertOverrides}. */
|
|
4059
4090
|
upsertPricingOverrides(input) {
|
|
4060
4091
|
return this.getPricingService().upsertOverrides(input);
|
|
4061
4092
|
}
|
|
4062
|
-
/** Clear pricing overrides for a set of activities.
|
|
4093
|
+
/** 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}. */
|
|
4063
4094
|
clearPricingOverrides(input) {
|
|
4064
4095
|
return this.getPricingService().clearOverrides(input);
|
|
4065
4096
|
}
|
|
4066
4097
|
// ─── Daily-note short-forms ───────────────────────────────────────────────
|
|
4067
|
-
/** Today's daily note.
|
|
4098
|
+
/** Today's daily note. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link DailyNoteService.getToday}. */
|
|
4068
4099
|
getDailyNoteToday() {
|
|
4069
4100
|
return this.getDailyNoteService().getToday();
|
|
4070
4101
|
}
|
|
4071
|
-
/** Update today's daily note.
|
|
4102
|
+
/** Update today's daily note. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link DailyNoteService.update}. */
|
|
4072
4103
|
updateDailyNote(note) {
|
|
4073
4104
|
return this.getDailyNoteService().update(note);
|
|
4074
4105
|
}
|
|
4075
4106
|
// ─── Availability short-forms ─────────────────────────────────────────────
|
|
4076
|
-
/** Availability times for an activity.
|
|
4107
|
+
/** Availability times for an activity. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AvailabilityService.getAvailabilityTimes}. */
|
|
4077
4108
|
getAvailabilityTimes(query) {
|
|
4078
4109
|
return this.getAvailabilityService().getAvailabilityTimes(query);
|
|
4079
4110
|
}
|
|
4080
4111
|
// ─── Membership short-forms ───────────────────────────────────────────────
|
|
4081
|
-
/** All memberships.
|
|
4112
|
+
/** All memberships. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link MembershipService.getAll}. */
|
|
4082
4113
|
getAllMemberships() {
|
|
4083
4114
|
return this.getMembershipService().getAll();
|
|
4084
4115
|
}
|
|
4085
|
-
/** Purchase a membership.
|
|
4116
|
+
/** Purchase a membership. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link MembershipService.purchase}. */
|
|
4086
4117
|
purchaseMembership(input) {
|
|
4087
4118
|
return this.getMembershipService().purchase(input);
|
|
4088
4119
|
}
|
|
4089
4120
|
// ─── Booking short-forms ──────────────────────────────────────────────────
|
|
4090
|
-
/** Booking by id.
|
|
4121
|
+
/** Booking by id. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.getById}. */
|
|
4091
4122
|
getBookingById(bookingId, options) {
|
|
4092
4123
|
return this.getBookingService().getById(bookingId, options);
|
|
4093
4124
|
}
|
|
4094
|
-
/** Bookings by time range.
|
|
4125
|
+
/** Bookings by time range. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.searchByTimeRange}. */
|
|
4095
4126
|
searchBookingsByTimeRange(input) {
|
|
4096
4127
|
return this.getBookingService().searchByTimeRange(input);
|
|
4097
4128
|
}
|
|
4098
|
-
/** Bookings on a timeslot.
|
|
4129
|
+
/** Bookings on a timeslot. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.searchByTimeslot}. */
|
|
4099
4130
|
searchBookingsByTimeslot(timeslotId, options) {
|
|
4100
4131
|
return this.getBookingService().searchByTimeslot(timeslotId, options);
|
|
4101
4132
|
}
|
|
4102
|
-
/** Guests on a booking.
|
|
4133
|
+
/** Guests on a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.getGuests}. */
|
|
4103
4134
|
getBookingGuests(bookingId) {
|
|
4104
4135
|
return this.getBookingService().getGuests(bookingId);
|
|
4105
4136
|
}
|
|
4106
|
-
/** Payments on file for a booking.
|
|
4137
|
+
/** 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}. */
|
|
4107
4138
|
getBookingPaymentsOnFile(bookingId) {
|
|
4108
4139
|
return this.getBookingService().getPaymentsOnFile(bookingId);
|
|
4109
4140
|
}
|
|
4110
|
-
/** Append or overwrite operator notes.
|
|
4141
|
+
/** Append or overwrite operator notes. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.appendNote}. */
|
|
4111
4142
|
appendBookingNote(bookingId, note, mode) {
|
|
4112
4143
|
return this.getBookingService().appendNote(bookingId, note, mode);
|
|
4113
4144
|
}
|
|
4114
|
-
/** Set booking check-in status.
|
|
4145
|
+
/** Set booking check-in status. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.setCheckinStatus}. */
|
|
4115
4146
|
setBookingCheckinStatus(bookingId, checkedIn) {
|
|
4116
4147
|
return this.getBookingService().setCheckinStatus(bookingId, checkedIn);
|
|
4117
4148
|
}
|
|
4118
|
-
/** Cancel a booking.
|
|
4149
|
+
/** Cancel a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.cancel}. */
|
|
4119
4150
|
cancelBooking(bookingId, notes) {
|
|
4120
4151
|
return this.getBookingService().cancel(bookingId, notes);
|
|
4121
4152
|
}
|
|
4122
|
-
/** Charge a booking.
|
|
4153
|
+
/** Charge a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.makePayment}. */
|
|
4123
4154
|
makeBookingPayment(input) {
|
|
4124
4155
|
return this.getBookingService().makePayment(input);
|
|
4125
4156
|
}
|
|
4126
|
-
/** Refund a booking payment.
|
|
4157
|
+
/** Refund a booking payment. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.refund}. */
|
|
4127
4158
|
refundBooking(input) {
|
|
4128
4159
|
return this.getBookingService().refund(input);
|
|
4129
4160
|
}
|
|
4130
|
-
/** Create an invoice link.
|
|
4161
|
+
/** Create an invoice link. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.createInvoiceLink}. */
|
|
4131
4162
|
createBookingInvoiceLink(bookingId) {
|
|
4132
4163
|
return this.getBookingService().createInvoiceLink(bookingId);
|
|
4133
4164
|
}
|
|
4134
|
-
/** List add-ons on a booking.
|
|
4165
|
+
/** 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}. */
|
|
4135
4166
|
listBookingAddons(bookingId) {
|
|
4136
4167
|
return this.getBookingService().listAddons(bookingId);
|
|
4137
4168
|
}
|
|
4138
|
-
/** Add an add-on to a booking.
|
|
4169
|
+
/** 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}. */
|
|
4139
4170
|
addBookingAddon(bookingId, input) {
|
|
4140
4171
|
return this.getBookingService().addAddon(bookingId, input);
|
|
4141
4172
|
}
|
|
4142
|
-
/** Remove an add-on from a booking.
|
|
4173
|
+
/** 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}. */
|
|
4143
4174
|
removeBookingAddon(bookingId, input) {
|
|
4144
4175
|
return this.getBookingService().removeAddon(bookingId, input);
|
|
4145
4176
|
}
|
|
4146
|
-
/** Create a booking.
|
|
4177
|
+
/** Create a booking. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link BookingService.create}. */
|
|
4147
4178
|
createBooking(input) {
|
|
4148
4179
|
return this.getBookingService().create(input);
|
|
4149
4180
|
}
|
|
4150
4181
|
// ─── Review short-forms ───────────────────────────────────────────────────
|
|
4151
|
-
/** Reviews for an activity.
|
|
4182
|
+
/** Reviews for an activity. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ReviewService.getReviews}. */
|
|
4152
4183
|
getReviews(productId, reviewCount, reviewOffset) {
|
|
4153
4184
|
return this.getReviewService().getReviews(productId, reviewCount, reviewOffset);
|
|
4154
4185
|
}
|
|
@@ -4156,7 +4187,7 @@ var PeekAccessService = class {
|
|
|
4156
4187
|
|
|
4157
4188
|
// src/internal/cng/endpoints.ts
|
|
4158
4189
|
var CNG_EXTENDABLE_SLUG = "cng_backoffice_api-v1";
|
|
4159
|
-
var PRODUCTS_PATH = "api/v2/
|
|
4190
|
+
var PRODUCTS_PATH = "api/v2/app-registry/products?active=1";
|
|
4160
4191
|
|
|
4161
4192
|
// src/models/cng/product.ts
|
|
4162
4193
|
var ACTIVITY_PRODUCT_TYPE2 = "ACTIVITY";
|
|
@@ -4167,14 +4198,11 @@ function fromProductNodes(nodes) {
|
|
|
4167
4198
|
}
|
|
4168
4199
|
function fromProductNode(node) {
|
|
4169
4200
|
return {
|
|
4170
|
-
productId: node.id
|
|
4201
|
+
productId: node.id == null ? "" : String(node.id),
|
|
4171
4202
|
name: node.name || "",
|
|
4172
|
-
type:
|
|
4173
|
-
color: node.
|
|
4174
|
-
tickets:
|
|
4175
|
-
id: ticket.id,
|
|
4176
|
-
name: ticket.name
|
|
4177
|
-
}))
|
|
4203
|
+
type: ACTIVITY_PRODUCT_TYPE2,
|
|
4204
|
+
color: node.access_control_color_hex || "",
|
|
4205
|
+
tickets: []
|
|
4178
4206
|
};
|
|
4179
4207
|
}
|
|
4180
4208
|
|
|
@@ -4193,15 +4221,13 @@ var CngProductService = class {
|
|
|
4193
4221
|
* ```
|
|
4194
4222
|
*/
|
|
4195
4223
|
async getAllActivities() {
|
|
4196
|
-
const body = await this.client.get(
|
|
4197
|
-
|
|
4198
|
-
);
|
|
4199
|
-
const nodes = Array.isArray(body) ? body : body?.products ?? [];
|
|
4200
|
-
return fromProductNodes(nodes ?? []);
|
|
4224
|
+
const body = await this.client.get(PRODUCTS_PATH);
|
|
4225
|
+
return fromProductNodes(body?.data ?? []);
|
|
4201
4226
|
}
|
|
4202
4227
|
};
|
|
4203
4228
|
|
|
4204
4229
|
// src/internal/cng/rest-client.ts
|
|
4230
|
+
var PERMISSION_SEPARATOR = ": ";
|
|
4205
4231
|
var RestClient = class {
|
|
4206
4232
|
constructor(options) {
|
|
4207
4233
|
this.options = options;
|
|
@@ -4214,6 +4240,7 @@ var RestClient = class {
|
|
|
4214
4240
|
*
|
|
4215
4241
|
* @throws {AdminAccountRequiredError} on HTTP 418
|
|
4216
4242
|
* @throws {RateLimitError} on HTTP 429 after retries are exhausted
|
|
4243
|
+
* @throws {CngPermissionError} on HTTP 403 (app missing a permission)
|
|
4217
4244
|
* @throws {CngApiError} on any other non-2xx response
|
|
4218
4245
|
*/
|
|
4219
4246
|
async get(path) {
|
|
@@ -4227,6 +4254,11 @@ var RestClient = class {
|
|
|
4227
4254
|
path,
|
|
4228
4255
|
async (response) => {
|
|
4229
4256
|
const body = await parseBody(response);
|
|
4257
|
+
if (response.status === FORBIDDEN_STATUS) {
|
|
4258
|
+
const permissions = extractMissingPermissions(body);
|
|
4259
|
+
logger.warn(`Missing permission for ${path} (HTTP 403)`, { url, permissions });
|
|
4260
|
+
throw new CngPermissionError(permissions, body);
|
|
4261
|
+
}
|
|
4230
4262
|
if (!response.ok) {
|
|
4231
4263
|
logger.error(`CNG request failed with HTTP ${response.status}`, { url });
|
|
4232
4264
|
throw new CngApiError(response.status, body);
|
|
@@ -4243,10 +4275,17 @@ var RestClient = class {
|
|
|
4243
4275
|
buildHeaders() {
|
|
4244
4276
|
return {
|
|
4245
4277
|
"X-Peek-Auth": `Bearer ${this.options.getToken()}`,
|
|
4246
|
-
"Content-Type": "application/json"
|
|
4278
|
+
"Content-Type": "application/json",
|
|
4279
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE
|
|
4247
4280
|
};
|
|
4248
4281
|
}
|
|
4249
4282
|
};
|
|
4283
|
+
function extractMissingPermissions(body) {
|
|
4284
|
+
if (typeof body !== "object" || body === null) return [];
|
|
4285
|
+
const raw = body.errors?.permission;
|
|
4286
|
+
if (!Array.isArray(raw)) return [];
|
|
4287
|
+
return raw.filter((entry) => typeof entry === "string").map((entry) => entry.split(PERMISSION_SEPARATOR).pop().trim()).filter((permission) => permission.length > 0);
|
|
4288
|
+
}
|
|
4250
4289
|
|
|
4251
4290
|
// src/cng-access-service.ts
|
|
4252
4291
|
var DEFAULT_BASE_URL2 = "https://app-registry.peeklabs.com/installations-api";
|
|
@@ -4282,7 +4321,7 @@ var CngAccessService = class {
|
|
|
4282
4321
|
}
|
|
4283
4322
|
return this.productService;
|
|
4284
4323
|
}
|
|
4285
|
-
/** All activities.
|
|
4324
|
+
/** All activities. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link CngProductService.getAllActivities}. */
|
|
4286
4325
|
getAllActivities() {
|
|
4287
4326
|
return this.getProductService().getAllActivities();
|
|
4288
4327
|
}
|
|
@@ -4377,7 +4416,8 @@ var RestClient2 = class {
|
|
|
4377
4416
|
buildHeaders() {
|
|
4378
4417
|
return {
|
|
4379
4418
|
"X-Peek-Auth": `Bearer ${this.options.getToken()}`,
|
|
4380
|
-
"Content-Type": "application/json"
|
|
4419
|
+
"Content-Type": "application/json",
|
|
4420
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE
|
|
4381
4421
|
};
|
|
4382
4422
|
}
|
|
4383
4423
|
};
|
|
@@ -4416,7 +4456,7 @@ var AcmeAccessService = class {
|
|
|
4416
4456
|
}
|
|
4417
4457
|
return this.productService;
|
|
4418
4458
|
}
|
|
4419
|
-
/** All activities.
|
|
4459
|
+
/** All activities. @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link AcmeProductService.getAllActivities}. */
|
|
4420
4460
|
getAllActivities() {
|
|
4421
4461
|
return this.getProductService().getAllActivities();
|
|
4422
4462
|
}
|
|
@@ -4602,6 +4642,7 @@ exports.AvailabilityService = AvailabilityService;
|
|
|
4602
4642
|
exports.BookingService = BookingService;
|
|
4603
4643
|
exports.CngAccessService = CngAccessService;
|
|
4604
4644
|
exports.CngApiError = CngApiError;
|
|
4645
|
+
exports.CngPermissionError = CngPermissionError;
|
|
4605
4646
|
exports.CngProductService = CngProductService;
|
|
4606
4647
|
exports.DailyNoteService = DailyNoteService;
|
|
4607
4648
|
exports.INSTALL_STATUSES = INSTALL_STATUSES;
|