@v-office/website-sdk 2.11.0 → 2.12.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 CHANGED
@@ -3,7 +3,7 @@
3
3
  Website-facing SDK facade for vOffice backends.
4
4
 
5
5
  The current SDK includes catalog-backed custom attributes, backend-aware search,
6
- and localized v10 REST search discount details.
6
+ localized search discount details, and quote booking-card modifier output.
7
7
  See `instructions/CHANGELOG.md` for the complete release history.
8
8
 
9
9
  ## Install
@@ -81,6 +81,11 @@ sdk.live.contact.submit(input);
81
81
  await sdk.dispose();
82
82
  ```
83
83
 
84
+ Both backends support fixed `start`/`end` search periods. Flexible-period query
85
+ keys (`month`, `dates`, `nights`, and `weekend`) are v10-only and are rejected
86
+ before transport by the v9 facade. An empty v9 query browses the scoped searchable
87
+ inventory without requiring a dummy occupancy value.
88
+
84
89
  Quote mutation helpers are available under `sdk.live.quote`:
85
90
 
86
91
  - `addAdditionalService`
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as createWebsiteSDK, zt as defineWebsiteSDKOptions } from "./client-DYAHnU5F.mjs";
2
+ import { t as createWebsiteSDK, zt as defineWebsiteSDKOptions } from "./client-Bmxh2SAu.mjs";
3
3
  import { SearchSearchSortSchema, defineCustomAttributesFromUnknown } from "@v-office/sdk-core";
4
4
  import { Console, Effect, FileSystem, Layer, Option, Path, Schema, Stdio, Terminal } from "effect";
5
5
  import { Command, Flag } from "effect/unstable/cli";
@@ -16,7 +16,7 @@ var CLICheckFailed = class extends Error {
16
16
  const toCLIError = (message, cause) => cause instanceof Error ? new CLICheckFailed(`${message}: ${cause.message}`, { cause }) : new CLICheckFailed(message, { cause });
17
17
  //#endregion
18
18
  //#region package.json
19
- var version = "2.11.0";
19
+ var version = "2.12.0";
20
20
  //#endregion
21
21
  //#region src/cli/output.ts
22
22
  const toJson = (value) => Effect.try({
@@ -2448,14 +2448,16 @@ const makeV9AvailabilityApi = ({ config, options }) => {
2448
2448
  getInitialAvailability: (input) => Effect.runPromise(Effect.gen(function* () {
2449
2449
  const now = yield* DateTime.now;
2450
2450
  const availability = yield* loadAvailability(input);
2451
+ const firstCalculationDate = toFirstCalculationDate({
2452
+ availability,
2453
+ now
2454
+ });
2455
+ const availabilityRestrictionsByDate = toAvailabilityRestrictionsByDate({ availability });
2451
2456
  return {
2452
2457
  calendarDays: yield* toInitialAvailabilityCalendarDays({
2453
2458
  input,
2454
- firstCalculationDate: toFirstCalculationDate({
2455
- availability,
2456
- now
2457
- }),
2458
- availabilityRestrictionsByDate: toAvailabilityRestrictionsByDate({ availability }),
2459
+ firstCalculationDate,
2460
+ availabilityRestrictionsByDate,
2459
2461
  translations
2460
2462
  }),
2461
2463
  minPersons: null,
@@ -2466,13 +2468,15 @@ const makeV9AvailabilityApi = ({ config, options }) => {
2466
2468
  getStartDateSelectedAvailability: (input) => Effect.runPromise(Effect.gen(function* () {
2467
2469
  const now = yield* DateTime.now;
2468
2470
  const availability = yield* loadAvailability(input);
2471
+ const firstCalculationDate = toFirstCalculationDate({
2472
+ availability,
2473
+ now
2474
+ });
2475
+ const availabilityRestrictionsByDate = toAvailabilityRestrictionsByDate({ availability });
2469
2476
  return { calendarDays: yield* toStartDateSelectedCalendarDays({
2470
2477
  input,
2471
- firstCalculationDate: toFirstCalculationDate({
2472
- availability,
2473
- now
2474
- }),
2475
- availabilityRestrictionsByDate: toAvailabilityRestrictionsByDate({ availability }),
2478
+ firstCalculationDate,
2479
+ availabilityRestrictionsByDate,
2476
2480
  translations
2477
2481
  }) };
2478
2482
  }))
@@ -3554,7 +3558,8 @@ const toUrvInsuranceOptions = ({ locale, plans, resourceLabels }) => plans.flatM
3554
3558
  const getErgoPlans = (raw) => {
3555
3559
  const record = asRecord(raw);
3556
3560
  const body = asRecord(record.body);
3557
- const availablePlanEntries = asArray(asRecord(record.AvailablePlans ?? body.AvailablePlans).AvailablePlan);
3561
+ const availablePlans = asRecord(record.AvailablePlans ?? body.AvailablePlans);
3562
+ const availablePlanEntries = asArray(availablePlans.AvailablePlan);
3558
3563
  return [
3559
3564
  ...asArray(record.insurancePlans),
3560
3565
  ...asArray(body.insurancePlans),
@@ -3576,7 +3581,9 @@ const toSelectableErgoAvailablePlans = (plans) => {
3576
3581
  };
3577
3582
  const getErgoPlanPrice = (plan) => {
3578
3583
  const premium = asRecord(plan.premium);
3579
- const totalPremium = asRecord(asRecord(asRecord(plan.Quote).Services).TotalPremium);
3584
+ const quote = asRecord(plan.Quote);
3585
+ const services = asRecord(quote.Services);
3586
+ const totalPremium = asRecord(services.TotalPremium);
3580
3587
  const amount = firstNumber(premium.amount, totalPremium.Amount);
3581
3588
  const currency = firstString(premium.currency, totalPremium.CurrencyCode) ?? "EUR";
3582
3589
  const decimals = firstNumber(premium.decimals, totalPremium.DecimalPlaces) ?? 2;
@@ -3586,7 +3593,8 @@ const getErgoPlanPrice = (plan) => {
3586
3593
  };
3587
3594
  };
3588
3595
  const getErgoDocuments = ({ plan, infLabel }) => {
3589
- const urls = asArray(asRecord(plan.PlanDetail).DescriptionURL).flatMap((entry) => {
3596
+ const planDetail = asRecord(plan.PlanDetail);
3597
+ const urls = asArray(planDetail.DescriptionURL).flatMap((entry) => {
3590
3598
  const resource = asRecord(entry);
3591
3599
  const type = firstString(resource.Type);
3592
3600
  const url = firstString(resource._);
@@ -3598,7 +3606,9 @@ const getErgoDocuments = ({ plan, infLabel }) => {
3598
3606
  return urls.length === 0 ? void 0 : urls;
3599
3607
  };
3600
3608
  const getErgoInsuranceTypes = (plan) => {
3601
- return asArray(asRecord(asRecord(plan.Quote).InsuranceTypes).InsuranceType).flatMap((entry) => {
3609
+ const quote = asRecord(plan.Quote);
3610
+ const insuranceTypes = asRecord(quote.InsuranceTypes);
3611
+ return asArray(insuranceTypes.InsuranceType).flatMap((entry) => {
3602
3612
  const insuranceType = asRecord(entry);
3603
3613
  const code = firstString(insuranceType.Code, insuranceType.Title);
3604
3614
  return code === void 0 ? [] : [code];
@@ -3607,7 +3617,11 @@ const getErgoInsuranceTypes = (plan) => {
3607
3617
  const isErgoPlanWithoutDeductible = (plan) => {
3608
3618
  const planCode = firstString(plan.plan_code, plan.PlanCode, plan.tariff_code);
3609
3619
  const planDetail = asRecord(plan.PlanDetail);
3610
- const tariffDescription = asRecord(asRecord(asRecord(asArray(asRecord(asRecord(plan.Quote).Services).Service)[0]).Tariff).TariffDescription);
3620
+ const quote = asRecord(plan.Quote);
3621
+ const services = asRecord(quote.Services);
3622
+ const service = asRecord(asArray(services.Service)[0]);
3623
+ const tariff = asRecord(service.Tariff);
3624
+ const tariffDescription = asRecord(tariff.TariffDescription);
3611
3625
  const titles = [firstString(plan.name, planDetail.Title), firstString(tariffDescription.Title)].filter((title) => title !== void 0);
3612
3626
  return planCode?.endsWith("O") === true || titles.some((title) => /\(ohne SB\)|ohne Selbstbeteiligung/i.test(title));
3613
3627
  };
@@ -3636,7 +3650,8 @@ const toInsuranceDocuments = (value) => {
3636
3650
  const getErgoPreContractDocuments = (raw) => {
3637
3651
  const record = asRecord(raw);
3638
3652
  const body = asRecord(record.body);
3639
- return toInsuranceDocuments(asArray(asRecord(record.PreContractualInformationServices ?? body.PreContractualInformationServices).PreContractualInformationService).flatMap((service) => asArray(asRecord(service).PreContractualInformation)));
3653
+ const services = asRecord(record.PreContractualInformationServices ?? body.PreContractualInformationServices);
3654
+ return toInsuranceDocuments(asArray(services.PreContractualInformationService).flatMap((service) => asArray(asRecord(service).PreContractualInformation)));
3640
3655
  };
3641
3656
  const toErgoInsuranceOptions = ({ featureLabels, infResourceLabel, locale, raw }) => getErgoPlans(raw).flatMap((entry) => {
3642
3657
  const plan = asRecord(entry);
@@ -3847,12 +3862,14 @@ const toPaymentScheduleOptions = ({ bookResponse, currency, quotePaymentSchedule
3847
3862
  const prepaymentAmount = positiveNumber(paymentSchedule.prepayment?.amount);
3848
3863
  const restAmount = positiveNumber(paymentSchedule.rest?.amount);
3849
3864
  const fullAmount = positiveNumber(paymentSchedule.total?.amount) ?? (prepaymentAmount === void 0 || restAmount === void 0 ? void 0 : prepaymentAmount + restAmount);
3865
+ const prepaymentPercent = toPercent("prepayment", quotePaymentSchedule);
3866
+ const restPercent = toPercent("rest", quotePaymentSchedule);
3850
3867
  const totalPriceAmount = toTotalPriceAmount({
3851
3868
  fullAmount,
3852
3869
  prepaymentAmount,
3853
- prepaymentPercent: toPercent("prepayment", quotePaymentSchedule),
3870
+ prepaymentPercent,
3854
3871
  restAmount,
3855
- restPercent: toPercent("rest", quotePaymentSchedule)
3872
+ restPercent
3856
3873
  });
3857
3874
  const depositAmount = toDepositAmount({
3858
3875
  fullAmount,
@@ -3871,7 +3888,7 @@ const toPaymentScheduleOptions = ({ bookResponse, currency, quotePaymentSchedule
3871
3888
  date: paymentSchedule.prepayment?.date ?? paymentSchedule.rest?.date,
3872
3889
  includesDeposit: true
3873
3890
  });
3874
- return removeInstallmentDuplicates([prepaymentOption, totalScheduleItem === void 0 ? void 0 : toScheduleOption({
3891
+ const totalOption = totalScheduleItem === void 0 ? void 0 : toScheduleOption({
3875
3892
  currency,
3876
3893
  depositAmount,
3877
3894
  forceFullAmount: true,
@@ -3879,14 +3896,16 @@ const toPaymentScheduleOptions = ({ bookResponse, currency, quotePaymentSchedule
3879
3896
  scheduleKey: "total",
3880
3897
  totalPriceAmount,
3881
3898
  ...quotePaymentSchedule === void 0 ? {} : { quotePaymentSchedule }
3882
- })].flatMap((option) => option === void 0 ? [] : [option]));
3899
+ });
3900
+ return removeInstallmentDuplicates([prepaymentOption, totalOption].flatMap((option) => option === void 0 ? [] : [option]));
3883
3901
  })());
3884
3902
  //#endregion
3885
3903
  //#region src/legacy-v9/parser/booking/output/to-payment-schedules.ts
3886
3904
  const getDepositAmount = (bookResponse) => firstNumber(...(bookResponse.reservation?.bookings ?? []).map((booking) => booking.lines?.deposit?.amount));
3887
3905
  const getBookingTotal = (bookResponse) => firstNumber(bookResponse.reservation?.total);
3888
3906
  const toUrvInsurancePaymentOptions = (bookResponse, label) => {
3889
- const travelInsurance = asRecord(asRecord(asRecord(bookResponse).travelInsuranceResult).travelInsurance ?? asRecord(bookResponse).travelInsurance);
3907
+ const travelInsuranceResult = asRecord(asRecord(bookResponse).travelInsuranceResult);
3908
+ const travelInsurance = asRecord(travelInsuranceResult.travelInsurance ?? asRecord(bookResponse).travelInsurance);
3890
3909
  const url = firstString(travelInsurance.paymentUrl, travelInsurance.paymentURL, travelInsurance.paymenturl);
3891
3910
  return url === void 0 ? [] : [{
3892
3911
  kind: "external_url",
@@ -4206,8 +4225,9 @@ const makeV9BookingApi = ({ config, options }) => {
4206
4225
  })
4207
4226
  }));
4208
4227
  return { book: (input) => Effect.runPromise(Effect.gen(function* () {
4228
+ const client = yield* V0OpenApiClient;
4209
4229
  return yield* limitBooking(book({
4210
- client: yield* V0OpenApiClient,
4230
+ client,
4211
4231
  input,
4212
4232
  translations
4213
4233
  }));
@@ -4303,8 +4323,9 @@ const makeV9ContactApi = ({ config, options }) => {
4303
4323
  input,
4304
4324
  translations
4305
4325
  });
4326
+ const client = yield* V0OpenApiClient;
4306
4327
  return yield* limitContact(submit({
4307
- client: yield* V0OpenApiClient,
4328
+ client,
4308
4329
  input
4309
4330
  }));
4310
4331
  }).pipe(Effect.provide(openApiClientLive))) };
@@ -4564,7 +4585,8 @@ const refreshUrvInsuranceOptions = ({ quote, mode, translations, v0Client }) =>
4564
4585
  });
4565
4586
  });
4566
4587
  const refreshV9InsuranceOptions = ({ quote, destinationCountryCode, translations, v0Client, v1Client }) => Effect.gen(function* () {
4567
- const settings = toConfiguredInsuranceSettings((yield* v1Client.execute("getSetup", { query: { include: "booking,search,common" } }).pipe(Effect.mapError(toInsuranceError("Failed to load v9 insurance settings.")))).data.data);
4588
+ const setup = yield* v1Client.execute("getSetup", { query: { include: "booking,search,common" } }).pipe(Effect.mapError(toInsuranceError("Failed to load v9 insurance settings.")));
4589
+ const settings = toConfiguredInsuranceSettings(setup.data.data);
4568
4590
  switch (settings.provider) {
4569
4591
  case "ergo": return withInsurance(quote, yield* refreshErgoInsuranceOptions({
4570
4592
  quote,
@@ -4610,11 +4632,12 @@ const createV9InsurancePreContract = ({ quote, customerInformation, v1Client })
4610
4632
  customerInformation,
4611
4633
  preContract: { kind: "not_required" }
4612
4634
  });
4635
+ const travelers = yield* getErgoTravelers(quote);
4613
4636
  const body = {
4614
4637
  ...toErgoTripAndCustomerInput({
4615
4638
  quote,
4616
4639
  customerInformation,
4617
- travelers: yield* getErgoTravelers(quote)
4640
+ travelers
4618
4641
  }),
4619
4642
  plan_code: option.id
4620
4643
  };
@@ -4685,7 +4708,7 @@ const bookV9Insurance = ({ quote, bookingNumber, guestToken, v1Client }) => Effe
4685
4708
  //#region src/legacy-v9/live/quote.ts
4686
4709
  const loadQuoteRuntime = Effect.tryPromise({
4687
4710
  try: async () => {
4688
- return { toGuestQuote: (await import("./quote-Cs6jGoRS.mjs")).toGuestQuote };
4711
+ return { toGuestQuote: (await import("./quote-Qy_affum.mjs")).toGuestQuote };
4689
4712
  },
4690
4713
  catch: (cause) => new CoreSDKError({
4691
4714
  source: "v10",
@@ -4952,7 +4975,7 @@ const parseV9SearchCursor = (cursor) => Effect.gen(function* () {
4952
4975
  return page;
4953
4976
  });
4954
4977
  const loadV9SearchRuntime = Effect.tryPromise({
4955
- try: () => import("./search-QlZrI7ue.mjs"),
4978
+ try: () => import("./search-BlL8vSPY.mjs"),
4956
4979
  catch: (cause) => new CoreSDKError({
4957
4980
  source: "v10",
4958
4981
  operation: "v9.search.runtime",
@@ -5315,7 +5338,7 @@ const DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES = [
5315
5338
  "avgRating"
5316
5339
  ];
5317
5340
  const loadV9RentalsRuntime = Effect.tryPromise({
5318
- try: () => import("./rentals-CFod9H4m.mjs"),
5341
+ try: () => import("./rentals-BG1diZoo.mjs"),
5319
5342
  catch: (cause) => new CoreSDKError({
5320
5343
  source: "v10",
5321
5344
  operation: "v9.rentals.runtime",
@@ -5334,12 +5357,13 @@ const makeV9RentalsApi = ({ config, options }) => {
5334
5357
  ...config.rentalDataAttributes ?? [],
5335
5358
  ...toCustomAttributeRentalDataAttributes(options.customAttributes)
5336
5359
  ];
5337
- const scopedRentalsWithoutFeedbacks = filterV9RentalsByScope((yield* graphql.execute(rentalsAllWithoutFeedbacksQuery, {
5360
+ const rentalsData = yield* graphql.execute(rentalsAllWithoutFeedbacksQuery, {
5338
5361
  language,
5339
5362
  rentalDataAttributes,
5340
5363
  rentalFacilityDataAttributes: [...DEFAULT_RENTAL_FACILITY_DATA_ATTRIBUTES],
5341
5364
  rentalRatingDataAttributes: [...DEFAULT_RENTAL_RATING_DATA_ATTRIBUTES]
5342
- })).all, options.rentalScope);
5365
+ });
5366
+ const scopedRentalsWithoutFeedbacks = filterV9RentalsByScope(rentalsData.all, options.rentalScope);
5343
5367
  if (scopedRentalsWithoutFeedbacks.length === 0) return [];
5344
5368
  const feedbacksData = yield* graphql.execute(rentalsAllFeedbacksQuery, {
5345
5369
  language,