@garagem-ai/site-sdk 0.4.8 → 0.4.10

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/dist/index.js CHANGED
@@ -20,8 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ AMENITY_FALLBACK_LABELS: () => AMENITY_FALLBACK_LABELS,
23
24
  FORBIDDEN_SEARCH_QUERY_KEYS: () => FORBIDDEN_SEARCH_QUERY_KEYS,
24
25
  GaragemSdkError: () => GaragemSdkError,
26
+ LISTING_AMENITY_TITLES: () => LISTING_AMENITY_TITLES,
25
27
  LeadSubmitError: () => LeadSubmitError,
26
28
  SEARCH_CSS_RECIPE: () => SEARCH_CSS_RECIPE,
27
29
  SEARCH_CSS_VARS: () => SEARCH_CSS_VARS,
@@ -66,6 +68,8 @@ __export(src_exports, {
66
68
  isListingDetailPath: () => isListingDetailPath,
67
69
  isStudioPreviewHost: () => isStudioPreviewHost,
68
70
  isVisitSlotAllowed: () => isVisitSlotAllowed,
71
+ labelAmenities: () => labelAmenities,
72
+ listingAmenityGroups: () => listingAmenityGroups,
69
73
  listingBusinessLabel: () => listingBusinessLabel,
70
74
  listingLocationLabel: () => listingLocationLabel,
71
75
  listingLookupKey: () => listingLookupKey,
@@ -93,6 +97,7 @@ __export(src_exports, {
93
97
  searchSortOptions: () => searchSortOptions,
94
98
  serializeAppliedSearchQuery: () => serializeAppliedSearchQuery2,
95
99
  slotsForDate: () => slotsForDate,
100
+ studioAmenityInstruction: () => studioAmenityInstruction,
96
101
  studioChromeInstruction: () => studioChromeInstruction,
97
102
  studioCodegenContractViolations: () => studioCodegenContractViolations,
98
103
  studioDefaultLeadUi: () => studioDefaultLeadUi,
@@ -842,6 +847,342 @@ async function submitContactLead(input) {
842
847
  });
843
848
  }
844
849
 
850
+ // src/amenity-labels.ts
851
+ var LISTING_AMENITY_TITLES = {
852
+ unit: "Comodidades",
853
+ building: "Comodidades do condom\xEDnio"
854
+ };
855
+ var AMENITY_FALLBACK_LABELS = {
856
+ // ==================== PROPERTY FEATURES ====================
857
+ // Amenities
858
+ arCondicionado: "Ar condicionado",
859
+ banheira: "Banheira",
860
+ carregadorEletrico: "Carregador el\xE9trico",
861
+ churrasqueira: "Churrasqueira",
862
+ chuveiroGas: "Chuveiro a g\xE1s",
863
+ chuveiroEletrico: "Chuveiro el\xE9trico",
864
+ energiaSolar: "Energia solar",
865
+ fechaduraDigital: "Fechadura digital",
866
+ fechaduraEletronica: "Fechadura eletr\xF4nica",
867
+ geradorEletrico: "Gerador el\xE9trico",
868
+ gesso: "Gesso",
869
+ hidromassagem: "Hidromassagem",
870
+ lareira: "Lareira",
871
+ ofuro: "Ofur\xF4",
872
+ spa: "Spa",
873
+ painelSolar: "Painel solar",
874
+ portaoEletronico: "Port\xE3o eletr\xF4nico",
875
+ sistemaAlarme: "Sistema de alarme",
876
+ homeTheater: "Home theater",
877
+ adega: "Adega",
878
+ split: "Split",
879
+ arCentral: "Ar central",
880
+ esperaSplit: "Espera para split",
881
+ vistaMar: "Vista para o mar",
882
+ vistaPanoramica: "Vista panor\xE2mica",
883
+ aguaQuente: "\xC1gua quente",
884
+ reformado: "Reformado",
885
+ tvCabo: "TV a cabo",
886
+ gradeado: "Gradeado",
887
+ antenaParabolica: "Antena parab\xF3lica",
888
+ aquecimento: "Aquecimento",
889
+ aquecimentoEletrico: "Aquecimento el\xE9trico",
890
+ aquecimentoCentral: "Aquecimento central",
891
+ cercaEletrica: "Cerca el\xE9trica",
892
+ monitoramento: "Monitoramento",
893
+ vigiaInterno: "Vigia interno",
894
+ vigiaExterno: "Vigia externo",
895
+ alarme: "Alarme",
896
+ agua: "\xC1gua",
897
+ redeEsgoto: "Rede de esgoto",
898
+ pavimentacao: "Pavimenta\xE7\xE3o",
899
+ energiaEletrica: "Energia el\xE9trica",
900
+ // Furniture
901
+ mobiliado: "Mobiliado",
902
+ armarioEmbutido: "Arm\xE1rio embutido",
903
+ armarioEmbutidoQuarto: "Arm\xE1rio embutido quarto",
904
+ armarioCozinha: "Arm\xE1rio cozinha",
905
+ armarioBanheiro: "Arm\xE1rio banheiro",
906
+ cozinhaPlanejada: "Cozinha planejada",
907
+ fogao: "Fog\xE3o",
908
+ fornoPizza: "Forno de pizza",
909
+ freezer: "Freezer",
910
+ dormitorioComArmario: "Dormit\xF3rio com arm\xE1rio",
911
+ semiMobiliado: "Semi mobiliado",
912
+ salaArmarios: "Sala com arm\xE1rios",
913
+ // Structure
914
+ piscina: "Piscina",
915
+ piscinaAquecida: "Piscina aquecida",
916
+ piscinaCoberta: "Piscina coberta",
917
+ poco: "Po\xE7o",
918
+ pocoArtesiano: "Po\xE7o artesiano",
919
+ bar: "Bar",
920
+ jardim: "Jardim",
921
+ lago: "Lago",
922
+ lavabo: "Lavabo",
923
+ quintal: "Quintal",
924
+ solarium: "Solarium",
925
+ quartoServico: "Quarto de servi\xE7o",
926
+ varanda: "Varanda",
927
+ varandaFechadaVidro: "Varanda fechada com vidro",
928
+ varandaGourmet: "Varanda gourmet",
929
+ banheiroServico: "Banheiro de servi\xE7o",
930
+ areaServico: "\xC1rea de servi\xE7o",
931
+ cinema: "Cinema",
932
+ closet: "Closet",
933
+ cozinhaAmericana: "Cozinha americana",
934
+ cozinhaGourmet: "Cozinha gourmet",
935
+ despensa: "Despensa",
936
+ escritorio: "Escrit\xF3rio",
937
+ edicula: "Ed\xEDcula",
938
+ horta: "Horta",
939
+ sacada: "Sacada",
940
+ salaJantar: "Sala de jantar",
941
+ cozinha: "Cozinha",
942
+ banheiroSocial: "Banheiro social",
943
+ terraco: "Terra\xE7o",
944
+ copa: "Copa",
945
+ suiteMaster: "Su\xEDte master",
946
+ wcEmpregada: "WC empregada",
947
+ dependenciaEmpregada: "Depend\xEAncia de empregada",
948
+ dependenciadeEmpregada: "Depend\xEAncia empregada",
949
+ salaTv: "Sala de TV",
950
+ copaCozinha: "Copa cozinha",
951
+ sacadaComChurrasqueira: "Sacada com churrasqueira",
952
+ hallPrivativo: "Hall privativo",
953
+ estarIntimo: "Estar \xEDntimo",
954
+ livingHall: "Living hall",
955
+ piscinaInterna: "Piscina interna",
956
+ deck: "Deck",
957
+ jardimInverno: "Jardim de inverno",
958
+ rouparia: "Rouparia",
959
+ living: "Living",
960
+ familyRoom: "Family room",
961
+ salafitness: "Sala fitness",
962
+ salaEstar: "Sala de estar",
963
+ mezanino: "Mezanino",
964
+ pisoElevado: "Piso elevado",
965
+ entradaServicoIndependente: "Entrada de servi\xE7o independente",
966
+ forro: "Forro",
967
+ vitrine: "Vitrine",
968
+ banheiroAuxiliar: "Banheiro auxiliar",
969
+ gabinete: "Gabinete",
970
+ quadraTenisPrivativa: "Quadra de t\xEAnis privativa",
971
+ porao: "Por\xE3o",
972
+ sotao: "S\xF3t\xE3o",
973
+ patio: "P\xE1tio",
974
+ canaletasNoRodape: "Canaletas no rodap\xE9",
975
+ // Accessibility
976
+ barraApoioVaso: "Barra de apoio vaso",
977
+ barraApoioChuveiro: "Barra de apoio chuveiro",
978
+ entradaSemDegrau: "Entrada sem degrau",
979
+ rampasAcesso: "Rampas de acesso",
980
+ vagaDeficientes: "Vaga para deficientes",
981
+ // Flooring
982
+ cimentoQueimado: "Cimento queimado",
983
+ madeira: "Madeira",
984
+ pisoFrio: "Piso frio",
985
+ laminado: "Laminado",
986
+ vinilico: "Vin\xEDlico",
987
+ porcelanato: "Porcelanato",
988
+ // ==================== BUILDING FEATURES ====================
989
+ // Amenities
990
+ elevador: "Elevador",
991
+ bicicletario: "Biciclet\xE1rio",
992
+ carregadorEletronico: "Carregador eletr\xF4nico",
993
+ concierge: "Concierge",
994
+ coworking: "Coworking",
995
+ deposito: "Dep\xF3sito",
996
+ lavanderia: "Lavanderia",
997
+ petPlace: "Pet place",
998
+ recebimentoEncomendas: "Recebimento de encomendas",
999
+ salaReuniao: "Sala de reuni\xE3o",
1000
+ salaoFestas: "Sal\xE3o de festas",
1001
+ valet: "Valet",
1002
+ garagemCoberta: "Garagem coberta",
1003
+ elevadorServico: "Elevador de servi\xE7o",
1004
+ // Leisure
1005
+ academia: "Academia",
1006
+ campoFutebol: "Campo de futebol",
1007
+ espacoGourmet: "Espa\xE7o gourmet",
1008
+ piscinaInfantil: "Piscina infantil",
1009
+ pistaCaminhada: "Pista de caminhada",
1010
+ playground: "Playground",
1011
+ quadraPoliesportiva: "Quadra poliesportiva",
1012
+ quadraTenis: "Quadra de t\xEAnis",
1013
+ salaJogos: "Sala de jogos",
1014
+ salaVapor: "Sala de vapor",
1015
+ sauna: "Sauna",
1016
+ // Security
1017
+ circuitoTv: "Circuito fechado de TV",
1018
+ controleAcessoEletronico: "Controle de acesso eletr\xF4nico",
1019
+ interfone: "Interfone",
1020
+ portaria24h: "Portaria 24h",
1021
+ porteiroFisico: "Porteiro f\xEDsico",
1022
+ seguranca24h: "Seguran\xE7a 24h",
1023
+ segurancaPatrimonial: "Seguran\xE7a patrimonial",
1024
+ condominioFechado: "Condom\xEDnio fechado",
1025
+ // Accessibility
1026
+ banheiroAcessivel: "Banheiro acess\xEDvel",
1027
+ elevadorAcessivel: "Elevador acess\xEDvel",
1028
+ pisoTatil: "Piso t\xE1til",
1029
+ // ==================== CANONICAL HAS*/IS* KEYS ====================
1030
+ has24hConcierge: "Portaria 24h",
1031
+ has24hSecurity: "Seguran\xE7a 24h",
1032
+ hasAccessRamps: "Rampas de acesso",
1033
+ hasAccessibleBathroom: "Banheiro acess\xEDvel",
1034
+ hasAccessibleElevator: "Elevador acess\xEDvel",
1035
+ hasAirConditioning: "Ar condicionado",
1036
+ hasAlarmSystem: "Sistema de alarme",
1037
+ hasBalcony: "Varanda",
1038
+ hasBikeStorage: "Biciclet\xE1rio",
1039
+ hasBuiltInWardrobe: "Arm\xE1rio embutido",
1040
+ hasCCTV: "CFTV",
1041
+ hasCloset: "Closet",
1042
+ hasConcierge: "Portaria",
1043
+ hasControlledAccess: "Condom\xEDnio fechado",
1044
+ hasCoworking: "Coworking",
1045
+ hasDisabledParking: "Vaga para deficientes",
1046
+ hasElectricCharger: "Carregador eletr\xF4nico",
1047
+ hasElectronicGate: "Port\xE3o eletr\xF4nico",
1048
+ hasElevator: "Elevador",
1049
+ hasFireplace: "Lareira",
1050
+ hasGarden: "Jardim",
1051
+ hasGasShower: "Chuveiro a g\xE1s",
1052
+ hasGenerator: "Gerador",
1053
+ hasGourmetBalcony: "Varanda gourmet",
1054
+ hasGourmetKitchen: "Cozinha gourmet",
1055
+ hasGrill: "Churrasqueira",
1056
+ hasGuestParking: "Estacionamento para visitantes",
1057
+ hasGym: "Academia",
1058
+ hasHeating: "Aquecimento",
1059
+ hasHomeOffice: "Home office",
1060
+ hasIntercom: "Interfone",
1061
+ hasJacuzzi: "Hidromassagem",
1062
+ hasKidsPool: "Piscina infantil",
1063
+ hasLaundry: "Lavanderia",
1064
+ hasMeetingRoom: "Sala de reuni\xE3o",
1065
+ hasOffice: "Escrit\xF3rio",
1066
+ hasOpenKitchen: "Cozinha americana",
1067
+ hasPackageReceival: "Recebimento de encomendas",
1068
+ hasPantry: "Despensa",
1069
+ hasParkingGarage: "Garagem coberta",
1070
+ hasPartySaloon: "Sal\xE3o de festas",
1071
+ hasPetArea: "Pet place",
1072
+ hasPipedGas: "G\xE1s encanado",
1073
+ hasPlayground: "Playground",
1074
+ hasPowderRoom: "Lavabo",
1075
+ hasPrivatePool: "Piscina privativa",
1076
+ hasSauna: "Sauna",
1077
+ hasSecurity: "Seguran\xE7a",
1078
+ hasServiceArea: "\xC1rea de servi\xE7o",
1079
+ hasSolarPanel: "Painel solar",
1080
+ hasSpa: "Spa",
1081
+ hasSportsCourt: "Quadra de esportes",
1082
+ hasStepFreeEntrance: "Entrada sem degrau",
1083
+ hasStorage: "Dep\xF3sito",
1084
+ hasSwimmingPool: "Piscina",
1085
+ hasTennisCourt: "Quadra de t\xEAnis",
1086
+ hasValetParking: "Valet",
1087
+ homeOffice: "Home office",
1088
+ isPetFriendly: "Pet friendly",
1089
+ isFurnished: "Mobiliado",
1090
+ isPartiallyFurnished: "Semi-mobiliado",
1091
+ petFriendly: "Pet friendly",
1092
+ piscinaPrivativa: "Piscina privativa",
1093
+ pisoLaminado: "Piso laminado",
1094
+ pisoMadeira: "Piso de madeira",
1095
+ pisoPorcelanato: "Piso porcelanato",
1096
+ quadraEsportes: "Quadra de esportes",
1097
+ rooftop: "Rooftop",
1098
+ suite: "Su\xEDte",
1099
+ triplex: "Triplex",
1100
+ duplex: "Duplex",
1101
+ cobertura: "Cobertura",
1102
+ forroGesso: "Forro de gesso",
1103
+ gerador: "Gerador",
1104
+ armariosCozinha: "Arm\xE1rios na cozinha",
1105
+ armariosQuarto: "Arm\xE1rios nos quartos",
1106
+ cftv: "CFTV"
1107
+ };
1108
+ function lookupLabel(id, options) {
1109
+ const fromDictionary = options?.find((option) => option.id === id)?.label;
1110
+ if (fromDictionary?.trim()) return fromDictionary.trim();
1111
+ return AMENITY_FALLBACK_LABELS[id];
1112
+ }
1113
+ function labelAmenities(ids, dictionary) {
1114
+ if (!ids?.length) return [];
1115
+ const labels = [];
1116
+ const seen = /* @__PURE__ */ new Set();
1117
+ for (const id of ids) {
1118
+ if (!id) continue;
1119
+ const label = lookupLabel(id, dictionary);
1120
+ if (!label || seen.has(label)) continue;
1121
+ seen.add(label);
1122
+ labels.push(label);
1123
+ }
1124
+ return labels.sort((a, b) => a.localeCompare(b, "pt-BR"));
1125
+ }
1126
+ function presentIds(ids) {
1127
+ return (ids ?? []).filter((id) => Boolean(id));
1128
+ }
1129
+ function buildingIdsFromMergedAmenities(listing, unitIds) {
1130
+ if (!listing.amenities || listing.propertyFeatures == null) return [];
1131
+ const unitCounts = /* @__PURE__ */ new Map();
1132
+ for (const id of unitIds) {
1133
+ unitCounts.set(id, (unitCounts.get(id) ?? 0) + 1);
1134
+ }
1135
+ return listing.amenities.filter((id) => {
1136
+ if (!id) return false;
1137
+ const count = unitCounts.get(id);
1138
+ if (count === void 0 || count === 0) return true;
1139
+ unitCounts.set(id, count - 1);
1140
+ return false;
1141
+ });
1142
+ }
1143
+ function unitAmenityIds(listing) {
1144
+ if (listing.propertyFeatures != null) {
1145
+ return presentIds(listing.propertyFeatures);
1146
+ }
1147
+ const building = new Set(
1148
+ listing.building?.amenities ?? listing.buildingAmenities ?? []
1149
+ );
1150
+ return (listing.amenities ?? []).filter((id) => id && !building.has(id));
1151
+ }
1152
+ function buildingAmenityIds(listing) {
1153
+ if (listing.building != null && listing.building.amenities != null) {
1154
+ return presentIds(listing.building.amenities);
1155
+ }
1156
+ if (listing.buildingAmenities != null) {
1157
+ return presentIds(listing.buildingAmenities);
1158
+ }
1159
+ return buildingIdsFromMergedAmenities(listing, unitAmenityIds(listing));
1160
+ }
1161
+ function listingAmenityGroups(listing, dictionary) {
1162
+ const groups = [];
1163
+ const unitIds = unitAmenityIds(listing);
1164
+ const unitLabels = labelAmenities(unitIds, dictionary?.propertyFeatures);
1165
+ if (unitLabels.length > 0) {
1166
+ groups.push({
1167
+ key: "unit",
1168
+ title: LISTING_AMENITY_TITLES.unit,
1169
+ labels: unitLabels
1170
+ });
1171
+ }
1172
+ const buildingLabels = labelAmenities(
1173
+ buildingAmenityIds(listing),
1174
+ dictionary?.buildingAmenities
1175
+ );
1176
+ if (buildingLabels.length > 0) {
1177
+ groups.push({
1178
+ key: "building",
1179
+ title: LISTING_AMENITY_TITLES.building,
1180
+ labels: buildingLabels
1181
+ });
1182
+ }
1183
+ return groups;
1184
+ }
1185
+
845
1186
  // src/presentation.ts
846
1187
  var SEARCH_CSS_VARS = {
847
1188
  cardRadius: "--garagem-listing-card-radius",
@@ -1702,10 +2043,10 @@ var STUDIO_SDK_CONTRACT = {
1702
2043
  /**
1703
2044
  * Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
1704
2045
  * prompts that skip the layout chrome tag match the tarball v0 installs.
1705
- * 0.4.7 lets SearchPage fill the site wrapper (`as="div"`) with no
1706
- * nested 80rem inset and no padding on the search slot.
2046
+ * 0.4.9 adds `listingAmenityGroups` so listing detail never prints
2047
+ * amenity ids.
1707
2048
  */
1708
- minNpmVersion: "0.4.7",
2049
+ minNpmVersion: "0.4.9",
1709
2050
  /** First release where ListingCard and ResultsSkeleton inject the sheet. */
1710
2051
  selfInjectSince: "0.4.2",
1711
2052
  chromeStrategy: "self-inject",
@@ -1737,7 +2078,8 @@ var STUDIO_SDK_CONTRACT = {
1737
2078
  "expandVisitTimeSlots",
1738
2079
  "isVisitSlotAllowed",
1739
2080
  "STUDIO_DEFAULT_VISIT_SCHEDULE"
1740
- ]
2081
+ ],
2082
+ amenityExports: ["listingAmenityGroups"]
1741
2083
  };
1742
2084
  var STUDIO_SITE_LAYOUT = {
1743
2085
  maxWidthRem: "80rem",
@@ -1831,6 +2173,10 @@ function studioLeadInstruction() {
1831
2173
  const names = STUDIO_SDK_CONTRACT.leadExports.join(", ");
1832
2174
  return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` \u2014 never concatenate a leads webhook URL and never POST the Showcase demo leads route.`;
1833
2175
  }
2176
+ function studioAmenityInstruction() {
2177
+ const names = STUDIO_SDK_CONTRACT.amenityExports.join(", ");
2178
+ 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\xEDnio\`). Labels are already alphabetical (pt-BR) \u2014 keep that order. Omit empty groups. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
2179
+ }
1834
2180
  function studioChromeInstruction() {
1835
2181
  const injectors = compareSemver(
1836
2182
  STUDIO_SDK_CONTRACT.minNpmVersion,
@@ -2016,8 +2362,10 @@ function createGaragemClient(options = {}) {
2016
2362
  }
2017
2363
  // Annotate the CommonJS export names for ESM import in node:
2018
2364
  0 && (module.exports = {
2365
+ AMENITY_FALLBACK_LABELS,
2019
2366
  FORBIDDEN_SEARCH_QUERY_KEYS,
2020
2367
  GaragemSdkError,
2368
+ LISTING_AMENITY_TITLES,
2021
2369
  LeadSubmitError,
2022
2370
  SEARCH_CSS_RECIPE,
2023
2371
  SEARCH_CSS_VARS,
@@ -2062,6 +2410,8 @@ function createGaragemClient(options = {}) {
2062
2410
  isListingDetailPath,
2063
2411
  isStudioPreviewHost,
2064
2412
  isVisitSlotAllowed,
2413
+ labelAmenities,
2414
+ listingAmenityGroups,
2065
2415
  listingBusinessLabel,
2066
2416
  listingLocationLabel,
2067
2417
  listingLookupKey,
@@ -2089,6 +2439,7 @@ function createGaragemClient(options = {}) {
2089
2439
  searchSortOptions,
2090
2440
  serializeAppliedSearchQuery,
2091
2441
  slotsForDate,
2442
+ studioAmenityInstruction,
2092
2443
  studioChromeInstruction,
2093
2444
  studioCodegenContractViolations,
2094
2445
  studioDefaultLeadUi,