@peektravel/app-utilities 0.9.4 → 0.9.5

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 CHANGED
@@ -2496,6 +2496,123 @@ function buildCancellation(items, addonOptionId, quantity) {
2496
2496
  return { bookingQuotes, canceledCount };
2497
2497
  }
2498
2498
 
2499
+ // src/internal/peek/custom-questions/custom-question-converter.ts
2500
+ function fromQuestionConfigurations(configs) {
2501
+ return configs.map(
2502
+ (config) => fromQuestionNode(config.question, config.order, config.isRequired)
2503
+ );
2504
+ }
2505
+ function fromQuestionNodes(questions) {
2506
+ return questions.map((question) => fromQuestionNode(question));
2507
+ }
2508
+ function fromQuestionNode(question, order, isRequired) {
2509
+ return {
2510
+ id: question.id,
2511
+ order: order ?? 0,
2512
+ isRequired: isRequired ?? false,
2513
+ questionText: question.text,
2514
+ hintText: question.hint ?? null,
2515
+ questionType: question.questionType,
2516
+ internalLabel: question.internalLabel ?? null,
2517
+ perGuest: question.perGuest ?? false,
2518
+ defaultValue: question.answerDefaultValue ?? null,
2519
+ options: (question.options ?? []).map(fromQuestionOption)
2520
+ };
2521
+ }
2522
+ function fromQuestionOption(option) {
2523
+ return {
2524
+ id: option.id,
2525
+ order: option.order,
2526
+ value: option.text
2527
+ };
2528
+ }
2529
+
2530
+ // src/internal/peek/custom-questions/custom-question-queries.ts
2531
+ var ALL_CUSTOM_QUESTIONS_QUERY = `
2532
+ query Sales {
2533
+ questions {
2534
+ id
2535
+ questionType
2536
+ text
2537
+ answerDefaultValue
2538
+ hint
2539
+ internalLabel
2540
+ perGuest
2541
+ ... on ChoiceQuestion {
2542
+ options {
2543
+ id
2544
+ text
2545
+ order
2546
+ }
2547
+ }
2548
+ }
2549
+ }
2550
+ `;
2551
+ var CUSTOM_QUESTIONS_QUERY = `
2552
+ query Sales($id: ID!) {
2553
+ activity(id: $id) {
2554
+ id
2555
+ name
2556
+ questionActivityConfigurations {
2557
+ isRequired
2558
+ order
2559
+ question {
2560
+ id
2561
+ questionType
2562
+ text
2563
+ answerDefaultValue
2564
+ hint
2565
+ internalLabel
2566
+ perGuest
2567
+ ... on ChoiceQuestion {
2568
+ options {
2569
+ id
2570
+ text
2571
+ order
2572
+ }
2573
+ }
2574
+ }
2575
+ }
2576
+ }
2577
+ }
2578
+ `;
2579
+
2580
+ // src/internal/peek/custom-questions/custom-question-service.ts
2581
+ var CustomQuestionService = class {
2582
+ constructor(client) {
2583
+ this.client = client;
2584
+ }
2585
+ client;
2586
+ /**
2587
+ * Returns every custom question defined on the account, across all
2588
+ * activities. Choice-style questions (`SELECT_ONE`, `LOCATION`, …) carry their
2589
+ * selectable {@link CustomQuestion.options}; free-text/checkbox questions
2590
+ * return an empty option list.
2591
+ *
2592
+ * These are account-wide question **definitions**, not customer answers — no
2593
+ * PII is involved, so the result is unaffected by `fullCustomerAccess`. Unlike
2594
+ * {@link ProductService.getCustomQuestions}, the catalog carries no
2595
+ * per-activity configuration, so {@link CustomQuestion.order} is `0` and
2596
+ * {@link CustomQuestion.isRequired} is `false` on every entry.
2597
+ *
2598
+ * @returns Every custom question on the account, or an empty list when none
2599
+ * are defined.
2600
+ *
2601
+ * @example
2602
+ * ```ts
2603
+ * const questions = await peek.getCustomQuestionService().getAll();
2604
+ * ```
2605
+ */
2606
+ async getAll() {
2607
+ const body = await this.client.request(
2608
+ SALES_ENDPOINT,
2609
+ ALL_CUSTOM_QUESTIONS_QUERY,
2610
+ {}
2611
+ );
2612
+ return fromQuestionNodes(body.data?.questions ?? []);
2613
+ }
2614
+ };
2615
+
2499
2616
  // src/internal/peek/daily-notes/daily-note-converter.ts
2500
2617
  function toDailyNote(response) {
2501
2618
  const union = response?.dailyNote;
@@ -2674,7 +2791,7 @@ async function requestWithRetry(http, url, init, label, onResponse) {
2674
2791
  // src/internal/sdk-headers.ts
2675
2792
  var SDK_HEADER_NAME = "x-peek-sdk";
2676
2793
  var SDK_PLATFORM = "js";
2677
- var SDK_VERSION = "0.9.4";
2794
+ var SDK_VERSION = "0.9.5";
2678
2795
  var SDK_HEADER_VALUE = `${SDK_PLATFORM}-${SDK_VERSION}`;
2679
2796
 
2680
2797
  // src/internal/peek/graphql-client.ts
@@ -3700,33 +3817,6 @@ function fromItemOptionNodes(nodes) {
3700
3817
  return Array.from(grouped.values());
3701
3818
  }
3702
3819
 
3703
- // src/internal/peek/products/custom-question-converter.ts
3704
- function fromQuestionConfigurations(configs) {
3705
- return configs.map(fromQuestionConfiguration);
3706
- }
3707
- function fromQuestionConfiguration(config) {
3708
- const question = config.question;
3709
- return {
3710
- id: question.id,
3711
- order: config.order ?? 0,
3712
- isRequired: config.isRequired ?? false,
3713
- questionText: question.text,
3714
- hintText: question.hint ?? null,
3715
- questionType: question.questionType,
3716
- internalLabel: question.internalLabel ?? null,
3717
- perGuest: question.perGuest ?? false,
3718
- defaultValue: question.answerDefaultValue ?? null,
3719
- options: (question.options ?? []).map(fromQuestionOption)
3720
- };
3721
- }
3722
- function fromQuestionOption(option) {
3723
- return {
3724
- id: option.id,
3725
- order: option.order,
3726
- value: option.text
3727
- };
3728
- }
3729
-
3730
3820
  // src/internal/peek/products/product-queries.ts
3731
3821
  var PRODUCTS_QUERY = `
3732
3822
  query Sales {
@@ -3785,36 +3875,6 @@ var ITEM_OPTIONS_QUERY = `
3785
3875
  }
3786
3876
  `;
3787
3877
 
3788
- // src/internal/peek/products/custom-question-queries.ts
3789
- var CUSTOM_QUESTIONS_QUERY = `
3790
- query Sales($id: ID!) {
3791
- activity(id: $id) {
3792
- id
3793
- name
3794
- questionActivityConfigurations {
3795
- isRequired
3796
- order
3797
- question {
3798
- id
3799
- questionType
3800
- text
3801
- answerDefaultValue
3802
- hint
3803
- internalLabel
3804
- perGuest
3805
- ... on ChoiceQuestion {
3806
- options {
3807
- id
3808
- text
3809
- order
3810
- }
3811
- }
3812
- }
3813
- }
3814
- }
3815
- }
3816
- `;
3817
-
3818
3878
  // src/internal/peek/products/product-service.ts
3819
3879
  var ERROR_PRODUCT_ID_REQUIRED2 = "A non-empty product id is required.";
3820
3880
  var DEFAULT_ITEM_OPTIONS_PAGE_SIZE = 50;
@@ -4393,6 +4453,7 @@ var PeekAccessService = class {
4393
4453
  membershipService;
4394
4454
  bookingServices = /* @__PURE__ */ new Map();
4395
4455
  reviewService;
4456
+ customQuestionService;
4396
4457
  constructor(config) {
4397
4458
  const hasApiUrl = !!config.apiUrl;
4398
4459
  const isV2 = config.mode === "v2";
@@ -4593,6 +4654,16 @@ var PeekAccessService = class {
4593
4654
  }
4594
4655
  return this.reviewService;
4595
4656
  }
4657
+ /**
4658
+ * Returns the {@link CustomQuestionService} for this install, bound to the
4659
+ * shared authenticated transport. The instance is created lazily and reused.
4660
+ */
4661
+ getCustomQuestionService() {
4662
+ if (!this.customQuestionService) {
4663
+ this.customQuestionService = new CustomQuestionService(this.client);
4664
+ }
4665
+ return this.customQuestionService;
4666
+ }
4596
4667
  // ─── Product short-forms ─────────────────────────────────────────────────
4597
4668
  /** All products (activities + add-ons). @deprecated The access service exposes only its resource-service accessors; call the service directly instead. See {@link ProductService.getAllProducts}. */
4598
4669
  getAllProducts() {
@@ -5242,6 +5313,7 @@ exports.CngAccessService = CngAccessService;
5242
5313
  exports.CngApiError = CngApiError;
5243
5314
  exports.CngPermissionError = CngPermissionError;
5244
5315
  exports.CngProductService = CngProductService;
5316
+ exports.CustomQuestionService = CustomQuestionService;
5245
5317
  exports.DailyNoteService = DailyNoteService;
5246
5318
  exports.INSTALL_STATUSES = INSTALL_STATUSES;
5247
5319
  exports.MembershipService = MembershipService;