@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/src/types.ts
CHANGED
|
@@ -139,6 +139,110 @@ export interface ListingsResult {
|
|
|
139
139
|
offset?: number;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
export type SearchUiOption = {
|
|
143
|
+
id: string;
|
|
144
|
+
slug: string;
|
|
145
|
+
label: string;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type SearchUiFilter = {
|
|
149
|
+
id: string;
|
|
150
|
+
label: string;
|
|
151
|
+
type: "enum" | "count" | "range";
|
|
152
|
+
options?: SearchUiOption[];
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export type SearchUiDictionary = {
|
|
156
|
+
listingTypes: SearchUiOption[];
|
|
157
|
+
propertyTypes: SearchUiOption[];
|
|
158
|
+
propertyFeatures: SearchUiOption[];
|
|
159
|
+
buildingAmenities: SearchUiOption[];
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/** Geo leftovers on a default-V2 search path (`/imoveis/...`). */
|
|
163
|
+
export type SearchPathLocation = {
|
|
164
|
+
state?: string;
|
|
165
|
+
city?: string;
|
|
166
|
+
neighborhood?: string;
|
|
167
|
+
street?: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Filters encoded in the public search pathname (not `?loc=`). */
|
|
171
|
+
export type SearchPathFilters = {
|
|
172
|
+
listingType?: ListingBusinessType | string;
|
|
173
|
+
propertyType?: string | string[];
|
|
174
|
+
location?: SearchPathLocation;
|
|
175
|
+
bedrooms?: number | number[];
|
|
176
|
+
bathrooms?: number | number[];
|
|
177
|
+
suites?: number | number[];
|
|
178
|
+
parkingSpots?: number | number[];
|
|
179
|
+
price?: { min?: number; max?: number };
|
|
180
|
+
area?: { min?: number; max?: number };
|
|
181
|
+
propertyFeatures?: string[];
|
|
182
|
+
buildingAmenities?: string[];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/** Query-string state on a search URL (`page`, `ordenar`, `q`, `loc`). */
|
|
186
|
+
export type AppliedSearchQuery = {
|
|
187
|
+
page?: number;
|
|
188
|
+
sort?: string | null;
|
|
189
|
+
query?: string;
|
|
190
|
+
loc?: string[];
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type AppliedSearchChange =
|
|
194
|
+
| { type: "sort"; sort: string | null }
|
|
195
|
+
| { type: "page"; page: number }
|
|
196
|
+
| { type: "query"; query: string }
|
|
197
|
+
| { type: "loc"; loc: string[] }
|
|
198
|
+
| { type: "applyFilters" };
|
|
199
|
+
|
|
200
|
+
/** Tenant search schema from `GET /search-ui`. */
|
|
201
|
+
export interface SearchUi {
|
|
202
|
+
defaultLimit: number;
|
|
203
|
+
maxLimit: number;
|
|
204
|
+
sorts: Array<{ id: string; label: string }>;
|
|
205
|
+
filters: SearchUiFilter[];
|
|
206
|
+
dictionary: SearchUiDictionary;
|
|
207
|
+
locationsPath: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export type QueryListingsFilters = {
|
|
211
|
+
listing_type?: string | string[];
|
|
212
|
+
property_type?: string | string[];
|
|
213
|
+
property_bedrooms?: string | string[] | number | number[];
|
|
214
|
+
property_bathrooms?: string | string[] | number | number[];
|
|
215
|
+
property_suites?: string | string[] | number | number[];
|
|
216
|
+
property_parking_spots?: string | string[] | number | number[];
|
|
217
|
+
propertyFeatures?: string[];
|
|
218
|
+
buildingAmenities?: string[];
|
|
219
|
+
price?: { min?: number; max?: number };
|
|
220
|
+
property_area_total?: { min?: number; max?: number };
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export type QueryListingsLocation = {
|
|
224
|
+
type: string;
|
|
225
|
+
value: string;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/** Friendly search body — Studio must not send Typesense `filter_by`. */
|
|
229
|
+
export interface QueryListingsParams {
|
|
230
|
+
page?: number;
|
|
231
|
+
limit?: number;
|
|
232
|
+
sort?: string;
|
|
233
|
+
q?: string;
|
|
234
|
+
filters?: QueryListingsFilters;
|
|
235
|
+
location?: QueryListingsLocation | QueryListingsLocation[];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface QueryListingsResult {
|
|
239
|
+
listings: Listing[];
|
|
240
|
+
page: number;
|
|
241
|
+
limit: number;
|
|
242
|
+
total: number;
|
|
243
|
+
totalPages: number;
|
|
244
|
+
}
|
|
245
|
+
|
|
142
246
|
/**
|
|
143
247
|
* Raw Typesense search parameters accepted by `searchListings`. Mirrors
|
|
144
248
|
* the same body the underlying `/api/sites/{siteId}/search` endpoint
|
|
@@ -146,10 +250,9 @@ export interface ListingsResult {
|
|
|
146
250
|
* `per_page`, `page`, facets, etc.) — see the Typesense docs at
|
|
147
251
|
* https://typesense.org/docs/latest/api/search.html for the full list.
|
|
148
252
|
*
|
|
149
|
-
* This is the SDK's escape hatch when
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* field is `q`.
|
|
253
|
+
* This is the SDK's escape hatch when `queryListings` isn't expressive
|
|
254
|
+
* enough (faceted search, multi-field sort, custom grouping). It's an
|
|
255
|
+
* open dictionary on purpose; the only required field is `q`.
|
|
153
256
|
*/
|
|
154
257
|
export interface SearchListingsParams {
|
|
155
258
|
q: string;
|