htag-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/dist/index.cjs ADDED
@@ -0,0 +1,510 @@
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
+ AddressClient: () => AddressClient,
24
+ AuthenticationError: () => AuthenticationError,
25
+ HtAgApiClient: () => HtAgApiClient,
26
+ HtAgError: () => HtAgError,
27
+ MarketsClient: () => MarketsClient,
28
+ PropertyClient: () => PropertyClient,
29
+ RateLimitError: () => RateLimitError,
30
+ ServerError: () => ServerError,
31
+ TrendsClient: () => TrendsClient,
32
+ ValidationError: () => ValidationError
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+
36
+ // src/errors.ts
37
+ var HtAgError = class extends Error {
38
+ /** HTTP status code, if available. */
39
+ status;
40
+ /** Raw response body, if available. */
41
+ body;
42
+ /** The request URL that caused the error. */
43
+ url;
44
+ constructor(message, options) {
45
+ super(message, { cause: options?.cause });
46
+ this.name = "HtAgError";
47
+ this.status = options?.status;
48
+ this.body = options?.body;
49
+ this.url = options?.url;
50
+ }
51
+ };
52
+ var AuthenticationError = class extends HtAgError {
53
+ constructor(options) {
54
+ super(
55
+ `Authentication failed (HTTP ${options.status}). Check your API key.`,
56
+ options
57
+ );
58
+ this.name = "AuthenticationError";
59
+ }
60
+ };
61
+ var RateLimitError = class extends HtAgError {
62
+ constructor(options) {
63
+ super("Rate limit exceeded. Please retry after a short delay.", {
64
+ status: 429,
65
+ ...options
66
+ });
67
+ this.name = "RateLimitError";
68
+ }
69
+ };
70
+ var ValidationError = class extends HtAgError {
71
+ constructor(options) {
72
+ const detail = extractDetail(options.body);
73
+ super(
74
+ detail ? `Validation error (HTTP ${options.status}): ${detail}` : `Validation error (HTTP ${options.status})`,
75
+ options
76
+ );
77
+ this.name = "ValidationError";
78
+ }
79
+ };
80
+ var ServerError = class extends HtAgError {
81
+ constructor(options) {
82
+ super(`Server error (HTTP ${options.status})`, options);
83
+ this.name = "ServerError";
84
+ }
85
+ };
86
+ function extractDetail(body) {
87
+ if (body && typeof body === "object" && "detail" in body) {
88
+ const detail = body.detail;
89
+ if (typeof detail === "string") return detail;
90
+ if (Array.isArray(detail)) {
91
+ return detail.map((d) => {
92
+ if (typeof d === "string") return d;
93
+ if (d && typeof d === "object" && "msg" in d) return String(d.msg);
94
+ return JSON.stringify(d);
95
+ }).join("; ");
96
+ }
97
+ return JSON.stringify(detail);
98
+ }
99
+ return void 0;
100
+ }
101
+
102
+ // src/http.ts
103
+ function toSnakeCase(str) {
104
+ return str.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
105
+ }
106
+ function buildQueryString(params) {
107
+ const parts = [];
108
+ for (const [key, value] of Object.entries(params)) {
109
+ if (key === "signal") continue;
110
+ if (value === void 0 || value === null) continue;
111
+ const snakeKey = toSnakeCase(key);
112
+ if (Array.isArray(value)) {
113
+ if (value.length > 0) {
114
+ parts.push(
115
+ `${encodeURIComponent(snakeKey)}=${encodeURIComponent(value.join(","))}`
116
+ );
117
+ }
118
+ } else {
119
+ parts.push(
120
+ `${encodeURIComponent(snakeKey)}=${encodeURIComponent(String(value))}`
121
+ );
122
+ }
123
+ }
124
+ return parts.length > 0 ? `?${parts.join("&")}` : "";
125
+ }
126
+ function isRetryable(status) {
127
+ return status === 429 || status >= 500;
128
+ }
129
+ function sleep(ms) {
130
+ return new Promise((resolve) => setTimeout(resolve, ms));
131
+ }
132
+ async function parseBody(response) {
133
+ const contentType = response.headers.get("content-type") ?? "";
134
+ if (contentType.includes("application/json")) {
135
+ try {
136
+ return await response.json();
137
+ } catch {
138
+ return await response.text();
139
+ }
140
+ }
141
+ return await response.text();
142
+ }
143
+ function throwForStatus(status, body, url) {
144
+ if (status === 401 || status === 403) {
145
+ throw new AuthenticationError({ status, body, url });
146
+ }
147
+ if (status === 429) {
148
+ throw new RateLimitError({ body, url });
149
+ }
150
+ if (status === 400 || status === 422) {
151
+ throw new ValidationError({ status, body, url });
152
+ }
153
+ if (status >= 500) {
154
+ throw new ServerError({ status, body, url });
155
+ }
156
+ throw new HtAgError(`HTTP ${status}`, { status, body, url });
157
+ }
158
+ var HttpClient = class {
159
+ constructor(config) {
160
+ this.config = config;
161
+ }
162
+ /**
163
+ * Execute a GET request against the public API base.
164
+ */
165
+ async get(path, options) {
166
+ return this.request("GET", this.config.publicBaseUrl + path, void 0, options);
167
+ }
168
+ /**
169
+ * Execute a POST request against the public API base.
170
+ */
171
+ async post(path, body, options) {
172
+ return this.request("POST", this.config.publicBaseUrl + path, body, options);
173
+ }
174
+ /**
175
+ * Execute a GET request against the internal API base.
176
+ */
177
+ async internalGet(path, options) {
178
+ return this.request("GET", this.config.internalBaseUrl + path, void 0, options);
179
+ }
180
+ /**
181
+ * Execute a POST request against the internal API base.
182
+ */
183
+ async internalPost(path, body, options) {
184
+ return this.request("POST", this.config.internalBaseUrl + path, body, options);
185
+ }
186
+ // -----------------------------------------------------------------------
187
+ // Core request implementation with retries and exponential backoff
188
+ // -----------------------------------------------------------------------
189
+ async request(method, url, body, options) {
190
+ const headers = {
191
+ "x-api-key": this.config.apiKey,
192
+ "accept": "application/json"
193
+ };
194
+ if (body !== void 0) {
195
+ headers["content-type"] = "application/json";
196
+ }
197
+ let lastError;
198
+ for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
199
+ if (attempt > 0) {
200
+ const base = this.config.retryBaseDelay * Math.pow(2, attempt - 1);
201
+ const jitter = Math.random() * base * 0.5;
202
+ await sleep(base + jitter);
203
+ }
204
+ const controller = new AbortController();
205
+ let timeoutId;
206
+ const cleanup = () => {
207
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
208
+ };
209
+ if (options?.signal) {
210
+ if (options.signal.aborted) {
211
+ throw new HtAgError("Request aborted", {
212
+ url,
213
+ cause: options.signal.reason
214
+ });
215
+ }
216
+ options.signal.addEventListener("abort", () => controller.abort(options.signal.reason), {
217
+ once: true
218
+ });
219
+ }
220
+ timeoutId = setTimeout(
221
+ () => controller.abort(new Error("Request timed out")),
222
+ this.config.timeout
223
+ );
224
+ try {
225
+ const response = await fetch(url, {
226
+ method,
227
+ headers,
228
+ body: body !== void 0 ? JSON.stringify(body) : void 0,
229
+ signal: controller.signal
230
+ });
231
+ cleanup();
232
+ if (response.ok) {
233
+ return await parseBody(response);
234
+ }
235
+ const responseBody = await parseBody(response);
236
+ if (isRetryable(response.status) && attempt < this.config.maxRetries) {
237
+ lastError = new HtAgError(`HTTP ${response.status}`, {
238
+ status: response.status,
239
+ body: responseBody,
240
+ url
241
+ });
242
+ continue;
243
+ }
244
+ throwForStatus(response.status, responseBody, url);
245
+ } catch (err) {
246
+ cleanup();
247
+ if (err instanceof HtAgError) {
248
+ throw err;
249
+ }
250
+ if (err instanceof DOMException && err.name === "AbortError") {
251
+ if (options?.signal?.aborted) {
252
+ throw new HtAgError("Request aborted", { url, cause: err });
253
+ }
254
+ throw new HtAgError("Request timed out", { url, cause: err });
255
+ }
256
+ if (attempt < this.config.maxRetries) {
257
+ lastError = err instanceof Error ? err : new Error(String(err));
258
+ continue;
259
+ }
260
+ throw new HtAgError(
261
+ `Network error: ${err instanceof Error ? err.message : String(err)}`,
262
+ { url, cause: err }
263
+ );
264
+ }
265
+ }
266
+ throw lastError ?? new HtAgError("Request failed after retries", { url });
267
+ }
268
+ };
269
+
270
+ // src/address/client.ts
271
+ var AddressClient = class {
272
+ /** @internal */
273
+ constructor(http) {
274
+ this.http = http;
275
+ }
276
+ /**
277
+ * Search for addresses matching a free-text query.
278
+ *
279
+ * `GET /v1/address/search`
280
+ */
281
+ async search(params) {
282
+ const { signal, ...query } = params;
283
+ const qs = buildQueryString(query);
284
+ return this.http.get(`/v1/address/search${qs}`, { signal });
285
+ }
286
+ /**
287
+ * Retrieve detailed insights for one or more addresses.
288
+ *
289
+ * `GET /v1/address/insights`
290
+ */
291
+ async insights(params) {
292
+ const { signal, ...query } = params;
293
+ const qs = buildQueryString(query);
294
+ return this.http.get(`/v1/address/insights${qs}`, { signal });
295
+ }
296
+ /**
297
+ * Standardise a batch of raw address strings into structured records.
298
+ *
299
+ * `POST /v1/address/standardise`
300
+ */
301
+ async standardise(params) {
302
+ const { signal, addresses } = params;
303
+ return this.http.post(
304
+ "/v1/address/standardise",
305
+ { addresses },
306
+ { signal }
307
+ );
308
+ }
309
+ };
310
+
311
+ // src/property/client.ts
312
+ var PropertyClient = class {
313
+ /** @internal */
314
+ constructor(http) {
315
+ this.http = http;
316
+ }
317
+ /**
318
+ * Search for recently sold properties near a location.
319
+ *
320
+ * `GET /v1/property/sold/search`
321
+ */
322
+ async soldSearch(params) {
323
+ const { signal, ...query } = params;
324
+ const qs = buildQueryString(query);
325
+ return this.http.get(`/v1/property/sold/search${qs}`, { signal });
326
+ }
327
+ };
328
+
329
+ // src/markets/trends.ts
330
+ var TrendsClient = class {
331
+ /** @internal */
332
+ constructor(http) {
333
+ this.http = http;
334
+ }
335
+ /**
336
+ * Price history trends.
337
+ *
338
+ * `GET /internal-api/v1/markets/trends/price`
339
+ */
340
+ async price(params) {
341
+ return this.trend("price", params);
342
+ }
343
+ /**
344
+ * Rent history trends.
345
+ *
346
+ * `GET /internal-api/v1/markets/trends/rent`
347
+ */
348
+ async rent(params) {
349
+ return this.trend("rent", params);
350
+ }
351
+ /**
352
+ * Yield history trends.
353
+ *
354
+ * `GET /internal-api/v1/markets/trends/yield`
355
+ */
356
+ async yieldHistory(params) {
357
+ return this.trend("yield", params);
358
+ }
359
+ /**
360
+ * Supply and demand (monthly frequency).
361
+ *
362
+ * `GET /internal-api/v1/markets/trends/supply-demand`
363
+ */
364
+ async supplyDemand(params) {
365
+ return this.trend("supply-demand", params);
366
+ }
367
+ /**
368
+ * Search interest index (quarterly frequency).
369
+ *
370
+ * `GET /internal-api/v1/markets/trends/search-index`
371
+ */
372
+ async searchIndex(params) {
373
+ return this.trend("search-index", params);
374
+ }
375
+ /**
376
+ * Hold period (yearly frequency).
377
+ *
378
+ * `GET /internal-api/v1/markets/trends/hold-period`
379
+ */
380
+ async holdPeriod(params) {
381
+ return this.trend("hold-period", params);
382
+ }
383
+ /**
384
+ * Performance essentials.
385
+ *
386
+ * `GET /internal-api/v1/markets/trends/performance`
387
+ */
388
+ async performance(params) {
389
+ return this.trend("performance", params);
390
+ }
391
+ /**
392
+ * Growth rate cycle.
393
+ *
394
+ * `GET /internal-api/v1/markets/trends/growth-rates`
395
+ */
396
+ async growthRates(params) {
397
+ return this.trend("growth-rates", params);
398
+ }
399
+ /**
400
+ * Demand profile breakdown.
401
+ *
402
+ * `GET /internal-api/v1/markets/trends/demand-profile`
403
+ */
404
+ async demandProfile(params) {
405
+ return this.trend("demand-profile", params);
406
+ }
407
+ // -----------------------------------------------------------------------
408
+ // Shared implementation
409
+ // -----------------------------------------------------------------------
410
+ async trend(metric, params) {
411
+ const { signal, ...query } = params;
412
+ const qs = buildQueryString(query);
413
+ return this.http.internalGet(
414
+ `/internal-api/v1/markets/trends/${metric}${qs}`,
415
+ { signal }
416
+ );
417
+ }
418
+ };
419
+
420
+ // src/markets/client.ts
421
+ var MarketsClient = class {
422
+ /** @internal */
423
+ constructor(http) {
424
+ this.http = http;
425
+ this.trends = new TrendsClient(http);
426
+ }
427
+ /** Sub-client for time-series trend endpoints. */
428
+ trends;
429
+ /**
430
+ * Retrieve market snapshot data with optional filters.
431
+ *
432
+ * `GET /internal-api/v1/markets/snapshots`
433
+ */
434
+ async snapshots(params) {
435
+ const { signal, ...query } = params;
436
+ const qs = buildQueryString(query);
437
+ return this.http.internalGet(
438
+ `/internal-api/v1/markets/snapshots${qs}`,
439
+ { signal }
440
+ );
441
+ }
442
+ /**
443
+ * Advanced market query with logical filter expressions.
444
+ *
445
+ * `POST /internal-api/v1/markets/query`
446
+ */
447
+ async query(body, options) {
448
+ return this.http.internalPost(
449
+ "/internal-api/v1/markets/query",
450
+ body,
451
+ options
452
+ );
453
+ }
454
+ };
455
+
456
+ // src/client.ts
457
+ var DEFAULT_MAX_RETRIES = 3;
458
+ var DEFAULT_RETRY_BASE_DELAY = 500;
459
+ var DEFAULT_TIMEOUT = 3e4;
460
+ function resolveBaseUrls(options) {
461
+ if (options.baseUrl) {
462
+ const base2 = options.baseUrl.replace(/\/+$/, "");
463
+ return { publicBaseUrl: base2, internalBaseUrl: base2 };
464
+ }
465
+ const env = options.environment ?? "prod";
466
+ const base = `https://api.${env}.htagai.com`;
467
+ return { publicBaseUrl: base, internalBaseUrl: base };
468
+ }
469
+ var HtAgApiClient = class {
470
+ /** Address search, insights and standardisation. */
471
+ address;
472
+ /** Sold property search. */
473
+ property;
474
+ /** Market snapshots, advanced queries and time-series trends. */
475
+ markets;
476
+ constructor(options) {
477
+ if (!options.apiKey) {
478
+ throw new Error(
479
+ "HtAgApiClient requires an apiKey. Pass it in the constructor options."
480
+ );
481
+ }
482
+ const { publicBaseUrl, internalBaseUrl } = resolveBaseUrls(options);
483
+ const config = {
484
+ apiKey: options.apiKey,
485
+ publicBaseUrl,
486
+ internalBaseUrl,
487
+ maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
488
+ retryBaseDelay: options.retryBaseDelay ?? DEFAULT_RETRY_BASE_DELAY,
489
+ timeout: options.timeout ?? DEFAULT_TIMEOUT
490
+ };
491
+ const http = new HttpClient(config);
492
+ this.address = new AddressClient(http);
493
+ this.property = new PropertyClient(http);
494
+ this.markets = new MarketsClient(http);
495
+ }
496
+ };
497
+ // Annotate the CommonJS export names for ESM import in node:
498
+ 0 && (module.exports = {
499
+ AddressClient,
500
+ AuthenticationError,
501
+ HtAgApiClient,
502
+ HtAgError,
503
+ MarketsClient,
504
+ PropertyClient,
505
+ RateLimitError,
506
+ ServerError,
507
+ TrendsClient,
508
+ ValidationError
509
+ });
510
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/address/client.ts","../src/property/client.ts","../src/markets/trends.ts","../src/markets/client.ts","../src/client.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @htag/sdk — Official TypeScript SDK for HtAG Location Intelligence APIs\n// ---------------------------------------------------------------------------\n\n// Main client\nexport { HtAgApiClient } from './client.js';\n\n// Configuration types\nexport type {\n HtAgClientOptions,\n ResolvedConfig,\n BaseResponse,\n RequestOptions,\n LevelEnum,\n PropertyTypeEnum,\n} from './types.js';\n\n// Error classes\nexport {\n HtAgError,\n AuthenticationError,\n RateLimitError,\n ValidationError,\n ServerError,\n} from './errors.js';\n\n// Address domain\nexport { AddressClient } from './address/index.js';\nexport type {\n AddressRecord,\n AddressSearchResult,\n AddressSearchParams,\n AddressSearchResponse,\n AddressInsightsParams,\n AddressInsightsResponse,\n BatchStandardiseParams,\n BatchStandardiseResponse,\n StandardisedAddress,\n} from './address/index.js';\n\n// Property domain\nexport { PropertyClient } from './property/index.js';\nexport type {\n SoldPropertyRecord,\n SoldSearchParams,\n SoldPropertiesResponse,\n} from './property/index.js';\n\n// Markets domain\nexport { MarketsClient, TrendsClient } from './markets/index.js';\nexport type {\n MarketSnapshot,\n PriceHistoryOut,\n RentHistoryOut,\n YieldHistoryOut,\n FSDMonthlyOut,\n FSDQuarterlyOut,\n FSDYearlyOut,\n EssentialsOut,\n GRCOut,\n DemandProfileOut,\n LogicNode,\n AdvancedSearchBody,\n SnapshotsParams,\n MarketQueryParams,\n TrendsParams,\n SnapshotsResponse,\n MarketQueryResponse,\n PriceResponse,\n RentResponse,\n YieldResponse,\n SupplyDemandResponse,\n SearchIndexResponse,\n HoldPeriodResponse,\n PerformanceResponse,\n GrowthRatesResponse,\n DemandProfileResponse,\n} from './markets/index.js';\n","/**\n * Base error class for all HtAG SDK errors.\n */\nexport class HtAgError extends Error {\n /** HTTP status code, if available. */\n readonly status: number | undefined;\n\n /** Raw response body, if available. */\n readonly body: unknown;\n\n /** The request URL that caused the error. */\n readonly url: string | undefined;\n\n constructor(\n message: string,\n options?: {\n status?: number;\n body?: unknown;\n url?: string;\n cause?: unknown;\n },\n ) {\n super(message, { cause: options?.cause });\n this.name = 'HtAgError';\n this.status = options?.status;\n this.body = options?.body;\n this.url = options?.url;\n }\n}\n\n/**\n * Thrown when the server returns 401 or 403.\n */\nexport class AuthenticationError extends HtAgError {\n constructor(options: { status: number; body: unknown; url: string }) {\n super(\n `Authentication failed (HTTP ${options.status}). Check your API key.`,\n options,\n );\n this.name = 'AuthenticationError';\n }\n}\n\n/**\n * Thrown when the server returns 429 after exhausting all retries.\n */\nexport class RateLimitError extends HtAgError {\n constructor(options: { body: unknown; url: string }) {\n super('Rate limit exceeded. Please retry after a short delay.', {\n status: 429,\n ...options,\n });\n this.name = 'RateLimitError';\n }\n}\n\n/**\n * Thrown when the server returns 400 or 422.\n */\nexport class ValidationError extends HtAgError {\n constructor(options: { status: number; body: unknown; url: string }) {\n const detail = extractDetail(options.body);\n super(\n detail\n ? `Validation error (HTTP ${options.status}): ${detail}`\n : `Validation error (HTTP ${options.status})`,\n options,\n );\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Thrown when the server returns a 5xx status after exhausting all retries.\n */\nexport class ServerError extends HtAgError {\n constructor(options: { status: number; body: unknown; url: string }) {\n super(`Server error (HTTP ${options.status})`, options);\n this.name = 'ServerError';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction extractDetail(body: unknown): string | undefined {\n if (body && typeof body === 'object' && 'detail' in body) {\n const detail = (body as Record<string, unknown>).detail;\n if (typeof detail === 'string') return detail;\n if (Array.isArray(detail)) {\n return detail\n .map((d) => {\n if (typeof d === 'string') return d;\n if (d && typeof d === 'object' && 'msg' in d) return String(d.msg);\n return JSON.stringify(d);\n })\n .join('; ');\n }\n return JSON.stringify(detail);\n }\n return undefined;\n}\n","import type { ResolvedConfig, RequestOptions } from './types.js';\nimport {\n HtAgError,\n AuthenticationError,\n RateLimitError,\n ValidationError,\n ServerError,\n} from './errors.js';\n\n// ---------------------------------------------------------------------------\n// camelCase -> snake_case conversion\n// ---------------------------------------------------------------------------\n\n/**\n * Convert a camelCase string to snake_case.\n *\n * Handles sequences of uppercase letters correctly:\n * - \"areaId\" -> \"area_id\"\n * - \"periodEndMin\" -> \"period_end_min\"\n * - \"IRSD\" -> \"irsd\" (all-caps treated as one token)\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .toLowerCase();\n}\n\n// ---------------------------------------------------------------------------\n// Query-string builder\n// ---------------------------------------------------------------------------\n\n/**\n * Build a URL query string from a params object, converting camelCase keys\n * to snake_case. Arrays are joined with commas. `undefined` and `null` values\n * are omitted.\n */\nexport function buildQueryString(\n params: Record<string, unknown>,\n): string {\n const parts: string[] = [];\n\n for (const [key, value] of Object.entries(params)) {\n // Skip internal SDK options that are not API params.\n if (key === 'signal') continue;\n if (value === undefined || value === null) continue;\n\n const snakeKey = toSnakeCase(key);\n\n if (Array.isArray(value)) {\n if (value.length > 0) {\n parts.push(\n `${encodeURIComponent(snakeKey)}=${encodeURIComponent(value.join(','))}`,\n );\n }\n } else {\n parts.push(\n `${encodeURIComponent(snakeKey)}=${encodeURIComponent(String(value))}`,\n );\n }\n }\n\n return parts.length > 0 ? `?${parts.join('&')}` : '';\n}\n\n// ---------------------------------------------------------------------------\n// Retryable HTTP client\n// ---------------------------------------------------------------------------\n\nfunction isRetryable(status: number): boolean {\n return status === 429 || status >= 500;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Parse the body of a response. Returns the parsed JSON on success or a string\n * representation when parsing fails.\n */\nasync function parseBody(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type') ?? '';\n if (contentType.includes('application/json')) {\n try {\n return await response.json();\n } catch {\n return await response.text();\n }\n }\n return await response.text();\n}\n\n/**\n * Throw the appropriate typed error for the given HTTP status.\n */\nfunction throwForStatus(\n status: number,\n body: unknown,\n url: string,\n): never {\n if (status === 401 || status === 403) {\n throw new AuthenticationError({ status, body, url });\n }\n if (status === 429) {\n throw new RateLimitError({ body, url });\n }\n if (status === 400 || status === 422) {\n throw new ValidationError({ status, body, url });\n }\n if (status >= 500) {\n throw new ServerError({ status, body, url });\n }\n throw new HtAgError(`HTTP ${status}`, { status, body, url });\n}\n\n/**\n * Internal HTTP transport used by all domain clients.\n */\nexport class HttpClient {\n constructor(private readonly config: ResolvedConfig) {}\n\n /**\n * Execute a GET request against the public API base.\n */\n async get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', this.config.publicBaseUrl + path, undefined, options);\n }\n\n /**\n * Execute a POST request against the public API base.\n */\n async post<T>(\n path: string,\n body: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request<T>('POST', this.config.publicBaseUrl + path, body, options);\n }\n\n /**\n * Execute a GET request against the internal API base.\n */\n async internalGet<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', this.config.internalBaseUrl + path, undefined, options);\n }\n\n /**\n * Execute a POST request against the internal API base.\n */\n async internalPost<T>(\n path: string,\n body: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n return this.request<T>('POST', this.config.internalBaseUrl + path, body, options);\n }\n\n // -----------------------------------------------------------------------\n // Core request implementation with retries and exponential backoff\n // -----------------------------------------------------------------------\n\n private async request<T>(\n method: string,\n url: string,\n body: unknown,\n options?: RequestOptions,\n ): Promise<T> {\n const headers: Record<string, string> = {\n 'x-api-key': this.config.apiKey,\n 'accept': 'application/json',\n };\n\n if (body !== undefined) {\n headers['content-type'] = 'application/json';\n }\n\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {\n // If this is a retry, wait with exponential backoff + jitter.\n if (attempt > 0) {\n const base = this.config.retryBaseDelay * Math.pow(2, attempt - 1);\n const jitter = Math.random() * base * 0.5;\n await sleep(base + jitter);\n }\n\n // Build an AbortController that combines the user signal with a timeout.\n const controller = new AbortController();\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const cleanup = () => {\n if (timeoutId !== undefined) clearTimeout(timeoutId);\n };\n\n // Wire up caller's abort signal.\n if (options?.signal) {\n if (options.signal.aborted) {\n throw new HtAgError('Request aborted', {\n url,\n cause: options.signal.reason,\n });\n }\n options.signal.addEventListener('abort', () => controller.abort(options.signal!.reason), {\n once: true,\n });\n }\n\n timeoutId = setTimeout(\n () => controller.abort(new Error('Request timed out')),\n this.config.timeout,\n );\n\n try {\n const response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n cleanup();\n\n if (response.ok) {\n return (await parseBody(response)) as T;\n }\n\n const responseBody = await parseBody(response);\n\n // Retry on retryable statuses, unless we've exhausted retries.\n if (isRetryable(response.status) && attempt < this.config.maxRetries) {\n lastError = new HtAgError(`HTTP ${response.status}`, {\n status: response.status,\n body: responseBody,\n url,\n });\n continue;\n }\n\n // Non-retryable or exhausted retries — throw typed error.\n throwForStatus(response.status, responseBody, url);\n } catch (err) {\n cleanup();\n\n // Re-throw our own typed errors.\n if (err instanceof HtAgError) {\n throw err;\n }\n\n // Handle abort / timeout.\n if (err instanceof DOMException && err.name === 'AbortError') {\n if (options?.signal?.aborted) {\n throw new HtAgError('Request aborted', { url, cause: err });\n }\n throw new HtAgError('Request timed out', { url, cause: err });\n }\n\n // Network / fetch errors — retry if we have attempts left.\n if (attempt < this.config.maxRetries) {\n lastError = err instanceof Error ? err : new Error(String(err));\n continue;\n }\n\n throw new HtAgError(\n `Network error: ${err instanceof Error ? err.message : String(err)}`,\n { url, cause: err },\n );\n }\n }\n\n // Should not reach here, but just in case.\n throw lastError ?? new HtAgError('Request failed after retries', { url });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { buildQueryString } from '../http.js';\nimport type {\n AddressSearchParams,\n AddressSearchResponse,\n AddressInsightsParams,\n AddressInsightsResponse,\n BatchStandardiseParams,\n BatchStandardiseResponse,\n} from './types.js';\n\n/**\n * Client for the Address API domain.\n *\n * ```ts\n * const results = await client.address.search({ q: '100 George St Sydney' });\n * ```\n */\nexport class AddressClient {\n /** @internal */\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Search for addresses matching a free-text query.\n *\n * `GET /v1/address/search`\n */\n async search(params: AddressSearchParams): Promise<AddressSearchResponse> {\n const { signal, ...query } = params;\n const qs = buildQueryString(query);\n return this.http.get<AddressSearchResponse>(`/v1/address/search${qs}`, { signal });\n }\n\n /**\n * Retrieve detailed insights for one or more addresses.\n *\n * `GET /v1/address/insights`\n */\n async insights(params: AddressInsightsParams): Promise<AddressInsightsResponse> {\n const { signal, ...query } = params;\n const qs = buildQueryString(query);\n return this.http.get<AddressInsightsResponse>(`/v1/address/insights${qs}`, { signal });\n }\n\n /**\n * Standardise a batch of raw address strings into structured records.\n *\n * `POST /v1/address/standardise`\n */\n async standardise(params: BatchStandardiseParams): Promise<BatchStandardiseResponse> {\n const { signal, addresses } = params;\n return this.http.post<BatchStandardiseResponse>(\n '/v1/address/standardise',\n { addresses },\n { signal },\n );\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { buildQueryString } from '../http.js';\nimport type {\n SoldSearchParams,\n SoldPropertiesResponse,\n} from './types.js';\n\n/**\n * Client for the Property API domain.\n *\n * ```ts\n * const sold = await client.property.soldSearch({ address: '100 George St Sydney', radius: 2000 });\n * ```\n */\nexport class PropertyClient {\n /** @internal */\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Search for recently sold properties near a location.\n *\n * `GET /v1/property/sold/search`\n */\n async soldSearch(params: SoldSearchParams): Promise<SoldPropertiesResponse> {\n const { signal, ...query } = params;\n const qs = buildQueryString(query);\n return this.http.get<SoldPropertiesResponse>(`/v1/property/sold/search${qs}`, { signal });\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { buildQueryString } from '../http.js';\nimport type {\n TrendsParams,\n PriceResponse,\n RentResponse,\n YieldResponse,\n SupplyDemandResponse,\n SearchIndexResponse,\n HoldPeriodResponse,\n PerformanceResponse,\n GrowthRatesResponse,\n DemandProfileResponse,\n} from './types.js';\n\n/**\n * Client for the Markets Trends API domain.\n *\n * Each method queries a specific time-series metric:\n *\n * ```ts\n * const prices = await client.markets.trends.price({\n * level: 'suburb',\n * areaId: ['SAL10001'],\n * propertyType: ['house'],\n * });\n * ```\n */\nexport class TrendsClient {\n /** @internal */\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Price history trends.\n *\n * `GET /internal-api/v1/markets/trends/price`\n */\n async price(params: TrendsParams): Promise<PriceResponse> {\n return this.trend<PriceResponse>('price', params);\n }\n\n /**\n * Rent history trends.\n *\n * `GET /internal-api/v1/markets/trends/rent`\n */\n async rent(params: TrendsParams): Promise<RentResponse> {\n return this.trend<RentResponse>('rent', params);\n }\n\n /**\n * Yield history trends.\n *\n * `GET /internal-api/v1/markets/trends/yield`\n */\n async yieldHistory(params: TrendsParams): Promise<YieldResponse> {\n return this.trend<YieldResponse>('yield', params);\n }\n\n /**\n * Supply and demand (monthly frequency).\n *\n * `GET /internal-api/v1/markets/trends/supply-demand`\n */\n async supplyDemand(params: TrendsParams): Promise<SupplyDemandResponse> {\n return this.trend<SupplyDemandResponse>('supply-demand', params);\n }\n\n /**\n * Search interest index (quarterly frequency).\n *\n * `GET /internal-api/v1/markets/trends/search-index`\n */\n async searchIndex(params: TrendsParams): Promise<SearchIndexResponse> {\n return this.trend<SearchIndexResponse>('search-index', params);\n }\n\n /**\n * Hold period (yearly frequency).\n *\n * `GET /internal-api/v1/markets/trends/hold-period`\n */\n async holdPeriod(params: TrendsParams): Promise<HoldPeriodResponse> {\n return this.trend<HoldPeriodResponse>('hold-period', params);\n }\n\n /**\n * Performance essentials.\n *\n * `GET /internal-api/v1/markets/trends/performance`\n */\n async performance(params: TrendsParams): Promise<PerformanceResponse> {\n return this.trend<PerformanceResponse>('performance', params);\n }\n\n /**\n * Growth rate cycle.\n *\n * `GET /internal-api/v1/markets/trends/growth-rates`\n */\n async growthRates(params: TrendsParams): Promise<GrowthRatesResponse> {\n return this.trend<GrowthRatesResponse>('growth-rates', params);\n }\n\n /**\n * Demand profile breakdown.\n *\n * `GET /internal-api/v1/markets/trends/demand-profile`\n */\n async demandProfile(params: TrendsParams): Promise<DemandProfileResponse> {\n return this.trend<DemandProfileResponse>('demand-profile', params);\n }\n\n // -----------------------------------------------------------------------\n // Shared implementation\n // -----------------------------------------------------------------------\n\n private async trend<T>(metric: string, params: TrendsParams): Promise<T> {\n const { signal, ...query } = params;\n const qs = buildQueryString(query);\n return this.http.internalGet<T>(\n `/internal-api/v1/markets/trends/${metric}${qs}`,\n { signal },\n );\n }\n}\n","import type { HttpClient } from '../http.js';\nimport { buildQueryString } from '../http.js';\nimport { TrendsClient } from './trends.js';\nimport type {\n SnapshotsParams,\n SnapshotsResponse,\n AdvancedSearchBody,\n MarketQueryResponse,\n} from './types.js';\nimport type { RequestOptions } from '../types.js';\n\n/**\n * Client for the Markets API domain.\n *\n * ```ts\n * const snapshots = await client.markets.snapshots({\n * level: 'suburb',\n * propertyType: ['house'],\n * });\n *\n * const prices = await client.markets.trends.price({\n * level: 'suburb',\n * areaId: ['SAL10001'],\n * });\n * ```\n */\nexport class MarketsClient {\n /** Sub-client for time-series trend endpoints. */\n readonly trends: TrendsClient;\n\n /** @internal */\n constructor(private readonly http: HttpClient) {\n this.trends = new TrendsClient(http);\n }\n\n /**\n * Retrieve market snapshot data with optional filters.\n *\n * `GET /internal-api/v1/markets/snapshots`\n */\n async snapshots(params: SnapshotsParams): Promise<SnapshotsResponse> {\n const { signal, ...query } = params;\n const qs = buildQueryString(query);\n return this.http.internalGet<SnapshotsResponse>(\n `/internal-api/v1/markets/snapshots${qs}`,\n { signal },\n );\n }\n\n /**\n * Advanced market query with logical filter expressions.\n *\n * `POST /internal-api/v1/markets/query`\n */\n async query(\n body: AdvancedSearchBody,\n options?: RequestOptions,\n ): Promise<MarketQueryResponse> {\n return this.http.internalPost<MarketQueryResponse>(\n '/internal-api/v1/markets/query',\n body,\n options,\n );\n }\n}\n","import type { HtAgClientOptions, ResolvedConfig } from './types.js';\nimport { HttpClient } from './http.js';\nimport { AddressClient } from './address/client.js';\nimport { PropertyClient } from './property/client.js';\nimport { MarketsClient } from './markets/client.js';\n\n// ---------------------------------------------------------------------------\n// Defaults\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_RETRY_BASE_DELAY = 500; // ms\nconst DEFAULT_TIMEOUT = 30_000; // 30 seconds\n\n/**\n * Build the environment-derived base URLs.\n *\n * - `prod` -> `https://api.prod.htagai.com`\n * - `dev` -> `https://api.dev.htagai.com`\n */\nfunction resolveBaseUrls(options: HtAgClientOptions): {\n publicBaseUrl: string;\n internalBaseUrl: string;\n} {\n if (options.baseUrl) {\n // Strip trailing slashes for consistency.\n const base = options.baseUrl.replace(/\\/+$/, '');\n return { publicBaseUrl: base, internalBaseUrl: base };\n }\n\n const env = options.environment ?? 'prod';\n const base = `https://api.${env}.htagai.com`;\n return { publicBaseUrl: base, internalBaseUrl: base };\n}\n\n// ---------------------------------------------------------------------------\n// HtAgApiClient\n// ---------------------------------------------------------------------------\n\n/**\n * Top-level client for the HtAG Location Intelligence APIs.\n *\n * ```ts\n * import { HtAgApiClient } from '@htag/sdk';\n *\n * const client = new HtAgApiClient({\n * apiKey: process.env.HTAG_API_KEY!,\n * environment: 'prod',\n * });\n *\n * const results = await client.address.search({ q: '100 George St Sydney' });\n * ```\n */\nexport class HtAgApiClient {\n /** Address search, insights and standardisation. */\n readonly address: AddressClient;\n\n /** Sold property search. */\n readonly property: PropertyClient;\n\n /** Market snapshots, advanced queries and time-series trends. */\n readonly markets: MarketsClient;\n\n constructor(options: HtAgClientOptions) {\n if (!options.apiKey) {\n throw new Error(\n 'HtAgApiClient requires an apiKey. Pass it in the constructor options.',\n );\n }\n\n const { publicBaseUrl, internalBaseUrl } = resolveBaseUrls(options);\n\n const config: ResolvedConfig = {\n apiKey: options.apiKey,\n publicBaseUrl,\n internalBaseUrl,\n maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,\n retryBaseDelay: options.retryBaseDelay ?? DEFAULT_RETRY_BASE_DELAY,\n timeout: options.timeout ?? DEFAULT_TIMEOUT,\n };\n\n const http = new HttpClient(config);\n\n this.address = new AddressClient(http);\n this.property = new PropertyClient(http);\n this.markets = new MarketsClient(http);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,YAAN,cAAwB,MAAM;AAAA;AAAA,EAE1B;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EAET,YACE,SACA,SAMA;AACA,UAAM,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;AACxC,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS;AACvB,SAAK,OAAO,SAAS;AACrB,SAAK,MAAM,SAAS;AAAA,EACtB;AACF;AAKO,IAAM,sBAAN,cAAkC,UAAU;AAAA,EACjD,YAAY,SAAyD;AACnE;AAAA,MACE,+BAA+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