@garagem-ai/site-sdk 0.1.1 → 0.3.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 +149 -61
- package/dist/index.d.mts +347 -8
- package/dist/index.d.ts +347 -8
- package/dist/index.js +783 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +762 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -6
- package/src/applied-query.ts +42 -0
- package/src/client.ts +174 -29
- package/src/fetchers.ts +259 -16
- package/src/index.ts +61 -0
- package/src/internal/url.ts +4 -2
- package/src/listing-path.ts +19 -0
- package/src/loc-params.ts +36 -0
- package/src/path.ts +73 -0
- package/src/resolve-site-id.ts +55 -0
- package/src/types.ts +187 -4
package/src/types.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface ListingPropertySummary {
|
|
|
21
21
|
parkingSpaces: number;
|
|
22
22
|
totalArea: number;
|
|
23
23
|
usableArea: number;
|
|
24
|
+
/** Monthly condo fee in BRL when the listing has one. */
|
|
25
|
+
condoFee?: number;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/** Address breakdown returned with every listing. */
|
|
@@ -61,7 +63,16 @@ export interface ListingMedia {
|
|
|
61
63
|
* promotional flows) don't get masked as "sob consulta".
|
|
62
64
|
*/
|
|
63
65
|
export interface Listing {
|
|
66
|
+
/** Internal UUID — POST lead with this. Never put it in the URL. */
|
|
64
67
|
id: string;
|
|
68
|
+
/** Public identity for display (`#ABC`) and lookup. `null` if the row has no code. */
|
|
69
|
+
listingCode: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Canonical public href from the Sites API (`/imoveis/.../id-{listingCode}`).
|
|
72
|
+
* Prefer `listingPublicPath(listing)` so a missing `path` (CDN deploy
|
|
73
|
+
* window) still falls back to `/imoveis/id-{listingCode}`.
|
|
74
|
+
*/
|
|
75
|
+
path: string;
|
|
65
76
|
title: string;
|
|
66
77
|
description: string;
|
|
67
78
|
businessType: ListingBusinessType;
|
|
@@ -128,6 +139,110 @@ export interface ListingsResult {
|
|
|
128
139
|
offset?: number;
|
|
129
140
|
}
|
|
130
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
|
+
|
|
131
246
|
/**
|
|
132
247
|
* Raw Typesense search parameters accepted by `searchListings`. Mirrors
|
|
133
248
|
* the same body the underlying `/api/sites/{siteId}/search` endpoint
|
|
@@ -135,10 +250,9 @@ export interface ListingsResult {
|
|
|
135
250
|
* `per_page`, `page`, facets, etc.) — see the Typesense docs at
|
|
136
251
|
* https://typesense.org/docs/latest/api/search.html for the full list.
|
|
137
252
|
*
|
|
138
|
-
* This is the SDK's escape hatch when
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* 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`.
|
|
142
256
|
*/
|
|
143
257
|
export interface SearchListingsParams {
|
|
144
258
|
q: string;
|
|
@@ -181,6 +295,75 @@ export interface Site {
|
|
|
181
295
|
tenantId: string;
|
|
182
296
|
}
|
|
183
297
|
|
|
298
|
+
/** Wrapped response from `getSimilarListings`. */
|
|
299
|
+
export interface SimilarListingsResult {
|
|
300
|
+
listings: Listing[];
|
|
301
|
+
total: number;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** CMS field type mirrored from the public CMS worker. */
|
|
305
|
+
export type CmsFieldType =
|
|
306
|
+
| "text"
|
|
307
|
+
| "richText"
|
|
308
|
+
| "image"
|
|
309
|
+
| "date"
|
|
310
|
+
| "select"
|
|
311
|
+
| "number"
|
|
312
|
+
| "url"
|
|
313
|
+
| "entry-reference";
|
|
314
|
+
|
|
315
|
+
export interface CmsFieldDefinition {
|
|
316
|
+
id: string;
|
|
317
|
+
label: string;
|
|
318
|
+
type: CmsFieldType;
|
|
319
|
+
required?: boolean;
|
|
320
|
+
placeholder?: string;
|
|
321
|
+
options?: string[];
|
|
322
|
+
targetCollection?: string;
|
|
323
|
+
displayField?: string;
|
|
324
|
+
inheritFields?: string[];
|
|
325
|
+
inheritLevelField?: boolean;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** CMS collection schema. Returned by `getCmsCollections` / `getCmsCollection`. */
|
|
329
|
+
export interface CmsCollection {
|
|
330
|
+
id: string;
|
|
331
|
+
name: string;
|
|
332
|
+
slug: string;
|
|
333
|
+
templatePageId: string | null;
|
|
334
|
+
fields: CmsFieldDefinition[];
|
|
335
|
+
createdAt: string;
|
|
336
|
+
updatedAt: string;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export type CmsEntryStatus = "draft" | "ready" | "published";
|
|
340
|
+
|
|
341
|
+
export interface CmsSeoData {
|
|
342
|
+
title?: string;
|
|
343
|
+
description?: string;
|
|
344
|
+
ogImage?: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Published CMS entry. Returned by `getCmsEntries` / `getCmsEntry`. */
|
|
348
|
+
export interface CmsEntry {
|
|
349
|
+
id: string;
|
|
350
|
+
collectionId: string;
|
|
351
|
+
slug: string;
|
|
352
|
+
status: CmsEntryStatus;
|
|
353
|
+
fields: Record<string, unknown>;
|
|
354
|
+
seo: CmsSeoData | null;
|
|
355
|
+
publishedAt: string | null;
|
|
356
|
+
createdAt: string;
|
|
357
|
+
updatedAt: string;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface CmsEntriesResult {
|
|
361
|
+
entries: CmsEntry[];
|
|
362
|
+
total: number;
|
|
363
|
+
limit: number;
|
|
364
|
+
offset: number;
|
|
365
|
+
}
|
|
366
|
+
|
|
184
367
|
/**
|
|
185
368
|
* App Router caching hints passed straight through to the underlying
|
|
186
369
|
* `fetch` call. See https://nextjs.org/docs/app/api-reference/functions/fetch.
|