@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/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
|
-
|
|
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,10 +25,21 @@ 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;
|
|
@@ -64,8 +75,9 @@ const peek = new PeekAccessService({
|
|
|
64
75
|
## Errors
|
|
65
76
|
|
|
66
77
|
- `AdminAccountRequiredError` (HTTP 418), `RateLimitError` (HTTP 429 after
|
|
67
|
-
retries), `PeekGraphQLError` (`.graphqlErrors` holds the raw array)
|
|
68
|
-
|
|
78
|
+
retries), `PeekGraphQLError` (`.graphqlErrors` holds the raw array),
|
|
79
|
+
`PiiAccessDisabledError` (a payment/booking-modification op was called without
|
|
80
|
+
`fullCustomerAccess`) — all importable; branch with `instanceof`.
|
|
69
81
|
- Plain `Error` for validation/precondition failures thrown before any request.
|
|
70
82
|
|
|
71
83
|
## Webhooks (booking + waiver)
|
|
@@ -80,9 +92,11 @@ external system** (App Store config), not from code.
|
|
|
80
92
|
the canonical maximal selection into `output_fields_gql_query`. That string is
|
|
81
93
|
documented in `docs/webhooks.md` and pinned by a drift-guard test — it is NOT a
|
|
82
94
|
runtime export.
|
|
83
|
-
- `parseWaiverWebhook(body): Waiver` — maps the fixed `snake_case`
|
|
95
|
+
- `parseWaiverWebhook(body, options?): Waiver` — maps the fixed `snake_case`
|
|
84
96
|
`waiver_webhook_data` payload to the clean `Waiver` model. **No query to
|
|
85
|
-
register** — just subscribe to the `agreement_signature_created` event.
|
|
97
|
+
register** — just subscribe to the `agreement_signature_created` event. Takes
|
|
98
|
+
the same `AccessOptions`; by default (`fullCustomerAccess` off) `guestName` and
|
|
99
|
+
`fileUrl` are redacted — pass `{ fullCustomerAccess: true }` to keep them.
|
|
86
100
|
|
|
87
101
|
**Full guide + booking query-to-register: `docs/webhooks.md` (shipped).**
|
|
88
102
|
|