@garagem-ai/site-sdk 0.13.3 → 0.13.5
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/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +17 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +17 -3
- package/dist/react.mjs.map +1 -1
- package/dist/{types-photo-search-BPLxl65M.d.mts → types-photo-search-CVPyF9zC.d.mts} +13 -1
- package/dist/{types-photo-search-BPLxl65M.d.ts → types-photo-search-CVPyF9zC.d.ts} +13 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/search-engine.ts +47 -3
- package/src/studio-contract.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -546,6 +546,19 @@ var LISTING_TYPE_ALIASES = {
|
|
|
546
546
|
rental: ["alugar"]
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
+
// ../search-url/listing-identity.ts
|
|
550
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
551
|
+
var LISTING_CODE_RE = /^(?:[A-Za-z0-9]+|[A-Z0-9]+(?:-[A-Z0-9]+)+)$/;
|
|
552
|
+
var LETTER_CODE_RE = /^[A-Z]{5}$/;
|
|
553
|
+
function isShortListingIdentity(segment) {
|
|
554
|
+
if (UUID_RE.test(segment) || LETTER_CODE_RE.test(segment)) return true;
|
|
555
|
+
return /\d/.test(segment) && LISTING_CODE_RE.test(segment);
|
|
556
|
+
}
|
|
557
|
+
function isShortListingPath(pathname) {
|
|
558
|
+
const parts = (pathname.split(/[?#]/)[0] ?? "").split("/").filter(Boolean);
|
|
559
|
+
return parts.length === 2 && parts[0] === SEARCH_BASE_ROUTE && isShortListingIdentity(parts[1] ?? "");
|
|
560
|
+
}
|
|
561
|
+
|
|
549
562
|
// ../search-url/path.ts
|
|
550
563
|
function toArray(value) {
|
|
551
564
|
if (value === void 0) return [];
|
|
@@ -642,6 +655,7 @@ function parseSearchPublicPath(pathname, dictionary = emptySearchUrlDictionary()
|
|
|
642
655
|
if (segments.some((segment) => segment.toLowerCase().startsWith("id-"))) {
|
|
643
656
|
return null;
|
|
644
657
|
}
|
|
658
|
+
if (isShortListingPath(raw)) return null;
|
|
645
659
|
const filters = {};
|
|
646
660
|
const locationParts = [];
|
|
647
661
|
const propertyTypes = [];
|
|
@@ -1016,9 +1030,9 @@ function pathnameOnly(pathname) {
|
|
|
1016
1030
|
return String(pathname || "").split(/[?#]/)[0] || "/";
|
|
1017
1031
|
}
|
|
1018
1032
|
function isListingDetailPath(pathname) {
|
|
1019
|
-
const
|
|
1020
|
-
const last =
|
|
1021
|
-
return last.toLowerCase().startsWith("id-");
|
|
1033
|
+
const path = pathnameOnly(pathname);
|
|
1034
|
+
const last = path.split("/").filter(Boolean).pop() || "";
|
|
1035
|
+
return last.toLowerCase().startsWith("id-") || isShortListingPath(path);
|
|
1022
1036
|
}
|
|
1023
1037
|
function readPublicSearch(pathname, search, dictionary) {
|
|
1024
1038
|
const pathFilters = parseSearchPublicPath2(pathnameOnly(pathname), dictionary) || {};
|
|
@@ -1029,6 +1043,27 @@ function lookupDisplay(table, slug) {
|
|
|
1029
1043
|
if (!slug || !table) return slug;
|
|
1030
1044
|
return table[slug] || table[String(slug).toLowerCase()] || slug;
|
|
1031
1045
|
}
|
|
1046
|
+
var LOCATION_FIELDS = ["state", "city", "neighborhood", "street"];
|
|
1047
|
+
var LOCATION_TABLE_KEY = {
|
|
1048
|
+
state: "states",
|
|
1049
|
+
city: "cities",
|
|
1050
|
+
neighborhood: "neighborhoods",
|
|
1051
|
+
street: "streets"
|
|
1052
|
+
};
|
|
1053
|
+
function locationTableHasSlug(table, slug) {
|
|
1054
|
+
if (!table) return false;
|
|
1055
|
+
if (Object.hasOwn(table, slug)) return true;
|
|
1056
|
+
const lower = slug.toLowerCase();
|
|
1057
|
+
return lower !== slug && Object.hasOwn(table, lower);
|
|
1058
|
+
}
|
|
1059
|
+
function unknownSearchLocation(location, tables) {
|
|
1060
|
+
if (!location) return false;
|
|
1061
|
+
const present = LOCATION_FIELDS.filter((key) => location[key]);
|
|
1062
|
+
if (present.length === 0 || !tables) return false;
|
|
1063
|
+
return present.some(
|
|
1064
|
+
(key) => !locationTableHasSlug(tables[LOCATION_TABLE_KEY[key]], location[key])
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1032
1067
|
function displayPathLocation(location, values) {
|
|
1033
1068
|
if (!location) return null;
|
|
1034
1069
|
const table = values || {};
|
|
@@ -1928,7 +1963,7 @@ var LeadSubmitError = class extends Error {
|
|
|
1928
1963
|
this.retryAfter = info.retryAfterSeconds ?? null;
|
|
1929
1964
|
}
|
|
1930
1965
|
};
|
|
1931
|
-
var
|
|
1966
|
+
var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1932
1967
|
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1933
1968
|
var NAME_RE = /^[^\d\s]{2,}.*$/;
|
|
1934
1969
|
var MESSAGE_MAX = 2e3;
|
|
@@ -1980,7 +2015,7 @@ async function getLeadUi(options) {
|
|
|
1980
2015
|
);
|
|
1981
2016
|
}
|
|
1982
2017
|
function assertListingId(listingId) {
|
|
1983
|
-
if (!
|
|
2018
|
+
if (!UUID_RE2.test(listingId.trim())) {
|
|
1984
2019
|
throw new LeadSubmitError(
|
|
1985
2020
|
"Garagem SDK: listingId must be the listing UUID, not a path or code.",
|
|
1986
2021
|
{ code: "invalid_listing_id" }
|
|
@@ -3250,7 +3285,10 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
3250
3285
|
*/
|
|
3251
3286
|
unpublishedSearchExports: [
|
|
3252
3287
|
"searchChromeModel",
|
|
3253
|
-
"rangeDraftFromPath"
|
|
3288
|
+
"rangeDraftFromPath",
|
|
3289
|
+
// `unknownSearchLocation` is in git. Prompts inline the same check with
|
|
3290
|
+
// `parseSearchPublicPath` + `locationsPath` until this name is on the pin.
|
|
3291
|
+
"unknownSearchLocation"
|
|
3254
3292
|
],
|
|
3255
3293
|
/**
|
|
3256
3294
|
* maps.fndn.ai helpers (static map, street view, boundaries, travel
|
|
@@ -5159,6 +5197,7 @@ export {
|
|
|
5159
5197
|
travelTimesFromListing,
|
|
5160
5198
|
truncateNationalPhoneDigits,
|
|
5161
5199
|
unavailableReactImports,
|
|
5200
|
+
unknownSearchLocation,
|
|
5162
5201
|
uploadSellerLeadPhoto,
|
|
5163
5202
|
visibleSearchFilters
|
|
5164
5203
|
};
|