@garagem-ai/site-sdk 0.4.0 → 0.4.2
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/README.md +29 -9
- package/dist/index.d.mts +57 -58
- package/dist/index.d.ts +57 -58
- package/dist/index.js +187 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +33 -6
- package/dist/react.d.ts +33 -6
- package/dist/react.js +573 -486
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +542 -456
- package/dist/react.mjs.map +1 -1
- package/dist/{listing-card-model-D7iR4asd.d.mts → search-engine-D4EZkNrQ.d.mts} +67 -1
- package/dist/{listing-card-model-D7iR4asd.d.ts → search-engine-D4EZkNrQ.d.ts} +67 -1
- package/package.json +9 -4
- package/src/index.ts +15 -0
- package/src/presentation.ts +7 -0
- package/src/react/filter-panel.tsx +39 -42
- package/src/react/icons.tsx +46 -0
- package/src/react/index.ts +7 -1
- package/src/react/listing-card.tsx +61 -106
- package/src/react/search-chrome.tsx +30 -27
- package/src/react/search-page.tsx +210 -111
- package/src/react/search-pagination.tsx +50 -40
- package/src/react/search-query-form.tsx +31 -26
- package/src/react/search.css +717 -0
- package/src/react/styles/index.ts +1 -0
- package/src/react/styles/search-chrome-css.generated.ts +5 -0
- package/src/react/styles/search-chrome-styles.tsx +31 -0
- package/src/react/types.ts +18 -0
- package/src/react/use-public-search.ts +7 -0
- package/src/search-engine.ts +79 -0
- package/src/studio-contract.ts +138 -0
package/README.md
CHANGED
|
@@ -245,25 +245,45 @@ option on `createGaragemClient`.
|
|
|
245
245
|
|
|
246
246
|
Headless URL/search helpers live on the main entry (`readPublicSearch`,
|
|
247
247
|
`hrefForPathFilters`, `toListingCardModel`, …). The React adapter is a
|
|
248
|
-
separate subpath — peer `react` + `next
|
|
248
|
+
separate subpath — peer `react` + `next`.
|
|
249
|
+
|
|
250
|
+
Studio codegen follows `STUDIO_SDK_CONTRACT`: pin
|
|
251
|
+
`@garagem-ai/site-sdk` to `minNpmVersion` and import only
|
|
252
|
+
`reactExports` (`SearchPage`, `ListingCard`, `usePublicSearch`,
|
|
253
|
+
`ResultsSkeleton` on the Studio pin). Preview, open-in-new-tab, and
|
|
254
|
+
published `next build` all resolve that tarball. Do **not** import npm
|
|
255
|
+
CSS (`@garagem-ai/site-sdk/react/search.css`) in Studio.
|
|
256
|
+
|
|
257
|
+
`SearchPage`, `ListingCard`, and `ResultsSkeleton` inject the chrome
|
|
258
|
+
stylesheet (JS `<style>` tag). Layout tags are optional.
|
|
249
259
|
|
|
250
260
|
```tsx
|
|
251
261
|
"use client";
|
|
252
|
-
import {
|
|
262
|
+
import { Suspense } from "react";
|
|
263
|
+
import { SearchPage, ResultsSkeleton } from "@garagem-ai/site-sdk/react";
|
|
253
264
|
|
|
254
265
|
export default function ImoveisPage() {
|
|
255
266
|
return (
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
267
|
+
<Suspense fallback={<ResultsSkeleton />}>
|
|
268
|
+
<SearchPage
|
|
269
|
+
siteId={process.env.NEXT_PUBLIC_GARAGEM_SITE_ID!}
|
|
270
|
+
variant="toolbar"
|
|
271
|
+
/>
|
|
272
|
+
</Suspense>
|
|
260
273
|
);
|
|
261
274
|
}
|
|
262
275
|
```
|
|
263
276
|
|
|
264
|
-
`variant` is `toolbar` (default), `dialog`, or `sidebar`.
|
|
265
|
-
(`SEARCH_CSS_VARS
|
|
266
|
-
|
|
277
|
+
`variant` is `toolbar` (default), `dialog`, or `sidebar`. Customize with
|
|
278
|
+
CSS variables (`SEARCH_CSS_VARS` / `SEARCH_CSS_RECIPE` in `globals.css`),
|
|
279
|
+
`classNames`, `icons`, and `data-slot`. Home and search should share
|
|
280
|
+
`ListingCard`. The search H1 is SEO stable: hit count is a sibling
|
|
281
|
+
`<span>`, not inside `<h1>`. Presentation tokens stay framework-free on
|
|
282
|
+
the main entry so other adapters can reuse them.
|
|
283
|
+
|
|
284
|
+
Hand-written Next apps that prefer a layout tag or a padded search
|
|
285
|
+
fallback can import those after they ship on npm; until then they are
|
|
286
|
+
not part of the Studio pin.
|
|
267
287
|
|
|
268
288
|
## What's NOT in this release
|
|
269
289
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters, k as SearchUiDictionary, l as QueryListingsFilters, A as AppliedSearchQuery, m as AppliedSearchChange } from './search-engine-D4EZkNrQ.mjs';
|
|
2
|
+
export { n as CmsEntryStatus, o as CmsFieldDefinition, p as CmsFieldType, q as CmsSeoData, F as FORBIDDEN_SEARCH_QUERY_KEYS, r as Listing, s as ListingBusinessType, t as ListingCardModel, u as ListingLocation, v as ListingMedia, w as ListingPriceVisibility, x as ListingPropertySummary, y as LocationNameTables, z as QueryListingsLocation, B as SEARCH_SORT_RELEVANCE, D as SearchPathLocation, E as SearchUiFilter, G as SearchUiOption, T as TOOLBAR_PRIMARY_FILTER_IDS, H as applyPathFilter, I as buildQueryListingsParams, J as canonicalizeSearchHref, K as clearStagedPathFilters, M as countFacetChoices, N as countOptionLabel, O as displayPathLocation, P as hrefForAppliedChange, U as hrefForPathFilters, V as hrefWithExplicitPage, W as isListingDetailPath, X as listingLocationLabel, Y as paginationPages, Z as pathFilterHasOption, _ as pathFilterValue, $ as publicSearchHref, a0 as readPublicSearch, a1 as searchHrefUsesLegacyFilterQuery, a2 as searchResultsHeading, a3 as searchSortOptions, a4 as toListingCardModel, a5 as toolbarFilterIds, a6 as visibleSearchFilters } from './search-engine-D4EZkNrQ.mjs';
|
|
3
3
|
|
|
4
4
|
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
5
5
|
type FetchLike = typeof fetch;
|
|
@@ -165,7 +165,11 @@ declare const SEARCH_CSS_VARS: {
|
|
|
165
165
|
readonly cardGap: "--garagem-listing-card-gap";
|
|
166
166
|
readonly priceSize: "--garagem-listing-price-size";
|
|
167
167
|
readonly mediaRatio: "--garagem-listing-media-ratio";
|
|
168
|
+
readonly controlHeight: "--garagem-search-control-height";
|
|
169
|
+
readonly iconSize: "--garagem-search-icon-size";
|
|
170
|
+
readonly skeleton: "--garagem-skeleton";
|
|
168
171
|
};
|
|
172
|
+
/** Paste into generated `globals.css` to override tokens. Layout lives in the chrome artifact. */
|
|
169
173
|
declare const SEARCH_CSS_RECIPE: string;
|
|
170
174
|
declare function formatListingPrice(amount: number | null | undefined, locale?: string, currency?: string): string;
|
|
171
175
|
/** Input mask: `499000` → `"499.000"` (no currency symbol). */
|
|
@@ -175,61 +179,6 @@ declare function parseGroupedInteger(value: unknown): number | undefined;
|
|
|
175
179
|
declare function formatAreaM2(area: number | null | undefined): string | null;
|
|
176
180
|
declare function listingBusinessLabel(businessType: string | undefined): string;
|
|
177
181
|
|
|
178
|
-
/** Query keys that must never encode filters (Editor/Studio path contract). */
|
|
179
|
-
declare const FORBIDDEN_SEARCH_QUERY_KEYS: readonly ["tipo", "quartos", "tipo-imovel", "banheiros", "vagas"];
|
|
180
|
-
/** Default option: omit `ordenar` (API has no relevance token). */
|
|
181
|
-
declare const SEARCH_SORT_RELEVANCE: {
|
|
182
|
-
readonly id: "";
|
|
183
|
-
readonly label: "Mais relevantes";
|
|
184
|
-
};
|
|
185
|
-
declare function searchSortOptions(sorts: Array<{
|
|
186
|
-
id: string;
|
|
187
|
-
label: string;
|
|
188
|
-
}> | undefined): Array<{
|
|
189
|
-
id: string;
|
|
190
|
-
label: string;
|
|
191
|
-
}>;
|
|
192
|
-
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
193
|
-
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
194
|
-
declare function isListingDetailPath(pathname: string): boolean;
|
|
195
|
-
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
196
|
-
pathFilters: SearchPathFilters;
|
|
197
|
-
applied: AppliedSearchQuery;
|
|
198
|
-
};
|
|
199
|
-
type LocationNameTables = {
|
|
200
|
-
states?: Record<string, string>;
|
|
201
|
-
cities?: Record<string, string>;
|
|
202
|
-
neighborhoods?: Record<string, string>;
|
|
203
|
-
streets?: Record<string, string>;
|
|
204
|
-
};
|
|
205
|
-
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
206
|
-
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
207
|
-
defaultLimit?: number;
|
|
208
|
-
} | null, locationValues?: LocationNameTables | null): QueryListingsParams;
|
|
209
|
-
declare function applyPathFilter(pathFilters: SearchPathFilters, filterId: string, value: unknown): SearchPathFilters;
|
|
210
|
-
declare function pathFilterValue(pathFilters: SearchPathFilters | undefined, filterId: string): string;
|
|
211
|
-
declare function pathFilterHasOption(pathFilters: SearchPathFilters | undefined, filterId: string, optionId: string): boolean;
|
|
212
|
-
declare function publicSearchHref(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, dictionary?: SearchUiDictionary, existingSearch?: string): string;
|
|
213
|
-
declare function hrefForPathFilters(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, nextPathFilters: SearchPathFilters): string;
|
|
214
|
-
declare function hrefForAppliedChange(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, change: AppliedSearchChange): string;
|
|
215
|
-
/** Canonical href if the current URL is out of generation order; otherwise null. */
|
|
216
|
-
declare function canonicalizeSearchHref(pathname: string, search: string, dictionary?: SearchUiDictionary): string | null;
|
|
217
|
-
declare function searchHrefUsesLegacyFilterQuery(href: string): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Drop staged filters. Location always stays until apply.
|
|
220
|
-
* `keepFilterIds` keeps toolbar-primary filters (price, bedrooms) so Limpar
|
|
221
|
-
* in the extra-filters dialog does not wipe values already on the toolbar.
|
|
222
|
-
*/
|
|
223
|
-
declare function clearStagedPathFilters(current: SearchPathFilters, keepFilterIds?: readonly string[]): SearchPathFilters;
|
|
224
|
-
declare function visibleSearchFilters(schema: SearchUi | null): SearchUiFilter[];
|
|
225
|
-
declare function toolbarFilterIds(schema: SearchUi | null): string[];
|
|
226
|
-
declare function countOptionLabel(option: Pick<SearchUiOption, "label">): string;
|
|
227
|
-
declare function countFacetChoices(options: SearchUiOption[] | undefined): Array<{
|
|
228
|
-
id: string;
|
|
229
|
-
label: string;
|
|
230
|
-
}>;
|
|
231
|
-
declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
|
|
232
|
-
|
|
233
182
|
declare function composeSearchPublicPath(filters: SearchPathFilters, dictionary?: SearchUiDictionary): string;
|
|
234
183
|
declare function parseSearchPublicPath(pathname: string, dictionary?: SearchUiDictionary): SearchPathFilters | null;
|
|
235
184
|
/**
|
|
@@ -283,6 +232,56 @@ declare function isStudioPreviewHost(host: string): boolean;
|
|
|
283
232
|
*/
|
|
284
233
|
declare function resolvePublicSiteId(options: ResolvePublicSiteIdOptions): Promise<string>;
|
|
285
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Studio ↔ npm contract. Prompt, completeness, and recipes must read this
|
|
237
|
+
* object — do not keep a second list of required `@garagem-ai/site-sdk/react`
|
|
238
|
+
* names in apps/site.
|
|
239
|
+
*
|
|
240
|
+
* `minNpmVersion` is the tarball v0 actually installs. Optional exports exist
|
|
241
|
+
* in git and may already be on npm, but Studio codegen must not name them
|
|
242
|
+
* while chromeStrategy is self-inject (v0 copies identifiers; a layout tag
|
|
243
|
+
* also breaks the pancake stack).
|
|
244
|
+
*/
|
|
245
|
+
declare const STUDIO_SDK_PACKAGE: "@garagem-ai/site-sdk";
|
|
246
|
+
declare const STUDIO_SDK_CONTRACT: {
|
|
247
|
+
readonly package: "@garagem-ai/site-sdk";
|
|
248
|
+
/**
|
|
249
|
+
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
250
|
+
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
251
|
+
* This PR’s changeset publishes that tarball as 0.4.2 — do not generate
|
|
252
|
+
* against this floor until Version Packages is on npm.
|
|
253
|
+
*/
|
|
254
|
+
readonly minNpmVersion: "0.4.2";
|
|
255
|
+
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
256
|
+
readonly selfInjectSince: "0.4.2";
|
|
257
|
+
readonly chromeStrategy: "self-inject";
|
|
258
|
+
readonly reactExports: readonly ["SearchPage", "ListingCard", "usePublicSearch", "ResultsSkeleton"];
|
|
259
|
+
/**
|
|
260
|
+
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
261
|
+
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
262
|
+
* `since`. Studio prompts must not mention these names at all (even as
|
|
263
|
+
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
264
|
+
* throws FatalRendererError.
|
|
265
|
+
*/
|
|
266
|
+
readonly optionalReactExports: {
|
|
267
|
+
readonly SearchPageFallback: "0.4.1";
|
|
268
|
+
readonly SearchChromeStyles: "0.4.1";
|
|
269
|
+
};
|
|
270
|
+
readonly forbiddenImports: readonly ["@garagem-ai/site-sdk/react/search.css"];
|
|
271
|
+
};
|
|
272
|
+
type StudioSdkContract = typeof STUDIO_SDK_CONTRACT;
|
|
273
|
+
declare function coerceNpmVersion(raw: unknown): string | null;
|
|
274
|
+
declare function compareSemver(a: string, b: string): number;
|
|
275
|
+
declare function parseReactSdkNamedImports(source: string): string[];
|
|
276
|
+
declare function unavailableReactImports(source: string, pin: string): string[];
|
|
277
|
+
declare function studioSdkPinInstruction(): string;
|
|
278
|
+
declare function studioChromeInstruction(): string;
|
|
279
|
+
/**
|
|
280
|
+
* Tokens that must not appear in Studio codegen (prompts, recipes, repair).
|
|
281
|
+
* v0 copies identifiers it sees, even inside “never import X”.
|
|
282
|
+
*/
|
|
283
|
+
declare function studioCodegenContractViolations(text: string): string[];
|
|
284
|
+
|
|
286
285
|
interface CreateGaragemClientOptions {
|
|
287
286
|
/** Garagem API base URL. Defaults to `https://app.garagem.ai`. */
|
|
288
287
|
baseUrl?: string;
|
|
@@ -378,4 +377,4 @@ interface GaragemClient {
|
|
|
378
377
|
*/
|
|
379
378
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
380
379
|
|
|
381
|
-
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions,
|
|
380
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, studioChromeInstruction, studioCodegenContractViolations, studioSdkPinInstruction, unavailableReactImports };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters, k as SearchUiDictionary, l as QueryListingsFilters, A as AppliedSearchQuery, m as AppliedSearchChange } from './search-engine-D4EZkNrQ.js';
|
|
2
|
+
export { n as CmsEntryStatus, o as CmsFieldDefinition, p as CmsFieldType, q as CmsSeoData, F as FORBIDDEN_SEARCH_QUERY_KEYS, r as Listing, s as ListingBusinessType, t as ListingCardModel, u as ListingLocation, v as ListingMedia, w as ListingPriceVisibility, x as ListingPropertySummary, y as LocationNameTables, z as QueryListingsLocation, B as SEARCH_SORT_RELEVANCE, D as SearchPathLocation, E as SearchUiFilter, G as SearchUiOption, T as TOOLBAR_PRIMARY_FILTER_IDS, H as applyPathFilter, I as buildQueryListingsParams, J as canonicalizeSearchHref, K as clearStagedPathFilters, M as countFacetChoices, N as countOptionLabel, O as displayPathLocation, P as hrefForAppliedChange, U as hrefForPathFilters, V as hrefWithExplicitPage, W as isListingDetailPath, X as listingLocationLabel, Y as paginationPages, Z as pathFilterHasOption, _ as pathFilterValue, $ as publicSearchHref, a0 as readPublicSearch, a1 as searchHrefUsesLegacyFilterQuery, a2 as searchResultsHeading, a3 as searchSortOptions, a4 as toListingCardModel, a5 as toolbarFilterIds, a6 as visibleSearchFilters } from './search-engine-D4EZkNrQ.js';
|
|
3
3
|
|
|
4
4
|
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
5
5
|
type FetchLike = typeof fetch;
|
|
@@ -165,7 +165,11 @@ declare const SEARCH_CSS_VARS: {
|
|
|
165
165
|
readonly cardGap: "--garagem-listing-card-gap";
|
|
166
166
|
readonly priceSize: "--garagem-listing-price-size";
|
|
167
167
|
readonly mediaRatio: "--garagem-listing-media-ratio";
|
|
168
|
+
readonly controlHeight: "--garagem-search-control-height";
|
|
169
|
+
readonly iconSize: "--garagem-search-icon-size";
|
|
170
|
+
readonly skeleton: "--garagem-skeleton";
|
|
168
171
|
};
|
|
172
|
+
/** Paste into generated `globals.css` to override tokens. Layout lives in the chrome artifact. */
|
|
169
173
|
declare const SEARCH_CSS_RECIPE: string;
|
|
170
174
|
declare function formatListingPrice(amount: number | null | undefined, locale?: string, currency?: string): string;
|
|
171
175
|
/** Input mask: `499000` → `"499.000"` (no currency symbol). */
|
|
@@ -175,61 +179,6 @@ declare function parseGroupedInteger(value: unknown): number | undefined;
|
|
|
175
179
|
declare function formatAreaM2(area: number | null | undefined): string | null;
|
|
176
180
|
declare function listingBusinessLabel(businessType: string | undefined): string;
|
|
177
181
|
|
|
178
|
-
/** Query keys that must never encode filters (Editor/Studio path contract). */
|
|
179
|
-
declare const FORBIDDEN_SEARCH_QUERY_KEYS: readonly ["tipo", "quartos", "tipo-imovel", "banheiros", "vagas"];
|
|
180
|
-
/** Default option: omit `ordenar` (API has no relevance token). */
|
|
181
|
-
declare const SEARCH_SORT_RELEVANCE: {
|
|
182
|
-
readonly id: "";
|
|
183
|
-
readonly label: "Mais relevantes";
|
|
184
|
-
};
|
|
185
|
-
declare function searchSortOptions(sorts: Array<{
|
|
186
|
-
id: string;
|
|
187
|
-
label: string;
|
|
188
|
-
}> | undefined): Array<{
|
|
189
|
-
id: string;
|
|
190
|
-
label: string;
|
|
191
|
-
}>;
|
|
192
|
-
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
193
|
-
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
194
|
-
declare function isListingDetailPath(pathname: string): boolean;
|
|
195
|
-
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
196
|
-
pathFilters: SearchPathFilters;
|
|
197
|
-
applied: AppliedSearchQuery;
|
|
198
|
-
};
|
|
199
|
-
type LocationNameTables = {
|
|
200
|
-
states?: Record<string, string>;
|
|
201
|
-
cities?: Record<string, string>;
|
|
202
|
-
neighborhoods?: Record<string, string>;
|
|
203
|
-
streets?: Record<string, string>;
|
|
204
|
-
};
|
|
205
|
-
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
206
|
-
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
207
|
-
defaultLimit?: number;
|
|
208
|
-
} | null, locationValues?: LocationNameTables | null): QueryListingsParams;
|
|
209
|
-
declare function applyPathFilter(pathFilters: SearchPathFilters, filterId: string, value: unknown): SearchPathFilters;
|
|
210
|
-
declare function pathFilterValue(pathFilters: SearchPathFilters | undefined, filterId: string): string;
|
|
211
|
-
declare function pathFilterHasOption(pathFilters: SearchPathFilters | undefined, filterId: string, optionId: string): boolean;
|
|
212
|
-
declare function publicSearchHref(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, dictionary?: SearchUiDictionary, existingSearch?: string): string;
|
|
213
|
-
declare function hrefForPathFilters(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, nextPathFilters: SearchPathFilters): string;
|
|
214
|
-
declare function hrefForAppliedChange(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, change: AppliedSearchChange): string;
|
|
215
|
-
/** Canonical href if the current URL is out of generation order; otherwise null. */
|
|
216
|
-
declare function canonicalizeSearchHref(pathname: string, search: string, dictionary?: SearchUiDictionary): string | null;
|
|
217
|
-
declare function searchHrefUsesLegacyFilterQuery(href: string): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Drop staged filters. Location always stays until apply.
|
|
220
|
-
* `keepFilterIds` keeps toolbar-primary filters (price, bedrooms) so Limpar
|
|
221
|
-
* in the extra-filters dialog does not wipe values already on the toolbar.
|
|
222
|
-
*/
|
|
223
|
-
declare function clearStagedPathFilters(current: SearchPathFilters, keepFilterIds?: readonly string[]): SearchPathFilters;
|
|
224
|
-
declare function visibleSearchFilters(schema: SearchUi | null): SearchUiFilter[];
|
|
225
|
-
declare function toolbarFilterIds(schema: SearchUi | null): string[];
|
|
226
|
-
declare function countOptionLabel(option: Pick<SearchUiOption, "label">): string;
|
|
227
|
-
declare function countFacetChoices(options: SearchUiOption[] | undefined): Array<{
|
|
228
|
-
id: string;
|
|
229
|
-
label: string;
|
|
230
|
-
}>;
|
|
231
|
-
declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
|
|
232
|
-
|
|
233
182
|
declare function composeSearchPublicPath(filters: SearchPathFilters, dictionary?: SearchUiDictionary): string;
|
|
234
183
|
declare function parseSearchPublicPath(pathname: string, dictionary?: SearchUiDictionary): SearchPathFilters | null;
|
|
235
184
|
/**
|
|
@@ -283,6 +232,56 @@ declare function isStudioPreviewHost(host: string): boolean;
|
|
|
283
232
|
*/
|
|
284
233
|
declare function resolvePublicSiteId(options: ResolvePublicSiteIdOptions): Promise<string>;
|
|
285
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Studio ↔ npm contract. Prompt, completeness, and recipes must read this
|
|
237
|
+
* object — do not keep a second list of required `@garagem-ai/site-sdk/react`
|
|
238
|
+
* names in apps/site.
|
|
239
|
+
*
|
|
240
|
+
* `minNpmVersion` is the tarball v0 actually installs. Optional exports exist
|
|
241
|
+
* in git and may already be on npm, but Studio codegen must not name them
|
|
242
|
+
* while chromeStrategy is self-inject (v0 copies identifiers; a layout tag
|
|
243
|
+
* also breaks the pancake stack).
|
|
244
|
+
*/
|
|
245
|
+
declare const STUDIO_SDK_PACKAGE: "@garagem-ai/site-sdk";
|
|
246
|
+
declare const STUDIO_SDK_CONTRACT: {
|
|
247
|
+
readonly package: "@garagem-ai/site-sdk";
|
|
248
|
+
/**
|
|
249
|
+
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
250
|
+
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
251
|
+
* This PR’s changeset publishes that tarball as 0.4.2 — do not generate
|
|
252
|
+
* against this floor until Version Packages is on npm.
|
|
253
|
+
*/
|
|
254
|
+
readonly minNpmVersion: "0.4.2";
|
|
255
|
+
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
256
|
+
readonly selfInjectSince: "0.4.2";
|
|
257
|
+
readonly chromeStrategy: "self-inject";
|
|
258
|
+
readonly reactExports: readonly ["SearchPage", "ListingCard", "usePublicSearch", "ResultsSkeleton"];
|
|
259
|
+
/**
|
|
260
|
+
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
261
|
+
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
262
|
+
* `since`. Studio prompts must not mention these names at all (even as
|
|
263
|
+
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
264
|
+
* throws FatalRendererError.
|
|
265
|
+
*/
|
|
266
|
+
readonly optionalReactExports: {
|
|
267
|
+
readonly SearchPageFallback: "0.4.1";
|
|
268
|
+
readonly SearchChromeStyles: "0.4.1";
|
|
269
|
+
};
|
|
270
|
+
readonly forbiddenImports: readonly ["@garagem-ai/site-sdk/react/search.css"];
|
|
271
|
+
};
|
|
272
|
+
type StudioSdkContract = typeof STUDIO_SDK_CONTRACT;
|
|
273
|
+
declare function coerceNpmVersion(raw: unknown): string | null;
|
|
274
|
+
declare function compareSemver(a: string, b: string): number;
|
|
275
|
+
declare function parseReactSdkNamedImports(source: string): string[];
|
|
276
|
+
declare function unavailableReactImports(source: string, pin: string): string[];
|
|
277
|
+
declare function studioSdkPinInstruction(): string;
|
|
278
|
+
declare function studioChromeInstruction(): string;
|
|
279
|
+
/**
|
|
280
|
+
* Tokens that must not appear in Studio codegen (prompts, recipes, repair).
|
|
281
|
+
* v0 copies identifiers it sees, even inside “never import X”.
|
|
282
|
+
*/
|
|
283
|
+
declare function studioCodegenContractViolations(text: string): string[];
|
|
284
|
+
|
|
286
285
|
interface CreateGaragemClientOptions {
|
|
287
286
|
/** Garagem API base URL. Defaults to `https://app.garagem.ai`. */
|
|
288
287
|
baseUrl?: string;
|
|
@@ -378,4 +377,4 @@ interface GaragemClient {
|
|
|
378
377
|
*/
|
|
379
378
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
380
379
|
|
|
381
|
-
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions,
|
|
380
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, studioChromeInstruction, studioCodegenContractViolations, studioSdkPinInstruction, unavailableReactImports };
|
package/dist/index.js
CHANGED
|
@@ -25,11 +25,15 @@ __export(src_exports, {
|
|
|
25
25
|
SEARCH_CSS_RECIPE: () => SEARCH_CSS_RECIPE,
|
|
26
26
|
SEARCH_CSS_VARS: () => SEARCH_CSS_VARS,
|
|
27
27
|
SEARCH_SORT_RELEVANCE: () => SEARCH_SORT_RELEVANCE,
|
|
28
|
+
STUDIO_SDK_CONTRACT: () => STUDIO_SDK_CONTRACT,
|
|
29
|
+
STUDIO_SDK_PACKAGE: () => STUDIO_SDK_PACKAGE,
|
|
28
30
|
TOOLBAR_PRIMARY_FILTER_IDS: () => TOOLBAR_PRIMARY_FILTER_IDS,
|
|
29
31
|
applyPathFilter: () => applyPathFilter,
|
|
30
32
|
buildQueryListingsParams: () => buildQueryListingsParams,
|
|
31
33
|
canonicalizeSearchHref: () => canonicalizeSearchHref,
|
|
32
34
|
clearStagedPathFilters: () => clearStagedPathFilters,
|
|
35
|
+
coerceNpmVersion: () => coerceNpmVersion,
|
|
36
|
+
compareSemver: () => compareSemver,
|
|
33
37
|
composeSearchPublicHref: () => composeSearchPublicHref2,
|
|
34
38
|
composeSearchPublicPath: () => composeSearchPublicPath2,
|
|
35
39
|
countFacetChoices: () => countFacetChoices,
|
|
@@ -50,6 +54,7 @@ __export(src_exports, {
|
|
|
50
54
|
getSite: () => getSite,
|
|
51
55
|
hrefForAppliedChange: () => hrefForAppliedChange,
|
|
52
56
|
hrefForPathFilters: () => hrefForPathFilters,
|
|
57
|
+
hrefWithExplicitPage: () => hrefWithExplicitPage,
|
|
53
58
|
isListingDetailPath: () => isListingDetailPath,
|
|
54
59
|
isStudioPreviewHost: () => isStudioPreviewHost,
|
|
55
60
|
listingBusinessLabel: () => listingBusinessLabel,
|
|
@@ -60,6 +65,7 @@ __export(src_exports, {
|
|
|
60
65
|
paginationPages: () => paginationPages,
|
|
61
66
|
parseAppliedSearchQuery: () => parseAppliedSearchQuery2,
|
|
62
67
|
parseGroupedInteger: () => parseGroupedInteger,
|
|
68
|
+
parseReactSdkNamedImports: () => parseReactSdkNamedImports,
|
|
63
69
|
parseSearchPublicPath: () => parseSearchPublicPath2,
|
|
64
70
|
pathFilterHasOption: () => pathFilterHasOption,
|
|
65
71
|
pathFilterValue: () => pathFilterValue,
|
|
@@ -72,10 +78,15 @@ __export(src_exports, {
|
|
|
72
78
|
resolvePublicSiteId: () => resolvePublicSiteId,
|
|
73
79
|
searchHrefUsesLegacyFilterQuery: () => searchHrefUsesLegacyFilterQuery,
|
|
74
80
|
searchListings: () => searchListings,
|
|
81
|
+
searchResultsHeading: () => searchResultsHeading,
|
|
75
82
|
searchSortOptions: () => searchSortOptions,
|
|
76
83
|
serializeAppliedSearchQuery: () => serializeAppliedSearchQuery2,
|
|
84
|
+
studioChromeInstruction: () => studioChromeInstruction,
|
|
85
|
+
studioCodegenContractViolations: () => studioCodegenContractViolations,
|
|
86
|
+
studioSdkPinInstruction: () => studioSdkPinInstruction,
|
|
77
87
|
toListingCardModel: () => toListingCardModel,
|
|
78
88
|
toolbarFilterIds: () => toolbarFilterIds,
|
|
89
|
+
unavailableReactImports: () => unavailableReactImports,
|
|
79
90
|
visibleSearchFilters: () => visibleSearchFilters
|
|
80
91
|
});
|
|
81
92
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -401,13 +412,19 @@ var SEARCH_CSS_VARS = {
|
|
|
401
412
|
cardRadius: "--garagem-listing-card-radius",
|
|
402
413
|
cardGap: "--garagem-listing-card-gap",
|
|
403
414
|
priceSize: "--garagem-listing-price-size",
|
|
404
|
-
mediaRatio: "--garagem-listing-media-ratio"
|
|
415
|
+
mediaRatio: "--garagem-listing-media-ratio",
|
|
416
|
+
controlHeight: "--garagem-search-control-height",
|
|
417
|
+
iconSize: "--garagem-search-icon-size",
|
|
418
|
+
skeleton: "--garagem-skeleton"
|
|
405
419
|
};
|
|
406
420
|
var SEARCH_CSS_RECIPE = `:root {
|
|
407
421
|
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
408
422
|
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
409
423
|
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
410
424
|
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
425
|
+
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
426
|
+
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
427
|
+
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
411
428
|
}
|
|
412
429
|
`;
|
|
413
430
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
@@ -1185,6 +1202,54 @@ function countFacetChoices(options) {
|
|
|
1185
1202
|
}
|
|
1186
1203
|
return out;
|
|
1187
1204
|
}
|
|
1205
|
+
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
1206
|
+
function pluralizePt(label) {
|
|
1207
|
+
const text = label.trim();
|
|
1208
|
+
if (!text || /s$/i.test(text)) return text;
|
|
1209
|
+
if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
|
|
1210
|
+
if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
|
|
1211
|
+
return `${text}s`;
|
|
1212
|
+
}
|
|
1213
|
+
function headingLocationSuffix(location) {
|
|
1214
|
+
if (!location) return "";
|
|
1215
|
+
if (location.street && location.neighborhood) {
|
|
1216
|
+
return `${location.street}, ${location.neighborhood}`;
|
|
1217
|
+
}
|
|
1218
|
+
if (location.neighborhood && location.city) {
|
|
1219
|
+
return `${location.neighborhood}, ${location.city}`;
|
|
1220
|
+
}
|
|
1221
|
+
if (location.city && location.state) {
|
|
1222
|
+
return `${location.city} - ${location.state}`;
|
|
1223
|
+
}
|
|
1224
|
+
return location.city || location.neighborhood || location.street || location.state || "";
|
|
1225
|
+
}
|
|
1226
|
+
function searchResultsHeading(pathFilters, dictionary, locationNames) {
|
|
1227
|
+
const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
|
|
1228
|
+
let noun = "Im\xF3veis";
|
|
1229
|
+
let found = "encontrados";
|
|
1230
|
+
if (types.length === 1) {
|
|
1231
|
+
const id = String(types[0]);
|
|
1232
|
+
const option = dictionary?.propertyTypes?.find(
|
|
1233
|
+
(entry) => entry.id === id || entry.slug === id
|
|
1234
|
+
);
|
|
1235
|
+
const label = option?.label;
|
|
1236
|
+
if (label) {
|
|
1237
|
+
noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
|
|
1238
|
+
if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
|
|
1239
|
+
found = "encontradas";
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const place = locationNames ? headingLocationSuffix(
|
|
1244
|
+
displayPathLocation(pathFilters.location, locationNames)
|
|
1245
|
+
) : "";
|
|
1246
|
+
if (place) return `${noun} ${found} em ${place}`;
|
|
1247
|
+
return `${noun} ${found}`;
|
|
1248
|
+
}
|
|
1249
|
+
function hrefWithExplicitPage(href, page) {
|
|
1250
|
+
if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
|
|
1251
|
+
return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
|
|
1252
|
+
}
|
|
1188
1253
|
function paginationPages(currentPage, totalPages, padding) {
|
|
1189
1254
|
if (totalPages < 1) return [];
|
|
1190
1255
|
const current = Math.min(Math.max(1, currentPage), totalPages);
|
|
@@ -1227,6 +1292,116 @@ async function resolvePublicSiteId(options) {
|
|
|
1227
1292
|
);
|
|
1228
1293
|
}
|
|
1229
1294
|
|
|
1295
|
+
// src/studio-contract.ts
|
|
1296
|
+
var STUDIO_SDK_PACKAGE = "@garagem-ai/site-sdk";
|
|
1297
|
+
var STUDIO_SDK_CONTRACT = {
|
|
1298
|
+
package: STUDIO_SDK_PACKAGE,
|
|
1299
|
+
/**
|
|
1300
|
+
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
1301
|
+
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
1302
|
+
* This PR’s changeset publishes that tarball as 0.4.2 — do not generate
|
|
1303
|
+
* against this floor until Version Packages is on npm.
|
|
1304
|
+
*/
|
|
1305
|
+
minNpmVersion: "0.4.2",
|
|
1306
|
+
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
1307
|
+
selfInjectSince: "0.4.2",
|
|
1308
|
+
chromeStrategy: "self-inject",
|
|
1309
|
+
reactExports: [
|
|
1310
|
+
"SearchPage",
|
|
1311
|
+
"ListingCard",
|
|
1312
|
+
"usePublicSearch",
|
|
1313
|
+
"ResultsSkeleton"
|
|
1314
|
+
],
|
|
1315
|
+
/**
|
|
1316
|
+
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
1317
|
+
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
1318
|
+
* `since`. Studio prompts must not mention these names at all (even as
|
|
1319
|
+
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
1320
|
+
* throws FatalRendererError.
|
|
1321
|
+
*/
|
|
1322
|
+
optionalReactExports: {
|
|
1323
|
+
SearchPageFallback: "0.4.1",
|
|
1324
|
+
SearchChromeStyles: "0.4.1"
|
|
1325
|
+
},
|
|
1326
|
+
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"]
|
|
1327
|
+
};
|
|
1328
|
+
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
1329
|
+
function coerceNpmVersion(raw) {
|
|
1330
|
+
if (typeof raw !== "string") return null;
|
|
1331
|
+
const match = raw.trim().match(/(\d+)\.(\d+)\.(\d+)/);
|
|
1332
|
+
return match ? `${match[1]}.${match[2]}.${match[3]}` : null;
|
|
1333
|
+
}
|
|
1334
|
+
function compareSemver(a, b) {
|
|
1335
|
+
const left = a.split(".").map((part) => Number(part));
|
|
1336
|
+
const right = b.split(".").map((part) => Number(part));
|
|
1337
|
+
for (let i = 0; i < 3; i += 1) {
|
|
1338
|
+
const delta = (left[i] ?? 0) - (right[i] ?? 0);
|
|
1339
|
+
if (delta !== 0) return delta;
|
|
1340
|
+
}
|
|
1341
|
+
return 0;
|
|
1342
|
+
}
|
|
1343
|
+
function parseReactSdkNamedImports(source) {
|
|
1344
|
+
const names = [];
|
|
1345
|
+
REACT_SDK_NAMED_IMPORT_RE.lastIndex = 0;
|
|
1346
|
+
let match;
|
|
1347
|
+
while ((match = REACT_SDK_NAMED_IMPORT_RE.exec(source)) !== null) {
|
|
1348
|
+
const body = match[1];
|
|
1349
|
+
if (!body) continue;
|
|
1350
|
+
for (const raw of body.split(",")) {
|
|
1351
|
+
const token = raw.trim();
|
|
1352
|
+
if (!token || token.startsWith("type ")) continue;
|
|
1353
|
+
const name = token.split(/\s+as\s+/)[0]?.trim();
|
|
1354
|
+
if (name) names.push(name);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return names;
|
|
1358
|
+
}
|
|
1359
|
+
function reactExportsAvailableAt(pin) {
|
|
1360
|
+
const available = new Set(STUDIO_SDK_CONTRACT.reactExports);
|
|
1361
|
+
for (const [name, since] of Object.entries(
|
|
1362
|
+
STUDIO_SDK_CONTRACT.optionalReactExports
|
|
1363
|
+
)) {
|
|
1364
|
+
if (compareSemver(pin, since) >= 0) available.add(name);
|
|
1365
|
+
}
|
|
1366
|
+
return available;
|
|
1367
|
+
}
|
|
1368
|
+
function unavailableReactImports(source, pin) {
|
|
1369
|
+
const available = reactExportsAvailableAt(pin);
|
|
1370
|
+
const missing = [];
|
|
1371
|
+
for (const name of parseReactSdkNamedImports(source)) {
|
|
1372
|
+
if (!available.has(name) && !missing.includes(name)) {
|
|
1373
|
+
missing.push(name);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return missing;
|
|
1377
|
+
}
|
|
1378
|
+
function studioSdkPinInstruction() {
|
|
1379
|
+
const version = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
1380
|
+
const names = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
1381
|
+
return `In \`package.json\` set \`"@garagem-ai/site-sdk": "${version}"\` (exact). Import only these \`${STUDIO_SDK_PACKAGE}/react\` names: ${names}.`;
|
|
1382
|
+
}
|
|
1383
|
+
function studioChromeInstruction() {
|
|
1384
|
+
const injectors = compareSemver(
|
|
1385
|
+
STUDIO_SDK_CONTRACT.minNpmVersion,
|
|
1386
|
+
STUDIO_SDK_CONTRACT.selfInjectSince
|
|
1387
|
+
) >= 0 ? "`SearchPage`, `ListingCard`, and `ResultsSkeleton`" : "`SearchPage`";
|
|
1388
|
+
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 layout into the app. Theme via CSS variables in \`app/globals.css\` (\`SEARCH_CSS_RECIPE\` / \`--garagem-*\`), \`classNames\`, and \`data-slot\`.`;
|
|
1389
|
+
}
|
|
1390
|
+
function studioCodegenContractViolations(text) {
|
|
1391
|
+
const violations = [];
|
|
1392
|
+
for (const name of Object.keys(STUDIO_SDK_CONTRACT.optionalReactExports)) {
|
|
1393
|
+
if (text.includes(name)) violations.push(name);
|
|
1394
|
+
}
|
|
1395
|
+
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
1396
|
+
const available = reactExportsAvailableAt(pin);
|
|
1397
|
+
for (const name of parseReactSdkNamedImports(text)) {
|
|
1398
|
+
if (!available.has(name) && !violations.includes(name)) {
|
|
1399
|
+
violations.push(name);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
return violations;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1230
1405
|
// src/client.ts
|
|
1231
1406
|
function createGaragemClient(options = {}) {
|
|
1232
1407
|
const resolveSiteId = (override) => {
|
|
@@ -1365,11 +1540,15 @@ function createGaragemClient(options = {}) {
|
|
|
1365
1540
|
SEARCH_CSS_RECIPE,
|
|
1366
1541
|
SEARCH_CSS_VARS,
|
|
1367
1542
|
SEARCH_SORT_RELEVANCE,
|
|
1543
|
+
STUDIO_SDK_CONTRACT,
|
|
1544
|
+
STUDIO_SDK_PACKAGE,
|
|
1368
1545
|
TOOLBAR_PRIMARY_FILTER_IDS,
|
|
1369
1546
|
applyPathFilter,
|
|
1370
1547
|
buildQueryListingsParams,
|
|
1371
1548
|
canonicalizeSearchHref,
|
|
1372
1549
|
clearStagedPathFilters,
|
|
1550
|
+
coerceNpmVersion,
|
|
1551
|
+
compareSemver,
|
|
1373
1552
|
composeSearchPublicHref,
|
|
1374
1553
|
composeSearchPublicPath,
|
|
1375
1554
|
countFacetChoices,
|
|
@@ -1390,6 +1569,7 @@ function createGaragemClient(options = {}) {
|
|
|
1390
1569
|
getSite,
|
|
1391
1570
|
hrefForAppliedChange,
|
|
1392
1571
|
hrefForPathFilters,
|
|
1572
|
+
hrefWithExplicitPage,
|
|
1393
1573
|
isListingDetailPath,
|
|
1394
1574
|
isStudioPreviewHost,
|
|
1395
1575
|
listingBusinessLabel,
|
|
@@ -1400,6 +1580,7 @@ function createGaragemClient(options = {}) {
|
|
|
1400
1580
|
paginationPages,
|
|
1401
1581
|
parseAppliedSearchQuery,
|
|
1402
1582
|
parseGroupedInteger,
|
|
1583
|
+
parseReactSdkNamedImports,
|
|
1403
1584
|
parseSearchPublicPath,
|
|
1404
1585
|
pathFilterHasOption,
|
|
1405
1586
|
pathFilterValue,
|
|
@@ -1412,10 +1593,15 @@ function createGaragemClient(options = {}) {
|
|
|
1412
1593
|
resolvePublicSiteId,
|
|
1413
1594
|
searchHrefUsesLegacyFilterQuery,
|
|
1414
1595
|
searchListings,
|
|
1596
|
+
searchResultsHeading,
|
|
1415
1597
|
searchSortOptions,
|
|
1416
1598
|
serializeAppliedSearchQuery,
|
|
1599
|
+
studioChromeInstruction,
|
|
1600
|
+
studioCodegenContractViolations,
|
|
1601
|
+
studioSdkPinInstruction,
|
|
1417
1602
|
toListingCardModel,
|
|
1418
1603
|
toolbarFilterIds,
|
|
1604
|
+
unavailableReactImports,
|
|
1419
1605
|
visibleSearchFilters
|
|
1420
1606
|
});
|
|
1421
1607
|
//# sourceMappingURL=index.js.map
|