geo-engine-node 1.1.2 → 2.0.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.d.ts CHANGED
@@ -1,110 +1,640 @@
1
- const DEFAULTS = {
2
- managementUrl: 'https://api.geoengine.dev',
3
- ingestUrl: 'https://ingest.geoengine.dev',
4
- timeout: 10000
5
- };
6
-
7
- class GeoEngine {
8
- /**
9
- * Inicializa el cliente de Geo-Engine.
10
- * @param {string} apiKey - Tu API Key.
11
- * @param {Object} [options] - Configuración opcional.
12
- */
13
- constructor(apiKey, options = {}) {
14
- if (!apiKey) {
15
- throw new Error('GeoEngine: API Key es requerida.');
16
- }
17
-
18
- this.apiKey = apiKey;
19
- this.config = { ...DEFAULTS, ...options };
20
- this.userAgent = 'GeoEngineNode/1.1.2';
21
- }
22
-
23
- /**
24
- * Helper privado para hacer peticiones con timeout
25
- */
26
- async _request(url, method, body) {
27
- const controller = new AbortController();
28
- const id = setTimeout(() => controller.abort(), this.config.timeout);
29
-
30
- try {
31
- const response = await fetch(url, {
32
- method: method,
33
- headers: {
34
- 'Content-Type': 'application/json',
35
- 'X-API-Key': this.apiKey,
36
- 'User-Agent': this.userAgent
37
- },
38
- body: JSON.stringify(body),
39
- signal: controller.signal
40
- });
41
-
42
- clearTimeout(id);
43
-
44
- if (!response.ok) {
45
- const errorText = await response.text();
46
- throw new Error(`GeoEngine API Error (${response.status}): ${errorText}`);
47
- }
48
-
49
- if (response.status === 204) return null;
50
-
51
- return await response.json();
52
- } catch (error) {
53
- clearTimeout(id);
54
- if (error.name === 'AbortError') {
55
- throw new Error(`GeoEngine: La petición excedió el tiempo límite de ${this.config.timeout}ms`);
56
- }
57
- throw error;
58
- }
59
- }
60
-
61
- /**
62
- * Envía una ubicación al motor de ingestión.
63
- */
64
- async sendLocation(deviceId, lat, lng) {
65
- if (!deviceId || lat === undefined || lng === undefined) {
66
- throw new Error("GeoEngine: deviceId, lat y lng son obligatorios.");
67
- }
1
+ /**
2
+ * Detailed error metadata returned by GeoEngine api-service.
3
+ */
4
+ interface SpatialErrorDetail {
5
+ '@type'?: string;
6
+ reason?: string;
7
+ domain?: string;
8
+ metadata?: Record<string, string>;
9
+ }
10
+ /**
11
+ * Base error class for all GeoEngine SDK exceptions.
12
+ */
13
+ declare class GeoEngineError extends Error {
14
+ constructor(message: string);
15
+ }
16
+ /**
17
+ * Error thrown when an operation is attempted on a closed client instance.
18
+ * Equivalent to Go's ErrClientClosed.
19
+ */
20
+ declare class ClientClosedError extends GeoEngineError {
21
+ constructor(message?: string);
22
+ }
23
+ /**
24
+ * Error thrown when a client-side parameter validation fails.
25
+ */
26
+ declare class ValidationError extends GeoEngineError {
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Error thrown when device_id is missing or empty.
31
+ * Equivalent to Go's ErrDeviceIDRequired.
32
+ */
33
+ declare class DeviceIDRequiredError extends ValidationError {
34
+ constructor(message?: string);
35
+ }
36
+ /**
37
+ * Error thrown when a geofence_id is missing or empty.
38
+ * Equivalent to Go's ErrGeofenceIDRequired.
39
+ */
40
+ declare class GeofenceIDRequiredError extends ValidationError {
41
+ constructor(message?: string);
42
+ }
43
+ /**
44
+ * Error thrown when latitude falls outside the valid range [-90, 90].
45
+ * Equivalent to Go's ErrInvalidLatitude.
46
+ */
47
+ declare class InvalidLatitudeError extends ValidationError {
48
+ constructor(message?: string);
49
+ }
50
+ /**
51
+ * Error thrown when longitude falls outside the valid range [-180, 180].
52
+ * Equivalent to Go's ErrInvalidLongitude.
53
+ */
54
+ declare class InvalidLongitudeError extends ValidationError {
55
+ constructor(message?: string);
56
+ }
57
+ /**
58
+ * Error thrown when coordinate polygon validation fails.
59
+ * Equivalent to Go's ErrInvalidCoordinates.
60
+ */
61
+ declare class InvalidCoordinatesError extends ValidationError {
62
+ constructor(message?: string);
63
+ }
64
+ /**
65
+ * Represents an HTTP error returned by the GeoEngine REST or Management API.
66
+ * Equivalent to Go's APIError.
67
+ */
68
+ declare class APIError extends GeoEngineError {
69
+ readonly statusCode: number;
70
+ constructor(statusCode: number, message: string);
71
+ }
72
+ /**
73
+ * Represents a structured error returned by GeoEngine api-service.
74
+ * Equivalent to Go's SpatialAPIError.
75
+ */
76
+ declare class SpatialAPIError extends APIError {
77
+ readonly code: string;
78
+ readonly statusText?: string;
79
+ readonly details: SpatialErrorDetail[];
80
+ constructor(statusCode: number, code: string, message: string, statusText?: string, details?: SpatialErrorDetail[]);
81
+ /**
82
+ * Returns true if the error indicates the geofence or resource was not found.
83
+ */
84
+ isNotFound(): boolean;
85
+ /**
86
+ * Returns true if the error indicates quota limit was hit.
87
+ */
88
+ isQuotaExceeded(): boolean;
89
+ /**
90
+ * Returns true if authentication failed.
91
+ */
92
+ isUnauthorized(): boolean;
93
+ /**
94
+ * Returns true if access to the requested resource is forbidden.
95
+ */
96
+ isForbidden(): boolean;
97
+ }
98
+ /**
99
+ * Specific error thrown when a geofence is not found (204 or 404).
100
+ * Equivalent to Go's ErrGeofenceNotFound.
101
+ */
102
+ declare class GeofenceNotFoundError extends SpatialAPIError {
103
+ constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
104
+ }
105
+ /**
106
+ * Specific error thrown when request quota limit is exceeded (HTTP 402 or 429).
107
+ * Equivalent to Go's ErrQuotaExceeded.
108
+ */
109
+ declare class QuotaExceededError extends SpatialAPIError {
110
+ constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
111
+ }
112
+ /**
113
+ * Specific error thrown when API authentication fails (HTTP 401).
114
+ * Equivalent to Go's ErrUnauthorized.
115
+ */
116
+ declare class AuthenticationError extends SpatialAPIError {
117
+ constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
118
+ }
119
+ /**
120
+ * Specific error thrown when access is forbidden (HTTP 403).
121
+ * Equivalent to Go's ErrForbidden.
122
+ */
123
+ declare class ForbiddenError extends SpatialAPIError {
124
+ constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
125
+ }
126
+ /**
127
+ * Error thrown when a network request exceeds its deadline or timeout limit.
128
+ */
129
+ declare class TimeoutError extends GeoEngineError {
130
+ constructor(timeoutMs: number);
131
+ }
68
132
 
69
- const payload = {
70
- device_id: deviceId,
71
- latitude: parseFloat(lat),
72
- longitude: parseFloat(lng),
73
- timestamp: Math.floor(Date.now() / 1000)
133
+ /**
134
+ * Configuration options for the GeoEngine Client.
135
+ * Matches and extends Go SDK Options.
136
+ */
137
+ interface GeoEngineOptions {
138
+ /**
139
+ * Secret API key. Can also be passed directly as first parameter to constructor.
140
+ */
141
+ apiKey?: string;
142
+ /**
143
+ * Bearer JWT token for authenticated operations.
144
+ */
145
+ jwtToken?: string;
146
+ /**
147
+ * Target environment ('live' or 'test'). Defaults to 'live'.
148
+ */
149
+ environment?: 'live' | 'test' | string;
150
+ /**
151
+ * Management service URL for geofences and administrative operations.
152
+ * Default: 'https://management.geoengine.dev'
153
+ */
154
+ managementUrl?: string;
155
+ /**
156
+ * Ingestion service URL for telemetry coordinates.
157
+ * Default: 'https://ingest.geoengine.dev'
158
+ */
159
+ ingestUrl?: string;
160
+ /**
161
+ * Spatial API service URL for spatial validation queries.
162
+ * Default: 'https://api.geoengine.dev'
163
+ */
164
+ apiServiceUrl?: string;
165
+ /**
166
+ * Convenience option to set ingestUrl, managementUrl, and apiServiceUrl to the same base URL (useful for testing/mocking).
167
+ */
168
+ baseUrl?: string;
169
+ /**
170
+ * HTTP request timeout in milliseconds. Default: 10000ms (10 seconds).
171
+ */
172
+ timeout?: number;
173
+ /**
174
+ * Maximum number of automatic retries on network failures or 429/5xx status codes.
175
+ * Default: 2.
176
+ */
177
+ maxRetries?: number;
178
+ /**
179
+ * Maximum batch size before flushing in AsyncIngester. Default: 100.
180
+ */
181
+ batchSize?: number;
182
+ /**
183
+ * Flush interval in milliseconds for AsyncIngester. Default: 500ms.
184
+ */
185
+ flushInterval?: number;
186
+ /**
187
+ * Buffer capacity for AsyncIngester queue. Default: 5000.
188
+ */
189
+ bufferSize?: number;
190
+ /**
191
+ * Custom fetch implementation (useful for testing or custom polyfills).
192
+ */
193
+ fetch?: typeof globalThis extends {
194
+ fetch: infer Fetch;
195
+ } ? Fetch : (...args: unknown[]) => Promise<unknown>;
196
+ }
197
+ /**
198
+ * Single telemetry ping matching PostGIS location_history and Go LocationPing.
199
+ */
200
+ interface LocationPing {
201
+ deviceId: string;
202
+ latitude: number;
203
+ longitude: number;
204
+ accuracy?: number;
205
+ speed?: number;
206
+ heading?: number;
207
+ timestamp?: number;
208
+ isMocked?: boolean;
209
+ }
210
+ /**
211
+ * Ingestion response status matching Go IngestResponse.
212
+ */
213
+ interface IngestResponse {
214
+ success: boolean;
215
+ processedCount: number;
216
+ errorMessage?: string;
217
+ }
218
+ /**
219
+ * Parameters for creating a geofence.
220
+ */
221
+ interface GeofenceRequest {
222
+ name: string;
223
+ description?: string;
224
+ color?: string;
225
+ webhookUrl?: string;
226
+ geojson: {
227
+ type: 'Polygon';
228
+ coordinates: number[][][];
74
229
  };
230
+ }
231
+ /**
232
+ * Parameters for validating a point against a specific geofence.
233
+ */
234
+ interface SpatialValidationRequest {
235
+ geofenceId: string;
236
+ latitude: number;
237
+ longitude: number;
238
+ }
239
+ interface SpatialValidationResultData {
240
+ inside: boolean;
241
+ geofence_id?: string;
242
+ geofenceId?: string;
243
+ geofence_name?: string;
244
+ geofenceName?: string;
245
+ latitude: number;
246
+ longitude: number;
247
+ }
248
+ /**
249
+ * Represents the validation result for a single geofence.
250
+ * Enriched class matching Go's SpatialValidationResult with helper methods.
251
+ */
252
+ declare class SpatialValidationResult {
253
+ readonly inside: boolean;
254
+ readonly geofenceId: string;
255
+ readonly geofenceName?: string;
256
+ readonly latitude: number;
257
+ readonly longitude: number;
258
+ constructor(data: SpatialValidationResultData);
259
+ /**
260
+ * Returns true if the coordinate is inside the geofence.
261
+ */
262
+ isInside(): boolean;
263
+ /**
264
+ * Returns true if the coordinate is outside the geofence.
265
+ */
266
+ isOutside(): boolean;
267
+ /**
268
+ * Returns latitude and longitude as a [latitude, longitude] tuple.
269
+ */
270
+ coordinates(): [number, number];
271
+ /**
272
+ * Formats the result into a clean, human-readable log string matching Go's String().
273
+ */
274
+ toString(): string;
275
+ }
276
+ /**
277
+ * Parameters for validating a point against all active geofences in the organization.
278
+ */
279
+ interface SpatialGeneralRequest {
280
+ latitude: number;
281
+ longitude: number;
282
+ }
283
+ /**
284
+ * Represents a matched geofence in general validation.
285
+ */
286
+ interface GeofenceMatch {
287
+ id: string;
288
+ name: string;
289
+ }
290
+ interface SpatialGeneralResultData {
291
+ inside: boolean;
292
+ total_matches?: number;
293
+ totalMatches?: number;
294
+ matched_geofences?: GeofenceMatch[];
295
+ matchedGeofences?: GeofenceMatch[];
296
+ latitude: number;
297
+ longitude: number;
298
+ }
299
+ /**
300
+ * Represents the result of validating a point against all active geofences.
301
+ * Enriched class matching Go's SpatialGeneralResult with helper methods.
302
+ */
303
+ declare class SpatialGeneralResult {
304
+ readonly inside: boolean;
305
+ readonly totalMatches: number;
306
+ readonly matchedGeofences: GeofenceMatch[];
307
+ readonly latitude: number;
308
+ readonly longitude: number;
309
+ constructor(data: SpatialGeneralResultData);
310
+ /**
311
+ * Returns true if the coordinate falls inside at least one geofence.
312
+ */
313
+ isInside(): boolean;
314
+ /**
315
+ * Returns true if one or more geofences matched the point.
316
+ */
317
+ hasMatches(): boolean;
318
+ /**
319
+ * Returns the first matched geofence, or null if no matches found.
320
+ */
321
+ firstMatch(): GeofenceMatch | null;
322
+ /**
323
+ * Returns all matched geofence IDs as a string array.
324
+ */
325
+ geofenceIds(): string[];
326
+ /**
327
+ * Returns all matched geofence names as a string array.
328
+ */
329
+ geofenceNames(): string[];
330
+ /**
331
+ * Checks whether a specific geofence ID or name is among the matches.
332
+ */
333
+ containsGeofence(idOrName: string): boolean;
334
+ /**
335
+ * Searches for a matched geofence by ID or name and returns it if found, or null.
336
+ */
337
+ findMatch(idOrName: string): GeofenceMatch | null;
338
+ /**
339
+ * Returns latitude and longitude as a [latitude, longitude] tuple.
340
+ */
341
+ coordinates(): [number, number];
342
+ /**
343
+ * Formats the result into a clean, human-readable log string matching Go's String().
344
+ */
345
+ toString(): string;
346
+ }
75
347
 
76
- return this._request(`${this.config.ingestUrl}/ingest`, 'POST', payload);
77
- }
348
+ interface RequestOptions {
349
+ method?: string;
350
+ endpoint: string;
351
+ body?: unknown;
352
+ timeout?: number;
353
+ isSpatial?: boolean;
354
+ }
355
+ interface HttpClientConfig {
356
+ apiKey: string;
357
+ jwtToken?: string;
358
+ environment: string;
359
+ managementUrl: string;
360
+ ingestUrl: string;
361
+ apiServiceUrl: string;
362
+ timeout: number;
363
+ maxRetries: number;
364
+ batchSize: number;
365
+ flushInterval: number;
366
+ bufferSize: number;
367
+ fetch: (...args: any[]) => Promise<any>;
368
+ }
369
+ /**
370
+ * Robust HTTP client handling authentication headers, HMAC generation,
371
+ * timeouts via AbortController, and exponential backoff retries.
372
+ */
373
+ declare class HttpClient {
374
+ private readonly config;
375
+ constructor(options?: GeoEngineOptions);
376
+ get options(): Readonly<HttpClientConfig>;
377
+ /**
378
+ * Executes an HTTP request with timeout, authentication headers and exponential backoff retry.
379
+ */
380
+ request<T>(opts: RequestOptions): Promise<T>;
381
+ }
78
382
 
79
- /**
80
- * Crea una nueva geocerca.
81
- */
82
- async createGeofence(name, coordinates, webhookUrl) {
83
- if (!name || !coordinates || coordinates.length < 3) {
84
- throw new Error("GeoEngine: Se requiere un nombre y al menos 3 coordenadas.");
85
- }
383
+ interface IngesterClient {
384
+ sendLocation(deviceId: string, lat: number, lng: number): Promise<void | unknown>;
385
+ }
386
+ /**
387
+ * Manages an in-memory queue for background batch ingestion of location telemetry.
388
+ * Equivalent to Go's AsyncIngester.
389
+ */
390
+ declare class AsyncIngester {
391
+ private readonly client;
392
+ private readonly bufferSize;
393
+ private readonly batchSize;
394
+ private readonly intervalMs;
395
+ private readonly queue;
396
+ private readonly inFlightPromises;
397
+ private timer;
398
+ private isClosed;
399
+ constructor(client: IngesterClient, bufferSize?: number, batchSize?: number, flushIntervalMs?: number);
400
+ /**
401
+ * Non-blockingly appends a location ping to the ingestion buffer queue.
402
+ *
403
+ * @param ping Location ping object
404
+ * @returns true if successfully queued, false if queue is full or ingester is stopped
405
+ */
406
+ enqueue(ping: LocationPing | null | undefined): boolean;
407
+ /**
408
+ * Flushes current queued batch of location telemetry items.
409
+ */
410
+ flush(): Promise<void>;
411
+ /**
412
+ * Drains all remaining pending items, halts worker timer, and releases resources.
413
+ * Safe to call multiple times.
414
+ */
415
+ stop(): Promise<void>;
416
+ }
86
417
 
87
- // Convertir formato simple [[lat,lng]] a GeoJSON [Lng, Lat]
88
- const polygon = coordinates.map(p => [p[1], p[0]]);
418
+ /**
419
+ * Handles point-in-polygon and spatial validation against the GeoEngine api-service.
420
+ * Equivalent to Go's SpatialService.
421
+ */
422
+ declare class SpatialService {
423
+ private readonly http;
424
+ constructor(http: HttpClient);
425
+ /**
426
+ * Convenience method to check if coordinates fall within a specific geofence.
427
+ *
428
+ * @param geofenceId Unique identifier of the geofence
429
+ * @param lat Decimal latitude [-90, 90]
430
+ * @param lng Decimal longitude [-180, 180]
431
+ * @returns SpatialValidationResult
432
+ */
433
+ validatePoint(geofenceId: string, lat: number, lng: number): Promise<SpatialValidationResult>;
434
+ /**
435
+ * Checks if coordinates fall inside the specified geofence using the api-service.
436
+ *
437
+ * @param req SpatialValidationRequest containing geofenceId, latitude, and longitude
438
+ * @returns SpatialValidationResult
439
+ */
440
+ validateLocation(req: SpatialValidationRequest): Promise<SpatialValidationResult>;
441
+ /**
442
+ * Checks whether coordinates intersect any geofence belonging to the organization.
443
+ *
444
+ * @param lat Decimal latitude [-90, 90]
445
+ * @param lng Decimal longitude [-180, 180]
446
+ * @returns SpatialGeneralResult
447
+ */
448
+ validateGeneral(lat: number, lng: number): Promise<SpatialGeneralResult>;
449
+ /**
450
+ * Checks whether coordinates intersect any geofence using the api-service.
451
+ *
452
+ * @param req SpatialGeneralRequest containing latitude and longitude
453
+ * @returns SpatialGeneralResult
454
+ */
455
+ validateGeneralLocation(req: SpatialGeneralRequest): Promise<SpatialGeneralResult>;
456
+ /**
457
+ * Initializes a fluent query builder for spatial coordinate validation.
458
+ *
459
+ * @param lat Decimal latitude
460
+ * @param lng Decimal longitude
461
+ * @returns SpatialCheckBuilder
462
+ */
463
+ check(lat: number, lng: number): SpatialCheckBuilder;
464
+ }
465
+ /**
466
+ * Fluent query builder for spatial evaluation operations.
467
+ * Equivalent to Go's SpatialCheckBuilder.
468
+ */
469
+ declare class SpatialCheckBuilder {
470
+ private readonly service;
471
+ private readonly lat;
472
+ private readonly lng;
473
+ constructor(service: SpatialService, lat: number, lng: number);
474
+ /**
475
+ * Configures validation targeting a specific geofence ID.
476
+ */
477
+ inGeofence(geofenceId: string): SingleGeofenceCheck;
478
+ /**
479
+ * Configures validation against all organization geofences.
480
+ */
481
+ inAllGeofences(): GeneralGeofenceCheck;
482
+ }
483
+ /**
484
+ * Evaluates coordinate containment inside a specific geofence.
485
+ * Equivalent to Go's SingleGeofenceCheck.
486
+ */
487
+ declare class SingleGeofenceCheck {
488
+ private readonly service;
489
+ private readonly geofenceId;
490
+ private readonly lat;
491
+ private readonly lng;
492
+ constructor(service: SpatialService, geofenceId: string, lat: number, lng: number);
493
+ /**
494
+ * Performs the single geofence spatial query.
495
+ */
496
+ execute(): Promise<SpatialValidationResult>;
497
+ /**
498
+ * Alias for execute().
499
+ */
500
+ executeSingle(): Promise<SpatialValidationResult>;
501
+ /**
502
+ * Alias for execute().
503
+ */
504
+ validate(): Promise<SpatialValidationResult>;
505
+ }
506
+ /**
507
+ * Evaluates coordinate containment across all organization geofences.
508
+ * Equivalent to Go's GeneralGeofenceCheck.
509
+ */
510
+ declare class GeneralGeofenceCheck {
511
+ private readonly service;
512
+ private readonly lat;
513
+ private readonly lng;
514
+ constructor(service: SpatialService, lat: number, lng: number);
515
+ /**
516
+ * Performs the general spatial query against all organization geofences.
517
+ */
518
+ execute(): Promise<SpatialGeneralResult>;
519
+ /**
520
+ * Alias for execute().
521
+ */
522
+ executeGeneral(): Promise<SpatialGeneralResult>;
523
+ /**
524
+ * Alias for execute().
525
+ */
526
+ validate(): Promise<SpatialGeneralResult>;
527
+ }
89
528
 
90
- // Cerrar polígono automáticamente
91
- const first = polygon[0];
92
- const last = polygon[polygon.length - 1];
93
- if (first[0] !== last[0] || first[1] !== last[1]) {
94
- polygon.push(first);
95
- }
529
+ /**
530
+ * GeoEngine Client for interacting with GeoEngine APIs over HTTP REST.
531
+ * Equivalent to Go's Client struct.
532
+ */
533
+ declare class GeoEngine {
534
+ private readonly http;
535
+ private isClosed;
536
+ /**
537
+ * Spatial provides point-in-polygon querying and geofence validation capabilities.
538
+ */
539
+ readonly spatial: SpatialService;
540
+ /**
541
+ * Alias for spatial (to maintain exact casing compatibility with Go client.Spatial).
542
+ */
543
+ readonly Spatial: SpatialService;
544
+ /**
545
+ * Initializes a new GeoEngine client instance.
546
+ *
547
+ * @param apiKey Your GeoEngine API Key (required)
548
+ * @param options Optional configuration parameters
549
+ */
550
+ constructor(apiKeyOrOptions: string | GeoEngineOptions, maybeOptions?: GeoEngineOptions);
551
+ /**
552
+ * Current configuration options.
553
+ */
554
+ get options(): Readonly<HttpClientConfig>;
555
+ /**
556
+ * Sends device coordinates over HTTP REST.
557
+ * Equivalent to Go's Client.SendLocation.
558
+ *
559
+ * @param deviceId Unique vehicle/device identifier
560
+ * @param lat Decimal latitude
561
+ * @param lng Decimal longitude
562
+ */
563
+ sendLocation(deviceId: string, lat: number, lng: number): Promise<void>;
564
+ /**
565
+ * Creates a spatial geofence polygon in PostGIS via the management REST API.
566
+ * Automatically validates and closes the polygon ring.
567
+ * Equivalent to Go's Client.CreateGeofence.
568
+ *
569
+ * @param name Geofence name
570
+ * @param coordinates Array of [latitude, longitude] pairs (at least 3 coordinates)
571
+ * @param webhookUrl Optional webhook URL triggered upon enter/exit
572
+ */
573
+ createGeofence(name: string, coordinates: Array<[number, number] | number[]>, webhookUrl?: string): Promise<unknown>;
574
+ /**
575
+ * Validates if coordinates fall within a geofence by ID via the Spatial service.
576
+ * Shortcut matching Go's Client.ValidateSpatialPoint.
577
+ */
578
+ validateSpatialPoint(geofenceId: string, lat: number, lng: number): Promise<SpatialValidationResult>;
579
+ /**
580
+ * Validates if coordinates fall within a geofence via the Spatial service.
581
+ * Shortcut matching Go's Client.ValidateSpatialLocation.
582
+ */
583
+ validateSpatialLocation(req: SpatialValidationRequest): Promise<SpatialValidationResult>;
584
+ /**
585
+ * Validates coordinates against all active geofences via the Spatial service.
586
+ * Shortcut matching Go's Client.ValidateSpatialGeneral.
587
+ */
588
+ validateSpatialGeneral(lat: number, lng: number): Promise<SpatialGeneralResult>;
589
+ /**
590
+ * Validates coordinates against all active geofences via the Spatial service.
591
+ * Shortcut matching Go's Client.ValidateSpatialGeneralLocation.
592
+ */
593
+ validateSpatialGeneralLocation(req: SpatialGeneralRequest): Promise<SpatialGeneralResult>;
594
+ /**
595
+ * Instantiates a new AsyncIngester connected to this client.
596
+ * Matches Go NewAsyncIngester.
597
+ *
598
+ * @param bufferSize Queue buffer capacity (default: options.bufferSize ?? 5000)
599
+ * @param batchSize Batch size before flushing (default: options.batchSize ?? 100)
600
+ * @param flushIntervalMs Flush interval in ms (default: options.flushInterval ?? 500)
601
+ */
602
+ createAsyncIngester(bufferSize?: number, batchSize?: number, flushIntervalMs?: number): AsyncIngester;
603
+ /**
604
+ * Closes the client, marking it inactive. Idempotent.
605
+ * Subsequent requests will throw ClientClosedError.
606
+ * Equivalent to Go's Client.Close.
607
+ */
608
+ close(): void;
609
+ }
96
610
 
97
- const payload = {
98
- name,
99
- webhook_url: webhookUrl,
100
- geojson: {
101
- type: 'Polygon',
102
- coordinates: [polygon]
103
- }
104
- };
611
+ /**
612
+ * Validates that latitude is between -90 and 90, and longitude is between -180 and 180 degrees.
613
+ * Equivalent to Go's ValidateCoordinates(lat, lng).
614
+ */
615
+ declare function validateCoordinates(lat: number, lng: number): void;
616
+ /**
617
+ * Validates that device ID is provided and not empty.
618
+ */
619
+ declare function validateDeviceId(deviceId: string): string;
620
+ /**
621
+ * Validates that geofence ID is provided and not empty.
622
+ */
623
+ declare function validateGeofenceId(geofenceId: string): string;
624
+ /**
625
+ * Validates coordinate array of [lat, lng] pairs for polygon creation,
626
+ * converts to GeoJSON [lng, lat] and ensures the linear ring is closed.
627
+ */
628
+ declare function validateAndNormalizePolygon(coordinates: Array<[number, number] | number[]>): [number, number][];
105
629
 
106
- return this._request(`${this.config.managementUrl}/geofences`, 'POST', payload);
107
- }
108
- }
630
+ /**
631
+ * Generates an HMAC-SHA256 signature from the API key and timestamp (in milliseconds).
632
+ * Matches the Go SDK Client.generateHMACSignature implementation.
633
+ *
634
+ * @param key The API secret key used as the HMAC secret
635
+ * @param timestamp Epoch timestamp in milliseconds
636
+ * @returns 64-character lowercase hexadecimal hash
637
+ */
638
+ declare function generateHMACSignature(key: string, timestamp: number): string;
109
639
 
110
- export { GeoEngine as default };
640
+ export { APIError, AsyncIngester, AuthenticationError, GeoEngine as Client, ClientClosedError, DeviceIDRequiredError, ForbiddenError, GeneralGeofenceCheck, GeoEngine, GeoEngineError, type GeoEngineOptions, GeofenceIDRequiredError, type GeofenceMatch, GeofenceNotFoundError, type GeofenceRequest, type HttpClientConfig, type IngestResponse, type IngesterClient, InvalidCoordinatesError, InvalidLatitudeError, InvalidLongitudeError, type LocationPing, QuotaExceededError, SingleGeofenceCheck, SpatialAPIError, SpatialCheckBuilder, type SpatialErrorDetail, type SpatialGeneralRequest, SpatialGeneralResult, type SpatialGeneralResultData, SpatialService, type SpatialValidationRequest, SpatialValidationResult, type SpatialValidationResultData, TimeoutError, ValidationError, GeoEngine as default, generateHMACSignature, validateAndNormalizePolygon, validateCoordinates, validateDeviceId, validateGeofenceId };