@wherabouts/sdk 0.2.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/CHANGELOG.md +35 -0
- package/README.md +138 -0
- package/dist/index.cjs +431 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +480 -0
- package/dist/index.d.ts +480 -0
- package/dist/index.js +419 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/shared-types.ts","../src/http.ts","../src/resources/addresses.ts","../src/resources/devices.ts","../src/resources/geocode.ts","../src/resources/regions.ts","../src/resources/routing.ts","../src/resources/webhooks.ts","../src/resources/zones.ts","../src/client.ts"],"names":[],"mappings":";;;AAMO,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EACpC,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,MAAA;AAAA,EAET,YAAY,OAAA,EAQT;AACF,IAAA,KAAA,CAAM,QAAQ,OAAO,CAAA;AACrB,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AACZ,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,QAAQ,IAAA,IAAQ,eAAA;AAC5B,IAAA,IAAA,CAAK,OAAA,GAAU,QAAQ,OAAA,IAAW,IAAA;AAClC,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,SAAA,IAAa,IAAA;AACtC,IAAA,IAAA,CAAK,MAAA,GAAS,QAAQ,MAAA,IAAU,IAAA;AAChC,IAAA,IAAA,CAAK,MAAA,GAAS,QAAQ,MAAA,IAAU,IAAA;AAAA,EACjC;AACD;;;ACnCO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,sBAAA,GAAyB;;;ACUtC,IAAM,gBAAA,G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zB,OAAO,EAAE,IAAA,EAAM,QAAQ,IAAA,EAAM,KAAA,EAAO,QAAQ,KAAA,EAAM;AAAA,IAClD,GAAG;AAAA,GACH;AACH,CAAA;;;AC9JO,IAAM,sBAAA,GAAyB,CACrC,MAAA,KACsB;AACtB,EAAA,MAAM,OAAA,GAAU,gBAAgB,MAAM,CAAA;AACtC,EAAA,OAAO;AAAA,IACN,SAAA,EAAW,gBAAgB,OAAO,CAAA;AAAA,IAClC,OAAA,EAAS,cAAc,OAAO,CAAA;AAAA,IAC9B,KAAA,EAAO,YAAY,OAAO,CAAA;AAAA,IAC1B,OAAA,EAAS,cAAc,OAAO,CAAA;AAAA,IAC9B,QAAA,EAAU,eAAe,OAAO,CAAA;AAAA,IAChC,OAAA,EAAS,cAAc,OAAO,CAAA;AAAA,IAC9B,OAAA,EAAS,cAAc,OAAO;AAAA,GAC/B;AACD","file":"index.cjs","sourcesContent":["import type {\n\tWheraboutsApiErrorPayload,\n\tWheraboutsErrorCode,\n\tWheraboutsFieldError,\n} from \"./shared-types.ts\";\n\nexport class WheraboutsApiError extends Error {\n\treadonly code: WheraboutsErrorCode | \"unknown_error\";\n\treadonly payload: WheraboutsApiErrorPayload | null;\n\treadonly status: number;\n\t/** Correlation id from the `X-Request-Id` header or error body, if present. */\n\treadonly requestId: string | null;\n\t/** Documentation link for this error, if the API provided one. */\n\treadonly docUrl: string | null;\n\t/** Field-level validation detail, if the API provided any. */\n\treadonly fields: WheraboutsFieldError[] | null;\n\n\tconstructor(options: {\n\t\tcode?: WheraboutsApiError[\"code\"];\n\t\tdocUrl?: string | null;\n\t\tfields?: WheraboutsFieldError[] | null;\n\t\tmessage: string;\n\t\tpayload?: WheraboutsApiErrorPayload | null;\n\t\trequestId?: string | null;\n\t\tstatus: number;\n\t}) {\n\t\tsuper(options.message);\n\t\tthis.name = \"WheraboutsApiError\";\n\t\tthis.status = options.status;\n\t\tthis.code = options.code ?? \"unknown_error\";\n\t\tthis.payload = options.payload ?? null;\n\t\tthis.requestId = options.requestId ?? null;\n\t\tthis.docUrl = options.docUrl ?? null;\n\t\tthis.fields = options.fields ?? null;\n\t}\n}\n","export const WHERABOUTS_API_VERSION = \"v1\" as const;\nexport const WHERABOUTS_SDK_VERSION = \"0.2.0\" as const;\n\n/**\n * Error codes the API may return. The server currently emits a subset; the full\n * union is declared for forward-compatibility with the Phase 2 error envelope\n * (see docs/CONTRACT.md §4). Unknown codes fall back to `unknown_error`.\n */\nexport type WheraboutsErrorCode =\n\t| \"bad_request\"\n\t| \"conflict\"\n\t| \"forbidden\"\n\t| \"internal_error\"\n\t| \"not_found\"\n\t| \"rate_limited\"\n\t| \"timeout\"\n\t| \"unauthorized\"\n\t| \"unprocessable\";\n\nexport interface WheraboutsFieldError {\n\tmessage: string;\n\tpath: string;\n}\n\nexport interface WheraboutsApiErrorPayload {\n\terror: {\n\t\tcode: WheraboutsErrorCode;\n\t\tmessage: string;\n\t\t/** Correlation id; also sent as the `X-Request-Id` response header. */\n\t\trequest_id?: string;\n\t\t/** Link to documentation for this error code. */\n\t\tdoc_url?: string;\n\t\t/** Field-level validation detail (validation errors only). */\n\t\tfields?: WheraboutsFieldError[];\n\t};\n}\n\nexport interface WheraboutsClientConfig {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetch?: typeof fetch;\n\theaders?: Record<string, string>;\n\t/** Max automatic retries for transient failures. Default 2. */\n\tmaxRetries?: number;\n\t/** Per-request timeout in milliseconds. Default 30000. */\n\ttimeoutMs?: number;\n}\n\n/**\n * Per-call overrides. Every resource method accepts an optional trailing\n * `options` argument of this shape.\n */\nexport interface CallOptions {\n\t/** Extra headers merged over (not replacing) the client headers. */\n\theaders?: Record<string, string>;\n\t/** Idempotency key for write requests. Auto-generated on writes if omitted. */\n\tidempotencyKey?: string;\n\t/** Override the client's `maxRetries` for this call. */\n\tmaxRetries?: number;\n\t/** Abort signal — aborting rejects the call (and is not retried). */\n\tsignal?: AbortSignal;\n\t/** Override the client's `timeoutMs` for this call. */\n\ttimeoutMs?: number;\n}\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\nexport interface RequestOptions extends CallOptions {\n\tbody?: unknown;\n\tmethod: HttpMethod;\n\tpath: string;\n\tquery?: Record<string, number | string | undefined>;\n}\n\nexport type Requester = <T>(opts: RequestOptions) => Promise<T>;\n","import { WheraboutsApiError } from \"./errors.ts\";\nimport {\n\ttype HttpMethod,\n\ttype Requester,\n\ttype RequestOptions,\n\tWHERABOUTS_API_VERSION,\n\tWHERABOUTS_SDK_VERSION,\n\ttype WheraboutsApiErrorPayload,\n\ttype WheraboutsClientConfig,\n} from \"./shared-types.ts\";\n\nconst DEFAULT_BASE_URL = \"https://api.wherabouts.com\";\nconst DEFAULT_MAX_RETRIES = 2;\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst BACKOFF_BASE_MS = 200;\nconst BACKOFF_CAP_MS = 5000;\nconst RETRYABLE_STATUSES = new Set([408, 425, 429, 500, 502, 503, 504]);\nconst WRITE_METHODS = new Set<HttpMethod>([\"POST\", \"PUT\"]);\n\nconst createBaseHeaders = (config: WheraboutsClientConfig): Headers => {\n\tconst headers = new Headers(config.headers);\n\theaders.set(\"accept\", \"application/json\");\n\theaders.set(\"authorization\", `Bearer ${config.apiKey}`);\n\theaders.set(\n\t\t\"x-wherabouts-sdk\",\n\t\t`js-ts/${WHERABOUTS_SDK_VERSION} api/${WHERABOUTS_API_VERSION}`\n\t);\n\treturn headers;\n};\n\nconst generateIdempotencyKey = (): string => {\n\tconst cryptoObj = globalThis.crypto;\n\tif (cryptoObj?.randomUUID) {\n\t\treturn cryptoObj.randomUUID();\n\t}\n\t// Fallback for runtimes without crypto.randomUUID.\n\treturn `${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`;\n};\n\nconst buildRequestHeaders = (\n\tbaseHeaders: Headers,\n\topts: RequestOptions\n): Headers => {\n\tconst headers = new Headers(baseHeaders);\n\tif (opts.headers) {\n\t\tfor (const [key, value] of Object.entries(opts.headers)) {\n\t\t\theaders.set(key, value);\n\t\t}\n\t}\n\tif (opts.body !== undefined) {\n\t\theaders.set(\"content-type\", \"application/json\");\n\t}\n\t// Writes carry an Idempotency-Key so retries are safe (docs/CONTRACT.md §6).\n\tif (WRITE_METHODS.has(opts.method)) {\n\t\theaders.set(\n\t\t\t\"idempotency-key\",\n\t\t\topts.idempotencyKey ?? generateIdempotencyKey()\n\t\t);\n\t} else if (opts.idempotencyKey) {\n\t\theaders.set(\"idempotency-key\", opts.idempotencyKey);\n\t}\n\treturn headers;\n};\n\nconst readRequestId = (response: Response): string | null =>\n\tresponse.headers.get(\"x-request-id\") ??\n\tresponse.headers.get(\"x-wherabouts-request-id\");\n\nconst parseApiError = async (\n\tresponse: Response\n): Promise<WheraboutsApiError> => {\n\tlet payload: WheraboutsApiErrorPayload | null = null;\n\ttry {\n\t\tpayload = (await response.json()) as WheraboutsApiErrorPayload;\n\t} catch {\n\t\tpayload = null;\n\t}\n\tconst message =\n\t\tpayload?.error.message ??\n\t\t`Wherabouts request failed with status ${response.status}`;\n\treturn new WheraboutsApiError({\n\t\tstatus: response.status,\n\t\tmessage,\n\t\tcode: payload?.error.code ?? \"unknown_error\",\n\t\tpayload,\n\t\trequestId: payload?.error.request_id ?? readRequestId(response),\n\t\tdocUrl: payload?.error.doc_url ?? null,\n\t\tfields: payload?.error.fields ?? null,\n\t});\n};\n\n/** Parse a `Retry-After` header (delta-seconds or HTTP-date) to milliseconds. */\nconst parseRetryAfter = (value: string | null): number | null => {\n\tif (!value) {\n\t\treturn null;\n\t}\n\tconst seconds = Number(value);\n\tif (Number.isFinite(seconds)) {\n\t\treturn Math.max(0, seconds * 1000);\n\t}\n\tconst dateMs = Date.parse(value);\n\tif (Number.isNaN(dateMs)) {\n\t\treturn null;\n\t}\n\treturn Math.max(0, dateMs - Date.now());\n};\n\n/** Exponential backoff with full jitter, capped. */\nconst computeBackoff = (attempt: number): number => {\n\tconst exponential = Math.min(BACKOFF_CAP_MS, BACKOFF_BASE_MS * 2 ** attempt);\n\treturn Math.random() * exponential;\n};\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n\tnew Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(signal.reason ?? new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timer);\n\t\t\treject(signal?.reason ?? new Error(\"Aborted\"));\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\nexport const createRequester = (config: WheraboutsClientConfig): Requester => {\n\tconst fetchImpl = config.fetch ?? globalThis.fetch;\n\tif (!fetchImpl) {\n\t\tthrow new Error(\n\t\t\t\"A fetch implementation is required to create the SDK client.\"\n\t\t);\n\t}\n\tconst baseUrl = new URL(config.baseUrl ?? DEFAULT_BASE_URL);\n\tconst baseHeaders = createBaseHeaders(config);\n\n\treturn async <T>(opts: RequestOptions): Promise<T> => {\n\t\tconst url = new URL(opts.path, baseUrl);\n\t\tif (opts.query) {\n\t\t\tfor (const [key, value] of Object.entries(opts.query)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\turl.searchParams.set(key, String(value));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst headers = buildRequestHeaders(baseHeaders, opts);\n\t\tconst hasBody = opts.body !== undefined;\n\t\tconst body = hasBody ? JSON.stringify(opts.body) : undefined;\n\t\tconst maxRetries =\n\t\t\topts.maxRetries ?? config.maxRetries ?? DEFAULT_MAX_RETRIES;\n\t\tconst timeoutMs = opts.timeoutMs ?? config.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\t\t// GET/PUT/DELETE are idempotent; POST is only retry-safe with a key (always\n\t\t// set for writes above), so every request here is retryable by method.\n\t\tconst callerSignal = opts.signal;\n\n\t\tlet attempt = 0;\n\t\t// Retry loop: returns on success or non-retryable failure; otherwise waits\n\t\t// and continues until `maxRetries` is exhausted.\n\t\twhile (true) {\n\t\t\tconst controller = new AbortController();\n\t\t\tlet timedOut = false;\n\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\ttimedOut = true;\n\t\t\t\tcontroller.abort();\n\t\t\t}, timeoutMs);\n\t\t\tconst onCallerAbort = () => controller.abort();\n\t\t\tif (callerSignal) {\n\t\t\t\tif (callerSignal.aborted) {\n\t\t\t\t\tcontroller.abort();\n\t\t\t\t} else {\n\t\t\t\t\tcallerSignal.addEventListener(\"abort\", onCallerAbort, { once: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst response = await fetchImpl(url, {\n\t\t\t\t\tmethod: opts.method,\n\t\t\t\t\theaders,\n\t\t\t\t\tbody,\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tif (RETRYABLE_STATUSES.has(response.status) && attempt < maxRetries) {\n\t\t\t\t\t\tconst wait =\n\t\t\t\t\t\t\tparseRetryAfter(response.headers.get(\"retry-after\")) ??\n\t\t\t\t\t\t\tcomputeBackoff(attempt);\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tawait sleep(Math.min(wait, BACKOFF_CAP_MS), callerSignal);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow await parseApiError(response);\n\t\t\t\t}\n\n\t\t\t\tif (response.status === 204) {\n\t\t\t\t\treturn undefined as T;\n\t\t\t\t}\n\t\t\t\tconst text = await response.text();\n\t\t\t\treturn (text ? JSON.parse(text) : undefined) as T;\n\t\t\t} catch (error) {\n\t\t\t\t// Caller aborted — never retry; propagate their intent.\n\t\t\t\tif (callerSignal?.aborted) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\t// Our timeout fired — treat like a transient failure.\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tif (attempt < maxRetries) {\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tawait sleep(computeBackoff(attempt - 1), callerSignal);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow new WheraboutsApiError({\n\t\t\t\t\t\tstatus: 0,\n\t\t\t\t\t\tcode: \"timeout\",\n\t\t\t\t\t\tmessage: `Request timed out after ${timeoutMs}ms.`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// A parsed API error (non-retryable status) — surface as-is.\n\t\t\t\tif (error instanceof WheraboutsApiError) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\t// Network/transport error — retry if budget remains.\n\t\t\t\tif (attempt < maxRetries) {\n\t\t\t\t\tattempt++;\n\t\t\t\t\tawait sleep(computeBackoff(attempt - 1), callerSignal);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\tcallerSignal?.removeEventListener(\"abort\", onCallerAbort);\n\t\t\t}\n\t\t}\n\t};\n};\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\nexport interface AddressSuggestion {\n\tcountry: string;\n\tformattedAddress: string;\n\tid: number;\n\tlatitude: number;\n\tlocality: string;\n\tlongitude: number;\n\tpostcode: string;\n\tstate: string;\n\tstreetAddress: string;\n}\n\nexport interface AddressRecord {\n\tbuildingName: string | null;\n\tconfidence: number | null;\n\tcountry: string;\n\tflatNumber: string | null;\n\tflatType: string | null;\n\tgnafPid: string | null;\n\tid: number;\n\tlatitude: number;\n\tlevelNumber: string | null;\n\tlevelType: string | null;\n\tlocality: string;\n\tlongitude: number;\n\tnumberFirst: string | null;\n\tnumberLast: string | null;\n\tpostcode: string;\n\tstate: string;\n\tstreetName: string;\n\tstreetSuffix: string | null;\n\tstreetType: string | null;\n}\n\nexport interface NearbyAddress {\n\tbuildingName: string | null;\n\tcountry: string;\n\tdistance: number;\n\tflatNumber: string | null;\n\tflatType: string | null;\n\tid: number;\n\tlatitude: number;\n\tlocality: string;\n\tlongitude: number;\n\tnumberFirst: string | null;\n\tnumberLast: string | null;\n\tpostcode: string;\n\tstate: string;\n\tstreetName: string;\n\tstreetType: string | null;\n}\n\nexport interface ReverseGeocodeAddress {\n\tconfidence: number | null;\n\tcountry: string;\n\tformattedAddress: string;\n\tid: number;\n\tlatitude: number;\n\tlocality: string;\n\tlongitude: number;\n\tpostcode: string;\n\tstate: string;\n\tstreetAddress: string;\n}\n\nexport interface AutocompleteParams {\n\tcountry?: string;\n\tlimit?: number;\n\tq: string;\n\tstate?: string;\n}\n\nexport interface NearbyParams {\n\tcountry?: string;\n\tlat: number;\n\tlimit?: number;\n\tlng: number;\n\tradius?: number;\n}\n\nexport interface ReverseParams {\n\tlat: number;\n\tlng: number;\n}\n\nexport interface AutocompleteResponse {\n\tcount: number;\n\tresults: AddressSuggestion[];\n}\n\nexport interface NearbyResponse {\n\tcount: number;\n\tquery: {\n\t\tlat: number;\n\t\tlng: number;\n\t\tradius: number;\n\t};\n\tresults: NearbyAddress[];\n}\n\nexport interface ReverseResponse {\n\taddress: ReverseGeocodeAddress;\n\tdistance: number;\n\tquery: {\n\t\tlat: number;\n\t\tlng: number;\n\t};\n}\n\nexport interface AddressesResource {\n\tautocomplete(\n\t\tparams: AutocompleteParams,\n\t\toptions?: CallOptions\n\t): Promise<AutocompleteResponse>;\n\tgetById(id: number, options?: CallOptions): Promise<AddressRecord>;\n\tnearby(params: NearbyParams, options?: CallOptions): Promise<NearbyResponse>;\n\treverse(\n\t\tparams: ReverseParams,\n\t\toptions?: CallOptions\n\t): Promise<ReverseResponse>;\n}\n\nexport const createAddresses = (request: Requester): AddressesResource => ({\n\tautocomplete: (params, options) =>\n\t\trequest<AutocompleteResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/addresses/autocomplete\",\n\t\t\tquery: {\n\t\t\t\tq: params.q,\n\t\t\t\tcountry: params.country,\n\t\t\t\tstate: params.state,\n\t\t\t\tlimit: params.limit,\n\t\t\t},\n\t\t\t...options,\n\t\t}),\n\tgetById: (id, options) =>\n\t\trequest<AddressRecord>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/api/v1/addresses/${id}`,\n\t\t\t...options,\n\t\t}),\n\tnearby: (params, options) =>\n\t\trequest<NearbyResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/addresses/nearby\",\n\t\t\tquery: {\n\t\t\t\tlat: params.lat,\n\t\t\t\tlng: params.lng,\n\t\t\t\tradius: params.radius,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcountry: params.country,\n\t\t\t},\n\t\t\t...options,\n\t\t}),\n\treverse: (params, options) =>\n\t\trequest<ReverseResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/addresses/reverse\",\n\t\t\tquery: { lat: params.lat, lng: params.lng },\n\t\t\t...options,\n\t\t}),\n});\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\nexport interface BoundaryCrossing {\n\tevent: \"entry\" | \"exit\";\n\tzoneId: number;\n\tzoneName: string;\n}\n\nexport interface PushLocationBody {\n\tlat: number;\n\tlng: number;\n}\n\nexport interface PushLocationResponse {\n\tcrossings: BoundaryCrossing[];\n\tzones: number[];\n}\n\nexport interface DeviceZonesResponse {\n\tdeviceId: string;\n\tlatitude: number | null;\n\tlongitude: number | null;\n\tupdatedAt: string | null;\n\tzoneIds: number[];\n}\n\nexport interface DevicesResource {\n\tpushLocation(\n\t\tdeviceId: string,\n\t\tbody: PushLocationBody,\n\t\toptions?: CallOptions\n\t): Promise<PushLocationResponse>;\n\tzones(deviceId: string, options?: CallOptions): Promise<DeviceZonesResponse>;\n}\n\nexport const createDevices = (request: Requester): DevicesResource => ({\n\tpushLocation: (deviceId, body, options) =>\n\t\trequest<PushLocationResponse>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `/api/v1/devices/${deviceId}/location`,\n\t\t\tbody,\n\t\t\t...options,\n\t\t}),\n\tzones: (deviceId, options) =>\n\t\trequest<DeviceZonesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/api/v1/devices/${deviceId}/zones`,\n\t\t\t...options,\n\t\t}),\n});\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\n// ---------------------------------------------------------------------------\n// Forward geocode types\n// ---------------------------------------------------------------------------\n\n/**\n * Params for forward geocoding. Provide `q` for unstructured free-text search,\n * OR `street` + `locality` (plus optional `state`, `postcode`, `country`) for\n * structured mode. Set `structured: \"true\"` when using structured fields.\n */\nexport interface ForwardGeocodeParams {\n\t/** ISO 3166-1 alpha-2 country code, e.g. \"AU\". */\n\tcountry?: string;\n\t/** Suburb / locality (structured mode). */\n\tlocality?: string;\n\t/** Postcode / ZIP. */\n\tpostcode?: string;\n\t/** Free-text address query (unstructured mode). */\n\tq?: string;\n\t/** State abbreviation, e.g. \"NSW\". */\n\tstate?: string;\n\t/** Street address (structured mode). */\n\tstreet?: string;\n\t/** Pass `\"true\"` to enable structured mode. */\n\tstructured?: \"true\" | \"false\";\n}\n\nexport interface GeocodeAddress {\n\tcountry: string;\n\tformattedAddress: string;\n\tid: number;\n\tlatitude: number;\n\tlocality: string;\n\tlongitude: number;\n\tpostcode: string;\n\tstate: string;\n\tstreetAddress: string;\n}\n\nexport interface ForwardGeocodeResponse {\n\taddress: GeocodeAddress;\n\tmatchType: \"structured\" | \"fuzzy\";\n}\n\n// ---------------------------------------------------------------------------\n// Batch geocode types\n// ---------------------------------------------------------------------------\n\nexport interface BatchSubmitBody {\n\taddresses: string[];\n}\n\nexport interface BatchSubmitResponse {\n\tinputCount: number;\n\tjobId: string;\n\tstatus: \"pending\" | \"processing\";\n}\n\nexport interface BatchJobStatus {\n\tcompletedAt: string | null;\n\tdownloadUrl: string | null;\n\terror: string | null;\n\tinputCount: number;\n\tjobId: string;\n\tprocessedCount: number | null;\n\tstatus: \"pending\" | \"processing\" | \"completed\" | \"failed\";\n}\n\nexport interface BatchResultsResponse {\n\tcount: number;\n\tresults: unknown[];\n}\n\n// ---------------------------------------------------------------------------\n// Resource factory\n// ---------------------------------------------------------------------------\n\nexport interface GeocodeResource {\n\tbatch: {\n\t\tsubmit(\n\t\t\tbody: BatchSubmitBody,\n\t\t\toptions?: CallOptions\n\t\t): Promise<BatchSubmitResponse>;\n\t\tpoll(jobId: string, options?: CallOptions): Promise<BatchJobStatus>;\n\t\tresults(\n\t\t\tjobId: string,\n\t\t\toptions?: CallOptions\n\t\t): Promise<BatchResultsResponse>;\n\t};\n\tforward(\n\t\tparams: ForwardGeocodeParams,\n\t\toptions?: CallOptions\n\t): Promise<ForwardGeocodeResponse>;\n}\n\nexport const createGeocode = (request: Requester): GeocodeResource => ({\n\tforward: (params, options) =>\n\t\trequest<ForwardGeocodeResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/addresses/geocode\",\n\t\t\tquery: {\n\t\t\t\tq: params.q,\n\t\t\t\tstructured: params.structured,\n\t\t\t\tstreet: params.street,\n\t\t\t\tlocality: params.locality,\n\t\t\t\tstate: params.state,\n\t\t\t\tpostcode: params.postcode,\n\t\t\t\tcountry: params.country,\n\t\t\t},\n\t\t\t...options,\n\t\t}),\n\tbatch: {\n\t\tsubmit: (body, options) =>\n\t\t\trequest<BatchSubmitResponse>({\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tpath: \"/api/v1/geocode/batch\",\n\t\t\t\tbody,\n\t\t\t\t...options,\n\t\t\t}),\n\t\tpoll: (jobId, options) =>\n\t\t\trequest<BatchJobStatus>({\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: `/api/v1/geocode/batch/${jobId}`,\n\t\t\t\t...options,\n\t\t\t}),\n\t\tresults: (jobId, options) =>\n\t\t\trequest<BatchResultsResponse>({\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tpath: `/api/v1/geocode/batch/${jobId}/results`,\n\t\t\t\t...options,\n\t\t\t}),\n\t},\n});\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\nexport interface RegionsClassifyParams {\n\tlat: number;\n\tlayers?: string;\n\tlng: number;\n}\n\nexport interface RegionMatch {\n\tcode: string;\n\tname: string;\n}\n\nexport interface RegionsClassifyResponse {\n\tquery: { lat: number; lng: number };\n\tregions: Record<string, RegionMatch>;\n}\n\nexport interface RegionsResource {\n\tclassify(\n\t\tparams: RegionsClassifyParams,\n\t\toptions?: CallOptions\n\t): Promise<RegionsClassifyResponse>;\n}\n\nexport const createRegions = (request: Requester): RegionsResource => ({\n\tclassify: (params, options) =>\n\t\trequest<RegionsClassifyResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/regions\",\n\t\t\tquery: { lat: params.lat, lng: params.lng, layers: params.layers },\n\t\t\t...options,\n\t\t}),\n});\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\nexport interface DirectionsParams {\n\tfrom?: string;\n\tfromAddressId?: number;\n\tprofile?: \"driving\";\n\tto?: string;\n\ttoAddressId?: number;\n}\n\nexport interface DirectionsGeometry {\n\tcoordinates: [number, number][];\n\ttype: \"LineString\";\n}\n\nexport interface DirectionsResponse {\n\tdistance_m: number;\n\tduration_s: number;\n\tgeometry: DirectionsGeometry;\n\tquery: {\n\t\tfrom: { lat: number; lng: number };\n\t\tprofile: string;\n\t\tto: { lat: number; lng: number };\n\t};\n}\n\nexport interface RoutingResource {\n\tdirections(\n\t\tparams: DirectionsParams,\n\t\toptions?: CallOptions\n\t): Promise<DirectionsResponse>;\n}\n\nexport const createRouting = (request: Requester): RoutingResource => ({\n\tdirections: (params, options) =>\n\t\trequest<DirectionsResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/routing/directions\",\n\t\t\tquery: {\n\t\t\t\tfrom: params.from,\n\t\t\t\tto: params.to,\n\t\t\t\tfromAddressId: params.fromAddressId,\n\t\t\t\ttoAddressId: params.toAddressId,\n\t\t\t\tprofile: params.profile,\n\t\t\t},\n\t\t\t...options,\n\t\t}),\n});\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\nexport type WebhookEvent = \"entry\" | \"exit\";\n\nexport interface CreateWebhookBody {\n\tevents?: WebhookEvent[];\n\turl: string;\n\tzoneId?: number;\n}\n\nexport interface WebhookSubscription {\n\tactive: boolean;\n\tcreatedAt: string;\n\tevents: WebhookEvent[];\n\tid: number;\n\turl: string;\n\tzoneId: number | null;\n}\n\nexport interface CreateWebhookResponse extends WebhookSubscription {\n\tsecret: string;\n}\n\nexport interface WebhookListItem extends WebhookSubscription {\n\tfailing: boolean;\n}\n\nexport interface ListWebhooksResponse {\n\tcount: number;\n\tresults: WebhookListItem[];\n}\n\nexport interface DeleteWebhookResponse {\n\tdeleted: true;\n\tid: number;\n}\n\nexport interface ReactivateWebhookResponse {\n\tid: number;\n\treactivated: true;\n}\n\nexport interface WebhooksResource {\n\tcreate(\n\t\tbody: CreateWebhookBody,\n\t\toptions?: CallOptions\n\t): Promise<CreateWebhookResponse>;\n\tdelete(id: number, options?: CallOptions): Promise<DeleteWebhookResponse>;\n\tlist(options?: CallOptions): Promise<ListWebhooksResponse>;\n\treactivate(\n\t\tid: number,\n\t\toptions?: CallOptions\n\t): Promise<ReactivateWebhookResponse>;\n}\n\nexport const createWebhooks = (request: Requester): WebhooksResource => ({\n\tcreate: (body, options) =>\n\t\trequest<CreateWebhookResponse>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/api/v1/webhooks\",\n\t\t\tbody,\n\t\t\t...options,\n\t\t}),\n\tlist: (options) =>\n\t\trequest<ListWebhooksResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/webhooks\",\n\t\t\t...options,\n\t\t}),\n\tdelete: (id, options) =>\n\t\trequest<DeleteWebhookResponse>({\n\t\t\tmethod: \"DELETE\",\n\t\t\tpath: `/api/v1/webhooks/${id}`,\n\t\t\t...options,\n\t\t}),\n\treactivate: (id, options) =>\n\t\trequest<ReactivateWebhookResponse>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `/api/v1/webhooks/${id}/reactivate`,\n\t\t\t...options,\n\t\t}),\n});\n","import type { CallOptions, Requester } from \"../shared-types.ts\";\n\n// --- Types ---\n\nexport interface ZoneRecord {\n\tcreatedAt: string;\n\tdescription: string | null;\n\tid: number;\n\tmetadata: Record<string, unknown> | null;\n\tname: string;\n\tprojectId: string;\n\tupdatedAt: string;\n}\n\nexport interface ZoneWithGeometry extends ZoneRecord {\n\tgeometry: {\n\t\ttype: string;\n\t\tcoordinates: number[][][];\n\t};\n}\n\n// --- GeoJSON Polygon geometry ---\n\nexport interface GeoJsonPolygon {\n\tcoordinates: number[][][];\n\ttype: \"Polygon\";\n}\n\n// --- Param interfaces ---\n\nexport interface ZoneListParams {\n\tlimit?: number;\n\tpage?: number;\n}\n\nexport interface ZoneContainsParams {\n\tlat: number;\n\tlng: number;\n}\n\nexport interface ZoneAddressesParams {\n\tlimit?: number;\n\tpage?: number;\n}\n\nexport interface ZoneCreateBody {\n\tdescription?: string;\n\tgeometry: GeoJsonPolygon;\n\tmetadata?: Record<string, unknown>;\n\tname: string;\n}\n\nexport interface ZoneUpdateBody {\n\tdescription?: string;\n\tgeometry?: GeoJsonPolygon;\n\tmetadata?: Record<string, unknown>;\n\tname?: string;\n}\n\n// --- Response interfaces ---\n\nexport interface ZoneListResponse {\n\tcount: number;\n\tpage: number;\n\tzones: ZoneRecord[];\n}\n\nexport interface ZoneDeleteResponse {\n\tsuccess: true;\n}\n\nexport interface ZoneContainsResponse {\n\tcount: number;\n\tquery: { lat: number; lng: number };\n\tzones: ZoneRecord[];\n}\n\nexport interface ZoneAddressesResponse {\n\tcount: number;\n\tquery: { id: number; limit: number; page: number };\n\tresults: Array<{\n\t\tbuildingName: string | null;\n\t\tcountry: string;\n\t\tflatNumber: string | null;\n\t\tflatType: string | null;\n\t\tid: number;\n\t\tlatitude: number;\n\t\tlocality: string;\n\t\tlongitude: number;\n\t\tnumberFirst: string | null;\n\t\tnumberLast: string | null;\n\t\tpostcode: string;\n\t\tstate: string;\n\t\tstreetName: string;\n\t\tstreetType: string | null;\n\t}>;\n\ttruncated: boolean;\n}\n\n// --- Resource interface ---\n\nexport interface ZonesResource {\n\taddresses(\n\t\tid: number,\n\t\tparams?: ZoneAddressesParams,\n\t\toptions?: CallOptions\n\t): Promise<ZoneAddressesResponse>;\n\tcontains(\n\t\tparams: ZoneContainsParams,\n\t\toptions?: CallOptions\n\t): Promise<ZoneContainsResponse>;\n\tcreate(body: ZoneCreateBody, options?: CallOptions): Promise<ZoneRecord>;\n\tdelete(id: number, options?: CallOptions): Promise<ZoneDeleteResponse>;\n\tget(id: number, options?: CallOptions): Promise<ZoneWithGeometry>;\n\tlist(\n\t\tparams?: ZoneListParams,\n\t\toptions?: CallOptions\n\t): Promise<ZoneListResponse>;\n\tupdate(\n\t\tid: number,\n\t\tbody: ZoneUpdateBody,\n\t\toptions?: CallOptions\n\t): Promise<ZoneRecord>;\n}\n\n// --- Factory ---\n\nexport const createZones = (request: Requester): ZonesResource => ({\n\tcreate: (body, options) =>\n\t\trequest<ZoneRecord>({\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/api/v1/zones\",\n\t\t\tbody,\n\t\t\t...options,\n\t\t}),\n\n\tlist: (params, options) =>\n\t\trequest<ZoneListResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/zones\",\n\t\t\tquery: { page: params?.page, limit: params?.limit },\n\t\t\t...options,\n\t\t}),\n\n\tget: (id, options) =>\n\t\trequest<ZoneWithGeometry>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/api/v1/zones/${id}`,\n\t\t\t...options,\n\t\t}),\n\n\tupdate: (id, body, options) =>\n\t\trequest<ZoneRecord>({\n\t\t\tmethod: \"PUT\",\n\t\t\tpath: `/api/v1/zones/${id}`,\n\t\t\tbody,\n\t\t\t...options,\n\t\t}),\n\n\tdelete: (id, options) =>\n\t\trequest<ZoneDeleteResponse>({\n\t\t\tmethod: \"DELETE\",\n\t\t\tpath: `/api/v1/zones/${id}`,\n\t\t\t...options,\n\t\t}),\n\n\tcontains: (params, options) =>\n\t\trequest<ZoneContainsResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/api/v1/zones/contains\",\n\t\t\tquery: { lat: params.lat, lng: params.lng },\n\t\t\t...options,\n\t\t}),\n\n\taddresses: (id, params, options) =>\n\t\trequest<ZoneAddressesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/api/v1/zones/${id}/addresses`,\n\t\t\tquery: { page: params?.page, limit: params?.limit },\n\t\t\t...options,\n\t\t}),\n});\n","import { createRequester } from \"./http.ts\";\nimport {\n\ttype AddressesResource,\n\tcreateAddresses,\n} from \"./resources/addresses.ts\";\nimport { createDevices, type DevicesResource } from \"./resources/devices.ts\";\nimport { createGeocode, type GeocodeResource } from \"./resources/geocode.ts\";\nimport { createRegions, type RegionsResource } from \"./resources/regions.ts\";\nimport { createRouting, type RoutingResource } from \"./resources/routing.ts\";\nimport { createWebhooks, type WebhooksResource } from \"./resources/webhooks.ts\";\nimport { createZones, type ZonesResource } from \"./resources/zones.ts\";\nimport type { WheraboutsClientConfig } from \"./shared-types.ts\";\n\nexport interface WheraboutsClient {\n\taddresses: AddressesResource;\n\tdevices: DevicesResource;\n\tgeocode: GeocodeResource;\n\tregions: RegionsResource;\n\trouting: RoutingResource;\n\twebhooks: WebhooksResource;\n\tzones: ZonesResource;\n}\n\nexport const createWheraboutsClient = (\n\tconfig: WheraboutsClientConfig\n): WheraboutsClient => {\n\tconst request = createRequester(config);\n\treturn {\n\t\taddresses: createAddresses(request),\n\t\tgeocode: createGeocode(request),\n\t\tzones: createZones(request),\n\t\tdevices: createDevices(request),\n\t\twebhooks: createWebhooks(request),\n\t\tregions: createRegions(request),\n\t\trouting: createRouting(request),\n\t};\n};\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
declare const WHERABOUTS_API_VERSION: "v1";
|
|
2
|
+
declare const WHERABOUTS_SDK_VERSION: "0.2.0";
|
|
3
|
+
/**
|
|
4
|
+
* Error codes the API may return. The server currently emits a subset; the full
|
|
5
|
+
* union is declared for forward-compatibility with the Phase 2 error envelope
|
|
6
|
+
* (see docs/CONTRACT.md §4). Unknown codes fall back to `unknown_error`.
|
|
7
|
+
*/
|
|
8
|
+
type WheraboutsErrorCode = "bad_request" | "conflict" | "forbidden" | "internal_error" | "not_found" | "rate_limited" | "timeout" | "unauthorized" | "unprocessable";
|
|
9
|
+
interface WheraboutsFieldError {
|
|
10
|
+
message: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}
|
|
13
|
+
interface WheraboutsApiErrorPayload {
|
|
14
|
+
error: {
|
|
15
|
+
code: WheraboutsErrorCode;
|
|
16
|
+
message: string;
|
|
17
|
+
/** Correlation id; also sent as the `X-Request-Id` response header. */
|
|
18
|
+
request_id?: string;
|
|
19
|
+
/** Link to documentation for this error code. */
|
|
20
|
+
doc_url?: string;
|
|
21
|
+
/** Field-level validation detail (validation errors only). */
|
|
22
|
+
fields?: WheraboutsFieldError[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface WheraboutsClientConfig {
|
|
26
|
+
apiKey: string;
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
/** Max automatic retries for transient failures. Default 2. */
|
|
31
|
+
maxRetries?: number;
|
|
32
|
+
/** Per-request timeout in milliseconds. Default 30000. */
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Per-call overrides. Every resource method accepts an optional trailing
|
|
37
|
+
* `options` argument of this shape.
|
|
38
|
+
*/
|
|
39
|
+
interface CallOptions {
|
|
40
|
+
/** Extra headers merged over (not replacing) the client headers. */
|
|
41
|
+
headers?: Record<string, string>;
|
|
42
|
+
/** Idempotency key for write requests. Auto-generated on writes if omitted. */
|
|
43
|
+
idempotencyKey?: string;
|
|
44
|
+
/** Override the client's `maxRetries` for this call. */
|
|
45
|
+
maxRetries?: number;
|
|
46
|
+
/** Abort signal — aborting rejects the call (and is not retried). */
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
/** Override the client's `timeoutMs` for this call. */
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
}
|
|
51
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
|
|
52
|
+
interface RequestOptions extends CallOptions {
|
|
53
|
+
body?: unknown;
|
|
54
|
+
method: HttpMethod;
|
|
55
|
+
path: string;
|
|
56
|
+
query?: Record<string, number | string | undefined>;
|
|
57
|
+
}
|
|
58
|
+
type Requester = <T>(opts: RequestOptions) => Promise<T>;
|
|
59
|
+
|
|
60
|
+
interface AddressSuggestion {
|
|
61
|
+
country: string;
|
|
62
|
+
formattedAddress: string;
|
|
63
|
+
id: number;
|
|
64
|
+
latitude: number;
|
|
65
|
+
locality: string;
|
|
66
|
+
longitude: number;
|
|
67
|
+
postcode: string;
|
|
68
|
+
state: string;
|
|
69
|
+
streetAddress: string;
|
|
70
|
+
}
|
|
71
|
+
interface AddressRecord {
|
|
72
|
+
buildingName: string | null;
|
|
73
|
+
confidence: number | null;
|
|
74
|
+
country: string;
|
|
75
|
+
flatNumber: string | null;
|
|
76
|
+
flatType: string | null;
|
|
77
|
+
gnafPid: string | null;
|
|
78
|
+
id: number;
|
|
79
|
+
latitude: number;
|
|
80
|
+
levelNumber: string | null;
|
|
81
|
+
levelType: string | null;
|
|
82
|
+
locality: string;
|
|
83
|
+
longitude: number;
|
|
84
|
+
numberFirst: string | null;
|
|
85
|
+
numberLast: string | null;
|
|
86
|
+
postcode: string;
|
|
87
|
+
state: string;
|
|
88
|
+
streetName: string;
|
|
89
|
+
streetSuffix: string | null;
|
|
90
|
+
streetType: string | null;
|
|
91
|
+
}
|
|
92
|
+
interface NearbyAddress {
|
|
93
|
+
buildingName: string | null;
|
|
94
|
+
country: string;
|
|
95
|
+
distance: number;
|
|
96
|
+
flatNumber: string | null;
|
|
97
|
+
flatType: string | null;
|
|
98
|
+
id: number;
|
|
99
|
+
latitude: number;
|
|
100
|
+
locality: string;
|
|
101
|
+
longitude: number;
|
|
102
|
+
numberFirst: string | null;
|
|
103
|
+
numberLast: string | null;
|
|
104
|
+
postcode: string;
|
|
105
|
+
state: string;
|
|
106
|
+
streetName: string;
|
|
107
|
+
streetType: string | null;
|
|
108
|
+
}
|
|
109
|
+
interface ReverseGeocodeAddress {
|
|
110
|
+
confidence: number | null;
|
|
111
|
+
country: string;
|
|
112
|
+
formattedAddress: string;
|
|
113
|
+
id: number;
|
|
114
|
+
latitude: number;
|
|
115
|
+
locality: string;
|
|
116
|
+
longitude: number;
|
|
117
|
+
postcode: string;
|
|
118
|
+
state: string;
|
|
119
|
+
streetAddress: string;
|
|
120
|
+
}
|
|
121
|
+
interface AutocompleteParams {
|
|
122
|
+
country?: string;
|
|
123
|
+
limit?: number;
|
|
124
|
+
q: string;
|
|
125
|
+
state?: string;
|
|
126
|
+
}
|
|
127
|
+
interface NearbyParams {
|
|
128
|
+
country?: string;
|
|
129
|
+
lat: number;
|
|
130
|
+
limit?: number;
|
|
131
|
+
lng: number;
|
|
132
|
+
radius?: number;
|
|
133
|
+
}
|
|
134
|
+
interface ReverseParams {
|
|
135
|
+
lat: number;
|
|
136
|
+
lng: number;
|
|
137
|
+
}
|
|
138
|
+
interface AutocompleteResponse {
|
|
139
|
+
count: number;
|
|
140
|
+
results: AddressSuggestion[];
|
|
141
|
+
}
|
|
142
|
+
interface NearbyResponse {
|
|
143
|
+
count: number;
|
|
144
|
+
query: {
|
|
145
|
+
lat: number;
|
|
146
|
+
lng: number;
|
|
147
|
+
radius: number;
|
|
148
|
+
};
|
|
149
|
+
results: NearbyAddress[];
|
|
150
|
+
}
|
|
151
|
+
interface ReverseResponse {
|
|
152
|
+
address: ReverseGeocodeAddress;
|
|
153
|
+
distance: number;
|
|
154
|
+
query: {
|
|
155
|
+
lat: number;
|
|
156
|
+
lng: number;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
interface AddressesResource {
|
|
160
|
+
autocomplete(params: AutocompleteParams, options?: CallOptions): Promise<AutocompleteResponse>;
|
|
161
|
+
getById(id: number, options?: CallOptions): Promise<AddressRecord>;
|
|
162
|
+
nearby(params: NearbyParams, options?: CallOptions): Promise<NearbyResponse>;
|
|
163
|
+
reverse(params: ReverseParams, options?: CallOptions): Promise<ReverseResponse>;
|
|
164
|
+
}
|
|
165
|
+
declare const createAddresses: (request: Requester) => AddressesResource;
|
|
166
|
+
|
|
167
|
+
interface BoundaryCrossing {
|
|
168
|
+
event: "entry" | "exit";
|
|
169
|
+
zoneId: number;
|
|
170
|
+
zoneName: string;
|
|
171
|
+
}
|
|
172
|
+
interface PushLocationBody {
|
|
173
|
+
lat: number;
|
|
174
|
+
lng: number;
|
|
175
|
+
}
|
|
176
|
+
interface PushLocationResponse {
|
|
177
|
+
crossings: BoundaryCrossing[];
|
|
178
|
+
zones: number[];
|
|
179
|
+
}
|
|
180
|
+
interface DeviceZonesResponse {
|
|
181
|
+
deviceId: string;
|
|
182
|
+
latitude: number | null;
|
|
183
|
+
longitude: number | null;
|
|
184
|
+
updatedAt: string | null;
|
|
185
|
+
zoneIds: number[];
|
|
186
|
+
}
|
|
187
|
+
interface DevicesResource {
|
|
188
|
+
pushLocation(deviceId: string, body: PushLocationBody, options?: CallOptions): Promise<PushLocationResponse>;
|
|
189
|
+
zones(deviceId: string, options?: CallOptions): Promise<DeviceZonesResponse>;
|
|
190
|
+
}
|
|
191
|
+
declare const createDevices: (request: Requester) => DevicesResource;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Params for forward geocoding. Provide `q` for unstructured free-text search,
|
|
195
|
+
* OR `street` + `locality` (plus optional `state`, `postcode`, `country`) for
|
|
196
|
+
* structured mode. Set `structured: "true"` when using structured fields.
|
|
197
|
+
*/
|
|
198
|
+
interface ForwardGeocodeParams {
|
|
199
|
+
/** ISO 3166-1 alpha-2 country code, e.g. "AU". */
|
|
200
|
+
country?: string;
|
|
201
|
+
/** Suburb / locality (structured mode). */
|
|
202
|
+
locality?: string;
|
|
203
|
+
/** Postcode / ZIP. */
|
|
204
|
+
postcode?: string;
|
|
205
|
+
/** Free-text address query (unstructured mode). */
|
|
206
|
+
q?: string;
|
|
207
|
+
/** State abbreviation, e.g. "NSW". */
|
|
208
|
+
state?: string;
|
|
209
|
+
/** Street address (structured mode). */
|
|
210
|
+
street?: string;
|
|
211
|
+
/** Pass `"true"` to enable structured mode. */
|
|
212
|
+
structured?: "true" | "false";
|
|
213
|
+
}
|
|
214
|
+
interface GeocodeAddress {
|
|
215
|
+
country: string;
|
|
216
|
+
formattedAddress: string;
|
|
217
|
+
id: number;
|
|
218
|
+
latitude: number;
|
|
219
|
+
locality: string;
|
|
220
|
+
longitude: number;
|
|
221
|
+
postcode: string;
|
|
222
|
+
state: string;
|
|
223
|
+
streetAddress: string;
|
|
224
|
+
}
|
|
225
|
+
interface ForwardGeocodeResponse {
|
|
226
|
+
address: GeocodeAddress;
|
|
227
|
+
matchType: "structured" | "fuzzy";
|
|
228
|
+
}
|
|
229
|
+
interface BatchSubmitBody {
|
|
230
|
+
addresses: string[];
|
|
231
|
+
}
|
|
232
|
+
interface BatchSubmitResponse {
|
|
233
|
+
inputCount: number;
|
|
234
|
+
jobId: string;
|
|
235
|
+
status: "pending" | "processing";
|
|
236
|
+
}
|
|
237
|
+
interface BatchJobStatus {
|
|
238
|
+
completedAt: string | null;
|
|
239
|
+
downloadUrl: string | null;
|
|
240
|
+
error: string | null;
|
|
241
|
+
inputCount: number;
|
|
242
|
+
jobId: string;
|
|
243
|
+
processedCount: number | null;
|
|
244
|
+
status: "pending" | "processing" | "completed" | "failed";
|
|
245
|
+
}
|
|
246
|
+
interface BatchResultsResponse {
|
|
247
|
+
count: number;
|
|
248
|
+
results: unknown[];
|
|
249
|
+
}
|
|
250
|
+
interface GeocodeResource {
|
|
251
|
+
batch: {
|
|
252
|
+
submit(body: BatchSubmitBody, options?: CallOptions): Promise<BatchSubmitResponse>;
|
|
253
|
+
poll(jobId: string, options?: CallOptions): Promise<BatchJobStatus>;
|
|
254
|
+
results(jobId: string, options?: CallOptions): Promise<BatchResultsResponse>;
|
|
255
|
+
};
|
|
256
|
+
forward(params: ForwardGeocodeParams, options?: CallOptions): Promise<ForwardGeocodeResponse>;
|
|
257
|
+
}
|
|
258
|
+
declare const createGeocode: (request: Requester) => GeocodeResource;
|
|
259
|
+
|
|
260
|
+
interface RegionsClassifyParams {
|
|
261
|
+
lat: number;
|
|
262
|
+
layers?: string;
|
|
263
|
+
lng: number;
|
|
264
|
+
}
|
|
265
|
+
interface RegionMatch {
|
|
266
|
+
code: string;
|
|
267
|
+
name: string;
|
|
268
|
+
}
|
|
269
|
+
interface RegionsClassifyResponse {
|
|
270
|
+
query: {
|
|
271
|
+
lat: number;
|
|
272
|
+
lng: number;
|
|
273
|
+
};
|
|
274
|
+
regions: Record<string, RegionMatch>;
|
|
275
|
+
}
|
|
276
|
+
interface RegionsResource {
|
|
277
|
+
classify(params: RegionsClassifyParams, options?: CallOptions): Promise<RegionsClassifyResponse>;
|
|
278
|
+
}
|
|
279
|
+
declare const createRegions: (request: Requester) => RegionsResource;
|
|
280
|
+
|
|
281
|
+
interface DirectionsParams {
|
|
282
|
+
from?: string;
|
|
283
|
+
fromAddressId?: number;
|
|
284
|
+
profile?: "driving";
|
|
285
|
+
to?: string;
|
|
286
|
+
toAddressId?: number;
|
|
287
|
+
}
|
|
288
|
+
interface DirectionsGeometry {
|
|
289
|
+
coordinates: [number, number][];
|
|
290
|
+
type: "LineString";
|
|
291
|
+
}
|
|
292
|
+
interface DirectionsResponse {
|
|
293
|
+
distance_m: number;
|
|
294
|
+
duration_s: number;
|
|
295
|
+
geometry: DirectionsGeometry;
|
|
296
|
+
query: {
|
|
297
|
+
from: {
|
|
298
|
+
lat: number;
|
|
299
|
+
lng: number;
|
|
300
|
+
};
|
|
301
|
+
profile: string;
|
|
302
|
+
to: {
|
|
303
|
+
lat: number;
|
|
304
|
+
lng: number;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
interface RoutingResource {
|
|
309
|
+
directions(params: DirectionsParams, options?: CallOptions): Promise<DirectionsResponse>;
|
|
310
|
+
}
|
|
311
|
+
declare const createRouting: (request: Requester) => RoutingResource;
|
|
312
|
+
|
|
313
|
+
type WebhookEvent = "entry" | "exit";
|
|
314
|
+
interface CreateWebhookBody {
|
|
315
|
+
events?: WebhookEvent[];
|
|
316
|
+
url: string;
|
|
317
|
+
zoneId?: number;
|
|
318
|
+
}
|
|
319
|
+
interface WebhookSubscription {
|
|
320
|
+
active: boolean;
|
|
321
|
+
createdAt: string;
|
|
322
|
+
events: WebhookEvent[];
|
|
323
|
+
id: number;
|
|
324
|
+
url: string;
|
|
325
|
+
zoneId: number | null;
|
|
326
|
+
}
|
|
327
|
+
interface CreateWebhookResponse extends WebhookSubscription {
|
|
328
|
+
secret: string;
|
|
329
|
+
}
|
|
330
|
+
interface WebhookListItem extends WebhookSubscription {
|
|
331
|
+
failing: boolean;
|
|
332
|
+
}
|
|
333
|
+
interface ListWebhooksResponse {
|
|
334
|
+
count: number;
|
|
335
|
+
results: WebhookListItem[];
|
|
336
|
+
}
|
|
337
|
+
interface DeleteWebhookResponse {
|
|
338
|
+
deleted: true;
|
|
339
|
+
id: number;
|
|
340
|
+
}
|
|
341
|
+
interface ReactivateWebhookResponse {
|
|
342
|
+
id: number;
|
|
343
|
+
reactivated: true;
|
|
344
|
+
}
|
|
345
|
+
interface WebhooksResource {
|
|
346
|
+
create(body: CreateWebhookBody, options?: CallOptions): Promise<CreateWebhookResponse>;
|
|
347
|
+
delete(id: number, options?: CallOptions): Promise<DeleteWebhookResponse>;
|
|
348
|
+
list(options?: CallOptions): Promise<ListWebhooksResponse>;
|
|
349
|
+
reactivate(id: number, options?: CallOptions): Promise<ReactivateWebhookResponse>;
|
|
350
|
+
}
|
|
351
|
+
declare const createWebhooks: (request: Requester) => WebhooksResource;
|
|
352
|
+
|
|
353
|
+
interface ZoneRecord {
|
|
354
|
+
createdAt: string;
|
|
355
|
+
description: string | null;
|
|
356
|
+
id: number;
|
|
357
|
+
metadata: Record<string, unknown> | null;
|
|
358
|
+
name: string;
|
|
359
|
+
projectId: string;
|
|
360
|
+
updatedAt: string;
|
|
361
|
+
}
|
|
362
|
+
interface ZoneWithGeometry extends ZoneRecord {
|
|
363
|
+
geometry: {
|
|
364
|
+
type: string;
|
|
365
|
+
coordinates: number[][][];
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
interface GeoJsonPolygon {
|
|
369
|
+
coordinates: number[][][];
|
|
370
|
+
type: "Polygon";
|
|
371
|
+
}
|
|
372
|
+
interface ZoneListParams {
|
|
373
|
+
limit?: number;
|
|
374
|
+
page?: number;
|
|
375
|
+
}
|
|
376
|
+
interface ZoneContainsParams {
|
|
377
|
+
lat: number;
|
|
378
|
+
lng: number;
|
|
379
|
+
}
|
|
380
|
+
interface ZoneAddressesParams {
|
|
381
|
+
limit?: number;
|
|
382
|
+
page?: number;
|
|
383
|
+
}
|
|
384
|
+
interface ZoneCreateBody {
|
|
385
|
+
description?: string;
|
|
386
|
+
geometry: GeoJsonPolygon;
|
|
387
|
+
metadata?: Record<string, unknown>;
|
|
388
|
+
name: string;
|
|
389
|
+
}
|
|
390
|
+
interface ZoneUpdateBody {
|
|
391
|
+
description?: string;
|
|
392
|
+
geometry?: GeoJsonPolygon;
|
|
393
|
+
metadata?: Record<string, unknown>;
|
|
394
|
+
name?: string;
|
|
395
|
+
}
|
|
396
|
+
interface ZoneListResponse {
|
|
397
|
+
count: number;
|
|
398
|
+
page: number;
|
|
399
|
+
zones: ZoneRecord[];
|
|
400
|
+
}
|
|
401
|
+
interface ZoneDeleteResponse {
|
|
402
|
+
success: true;
|
|
403
|
+
}
|
|
404
|
+
interface ZoneContainsResponse {
|
|
405
|
+
count: number;
|
|
406
|
+
query: {
|
|
407
|
+
lat: number;
|
|
408
|
+
lng: number;
|
|
409
|
+
};
|
|
410
|
+
zones: ZoneRecord[];
|
|
411
|
+
}
|
|
412
|
+
interface ZoneAddressesResponse {
|
|
413
|
+
count: number;
|
|
414
|
+
query: {
|
|
415
|
+
id: number;
|
|
416
|
+
limit: number;
|
|
417
|
+
page: number;
|
|
418
|
+
};
|
|
419
|
+
results: Array<{
|
|
420
|
+
buildingName: string | null;
|
|
421
|
+
country: string;
|
|
422
|
+
flatNumber: string | null;
|
|
423
|
+
flatType: string | null;
|
|
424
|
+
id: number;
|
|
425
|
+
latitude: number;
|
|
426
|
+
locality: string;
|
|
427
|
+
longitude: number;
|
|
428
|
+
numberFirst: string | null;
|
|
429
|
+
numberLast: string | null;
|
|
430
|
+
postcode: string;
|
|
431
|
+
state: string;
|
|
432
|
+
streetName: string;
|
|
433
|
+
streetType: string | null;
|
|
434
|
+
}>;
|
|
435
|
+
truncated: boolean;
|
|
436
|
+
}
|
|
437
|
+
interface ZonesResource {
|
|
438
|
+
addresses(id: number, params?: ZoneAddressesParams, options?: CallOptions): Promise<ZoneAddressesResponse>;
|
|
439
|
+
contains(params: ZoneContainsParams, options?: CallOptions): Promise<ZoneContainsResponse>;
|
|
440
|
+
create(body: ZoneCreateBody, options?: CallOptions): Promise<ZoneRecord>;
|
|
441
|
+
delete(id: number, options?: CallOptions): Promise<ZoneDeleteResponse>;
|
|
442
|
+
get(id: number, options?: CallOptions): Promise<ZoneWithGeometry>;
|
|
443
|
+
list(params?: ZoneListParams, options?: CallOptions): Promise<ZoneListResponse>;
|
|
444
|
+
update(id: number, body: ZoneUpdateBody, options?: CallOptions): Promise<ZoneRecord>;
|
|
445
|
+
}
|
|
446
|
+
declare const createZones: (request: Requester) => ZonesResource;
|
|
447
|
+
|
|
448
|
+
interface WheraboutsClient {
|
|
449
|
+
addresses: AddressesResource;
|
|
450
|
+
devices: DevicesResource;
|
|
451
|
+
geocode: GeocodeResource;
|
|
452
|
+
regions: RegionsResource;
|
|
453
|
+
routing: RoutingResource;
|
|
454
|
+
webhooks: WebhooksResource;
|
|
455
|
+
zones: ZonesResource;
|
|
456
|
+
}
|
|
457
|
+
declare const createWheraboutsClient: (config: WheraboutsClientConfig) => WheraboutsClient;
|
|
458
|
+
|
|
459
|
+
declare class WheraboutsApiError extends Error {
|
|
460
|
+
readonly code: WheraboutsErrorCode | "unknown_error";
|
|
461
|
+
readonly payload: WheraboutsApiErrorPayload | null;
|
|
462
|
+
readonly status: number;
|
|
463
|
+
/** Correlation id from the `X-Request-Id` header or error body, if present. */
|
|
464
|
+
readonly requestId: string | null;
|
|
465
|
+
/** Documentation link for this error, if the API provided one. */
|
|
466
|
+
readonly docUrl: string | null;
|
|
467
|
+
/** Field-level validation detail, if the API provided any. */
|
|
468
|
+
readonly fields: WheraboutsFieldError[] | null;
|
|
469
|
+
constructor(options: {
|
|
470
|
+
code?: WheraboutsApiError["code"];
|
|
471
|
+
docUrl?: string | null;
|
|
472
|
+
fields?: WheraboutsFieldError[] | null;
|
|
473
|
+
message: string;
|
|
474
|
+
payload?: WheraboutsApiErrorPayload | null;
|
|
475
|
+
requestId?: string | null;
|
|
476
|
+
status: number;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export { type AddressRecord, type AddressSuggestion, type AddressesResource, type AutocompleteParams, type AutocompleteResponse, type BatchJobStatus, type BatchResultsResponse, type BatchSubmitBody, type BatchSubmitResponse, type BoundaryCrossing, type CallOptions, type CreateWebhookBody, type CreateWebhookResponse, type DeleteWebhookResponse, type DeviceZonesResponse, type DevicesResource, type DirectionsGeometry, type DirectionsParams, type DirectionsResponse, type ForwardGeocodeParams, type ForwardGeocodeResponse, type GeoJsonPolygon, type GeocodeAddress, type GeocodeResource, type ListWebhooksResponse, type NearbyAddress, type NearbyParams, type NearbyResponse, type PushLocationBody, type PushLocationResponse, type ReactivateWebhookResponse, type RegionMatch, type RegionsClassifyParams, type RegionsClassifyResponse, type RegionsResource, type ReverseGeocodeAddress, type ReverseParams, type ReverseResponse, type RoutingResource, WHERABOUTS_API_VERSION, WHERABOUTS_SDK_VERSION, type WebhookEvent, type WebhookListItem, type WebhookSubscription, type WebhooksResource, WheraboutsApiError, type WheraboutsApiErrorPayload, type WheraboutsClient, type WheraboutsClientConfig, type WheraboutsErrorCode, type WheraboutsFieldError, type ZoneAddressesParams, type ZoneAddressesResponse, type ZoneContainsParams, type ZoneContainsResponse, type ZoneCreateBody, type ZoneDeleteResponse, type ZoneListParams, type ZoneListResponse, type ZoneRecord, type ZoneUpdateBody, type ZoneWithGeometry, type ZonesResource, createAddresses, createDevices, createGeocode, createRegions, createRouting, createWebhooks, createWheraboutsClient, createZones };
|