@v-office/website-sdk 2.24.0 → 2.25.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 (32) hide show
  1. package/dist/cli.mjs +89 -2
  2. package/dist/{client-DC4LG3CP.mjs → client-0Lgv-Gb_.mjs} +83 -18
  3. package/dist/index.d.mts +17 -5
  4. package/dist/index.mjs +1 -1
  5. package/dist/instructions/CHANGELOG.md +2 -0
  6. package/dist/instructions/MIGRATION.md +2 -0
  7. package/dist/instructions/creation.md +5 -0
  8. package/dist/instructions/rentals.md +75 -0
  9. package/dist/instructions/search.md +1 -2
  10. package/dist/instructions/versions/2.24.1/CHANGELOG.md +17 -0
  11. package/dist/instructions/versions/2.24.1/MIGRATION.md +9 -0
  12. package/dist/instructions/versions/2.25.0/CHANGELOG.md +41 -0
  13. package/dist/instructions/versions/2.25.0/MIGRATION.md +64 -0
  14. package/dist/{to-rental-highlights-C1NF2uuE.mjs → operations-DwURbo0b.mjs} +1 -626
  15. package/dist/{rentals-eqFhtCdT.mjs → rentals-Dn0-kGWD.mjs} +96 -33
  16. package/dist/{search-CKL-8T8q.mjs → search-BLTTQAsG.mjs} +4 -3
  17. package/dist/to-rental-highlights-BL5m3Uen.mjs +626 -0
  18. package/dist/translations/v9/de-DE/core.json +3 -1
  19. package/dist/translations/v9/en-US/core.json +3 -1
  20. package/dist/{v9-data-BnYxa2Ek.mjs → v9-data-C3SWtDGs.mjs} +7 -5
  21. package/instructions/CHANGELOG.md +2 -0
  22. package/instructions/MIGRATION.md +2 -0
  23. package/instructions/creation.md +5 -0
  24. package/instructions/rentals.md +75 -0
  25. package/instructions/search.md +1 -2
  26. package/instructions/versions/2.24.1/CHANGELOG.md +17 -0
  27. package/instructions/versions/2.24.1/MIGRATION.md +9 -0
  28. package/instructions/versions/2.24.1/release.json +3 -0
  29. package/instructions/versions/2.25.0/CHANGELOG.md +41 -0
  30. package/instructions/versions/2.25.0/MIGRATION.md +64 -0
  31. package/instructions/versions/2.25.0/release.json +3 -0
  32. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
- import { Wt as V9_FACILITY_ATTRIBUTE_KEYS } from "./client-DC4LG3CP.mjs";
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 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";
1
+ import { Gt as V9_FACILITY_ATTRIBUTE_KEYS } from "./client-0Lgv-Gb_.mjs";
2
+ import { i as VofficeUnitDataPropertyMetadata, l as parseVofficeUnitData, n as VofficeUnitDataPropertyCategoryLabelKeys, o as parseVofficeFacilityData, r as VofficeUnitDataPropertyCategoryValues, s as parseVofficeFeedbackData, t as VofficeUnitDataFieldSchemas } from "./v9-data-C3SWtDGs.mjs";
3
+ import { a as rentalsAllByFacilityObjectGroupsWithoutFeedbacksQuery, i as rentalIdsQuery, o as rentalsAllFeedbacksQuery, r as rentalFacilitiesForObjectGroupRelationQuery, s as rentalsAllWithoutFeedbacksQuery } from "./operations-DwURbo0b.mjs";
4
+ import { a as toFacilityImages, c as toLocalizedString, i as toLocation, o as toImages, r as renderVofficePropertyAttribute, s as toAddress, t as toRentalHighlights } from "./to-rental-highlights-BL5m3Uen.mjs";
4
5
  import { CoreSDKError, makeTranslate, renderResolvedCustomAttribute, toCustomAttributeList, toResolvedCustomAttributeCategoryTranslationKey } from "@v-office/sdk-core";
5
6
  import { Effect } from "effect";
6
7
  //#region src/legacy-v9/parser/rentals/to-description.ts
@@ -286,45 +287,106 @@ const toTravelDate = (locale, value) => {
286
287
  year: "numeric"
287
288
  }).format(new Date(value));
288
289
  };
289
- const toReviews = ({ locale, translations, rental }) => Effect.gen(function* () {
290
+ const toText = (value) => typeof value === "string" && value.trim().length > 0 ? value : void 0;
291
+ const toReviewText = ({ text, textCriteria }) => {
292
+ if (textCriteria.length === 0) return text;
293
+ return [...text === void 0 ? [] : [text], ...textCriteria.map((criterion) => `${criterion.label}\n${criterion.text}`)].join("\n\n");
294
+ };
295
+ const toCategories = ({ items, criteria, locale }) => criteria.flatMap((criterion) => {
296
+ if (criterion.type !== "stars") return [];
297
+ const ratings = items.flatMap((item) => {
298
+ const rating = item.criterionRatings.get(criterion.v9);
299
+ return rating === void 0 ? [] : [rating];
300
+ });
301
+ if (ratings.length === 0) return [];
302
+ return [{
303
+ label: criterion.label[locale],
304
+ rating: roundRatingUp(ratings.reduce((ratingSum, rating) => ratingSum + rating, 0) / ratings.length).toString()
305
+ }];
306
+ });
307
+ const toReviews = ({ locale, translations, rental, options }) => Effect.gen(function* () {
290
308
  const parsedItems = (yield* Effect.succeed(rental.voffice_feedbacks))?.flatMap((feedback) => {
291
- const { forename, surname, avgRating, text, highlighted, arrival, departure, onDate, onTimestamp } = parseVofficeFeedbackData(feedback.data).known;
292
- const author = [forename, surname].filter((value) => value != null && value !== "").join(" ");
293
- if (author === "" || avgRating == null || avgRating < 1 || text == null) return [];
309
+ const parsed = parseVofficeFeedbackData(feedback.data);
310
+ const { forename, city, avgRating, text, highlighted, arrival, departure, onDate, onTimestamp } = parsed.known;
311
+ const values = {
312
+ ...parsed.unknown,
313
+ ...parsed.known
314
+ };
315
+ const rating = avgRating != null && avgRating >= 1 ? roundRatingUp(avgRating) : void 0;
316
+ const reviewText = toReviewText({
317
+ text: toText(text),
318
+ textCriteria: options.criteria.flatMap((criterion) => {
319
+ if (criterion.type !== "text") return [];
320
+ const criterionText = toText(values[criterion.v9]);
321
+ return criterionText === void 0 ? [] : [{
322
+ label: criterion.label[locale],
323
+ text: criterionText
324
+ }];
325
+ })
326
+ });
327
+ if (rating === void 0 && !options.includeItemsWithoutRating) return [];
328
+ if (reviewText === void 0 && !options.includeItemsWithoutText) return [];
329
+ if (rating === void 0 && reviewText === void 0) return [];
330
+ const criterionRatings = new Map(options.criteria.flatMap((criterion) => {
331
+ const value = values[criterion.v9];
332
+ return criterion.type === "stars" && typeof value === "number" && value >= 1 && value <= 5 ? [[criterion.v9, value]] : [];
333
+ }));
294
334
  return [{
295
- rating: roundRatingUp(avgRating),
296
- author,
297
- text,
335
+ rating,
336
+ forename: toText(forename)?.trim(),
337
+ city: options.showAuthorCity ? toText(city)?.trim() : void 0,
338
+ text: reviewText,
298
339
  highlighted: highlighted === true,
299
- travelDate: toTravelDate(locale, arrival ?? departure ?? onDate ?? onTimestamp)
340
+ travelDate: toTravelDate(locale, arrival ?? departure ?? onDate ?? onTimestamp),
341
+ criterionRatings
300
342
  }];
301
343
  }) ?? [];
302
344
  if (parsedItems.length === 0) return void 0;
303
- const averageRating = parsedItems.reduce((ratingSum, item) => ratingSum + item.rating, 0) / parsedItems.length;
304
- const summaryRating = roundRatingUp(averageRating);
345
+ const guest = yield* translations.translate(locale, "reviews.item.guest");
346
+ const authorWithCityTemplate = yield* translations.translate(locale, "reviews.item.authorWithCity");
347
+ const authorTemplate = yield* translations.translate(locale, "reviews.item.author");
348
+ const authorWithDateTemplate = yield* translations.translate(locale, "reviews.item.authorWithDate");
349
+ const items = parsedItems.sort((left, right) => Number(right.highlighted) - Number(left.highlighted)).flatMap(({ rating, forename, city, text, travelDate }) => {
350
+ const author = city === void 0 ? forename ?? guest : renderTemplate(authorWithCityTemplate, {
351
+ author: forename ?? guest,
352
+ city
353
+ });
354
+ const shared = { author: travelDate == null ? renderTemplate(authorTemplate, { author }) : renderTemplate(authorWithDateTemplate, {
355
+ author,
356
+ date: travelDate
357
+ }) };
358
+ if (rating !== void 0) return [{
359
+ ...shared,
360
+ rating: rating.toString(),
361
+ ...text === void 0 ? {} : { text }
362
+ }];
363
+ return text === void 0 ? [] : [{
364
+ ...shared,
365
+ text
366
+ }];
367
+ });
368
+ const ratings = parsedItems.flatMap((item) => item.rating === void 0 ? [] : [item.rating]);
369
+ if (ratings.length === 0) return { items };
370
+ const summaryRating = roundRatingUp(ratings.reduce((ratingSum, rating) => ratingSum + rating, 0) / ratings.length);
305
371
  const summaryRatingTemplate = yield* translations.translate(locale, "reviews.summary.rating");
306
372
  const summaryCountTemplate = yield* translations.translate(locale, "reviews.summary.count");
307
373
  const classification = toClassification(summaryRating);
308
- const summary = {
309
- rating: renderTemplate(summaryRatingTemplate, {
310
- rating: summaryRating.toString(),
311
- maxRating: "5"
312
- }),
313
- count: renderTemplate(summaryCountTemplate, { count: parsedItems.length.toString() }),
314
- classification: yield* translations.translate(locale, `reviews.summary.classification.${classification}`)
315
- };
316
- const authorTemplate = yield* translations.translate(locale, "reviews.item.author");
317
- const authorWithDateTemplate = yield* translations.translate(locale, "reviews.item.authorWithDate");
374
+ const categories = toCategories({
375
+ items: parsedItems,
376
+ criteria: options.criteria,
377
+ locale
378
+ });
318
379
  return {
319
- items: parsedItems.sort((left, right) => Number(right.highlighted) - Number(left.highlighted)).map(({ highlighted: _highlighted, rating, author, travelDate, ...item }) => ({
320
- ...item,
321
- author: travelDate == null ? renderTemplate(authorTemplate, { author }) : renderTemplate(authorWithDateTemplate, {
322
- author,
323
- date: travelDate
380
+ items,
381
+ summary: {
382
+ rating: renderTemplate(summaryRatingTemplate, {
383
+ rating: summaryRating.toString(),
384
+ maxRating: "5"
324
385
  }),
325
- rating: rating.toString()
326
- })),
327
- summary
386
+ count: renderTemplate(summaryCountTemplate, { count: ratings.length.toString() }),
387
+ classification: yield* translations.translate(locale, `reviews.summary.classification.${classification}`),
388
+ ...categories.length === 0 ? {} : { categories }
389
+ }
328
390
  };
329
391
  });
330
392
  //#endregion
@@ -377,7 +439,7 @@ const toRooms = ({ locale, translations, roomDetails }) => Effect.gen(function*
377
439
  });
378
440
  //#endregion
379
441
  //#region src/legacy-v9/parser/rentals/to-rental-list-item.ts
380
- const toRentalRentalsOutput = ({ rental, locale, translations, imageProxyBaseUrl, rentalHighlightPrioritization, rentalPropertyHighlightPrioritization, customAttributes, v9PropertyHighlightSources }) => Effect.gen(function* () {
442
+ const toRentalRentalsOutput = ({ rental, locale, translations, imageProxyBaseUrl, rentalHighlightPrioritization, rentalPropertyHighlightPrioritization, customAttributes, v9PropertyHighlightSources, reviews: reviewsOptions }) => Effect.gen(function* () {
381
443
  const data = parseVofficeUnitData(rental.data);
382
444
  const rawRentalType = data.known.type?.trim();
383
445
  const translatedRentalType = rawRentalType != null && rawRentalType.length > 0 ? yield* toRentalType({
@@ -415,7 +477,8 @@ const toRentalRentalsOutput = ({ rental, locale, translations, imageProxyBaseUrl
415
477
  const reviews = yield* toReviews({
416
478
  locale,
417
479
  translations,
418
- rental
480
+ rental,
481
+ options: reviewsOptions
419
482
  });
420
483
  const item = {
421
484
  id: rental.voffice_id.toString(),
@@ -1,6 +1,7 @@
1
- import { a as parseQueryParameters, i as collectQueryParameters, n as makeV9CustomAttributeFilterCapabilities, o as toQueryString, r as toBasicQueryInputs, s as applyVofficeFilterDerivedBasicQueryInputs } from "./client-DC4LG3CP.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";
1
+ import { a as parseQueryParameters, i as collectQueryParameters, n as makeV9CustomAttributeFilterCapabilities, o as toQueryString, r as toBasicQueryInputs, s as applyVofficeFilterDerivedBasicQueryInputs } from "./client-0Lgv-Gb_.mjs";
2
+ import { l as parseVofficeUnitData } from "./v9-data-C3SWtDGs.mjs";
3
+ import { n as searchQuery, t as mapSearchQuery } from "./operations-DwURbo0b.mjs";
4
+ import { i as toLocation, n as toV9RentalHighlightKey, o as toImages, s as toAddress, t as toRentalHighlights } from "./to-rental-highlights-BL5m3Uen.mjs";
4
5
  import { CoreSDKError, STABLE_SEARCH_INPUTS, daysBetweenLocalDates, expandCustomAttributeFilterCompositions, parseChildrenAges, parseOccupancyCount, resolveExpandedCompositions, toFormattedSearchPrice, toIsoDateFromPeriodQueryDate, toStableSearchInputBackendQueryKeys, toStableSearchInputParameterValues, toStableSearchInputQueryKeys, toUnusedFilterKeys } from "@v-office/sdk-core";
5
6
  import { Effect } from "effect";
6
7
  //#region src/legacy-v9/parser/search/input/search-input-error.ts