@garagem-ai/site-sdk 0.14.1 → 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.d.mts +43 -5
- package/dist/index.d.ts +43 -5
- package/dist/index.js +96 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -4
- 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 +31 -2
- 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
|
|
|
@@ -3490,7 +3561,15 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
3490
3561
|
* `developmentCardSince` — v0 copies the field and an older
|
|
3491
3562
|
* `toListingCardModel` does not set it.
|
|
3492
3563
|
*/
|
|
3493
|
-
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"
|
|
3494
3573
|
};
|
|
3495
3574
|
function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3496
3575
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
|
|
@@ -3618,6 +3697,13 @@ function studioLeadInstruction() {
|
|
|
3618
3697
|
function developmentCardPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3619
3698
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.developmentCardSince) >= 0;
|
|
3620
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
|
+
}
|
|
3621
3707
|
function studioDevelopmentCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3622
3708
|
if (!developmentCardPublished(pin)) return "";
|
|
3623
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.`;
|
|
@@ -3630,9 +3716,11 @@ function studioListingCardInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
|
3630
3716
|
|
|
3631
3717
|
${development}` : base;
|
|
3632
3718
|
}
|
|
3633
|
-
function studioListingDetailInstruction() {
|
|
3719
|
+
function studioListingDetailInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3634
3720
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
3635
|
-
|
|
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;
|
|
3636
3724
|
}
|
|
3637
3725
|
function studioPhotoInstructionFor(published) {
|
|
3638
3726
|
const has = (name) => published.includes(name);
|
|
@@ -5176,6 +5264,7 @@ export {
|
|
|
5176
5264
|
createTravelTimeCache,
|
|
5177
5265
|
defaultPhoneCountry,
|
|
5178
5266
|
developmentCardPublished,
|
|
5267
|
+
developmentProfilePublished,
|
|
5179
5268
|
displayPathLocation,
|
|
5180
5269
|
expandVisitSchedule,
|
|
5181
5270
|
expandVisitTimeSlots,
|
|
@@ -5292,6 +5381,7 @@ export {
|
|
|
5292
5381
|
studioCodegenContractViolations,
|
|
5293
5382
|
studioDefaultLeadUi,
|
|
5294
5383
|
studioDevelopmentCardInstruction,
|
|
5384
|
+
studioDevelopmentProfileInstruction,
|
|
5295
5385
|
studioLayoutInstruction,
|
|
5296
5386
|
studioLeadInstruction,
|
|
5297
5387
|
studioListingCardInstruction,
|