@v-office/website-sdk 1.2.0 → 2.0.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 +91 -232
- package/dist/cli.mjs +102 -83
- package/dist/client-BSUd3vuc.mjs +5111 -0
- package/dist/index.d.mts +2463 -11751
- package/dist/index.mjs +16 -4
- package/dist/instructions/CHANGELOG.md +9 -0
- package/dist/instructions/MIGRATION.md +9 -0
- package/dist/instructions/README.md +62 -0
- package/dist/instructions/availability.md +157 -0
- package/dist/instructions/booking.md +165 -0
- package/dist/instructions/contact.md +92 -0
- package/dist/instructions/creation.md +223 -0
- package/dist/instructions/filter.md +156 -0
- package/dist/instructions/quote.md +318 -0
- package/dist/instructions/rentals.md +152 -0
- package/dist/instructions/search.md +233 -0
- package/dist/instructions/versions/2.0.0/CHANGELOG.md +69 -0
- package/dist/instructions/versions/2.0.0/MIGRATION.md +223 -0
- package/dist/{quote-Bo-gBDkQ.mjs → quote-1uEIO44v.mjs} +15 -16
- package/dist/{rentals-Ba6ZO6bX.mjs → rentals-Quwc78o2.mjs} +22 -138
- package/dist/{search-BofxXqF0.mjs → search-GRQeXDvo.mjs} +43 -24
- package/dist/to-rental-highlights-FNZBR4aD.mjs +5905 -0
- package/instructions/CHANGELOG.md +9 -0
- package/instructions/MIGRATION.md +9 -0
- package/instructions/README.md +62 -0
- package/instructions/availability.md +157 -0
- package/instructions/booking.md +165 -0
- package/instructions/contact.md +92 -0
- package/instructions/creation.md +223 -0
- package/instructions/filter.md +156 -0
- package/instructions/quote.md +318 -0
- package/instructions/rentals.md +152 -0
- package/instructions/search.md +233 -0
- package/instructions/versions/2.0.0/CHANGELOG.md +69 -0
- package/instructions/versions/2.0.0/MIGRATION.md +223 -0
- package/package.json +41 -56
- package/dist/client-DYP0Y59i.mjs +0 -33236
- package/dist/custom-attribute-D5Kb1YHA.mjs +0 -54
- package/dist/errors-2cuUGSvi.mjs +0 -5
- package/dist/operations-B4IgNB3E.mjs +0 -12618
- package/dist/operations-Bxhb0jmN.mjs +0 -1085
- package/dist/quote-BKcAIFuH.mjs +0 -513
- package/dist/quote-CRjV_lf-.mjs +0 -609
- package/dist/rentals-DBTPlC6X.mjs +0 -323
- package/dist/search-filter-metadata-DZP0-Udc.mjs +0 -4294
- package/dist/to-rental-highlights-BShYK50C.mjs +0 -402
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { d as formatCurrency, g as toNightCount, n as addGuestQuoteAdditionalServiceSelection, t as GuestQuote } from "./quote-CRjV_lf-.mjs";
|
|
1
|
+
import { GuestQuote, addGuestQuoteAdditionalServiceSelection, formatCurrency, toNightCount } from "@v-office/sdk-core";
|
|
3
2
|
import { DateTime, Effect } from "effect";
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/legacy-v9/parser/quote/to-additional-service-calculation.ts
|
|
5
4
|
const toAdditionalServiceCalculation = (line) => {
|
|
6
5
|
switch (line.calculation) {
|
|
7
6
|
case "NIGHT": return "PER_NIGHT";
|
|
@@ -12,7 +11,7 @@ const toAdditionalServiceCalculation = (line) => {
|
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
13
|
//#endregion
|
|
15
|
-
//#region src/
|
|
14
|
+
//#region src/legacy-v9/parser/quote/to-charge.ts
|
|
16
15
|
const toCharge = ({ serviceLine, chargeAmount, currency, locale, translations }) => Effect.gen(function* () {
|
|
17
16
|
switch (serviceLine.calculation) {
|
|
18
17
|
case "NIGHT": return `${formatCurrency(chargeAmount, locale, currency)}${yield* translations.translate(locale, "quote.additionalService.night")}`;
|
|
@@ -21,26 +20,26 @@ const toCharge = ({ serviceLine, chargeAmount, currency, locale, translations })
|
|
|
21
20
|
}
|
|
22
21
|
});
|
|
23
22
|
//#endregion
|
|
24
|
-
//#region src/
|
|
23
|
+
//#region src/legacy-v9/parser/quote/to-charge-amount.ts
|
|
25
24
|
const toChargeAmount = ({ input, serviceLine }) => {
|
|
26
25
|
const amount = serviceLine.amount ?? 1;
|
|
27
26
|
if (amount <= 0 || serviceLine.total == null) return void 0;
|
|
28
27
|
switch (serviceLine.calculation) {
|
|
29
|
-
case "NIGHT": return serviceLine.total / toNightCount(input) / amount;
|
|
30
|
-
case "DAY": return serviceLine.total / toNightCount(input) / amount;
|
|
28
|
+
case "NIGHT": return serviceLine.total / toNightCount(input.period) / amount;
|
|
29
|
+
case "DAY": return serviceLine.total / toNightCount(input.period) / amount;
|
|
31
30
|
case "USAGE": return serviceLine.total / amount;
|
|
32
31
|
default: return serviceLine.total / amount;
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
//#endregion
|
|
36
|
-
//#region src/
|
|
35
|
+
//#region src/legacy-v9/parser/quote/to-service-line-label.ts
|
|
37
36
|
const toServiceLineLabel = ({ serviceLine, locale, translations }) => Effect.gen(function* () {
|
|
38
37
|
if (serviceLine.service?.name != null && serviceLine.service.name.trim().length > 0) return serviceLine.service.name;
|
|
39
38
|
if (serviceLine.service?.type != null && serviceLine.service.type.trim().length > 0) return yield* translations.translate(locale, `Service.type.${serviceLine.service.type}`);
|
|
40
39
|
return yield* translations.translate(locale, "Service.type.OTHER");
|
|
41
40
|
});
|
|
42
41
|
//#endregion
|
|
43
|
-
//#region src/
|
|
42
|
+
//#region src/legacy-v9/parser/quote/utils.ts
|
|
44
43
|
const hasEnoughLeadTime = ({ bookingStart, leadTimeDays, today }) => {
|
|
45
44
|
if (leadTimeDays == null) return true;
|
|
46
45
|
const start = DateTime.removeTime(DateTime.makeUnsafe(bookingStart));
|
|
@@ -51,7 +50,7 @@ const getLineServiceId = (line) => line.service?.id == null ? void 0 : String(li
|
|
|
51
50
|
const isTaxLine = (line) => line.service?.type === "VTAX" || line.service?.type === "TAXES";
|
|
52
51
|
const getTotal = (line) => line.total ?? 0;
|
|
53
52
|
//#endregion
|
|
54
|
-
//#region src/
|
|
53
|
+
//#region src/legacy-v9/parser/quote/to-additional-services.ts
|
|
55
54
|
const toDescription = (line) => {
|
|
56
55
|
if (Array.isArray(line.beon_data)) return void 0;
|
|
57
56
|
return line.beon_data?.description;
|
|
@@ -120,7 +119,7 @@ const toAdditionalServices = ({ input, guestQuoteResult, locale, translations })
|
|
|
120
119
|
return additionalServices;
|
|
121
120
|
});
|
|
122
121
|
//#endregion
|
|
123
|
-
//#region src/
|
|
122
|
+
//#region src/legacy-v9/parser/quote/to-backend-context.ts
|
|
124
123
|
const toSelectionQuantity = (selections, serviceId) => selections.find((selection) => selection.id === serviceId)?.quantity ?? 0;
|
|
125
124
|
const toSelectedTotal = (line, amount) => {
|
|
126
125
|
if (line.price == null) return void 0;
|
|
@@ -164,7 +163,7 @@ const updateV9QuoteBackendContext = (context, selections) => {
|
|
|
164
163
|
};
|
|
165
164
|
};
|
|
166
165
|
//#endregion
|
|
167
|
-
//#region src/
|
|
166
|
+
//#region src/legacy-v9/parser/quote/to-sections-included.ts
|
|
168
167
|
const isIncludedSubItem = (line) => line.service?.type === "RENT" || line.service?.summary === "SHOW";
|
|
169
168
|
const toSectionsIncluded = ({ input: _input, guestQuoteResult, locale, translations }) => Effect.gen(function* () {
|
|
170
169
|
const subItems = [];
|
|
@@ -193,7 +192,7 @@ const toSectionsIncluded = ({ input: _input, guestQuoteResult, locale, translati
|
|
|
193
192
|
};
|
|
194
193
|
});
|
|
195
194
|
//#endregion
|
|
196
|
-
//#region src/
|
|
195
|
+
//#region src/legacy-v9/parser/quote/to-sections-other.ts
|
|
197
196
|
const isOther = (line) => line.service?.type !== "RENT" && !isTaxLine(line) && line.service?.summary !== "ADD_NO_SHOW";
|
|
198
197
|
const toSectionsOther = ({ input: _input, guestQuoteResult, locale, translations }) => Effect.gen(function* () {
|
|
199
198
|
const lines = [];
|
|
@@ -212,7 +211,7 @@ const toSectionsOther = ({ input: _input, guestQuoteResult, locale, translations
|
|
|
212
211
|
return lines;
|
|
213
212
|
});
|
|
214
213
|
//#endregion
|
|
215
|
-
//#region src/
|
|
214
|
+
//#region src/legacy-v9/parser/quote/to-sections-tax.ts
|
|
216
215
|
const toSectionsTax = ({ input: _input, guestQuoteResult, locale, translations }) => Effect.gen(function* () {
|
|
217
216
|
let total = 0;
|
|
218
217
|
for (const line of guestQuoteResult?.mandatory ?? []) if (isTaxLine(line)) total += getTotal(line);
|
|
@@ -222,7 +221,7 @@ const toSectionsTax = ({ input: _input, guestQuoteResult, locale, translations }
|
|
|
222
221
|
} };
|
|
223
222
|
});
|
|
224
223
|
//#endregion
|
|
225
|
-
//#region src/
|
|
224
|
+
//#region src/legacy-v9/parser/quote/to-sections.ts
|
|
226
225
|
const hasSectionLineContent = (line) => line.item.appliedCharge !== 0 || (line.subItems?.length ?? 0) > 0;
|
|
227
226
|
const toSections = ({ input, guestQuoteResult, locale, translations }) => Effect.gen(function* () {
|
|
228
227
|
const sections = [];
|
|
@@ -250,7 +249,7 @@ const toSections = ({ input, guestQuoteResult, locale, translations }) => Effect
|
|
|
250
249
|
return sections;
|
|
251
250
|
});
|
|
252
251
|
//#endregion
|
|
253
|
-
//#region src/
|
|
252
|
+
//#region src/legacy-v9/parser/quote/to-guest-quote.ts
|
|
254
253
|
const toBaseTotal = (guestQuoteResult) => {
|
|
255
254
|
const paymentScheduleTotal = guestQuoteResult?.paymentSchedule?.total?.amount;
|
|
256
255
|
if (paymentScheduleTotal != null) return paymentScheduleTotal;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import { b as localeToLanguage, y as makeTranslate } from "./quote-CRjV_lf-.mjs";
|
|
4
|
-
import { i as renderLabeledAttributeValue, t as renderCustomAttributeHighlight } from "./custom-attribute-D5Kb1YHA.mjs";
|
|
5
|
-
import { n as toAddress, r as toLocalizedString, t as toRentalHighlights } from "./to-rental-highlights-BShYK50C.mjs";
|
|
1
|
+
import { c as VofficeUnitDataFieldSchemas, d as VofficeUnitDataPropertyMetadata, f as parseVofficeFacilityData, i as toLocalizedString, l as VofficeUnitDataPropertyCategoryLabelKeys, m as parseVofficeUnitData, n as toImages, o as rentalsAllFeedbacksQuery, p as parseVofficeFeedbackData, r as toAddress, s as rentalsAllWithoutFeedbacksQuery, t as toRentalHighlights, u as VofficeUnitDataPropertyCategoryValues } from "./to-rental-highlights-FNZBR4aD.mjs";
|
|
2
|
+
import { makeTranslate, renderCustomAttributeHighlight, renderLabeledAttributeValue } from "@v-office/sdk-core";
|
|
6
3
|
import { Effect } from "effect";
|
|
7
|
-
//#region src/
|
|
4
|
+
//#region src/legacy-v9/parser/rentals/to-description.ts
|
|
8
5
|
const toDescription = (data, locale) => {
|
|
9
6
|
const description = {};
|
|
10
7
|
const intro = toLocalizedString(data.known.intro, locale);
|
|
@@ -26,129 +23,7 @@ const toDescription = (data, locale) => {
|
|
|
26
23
|
return description;
|
|
27
24
|
};
|
|
28
25
|
//#endregion
|
|
29
|
-
//#region src/
|
|
30
|
-
const IMAGE_ASPECT_RATIO = 3 / 2;
|
|
31
|
-
const IMAGE_SRCSET_WIDTHS = [
|
|
32
|
-
320,
|
|
33
|
-
480,
|
|
34
|
-
640,
|
|
35
|
-
960,
|
|
36
|
-
1280,
|
|
37
|
-
1920,
|
|
38
|
-
2560
|
|
39
|
-
];
|
|
40
|
-
const IMAGE_DEFAULT_WIDTH = 960;
|
|
41
|
-
const buildImageUrl = (imageProxyBaseUrl, path, width) => {
|
|
42
|
-
const base = imageProxyBaseUrl.replace(/\/$/, "");
|
|
43
|
-
const normalizedPath = path.replace(/^\/+/, "");
|
|
44
|
-
return `${base}/_/rs:fill:${width}:${Math.round(width / IMAGE_ASPECT_RATIO)}:0/plain/${normalizedPath}`;
|
|
45
|
-
};
|
|
46
|
-
const buildSrcset = (imageProxyBaseUrl, path) => IMAGE_SRCSET_WIDTHS.map((width) => `${buildImageUrl(imageProxyBaseUrl, path, width)} ${width}w`).join(", ");
|
|
47
|
-
const isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
48
|
-
const toDataImageId = (dataImage) => dataImage?.id?.toString();
|
|
49
|
-
const getImagePath = (entry) => entry.image?.path ?? entry.normalizedPath;
|
|
50
|
-
const getFileName = (path) => path?.split("/").at(-1);
|
|
51
|
-
const getDirectoryName = (path) => {
|
|
52
|
-
const lastSlashIndex = path.lastIndexOf("/");
|
|
53
|
-
return lastSlashIndex === -1 ? void 0 : path.slice(0, lastSlashIndex);
|
|
54
|
-
};
|
|
55
|
-
const stripDataImageFilePrefix = (fileName) => fileName.replace(/^mf(?=\d)/i, "");
|
|
56
|
-
const getDataImageFileName = (dataImage) => {
|
|
57
|
-
const name = dataImage.name != null ? stripDataImageFilePrefix(dataImage.name) : void 0;
|
|
58
|
-
if (name != null) return name;
|
|
59
|
-
return dataImage.id != null ? `${dataImage.id}.jpg` : void 0;
|
|
60
|
-
};
|
|
61
|
-
const normalizeDataImagePath = (dataImage, vofficeImages) => {
|
|
62
|
-
const fileName = getDataImageFileName(dataImage);
|
|
63
|
-
if (fileName == null) return void 0;
|
|
64
|
-
const matchingPath = vofficeImages.find((image) => getFileName(image.path ?? void 0) === fileName)?.path;
|
|
65
|
-
if (matchingPath != null) return matchingPath;
|
|
66
|
-
const directoryName = vofficeImages.map((image) => image.path != null ? getDirectoryName(image.path) : void 0).find((path) => path != null);
|
|
67
|
-
return directoryName != null ? `${directoryName}/${fileName}` : void 0;
|
|
68
|
-
};
|
|
69
|
-
const pathMatchesName = (path, name) => path != null && name != null && (path === name || path.endsWith(`/${name}`));
|
|
70
|
-
const entriesShareId = (left, right) => {
|
|
71
|
-
const leftIds = [left.image?.id, toDataImageId(left.dataImage)].filter(isNonEmptyString);
|
|
72
|
-
const rightIds = [right.image?.id, toDataImageId(right.dataImage)].filter(isNonEmptyString);
|
|
73
|
-
return leftIds.some((leftId) => rightIds.includes(leftId));
|
|
74
|
-
};
|
|
75
|
-
const entriesSharePathOrName = (left, right) => {
|
|
76
|
-
const leftPath = getImagePath(left);
|
|
77
|
-
const rightPath = getImagePath(right);
|
|
78
|
-
const leftName = left.dataImage != null ? getDataImageFileName(left.dataImage) : getFileName(left.image?.path ?? void 0);
|
|
79
|
-
const rightName = right.dataImage != null ? getDataImageFileName(right.dataImage) : getFileName(right.image?.path ?? void 0);
|
|
80
|
-
return leftPath != null && rightPath != null && leftPath === rightPath || pathMatchesName(leftPath, rightName) || pathMatchesName(rightPath, leftName);
|
|
81
|
-
};
|
|
82
|
-
const entriesMatch = (left, right) => entriesShareId(left, right) || entriesSharePathOrName(left, right);
|
|
83
|
-
const mergeEntry = (existing, next) => {
|
|
84
|
-
const image = existing.image ?? next.image;
|
|
85
|
-
const dataImage = existing.dataImage ?? next.dataImage;
|
|
86
|
-
const normalizedPath = existing.normalizedPath ?? next.normalizedPath;
|
|
87
|
-
const entry = { source: existing.source };
|
|
88
|
-
if (image != null) entry.image = image;
|
|
89
|
-
if (dataImage != null) entry.dataImage = dataImage;
|
|
90
|
-
if (normalizedPath != null) entry.normalizedPath = normalizedPath;
|
|
91
|
-
return entry;
|
|
92
|
-
};
|
|
93
|
-
const mergeImageEntries = (entries) => {
|
|
94
|
-
const merged = [];
|
|
95
|
-
for (const entry of entries) {
|
|
96
|
-
const index = merged.findIndex((existing) => entriesMatch(existing, entry));
|
|
97
|
-
if (index === -1) {
|
|
98
|
-
merged.push(entry);
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
merged[index] = mergeEntry(merged[index], entry);
|
|
102
|
-
}
|
|
103
|
-
return merged;
|
|
104
|
-
};
|
|
105
|
-
const getImageEntries = (rental, data) => {
|
|
106
|
-
const vofficeImages = rental.voffice_images ?? [];
|
|
107
|
-
return [
|
|
108
|
-
...vofficeImages.map((image) => ({
|
|
109
|
-
source: "voffice_images",
|
|
110
|
-
image
|
|
111
|
-
})),
|
|
112
|
-
...(rental.voffice_room_images ?? []).map((image) => ({
|
|
113
|
-
source: "voffice_room_images",
|
|
114
|
-
image
|
|
115
|
-
})),
|
|
116
|
-
...(data.known.images ?? []).flatMap((dataImage) => {
|
|
117
|
-
const normalizedPath = normalizeDataImagePath(dataImage, vofficeImages);
|
|
118
|
-
if (normalizedPath == null) return [];
|
|
119
|
-
return [{
|
|
120
|
-
source: "data_images",
|
|
121
|
-
dataImage,
|
|
122
|
-
normalizedPath
|
|
123
|
-
}];
|
|
124
|
-
})
|
|
125
|
-
];
|
|
126
|
-
};
|
|
127
|
-
const toImage = (imageProxyBaseUrl, entry, locale) => {
|
|
128
|
-
const path = getImagePath(entry);
|
|
129
|
-
const src = path != null ? buildImageUrl(imageProxyBaseUrl, path, IMAGE_DEFAULT_WIDTH) : "";
|
|
130
|
-
const srcset = path != null ? buildSrcset(imageProxyBaseUrl, path) : "";
|
|
131
|
-
const title = toLocalizedString(entry.dataImage?.titles, locale) ?? entry.image?.title;
|
|
132
|
-
const alt = title ?? entry.image?.description ?? "";
|
|
133
|
-
const metadata = { source: entry.source };
|
|
134
|
-
if (entry.dataImage != null) metadata.dataImage = entry.dataImage;
|
|
135
|
-
const image = {
|
|
136
|
-
idOrPath: path ?? toDataImageId(entry.dataImage) ?? entry.dataImage?.name ?? "",
|
|
137
|
-
src,
|
|
138
|
-
srcset,
|
|
139
|
-
alt,
|
|
140
|
-
metadata
|
|
141
|
-
};
|
|
142
|
-
if (title != null) image.title = title;
|
|
143
|
-
if (entry.dataImage?.tag != null) image.category = entry.dataImage.tag;
|
|
144
|
-
return image;
|
|
145
|
-
};
|
|
146
|
-
const toImages = (imageProxyBaseUrl, rental, locale, data) => {
|
|
147
|
-
if (rental.voffice_images == null || rental.voffice_images.length === 0) return [];
|
|
148
|
-
return mergeImageEntries(getImageEntries(rental, data)).map((entry) => toImage(imageProxyBaseUrl, entry, locale));
|
|
149
|
-
};
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/adapters/v9/parser/rentals/to-location.ts
|
|
26
|
+
//#region src/legacy-v9/parser/rentals/to-location.ts
|
|
152
27
|
const toLocation = (location) => {
|
|
153
28
|
if (location == null) return void 0;
|
|
154
29
|
const [longitude, latitude] = location.coordinates;
|
|
@@ -158,7 +33,7 @@ const toLocation = (location) => {
|
|
|
158
33
|
};
|
|
159
34
|
};
|
|
160
35
|
//#endregion
|
|
161
|
-
//#region src/
|
|
36
|
+
//#region src/legacy-v9/parser/rentals/to-property.ts
|
|
162
37
|
const toProperty = (facility, locale) => {
|
|
163
38
|
const data = parseVofficeFacilityData(facility.data);
|
|
164
39
|
const name = toLocalizedString(data.known.name, locale);
|
|
@@ -171,7 +46,7 @@ const toProperty = (facility, locale) => {
|
|
|
171
46
|
return property;
|
|
172
47
|
};
|
|
173
48
|
//#endregion
|
|
174
|
-
//#region src/
|
|
49
|
+
//#region src/legacy-v9/parser/rentals/to-rental-attributes.ts
|
|
175
50
|
const GENERAL_CATEGORY$1 = {
|
|
176
51
|
key: "GENERAL",
|
|
177
52
|
labelKey: VofficeUnitDataPropertyCategoryLabelKeys.GENERAL
|
|
@@ -184,6 +59,7 @@ const PROPERTY_METADATA_ENTRIES = Object.entries(VofficeUnitDataPropertyMetadata
|
|
|
184
59
|
})).filter(({ metadata }) => metadata.category.key !== "LOCATION").sort((left, right) => {
|
|
185
60
|
return (CATEGORY_ORDER.get(left.metadata.category.key) ?? Number.MAX_SAFE_INTEGER) - (CATEGORY_ORDER.get(right.metadata.category.key) ?? Number.MAX_SAFE_INTEGER) || left.index - right.index;
|
|
186
61
|
});
|
|
62
|
+
const canRenderLabeledAttributeValue$1 = (value) => value !== false && value !== 0 && value !== "false" && value !== "0" && value != null && value !== "";
|
|
187
63
|
const toRentalAttributes = ({ locale, translations, attributes, customAttributeFilterDefinitions }) => Effect.gen(function* () {
|
|
188
64
|
const result = [];
|
|
189
65
|
const categoriesByKey = /* @__PURE__ */ new Map();
|
|
@@ -212,11 +88,13 @@ const toRentalAttributes = ({ locale, translations, attributes, customAttributeF
|
|
|
212
88
|
return subCategory;
|
|
213
89
|
});
|
|
214
90
|
for (const { key, metadata } of PROPERTY_METADATA_ENTRIES) {
|
|
91
|
+
const value = knownAttributes[key];
|
|
92
|
+
if (!canRenderLabeledAttributeValue$1(value)) continue;
|
|
215
93
|
const attribute = renderLabeledAttributeValue({
|
|
216
94
|
key,
|
|
217
95
|
label: yield* translate(metadata.labelKey, key),
|
|
218
96
|
locale,
|
|
219
|
-
value
|
|
97
|
+
value
|
|
220
98
|
});
|
|
221
99
|
if (attribute == null) continue;
|
|
222
100
|
const categoryMetadata = metadata.category ?? GENERAL_CATEGORY$1;
|
|
@@ -255,10 +133,10 @@ const toRentalAttributes = ({ locale, translations, attributes, customAttributeF
|
|
|
255
133
|
return result;
|
|
256
134
|
});
|
|
257
135
|
//#endregion
|
|
258
|
-
//#region src/
|
|
136
|
+
//#region src/legacy-v9/parser/rentals/to-rental-type.ts
|
|
259
137
|
const toRentalType = ({ translations, locale, rentalType }) => makeTranslate(translations, locale)(`Rental.rentalType.option.${rentalType}`, rentalType);
|
|
260
138
|
//#endregion
|
|
261
|
-
//#region src/
|
|
139
|
+
//#region src/legacy-v9/parser/rentals/to-rental-vicinity.ts
|
|
262
140
|
const GENERAL_CATEGORY = {
|
|
263
141
|
key: "GENERAL",
|
|
264
142
|
labelKey: VofficeUnitDataPropertyCategoryLabelKeys.GENERAL
|
|
@@ -268,16 +146,19 @@ const LOCATION_METADATA_ENTRIES = Object.entries(VofficeUnitDataPropertyMetadata
|
|
|
268
146
|
metadata,
|
|
269
147
|
index
|
|
270
148
|
})).filter(({ metadata }) => metadata.category.key === "LOCATION").sort((left, right) => left.index - right.index);
|
|
149
|
+
const canRenderLabeledAttributeValue = (value) => value !== false && value !== 0 && value !== "false" && value !== "0" && value != null && value !== "";
|
|
271
150
|
const toRentalVicinity = ({ locale, translations, attributes }) => Effect.gen(function* () {
|
|
272
151
|
const items = [];
|
|
273
152
|
const knownAttributes = attributes.known;
|
|
274
153
|
const translate = makeTranslate(translations, locale);
|
|
275
154
|
for (const { key, metadata } of LOCATION_METADATA_ENTRIES) {
|
|
155
|
+
const value = knownAttributes[key];
|
|
156
|
+
if (!canRenderLabeledAttributeValue(value)) continue;
|
|
276
157
|
const item = renderLabeledAttributeValue({
|
|
277
158
|
key,
|
|
278
159
|
label: yield* translate(metadata.labelKey, key),
|
|
279
160
|
locale,
|
|
280
|
-
value
|
|
161
|
+
value
|
|
281
162
|
});
|
|
282
163
|
if (item != null) items.push(item);
|
|
283
164
|
}
|
|
@@ -288,7 +169,7 @@ const toRentalVicinity = ({ locale, translations, attributes }) => Effect.gen(fu
|
|
|
288
169
|
}];
|
|
289
170
|
});
|
|
290
171
|
//#endregion
|
|
291
|
-
//#region src/
|
|
172
|
+
//#region src/legacy-v9/parser/rentals/to-reviews.ts
|
|
292
173
|
const toClassification = (rating) => {
|
|
293
174
|
if (rating >= 4.5) return "excellent";
|
|
294
175
|
if (rating >= 4) return "very-good";
|
|
@@ -346,7 +227,7 @@ const toReviews = ({ locale, translations, rental }) => Effect.gen(function* ()
|
|
|
346
227
|
};
|
|
347
228
|
});
|
|
348
229
|
//#endregion
|
|
349
|
-
//#region src/
|
|
230
|
+
//#region src/legacy-v9/parser/rentals/to-rental-list-item.ts
|
|
350
231
|
const toRentalRentalsOutput = ({ rental, locale, translations, imageProxyBaseUrl, rentalHighlightPrioritization, customAttributeFilterDefinitions }) => Effect.gen(function* () {
|
|
351
232
|
const data = parseVofficeUnitData(rental.data);
|
|
352
233
|
const rawRentalType = data.known.type?.trim();
|
|
@@ -400,4 +281,7 @@ const toRentalRentalsOutput = ({ rental, locale, translations, imageProxyBaseUrl
|
|
|
400
281
|
return item;
|
|
401
282
|
});
|
|
402
283
|
//#endregion
|
|
403
|
-
|
|
284
|
+
//#region src/legacy-v9/runtime/rentals.ts
|
|
285
|
+
const defaultRentalDataAttributes = Object.keys(VofficeUnitDataFieldSchemas);
|
|
286
|
+
//#endregion
|
|
287
|
+
export { defaultRentalDataAttributes, rentalsAllFeedbacksQuery, rentalsAllWithoutFeedbacksQuery, toRentalRentalsOutput };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { n as toAddress, t as toRentalHighlights } from "./to-rental-highlights-BShYK50C.mjs";
|
|
1
|
+
import { n as stable_filters_default } from "./client-BSUd3vuc.mjs";
|
|
2
|
+
import { a as searchQuery, c as VofficeUnitDataFieldSchemas, m as parseVofficeUnitData, n as toImages, r as toAddress, t as toRentalHighlights } from "./to-rental-highlights-FNZBR4aD.mjs";
|
|
3
|
+
import { CoreSDKError, STABLE_SEARCH_INPUTS, collectQueryParameters, daysBetweenLocalDates, expandCustomAttributeFilterCompositions, parseChildrenAges, parseOccupancyCount, parseQueryParameters, toCustomAttributeFilterLabel, toFormattedSearchPrice, toIsoDateFromPeriodQueryDate, toQueryString, toStableSearchInputBackendQueryKeys, toStableSearchInputParameterValues, toStableSearchInputQueryKeys, toUnusedFilterKeys } from "@v-office/sdk-core";
|
|
5
4
|
import { Effect } from "effect";
|
|
6
|
-
//#region src/
|
|
5
|
+
//#region src/legacy-v9/parser/search/input/filter/apply-voffice-filter-derived-basic-query-inputs.ts
|
|
7
6
|
const hasBasicQueryInput = ({ basicQueryInputs, key }) => basicQueryInputs.some((input) => input.key === key);
|
|
8
7
|
const derivedBooleanFilters = [{
|
|
9
8
|
key: "pets",
|
|
@@ -32,10 +31,10 @@ const applyVofficeFilterDerivedBasicQueryInputs = ({ appliedFilters, basicQueryI
|
|
|
32
31
|
};
|
|
33
32
|
});
|
|
34
33
|
//#endregion
|
|
35
|
-
//#region src/
|
|
34
|
+
//#region src/legacy-v9/parser/search/input/filter/filter-query-keys.ts
|
|
36
35
|
const FILTER_QUERY_KEYS = new Set(Object.keys(stable_filters_default));
|
|
37
36
|
//#endregion
|
|
38
|
-
//#region src/
|
|
37
|
+
//#region src/legacy-v9/parser/search/input/filter/to-basic-query-inputs.ts
|
|
39
38
|
const isEnabledBooleanFilter = (value) => {
|
|
40
39
|
const normalizedValue = value.toLowerCase();
|
|
41
40
|
return normalizedValue === "" || normalizedValue === "true" || normalizedValue === "1";
|
|
@@ -129,10 +128,10 @@ const toBasicQueryInputs = ({ query, customAttributeFilterDefinitions, locale, t
|
|
|
129
128
|
};
|
|
130
129
|
};
|
|
131
130
|
//#endregion
|
|
132
|
-
//#region src/
|
|
131
|
+
//#region src/legacy-v9/parser/search/input/occupancy/occupancy-query-keys.ts
|
|
133
132
|
const OCCUPANCY_QUERY_KEYS = toStableSearchInputQueryKeys(STABLE_SEARCH_INPUTS.occupancy);
|
|
134
133
|
//#endregion
|
|
135
|
-
//#region src/
|
|
134
|
+
//#region src/legacy-v9/parser/search/input/occupancy/collect-occupancy-query-parameters.ts
|
|
136
135
|
const hasOccupancyInput = (query) => parseQueryParameters(query).some(([key]) => OCCUPANCY_QUERY_KEYS.has(key));
|
|
137
136
|
const collectOccupancyQueryParameters = ({ query }) => {
|
|
138
137
|
const { matchingParameters, remainingParameters } = collectQueryParameters({
|
|
@@ -145,7 +144,7 @@ const collectOccupancyQueryParameters = ({ query }) => {
|
|
|
145
144
|
};
|
|
146
145
|
};
|
|
147
146
|
//#endregion
|
|
148
|
-
//#region src/
|
|
147
|
+
//#region src/legacy-v9/parser/search/input/occupancy/to-occupancy-input.ts
|
|
149
148
|
const parseStableOccupancyCount = ({ key, occupancyParameters }) => Effect.gen(function* () {
|
|
150
149
|
const values = toStableSearchInputParameterValues({
|
|
151
150
|
key,
|
|
@@ -185,20 +184,20 @@ const toOccupancyInput = ({ query }) => Effect.gen(function* () {
|
|
|
185
184
|
};
|
|
186
185
|
});
|
|
187
186
|
//#endregion
|
|
188
|
-
//#region src/
|
|
189
|
-
const failInvalidV9SearchInput = (message) => Effect.fail(new
|
|
190
|
-
|
|
191
|
-
operation: "search",
|
|
187
|
+
//#region src/legacy-v9/parser/search/input/search-input-error.ts
|
|
188
|
+
const failInvalidV9SearchInput = (message) => Effect.fail(new CoreSDKError({
|
|
189
|
+
source: "v10",
|
|
190
|
+
operation: "v9.search",
|
|
192
191
|
message
|
|
193
192
|
}));
|
|
194
193
|
//#endregion
|
|
195
|
-
//#region src/
|
|
194
|
+
//#region src/legacy-v9/parser/search/input/period/period-query-keys.ts
|
|
196
195
|
const PERIOD_QUERY_KEYS = toStableSearchInputBackendQueryKeys({
|
|
197
196
|
backend: "v9",
|
|
198
197
|
group: STABLE_SEARCH_INPUTS.period
|
|
199
198
|
});
|
|
200
199
|
//#endregion
|
|
201
|
-
//#region src/
|
|
200
|
+
//#region src/legacy-v9/parser/search/input/period/collect-period-query-parameters.ts
|
|
202
201
|
const hasPeriodInput = (query) => parseQueryParameters(query).some(([key]) => PERIOD_QUERY_KEYS.has(key));
|
|
203
202
|
const collectPeriodQueryParameters = ({ query }) => {
|
|
204
203
|
const { matchingParameters, remainingParameters } = collectQueryParameters({
|
|
@@ -211,7 +210,7 @@ const collectPeriodQueryParameters = ({ query }) => {
|
|
|
211
210
|
};
|
|
212
211
|
};
|
|
213
212
|
//#endregion
|
|
214
|
-
//#region src/
|
|
213
|
+
//#region src/legacy-v9/parser/search/input/period/to-period-input.ts
|
|
215
214
|
const parseScalarParameter = ({ key, values }) => {
|
|
216
215
|
if (values.length > 1) return failInvalidV9SearchInput(`Expected at most one "${key}" query parameter.`);
|
|
217
216
|
return Effect.succeed(values[0]);
|
|
@@ -284,7 +283,7 @@ const toPeriodInput = ({ query }) => Effect.gen(function* () {
|
|
|
284
283
|
};
|
|
285
284
|
});
|
|
286
285
|
//#endregion
|
|
287
|
-
//#region src/
|
|
286
|
+
//#region src/legacy-v9/parser/search/input/to-query-input.ts
|
|
288
287
|
const toQueryInput = ({ query, customAttributeFilterDefinitions, locale, translations }) => Effect.gen(function* () {
|
|
289
288
|
const compositionResult = expandCustomAttributeFilterCompositions({
|
|
290
289
|
customAttributeFilterDefinitions,
|
|
@@ -325,19 +324,19 @@ const toQueryInput = ({ query, customAttributeFilterDefinitions, locale, transla
|
|
|
325
324
|
};
|
|
326
325
|
});
|
|
327
326
|
//#endregion
|
|
328
|
-
//#region src/
|
|
329
|
-
const DEFAULT_V9_SEARCH_CURRENCY = "EUR";
|
|
327
|
+
//#region src/legacy-v9/parser/search/output/to-formatted-price.ts
|
|
328
|
+
const DEFAULT_V9_SEARCH_CURRENCY$1 = "EUR";
|
|
330
329
|
const toFormattedPrice = ({ locale, calc }) => {
|
|
331
330
|
if (calc?.total == null) return Effect.succeed(null);
|
|
332
331
|
return Effect.succeed(toFormattedSearchPrice({
|
|
333
332
|
amount: calc.total,
|
|
334
|
-
currency: DEFAULT_V9_SEARCH_CURRENCY,
|
|
333
|
+
currency: DEFAULT_V9_SEARCH_CURRENCY$1,
|
|
335
334
|
locale
|
|
336
335
|
}));
|
|
337
336
|
};
|
|
338
337
|
//#endregion
|
|
339
|
-
//#region src/
|
|
340
|
-
const toSearchOutputItem = ({ locale, rentalHighlightPrioritization, customAttributeFilterDefinitions, rental, translations, includeFormattedTotal }) => Effect.gen(function* () {
|
|
338
|
+
//#region src/legacy-v9/parser/search/to-search-output-item.ts
|
|
339
|
+
const toSearchOutputItem = ({ locale, imageProxyBaseUrl, rentalHighlightPrioritization, customAttributeFilterDefinitions, rental, translations, includeFormattedTotal }) => Effect.gen(function* () {
|
|
341
340
|
const data = parseVofficeUnitData(rental.data);
|
|
342
341
|
const item = {
|
|
343
342
|
id: rental.voffice_id.toString(),
|
|
@@ -346,6 +345,8 @@ const toSearchOutputItem = ({ locale, rentalHighlightPrioritization, customAttri
|
|
|
346
345
|
};
|
|
347
346
|
const address = toAddress(data, locale);
|
|
348
347
|
if (Object.keys(address).length > 0) item.address = address;
|
|
348
|
+
const images = toImages(imageProxyBaseUrl, rental, locale, data);
|
|
349
|
+
if (images.length > 0) item.images = images;
|
|
349
350
|
const highlights = yield* toRentalHighlights({
|
|
350
351
|
locale,
|
|
351
352
|
translations,
|
|
@@ -362,4 +363,22 @@ const toSearchOutputItem = ({ locale, rentalHighlightPrioritization, customAttri
|
|
|
362
363
|
return item;
|
|
363
364
|
});
|
|
364
365
|
//#endregion
|
|
365
|
-
|
|
366
|
+
//#region src/legacy-v9/parser/search/output/to-alternative-periods.ts
|
|
367
|
+
const DEFAULT_V9_SEARCH_CURRENCY = "EUR";
|
|
368
|
+
const toAlternativePeriods = ({ locale, alternatives }) => Effect.succeed((alternatives ?? []).flatMap((alternative) => {
|
|
369
|
+
if (alternative.fromdate == null || alternative.tilldate == null) return [];
|
|
370
|
+
return [{
|
|
371
|
+
start: alternative.fromdate,
|
|
372
|
+
end: alternative.tilldate,
|
|
373
|
+
...alternative.calc?.total == null ? {} : { formattedTotal: toFormattedSearchPrice({
|
|
374
|
+
amount: alternative.calc.total,
|
|
375
|
+
currency: DEFAULT_V9_SEARCH_CURRENCY,
|
|
376
|
+
locale
|
|
377
|
+
}) }
|
|
378
|
+
}];
|
|
379
|
+
}));
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/legacy-v9/runtime/search.ts
|
|
382
|
+
const defaultSearchDataAttributes = Object.keys(VofficeUnitDataFieldSchemas);
|
|
383
|
+
//#endregion
|
|
384
|
+
export { defaultSearchDataAttributes, searchQuery, toAlternativePeriods, toQueryInput, toSearchOutputItem };
|