@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.mjs CHANGED
@@ -2904,6 +2904,76 @@ function listingAmenityGroups(listing, dictionary) {
2904
2904
  return groups;
2905
2905
  }
2906
2906
 
2907
+ // src/listing-development.ts
2908
+ function formatDateBR(iso) {
2909
+ const match = iso.match(/^(\d{4})-(\d{2})-(\d{2})/);
2910
+ if (!match) return iso;
2911
+ return `${match[3]}/${match[2]}/${match[1]}`;
2912
+ }
2913
+ function countLabel(count, singular, plural) {
2914
+ return `${count} ${count === 1 ? singular : plural}`;
2915
+ }
2916
+ function typologySpecs(typology) {
2917
+ const parts = [];
2918
+ if (typology.bedrooms > 0) {
2919
+ parts.push(countLabel(typology.bedrooms, "quarto", "quartos"));
2920
+ }
2921
+ if (typology.bathrooms > 0) {
2922
+ parts.push(countLabel(typology.bathrooms, "banheiro", "banheiros"));
2923
+ }
2924
+ if (typology.area != null && typology.area > 0) {
2925
+ parts.push(`${Math.round(typology.area)} m\xB2`);
2926
+ }
2927
+ return parts.length > 0 ? parts.join(" \xB7 ") : null;
2928
+ }
2929
+ function typologyModel(typology) {
2930
+ const available = typology.availableUnits != null && typology.availableUnits > 0 ? typology.availableUnits : null;
2931
+ return {
2932
+ name: typology.name,
2933
+ code: typology.code?.trim() || null,
2934
+ availableLabel: available == null ? null : countLabel(available, "dispon\xEDvel", "dispon\xEDveis"),
2935
+ specs: typologySpecs(typology),
2936
+ priceLabel: formatListingPrice(typology.price),
2937
+ pricePerSqmLabel: typology.pricePerSqm == null ? null : `${formatListingPrice(typology.pricePerSqm)}/m\xB2`
2938
+ };
2939
+ }
2940
+ function developmentFacts(profile) {
2941
+ const facts = [];
2942
+ if (profile.developer) {
2943
+ facts.push({ label: "Construtora", text: profile.developer });
2944
+ }
2945
+ if (profile.deliveryDate) {
2946
+ facts.push({
2947
+ label: "Data de entrega",
2948
+ text: formatDateBR(profile.deliveryDate)
2949
+ });
2950
+ }
2951
+ if (profile.launchDate) {
2952
+ facts.push({ label: "Lan\xE7amento", text: formatDateBR(profile.launchDate) });
2953
+ }
2954
+ if (profile.towers != null && profile.towers > 0) {
2955
+ facts.push({ label: "Torres", text: String(profile.towers) });
2956
+ }
2957
+ if (profile.floors != null && profile.floors > 0) {
2958
+ facts.push({ label: "Total de andares", text: String(profile.floors) });
2959
+ }
2960
+ if (profile.totalUnits != null && profile.totalUnits > 0) {
2961
+ facts.push({
2962
+ label: "Total de unidades",
2963
+ text: String(profile.totalUnits)
2964
+ });
2965
+ }
2966
+ return facts;
2967
+ }
2968
+ function listingDevelopmentModel(profile) {
2969
+ if (!profile) return null;
2970
+ const name = profile.name.trim();
2971
+ const facts = developmentFacts(profile);
2972
+ const typologies = profile.typologies.map(typologyModel);
2973
+ if (!name && facts.length === 0 && typologies.length === 0) return null;
2974
+ return { name, facts, typologies };
2975
+ }
2976
+
2907
2977
  // src/listing-card-model.ts
2908
2978
  function listingLocationLabel(location) {
2909
2979
  return [location.neighborhood, location.city, location.state].map((part) => part ? String(part).trim() : "").filter(Boolean).join(", ");
@@ -3208,7 +3278,8 @@ function listingDetailModel(listing, options) {
3208
3278
  description,
3209
3279
  descriptionTruncated: truncated,
3210
3280
  descriptionToggleLabel: truncated ? expanded ? "Ler menos" : "Ler mais" : null,
3211
- mediaOverlays: listingMediaOverlays(listing)
3281
+ mediaOverlays: listingMediaOverlays(listing),
3282
+ development: listingDevelopmentModel(listing.developmentProfile)
3212
3283
  };
3213
3284
  }
3214
3285
 
@@ -3244,9 +3315,11 @@ var STUDIO_SDK_CONTRACT = {
3244
3315
  /**
3245
3316
  * Exact pin for generated Studio sites. Must match a tarball already on
3246
3317
  * npm — v0 installs this version. After a later changeset publishes, bump
3247
- * this and move that release's names from `optionalReactExports` /
3248
- * `unpublishedSearchExports` / `unpublishedPhoneExports` into the
3249
- * prompt-safe lists. Do not bump here until that tarball is on npm.
3318
+ * this and move names that tarball newly exports out of
3319
+ * `optionalReactExports` / `unpublishedSearchExports` /
3320
+ * `unpublishedPhoneExports` into the prompt-safe lists. Names that stay
3321
+ * forbidden after they ship (`searchChromeModel`, `rangeDraftFromPath`)
3322
+ * do not move. Do not bump here until that tarball is on npm.
3250
3323
  * Phone mask helpers shipped in 0.6.0. Map search
3251
3324
  * (`useMapSearch`, `searchListingsInBounds`) shipped in 0.9.0 — 0.7.0
3252
3325
  * does not export them. Property registration shipped in 0.10.0.
@@ -3255,10 +3328,12 @@ var STUDIO_SDK_CONTRACT = {
3255
3328
  * 0.12.0. Analytics catalog events (`trackListingView` plus the search
3256
3329
  * and lead emitters) shipped in 0.13.0. `property_search` sends a city
3257
3330
  * or neighborhood only when the site's location table knows it, as of
3258
- * 0.13.2. Search filter helpers (`visibleSearchFilters` /
3259
- * `toolbarFilterIds`) shipped in 0.4.12 and remain on this pin.
3331
+ * 0.13.2. Development cards (`model.unitCount`, "A partir de" on a
3332
+ * public price) shipped in 0.14.0. Search filter helpers
3333
+ * (`visibleSearchFilters` / `toolbarFilterIds`) shipped in 0.4.12 and
3334
+ * remain on this pin.
3260
3335
  */
3261
- minNpmVersion: "0.13.2",
3336
+ minNpmVersion: "0.14.0",
3262
3337
  /** Historical: older tarballs inject card CSS when those components mount. */
3263
3338
  selfInjectSince: "0.4.2",
3264
3339
  chromeStrategy: "app-owned",
@@ -3360,8 +3435,9 @@ var STUDIO_SDK_CONTRACT = {
3360
3435
  /**
3361
3436
  * Names already on the pinned npm tarball (`minNpmVersion`) — safe for
3362
3437
  * Studio prompts and completeness. Includes `visibleSearchFilters` +
3363
- * `toolbarFilterIds` (shipped in 0.4.12). Do not confuse with
3364
- * `unpublishedSearchExports` (`searchChromeModel`, …).
3438
+ * `toolbarFilterIds` (shipped in 0.4.12) and `unknownSearchLocation`
3439
+ * (shipped in 0.13.4). Do not confuse with `unpublishedSearchExports`
3440
+ * (`searchChromeModel`, …).
3365
3441
  */
3366
3442
  searchExports: [
3367
3443
  "searchResultsHeading",
@@ -3371,23 +3447,19 @@ var STUDIO_SDK_CONTRACT = {
3371
3447
  "paginationPages",
3372
3448
  "hrefWithExplicitPage",
3373
3449
  "countOptionLabel",
3374
- "countFacetChoices"
3450
+ "countFacetChoices",
3451
+ "unknownSearchLocation"
3375
3452
  ],
3376
3453
  /**
3377
- * Main-package helpers in git / newer tarballs but not required on
3378
- * `minNpmVersion`. Prompts must not mention these until the pin bumps and
3379
- * they move into `searchExports`. Independent of the 0.4.12 filter helpers
3380
- * already listed in `searchExports`.
3454
+ * Exported by the pinned tarball, and still forbidden in prompts.
3455
+ * `searchChromeModel` is retired bundled chrome — the prompt names
3456
+ * `visibleSearchFilters` and `toolbarFilterIds` instead. `rangeDraftFromPath`
3457
+ * stays unnamed; price and area drafts stay local state. Helpers the pin
3458
+ * allows (`unknownSearchLocation`, `isAnalyticsDocumentUrl`) are not here.
3381
3459
  */
3382
3460
  unpublishedSearchExports: [
3383
3461
  "searchChromeModel",
3384
- "rangeDraftFromPath",
3385
- // `unknownSearchLocation` is in git. Prompts inline the same check with
3386
- // `parseSearchPublicPath` + `locationsPath` until this name is on the pin.
3387
- "unknownSearchLocation",
3388
- // In git. The installed client inlines the check. Naming it in a prompt
3389
- // makes v0 import it from the pinned tarball, which does not export it.
3390
- "isAnalyticsDocumentUrl"
3462
+ "rangeDraftFromPath"
3391
3463
  ],
3392
3464
  /**
3393
3465
  * maps.fndn.ai helpers (static map, street view, boundaries, travel
@@ -3475,10 +3547,12 @@ var STUDIO_SDK_CONTRACT = {
3475
3547
  /**
3476
3548
  * Listing-view analytics. Search and lead catalog events need no prompt:
3477
3549
  * `usePublicSearch` and the lead helpers emit them from `analyticsSince`.
3478
- * Below it `studioListingViewInstruction` prints nothing and
3479
- * `studioCodegenContractViolations` flags `trackListingView`.
3550
+ * `isAnalyticsDocumentUrl` shipped in 0.13.6 and is prompt-safe on this
3551
+ * pin (it is not a search import). Below `analyticsSince`,
3552
+ * `studioListingViewInstruction` prints nothing and
3553
+ * `studioCodegenContractViolations` flags these names.
3480
3554
  */
3481
- analyticsExports: ["trackListingView"],
3555
+ analyticsExports: ["trackListingView", "isAnalyticsDocumentUrl"],
3482
3556
  analyticsSince: "0.13.0",
3483
3557
  /**
3484
3558
  * Development cards (`model.unitCount`, "A partir de" on `priceLabel`).
@@ -3487,7 +3561,15 @@ var STUDIO_SDK_CONTRACT = {
3487
3561
  * `developmentCardSince` — v0 copies the field and an older
3488
3562
  * `toListingCardModel` does not set it.
3489
3563
  */
3490
- developmentCardSince: "0.14.0"
3564
+ developmentCardSince: "0.14.0",
3565
+ /**
3566
+ * Listing-detail lançamento block (`model.development`). The API can
3567
+ * return `developmentProfile` before this pin. Prompts must not name
3568
+ * `model.development` until `minNpmVersion` reaches
3569
+ * `developmentProfileSince` — an older `listingDetailModel` leaves it
3570
+ * undefined and a generated page would render an empty section.
3571
+ */
3572
+ developmentProfileSince: "0.15.0"
3491
3573
  };
3492
3574
  function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3493
3575
  return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
@@ -3615,6 +3697,13 @@ function studioLeadInstruction() {
3615
3697
  function developmentCardPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3616
3698
  return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentCardSince) >= 0;
3617
3699
  }
3700
+ function developmentProfilePublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3701
+ return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentProfileSince) >= 0;
3702
+ }
3703
+ function studioDevelopmentProfileInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3704
+ if (!developmentProfilePublished(pin)) return "";
3705
+ 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.`;
3706
+ }
3618
3707
  function studioDevelopmentCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3619
3708
  if (!developmentCardPublished(pin)) return "";
3620
3709
  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.`;
@@ -3627,9 +3716,11 @@ function studioListingCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3627
3716
 
3628
3717
  ${development}` : base;
3629
3718
  }
3630
- function studioListingDetailInstruction() {
3719
+ function studioListingDetailInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
3631
3720
  const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
3632
- 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.`;
3721
+ 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.`;
3722
+ const development = studioDevelopmentProfileInstruction(pin);
3723
+ return development ? `${base} ${development}` : base;
3633
3724
  }
3634
3725
  function studioPhotoInstructionFor(published) {
3635
3726
  const has = (name) => published.includes(name);
@@ -5173,6 +5264,7 @@ export {
5173
5264
  createTravelTimeCache,
5174
5265
  defaultPhoneCountry,
5175
5266
  developmentCardPublished,
5267
+ developmentProfilePublished,
5176
5268
  displayPathLocation,
5177
5269
  expandVisitSchedule,
5178
5270
  expandVisitTimeSlots,
@@ -5289,6 +5381,7 @@ export {
5289
5381
  studioCodegenContractViolations,
5290
5382
  studioDefaultLeadUi,
5291
5383
  studioDevelopmentCardInstruction,
5384
+ studioDevelopmentProfileInstruction,
5292
5385
  studioLayoutInstruction,
5293
5386
  studioLeadInstruction,
5294
5387
  studioListingCardInstruction,