@garagem-ai/site-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -0
- package/dist/index.d.mts +325 -0
- package/dist/index.d.ts +325 -0
- package/dist/index.js +236 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +204 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -0
- package/src/client.ts +145 -0
- package/src/fetchers.ts +244 -0
- package/src/index.ts +55 -0
- package/src/internal/url.ts +32 -0
- package/src/types.ts +194 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for the Garagem Sites SDK.
|
|
3
|
+
*
|
|
4
|
+
* These match the canonical shapes returned by the public Garagem
|
|
5
|
+
* Sites API (`/api/sites/...`). Treat them as the public contract —
|
|
6
|
+
* additive changes only, never breaking.
|
|
7
|
+
*/
|
|
8
|
+
/** Sale/rental indicator. The API may return additional string values; consumers should branch defensively. */
|
|
9
|
+
type ListingBusinessType = "sale" | "rental" | (string & {});
|
|
10
|
+
/** Whether the price is shown publicly or kept on request. */
|
|
11
|
+
type ListingPriceVisibility = "public" | "private";
|
|
12
|
+
/** Property-level fields shown on a listing summary card. */
|
|
13
|
+
interface ListingPropertySummary {
|
|
14
|
+
type: string;
|
|
15
|
+
bedrooms: number;
|
|
16
|
+
bathrooms: number;
|
|
17
|
+
suites: number;
|
|
18
|
+
parkingSpaces: number;
|
|
19
|
+
totalArea: number;
|
|
20
|
+
usableArea: number;
|
|
21
|
+
}
|
|
22
|
+
/** Address breakdown returned with every listing. */
|
|
23
|
+
interface ListingLocation {
|
|
24
|
+
street: string;
|
|
25
|
+
number: string;
|
|
26
|
+
complement?: string;
|
|
27
|
+
neighborhood: string;
|
|
28
|
+
city: string;
|
|
29
|
+
state: string;
|
|
30
|
+
postalCode: string;
|
|
31
|
+
country?: string;
|
|
32
|
+
coordinates?: {
|
|
33
|
+
lat: number;
|
|
34
|
+
lng: number;
|
|
35
|
+
} | null;
|
|
36
|
+
}
|
|
37
|
+
/** Single media item attached to a listing (image, video, floor plan, …). */
|
|
38
|
+
interface ListingMedia {
|
|
39
|
+
id: string;
|
|
40
|
+
type: string;
|
|
41
|
+
category: string;
|
|
42
|
+
src: string;
|
|
43
|
+
alt?: string;
|
|
44
|
+
caption?: string;
|
|
45
|
+
order?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Minimum information needed to render a listing on a grid or card.
|
|
49
|
+
* Returned by `getListings`.
|
|
50
|
+
*
|
|
51
|
+
* `price` is `null` when the listing's `priceVisibility` is `"private"`
|
|
52
|
+
* (i.e. the price is hidden behind an explicit lead request) or when
|
|
53
|
+
* the underlying record has no price set. Always branch on `price ==
|
|
54
|
+
* null` rather than `!price` so genuine `0` values (rare but legal in
|
|
55
|
+
* promotional flows) don't get masked as "sob consulta".
|
|
56
|
+
*/
|
|
57
|
+
interface Listing {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
businessType: ListingBusinessType;
|
|
62
|
+
price: number | null;
|
|
63
|
+
priceVisibility: ListingPriceVisibility;
|
|
64
|
+
status: string;
|
|
65
|
+
featured: boolean;
|
|
66
|
+
property: ListingPropertySummary;
|
|
67
|
+
location: ListingLocation;
|
|
68
|
+
coverImage?: {
|
|
69
|
+
src: string;
|
|
70
|
+
alt: string;
|
|
71
|
+
} | null;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
updatedAt: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Full listing data including amenities, full media gallery, building
|
|
77
|
+
* details and richer property info. Returned by `getListing`.
|
|
78
|
+
*/
|
|
79
|
+
interface ListingDetail extends Listing {
|
|
80
|
+
amenities: string[];
|
|
81
|
+
tags: string[];
|
|
82
|
+
property: ListingPropertySummary & {
|
|
83
|
+
id: string;
|
|
84
|
+
builtArea?: number;
|
|
85
|
+
landArea?: number;
|
|
86
|
+
floor?: number;
|
|
87
|
+
totalFloors?: number;
|
|
88
|
+
yearBuilt?: number;
|
|
89
|
+
furnished?: boolean;
|
|
90
|
+
petFriendly?: boolean;
|
|
91
|
+
};
|
|
92
|
+
building?: {
|
|
93
|
+
name: string;
|
|
94
|
+
amenities: string[];
|
|
95
|
+
elevators?: number;
|
|
96
|
+
unitsPerFloor?: number;
|
|
97
|
+
totalUnits?: number;
|
|
98
|
+
} | null;
|
|
99
|
+
media: ListingMedia[];
|
|
100
|
+
}
|
|
101
|
+
/** Filter / pagination options for `getListings`. */
|
|
102
|
+
interface ListingFilters {
|
|
103
|
+
limit?: number;
|
|
104
|
+
offset?: number;
|
|
105
|
+
businessType?: ListingBusinessType;
|
|
106
|
+
propertyType?: string;
|
|
107
|
+
city?: string;
|
|
108
|
+
neighborhood?: string;
|
|
109
|
+
minPrice?: number;
|
|
110
|
+
maxPrice?: number;
|
|
111
|
+
}
|
|
112
|
+
/** Wrapped response from `getListings`. */
|
|
113
|
+
interface ListingsResult {
|
|
114
|
+
listings: Listing[];
|
|
115
|
+
total: number;
|
|
116
|
+
/** Echo of the `limit` query param actually applied (subject to a 100-item cap). */
|
|
117
|
+
limit?: number;
|
|
118
|
+
/** Echo of the `offset` query param actually applied. */
|
|
119
|
+
offset?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Raw Typesense search parameters accepted by `searchListings`. Mirrors
|
|
123
|
+
* the same body the underlying `/api/sites/{siteId}/search` endpoint
|
|
124
|
+
* forwards to Typesense (`q`, `query_by`, `filter_by`, `sort_by`,
|
|
125
|
+
* `per_page`, `page`, facets, etc.) — see the Typesense docs at
|
|
126
|
+
* https://typesense.org/docs/latest/api/search.html for the full list.
|
|
127
|
+
*
|
|
128
|
+
* This is the SDK's escape hatch when the friendly `getListings` API
|
|
129
|
+
* isn't expressive enough (faceted search, multi-field sort, custom
|
|
130
|
+
* grouping). It's an open dictionary on purpose; the only required
|
|
131
|
+
* field is `q`.
|
|
132
|
+
*/
|
|
133
|
+
interface SearchListingsParams {
|
|
134
|
+
q: string;
|
|
135
|
+
query_by?: string;
|
|
136
|
+
filter_by?: string;
|
|
137
|
+
sort_by?: string;
|
|
138
|
+
per_page?: number;
|
|
139
|
+
page?: number;
|
|
140
|
+
facet_by?: string;
|
|
141
|
+
group_by?: string;
|
|
142
|
+
group_limit?: number;
|
|
143
|
+
/** Any other Typesense param. The SDK passes the whole object through. */
|
|
144
|
+
[key: string]: unknown;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Raw Typesense response shape — what the backend returns from
|
|
148
|
+
* `multi_search`. Generic over the document type so power users can
|
|
149
|
+
* narrow it in their own codebases without losing access to `hits[].
|
|
150
|
+
* highlight` and `text_match`.
|
|
151
|
+
*/
|
|
152
|
+
interface SearchListingsResult<TDocument = Record<string, unknown>> {
|
|
153
|
+
found: number;
|
|
154
|
+
page: number;
|
|
155
|
+
search_time_ms: number;
|
|
156
|
+
hits: Array<{
|
|
157
|
+
document: TDocument;
|
|
158
|
+
highlight?: Record<string, unknown>;
|
|
159
|
+
text_match?: number;
|
|
160
|
+
}>;
|
|
161
|
+
/** Any other Typesense field. Stays open so we don't break on engine upgrades. */
|
|
162
|
+
[key: string]: unknown;
|
|
163
|
+
}
|
|
164
|
+
/** Public summary of a Garagem-managed site. Returned by `getSite`. */
|
|
165
|
+
interface Site {
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
domain: string | null;
|
|
169
|
+
tenantId: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* App Router caching hints passed straight through to the underlying
|
|
173
|
+
* `fetch` call. See https://nextjs.org/docs/app/api-reference/functions/fetch.
|
|
174
|
+
*
|
|
175
|
+
* Typed loosely so this works in plain Node, Edge, Cloudflare Workers
|
|
176
|
+
* and Bun runtimes without Next-specific types being mandatory.
|
|
177
|
+
*/
|
|
178
|
+
interface RequestNextOptions {
|
|
179
|
+
revalidate?: number | false;
|
|
180
|
+
tags?: string[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
184
|
+
type FetchLike = typeof fetch;
|
|
185
|
+
interface BaseOptions {
|
|
186
|
+
/** Garagem API base URL. Defaults to `https://app.garagem.ai`. */
|
|
187
|
+
baseUrl?: string;
|
|
188
|
+
/** Override the fetch implementation (testing, edge runtimes, retries). */
|
|
189
|
+
fetch?: FetchLike;
|
|
190
|
+
/**
|
|
191
|
+
* Next.js App Router caching hints. Ignored on runtimes that don't
|
|
192
|
+
* understand them.
|
|
193
|
+
*/
|
|
194
|
+
next?: RequestNextOptions;
|
|
195
|
+
}
|
|
196
|
+
interface GetListingsOptions extends BaseOptions {
|
|
197
|
+
siteId: string;
|
|
198
|
+
filters?: ListingFilters;
|
|
199
|
+
}
|
|
200
|
+
interface GetListingOptions extends BaseOptions {
|
|
201
|
+
siteId: string;
|
|
202
|
+
listingId: string;
|
|
203
|
+
}
|
|
204
|
+
interface GetSiteOptions extends BaseOptions {
|
|
205
|
+
/** Look up by site ID, or… */
|
|
206
|
+
siteId?: string;
|
|
207
|
+
/** …by domain. Exactly one of `siteId` / `domain` must be provided. */
|
|
208
|
+
domain?: string;
|
|
209
|
+
}
|
|
210
|
+
interface SearchListingsOptions extends BaseOptions {
|
|
211
|
+
siteId: string;
|
|
212
|
+
params: SearchListingsParams;
|
|
213
|
+
}
|
|
214
|
+
/** Error thrown when a fetcher hits a non-2xx response. */
|
|
215
|
+
declare class GaragemSdkError extends Error {
|
|
216
|
+
readonly status: number;
|
|
217
|
+
readonly url: string;
|
|
218
|
+
constructor(message: string, info: {
|
|
219
|
+
status: number;
|
|
220
|
+
url: string;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Fetch a paginated list of listings for a given site.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* const { listings } = await getListings({
|
|
228
|
+
* siteId: "abc",
|
|
229
|
+
* filters: { city: "São Paulo", limit: 24 },
|
|
230
|
+
* next: { revalidate: 300, tags: [`site:abc:listings`] },
|
|
231
|
+
* });
|
|
232
|
+
*/
|
|
233
|
+
declare function getListings(options: GetListingsOptions): Promise<ListingsResult>;
|
|
234
|
+
/**
|
|
235
|
+
* Fetch a single listing's full detail (amenities, gallery, building).
|
|
236
|
+
*/
|
|
237
|
+
declare function getListing(options: GetListingOptions): Promise<ListingDetail>;
|
|
238
|
+
/**
|
|
239
|
+
* Resolve a site's public profile by ID or by domain. Returns `null`
|
|
240
|
+
* when the site does not exist or the host is unrecognized.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* const site = await getSite({ domain: "imobiliariax.com.br" });
|
|
244
|
+
* if (!site) return notFound();
|
|
245
|
+
*/
|
|
246
|
+
declare function getSite(options: GetSiteOptions): Promise<Site | null>;
|
|
247
|
+
/**
|
|
248
|
+
* Advanced search escape hatch.
|
|
249
|
+
*
|
|
250
|
+
* Calls `POST /api/sites/{siteId}/search` directly and returns the raw
|
|
251
|
+
* Typesense response (`{ found, page, hits: [{ document, ... }], ... }`).
|
|
252
|
+
* Use when the friendly `getListings({ filters })` API isn't expressive
|
|
253
|
+
* enough — faceted search, multi-field sort, custom grouping, etc.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* const result = await searchListings({
|
|
257
|
+
* siteId: "abc",
|
|
258
|
+
* params: {
|
|
259
|
+
* q: "frente mar",
|
|
260
|
+
* query_by: "title,description,neighborhood",
|
|
261
|
+
* filter_by: "businessType:=sale && bedrooms:>=3",
|
|
262
|
+
* sort_by: "price:asc",
|
|
263
|
+
* per_page: 24,
|
|
264
|
+
* page: 1,
|
|
265
|
+
* facet_by: "neighborhood,propertyType",
|
|
266
|
+
* },
|
|
267
|
+
* });
|
|
268
|
+
* for (const hit of result.hits) {
|
|
269
|
+
* console.log(hit.document, hit.highlight);
|
|
270
|
+
* }
|
|
271
|
+
*/
|
|
272
|
+
declare function searchListings<TDocument = Record<string, unknown>>(options: SearchListingsOptions): Promise<SearchListingsResult<TDocument>>;
|
|
273
|
+
|
|
274
|
+
interface CreateGaragemClientOptions {
|
|
275
|
+
/** Garagem API base URL. Defaults to `https://app.garagem.ai`. */
|
|
276
|
+
baseUrl?: string;
|
|
277
|
+
/** Pre-bind a site so each call doesn't repeat it. */
|
|
278
|
+
siteId?: string;
|
|
279
|
+
/** Custom fetch implementation. */
|
|
280
|
+
fetch?: FetchLike;
|
|
281
|
+
/** Default Next.js caching hints applied to every request. */
|
|
282
|
+
next?: RequestNextOptions;
|
|
283
|
+
}
|
|
284
|
+
interface GaragemClient {
|
|
285
|
+
/** Configuration the client was created with. */
|
|
286
|
+
readonly options: Readonly<CreateGaragemClientOptions>;
|
|
287
|
+
/** List listings for the bound (or explicitly passed) site. */
|
|
288
|
+
getListings(args?: {
|
|
289
|
+
filters?: ListingFilters;
|
|
290
|
+
siteId?: string;
|
|
291
|
+
next?: RequestNextOptions;
|
|
292
|
+
}): Promise<ListingsResult>;
|
|
293
|
+
/** Fetch a single listing detail. */
|
|
294
|
+
getListing(args: {
|
|
295
|
+
listingId: string;
|
|
296
|
+
siteId?: string;
|
|
297
|
+
next?: RequestNextOptions;
|
|
298
|
+
}): Promise<ListingDetail>;
|
|
299
|
+
/** Resolve a site by ID or domain. */
|
|
300
|
+
getSite(args: {
|
|
301
|
+
siteId?: string;
|
|
302
|
+
domain?: string;
|
|
303
|
+
next?: RequestNextOptions;
|
|
304
|
+
}): Promise<Site | null>;
|
|
305
|
+
/**
|
|
306
|
+
* Advanced search — raw Typesense parameters, raw response. Use when
|
|
307
|
+
* the friendly `getListings({ filters })` API isn't expressive enough.
|
|
308
|
+
*/
|
|
309
|
+
searchListings<TDocument = Record<string, unknown>>(args: {
|
|
310
|
+
params: SearchListingsParams;
|
|
311
|
+
siteId?: string;
|
|
312
|
+
next?: RequestNextOptions;
|
|
313
|
+
}): Promise<SearchListingsResult<TDocument>>;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Bind base URL, fetch and site to a single client object. Useful when
|
|
317
|
+
* the same configuration is shared across many calls (RSC pages, API
|
|
318
|
+
* routes, scripts).
|
|
319
|
+
*
|
|
320
|
+
* The bare functions (`getListings`, `getListing`, `getSite`) are also
|
|
321
|
+
* exported for the no-client style.
|
|
322
|
+
*/
|
|
323
|
+
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
324
|
+
|
|
325
|
+
export { type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetListingOptions, type GetListingsOptions, type GetSiteOptions, type Listing, type ListingBusinessType, type ListingDetail, type ListingFilters, type ListingLocation, type ListingMedia, type ListingPriceVisibility, type ListingPropertySummary, type ListingsResult, type RequestNextOptions, type SearchListingsOptions, type SearchListingsParams, type SearchListingsResult, type Site, createGaragemClient, getListing, getListings, getSite, searchListings };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
GaragemSdkError: () => GaragemSdkError,
|
|
24
|
+
createGaragemClient: () => createGaragemClient,
|
|
25
|
+
getListing: () => getListing,
|
|
26
|
+
getListings: () => getListings,
|
|
27
|
+
getSite: () => getSite,
|
|
28
|
+
searchListings: () => searchListings
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
|
+
|
|
32
|
+
// src/internal/url.ts
|
|
33
|
+
var DEFAULT_BASE_URL = "https://app.garagem.ai";
|
|
34
|
+
function normalizeBaseUrl(baseUrl) {
|
|
35
|
+
const url = baseUrl ?? DEFAULT_BASE_URL;
|
|
36
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
37
|
+
}
|
|
38
|
+
function buildListingFiltersQuery(filters) {
|
|
39
|
+
const params = new URLSearchParams();
|
|
40
|
+
if (!filters) return params;
|
|
41
|
+
if (filters.limit != null) params.set("limit", String(filters.limit));
|
|
42
|
+
if (filters.offset != null) params.set("offset", String(filters.offset));
|
|
43
|
+
if (filters.businessType) params.set("businessType", filters.businessType);
|
|
44
|
+
if (filters.propertyType) params.set("propertyType", filters.propertyType);
|
|
45
|
+
if (filters.city) params.set("city", filters.city);
|
|
46
|
+
if (filters.neighborhood) params.set("neighborhood", filters.neighborhood);
|
|
47
|
+
if (filters.minPrice != null) params.set("minPrice", String(filters.minPrice));
|
|
48
|
+
if (filters.maxPrice != null) params.set("maxPrice", String(filters.maxPrice));
|
|
49
|
+
return params;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/fetchers.ts
|
|
53
|
+
async function callJson(url, init, fetchImpl) {
|
|
54
|
+
const response = await fetchImpl(url, init);
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
const text = await response.text().catch(() => "");
|
|
57
|
+
throw new GaragemSdkError(
|
|
58
|
+
`Garagem SDK: request failed (${response.status} ${response.statusText}) for ${url}${text ? ` \u2014 ${text.slice(0, 200)}` : ""}`,
|
|
59
|
+
{ status: response.status, url }
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return await response.json();
|
|
63
|
+
}
|
|
64
|
+
var GaragemSdkError = class extends Error {
|
|
65
|
+
status;
|
|
66
|
+
url;
|
|
67
|
+
constructor(message, info) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.name = "GaragemSdkError";
|
|
70
|
+
this.status = info.status;
|
|
71
|
+
this.url = info.url;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
async function getListings(options) {
|
|
75
|
+
const { siteId, filters, baseUrl, fetch: fetchImpl, next } = options;
|
|
76
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
77
|
+
const params = buildListingFiltersQuery(filters);
|
|
78
|
+
const qs = params.size > 0 ? `?${params.toString()}` : "";
|
|
79
|
+
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/listings${qs}`;
|
|
80
|
+
const data = await callJson(
|
|
81
|
+
url,
|
|
82
|
+
{ method: "GET", headers: { "Content-Type": "application/json" }, next },
|
|
83
|
+
fetchImpl ?? fetch
|
|
84
|
+
);
|
|
85
|
+
return {
|
|
86
|
+
listings: data.listings ?? [],
|
|
87
|
+
total: data.total ?? 0
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function getListing(options) {
|
|
91
|
+
const { siteId, listingId, baseUrl, fetch: fetchImpl, next } = options;
|
|
92
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
93
|
+
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/listings/${encodeURIComponent(
|
|
94
|
+
listingId
|
|
95
|
+
)}`;
|
|
96
|
+
return callJson(
|
|
97
|
+
url,
|
|
98
|
+
{ method: "GET", headers: { "Content-Type": "application/json" }, next },
|
|
99
|
+
fetchImpl ?? fetch
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
async function getSite(options) {
|
|
103
|
+
const { siteId, domain, baseUrl, fetch: fetchImpl, next } = options;
|
|
104
|
+
if (!siteId && !domain) {
|
|
105
|
+
throw new TypeError(
|
|
106
|
+
"getSite: provide exactly one of `siteId` or `domain`."
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (siteId && domain) {
|
|
110
|
+
throw new TypeError(
|
|
111
|
+
"getSite: provide only one of `siteId` or `domain`, not both."
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
115
|
+
const params = new URLSearchParams();
|
|
116
|
+
if (siteId) params.set("siteId", siteId);
|
|
117
|
+
if (domain) params.set("domain", domain);
|
|
118
|
+
const url = `${base}/api/sites/resolve?${params.toString()}`;
|
|
119
|
+
const f = fetchImpl ?? fetch;
|
|
120
|
+
const response = await f(url, {
|
|
121
|
+
method: "GET",
|
|
122
|
+
headers: { "Content-Type": "application/json" },
|
|
123
|
+
next
|
|
124
|
+
});
|
|
125
|
+
if (response.status === 404) return null;
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
throw new GaragemSdkError(
|
|
128
|
+
`Garagem SDK: getSite failed (${response.status}) for ${url}`,
|
|
129
|
+
{ status: response.status, url }
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const data = await response.json();
|
|
133
|
+
return {
|
|
134
|
+
id: data.id,
|
|
135
|
+
name: data.name,
|
|
136
|
+
domain: data.domain,
|
|
137
|
+
tenantId: data.tenantId
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async function searchListings(options) {
|
|
141
|
+
const { siteId, params, baseUrl, fetch: fetchImpl, next } = options;
|
|
142
|
+
if (!params || typeof params.q !== "string") {
|
|
143
|
+
throw new TypeError(
|
|
144
|
+
"Garagem SDK: searchListings requires `params.q` (Typesense query string)."
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
148
|
+
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search`;
|
|
149
|
+
return callJson(
|
|
150
|
+
url,
|
|
151
|
+
{
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: { "Content-Type": "application/json" },
|
|
154
|
+
body: JSON.stringify(params),
|
|
155
|
+
next
|
|
156
|
+
},
|
|
157
|
+
fetchImpl ?? fetch
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/client.ts
|
|
162
|
+
function createGaragemClient(options = {}) {
|
|
163
|
+
const resolveSiteId = (override) => {
|
|
164
|
+
const id = override ?? options.siteId;
|
|
165
|
+
if (!id) {
|
|
166
|
+
throw new TypeError(
|
|
167
|
+
"Garagem SDK: siteId is required \u2014 pass it to createGaragemClient or to the call itself."
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return id;
|
|
171
|
+
};
|
|
172
|
+
const mergeNext = (callNext) => {
|
|
173
|
+
if (!options.next && !callNext) return void 0;
|
|
174
|
+
return { ...options.next, ...callNext };
|
|
175
|
+
};
|
|
176
|
+
return {
|
|
177
|
+
options: Object.freeze({ ...options }),
|
|
178
|
+
async getListings({ filters, siteId, next } = {}) {
|
|
179
|
+
const opts = {
|
|
180
|
+
siteId: resolveSiteId(siteId)
|
|
181
|
+
};
|
|
182
|
+
if (filters !== void 0) opts.filters = filters;
|
|
183
|
+
if (options.baseUrl !== void 0) opts.baseUrl = options.baseUrl;
|
|
184
|
+
if (options.fetch !== void 0) opts.fetch = options.fetch;
|
|
185
|
+
const merged = mergeNext(next);
|
|
186
|
+
if (merged !== void 0) opts.next = merged;
|
|
187
|
+
return getListings(opts);
|
|
188
|
+
},
|
|
189
|
+
async getListing({ listingId, siteId, next }) {
|
|
190
|
+
const opts = {
|
|
191
|
+
siteId: resolveSiteId(siteId),
|
|
192
|
+
listingId
|
|
193
|
+
};
|
|
194
|
+
if (options.baseUrl !== void 0) opts.baseUrl = options.baseUrl;
|
|
195
|
+
if (options.fetch !== void 0) opts.fetch = options.fetch;
|
|
196
|
+
const merged = mergeNext(next);
|
|
197
|
+
if (merged !== void 0) opts.next = merged;
|
|
198
|
+
return getListing(opts);
|
|
199
|
+
},
|
|
200
|
+
async getSite({ siteId, domain, next }) {
|
|
201
|
+
const opts = {};
|
|
202
|
+
if (siteId !== void 0) opts.siteId = siteId;
|
|
203
|
+
if (domain !== void 0) opts.domain = domain;
|
|
204
|
+
if (options.baseUrl !== void 0) opts.baseUrl = options.baseUrl;
|
|
205
|
+
if (options.fetch !== void 0) opts.fetch = options.fetch;
|
|
206
|
+
const merged = mergeNext(next);
|
|
207
|
+
if (merged !== void 0) opts.next = merged;
|
|
208
|
+
return getSite(opts);
|
|
209
|
+
},
|
|
210
|
+
async searchListings({
|
|
211
|
+
params,
|
|
212
|
+
siteId,
|
|
213
|
+
next
|
|
214
|
+
}) {
|
|
215
|
+
const opts = {
|
|
216
|
+
siteId: resolveSiteId(siteId),
|
|
217
|
+
params
|
|
218
|
+
};
|
|
219
|
+
if (options.baseUrl !== void 0) opts.baseUrl = options.baseUrl;
|
|
220
|
+
if (options.fetch !== void 0) opts.fetch = options.fetch;
|
|
221
|
+
const merged = mergeNext(next);
|
|
222
|
+
if (merged !== void 0) opts.next = merged;
|
|
223
|
+
return searchListings(opts);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
228
|
+
0 && (module.exports = {
|
|
229
|
+
GaragemSdkError,
|
|
230
|
+
createGaragemClient,
|
|
231
|
+
getListing,
|
|
232
|
+
getListings,
|
|
233
|
+
getSite,
|
|
234
|
+
searchListings
|
|
235
|
+
});
|
|
236
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/internal/url.ts","../src/fetchers.ts","../src/client.ts"],"sourcesContent":["/**\n * @garagem-ai/site-sdk — typed, runtime-agnostic SDK for building\n * custom real estate sites against the Garagem platform.\n *\n * Two usage styles:\n *\n * 1. Bare functions (simple):\n *\n * import { getListings } from \"@garagem-ai/site-sdk\";\n * const { listings } = await getListings({ siteId: \"abc\" });\n *\n * 2. Client object (binds defaults):\n *\n * import { createGaragemClient } from \"@garagem-ai/site-sdk\";\n * const garagem = createGaragemClient({ siteId: \"abc\" });\n * const { listings } = await garagem.getListings();\n *\n * Works in Node, Edge runtimes, Cloudflare Workers, Bun, Deno and the\n * browser — anywhere `fetch` is available.\n */\n\nexport type {\n Listing,\n ListingBusinessType,\n ListingDetail,\n ListingFilters,\n ListingLocation,\n ListingMedia,\n ListingPriceVisibility,\n ListingPropertySummary,\n ListingsResult,\n RequestNextOptions,\n SearchListingsParams,\n SearchListingsResult,\n Site,\n} from \"./types\";\n\nexport {\n getListing,\n getListings,\n getSite,\n searchListings,\n GaragemSdkError,\n type FetchLike,\n type GetListingOptions,\n type GetListingsOptions,\n type GetSiteOptions,\n type SearchListingsOptions,\n} from \"./fetchers\";\n\nexport {\n createGaragemClient,\n type CreateGaragemClientOptions,\n type GaragemClient,\n} from \"./client\";\n","import type { ListingFilters } from \"../types\";\n\n/** Default base URL — the public Garagem API. Override via `baseUrl`. */\nexport const DEFAULT_BASE_URL = \"https://app.garagem.ai\";\n\nexport function normalizeBaseUrl(baseUrl: string | undefined): string {\n const url = baseUrl ?? DEFAULT_BASE_URL;\n return url.endsWith(\"/\") ? url.slice(0, -1) : url;\n}\n\n/**\n * Serialize listing filters into URLSearchParams. Skips undefined/null\n * values so the URL stays clean. Kept separate from the fetcher so it's\n * testable in isolation.\n */\nexport function buildListingFiltersQuery(\n filters: ListingFilters | undefined\n): URLSearchParams {\n const params = new URLSearchParams();\n if (!filters) return params;\n\n if (filters.limit != null) params.set(\"limit\", String(filters.limit));\n if (filters.offset != null) params.set(\"offset\", String(filters.offset));\n if (filters.businessType) params.set(\"businessType\", filters.businessType);\n if (filters.propertyType) params.set(\"propertyType\", filters.propertyType);\n if (filters.city) params.set(\"city\", filters.city);\n if (filters.neighborhood) params.set(\"neighborhood\", filters.neighborhood);\n if (filters.minPrice != null) params.set(\"minPrice\", String(filters.minPrice));\n if (filters.maxPrice != null) params.set(\"maxPrice\", String(filters.maxPrice));\n\n return params;\n}\n","import type {\n Listing,\n ListingDetail,\n ListingFilters,\n ListingsResult,\n RequestNextOptions,\n SearchListingsParams,\n SearchListingsResult,\n Site,\n} from \"./types\";\nimport {\n buildListingFiltersQuery,\n normalizeBaseUrl,\n} from \"./internal/url\";\n\n/** Custom fetch implementation. Defaults to the global `fetch`. */\nexport type FetchLike = typeof fetch;\n\ninterface BaseOptions {\n /** Garagem API base URL. Defaults to `https://app.garagem.ai`. */\n baseUrl?: string;\n /** Override the fetch implementation (testing, edge runtimes, retries). */\n fetch?: FetchLike;\n /**\n * Next.js App Router caching hints. Ignored on runtimes that don't\n * understand them.\n */\n next?: RequestNextOptions;\n}\n\nexport interface GetListingsOptions extends BaseOptions {\n siteId: string;\n filters?: ListingFilters;\n}\n\nexport interface GetListingOptions extends BaseOptions {\n siteId: string;\n listingId: string;\n}\n\nexport interface GetSiteOptions extends BaseOptions {\n /** Look up by site ID, or… */\n siteId?: string;\n /** …by domain. Exactly one of `siteId` / `domain` must be provided. */\n domain?: string;\n}\n\nexport interface SearchListingsOptions extends BaseOptions {\n siteId: string;\n params: SearchListingsParams;\n}\n\ninterface FetchInit extends RequestInit {\n /**\n * Next.js attaches this on `fetch` (App Router). Adding it here keeps\n * `RequestInit` typed without forcing consumers to install Next types.\n */\n next?: RequestNextOptions;\n}\n\nasync function callJson<T>(\n url: string,\n init: FetchInit,\n fetchImpl: FetchLike\n): Promise<T> {\n const response = await fetchImpl(url, init);\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new GaragemSdkError(\n `Garagem SDK: request failed (${response.status} ${response.statusText}) for ${url}${\n text ? ` — ${text.slice(0, 200)}` : \"\"\n }`,\n { status: response.status, url }\n );\n }\n return (await response.json()) as T;\n}\n\n/** Error thrown when a fetcher hits a non-2xx response. */\nexport class GaragemSdkError extends Error {\n readonly status: number;\n readonly url: string;\n constructor(message: string, info: { status: number; url: string }) {\n super(message);\n this.name = \"GaragemSdkError\";\n this.status = info.status;\n this.url = info.url;\n }\n}\n\n/**\n * Fetch a paginated list of listings for a given site.\n *\n * @example\n * const { listings } = await getListings({\n * siteId: \"abc\",\n * filters: { city: \"São Paulo\", limit: 24 },\n * next: { revalidate: 300, tags: [`site:abc:listings`] },\n * });\n */\nexport async function getListings(\n options: GetListingsOptions\n): Promise<ListingsResult> {\n const { siteId, filters, baseUrl, fetch: fetchImpl, next } = options;\n const base = normalizeBaseUrl(baseUrl);\n const params = buildListingFiltersQuery(filters);\n const qs = params.size > 0 ? `?${params.toString()}` : \"\";\n const url = `${base}/api/sites/${encodeURIComponent(siteId)}/listings${qs}`;\n\n const data = await callJson<{ listings?: Listing[]; total?: number }>(\n url,\n { method: \"GET\", headers: { \"Content-Type\": \"application/json\" }, next },\n fetchImpl ?? fetch\n );\n return {\n listings: data.listings ?? [],\n total: data.total ?? 0,\n };\n}\n\n/**\n * Fetch a single listing's full detail (amenities, gallery, building).\n */\nexport async function getListing(\n options: GetListingOptions\n): Promise<ListingDetail> {\n const { siteId, listingId, baseUrl, fetch: fetchImpl, next } = options;\n const base = normalizeBaseUrl(baseUrl);\n const url = `${base}/api/sites/${encodeURIComponent(siteId)}/listings/${encodeURIComponent(\n listingId\n )}`;\n\n return callJson<ListingDetail>(\n url,\n { method: \"GET\", headers: { \"Content-Type\": \"application/json\" }, next },\n fetchImpl ?? fetch\n );\n}\n\n/**\n * Resolve a site's public profile by ID or by domain. Returns `null`\n * when the site does not exist or the host is unrecognized.\n *\n * @example\n * const site = await getSite({ domain: \"imobiliariax.com.br\" });\n * if (!site) return notFound();\n */\nexport async function getSite(\n options: GetSiteOptions\n): Promise<Site | null> {\n const { siteId, domain, baseUrl, fetch: fetchImpl, next } = options;\n if (!siteId && !domain) {\n throw new TypeError(\n \"getSite: provide exactly one of `siteId` or `domain`.\"\n );\n }\n if (siteId && domain) {\n throw new TypeError(\n \"getSite: provide only one of `siteId` or `domain`, not both.\"\n );\n }\n\n const base = normalizeBaseUrl(baseUrl);\n const params = new URLSearchParams();\n if (siteId) params.set(\"siteId\", siteId);\n if (domain) params.set(\"domain\", domain);\n const url = `${base}/api/sites/resolve?${params.toString()}`;\n\n const f = fetchImpl ?? fetch;\n const response = await f(url, {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n next,\n } as FetchInit);\n if (response.status === 404) return null;\n if (!response.ok) {\n throw new GaragemSdkError(\n `Garagem SDK: getSite failed (${response.status}) for ${url}`,\n { status: response.status, url }\n );\n }\n const data = (await response.json()) as {\n id: string;\n name: string;\n domain: string | null;\n tenantId: string;\n };\n return {\n id: data.id,\n name: data.name,\n domain: data.domain,\n tenantId: data.tenantId,\n };\n}\n\n/**\n * Advanced search escape hatch.\n *\n * Calls `POST /api/sites/{siteId}/search` directly and returns the raw\n * Typesense response (`{ found, page, hits: [{ document, ... }], ... }`).\n * Use when the friendly `getListings({ filters })` API isn't expressive\n * enough — faceted search, multi-field sort, custom grouping, etc.\n *\n * @example\n * const result = await searchListings({\n * siteId: \"abc\",\n * params: {\n * q: \"frente mar\",\n * query_by: \"title,description,neighborhood\",\n * filter_by: \"businessType:=sale && bedrooms:>=3\",\n * sort_by: \"price:asc\",\n * per_page: 24,\n * page: 1,\n * facet_by: \"neighborhood,propertyType\",\n * },\n * });\n * for (const hit of result.hits) {\n * console.log(hit.document, hit.highlight);\n * }\n */\nexport async function searchListings<\n TDocument = Record<string, unknown>,\n>(\n options: SearchListingsOptions\n): Promise<SearchListingsResult<TDocument>> {\n const { siteId, params, baseUrl, fetch: fetchImpl, next } = options;\n if (!params || typeof params.q !== \"string\") {\n throw new TypeError(\n \"Garagem SDK: searchListings requires `params.q` (Typesense query string).\"\n );\n }\n const base = normalizeBaseUrl(baseUrl);\n const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search`;\n return callJson<SearchListingsResult<TDocument>>(\n url,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(params),\n next,\n },\n fetchImpl ?? fetch\n );\n}\n","import {\n getListing,\n getListings,\n getSite,\n searchListings,\n type FetchLike,\n type GetListingOptions,\n type GetListingsOptions,\n type GetSiteOptions,\n type SearchListingsOptions,\n} from \"./fetchers\";\nimport type {\n ListingDetail,\n ListingFilters,\n ListingsResult,\n RequestNextOptions,\n SearchListingsParams,\n SearchListingsResult,\n Site,\n} from \"./types\";\n\nexport interface CreateGaragemClientOptions {\n /** Garagem API base URL. Defaults to `https://app.garagem.ai`. */\n baseUrl?: string;\n /** Pre-bind a site so each call doesn't repeat it. */\n siteId?: string;\n /** Custom fetch implementation. */\n fetch?: FetchLike;\n /** Default Next.js caching hints applied to every request. */\n next?: RequestNextOptions;\n}\n\nexport interface GaragemClient {\n /** Configuration the client was created with. */\n readonly options: Readonly<CreateGaragemClientOptions>;\n /** List listings for the bound (or explicitly passed) site. */\n getListings(\n args?: { filters?: ListingFilters; siteId?: string; next?: RequestNextOptions }\n ): Promise<ListingsResult>;\n /** Fetch a single listing detail. */\n getListing(\n args: { listingId: string; siteId?: string; next?: RequestNextOptions }\n ): Promise<ListingDetail>;\n /** Resolve a site by ID or domain. */\n getSite(\n args: { siteId?: string; domain?: string; next?: RequestNextOptions }\n ): Promise<Site | null>;\n /**\n * Advanced search — raw Typesense parameters, raw response. Use when\n * the friendly `getListings({ filters })` API isn't expressive enough.\n */\n searchListings<TDocument = Record<string, unknown>>(\n args: {\n params: SearchListingsParams;\n siteId?: string;\n next?: RequestNextOptions;\n }\n ): Promise<SearchListingsResult<TDocument>>;\n}\n\n/**\n * Bind base URL, fetch and site to a single client object. Useful when\n * the same configuration is shared across many calls (RSC pages, API\n * routes, scripts).\n *\n * The bare functions (`getListings`, `getListing`, `getSite`) are also\n * exported for the no-client style.\n */\nexport function createGaragemClient(\n options: CreateGaragemClientOptions = {}\n): GaragemClient {\n const resolveSiteId = (override?: string): string => {\n const id = override ?? options.siteId;\n if (!id) {\n throw new TypeError(\n \"Garagem SDK: siteId is required — pass it to createGaragemClient or to the call itself.\"\n );\n }\n return id;\n };\n const mergeNext = (\n callNext?: RequestNextOptions\n ): RequestNextOptions | undefined => {\n if (!options.next && !callNext) return undefined;\n return { ...options.next, ...callNext };\n };\n\n // All methods are `async` so validation failures (e.g. missing siteId)\n // surface as promise rejections rather than synchronous throws. SDK\n // callers always `await` — this keeps error handling predictable.\n return {\n options: Object.freeze({ ...options }),\n async getListings({ filters, siteId, next } = {}) {\n const opts: GetListingsOptions = {\n siteId: resolveSiteId(siteId),\n };\n if (filters !== undefined) opts.filters = filters;\n if (options.baseUrl !== undefined) opts.baseUrl = options.baseUrl;\n if (options.fetch !== undefined) opts.fetch = options.fetch;\n const merged = mergeNext(next);\n if (merged !== undefined) opts.next = merged;\n return getListings(opts);\n },\n async getListing({ listingId, siteId, next }) {\n const opts: GetListingOptions = {\n siteId: resolveSiteId(siteId),\n listingId,\n };\n if (options.baseUrl !== undefined) opts.baseUrl = options.baseUrl;\n if (options.fetch !== undefined) opts.fetch = options.fetch;\n const merged = mergeNext(next);\n if (merged !== undefined) opts.next = merged;\n return getListing(opts);\n },\n async getSite({ siteId, domain, next }) {\n const opts: GetSiteOptions = {};\n if (siteId !== undefined) opts.siteId = siteId;\n if (domain !== undefined) opts.domain = domain;\n if (options.baseUrl !== undefined) opts.baseUrl = options.baseUrl;\n if (options.fetch !== undefined) opts.fetch = options.fetch;\n const merged = mergeNext(next);\n if (merged !== undefined) opts.next = merged;\n return getSite(opts);\n },\n async searchListings<TDocument = Record<string, unknown>>({\n params,\n siteId,\n next,\n }: {\n params: SearchListingsParams;\n siteId?: string;\n next?: RequestNextOptions;\n }) {\n const opts: SearchListingsOptions = {\n siteId: resolveSiteId(siteId),\n params,\n };\n if (options.baseUrl !== undefined) opts.baseUrl = options.baseUrl;\n if (options.fetch !== undefined) opts.fetch = options.fetch;\n const merged = mergeNext(next);\n if (merged !== undefined) opts.next = merged;\n return searchListings<TDocument>(opts);\n },\n };\n}\n"],"mappings":";;;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