@garagem-ai/site-sdk 0.13.6 → 0.14.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/dist/index.mjs CHANGED
@@ -2908,9 +2908,21 @@ function listingAmenityGroups(listing, dictionary) {
2908
2908
  function listingLocationLabel(location) {
2909
2909
  return [location.neighborhood, location.city, location.state].map((part) => part ? String(part).trim() : "").filter(Boolean).join(", ");
2910
2910
  }
2911
+ function cardPriceLabel(isPrivate, collapsed, price, formattedPrice) {
2912
+ if (isPrivate) return "Sob consulta";
2913
+ if (collapsed && price != null) return `A partir de ${formattedPrice}`;
2914
+ return formattedPrice;
2915
+ }
2911
2916
  function toListingCardModel(listing) {
2912
2917
  const isPrivate = listing.priceVisibility === "private";
2913
2918
  const area = listing.property?.usableArea ?? listing.property?.totalArea;
2919
+ const unitCount = listing.development?.unitCount;
2920
+ const collapsed = typeof unitCount === "number" && unitCount > 1;
2921
+ const formattedPrice = formatListingPrice(
2922
+ listing.price,
2923
+ "pt-BR",
2924
+ listing.currency ?? "BRL"
2925
+ );
2914
2926
  return {
2915
2927
  href: listingPublicPath(listing),
2916
2928
  title: listing.title,
@@ -2918,7 +2930,12 @@ function toListingCardModel(listing) {
2918
2930
  businessLabel: listingBusinessLabel(listing.businessType),
2919
2931
  priceVisibility: listing.priceVisibility,
2920
2932
  price: listing.price,
2921
- priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price, "pt-BR", listing.currency ?? "BRL"),
2933
+ priceLabel: cardPriceLabel(
2934
+ isPrivate,
2935
+ collapsed,
2936
+ listing.price,
2937
+ formattedPrice
2938
+ ),
2922
2939
  pricePeriod: listing.businessType === "rental" && !isPrivate && listing.price != null ? "/m\xEAs" : null,
2923
2940
  locationLabel: listingLocationLabel(listing.location || {}),
2924
2941
  propertyType: listing.property?.type ?? null,
@@ -2927,7 +2944,8 @@ function toListingCardModel(listing) {
2927
2944
  bedrooms: listing.property?.bedrooms ?? null,
2928
2945
  bathrooms: listing.property?.bathrooms ?? null,
2929
2946
  parkingSpaces: listing.property?.parkingSpaces ?? null,
2930
- areaM2: area ?? null
2947
+ areaM2: area ?? null,
2948
+ unitCount: collapsed && typeof unitCount === "number" ? unitCount : null
2931
2949
  };
2932
2950
  }
2933
2951
 
@@ -3461,7 +3479,15 @@ var STUDIO_SDK_CONTRACT = {
3461
3479
  * `studioCodegenContractViolations` flags `trackListingView`.
3462
3480
  */
3463
3481
  analyticsExports: ["trackListingView"],
3464
- analyticsSince: "0.13.0"
3482
+ analyticsSince: "0.13.0",
3483
+ /**
3484
+ * Development cards (`model.unitCount`, "A partir de" on `priceLabel`).
3485
+ * The search API can return `listing.development` before this pin.
3486
+ * Prompts must not name `unitCount` until `minNpmVersion` reaches
3487
+ * `developmentCardSince` — v0 copies the field and an older
3488
+ * `toListingCardModel` does not set it.
3489
+ */
3490
+ developmentCardSince: "0.14.0"
3465
3491
  };
3466
3492
  function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3467
3493
  return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
@@ -3586,9 +3612,20 @@ function studioLeadInstruction() {
3586
3612
  const phone = STUDIO_SDK_CONTRACT.phoneExports.join(", ");
3587
3613
  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. Phone fields: import ${phone} from the same package. Display draft is \`formatPhoneNational\` (default country \`BR\`); changing country calls \`remaskPhoneForCountry\`; submit \`toE164\` and require \`isValidPhone\`. Do not invent a second mask and do not import \`@garagem/ui\` PhoneInput.`;
3588
3614
  }
3589
- function studioListingCardInstruction() {
3615
+ function developmentCardPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3616
+ return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentCardSince) >= 0;
3617
+ }
3618
+ function studioDevelopmentCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3619
+ if (!developmentCardPublished(pin)) return "";
3620
+ return `Development cards: \`toListingCardModel\` sets \`model.unitCount\` when several primary-market units were collapsed into one card, and \`model.priceLabel\` already starts with "A partir de". When \`model.unitCount\` is greater than 1, show it as "N unidades" and omit that line when it is null. Keep \`model.title\`, \`model.priceLabel\`, and \`model.href\`. Do not group listings in the page.`;
3621
+ }
3622
+ function studioListingCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3590
3623
  const names = STUDIO_SDK_CONTRACT.listingCardExports.join(", ");
3591
- return `Listing card (site-wide). WRITE \`components/garagem/listing-card.tsx\` \u2014 one module for home, search results, and similar listings. Do not invent a second card. From \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`const model = toListingCardModel(listing)\`. href is \`model.href\` / \`listingPublicPath(listing)\` \u2014 never \`listing.id\` or \`property.id\`. Skip the card or omit the link when href is empty (no \`href=""\`, no \`href="#"\`). Must show title (\`model.title\`) and price (\`model.priceLabel\` \u2014 \u201CSob consulta\u201D when private; \`model.pricePeriod\` \u201C/m\xEAs\u201D when present, omit when null). Photo: \`model.coverSrc\` as img \`src\`, alt \`model.coverAlt\`; skip the img when cover is missing; an empty-photo block is allowed; never Unsplash, \`/placeholder.svg\`, or invented \`?query=\` images. Show when present, omit the line when missing: \`locationLabel\` (else \`propertyType\`), \`listingBusinessLabel\` / \`model.businessLabel\`, bedrooms, bathrooms, parkingSpaces, area via \`formatAreaM2\`. Never interpolate the listing object as a React child. Design is free (grid vs carousel vs mosaic; radius is site \`--radius\`). WRITE \`components/garagem/listing-card-skeleton.tsx\` only for a slot whose content is still unknown \u2014 never as a \`<Suspense>\` fallback that replaces the catalog, and never the text \u201CCarregando im\xF3veis\u2026\u201D. Do not \`if (search.loading) return\` that skeleton inside the search client.`;
3624
+ const base = `Listing card (site-wide). WRITE \`components/garagem/listing-card.tsx\` \u2014 one module for home, search results, and similar listings. Do not invent a second card. From \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`const model = toListingCardModel(listing)\`. href is \`model.href\` / \`listingPublicPath(listing)\` \u2014 never \`listing.id\` or \`property.id\`. Skip the card or omit the link when href is empty (no \`href=""\`, no \`href="#"\`). Must show title (\`model.title\`) and price (\`model.priceLabel\` \u2014 \u201CSob consulta\u201D when private; \`model.pricePeriod\` \u201C/m\xEAs\u201D when present, omit when null). Photo: \`model.coverSrc\` as img \`src\`, alt \`model.coverAlt\`; skip the img when cover is missing; an empty-photo block is allowed; never Unsplash, \`/placeholder.svg\`, or invented \`?query=\` images. Show when present, omit the line when missing: \`locationLabel\` (else \`propertyType\`), \`listingBusinessLabel\` / \`model.businessLabel\`, bedrooms, bathrooms, parkingSpaces, area via \`formatAreaM2\`. Never interpolate the listing object as a React child. Design is free (grid vs carousel vs mosaic; radius is site \`--radius\`). WRITE \`components/garagem/listing-card-skeleton.tsx\` only for a slot whose content is still unknown \u2014 never as a \`<Suspense>\` fallback that replaces the catalog, and never the text \u201CCarregando im\xF3veis\u2026\u201D. Do not \`if (search.loading) return\` that skeleton inside the search client.`;
3625
+ const development = studioDevelopmentCardInstruction(pin);
3626
+ return development ? `${base}
3627
+
3628
+ ${development}` : base;
3592
3629
  }
3593
3630
  function studioListingDetailInstruction() {
3594
3631
  const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
@@ -5135,6 +5172,7 @@ export {
5135
5172
  createGaragemClient,
5136
5173
  createTravelTimeCache,
5137
5174
  defaultPhoneCountry,
5175
+ developmentCardPublished,
5138
5176
  displayPathLocation,
5139
5177
  expandVisitSchedule,
5140
5178
  expandVisitTimeSlots,
@@ -5250,6 +5288,7 @@ export {
5250
5288
  studioChromeInstruction,
5251
5289
  studioCodegenContractViolations,
5252
5290
  studioDefaultLeadUi,
5291
+ studioDevelopmentCardInstruction,
5253
5292
  studioLayoutInstruction,
5254
5293
  studioLeadInstruction,
5255
5294
  studioListingCardInstruction,