@v-office/website-sdk 2.28.1 → 2.29.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.
Files changed (36) hide show
  1. package/README.md +8 -0
  2. package/dist/cli.mjs +420 -12
  3. package/dist/{client-EtS0Qm3i.mjs → client-B8cF8Ra1.mjs} +285 -45
  4. package/dist/index.d.mts +36 -4
  5. package/dist/index.mjs +1 -1
  6. package/dist/instructions/CHANGELOG.md +1 -0
  7. package/dist/instructions/MIGRATION.md +1 -0
  8. package/dist/instructions/README.md +3 -2
  9. package/dist/instructions/creation.md +35 -4
  10. package/dist/instructions/custom-attributes.md +2 -2
  11. package/dist/instructions/filter.md +5 -3
  12. package/dist/instructions/quote.md +1 -1
  13. package/dist/instructions/rentals.md +36 -0
  14. package/dist/instructions/search.md +214 -6
  15. package/dist/instructions/versions/2.29.0/CHANGELOG.md +62 -0
  16. package/dist/instructions/versions/2.29.0/MIGRATION.md +97 -0
  17. package/dist/{v9-data-C3SWtDGs.mjs → operations-CfjJjdrw.mjs} +3122 -1
  18. package/dist/{rentals-B4g91vwW.mjs → rentals-DvYUm25t.mjs} +4 -5
  19. package/dist/{search-B-lvOmXL.mjs → search-BkrzAC9w.mjs} +6 -5
  20. package/dist/{to-rental-highlights-BL5m3Uen.mjs → to-rental-highlights-D7oepO6s.mjs} +1 -1
  21. package/dist/translations/v9/de-DE/core.json +8 -1
  22. package/dist/translations/v9/en-US/core.json +8 -1
  23. package/instructions/CHANGELOG.md +1 -0
  24. package/instructions/MIGRATION.md +1 -0
  25. package/instructions/README.md +3 -2
  26. package/instructions/creation.md +35 -4
  27. package/instructions/custom-attributes.md +2 -2
  28. package/instructions/filter.md +5 -3
  29. package/instructions/quote.md +1 -1
  30. package/instructions/rentals.md +36 -0
  31. package/instructions/search.md +214 -6
  32. package/instructions/versions/2.29.0/CHANGELOG.md +62 -0
  33. package/instructions/versions/2.29.0/MIGRATION.md +97 -0
  34. package/instructions/versions/2.29.0/release.json +3 -0
  35. package/package.json +5 -3
  36. package/dist/operations-DwURbo0b.mjs +0 -2850
@@ -1,6 +1,6 @@
1
- import { a as customDataAttribute, l as parseVofficeUnitData } from "./v9-data-C3SWtDGs.mjs";
2
- import { AvailabilityService, BookingBookOutput, BookingService, ContactService, CoreSDKError, DEFAULT_RENTAL_HIGHLIGHT_PRIORITIZATION, DEFAULT_RENTAL_PROPERTY_HIGHLIGHT_PRIORITIZATION, DocumentsService, EMPTY_CUSTOM_ATTRIBUTE_REGISTRY, FilterService, QuoteService, RentalService, SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS, SearchService, TranslationService, addGuestQuoteAdditionalServiceSelection, asArray, asRecord, assertNoNestedCustomAttributeFilterCompositions, assertNoReservedQueryKeys, assertUniqueCustomFilterQueryKeys, assertUniqueFilterQueryKeys, clearGuestQuoteAdditionalServiceSelections, collectQueryParameters, createCoreRuntime, expandCustomAttributeFilterCompositions, firstNumber, firstString, formatCurrency, formatLocalDate, getBookingBookGuestToken, getGuestQuoteBackendContext, getGuestQuoteInput, isDisplayableCustomAttribute, localeToLanguage, makeMinIntervalLimiter, makeTranslationLive, parseQueryParameters, refreshGuestQuoteInsurancePassthrough, removeGuestQuoteAdditionalServiceSelection, selectGuestQuoteCancellationPolicySelection, toCustomAttributeFilterLabel, toCustomAttributeFilterOutputItem, toCustomAttributeList, toInitialAvailabilityCalendarDays, toQueryString, toResolvedCustomAttributeCategoryTranslationKey, toStartDateSelectedCalendarDays, validateContactSubmitInput, withGuestQuoteInsurance, withGuestQuoteInsuranceRefresh } from "@v-office/sdk-core";
3
- import { Context, Data, DateTime, Effect, Layer, Schema, SchemaGetter } from "effect";
1
+ import { m as customDataAttribute, t as voucherValidityQuery, v as parseVofficeUnitData } from "./operations-CfjJjdrw.mjs";
2
+ import { AvailabilityService, BookingBookOutput, BookingService, ContactService, CoreSDKError, DEFAULT_RENTAL_HIGHLIGHT_PRIORITIZATION, DEFAULT_RENTAL_PROPERTY_HIGHLIGHT_PRIORITIZATION, DocumentsService, EMPTY_CUSTOM_ATTRIBUTE_REGISTRY, FilterService, QuoteService, RentalService, SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS, SearchService, TranslationService, addGuestQuoteAdditionalServiceSelection, asArray, asRecord, assertNoNestedCustomAttributeFilterCompositions, assertNoReservedQueryKeys, assertUniqueCustomFilterQueryKeys, assertUniqueFilterQueryKeys, clearGuestQuoteAdditionalServiceSelections, collectQueryParameters, createCoreRuntime, daysBetweenLocalDates, expandCustomAttributeFilterCompositions, firstNumber, firstString, formatCurrency, formatLocalDate, getBookingBookGuestToken, getGuestQuoteBackendContext, getGuestQuoteInput, isDisplayableCustomAttribute, localeToLanguage, makeMinIntervalLimiter, makeTranslationLive, parseQueryParameters, refreshGuestQuoteInsurancePassthrough, removeGuestQuoteAdditionalServiceSelection, selectGuestQuoteCancellationPolicySelection, toCustomAttributeFilterLabel, toCustomAttributeFilterOutputItem, toCustomAttributeList, toInitialAvailabilityCalendarDays, toIsoDateFromPeriodQueryDate, toQueryString, toResolvedCustomAttributeCategoryTranslationKey, toStartDateSelectedCalendarDays, validateContactSubmitInput, withGuestQuoteInsurance, withGuestQuoteInsuranceRefresh } from "@v-office/sdk-core";
3
+ import { Context, Data, DateTime, Duration, Effect, Layer, Schema, SchemaGetter } from "effect";
4
4
  import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http";
5
5
  import { Kind, print, visit } from "graphql";
6
6
  //#region codegen/v9/graphql-codegen/stable-filters.json
@@ -162,6 +162,20 @@ var stable_filters_default = {
162
162
  }
163
163
  };
164
164
  //#endregion
165
+ //#region src/legacy-v9/hub-filter-keys.ts
166
+ const V9_HUB_RENTAL_IDS_FILTER_KEY = "voffice_id";
167
+ const V9_HUB_FACILITY_SCOPE_FILTER_KEY = "facility_scope";
168
+ const V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY = "objectGroup_scope";
169
+ const V9_HUB_OBJECT_GROUP_FILTER_KEY = "objectGroup";
170
+ const V9_HUB_FACILITY_SEARCH_FILTER_KEY = "facility_search";
171
+ const V9_HUB_OFFERS_FILTER_KEY = "offers";
172
+ const V9_HUB_OFFER_FILTER_KEY = "offer";
173
+ const V9_SDK_OWNED_HUB_FILTER_KEYS = /* @__PURE__ */ new Set([
174
+ V9_HUB_RENTAL_IDS_FILTER_KEY,
175
+ V9_HUB_FACILITY_SCOPE_FILTER_KEY,
176
+ V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY
177
+ ]);
178
+ //#endregion
165
179
  //#region src/legacy-v9/facility-attribute-keys.ts
166
180
  const V9_FACILITY_ATTRIBUTE_KEYS = [
167
181
  "allergic",
@@ -328,6 +342,12 @@ const toV9Options = (options) => {
328
342
  operation: "options.normalize",
329
343
  message: `${collisions.join(", ")} ${collisions.length === 1 ? "is" : "are"} already owned by a v9 built-in search filter. Rename the configured custom filter.`
330
344
  });
345
+ const sdkOwnedKeys = [...new Set(options.customAttributeFilterDefinitions.filter((definition) => definition.source === "backendFilter").map((definition) => definition.key).filter((key) => V9_SDK_OWNED_HUB_FILTER_KEYS.has(key)))];
346
+ if (sdkOwnedKeys.length > 0) throw new CoreSDKError({
347
+ source: "v9",
348
+ operation: "options.normalize",
349
+ message: `${sdkOwnedKeys.join(", ")} ${sdkOwnedKeys.length === 1 ? "is" : "are"} set by the SDK and cannot be a backendFilter key. Rename the configured custom filter.`
350
+ });
331
351
  return {
332
352
  ...options.translationOverrides === void 0 ? {} : { translationOverrides: options.translationOverrides },
333
353
  customAttributes: options.customAttributes,
@@ -396,7 +416,9 @@ const V9_CONFIG_FIELDS = {
396
416
  v0ApiBaseUrl: true,
397
417
  v1ApiBaseUrl: true,
398
418
  rentalDataAttributes: true,
399
- facilityObjectGroupRelationAttributeId: true
419
+ facilityObjectGroupRelationAttributeId: true,
420
+ rentalScopePropertyKind: true,
421
+ rentalIdsSearch: true
400
422
  };
401
423
  const OPTION_FIELDS = {
402
424
  translationOverrides: true,
@@ -659,7 +681,20 @@ const submitContactEffect = (input) => Effect.gen(function* () {
659
681
  });
660
682
  //#endregion
661
683
  //#region src/legacy-v9/config.ts
684
+ const toV9RentalScopePropertyKind = (config) => config.rentalScopePropertyKind ?? "facility";
662
685
  const validateWebsiteV9Config = (config) => {
686
+ const propertyKind = config.rentalScopePropertyKind;
687
+ if (propertyKind !== void 0 && propertyKind !== "facility" && propertyKind !== "objectGroup") throw new CoreSDKError({
688
+ source: "v9",
689
+ operation: "v9.config",
690
+ message: `Expected rentalScopePropertyKind to be "facility" or "objectGroup", received "${String(propertyKind)}".`
691
+ });
692
+ const rentalIdsSearch = config.rentalIdsSearch;
693
+ if (rentalIdsSearch !== void 0 && typeof rentalIdsSearch !== "boolean") throw new CoreSDKError({
694
+ source: "v9",
695
+ operation: "v9.config",
696
+ message: `Expected rentalIdsSearch to be a boolean, received "${String(rentalIdsSearch)}".`
697
+ });
663
698
  const attributeId = config.facilityObjectGroupRelationAttributeId;
664
699
  if (attributeId === void 0) return;
665
700
  if (Number.isSafeInteger(attributeId) && attributeId > 0) return;
@@ -1718,7 +1753,14 @@ var core_default$1 = {
1718
1753
  "Property.propertyType.option.HOSTEL": "Hostel",
1719
1754
  "Property.propertyType.option.HOTEL": "Hotel",
1720
1755
  "reviews.item.guest": "Gast",
1721
- "reviews.item.authorWithCity": "{author} aus {city}"
1756
+ "reviews.item.authorWithCity": "{author} aus {city}",
1757
+ "voucher.validate.reason.valid": "Der Gutscheincode ist gültig.",
1758
+ "voucher.validate.reason.not_yet_valid": "Der Gutscheincode ist noch nicht gültig.",
1759
+ "voucher.validate.reason.expired": "Der Gutscheincode ist abgelaufen.",
1760
+ "voucher.validate.reason.unknown": "Dieser Gutscheincode ist unbekannt.",
1761
+ "voucher.validate.reason.stay_too_short": "Der Aufenthalt ist für diesen Gutscheincode zu kurz.",
1762
+ "voucher.validate.reason.outside_booking_window": "Der gewählte Anreisetag liegt außerhalb des Buchungszeitraums dieses Gutscheincodes.",
1763
+ "voucher.validate.reason.rate_limited": "Zu viele Versuche. Bitte versuchen Sie es später erneut."
1722
1764
  };
1723
1765
  //#endregion
1724
1766
  //#region translations/v9/de-DE/filter.json
@@ -2459,7 +2501,14 @@ var core_default = {
2459
2501
  "Property.propertyType.option.HOSTEL": "Hostel",
2460
2502
  "Property.propertyType.option.HOTEL": "Hotel",
2461
2503
  "reviews.item.guest": "Guest",
2462
- "reviews.item.authorWithCity": "{author} from {city}"
2504
+ "reviews.item.authorWithCity": "{author} from {city}",
2505
+ "voucher.validate.reason.valid": "The voucher code is valid.",
2506
+ "voucher.validate.reason.not_yet_valid": "The voucher code is not valid yet.",
2507
+ "voucher.validate.reason.expired": "The voucher code has expired.",
2508
+ "voucher.validate.reason.unknown": "This voucher code is unknown.",
2509
+ "voucher.validate.reason.stay_too_short": "The stay is too short for this voucher code.",
2510
+ "voucher.validate.reason.outside_booking_window": "The selected arrival date is outside this voucher code's booking window.",
2511
+ "voucher.validate.reason.rate_limited": "Too many attempts. Please try again later."
2463
2512
  };
2464
2513
  //#endregion
2465
2514
  //#region translations/v9/en-US/filter.json
@@ -5828,44 +5877,77 @@ const makeV9GraphQLClient = (config) => ({ execute: (document, variables) => Eff
5828
5877
  */
5829
5878
  const toCustomAttributeRentalDataAttributes = (customAttributes) => toCustomAttributeList(customAttributes).flatMap((attribute) => attribute.v9 !== void 0 && isDisplayableCustomAttribute(attribute) ? [attribute.v9] : []);
5830
5879
  //#endregion
5880
+ //#region src/legacy-v9/parser/search/input/shared/to-positive-id.ts
5881
+ const MAX_GRAPHQL_INT = 2147483647;
5882
+ const toNonNegativeInt = (value) => {
5883
+ if (!/^\d+$/.test(value)) return;
5884
+ const number = Number(value);
5885
+ return number <= MAX_GRAPHQL_INT ? number : void 0;
5886
+ };
5887
+ const toPositiveId = (value) => {
5888
+ const id = toNonNegativeInt(value);
5889
+ return id !== void 0 && id > 0 ? id : void 0;
5890
+ };
5891
+ //#endregion
5892
+ //#region src/legacy-v9/rental-ids.ts
5893
+ const toV9RentalIds = (rentalIds) => Array.isArray(rentalIds) ? [...new Set(rentalIds.flatMap((rentalId) => typeof rentalId === "string" ? toPositiveId(rentalId.trim()) ?? [] : []))] : [];
5894
+ const applyV9RentalIdsToSearchQueryInput = ({ input, rentalIdsIn, rentalIdsSearch }) => Effect.gen(function* () {
5895
+ if (rentalIdsIn === void 0) return input;
5896
+ if (!rentalIdsSearch) return yield* Effect.fail(new CoreSDKError({
5897
+ source: "v9",
5898
+ operation: "v9.search",
5899
+ message: `rentalIdsIn needs rentalIdsSearch: true in the v9 config and a "${V9_HUB_RENTAL_IDS_FILTER_KEY}" filter in the be-on! Hub. Run \`website-sdk hub-filters request --unit\` and hand the file to a be-on! developer.`
5900
+ }));
5901
+ if (Array.isArray(rentalIdsIn) && rentalIdsIn.length === 0) return input;
5902
+ const rentalIds = toV9RentalIds(rentalIdsIn);
5903
+ if (rentalIds.length === 0) return void 0;
5904
+ return {
5905
+ ...input,
5906
+ basicQueryInputs: [...[input.basicQueryInputs ?? []].flat(), {
5907
+ key: V9_HUB_RENTAL_IDS_FILTER_KEY,
5908
+ value: rentalIds
5909
+ }]
5910
+ };
5911
+ });
5912
+ //#endregion
5831
5913
  //#region src/legacy-v9/rental-scope.ts
5832
5914
  const toV9PropertyScope = (scope) => {
5833
5915
  if (scope.propertyId == null) return { kind: "absent" };
5834
- const configuredPropertyId = scope.propertyId.trim();
5835
- if (configuredPropertyId.length === 0) return { kind: "invalid" };
5836
- const propertyId = Number(configuredPropertyId);
5837
- return Number.isInteger(propertyId) ? {
5916
+ const propertyId = toPositiveId(scope.propertyId.trim());
5917
+ return propertyId === void 0 ? { kind: "invalid" } : {
5838
5918
  kind: "valid",
5839
5919
  propertyId
5840
- } : { kind: "invalid" };
5920
+ };
5841
5921
  };
5842
5922
  const validateV9RentalScope = (scope) => {
5843
5923
  if (toV9PropertyScope(scope).kind !== "invalid") return;
5844
5924
  throw new CoreSDKError({
5845
5925
  source: "v9",
5846
5926
  operation: "v9.config",
5847
- message: `Expected rentalScope.propertyId to be a vOffice property ID, received "${scope.propertyId}".`
5927
+ message: `Expected rentalScope.propertyId to be a positive integer ID: a facility ID as in rental.property.id, or an object group ID with rentalScopePropertyKind "objectGroup", received "${scope.propertyId}".`
5848
5928
  });
5849
5929
  };
5850
- const filterV9RentalsByScope = (rentals, scope) => {
5930
+ const toHubFilterKey = (propertyKind) => propertyKind === "objectGroup" ? V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY : V9_HUB_FACILITY_SCOPE_FILTER_KEY;
5931
+ const toV9RentalScopeHubFilterKey = ({ scope, propertyKind }) => {
5932
+ if (toV9PropertyScope(scope).kind === "absent") return void 0;
5933
+ return toHubFilterKey(propertyKind);
5934
+ };
5935
+ const filterV9RentalsByScope = ({ rentals, scope, propertyKind }) => {
5851
5936
  const propertyScope = toV9PropertyScope(scope);
5852
5937
  if (propertyScope.kind === "absent") return rentals;
5853
5938
  if (propertyScope.kind === "invalid") return [];
5854
- return rentals.filter((rental) => rental.voffice_facility_id === propertyScope.propertyId);
5939
+ return rentals.filter((rental) => propertyKind === "objectGroup" ? (rental.voffice_groups ?? []).some((group) => group.voffice_group_id === propertyScope.propertyId) : rental.voffice_facility_id === propertyScope.propertyId);
5855
5940
  };
5856
- const applyV9RentalScopeToSearchQueryInput = (input, scope) => {
5941
+ const applyV9RentalScopeToSearchQueryInput = ({ input, scope, propertyKind }) => {
5857
5942
  const propertyScope = toV9PropertyScope(scope);
5858
5943
  if (propertyScope.kind === "absent") return input;
5859
5944
  if (propertyScope.kind === "invalid") return void 0;
5860
5945
  return {
5861
5946
  ...input,
5862
- vofficeData: {
5863
- ...input.vofficeData,
5864
- filter: {
5865
- ...input.vofficeData?.filter,
5866
- falicityid: propertyScope.propertyId
5867
- }
5868
- }
5947
+ basicQueryInputs: [...[input.basicQueryInputs ?? []].flat(), {
5948
+ key: toHubFilterKey(propertyKind),
5949
+ value: propertyScope.propertyId
5950
+ }]
5869
5951
  };
5870
5952
  };
5871
5953
  //#endregion
@@ -5899,7 +5981,7 @@ const parseV9SearchCursor = (cursor) => Effect.gen(function* () {
5899
5981
  return page;
5900
5982
  });
5901
5983
  const loadV9SearchRuntime = Effect.tryPromise({
5902
- try: () => import("./search-B-lvOmXL.mjs"),
5984
+ try: () => import("./search-BkrzAC9w.mjs"),
5903
5985
  catch: (cause) => new CoreSDKError({
5904
5986
  source: "v9",
5905
5987
  operation: "v9.search.runtime",
@@ -5942,6 +6024,7 @@ const toUniqueResults = (entries) => {
5942
6024
  const makeV9SearchApi = ({ config, options }) => {
5943
6025
  const graphql = makeV9GraphQLClient(config);
5944
6026
  const translations = makeV9TranslationService(options.translationOverrides);
6027
+ const propertyKind = toV9RentalScopePropertyKind(config);
5945
6028
  const customAttributeDataAttributes = toCustomAttributeRentalDataAttributes(options.customAttributes);
5946
6029
  const limitSearch = Effect.runSync(makeMinIntervalLimiter({
5947
6030
  interval: "1 second",
@@ -5959,13 +6042,23 @@ const makeV9SearchApi = ({ config, options }) => {
5959
6042
  translations,
5960
6043
  customAttributeFilterDefinitions: options.customAttributeFilterDefinitions,
5961
6044
  query: input.query,
5962
- sort: input.sort
6045
+ sort: input.sort,
6046
+ voucher: input.voucher
6047
+ });
6048
+ const scopedInput = applyV9RentalScopeToSearchQueryInput({
6049
+ input: queryInput,
6050
+ scope: options.rentalScope,
6051
+ propertyKind
5963
6052
  });
5964
6053
  return {
5965
6054
  runtime,
5966
6055
  appliedFilters,
5967
6056
  unusedFilterKeys,
5968
- scopedQueryInput: applyV9RentalScopeToSearchQueryInput(queryInput, options.rentalScope)
6057
+ scopedQueryInput: scopedInput === void 0 ? void 0 : yield* applyV9RentalIdsToSearchQueryInput({
6058
+ input: scopedInput,
6059
+ rentalIdsIn: input.rentalIdsIn,
6060
+ rentalIdsSearch: config.rentalIdsSearch === true
6061
+ })
5969
6062
  };
5970
6063
  });
5971
6064
  const searchPage = ({ input, runtime, scopedQueryInput, page, first }) => Effect.gen(function* () {
@@ -6182,7 +6275,10 @@ const makeV9SearchApi = ({ config, options }) => {
6182
6275
  operation: "search.mapSearch",
6183
6276
  message: "mapSearch is not available with searchAllRentalsAtOnce; search already returns every result."
6184
6277
  }) : Effect.runPromise(limitSearch(Effect.gen(function* () {
6185
- const { runtime, appliedFilters, unusedFilterKeys, scopedQueryInput } = yield* toScopedQuery(input);
6278
+ const { runtime, appliedFilters, unusedFilterKeys, scopedQueryInput } = yield* toScopedQuery({
6279
+ locale: input.locale,
6280
+ query: input.query
6281
+ });
6186
6282
  if (scopedQueryInput === void 0) return {
6187
6283
  items: [],
6188
6284
  totalCount: 0,
@@ -6253,6 +6349,68 @@ const makeV9SearchApi = ({ config, options }) => {
6253
6349
  };
6254
6350
  };
6255
6351
  //#endregion
6352
+ //#region src/legacy-v9/voucher-code.ts
6353
+ const toVoucherCode = (voucher) => {
6354
+ const code = voucher?.trim();
6355
+ return code === void 0 || code === "" ? void 0 : code;
6356
+ };
6357
+ //#endregion
6358
+ //#region src/legacy-v9/live/voucher.ts
6359
+ const OPERATION = "v9.voucher.validate";
6360
+ const REASONS = {
6361
+ VALID: "valid",
6362
+ NOT_YET_VALID: "not_yet_valid",
6363
+ EXPIRED: "expired",
6364
+ UNKNOWN: "unknown",
6365
+ STAY_TOO_SHORT: "stay_too_short",
6366
+ OUTSIDE_BOOKING_WINDOW: "outside_booking_window",
6367
+ RATE_LIMITED: "rate_limited"
6368
+ };
6369
+ const failInvalidInput = (message) => Effect.fail(new CoreSDKError({
6370
+ source: "v9",
6371
+ operation: OPERATION,
6372
+ message
6373
+ }));
6374
+ const toIsoDate = ({ name, value }) => Effect.gen(function* () {
6375
+ if (value === void 0) return void 0;
6376
+ const isoDate = toIsoDateFromPeriodQueryDate(value);
6377
+ if (isoDate === void 0) return yield* failInvalidInput(`Expected "${name}" to use DD-MM-YYYY or YYYY-MM-DD dates.`);
6378
+ return isoDate;
6379
+ });
6380
+ const makeV9VoucherApi = ({ config, options }) => {
6381
+ const graphql = makeV9GraphQLClient(config);
6382
+ const translations = makeV9TranslationService(options.translationOverrides);
6383
+ const validate = ({ code, start, end, locale }) => Effect.gen(function* () {
6384
+ const voucherCode = toVoucherCode(code);
6385
+ if (voucherCode === void 0) return yield* failInvalidInput("Expected \"code\" to be a non-empty voucher code.");
6386
+ const fromdate = yield* toIsoDate({
6387
+ name: "start",
6388
+ value: start
6389
+ });
6390
+ const tilldate = yield* toIsoDate({
6391
+ name: "end",
6392
+ value: end
6393
+ });
6394
+ if (fromdate !== void 0 && tilldate !== void 0 && daysBetweenLocalDates({
6395
+ start: fromdate,
6396
+ end: tilldate
6397
+ }) <= 0) return yield* failInvalidInput("Expected \"end\" to be after \"start\".");
6398
+ const { voucherValidity } = yield* graphql.execute(voucherValidityQuery, {
6399
+ code: voucherCode,
6400
+ ...fromdate === void 0 ? {} : { fromdate },
6401
+ ...tilldate === void 0 ? {} : { tilldate }
6402
+ });
6403
+ const reason = REASONS[voucherValidity.reason] ?? "unknown";
6404
+ const label = yield* translations.translate(locale, `voucher.validate.reason.${reason}`);
6405
+ return {
6406
+ valid: voucherValidity.valid,
6407
+ reason,
6408
+ label
6409
+ };
6410
+ });
6411
+ return { validate: (input) => Effect.runPromise(validate(input)) };
6412
+ };
6413
+ //#endregion
6256
6414
  //#region src/legacy-v9/parser/filter/to-options.ts
6257
6415
  const toOptions = ({ stableFilter, label }) => {
6258
6416
  if (stableFilter.type === "InputFilter" && stableFilter.group === "rooms" && stableFilter.display_type === "number") return Array.from({ length: 10 }, (_, index) => {
@@ -6355,11 +6513,11 @@ const toCustomBackendFilterInput = ({ queryKey, value, filter }) => {
6355
6513
  value: true
6356
6514
  } : void 0;
6357
6515
  case "int": {
6358
- const numberValue = Number(value);
6359
- return Number.isInteger(numberValue) && numberValue >= 0 ? {
6516
+ const numberValue = toNonNegativeInt(value);
6517
+ return numberValue === void 0 ? void 0 : {
6360
6518
  key: queryKey,
6361
6519
  value: numberValue
6362
- } : void 0;
6520
+ };
6363
6521
  }
6364
6522
  case "string": return value.length > 0 ? {
6365
6523
  key: queryKey,
@@ -6498,6 +6656,26 @@ const makeV9FilterApi = ({ options }) => {
6498
6656
  })) };
6499
6657
  };
6500
6658
  //#endregion
6659
+ //#region src/legacy-v9/hub-filter-requirements.ts
6660
+ const toV9SdkOwnedHubFilterKeys = ({ config, rentalScope }) => {
6661
+ const scopeKey = toV9RentalScopeHubFilterKey({
6662
+ scope: rentalScope ?? {},
6663
+ propertyKind: toV9RentalScopePropertyKind(config)
6664
+ });
6665
+ return [...scopeKey === void 0 ? [] : [scopeKey], ...config.rentalIdsSearch === true ? [V9_HUB_RENTAL_IDS_FILTER_KEY] : []];
6666
+ };
6667
+ const toV9RequiredHubFilterKeys = ({ config, rentalScope, customAttributeFilterDefinitions }) => [.../* @__PURE__ */ new Set([...customAttributeFilterDefinitions.flatMap((definition) => definition.source === "backendFilter" && definition.searchable ? [definition.key] : []), ...toV9SdkOwnedHubFilterKeys({
6668
+ config,
6669
+ rentalScope
6670
+ })])];
6671
+ const checkV9HubFilters = ({ required, hubFilters }) => {
6672
+ const hubKeys = new Set(hubFilters.map(({ key }) => key));
6673
+ return {
6674
+ present: required.filter((key) => hubKeys.has(key)),
6675
+ missing: required.filter((key) => !hubKeys.has(key))
6676
+ };
6677
+ };
6678
+ //#endregion
6501
6679
  //#region src/legacy-v9/static/rentals.ts
6502
6680
  const DEFAULT_RENTAL_FACILITY_DATA_ATTRIBUTES = [
6503
6681
  "address",
@@ -6521,6 +6699,11 @@ const DEFAULT_RENTAL_FACILITY_DATA_ATTRIBUTES = [
6521
6699
  ];
6522
6700
  const DEFAULT_RENTAL_RATING_DATA_ATTRIBUTES = [];
6523
6701
  const RENTAL_BATCH_SIZE = 128;
6702
+ const HUB_FILTER_PURPOSES = {
6703
+ [V9_HUB_FACILITY_SCOPE_FILTER_KEY]: "searches cannot be limited to rentalScope",
6704
+ [V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY]: "searches cannot be limited to rentalScope",
6705
+ [V9_HUB_RENTAL_IDS_FILTER_KEY]: "searches cannot use rentalIdsIn"
6706
+ };
6524
6707
  const DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES = [
6525
6708
  "id",
6526
6709
  "arrival",
@@ -6533,11 +6716,12 @@ const DEFAULT_RENTAL_FEEDBACK_DATA_ATTRIBUTES = [
6533
6716
  "text",
6534
6717
  "avgRating"
6535
6718
  ];
6536
- const orderRentalsById = ({ rentalIds, rentals }) => {
6719
+ const orderRentalsById = ({ rentalIds, rentals, missing }) => {
6537
6720
  const rentalsById = new Map(rentals.map((rental) => [rental.voffice_id, rental]));
6538
- return rentalIds.map((rentalId) => {
6721
+ return rentalIds.flatMap((rentalId) => {
6539
6722
  const rental = rentalsById.get(rentalId);
6540
- if (rental != null) return rental;
6723
+ if (rental != null) return [rental];
6724
+ if (missing === "drop") return [];
6541
6725
  throw new CoreSDKError({
6542
6726
  source: "v9",
6543
6727
  operation: "v9.rentals.batch",
@@ -6546,7 +6730,7 @@ const orderRentalsById = ({ rentalIds, rentals }) => {
6546
6730
  });
6547
6731
  };
6548
6732
  const loadV9RentalsRuntime = Effect.tryPromise({
6549
- try: () => import("./rentals-B4g91vwW.mjs"),
6733
+ try: () => import("./rentals-DvYUm25t.mjs"),
6550
6734
  catch: (cause) => new CoreSDKError({
6551
6735
  source: "v9",
6552
6736
  operation: "v9.rentals.runtime",
@@ -6557,9 +6741,10 @@ const loadV9RentalsRuntime = Effect.tryPromise({
6557
6741
  const makeV9RentalsApi = ({ config, options }) => {
6558
6742
  const graphql = makeV9GraphQLClient(config);
6559
6743
  const translations = makeV9TranslationService(options.translationOverrides);
6560
- return { getRentals: (input) => Effect.runPromise(Effect.gen(function* () {
6561
- const { associateRentalsWithFacilitiesByObjectGroups, defaultRentalDataAttributes, rentalFacilitiesForObjectGroupRelationQuery, rentalIdsQuery, rentalsAllByFacilityObjectGroupsWithoutFeedbacksQuery, rentalsAllFeedbacksQuery, rentalsAllWithoutFeedbacksQuery, toRentalRentalsOutput } = yield* loadV9RentalsRuntime;
6562
- const language = localeToLanguage(input.locale);
6744
+ const propertyKind = toV9RentalScopePropertyKind(config);
6745
+ const loadRentals = ({ locale, rentalIds, missing }) => Effect.gen(function* () {
6746
+ const { associateRentalsWithFacilitiesByObjectGroups, defaultRentalDataAttributes, rentalFacilitiesForObjectGroupRelationQuery, rentalsAllByFacilityObjectGroupsWithoutFeedbacksQuery, rentalsAllFeedbacksQuery, rentalsAllWithoutFeedbacksQuery, toRentalRentalsOutput } = yield* loadV9RentalsRuntime;
6747
+ const language = localeToLanguage(locale);
6563
6748
  const rentalDataAttributes = [
6564
6749
  ...defaultRentalDataAttributes,
6565
6750
  ...config.rentalDataAttributes ?? [],
@@ -6575,8 +6760,6 @@ const makeV9RentalsApi = ({ config, options }) => {
6575
6760
  ...options.v9Reviews.criteria.map((criterion) => customDataAttribute(criterion.v9))
6576
6761
  ];
6577
6762
  const relationAttributeId = config.facilityObjectGroupRelationAttributeId;
6578
- const rentalIds = (yield* graphql.execute(rentalIdsQuery, {})).all.map((rental) => rental.voffice_id);
6579
- if (rentalIds.length === 0) return [];
6580
6763
  const directRentals = [];
6581
6764
  const objectGroupRentals = [];
6582
6765
  for (let offset = 0; offset < rentalIds.length; offset += RENTAL_BATCH_SIZE) {
@@ -6600,9 +6783,11 @@ const makeV9RentalsApi = ({ config, options }) => {
6600
6783
  objectGroupRentals.push(...rentalsData.all);
6601
6784
  }
6602
6785
  }
6786
+ if (missing === "drop" && directRentals.length + objectGroupRentals.length === 0) return [];
6603
6787
  const rentalsWithoutFeedbacks = relationAttributeId === void 0 ? orderRentalsById({
6604
6788
  rentalIds,
6605
- rentals: directRentals
6789
+ rentals: directRentals,
6790
+ missing
6606
6791
  }) : yield* Effect.gen(function* () {
6607
6792
  const facilitiesData = yield* graphql.execute(rentalFacilitiesForObjectGroupRelationQuery, {
6608
6793
  language,
@@ -6610,7 +6795,8 @@ const makeV9RentalsApi = ({ config, options }) => {
6610
6795
  });
6611
6796
  const orderedRentals = orderRentalsById({
6612
6797
  rentalIds,
6613
- rentals: objectGroupRentals
6798
+ rentals: objectGroupRentals,
6799
+ missing
6614
6800
  });
6615
6801
  return yield* Effect.try({
6616
6802
  try: () => associateRentalsWithFacilitiesByObjectGroups({
@@ -6626,7 +6812,11 @@ const makeV9RentalsApi = ({ config, options }) => {
6626
6812
  })
6627
6813
  });
6628
6814
  });
6629
- const scopedRentalsWithoutFeedbacks = filterV9RentalsByScope(rentalsWithoutFeedbacks, options.rentalScope);
6815
+ const scopedRentalsWithoutFeedbacks = filterV9RentalsByScope({
6816
+ rentals: rentalsWithoutFeedbacks,
6817
+ scope: options.rentalScope,
6818
+ propertyKind
6819
+ });
6630
6820
  if (scopedRentalsWithoutFeedbacks.length === 0) return [];
6631
6821
  const feedbackRentals = [];
6632
6822
  for (let offset = 0; offset < scopedRentalsWithoutFeedbacks.length; offset += RENTAL_BATCH_SIZE) {
@@ -6645,7 +6835,7 @@ const makeV9RentalsApi = ({ config, options }) => {
6645
6835
  }));
6646
6836
  return yield* Effect.all(scopedRentals.map((rental) => toRentalRentalsOutput({
6647
6837
  rental,
6648
- locale: input.locale,
6838
+ locale,
6649
6839
  translations,
6650
6840
  imageProxyBaseUrl: config.imageProxyBaseUrl,
6651
6841
  rentalHighlightPrioritization: [...options.rentalHighlightPrioritization],
@@ -6654,7 +6844,51 @@ const makeV9RentalsApi = ({ config, options }) => {
6654
6844
  v9PropertyHighlightSources: options.v9PropertyHighlightSources,
6655
6845
  reviews: options.v9Reviews
6656
6846
  })));
6657
- })) };
6847
+ });
6848
+ const requiredHubFilterKeys = toV9SdkOwnedHubFilterKeys({
6849
+ config,
6850
+ rentalScope: options.rentalScope
6851
+ });
6852
+ const checkHubFilters = Effect.gen(function* () {
6853
+ if (config.facilityObjectGroupRelationAttributeId !== void 0 && requiredHubFilterKeys.includes("facility_scope")) return yield* Effect.fail(new CoreSDKError({
6854
+ source: "v9",
6855
+ operation: "v9.rentals.hub-filters",
6856
+ message: "A facility rentalScope cannot be combined with facilityObjectGroupRelationAttributeId: listings would use the facilities derived from object groups, while the search uses the facility stored on each rental. If the facilities are maintained on the rentals in vOffice, remove facilityObjectGroupRelationAttributeId. Otherwise set rentalScopePropertyKind: \"objectGroup\" and use the object group ID as rentalScope.propertyId."
6857
+ }));
6858
+ const { hubFiltersQuery } = yield* loadV9RentalsRuntime;
6859
+ const hubFilters = yield* graphql.execute(hubFiltersQuery, { language: "de" });
6860
+ const { missing: missingHubFilterKeys } = checkV9HubFilters({
6861
+ required: requiredHubFilterKeys,
6862
+ hubFilters: hubFilters.filter
6863
+ });
6864
+ if (missingHubFilterKeys.length > 0) return yield* Effect.fail(new CoreSDKError({
6865
+ source: "v9",
6866
+ operation: "v9.rentals.hub-filters",
6867
+ message: "The be-on! Hub lacks filters for this API key: " + missingHubFilterKeys.map((key) => `"${key}" (${HUB_FILTER_PURPOSES[key]})`).join(", ") + ". Run `website-sdk hub-filters request` and hand the file to a be-on! developer."
6868
+ }));
6869
+ });
6870
+ const [checkHubFiltersOnce, invalidateHubFiltersCheck] = Effect.runSync(Effect.cachedInvalidateWithTTL(checkHubFilters, Duration.infinity));
6871
+ return {
6872
+ getRentals: (input) => Effect.runPromise(Effect.gen(function* () {
6873
+ const { rentalIdsQuery } = yield* loadV9RentalsRuntime;
6874
+ if (requiredHubFilterKeys.length > 0) yield* checkHubFiltersOnce.pipe(Effect.tapError(() => invalidateHubFiltersCheck));
6875
+ const rentalIds = (yield* graphql.execute(rentalIdsQuery, {})).all.map((rental) => rental.voffice_id);
6876
+ if (rentalIds.length === 0) return [];
6877
+ return yield* loadRentals({
6878
+ locale: input.locale,
6879
+ rentalIds,
6880
+ missing: "fail"
6881
+ });
6882
+ })),
6883
+ getRentalsByIds: (input) => Effect.runPromise(Effect.suspend(() => {
6884
+ const voffice_ids = toV9RentalIds(input.rentalIds);
6885
+ return voffice_ids.length === 0 ? Effect.succeed([]) : loadRentals({
6886
+ locale: input.locale,
6887
+ rentalIds: voffice_ids,
6888
+ missing: "drop"
6889
+ });
6890
+ }))
6891
+ };
6658
6892
  };
6659
6893
  //#endregion
6660
6894
  //#region src/client.ts
@@ -6689,12 +6923,16 @@ function createWebsiteSDK({ config, options }) {
6689
6923
  config,
6690
6924
  options: v9Options
6691
6925
  });
6926
+ const voucher = makeV9VoucherApi({
6927
+ config,
6928
+ options: v9Options
6929
+ });
6692
6930
  recordConstructedBackend("v9");
6693
6931
  recordConstructedSdk(config, options);
6694
6932
  return {
6695
6933
  backend: "v9",
6696
6934
  static: {
6697
- rentals,
6935
+ rentals: { getRentals: rentals.getRentals },
6698
6936
  filter: { getFilters: filter.getFilters }
6699
6937
  },
6700
6938
  live: {
@@ -6704,6 +6942,8 @@ function createWebsiteSDK({ config, options }) {
6704
6942
  mapSearch: search.mapSearch,
6705
6943
  searchPages: search.searchPages
6706
6944
  },
6945
+ voucher: { validate: voucher.validate },
6946
+ rentals: { getRentalsByIds: rentals.getRentalsByIds },
6707
6947
  availability: {
6708
6948
  getInitialAvailability: availability.getInitialAvailability,
6709
6949
  getStartDateSelectedAvailability: availability.getStartDateSelectedAvailability
@@ -6772,4 +7012,4 @@ function createWebsiteSDK({ config, options }) {
6772
7012
  return sdk;
6773
7013
  }
6774
7014
  //#endregion
6775
- export { SearchPropertiesResponseSchema as $, ErgoBankSchema as A, getStartDateSelectedAvailabilityEffect as At, OnOfficeUnitCollectionResponseSchema as B, submitPaymentOption as Bt, DocumentResourceResponseSchema as C, bookInsuranceEffect as Ct, DocumentSummarySchema as D, getFiltersEffect as Dt, DocumentStatusUpdateRequestSchema as E, getBankTransferDetailsEffect as Et, ErgoPlanSearchRequestSchema as F, searchEffect as Ft, QuotePricesPayloadSchema as G, V9_FACILITY_ATTRIBUTE_KEYS as Gt, PaymentScheduleItemSchema as H, defineWebsiteSDKOptions as Ht, ErgoPolicyNumberRequestSchema as I, selectCancellationPolicyEffect as It, QuoteServiceSchema as J, QuotePricesResponseSchema$1 as K, ErgoReadPreContractRequestSchema as L, selectInsuranceEffect as Lt, ErgoCommonFieldsSchema as M, mapSearchEffect as Mt, ErgoCreatePreContractRequestSchema as N, quoteEffect as Nt, DocumentTypeSchema as O, getInitialAvailabilityEffect as Ot, ErgoPersonSchema as P, removeAdditionalServiceEffect as Pt, RoomImageSchema as Q, ErgoTripAndCustomerRequestSchema as R, selectInsurancePaymentEffect as Rt, DocumentCollectionResponseSchema as S, bookEffect as St, DocumentStatusSchema as T, createInsurancePreContractEffect as Tt, PaymentScheduleSchema$1 as U, defineV9PropertyHighlightSources as Ut, OnOfficeUnitSchema as V, submitPaymentOptionEffect as Vt, QuoteLineSchema$1 as W, defineV9PropertyHighlightSourcesFromUnknown as Wt, RawVofficeObjectSchema as X, RawObjectResponseSchema as Y, RegionListResponseSchema as Z, ApiEnvelopeBaseSchema as _, V1_BASE_URL as _t, parseQueryParameters as a, SetupResponseSchema as at, CurrentMemberResponseSchema as b, decodeV1OperationResponse as bt, makeV9GraphQLClient as c, TileTagSchema as ct, makeV0OpenApiClientFetchLive as d, UnitIdsResponseSchema as dt, ServiceBeonDataSchema as et, makeV0OpenApiClientLive as f, UnitListItemSchema as ft, makeV1OpenApiClientLive as g, UnitServicePriceSchema as gt, makeV1OpenApiClientFetchLive as h, UnitResponseSchema as ht, collectQueryParameters as i, SetupDataSchema as it, ErgoBookRequestSchema as j, getTermsAndPrivacyPolicyEffect as jt, ErgoAddressSchema as k, getRentalsEffect as kt, V0OpenApiClient as l, TravelInsuranceBookingSchema as lt, V1OpenApiClientError as m, UnitOfferSchema as mt, makeV9CustomAttributeFilterCapabilities as n, ServiceLimitSchema as nt, toQueryString as o, TileCollectionResponseSchema as ot, V1OpenApiClient as p, UnitListResponseSchema as pt, QuoteSchema as q, toBasicQueryInputs as r, ServiceListResponseSchema as rt, applyVofficeFilterDerivedBasicQueryInputs as s, TileSchema as st, createWebsiteSDK as t, ServiceImageSchema as tt, V0OpenApiClientError as u, TravelInsuranceBookingStoreRequestSchema as ut, CalendarDaySchema as v, V1_OPERATIONS as vt, DocumentResourceSchema as w, clearAdditionalServicesEffect as wt, CustomerUnitSummarySchema as x, addAdditionalServiceEffect as xt, CalendarResponseSchema$1 as y, VideoResponseSchema as yt, FacilityListResponseSchema as z, submitContactEffect as zt };
7015
+ export { RawObjectResponseSchema as $, V9_HUB_OBJECT_GROUP_SCOPE_FILTER_KEY as $t, DocumentStatusUpdateRequestSchema as A, getBankTransferDetailsEffect as At, ErgoPolicyNumberRequestSchema as B, selectCancellationPolicyEffect as Bt, CalendarResponseSchema$1 as C, VideoResponseSchema as Ct, DocumentResourceResponseSchema as D, bookInsuranceEffect as Dt, DocumentCollectionResponseSchema as E, bookEffect as Et, ErgoBookRequestSchema as F, getTermsAndPrivacyPolicyEffect as Ft, OnOfficeUnitSchema as G, submitPaymentOptionEffect as Gt, ErgoTripAndCustomerRequestSchema as H, selectInsurancePaymentEffect as Ht, ErgoCommonFieldsSchema as I, mapSearchEffect as It, QuoteLineSchema$1 as J, defineV9PropertyHighlightSourcesFromUnknown as Jt, PaymentScheduleItemSchema as K, defineWebsiteSDKOptions as Kt, ErgoCreatePreContractRequestSchema as L, quoteEffect as Lt, DocumentTypeSchema as M, getInitialAvailabilityEffect as Mt, ErgoAddressSchema as N, getRentalsEffect as Nt, DocumentResourceSchema as O, clearAdditionalServicesEffect as Ot, ErgoBankSchema as P, getStartDateSelectedAvailabilityEffect as Pt, QuoteServiceSchema as Q, V9_HUB_OBJECT_GROUP_FILTER_KEY as Qt, ErgoPersonSchema as R, removeAdditionalServiceEffect as Rt, CalendarDaySchema as S, V1_OPERATIONS as St, CustomerUnitSummarySchema as T, addAdditionalServiceEffect as Tt, FacilityListResponseSchema as U, submitContactEffect as Ut, ErgoReadPreContractRequestSchema as V, selectInsuranceEffect as Vt, OnOfficeUnitCollectionResponseSchema as W, submitPaymentOption as Wt, QuotePricesResponseSchema$1 as X, V9_HUB_FACILITY_SCOPE_FILTER_KEY as Xt, QuotePricesPayloadSchema as Y, V9_FACILITY_ATTRIBUTE_KEYS as Yt, QuoteSchema as Z, V9_HUB_FACILITY_SEARCH_FILTER_KEY as Zt, V1OpenApiClient as _, UnitListResponseSchema as _t, makeV9CustomAttributeFilterCapabilities as a, ServiceImageSchema as at, makeV1OpenApiClientLive as b, UnitServicePriceSchema as bt, parseQueryParameters as c, SetupDataSchema as ct, toVoucherCode as d, TileSchema as dt, V9_HUB_OFFERS_FILTER_KEY as en, RawVofficeObjectSchema as et, makeV9GraphQLClient as f, TileTagSchema as ft, makeV0OpenApiClientLive as g, UnitListItemSchema as gt, makeV0OpenApiClientFetchLive as h, UnitIdsResponseSchema as ht, toV9SdkOwnedHubFilterKeys as i, ServiceBeonDataSchema as it, DocumentSummarySchema as j, getFiltersEffect as jt, DocumentStatusSchema as k, createInsurancePreContractEffect as kt, toQueryString as l, SetupResponseSchema as lt, V0OpenApiClientError as m, TravelInsuranceBookingStoreRequestSchema as mt, checkV9HubFilters as n, V9_HUB_RENTAL_IDS_FILTER_KEY as nn, RoomImageSchema as nt, toBasicQueryInputs as o, ServiceLimitSchema as ot, V0OpenApiClient as p, TravelInsuranceBookingSchema as pt, PaymentScheduleSchema$1 as q, defineV9PropertyHighlightSources as qt, toV9RequiredHubFilterKeys as r, V9_SDK_OWNED_HUB_FILTER_KEYS as rn, SearchPropertiesResponseSchema as rt, collectQueryParameters as s, ServiceListResponseSchema as st, createWebsiteSDK as t, V9_HUB_OFFER_FILTER_KEY as tn, RegionListResponseSchema as tt, applyVofficeFilterDerivedBasicQueryInputs as u, TileCollectionResponseSchema as ut, V1OpenApiClientError as v, UnitOfferSchema as vt, CurrentMemberResponseSchema as w, decodeV1OperationResponse as wt, ApiEnvelopeBaseSchema as x, V1_BASE_URL as xt, makeV1OpenApiClientFetchLive as y, UnitResponseSchema as yt, ErgoPlanSearchRequestSchema as z, searchEffect as zt };