@garagem-ai/site-sdk 0.14.0 → 0.15.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.js CHANGED
@@ -81,6 +81,7 @@ __export(src_exports, {
81
81
  createTravelTimeCache: () => createTravelTimeCache,
82
82
  defaultPhoneCountry: () => defaultPhoneCountry,
83
83
  developmentCardPublished: () => developmentCardPublished,
84
+ developmentProfilePublished: () => developmentProfilePublished,
84
85
  displayPathLocation: () => displayPathLocation,
85
86
  expandVisitSchedule: () => expandVisitSchedule,
86
87
  expandVisitTimeSlots: () => expandVisitTimeSlots,
@@ -197,6 +198,7 @@ __export(src_exports, {
197
198
  studioCodegenContractViolations: () => studioCodegenContractViolations,
198
199
  studioDefaultLeadUi: () => studioDefaultLeadUi,
199
200
  studioDevelopmentCardInstruction: () => studioDevelopmentCardInstruction,
201
+ studioDevelopmentProfileInstruction: () => studioDevelopmentProfileInstruction,
200
202
  studioLayoutInstruction: () => studioLayoutInstruction,
201
203
  studioLeadInstruction: () => studioLeadInstruction,
202
204
  studioListingCardInstruction: () => studioListingCardInstruction,
@@ -3135,6 +3137,76 @@ function listingAmenityGroups(listing, dictionary) {
3135
3137
  return groups;
3136
3138
  }
3137
3139
 
3140
+ // src/listing-development.ts
3141
+ function formatDateBR(iso) {
3142
+ const match = iso.match(/^(\d{4})-(\d{2})-(\d{2})/);
3143
+ if (!match) return iso;
3144
+ return `${match[3]}/${match[2]}/${match[1]}`;
3145
+ }
3146
+ function countLabel(count, singular, plural) {
3147
+ return `${count} ${count === 1 ? singular : plural}`;
3148
+ }
3149
+ function typologySpecs(typology) {
3150
+ const parts = [];
3151
+ if (typology.bedrooms > 0) {
3152
+ parts.push(countLabel(typology.bedrooms, "quarto", "quartos"));
3153
+ }
3154
+ if (typology.bathrooms > 0) {
3155
+ parts.push(countLabel(typology.bathrooms, "banheiro", "banheiros"));
3156
+ }
3157
+ if (typology.area != null && typology.area > 0) {
3158
+ parts.push(`${Math.round(typology.area)} m\xB2`);
3159
+ }
3160
+ return parts.length > 0 ? parts.join(" \xB7 ") : null;
3161
+ }
3162
+ function typologyModel(typology) {
3163
+ const available = typology.availableUnits != null && typology.availableUnits > 0 ? typology.availableUnits : null;
3164
+ return {
3165
+ name: typology.name,
3166
+ code: typology.code?.trim() || null,
3167
+ availableLabel: available == null ? null : countLabel(available, "dispon\xEDvel", "dispon\xEDveis"),
3168
+ specs: typologySpecs(typology),
3169
+ priceLabel: formatListingPrice(typology.price),
3170
+ pricePerSqmLabel: typology.pricePerSqm == null ? null : `${formatListingPrice(typology.pricePerSqm)}/m\xB2`
3171
+ };
3172
+ }
3173
+ function developmentFacts(profile) {
3174
+ const facts = [];
3175
+ if (profile.developer) {
3176
+ facts.push({ label: "Construtora", text: profile.developer });
3177
+ }
3178
+ if (profile.deliveryDate) {
3179
+ facts.push({
3180
+ label: "Data de entrega",
3181
+ text: formatDateBR(profile.deliveryDate)
3182
+ });
3183
+ }
3184
+ if (profile.launchDate) {
3185
+ facts.push({ label: "Lan\xE7amento", text: formatDateBR(profile.launchDate) });
3186
+ }
3187
+ if (profile.towers != null && profile.towers > 0) {
3188
+ facts.push({ label: "Torres", text: String(profile.towers) });
3189
+ }
3190
+ if (profile.floors != null && profile.floors > 0) {
3191
+ facts.push({ label: "Total de andares", text: String(profile.floors) });
3192
+ }
3193
+ if (profile.totalUnits != null && profile.totalUnits > 0) {
3194
+ facts.push({
3195
+ label: "Total de unidades",
3196
+ text: String(profile.totalUnits)
3197
+ });
3198
+ }
3199
+ return facts;
3200
+ }
3201
+ function listingDevelopmentModel(profile) {
3202
+ if (!profile) return null;
3203
+ const name = profile.name.trim();
3204
+ const facts = developmentFacts(profile);
3205
+ const typologies = profile.typologies.map(typologyModel);
3206
+ if (!name && facts.length === 0 && typologies.length === 0) return null;
3207
+ return { name, facts, typologies };
3208
+ }
3209
+
3138
3210
  // src/listing-card-model.ts
3139
3211
  function listingLocationLabel(location) {
3140
3212
  return [location.neighborhood, location.city, location.state].map((part) => part ? String(part).trim() : "").filter(Boolean).join(", ");
@@ -3439,7 +3511,8 @@ function listingDetailModel(listing, options) {
3439
3511
  description,
3440
3512
  descriptionTruncated: truncated,
3441
3513
  descriptionToggleLabel: truncated ? expanded ? "Ler menos" : "Ler mais" : null,
3442
- mediaOverlays: listingMediaOverlays(listing)
3514
+ mediaOverlays: listingMediaOverlays(listing),
3515
+ development: listingDevelopmentModel(listing.developmentProfile)
3443
3516
  };
3444
3517
  }
3445
3518
 
@@ -3475,9 +3548,11 @@ var STUDIO_SDK_CONTRACT = {
3475
3548
  /**
3476
3549
  * Exact pin for generated Studio sites. Must match a tarball already on
3477
3550
  * npm — v0 installs this version. After a later changeset publishes, bump
3478
- * this and move that release's names from `optionalReactExports` /
3479
- * `unpublishedSearchExports` / `unpublishedPhoneExports` into the
3480
- * prompt-safe lists. Do not bump here until that tarball is on npm.
3551
+ * this and move names that tarball newly exports out of
3552
+ * `optionalReactExports` / `unpublishedSearchExports` /
3553
+ * `unpublishedPhoneExports` into the prompt-safe lists. Names that stay
3554
+ * forbidden after they ship (`searchChromeModel`, `rangeDraftFromPath`)
3555
+ * do not move. Do not bump here until that tarball is on npm.
3481
3556
  * Phone mask helpers shipped in 0.6.0. Map search
3482
3557
  * (`useMapSearch`, `searchListingsInBounds`) shipped in 0.9.0 — 0.7.0
3483
3558
  * does not export them. Property registration shipped in 0.10.0.
@@ -3486,10 +3561,12 @@ var STUDIO_SDK_CONTRACT = {
3486
3561
  * 0.12.0. Analytics catalog events (`trackListingView` plus the search
3487
3562
  * and lead emitters) shipped in 0.13.0. `property_search` sends a city
3488
3563
  * or neighborhood only when the site's location table knows it, as of
3489
- * 0.13.2. Search filter helpers (`visibleSearchFilters` /
3490
- * `toolbarFilterIds`) shipped in 0.4.12 and remain on this pin.
3564
+ * 0.13.2. Development cards (`model.unitCount`, "A partir de" on a
3565
+ * public price) shipped in 0.14.0. Search filter helpers
3566
+ * (`visibleSearchFilters` / `toolbarFilterIds`) shipped in 0.4.12 and
3567
+ * remain on this pin.
3491
3568
  */
3492
- minNpmVersion: "0.13.2",
3569
+ minNpmVersion: "0.14.0",
3493
3570
  /** Historical: older tarballs inject card CSS when those components mount. */
3494
3571
  selfInjectSince: "0.4.2",
3495
3572
  chromeStrategy: "app-owned",
@@ -3591,8 +3668,9 @@ var STUDIO_SDK_CONTRACT = {
3591
3668
  /**
3592
3669
  * Names already on the pinned npm tarball (`minNpmVersion`) — safe for
3593
3670
  * Studio prompts and completeness. Includes `visibleSearchFilters` +
3594
- * `toolbarFilterIds` (shipped in 0.4.12). Do not confuse with
3595
- * `unpublishedSearchExports` (`searchChromeModel`, …).
3671
+ * `toolbarFilterIds` (shipped in 0.4.12) and `unknownSearchLocation`
3672
+ * (shipped in 0.13.4). Do not confuse with `unpublishedSearchExports`
3673
+ * (`searchChromeModel`, …).
3596
3674
  */
3597
3675
  searchExports: [
3598
3676
  "searchResultsHeading",
@@ -3602,23 +3680,19 @@ var STUDIO_SDK_CONTRACT = {
3602
3680
  "paginationPages",
3603
3681
  "hrefWithExplicitPage",
3604
3682
  "countOptionLabel",
3605
- "countFacetChoices"
3683
+ "countFacetChoices",
3684
+ "unknownSearchLocation"
3606
3685
  ],
3607
3686
  /**
3608
- * Main-package helpers in git / newer tarballs but not required on
3609
- * `minNpmVersion`. Prompts must not mention these until the pin bumps and
3610
- * they move into `searchExports`. Independent of the 0.4.12 filter helpers
3611
- * already listed in `searchExports`.
3687
+ * Exported by the pinned tarball, and still forbidden in prompts.
3688
+ * `searchChromeModel` is retired bundled chrome — the prompt names
3689
+ * `visibleSearchFilters` and `toolbarFilterIds` instead. `rangeDraftFromPath`
3690
+ * stays unnamed; price and area drafts stay local state. Helpers the pin
3691
+ * allows (`unknownSearchLocation`, `isAnalyticsDocumentUrl`) are not here.
3612
3692
  */
3613
3693
  unpublishedSearchExports: [
3614
3694
  "searchChromeModel",
3615
- "rangeDraftFromPath",
3616
- // `unknownSearchLocation` is in git. Prompts inline the same check with
3617
- // `parseSearchPublicPath` + `locationsPath` until this name is on the pin.
3618
- "unknownSearchLocation",
3619
- // In git. The installed client inlines the check. Naming it in a prompt
3620
- // makes v0 import it from the pinned tarball, which does not export it.
3621
- "isAnalyticsDocumentUrl"
3695
+ "rangeDraftFromPath"
3622
3696
  ],
3623
3697
  /**
3624
3698
  * maps.fndn.ai helpers (static map, street view, boundaries, travel
@@ -3706,10 +3780,12 @@ var STUDIO_SDK_CONTRACT = {
3706
3780
  /**
3707
3781
  * Listing-view analytics. Search and lead catalog events need no prompt:
3708
3782
  * `usePublicSearch` and the lead helpers emit them from `analyticsSince`.
3709
- * Below it `studioListingViewInstruction` prints nothing and
3710
- * `studioCodegenContractViolations` flags `trackListingView`.
3783
+ * `isAnalyticsDocumentUrl` shipped in 0.13.6 and is prompt-safe on this
3784
+ * pin (it is not a search import). Below `analyticsSince`,
3785
+ * `studioListingViewInstruction` prints nothing and
3786
+ * `studioCodegenContractViolations` flags these names.
3711
3787
  */
3712
- analyticsExports: ["trackListingView"],
3788
+ analyticsExports: ["trackListingView", "isAnalyticsDocumentUrl"],
3713
3789
  analyticsSince: "0.13.0",
3714
3790
  /**
3715
3791
  * Development cards (`model.unitCount`, "A partir de" on `priceLabel`).
@@ -3718,7 +3794,15 @@ var STUDIO_SDK_CONTRACT = {
3718
3794
  * `developmentCardSince` — v0 copies the field and an older
3719
3795
  * `toListingCardModel` does not set it.
3720
3796
  */
3721
- developmentCardSince: "0.14.0"
3797
+ developmentCardSince: "0.14.0",
3798
+ /**
3799
+ * Listing-detail lançamento block (`model.development`). The API can
3800
+ * return `developmentProfile` before this pin. Prompts must not name
3801
+ * `model.development` until `minNpmVersion` reaches
3802
+ * `developmentProfileSince` — an older `listingDetailModel` leaves it
3803
+ * undefined and a generated page would render an empty section.
3804
+ */
3805
+ developmentProfileSince: "0.15.0"
3722
3806
  };
3723
3807
  function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3724
3808
  return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
@@ -3846,6 +3930,13 @@ function studioLeadInstruction() {
3846
3930
  function developmentCardPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3847
3931
  return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentCardSince) >= 0;
3848
3932
  }
3933
+ function developmentProfilePublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3934
+ return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentProfileSince) >= 0;
3935
+ }
3936
+ function studioDevelopmentProfileInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3937
+ if (!developmentProfilePublished(pin)) return "";
3938
+ return `Primary-market detail: \`listingDetailModel\` sets \`model.development\` only for a lan\xE7amento. When \`model.development\` is null, render neither "Sobre o empreendimento" nor "Tipologias dispon\xEDveis" \u2014 \`listing.building\` on a resale condo is not a lan\xE7amento, and \`listing.development\` on a search card is only the collapsed unit count. When it is set, render "Sobre o empreendimento" with \`model.development.name\` when that string is non-empty, then each \`model.development.facts\` item as \`label\` and \`text\`. Render "Tipologias dispon\xEDveis" only when \`model.development.typologies.length\` is greater than 0. Each typology shows \`name\`, \`code\` when set, \`availableLabel\` when set, \`specs\` when set, \`priceLabel\`, and \`pricePerSqmLabel\` when set. Do not fetch typologies from another route.`;
3939
+ }
3849
3940
  function studioDevelopmentCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3850
3941
  if (!developmentCardPublished(pin)) return "";
3851
3942
  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.`;
@@ -3858,9 +3949,11 @@ function studioListingCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3858
3949
 
3859
3950
  ${development}` : base;
3860
3951
  }
3861
- function studioListingDetailInstruction() {
3952
+ function studioListingDetailInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3862
3953
  const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
3863
- return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingDetailModel\` leaves: \`model.facts[].label\` / \`.text\`, \`model.values[].label\` / \`.text\`, \`model.location.label\` / \`model.location.mapsHref\`, breadcrumb \`.href\` (search prefixes of \`listing.path\`). The pre\xE7o / sob consulta entry is the primary value; condom\xEDnio and IPTU are secondary and omitted when missing. \`model.description\` is the complete string \u2014 do not slice. A collapsed disclosure uses a container (max-height or overflow), not a cut of the string. Never interpolate \`model.location\`, \`model.facts\`, \`model.values\`, \`model.breadcrumb\`, or \`model.mediaOverlays\` as a React child. Video/tour: \`model.mediaOverlays\` as hash links (\`#video\` / \`#tour\`); player src is \`embedSrc\`; fullscreen overlay closes with browser back; omit when that overlay is absent. Do not key the page on \`location.hash\`. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` plus the site listing-card module; hide the section when empty. Do not invent a local recommendation loop.`;
3954
+ const base = `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingDetailModel\` leaves: \`model.facts[].label\` / \`.text\`, \`model.values[].label\` / \`.text\`, \`model.location.label\` / \`model.location.mapsHref\`, breadcrumb \`.href\` (search prefixes of \`listing.path\`). The pre\xE7o / sob consulta entry is the primary value; condom\xEDnio and IPTU are secondary and omitted when missing. \`model.description\` is the complete string \u2014 do not slice. A collapsed disclosure uses a container (max-height or overflow), not a cut of the string. Never interpolate \`model.location\`, \`model.facts\`, \`model.values\`, \`model.breadcrumb\`, or \`model.mediaOverlays\` as a React child. Video/tour: \`model.mediaOverlays\` as hash links (\`#video\` / \`#tour\`); player src is \`embedSrc\`; fullscreen overlay closes with browser back; omit when that overlay is absent. Do not key the page on \`location.hash\`. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` plus the site listing-card module; hide the section when empty. Do not invent a local recommendation loop.`;
3955
+ const development = studioDevelopmentProfileInstruction(pin);
3956
+ return development ? `${base} ${development}` : base;
3864
3957
  }
3865
3958
  function studioPhotoInstructionFor(published) {
3866
3959
  const has = (name) => published.includes(name);
@@ -5405,6 +5498,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
5405
5498
  createTravelTimeCache,
5406
5499
  defaultPhoneCountry,
5407
5500
  developmentCardPublished,
5501
+ developmentProfilePublished,
5408
5502
  displayPathLocation,
5409
5503
  expandVisitSchedule,
5410
5504
  expandVisitTimeSlots,
@@ -5521,6 +5615,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
5521
5615
  studioCodegenContractViolations,
5522
5616
  studioDefaultLeadUi,
5523
5617
  studioDevelopmentCardInstruction,
5618
+ studioDevelopmentProfileInstruction,
5524
5619
  studioLayoutInstruction,
5525
5620
  studioLeadInstruction,
5526
5621
  studioListingCardInstruction,