@garagem-ai/site-sdk 0.14.1 → 0.15.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.d.mts +46 -7
- package/dist/index.d.ts +46 -7
- package/dist/index.js +99 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/{types-photo-search--3fBk3Cs.d.mts → types-photo-search-BqKzj97S.d.mts} +27 -0
- package/dist/{types-photo-search--3fBk3Cs.d.ts → types-photo-search-BqKzj97S.d.ts} +27 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/listing-detail.ts +18 -1
- package/src/listing-development.ts +107 -0
- package/src/studio-contract.ts +34 -4
- package/src/types.ts +27 -0
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
|
|
|
@@ -3258,11 +3329,12 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
3258
3329
|
* and lead emitters) shipped in 0.13.0. `property_search` sends a city
|
|
3259
3330
|
* or neighborhood only when the site's location table knows it, as of
|
|
3260
3331
|
* 0.13.2. Development cards (`model.unitCount`, "A partir de" on a
|
|
3261
|
-
* public price) shipped in 0.14.0.
|
|
3332
|
+
* public price) shipped in 0.14.0. The listing-detail lançamento
|
|
3333
|
+
* block (`model.development`) shipped in 0.15.0. Search filter helpers
|
|
3262
3334
|
* (`visibleSearchFilters` / `toolbarFilterIds`) shipped in 0.4.12 and
|
|
3263
3335
|
* remain on this pin.
|
|
3264
3336
|
*/
|
|
3265
|
-
minNpmVersion: "0.
|
|
3337
|
+
minNpmVersion: "0.15.0",
|
|
3266
3338
|
/** Historical: older tarballs inject card CSS when those components mount. */
|
|
3267
3339
|
selfInjectSince: "0.4.2",
|
|
3268
3340
|
chromeStrategy: "app-owned",
|
|
@@ -3490,7 +3562,15 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
3490
3562
|
* `developmentCardSince` — v0 copies the field and an older
|
|
3491
3563
|
* `toListingCardModel` does not set it.
|
|
3492
3564
|
*/
|
|
3493
|
-
developmentCardSince: "0.14.0"
|
|
3565
|
+
developmentCardSince: "0.14.0",
|
|
3566
|
+
/**
|
|
3567
|
+
* Listing-detail lançamento block (`model.development`). The API can
|
|
3568
|
+
* return `developmentProfile` before this pin. Prompts must not name
|
|
3569
|
+
* `model.development` until `minNpmVersion` reaches
|
|
3570
|
+
* `developmentProfileSince` — an older `listingDetailModel` leaves it
|
|
3571
|
+
* undefined and a generated page would render an empty section.
|
|
3572
|
+
*/
|
|
3573
|
+
developmentProfileSince: "0.15.0"
|
|
3494
3574
|
};
|
|
3495
3575
|
function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3496
3576
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
|
|
@@ -3618,6 +3698,13 @@ function studioLeadInstruction() {
|
|
|
3618
3698
|
function developmentCardPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3619
3699
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentCardSince) >= 0;
|
|
3620
3700
|
}
|
|
3701
|
+
function developmentProfilePublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3702
|
+
return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentProfileSince) >= 0;
|
|
3703
|
+
}
|
|
3704
|
+
function studioDevelopmentProfileInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3705
|
+
if (!developmentProfilePublished(pin)) return "";
|
|
3706
|
+
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.`;
|
|
3707
|
+
}
|
|
3621
3708
|
function studioDevelopmentCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3622
3709
|
if (!developmentCardPublished(pin)) return "";
|
|
3623
3710
|
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.`;
|
|
@@ -3630,9 +3717,11 @@ function studioListingCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
|
3630
3717
|
|
|
3631
3718
|
${development}` : base;
|
|
3632
3719
|
}
|
|
3633
|
-
function studioListingDetailInstruction() {
|
|
3720
|
+
function studioListingDetailInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3634
3721
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
3635
|
-
|
|
3722
|
+
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.`;
|
|
3723
|
+
const development = studioDevelopmentProfileInstruction(pin);
|
|
3724
|
+
return development ? `${base} ${development}` : base;
|
|
3636
3725
|
}
|
|
3637
3726
|
function studioPhotoInstructionFor(published) {
|
|
3638
3727
|
const has = (name) => published.includes(name);
|
|
@@ -5176,6 +5265,7 @@ export {
|
|
|
5176
5265
|
createTravelTimeCache,
|
|
5177
5266
|
defaultPhoneCountry,
|
|
5178
5267
|
developmentCardPublished,
|
|
5268
|
+
developmentProfilePublished,
|
|
5179
5269
|
displayPathLocation,
|
|
5180
5270
|
expandVisitSchedule,
|
|
5181
5271
|
expandVisitTimeSlots,
|
|
@@ -5292,6 +5382,7 @@ export {
|
|
|
5292
5382
|
studioCodegenContractViolations,
|
|
5293
5383
|
studioDefaultLeadUi,
|
|
5294
5384
|
studioDevelopmentCardInstruction,
|
|
5385
|
+
studioDevelopmentProfileInstruction,
|
|
5295
5386
|
studioLayoutInstruction,
|
|
5296
5387
|
studioLeadInstruction,
|
|
5297
5388
|
studioListingCardInstruction,
|