@v-office/website-sdk 2.22.0 → 2.23.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.
@@ -110,9 +110,14 @@ type WebsiteSDKOptions = {
110
110
  rentalPropertyHighlightPrioritization?: readonly RentalPropertyHighlightPrioritizationKey[];
111
111
  rentalScope?: RentalScope;
112
112
  shouldAddProposedAdditionalServiceAmount?: boolean;
113
+ searchAllRentalsAtOnce?: boolean;
113
114
  };
114
115
  ```
115
116
 
117
+ `searchAllRentalsAtOnce` selects how a site searches, on v9 and v10 alike: every
118
+ result with prices in one call (portfolios of up to 100 rentals), or paged results
119
+ plus `mapSearch`. See `search.md`.
120
+
116
121
  `rentalHighlightPrioritization` and `rentalPropertyHighlightPrioritization` select
117
122
  which facts become highlights and set their order. They are ordered allowlists, not
118
123
  sorts over every available fact. A key that is not listed is not emitted even when
@@ -135,6 +140,7 @@ Unset options are normalized by the SDK:
135
140
  - `rentalPropertyHighlightPrioritization` defaults to the SDK default property highlight selection.
136
141
  - `rentalScope` defaults to `{}`.
137
142
  - `shouldAddProposedAdditionalServiceAmount` defaults to `false`.
143
+ - `searchAllRentalsAtOnce` defaults to `false`.
138
144
  - `translationOverrides` is omitted unless provided.
139
145
 
140
146
  ### v9 Property Highlight Sources
@@ -403,6 +403,9 @@ fixed-period search without a window, the dates are the requested ones and
403
403
  }
404
404
  ```
405
405
 
406
+ `pageInfo.totalCount` is the number of rentals the backend matched for the search
407
+ over all pages.
408
+
406
409
  `appliedFilters` reports what the backend actually applied, and is what a "remove
407
410
  this filter" chip should be built from. `label` is localized presentation and can
408
411
  repeat, so it cannot identify a filter; `key` plus `value` can. `value` is the
@@ -424,6 +427,84 @@ the expanded leaf entries. A UI may collapse those leaves under the composition
424
427
  display, but should keep the returned keys and canonical values when removing direct
425
428
  filters.
426
429
 
430
+ ## All Rentals At Once Or Map Search
431
+
432
+ A search that prices many results is slow the first time the backend sees it, and
433
+ a list next to a map should not wait for every price. An SDK therefore works in one
434
+ of two modes, chosen with the `searchAllRentalsAtOnce` option (default `false`).
435
+ Both modes behave the same on v9 and v10, so a site keeps its code when it moves
436
+ from one backend to the other.
437
+
438
+ ### `searchAllRentalsAtOnce: true`
439
+
440
+ For portfolios of up to `SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS` (100) rentals.
441
+ `sdk.live.search.search` returns every result with its price in one call, so a list
442
+ and a map can show all results with prices at the same time:
443
+
444
+ ```ts
445
+ const sdk = createWebsiteSDK({ config, options: { searchAllRentalsAtOnce: true } });
446
+ const output = await sdk.live.search.search({ locale: "de-DE", query: "adults=2" });
447
+ // output.pageInfo: { hasNextPage: false, totalCount }
448
+ ```
449
+
450
+ - The input has no `cursor` and no `limit`; passing either rejects the call with a
451
+ `CoreSDKError` whose `operation` is `search.allRentalsAtOnce`.
452
+ - When the search matches more than 100 rentals, the call rejects with the same
453
+ `operation`. Use the default mode for such a portfolio.
454
+ - `mapSearch` is not available: with `searchAllRentalsAtOnce: true` written in the
455
+ code, the returned `WebsiteSDKV9AllRentalsAtOnce`, `WebsiteSDKV10AllRentalsAtOnce`
456
+ or `WebsiteSDKAllRentalsAtOnce` type has no `mapSearch` and no `cursor`/`limit`;
457
+ when the value is only known at runtime, `mapSearch` rejects with the `operation`
458
+ `search.mapSearch`.
459
+ - The call counts as one request for the search rate limit.
460
+
461
+ ### `searchAllRentalsAtOnce: false` (default)
462
+
463
+ `sdk.live.search.search` is paged as before. `sdk.live.search.mapSearch` returns
464
+ every rental the search matches, with its location and without prices:
465
+
466
+ ```ts
467
+ const map = await sdk.live.search.mapSearch({ locale: "de-DE", query: "adults=2" });
468
+ // map: { items: { id, location? }[], totalCount, appliedFilters, unusedFilterKeys }
469
+ ```
470
+
471
+ `mapSearch` takes the same `query` as `search`, so map and list use the same
472
+ filters. Because it arrives before any result is priced, its `totalCount` can also
473
+ decide how to load the list: at most `SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS`
474
+ matches can be loaded in one `search` call with that `limit` and shown with prices on
475
+ the map (matched by `id`); more matches are paged, with a map without prices.
476
+
477
+ ```ts
478
+ const map = await sdk.live.search.mapSearch({ locale, query });
479
+ if (map.totalCount <= SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS) {
480
+ const all = await sdk.live.search.search({
481
+ locale,
482
+ query,
483
+ limit: SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS,
484
+ });
485
+ } else {
486
+ const page = await sdk.live.search.search({ locale, query, limit: 24, cursor });
487
+ }
488
+ ```
489
+
490
+ In this mode a `search` call is one backend request, whatever its `limit`.
491
+
492
+ ### How each backend does it
493
+
494
+ - v9 prices the rentals of one request one after another, but separate requests in
495
+ parallel. `searchAllRentalsAtOnce` counts the matches without prices first, then
496
+ fetches the priced results as backend pages of ten, at most eight at a time, and
497
+ merges them in backend order; an oversized search is refused before any price is
498
+ requested. When a booking between the requests moves rentals across page
499
+ boundaries, the pages disagree with the count; the SDK then asks for all results in
500
+ one request, a consistent snapshot, instead of returning a set with a gap. `mapSearch` selects no prices and loads up to 1,000 matches per request,
501
+ as many requests as the matches need.
502
+ - v10 answers the whole result set in one request. `searchAllRentalsAtOnce` asks for
503
+ 101 results and refuses the search when the response total is above 100.
504
+ `mapSearch` is one request without prices that returns only the location, for up
505
+ to 1,000 matches: the backend's result window, so `items` holds at most 1,000
506
+ rentals while `totalCount` can be higher.
507
+
427
508
  ## Backend Behavior
428
509
 
429
510
  ### v10
@@ -482,6 +563,9 @@ shape:
482
563
  length, not the stay itself. The backend returns the bookable stays inside the
483
564
  window, earliest first; the SDK keeps that order.
484
565
  - v9 never executes a custom-attribute search filter.
566
+ - A search requests only the rental data the search output reads: `name`,
567
+ `address`, `regionName`, `images`, the attribute behind each configured rental
568
+ highlight, the configured custom attributes and `rentalDataAttributes`.
485
569
 
486
570
  The field is omitted when v9 returns no final total or when its original total is
487
571
  not greater than the final total. v9 exposes at most one aggregated applied entry,
@@ -493,7 +577,7 @@ Use flat `WebsiteSDKConfig` files and optional `WebsiteSDKOptions`.
493
577
 
494
578
  For v10, config requires `searchEndpoint` (the full REST search URL) as of 2.5.0. See `creation.md` for `searchEndpoint` and the `customAttributes` option.
495
579
 
496
- Custom filter definitions can extend accepted search query keys. Search requests are rate-limited to one backend request per second with a queue size of five.
580
+ Custom filter definitions can extend accepted search query keys. Search requests are rate-limited to one backend request per second with a queue size of five. A `searchAllRentalsAtOnce` search and a `mapSearch` each count as one request, including every backend request they make.
497
581
 
498
582
  ## CLI Usage
499
583
 
@@ -0,0 +1,62 @@
1
+ # Changelog: 2.23.0
2
+
3
+ A search that the backend has not answered before is slow: the v9 backend prices
4
+ the rentals of one request one after another, about 40–75 ms per rental, and caches
5
+ only whole searches. A site that shows every result with its price on a map had to
6
+ request all of them in one call, which took 3–9 s for a portfolio of about 70
7
+ rentals on v9. Separate requests are priced in parallel, and a search that selects
8
+ no prices costs almost nothing. This release uses both, with the same API on v9 and
9
+ v10 so a site keeps its code when it switches backend: small portfolios get every
10
+ priced result in one call, large portfolios get a map search next to a paged list.
11
+
12
+ Measured against a v9 hub with 74 rentals, first request for a date range: 71
13
+ results in 8.6 s with one request, 2.1 s with `searchAllRentalsAtOnce`. A search
14
+ with few results gains nothing and costs the count request: 18 results in 1.4 s
15
+ before, 1.7 s now.
16
+
17
+ ## Added
18
+
19
+ - The `searchAllRentalsAtOnce` option (default `false`), on v9 and v10. With
20
+ `true`, `sdk.live.search.search` returns every result with its price in one call
21
+ and takes no `cursor` or `limit`. A search that matches more than
22
+ `SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS` (100) rentals, or a passed `cursor` or
23
+ `limit`, rejects with the `CoreSDKError` operation `search.allRentalsAtOnce`. The
24
+ whole call counts as one request for the search rate limit.
25
+ - v9: counts the matches without prices, then fetches the priced results as
26
+ parallel backend pages of ten, at most eight at a time. An oversized search is
27
+ refused before any price is requested. When a booking between the requests
28
+ shifts rentals across page boundaries, it asks for all results in one request
29
+ instead.
30
+ - v10: one request for 101 results; refused when the response total is above 100.
31
+ - `sdk.live.search.mapSearch({ locale, query })` in the default mode, on v9 and
32
+ v10: every rental the search matches, with `id` and `location`, plus
33
+ `totalCount`, `appliedFilters` and `unusedFilterKeys`, without prices. It
34
+ rejects with the operation `search.mapSearch` when the SDK was created with
35
+ `searchAllRentalsAtOnce: true`. v9 loads up to 1,000 matches per backend request;
36
+ v10 answers up to 1,000 matches, its result window.
37
+ - `pageInfo.totalCount` on every search output: the number of rentals the backend
38
+ matched over all pages.
39
+ - The types `WebsiteSDKAllRentalsAtOnce`, `WebsiteSDKV9AllRentalsAtOnce`,
40
+ `WebsiteSDKV10AllRentalsAtOnce` with their `...Live` types and
41
+ `V9SearchAllRentalsAtOnceInput`, and from `@v-office/sdk-core` 1.24.0
42
+ `SEARCH_ALL_RENTALS_AT_ONCE_MAX_RESULTS`, `SearchMapSearchInput`,
43
+ `SearchMapSearchOutput`, `SearchMapSearchOutputItem`,
44
+ `SearchAllRentalsAtOnceInput` and the matching schemas. `createWebsiteSDK`
45
+ returns an `...AllRentalsAtOnce` type when `searchAllRentalsAtOnce: true` is
46
+ written in the options; it has no `mapSearch` and no `cursor`/`limit`.
47
+
48
+ ## Changed
49
+
50
+ - `v9`: a search requests only the rental data the search output reads (`name`,
51
+ `address`, `regionName`, `images`, the attribute behind each configured rental
52
+ highlight, configured custom attributes and `rentalDataAttributes`) instead of
53
+ every known attribute: 56 instead of 450 attributes with the default highlights,
54
+ and a response of 52 KB instead of 164 KB gzipped (624 KB instead of 1,471 KB
55
+ uncompressed) for 71 rentals. The output is unchanged.
56
+ - Requires `@v-office/sdk-core` 1.24.0.
57
+
58
+ ## Unchanged
59
+
60
+ - A paged search in the default mode, on v9 and v10: same request per call, same
61
+ items, alternatives and prices; `pageInfo` gains `totalCount`. On v9 verified
62
+ against the hub with 2.22.0 side by side.
@@ -0,0 +1,33 @@
1
+ # Migration: 2.22.0 to 2.23.0
2
+
3
+ ## 1. Upgrade
4
+
5
+ ```sh
6
+ pnpm add @v-office/website-sdk@2.23.0
7
+ ```
8
+
9
+ No changes are required. The default mode searches as before, and the search
10
+ output only gains `pageInfo.totalCount`.
11
+
12
+ ## 2. Show every result with its price on list and map (up to 100 rentals)
13
+
14
+ Create the SDK with `searchAllRentalsAtOnce: true` and drop the pagination loop:
15
+ one `search` call returns every result with `pageInfo.hasNextPage: false`. Remove
16
+ `cursor` and `limit` from the input; the call rejects them. The same code works on
17
+ v9 and v10.
18
+
19
+ ```ts
20
+ const sdk = createWebsiteSDK({ config, options: { searchAllRentalsAtOnce: true } });
21
+ const { items, alternatives, pageInfo } = await sdk.live.search.search({ locale, query });
22
+ ```
23
+
24
+ ## 3. Map for a larger portfolio (default mode)
25
+
26
+ Load the map with `mapSearch` and page the list with `search`. Use `totalCount`
27
+ from `mapSearch` to load a search with few matches in one call and show its prices
28
+ on the map; see `search.md`, "All Rentals At Once Or Map Search".
29
+
30
+ ```ts
31
+ const map = await sdk.live.search.mapSearch({ locale, query });
32
+ // map.items: { id, location? }[] for every match; map.totalCount
33
+ ```
@@ -1,6 +1,6 @@
1
- import { Ut as V9_FACILITY_ATTRIBUTE_KEYS } from "./client-BtZ30vTP.mjs";
1
+ import { Wt as V9_FACILITY_ATTRIBUTE_KEYS } from "./client-CGO5Pmuv.mjs";
2
2
  import { c as parseVofficeUnitData, i as VofficeUnitDataPropertyMetadata, n as VofficeUnitDataPropertyCategoryLabelKeys, o as parseVofficeFacilityData, r as VofficeUnitDataPropertyCategoryValues, s as parseVofficeFeedbackData, t as VofficeUnitDataFieldSchemas } from "./v9-data-BnYxa2Ek.mjs";
3
- import { a as toAddress, c as rentalFacilitiesForObjectGroupRelationQuery, d as rentalsAllFeedbacksQuery, f as rentalsAllWithoutFeedbacksQuery, i as toImages, l as rentalIdsQuery, n as renderVofficePropertyAttribute, o as toLocalizedString, r as toFacilityImages, t as toRentalHighlights, u as rentalsAllByFacilityObjectGroupsWithoutFeedbacksQuery } from "./to-rental-highlights-CN-wpRh3.mjs";
3
+ import { a as toFacilityImages, c as toLocalizedString, d as rentalFacilitiesForObjectGroupRelationQuery, f as rentalIdsQuery, h as rentalsAllWithoutFeedbacksQuery, i as toLocation, m as rentalsAllFeedbacksQuery, o as toImages, p as rentalsAllByFacilityObjectGroupsWithoutFeedbacksQuery, r as renderVofficePropertyAttribute, s as toAddress, t as toRentalHighlights } from "./to-rental-highlights-C1NF2uuE.mjs";
4
4
  import { CoreSDKError, makeTranslate, renderResolvedCustomAttribute, toCustomAttributeList, toResolvedCustomAttributeCategoryTranslationKey } from "@v-office/sdk-core";
5
5
  import { Effect } from "effect";
6
6
  //#region src/legacy-v9/parser/rentals/to-description.ts
@@ -25,16 +25,6 @@ const toDescription = (data, locale) => {
25
25
  return description;
26
26
  };
27
27
  //#endregion
28
- //#region src/legacy-v9/parser/rentals/to-location.ts
29
- const toLocation = (location) => {
30
- if (location == null) return void 0;
31
- const [longitude, latitude] = location.coordinates;
32
- return {
33
- latitude,
34
- longitude
35
- };
36
- };
37
- //#endregion
38
28
  //#region src/legacy-v9/parser/rentals/to-property-attributes.ts
39
29
  const toPropertyAttributes = ({ attributes, locale, translations }) => Effect.gen(function* () {
40
30
  const items = [];
@@ -1,6 +1,6 @@
1
- import { a as parseQueryParameters, i as collectQueryParameters, n as makeV9CustomAttributeFilterCapabilities, o as toQueryString, r as toBasicQueryInputs, s as applyVofficeFilterDerivedBasicQueryInputs } from "./client-BtZ30vTP.mjs";
2
- import { c as parseVofficeUnitData, t as VofficeUnitDataFieldSchemas } from "./v9-data-BnYxa2Ek.mjs";
3
- import { a as toAddress, i as toImages, s as searchQuery, t as toRentalHighlights } from "./to-rental-highlights-CN-wpRh3.mjs";
1
+ import { a as parseQueryParameters, i as collectQueryParameters, n as makeV9CustomAttributeFilterCapabilities, o as toQueryString, r as toBasicQueryInputs, s as applyVofficeFilterDerivedBasicQueryInputs } from "./client-CGO5Pmuv.mjs";
2
+ import { c as parseVofficeUnitData } from "./v9-data-BnYxa2Ek.mjs";
3
+ import { i as toLocation, l as mapSearchQuery, n as toV9RentalHighlightKey, o as toImages, s as toAddress, t as toRentalHighlights, u as searchQuery } from "./to-rental-highlights-C1NF2uuE.mjs";
4
4
  import { CoreSDKError, STABLE_SEARCH_INPUTS, daysBetweenLocalDates, expandCustomAttributeFilterCompositions, parseChildrenAges, parseOccupancyCount, resolveExpandedCompositions, toFormattedSearchPrice, toIsoDateFromPeriodQueryDate, toStableSearchInputBackendQueryKeys, toStableSearchInputParameterValues, toStableSearchInputQueryKeys, toUnusedFilterKeys } from "@v-office/sdk-core";
5
5
  import { Effect } from "effect";
6
6
  //#region src/legacy-v9/parser/search/input/search-input-error.ts
@@ -322,6 +322,18 @@ const toSearchPeriods = ({ locale, periods }) => Effect.succeed((periods ?? []).
322
322
  }));
323
323
  //#endregion
324
324
  //#region src/legacy-v9/runtime/search.ts
325
- const defaultSearchDataAttributes = Object.keys(VofficeUnitDataFieldSchemas);
325
+ /**
326
+ * The rental data `toSearchOutputItem` reads: name, address with the region name,
327
+ * images, and the v9 attribute behind each configured highlight key. Requesting
328
+ * every known attribute instead more than doubles the response for the same output.
329
+ */
330
+ const toSearchDataAttributes = (rentalHighlightPrioritization) => [.../* @__PURE__ */ new Set([
331
+ "name",
332
+ "address",
333
+ "regionName",
334
+ "images",
335
+ ...rentalHighlightPrioritization.flatMap((key) => toV9RentalHighlightKey(key) ?? [])
336
+ ])];
337
+ const mapSearchDataAttributes = ["loc"];
326
338
  //#endregion
327
- export { defaultSearchDataAttributes, resolveExactMatch, searchQuery, toQueryInput, toSearchOutputItem, toSearchPeriods };
339
+ export { mapSearchDataAttributes, mapSearchQuery, parseVofficeUnitData, resolveExactMatch, searchQuery, toLocation, toQueryInput, toSearchDataAttributes, toSearchOutputItem, toSearchPeriods };