@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
|
@@ -864,6 +864,7 @@ declare function searchSortOptions(sorts: Array<{
|
|
|
864
864
|
}>;
|
|
865
865
|
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
866
866
|
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
867
|
+
/** Listing detail: `…/id-<código>` at any depth, or the short CRM link `/imoveis/<código>`. */
|
|
867
868
|
declare function isListingDetailPath(pathname: string): boolean;
|
|
868
869
|
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
869
870
|
pathFilters: SearchPathFilters;
|
|
@@ -875,6 +876,17 @@ type LocationNameTables = {
|
|
|
875
876
|
neighborhoods?: Record<string, string>;
|
|
876
877
|
streets?: Record<string, string>;
|
|
877
878
|
};
|
|
879
|
+
/**
|
|
880
|
+
* True when the path parser stored a place the site's location table does
|
|
881
|
+
* not know (`/imoveis/sobre` → neighborhood `sobre`). `null` tables mean the
|
|
882
|
+
* locations request failed: do not 404 the search. A path with no location
|
|
883
|
+
* (`/imoveis`, `/imoveis/venda`, `/imoveis/4-quartos`) is a normal search.
|
|
884
|
+
*
|
|
885
|
+
* Studio prompts inline this check. The name stays off the npm pin until a
|
|
886
|
+
* published tarball exports it — naming it earlier makes v0 import a missing
|
|
887
|
+
* export.
|
|
888
|
+
*/
|
|
889
|
+
declare function unknownSearchLocation(location: SearchPathFilters["location"] | null | undefined, tables: LocationNameTables | null | undefined): boolean;
|
|
878
890
|
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
879
891
|
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
880
892
|
defaultLimit?: number;
|
|
@@ -1109,4 +1121,4 @@ type ListingWithMatchedPhoto = Listing & {
|
|
|
1109
1121
|
matchedPhoto: MatchedListingPhoto | null;
|
|
1110
1122
|
};
|
|
1111
1123
|
|
|
1112
|
-
export { type CmsEntryStatus as $, type AppliedSearchQuery as A, type BoundaryCity as B, type CmsCollection as C, type TravelDestination as D, type TravelMode as E, type FetchLike as F, type TravelTimeOptions as G, type TravelTime as H, type TravelTimesOptions as I, type TravelTimeElement as J, type PhotoSearchResult as K, type ListingDetail as L, type MapsCoordinates as M, type NeighborhoodBoundaryOptions as N, type PhotoSearchItem as O, type PhotoSearchParams as P, type QueryListingsFilters as Q, type RequestNextOptions as R, type SearchPathFilters as S, type TravelTimeCacheOptions as T, type ListingWithMatchedPhoto as U, type MatchedListingPhoto as V, type BoundaryFeature as W, type BoundaryFeatureCollection as X, type BoundaryGeometry as Y, type BoundaryLayerUrlKind as Z, type BoundarySourceLayer as _, type Listing as a, hrefForAppliedChange as a$, type CmsFieldDefinition as a0, type CmsFieldType as a1, type CmsSeoData as a2, FORBIDDEN_SEARCH_QUERY_KEYS as a3, GaragemSdkError as a4, type GetCmsCollectionOptions as a5, type GetCmsCollectionsOptions as a6, type GetCmsEntriesOptions as a7, type GetCmsEntryOptions as a8, type GetListingOptions as a9, type SearchChromeModel as aA, type SearchListingsOptions as aB, type SearchPathLocation as aC, type SearchUiFilter as aD, type SearchUiOption as aE, type StaticMapStyle as aF, TOOLBAR_PRIMARY_FILTER_IDS as aG, applyPathFilter as aH, buildQueryListingsParams as aI, canonicalizeSearchHref as aJ, capMapPage as aK, capMapPageSize as aL, clearStagedPathFilters as aM, clusterBuckets as aN, clusterPins as aO, countFacetChoices as aP, countOptionLabel as aQ, displayPathLocation as aR, getCmsCollection as aS, getCmsCollections as aT, getCmsEntries as aU, getCmsEntry as aV, getListing as aW, getListings as aX, getSearchUi as aY, getSimilarListings as aZ, getSite as a_, type GetListingsOptions as aa, type GetSearchUiOptions as ab, type GetSimilarListingsOptions as ac, type GetSiteOptions as ad, type ListingBusinessType as ae, type ListingCardModel as af, type ListingPriceVisibility as ag, type ListingPropertySummary as ah, type LocationNameTables as ai, MAP_POLYGON_MAX_VERTICES as aj, MAP_SEARCH_DEFAULT_PAGE_SIZE as ak, MAP_SEARCH_MAX_PAGE_SIZE as al, MAP_VIEWPORT_DEBOUNCE_MS as am, type MapBounds as an, type MapBoundsSearchOptions as ao, type MapBucket as ap, type MapPin as aq, type MapPinCluster as ar, type MapPolygon as as, type MapPolygonSearchOptions as at, type MapSearchResult as au, type MapsBaseOptions as av, type QueryListingsLocation as aw, type QueryListingsOptions as ax, SEARCH_EMPTY_COPY as ay, SEARCH_SORT_RELEVANCE as az, type ListingLocation as b, hrefForPathFilters as b0, hrefWithExplicitPage as b1, isListingDetailPath as b2, isMapBounds as b3, isMapPolygon as b4, listingLocationLabel as b5, mapClusterCellDegrees as b6, mapSearchPins as b7, paginationPages as b8, pathFilterHasOption as b9, pathFilterValue as ba, publicSearchHref as bb, queryListings as bc, rangeDraftFromPath as bd, readPublicSearch as be, searchChromeModel as bf, searchHrefUsesLegacyFilterQuery as bg, searchListings as bh, searchListingsInBounds as bi, searchListingsInPolygon as bj, searchResultsHeading as bk, searchSortOptions as bl, toListingCardModel as bm, toolbarFilterIds as bn,
|
|
1124
|
+
export { type CmsEntryStatus as $, type AppliedSearchQuery as A, type BoundaryCity as B, type CmsCollection as C, type TravelDestination as D, type TravelMode as E, type FetchLike as F, type TravelTimeOptions as G, type TravelTime as H, type TravelTimesOptions as I, type TravelTimeElement as J, type PhotoSearchResult as K, type ListingDetail as L, type MapsCoordinates as M, type NeighborhoodBoundaryOptions as N, type PhotoSearchItem as O, type PhotoSearchParams as P, type QueryListingsFilters as Q, type RequestNextOptions as R, type SearchPathFilters as S, type TravelTimeCacheOptions as T, type ListingWithMatchedPhoto as U, type MatchedListingPhoto as V, type BoundaryFeature as W, type BoundaryFeatureCollection as X, type BoundaryGeometry as Y, type BoundaryLayerUrlKind as Z, type BoundarySourceLayer as _, type Listing as a, hrefForAppliedChange as a$, type CmsFieldDefinition as a0, type CmsFieldType as a1, type CmsSeoData as a2, FORBIDDEN_SEARCH_QUERY_KEYS as a3, GaragemSdkError as a4, type GetCmsCollectionOptions as a5, type GetCmsCollectionsOptions as a6, type GetCmsEntriesOptions as a7, type GetCmsEntryOptions as a8, type GetListingOptions as a9, type SearchChromeModel as aA, type SearchListingsOptions as aB, type SearchPathLocation as aC, type SearchUiFilter as aD, type SearchUiOption as aE, type StaticMapStyle as aF, TOOLBAR_PRIMARY_FILTER_IDS as aG, applyPathFilter as aH, buildQueryListingsParams as aI, canonicalizeSearchHref as aJ, capMapPage as aK, capMapPageSize as aL, clearStagedPathFilters as aM, clusterBuckets as aN, clusterPins as aO, countFacetChoices as aP, countOptionLabel as aQ, displayPathLocation as aR, getCmsCollection as aS, getCmsCollections as aT, getCmsEntries as aU, getCmsEntry as aV, getListing as aW, getListings as aX, getSearchUi as aY, getSimilarListings as aZ, getSite as a_, type GetListingsOptions as aa, type GetSearchUiOptions as ab, type GetSimilarListingsOptions as ac, type GetSiteOptions as ad, type ListingBusinessType as ae, type ListingCardModel as af, type ListingPriceVisibility as ag, type ListingPropertySummary as ah, type LocationNameTables as ai, MAP_POLYGON_MAX_VERTICES as aj, MAP_SEARCH_DEFAULT_PAGE_SIZE as ak, MAP_SEARCH_MAX_PAGE_SIZE as al, MAP_VIEWPORT_DEBOUNCE_MS as am, type MapBounds as an, type MapBoundsSearchOptions as ao, type MapBucket as ap, type MapPin as aq, type MapPinCluster as ar, type MapPolygon as as, type MapPolygonSearchOptions as at, type MapSearchResult as au, type MapsBaseOptions as av, type QueryListingsLocation as aw, type QueryListingsOptions as ax, SEARCH_EMPTY_COPY as ay, SEARCH_SORT_RELEVANCE as az, type ListingLocation as b, hrefForPathFilters as b0, hrefWithExplicitPage as b1, isListingDetailPath as b2, isMapBounds as b3, isMapPolygon as b4, listingLocationLabel as b5, mapClusterCellDegrees as b6, mapSearchPins as b7, paginationPages as b8, pathFilterHasOption as b9, pathFilterValue as ba, publicSearchHref as bb, queryListings as bc, rangeDraftFromPath as bd, readPublicSearch as be, searchChromeModel as bf, searchHrefUsesLegacyFilterQuery as bg, searchListings as bh, searchListingsInBounds as bi, searchListingsInPolygon as bj, searchResultsHeading as bk, searchSortOptions as bl, toListingCardModel as bm, toolbarFilterIds as bn, unknownSearchLocation as bo, visibleSearchFilters as bp, type MapSearchSubscription as bq, type ListingMedia as c, type SearchUiDictionary as d, type AppliedSearchChange as e, type ListingFilters as f, type ListingsResult as g, type Site as h, type SearchListingsParams as i, type SearchListingsResult as j, type SearchUi as k, type QueryListingsParams as l, type QueryListingsResult as m, type SimilarListingsResult as n, type CmsEntriesResult as o, type CmsEntry as p, type BoundaryLayerOptions as q, type TravelTimeCache as r, type MapsFetchOptions as s, type BoundaryLayer as t, type ListingWithLocation as u, type StaticMapOptions as v, type StreetViewAvailabilityOptions as w, type StreetViewAvailability as x, type StreetViewOptions as y, type NeighborhoodBoundary as z };
|
|
@@ -864,6 +864,7 @@ declare function searchSortOptions(sorts: Array<{
|
|
|
864
864
|
}>;
|
|
865
865
|
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
866
866
|
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
867
|
+
/** Listing detail: `…/id-<código>` at any depth, or the short CRM link `/imoveis/<código>`. */
|
|
867
868
|
declare function isListingDetailPath(pathname: string): boolean;
|
|
868
869
|
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
869
870
|
pathFilters: SearchPathFilters;
|
|
@@ -875,6 +876,17 @@ type LocationNameTables = {
|
|
|
875
876
|
neighborhoods?: Record<string, string>;
|
|
876
877
|
streets?: Record<string, string>;
|
|
877
878
|
};
|
|
879
|
+
/**
|
|
880
|
+
* True when the path parser stored a place the site's location table does
|
|
881
|
+
* not know (`/imoveis/sobre` → neighborhood `sobre`). `null` tables mean the
|
|
882
|
+
* locations request failed: do not 404 the search. A path with no location
|
|
883
|
+
* (`/imoveis`, `/imoveis/venda`, `/imoveis/4-quartos`) is a normal search.
|
|
884
|
+
*
|
|
885
|
+
* Studio prompts inline this check. The name stays off the npm pin until a
|
|
886
|
+
* published tarball exports it — naming it earlier makes v0 import a missing
|
|
887
|
+
* export.
|
|
888
|
+
*/
|
|
889
|
+
declare function unknownSearchLocation(location: SearchPathFilters["location"] | null | undefined, tables: LocationNameTables | null | undefined): boolean;
|
|
878
890
|
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
879
891
|
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
880
892
|
defaultLimit?: number;
|
|
@@ -1109,4 +1121,4 @@ type ListingWithMatchedPhoto = Listing & {
|
|
|
1109
1121
|
matchedPhoto: MatchedListingPhoto | null;
|
|
1110
1122
|
};
|
|
1111
1123
|
|
|
1112
|
-
export { type CmsEntryStatus as $, type AppliedSearchQuery as A, type BoundaryCity as B, type CmsCollection as C, type TravelDestination as D, type TravelMode as E, type FetchLike as F, type TravelTimeOptions as G, type TravelTime as H, type TravelTimesOptions as I, type TravelTimeElement as J, type PhotoSearchResult as K, type ListingDetail as L, type MapsCoordinates as M, type NeighborhoodBoundaryOptions as N, type PhotoSearchItem as O, type PhotoSearchParams as P, type QueryListingsFilters as Q, type RequestNextOptions as R, type SearchPathFilters as S, type TravelTimeCacheOptions as T, type ListingWithMatchedPhoto as U, type MatchedListingPhoto as V, type BoundaryFeature as W, type BoundaryFeatureCollection as X, type BoundaryGeometry as Y, type BoundaryLayerUrlKind as Z, type BoundarySourceLayer as _, type Listing as a, hrefForAppliedChange as a$, type CmsFieldDefinition as a0, type CmsFieldType as a1, type CmsSeoData as a2, FORBIDDEN_SEARCH_QUERY_KEYS as a3, GaragemSdkError as a4, type GetCmsCollectionOptions as a5, type GetCmsCollectionsOptions as a6, type GetCmsEntriesOptions as a7, type GetCmsEntryOptions as a8, type GetListingOptions as a9, type SearchChromeModel as aA, type SearchListingsOptions as aB, type SearchPathLocation as aC, type SearchUiFilter as aD, type SearchUiOption as aE, type StaticMapStyle as aF, TOOLBAR_PRIMARY_FILTER_IDS as aG, applyPathFilter as aH, buildQueryListingsParams as aI, canonicalizeSearchHref as aJ, capMapPage as aK, capMapPageSize as aL, clearStagedPathFilters as aM, clusterBuckets as aN, clusterPins as aO, countFacetChoices as aP, countOptionLabel as aQ, displayPathLocation as aR, getCmsCollection as aS, getCmsCollections as aT, getCmsEntries as aU, getCmsEntry as aV, getListing as aW, getListings as aX, getSearchUi as aY, getSimilarListings as aZ, getSite as a_, type GetListingsOptions as aa, type GetSearchUiOptions as ab, type GetSimilarListingsOptions as ac, type GetSiteOptions as ad, type ListingBusinessType as ae, type ListingCardModel as af, type ListingPriceVisibility as ag, type ListingPropertySummary as ah, type LocationNameTables as ai, MAP_POLYGON_MAX_VERTICES as aj, MAP_SEARCH_DEFAULT_PAGE_SIZE as ak, MAP_SEARCH_MAX_PAGE_SIZE as al, MAP_VIEWPORT_DEBOUNCE_MS as am, type MapBounds as an, type MapBoundsSearchOptions as ao, type MapBucket as ap, type MapPin as aq, type MapPinCluster as ar, type MapPolygon as as, type MapPolygonSearchOptions as at, type MapSearchResult as au, type MapsBaseOptions as av, type QueryListingsLocation as aw, type QueryListingsOptions as ax, SEARCH_EMPTY_COPY as ay, SEARCH_SORT_RELEVANCE as az, type ListingLocation as b, hrefForPathFilters as b0, hrefWithExplicitPage as b1, isListingDetailPath as b2, isMapBounds as b3, isMapPolygon as b4, listingLocationLabel as b5, mapClusterCellDegrees as b6, mapSearchPins as b7, paginationPages as b8, pathFilterHasOption as b9, pathFilterValue as ba, publicSearchHref as bb, queryListings as bc, rangeDraftFromPath as bd, readPublicSearch as be, searchChromeModel as bf, searchHrefUsesLegacyFilterQuery as bg, searchListings as bh, searchListingsInBounds as bi, searchListingsInPolygon as bj, searchResultsHeading as bk, searchSortOptions as bl, toListingCardModel as bm, toolbarFilterIds as bn,
|
|
1124
|
+
export { type CmsEntryStatus as $, type AppliedSearchQuery as A, type BoundaryCity as B, type CmsCollection as C, type TravelDestination as D, type TravelMode as E, type FetchLike as F, type TravelTimeOptions as G, type TravelTime as H, type TravelTimesOptions as I, type TravelTimeElement as J, type PhotoSearchResult as K, type ListingDetail as L, type MapsCoordinates as M, type NeighborhoodBoundaryOptions as N, type PhotoSearchItem as O, type PhotoSearchParams as P, type QueryListingsFilters as Q, type RequestNextOptions as R, type SearchPathFilters as S, type TravelTimeCacheOptions as T, type ListingWithMatchedPhoto as U, type MatchedListingPhoto as V, type BoundaryFeature as W, type BoundaryFeatureCollection as X, type BoundaryGeometry as Y, type BoundaryLayerUrlKind as Z, type BoundarySourceLayer as _, type Listing as a, hrefForAppliedChange as a$, type CmsFieldDefinition as a0, type CmsFieldType as a1, type CmsSeoData as a2, FORBIDDEN_SEARCH_QUERY_KEYS as a3, GaragemSdkError as a4, type GetCmsCollectionOptions as a5, type GetCmsCollectionsOptions as a6, type GetCmsEntriesOptions as a7, type GetCmsEntryOptions as a8, type GetListingOptions as a9, type SearchChromeModel as aA, type SearchListingsOptions as aB, type SearchPathLocation as aC, type SearchUiFilter as aD, type SearchUiOption as aE, type StaticMapStyle as aF, TOOLBAR_PRIMARY_FILTER_IDS as aG, applyPathFilter as aH, buildQueryListingsParams as aI, canonicalizeSearchHref as aJ, capMapPage as aK, capMapPageSize as aL, clearStagedPathFilters as aM, clusterBuckets as aN, clusterPins as aO, countFacetChoices as aP, countOptionLabel as aQ, displayPathLocation as aR, getCmsCollection as aS, getCmsCollections as aT, getCmsEntries as aU, getCmsEntry as aV, getListing as aW, getListings as aX, getSearchUi as aY, getSimilarListings as aZ, getSite as a_, type GetListingsOptions as aa, type GetSearchUiOptions as ab, type GetSimilarListingsOptions as ac, type GetSiteOptions as ad, type ListingBusinessType as ae, type ListingCardModel as af, type ListingPriceVisibility as ag, type ListingPropertySummary as ah, type LocationNameTables as ai, MAP_POLYGON_MAX_VERTICES as aj, MAP_SEARCH_DEFAULT_PAGE_SIZE as ak, MAP_SEARCH_MAX_PAGE_SIZE as al, MAP_VIEWPORT_DEBOUNCE_MS as am, type MapBounds as an, type MapBoundsSearchOptions as ao, type MapBucket as ap, type MapPin as aq, type MapPinCluster as ar, type MapPolygon as as, type MapPolygonSearchOptions as at, type MapSearchResult as au, type MapsBaseOptions as av, type QueryListingsLocation as aw, type QueryListingsOptions as ax, SEARCH_EMPTY_COPY as ay, SEARCH_SORT_RELEVANCE as az, type ListingLocation as b, hrefForPathFilters as b0, hrefWithExplicitPage as b1, isListingDetailPath as b2, isMapBounds as b3, isMapPolygon as b4, listingLocationLabel as b5, mapClusterCellDegrees as b6, mapSearchPins as b7, paginationPages as b8, pathFilterHasOption as b9, pathFilterValue as ba, publicSearchHref as bb, queryListings as bc, rangeDraftFromPath as bd, readPublicSearch as be, searchChromeModel as bf, searchHrefUsesLegacyFilterQuery as bg, searchListings as bh, searchListingsInBounds as bi, searchListingsInPolygon as bj, searchResultsHeading as bk, searchSortOptions as bl, toListingCardModel as bm, toolbarFilterIds as bn, unknownSearchLocation as bo, visibleSearchFilters as bp, type MapSearchSubscription as bq, type ListingMedia as c, type SearchUiDictionary as d, type AppliedSearchChange as e, type ListingFilters as f, type ListingsResult as g, type Site as h, type SearchListingsParams as i, type SearchListingsResult as j, type SearchUi as k, type QueryListingsParams as l, type QueryListingsResult as m, type SimilarListingsResult as n, type CmsEntriesResult as o, type CmsEntry as p, type BoundaryLayerOptions as q, type TravelTimeCache as r, type MapsFetchOptions as s, type BoundaryLayer as t, type ListingWithLocation as u, type StaticMapOptions as v, type StreetViewAvailabilityOptions as w, type StreetViewAvailability as x, type StreetViewOptions as y, type NeighborhoodBoundary as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@garagem-ai/site-sdk",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Typed, runtime-agnostic SDK for building custom real estate sites against the Garagem platform. Drop into any Next.js (or other JS) project to fetch listings, sites and CMS data.",
|
|
6
6
|
"main": "./dist/index.js",
|
package/src/index.ts
CHANGED
package/src/search-engine.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isShortListingPath } from "@garagem/search-url";
|
|
1
2
|
import {
|
|
2
3
|
composeSearchPublicHref,
|
|
3
4
|
parseAppliedSearchQuery,
|
|
@@ -77,10 +78,11 @@ function pathnameOnly(pathname: string): string {
|
|
|
77
78
|
return String(pathname || "").split(/[?#]/)[0] || "/";
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/** Listing detail: `…/id-<código>` at any depth, or the short CRM link `/imoveis/<código>`. */
|
|
80
82
|
export function isListingDetailPath(pathname: string): boolean {
|
|
81
|
-
const
|
|
82
|
-
const last =
|
|
83
|
-
return last.toLowerCase().startsWith("id-");
|
|
83
|
+
const path = pathnameOnly(pathname);
|
|
84
|
+
const last = path.split("/").filter(Boolean).pop() || "";
|
|
85
|
+
return last.toLowerCase().startsWith("id-") || isShortListingPath(path);
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
export function readPublicSearch(
|
|
@@ -109,6 +111,48 @@ export type LocationNameTables = {
|
|
|
109
111
|
streets?: Record<string, string>;
|
|
110
112
|
};
|
|
111
113
|
|
|
114
|
+
const LOCATION_FIELDS = ["state", "city", "neighborhood", "street"] as const;
|
|
115
|
+
|
|
116
|
+
const LOCATION_TABLE_KEY = {
|
|
117
|
+
state: "states",
|
|
118
|
+
city: "cities",
|
|
119
|
+
neighborhood: "neighborhoods",
|
|
120
|
+
street: "streets",
|
|
121
|
+
} as const;
|
|
122
|
+
|
|
123
|
+
function locationTableHasSlug(
|
|
124
|
+
table: Record<string, string> | undefined,
|
|
125
|
+
slug: string
|
|
126
|
+
): boolean {
|
|
127
|
+
if (!table) return false;
|
|
128
|
+
if (Object.hasOwn(table, slug)) return true;
|
|
129
|
+
const lower = slug.toLowerCase();
|
|
130
|
+
return lower !== slug && Object.hasOwn(table, lower);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* True when the path parser stored a place the site's location table does
|
|
135
|
+
* not know (`/imoveis/sobre` → neighborhood `sobre`). `null` tables mean the
|
|
136
|
+
* locations request failed: do not 404 the search. A path with no location
|
|
137
|
+
* (`/imoveis`, `/imoveis/venda`, `/imoveis/4-quartos`) is a normal search.
|
|
138
|
+
*
|
|
139
|
+
* Studio prompts inline this check. The name stays off the npm pin until a
|
|
140
|
+
* published tarball exports it — naming it earlier makes v0 import a missing
|
|
141
|
+
* export.
|
|
142
|
+
*/
|
|
143
|
+
export function unknownSearchLocation(
|
|
144
|
+
location: SearchPathFilters["location"] | null | undefined,
|
|
145
|
+
tables: LocationNameTables | null | undefined
|
|
146
|
+
): boolean {
|
|
147
|
+
if (!location) return false;
|
|
148
|
+
const present = LOCATION_FIELDS.filter((key) => location[key]);
|
|
149
|
+
if (present.length === 0 || !tables) return false;
|
|
150
|
+
return present.some(
|
|
151
|
+
(key) =>
|
|
152
|
+
!locationTableHasSlug(tables[LOCATION_TABLE_KEY[key]], location[key]!)
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
112
156
|
export function displayPathLocation(
|
|
113
157
|
location: SearchPathFilters["location"],
|
|
114
158
|
values?: LocationNameTables | null
|
package/src/studio-contract.ts
CHANGED
|
@@ -155,6 +155,9 @@ export const STUDIO_SDK_CONTRACT = {
|
|
|
155
155
|
unpublishedSearchExports: [
|
|
156
156
|
"searchChromeModel",
|
|
157
157
|
"rangeDraftFromPath",
|
|
158
|
+
// `unknownSearchLocation` is in git. Prompts inline the same check with
|
|
159
|
+
// `parseSearchPublicPath` + `locationsPath` until this name is on the pin.
|
|
160
|
+
"unknownSearchLocation",
|
|
158
161
|
] as const,
|
|
159
162
|
/**
|
|
160
163
|
* maps.fndn.ai helpers (static map, street view, boundaries, travel
|