geo-engine-node 1.1.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +391 -0
- package/Readme.md +326 -67
- package/dist/index.cjs +1432 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +987 -0
- package/dist/index.d.ts +987 -0
- package/dist/index.js +1358 -0
- package/dist/index.js.map +1 -0
- package/package.json +20 -9
- package/.idea/modules.xml +0 -8
- package/.idea/node.js.iml +0 -8
- package/index.js +0 -110
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,987 @@
|
|
|
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
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Error thrown when a user ID is missing or empty.
|
|
134
|
+
* Equivalent to Go's ErrUserIDRequired.
|
|
135
|
+
*/
|
|
136
|
+
declare class UserIDRequiredError extends ValidationError {
|
|
137
|
+
constructor(message?: string);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Error thrown when a GeoIdentity rule ID is missing or empty.
|
|
141
|
+
* Equivalent to Go's ErrRuleIDRequired.
|
|
142
|
+
*/
|
|
143
|
+
declare class RuleIDRequiredError extends ValidationError {
|
|
144
|
+
constructor(message?: string);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Error thrown when a GeoIdentity rule name is missing or empty.
|
|
148
|
+
* Equivalent to Go's ErrRuleNameRequired.
|
|
149
|
+
*/
|
|
150
|
+
declare class RuleNameRequiredError extends ValidationError {
|
|
151
|
+
constructor(message?: string);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Error thrown when an invitation email is missing or empty.
|
|
155
|
+
* Equivalent to Go's ErrEmailRequired.
|
|
156
|
+
*/
|
|
157
|
+
declare class EmailRequiredError extends ValidationError {
|
|
158
|
+
constructor(message?: string);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Error thrown when a role is missing or empty.
|
|
162
|
+
* Equivalent to Go's ErrRoleRequired.
|
|
163
|
+
*/
|
|
164
|
+
declare class RoleRequiredError extends ValidationError {
|
|
165
|
+
constructor(message?: string);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Structured error returned by the api-service Users and GeoIdentity endpoints.
|
|
169
|
+
* Equivalent to Go's APIServiceError. Branch on the subclasses (for example
|
|
170
|
+
* UserNotFoundError) or on `code`.
|
|
171
|
+
*/
|
|
172
|
+
declare class APIServiceError extends APIError {
|
|
173
|
+
/** Machine-readable reason, e.g. "USER_NOT_FOUND". Empty when the API sent none. */
|
|
174
|
+
readonly code: string;
|
|
175
|
+
/** Message returned by the API, without the SDK prefix. */
|
|
176
|
+
readonly apiMessage: string;
|
|
177
|
+
readonly details: SpatialErrorDetail[];
|
|
178
|
+
constructor(statusCode: number, code: string, message: string, details?: SpatialErrorDetail[]);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The user does not exist in the organization (or its access was revoked).
|
|
182
|
+
* Equivalent to Go's ErrUserNotFound.
|
|
183
|
+
*/
|
|
184
|
+
declare class UserNotFoundError extends APIServiceError {
|
|
185
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The GeoIdentity rule does not exist.
|
|
189
|
+
* Equivalent to Go's ErrRuleNotFound.
|
|
190
|
+
*/
|
|
191
|
+
declare class RuleNotFoundError extends APIServiceError {
|
|
192
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The invited email already belongs to the organization.
|
|
196
|
+
* Equivalent to Go's ErrUserAlreadyExists.
|
|
197
|
+
*/
|
|
198
|
+
declare class UserAlreadyExistsError extends APIServiceError {
|
|
199
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* A pending invitation already exists for the email.
|
|
203
|
+
* Equivalent to Go's ErrInvitationPending.
|
|
204
|
+
*/
|
|
205
|
+
declare class InvitationPendingError extends APIServiceError {
|
|
206
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The operation would leave the organization without an admin.
|
|
210
|
+
* Equivalent to Go's ErrLastAdmin.
|
|
211
|
+
*/
|
|
212
|
+
declare class LastAdminError extends APIServiceError {
|
|
213
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The operation would leave a rule without assigned subjects.
|
|
217
|
+
* Equivalent to Go's ErrLastSubject.
|
|
218
|
+
*/
|
|
219
|
+
declare class LastSubjectError extends APIServiceError {
|
|
220
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Configuration options for the GeoEngine Client.
|
|
225
|
+
* Matches and extends Go SDK Options.
|
|
226
|
+
*/
|
|
227
|
+
interface GeoEngineOptions {
|
|
228
|
+
/**
|
|
229
|
+
* Secret API key. Can also be passed directly as first parameter to constructor.
|
|
230
|
+
*/
|
|
231
|
+
apiKey?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Bearer JWT token for authenticated operations.
|
|
234
|
+
*/
|
|
235
|
+
jwtToken?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Target environment ('live' or 'test'). Defaults to 'live'.
|
|
238
|
+
*/
|
|
239
|
+
environment?: 'live' | 'test' | string;
|
|
240
|
+
/**
|
|
241
|
+
* Management service URL for geofences and administrative operations.
|
|
242
|
+
* Default: 'https://management.geoengine.dev'
|
|
243
|
+
*/
|
|
244
|
+
managementUrl?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Ingestion service URL for telemetry coordinates.
|
|
247
|
+
* Default: 'https://ingest.geoengine.dev'
|
|
248
|
+
*/
|
|
249
|
+
ingestUrl?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Spatial API service URL for spatial validation queries.
|
|
252
|
+
* Default: 'https://api.geoengine.dev'
|
|
253
|
+
*/
|
|
254
|
+
apiServiceUrl?: string;
|
|
255
|
+
/**
|
|
256
|
+
* Convenience option to set ingestUrl, managementUrl, and apiServiceUrl to the same base URL (useful for testing/mocking).
|
|
257
|
+
*/
|
|
258
|
+
baseUrl?: string;
|
|
259
|
+
/**
|
|
260
|
+
* HTTP request timeout in milliseconds. Default: 10000ms (10 seconds).
|
|
261
|
+
*/
|
|
262
|
+
timeout?: number;
|
|
263
|
+
/**
|
|
264
|
+
* Maximum number of automatic retries on network failures or 429/5xx status codes.
|
|
265
|
+
* Default: 2.
|
|
266
|
+
*/
|
|
267
|
+
maxRetries?: number;
|
|
268
|
+
/**
|
|
269
|
+
* Maximum batch size before flushing in AsyncIngester. Default: 100.
|
|
270
|
+
*/
|
|
271
|
+
batchSize?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Flush interval in milliseconds for AsyncIngester. Default: 500ms.
|
|
274
|
+
*/
|
|
275
|
+
flushInterval?: number;
|
|
276
|
+
/**
|
|
277
|
+
* Buffer capacity for AsyncIngester queue. Default: 5000.
|
|
278
|
+
*/
|
|
279
|
+
bufferSize?: number;
|
|
280
|
+
/**
|
|
281
|
+
* Custom fetch implementation (useful for testing or custom polyfills).
|
|
282
|
+
*/
|
|
283
|
+
fetch?: typeof globalThis extends {
|
|
284
|
+
fetch: infer Fetch;
|
|
285
|
+
} ? Fetch : (...args: unknown[]) => Promise<unknown>;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Single telemetry ping matching PostGIS location_history and Go LocationPing.
|
|
289
|
+
*/
|
|
290
|
+
interface LocationPing {
|
|
291
|
+
deviceId: string;
|
|
292
|
+
latitude: number;
|
|
293
|
+
longitude: number;
|
|
294
|
+
accuracy?: number;
|
|
295
|
+
speed?: number;
|
|
296
|
+
heading?: number;
|
|
297
|
+
timestamp?: number;
|
|
298
|
+
isMocked?: boolean;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Ingestion response status matching Go IngestResponse.
|
|
302
|
+
*/
|
|
303
|
+
interface IngestResponse {
|
|
304
|
+
success: boolean;
|
|
305
|
+
processedCount: number;
|
|
306
|
+
errorMessage?: string;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Parameters for creating a geofence.
|
|
310
|
+
*/
|
|
311
|
+
interface GeofenceRequest {
|
|
312
|
+
name: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
color?: string;
|
|
315
|
+
webhookUrl?: string;
|
|
316
|
+
geojson: {
|
|
317
|
+
type: 'Polygon';
|
|
318
|
+
coordinates: number[][][];
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Parameters for validating a point against a specific geofence.
|
|
323
|
+
*/
|
|
324
|
+
interface SpatialValidationRequest {
|
|
325
|
+
geofenceId: string;
|
|
326
|
+
latitude: number;
|
|
327
|
+
longitude: number;
|
|
328
|
+
}
|
|
329
|
+
interface SpatialValidationResultData {
|
|
330
|
+
inside: boolean;
|
|
331
|
+
geofence_id?: string;
|
|
332
|
+
geofenceId?: string;
|
|
333
|
+
geofence_name?: string;
|
|
334
|
+
geofenceName?: string;
|
|
335
|
+
latitude: number;
|
|
336
|
+
longitude: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Represents the validation result for a single geofence.
|
|
340
|
+
* Enriched class matching Go's SpatialValidationResult with helper methods.
|
|
341
|
+
*/
|
|
342
|
+
declare class SpatialValidationResult {
|
|
343
|
+
readonly inside: boolean;
|
|
344
|
+
readonly geofenceId: string;
|
|
345
|
+
readonly geofenceName?: string;
|
|
346
|
+
readonly latitude: number;
|
|
347
|
+
readonly longitude: number;
|
|
348
|
+
constructor(data: SpatialValidationResultData);
|
|
349
|
+
/**
|
|
350
|
+
* Returns true if the coordinate is inside the geofence.
|
|
351
|
+
*/
|
|
352
|
+
isInside(): boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Returns true if the coordinate is outside the geofence.
|
|
355
|
+
*/
|
|
356
|
+
isOutside(): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Returns latitude and longitude as a [latitude, longitude] tuple.
|
|
359
|
+
*/
|
|
360
|
+
coordinates(): [number, number];
|
|
361
|
+
/**
|
|
362
|
+
* Formats the result into a clean, human-readable log string matching Go's String().
|
|
363
|
+
*/
|
|
364
|
+
toString(): string;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Parameters for validating a point against all active geofences in the organization.
|
|
368
|
+
*/
|
|
369
|
+
interface SpatialGeneralRequest {
|
|
370
|
+
latitude: number;
|
|
371
|
+
longitude: number;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Represents a matched geofence in general validation.
|
|
375
|
+
*/
|
|
376
|
+
interface GeofenceMatch {
|
|
377
|
+
id: string;
|
|
378
|
+
name: string;
|
|
379
|
+
}
|
|
380
|
+
interface SpatialGeneralResultData {
|
|
381
|
+
inside: boolean;
|
|
382
|
+
total_matches?: number;
|
|
383
|
+
totalMatches?: number;
|
|
384
|
+
matched_geofences?: GeofenceMatch[];
|
|
385
|
+
matchedGeofences?: GeofenceMatch[];
|
|
386
|
+
latitude: number;
|
|
387
|
+
longitude: number;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Represents the result of validating a point against all active geofences.
|
|
391
|
+
* Enriched class matching Go's SpatialGeneralResult with helper methods.
|
|
392
|
+
*/
|
|
393
|
+
declare class SpatialGeneralResult {
|
|
394
|
+
readonly inside: boolean;
|
|
395
|
+
readonly totalMatches: number;
|
|
396
|
+
readonly matchedGeofences: GeofenceMatch[];
|
|
397
|
+
readonly latitude: number;
|
|
398
|
+
readonly longitude: number;
|
|
399
|
+
constructor(data: SpatialGeneralResultData);
|
|
400
|
+
/**
|
|
401
|
+
* Returns true if the coordinate falls inside at least one geofence.
|
|
402
|
+
*/
|
|
403
|
+
isInside(): boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Returns true if one or more geofences matched the point.
|
|
406
|
+
*/
|
|
407
|
+
hasMatches(): boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Returns the first matched geofence, or null if no matches found.
|
|
410
|
+
*/
|
|
411
|
+
firstMatch(): GeofenceMatch | null;
|
|
412
|
+
/**
|
|
413
|
+
* Returns all matched geofence IDs as a string array.
|
|
414
|
+
*/
|
|
415
|
+
geofenceIds(): string[];
|
|
416
|
+
/**
|
|
417
|
+
* Returns all matched geofence names as a string array.
|
|
418
|
+
*/
|
|
419
|
+
geofenceNames(): string[];
|
|
420
|
+
/**
|
|
421
|
+
* Checks whether a specific geofence ID or name is among the matches.
|
|
422
|
+
*/
|
|
423
|
+
containsGeofence(idOrName: string): boolean;
|
|
424
|
+
/**
|
|
425
|
+
* Searches for a matched geofence by ID or name and returns it if found, or null.
|
|
426
|
+
*/
|
|
427
|
+
findMatch(idOrName: string): GeofenceMatch | null;
|
|
428
|
+
/**
|
|
429
|
+
* Returns latitude and longitude as a [latitude, longitude] tuple.
|
|
430
|
+
*/
|
|
431
|
+
coordinates(): [number, number];
|
|
432
|
+
/**
|
|
433
|
+
* Formats the result into a clean, human-readable log string matching Go's String().
|
|
434
|
+
*/
|
|
435
|
+
toString(): string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
interface RequestOptions {
|
|
439
|
+
method?: string;
|
|
440
|
+
endpoint: string;
|
|
441
|
+
body?: unknown;
|
|
442
|
+
timeout?: number;
|
|
443
|
+
isSpatial?: boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Marks a Users / GeoIdentity call: the `{ success, data }` envelope is unwrapped,
|
|
446
|
+
* errors are parsed into APIServiceError subclasses, and only GET requests are
|
|
447
|
+
* retried automatically (writes such as invitations must not be sent twice).
|
|
448
|
+
*/
|
|
449
|
+
isApiService?: boolean;
|
|
450
|
+
}
|
|
451
|
+
interface HttpClientConfig {
|
|
452
|
+
apiKey: string;
|
|
453
|
+
jwtToken?: string;
|
|
454
|
+
environment: string;
|
|
455
|
+
managementUrl: string;
|
|
456
|
+
ingestUrl: string;
|
|
457
|
+
apiServiceUrl: string;
|
|
458
|
+
timeout: number;
|
|
459
|
+
maxRetries: number;
|
|
460
|
+
batchSize: number;
|
|
461
|
+
flushInterval: number;
|
|
462
|
+
bufferSize: number;
|
|
463
|
+
fetch: (...args: any[]) => Promise<any>;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Robust HTTP client handling authentication headers, HMAC generation,
|
|
467
|
+
* timeouts via AbortController, and exponential backoff retries.
|
|
468
|
+
*/
|
|
469
|
+
declare class HttpClient {
|
|
470
|
+
private readonly config;
|
|
471
|
+
constructor(options?: GeoEngineOptions);
|
|
472
|
+
get options(): Readonly<HttpClientConfig>;
|
|
473
|
+
/**
|
|
474
|
+
* Executes an HTTP request with timeout, authentication headers and exponential backoff retry.
|
|
475
|
+
*/
|
|
476
|
+
request<T>(opts: RequestOptions): Promise<T>;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** Verdict applied when a GeoIdentity rule matches. */
|
|
480
|
+
declare const RuleActions: {
|
|
481
|
+
readonly Allow: "ALLOW";
|
|
482
|
+
readonly Block: "BLOCK";
|
|
483
|
+
readonly Challenge: "CHALLENGE";
|
|
484
|
+
};
|
|
485
|
+
type RuleAction = (typeof RuleActions)[keyof typeof RuleActions];
|
|
486
|
+
/** Who a GeoIdentity rule applies to. `All` applies the rule to every member of the organization. */
|
|
487
|
+
declare const SubjectTypes: {
|
|
488
|
+
readonly User: "USER";
|
|
489
|
+
readonly Role: "ROLE";
|
|
490
|
+
readonly Device: "DEVICE";
|
|
491
|
+
readonly All: "ALL";
|
|
492
|
+
};
|
|
493
|
+
type SubjectType = (typeof SubjectTypes)[keyof typeof SubjectTypes];
|
|
494
|
+
/** Binds a rule to a subject. For SubjectTypes.All the subjectId is "*". */
|
|
495
|
+
interface SubjectAssignment {
|
|
496
|
+
subjectType: SubjectType;
|
|
497
|
+
subjectId: string;
|
|
498
|
+
}
|
|
499
|
+
/** GeoJSON Polygon or MultiPolygon used as a rule's spatial boundary. See polygonFromLatLng. */
|
|
500
|
+
type GeoLimit = {
|
|
501
|
+
type: 'Polygon';
|
|
502
|
+
coordinates: number[][][];
|
|
503
|
+
} | {
|
|
504
|
+
type: 'MultiPolygon';
|
|
505
|
+
coordinates: number[][][][];
|
|
506
|
+
};
|
|
507
|
+
/** A GeoIdentity access policy. */
|
|
508
|
+
interface Rule {
|
|
509
|
+
id: string;
|
|
510
|
+
orgId: string;
|
|
511
|
+
name: string;
|
|
512
|
+
description?: string;
|
|
513
|
+
priority: number;
|
|
514
|
+
action: RuleAction;
|
|
515
|
+
isActive: boolean;
|
|
516
|
+
whiteIpList: string[];
|
|
517
|
+
blackIpList: string[];
|
|
518
|
+
blockDatacenter: boolean;
|
|
519
|
+
blockTor: boolean;
|
|
520
|
+
riskAccepted: number;
|
|
521
|
+
geoLimit?: GeoLimit | null;
|
|
522
|
+
/** Only populated by calls that return a single rule (getRule, createRule, assignments...). */
|
|
523
|
+
assignedSubjects: SubjectAssignment[];
|
|
524
|
+
subjectsCount: number;
|
|
525
|
+
/** ISO 8601 timestamp. */
|
|
526
|
+
createdAt?: string;
|
|
527
|
+
/** ISO 8601 timestamp. */
|
|
528
|
+
updatedAt?: string;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Payload for GeoIdentityService.createRule.
|
|
532
|
+
* When assignedSubjects is empty the rule applies to the whole organization.
|
|
533
|
+
*/
|
|
534
|
+
interface CreateRuleRequest {
|
|
535
|
+
name: string;
|
|
536
|
+
description?: string;
|
|
537
|
+
priority?: number;
|
|
538
|
+
action?: RuleAction;
|
|
539
|
+
isActive?: boolean;
|
|
540
|
+
/** IPs or CIDR ranges. */
|
|
541
|
+
whiteIpList?: string[];
|
|
542
|
+
/** IPs or CIDR ranges. */
|
|
543
|
+
blackIpList?: string[];
|
|
544
|
+
blockDatacenter?: boolean;
|
|
545
|
+
blockTor?: boolean;
|
|
546
|
+
riskAccepted?: number;
|
|
547
|
+
geoLimit?: GeoLimit;
|
|
548
|
+
assignedSubjects?: SubjectAssignment[];
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Payload for GeoIdentityService.updateRule. Omitted fields are left unchanged.
|
|
552
|
+
* Set geoLimit to null to remove the spatial boundary.
|
|
553
|
+
*/
|
|
554
|
+
interface UpdateRuleRequest {
|
|
555
|
+
name?: string;
|
|
556
|
+
description?: string;
|
|
557
|
+
priority?: number;
|
|
558
|
+
action?: RuleAction;
|
|
559
|
+
isActive?: boolean;
|
|
560
|
+
whiteIpList?: string[];
|
|
561
|
+
blackIpList?: string[];
|
|
562
|
+
blockDatacenter?: boolean;
|
|
563
|
+
blockTor?: boolean;
|
|
564
|
+
riskAccepted?: number;
|
|
565
|
+
geoLimit?: GeoLimit | null;
|
|
566
|
+
assignedSubjects?: SubjectAssignment[];
|
|
567
|
+
}
|
|
568
|
+
/** Filters GeoIdentityService.listRules. Omit isActive to return every rule. */
|
|
569
|
+
interface ListRulesOptions {
|
|
570
|
+
isActive?: boolean;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Manages GeoIdentity access rules and assigns them to users or to the whole organization.
|
|
574
|
+
* Equivalent to Go's GeoIdentityService.
|
|
575
|
+
*/
|
|
576
|
+
declare class GeoIdentityService {
|
|
577
|
+
private readonly http;
|
|
578
|
+
private readonly isClosed;
|
|
579
|
+
constructor(http: HttpClient, isClosed?: () => boolean);
|
|
580
|
+
/** Creates a GeoIdentity rule. */
|
|
581
|
+
createRule(req: CreateRuleRequest): Promise<Rule>;
|
|
582
|
+
/**
|
|
583
|
+
* Returns the organization's rules ordered by priority.
|
|
584
|
+
* Use getRule to load a rule's assigned subjects.
|
|
585
|
+
*/
|
|
586
|
+
listRules(opts?: ListRulesOptions): Promise<Rule[]>;
|
|
587
|
+
/** Returns a rule including its assigned subjects. */
|
|
588
|
+
getRule(ruleId: string): Promise<Rule>;
|
|
589
|
+
/** Partially updates a rule. */
|
|
590
|
+
updateRule(ruleId: string, req: UpdateRuleRequest): Promise<Rule>;
|
|
591
|
+
/** Deletes a rule and all of its assignments. */
|
|
592
|
+
deleteRule(ruleId: string): Promise<void>;
|
|
593
|
+
/** Applies the rule to a member of the organization. Assigning twice is a no-op. */
|
|
594
|
+
assignToUser(ruleId: string, userId: string): Promise<Rule>;
|
|
595
|
+
/** Applies the rule to every member of the organization. */
|
|
596
|
+
assignToOrganization(ruleId: string): Promise<Rule>;
|
|
597
|
+
/**
|
|
598
|
+
* Removes a user assignment from the rule.
|
|
599
|
+
* Throws LastSubjectError if it is the rule's only subject; deactivate or delete the rule instead.
|
|
600
|
+
*/
|
|
601
|
+
unassignFromUser(ruleId: string, userId: string): Promise<Rule>;
|
|
602
|
+
/**
|
|
603
|
+
* Removes the organization-wide assignment from the rule.
|
|
604
|
+
* Throws LastSubjectError if it is the rule's only subject.
|
|
605
|
+
*/
|
|
606
|
+
unassignFromOrganization(ruleId: string): Promise<Rule>;
|
|
607
|
+
/**
|
|
608
|
+
* Returns the rules that apply to a user: assigned directly, through the user's role,
|
|
609
|
+
* or to the whole organization.
|
|
610
|
+
*/
|
|
611
|
+
listUserRules(userId: string): Promise<Rule[]>;
|
|
612
|
+
private changeAssignment;
|
|
613
|
+
private send;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Builds a GeoJSON Polygon for a rule's geoLimit from [lat, lng] pairs, the same order
|
|
617
|
+
* used by GeoEngine.createGeofence. The ring is closed automatically.
|
|
618
|
+
* Equivalent to Go's PolygonFromLatLng.
|
|
619
|
+
*/
|
|
620
|
+
declare function polygonFromLatLng(coordinates: Array<[number, number] | number[]>): {
|
|
621
|
+
type: 'Polygon';
|
|
622
|
+
coordinates: number[][][];
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
interface IngesterClient {
|
|
626
|
+
sendLocation(deviceId: string, lat: number, lng: number): Promise<void | unknown>;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Manages an in-memory queue for background batch ingestion of location telemetry.
|
|
630
|
+
* Equivalent to Go's AsyncIngester.
|
|
631
|
+
*/
|
|
632
|
+
declare class AsyncIngester {
|
|
633
|
+
private readonly client;
|
|
634
|
+
private readonly bufferSize;
|
|
635
|
+
private readonly batchSize;
|
|
636
|
+
private readonly intervalMs;
|
|
637
|
+
private readonly queue;
|
|
638
|
+
private readonly inFlightPromises;
|
|
639
|
+
private timer;
|
|
640
|
+
private isClosed;
|
|
641
|
+
constructor(client: IngesterClient, bufferSize?: number, batchSize?: number, flushIntervalMs?: number);
|
|
642
|
+
/**
|
|
643
|
+
* Non-blockingly appends a location ping to the ingestion buffer queue.
|
|
644
|
+
*
|
|
645
|
+
* @param ping Location ping object
|
|
646
|
+
* @returns true if successfully queued, false if queue is full or ingester is stopped
|
|
647
|
+
*/
|
|
648
|
+
enqueue(ping: LocationPing | null | undefined): boolean;
|
|
649
|
+
/**
|
|
650
|
+
* Flushes current queued batch of location telemetry items.
|
|
651
|
+
*/
|
|
652
|
+
flush(): Promise<void>;
|
|
653
|
+
/**
|
|
654
|
+
* Drains all remaining pending items, halts worker timer, and releases resources.
|
|
655
|
+
* Safe to call multiple times.
|
|
656
|
+
*/
|
|
657
|
+
stop(): Promise<void>;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Handles point-in-polygon and spatial validation against the GeoEngine api-service.
|
|
662
|
+
* Equivalent to Go's SpatialService.
|
|
663
|
+
*/
|
|
664
|
+
declare class SpatialService {
|
|
665
|
+
private readonly http;
|
|
666
|
+
constructor(http: HttpClient);
|
|
667
|
+
/**
|
|
668
|
+
* Convenience method to check if coordinates fall within a specific geofence.
|
|
669
|
+
*
|
|
670
|
+
* @param geofenceId Unique identifier of the geofence
|
|
671
|
+
* @param lat Decimal latitude [-90, 90]
|
|
672
|
+
* @param lng Decimal longitude [-180, 180]
|
|
673
|
+
* @returns SpatialValidationResult
|
|
674
|
+
*/
|
|
675
|
+
validatePoint(geofenceId: string, lat: number, lng: number): Promise<SpatialValidationResult>;
|
|
676
|
+
/**
|
|
677
|
+
* Checks if coordinates fall inside the specified geofence using the api-service.
|
|
678
|
+
*
|
|
679
|
+
* @param req SpatialValidationRequest containing geofenceId, latitude, and longitude
|
|
680
|
+
* @returns SpatialValidationResult
|
|
681
|
+
*/
|
|
682
|
+
validateLocation(req: SpatialValidationRequest): Promise<SpatialValidationResult>;
|
|
683
|
+
/**
|
|
684
|
+
* Checks whether coordinates intersect any geofence belonging to the organization.
|
|
685
|
+
*
|
|
686
|
+
* @param lat Decimal latitude [-90, 90]
|
|
687
|
+
* @param lng Decimal longitude [-180, 180]
|
|
688
|
+
* @returns SpatialGeneralResult
|
|
689
|
+
*/
|
|
690
|
+
validateGeneral(lat: number, lng: number): Promise<SpatialGeneralResult>;
|
|
691
|
+
/**
|
|
692
|
+
* Checks whether coordinates intersect any geofence using the api-service.
|
|
693
|
+
*
|
|
694
|
+
* @param req SpatialGeneralRequest containing latitude and longitude
|
|
695
|
+
* @returns SpatialGeneralResult
|
|
696
|
+
*/
|
|
697
|
+
validateGeneralLocation(req: SpatialGeneralRequest): Promise<SpatialGeneralResult>;
|
|
698
|
+
/**
|
|
699
|
+
* Initializes a fluent query builder for spatial coordinate validation.
|
|
700
|
+
*
|
|
701
|
+
* @param lat Decimal latitude
|
|
702
|
+
* @param lng Decimal longitude
|
|
703
|
+
* @returns SpatialCheckBuilder
|
|
704
|
+
*/
|
|
705
|
+
check(lat: number, lng: number): SpatialCheckBuilder;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Fluent query builder for spatial evaluation operations.
|
|
709
|
+
* Equivalent to Go's SpatialCheckBuilder.
|
|
710
|
+
*/
|
|
711
|
+
declare class SpatialCheckBuilder {
|
|
712
|
+
private readonly service;
|
|
713
|
+
private readonly lat;
|
|
714
|
+
private readonly lng;
|
|
715
|
+
constructor(service: SpatialService, lat: number, lng: number);
|
|
716
|
+
/**
|
|
717
|
+
* Configures validation targeting a specific geofence ID.
|
|
718
|
+
*/
|
|
719
|
+
inGeofence(geofenceId: string): SingleGeofenceCheck;
|
|
720
|
+
/**
|
|
721
|
+
* Configures validation against all organization geofences.
|
|
722
|
+
*/
|
|
723
|
+
inAllGeofences(): GeneralGeofenceCheck;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Evaluates coordinate containment inside a specific geofence.
|
|
727
|
+
* Equivalent to Go's SingleGeofenceCheck.
|
|
728
|
+
*/
|
|
729
|
+
declare class SingleGeofenceCheck {
|
|
730
|
+
private readonly service;
|
|
731
|
+
private readonly geofenceId;
|
|
732
|
+
private readonly lat;
|
|
733
|
+
private readonly lng;
|
|
734
|
+
constructor(service: SpatialService, geofenceId: string, lat: number, lng: number);
|
|
735
|
+
/**
|
|
736
|
+
* Performs the single geofence spatial query.
|
|
737
|
+
*/
|
|
738
|
+
execute(): Promise<SpatialValidationResult>;
|
|
739
|
+
/**
|
|
740
|
+
* Alias for execute().
|
|
741
|
+
*/
|
|
742
|
+
executeSingle(): Promise<SpatialValidationResult>;
|
|
743
|
+
/**
|
|
744
|
+
* Alias for execute().
|
|
745
|
+
*/
|
|
746
|
+
validate(): Promise<SpatialValidationResult>;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Evaluates coordinate containment across all organization geofences.
|
|
750
|
+
* Equivalent to Go's GeneralGeofenceCheck.
|
|
751
|
+
*/
|
|
752
|
+
declare class GeneralGeofenceCheck {
|
|
753
|
+
private readonly service;
|
|
754
|
+
private readonly lat;
|
|
755
|
+
private readonly lng;
|
|
756
|
+
constructor(service: SpatialService, lat: number, lng: number);
|
|
757
|
+
/**
|
|
758
|
+
* Performs the general spatial query against all organization geofences.
|
|
759
|
+
*/
|
|
760
|
+
execute(): Promise<SpatialGeneralResult>;
|
|
761
|
+
/**
|
|
762
|
+
* Alias for execute().
|
|
763
|
+
*/
|
|
764
|
+
executeGeneral(): Promise<SpatialGeneralResult>;
|
|
765
|
+
/**
|
|
766
|
+
* Alias for execute().
|
|
767
|
+
*/
|
|
768
|
+
validate(): Promise<SpatialGeneralResult>;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Organization roles accepted by the Users service.
|
|
773
|
+
* The short form ("admin", "viewer", ...) is also accepted by the API.
|
|
774
|
+
*/
|
|
775
|
+
declare const Roles: {
|
|
776
|
+
readonly Admin: "roles/geoengine.admin";
|
|
777
|
+
readonly Dispatcher: "roles/geoengine.dispatcher";
|
|
778
|
+
readonly Billing: "roles/geoengine.billing";
|
|
779
|
+
readonly Viewer: "roles/geoengine.viewer";
|
|
780
|
+
readonly Device: "roles/geoengine.device";
|
|
781
|
+
};
|
|
782
|
+
/** User status values returned by the API. */
|
|
783
|
+
declare const UserStatus: {
|
|
784
|
+
readonly Active: "active";
|
|
785
|
+
readonly Pending: "pending";
|
|
786
|
+
readonly Revoked: "revoked";
|
|
787
|
+
};
|
|
788
|
+
/** A member of the organization that owns the API key. */
|
|
789
|
+
interface User {
|
|
790
|
+
id: string;
|
|
791
|
+
email: string;
|
|
792
|
+
name: string;
|
|
793
|
+
role: string;
|
|
794
|
+
status: string;
|
|
795
|
+
permissions: string[];
|
|
796
|
+
/** ISO 8601 timestamp. */
|
|
797
|
+
createdAt?: string;
|
|
798
|
+
/** ISO 8601 timestamp. Absent if the user never signed in. */
|
|
799
|
+
lastLoginAt?: string;
|
|
800
|
+
}
|
|
801
|
+
/** An organization role and the permissions it grants. */
|
|
802
|
+
interface Role {
|
|
803
|
+
id: string;
|
|
804
|
+
permissions: string[];
|
|
805
|
+
}
|
|
806
|
+
/** Payload for UsersService.invite. */
|
|
807
|
+
interface InviteUserRequest {
|
|
808
|
+
email: string;
|
|
809
|
+
role: string;
|
|
810
|
+
/** Shown in the invitation email. Optional. */
|
|
811
|
+
inviterName?: string;
|
|
812
|
+
/** Email language: "es" (default), "en" or "pt". Optional. */
|
|
813
|
+
lang?: 'es' | 'en' | 'pt' | (string & {});
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Result of UsersService.invite. The invitation email is sent by GeoEngine;
|
|
817
|
+
* inviteUrl is returned as well so it can be delivered through other channels.
|
|
818
|
+
*/
|
|
819
|
+
interface Invitation {
|
|
820
|
+
email: string;
|
|
821
|
+
role: string;
|
|
822
|
+
status: string;
|
|
823
|
+
inviteUrl: string;
|
|
824
|
+
/** ISO 8601 timestamp. */
|
|
825
|
+
expiresAt?: string;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Manages organization members, roles and invitations through the api-service.
|
|
829
|
+
* Equivalent to Go's UsersService.
|
|
830
|
+
*/
|
|
831
|
+
declare class UsersService {
|
|
832
|
+
private readonly http;
|
|
833
|
+
private readonly isClosed;
|
|
834
|
+
constructor(http: HttpClient, isClosed?: () => boolean);
|
|
835
|
+
/** Returns the members of the organization. */
|
|
836
|
+
list(): Promise<User[]>;
|
|
837
|
+
/** Returns a single member of the organization. */
|
|
838
|
+
get(userId: string): Promise<User>;
|
|
839
|
+
/** Returns the roles available to the organization and their permissions. */
|
|
840
|
+
listRoles(): Promise<Role[]>;
|
|
841
|
+
/**
|
|
842
|
+
* Creates an invitation and emails it to the recipient.
|
|
843
|
+
* Throws InvitationPendingError if a pending invitation already exists for the email,
|
|
844
|
+
* and UserAlreadyExistsError if the email already belongs to the organization.
|
|
845
|
+
*/
|
|
846
|
+
invite(req: InviteUserRequest): Promise<Invitation>;
|
|
847
|
+
/**
|
|
848
|
+
* Changes the role of a member. The new permissions apply on the user's next sign-in.
|
|
849
|
+
* Throws LastAdminError if the change would leave the organization without an admin.
|
|
850
|
+
*/
|
|
851
|
+
updateRole(userId: string, role: string): Promise<User>;
|
|
852
|
+
/**
|
|
853
|
+
* Revokes a member's access to the organization.
|
|
854
|
+
* Throws LastAdminError if the member is the last admin.
|
|
855
|
+
*/
|
|
856
|
+
remove(userId: string): Promise<void>;
|
|
857
|
+
private send;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* GeoEngine Client for interacting with GeoEngine APIs over HTTP REST.
|
|
862
|
+
* Equivalent to Go's Client struct.
|
|
863
|
+
*/
|
|
864
|
+
declare class GeoEngine {
|
|
865
|
+
private readonly http;
|
|
866
|
+
private isClosed;
|
|
867
|
+
/**
|
|
868
|
+
* Spatial provides point-in-polygon querying and geofence validation capabilities.
|
|
869
|
+
*/
|
|
870
|
+
readonly spatial: SpatialService;
|
|
871
|
+
/**
|
|
872
|
+
* Alias for spatial (to maintain exact casing compatibility with Go client.Spatial).
|
|
873
|
+
*/
|
|
874
|
+
readonly Spatial: SpatialService;
|
|
875
|
+
/**
|
|
876
|
+
* Users manages organization members, roles and invitations.
|
|
877
|
+
*/
|
|
878
|
+
readonly users: UsersService;
|
|
879
|
+
/**
|
|
880
|
+
* Alias for users (matches Go client.Users).
|
|
881
|
+
*/
|
|
882
|
+
readonly Users: UsersService;
|
|
883
|
+
/**
|
|
884
|
+
* GeoIdentity manages GeoIdentity access rules for users and the organization.
|
|
885
|
+
*/
|
|
886
|
+
readonly geoIdentity: GeoIdentityService;
|
|
887
|
+
/**
|
|
888
|
+
* Alias for geoIdentity (matches Go client.GeoIdentity).
|
|
889
|
+
*/
|
|
890
|
+
readonly GeoIdentity: GeoIdentityService;
|
|
891
|
+
/**
|
|
892
|
+
* Initializes a new GeoEngine client instance.
|
|
893
|
+
*
|
|
894
|
+
* @param apiKey Your GeoEngine API Key (required)
|
|
895
|
+
* @param options Optional configuration parameters
|
|
896
|
+
*/
|
|
897
|
+
constructor(apiKeyOrOptions: string | GeoEngineOptions, maybeOptions?: GeoEngineOptions);
|
|
898
|
+
/**
|
|
899
|
+
* Current configuration options.
|
|
900
|
+
*/
|
|
901
|
+
get options(): Readonly<HttpClientConfig>;
|
|
902
|
+
/**
|
|
903
|
+
* Sends device coordinates over HTTP REST.
|
|
904
|
+
* Equivalent to Go's Client.SendLocation.
|
|
905
|
+
*
|
|
906
|
+
* @param deviceId Unique vehicle/device identifier
|
|
907
|
+
* @param lat Decimal latitude
|
|
908
|
+
* @param lng Decimal longitude
|
|
909
|
+
*/
|
|
910
|
+
sendLocation(deviceId: string, lat: number, lng: number): Promise<void>;
|
|
911
|
+
/**
|
|
912
|
+
* Creates a spatial geofence polygon in PostGIS via the management REST API.
|
|
913
|
+
* Automatically validates and closes the polygon ring.
|
|
914
|
+
* Equivalent to Go's Client.CreateGeofence.
|
|
915
|
+
*
|
|
916
|
+
* @param name Geofence name
|
|
917
|
+
* @param coordinates Array of [latitude, longitude] pairs (at least 3 coordinates)
|
|
918
|
+
* @param webhookUrl Optional webhook URL triggered upon enter/exit
|
|
919
|
+
*/
|
|
920
|
+
createGeofence(name: string, coordinates: Array<[number, number] | number[]>, webhookUrl?: string): Promise<unknown>;
|
|
921
|
+
/**
|
|
922
|
+
* Validates if coordinates fall within a geofence by ID via the Spatial service.
|
|
923
|
+
* Shortcut matching Go's Client.ValidateSpatialPoint.
|
|
924
|
+
*/
|
|
925
|
+
validateSpatialPoint(geofenceId: string, lat: number, lng: number): Promise<SpatialValidationResult>;
|
|
926
|
+
/**
|
|
927
|
+
* Validates if coordinates fall within a geofence via the Spatial service.
|
|
928
|
+
* Shortcut matching Go's Client.ValidateSpatialLocation.
|
|
929
|
+
*/
|
|
930
|
+
validateSpatialLocation(req: SpatialValidationRequest): Promise<SpatialValidationResult>;
|
|
931
|
+
/**
|
|
932
|
+
* Validates coordinates against all active geofences via the Spatial service.
|
|
933
|
+
* Shortcut matching Go's Client.ValidateSpatialGeneral.
|
|
934
|
+
*/
|
|
935
|
+
validateSpatialGeneral(lat: number, lng: number): Promise<SpatialGeneralResult>;
|
|
936
|
+
/**
|
|
937
|
+
* Validates coordinates against all active geofences via the Spatial service.
|
|
938
|
+
* Shortcut matching Go's Client.ValidateSpatialGeneralLocation.
|
|
939
|
+
*/
|
|
940
|
+
validateSpatialGeneralLocation(req: SpatialGeneralRequest): Promise<SpatialGeneralResult>;
|
|
941
|
+
/**
|
|
942
|
+
* Instantiates a new AsyncIngester connected to this client.
|
|
943
|
+
* Matches Go NewAsyncIngester.
|
|
944
|
+
*
|
|
945
|
+
* @param bufferSize Queue buffer capacity (default: options.bufferSize ?? 5000)
|
|
946
|
+
* @param batchSize Batch size before flushing (default: options.batchSize ?? 100)
|
|
947
|
+
* @param flushIntervalMs Flush interval in ms (default: options.flushInterval ?? 500)
|
|
948
|
+
*/
|
|
949
|
+
createAsyncIngester(bufferSize?: number, batchSize?: number, flushIntervalMs?: number): AsyncIngester;
|
|
950
|
+
/**
|
|
951
|
+
* Closes the client, marking it inactive. Idempotent.
|
|
952
|
+
* Subsequent requests will throw ClientClosedError.
|
|
953
|
+
* Equivalent to Go's Client.Close.
|
|
954
|
+
*/
|
|
955
|
+
close(): void;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Validates that latitude is between -90 and 90, and longitude is between -180 and 180 degrees.
|
|
960
|
+
* Equivalent to Go's ValidateCoordinates(lat, lng).
|
|
961
|
+
*/
|
|
962
|
+
declare function validateCoordinates(lat: number, lng: number): void;
|
|
963
|
+
/**
|
|
964
|
+
* Validates that device ID is provided and not empty.
|
|
965
|
+
*/
|
|
966
|
+
declare function validateDeviceId(deviceId: string): string;
|
|
967
|
+
/**
|
|
968
|
+
* Validates that geofence ID is provided and not empty.
|
|
969
|
+
*/
|
|
970
|
+
declare function validateGeofenceId(geofenceId: string): string;
|
|
971
|
+
/**
|
|
972
|
+
* Validates coordinate array of [lat, lng] pairs for polygon creation,
|
|
973
|
+
* converts to GeoJSON [lng, lat] and ensures the linear ring is closed.
|
|
974
|
+
*/
|
|
975
|
+
declare function validateAndNormalizePolygon(coordinates: Array<[number, number] | number[]>): [number, number][];
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Generates an HMAC-SHA256 signature from the API key and timestamp (in milliseconds).
|
|
979
|
+
* Matches the Go SDK Client.generateHMACSignature implementation.
|
|
980
|
+
*
|
|
981
|
+
* @param key The API secret key used as the HMAC secret
|
|
982
|
+
* @param timestamp Epoch timestamp in milliseconds
|
|
983
|
+
* @returns 64-character lowercase hexadecimal hash
|
|
984
|
+
*/
|
|
985
|
+
declare function generateHMACSignature(key: string, timestamp: number): string;
|
|
986
|
+
|
|
987
|
+
export { APIError, APIServiceError, AsyncIngester, AuthenticationError, GeoEngine as Client, ClientClosedError, type CreateRuleRequest, DeviceIDRequiredError, EmailRequiredError, ForbiddenError, GeneralGeofenceCheck, GeoEngine, GeoEngineError, type GeoEngineOptions, GeoIdentityService, type GeoLimit, GeofenceIDRequiredError, type GeofenceMatch, GeofenceNotFoundError, type GeofenceRequest, type HttpClientConfig, type IngestResponse, type IngesterClient, InvalidCoordinatesError, InvalidLatitudeError, InvalidLongitudeError, type Invitation, InvitationPendingError, type InviteUserRequest, LastAdminError, LastSubjectError, type ListRulesOptions, type LocationPing, QuotaExceededError, type Role, RoleRequiredError, Roles, type Rule, type RuleAction, RuleActions, RuleIDRequiredError, RuleNameRequiredError, RuleNotFoundError, SingleGeofenceCheck, SpatialAPIError, SpatialCheckBuilder, type SpatialErrorDetail, type SpatialGeneralRequest, SpatialGeneralResult, type SpatialGeneralResultData, SpatialService, type SpatialValidationRequest, SpatialValidationResult, type SpatialValidationResultData, type SubjectAssignment, type SubjectType, SubjectTypes, TimeoutError, type UpdateRuleRequest, type User, UserAlreadyExistsError, UserIDRequiredError, UserNotFoundError, UserStatus, UsersService, ValidationError, GeoEngine as default, generateHMACSignature, polygonFromLatLng, validateAndNormalizePolygon, validateCoordinates, validateDeviceId, validateGeofenceId };
|