@peektravel/app-utilities 0.9.0 → 0.9.2
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 +6 -3
- package/dist/index.cjs +152 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -57
- package/dist/index.d.ts +113 -57
- package/dist/index.js +152 -41
- package/dist/index.js.map +1 -1
- package/docs/webhooks.md +11 -8
- package/llms.txt +25 -8
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A platform's tiny map of **API endpoint key → relative path** (the "slug"
|
|
3
|
+
* inserted between the install's base API URL and the endpoint's own path).
|
|
4
|
+
*
|
|
5
|
+
* The base API URL is the install's app endpoint with no routing segment — the
|
|
6
|
+
* install webhook's `apiUrl` (with any slug stripped back off), or
|
|
7
|
+
* `baseUrl/appId` when built from the deprecated defaults. Each service class
|
|
8
|
+
* resolves *its own* slug through this lookup, so two services on the same
|
|
9
|
+
* platform can route through different slugs. Adding a new API — even one on a
|
|
10
|
+
* different slug than its siblings — is a single entry here.
|
|
11
|
+
*
|
|
12
|
+
* An empty-string path means the endpoint sits directly on the base with no
|
|
13
|
+
* slug (e.g. the legacy Peek v1 GraphQL gateway, which has no extendable slug).
|
|
14
|
+
*/
|
|
15
|
+
declare class ApiEndpoints<Key extends string = string> {
|
|
16
|
+
private readonly paths;
|
|
17
|
+
constructor(paths: Readonly<Record<Key, string>>);
|
|
18
|
+
/** The relative path (slug) for `endpoint`, appended to the base API URL. */
|
|
19
|
+
pathFor(endpoint: Key): string;
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
/**
|
|
2
23
|
* Minimal structured logger interface the package can write diagnostics to.
|
|
3
24
|
*
|
|
@@ -20,19 +41,13 @@ interface GraphQLBody<T> {
|
|
|
20
41
|
}
|
|
21
42
|
interface GraphQLClientOptions {
|
|
22
43
|
/**
|
|
23
|
-
* The install's
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* construction. Takes precedence over `baseUrl`.
|
|
44
|
+
* The install's **base API URL** (no trailing slash, no routing slug). Every
|
|
45
|
+
* GraphQL call POSTs to `baseApiUrl/<slug>`, where the slug comes from
|
|
46
|
+
* {@link endpoints} for the request's endpoint name.
|
|
27
47
|
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
* when `apiUrl` is not set; the URL is `baseUrl/appId/[prefix/]endpointName`.
|
|
32
|
-
*/
|
|
33
|
-
baseUrl?: string;
|
|
34
|
-
/** Peek app ID, used in the endpoint path (legacy `baseUrl` mode only). */
|
|
35
|
-
appId?: string;
|
|
48
|
+
baseApiUrl: string;
|
|
49
|
+
/** Maps an endpoint name to the relative slug appended to {@link baseApiUrl}. */
|
|
50
|
+
endpoints: ApiEndpoints;
|
|
36
51
|
/** API gateway key sent as the `pk-api-key` header. Omitted from headers when absent (v2 mode). */
|
|
37
52
|
gatewayKey?: string;
|
|
38
53
|
/** Supplies a valid bearer token for each request. */
|
|
@@ -43,11 +58,6 @@ interface GraphQLClientOptions {
|
|
|
43
58
|
logger: Logger;
|
|
44
59
|
/** `fetch` implementation to use. */
|
|
45
60
|
fetchFn: typeof fetch;
|
|
46
|
-
/**
|
|
47
|
-
* Optional fixed path segment inserted between `appId` and the endpoint name.
|
|
48
|
-
* Used in v2 mode: `baseUrl/appId/endpointPathPrefix/endpointName`.
|
|
49
|
-
*/
|
|
50
|
-
endpointPathPrefix?: string;
|
|
51
61
|
}
|
|
52
62
|
declare class GraphQLClient {
|
|
53
63
|
private readonly options;
|
|
@@ -904,6 +914,16 @@ interface CreateBookingInput {
|
|
|
904
914
|
* Default: `false`.
|
|
905
915
|
*/
|
|
906
916
|
requireRequiredQuestions?: boolean;
|
|
917
|
+
/**
|
|
918
|
+
* When `true`, a `customQuestionAnswers` entry whose `questionIdOrText` is a
|
|
919
|
+
* `cq_…` id is accepted even if that id is **not** among the activity's custom
|
|
920
|
+
* questions — the check that a question id must match the activity's list is
|
|
921
|
+
* skipped, and the answer is sent as-is (as a text answer). Entries given by
|
|
922
|
+
* question **name** are unaffected: they still must match a question, so the
|
|
923
|
+
* activity's questions are fetched only when a by-name answer (or
|
|
924
|
+
* `requireRequiredQuestions`) needs them. Default: `false`.
|
|
925
|
+
*/
|
|
926
|
+
acceptAllCustomQuestionIds?: boolean;
|
|
907
927
|
/** Suppress the customer confirmation email. Default: false. */
|
|
908
928
|
skipCustomerEmail?: boolean;
|
|
909
929
|
/** Clone the quote from an existing order. */
|
|
@@ -1285,7 +1305,9 @@ declare class BookingService {
|
|
|
1285
1305
|
* Resolves the input's custom-question answers into the quote's
|
|
1286
1306
|
* `questionAnswers` payload (each tagged with a fresh `refid`), or `null` when
|
|
1287
1307
|
* none were supplied. Fetches the activity's custom questions to validate
|
|
1288
|
-
* against; throws on the first unmatched/ambiguous/invalid answer.
|
|
1308
|
+
* against; throws on the first unmatched/ambiguous/invalid answer. When
|
|
1309
|
+
* `acceptAllCustomQuestionIds` is set the fetch is skipped if every answer is
|
|
1310
|
+
* given by id (a by-name answer still needs the list to resolve).
|
|
1289
1311
|
*/
|
|
1290
1312
|
private buildQuestionAnswers;
|
|
1291
1313
|
private markCreatedBookingPaid;
|
|
@@ -1671,13 +1693,17 @@ interface BaseAccessServiceConfig {
|
|
|
1671
1693
|
/** JWT issuer — the app name / app ID. */
|
|
1672
1694
|
issuer: string;
|
|
1673
1695
|
/**
|
|
1674
|
-
* The install's **
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
-
*
|
|
1678
|
-
*
|
|
1679
|
-
* it
|
|
1680
|
-
*
|
|
1696
|
+
* The install's **base API URL** — persist the install webhook's `apiUrl` and
|
|
1697
|
+
* pass it here. It is the app endpoint with no per-platform routing slug; each
|
|
1698
|
+
* service class appends its own slug (e.g. `peek_backoffice_api-v1`, via that
|
|
1699
|
+
* platform's endpoint lookup) when it makes a call, so different services can
|
|
1700
|
+
* route through different slugs. If the URL you pass still carries this
|
|
1701
|
+
* platform's slug it is stripped back off to recover the base; a URL carrying a
|
|
1702
|
+
* *different* platform's slug makes the constructor throw. No app-id/gateway
|
|
1703
|
+
* segment is inserted, so `appId` is not required. This is the forward-looking
|
|
1704
|
+
* way to target an install — prefer it over `baseUrl`/`appId`, which are
|
|
1705
|
+
* deprecated (the hardcoded base-URL fallbacks will be removed and a URL will
|
|
1706
|
+
* become required in a future release).
|
|
1681
1707
|
*/
|
|
1682
1708
|
apiUrl?: string;
|
|
1683
1709
|
/**
|
|
@@ -1808,6 +1834,31 @@ interface Review {
|
|
|
1808
1834
|
/** Free-text review. May be null. */
|
|
1809
1835
|
comment: string | null;
|
|
1810
1836
|
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Aggregate review statistics for a single activity (product), as returned by
|
|
1839
|
+
* {@link ReviewService.getAllReviewSummaries}. Carries no per-review detail or
|
|
1840
|
+
* PII — just the rating distribution and average.
|
|
1841
|
+
*/
|
|
1842
|
+
interface ProductReviewSummary {
|
|
1843
|
+
/** Activity (product) id the summary is for. */
|
|
1844
|
+
productId: string;
|
|
1845
|
+
/** Activity (product) name. */
|
|
1846
|
+
productName: string;
|
|
1847
|
+
/** Average star rating as a decimal, or `null` when there are no ratings. */
|
|
1848
|
+
avgRating: number | null;
|
|
1849
|
+
/** Total number of reviews. */
|
|
1850
|
+
countTotal: number;
|
|
1851
|
+
/** Number of 1-star reviews. */
|
|
1852
|
+
countOneStar: number;
|
|
1853
|
+
/** Number of 2-star reviews. */
|
|
1854
|
+
countTwoStar: number;
|
|
1855
|
+
/** Number of 3-star reviews. */
|
|
1856
|
+
countThreeStar: number;
|
|
1857
|
+
/** Number of 4-star reviews. */
|
|
1858
|
+
countFourStar: number;
|
|
1859
|
+
/** Number of 5-star reviews. */
|
|
1860
|
+
countFiveStar: number;
|
|
1861
|
+
}
|
|
1811
1862
|
|
|
1812
1863
|
/**
|
|
1813
1864
|
* Reads activity reviews from the gateway, which returns them newest-first
|
|
@@ -1848,6 +1899,22 @@ declare class ReviewService {
|
|
|
1848
1899
|
* ```
|
|
1849
1900
|
*/
|
|
1850
1901
|
getReviews(productId: string, reviewCount?: number, reviewOffset?: number): Promise<Review[]>;
|
|
1902
|
+
/**
|
|
1903
|
+
* Returns an aggregate review summary for **every** activity — its average
|
|
1904
|
+
* rating and the count of reviews at each star level. This reads the same
|
|
1905
|
+
* activity list as `getAllProducts`; it carries no per-review detail or PII, so
|
|
1906
|
+
* it is unaffected by `fullCustomerAccess`. An activity with no reviews comes
|
|
1907
|
+
* back with a `null` `avgRating` and zero counts.
|
|
1908
|
+
*
|
|
1909
|
+
* @example
|
|
1910
|
+
* ```ts
|
|
1911
|
+
* const summaries = await peek.getReviewService().getAllReviewSummaries();
|
|
1912
|
+
* for (const s of summaries) {
|
|
1913
|
+
* console.log(s.productName, s.avgRating, s.countTotal);
|
|
1914
|
+
* }
|
|
1915
|
+
* ```
|
|
1916
|
+
*/
|
|
1917
|
+
getAllReviewSummaries(): Promise<ProductReviewSummary[]>;
|
|
1851
1918
|
private validate;
|
|
1852
1919
|
}
|
|
1853
1920
|
|
|
@@ -2266,21 +2333,13 @@ declare class PeekAccessService {
|
|
|
2266
2333
|
|
|
2267
2334
|
interface RestClientOptions$1 {
|
|
2268
2335
|
/**
|
|
2269
|
-
* The install's
|
|
2270
|
-
*
|
|
2271
|
-
*
|
|
2272
|
-
* `baseUrl`.
|
|
2273
|
-
*/
|
|
2274
|
-
apiUrl?: string;
|
|
2275
|
-
/**
|
|
2276
|
-
* Base URL of the backoffice gateway (no trailing slash). Used only when
|
|
2277
|
-
* `apiUrl` is not set; the URL is `baseUrl/appId/extendableSlug/path`.
|
|
2336
|
+
* The install's **base API URL** (no trailing slash, no routing slug). Each
|
|
2337
|
+
* request builds `baseApiUrl/<slug>/<path>`, where the slug comes from
|
|
2338
|
+
* {@link endpoints} for the request's endpoint key.
|
|
2278
2339
|
*/
|
|
2279
|
-
|
|
2280
|
-
/**
|
|
2281
|
-
|
|
2282
|
-
/** Fixed extendable slug inserted between `appId` and the REST path (legacy mode). */
|
|
2283
|
-
extendableSlug?: string;
|
|
2340
|
+
baseApiUrl: string;
|
|
2341
|
+
/** Maps an endpoint key to the relative slug appended to {@link baseApiUrl}. */
|
|
2342
|
+
endpoints: ApiEndpoints;
|
|
2284
2343
|
/** Supplies a valid bearer token for each request. */
|
|
2285
2344
|
getToken: () => string;
|
|
2286
2345
|
/** Backoff delays (ms) applied on successive HTTP 429 responses. */
|
|
@@ -2303,7 +2362,7 @@ declare class RestClient$1 {
|
|
|
2303
2362
|
* @throws {CngPermissionError} on HTTP 403 (app missing a permission)
|
|
2304
2363
|
* @throws {CngApiError} on any other non-2xx response
|
|
2305
2364
|
*/
|
|
2306
|
-
get<T>(path: string): Promise<T>;
|
|
2365
|
+
get<T>(endpoint: string, path: string): Promise<T>;
|
|
2307
2366
|
private endpoint;
|
|
2308
2367
|
private buildHeaders;
|
|
2309
2368
|
}
|
|
@@ -2411,21 +2470,13 @@ declare class CngAccessService {
|
|
|
2411
2470
|
|
|
2412
2471
|
interface RestClientOptions {
|
|
2413
2472
|
/**
|
|
2414
|
-
* The install's
|
|
2415
|
-
*
|
|
2416
|
-
*
|
|
2417
|
-
* `baseUrl`.
|
|
2418
|
-
*/
|
|
2419
|
-
apiUrl?: string;
|
|
2420
|
-
/**
|
|
2421
|
-
* Base URL of the backoffice gateway (no trailing slash). Used only when
|
|
2422
|
-
* `apiUrl` is not set; the URL is `baseUrl/appId/extendableSlug/path`.
|
|
2473
|
+
* The install's **base API URL** (no trailing slash, no routing slug). Each
|
|
2474
|
+
* request builds `baseApiUrl/<slug>/<path>`, where the slug comes from
|
|
2475
|
+
* {@link endpoints} for the request's endpoint key.
|
|
2423
2476
|
*/
|
|
2424
|
-
|
|
2425
|
-
/**
|
|
2426
|
-
|
|
2427
|
-
/** Fixed extendable slug inserted between `appId` and the REST path (legacy mode). */
|
|
2428
|
-
extendableSlug?: string;
|
|
2477
|
+
baseApiUrl: string;
|
|
2478
|
+
/** Maps an endpoint key to the relative slug appended to {@link baseApiUrl}. */
|
|
2479
|
+
endpoints: ApiEndpoints;
|
|
2429
2480
|
/** Supplies a valid bearer token for each request. */
|
|
2430
2481
|
getToken: () => string;
|
|
2431
2482
|
/** Backoff delays (ms) applied on successive HTTP 429 responses. */
|
|
@@ -2447,7 +2498,7 @@ declare class RestClient {
|
|
|
2447
2498
|
* @throws {RateLimitError} on HTTP 429 after retries are exhausted
|
|
2448
2499
|
* @throws {AcmeApiError} on any other non-2xx response
|
|
2449
2500
|
*/
|
|
2450
|
-
get<T>(path: string): Promise<T>;
|
|
2501
|
+
get<T>(endpoint: string, path: string): Promise<T>;
|
|
2451
2502
|
private endpoint;
|
|
2452
2503
|
private buildHeaders;
|
|
2453
2504
|
}
|
|
@@ -2565,7 +2616,12 @@ declare class AcmeAccessService {
|
|
|
2565
2616
|
interface InstallAccessTarget {
|
|
2566
2617
|
/** Which platform serves the install (the install webhook's `platform`). */
|
|
2567
2618
|
platform: PeekPlatform | null;
|
|
2568
|
-
/**
|
|
2619
|
+
/**
|
|
2620
|
+
* The install's base API URL (the install webhook's `apiUrl`). The chosen
|
|
2621
|
+
* access service's service classes append their own backoffice slug when they
|
|
2622
|
+
* call; a URL already carrying this platform's slug is stripped back to the
|
|
2623
|
+
* base, and one carrying a different platform's slug throws.
|
|
2624
|
+
*/
|
|
2569
2625
|
apiUrl: string;
|
|
2570
2626
|
/** The install id (the install webhook's `installId`) — becomes the JWT subject. */
|
|
2571
2627
|
installId: string;
|
|
@@ -2987,4 +3043,4 @@ declare class AcmeApiError extends Error {
|
|
|
2987
3043
|
constructor(statusCode: number, body: unknown, message?: string);
|
|
2988
3044
|
}
|
|
2989
3045
|
|
|
2990
|
-
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 ActivityOverrides, 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, type ClearOverridesInput, CngAccessService, type CngAccessServiceConfig, CngApiError, CngPermissionError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreateEngineInput, type CreatePromoCodeInput, type CreatedBooking, type CreatedPricingEngine, type CreatedPromoCode, type CustomQuestion, type CustomQuestionAnswer, type CustomQuestionAnswerInput, type CustomQuestionOption, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, INSTALL_STATUSES, type InstallAccessConfig, type InstallAccessService, type InstallAccessTarget, type InstallStatus, type InstallWebhook, type InstallWebhookAccount, type InstallWebhookClaims, 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, PeekHttpError, type PeekPlatform, PiiAccessDisabledError, type Price, type PricingActivityContext, type PricingEngine, type PricingMoney, type PricingNamedRef, type PricingOverride, type PricingOverrideFilter, PricingService, type Product, type ProductMeetingLocation, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type ResolvedOverride, type ResolvedPricingOverride, type ResolvedResourceOption, type Resource, type ResourceOptionOverride, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateEngineInput, type UpdateTimeslotResult, type UpsertOverridesInput, type UpsertOverridesResult, type Waiver, createAccessServiceForInstall, noopLogger, parseBookingWebhook, parseInstallWebhook, parseWaiverWebhook, verifyInstallWebhook };
|
|
3046
|
+
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 ActivityOverrides, 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, type ClearOverridesInput, CngAccessService, type CngAccessServiceConfig, CngApiError, CngPermissionError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreateEngineInput, type CreatePromoCodeInput, type CreatedBooking, type CreatedPricingEngine, type CreatedPromoCode, type CustomQuestion, type CustomQuestionAnswer, type CustomQuestionAnswerInput, type CustomQuestionOption, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, INSTALL_STATUSES, type InstallAccessConfig, type InstallAccessService, type InstallAccessTarget, type InstallStatus, type InstallWebhook, type InstallWebhookAccount, type InstallWebhookClaims, 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, PeekHttpError, type PeekPlatform, PiiAccessDisabledError, type Price, type PricingActivityContext, type PricingEngine, type PricingMoney, type PricingNamedRef, type PricingOverride, type PricingOverrideFilter, PricingService, type Product, type ProductMeetingLocation, type ProductReviewSummary, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type ResolvedOverride, type ResolvedPricingOverride, type ResolvedResourceOption, type Resource, type ResourceOptionOverride, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateEngineInput, type UpdateTimeslotResult, type UpsertOverridesInput, type UpsertOverridesResult, type Waiver, createAccessServiceForInstall, noopLogger, parseBookingWebhook, parseInstallWebhook, parseWaiverWebhook, verifyInstallWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A platform's tiny map of **API endpoint key → relative path** (the "slug"
|
|
3
|
+
* inserted between the install's base API URL and the endpoint's own path).
|
|
4
|
+
*
|
|
5
|
+
* The base API URL is the install's app endpoint with no routing segment — the
|
|
6
|
+
* install webhook's `apiUrl` (with any slug stripped back off), or
|
|
7
|
+
* `baseUrl/appId` when built from the deprecated defaults. Each service class
|
|
8
|
+
* resolves *its own* slug through this lookup, so two services on the same
|
|
9
|
+
* platform can route through different slugs. Adding a new API — even one on a
|
|
10
|
+
* different slug than its siblings — is a single entry here.
|
|
11
|
+
*
|
|
12
|
+
* An empty-string path means the endpoint sits directly on the base with no
|
|
13
|
+
* slug (e.g. the legacy Peek v1 GraphQL gateway, which has no extendable slug).
|
|
14
|
+
*/
|
|
15
|
+
declare class ApiEndpoints<Key extends string = string> {
|
|
16
|
+
private readonly paths;
|
|
17
|
+
constructor(paths: Readonly<Record<Key, string>>);
|
|
18
|
+
/** The relative path (slug) for `endpoint`, appended to the base API URL. */
|
|
19
|
+
pathFor(endpoint: Key): string;
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
/**
|
|
2
23
|
* Minimal structured logger interface the package can write diagnostics to.
|
|
3
24
|
*
|
|
@@ -20,19 +41,13 @@ interface GraphQLBody<T> {
|
|
|
20
41
|
}
|
|
21
42
|
interface GraphQLClientOptions {
|
|
22
43
|
/**
|
|
23
|
-
* The install's
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* construction. Takes precedence over `baseUrl`.
|
|
44
|
+
* The install's **base API URL** (no trailing slash, no routing slug). Every
|
|
45
|
+
* GraphQL call POSTs to `baseApiUrl/<slug>`, where the slug comes from
|
|
46
|
+
* {@link endpoints} for the request's endpoint name.
|
|
27
47
|
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
* when `apiUrl` is not set; the URL is `baseUrl/appId/[prefix/]endpointName`.
|
|
32
|
-
*/
|
|
33
|
-
baseUrl?: string;
|
|
34
|
-
/** Peek app ID, used in the endpoint path (legacy `baseUrl` mode only). */
|
|
35
|
-
appId?: string;
|
|
48
|
+
baseApiUrl: string;
|
|
49
|
+
/** Maps an endpoint name to the relative slug appended to {@link baseApiUrl}. */
|
|
50
|
+
endpoints: ApiEndpoints;
|
|
36
51
|
/** API gateway key sent as the `pk-api-key` header. Omitted from headers when absent (v2 mode). */
|
|
37
52
|
gatewayKey?: string;
|
|
38
53
|
/** Supplies a valid bearer token for each request. */
|
|
@@ -43,11 +58,6 @@ interface GraphQLClientOptions {
|
|
|
43
58
|
logger: Logger;
|
|
44
59
|
/** `fetch` implementation to use. */
|
|
45
60
|
fetchFn: typeof fetch;
|
|
46
|
-
/**
|
|
47
|
-
* Optional fixed path segment inserted between `appId` and the endpoint name.
|
|
48
|
-
* Used in v2 mode: `baseUrl/appId/endpointPathPrefix/endpointName`.
|
|
49
|
-
*/
|
|
50
|
-
endpointPathPrefix?: string;
|
|
51
61
|
}
|
|
52
62
|
declare class GraphQLClient {
|
|
53
63
|
private readonly options;
|
|
@@ -904,6 +914,16 @@ interface CreateBookingInput {
|
|
|
904
914
|
* Default: `false`.
|
|
905
915
|
*/
|
|
906
916
|
requireRequiredQuestions?: boolean;
|
|
917
|
+
/**
|
|
918
|
+
* When `true`, a `customQuestionAnswers` entry whose `questionIdOrText` is a
|
|
919
|
+
* `cq_…` id is accepted even if that id is **not** among the activity's custom
|
|
920
|
+
* questions — the check that a question id must match the activity's list is
|
|
921
|
+
* skipped, and the answer is sent as-is (as a text answer). Entries given by
|
|
922
|
+
* question **name** are unaffected: they still must match a question, so the
|
|
923
|
+
* activity's questions are fetched only when a by-name answer (or
|
|
924
|
+
* `requireRequiredQuestions`) needs them. Default: `false`.
|
|
925
|
+
*/
|
|
926
|
+
acceptAllCustomQuestionIds?: boolean;
|
|
907
927
|
/** Suppress the customer confirmation email. Default: false. */
|
|
908
928
|
skipCustomerEmail?: boolean;
|
|
909
929
|
/** Clone the quote from an existing order. */
|
|
@@ -1285,7 +1305,9 @@ declare class BookingService {
|
|
|
1285
1305
|
* Resolves the input's custom-question answers into the quote's
|
|
1286
1306
|
* `questionAnswers` payload (each tagged with a fresh `refid`), or `null` when
|
|
1287
1307
|
* none were supplied. Fetches the activity's custom questions to validate
|
|
1288
|
-
* against; throws on the first unmatched/ambiguous/invalid answer.
|
|
1308
|
+
* against; throws on the first unmatched/ambiguous/invalid answer. When
|
|
1309
|
+
* `acceptAllCustomQuestionIds` is set the fetch is skipped if every answer is
|
|
1310
|
+
* given by id (a by-name answer still needs the list to resolve).
|
|
1289
1311
|
*/
|
|
1290
1312
|
private buildQuestionAnswers;
|
|
1291
1313
|
private markCreatedBookingPaid;
|
|
@@ -1671,13 +1693,17 @@ interface BaseAccessServiceConfig {
|
|
|
1671
1693
|
/** JWT issuer — the app name / app ID. */
|
|
1672
1694
|
issuer: string;
|
|
1673
1695
|
/**
|
|
1674
|
-
* The install's **
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
-
*
|
|
1678
|
-
*
|
|
1679
|
-
* it
|
|
1680
|
-
*
|
|
1696
|
+
* The install's **base API URL** — persist the install webhook's `apiUrl` and
|
|
1697
|
+
* pass it here. It is the app endpoint with no per-platform routing slug; each
|
|
1698
|
+
* service class appends its own slug (e.g. `peek_backoffice_api-v1`, via that
|
|
1699
|
+
* platform's endpoint lookup) when it makes a call, so different services can
|
|
1700
|
+
* route through different slugs. If the URL you pass still carries this
|
|
1701
|
+
* platform's slug it is stripped back off to recover the base; a URL carrying a
|
|
1702
|
+
* *different* platform's slug makes the constructor throw. No app-id/gateway
|
|
1703
|
+
* segment is inserted, so `appId` is not required. This is the forward-looking
|
|
1704
|
+
* way to target an install — prefer it over `baseUrl`/`appId`, which are
|
|
1705
|
+
* deprecated (the hardcoded base-URL fallbacks will be removed and a URL will
|
|
1706
|
+
* become required in a future release).
|
|
1681
1707
|
*/
|
|
1682
1708
|
apiUrl?: string;
|
|
1683
1709
|
/**
|
|
@@ -1808,6 +1834,31 @@ interface Review {
|
|
|
1808
1834
|
/** Free-text review. May be null. */
|
|
1809
1835
|
comment: string | null;
|
|
1810
1836
|
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Aggregate review statistics for a single activity (product), as returned by
|
|
1839
|
+
* {@link ReviewService.getAllReviewSummaries}. Carries no per-review detail or
|
|
1840
|
+
* PII — just the rating distribution and average.
|
|
1841
|
+
*/
|
|
1842
|
+
interface ProductReviewSummary {
|
|
1843
|
+
/** Activity (product) id the summary is for. */
|
|
1844
|
+
productId: string;
|
|
1845
|
+
/** Activity (product) name. */
|
|
1846
|
+
productName: string;
|
|
1847
|
+
/** Average star rating as a decimal, or `null` when there are no ratings. */
|
|
1848
|
+
avgRating: number | null;
|
|
1849
|
+
/** Total number of reviews. */
|
|
1850
|
+
countTotal: number;
|
|
1851
|
+
/** Number of 1-star reviews. */
|
|
1852
|
+
countOneStar: number;
|
|
1853
|
+
/** Number of 2-star reviews. */
|
|
1854
|
+
countTwoStar: number;
|
|
1855
|
+
/** Number of 3-star reviews. */
|
|
1856
|
+
countThreeStar: number;
|
|
1857
|
+
/** Number of 4-star reviews. */
|
|
1858
|
+
countFourStar: number;
|
|
1859
|
+
/** Number of 5-star reviews. */
|
|
1860
|
+
countFiveStar: number;
|
|
1861
|
+
}
|
|
1811
1862
|
|
|
1812
1863
|
/**
|
|
1813
1864
|
* Reads activity reviews from the gateway, which returns them newest-first
|
|
@@ -1848,6 +1899,22 @@ declare class ReviewService {
|
|
|
1848
1899
|
* ```
|
|
1849
1900
|
*/
|
|
1850
1901
|
getReviews(productId: string, reviewCount?: number, reviewOffset?: number): Promise<Review[]>;
|
|
1902
|
+
/**
|
|
1903
|
+
* Returns an aggregate review summary for **every** activity — its average
|
|
1904
|
+
* rating and the count of reviews at each star level. This reads the same
|
|
1905
|
+
* activity list as `getAllProducts`; it carries no per-review detail or PII, so
|
|
1906
|
+
* it is unaffected by `fullCustomerAccess`. An activity with no reviews comes
|
|
1907
|
+
* back with a `null` `avgRating` and zero counts.
|
|
1908
|
+
*
|
|
1909
|
+
* @example
|
|
1910
|
+
* ```ts
|
|
1911
|
+
* const summaries = await peek.getReviewService().getAllReviewSummaries();
|
|
1912
|
+
* for (const s of summaries) {
|
|
1913
|
+
* console.log(s.productName, s.avgRating, s.countTotal);
|
|
1914
|
+
* }
|
|
1915
|
+
* ```
|
|
1916
|
+
*/
|
|
1917
|
+
getAllReviewSummaries(): Promise<ProductReviewSummary[]>;
|
|
1851
1918
|
private validate;
|
|
1852
1919
|
}
|
|
1853
1920
|
|
|
@@ -2266,21 +2333,13 @@ declare class PeekAccessService {
|
|
|
2266
2333
|
|
|
2267
2334
|
interface RestClientOptions$1 {
|
|
2268
2335
|
/**
|
|
2269
|
-
* The install's
|
|
2270
|
-
*
|
|
2271
|
-
*
|
|
2272
|
-
* `baseUrl`.
|
|
2273
|
-
*/
|
|
2274
|
-
apiUrl?: string;
|
|
2275
|
-
/**
|
|
2276
|
-
* Base URL of the backoffice gateway (no trailing slash). Used only when
|
|
2277
|
-
* `apiUrl` is not set; the URL is `baseUrl/appId/extendableSlug/path`.
|
|
2336
|
+
* The install's **base API URL** (no trailing slash, no routing slug). Each
|
|
2337
|
+
* request builds `baseApiUrl/<slug>/<path>`, where the slug comes from
|
|
2338
|
+
* {@link endpoints} for the request's endpoint key.
|
|
2278
2339
|
*/
|
|
2279
|
-
|
|
2280
|
-
/**
|
|
2281
|
-
|
|
2282
|
-
/** Fixed extendable slug inserted between `appId` and the REST path (legacy mode). */
|
|
2283
|
-
extendableSlug?: string;
|
|
2340
|
+
baseApiUrl: string;
|
|
2341
|
+
/** Maps an endpoint key to the relative slug appended to {@link baseApiUrl}. */
|
|
2342
|
+
endpoints: ApiEndpoints;
|
|
2284
2343
|
/** Supplies a valid bearer token for each request. */
|
|
2285
2344
|
getToken: () => string;
|
|
2286
2345
|
/** Backoff delays (ms) applied on successive HTTP 429 responses. */
|
|
@@ -2303,7 +2362,7 @@ declare class RestClient$1 {
|
|
|
2303
2362
|
* @throws {CngPermissionError} on HTTP 403 (app missing a permission)
|
|
2304
2363
|
* @throws {CngApiError} on any other non-2xx response
|
|
2305
2364
|
*/
|
|
2306
|
-
get<T>(path: string): Promise<T>;
|
|
2365
|
+
get<T>(endpoint: string, path: string): Promise<T>;
|
|
2307
2366
|
private endpoint;
|
|
2308
2367
|
private buildHeaders;
|
|
2309
2368
|
}
|
|
@@ -2411,21 +2470,13 @@ declare class CngAccessService {
|
|
|
2411
2470
|
|
|
2412
2471
|
interface RestClientOptions {
|
|
2413
2472
|
/**
|
|
2414
|
-
* The install's
|
|
2415
|
-
*
|
|
2416
|
-
*
|
|
2417
|
-
* `baseUrl`.
|
|
2418
|
-
*/
|
|
2419
|
-
apiUrl?: string;
|
|
2420
|
-
/**
|
|
2421
|
-
* Base URL of the backoffice gateway (no trailing slash). Used only when
|
|
2422
|
-
* `apiUrl` is not set; the URL is `baseUrl/appId/extendableSlug/path`.
|
|
2473
|
+
* The install's **base API URL** (no trailing slash, no routing slug). Each
|
|
2474
|
+
* request builds `baseApiUrl/<slug>/<path>`, where the slug comes from
|
|
2475
|
+
* {@link endpoints} for the request's endpoint key.
|
|
2423
2476
|
*/
|
|
2424
|
-
|
|
2425
|
-
/**
|
|
2426
|
-
|
|
2427
|
-
/** Fixed extendable slug inserted between `appId` and the REST path (legacy mode). */
|
|
2428
|
-
extendableSlug?: string;
|
|
2477
|
+
baseApiUrl: string;
|
|
2478
|
+
/** Maps an endpoint key to the relative slug appended to {@link baseApiUrl}. */
|
|
2479
|
+
endpoints: ApiEndpoints;
|
|
2429
2480
|
/** Supplies a valid bearer token for each request. */
|
|
2430
2481
|
getToken: () => string;
|
|
2431
2482
|
/** Backoff delays (ms) applied on successive HTTP 429 responses. */
|
|
@@ -2447,7 +2498,7 @@ declare class RestClient {
|
|
|
2447
2498
|
* @throws {RateLimitError} on HTTP 429 after retries are exhausted
|
|
2448
2499
|
* @throws {AcmeApiError} on any other non-2xx response
|
|
2449
2500
|
*/
|
|
2450
|
-
get<T>(path: string): Promise<T>;
|
|
2501
|
+
get<T>(endpoint: string, path: string): Promise<T>;
|
|
2451
2502
|
private endpoint;
|
|
2452
2503
|
private buildHeaders;
|
|
2453
2504
|
}
|
|
@@ -2565,7 +2616,12 @@ declare class AcmeAccessService {
|
|
|
2565
2616
|
interface InstallAccessTarget {
|
|
2566
2617
|
/** Which platform serves the install (the install webhook's `platform`). */
|
|
2567
2618
|
platform: PeekPlatform | null;
|
|
2568
|
-
/**
|
|
2619
|
+
/**
|
|
2620
|
+
* The install's base API URL (the install webhook's `apiUrl`). The chosen
|
|
2621
|
+
* access service's service classes append their own backoffice slug when they
|
|
2622
|
+
* call; a URL already carrying this platform's slug is stripped back to the
|
|
2623
|
+
* base, and one carrying a different platform's slug throws.
|
|
2624
|
+
*/
|
|
2569
2625
|
apiUrl: string;
|
|
2570
2626
|
/** The install id (the install webhook's `installId`) — becomes the JWT subject. */
|
|
2571
2627
|
installId: string;
|
|
@@ -2987,4 +3043,4 @@ declare class AcmeApiError extends Error {
|
|
|
2987
3043
|
constructor(statusCode: number, body: unknown, message?: string);
|
|
2988
3044
|
}
|
|
2989
3045
|
|
|
2990
|
-
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 ActivityOverrides, 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, type ClearOverridesInput, CngAccessService, type CngAccessServiceConfig, CngApiError, CngPermissionError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreateEngineInput, type CreatePromoCodeInput, type CreatedBooking, type CreatedPricingEngine, type CreatedPromoCode, type CustomQuestion, type CustomQuestionAnswer, type CustomQuestionAnswerInput, type CustomQuestionOption, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, INSTALL_STATUSES, type InstallAccessConfig, type InstallAccessService, type InstallAccessTarget, type InstallStatus, type InstallWebhook, type InstallWebhookAccount, type InstallWebhookClaims, 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, PeekHttpError, type PeekPlatform, PiiAccessDisabledError, type Price, type PricingActivityContext, type PricingEngine, type PricingMoney, type PricingNamedRef, type PricingOverride, type PricingOverrideFilter, PricingService, type Product, type ProductMeetingLocation, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type ResolvedOverride, type ResolvedPricingOverride, type ResolvedResourceOption, type Resource, type ResourceOptionOverride, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateEngineInput, type UpdateTimeslotResult, type UpsertOverridesInput, type UpsertOverridesResult, type Waiver, createAccessServiceForInstall, noopLogger, parseBookingWebhook, parseInstallWebhook, parseWaiverWebhook, verifyInstallWebhook };
|
|
3046
|
+
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 ActivityOverrides, 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, type ClearOverridesInput, CngAccessService, type CngAccessServiceConfig, CngApiError, CngPermissionError, CngProductService, type CreateBookingGuest, type CreateBookingInput, type CreateBookingTicket, type CreateEngineInput, type CreatePromoCodeInput, type CreatedBooking, type CreatedPricingEngine, type CreatedPromoCode, type CustomQuestion, type CustomQuestionAnswer, type CustomQuestionAnswerInput, type CustomQuestionOption, type DailyNote, DailyNoteService, type Duration, type Guest, type GuestMetadata, type Guide, type GuideAssignment, INSTALL_STATUSES, type InstallAccessConfig, type InstallAccessService, type InstallAccessTarget, type InstallStatus, type InstallWebhook, type InstallWebhookAccount, type InstallWebhookClaims, 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, PeekHttpError, type PeekPlatform, PiiAccessDisabledError, type Price, type PricingActivityContext, type PricingEngine, type PricingMoney, type PricingNamedRef, type PricingOverride, type PricingOverrideFilter, PricingService, type Product, type ProductMeetingLocation, type ProductReviewSummary, ProductService, type ProductServiceOptions, type ProductTicket, type PromoCode, type PromoCodeFixedAmount, PromoCodeService, type PromoCodeServiceOptions, type PurchasedMembership, RENTAL_PRODUCT_TYPE, RateLimitError, type RefundInput, type RefundResult, ResellerService, type ResolvedOverride, type ResolvedPricingOverride, type ResolvedResourceOption, type Resource, type ResourceOptionOverride, type ResourceOptionQuantity, type ResourcePool, type ResourcePoolAccountUser, type ResourcePoolAssignment, type ResourcePoolMode, ResourcePoolService, type Review, ReviewService, type Ticket, type Timeslot, type TimeslotFilter, TimeslotService, type UpdateEngineInput, type UpdateTimeslotResult, type UpsertOverridesInput, type UpsertOverridesResult, type Waiver, createAccessServiceForInstall, noopLogger, parseBookingWebhook, parseInstallWebhook, parseWaiverWebhook, verifyInstallWebhook };
|