@garagem-ai/site-sdk 0.4.4 → 0.4.6

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 CHANGED
@@ -172,6 +172,7 @@ type VisitSchedule = VisitScheduleConfig & {
172
172
  weekendTimeSlots: HHmm[];
173
173
  timeSlots: HHmm[];
174
174
  };
175
+ declare function normalizeVisitTime(value: string): HHmm | null;
175
176
  declare function expandVisitTimeSlots(hours: VisitHours): HHmm[];
176
177
  declare function expandVisitSchedule(config: VisitScheduleConfig): VisitSchedule;
177
178
  declare const STUDIO_DEFAULT_VISIT_SCHEDULE: VisitSchedule;
@@ -209,7 +210,7 @@ type LeadUi = {
209
210
  };
210
211
  };
211
212
  type GetLeadUiOptions = {
212
- siteId: string;
213
+ siteId?: string | Promise<string>;
213
214
  baseUrl?: string;
214
215
  fetch?: FetchLike;
215
216
  next?: RequestNextOptions;
@@ -221,7 +222,7 @@ type LeadContact = {
221
222
  message?: string;
222
223
  };
223
224
  type LeadSubmitBase = LeadContact & {
224
- siteId: string;
225
+ siteId?: string | Promise<string>;
225
226
  baseUrl?: string;
226
227
  fetch?: FetchLike;
227
228
  listingId: string;
@@ -358,10 +359,9 @@ declare const STUDIO_SDK_CONTRACT: {
358
359
  /**
359
360
  * Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
360
361
  * prompts that skip the layout chrome tag match the tarball v0 installs.
361
- * This PR’s changeset publishes that tarball as 0.4.3 — do not generate
362
- * against this floor until Version Packages is on npm.
362
+ * 0.4.5 normalizes visit dates and recovers a missing browser siteId.
363
363
  */
364
- readonly minNpmVersion: "0.4.3";
364
+ readonly minNpmVersion: "0.4.5";
365
365
  /** First release where ListingCard and ResultsSkeleton inject the sheet. */
366
366
  readonly selfInjectSince: "0.4.2";
367
367
  readonly chromeStrategy: "self-inject";
@@ -504,4 +504,4 @@ interface GaragemClient {
504
504
  */
505
505
  declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
506
506
 
507
- export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type ContactLeadInput, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetLeadUiOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, type HHmm, type LeadContact, type LeadField, type LeadFieldId, LeadSubmitError, type LeadSubmitErrorCode, type LeadSubmitResult, type LeadUi, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_DEFAULT_VISIT_SCHEDULE, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, VISIT_TIME_ZONE, type VisitHours, type VisitLeadInput, type VisitSchedule, type VisitScheduleConfig, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, expandVisitSchedule, expandVisitTimeSlots, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getLeadUi, getListing, getListings, getSearchUi, getSimilarListings, getSite, hasShowcaseLeadsPostUrl, isStudioPreviewHost, isVisitSlotAllowed, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, normalizeVisitDate, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, slotsForDate, studioChromeInstruction, studioCodegenContractViolations, studioDefaultLeadUi, studioLeadInstruction, studioSdkPinInstruction, submitContactLead, submitVisitLead, unavailableReactImports };
507
+ export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type ContactLeadInput, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetLeadUiOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, type HHmm, type LeadContact, type LeadField, type LeadFieldId, LeadSubmitError, type LeadSubmitErrorCode, type LeadSubmitResult, type LeadUi, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_DEFAULT_VISIT_SCHEDULE, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, VISIT_TIME_ZONE, type VisitHours, type VisitLeadInput, type VisitSchedule, type VisitScheduleConfig, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, expandVisitSchedule, expandVisitTimeSlots, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getLeadUi, getListing, getListings, getSearchUi, getSimilarListings, getSite, hasShowcaseLeadsPostUrl, isStudioPreviewHost, isVisitSlotAllowed, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, normalizeVisitDate, normalizeVisitTime, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, slotsForDate, studioChromeInstruction, studioCodegenContractViolations, studioDefaultLeadUi, studioLeadInstruction, studioSdkPinInstruction, submitContactLead, submitVisitLead, unavailableReactImports };
package/dist/index.d.ts CHANGED
@@ -172,6 +172,7 @@ type VisitSchedule = VisitScheduleConfig & {
172
172
  weekendTimeSlots: HHmm[];
173
173
  timeSlots: HHmm[];
174
174
  };
175
+ declare function normalizeVisitTime(value: string): HHmm | null;
175
176
  declare function expandVisitTimeSlots(hours: VisitHours): HHmm[];
176
177
  declare function expandVisitSchedule(config: VisitScheduleConfig): VisitSchedule;
177
178
  declare const STUDIO_DEFAULT_VISIT_SCHEDULE: VisitSchedule;
@@ -209,7 +210,7 @@ type LeadUi = {
209
210
  };
210
211
  };
211
212
  type GetLeadUiOptions = {
212
- siteId: string;
213
+ siteId?: string | Promise<string>;
213
214
  baseUrl?: string;
214
215
  fetch?: FetchLike;
215
216
  next?: RequestNextOptions;
@@ -221,7 +222,7 @@ type LeadContact = {
221
222
  message?: string;
222
223
  };
223
224
  type LeadSubmitBase = LeadContact & {
224
- siteId: string;
225
+ siteId?: string | Promise<string>;
225
226
  baseUrl?: string;
226
227
  fetch?: FetchLike;
227
228
  listingId: string;
@@ -358,10 +359,9 @@ declare const STUDIO_SDK_CONTRACT: {
358
359
  /**
359
360
  * Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
360
361
  * prompts that skip the layout chrome tag match the tarball v0 installs.
361
- * This PR’s changeset publishes that tarball as 0.4.3 — do not generate
362
- * against this floor until Version Packages is on npm.
362
+ * 0.4.5 normalizes visit dates and recovers a missing browser siteId.
363
363
  */
364
- readonly minNpmVersion: "0.4.3";
364
+ readonly minNpmVersion: "0.4.5";
365
365
  /** First release where ListingCard and ResultsSkeleton inject the sheet. */
366
366
  readonly selfInjectSince: "0.4.2";
367
367
  readonly chromeStrategy: "self-inject";
@@ -504,4 +504,4 @@ interface GaragemClient {
504
504
  */
505
505
  declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
506
506
 
507
- export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type ContactLeadInput, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetLeadUiOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, type HHmm, type LeadContact, type LeadField, type LeadFieldId, LeadSubmitError, type LeadSubmitErrorCode, type LeadSubmitResult, type LeadUi, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_DEFAULT_VISIT_SCHEDULE, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, VISIT_TIME_ZONE, type VisitHours, type VisitLeadInput, type VisitSchedule, type VisitScheduleConfig, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, expandVisitSchedule, expandVisitTimeSlots, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getLeadUi, getListing, getListings, getSearchUi, getSimilarListings, getSite, hasShowcaseLeadsPostUrl, isStudioPreviewHost, isVisitSlotAllowed, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, normalizeVisitDate, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, slotsForDate, studioChromeInstruction, studioCodegenContractViolations, studioDefaultLeadUi, studioLeadInstruction, studioSdkPinInstruction, submitContactLead, submitVisitLead, unavailableReactImports };
507
+ export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type ContactLeadInput, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetLeadUiOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, type HHmm, type LeadContact, type LeadField, type LeadFieldId, LeadSubmitError, type LeadSubmitErrorCode, type LeadSubmitResult, type LeadUi, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, STUDIO_DEFAULT_VISIT_SCHEDULE, STUDIO_SDK_CONTRACT, STUDIO_SDK_PACKAGE, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, type StudioSdkContract, VISIT_TIME_ZONE, type VisitHours, type VisitLeadInput, type VisitSchedule, type VisitScheduleConfig, coerceNpmVersion, compareSemver, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, expandVisitSchedule, expandVisitTimeSlots, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getLeadUi, getListing, getListings, getSearchUi, getSimilarListings, getSite, hasShowcaseLeadsPostUrl, isStudioPreviewHost, isVisitSlotAllowed, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, normalizeVisitDate, normalizeVisitTime, parseAppliedSearchQuery, parseGroupedInteger, parseReactSdkNamedImports, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery, slotsForDate, studioChromeInstruction, studioCodegenContractViolations, studioDefaultLeadUi, studioLeadInstruction, studioSdkPinInstruction, submitContactLead, submitVisitLead, unavailableReactImports };
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ __export(src_exports, {
71
71
  listingPublicPath: () => listingPublicPath,
72
72
  mergeAppliedSearchQueryIntoSearch: () => mergeAppliedSearchQueryIntoSearch2,
73
73
  normalizeVisitDate: () => normalizeVisitDate,
74
+ normalizeVisitTime: () => normalizeVisitTime,
74
75
  paginationPages: () => paginationPages,
75
76
  parseAppliedSearchQuery: () => parseAppliedSearchQuery2,
76
77
  parseGroupedInteger: () => parseGroupedInteger,
@@ -126,7 +127,8 @@ function normalizeBaseUrl(baseUrl) {
126
127
  return url.endsWith("/") ? url.slice(0, -1) : url;
127
128
  }
128
129
  async function coerceSiteId(siteId) {
129
- const value = await Promise.resolve(siteId);
130
+ const raw = typeof siteId === "function" ? siteId() : siteId;
131
+ const value = await Promise.resolve(raw);
130
132
  if (typeof value !== "string" || !value.trim()) {
131
133
  throw new TypeError(
132
134
  "Garagem SDK: siteId must be a string. Await resolveSiteId(...) before getListings / getSearchUi / queryListings."
@@ -424,8 +426,10 @@ async function getCmsEntry(options) {
424
426
  // src/schedule.ts
425
427
  var VISIT_TIME_ZONE = "America/Sao_Paulo";
426
428
  var HHMM_RE = /^([01]\d|2[0-3]):([0-5]\d)$/;
429
+ var VISIT_TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)(?::[0-5]\d(?:\.\d+)?)?$/;
427
430
  var YMD_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
428
431
  var ISO_INSTANT_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
432
+ var DATETIME_LOCAL_RE = /^(\d{4}-\d{2}-\d{2})T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;
429
433
  var WEEKDAY_SHORT = {
430
434
  Sun: 0,
431
435
  Mon: 1,
@@ -448,6 +452,10 @@ function minutesOfDay(hhmm) {
448
452
  if (!parsed) return null;
449
453
  return parsed.hour * 60 + parsed.minute;
450
454
  }
455
+ function normalizeVisitTime(value) {
456
+ const match = VISIT_TIME_RE.exec(value.trim());
457
+ return match ? `${match[1]}:${match[2]}` : null;
458
+ }
451
459
  function expandVisitTimeSlots(hours) {
452
460
  const start = minutesOfDay(hours.start);
453
461
  const end = minutesOfDay(hours.end);
@@ -529,10 +537,15 @@ function parseYmd(value) {
529
537
  }
530
538
  function normalizeVisitDate(date, timeZone = VISIT_TIME_ZONE) {
531
539
  if (typeof date === "string") {
532
- if (parseYmd(date)) return date;
533
- if (!ISO_INSTANT_RE.test(date)) return null;
534
- const instant = new Date(date);
535
- return Number.isFinite(instant.getTime()) ? calendarYmd(instant, timeZone) : null;
540
+ const trimmed = date.trim();
541
+ if (parseYmd(trimmed)) return trimmed;
542
+ if (ISO_INSTANT_RE.test(trimmed)) {
543
+ const instant = new Date(trimmed);
544
+ return Number.isFinite(instant.getTime()) ? calendarYmd(instant, timeZone) : null;
545
+ }
546
+ const local = DATETIME_LOCAL_RE.exec(trimmed);
547
+ if (local && parseYmd(local[1])) return local[1];
548
+ return null;
536
549
  }
537
550
  if (date instanceof Date && Number.isFinite(date.getTime())) {
538
551
  return calendarYmd(date, timeZone);
@@ -553,6 +566,7 @@ function slotsForDate(schedule, date, now = /* @__PURE__ */ new Date()) {
553
566
  if (!ymd) return [];
554
567
  const weekday = weekdayOfYmd(ymd, timeZone);
555
568
  if (weekday == null) return [];
569
+ if (schedule.disabledDays.includes(weekday)) return [];
556
570
  if (weekday === 0 && !schedule.sunday) return [];
557
571
  if (weekday === 6 && !schedule.saturday) return [];
558
572
  const base = weekday === 0 || weekday === 6 ? schedule.weekendTimeSlots : schedule.weekdayTimeSlots;
@@ -567,10 +581,61 @@ function slotsForDate(schedule, date, now = /* @__PURE__ */ new Date()) {
567
581
  });
568
582
  }
569
583
  function isVisitSlotAllowed(schedule, visitDate, visitTime, now = /* @__PURE__ */ new Date()) {
570
- return slotsForDate(schedule, visitDate, now).includes(visitTime);
584
+ const time = normalizeVisitTime(visitTime);
585
+ if (!time) return false;
586
+ return slotsForDate(schedule, visitDate, now).includes(time);
587
+ }
588
+
589
+ // src/resolve-site-id.ts
590
+ var PREVIEW_HOST_SUFFIXES = [".vusercontent.net"];
591
+ function isStudioPreviewHost(host) {
592
+ const normalized = stripPort(host);
593
+ if (normalized === "localhost" || normalized === "127.0.0.1") return true;
594
+ return PREVIEW_HOST_SUFFIXES.some((suffix) => normalized.endsWith(suffix));
595
+ }
596
+ function stripPort(host) {
597
+ return host.trim().toLowerCase().split(":")[0] ?? "";
598
+ }
599
+ async function resolvePublicSiteId(options) {
600
+ const fallback = options.fallback?.trim() ?? "";
601
+ const host = options.host ? stripPort(options.host) : "";
602
+ if (host && !isStudioPreviewHost(host)) {
603
+ const site = await getSite({
604
+ domain: host,
605
+ baseUrl: options.baseUrl,
606
+ fetch: options.fetch
607
+ });
608
+ if (site?.id) return site.id;
609
+ throw new GaragemSdkError(
610
+ `Garagem SDK: no published site found for domain "${host}"`,
611
+ { status: 404, url: host }
612
+ );
613
+ }
614
+ if (fallback) return fallback;
615
+ throw new GaragemSdkError(
616
+ "Garagem SDK: could not resolve a site id (no host match and no fallback)",
617
+ { status: 404, url: host || "fallback" }
618
+ );
571
619
  }
572
620
 
573
621
  // src/leads.ts
622
+ function browserHost() {
623
+ if (typeof window === "undefined") return "";
624
+ return window.location.host;
625
+ }
626
+ async function resolveLeadSiteId(input) {
627
+ try {
628
+ return await coerceSiteId(input.siteId);
629
+ } catch (error) {
630
+ const host = browserHost();
631
+ if (!host) throw error;
632
+ return resolvePublicSiteId({
633
+ host,
634
+ baseUrl: input.baseUrl,
635
+ fetch: input.fetch
636
+ });
637
+ }
638
+ }
574
639
  var LeadSubmitError = class extends Error {
575
640
  code;
576
641
  status;
@@ -615,7 +680,7 @@ function studioDefaultLeadUi() {
615
680
  };
616
681
  }
617
682
  async function getLeadUi(options) {
618
- const siteId = await coerceSiteId(options.siteId);
683
+ const siteId = await resolveLeadSiteId(options);
619
684
  const url = `${normalizeBaseUrl(options.baseUrl)}/api/sites/${encodeURIComponent(siteId)}/leads/ui`;
620
685
  return callJson(
621
686
  url,
@@ -673,7 +738,7 @@ function normalizeContact(input) {
673
738
  };
674
739
  }
675
740
  async function postSiteLead(input) {
676
- const siteId = await coerceSiteId(input.siteId);
741
+ const siteId = await resolveLeadSiteId(input);
677
742
  const base = normalizeBaseUrl(input.baseUrl);
678
743
  const url = `${base}/api/webhooks/sites/${encodeURIComponent(siteId)}/leads`;
679
744
  const f = input.fetch ?? fetch;
@@ -733,7 +798,8 @@ async function submitVisitLead(input) {
733
798
  const prepared = leadPostContext(input);
734
799
  const schedule = input.schedule ?? STUDIO_DEFAULT_VISIT_SCHEDULE;
735
800
  const visitDate = normalizeVisitDate(input.visitDate, schedule.timeZone);
736
- if (!visitDate || !isVisitSlotAllowed(schedule, visitDate, input.visitTime)) {
801
+ const visitTime = normalizeVisitTime(input.visitTime);
802
+ if (!visitDate || !visitTime || !isVisitSlotAllowed(schedule, visitDate, visitTime)) {
737
803
  throw new LeadSubmitError(
738
804
  "Garagem SDK: visitDate/visitTime is outside the published schedule.",
739
805
  { code: "invalid_slot" }
@@ -750,7 +816,7 @@ async function submitVisitLead(input) {
750
816
  propertyId: prepared.listingId,
751
817
  listingId: prepared.listingId,
752
818
  visitDate,
753
- visitTime: input.visitTime,
819
+ visitTime,
754
820
  ...prepared.extras
755
821
  }
756
822
  });
@@ -1625,38 +1691,6 @@ function paginationPages(currentPage, totalPages, padding) {
1625
1691
  return pages;
1626
1692
  }
1627
1693
 
1628
- // src/resolve-site-id.ts
1629
- var PREVIEW_HOST_SUFFIXES = [".vusercontent.net"];
1630
- function isStudioPreviewHost(host) {
1631
- const normalized = stripPort(host);
1632
- if (normalized === "localhost" || normalized === "127.0.0.1") return true;
1633
- return PREVIEW_HOST_SUFFIXES.some((suffix) => normalized.endsWith(suffix));
1634
- }
1635
- function stripPort(host) {
1636
- return host.trim().toLowerCase().split(":")[0] ?? "";
1637
- }
1638
- async function resolvePublicSiteId(options) {
1639
- const fallback = options.fallback?.trim() ?? "";
1640
- const host = options.host ? stripPort(options.host) : "";
1641
- if (host && !isStudioPreviewHost(host)) {
1642
- const site = await getSite({
1643
- domain: host,
1644
- baseUrl: options.baseUrl,
1645
- fetch: options.fetch
1646
- });
1647
- if (site?.id) return site.id;
1648
- throw new GaragemSdkError(
1649
- `Garagem SDK: no published site found for domain "${host}"`,
1650
- { status: 404, url: host }
1651
- );
1652
- }
1653
- if (fallback) return fallback;
1654
- throw new GaragemSdkError(
1655
- "Garagem SDK: could not resolve a site id (no host match and no fallback)",
1656
- { status: 404, url: host || "fallback" }
1657
- );
1658
- }
1659
-
1660
1694
  // src/studio-contract.ts
1661
1695
  var STUDIO_SDK_PACKAGE = "@garagem-ai/site-sdk";
1662
1696
  var STUDIO_SDK_CONTRACT = {
@@ -1664,10 +1698,9 @@ var STUDIO_SDK_CONTRACT = {
1664
1698
  /**
1665
1699
  * Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
1666
1700
  * prompts that skip the layout chrome tag match the tarball v0 installs.
1667
- * This PR’s changeset publishes that tarball as 0.4.3 — do not generate
1668
- * against this floor until Version Packages is on npm.
1701
+ * 0.4.5 normalizes visit dates and recovers a missing browser siteId.
1669
1702
  */
1670
- minNpmVersion: "0.4.3",
1703
+ minNpmVersion: "0.4.5",
1671
1704
  /** First release where ListingCard and ResultsSkeleton inject the sheet. */
1672
1705
  selfInjectSince: "0.4.2",
1673
1706
  chromeStrategy: "self-inject",
@@ -2000,6 +2033,7 @@ function createGaragemClient(options = {}) {
2000
2033
  listingPublicPath,
2001
2034
  mergeAppliedSearchQueryIntoSearch,
2002
2035
  normalizeVisitDate,
2036
+ normalizeVisitTime,
2003
2037
  paginationPages,
2004
2038
  parseAppliedSearchQuery,
2005
2039
  parseGroupedInteger,