@garagem-ai/site-sdk 0.4.5 → 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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -10
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/leads.ts +8 -2
- package/src/react/styles/search-chrome-css.generated.ts +1 -1
- package/src/schedule.ts +22 -7
- package/src/studio-contract.ts +2 -3
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;
|
|
@@ -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
|
-
*
|
|
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.
|
|
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;
|
|
@@ -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
|
-
*
|
|
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.
|
|
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,
|
|
@@ -425,8 +426,10 @@ async function getCmsEntry(options) {
|
|
|
425
426
|
// src/schedule.ts
|
|
426
427
|
var VISIT_TIME_ZONE = "America/Sao_Paulo";
|
|
427
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+)?)?$/;
|
|
428
430
|
var YMD_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
429
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+)?)?$/;
|
|
430
433
|
var WEEKDAY_SHORT = {
|
|
431
434
|
Sun: 0,
|
|
432
435
|
Mon: 1,
|
|
@@ -449,6 +452,10 @@ function minutesOfDay(hhmm) {
|
|
|
449
452
|
if (!parsed) return null;
|
|
450
453
|
return parsed.hour * 60 + parsed.minute;
|
|
451
454
|
}
|
|
455
|
+
function normalizeVisitTime(value) {
|
|
456
|
+
const match = VISIT_TIME_RE.exec(value.trim());
|
|
457
|
+
return match ? `${match[1]}:${match[2]}` : null;
|
|
458
|
+
}
|
|
452
459
|
function expandVisitTimeSlots(hours) {
|
|
453
460
|
const start = minutesOfDay(hours.start);
|
|
454
461
|
const end = minutesOfDay(hours.end);
|
|
@@ -530,10 +537,15 @@ function parseYmd(value) {
|
|
|
530
537
|
}
|
|
531
538
|
function normalizeVisitDate(date, timeZone = VISIT_TIME_ZONE) {
|
|
532
539
|
if (typeof date === "string") {
|
|
533
|
-
|
|
534
|
-
if (
|
|
535
|
-
|
|
536
|
-
|
|
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;
|
|
537
549
|
}
|
|
538
550
|
if (date instanceof Date && Number.isFinite(date.getTime())) {
|
|
539
551
|
return calendarYmd(date, timeZone);
|
|
@@ -569,7 +581,9 @@ function slotsForDate(schedule, date, now = /* @__PURE__ */ new Date()) {
|
|
|
569
581
|
});
|
|
570
582
|
}
|
|
571
583
|
function isVisitSlotAllowed(schedule, visitDate, visitTime, now = /* @__PURE__ */ new Date()) {
|
|
572
|
-
|
|
584
|
+
const time = normalizeVisitTime(visitTime);
|
|
585
|
+
if (!time) return false;
|
|
586
|
+
return slotsForDate(schedule, visitDate, now).includes(time);
|
|
573
587
|
}
|
|
574
588
|
|
|
575
589
|
// src/resolve-site-id.ts
|
|
@@ -784,7 +798,8 @@ async function submitVisitLead(input) {
|
|
|
784
798
|
const prepared = leadPostContext(input);
|
|
785
799
|
const schedule = input.schedule ?? STUDIO_DEFAULT_VISIT_SCHEDULE;
|
|
786
800
|
const visitDate = normalizeVisitDate(input.visitDate, schedule.timeZone);
|
|
787
|
-
|
|
801
|
+
const visitTime = normalizeVisitTime(input.visitTime);
|
|
802
|
+
if (!visitDate || !visitTime || !isVisitSlotAllowed(schedule, visitDate, visitTime)) {
|
|
788
803
|
throw new LeadSubmitError(
|
|
789
804
|
"Garagem SDK: visitDate/visitTime is outside the published schedule.",
|
|
790
805
|
{ code: "invalid_slot" }
|
|
@@ -801,7 +816,7 @@ async function submitVisitLead(input) {
|
|
|
801
816
|
propertyId: prepared.listingId,
|
|
802
817
|
listingId: prepared.listingId,
|
|
803
818
|
visitDate,
|
|
804
|
-
visitTime
|
|
819
|
+
visitTime,
|
|
805
820
|
...prepared.extras
|
|
806
821
|
}
|
|
807
822
|
});
|
|
@@ -1683,10 +1698,9 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
1683
1698
|
/**
|
|
1684
1699
|
* Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
|
|
1685
1700
|
* prompts that skip the layout chrome tag match the tarball v0 installs.
|
|
1686
|
-
*
|
|
1687
|
-
* against this floor until Version Packages is on npm.
|
|
1701
|
+
* 0.4.5 normalizes visit dates and recovers a missing browser siteId.
|
|
1688
1702
|
*/
|
|
1689
|
-
minNpmVersion: "0.4.
|
|
1703
|
+
minNpmVersion: "0.4.5",
|
|
1690
1704
|
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
1691
1705
|
selfInjectSince: "0.4.2",
|
|
1692
1706
|
chromeStrategy: "self-inject",
|
|
@@ -2019,6 +2033,7 @@ function createGaragemClient(options = {}) {
|
|
|
2019
2033
|
listingPublicPath,
|
|
2020
2034
|
mergeAppliedSearchQueryIntoSearch,
|
|
2021
2035
|
normalizeVisitDate,
|
|
2036
|
+
normalizeVisitTime,
|
|
2022
2037
|
paginationPages,
|
|
2023
2038
|
parseAppliedSearchQuery,
|
|
2024
2039
|
parseGroupedInteger,
|