@garagem-ai/site-sdk 0.4.14 → 0.5.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
@@ -1918,6 +1918,35 @@ function paginationPages(currentPage, totalPages, padding) {
1918
1918
  for (let i = start; i <= end; i += 1) pages.push(i);
1919
1919
  return pages;
1920
1920
  }
1921
+ var SEARCH_EMPTY_COPY = "Nenhum im\xF3vel encontrado. Ajuste a busca ou os filtros.";
1922
+ function rangeDraftFromPath(pathFilters) {
1923
+ const price = pathFilters.price || {};
1924
+ const area = pathFilters.area || {};
1925
+ return {
1926
+ price: {
1927
+ min: price.min != null ? formatGroupedInteger(price.min) : "",
1928
+ max: price.max != null ? formatGroupedInteger(price.max) : ""
1929
+ },
1930
+ property_area_total: {
1931
+ min: area.min != null ? String(area.min) : "",
1932
+ max: area.max != null ? String(area.max) : ""
1933
+ }
1934
+ };
1935
+ }
1936
+ function searchChromeModel(schema, pathFilters, locationNames) {
1937
+ const filters = visibleSearchFilters(schema);
1938
+ const toolbarIds = new Set(toolbarFilterIds(schema));
1939
+ return {
1940
+ headingTitle: searchResultsHeading(
1941
+ pathFilters,
1942
+ schema?.dictionary,
1943
+ locationNames
1944
+ ),
1945
+ toolbarFilters: filters.filter((filter) => toolbarIds.has(filter.id)),
1946
+ extraFilters: filters.filter((filter) => !toolbarIds.has(filter.id)),
1947
+ sortOptions: searchSortOptions(schema?.sorts)
1948
+ };
1949
+ }
1921
1950
 
1922
1951
  // src/listing-detail.ts
1923
1952
  var LISTING_DESCRIPTION_CLAMP = 280;
@@ -2210,18 +2239,13 @@ var STUDIO_SDK_CONTRACT = {
2210
2239
  * Exact pin for generated Studio sites. Must match a tarball already on
2211
2240
  * npm — v0 installs this version. After the 0.4.13 changeset publishes,
2212
2241
  * bump this and move that release's names from `optionalReactExports`
2213
- * into `reactExports`.
2242
+ * into `reactExports`. Do not bump here until a headless tarball is on npm.
2214
2243
  */
2215
2244
  minNpmVersion: "0.4.12",
2216
- /** First release where ListingCard and ResultsSkeleton inject the sheet. */
2245
+ /** First release where ListingCard and ResultsSkeleton inject card CSS. */
2217
2246
  selfInjectSince: "0.4.2",
2218
2247
  chromeStrategy: "self-inject",
2219
- reactExports: [
2220
- "SearchPage",
2221
- "ListingCard",
2222
- "usePublicSearch",
2223
- "ResultsSkeleton"
2224
- ],
2248
+ reactExports: ["usePublicSearch", "ListingCard", "ResultsSkeleton"],
2225
2249
  /**
2226
2250
  * Names that exist in git / the unpublished patch. Completeness treats an
2227
2251
  * import as `sdk-export-mismatch` when the generated pin is older than
@@ -2230,10 +2254,22 @@ var STUDIO_SDK_CONTRACT = {
2230
2254
  * throws FatalRendererError.
2231
2255
  */
2232
2256
  optionalReactExports: {
2233
- SearchPageFallback: "0.4.1",
2234
2257
  SearchChromeStyles: "0.4.1",
2235
2258
  ListingDetailFields: "0.4.13"
2236
2259
  },
2260
+ /**
2261
+ * Former `/react` chrome. Completeness flags imports as mismatch (not in
2262
+ * `reactExports`). Prompts must not mention these names at all — v0 copies
2263
+ * identifiers even inside “never import”.
2264
+ */
2265
+ retiredReactExports: [
2266
+ "SearchPage",
2267
+ "SearchQueryForm",
2268
+ "SearchSortSelect",
2269
+ "FilterPanel",
2270
+ "SearchPagination",
2271
+ "SearchPageFallback"
2272
+ ],
2237
2273
  forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"],
2238
2274
  leadStrategy: "visit-default",
2239
2275
  leadExports: [
@@ -2247,7 +2283,22 @@ var STUDIO_SDK_CONTRACT = {
2247
2283
  "STUDIO_DEFAULT_VISIT_SCHEDULE"
2248
2284
  ],
2249
2285
  listingDetailExports: ["listingDetailModel", "getSimilarListings"],
2250
- amenityExports: ["listingAmenityGroups"]
2286
+ amenityExports: ["listingAmenityGroups"],
2287
+ /** Names on the pinned tarball — safe to put in Studio prompts. */
2288
+ searchExports: [
2289
+ "searchResultsHeading",
2290
+ "searchSortOptions",
2291
+ "paginationPages",
2292
+ "hrefWithExplicitPage"
2293
+ ],
2294
+ /**
2295
+ * Main-package helpers in git but not on `minNpmVersion`. Prompts must
2296
+ * not mention these until the pin bumps and they move into `searchExports`.
2297
+ */
2298
+ unpublishedSearchExports: [
2299
+ "searchChromeModel",
2300
+ "rangeDraftFromPath"
2301
+ ]
2251
2302
  };
2252
2303
  var STUDIO_SITE_LAYOUT = {
2253
2304
  maxWidthRem: "80rem",
@@ -2276,7 +2327,7 @@ ${studioSiteWidthCss()}
2276
2327
  Every page section is two layers: (1) surface \u2014 \`section\` / header / footer \`${STUDIO_SITE_LAYOUT.surfaceClassName}\`, background to the viewport edges, no max-width class and no horizontal padding; (2) wrapper \u2014 one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Header and footer use that same inner wrapper. Components fill the wrapper (\`w-full\`). Never nest a second max-width container with extra horizontal padding. ${studioSearchLandmarkInstruction()} Do not use \`ml-auto\` on the content wrapper. To make the site narrower or wider, change ONLY \`--site-max-width\` in \`app/globals.css\` (allowed: ${scale}; default ${STUDIO_SITE_LAYOUT.maxWidthRem}). Do not edit wrapper class names or horizontal padding. Full-bleed image surfaces (home hero, listing gallery) stay flush with the header \u2014 do not add vertical padding there.`;
2277
2328
  }
2278
2329
  function studioSearchLandmarkInstruction() {
2279
- return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Pass \`as="div"\` to \`SearchPage\` so it is not a second main. Mount as one line: \`<SearchPage as="div" siteId={() => resolveSiteId(window.location.host)} baseUrl={GARAGEM_API_BASE} variant="toolbar" />\`. Do not wrap \`SearchPage\` in \`<section>\` or add another \`<h1>\`. SearchPage owns the SEO heading: count in \`data-slot="search-heading-count"\` (sibling \`<span>\`), title in \`<h1 data-slot="search-heading-title">\` \u2014 never put the count inside the H1. Do not put vertical padding on SearchPage. \`pt-4 pb-12\` is the default on that search \`<main>\` \u2014 change those values if the design needs it. Flush search (glued to the header) is allowed only with \`${STUDIO_SITE_LAYOUT.searchFlushMarker}\` on that \`<main>\`. Never add that vertical padding to home heroes or listing galleries.`;
2330
+ return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Wire the catalog with \`usePublicSearch\` from \`${STUDIO_SDK_PACKAGE}/react\` inside \`<Suspense fallback={<ResultsSkeleton />}>\`. Do not wrap the search UI in \`<section>\` or a second max-width. The page owns the SEO heading: count in a sibling \`<span data-slot="search-heading-count">\`, title in \`<h1 data-slot="search-heading-title">\` \u2014 never put the count inside the H1. \`pt-4 pb-12\` is the default on that search \`<main>\` \u2014 change those values if the design needs it. Flush search (glued to the header) is allowed only with \`${STUDIO_SITE_LAYOUT.searchFlushMarker}\` on that \`<main>\`. Never add that vertical padding to home heroes or listing galleries.`;
2280
2331
  }
2281
2332
  var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
2282
2333
  var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
@@ -2348,17 +2399,31 @@ function studioListingDetailInstruction() {
2348
2399
  function studioAmenityInstruction() {
2349
2400
  return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (optional dictionary from \`getSearchUi()\`). Each group is \`{ title, labels: string[] }\` \u2014 render \`group.labels.map((label) => \u2026)\` and hide a group when \`group.labels.length === 0\`. Titles: \`Comodidades\` / \`Comodidades do condom\xEDnio\`. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
2350
2401
  }
2402
+ function studioSearchInstruction() {
2403
+ const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
2404
+ const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
2405
+ return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}. Call \`usePublicSearch({ siteId, baseUrl: GARAGEM_API_BASE })\` in a client component inside \`<Suspense>\` (\`useSearchParams\`). Compose the page UI in the app \u2014 do not paste a canonical search TSX. Title from \`searchResultsHeading\`; sort \`.id\` / \`.label\` from \`searchSortOptions\`. Never interpolate \`schema\`, \`pathFilters\`, or a filter object as a React child. \`queryListings\` key is \`params\`. The URL is the document. Empty copy: ${JSON.stringify(SEARCH_EMPTY_COPY)}`;
2406
+ }
2351
2407
  function studioChromeInstruction() {
2352
- const injectors = compareSemver(
2353
- STUDIO_SDK_CONTRACT.minNpmVersion,
2354
- STUDIO_SDK_CONTRACT.selfInjectSince
2355
- ) >= 0 ? "`SearchPage`, `ListingCard`, and `ResultsSkeleton`" : "`SearchPage`";
2356
- return `Search chrome CSS is injected by ${injectors} (JS \`<style>\` tag). Never \`import "@garagem-ai/site-sdk/react/search.css"\` \u2014 v0 preview cannot load npm CSS. Do not copy SDK card/toolbar layout into the app. Theme via CSS variables in \`app/globals.css\` (\`SEARCH_CSS_RECIPE\` / \`--garagem-*\`), \`classNames\`, and \`data-slot\`.`;
2408
+ return `ListingCard and ResultsSkeleton inject card/skeleton CSS (JS \`<style>\` tag). Never \`import "${STUDIO_SDK_CONTRACT.forbiddenImports[0]}"\` \u2014 v0 preview cannot load npm CSS. Do not copy SDK card layout into the app. Theme cards via CSS variables in \`app/globals.css\` (\`SEARCH_CSS_RECIPE\` / \`--garagem-*\`). Search chrome (query, toolbar, sort, filters, pagination) is app-owned \u2014 theme with the site tokens, not an SDK stylesheet.`;
2409
+ }
2410
+ function mentionsExportName(text, name) {
2411
+ return new RegExp(`\\b${name}\\b`).test(text);
2357
2412
  }
2358
2413
  function studioCodegenContractViolations(text) {
2359
2414
  const violations = [];
2360
2415
  for (const name of Object.keys(STUDIO_SDK_CONTRACT.optionalReactExports)) {
2361
- if (text.includes(name)) violations.push(name);
2416
+ if (mentionsExportName(text, name)) violations.push(name);
2417
+ }
2418
+ for (const name of STUDIO_SDK_CONTRACT.retiredReactExports) {
2419
+ if (mentionsExportName(text, name) && !violations.includes(name)) {
2420
+ violations.push(name);
2421
+ }
2422
+ }
2423
+ for (const name of STUDIO_SDK_CONTRACT.unpublishedSearchExports) {
2424
+ if (mentionsExportName(text, name) && !violations.includes(name)) {
2425
+ violations.push(name);
2426
+ }
2362
2427
  }
2363
2428
  const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
2364
2429
  const available = reactExportsAvailableAt(pin);
@@ -2540,6 +2605,7 @@ export {
2540
2605
  LeadSubmitError,
2541
2606
  SEARCH_CSS_RECIPE,
2542
2607
  SEARCH_CSS_VARS,
2608
+ SEARCH_EMPTY_COPY,
2543
2609
  SEARCH_SORT_RELEVANCE,
2544
2610
  STUDIO_DEFAULT_VISIT_SCHEDULE,
2545
2611
  STUDIO_SDK_CONTRACT,
@@ -2610,9 +2676,11 @@ export {
2610
2676
  pathLocationToFilterInput,
2611
2677
  publicSearchHref,
2612
2678
  queryListings,
2679
+ rangeDraftFromPath,
2613
2680
  readPublicSearch,
2614
2681
  reduceAppliedSearchQuery2 as reduceAppliedSearchQuery,
2615
2682
  resolvePublicSiteId,
2683
+ searchChromeModel,
2616
2684
  searchHrefUsesLegacyFilterQuery,
2617
2685
  searchListings,
2618
2686
  searchResultsHeading,
@@ -2627,6 +2695,7 @@ export {
2627
2695
  studioLeadInstruction,
2628
2696
  studioListingDetailInstruction,
2629
2697
  studioSdkPinInstruction,
2698
+ studioSearchInstruction,
2630
2699
  studioSearchLandmarkInstruction,
2631
2700
  studioSiteWidthCss,
2632
2701
  submitContactLead,