@peektravel/app-utilities 0.4.1 → 0.5.1

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/docs/webhooks.md CHANGED
@@ -112,7 +112,8 @@ config. Leave `output_fields_gql_query` null; the `output_format` is
112
112
  import { parseWaiverWebhook, type Waiver } from "@peektravel/app-utilities";
113
113
 
114
114
  app.post("/waiver-webhook", (req, res) => {
115
- const waiver: Waiver = parseWaiverWebhook(req.body);
115
+ // PII (guestName, fileUrl) is redacted unless you opt in:
116
+ const waiver: Waiver = parseWaiverWebhook(req.body, { fullCustomerAccess: true });
116
117
  // waiver.bookingId, waiver.templateId, waiver.fileUrl, waiver.signedAt,
117
118
  // waiver.guestName, waiver.isSignedByGuardian, …
118
119
  res.sendStatus(200);
@@ -125,6 +126,13 @@ bare node / a JSON string, maps the raw `snake_case` payload to the clean
125
126
  camelCase [`Waiver`](#waiver-webhooks) model, and never throws on malformed input
126
127
  (missing fields become `""` / `null` / `false`).
127
128
 
129
+ **PII:** `parseWaiverWebhook(body, options?)` takes the same `AccessOptions` as
130
+ the access services. By **default** (`fullCustomerAccess` unset/`false`) the participant
131
+ `guestName` and the signed-document `fileUrl` are redacted (`null`/`""`); pass
132
+ `{ fullCustomerAccess: true }` to keep them. The booking parser
133
+ `parseBookingWebhook(body)` is unaffected — a booking webhook carries whatever
134
+ its registered selection includes.
135
+
128
136
  The resulting `Waiver` is flat:
129
137
 
130
138
  | Field | Type | From |
package/llms.txt CHANGED
@@ -25,20 +25,37 @@ const peek = new PeekAccessService({
25
25
  appId, // gateway path segment
26
26
  gatewayKey, // pk-api-key header
27
27
  // optional: baseUrl, tokenTtlSeconds, tokenRefreshLeewaySeconds,
28
- // retryDelaysMs, logger, fetch, itemOptionsPageSize
28
+ // retryDelaysMs, logger, fetch, itemOptionsPageSize,
29
+ // accessOptions: { fullCustomerAccess: false } // default — see "Access options / PII"
29
30
  });
30
31
  ```
31
32
 
33
+ ## Access options / PII
34
+
35
+ Every access service takes `accessOptions?: AccessOptions` (`{ fullCustomerAccess?: boolean }`,
36
+ default `false`). With `fullCustomerAccess` off, customer PII is **not requested** at the
37
+ GraphQL layer (booking guest identity + custom question answers + `portalUrl`,
38
+ review reviewer name/email → `null`/empty), and `BookingService` **disables**
39
+ `getPaymentsOnFile`/`makePayment`/`refund`/`createInvoiceLink`/`addAddon`/
40
+ `removeAddon` (throw `PiiAccessDisabledError`). `create` (incl. `markAsPaid`) and
41
+ non-payment reads/mutations stay available. Pass `{ fullCustomerAccess: true }` to opt in.
42
+
32
43
  ## Resources (accessor → methods)
33
44
 
34
45
  - `getProductService()` — `getAllProducts()` (flat list of activities + add-ons;
35
- add-ons have `type === ADD_ON_PRODUCT_TYPE`)
46
+ add-ons have `type === ADD_ON_PRODUCT_TYPE`); `Product.currency` carries the
47
+ activity's ISO currency (empty for add-ons)
36
48
  - `getAccountUserService()` — `getAll()`, `getById(userId)`
37
49
  - `getResourcePoolService()` — `getAll(mode?)`
38
50
  - `getTimeslotService()` — `getForDay(productId, date, filter?)`, `getById(id)`,
39
51
  `setAvailability(...)`, `setNotes(...)`, `assignGuide({timeslotIds, guideIds, action})`
40
52
  - `getResellerService()` — `getAllChannels(agentsPerChannel?)`
41
53
  - `getPromoCodeService()` — `getAll()`, `create(input)`
54
+ - `getPricingService()` — `createEngine(input)`, `updateEngine(input)`,
55
+ `deleteEngine(id)` (idempotent), `upsertOverrides(input)`, `clearOverrides(input)`.
56
+ Primitives-only: caller builds the `UpsertOverridesInput` (segmentation,
57
+ override `order`, `spotsTaken` bounds are the caller's job); service sends it
58
+ as-is and returns the resolved `activityContexts`.
42
59
  - `getDailyNoteService()` — `getToday()`, `update(note)`
43
60
  - `getAvailabilityService()` — `getAvailabilityTimes({activityId, date, resourceOptionQuantities})`
44
61
  - `getMembershipService()` — `getAll()`, `purchase(input)`
@@ -49,6 +66,24 @@ const peek = new PeekAccessService({
49
66
  `listAddons(id)`, `addAddon(id, {addonOptionId, quantity})`,
50
67
  `removeAddon(id, {addonOptionId, quantity})`, `create(input)`
51
68
 
69
+ ## Sibling accessors (CNG, ACME — REST, not GraphQL)
70
+
71
+ Two brand-parallel accessors sit alongside `PeekAccessService` and share the same
72
+ auth/transport/UI plumbing. Both are **REST** and deliberately minimal today
73
+ (products only). Construct one per install, same config shape **minus `gatewayKey`**
74
+ (`installId`, `jwtSecret`, `issuer`, `appId`); both default the base URL to the
75
+ app-registry installations API.
76
+
77
+ - `CngAccessService` — `getProductService().getAllActivities()` (short-form
78
+ `getAllActivities()`) → `Activity[]` (`Activity`/`ActivityTicket` models).
79
+ Errors surface as `CngApiError`.
80
+ - `AcmeAccessService` — `getProductService().getAllActivities()` (short-form
81
+ `getAllActivities()`) → `AcmeActivity[]` (`AcmeActivity`/`AcmeActivityTicket`
82
+ models). Errors surface as `AcmeApiError`.
83
+
84
+ All are exported from the package root `.`; REST paths and raw response shapes
85
+ stay internal.
86
+
52
87
  ## Input conventions (enforced in the service layer; violations throw plain Error)
53
88
 
54
89
  - Booking ids normalized (lowercased, `-`→`_`): `B-ABC123` == `b_abc123`.
@@ -64,8 +99,10 @@ const peek = new PeekAccessService({
64
99
  ## Errors
65
100
 
66
101
  - `AdminAccountRequiredError` (HTTP 418), `RateLimitError` (HTTP 429 after
67
- retries), `PeekGraphQLError` (`.graphqlErrors` holds the raw array) — all
68
- importable; branch with `instanceof`.
102
+ retries), `PeekGraphQLError` (`.graphqlErrors` holds the raw array),
103
+ `PiiAccessDisabledError` (a payment/booking-modification op was called without
104
+ `fullCustomerAccess`), and the REST-sibling `CngApiError` / `AcmeApiError` —
105
+ all importable; branch with `instanceof`.
69
106
  - Plain `Error` for validation/precondition failures thrown before any request.
70
107
 
71
108
  ## Webhooks (booking + waiver)
@@ -80,9 +117,11 @@ external system** (App Store config), not from code.
80
117
  the canonical maximal selection into `output_fields_gql_query`. That string is
81
118
  documented in `docs/webhooks.md` and pinned by a drift-guard test — it is NOT a
82
119
  runtime export.
83
- - `parseWaiverWebhook(body): Waiver` — maps the fixed `snake_case`
120
+ - `parseWaiverWebhook(body, options?): Waiver` — maps the fixed `snake_case`
84
121
  `waiver_webhook_data` payload to the clean `Waiver` model. **No query to
85
- register** — just subscribe to the `agreement_signature_created` event.
122
+ register** — just subscribe to the `agreement_signature_created` event. Takes
123
+ the same `AccessOptions`; by default (`fullCustomerAccess` off) `guestName` and
124
+ `fileUrl` are redacted — pass `{ fullCustomerAccess: true }` to keep them.
86
125
 
87
126
  **Full guide + booking query-to-register: `docs/webhooks.md` (shipped).**
88
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peektravel/app-utilities",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "GraphQL JS mapping utilities extracted from the Peek Pro Autopilot connector.",
5
5
  "license": "MIT",
6
6
  "repository": {