geo-engine-node 2.0.0 → 3.0.0-rc.1
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/LICENSE +21 -0
- package/README.es.md +397 -0
- package/Readme.md +261 -100
- package/dist/chunk-425YTEGY.js +1231 -0
- package/dist/chunk-425YTEGY.js.map +1 -0
- package/dist/chunk-A6RGK4MA.cjs +1231 -0
- package/dist/chunk-A6RGK4MA.cjs.map +1 -0
- package/dist/errors-C5S_d0Ca.d.cts +473 -0
- package/dist/errors-C5S_d0Ca.d.ts +473 -0
- package/dist/identity.cjs +196 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +10 -0
- package/dist/identity.d.ts +10 -0
- package/dist/identity.js +196 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.cjs +465 -455
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +275 -134
- package/dist/index.d.ts +275 -134
- package/dist/index.js +375 -310
- package/dist/index.js.map +1 -1
- package/package.json +38 -9
package/dist/index.cjs
CHANGED
|
@@ -1,374 +1,362 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var ClientClosedError = class extends GeoEngineError {
|
|
65
|
-
constructor(message = "geoengine: client is closed") {
|
|
66
|
-
super(message);
|
|
67
|
-
this.name = "ClientClosedError";
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var ValidationError = class extends GeoEngineError {
|
|
71
|
-
constructor(message) {
|
|
72
|
-
super(message);
|
|
73
|
-
this.name = "ValidationError";
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
var DeviceIDRequiredError = class extends ValidationError {
|
|
77
|
-
constructor(message = "geoengine: device_id is required") {
|
|
78
|
-
super(message);
|
|
79
|
-
this.name = "DeviceIDRequiredError";
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var GeofenceIDRequiredError = class extends ValidationError {
|
|
83
|
-
constructor(message = "geoengine: geofence_id is required") {
|
|
84
|
-
super(message);
|
|
85
|
-
this.name = "GeofenceIDRequiredError";
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
var InvalidLatitudeError = class extends ValidationError {
|
|
89
|
-
constructor(message = "geoengine: latitude must be between -90 and 90 degrees") {
|
|
90
|
-
super(message);
|
|
91
|
-
this.name = "InvalidLatitudeError";
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var InvalidLongitudeError = class extends ValidationError {
|
|
95
|
-
constructor(message = "geoengine: longitude must be between -180 and 180 degrees") {
|
|
96
|
-
super(message);
|
|
97
|
-
this.name = "InvalidLongitudeError";
|
|
98
|
-
}
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunkA6RGK4MAcjs = require('./chunk-A6RGK4MA.cjs');
|
|
36
|
+
|
|
37
|
+
// src/users.ts
|
|
38
|
+
var Roles = {
|
|
39
|
+
Admin: "roles/geoengine.admin",
|
|
40
|
+
Dispatcher: "roles/geoengine.dispatcher",
|
|
41
|
+
Billing: "roles/geoengine.billing",
|
|
42
|
+
Viewer: "roles/geoengine.viewer",
|
|
43
|
+
Device: "roles/geoengine.device"
|
|
99
44
|
};
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
45
|
+
var UserStatus = {
|
|
46
|
+
Active: "active",
|
|
47
|
+
Pending: "pending",
|
|
48
|
+
Revoked: "revoked"
|
|
105
49
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
50
|
+
function toUser(raw) {
|
|
51
|
+
return {
|
|
52
|
+
id: raw.id,
|
|
53
|
+
email: raw.email,
|
|
54
|
+
name: raw.name,
|
|
55
|
+
role: raw.role,
|
|
56
|
+
status: raw.status,
|
|
57
|
+
permissions: _nullishCoalesce(raw.permissions, () => ( [])),
|
|
58
|
+
createdAt: raw.created_at,
|
|
59
|
+
lastLoginAt: raw.last_login_at
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function isBlank(value) {
|
|
63
|
+
return typeof value !== "string" || value.trim() === "";
|
|
64
|
+
}
|
|
65
|
+
function userPath(userId, suffix = "") {
|
|
66
|
+
if (isBlank(userId)) {
|
|
67
|
+
throw new (0, _chunkA6RGK4MAcjs.UserIDRequiredError)();
|
|
112
68
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
69
|
+
return `/api/users/${encodeURIComponent(userId.trim())}${suffix}`;
|
|
70
|
+
}
|
|
71
|
+
async function apiServiceRequest(http, isClosed, method, path, body) {
|
|
72
|
+
if (isClosed()) {
|
|
73
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
74
|
+
}
|
|
75
|
+
return http.request({
|
|
76
|
+
endpoint: `${http.options.apiServiceUrl.replace(/\/+$/, "")}${path}`,
|
|
77
|
+
method,
|
|
78
|
+
body,
|
|
79
|
+
isApiService: true
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
var UsersService = class {
|
|
83
|
+
constructor(http, isClosed = () => false) {
|
|
84
|
+
this.http = http;
|
|
85
|
+
this.isClosed = isClosed;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/** Returns the members of the organization. */
|
|
90
|
+
async list() {
|
|
91
|
+
const raw = await this.send("GET", "/api/users");
|
|
92
|
+
return (_nullishCoalesce(raw, () => ( []))).map(toUser);
|
|
93
|
+
}
|
|
94
|
+
/** Returns a single member of the organization. */
|
|
95
|
+
async get(userId) {
|
|
96
|
+
return toUser(await this.send("GET", userPath(userId)));
|
|
97
|
+
}
|
|
98
|
+
/** Returns the roles available to the organization and their permissions. */
|
|
99
|
+
async listRoles() {
|
|
100
|
+
const raw = await this.send(
|
|
101
|
+
"GET",
|
|
102
|
+
"/api/users/roles"
|
|
103
|
+
);
|
|
104
|
+
return (_nullishCoalesce(raw, () => ( []))).map((r) => ({ id: r.id, permissions: _nullishCoalesce(r.permissions, () => ( [])) }));
|
|
125
105
|
}
|
|
126
106
|
/**
|
|
127
|
-
*
|
|
107
|
+
* Creates an invitation and emails it to the recipient.
|
|
108
|
+
* Throws InvitationPendingError if a pending invitation already exists for the email,
|
|
109
|
+
* and UserAlreadyExistsError if the email already belongs to the organization.
|
|
128
110
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
111
|
+
async invite(req) {
|
|
112
|
+
if (isBlank(_optionalChain([req, 'optionalAccess', _ => _.email]))) {
|
|
113
|
+
throw new (0, _chunkA6RGK4MAcjs.EmailRequiredError)();
|
|
114
|
+
}
|
|
115
|
+
if (isBlank(req.role)) {
|
|
116
|
+
throw new (0, _chunkA6RGK4MAcjs.RoleRequiredError)();
|
|
117
|
+
}
|
|
118
|
+
const raw = await this.send("POST", "/api/users/invite", {
|
|
119
|
+
email: req.email,
|
|
120
|
+
role: req.role,
|
|
121
|
+
inviter_name: req.inviterName || void 0,
|
|
122
|
+
lang: req.lang || void 0
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
email: raw.email,
|
|
126
|
+
role: raw.role,
|
|
127
|
+
status: raw.status,
|
|
128
|
+
inviteUrl: raw.invite_url,
|
|
129
|
+
expiresAt: raw.expires_at
|
|
130
|
+
};
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
133
|
+
* Changes the role of a member. The new permissions apply on the user's next sign-in.
|
|
134
|
+
* Throws LastAdminError if the change would leave the organization without an admin.
|
|
134
135
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
async updateRole(userId, role) {
|
|
137
|
+
if (isBlank(role)) {
|
|
138
|
+
throw new (0, _chunkA6RGK4MAcjs.RoleRequiredError)();
|
|
139
|
+
}
|
|
140
|
+
return toUser(await this.send("PATCH", userPath(userId, "/role"), { role }));
|
|
137
141
|
}
|
|
138
142
|
/**
|
|
139
|
-
*
|
|
143
|
+
* Revokes a member's access to the organization.
|
|
144
|
+
* Throws LastAdminError if the member is the last admin.
|
|
140
145
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
async remove(userId) {
|
|
147
|
+
await this.send("DELETE", userPath(userId));
|
|
143
148
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
*/
|
|
147
|
-
isForbidden() {
|
|
148
|
-
return this.statusCode === 403 || this.code === "FORBIDDEN";
|
|
149
|
+
send(method, path, body) {
|
|
150
|
+
return apiServiceRequest(this.http, this.isClosed, method, path, body);
|
|
149
151
|
}
|
|
150
152
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
|
|
154
|
+
// src/validation.ts
|
|
155
|
+
function validateCoordinates(lat, lng) {
|
|
156
|
+
if (typeof lat !== "number" || Number.isNaN(lat) || lat < -90 || lat > 90) {
|
|
157
|
+
throw new (0, _chunkA6RGK4MAcjs.InvalidLatitudeError)();
|
|
155
158
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
constructor(message = "request quota exceeded", statusCode = 402, details = []) {
|
|
159
|
-
super(statusCode, "QUOTA_EXCEEDED", message, "Payment Required", details);
|
|
160
|
-
this.name = "QuotaExceededError";
|
|
159
|
+
if (typeof lng !== "number" || Number.isNaN(lng) || lng < -180 || lng > 180) {
|
|
160
|
+
throw new (0, _chunkA6RGK4MAcjs.InvalidLongitudeError)();
|
|
161
161
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.name = "AuthenticationError";
|
|
162
|
+
}
|
|
163
|
+
function validateDeviceId(deviceId) {
|
|
164
|
+
if (!deviceId || typeof deviceId !== "string" || deviceId.trim() === "") {
|
|
165
|
+
throw new (0, _chunkA6RGK4MAcjs.DeviceIDRequiredError)();
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
return deviceId.trim();
|
|
168
|
+
}
|
|
169
|
+
function validateGeofenceId(geofenceId) {
|
|
170
|
+
if (!geofenceId || typeof geofenceId !== "string" || geofenceId.trim() === "") {
|
|
171
|
+
throw new (0, _chunkA6RGK4MAcjs.GeofenceIDRequiredError)();
|
|
173
172
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
return geofenceId.trim();
|
|
174
|
+
}
|
|
175
|
+
function validateAndNormalizePolygon(coordinates) {
|
|
176
|
+
if (!Array.isArray(coordinates) || coordinates.length < 3) {
|
|
177
|
+
throw new (0, _chunkA6RGK4MAcjs.InvalidCoordinatesError)();
|
|
179
178
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
const polygon = [];
|
|
180
|
+
for (const p of coordinates) {
|
|
181
|
+
if (!Array.isArray(p) || p.length !== 2) {
|
|
182
|
+
throw new (0, _chunkA6RGK4MAcjs.ValidationError)(
|
|
183
|
+
`geoengine: invalid coordinate format: ${JSON.stringify(p)} (expected [lat, lng])`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const lat = p[0];
|
|
187
|
+
const lng = p[1];
|
|
188
|
+
validateCoordinates(lat, lng);
|
|
189
|
+
polygon.push([lng, lat]);
|
|
187
190
|
}
|
|
188
|
-
|
|
191
|
+
const first = polygon[0];
|
|
192
|
+
const last = polygon[polygon.length - 1];
|
|
193
|
+
if (first[0] !== last[0] || first[1] !== last[1]) {
|
|
194
|
+
polygon.push([first[0], first[1]]);
|
|
195
|
+
}
|
|
196
|
+
return polygon;
|
|
189
197
|
}
|
|
190
198
|
|
|
191
|
-
// src/
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
// src/geoidentity.ts
|
|
200
|
+
var RuleActions = {
|
|
201
|
+
Allow: "ALLOW",
|
|
202
|
+
Block: "BLOCK",
|
|
203
|
+
Challenge: "CHALLENGE"
|
|
204
|
+
};
|
|
205
|
+
var SubjectTypes = {
|
|
206
|
+
User: "USER",
|
|
207
|
+
Role: "ROLE",
|
|
208
|
+
Device: "DEVICE",
|
|
209
|
+
All: "ALL"
|
|
210
|
+
};
|
|
211
|
+
function toRule(raw) {
|
|
212
|
+
return {
|
|
213
|
+
id: raw.id,
|
|
214
|
+
orgId: raw.org_id,
|
|
215
|
+
name: raw.name,
|
|
216
|
+
description: raw.description,
|
|
217
|
+
priority: _nullishCoalesce(raw.priority, () => ( 0)),
|
|
218
|
+
action: raw.action,
|
|
219
|
+
isActive: Boolean(raw.is_active),
|
|
220
|
+
whiteIpList: _nullishCoalesce(raw.white_ip_list, () => ( [])),
|
|
221
|
+
blackIpList: _nullishCoalesce(raw.black_ip_list, () => ( [])),
|
|
222
|
+
blockDatacenter: Boolean(raw.block_datacenter),
|
|
223
|
+
blockTor: Boolean(raw.block_tor),
|
|
224
|
+
riskAccepted: _nullishCoalesce(raw.risk_accepted, () => ( 0)),
|
|
225
|
+
geoLimit: raw.geo_limit,
|
|
226
|
+
assignedSubjects: (_nullishCoalesce(raw.assigned_subjects, () => ( []))).map((s) => ({
|
|
227
|
+
subjectType: s.subject_type,
|
|
228
|
+
subjectId: s.subject_id
|
|
229
|
+
})),
|
|
230
|
+
subjectsCount: _nullishCoalesce(raw.subjects_count, () => ( 0)),
|
|
231
|
+
createdAt: raw.created_at,
|
|
232
|
+
updatedAt: raw.updated_at
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function toWire(req) {
|
|
236
|
+
return {
|
|
237
|
+
name: req.name,
|
|
238
|
+
description: req.description,
|
|
239
|
+
priority: req.priority,
|
|
240
|
+
action: req.action,
|
|
241
|
+
is_active: req.isActive,
|
|
242
|
+
white_ip_list: req.whiteIpList,
|
|
243
|
+
black_ip_list: req.blackIpList,
|
|
244
|
+
block_datacenter: req.blockDatacenter,
|
|
245
|
+
block_tor: req.blockTor,
|
|
246
|
+
risk_accepted: req.riskAccepted,
|
|
247
|
+
geo_limit: req.geoLimit,
|
|
248
|
+
assigned_subjects: _optionalChain([req, 'access', _2 => _2.assignedSubjects, 'optionalAccess', _3 => _3.map, 'call', _4 => _4((s) => ({
|
|
249
|
+
subject_type: s.subjectType,
|
|
250
|
+
subject_id: s.subjectId
|
|
251
|
+
}))])
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
var RULES_PATH = "/api/users/geoidentity/rules";
|
|
255
|
+
function rulePath(ruleId, suffix = "") {
|
|
256
|
+
if (typeof ruleId !== "string" || ruleId.trim() === "") {
|
|
257
|
+
throw new (0, _chunkA6RGK4MAcjs.RuleIDRequiredError)();
|
|
210
258
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
259
|
+
return `${RULES_PATH}/${encodeURIComponent(ruleId.trim())}${suffix}`;
|
|
260
|
+
}
|
|
261
|
+
function requireUserId(userId) {
|
|
262
|
+
if (typeof userId !== "string" || userId.trim() === "") {
|
|
263
|
+
throw new (0, _chunkA6RGK4MAcjs.UserIDRequiredError)();
|
|
264
|
+
}
|
|
265
|
+
return userId.trim();
|
|
266
|
+
}
|
|
267
|
+
var GeoIdentityService = class {
|
|
268
|
+
constructor(http, isClosed = () => false) {
|
|
269
|
+
this.http = http;
|
|
270
|
+
this.isClosed = isClosed;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
/** Creates a GeoIdentity rule. */
|
|
275
|
+
async createRule(req) {
|
|
276
|
+
if (typeof _optionalChain([req, 'optionalAccess', _5 => _5.name]) !== "string" || req.name.trim() === "") {
|
|
277
|
+
throw new (0, _chunkA6RGK4MAcjs.RuleNameRequiredError)();
|
|
228
278
|
}
|
|
279
|
+
return toRule(await this.send("POST", RULES_PATH, toWire(req)));
|
|
229
280
|
}
|
|
230
|
-
|
|
231
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Returns the organization's rules ordered by priority.
|
|
283
|
+
* Use getRule to load a rule's assigned subjects.
|
|
284
|
+
*/
|
|
285
|
+
async listRules(opts = {}) {
|
|
286
|
+
const query = typeof opts.isActive === "boolean" ? `?is_active=${opts.isActive}` : "";
|
|
287
|
+
const raw = await this.send("GET", RULES_PATH + query);
|
|
288
|
+
return (_nullishCoalesce(raw, () => ( []))).map(toRule);
|
|
232
289
|
}
|
|
233
|
-
|
|
234
|
-
|
|
290
|
+
/** Returns a rule including its assigned subjects. */
|
|
291
|
+
async getRule(ruleId) {
|
|
292
|
+
return toRule(await this.send("GET", rulePath(ruleId)));
|
|
235
293
|
}
|
|
236
|
-
|
|
237
|
-
|
|
294
|
+
/** Partially updates a rule. */
|
|
295
|
+
async updateRule(ruleId, req) {
|
|
296
|
+
return toRule(await this.send("PATCH", rulePath(ruleId), toWire(_nullishCoalesce(req, () => ( {})))));
|
|
238
297
|
}
|
|
239
|
-
|
|
240
|
-
|
|
298
|
+
/** Deletes a rule and all of its assignments. */
|
|
299
|
+
async deleteRule(ruleId) {
|
|
300
|
+
await this.send("DELETE", rulePath(ruleId));
|
|
241
301
|
}
|
|
242
|
-
|
|
243
|
-
|
|
302
|
+
/** Applies the rule to a member of the organization. Assigning twice is a no-op. */
|
|
303
|
+
async assignToUser(ruleId, userId) {
|
|
304
|
+
return this.changeAssignment("POST", ruleId, { scope: "user", user_id: requireUserId(userId) });
|
|
244
305
|
}
|
|
245
|
-
|
|
246
|
-
|
|
306
|
+
/** Applies the rule to every member of the organization. */
|
|
307
|
+
async assignToOrganization(ruleId) {
|
|
308
|
+
return this.changeAssignment("POST", ruleId, { scope: "organization" });
|
|
247
309
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const defaultIngest = "https://ingest.geoengine.dev";
|
|
255
|
-
const defaultApiService = "https://api.geoengine.dev";
|
|
256
|
-
this.config = {
|
|
257
|
-
apiKey: options.apiKey ?? "",
|
|
258
|
-
jwtToken: options.jwtToken,
|
|
259
|
-
environment: options.environment ?? "live",
|
|
260
|
-
managementUrl: options.baseUrl ?? options.managementUrl ?? defaultManagement,
|
|
261
|
-
ingestUrl: options.baseUrl ?? options.ingestUrl ?? defaultIngest,
|
|
262
|
-
apiServiceUrl: options.baseUrl ?? options.apiServiceUrl ?? defaultApiService,
|
|
263
|
-
timeout: options.timeout ?? 1e4,
|
|
264
|
-
maxRetries: options.maxRetries ?? 2,
|
|
265
|
-
batchSize: options.batchSize ?? 100,
|
|
266
|
-
flushInterval: options.flushInterval ?? 500,
|
|
267
|
-
bufferSize: options.bufferSize ?? 5e3,
|
|
268
|
-
fetch: options.fetch ?? globalThis.fetch
|
|
269
|
-
};
|
|
310
|
+
/**
|
|
311
|
+
* Removes a user assignment from the rule.
|
|
312
|
+
* Throws LastSubjectError if it is the rule's only subject; deactivate or delete the rule instead.
|
|
313
|
+
*/
|
|
314
|
+
async unassignFromUser(ruleId, userId) {
|
|
315
|
+
return this.changeAssignment("DELETE", ruleId, { scope: "user", user_id: requireUserId(userId) });
|
|
270
316
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
"X-Request-Time": now.toString(),
|
|
292
|
-
"X-Signature": generateHMACSignature(this.config.apiKey, now),
|
|
293
|
-
"User-Agent": USER_AGENT
|
|
294
|
-
};
|
|
295
|
-
if (this.config.jwtToken) {
|
|
296
|
-
headers["Authorization"] = `Bearer ${this.config.jwtToken}`;
|
|
297
|
-
}
|
|
298
|
-
try {
|
|
299
|
-
const response = await this.config.fetch(opts.endpoint, {
|
|
300
|
-
method,
|
|
301
|
-
headers,
|
|
302
|
-
body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0,
|
|
303
|
-
signal: controller.signal
|
|
304
|
-
});
|
|
305
|
-
globalThis.clearTimeout(timeoutId);
|
|
306
|
-
if (response.status === 204) {
|
|
307
|
-
if (opts.isSpatial) {
|
|
308
|
-
throw new GeofenceNotFoundError("geofence not found", 204);
|
|
309
|
-
}
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
if ((response.status === 429 || response.status >= 500) && attempt <= maxRetries) {
|
|
313
|
-
const delay = Math.min(100 * Math.pow(2, attempt) + Math.random() * 50, 2e3);
|
|
314
|
-
await new Promise(
|
|
315
|
-
(resolve) => globalThis.setTimeout(() => resolve(), delay)
|
|
316
|
-
);
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
const responseText = await response.text();
|
|
320
|
-
if (!response.ok) {
|
|
321
|
-
throw parseHttpError(response.status, responseText, opts.isSpatial);
|
|
322
|
-
}
|
|
323
|
-
if (!responseText || responseText.trim() === "") {
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
const json = JSON.parse(responseText);
|
|
327
|
-
if (opts.isSpatial && typeof json === "object" && json !== null && "success" in json) {
|
|
328
|
-
if (!json.success) {
|
|
329
|
-
throw parseHttpError(response.status, responseText, true);
|
|
330
|
-
}
|
|
331
|
-
return json.data;
|
|
332
|
-
}
|
|
333
|
-
return json;
|
|
334
|
-
} catch (err) {
|
|
335
|
-
globalThis.clearTimeout(timeoutId);
|
|
336
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
337
|
-
throw new TimeoutError(timeoutMs);
|
|
338
|
-
}
|
|
339
|
-
if (err instanceof APIError) {
|
|
340
|
-
throw err;
|
|
341
|
-
}
|
|
342
|
-
if (attempt <= maxRetries) {
|
|
343
|
-
const delay = Math.min(100 * Math.pow(2, attempt) + Math.random() * 50, 2e3);
|
|
344
|
-
await new Promise(
|
|
345
|
-
(resolve) => globalThis.setTimeout(() => resolve(), delay)
|
|
346
|
-
);
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
throw err;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
317
|
+
/**
|
|
318
|
+
* Removes the organization-wide assignment from the rule.
|
|
319
|
+
* Throws LastSubjectError if it is the rule's only subject.
|
|
320
|
+
*/
|
|
321
|
+
async unassignFromOrganization(ruleId) {
|
|
322
|
+
return this.changeAssignment("DELETE", ruleId, { scope: "organization" });
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Returns the rules that apply to a user: assigned directly, through the user's role,
|
|
326
|
+
* or to the whole organization.
|
|
327
|
+
*/
|
|
328
|
+
async listUserRules(userId) {
|
|
329
|
+
const raw = await this.send("GET", userPath(userId, "/geoidentity/rules"));
|
|
330
|
+
return (_nullishCoalesce(raw, () => ( []))).map(toRule);
|
|
331
|
+
}
|
|
332
|
+
async changeAssignment(method, ruleId, payload) {
|
|
333
|
+
return toRule(await this.send(method, rulePath(ruleId, "/assignments"), payload));
|
|
334
|
+
}
|
|
335
|
+
send(method, path, body) {
|
|
336
|
+
return apiServiceRequest(this.http, this.isClosed, method, path, body);
|
|
352
337
|
}
|
|
353
338
|
};
|
|
339
|
+
function polygonFromLatLng(coordinates) {
|
|
340
|
+
return { type: "Polygon", coordinates: [validateAndNormalizePolygon(coordinates)] };
|
|
341
|
+
}
|
|
354
342
|
|
|
355
343
|
// src/ingester.ts
|
|
356
|
-
var
|
|
357
|
-
var AsyncIngester = class {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
queue = []
|
|
363
|
-
inFlightPromises = /* @__PURE__ */ new Set()
|
|
364
|
-
timer = null
|
|
365
|
-
isClosed = false
|
|
366
|
-
constructor(client, bufferSize = 5e3, batchSize = 100, flushIntervalMs = 500) {
|
|
344
|
+
var _timers = require('timers');
|
|
345
|
+
var AsyncIngester = (_class = class {
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
__init() {this.queue = []}
|
|
351
|
+
__init2() {this.inFlightPromises = /* @__PURE__ */ new Set()}
|
|
352
|
+
__init3() {this.timer = null}
|
|
353
|
+
__init4() {this.isClosed = false}
|
|
354
|
+
constructor(client, bufferSize = 5e3, batchSize = 100, flushIntervalMs = 500) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
367
355
|
this.client = client;
|
|
368
356
|
this.bufferSize = bufferSize;
|
|
369
357
|
this.batchSize = batchSize;
|
|
370
358
|
this.intervalMs = flushIntervalMs;
|
|
371
|
-
this.timer = (0,
|
|
359
|
+
this.timer = _timers.setInterval.call(void 0, () => {
|
|
372
360
|
void this.flush();
|
|
373
361
|
}, this.intervalMs);
|
|
374
362
|
if (this.timer && typeof this.timer.unref === "function") {
|
|
@@ -426,7 +414,7 @@ var AsyncIngester = class {
|
|
|
426
414
|
}
|
|
427
415
|
this.isClosed = true;
|
|
428
416
|
if (this.timer) {
|
|
429
|
-
(0,
|
|
417
|
+
_timers.clearInterval.call(void 0, this.timer);
|
|
430
418
|
this.timer = null;
|
|
431
419
|
}
|
|
432
420
|
while (this.queue.length > 0) {
|
|
@@ -436,19 +424,19 @@ var AsyncIngester = class {
|
|
|
436
424
|
await Promise.all(Array.from(this.inFlightPromises));
|
|
437
425
|
}
|
|
438
426
|
}
|
|
439
|
-
};
|
|
427
|
+
}, _class);
|
|
440
428
|
|
|
441
429
|
// src/models.ts
|
|
442
430
|
var SpatialValidationResult = class {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
448
436
|
constructor(data) {
|
|
449
437
|
this.inside = Boolean(data.inside);
|
|
450
|
-
this.geofenceId = data.geofence_id
|
|
451
|
-
this.geofenceName = data.geofence_name
|
|
438
|
+
this.geofenceId = _nullishCoalesce(_nullishCoalesce(data.geofence_id, () => ( data.geofenceId)), () => ( ""));
|
|
439
|
+
this.geofenceName = _nullishCoalesce(data.geofence_name, () => ( data.geofenceName));
|
|
452
440
|
this.latitude = data.latitude;
|
|
453
441
|
this.longitude = data.longitude;
|
|
454
442
|
}
|
|
@@ -480,15 +468,15 @@ var SpatialValidationResult = class {
|
|
|
480
468
|
}
|
|
481
469
|
};
|
|
482
470
|
var SpatialGeneralResult = class {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
488
476
|
constructor(data) {
|
|
489
477
|
this.inside = Boolean(data.inside);
|
|
490
|
-
this.totalMatches = data.total_matches
|
|
491
|
-
this.matchedGeofences = data.matched_geofences
|
|
478
|
+
this.totalMatches = _nullishCoalesce(_nullishCoalesce(data.total_matches, () => ( data.totalMatches)), () => ( (_nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'access', _6 => _6.matched_geofences, 'optionalAccess', _7 => _7.length]), () => ( _optionalChain([data, 'access', _8 => _8.matchedGeofences, 'optionalAccess', _9 => _9.length]))), () => ( 0)))));
|
|
479
|
+
this.matchedGeofences = _nullishCoalesce(_nullishCoalesce(data.matched_geofences, () => ( data.matchedGeofences)), () => ( []));
|
|
492
480
|
this.latitude = data.latitude;
|
|
493
481
|
this.longitude = data.longitude;
|
|
494
482
|
}
|
|
@@ -508,7 +496,7 @@ var SpatialGeneralResult = class {
|
|
|
508
496
|
* Returns the first matched geofence, or null if no matches found.
|
|
509
497
|
*/
|
|
510
498
|
firstMatch() {
|
|
511
|
-
return this.matchedGeofences[0]
|
|
499
|
+
return _nullishCoalesce(this.matchedGeofences[0], () => ( null));
|
|
512
500
|
}
|
|
513
501
|
/**
|
|
514
502
|
* Returns all matched geofence IDs as a string array.
|
|
@@ -555,57 +543,12 @@ var SpatialGeneralResult = class {
|
|
|
555
543
|
}
|
|
556
544
|
};
|
|
557
545
|
|
|
558
|
-
// src/validation.ts
|
|
559
|
-
function validateCoordinates(lat, lng) {
|
|
560
|
-
if (typeof lat !== "number" || Number.isNaN(lat) || lat < -90 || lat > 90) {
|
|
561
|
-
throw new InvalidLatitudeError();
|
|
562
|
-
}
|
|
563
|
-
if (typeof lng !== "number" || Number.isNaN(lng) || lng < -180 || lng > 180) {
|
|
564
|
-
throw new InvalidLongitudeError();
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
function validateDeviceId(deviceId) {
|
|
568
|
-
if (!deviceId || typeof deviceId !== "string" || deviceId.trim() === "") {
|
|
569
|
-
throw new DeviceIDRequiredError();
|
|
570
|
-
}
|
|
571
|
-
return deviceId.trim();
|
|
572
|
-
}
|
|
573
|
-
function validateGeofenceId(geofenceId) {
|
|
574
|
-
if (!geofenceId || typeof geofenceId !== "string" || geofenceId.trim() === "") {
|
|
575
|
-
throw new GeofenceIDRequiredError();
|
|
576
|
-
}
|
|
577
|
-
return geofenceId.trim();
|
|
578
|
-
}
|
|
579
|
-
function validateAndNormalizePolygon(coordinates) {
|
|
580
|
-
if (!Array.isArray(coordinates) || coordinates.length < 3) {
|
|
581
|
-
throw new InvalidCoordinatesError();
|
|
582
|
-
}
|
|
583
|
-
const polygon = [];
|
|
584
|
-
for (const p of coordinates) {
|
|
585
|
-
if (!Array.isArray(p) || p.length !== 2) {
|
|
586
|
-
throw new ValidationError(
|
|
587
|
-
`geoengine: invalid coordinate format: ${JSON.stringify(p)} (expected [lat, lng])`
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
const lat = p[0];
|
|
591
|
-
const lng = p[1];
|
|
592
|
-
validateCoordinates(lat, lng);
|
|
593
|
-
polygon.push([lng, lat]);
|
|
594
|
-
}
|
|
595
|
-
const first = polygon[0];
|
|
596
|
-
const last = polygon[polygon.length - 1];
|
|
597
|
-
if (first[0] !== last[0] || first[1] !== last[1]) {
|
|
598
|
-
polygon.push([first[0], first[1]]);
|
|
599
|
-
}
|
|
600
|
-
return polygon;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
546
|
// src/spatial.ts
|
|
604
547
|
var SpatialService = class {
|
|
605
548
|
constructor(http) {
|
|
606
549
|
this.http = http;
|
|
607
550
|
}
|
|
608
|
-
|
|
551
|
+
|
|
609
552
|
/**
|
|
610
553
|
* Convenience method to check if coordinates fall within a specific geofence.
|
|
611
554
|
*
|
|
@@ -698,9 +641,9 @@ var SpatialCheckBuilder = class {
|
|
|
698
641
|
this.lat = lat;
|
|
699
642
|
this.lng = lng;
|
|
700
643
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
704
647
|
/**
|
|
705
648
|
* Configures validation targeting a specific geofence ID.
|
|
706
649
|
*/
|
|
@@ -721,10 +664,10 @@ var SingleGeofenceCheck = class {
|
|
|
721
664
|
this.lat = lat;
|
|
722
665
|
this.lng = lng;
|
|
723
666
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
728
671
|
/**
|
|
729
672
|
* Performs the single geofence spatial query.
|
|
730
673
|
*/
|
|
@@ -750,9 +693,9 @@ var GeneralGeofenceCheck = class {
|
|
|
750
693
|
this.lat = lat;
|
|
751
694
|
this.lng = lng;
|
|
752
695
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
756
699
|
/**
|
|
757
700
|
* Performs the general spatial query against all organization geofences.
|
|
758
701
|
*/
|
|
@@ -774,24 +717,45 @@ var GeneralGeofenceCheck = class {
|
|
|
774
717
|
};
|
|
775
718
|
|
|
776
719
|
// src/client.ts
|
|
777
|
-
var GeoEngine = class {
|
|
778
|
-
|
|
779
|
-
|
|
720
|
+
var GeoEngine = (_class2 = class {
|
|
721
|
+
#apiKey;
|
|
722
|
+
|
|
723
|
+
__init5() {this.isClosed = false}
|
|
780
724
|
/**
|
|
781
725
|
* Spatial provides point-in-polygon querying and geofence validation capabilities.
|
|
782
726
|
*/
|
|
783
|
-
|
|
727
|
+
|
|
784
728
|
/**
|
|
785
729
|
* Alias for spatial (to maintain exact casing compatibility with Go client.Spatial).
|
|
786
730
|
*/
|
|
787
|
-
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Users manages organization members, roles and invitations.
|
|
734
|
+
*/
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Alias for users (matches Go client.Users).
|
|
738
|
+
*/
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* GeoIdentity manages GeoIdentity access rules for users and the organization.
|
|
742
|
+
*/
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Alias for geoIdentity (matches Go client.GeoIdentity).
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Server-only runtime decision client for `POST /v1/evaluate`.
|
|
750
|
+
*/
|
|
751
|
+
|
|
788
752
|
/**
|
|
789
753
|
* Initializes a new GeoEngine client instance.
|
|
790
754
|
*
|
|
791
755
|
* @param apiKey Your GeoEngine API Key (required)
|
|
792
756
|
* @param options Optional configuration parameters
|
|
793
757
|
*/
|
|
794
|
-
constructor(apiKeyOrOptions, maybeOptions = {}) {
|
|
758
|
+
constructor(apiKeyOrOptions, maybeOptions = {}) {;_class2.prototype.__init5.call(this);
|
|
795
759
|
let resolvedOptions;
|
|
796
760
|
if (typeof apiKeyOrOptions === "string") {
|
|
797
761
|
resolvedOptions = { ...maybeOptions, apiKey: apiKeyOrOptions };
|
|
@@ -801,18 +765,41 @@ var GeoEngine = class {
|
|
|
801
765
|
resolvedOptions = {};
|
|
802
766
|
}
|
|
803
767
|
if (!resolvedOptions.apiKey || resolvedOptions.apiKey.trim() === "") {
|
|
804
|
-
throw new ValidationError("GeoEngine: API Key es requerida.");
|
|
768
|
+
throw new (0, _chunkA6RGK4MAcjs.ValidationError)("GeoEngine: API Key es requerida.");
|
|
805
769
|
}
|
|
806
|
-
this
|
|
770
|
+
this.#apiKey = resolvedOptions.apiKey;
|
|
771
|
+
this.http = new (0, _chunkA6RGK4MAcjs.HttpClient)(resolvedOptions);
|
|
807
772
|
this.spatial = new SpatialService(this.http);
|
|
808
773
|
this.Spatial = this.spatial;
|
|
774
|
+
const isClosed = () => this.isClosed;
|
|
775
|
+
this.users = new UsersService(this.http, isClosed);
|
|
776
|
+
this.Users = this.users;
|
|
777
|
+
this.geoIdentity = new GeoIdentityService(this.http, isClosed);
|
|
778
|
+
this.GeoIdentity = this.geoIdentity;
|
|
779
|
+
this.identity = new (0, _chunkA6RGK4MAcjs.IdentityService)({
|
|
780
|
+
getBaseUrl: () => this.http.options.apiServiceUrl,
|
|
781
|
+
getApiKey: () => this.#apiKey,
|
|
782
|
+
getTimeoutMs: () => this.http.options.identityTimeoutMs,
|
|
783
|
+
getFetch: () => this.http.options.fetch,
|
|
784
|
+
isClosed
|
|
785
|
+
});
|
|
809
786
|
}
|
|
810
787
|
/**
|
|
811
|
-
* Current configuration options.
|
|
788
|
+
* Current configuration options (without secret apiKey).
|
|
812
789
|
*/
|
|
813
790
|
get options() {
|
|
814
791
|
return this.http.options;
|
|
815
792
|
}
|
|
793
|
+
toJSON() {
|
|
794
|
+
return {
|
|
795
|
+
apiKey: "[REDACTED]",
|
|
796
|
+
closed: this.isClosed,
|
|
797
|
+
options: this.http.toJSON()
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
801
|
+
return this.toJSON();
|
|
802
|
+
}
|
|
816
803
|
/**
|
|
817
804
|
* Sends device coordinates over HTTP REST.
|
|
818
805
|
* Equivalent to Go's Client.SendLocation.
|
|
@@ -823,7 +810,7 @@ var GeoEngine = class {
|
|
|
823
810
|
*/
|
|
824
811
|
async sendLocation(deviceId, lat, lng) {
|
|
825
812
|
if (this.isClosed) {
|
|
826
|
-
throw new ClientClosedError();
|
|
813
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
827
814
|
}
|
|
828
815
|
const validId = validateDeviceId(deviceId);
|
|
829
816
|
const payload = {
|
|
@@ -850,10 +837,10 @@ var GeoEngine = class {
|
|
|
850
837
|
*/
|
|
851
838
|
async createGeofence(name, coordinates, webhookUrl) {
|
|
852
839
|
if (this.isClosed) {
|
|
853
|
-
throw new ClientClosedError();
|
|
840
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
854
841
|
}
|
|
855
842
|
if (!name || typeof name !== "string" || name.trim() === "") {
|
|
856
|
-
throw new ValidationError("geoengine: name is required");
|
|
843
|
+
throw new (0, _chunkA6RGK4MAcjs.ValidationError)("geoengine: name is required");
|
|
857
844
|
}
|
|
858
845
|
const polygon = validateAndNormalizePolygon(coordinates);
|
|
859
846
|
const payload = {
|
|
@@ -878,7 +865,7 @@ var GeoEngine = class {
|
|
|
878
865
|
*/
|
|
879
866
|
async validateSpatialPoint(geofenceId, lat, lng) {
|
|
880
867
|
if (this.isClosed) {
|
|
881
|
-
throw new ClientClosedError();
|
|
868
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
882
869
|
}
|
|
883
870
|
return this.spatial.validatePoint(geofenceId, lat, lng);
|
|
884
871
|
}
|
|
@@ -888,7 +875,7 @@ var GeoEngine = class {
|
|
|
888
875
|
*/
|
|
889
876
|
async validateSpatialLocation(req) {
|
|
890
877
|
if (this.isClosed) {
|
|
891
|
-
throw new ClientClosedError();
|
|
878
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
892
879
|
}
|
|
893
880
|
return this.spatial.validateLocation(req);
|
|
894
881
|
}
|
|
@@ -898,7 +885,7 @@ var GeoEngine = class {
|
|
|
898
885
|
*/
|
|
899
886
|
async validateSpatialGeneral(lat, lng) {
|
|
900
887
|
if (this.isClosed) {
|
|
901
|
-
throw new ClientClosedError();
|
|
888
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
902
889
|
}
|
|
903
890
|
return this.spatial.validateGeneral(lat, lng);
|
|
904
891
|
}
|
|
@@ -908,7 +895,7 @@ var GeoEngine = class {
|
|
|
908
895
|
*/
|
|
909
896
|
async validateSpatialGeneralLocation(req) {
|
|
910
897
|
if (this.isClosed) {
|
|
911
|
-
throw new ClientClosedError();
|
|
898
|
+
throw new (0, _chunkA6RGK4MAcjs.ClientClosedError)();
|
|
912
899
|
}
|
|
913
900
|
return this.spatial.validateGeneralLocation(req);
|
|
914
901
|
}
|
|
@@ -923,9 +910,9 @@ var GeoEngine = class {
|
|
|
923
910
|
createAsyncIngester(bufferSize, batchSize, flushIntervalMs) {
|
|
924
911
|
return new AsyncIngester(
|
|
925
912
|
this,
|
|
926
|
-
bufferSize
|
|
927
|
-
batchSize
|
|
928
|
-
flushIntervalMs
|
|
913
|
+
_nullishCoalesce(bufferSize, () => ( this.http.options.bufferSize)),
|
|
914
|
+
_nullishCoalesce(batchSize, () => ( this.http.options.batchSize)),
|
|
915
|
+
_nullishCoalesce(flushIntervalMs, () => ( this.http.options.flushInterval))
|
|
929
916
|
);
|
|
930
917
|
}
|
|
931
918
|
/**
|
|
@@ -936,40 +923,63 @@ var GeoEngine = class {
|
|
|
936
923
|
close() {
|
|
937
924
|
this.isClosed = true;
|
|
938
925
|
}
|
|
939
|
-
};
|
|
926
|
+
}, _class2);
|
|
940
927
|
|
|
941
928
|
// src/index.ts
|
|
942
|
-
var
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
929
|
+
var src_default = GeoEngine;
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
exports.APIError = _chunkA6RGK4MAcjs.APIError; exports.APIServiceError = _chunkA6RGK4MAcjs.APIServiceError; exports.AsyncIngester = AsyncIngester; exports.AuthenticationError = _chunkA6RGK4MAcjs.AuthenticationError; exports.Client = GeoEngine; exports.ClientClosedError = _chunkA6RGK4MAcjs.ClientClosedError; exports.DeviceIDRequiredError = _chunkA6RGK4MAcjs.DeviceIDRequiredError; exports.EmailRequiredError = _chunkA6RGK4MAcjs.EmailRequiredError; exports.ForbiddenError = _chunkA6RGK4MAcjs.ForbiddenError; exports.GeneralGeofenceCheck = GeneralGeofenceCheck; exports.GeoEngine = GeoEngine; exports.GeoEngineError = _chunkA6RGK4MAcjs.GeoEngineError; exports.GeoIdentityService = GeoIdentityService; exports.GeofenceIDRequiredError = _chunkA6RGK4MAcjs.GeofenceIDRequiredError; exports.GeofenceNotFoundError = _chunkA6RGK4MAcjs.GeofenceNotFoundError; exports.IdentityIntegrationError = _chunkA6RGK4MAcjs.IdentityIntegrationError; exports.IdentityService = _chunkA6RGK4MAcjs.IdentityService; exports.IdentityTransientError = _chunkA6RGK4MAcjs.IdentityTransientError; exports.InvalidCoordinatesError = _chunkA6RGK4MAcjs.InvalidCoordinatesError; exports.InvalidLatitudeError = _chunkA6RGK4MAcjs.InvalidLatitudeError; exports.InvalidLongitudeError = _chunkA6RGK4MAcjs.InvalidLongitudeError; exports.InvitationPendingError = _chunkA6RGK4MAcjs.InvitationPendingError; exports.LastAdminError = _chunkA6RGK4MAcjs.LastAdminError; exports.LastSubjectError = _chunkA6RGK4MAcjs.LastSubjectError; exports.QuotaExceededError = _chunkA6RGK4MAcjs.QuotaExceededError; exports.RoleRequiredError = _chunkA6RGK4MAcjs.RoleRequiredError; exports.Roles = Roles; exports.RuleActions = RuleActions; exports.RuleIDRequiredError = _chunkA6RGK4MAcjs.RuleIDRequiredError; exports.RuleNameRequiredError = _chunkA6RGK4MAcjs.RuleNameRequiredError; exports.RuleNotFoundError = _chunkA6RGK4MAcjs.RuleNotFoundError; exports.SingleGeofenceCheck = SingleGeofenceCheck; exports.SpatialAPIError = _chunkA6RGK4MAcjs.SpatialAPIError; exports.SpatialCheckBuilder = SpatialCheckBuilder; exports.SpatialGeneralResult = SpatialGeneralResult; exports.SpatialService = SpatialService; exports.SpatialValidationResult = SpatialValidationResult; exports.SubjectTypes = SubjectTypes; exports.TimeoutError = _chunkA6RGK4MAcjs.TimeoutError; exports.UserAlreadyExistsError = _chunkA6RGK4MAcjs.UserAlreadyExistsError; exports.UserIDRequiredError = _chunkA6RGK4MAcjs.UserIDRequiredError; exports.UserNotFoundError = _chunkA6RGK4MAcjs.UserNotFoundError; exports.UserStatus = UserStatus; exports.UsersService = UsersService; exports.ValidationError = _chunkA6RGK4MAcjs.ValidationError; exports.default = src_default; exports.generateHMACSignature = _chunkA6RGK4MAcjs.generateHMACSignature; exports.isTransient = _chunkA6RGK4MAcjs.isTransient; exports.polygonFromLatLng = polygonFromLatLng; exports.validateAndNormalizePolygon = validateAndNormalizePolygon; exports.validateCoordinates = validateCoordinates; exports.validateDeviceId = validateDeviceId; exports.validateGeofenceId = validateGeofenceId;
|
|
975
985
|
//# sourceMappingURL=index.cjs.map
|