@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/dist/index.d.cts CHANGED
@@ -156,6 +156,31 @@ declare class ProductService {
156
156
  private fetchAllItemOptionNodes;
157
157
  }
158
158
 
159
+ /**
160
+ * Cross-cutting options that govern what data an access service will read and
161
+ * expose. Passed once when constructing an access service and threaded down to
162
+ * the resource services (and the webhook parsers) so a single object controls
163
+ * behaviour everywhere, rather than a boolean being passed hand-to-hand.
164
+ *
165
+ * Kept deliberately small — today it carries a single PII toggle, but new
166
+ * cross-cutting flags slot in here without changing any downstream signatures.
167
+ */
168
+ /** Options controlling PII exposure across an access service's reads. */
169
+ interface AccessOptions {
170
+ /**
171
+ * When `true`, customer PII (guest names/emails/phones, custom question
172
+ * answers, the customer booking-portal URL, waiver participant details, …) is
173
+ * requested and returned, and payment/booking-modification operations are
174
+ * available.
175
+ *
176
+ * When `false` (the default), those PII fields are never requested from the
177
+ * gateway and come back `null`/empty, and the payment/booking-modification
178
+ * operations that touch customer financial data are disabled (they throw a
179
+ * {@link PiiAccessDisabledError}).
180
+ */
181
+ fullCustomerAccess?: boolean;
182
+ }
183
+
159
184
  /**
160
185
  * The clean, transport-agnostic data model for Peek Pro bookings.
161
186
  *
@@ -667,6 +692,8 @@ interface CancelBookingResult {
667
692
  interface BookingServiceOptions {
668
693
  /** Page size for cursor pagination. Default: 50. */
669
694
  pageSize?: number;
695
+ /** Cross-cutting access options (PII exposure). Default: PII off. */
696
+ accessOptions?: AccessOptions;
670
697
  }
671
698
  /** Dependencies the {@link BookingService} composes for add-on resolution. */
672
699
  interface BookingServiceDeps {
@@ -688,7 +715,15 @@ declare class BookingService {
688
715
  private readonly client;
689
716
  private readonly deps;
690
717
  private readonly pageSize;
718
+ /** Whether customer PII is requested and payment operations are allowed. */
719
+ private readonly fullCustomerAccess;
691
720
  constructor(client: GraphQLClient, deps: BookingServiceDeps, options?: BookingServiceOptions);
721
+ /**
722
+ * Throws a {@link PiiAccessDisabledError} for `operation` when this service was
723
+ * created without `fullCustomerAccess` — used to gate payment and booking-modification
724
+ * operations that touch customer financial data.
725
+ */
726
+ private assertPiiEnabled;
692
727
  /**
693
728
  * Returns a single booking by id, or null when not found. The `bookingId` is
694
729
  * normalized internally (lowercased, `-` → `_`), so `B-ABC123` and `b_abc123`
@@ -1226,6 +1261,12 @@ interface BaseAccessServiceConfig {
1226
1261
  logger?: Logger;
1227
1262
  /** Custom `fetch` implementation. Default: the global `fetch`. */
1228
1263
  fetch?: typeof fetch;
1264
+ /**
1265
+ * Cross-cutting access options (PII exposure, …). When omitted, defaults are
1266
+ * used ({@link AccessOptions.fullCustomerAccess} `false`). Threaded down to the
1267
+ * resource services that read customer data.
1268
+ */
1269
+ accessOptions?: AccessOptions;
1229
1270
  }
1230
1271
 
1231
1272
  declare class MembershipService {
@@ -1335,7 +1376,9 @@ interface Review {
1335
1376
  */
1336
1377
  declare class ReviewService {
1337
1378
  private readonly client;
1338
- constructor(client: GraphQLClient);
1379
+ /** Whether reviewer PII (name/email) is requested. */
1380
+ private readonly fullCustomerAccess;
1381
+ constructor(client: GraphQLClient, accessOptions?: AccessOptions);
1339
1382
  /**
1340
1383
  * Returns up to `reviewCount` reviews for an activity in **descending order
1341
1384
  * by review date (newest first)**, skipping the `reviewOffset` newest reviews
@@ -1506,6 +1549,7 @@ interface PeekAccessServiceConfig extends BaseAccessServiceConfig {
1506
1549
  declare class PeekAccessService {
1507
1550
  private readonly client;
1508
1551
  private readonly productServiceOptions;
1552
+ private readonly accessOptions;
1509
1553
  private readonly jwtSecret;
1510
1554
  private productService?;
1511
1555
  private accountUserService?;
@@ -2001,8 +2045,13 @@ interface Waiver {
2001
2045
  * Accepts the raw request body — either the `{ waiver: … }` envelope or a bare
2002
2046
  * waiver node, and a JSON string is parsed first. Never throws on malformed
2003
2047
  * input: a missing/garbled body yields a {@link Waiver} with empty fields.
2048
+ *
2049
+ * Because a waiver webhook has no GraphQL selection to trim (Peek delivers a
2050
+ * fixed payload), the PII fields — the participant `guestName` and the signed
2051
+ * document `fileUrl` — are instead redacted here at parse time when `options`
2052
+ * does not enable PII. Pass `{ fullCustomerAccess: true }` to keep them.
2004
2053
  */
2005
- declare function parseWaiverWebhook(payload: unknown): Waiver;
2054
+ declare function parseWaiverWebhook(payload: unknown, options?: AccessOptions): Waiver;
2006
2055
 
2007
2056
  /**
2008
2057
  * Typed errors thrown by the package. Each mirrors a failure mode of the Peek
@@ -2040,6 +2089,18 @@ declare class PeekGraphQLError extends Error {
2040
2089
  readonly graphqlErrors: unknown[];
2041
2090
  constructor(graphqlErrors: unknown[], message?: string);
2042
2091
  }
2092
+ /**
2093
+ * Thrown when a payment or booking-modification operation is called on an
2094
+ * access service that was constructed without `fullCustomerAccess` (PII access
2095
+ * disabled). These operations — pulling payment sources, charging/refunding,
2096
+ * creating invoice links, and adding/removing add-ons — touch customer
2097
+ * financial data, so they are gated behind the same flag as customer PII.
2098
+ */
2099
+ declare class PiiAccessDisabledError extends Error {
2100
+ /** The name of the operation that was blocked (e.g. `"makePayment"`). */
2101
+ readonly operation: string;
2102
+ constructor(operation: string);
2103
+ }
2043
2104
  /**
2044
2105
  * Thrown when the CNG REST gateway returns a non-2xx response that is not one
2045
2106
  * of the specifically-handled statuses (418/429). The offending status is
@@ -2068,4 +2129,4 @@ declare class AcmeApiError extends Error {
2068
2129
  constructor(statusCode: number, body: unknown, message?: string);
2069
2130
  }
2070
2131
 
2071
- export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, type AccountUser, AccountUserService, type AccountUserServiceOptions, AcmeAccessService, type AcmeAccessServiceConfig, type AcmeActivity, type AcmeActivityTicket, AcmeApiError, AcmeProductService, type Activity, 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, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreatePromoCodeInput, type CreatedBooking, 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, type Price, 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 Resource, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateTimeslotResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };
2132
+ 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 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, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreatePromoCodeInput, type CreatedBooking, 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 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 Resource, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateTimeslotResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };
package/dist/index.d.ts CHANGED
@@ -156,6 +156,31 @@ declare class ProductService {
156
156
  private fetchAllItemOptionNodes;
157
157
  }
158
158
 
159
+ /**
160
+ * Cross-cutting options that govern what data an access service will read and
161
+ * expose. Passed once when constructing an access service and threaded down to
162
+ * the resource services (and the webhook parsers) so a single object controls
163
+ * behaviour everywhere, rather than a boolean being passed hand-to-hand.
164
+ *
165
+ * Kept deliberately small — today it carries a single PII toggle, but new
166
+ * cross-cutting flags slot in here without changing any downstream signatures.
167
+ */
168
+ /** Options controlling PII exposure across an access service's reads. */
169
+ interface AccessOptions {
170
+ /**
171
+ * When `true`, customer PII (guest names/emails/phones, custom question
172
+ * answers, the customer booking-portal URL, waiver participant details, …) is
173
+ * requested and returned, and payment/booking-modification operations are
174
+ * available.
175
+ *
176
+ * When `false` (the default), those PII fields are never requested from the
177
+ * gateway and come back `null`/empty, and the payment/booking-modification
178
+ * operations that touch customer financial data are disabled (they throw a
179
+ * {@link PiiAccessDisabledError}).
180
+ */
181
+ fullCustomerAccess?: boolean;
182
+ }
183
+
159
184
  /**
160
185
  * The clean, transport-agnostic data model for Peek Pro bookings.
161
186
  *
@@ -667,6 +692,8 @@ interface CancelBookingResult {
667
692
  interface BookingServiceOptions {
668
693
  /** Page size for cursor pagination. Default: 50. */
669
694
  pageSize?: number;
695
+ /** Cross-cutting access options (PII exposure). Default: PII off. */
696
+ accessOptions?: AccessOptions;
670
697
  }
671
698
  /** Dependencies the {@link BookingService} composes for add-on resolution. */
672
699
  interface BookingServiceDeps {
@@ -688,7 +715,15 @@ declare class BookingService {
688
715
  private readonly client;
689
716
  private readonly deps;
690
717
  private readonly pageSize;
718
+ /** Whether customer PII is requested and payment operations are allowed. */
719
+ private readonly fullCustomerAccess;
691
720
  constructor(client: GraphQLClient, deps: BookingServiceDeps, options?: BookingServiceOptions);
721
+ /**
722
+ * Throws a {@link PiiAccessDisabledError} for `operation` when this service was
723
+ * created without `fullCustomerAccess` — used to gate payment and booking-modification
724
+ * operations that touch customer financial data.
725
+ */
726
+ private assertPiiEnabled;
692
727
  /**
693
728
  * Returns a single booking by id, or null when not found. The `bookingId` is
694
729
  * normalized internally (lowercased, `-` → `_`), so `B-ABC123` and `b_abc123`
@@ -1226,6 +1261,12 @@ interface BaseAccessServiceConfig {
1226
1261
  logger?: Logger;
1227
1262
  /** Custom `fetch` implementation. Default: the global `fetch`. */
1228
1263
  fetch?: typeof fetch;
1264
+ /**
1265
+ * Cross-cutting access options (PII exposure, …). When omitted, defaults are
1266
+ * used ({@link AccessOptions.fullCustomerAccess} `false`). Threaded down to the
1267
+ * resource services that read customer data.
1268
+ */
1269
+ accessOptions?: AccessOptions;
1229
1270
  }
1230
1271
 
1231
1272
  declare class MembershipService {
@@ -1335,7 +1376,9 @@ interface Review {
1335
1376
  */
1336
1377
  declare class ReviewService {
1337
1378
  private readonly client;
1338
- constructor(client: GraphQLClient);
1379
+ /** Whether reviewer PII (name/email) is requested. */
1380
+ private readonly fullCustomerAccess;
1381
+ constructor(client: GraphQLClient, accessOptions?: AccessOptions);
1339
1382
  /**
1340
1383
  * Returns up to `reviewCount` reviews for an activity in **descending order
1341
1384
  * by review date (newest first)**, skipping the `reviewOffset` newest reviews
@@ -1506,6 +1549,7 @@ interface PeekAccessServiceConfig extends BaseAccessServiceConfig {
1506
1549
  declare class PeekAccessService {
1507
1550
  private readonly client;
1508
1551
  private readonly productServiceOptions;
1552
+ private readonly accessOptions;
1509
1553
  private readonly jwtSecret;
1510
1554
  private productService?;
1511
1555
  private accountUserService?;
@@ -2001,8 +2045,13 @@ interface Waiver {
2001
2045
  * Accepts the raw request body — either the `{ waiver: … }` envelope or a bare
2002
2046
  * waiver node, and a JSON string is parsed first. Never throws on malformed
2003
2047
  * input: a missing/garbled body yields a {@link Waiver} with empty fields.
2048
+ *
2049
+ * Because a waiver webhook has no GraphQL selection to trim (Peek delivers a
2050
+ * fixed payload), the PII fields — the participant `guestName` and the signed
2051
+ * document `fileUrl` — are instead redacted here at parse time when `options`
2052
+ * does not enable PII. Pass `{ fullCustomerAccess: true }` to keep them.
2004
2053
  */
2005
- declare function parseWaiverWebhook(payload: unknown): Waiver;
2054
+ declare function parseWaiverWebhook(payload: unknown, options?: AccessOptions): Waiver;
2006
2055
 
2007
2056
  /**
2008
2057
  * Typed errors thrown by the package. Each mirrors a failure mode of the Peek
@@ -2040,6 +2089,18 @@ declare class PeekGraphQLError extends Error {
2040
2089
  readonly graphqlErrors: unknown[];
2041
2090
  constructor(graphqlErrors: unknown[], message?: string);
2042
2091
  }
2092
+ /**
2093
+ * Thrown when a payment or booking-modification operation is called on an
2094
+ * access service that was constructed without `fullCustomerAccess` (PII access
2095
+ * disabled). These operations — pulling payment sources, charging/refunding,
2096
+ * creating invoice links, and adding/removing add-ons — touch customer
2097
+ * financial data, so they are gated behind the same flag as customer PII.
2098
+ */
2099
+ declare class PiiAccessDisabledError extends Error {
2100
+ /** The name of the operation that was blocked (e.g. `"makePayment"`). */
2101
+ readonly operation: string;
2102
+ constructor(operation: string);
2103
+ }
2043
2104
  /**
2044
2105
  * Thrown when the CNG REST gateway returns a non-2xx response that is not one
2045
2106
  * of the specifically-handled statuses (418/429). The offending status is
@@ -2068,4 +2129,4 @@ declare class AcmeApiError extends Error {
2068
2129
  constructor(statusCode: number, body: unknown, message?: string);
2069
2130
  }
2070
2131
 
2071
- export { ACTIVITY_PRODUCT_TYPE, ADD_ON_PRODUCT_TYPE, type AccountUser, AccountUserService, type AccountUserServiceOptions, AcmeAccessService, type AcmeAccessServiceConfig, type AcmeActivity, type AcmeActivityTicket, AcmeApiError, AcmeProductService, type Activity, 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, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreatePromoCodeInput, type CreatedBooking, 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, type Price, 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 Resource, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateTimeslotResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };
2132
+ 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 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, CngAccessService, type CngAccessServiceConfig, CngApiError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreatePromoCodeInput, type CreatedBooking, 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 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 Resource, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateTimeslotResult, type Waiver, noopLogger, parseBookingWebhook, parseWaiverWebhook };