tripstorekrabi-shared 1.26.2 → 1.26.4
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/package.json +1 -1
- package/product.js +11 -32
package/package.json
CHANGED
package/product.js
CHANGED
|
@@ -40,8 +40,12 @@ export function buildIndex(id, product) {
|
|
|
40
40
|
|
|
41
41
|
const safeIntPrice = isNaN(rawPrice) || !isFinite(rawPrice) ? 0 : Math.round(rawPrice);
|
|
42
42
|
|
|
43
|
+
const type = String(product.type || '').trim().toLowerCase() || (product.from ? 'transfer' : 'activity');
|
|
44
|
+
const isTransfer = type === 'transfer';
|
|
45
|
+
|
|
43
46
|
let document = {
|
|
44
47
|
id,
|
|
48
|
+
type,
|
|
45
49
|
title: String(product.title || '').trim(),
|
|
46
50
|
subtitle: String(product.subtitle || '').trim(),
|
|
47
51
|
summary: String(product.summary || '').trim(),
|
|
@@ -65,34 +69,6 @@ export function buildIndex(id, product) {
|
|
|
65
69
|
document.shortName = String(product.shortName).trim();
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
const isTransfer = Boolean(product.from && product.to);
|
|
69
|
-
|
|
70
|
-
if (isTransfer) {
|
|
71
|
-
// For transfers, always derive destinations directly from `from` and `to`
|
|
72
|
-
const transferDestinations = Array.from(
|
|
73
|
-
new Set([product.from, product.to].map((d) => String(d || '').trim()).filter(Boolean))
|
|
74
|
-
);
|
|
75
|
-
if (transferDestinations.length > 0) {
|
|
76
|
-
document.destinations = transferDestinations;
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
// For activities, clean and deduplicate `destinations` (or fallback to `destination`)
|
|
80
|
-
const rawDestinations = Array.isArray(product.destinations)
|
|
81
|
-
? product.destinations
|
|
82
|
-
: product.destination
|
|
83
|
-
? [product.destination]
|
|
84
|
-
: [];
|
|
85
|
-
|
|
86
|
-
const cleanedDestinations = Array.from(
|
|
87
|
-
new Set(rawDestinations.map((d) => String(d || '').trim()).filter(Boolean))
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
if (cleanedDestinations.length > 0) {
|
|
91
|
-
document.destinations = cleanedDestinations;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Populate keywords array
|
|
96
72
|
const validKeywords = Array.isArray(product.keywords)
|
|
97
73
|
? product.keywords.map((k) => String(k || '').trim()).filter(Boolean)
|
|
98
74
|
: [];
|
|
@@ -100,8 +76,11 @@ export function buildIndex(id, product) {
|
|
|
100
76
|
document.keywords = Array.from(new Set(validKeywords));
|
|
101
77
|
|
|
102
78
|
if (isTransfer) {
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
const from = String(product.from || '').trim();
|
|
80
|
+
const to = String(product.to || '').trim();
|
|
81
|
+
|
|
82
|
+
if (from) document.from = from;
|
|
83
|
+
if (to) document.to = to;
|
|
105
84
|
|
|
106
85
|
if (Array.isArray(product.waypoints) && product.waypoints.length > 0) {
|
|
107
86
|
const startWp = product.waypoints[0]?.latLng;
|
|
@@ -114,9 +93,9 @@ export function buildIndex(id, product) {
|
|
|
114
93
|
document.end = [endWp.lat, endWp.lng];
|
|
115
94
|
}
|
|
116
95
|
}
|
|
96
|
+
} else if (Array.isArray(product.places) && product.places.length > 0) {
|
|
97
|
+
document.places = product.places;
|
|
117
98
|
}
|
|
118
99
|
|
|
119
|
-
document.type = product.from ? 'transfer' : 'activity';
|
|
120
|
-
|
|
121
100
|
return document;
|
|
122
101
|
}
|