@garagem-ai/site-sdk 0.13.6 → 0.14.1

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
 
@@ -3226,9 +3244,11 @@ var STUDIO_SDK_CONTRACT = {
3226
3244
  /**
3227
3245
  * Exact pin for generated Studio sites. Must match a tarball already on
3228
3246
  * npm — v0 installs this version. After a later changeset publishes, bump
3229
- * this and move that release's names from `optionalReactExports` /
3230
- * `unpublishedSearchExports` / `unpublishedPhoneExports` into the
3231
- * prompt-safe lists. Do not bump here until that tarball is on npm.
3247
+ * this and move names that tarball newly exports out of
3248
+ * `optionalReactExports` / `unpublishedSearchExports` /
3249
+ * `unpublishedPhoneExports` into the prompt-safe lists. Names that stay
3250
+ * forbidden after they ship (`searchChromeModel`, `rangeDraftFromPath`)
3251
+ * do not move. Do not bump here until that tarball is on npm.
3232
3252
  * Phone mask helpers shipped in 0.6.0. Map search
3233
3253
  * (`useMapSearch`, `searchListingsInBounds`) shipped in 0.9.0 — 0.7.0
3234
3254
  * does not export them. Property registration shipped in 0.10.0.
@@ -3237,10 +3257,12 @@ var STUDIO_SDK_CONTRACT = {
3237
3257
  * 0.12.0. Analytics catalog events (`trackListingView` plus the search
3238
3258
  * and lead emitters) shipped in 0.13.0. `property_search` sends a city
3239
3259
  * or neighborhood only when the site's location table knows it, as of
3240
- * 0.13.2. Search filter helpers (`visibleSearchFilters` /
3241
- * `toolbarFilterIds`) shipped in 0.4.12 and remain on this pin.
3260
+ * 0.13.2. Development cards (`model.unitCount`, "A partir de" on a
3261
+ * public price) shipped in 0.14.0. Search filter helpers
3262
+ * (`visibleSearchFilters` / `toolbarFilterIds`) shipped in 0.4.12 and
3263
+ * remain on this pin.
3242
3264
  */
3243
- minNpmVersion: "0.13.2",
3265
+ minNpmVersion: "0.14.0",
3244
3266
  /** Historical: older tarballs inject card CSS when those components mount. */
3245
3267
  selfInjectSince: "0.4.2",
3246
3268
  chromeStrategy: "app-owned",
@@ -3342,8 +3364,9 @@ var STUDIO_SDK_CONTRACT = {
3342
3364
  /**
3343
3365
  * Names already on the pinned npm tarball (`minNpmVersion`) — safe for
3344
3366
  * Studio prompts and completeness. Includes `visibleSearchFilters` +
3345
- * `toolbarFilterIds` (shipped in 0.4.12). Do not confuse with
3346
- * `unpublishedSearchExports` (`searchChromeModel`, …).
3367
+ * `toolbarFilterIds` (shipped in 0.4.12) and `unknownSearchLocation`
3368
+ * (shipped in 0.13.4). Do not confuse with `unpublishedSearchExports`
3369
+ * (`searchChromeModel`, …).
3347
3370
  */
3348
3371
  searchExports: [
3349
3372
  "searchResultsHeading",
@@ -3353,23 +3376,19 @@ var STUDIO_SDK_CONTRACT = {
3353
3376
  "paginationPages",
3354
3377
  "hrefWithExplicitPage",
3355
3378
  "countOptionLabel",
3356
- "countFacetChoices"
3379
+ "countFacetChoices",
3380
+ "unknownSearchLocation"
3357
3381
  ],
3358
3382
  /**
3359
- * Main-package helpers in git / newer tarballs but not required on
3360
- * `minNpmVersion`. Prompts must not mention these until the pin bumps and
3361
- * they move into `searchExports`. Independent of the 0.4.12 filter helpers
3362
- * already listed in `searchExports`.
3383
+ * Exported by the pinned tarball, and still forbidden in prompts.
3384
+ * `searchChromeModel` is retired bundled chrome — the prompt names
3385
+ * `visibleSearchFilters` and `toolbarFilterIds` instead. `rangeDraftFromPath`
3386
+ * stays unnamed; price and area drafts stay local state. Helpers the pin
3387
+ * allows (`unknownSearchLocation`, `isAnalyticsDocumentUrl`) are not here.
3363
3388
  */
3364
3389
  unpublishedSearchExports: [
3365
3390
  "searchChromeModel",
3366
- "rangeDraftFromPath",
3367
- // `unknownSearchLocation` is in git. Prompts inline the same check with
3368
- // `parseSearchPublicPath` + `locationsPath` until this name is on the pin.
3369
- "unknownSearchLocation",
3370
- // In git. The installed client inlines the check. Naming it in a prompt
3371
- // makes v0 import it from the pinned tarball, which does not export it.
3372
- "isAnalyticsDocumentUrl"
3391
+ "rangeDraftFromPath"
3373
3392
  ],
3374
3393
  /**
3375
3394
  * maps.fndn.ai helpers (static map, street view, boundaries, travel
@@ -3457,11 +3476,21 @@ var STUDIO_SDK_CONTRACT = {
3457
3476
  /**
3458
3477
  * Listing-view analytics. Search and lead catalog events need no prompt:
3459
3478
  * `usePublicSearch` and the lead helpers emit them from `analyticsSince`.
3460
- * Below it `studioListingViewInstruction` prints nothing and
3461
- * `studioCodegenContractViolations` flags `trackListingView`.
3479
+ * `isAnalyticsDocumentUrl` shipped in 0.13.6 and is prompt-safe on this
3480
+ * pin (it is not a search import). Below `analyticsSince`,
3481
+ * `studioListingViewInstruction` prints nothing and
3482
+ * `studioCodegenContractViolations` flags these names.
3483
+ */
3484
+ analyticsExports: ["trackListingView", "isAnalyticsDocumentUrl"],
3485
+ analyticsSince: "0.13.0",
3486
+ /**
3487
+ * Development cards (`model.unitCount`, "A partir de" on `priceLabel`).
3488
+ * The search API can return `listing.development` before this pin.
3489
+ * Prompts must not name `unitCount` until `minNpmVersion` reaches
3490
+ * `developmentCardSince` — v0 copies the field and an older
3491
+ * `toListingCardModel` does not set it.
3462
3492
  */
3463
- analyticsExports: ["trackListingView"],
3464
- analyticsSince: "0.13.0"
3493
+ developmentCardSince: "0.14.0"
3465
3494
  };
3466
3495
  function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3467
3496
  return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
@@ -3586,9 +3615,20 @@ function studioLeadInstruction() {
3586
3615
  const phone = STUDIO_SDK_CONTRACT.phoneExports.join(", ");
3587
3616
  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
3617
  }
3589
- function studioListingCardInstruction() {
3618
+ function developmentCardPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3619
+ return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentCardSince) >= 0;
3620
+ }
3621
+ function studioDevelopmentCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3622
+ if (!developmentCardPublished(pin)) return "";
3623
+ 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.`;
3624
+ }
3625
+ function studioListingCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3590
3626
  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.`;
3627
+ 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.`;
3628
+ const development = studioDevelopmentCardInstruction(pin);
3629
+ return development ? `${base}
3630
+
3631
+ ${development}` : base;
3592
3632
  }
3593
3633
  function studioListingDetailInstruction() {
3594
3634
  const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
@@ -5135,6 +5175,7 @@ export {
5135
5175
  createGaragemClient,
5136
5176
  createTravelTimeCache,
5137
5177
  defaultPhoneCountry,
5178
+ developmentCardPublished,
5138
5179
  displayPathLocation,
5139
5180
  expandVisitSchedule,
5140
5181
  expandVisitTimeSlots,
@@ -5250,6 +5291,7 @@ export {
5250
5291
  studioChromeInstruction,
5251
5292
  studioCodegenContractViolations,
5252
5293
  studioDefaultLeadUi,
5294
+ studioDevelopmentCardInstruction,
5253
5295
  studioLayoutInstruction,
5254
5296
  studioLeadInstruction,
5255
5297
  studioListingCardInstruction,