@garagem-ai/site-sdk 0.2.0 → 0.4.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 +26 -3
- package/dist/index.d.mts +146 -249
- package/dist/index.d.ts +146 -249
- package/dist/index.js +960 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +914 -16
- package/dist/index.mjs.map +1 -1
- package/dist/listing-card-model-D7iR4asd.d.mts +402 -0
- package/dist/listing-card-model-D7iR4asd.d.ts +402 -0
- package/dist/react.d.mts +136 -0
- package/dist/react.d.ts +136 -0
- package/dist/react.js +2070 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +2030 -0
- package/dist/react.mjs.map +1 -0
- package/package.json +47 -4
- package/src/applied-query.ts +42 -0
- package/src/client.ts +36 -1
- package/src/fetchers.ts +81 -18
- package/src/index.ts +77 -0
- package/src/internal/url.ts +14 -0
- package/src/listing-card-model.ts +90 -0
- package/src/loc-params.ts +36 -0
- package/src/path.ts +73 -0
- package/src/presentation.ts +72 -0
- package/src/react/cn.ts +3 -0
- package/src/react/filter-panel.tsx +251 -0
- package/src/react/index.ts +20 -0
- package/src/react/listing-card.tsx +143 -0
- package/src/react/search-chrome.tsx +72 -0
- package/src/react/search-page.tsx +366 -0
- package/src/react/search-pagination.tsx +110 -0
- package/src/react/search-query-form.tsx +76 -0
- package/src/react/types.ts +88 -0
- package/src/react/use-public-search.ts +297 -0
- package/src/search-engine.ts +404 -0
- package/src/types.ts +107 -4
package/README.md
CHANGED
|
@@ -241,11 +241,34 @@ add **publishable keys** with per-tenant rate limits and a domain allowlist —
|
|
|
241
241
|
no breaking changes to the call sites, just an additional `publishableKey`
|
|
242
242
|
option on `createGaragemClient`.
|
|
243
243
|
|
|
244
|
-
##
|
|
244
|
+
## Search UI (`@garagem-ai/site-sdk/react`)
|
|
245
|
+
|
|
246
|
+
Headless URL/search helpers live on the main entry (`readPublicSearch`,
|
|
247
|
+
`hrefForPathFilters`, `toListingCardModel`, …). The React adapter is a
|
|
248
|
+
separate subpath — peer `react` + `next`:
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
"use client";
|
|
252
|
+
import { SearchPage, ListingCard } from "@garagem-ai/site-sdk/react";
|
|
253
|
+
|
|
254
|
+
export default function ImoveisPage() {
|
|
255
|
+
return (
|
|
256
|
+
<SearchPage
|
|
257
|
+
siteId={process.env.NEXT_PUBLIC_GARAGEM_SITE_ID!}
|
|
258
|
+
variant="toolbar"
|
|
259
|
+
/>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
`variant` is `toolbar` (default), `dialog`, or `sidebar`. Presentation tokens
|
|
265
|
+
(`SEARCH_CSS_VARS`, `formatListingPrice`) stay framework-free on the main
|
|
266
|
+
entry so other adapters can reuse them.
|
|
267
|
+
|
|
268
|
+
## What's NOT in this release
|
|
245
269
|
|
|
246
270
|
- CMS writes / drafts (editor + CMS worker only).
|
|
247
|
-
- Typesense / InstantSearch helpers
|
|
248
|
-
- React hooks (`useListings`, `useSearch`, …) — coming as `@garagem-ai/site-sdk/react` subpath.
|
|
271
|
+
- Typesense / InstantSearch helpers.
|
|
249
272
|
- LiveSession / lead submission helpers.
|
|
250
273
|
|
|
251
274
|
All of these will land additively; the v0.2 surface above will not break.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,248 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* These match the canonical shapes returned by the public Garagem
|
|
5
|
-
* Sites API (`/api/sites/...`). Treat them as the public contract —
|
|
6
|
-
* additive changes only, never breaking.
|
|
7
|
-
*/
|
|
8
|
-
/** Sale/rental indicator. The API may return additional string values; consumers should branch defensively. */
|
|
9
|
-
type ListingBusinessType = "sale" | "rental" | (string & {});
|
|
10
|
-
/** Whether the price is shown publicly or kept on request. */
|
|
11
|
-
type ListingPriceVisibility = "public" | "private";
|
|
12
|
-
/** Property-level fields shown on a listing summary card. */
|
|
13
|
-
interface ListingPropertySummary {
|
|
14
|
-
type: string;
|
|
15
|
-
bedrooms: number;
|
|
16
|
-
bathrooms: number;
|
|
17
|
-
suites: number;
|
|
18
|
-
parkingSpaces: number;
|
|
19
|
-
totalArea: number;
|
|
20
|
-
usableArea: number;
|
|
21
|
-
/** Monthly condo fee in BRL when the listing has one. */
|
|
22
|
-
condoFee?: number;
|
|
23
|
-
}
|
|
24
|
-
/** Address breakdown returned with every listing. */
|
|
25
|
-
interface ListingLocation {
|
|
26
|
-
street: string;
|
|
27
|
-
number: string;
|
|
28
|
-
complement?: string;
|
|
29
|
-
neighborhood: string;
|
|
30
|
-
city: string;
|
|
31
|
-
state: string;
|
|
32
|
-
postalCode: string;
|
|
33
|
-
country?: string;
|
|
34
|
-
coordinates?: {
|
|
35
|
-
lat: number;
|
|
36
|
-
lng: number;
|
|
37
|
-
} | null;
|
|
38
|
-
}
|
|
39
|
-
/** Single media item attached to a listing (image, video, floor plan, …). */
|
|
40
|
-
interface ListingMedia {
|
|
41
|
-
id: string;
|
|
42
|
-
type: string;
|
|
43
|
-
category: string;
|
|
44
|
-
src: string;
|
|
45
|
-
alt?: string;
|
|
46
|
-
caption?: string;
|
|
47
|
-
order?: number;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Minimum information needed to render a listing on a grid or card.
|
|
51
|
-
* Returned by `getListings`.
|
|
52
|
-
*
|
|
53
|
-
* `price` is `null` when the listing's `priceVisibility` is `"private"`
|
|
54
|
-
* (i.e. the price is hidden behind an explicit lead request) or when
|
|
55
|
-
* the underlying record has no price set. Always branch on `price ==
|
|
56
|
-
* null` rather than `!price` so genuine `0` values (rare but legal in
|
|
57
|
-
* promotional flows) don't get masked as "sob consulta".
|
|
58
|
-
*/
|
|
59
|
-
interface Listing {
|
|
60
|
-
/** Internal UUID — POST lead with this. Never put it in the URL. */
|
|
61
|
-
id: string;
|
|
62
|
-
/** Public identity for display (`#ABC`) and lookup. `null` if the row has no code. */
|
|
63
|
-
listingCode: string | null;
|
|
64
|
-
/**
|
|
65
|
-
* Canonical public href from the Sites API (`/imoveis/.../id-{listingCode}`).
|
|
66
|
-
* Prefer `listingPublicPath(listing)` so a missing `path` (CDN deploy
|
|
67
|
-
* window) still falls back to `/imoveis/id-{listingCode}`.
|
|
68
|
-
*/
|
|
69
|
-
path: string;
|
|
70
|
-
title: string;
|
|
71
|
-
description: string;
|
|
72
|
-
businessType: ListingBusinessType;
|
|
73
|
-
price: number | null;
|
|
74
|
-
priceVisibility: ListingPriceVisibility;
|
|
75
|
-
status: string;
|
|
76
|
-
featured: boolean;
|
|
77
|
-
property: ListingPropertySummary;
|
|
78
|
-
location: ListingLocation;
|
|
79
|
-
coverImage?: {
|
|
80
|
-
src: string;
|
|
81
|
-
alt: string;
|
|
82
|
-
} | null;
|
|
83
|
-
createdAt: string;
|
|
84
|
-
updatedAt: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Full listing data including amenities, full media gallery, building
|
|
88
|
-
* details and richer property info. Returned by `getListing`.
|
|
89
|
-
*/
|
|
90
|
-
interface ListingDetail extends Listing {
|
|
91
|
-
amenities: string[];
|
|
92
|
-
tags: string[];
|
|
93
|
-
property: ListingPropertySummary & {
|
|
94
|
-
id: string;
|
|
95
|
-
builtArea?: number;
|
|
96
|
-
landArea?: number;
|
|
97
|
-
floor?: number;
|
|
98
|
-
totalFloors?: number;
|
|
99
|
-
yearBuilt?: number;
|
|
100
|
-
furnished?: boolean;
|
|
101
|
-
petFriendly?: boolean;
|
|
102
|
-
};
|
|
103
|
-
building?: {
|
|
104
|
-
name: string;
|
|
105
|
-
amenities: string[];
|
|
106
|
-
elevators?: number;
|
|
107
|
-
unitsPerFloor?: number;
|
|
108
|
-
totalUnits?: number;
|
|
109
|
-
} | null;
|
|
110
|
-
media: ListingMedia[];
|
|
111
|
-
}
|
|
112
|
-
/** Filter / pagination options for `getListings`. */
|
|
113
|
-
interface ListingFilters {
|
|
114
|
-
limit?: number;
|
|
115
|
-
offset?: number;
|
|
116
|
-
businessType?: ListingBusinessType;
|
|
117
|
-
propertyType?: string;
|
|
118
|
-
city?: string;
|
|
119
|
-
neighborhood?: string;
|
|
120
|
-
minPrice?: number;
|
|
121
|
-
maxPrice?: number;
|
|
122
|
-
}
|
|
123
|
-
/** Wrapped response from `getListings`. */
|
|
124
|
-
interface ListingsResult {
|
|
125
|
-
listings: Listing[];
|
|
126
|
-
total: number;
|
|
127
|
-
/** Echo of the `limit` query param actually applied (subject to a 100-item cap). */
|
|
128
|
-
limit?: number;
|
|
129
|
-
/** Echo of the `offset` query param actually applied. */
|
|
130
|
-
offset?: number;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Raw Typesense search parameters accepted by `searchListings`. Mirrors
|
|
134
|
-
* the same body the underlying `/api/sites/{siteId}/search` endpoint
|
|
135
|
-
* forwards to Typesense (`q`, `query_by`, `filter_by`, `sort_by`,
|
|
136
|
-
* `per_page`, `page`, facets, etc.) — see the Typesense docs at
|
|
137
|
-
* https://typesense.org/docs/latest/api/search.html for the full list.
|
|
138
|
-
*
|
|
139
|
-
* This is the SDK's escape hatch when the friendly `getListings` API
|
|
140
|
-
* isn't expressive enough (faceted search, multi-field sort, custom
|
|
141
|
-
* grouping). It's an open dictionary on purpose; the only required
|
|
142
|
-
* field is `q`.
|
|
143
|
-
*/
|
|
144
|
-
interface SearchListingsParams {
|
|
145
|
-
q: string;
|
|
146
|
-
query_by?: string;
|
|
147
|
-
filter_by?: string;
|
|
148
|
-
sort_by?: string;
|
|
149
|
-
per_page?: number;
|
|
150
|
-
page?: number;
|
|
151
|
-
facet_by?: string;
|
|
152
|
-
group_by?: string;
|
|
153
|
-
group_limit?: number;
|
|
154
|
-
/** Any other Typesense param. The SDK passes the whole object through. */
|
|
155
|
-
[key: string]: unknown;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Raw Typesense response shape — what the backend returns from
|
|
159
|
-
* `multi_search`. Generic over the document type so power users can
|
|
160
|
-
* narrow it in their own codebases without losing access to `hits[].
|
|
161
|
-
* highlight` and `text_match`.
|
|
162
|
-
*/
|
|
163
|
-
interface SearchListingsResult<TDocument = Record<string, unknown>> {
|
|
164
|
-
found: number;
|
|
165
|
-
page: number;
|
|
166
|
-
search_time_ms: number;
|
|
167
|
-
hits: Array<{
|
|
168
|
-
document: TDocument;
|
|
169
|
-
highlight?: Record<string, unknown>;
|
|
170
|
-
text_match?: number;
|
|
171
|
-
}>;
|
|
172
|
-
/** Any other Typesense field. Stays open so we don't break on engine upgrades. */
|
|
173
|
-
[key: string]: unknown;
|
|
174
|
-
}
|
|
175
|
-
/** Public summary of a Garagem-managed site. Returned by `getSite`. */
|
|
176
|
-
interface Site {
|
|
177
|
-
id: string;
|
|
178
|
-
name: string;
|
|
179
|
-
domain: string | null;
|
|
180
|
-
tenantId: string;
|
|
181
|
-
}
|
|
182
|
-
/** Wrapped response from `getSimilarListings`. */
|
|
183
|
-
interface SimilarListingsResult {
|
|
184
|
-
listings: Listing[];
|
|
185
|
-
total: number;
|
|
186
|
-
}
|
|
187
|
-
/** CMS field type mirrored from the public CMS worker. */
|
|
188
|
-
type CmsFieldType = "text" | "richText" | "image" | "date" | "select" | "number" | "url" | "entry-reference";
|
|
189
|
-
interface CmsFieldDefinition {
|
|
190
|
-
id: string;
|
|
191
|
-
label: string;
|
|
192
|
-
type: CmsFieldType;
|
|
193
|
-
required?: boolean;
|
|
194
|
-
placeholder?: string;
|
|
195
|
-
options?: string[];
|
|
196
|
-
targetCollection?: string;
|
|
197
|
-
displayField?: string;
|
|
198
|
-
inheritFields?: string[];
|
|
199
|
-
inheritLevelField?: boolean;
|
|
200
|
-
}
|
|
201
|
-
/** CMS collection schema. Returned by `getCmsCollections` / `getCmsCollection`. */
|
|
202
|
-
interface CmsCollection {
|
|
203
|
-
id: string;
|
|
204
|
-
name: string;
|
|
205
|
-
slug: string;
|
|
206
|
-
templatePageId: string | null;
|
|
207
|
-
fields: CmsFieldDefinition[];
|
|
208
|
-
createdAt: string;
|
|
209
|
-
updatedAt: string;
|
|
210
|
-
}
|
|
211
|
-
type CmsEntryStatus = "draft" | "ready" | "published";
|
|
212
|
-
interface CmsSeoData {
|
|
213
|
-
title?: string;
|
|
214
|
-
description?: string;
|
|
215
|
-
ogImage?: string;
|
|
216
|
-
}
|
|
217
|
-
/** Published CMS entry. Returned by `getCmsEntries` / `getCmsEntry`. */
|
|
218
|
-
interface CmsEntry {
|
|
219
|
-
id: string;
|
|
220
|
-
collectionId: string;
|
|
221
|
-
slug: string;
|
|
222
|
-
status: CmsEntryStatus;
|
|
223
|
-
fields: Record<string, unknown>;
|
|
224
|
-
seo: CmsSeoData | null;
|
|
225
|
-
publishedAt: string | null;
|
|
226
|
-
createdAt: string;
|
|
227
|
-
updatedAt: string;
|
|
228
|
-
}
|
|
229
|
-
interface CmsEntriesResult {
|
|
230
|
-
entries: CmsEntry[];
|
|
231
|
-
total: number;
|
|
232
|
-
limit: number;
|
|
233
|
-
offset: number;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* App Router caching hints passed straight through to the underlying
|
|
237
|
-
* `fetch` call. See https://nextjs.org/docs/app/api-reference/functions/fetch.
|
|
238
|
-
*
|
|
239
|
-
* Typed loosely so this works in plain Node, Edge, Cloudflare Workers
|
|
240
|
-
* and Bun runtimes without Next-specific types being mandatory.
|
|
241
|
-
*/
|
|
242
|
-
interface RequestNextOptions {
|
|
243
|
-
revalidate?: number | false;
|
|
244
|
-
tags?: string[];
|
|
245
|
-
}
|
|
1
|
+
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters, A as AppliedSearchQuery, k as SearchUiDictionary, l as SearchUiOption, m as AppliedSearchChange, n as SearchUiFilter, o as QueryListingsFilters } from './listing-card-model-D7iR4asd.mjs';
|
|
2
|
+
export { p as CmsEntryStatus, q as CmsFieldDefinition, r as CmsFieldType, s as CmsSeoData, t as Listing, u as ListingBusinessType, v as ListingCardModel, w as ListingLocation, x as ListingMedia, y as ListingPriceVisibility, z as ListingPropertySummary, B as QueryListingsLocation, D as SearchPathLocation, E as listingLocationLabel, F as toListingCardModel } from './listing-card-model-D7iR4asd.mjs';
|
|
246
3
|
|
|
247
4
|
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
248
5
|
type FetchLike = typeof fetch;
|
|
@@ -275,6 +32,13 @@ interface SearchListingsOptions extends BaseOptions {
|
|
|
275
32
|
siteId: string;
|
|
276
33
|
params: SearchListingsParams;
|
|
277
34
|
}
|
|
35
|
+
interface GetSearchUiOptions extends BaseOptions {
|
|
36
|
+
siteId: string;
|
|
37
|
+
}
|
|
38
|
+
interface QueryListingsOptions extends BaseOptions {
|
|
39
|
+
siteId: string;
|
|
40
|
+
params?: QueryListingsParams;
|
|
41
|
+
}
|
|
278
42
|
interface GetSimilarListingsOptions extends BaseOptions {
|
|
279
43
|
siteId: string;
|
|
280
44
|
listingId: string;
|
|
@@ -338,8 +102,8 @@ declare function getSite(options: GetSiteOptions): Promise<Site | null>;
|
|
|
338
102
|
*
|
|
339
103
|
* Calls `POST /api/sites/{siteId}/search` directly and returns the raw
|
|
340
104
|
* Typesense response (`{ found, page, hits: [{ document, ... }], ... }`).
|
|
341
|
-
* Use when
|
|
342
|
-
*
|
|
105
|
+
* Use when `queryListings` isn't expressive enough — faceted search,
|
|
106
|
+
* multi-field sort, custom grouping, etc.
|
|
343
107
|
*
|
|
344
108
|
* @example
|
|
345
109
|
* const result = await searchListings({
|
|
@@ -359,6 +123,16 @@ declare function getSite(options: GetSiteOptions): Promise<Site | null>;
|
|
|
359
123
|
* }
|
|
360
124
|
*/
|
|
361
125
|
declare function searchListings<TDocument = Record<string, unknown>>(options: SearchListingsOptions): Promise<SearchListingsResult<TDocument>>;
|
|
126
|
+
/**
|
|
127
|
+
* Tenant search schema: filters, slugs, sort tokens, defaultLimit 12.
|
|
128
|
+
* Use this to render the search UI — do not hardcode property types.
|
|
129
|
+
*/
|
|
130
|
+
declare function getSearchUi(options: GetSearchUiOptions): Promise<SearchUi>;
|
|
131
|
+
/**
|
|
132
|
+
* Friendly catalog search (editor combinators). Prefer this over
|
|
133
|
+
* `searchListings` — that helper is a raw Typesense escape hatch.
|
|
134
|
+
*/
|
|
135
|
+
declare function queryListings(options: QueryListingsOptions): Promise<QueryListingsResult>;
|
|
362
136
|
/**
|
|
363
137
|
* Fetch similar listings for a detail page carousel.
|
|
364
138
|
* Returns an empty list when the reference listing is missing.
|
|
@@ -381,6 +155,118 @@ declare function listingPublicPath(listing: {
|
|
|
381
155
|
id?: string | null;
|
|
382
156
|
}): string;
|
|
383
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Presentation helpers with no UI framework.
|
|
160
|
+
* React / React Native / Flutter adapters consume these formatters and
|
|
161
|
+
* CSS custom-property names; they must not live inside JSX.
|
|
162
|
+
*/
|
|
163
|
+
declare const SEARCH_CSS_VARS: {
|
|
164
|
+
readonly cardRadius: "--garagem-listing-card-radius";
|
|
165
|
+
readonly cardGap: "--garagem-listing-card-gap";
|
|
166
|
+
readonly priceSize: "--garagem-listing-price-size";
|
|
167
|
+
readonly mediaRatio: "--garagem-listing-media-ratio";
|
|
168
|
+
};
|
|
169
|
+
declare const SEARCH_CSS_RECIPE: string;
|
|
170
|
+
declare function formatListingPrice(amount: number | null | undefined, locale?: string, currency?: string): string;
|
|
171
|
+
/** Input mask: `499000` → `"499.000"` (no currency symbol). */
|
|
172
|
+
declare function formatGroupedInteger(value: string | number | null | undefined, locale?: string): string;
|
|
173
|
+
/** Inverse of `formatGroupedInteger`: `"499.000"` / `"499000"` → `499000`. */
|
|
174
|
+
declare function parseGroupedInteger(value: unknown): number | undefined;
|
|
175
|
+
declare function formatAreaM2(area: number | null | undefined): string | null;
|
|
176
|
+
declare function listingBusinessLabel(businessType: string | undefined): string;
|
|
177
|
+
|
|
178
|
+
/** Query keys that must never encode filters (Editor/Studio path contract). */
|
|
179
|
+
declare const FORBIDDEN_SEARCH_QUERY_KEYS: readonly ["tipo", "quartos", "tipo-imovel", "banheiros", "vagas"];
|
|
180
|
+
/** Default option: omit `ordenar` (API has no relevance token). */
|
|
181
|
+
declare const SEARCH_SORT_RELEVANCE: {
|
|
182
|
+
readonly id: "";
|
|
183
|
+
readonly label: "Mais relevantes";
|
|
184
|
+
};
|
|
185
|
+
declare function searchSortOptions(sorts: Array<{
|
|
186
|
+
id: string;
|
|
187
|
+
label: string;
|
|
188
|
+
}> | undefined): Array<{
|
|
189
|
+
id: string;
|
|
190
|
+
label: string;
|
|
191
|
+
}>;
|
|
192
|
+
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
193
|
+
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
194
|
+
declare function isListingDetailPath(pathname: string): boolean;
|
|
195
|
+
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
196
|
+
pathFilters: SearchPathFilters;
|
|
197
|
+
applied: AppliedSearchQuery;
|
|
198
|
+
};
|
|
199
|
+
type LocationNameTables = {
|
|
200
|
+
states?: Record<string, string>;
|
|
201
|
+
cities?: Record<string, string>;
|
|
202
|
+
neighborhoods?: Record<string, string>;
|
|
203
|
+
streets?: Record<string, string>;
|
|
204
|
+
};
|
|
205
|
+
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
206
|
+
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
207
|
+
defaultLimit?: number;
|
|
208
|
+
} | null, locationValues?: LocationNameTables | null): QueryListingsParams;
|
|
209
|
+
declare function applyPathFilter(pathFilters: SearchPathFilters, filterId: string, value: unknown): SearchPathFilters;
|
|
210
|
+
declare function pathFilterValue(pathFilters: SearchPathFilters | undefined, filterId: string): string;
|
|
211
|
+
declare function pathFilterHasOption(pathFilters: SearchPathFilters | undefined, filterId: string, optionId: string): boolean;
|
|
212
|
+
declare function publicSearchHref(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, dictionary?: SearchUiDictionary, existingSearch?: string): string;
|
|
213
|
+
declare function hrefForPathFilters(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, nextPathFilters: SearchPathFilters): string;
|
|
214
|
+
declare function hrefForAppliedChange(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, change: AppliedSearchChange): string;
|
|
215
|
+
/** Canonical href if the current URL is out of generation order; otherwise null. */
|
|
216
|
+
declare function canonicalizeSearchHref(pathname: string, search: string, dictionary?: SearchUiDictionary): string | null;
|
|
217
|
+
declare function searchHrefUsesLegacyFilterQuery(href: string): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Drop staged filters. Location always stays until apply.
|
|
220
|
+
* `keepFilterIds` keeps toolbar-primary filters (price, bedrooms) so Limpar
|
|
221
|
+
* in the extra-filters dialog does not wipe values already on the toolbar.
|
|
222
|
+
*/
|
|
223
|
+
declare function clearStagedPathFilters(current: SearchPathFilters, keepFilterIds?: readonly string[]): SearchPathFilters;
|
|
224
|
+
declare function visibleSearchFilters(schema: SearchUi | null): SearchUiFilter[];
|
|
225
|
+
declare function toolbarFilterIds(schema: SearchUi | null): string[];
|
|
226
|
+
declare function countOptionLabel(option: Pick<SearchUiOption, "label">): string;
|
|
227
|
+
declare function countFacetChoices(options: SearchUiOption[] | undefined): Array<{
|
|
228
|
+
id: string;
|
|
229
|
+
label: string;
|
|
230
|
+
}>;
|
|
231
|
+
declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
|
|
232
|
+
|
|
233
|
+
declare function composeSearchPublicPath(filters: SearchPathFilters, dictionary?: SearchUiDictionary): string;
|
|
234
|
+
declare function parseSearchPublicPath(pathname: string, dictionary?: SearchUiDictionary): SearchPathFilters | null;
|
|
235
|
+
/**
|
|
236
|
+
* Convert `SearchPathFilters` (returned by `parseSearchPublicPath`) to
|
|
237
|
+
* `QueryListingsFilters` (accepted by `queryListings`).
|
|
238
|
+
*
|
|
239
|
+
* This maps path-based filter keys (`bedrooms`, `parkingSpots`, `area`)
|
|
240
|
+
* to the POST API keys (`property_bedrooms`, `property_parking_spots`,
|
|
241
|
+
* `property_area_total`).
|
|
242
|
+
*
|
|
243
|
+
* Location is **not** included — use `pathLocationToFilterInput` separately
|
|
244
|
+
* and pass the result as the `location` field in `QueryListingsParams`.
|
|
245
|
+
*/
|
|
246
|
+
declare function pathFiltersToQueryFilters(pathFilters: SearchPathFilters): QueryListingsFilters;
|
|
247
|
+
|
|
248
|
+
declare function parseAppliedSearchQuery(search: string | URLSearchParams): AppliedSearchQuery;
|
|
249
|
+
declare function serializeAppliedSearchQuery(query: AppliedSearchQuery): URLSearchParams;
|
|
250
|
+
declare function mergeAppliedSearchQueryIntoSearch(existing: string | URLSearchParams, query: AppliedSearchQuery): URLSearchParams;
|
|
251
|
+
declare function reduceAppliedSearchQuery(prev: AppliedSearchQuery, change: AppliedSearchChange): AppliedSearchQuery;
|
|
252
|
+
declare function composeSearchPublicHref(pathname: string, query: AppliedSearchQuery, existingSearch?: string | URLSearchParams): string;
|
|
253
|
+
|
|
254
|
+
type LocationFilterInput = {
|
|
255
|
+
type: string;
|
|
256
|
+
value: string;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Convert a SearchPathLocation (from parseSearchPublicPath) to the correct
|
|
260
|
+
* LocationFilterInput format for the friendly search API. This ensures that
|
|
261
|
+
* hierarchical location filters are ANDed correctly instead of ORed.
|
|
262
|
+
*/
|
|
263
|
+
declare function pathLocationToFilterInput(location: {
|
|
264
|
+
state?: string;
|
|
265
|
+
city?: string;
|
|
266
|
+
neighborhood?: string;
|
|
267
|
+
street?: string;
|
|
268
|
+
}): LocationFilterInput | null;
|
|
269
|
+
|
|
384
270
|
interface ResolvePublicSiteIdOptions {
|
|
385
271
|
/** Request host (`headers().get("host")`). Port is stripped. */
|
|
386
272
|
host?: string | null;
|
|
@@ -430,13 +316,24 @@ interface GaragemClient {
|
|
|
430
316
|
}): Promise<Site | null>;
|
|
431
317
|
/**
|
|
432
318
|
* Advanced search — raw Typesense parameters, raw response. Use when
|
|
433
|
-
*
|
|
319
|
+
* `queryListings` isn't expressive enough.
|
|
434
320
|
*/
|
|
435
321
|
searchListings<TDocument = Record<string, unknown>>(args: {
|
|
436
322
|
params: SearchListingsParams;
|
|
437
323
|
siteId?: string;
|
|
438
324
|
next?: RequestNextOptions;
|
|
439
325
|
}): Promise<SearchListingsResult<TDocument>>;
|
|
326
|
+
/** Tenant search schema (filters, slugs, defaultLimit). */
|
|
327
|
+
getSearchUi(args?: {
|
|
328
|
+
siteId?: string;
|
|
329
|
+
next?: RequestNextOptions;
|
|
330
|
+
}): Promise<SearchUi>;
|
|
331
|
+
/** Friendly catalog search — editor combinators, no Typesense `filter_by`. */
|
|
332
|
+
queryListings(args?: {
|
|
333
|
+
params?: QueryListingsParams;
|
|
334
|
+
siteId?: string;
|
|
335
|
+
next?: RequestNextOptions;
|
|
336
|
+
}): Promise<QueryListingsResult>;
|
|
440
337
|
/** Similar listings carousel for a detail page. */
|
|
441
338
|
getSimilarListings(args: {
|
|
442
339
|
listingId: string;
|
|
@@ -481,4 +378,4 @@ interface GaragemClient {
|
|
|
481
378
|
*/
|
|
482
379
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
483
380
|
|
|
484
|
-
export {
|
|
381
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, FORBIDDEN_SEARCH_QUERY_KEYS, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, type LocationNameTables, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, SEARCH_SORT_RELEVANCE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SearchUiFilter, SearchUiOption, SimilarListingsResult, Site, TOOLBAR_PRIMARY_FILTER_IDS, applyPathFilter, buildQueryListingsParams, canonicalizeSearchHref, clearStagedPathFilters, composeSearchPublicHref, composeSearchPublicPath, countFacetChoices, countOptionLabel, createGaragemClient, displayPathLocation, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, hrefForAppliedChange, hrefForPathFilters, isListingDetailPath, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, paginationPages, parseAppliedSearchQuery, parseGroupedInteger, parseSearchPublicPath, pathFilterHasOption, pathFilterValue, pathFiltersToQueryFilters, pathLocationToFilterInput, publicSearchHref, queryListings, readPublicSearch, reduceAppliedSearchQuery, resolvePublicSiteId, searchHrefUsesLegacyFilterQuery, searchListings, searchSortOptions, serializeAppliedSearchQuery, toolbarFilterIds, visibleSearchFilters };
|