@garagem-ai/site-sdk 0.4.8 → 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 {
@@ -88,13 +95,25 @@ interface Listing {
88
95
  * details and richer property info. Returned by `getListing`.
89
96
  */
90
97
  interface ListingDetail extends Listing {
98
+ /**
99
+ * Unit + building amenity ids (legacy merged list). Prefer
100
+ * `propertyFeatures` and `buildingAmenities` with `listingAmenityGroups`.
101
+ */
91
102
  amenities: string[];
103
+ /** Unit amenity ids only. Absent on older payloads — fall back to `amenities`. */
104
+ propertyFeatures?: string[];
105
+ /**
106
+ * Condo amenity ids. Present even when `building` is null (Typesense has
107
+ * `buildingAmenities` but no `buildingId`). Prefer this over reconstructing
108
+ * from the merged `amenities` list.
109
+ */
110
+ buildingAmenities?: string[];
92
111
  tags: string[];
93
112
  property: ListingPropertySummary & {
94
113
  id: string;
95
114
  builtArea?: number;
96
115
  landArea?: number;
97
- floor?: number;
116
+ floor?: number | string;
98
117
  totalFloors?: number;
99
118
  yearBuilt?: number;
100
119
  furnished?: boolean;
@@ -465,4 +484,4 @@ declare function searchResultsHeading(pathFilters: SearchPathFilters, dictionary
465
484
  declare function hrefWithExplicitPage(href: string, page: number): string;
466
485
  declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
467
486
 
468
- 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 {
@@ -88,13 +95,25 @@ interface Listing {
88
95
  * details and richer property info. Returned by `getListing`.
89
96
  */
90
97
  interface ListingDetail extends Listing {
98
+ /**
99
+ * Unit + building amenity ids (legacy merged list). Prefer
100
+ * `propertyFeatures` and `buildingAmenities` with `listingAmenityGroups`.
101
+ */
91
102
  amenities: string[];
103
+ /** Unit amenity ids only. Absent on older payloads — fall back to `amenities`. */
104
+ propertyFeatures?: string[];
105
+ /**
106
+ * Condo amenity ids. Present even when `building` is null (Typesense has
107
+ * `buildingAmenities` but no `buildingId`). Prefer this over reconstructing
108
+ * from the merged `amenities` list.
109
+ */
110
+ buildingAmenities?: string[];
92
111
  tags: string[];
93
112
  property: ListingPropertySummary & {
94
113
  id: string;
95
114
  builtArea?: number;
96
115
  landArea?: number;
97
- floor?: number;
116
+ floor?: number | string;
98
117
  totalFloors?: number;
99
118
  yearBuilt?: number;
100
119
  furnished?: boolean;
@@ -465,4 +484,4 @@ declare function searchResultsHeading(pathFilters: SearchPathFilters, dictionary
465
484
  declare function hrefWithExplicitPage(href: string, page: number): string;
466
485
  declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
467
486
 
468
- 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.8",
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",
@@ -0,0 +1,400 @@
1
+ /**
2
+ * Portuguese labels for listing amenity ids. Tenant search-ui dictionary
3
+ * wins; this map is the default-catalog fallback so generated Studio pages
4
+ * never print camelCase keys.
5
+ */
6
+
7
+ export const LISTING_AMENITY_TITLES = {
8
+ unit: "Comodidades",
9
+ building: "Comodidades do condomínio",
10
+ } as const;
11
+
12
+ export type AmenityLabelOption = {
13
+ id: string;
14
+ label: string;
15
+ };
16
+
17
+ export type AmenityLabelDictionary = {
18
+ propertyFeatures?: AmenityLabelOption[];
19
+ buildingAmenities?: AmenityLabelOption[];
20
+ };
21
+
22
+ export type ListingAmenityGroupKey = keyof typeof LISTING_AMENITY_TITLES;
23
+
24
+ export type ListingAmenityGroup = {
25
+ key: ListingAmenityGroupKey;
26
+ title: string;
27
+ labels: string[];
28
+ };
29
+
30
+ export type ListingAmenitySource = {
31
+ amenities?: string[] | null;
32
+ propertyFeatures?: string[] | null;
33
+ /** Condo amenity ids, even when `building` is null (no buildingId). */
34
+ buildingAmenities?: string[] | null;
35
+ building?: { amenities?: string[] | null } | null;
36
+ };
37
+
38
+ /**
39
+ * Default tenant ids + canonical `has*` / `is*` keys seen on public listings.
40
+ * Aligned with DEFAULT_PROPERTY_FEATURES and DEFAULT_BUILDING_FEATURES from
41
+ * Foundation's field-definitions.ts so generated Studio pages never need a
42
+ * dictionary for standard amenities.
43
+ */
44
+ export const AMENITY_FALLBACK_LABELS: Record<string, string> = {
45
+ // ==================== PROPERTY FEATURES ====================
46
+ // Amenities
47
+ arCondicionado: "Ar condicionado",
48
+ banheira: "Banheira",
49
+ carregadorEletrico: "Carregador elétrico",
50
+ churrasqueira: "Churrasqueira",
51
+ chuveiroGas: "Chuveiro a gás",
52
+ chuveiroEletrico: "Chuveiro elétrico",
53
+ energiaSolar: "Energia solar",
54
+ fechaduraDigital: "Fechadura digital",
55
+ fechaduraEletronica: "Fechadura eletrônica",
56
+ geradorEletrico: "Gerador elétrico",
57
+ gesso: "Gesso",
58
+ hidromassagem: "Hidromassagem",
59
+ lareira: "Lareira",
60
+ ofuro: "Ofurô",
61
+ spa: "Spa",
62
+ painelSolar: "Painel solar",
63
+ portaoEletronico: "Portão eletrônico",
64
+ sistemaAlarme: "Sistema de alarme",
65
+ homeTheater: "Home theater",
66
+ adega: "Adega",
67
+ split: "Split",
68
+ arCentral: "Ar central",
69
+ esperaSplit: "Espera para split",
70
+ vistaMar: "Vista para o mar",
71
+ vistaPanoramica: "Vista panorâmica",
72
+ aguaQuente: "Água quente",
73
+ reformado: "Reformado",
74
+ tvCabo: "TV a cabo",
75
+ gradeado: "Gradeado",
76
+ antenaParabolica: "Antena parabólica",
77
+ aquecimento: "Aquecimento",
78
+ aquecimentoEletrico: "Aquecimento elétrico",
79
+ aquecimentoCentral: "Aquecimento central",
80
+ cercaEletrica: "Cerca elétrica",
81
+ monitoramento: "Monitoramento",
82
+ vigiaInterno: "Vigia interno",
83
+ vigiaExterno: "Vigia externo",
84
+ alarme: "Alarme",
85
+ agua: "Água",
86
+ redeEsgoto: "Rede de esgoto",
87
+ pavimentacao: "Pavimentação",
88
+ energiaEletrica: "Energia elétrica",
89
+ // Furniture
90
+ mobiliado: "Mobiliado",
91
+ armarioEmbutido: "Armário embutido",
92
+ armarioEmbutidoQuarto: "Armário embutido quarto",
93
+ armarioCozinha: "Armário cozinha",
94
+ armarioBanheiro: "Armário banheiro",
95
+ cozinhaPlanejada: "Cozinha planejada",
96
+ fogao: "Fogão",
97
+ fornoPizza: "Forno de pizza",
98
+ freezer: "Freezer",
99
+ dormitorioComArmario: "Dormitório com armário",
100
+ semiMobiliado: "Semi mobiliado",
101
+ salaArmarios: "Sala com armários",
102
+ // Structure
103
+ piscina: "Piscina",
104
+ piscinaAquecida: "Piscina aquecida",
105
+ piscinaCoberta: "Piscina coberta",
106
+ poco: "Poço",
107
+ pocoArtesiano: "Poço artesiano",
108
+ bar: "Bar",
109
+ jardim: "Jardim",
110
+ lago: "Lago",
111
+ lavabo: "Lavabo",
112
+ quintal: "Quintal",
113
+ solarium: "Solarium",
114
+ quartoServico: "Quarto de serviço",
115
+ varanda: "Varanda",
116
+ varandaFechadaVidro: "Varanda fechada com vidro",
117
+ varandaGourmet: "Varanda gourmet",
118
+ banheiroServico: "Banheiro de serviço",
119
+ areaServico: "Área de serviço",
120
+ cinema: "Cinema",
121
+ closet: "Closet",
122
+ cozinhaAmericana: "Cozinha americana",
123
+ cozinhaGourmet: "Cozinha gourmet",
124
+ despensa: "Despensa",
125
+ escritorio: "Escritório",
126
+ edicula: "Edícula",
127
+ horta: "Horta",
128
+ sacada: "Sacada",
129
+ salaJantar: "Sala de jantar",
130
+ cozinha: "Cozinha",
131
+ banheiroSocial: "Banheiro social",
132
+ terraco: "Terraço",
133
+ copa: "Copa",
134
+ suiteMaster: "Suíte master",
135
+ wcEmpregada: "WC empregada",
136
+ dependenciaEmpregada: "Dependência de empregada",
137
+ dependenciadeEmpregada: "Dependência empregada",
138
+ salaTv: "Sala de TV",
139
+ copaCozinha: "Copa cozinha",
140
+ sacadaComChurrasqueira: "Sacada com churrasqueira",
141
+ hallPrivativo: "Hall privativo",
142
+ estarIntimo: "Estar íntimo",
143
+ livingHall: "Living hall",
144
+ piscinaInterna: "Piscina interna",
145
+ deck: "Deck",
146
+ jardimInverno: "Jardim de inverno",
147
+ rouparia: "Rouparia",
148
+ living: "Living",
149
+ familyRoom: "Family room",
150
+ salafitness: "Sala fitness",
151
+ salaEstar: "Sala de estar",
152
+ mezanino: "Mezanino",
153
+ pisoElevado: "Piso elevado",
154
+ entradaServicoIndependente: "Entrada de serviço independente",
155
+ forro: "Forro",
156
+ vitrine: "Vitrine",
157
+ banheiroAuxiliar: "Banheiro auxiliar",
158
+ gabinete: "Gabinete",
159
+ quadraTenisPrivativa: "Quadra de tênis privativa",
160
+ porao: "Porão",
161
+ sotao: "Sótão",
162
+ patio: "Pátio",
163
+ canaletasNoRodape: "Canaletas no rodapé",
164
+ // Accessibility
165
+ barraApoioVaso: "Barra de apoio vaso",
166
+ barraApoioChuveiro: "Barra de apoio chuveiro",
167
+ entradaSemDegrau: "Entrada sem degrau",
168
+ rampasAcesso: "Rampas de acesso",
169
+ vagaDeficientes: "Vaga para deficientes",
170
+ // Flooring
171
+ cimentoQueimado: "Cimento queimado",
172
+ madeira: "Madeira",
173
+ pisoFrio: "Piso frio",
174
+ laminado: "Laminado",
175
+ vinilico: "Vinílico",
176
+ porcelanato: "Porcelanato",
177
+
178
+ // ==================== BUILDING FEATURES ====================
179
+ // Amenities
180
+ elevador: "Elevador",
181
+ bicicletario: "Bicicletário",
182
+ carregadorEletronico: "Carregador eletrônico",
183
+ concierge: "Concierge",
184
+ coworking: "Coworking",
185
+ deposito: "Depósito",
186
+ lavanderia: "Lavanderia",
187
+ petPlace: "Pet place",
188
+ recebimentoEncomendas: "Recebimento de encomendas",
189
+ salaReuniao: "Sala de reunião",
190
+ salaoFestas: "Salão de festas",
191
+ valet: "Valet",
192
+ garagemCoberta: "Garagem coberta",
193
+ elevadorServico: "Elevador de serviço",
194
+ // Leisure
195
+ academia: "Academia",
196
+ campoFutebol: "Campo de futebol",
197
+ espacoGourmet: "Espaço gourmet",
198
+ piscinaInfantil: "Piscina infantil",
199
+ pistaCaminhada: "Pista de caminhada",
200
+ playground: "Playground",
201
+ quadraPoliesportiva: "Quadra poliesportiva",
202
+ quadraTenis: "Quadra de tênis",
203
+ salaJogos: "Sala de jogos",
204
+ salaVapor: "Sala de vapor",
205
+ sauna: "Sauna",
206
+ // Security
207
+ circuitoTv: "Circuito fechado de TV",
208
+ controleAcessoEletronico: "Controle de acesso eletrônico",
209
+ interfone: "Interfone",
210
+ portaria24h: "Portaria 24h",
211
+ porteiroFisico: "Porteiro físico",
212
+ seguranca24h: "Segurança 24h",
213
+ segurancaPatrimonial: "Segurança patrimonial",
214
+ condominioFechado: "Condomínio fechado",
215
+ // Accessibility
216
+ banheiroAcessivel: "Banheiro acessível",
217
+ elevadorAcessivel: "Elevador acessível",
218
+ pisoTatil: "Piso tátil",
219
+
220
+ // ==================== CANONICAL HAS*/IS* KEYS ====================
221
+ has24hConcierge: "Portaria 24h",
222
+ has24hSecurity: "Segurança 24h",
223
+ hasAccessRamps: "Rampas de acesso",
224
+ hasAccessibleBathroom: "Banheiro acessível",
225
+ hasAccessibleElevator: "Elevador acessível",
226
+ hasAirConditioning: "Ar condicionado",
227
+ hasAlarmSystem: "Sistema de alarme",
228
+ hasBalcony: "Varanda",
229
+ hasBikeStorage: "Bicicletário",
230
+ hasBuiltInWardrobe: "Armário embutido",
231
+ hasCCTV: "CFTV",
232
+ hasCloset: "Closet",
233
+ hasConcierge: "Portaria",
234
+ hasControlledAccess: "Condomínio fechado",
235
+ hasCoworking: "Coworking",
236
+ hasDisabledParking: "Vaga para deficientes",
237
+ hasElectricCharger: "Carregador eletrônico",
238
+ hasElectronicGate: "Portão eletrônico",
239
+ hasElevator: "Elevador",
240
+ hasFireplace: "Lareira",
241
+ hasGarden: "Jardim",
242
+ hasGasShower: "Chuveiro a gás",
243
+ hasGenerator: "Gerador",
244
+ hasGourmetBalcony: "Varanda gourmet",
245
+ hasGourmetKitchen: "Cozinha gourmet",
246
+ hasGrill: "Churrasqueira",
247
+ hasGuestParking: "Estacionamento para visitantes",
248
+ hasGym: "Academia",
249
+ hasHeating: "Aquecimento",
250
+ hasHomeOffice: "Home office",
251
+ hasIntercom: "Interfone",
252
+ hasJacuzzi: "Hidromassagem",
253
+ hasKidsPool: "Piscina infantil",
254
+ hasLaundry: "Lavanderia",
255
+ hasMeetingRoom: "Sala de reunião",
256
+ hasOffice: "Escritório",
257
+ hasOpenKitchen: "Cozinha americana",
258
+ hasPackageReceival: "Recebimento de encomendas",
259
+ hasPantry: "Despensa",
260
+ hasParkingGarage: "Garagem coberta",
261
+ hasPartySaloon: "Salão de festas",
262
+ hasPetArea: "Pet place",
263
+ hasPipedGas: "Gás encanado",
264
+ hasPlayground: "Playground",
265
+ hasPowderRoom: "Lavabo",
266
+ hasPrivatePool: "Piscina privativa",
267
+ hasSauna: "Sauna",
268
+ hasSecurity: "Segurança",
269
+ hasServiceArea: "Área de serviço",
270
+ hasSolarPanel: "Painel solar",
271
+ hasSpa: "Spa",
272
+ hasSportsCourt: "Quadra de esportes",
273
+ hasStepFreeEntrance: "Entrada sem degrau",
274
+ hasStorage: "Depósito",
275
+ hasSwimmingPool: "Piscina",
276
+ hasTennisCourt: "Quadra de tênis",
277
+ hasValetParking: "Valet",
278
+ homeOffice: "Home office",
279
+ isPetFriendly: "Pet friendly",
280
+ isFurnished: "Mobiliado",
281
+ isPartiallyFurnished: "Semi-mobiliado",
282
+ petFriendly: "Pet friendly",
283
+ piscinaPrivativa: "Piscina privativa",
284
+ pisoLaminado: "Piso laminado",
285
+ pisoMadeira: "Piso de madeira",
286
+ pisoPorcelanato: "Piso porcelanato",
287
+ quadraEsportes: "Quadra de esportes",
288
+ rooftop: "Rooftop",
289
+ suite: "Suíte",
290
+ triplex: "Triplex",
291
+ duplex: "Duplex",
292
+ cobertura: "Cobertura",
293
+ forroGesso: "Forro de gesso",
294
+ gerador: "Gerador",
295
+ armariosCozinha: "Armários na cozinha",
296
+ armariosQuarto: "Armários nos quartos",
297
+ cftv: "CFTV",
298
+ };
299
+
300
+ function lookupLabel(
301
+ id: string,
302
+ options?: AmenityLabelOption[]
303
+ ): string | undefined {
304
+ const fromDictionary = options?.find((option) => option.id === id)?.label;
305
+ if (fromDictionary?.trim()) return fromDictionary.trim();
306
+ return AMENITY_FALLBACK_LABELS[id];
307
+ }
308
+
309
+ export function labelAmenities(
310
+ ids: readonly string[] | null | undefined,
311
+ dictionary?: AmenityLabelOption[]
312
+ ): string[] {
313
+ if (!ids?.length) return [];
314
+ const labels: string[] = [];
315
+ const seen = new Set<string>();
316
+ for (const id of ids) {
317
+ if (!id) continue;
318
+ const label = lookupLabel(id, dictionary);
319
+ if (!label || seen.has(label)) continue;
320
+ seen.add(label);
321
+ labels.push(label);
322
+ }
323
+ return labels.sort((a, b) => a.localeCompare(b, "pt-BR"));
324
+ }
325
+
326
+ function presentIds(ids: readonly string[] | null | undefined): string[] {
327
+ return (ids ?? []).filter((id): id is string => Boolean(id));
328
+ }
329
+
330
+ /**
331
+ * Older payloads merge unit + condo ids into `amenities` as
332
+ * `[...propertyFeatures, ...buildingAmenities]` (duplicates kept). Consume
333
+ * unit occurrences first so shared catalog ids stay in the building group.
334
+ */
335
+ function buildingIdsFromMergedAmenities(
336
+ listing: ListingAmenitySource,
337
+ unitIds: readonly string[]
338
+ ): string[] {
339
+ if (!listing.amenities || listing.propertyFeatures == null) return [];
340
+ const unitCounts = new Map<string, number>();
341
+ for (const id of unitIds) {
342
+ unitCounts.set(id, (unitCounts.get(id) ?? 0) + 1);
343
+ }
344
+ return listing.amenities.filter((id) => {
345
+ if (!id) return false;
346
+ const count = unitCounts.get(id);
347
+ if (count === undefined || count === 0) return true;
348
+ unitCounts.set(id, count - 1);
349
+ return false;
350
+ });
351
+ }
352
+
353
+ export function unitAmenityIds(listing: ListingAmenitySource): string[] {
354
+ if (listing.propertyFeatures != null) {
355
+ return presentIds(listing.propertyFeatures);
356
+ }
357
+ const building = new Set(
358
+ listing.building?.amenities ?? listing.buildingAmenities ?? []
359
+ );
360
+ return (listing.amenities ?? []).filter((id) => id && !building.has(id));
361
+ }
362
+
363
+ function buildingAmenityIds(listing: ListingAmenitySource): string[] {
364
+ if (listing.building != null && listing.building.amenities != null) {
365
+ return presentIds(listing.building.amenities);
366
+ }
367
+ if (listing.buildingAmenities != null) {
368
+ return presentIds(listing.buildingAmenities);
369
+ }
370
+ return buildingIdsFromMergedAmenities(listing, unitAmenityIds(listing));
371
+ }
372
+
373
+ export function listingAmenityGroups(
374
+ listing: ListingAmenitySource,
375
+ dictionary?: AmenityLabelDictionary
376
+ ): ListingAmenityGroup[] {
377
+ const groups: ListingAmenityGroup[] = [];
378
+ const unitIds = unitAmenityIds(listing);
379
+ const unitLabels = labelAmenities(unitIds, dictionary?.propertyFeatures);
380
+ if (unitLabels.length > 0) {
381
+ groups.push({
382
+ key: "unit",
383
+ title: LISTING_AMENITY_TITLES.unit,
384
+ labels: unitLabels,
385
+ });
386
+ }
387
+
388
+ const buildingLabels = labelAmenities(
389
+ buildingAmenityIds(listing),
390
+ dictionary?.buildingAmenities
391
+ );
392
+ if (buildingLabels.length > 0) {
393
+ groups.push({
394
+ key: "building",
395
+ title: LISTING_AMENITY_TITLES.building,
396
+ labels: buildingLabels,
397
+ });
398
+ }
399
+ return groups;
400
+ }
package/src/index.ts CHANGED
@@ -114,8 +114,38 @@ export {
114
114
  type VisitLeadInput,
115
115
  } from "./leads";
116
116
 
117
+ export {
118
+ AMENITY_FALLBACK_LABELS,
119
+ LISTING_AMENITY_TITLES,
120
+ labelAmenities,
121
+ listingAmenityGroups,
122
+ type AmenityLabelDictionary,
123
+ type AmenityLabelOption,
124
+ type ListingAmenityGroup,
125
+ type ListingAmenityGroupKey,
126
+ type ListingAmenitySource,
127
+ } from "./amenity-labels";
128
+
117
129
  export { listingLookupKey, listingPublicPath } from "./listing-path";
118
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
+
119
149
  export {
120
150
  toListingCardModel,
121
151
  listingLocationLabel,
@@ -195,7 +225,9 @@ export {
195
225
  studioChromeInstruction,
196
226
  studioCodegenContractViolations,
197
227
  studioLayoutInstruction,
228
+ studioAmenityInstruction,
198
229
  studioLeadInstruction,
230
+ studioListingDetailInstruction,
199
231
  studioSearchLandmarkInstruction,
200
232
  studioSdkPinInstruction,
201
233
  studioSiteWidthCss,