@garagem-ai/site-sdk 0.4.2 → 0.4.4
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 +16 -11
- package/dist/index.d.mts +130 -3
- package/dist/index.d.ts +130 -3
- package/dist/index.js +431 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +417 -3
- 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/client.ts +51 -0
- package/src/fetchers.ts +2 -1
- package/src/index.ts +33 -0
- package/src/leads.ts +343 -0
- package/src/react/styles/search-chrome-css.generated.ts +1 -1
- package/src/schedule.ts +236 -0
- package/src/studio-contract.ts +32 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@garagem-ai/site-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Typed, runtime-agnostic SDK for building custom real estate sites against the Garagem platform. Drop into any Next.js (or other JS) project to fetch listings, sites and CMS data.",
|
|
6
6
|
"main": "./dist/index.js",
|
package/src/client.ts
CHANGED
|
@@ -23,6 +23,16 @@ import {
|
|
|
23
23
|
type QueryListingsOptions,
|
|
24
24
|
type SearchListingsOptions,
|
|
25
25
|
} from "./fetchers";
|
|
26
|
+
import {
|
|
27
|
+
getLeadUi,
|
|
28
|
+
submitContactLead,
|
|
29
|
+
submitVisitLead,
|
|
30
|
+
type ContactLeadInput,
|
|
31
|
+
type GetLeadUiOptions,
|
|
32
|
+
type LeadSubmitResult,
|
|
33
|
+
type LeadUi,
|
|
34
|
+
type VisitLeadInput,
|
|
35
|
+
} from "./leads";
|
|
26
36
|
import type {
|
|
27
37
|
CmsCollection,
|
|
28
38
|
CmsEntriesResult,
|
|
@@ -125,6 +135,23 @@ export interface GaragemClient {
|
|
|
125
135
|
siteId?: string;
|
|
126
136
|
next?: RequestNextOptions;
|
|
127
137
|
}): Promise<CmsEntry>;
|
|
138
|
+
/** Visit/contact dialog schema (slots, labels). */
|
|
139
|
+
getLeadUi(args?: {
|
|
140
|
+
siteId?: string;
|
|
141
|
+
next?: RequestNextOptions;
|
|
142
|
+
}): Promise<LeadUi>;
|
|
143
|
+
/** POST a visit lead (`leadType: "visit"`). */
|
|
144
|
+
submitVisitLead(
|
|
145
|
+
args: Omit<VisitLeadInput, "siteId" | "baseUrl" | "fetch"> & {
|
|
146
|
+
siteId?: string;
|
|
147
|
+
}
|
|
148
|
+
): Promise<LeadSubmitResult>;
|
|
149
|
+
/** POST a contact lead (`leadType: "contact"`). */
|
|
150
|
+
submitContactLead(
|
|
151
|
+
args: Omit<ContactLeadInput, "siteId" | "baseUrl" | "fetch"> & {
|
|
152
|
+
siteId?: string;
|
|
153
|
+
}
|
|
154
|
+
): Promise<LeadSubmitResult>;
|
|
128
155
|
}
|
|
129
156
|
|
|
130
157
|
/**
|
|
@@ -286,5 +313,29 @@ export function createGaragemClient(
|
|
|
286
313
|
if (merged !== undefined) opts.next = merged;
|
|
287
314
|
return getCmsEntry(opts);
|
|
288
315
|
},
|
|
316
|
+
async getLeadUi({ siteId, next } = {}) {
|
|
317
|
+
const opts: GetLeadUiOptions = withDefaults({
|
|
318
|
+
siteId: resolveSiteId(siteId),
|
|
319
|
+
});
|
|
320
|
+
const merged = mergeNext(next);
|
|
321
|
+
if (merged !== undefined) opts.next = merged;
|
|
322
|
+
return getLeadUi(opts);
|
|
323
|
+
},
|
|
324
|
+
async submitVisitLead(args) {
|
|
325
|
+
return submitVisitLead(
|
|
326
|
+
withDefaults({
|
|
327
|
+
...args,
|
|
328
|
+
siteId: resolveSiteId(args.siteId),
|
|
329
|
+
})
|
|
330
|
+
);
|
|
331
|
+
},
|
|
332
|
+
async submitContactLead(args) {
|
|
333
|
+
return submitContactLead(
|
|
334
|
+
withDefaults({
|
|
335
|
+
...args,
|
|
336
|
+
siteId: resolveSiteId(args.siteId),
|
|
337
|
+
})
|
|
338
|
+
);
|
|
339
|
+
},
|
|
289
340
|
};
|
|
290
341
|
}
|
package/src/fetchers.ts
CHANGED
|
@@ -105,7 +105,8 @@ interface FetchInit extends RequestInit {
|
|
|
105
105
|
next?: RequestNextOptions;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
/** Shared JSON fetch for SDK helpers (not part of the public barrel). */
|
|
109
|
+
export async function callJson<T>(
|
|
109
110
|
url: string,
|
|
110
111
|
init: FetchInit,
|
|
111
112
|
fetchImpl: FetchLike
|
package/src/index.ts
CHANGED
|
@@ -82,6 +82,37 @@ export {
|
|
|
82
82
|
type SearchListingsOptions,
|
|
83
83
|
} from "./fetchers";
|
|
84
84
|
|
|
85
|
+
export {
|
|
86
|
+
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
87
|
+
VISIT_TIME_ZONE,
|
|
88
|
+
expandVisitSchedule,
|
|
89
|
+
expandVisitTimeSlots,
|
|
90
|
+
isVisitSlotAllowed,
|
|
91
|
+
normalizeVisitDate,
|
|
92
|
+
slotsForDate,
|
|
93
|
+
type HHmm,
|
|
94
|
+
type VisitHours,
|
|
95
|
+
type VisitSchedule,
|
|
96
|
+
type VisitScheduleConfig,
|
|
97
|
+
} from "./schedule";
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
LeadSubmitError,
|
|
101
|
+
getLeadUi,
|
|
102
|
+
studioDefaultLeadUi,
|
|
103
|
+
submitContactLead,
|
|
104
|
+
submitVisitLead,
|
|
105
|
+
type ContactLeadInput,
|
|
106
|
+
type GetLeadUiOptions,
|
|
107
|
+
type LeadContact,
|
|
108
|
+
type LeadField,
|
|
109
|
+
type LeadFieldId,
|
|
110
|
+
type LeadSubmitErrorCode,
|
|
111
|
+
type LeadSubmitResult,
|
|
112
|
+
type LeadUi,
|
|
113
|
+
type VisitLeadInput,
|
|
114
|
+
} from "./leads";
|
|
115
|
+
|
|
85
116
|
export { listingLookupKey, listingPublicPath } from "./listing-path";
|
|
86
117
|
|
|
87
118
|
export {
|
|
@@ -161,7 +192,9 @@ export {
|
|
|
161
192
|
parseReactSdkNamedImports,
|
|
162
193
|
studioChromeInstruction,
|
|
163
194
|
studioCodegenContractViolations,
|
|
195
|
+
studioLeadInstruction,
|
|
164
196
|
studioSdkPinInstruction,
|
|
197
|
+
hasShowcaseLeadsPostUrl,
|
|
165
198
|
unavailableReactImports,
|
|
166
199
|
type StudioSdkContract,
|
|
167
200
|
} from "./studio-contract";
|
package/src/leads.ts
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless visit / contact leads. Schema via GET /leads/ui; POST always
|
|
3
|
+
* goes to the webhook (`source: "site-sdk"`). v0 draws the dialog.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { callJson, type FetchLike } from "./fetchers";
|
|
7
|
+
import { coerceSiteId, normalizeBaseUrl } from "./internal/url";
|
|
8
|
+
import {
|
|
9
|
+
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
10
|
+
isVisitSlotAllowed,
|
|
11
|
+
normalizeVisitDate,
|
|
12
|
+
type HHmm,
|
|
13
|
+
type VisitSchedule,
|
|
14
|
+
} from "./schedule";
|
|
15
|
+
import type { RequestNextOptions } from "./types";
|
|
16
|
+
|
|
17
|
+
export type LeadFieldId = "name" | "email" | "phone" | "message";
|
|
18
|
+
|
|
19
|
+
export type LeadField = {
|
|
20
|
+
id: LeadFieldId;
|
|
21
|
+
required: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type LeadUi = {
|
|
25
|
+
defaultVariant: "visit";
|
|
26
|
+
timeZone: "America/Sao_Paulo";
|
|
27
|
+
variants: {
|
|
28
|
+
visit: {
|
|
29
|
+
ctaLabel: string;
|
|
30
|
+
requireDateTime: true;
|
|
31
|
+
schedule: VisitSchedule;
|
|
32
|
+
fields: LeadField[];
|
|
33
|
+
};
|
|
34
|
+
contact: {
|
|
35
|
+
ctaLabel: string;
|
|
36
|
+
requireDateTime: false;
|
|
37
|
+
whatsappPhone: string | null;
|
|
38
|
+
fields: LeadField[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type GetLeadUiOptions = {
|
|
44
|
+
siteId: string;
|
|
45
|
+
baseUrl?: string;
|
|
46
|
+
fetch?: FetchLike;
|
|
47
|
+
next?: RequestNextOptions;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type LeadContact = {
|
|
51
|
+
name: string;
|
|
52
|
+
email?: string;
|
|
53
|
+
phone?: string;
|
|
54
|
+
message?: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
type LeadSubmitBase = LeadContact & {
|
|
58
|
+
siteId: string;
|
|
59
|
+
baseUrl?: string;
|
|
60
|
+
fetch?: FetchLike;
|
|
61
|
+
listingId: string;
|
|
62
|
+
visitorId?: string;
|
|
63
|
+
brokerRef?: string;
|
|
64
|
+
referrer?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type VisitLeadInput = LeadSubmitBase & {
|
|
68
|
+
visitDate: Date | string;
|
|
69
|
+
visitTime: HHmm;
|
|
70
|
+
schedule?: VisitSchedule;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type ContactLeadInput = LeadSubmitBase;
|
|
74
|
+
|
|
75
|
+
export type LeadSubmitResult = { ok: true; status: 202; id: string };
|
|
76
|
+
|
|
77
|
+
export type LeadSubmitErrorCode =
|
|
78
|
+
| "invalid_listing_id"
|
|
79
|
+
| "invalid_contact"
|
|
80
|
+
| "invalid_slot"
|
|
81
|
+
| "rate_limited"
|
|
82
|
+
| "not_found"
|
|
83
|
+
| "http"
|
|
84
|
+
| "network";
|
|
85
|
+
|
|
86
|
+
export class LeadSubmitError extends Error {
|
|
87
|
+
readonly code: LeadSubmitErrorCode;
|
|
88
|
+
readonly status?: number;
|
|
89
|
+
readonly retryAfterSeconds?: number;
|
|
90
|
+
|
|
91
|
+
constructor(
|
|
92
|
+
message: string,
|
|
93
|
+
info: {
|
|
94
|
+
code: LeadSubmitErrorCode;
|
|
95
|
+
status?: number;
|
|
96
|
+
retryAfterSeconds?: number;
|
|
97
|
+
}
|
|
98
|
+
) {
|
|
99
|
+
super(message);
|
|
100
|
+
this.name = "LeadSubmitError";
|
|
101
|
+
this.code = info.code;
|
|
102
|
+
if (info.status != null) this.status = info.status;
|
|
103
|
+
if (info.retryAfterSeconds != null) {
|
|
104
|
+
this.retryAfterSeconds = info.retryAfterSeconds;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const UUID_RE =
|
|
110
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
111
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
112
|
+
const MESSAGE_MAX = 2000;
|
|
113
|
+
|
|
114
|
+
const CONTACT_FIELDS: LeadField[] = [
|
|
115
|
+
{ id: "name", required: true },
|
|
116
|
+
{ id: "email", required: false },
|
|
117
|
+
{ id: "phone", required: false },
|
|
118
|
+
{ id: "message", required: false },
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
/** Fallback when GET /leads/ui fails — same default the API publishes. */
|
|
122
|
+
export function studioDefaultLeadUi(): LeadUi {
|
|
123
|
+
return {
|
|
124
|
+
defaultVariant: "visit",
|
|
125
|
+
timeZone: "America/Sao_Paulo",
|
|
126
|
+
variants: {
|
|
127
|
+
visit: {
|
|
128
|
+
ctaLabel: "Agendar visita",
|
|
129
|
+
requireDateTime: true,
|
|
130
|
+
schedule: STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
131
|
+
fields: CONTACT_FIELDS,
|
|
132
|
+
},
|
|
133
|
+
contact: {
|
|
134
|
+
ctaLabel: "Fale conosco",
|
|
135
|
+
requireDateTime: false,
|
|
136
|
+
whatsappPhone: null,
|
|
137
|
+
fields: CONTACT_FIELDS,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function getLeadUi(options: GetLeadUiOptions): Promise<LeadUi> {
|
|
144
|
+
const siteId = await coerceSiteId(options.siteId);
|
|
145
|
+
const url = `${normalizeBaseUrl(options.baseUrl)}/api/sites/${encodeURIComponent(siteId)}/leads/ui`;
|
|
146
|
+
return callJson<LeadUi>(
|
|
147
|
+
url,
|
|
148
|
+
{
|
|
149
|
+
method: "GET",
|
|
150
|
+
headers: { Accept: "application/json" },
|
|
151
|
+
next: options.next,
|
|
152
|
+
},
|
|
153
|
+
options.fetch ?? fetch
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function assertListingId(listingId: string): void {
|
|
158
|
+
if (!UUID_RE.test(listingId.trim())) {
|
|
159
|
+
throw new LeadSubmitError(
|
|
160
|
+
"Garagem SDK: listingId must be the listing UUID, not a path or code.",
|
|
161
|
+
{ code: "invalid_listing_id" }
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function normalizeContact(input: LeadContact): {
|
|
167
|
+
name: string;
|
|
168
|
+
email?: string;
|
|
169
|
+
phone?: string;
|
|
170
|
+
message?: string;
|
|
171
|
+
} {
|
|
172
|
+
const name = input.name.trim();
|
|
173
|
+
if (name.length < 2 || name.length > 200) {
|
|
174
|
+
throw new LeadSubmitError("Garagem SDK: name is required.", {
|
|
175
|
+
code: "invalid_contact",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const email = input.email?.trim() || undefined;
|
|
179
|
+
const phone = input.phone?.trim() || undefined;
|
|
180
|
+
if (!email && !phone) {
|
|
181
|
+
throw new LeadSubmitError("Garagem SDK: email and/or phone is required.", {
|
|
182
|
+
code: "invalid_contact",
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (email && !EMAIL_RE.test(email)) {
|
|
186
|
+
throw new LeadSubmitError("Garagem SDK: email is invalid.", {
|
|
187
|
+
code: "invalid_contact",
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (phone && (phone.length < 5 || phone.length > 40)) {
|
|
191
|
+
throw new LeadSubmitError("Garagem SDK: phone is invalid.", {
|
|
192
|
+
code: "invalid_contact",
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const message = input.message?.trim() || undefined;
|
|
196
|
+
if (message && message.length > MESSAGE_MAX) {
|
|
197
|
+
throw new LeadSubmitError("Garagem SDK: message is too long.", {
|
|
198
|
+
code: "invalid_contact",
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
name,
|
|
203
|
+
...(email ? { email } : {}),
|
|
204
|
+
...(phone ? { phone } : {}),
|
|
205
|
+
...(message ? { message } : {}),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type SiteSdkLeadBody = {
|
|
210
|
+
source: "site-sdk";
|
|
211
|
+
leadType: "visit" | "contact";
|
|
212
|
+
name: string;
|
|
213
|
+
email?: string;
|
|
214
|
+
phone?: string;
|
|
215
|
+
message?: string;
|
|
216
|
+
propertyId: string;
|
|
217
|
+
listingId: string;
|
|
218
|
+
visitDate?: string;
|
|
219
|
+
visitTime?: string;
|
|
220
|
+
visitorId?: string;
|
|
221
|
+
brokerRef?: string;
|
|
222
|
+
referrer?: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
async function postSiteLead(input: {
|
|
226
|
+
siteId: string;
|
|
227
|
+
baseUrl?: string;
|
|
228
|
+
fetch?: FetchLike;
|
|
229
|
+
body: SiteSdkLeadBody;
|
|
230
|
+
}): Promise<LeadSubmitResult> {
|
|
231
|
+
const siteId = await coerceSiteId(input.siteId);
|
|
232
|
+
const base = normalizeBaseUrl(input.baseUrl);
|
|
233
|
+
const url = `${base}/api/webhooks/sites/${encodeURIComponent(siteId)}/leads`;
|
|
234
|
+
const f = input.fetch ?? fetch;
|
|
235
|
+
let response: Response;
|
|
236
|
+
try {
|
|
237
|
+
response = await f(url, {
|
|
238
|
+
method: "POST",
|
|
239
|
+
headers: {
|
|
240
|
+
Accept: "application/json",
|
|
241
|
+
"Content-Type": "application/json",
|
|
242
|
+
},
|
|
243
|
+
body: JSON.stringify(input.body),
|
|
244
|
+
});
|
|
245
|
+
} catch (error) {
|
|
246
|
+
throw new LeadSubmitError(
|
|
247
|
+
error instanceof Error ? error.message : "Garagem SDK: network error.",
|
|
248
|
+
{ code: "network" }
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (response.status === 202) {
|
|
253
|
+
const data = (await response.json().catch(() => ({}))) as {
|
|
254
|
+
id?: unknown;
|
|
255
|
+
};
|
|
256
|
+
const id = typeof data.id === "string" && data.id ? data.id : "";
|
|
257
|
+
return { ok: true, status: 202, id };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const retryAfter = Number(response.headers.get("Retry-After") ?? "");
|
|
261
|
+
if (response.status === 429) {
|
|
262
|
+
throw new LeadSubmitError("Garagem SDK: too many lead submissions.", {
|
|
263
|
+
code: "rate_limited",
|
|
264
|
+
status: 429,
|
|
265
|
+
retryAfterSeconds: Number.isFinite(retryAfter) ? retryAfter : undefined,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (response.status === 404) {
|
|
269
|
+
throw new LeadSubmitError("Garagem SDK: listing or site not found.", {
|
|
270
|
+
code: "not_found",
|
|
271
|
+
status: 404,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
throw new LeadSubmitError(
|
|
275
|
+
`Garagem SDK: lead submit failed (${response.status}).`,
|
|
276
|
+
{ code: "http", status: response.status }
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function leadPostContext(input: LeadSubmitBase): {
|
|
281
|
+
listingId: string;
|
|
282
|
+
contact: ReturnType<typeof normalizeContact>;
|
|
283
|
+
extras: Pick<SiteSdkLeadBody, "visitorId" | "brokerRef" | "referrer">;
|
|
284
|
+
} {
|
|
285
|
+
assertListingId(input.listingId);
|
|
286
|
+
return {
|
|
287
|
+
listingId: input.listingId.trim(),
|
|
288
|
+
contact: normalizeContact(input),
|
|
289
|
+
extras: {
|
|
290
|
+
...(input.visitorId ? { visitorId: input.visitorId } : {}),
|
|
291
|
+
...(input.brokerRef ? { brokerRef: input.brokerRef } : {}),
|
|
292
|
+
...(input.referrer ? { referrer: input.referrer } : {}),
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export async function submitVisitLead(
|
|
298
|
+
input: VisitLeadInput
|
|
299
|
+
): Promise<LeadSubmitResult> {
|
|
300
|
+
const prepared = leadPostContext(input);
|
|
301
|
+
const schedule = input.schedule ?? STUDIO_DEFAULT_VISIT_SCHEDULE;
|
|
302
|
+
const visitDate = normalizeVisitDate(input.visitDate, schedule.timeZone);
|
|
303
|
+
if (!visitDate || !isVisitSlotAllowed(schedule, visitDate, input.visitTime)) {
|
|
304
|
+
throw new LeadSubmitError(
|
|
305
|
+
"Garagem SDK: visitDate/visitTime is outside the published schedule.",
|
|
306
|
+
{ code: "invalid_slot" }
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
return postSiteLead({
|
|
310
|
+
siteId: input.siteId,
|
|
311
|
+
baseUrl: input.baseUrl,
|
|
312
|
+
fetch: input.fetch,
|
|
313
|
+
body: {
|
|
314
|
+
source: "site-sdk",
|
|
315
|
+
leadType: "visit",
|
|
316
|
+
...prepared.contact,
|
|
317
|
+
propertyId: prepared.listingId,
|
|
318
|
+
listingId: prepared.listingId,
|
|
319
|
+
visitDate,
|
|
320
|
+
visitTime: input.visitTime,
|
|
321
|
+
...prepared.extras,
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export async function submitContactLead(
|
|
327
|
+
input: ContactLeadInput
|
|
328
|
+
): Promise<LeadSubmitResult> {
|
|
329
|
+
const prepared = leadPostContext(input);
|
|
330
|
+
return postSiteLead({
|
|
331
|
+
siteId: input.siteId,
|
|
332
|
+
baseUrl: input.baseUrl,
|
|
333
|
+
fetch: input.fetch,
|
|
334
|
+
body: {
|
|
335
|
+
source: "site-sdk",
|
|
336
|
+
leadType: "contact",
|
|
337
|
+
...prepared.contact,
|
|
338
|
+
propertyId: prepared.listingId,
|
|
339
|
+
listingId: prepared.listingId,
|
|
340
|
+
...prepared.extras,
|
|
341
|
+
},
|
|
342
|
+
});
|
|
343
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Generated by scripts/build-search-chrome-css.mjs — do not edit. */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/* prettier-ignore */
|
|
4
|
-
export const SEARCH_CHROME_CSS_VERSION = "0.4.
|
|
4
|
+
export const SEARCH_CHROME_CSS_VERSION = "0.4.4";
|
|
5
5
|
export const SEARCH_CHROME_CSS = ":root{--garagem-listing-card-radius:0.75rem;--garagem-listing-card-gap:1.5rem;--garagem-listing-price-size:1.125rem;--garagem-listing-media-ratio:4 / 3;--garagem-search-control-height:2.75rem;--garagem-search-icon-size:1.25rem;--garagem-search-radius:var(--radius,0.75rem);--garagem-skeleton:var(--muted,#e7e5e4)}[data-slot=\"search-page\"]{margin-inline:auto;max-width:80rem;padding:3rem 1.5rem}[data-slot=\"search-heading\"]{display:flex;min-width:0;align-items:baseline;gap:0.375rem;font-size:1.25rem;font-weight:600}[data-slot=\"search-heading-count\"]{flex-shrink:0}[data-slot=\"search-heading-title\"]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:inherit;font-weight:inherit}[data-slot=\"search-query-sort\"]{display:flex;flex-direction:column;gap:1rem}@media (min-width:1024px){[data-slot=\"search-query-sort\"]{flex-direction:row;align-items:flex-end}}[data-slot=\"search-query\"]{flex:1;min-width:0}[data-slot=\"search-query-input\"],[data-slot=\"search-sort-trigger\"],[data-slot=\"search-toolbar-trigger\"],[data-slot=\"search-filters-trigger\"]{min-height:var(--garagem-search-control-height)}[data-slot=\"search-query-field\"]{position:relative}[data-slot=\"search-query-input\"]{width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 5.5rem 0.5rem 1rem;outline:none}[data-slot=\"search-query-actions\"]{position:absolute;top:50%;right:0.35rem;display:flex;transform:translateY(-50%);align-items:center;gap:0.15rem}[data-slot=\"search-icon-button\"]{display:inline-flex;height:2.25rem;width:2.25rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:999px;background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot=\"search-icon-button\"][data-kind=\"clear\"]{background:transparent;color:var(--muted-foreground,#737373)}[data-slot=\"search-icon\"]{width:var(--garagem-search-icon-size);height:var(--garagem-search-icon-size);display:block}[data-slot=\"search-sort\"]{display:flex;flex-direction:column;gap:0.25rem}[data-slot=\"search-sort-trigger\"]{appearance:none;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 2.25rem 0.5rem 0.75rem;background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>\");background-repeat:no-repeat;background-position:right 0.65rem center}[data-slot=\"search-toolbar\"]{display:flex;flex-wrap:wrap;align-items:flex-end;gap:0.5rem}[data-slot=\"search-toolbar-trigger\"],[data-slot=\"search-filters-trigger\"]{cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 0.75rem;font-size:0.875rem}[data-slot=\"search-popover\"]{position:absolute;z-index:30;margin-top:0.5rem;width:18rem;border-radius:0.75rem;border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:1rem;box-shadow:0 10px 30px rgb(0 0 0 / 0.12);animation:garagem-search-in 140ms ease-out}[data-slot=\"search-grid\"],[data-slot=\"search-skeleton\"]{display:grid;grid-template-columns:1fr;gap:var(--garagem-listing-card-gap)}@media (min-width:640px){[data-slot=\"search-grid\"],[data-slot=\"search-skeleton\"]{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:1024px){[data-slot=\"search-grid\"],[data-slot=\"search-skeleton\"]{grid-template-columns:repeat(3,minmax(0,1fr))}}[data-slot=\"listing-card\"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7);background:var(--card,var(--background,#fff))}[data-slot=\"listing-card-price-row\"]{display:inline-flex;align-items:baseline;gap:0.25rem}[data-slot=\"listing-card-price\"]{font-size:var(--garagem-listing-price-size);font-weight:600}[data-slot=\"listing-card-period\"]{font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-checkbox\"]{appearance:none;width:1.15rem;height:1.15rem;flex-shrink:0;cursor:pointer;border:1px solid var(--primary,#111);border-radius:0.25rem;background:var(--background,#fff)}[data-slot=\"search-checkbox\"]:checked{background-color:var(--primary,#111);background-image:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'><path d='M5 12l5 5L20 7'/></svg>\");background-repeat:no-repeat;background-position:center;background-size:0.8rem}[data-slot=\"search-scroll\"]{max-height:12rem;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--muted-foreground,#a1a1aa) transparent}[data-slot=\"search-range-apply\"]{display:inline-flex;min-height:2.5rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:var(--garagem-search-radius);background:var(--primary,#111);color:var(--primary-foreground,#fff);padding:0 0.75rem;font-size:0.75rem;font-weight:600}[data-slot=\"search-sheet\"]{position:fixed;inset:0;z-index:40}[data-slot=\"search-sheet-overlay\"]{position:absolute;inset:0;border:0;cursor:pointer;background:rgb(0 0 0 / 0.4);animation:garagem-search-fade 160ms ease-out}[data-slot=\"search-sheet-panel\"]{position:absolute;top:0;right:0;display:flex;height:100dvh;width:min(22rem,100%);flex-direction:column;background:var(--background,#fff);animation:garagem-search-sheet 180ms ease-out}[data-slot=\"search-sheet-body\"]{min-height:0;flex:1;overflow:auto;padding:1.5rem 1.5rem 0;scrollbar-width:thin}[data-slot=\"search-sheet-footer\"]{display:flex;gap:0.5rem;border-top:1px solid var(--border,#e4e4e7);padding:1rem 1.5rem}[data-slot=\"search-apply-bar\"]{display:flex;width:100%;gap:0.5rem}[data-slot=\"search-apply-bar\"] > button{min-height:2.5rem;flex:1;cursor:pointer;border-radius:var(--garagem-search-radius);padding:0 1rem}[data-slot=\"search-apply-bar\"] > button[data-kind=\"clear\"]{border:1px solid var(--border,#e4e4e7);background:transparent}[data-slot=\"search-apply-bar\"] > button[data-kind=\"apply\"]{border:0;background:var(--primary,#111);color:var(--primary-foreground,#fff);font-weight:600}[data-slot=\"search-pagination\"]{margin-top:2.5rem;display:flex;justify-content:center}[data-slot=\"search-pagination\"] ul{display:flex;flex-wrap:wrap;justify-content:center;gap:0.25rem;padding:0;margin:0;list-style:none}[data-slot=\"search-pagination-item\"]{display:inline-flex;width:2.25rem;height:2.25rem;align-items:center;justify-content:center;border:1px solid var(--border,#e4e4e7);border-radius:0.375rem;font-size:0.75rem;font-weight:500}@media (min-width:768px){[data-slot=\"search-pagination-item\"]{width:2.5rem;height:2.5rem}}[data-slot=\"search-pagination-item\"] a,[data-slot=\"search-pagination-item\"] span{display:flex;width:100%;height:100%;align-items:center;justify-content:center;color:inherit;text-decoration:none}[data-slot=\"search-pagination-item\"][data-current=\"true\"]{background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot=\"search-pagination-item\"][data-disabled=\"true\"]{cursor:not-allowed;color:var(--muted-foreground,#737373)}[data-slot=\"search-toolbar-item\"]{position:relative}[data-slot=\"search-body\"]{margin-top:2rem;display:flex;flex-direction:column;gap:1.5rem}[data-slot=\"search-label\"]{margin-bottom:0.25rem;display:block;font-size:0.875rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-sheet-title\"]{padding:1.5rem 1.5rem 0;font-size:1.125rem;font-weight:600}[data-slot=\"search-layout\"]{display:grid;gap:2rem}[data-slot=\"search-sidebar\"]{display:none}[data-slot=\"search-layout\"] > div > [data-slot=\"search-filters-trigger\"]{margin-bottom:1rem}@media (min-width:1024px){[data-slot=\"search-layout\"]{grid-template-columns:280px minmax(0,1fr)}[data-slot=\"search-sidebar\"]{display:block;position:sticky;top:1.5rem;align-self:start}[data-slot=\"search-layout\"] > div > [data-slot=\"search-filters-trigger\"]{display:none}}[data-slot=\"listing-card-link\"]{display:block;color:inherit;text-decoration:none;cursor:pointer}[data-slot=\"listing-card-media\"]{position:relative;width:100%;overflow:hidden;background:var(--muted,#f5f5f4);aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot=\"listing-card-media\"] img{height:100%;width:100%;object-fit:cover;transition:transform 0.3s}[data-slot=\"listing-card\"]:hover [data-slot=\"listing-card-media\"] img{transform:scale(1.05)}@media (prefers-reduced-motion:reduce){[data-slot=\"listing-card-media\"] img{transition:none}[data-slot=\"listing-card\"]:hover [data-slot=\"listing-card-media\"] img{transform:none}}[data-slot=\"listing-card-empty\"]{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"listing-card-cta\"]{margin-top:0.75rem}[data-slot=\"search-filters\"]{display:flex;flex-direction:column;gap:1.25rem}[data-slot=\"search-filter\"]{margin:0;padding:0;border:0;font-size:0.875rem}[data-slot=\"search-filter\"] legend{margin-bottom:0.5rem;padding:0;color:var(--muted-foreground,#737373)}[data-slot=\"search-range-row\"]{display:flex;align-items:flex-end;gap:0.5rem}[data-slot=\"search-range-side\"]{min-width:0;flex:1}[data-slot=\"search-range-side\"] > span:first-child{margin-bottom:0.25rem;display:block;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-range-affix\"]{position:relative;display:block}[data-slot=\"search-range-prefix\"]{pointer-events:none;position:absolute;inset-block:0;left:0;display:flex;align-items:center;padding-left:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-range-input\"]{min-height:2.5rem;width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem}[data-slot=\"search-range-affix\"] [data-slot=\"search-range-input\"]{padding-left:2.5rem}[data-slot=\"search-count-group\"]{display:flex;flex-wrap:wrap;gap:0.375rem}[data-slot=\"search-count-choice\"]{min-height:2.5rem;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem;font-size:0.875rem}[data-slot=\"search-count-choice\"][data-selected=\"true\"]{border-color:var(--primary,#111);background:color-mix(in srgb,var(--primary,#111) 10%,transparent)}[data-slot=\"search-enum-list\"],[data-slot=\"search-scroll\"]{display:flex;flex-direction:column;gap:0.375rem}[data-slot=\"search-enum-option\"]{display:flex;cursor:pointer;align-items:center;gap:0.5rem}[data-slot=\"listing-card-badge\"]{position:absolute;left:0.75rem;top:0.75rem;border-radius:999px;background:color-mix(in srgb,var(--background,#fff) 90%,transparent);padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500}[data-slot=\"listing-card-body\"]{padding:1rem}[data-slot=\"listing-card-title\"]{display:-webkit-box;margin-top:0.25rem;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;font-weight:500}[data-slot=\"listing-card-location\"]{margin-top:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"listing-card-features\"]{display:flex;flex-wrap:wrap;margin-top:0.75rem;gap:0.25rem 1rem;padding:0;list-style:none;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot=\"search-skeleton-block\"]{animation:garagem-search-pulse 1.2s ease-in-out infinite;background:var(--garagem-skeleton);border-radius:0.375rem}[data-slot=\"search-skeleton-card\"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7)}[data-slot=\"search-skeleton-body\"]{display:flex;flex-direction:column;gap:0.5rem;padding:1rem}[data-slot=\"search-skeleton-block\"][data-kind=\"media\"]{aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot=\"search-skeleton-block\"][data-kind=\"line-lg\"]{height:1.25rem;width:50%}[data-slot=\"search-skeleton-block\"][data-kind=\"line-md\"]{height:1rem;width:75%}[data-slot=\"search-skeleton-block\"][data-kind=\"line-sm\"]{height:0.75rem;width:66.666667%}[data-slot=\"search-skeleton-block\"][data-kind=\"detail-media\"]{max-width:45rem;aspect-ratio:4 / 3}[data-slot=\"search-skeleton-block\"][data-kind=\"detail-title\"]{width:66.666667%;height:2rem;margin-top:1.5rem}@media (prefers-reduced-motion:reduce){[data-slot=\"search-popover\"],[data-slot=\"search-sheet-overlay\"],[data-slot=\"search-sheet-panel\"],[data-slot=\"search-skeleton-block\"]{animation:none}}@keyframes garagem-search-in{from{opacity:0;transform:translateY(-4px) scale(0.98)}to{opacity:1;transform:none}}@keyframes garagem-search-fade{from{opacity:0}to{opacity:1}}@keyframes garagem-search-sheet{from{transform:translateX(100%)}to{transform:none}}@keyframes garagem-search-pulse{50%{opacity:0.55}}";
|