@garagem-ai/site-sdk 0.4.10 → 0.4.11

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.
@@ -20,6 +20,13 @@ interface ListingPropertySummary {
20
20
  usableArea: number;
21
21
  /** Monthly condo fee in BRL when the listing has one. */
22
22
  condoFee?: number;
23
+ /** Annual or listed IPTU in BRL when the listing has one. */
24
+ propertyTax?: number;
25
+ /**
26
+ * Living-room count from the catalog (`custom.salas`). Not total rooms
27
+ * and not `bedrooms`.
28
+ */
29
+ rooms?: number;
23
30
  }
24
31
  /** Address breakdown returned with every listing. */
25
32
  interface ListingLocation {
@@ -106,7 +113,7 @@ interface ListingDetail extends Listing {
106
113
  id: string;
107
114
  builtArea?: number;
108
115
  landArea?: number;
109
- floor?: number;
116
+ floor?: number | string;
110
117
  totalFloors?: number;
111
118
  yearBuilt?: number;
112
119
  furnished?: boolean;
@@ -477,4 +484,4 @@ declare function searchResultsHeading(pathFilters: SearchPathFilters, dictionary
477
484
  declare function hrefWithExplicitPage(href: string, page: number): string;
478
485
  declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
479
486
 
480
- export { publicSearchHref as $, type AppliedSearchQuery as A, SEARCH_SORT_RELEVANCE as B, type CmsCollection as C, type SearchPathLocation as D, type SearchUiFilter as E, FORBIDDEN_SEARCH_QUERY_KEYS as F, type SearchUiOption as G, applyPathFilter as H, buildQueryListingsParams as I, canonicalizeSearchHref as J, clearStagedPathFilters as K, type ListingFilters as L, countFacetChoices as M, countOptionLabel as N, displayPathLocation as O, hrefForAppliedChange as P, type QueryListingsParams as Q, type RequestNextOptions as R, type SearchListingsParams as S, TOOLBAR_PRIMARY_FILTER_IDS as T, hrefForPathFilters as U, hrefWithExplicitPage as V, isListingDetailPath as W, listingLocationLabel as X, paginationPages as Y, pathFilterHasOption as Z, pathFilterValue as _, type CmsEntriesResult as a, readPublicSearch as a0, searchHrefUsesLegacyFilterQuery as a1, searchResultsHeading as a2, searchSortOptions as a3, toListingCardModel as a4, toolbarFilterIds as a5, visibleSearchFilters as a6, type CmsEntry as b, type ListingDetail as c, type ListingsResult as d, type SearchUi as e, type SimilarListingsResult as f, type Site as g, type QueryListingsResult as h, type SearchListingsResult as i, type SearchPathFilters as j, type SearchUiDictionary as k, type QueryListingsFilters as l, type AppliedSearchChange as m, type CmsEntryStatus as n, type CmsFieldDefinition as o, type CmsFieldType as p, type CmsSeoData as q, type Listing as r, type ListingBusinessType as s, type ListingCardModel as t, type ListingLocation as u, type ListingMedia as v, type ListingPriceVisibility as w, type ListingPropertySummary as x, type LocationNameTables as y, type QueryListingsLocation as z };
487
+ export { publicSearchHref as $, type AppliedSearchQuery as A, SEARCH_SORT_RELEVANCE as B, type CmsCollection as C, type SearchPathLocation as D, type SearchUiFilter as E, FORBIDDEN_SEARCH_QUERY_KEYS as F, type SearchUiOption as G, applyPathFilter as H, buildQueryListingsParams as I, canonicalizeSearchHref as J, clearStagedPathFilters as K, type ListingFilters as L, countFacetChoices as M, countOptionLabel as N, displayPathLocation as O, hrefForAppliedChange as P, type QueryListingsParams as Q, type RequestNextOptions as R, type SearchListingsParams as S, TOOLBAR_PRIMARY_FILTER_IDS as T, hrefForPathFilters as U, hrefWithExplicitPage as V, isListingDetailPath as W, listingLocationLabel as X, paginationPages as Y, pathFilterHasOption as Z, pathFilterValue as _, type CmsEntriesResult as a, readPublicSearch as a0, searchHrefUsesLegacyFilterQuery as a1, searchResultsHeading as a2, searchSortOptions as a3, toListingCardModel as a4, toolbarFilterIds as a5, visibleSearchFilters as a6, type CmsEntry as b, type ListingDetail as c, type ListingsResult as d, type SearchUi as e, type SimilarListingsResult as f, type Site as g, type QueryListingsResult as h, type SearchListingsResult as i, type ListingLocation as j, type ListingMedia as k, type SearchPathFilters as l, type SearchUiDictionary as m, type QueryListingsFilters as n, type AppliedSearchChange as o, type CmsEntryStatus as p, type CmsFieldDefinition as q, type CmsFieldType as r, type CmsSeoData as s, type Listing as t, type ListingBusinessType as u, type ListingCardModel as v, type ListingPriceVisibility as w, type ListingPropertySummary as x, type LocationNameTables as y, type QueryListingsLocation as z };
@@ -20,6 +20,13 @@ interface ListingPropertySummary {
20
20
  usableArea: number;
21
21
  /** Monthly condo fee in BRL when the listing has one. */
22
22
  condoFee?: number;
23
+ /** Annual or listed IPTU in BRL when the listing has one. */
24
+ propertyTax?: number;
25
+ /**
26
+ * Living-room count from the catalog (`custom.salas`). Not total rooms
27
+ * and not `bedrooms`.
28
+ */
29
+ rooms?: number;
23
30
  }
24
31
  /** Address breakdown returned with every listing. */
25
32
  interface ListingLocation {
@@ -106,7 +113,7 @@ interface ListingDetail extends Listing {
106
113
  id: string;
107
114
  builtArea?: number;
108
115
  landArea?: number;
109
- floor?: number;
116
+ floor?: number | string;
110
117
  totalFloors?: number;
111
118
  yearBuilt?: number;
112
119
  furnished?: boolean;
@@ -477,4 +484,4 @@ declare function searchResultsHeading(pathFilters: SearchPathFilters, dictionary
477
484
  declare function hrefWithExplicitPage(href: string, page: number): string;
478
485
  declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
479
486
 
480
- export { publicSearchHref as $, type AppliedSearchQuery as A, SEARCH_SORT_RELEVANCE as B, type CmsCollection as C, type SearchPathLocation as D, type SearchUiFilter as E, FORBIDDEN_SEARCH_QUERY_KEYS as F, type SearchUiOption as G, applyPathFilter as H, buildQueryListingsParams as I, canonicalizeSearchHref as J, clearStagedPathFilters as K, type ListingFilters as L, countFacetChoices as M, countOptionLabel as N, displayPathLocation as O, hrefForAppliedChange as P, type QueryListingsParams as Q, type RequestNextOptions as R, type SearchListingsParams as S, TOOLBAR_PRIMARY_FILTER_IDS as T, hrefForPathFilters as U, hrefWithExplicitPage as V, isListingDetailPath as W, listingLocationLabel as X, paginationPages as Y, pathFilterHasOption as Z, pathFilterValue as _, type CmsEntriesResult as a, readPublicSearch as a0, searchHrefUsesLegacyFilterQuery as a1, searchResultsHeading as a2, searchSortOptions as a3, toListingCardModel as a4, toolbarFilterIds as a5, visibleSearchFilters as a6, type CmsEntry as b, type ListingDetail as c, type ListingsResult as d, type SearchUi as e, type SimilarListingsResult as f, type Site as g, type QueryListingsResult as h, type SearchListingsResult as i, type SearchPathFilters as j, type SearchUiDictionary as k, type QueryListingsFilters as l, type AppliedSearchChange as m, type CmsEntryStatus as n, type CmsFieldDefinition as o, type CmsFieldType as p, type CmsSeoData as q, type Listing as r, type ListingBusinessType as s, type ListingCardModel as t, type ListingLocation as u, type ListingMedia as v, type ListingPriceVisibility as w, type ListingPropertySummary as x, type LocationNameTables as y, type QueryListingsLocation as z };
487
+ export { publicSearchHref as $, type AppliedSearchQuery as A, SEARCH_SORT_RELEVANCE as B, type CmsCollection as C, type SearchPathLocation as D, type SearchUiFilter as E, FORBIDDEN_SEARCH_QUERY_KEYS as F, type SearchUiOption as G, applyPathFilter as H, buildQueryListingsParams as I, canonicalizeSearchHref as J, clearStagedPathFilters as K, type ListingFilters as L, countFacetChoices as M, countOptionLabel as N, displayPathLocation as O, hrefForAppliedChange as P, type QueryListingsParams as Q, type RequestNextOptions as R, type SearchListingsParams as S, TOOLBAR_PRIMARY_FILTER_IDS as T, hrefForPathFilters as U, hrefWithExplicitPage as V, isListingDetailPath as W, listingLocationLabel as X, paginationPages as Y, pathFilterHasOption as Z, pathFilterValue as _, type CmsEntriesResult as a, readPublicSearch as a0, searchHrefUsesLegacyFilterQuery as a1, searchResultsHeading as a2, searchSortOptions as a3, toListingCardModel as a4, toolbarFilterIds as a5, visibleSearchFilters as a6, type CmsEntry as b, type ListingDetail as c, type ListingsResult as d, type SearchUi as e, type SimilarListingsResult as f, type Site as g, type QueryListingsResult as h, type SearchListingsResult as i, type ListingLocation as j, type ListingMedia as k, type SearchPathFilters as l, type SearchUiDictionary as m, type QueryListingsFilters as n, type AppliedSearchChange as o, type CmsEntryStatus as p, type CmsFieldDefinition as q, type CmsFieldType as r, type CmsSeoData as s, type Listing as t, type ListingBusinessType as u, type ListingCardModel as v, type ListingPriceVisibility as w, type ListingPropertySummary as x, type LocationNameTables as y, type QueryListingsLocation as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garagem-ai/site-sdk",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
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
@@ -128,6 +128,24 @@ export {
128
128
 
129
129
  export { listingLookupKey, listingPublicPath } from "./listing-path";
130
130
 
131
+ export {
132
+ LISTING_DESCRIPTION_CLAMP,
133
+ listingBreadcrumb,
134
+ listingDescriptionPreview,
135
+ listingDetailModel,
136
+ listingFacts,
137
+ listingLocationBlock,
138
+ listingMapsHref,
139
+ listingMediaOverlays,
140
+ listingValues,
141
+ type ListingBreadcrumbCrumb,
142
+ type ListingDescriptionPreview,
143
+ type ListingFact,
144
+ type ListingLocationBlock,
145
+ type ListingMediaOverlay,
146
+ type ListingValue,
147
+ } from "./listing-detail";
148
+
131
149
  export {
132
150
  toListingCardModel,
133
151
  listingLocationLabel,
@@ -209,6 +227,7 @@ export {
209
227
  studioLayoutInstruction,
210
228
  studioAmenityInstruction,
211
229
  studioLeadInstruction,
230
+ studioListingDetailInstruction,
212
231
  studioSearchLandmarkInstruction,
213
232
  studioSdkPinInstruction,
214
233
  studioSiteWidthCss,
@@ -0,0 +1,357 @@
1
+ import { listingLocationLabel } from "./listing-card-model";
2
+ import { listingPublicPath } from "./listing-path";
3
+ import { formatAreaM2, formatListingPrice } from "./presentation";
4
+ import { isListingDetailPath } from "./search-engine";
5
+ import type { ListingDetail, ListingLocation, ListingMedia } from "./types";
6
+
7
+ export const LISTING_DESCRIPTION_CLAMP = 280;
8
+
9
+ const VIDEO_HOST_HINTS = [
10
+ "youtube.com",
11
+ "youtu.be",
12
+ "vimeo.com",
13
+ "wistia.com",
14
+ "wistia.net",
15
+ ] as const;
16
+
17
+ const BREADCRUMB_LABELS: Record<string, string> = {
18
+ imoveis: "Imóveis",
19
+ venda: "Venda",
20
+ aluguel: "Aluguel",
21
+ rental: "Aluguel",
22
+ sale: "Venda",
23
+ };
24
+
25
+ export type ListingFact = { key: string; label: string; text: string };
26
+ export type ListingValue = { key: string; label: string; text: string };
27
+ export type ListingBreadcrumbCrumb = { label: string; href: string };
28
+ export type ListingLocationBlock = { label: string; mapsHref: string | null };
29
+ export type ListingDescriptionPreview = {
30
+ text: string;
31
+ truncated: boolean;
32
+ toggleLabel: string | null;
33
+ };
34
+ export type ListingMediaOverlay = {
35
+ key: "video" | "tour";
36
+ hash: "video" | "tour";
37
+ title: string;
38
+ href: string;
39
+ embedSrc: string;
40
+ };
41
+
42
+ function finiteNumber(value: unknown): number | null {
43
+ if (typeof value === "number" && Number.isFinite(value)) return value;
44
+ if (typeof value === "string" && value.trim() !== "") {
45
+ const parsed = Number(value);
46
+ if (Number.isFinite(parsed)) return parsed;
47
+ }
48
+ return null;
49
+ }
50
+
51
+ function positiveCount(value: unknown): number | null {
52
+ const amount = finiteNumber(value);
53
+ return amount != null && amount > 0 ? amount : null;
54
+ }
55
+
56
+ function formatFloorFact(value: unknown): string | null {
57
+ if (typeof value === "number" && Number.isFinite(value)) {
58
+ return value === 0 ? "Térreo" : String(value);
59
+ }
60
+ if (typeof value !== "string") return null;
61
+ const trimmed = value.trim();
62
+ if (!trimmed) return null;
63
+ const parsed = Number(trimmed);
64
+ if (Number.isFinite(parsed) && trimmed === String(parsed)) {
65
+ return parsed === 0 ? "Térreo" : trimmed;
66
+ }
67
+ return trimmed;
68
+ }
69
+
70
+ function httpsUrl(raw: string | null | undefined): string | null {
71
+ if (!raw) return null;
72
+ try {
73
+ const url = new URL(raw);
74
+ if (url.protocol !== "https:") return null;
75
+ return url.toString();
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
80
+
81
+ function isVideoPlatformUrl(url: string): boolean {
82
+ const host = new URL(url).hostname.toLowerCase();
83
+ return VIDEO_HOST_HINTS.some(
84
+ (hint) => host === hint || host.endsWith(`.${hint}`)
85
+ );
86
+ }
87
+
88
+ function overlayKind(
89
+ type: string | undefined,
90
+ src: string
91
+ ): "video" | "tour" | null {
92
+ if (type === "image" || type === "photo") return null;
93
+ const host = new URL(src).hostname.toLowerCase();
94
+ if (
95
+ type === "tour" ||
96
+ type === "virtual_tour" ||
97
+ host.includes("matterport")
98
+ ) {
99
+ return "tour";
100
+ }
101
+ if (isVideoPlatformUrl(src) || type === "video") return "video";
102
+ return type ? "tour" : null;
103
+ }
104
+
105
+ /** Mirrors `@garagem/ui` `extractVimeoVideoId` — site-sdk cannot import that package. */
106
+ const VIMEO_ID_RE =
107
+ /vimeo\.com\/(?:video\/|channels\/[^/]+\/|groups\/[^/]+\/videos\/)?(\d+)/i;
108
+ const WISTIA_ID_RE = /\/(?:medias|embed\/(?:iframe|medias))\/([a-zA-Z0-9]+)/i;
109
+
110
+ function vimeoPrivacyHash(url: URL, id: string): string | null {
111
+ const fromQuery = url.searchParams.get("h");
112
+ if (fromQuery) return fromQuery;
113
+ const segments = url.pathname.split("/").filter(Boolean);
114
+ const idIndex = segments.indexOf(id);
115
+ const next = idIndex >= 0 ? segments[idIndex + 1] : undefined;
116
+ return next && /^[a-f0-9]{6,12}$/i.test(next) ? next : null;
117
+ }
118
+
119
+ function embedSrc(src: string): string {
120
+ const url = new URL(src);
121
+ const host = url.hostname.toLowerCase();
122
+ if (host === "youtu.be" || host.endsWith(".youtu.be")) {
123
+ const id = url.pathname.replace(/^\//, "").split("/")[0];
124
+ return id ? `https://www.youtube.com/embed/${id}` : src;
125
+ }
126
+ if (host.includes("youtube.com")) {
127
+ const id = url.searchParams.get("v") || url.pathname.split("/").pop();
128
+ return id ? `https://www.youtube.com/embed/${id}` : src;
129
+ }
130
+ if (host.includes("player.vimeo.com")) return src;
131
+ if (host.includes("vimeo.com")) {
132
+ const id = src.match(VIMEO_ID_RE)?.[1];
133
+ if (!id) return src;
134
+ const hash = vimeoPrivacyHash(url, id);
135
+ return hash
136
+ ? `https://player.vimeo.com/video/${id}?h=${encodeURIComponent(hash)}`
137
+ : `https://player.vimeo.com/video/${id}`;
138
+ }
139
+ if (host.includes("wistia.com") || host.includes("wistia.net")) {
140
+ if (src.includes("/embed/iframe/")) return src;
141
+ const id = src.match(WISTIA_ID_RE)?.[1];
142
+ return id ? `https://fast.wistia.net/embed/iframe/${id}` : src;
143
+ }
144
+ return src;
145
+ }
146
+
147
+ function crumbLabel(segment: string): string {
148
+ const mapped = BREADCRUMB_LABELS[segment];
149
+ if (mapped) return mapped;
150
+ if (/^[a-z]{2}$/.test(segment)) return segment.toUpperCase();
151
+ return segment
152
+ .split("-")
153
+ .filter(Boolean)
154
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
155
+ .join(" ");
156
+ }
157
+
158
+ export function listingValues(listing: {
159
+ price?: number | null;
160
+ priceVisibility?: string | null;
161
+ property?: { condoFee?: number | null; propertyTax?: number | null } | null;
162
+ }): ListingValue[] {
163
+ const values: ListingValue[] = [
164
+ {
165
+ key: "price",
166
+ label: "Preço",
167
+ text:
168
+ listing.priceVisibility === "private"
169
+ ? "Sob consulta"
170
+ : formatListingPrice(listing.price),
171
+ },
172
+ ];
173
+ const condoFee = positiveCount(listing.property?.condoFee);
174
+ if (condoFee != null) {
175
+ values.push({
176
+ key: "condoFee",
177
+ label: "Condomínio",
178
+ text: formatListingPrice(condoFee),
179
+ });
180
+ }
181
+ const propertyTax = positiveCount(listing.property?.propertyTax);
182
+ if (propertyTax != null) {
183
+ values.push({
184
+ key: "propertyTax",
185
+ label: "IPTU",
186
+ text: formatListingPrice(propertyTax),
187
+ });
188
+ }
189
+ return values;
190
+ }
191
+
192
+ export function listingFacts(listing: {
193
+ property?: {
194
+ totalArea?: number | null;
195
+ usableArea?: number | null;
196
+ bedrooms?: number | null;
197
+ suites?: number | null;
198
+ parkingSpaces?: number | null;
199
+ rooms?: number | null;
200
+ floor?: number | string | null;
201
+ } | null;
202
+ }): ListingFact[] {
203
+ const property = listing.property ?? {};
204
+ const facts: ListingFact[] = [];
205
+ const area = formatAreaM2(
206
+ positiveCount(property.usableArea) ?? positiveCount(property.totalArea)
207
+ );
208
+ if (area) facts.push({ key: "area", label: "Área", text: area });
209
+ const bedrooms = positiveCount(property.bedrooms);
210
+ if (bedrooms != null) {
211
+ facts.push({
212
+ key: "bedrooms",
213
+ label: "Dormitórios",
214
+ text: String(bedrooms),
215
+ });
216
+ }
217
+ const suites = positiveCount(property.suites);
218
+ if (suites != null) {
219
+ facts.push({ key: "suites", label: "Suítes", text: String(suites) });
220
+ }
221
+ const parking = positiveCount(property.parkingSpaces);
222
+ if (parking != null) {
223
+ facts.push({ key: "parkingSpaces", label: "Vagas", text: String(parking) });
224
+ }
225
+ const rooms = positiveCount(property.rooms);
226
+ if (rooms != null) {
227
+ facts.push({ key: "rooms", label: "Salas", text: String(rooms) });
228
+ }
229
+ const floorText = formatFloorFact(property.floor);
230
+ if (floorText) {
231
+ facts.push({ key: "floor", label: "Andar", text: floorText });
232
+ }
233
+ return facts;
234
+ }
235
+
236
+ export function listingMapsHref(
237
+ location: ListingLocation | null | undefined
238
+ ): string | null {
239
+ if (!location) return null;
240
+ const lat = finiteNumber(location.coordinates?.lat);
241
+ const lng = finiteNumber(location.coordinates?.lng);
242
+ if (lat != null && lng != null && !(lat === 0 && lng === 0)) {
243
+ return `https://www.google.com/maps/search/?api=1&query=${lat},${lng}`;
244
+ }
245
+ const query = [
246
+ [location.street, location.number].filter(Boolean).join(" ").trim(),
247
+ location.neighborhood,
248
+ location.city,
249
+ location.state,
250
+ ]
251
+ .map((part) => (part ? String(part).trim() : ""))
252
+ .filter(Boolean)
253
+ .join(", ");
254
+ if (!query) return null;
255
+ return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`;
256
+ }
257
+
258
+ export function listingLocationBlock(
259
+ listing: { location?: ListingLocation | null } | null | undefined
260
+ ): ListingLocationBlock | null {
261
+ const location = listing?.location;
262
+ if (!location) return null;
263
+ const street = [location.street, location.number]
264
+ .filter(Boolean)
265
+ .join(" ")
266
+ .trim();
267
+ const label = street || listingLocationLabel(location);
268
+ const mapsHref = listingMapsHref(location);
269
+ if (!label && !mapsHref) return null;
270
+ return { label, mapsHref };
271
+ }
272
+
273
+ export function listingBreadcrumb(listing: {
274
+ path?: string | null;
275
+ listingCode?: string | null;
276
+ id?: string | null;
277
+ }): ListingBreadcrumbCrumb[] {
278
+ const path = listingPublicPath(listing);
279
+ const segments = path.split("/").filter(Boolean);
280
+ if (segments[0] !== "imoveis") return [];
281
+ const crumbs: ListingBreadcrumbCrumb[] = [
282
+ { label: "Imóveis", href: "/imoveis" },
283
+ ];
284
+ let href = "/imoveis";
285
+ for (const segment of segments.slice(1)) {
286
+ if (segment.startsWith("id-")) break;
287
+ href = `${href}/${segment}`;
288
+ if (isListingDetailPath(href)) continue;
289
+ crumbs.push({ label: crumbLabel(segment), href });
290
+ }
291
+ return crumbs;
292
+ }
293
+
294
+ export function listingDescriptionPreview(
295
+ description: string | null | undefined,
296
+ expanded = false
297
+ ): ListingDescriptionPreview | null {
298
+ const text = description?.trim() ?? "";
299
+ if (!text) return null;
300
+ if (text.length <= LISTING_DESCRIPTION_CLAMP) {
301
+ return { text, truncated: false, toggleLabel: null };
302
+ }
303
+ if (expanded) {
304
+ return { text, truncated: true, toggleLabel: "Ler menos" };
305
+ }
306
+ return {
307
+ text: `${text.slice(0, LISTING_DESCRIPTION_CLAMP).trimEnd()}…`,
308
+ truncated: true,
309
+ toggleLabel: "Ler mais",
310
+ };
311
+ }
312
+
313
+ export function listingMediaOverlays(listing: {
314
+ media?: ListingMedia[] | null;
315
+ }): ListingMediaOverlay[] {
316
+ const overlays: ListingMediaOverlay[] = [];
317
+ const seen = new Set<"video" | "tour">();
318
+ for (const item of listing.media ?? []) {
319
+ const src = httpsUrl(item.src);
320
+ if (!src) continue;
321
+ const kind = overlayKind(item.type, src);
322
+ if (!kind || seen.has(kind)) continue;
323
+ seen.add(kind);
324
+ overlays.push({
325
+ key: kind,
326
+ hash: kind,
327
+ title: kind === "video" ? "Vídeo" : "Tour virtual",
328
+ href: `#${kind}`,
329
+ embedSrc: embedSrc(src),
330
+ });
331
+ }
332
+ return overlays;
333
+ }
334
+
335
+ export function listingDetailModel(
336
+ listing: Pick<
337
+ ListingDetail,
338
+ "id" | "listingCode" | "path" | "price" | "priceVisibility" | "description"
339
+ > & {
340
+ property?: ListingDetail["property"] | null;
341
+ location?: ListingLocation | null;
342
+ media?: ListingMedia[] | null;
343
+ },
344
+ options?: { descriptionExpanded?: boolean }
345
+ ) {
346
+ return {
347
+ breadcrumb: listingBreadcrumb(listing),
348
+ values: listingValues(listing),
349
+ facts: listingFacts(listing),
350
+ location: listingLocationBlock(listing),
351
+ description: listingDescriptionPreview(
352
+ listing.description,
353
+ options?.descriptionExpanded === true
354
+ ),
355
+ mediaOverlays: listingMediaOverlays(listing),
356
+ };
357
+ }
@@ -1,5 +1,5 @@
1
1
  /* Generated by scripts/build-search-chrome-css.mjs — do not edit. */
2
2
  /* eslint-disable */
3
3
  /* prettier-ignore */
4
- export const SEARCH_CHROME_CSS_VERSION = "0.4.10";
4
+ export const SEARCH_CHROME_CSS_VERSION = "0.4.11";
5
5
  export const SEARCH_CHROME_CSS = ":root{--garagem-listing-card-radius:0.75rem;--garagem-listing-card-gap:1.5rem;--garagem-listing-price-size:1.125rem;--garagem-listing-media-ratio:4 / 3;--garagem-search-control-height:2.75rem;--garagem-search-icon-size:1.25rem;--garagem-search-radius:var(--radius,0.75rem);--garagem-skeleton:var(--muted,#e7e5e4)}[data-slot=\"search-heading\"]{display:flex;min-width:0;align-items:baseline;gap:0.375rem;font-size:1.25rem;font-weight:600}[data-slot=\"search-heading-count\"]{flex-shrink:0}[data-slot=\"search-heading-title\"]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:inherit;font-weight:inherit}[data-slot=\"search-query-sort\"]{display:flex;flex-direction:column;gap:1rem}@media (min-width:1024px){[data-slot=\"search-query-sort\"]{flex-direction:row;align-items:flex-end}}[data-slot=\"search-query\"]{flex:1;min-width:0}[data-slot=\"search-query-input\"],[data-slot=\"search-sort-trigger\"],[data-slot=\"search-toolbar-trigger\"],[data-slot=\"search-filters-trigger\"]{min-height:var(--garagem-search-control-height)}[data-slot=\"search-query-field\"]{position:relative}[data-slot=\"search-query-input\"]{width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 5.5rem 0.5rem 1rem;outline:none}[data-slot=\"search-query-actions\"]{position:absolute;top:50%;right:0.35rem;display:flex;transform:translateY(-50%);align-items:center;gap:0.15rem}[data-slot=\"search-icon-button\"]{display:inline-flex;height:2.25rem;width:2.25rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:999px;background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot=\"search-icon-button\"][data-kind=\"clear\"]{background:transparent;color:var(--muted-foreground,#737373)}[data-slot=\"search-icon\"]{width:var(--garagem-search-icon-size);height:var(--garagem-search-icon-size);display:block}[data-slot=\"search-sort\"]{display:flex;flex-direction:column;gap:0.25rem}[data-slot=\"search-sort-trigger\"]{appearance:none;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 2.25rem 0.5rem 0.75rem;background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>\");background-repeat:no-repeat;background-position:right 0.65rem center}[data-slot=\"search-toolbar\"]{display:flex;flex-wrap:wrap;align-items:flex-end;gap:0.5rem}[data-slot=\"search-toolbar-trigger\"],[data-slot=\"search-filters-trigger\"]{cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 0.75rem;font-size:0.875rem}[data-slot=\"search-popover\"]{position:absolute;z-index:30;margin-top:0.5rem;width:18rem;border-radius:0.75rem;border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:1rem;box-shadow:0 10px 30px rgb(0 0 0 / 0.12);animation:garagem-search-in 140ms ease-out}[data-slot=\"search-grid\"],[data-slot=\"search-skeleton\"]{display:grid;grid-template-columns:1fr;gap:var(--garagem-listing-card-gap)}@media (min-width:640px){[data-slot=\"search-grid\"],[data-slot=\"search-skeleton\"]{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:1024px){[data-slot=\"search-grid\"],[data-slot=\"search-skeleton\"]{grid-template-columns:repeat(3,minmax(0,1fr))}}[data-slot=\"listing-card\"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7);background:var(--card,var(--background,#fff))}[data-slot=\"listing-card-price-row\"]{display:inline-flex;align-items:baseline;gap:0.25rem}[data-slot=\"listing-card-price\"]{font-size:var(--garagem-listing-price-size);font-weight:600}[data-slot=\"listing-card-period\"]{font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-checkbox\"]{appearance:none;width:1.15rem;height:1.15rem;flex-shrink:0;cursor:pointer;border:1px solid var(--primary,#111);border-radius:0.25rem;background:var(--background,#fff)}[data-slot=\"search-checkbox\"]:checked{background-color:var(--primary,#111);background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'><path d='M5 12l5 5L20 7'/></svg>\");background-repeat:no-repeat;background-position:center;background-size:0.8rem}[data-slot=\"search-scroll\"]{max-height:12rem;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--muted-foreground,#a1a1aa) transparent}[data-slot=\"search-range-apply\"]{display:inline-flex;min-height:2.5rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:var(--garagem-search-radius);background:var(--primary,#111);color:var(--primary-foreground,#fff);padding:0 0.75rem;font-size:0.75rem;font-weight:600}[data-slot=\"search-sheet\"]{position:fixed;inset:0;z-index:40}[data-slot=\"search-sheet-overlay\"]{position:absolute;inset:0;border:0;cursor:pointer;background:rgb(0 0 0 / 0.4);animation:garagem-search-fade 160ms ease-out}[data-slot=\"search-sheet-panel\"]{position:absolute;top:0;right:0;display:flex;height:100dvh;width:min(22rem,100%);flex-direction:column;background:var(--background,#fff);animation:garagem-search-sheet 180ms ease-out}[data-slot=\"search-sheet-body\"]{min-height:0;flex:1;overflow:auto;padding:1.5rem 1.5rem 0;scrollbar-width:thin}[data-slot=\"search-sheet-footer\"]{display:flex;gap:0.5rem;border-top:1px solid var(--border,#e4e4e7);padding:1rem 1.5rem}[data-slot=\"search-apply-bar\"]{display:flex;width:100%;gap:0.5rem}[data-slot=\"search-apply-bar\"] > button{min-height:2.5rem;flex:1;cursor:pointer;border-radius:var(--garagem-search-radius);padding:0 1rem}[data-slot=\"search-apply-bar\"] > button[data-kind=\"clear\"]{border:1px solid var(--border,#e4e4e7);background:transparent}[data-slot=\"search-apply-bar\"] > button[data-kind=\"apply\"]{border:0;background:var(--primary,#111);color:var(--primary-foreground,#fff);font-weight:600}[data-slot=\"search-pagination\"]{margin-top:2.5rem;display:flex;justify-content:center}[data-slot=\"search-pagination\"] ul{display:flex;flex-wrap:wrap;justify-content:center;gap:0.25rem;padding:0;margin:0;list-style:none}[data-slot=\"search-pagination-item\"]{display:inline-flex;width:2.25rem;height:2.25rem;align-items:center;justify-content:center;border:1px solid var(--border,#e4e4e7);border-radius:0.375rem;font-size:0.75rem;font-weight:500}@media (min-width:768px){[data-slot=\"search-pagination-item\"]{width:2.5rem;height:2.5rem}}[data-slot=\"search-pagination-item\"] a,[data-slot=\"search-pagination-item\"] span{display:flex;width:100%;height:100%;align-items:center;justify-content:center;color:inherit;text-decoration:none}[data-slot=\"search-pagination-item\"][data-current=\"true\"]{background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot=\"search-pagination-item\"][data-disabled=\"true\"]{cursor:not-allowed;color:var(--muted-foreground,#737373)}[data-slot=\"search-toolbar-item\"]{position:relative}[data-slot=\"search-body\"]{margin-top:2rem;display:flex;flex-direction:column;gap:1.5rem}[data-slot=\"search-label\"]{margin-bottom:0.25rem;display:block;font-size:0.875rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-sheet-title\"]{padding:1.5rem 1.5rem 0;font-size:1.125rem;font-weight:600}[data-slot=\"search-layout\"]{display:grid;gap:2rem}[data-slot=\"search-sidebar\"]{display:none}[data-slot=\"search-layout\"] > div > [data-slot=\"search-filters-trigger\"]{margin-bottom:1rem}@media (min-width:1024px){[data-slot=\"search-layout\"]{grid-template-columns:280px minmax(0,1fr)}[data-slot=\"search-sidebar\"]{display:block;position:sticky;top:1.5rem;align-self:start}[data-slot=\"search-layout\"] > div > [data-slot=\"search-filters-trigger\"]{display:none}}[data-slot=\"listing-card-link\"]{display:block;color:inherit;text-decoration:none;cursor:pointer}[data-slot=\"listing-card-media\"]{position:relative;width:100%;overflow:hidden;background:var(--muted,#f5f5f4);aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot=\"listing-card-media\"] img{height:100%;width:100%;object-fit:cover;transition:transform 0.3s}[data-slot=\"listing-card\"]:hover [data-slot=\"listing-card-media\"] img{transform:scale(1.05)}@media (prefers-reduced-motion:reduce){[data-slot=\"listing-card-media\"] img{transition:none}[data-slot=\"listing-card\"]:hover [data-slot=\"listing-card-media\"] img{transform:none}}[data-slot=\"listing-card-empty\"]{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"listing-card-cta\"]{margin-top:0.75rem}[data-slot=\"search-filters\"]{display:flex;flex-direction:column;gap:1.25rem}[data-slot=\"search-filter\"]{margin:0;padding:0;border:0;font-size:0.875rem}[data-slot=\"search-filter\"] legend{margin-bottom:0.5rem;padding:0;color:var(--muted-foreground,#737373)}[data-slot=\"search-range-row\"]{display:flex;align-items:flex-end;gap:0.5rem}[data-slot=\"search-range-side\"]{min-width:0;flex:1}[data-slot=\"search-range-side\"] > span:first-child{margin-bottom:0.25rem;display:block;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-range-affix\"]{position:relative;display:block}[data-slot=\"search-range-prefix\"]{pointer-events:none;position:absolute;inset-block:0;left:0;display:flex;align-items:center;padding-left:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-range-input\"]{min-height:2.5rem;width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem}[data-slot=\"search-range-affix\"] [data-slot=\"search-range-input\"]{padding-left:2.5rem}[data-slot=\"search-count-group\"]{display:flex;flex-wrap:wrap;gap:0.375rem}[data-slot=\"search-count-choice\"]{min-height:2.5rem;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem;font-size:0.875rem}[data-slot=\"search-count-choice\"][data-selected=\"true\"]{border-color:var(--primary,#111);background:color-mix(in srgb,var(--primary,#111) 10%,transparent)}[data-slot=\"search-enum-list\"],[data-slot=\"search-scroll\"]{display:flex;flex-direction:column;gap:0.375rem}[data-slot=\"search-enum-option\"]{display:flex;cursor:pointer;align-items:center;gap:0.5rem}[data-slot=\"listing-card-badge\"]{position:absolute;left:0.75rem;top:0.75rem;border-radius:999px;background:color-mix(in srgb,var(--background,#fff) 90%,transparent);padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500}[data-slot=\"listing-card-body\"]{padding:1rem}[data-slot=\"listing-card-title\"]{display:-webkit-box;margin-top:0.25rem;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;font-weight:500}[data-slot=\"listing-card-location\"]{margin-top:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"listing-card-features\"]{display:flex;flex-wrap:wrap;margin-top:0.75rem;gap:0.25rem 1rem;padding:0;list-style:none;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-skeleton-block\"]{animation:garagem-search-pulse 1.2s ease-in-out infinite;background:var(--garagem-skeleton);border-radius:0.375rem}[data-slot=\"search-skeleton-card\"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7)}[data-slot=\"search-skeleton-body\"]{display:flex;flex-direction:column;gap:0.5rem;padding:1rem}[data-slot=\"search-skeleton-block\"][data-kind=\"media\"]{aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot=\"search-skeleton-block\"][data-kind=\"line-lg\"]{height:1.25rem;width:50%}[data-slot=\"search-skeleton-block\"][data-kind=\"line-md\"]{height:1rem;width:75%}[data-slot=\"search-skeleton-block\"][data-kind=\"line-sm\"]{height:0.75rem;width:66.666667%}[data-slot=\"search-skeleton-block\"][data-kind=\"detail-media\"]{max-width:45rem;aspect-ratio:4 / 3}[data-slot=\"search-skeleton-block\"][data-kind=\"detail-title\"]{width:66.666667%;height:2rem;margin-top:1.5rem}@media (prefers-reduced-motion:reduce){[data-slot=\"search-popover\"],[data-slot=\"search-sheet-overlay\"],[data-slot=\"search-sheet-panel\"],[data-slot=\"search-skeleton-block\"]{animation:none}}@keyframes garagem-search-in{from{opacity:0;transform:translateY(-4px) scale(0.98)}to{opacity:1;transform:none}}@keyframes garagem-search-fade{from{opacity:0}to{opacity:1}}@keyframes garagem-search-sheet{from{transform:translateX(100%)}to{transform:none}}@keyframes garagem-search-pulse{50%{opacity:0.55}}";
@@ -15,8 +15,9 @@ export const STUDIO_SDK_CONTRACT = {
15
15
  /**
16
16
  * Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
17
17
  * prompts that skip the layout chrome tag match the tarball v0 installs.
18
- * 0.4.9 adds `listingAmenityGroups` so listing detail never prints
19
- * amenity ids.
18
+ * 0.4.9 adds listingDetailModel (values, facts, location, breadcrumb,
19
+ * description clamp, video/tour), getSimilarListings, and
20
+ * listingAmenityGroups so listing detail never prints amenity ids.
20
21
  */
21
22
  minNpmVersion: "0.4.9",
22
23
  /** First release where ListingCard and ResultsSkeleton inject the sheet. */
@@ -51,6 +52,7 @@ export const STUDIO_SDK_CONTRACT = {
51
52
  "isVisitSlotAllowed",
52
53
  "STUDIO_DEFAULT_VISIT_SCHEDULE",
53
54
  ] as const,
55
+ listingDetailExports: ["listingDetailModel", "getSimilarListings"] as const,
54
56
  amenityExports: ["listingAmenityGroups"] as const,
55
57
  } as const;
56
58
 
@@ -171,6 +173,11 @@ export function studioLeadInstruction(): string {
171
173
  return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` — never concatenate a leads webhook URL and never POST the Showcase demo leads route.`;
172
174
  }
173
175
 
176
+ export function studioListingDetailInstruction(): string {
177
+ const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
178
+ return `Listing detail blocks: import ${names} from \`${STUDIO_SDK_PACKAGE}\` and \`ListingCard\` from \`${STUDIO_SDK_PACKAGE}/react\`. Render \`listingDetailModel(listing)\` for breadcrumb (hrefs are search prefixes of \`listing.path\`, never invented paths), values (price / sob consulta, condo, IPTU), facts (omit empty zeros; bedrooms ≠ salas), location plus a discreet Google Maps \`<a target="_blank" rel="noopener noreferrer">\`, and description with the helper clamp + toggle (keep the full text; do not drop the remainder). Video/tour: \`model.mediaOverlays\` as hash links (\`#video\` / \`#tour\`) and a fullscreen overlay that closes with browser back; omit when empty. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` + \`ListingCard\`; hide the section when the list is empty. Do not invent a local recommendation loop.`;
179
+ }
180
+
174
181
  export function studioAmenityInstruction(): string {
175
182
  const names = STUDIO_SDK_CONTRACT.amenityExports.join(", ");
176
183
  return `Listing amenities: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingAmenityGroups(listing)\` (optional second arg: \`getSearchUi().dictionary\`). Use the helper titles (\`Comodidades\` / \`Comodidades do condomínio\`). Labels are already alphabetical (pt-BR) — keep that order. Omit empty groups. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
package/src/types.ts CHANGED
@@ -23,6 +23,13 @@ export interface ListingPropertySummary {
23
23
  usableArea: number;
24
24
  /** Monthly condo fee in BRL when the listing has one. */
25
25
  condoFee?: number;
26
+ /** Annual or listed IPTU in BRL when the listing has one. */
27
+ propertyTax?: number;
28
+ /**
29
+ * Living-room count from the catalog (`custom.salas`). Not total rooms
30
+ * and not `bedrooms`.
31
+ */
32
+ rooms?: number;
26
33
  }
27
34
 
28
35
  /** Address breakdown returned with every listing. */
@@ -113,7 +120,7 @@ export interface ListingDetail extends Listing {
113
120
  id: string;
114
121
  builtArea?: number;
115
122
  landArea?: number;
116
- floor?: number;
123
+ floor?: number | string;
117
124
  totalFloors?: number;
118
125
  yearBuilt?: number;
119
126
  furnished?: boolean;