@latlng/sdk 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/client.d.ts +6 -1
- package/dist/errors/index.d.ts +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +277 -269
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,31 +16,31 @@ var e = class extends Error {
|
|
|
16
16
|
constructor(e, t) {
|
|
17
17
|
super(e, t), this.status = t.status, this.url = t.url, this.body = t.body;
|
|
18
18
|
}
|
|
19
|
-
}, r = class extends n {}, i = class extends n {};
|
|
19
|
+
}, r = class extends n {}, i = class extends n {}, a = class extends n {}, o = class extends n {};
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/http/routes.ts
|
|
22
|
-
function
|
|
22
|
+
function s(e, t) {
|
|
23
23
|
return `${e.endsWith("/") ? e.slice(0, -1) : e}${t}`;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function c(e) {
|
|
26
26
|
let t = new URLSearchParams();
|
|
27
27
|
for (let [n, r] of Object.entries(e)) r != null && t.set(n, String(r));
|
|
28
28
|
let n = t.toString();
|
|
29
29
|
return n ? `?${n}` : "";
|
|
30
30
|
}
|
|
31
|
-
var
|
|
31
|
+
var l = {
|
|
32
32
|
ping: () => "/ping",
|
|
33
33
|
healthz: () => "/healthz",
|
|
34
34
|
server: () => "/server",
|
|
35
|
-
info: (e) => `/info${
|
|
35
|
+
info: (e) => `/info${c({ section: e })}`,
|
|
36
36
|
metrics: () => "/metrics",
|
|
37
|
-
collections: (e) => `/collections${
|
|
37
|
+
collections: (e) => `/collections${c({ match_pattern: e })}`,
|
|
38
38
|
collection: (e) => `/collections/${encodeURIComponent(e)}`,
|
|
39
39
|
renameCollection: (e) => `/collections/${encodeURIComponent(e)}/rename`,
|
|
40
40
|
bounds: (e) => `/collections/${encodeURIComponent(e)}/bounds`,
|
|
41
41
|
stats: (e) => `/collections/${encodeURIComponent(e)}/stats`,
|
|
42
42
|
object: (e, t) => `/collections/${encodeURIComponent(e)}/objects/${encodeURIComponent(t)}`,
|
|
43
|
-
objects: (e, t) => `/collections/${encodeURIComponent(e)}/objects${
|
|
43
|
+
objects: (e, t) => `/collections/${encodeURIComponent(e)}/objects${c({ match_pattern: t })}`,
|
|
44
44
|
fields: (e, t) => `/collections/${encodeURIComponent(e)}/objects/${encodeURIComponent(t)}/fields`,
|
|
45
45
|
field: (e, t, n) => `/collections/${encodeURIComponent(e)}/objects/${encodeURIComponent(t)}/fields/${encodeURIComponent(n)}`,
|
|
46
46
|
expire: (e, t) => `/collections/${encodeURIComponent(e)}/objects/${encodeURIComponent(t)}/expire`,
|
|
@@ -52,9 +52,9 @@ var s = {
|
|
|
52
52
|
intersects: (e) => `/collections/${encodeURIComponent(e)}/search/intersects`,
|
|
53
53
|
scan: (e) => `/collections/${encodeURIComponent(e)}/search/scan`,
|
|
54
54
|
search: (e) => `/collections/${encodeURIComponent(e)}/search/text`,
|
|
55
|
-
channels: (e) => `/channels${
|
|
55
|
+
channels: (e) => `/channels${c({ match_pattern: e })}`,
|
|
56
56
|
channel: (e) => `/channels/${encodeURIComponent(e)}`,
|
|
57
|
-
hooks: (e) => `/hooks${
|
|
57
|
+
hooks: (e) => `/hooks${c({ match_pattern: e })}`,
|
|
58
58
|
hook: (e) => `/hooks/${encodeURIComponent(e)}`,
|
|
59
59
|
config: (e) => `/config/${encodeURIComponent(e)}`,
|
|
60
60
|
flushdb: () => "/admin/flushdb",
|
|
@@ -68,12 +68,12 @@ var s = {
|
|
|
68
68
|
};
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/auth/token.ts
|
|
71
|
-
function
|
|
71
|
+
function u(e, t) {
|
|
72
72
|
t && e.set("authorization", `Bearer ${t}`);
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/internal/json.ts
|
|
76
|
-
async function
|
|
76
|
+
async function d(e) {
|
|
77
77
|
if (e.status === 204) return;
|
|
78
78
|
let t = await e.text();
|
|
79
79
|
if (t) try {
|
|
@@ -84,7 +84,7 @@ async function l(e) {
|
|
|
84
84
|
}
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region src/http/transport.ts
|
|
87
|
-
var
|
|
87
|
+
var f = class {
|
|
88
88
|
baseUrl;
|
|
89
89
|
token;
|
|
90
90
|
timeoutMs;
|
|
@@ -94,30 +94,30 @@ var u = class {
|
|
|
94
94
|
this.baseUrl = e.baseUrl, this.token = e.token, this.timeoutMs = e.timeoutMs ?? 5e3, this.headers = e.headers, this.fetchImpl = e.fetch ?? globalThis.fetch.bind(globalThis);
|
|
95
95
|
}
|
|
96
96
|
async request(e) {
|
|
97
|
-
let r =
|
|
98
|
-
e.body !== void 0 &&
|
|
97
|
+
let r = s(e.baseUrl ?? this.baseUrl, e.path), i = new AbortController(), a = setTimeout(() => i.abort(), this.timeoutMs), o = new Headers(this.headers);
|
|
98
|
+
e.body !== void 0 && o.set("content-type", "application/json"), u(o, this.token);
|
|
99
99
|
try {
|
|
100
100
|
let t = await this.fetchImpl(r, {
|
|
101
101
|
method: e.method ?? "GET",
|
|
102
|
-
headers:
|
|
102
|
+
headers: o,
|
|
103
103
|
body: e.body === void 0 ? void 0 : JSON.stringify(e.body),
|
|
104
104
|
signal: i.signal
|
|
105
|
-
}), n = await
|
|
105
|
+
}), n = await d(t);
|
|
106
106
|
if (!t.ok) throw this.toHttpError(r, t.status, n);
|
|
107
107
|
return e.parser ? e.parser(n) : n;
|
|
108
108
|
} catch (e) {
|
|
109
109
|
throw e instanceof n ? e : e instanceof DOMException && e.name === "AbortError" ? new t(this.timeoutMs, { cause: e }) : e;
|
|
110
110
|
} finally {
|
|
111
|
-
clearTimeout(
|
|
111
|
+
clearTimeout(a);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
async requestText(e) {
|
|
115
|
-
let r =
|
|
116
|
-
e.body !== void 0 &&
|
|
115
|
+
let r = s(e.baseUrl ?? this.baseUrl, e.path), i = new AbortController(), a = setTimeout(() => i.abort(), this.timeoutMs), o = new Headers(this.headers);
|
|
116
|
+
e.body !== void 0 && o.set("content-type", "application/json"), u(o, this.token);
|
|
117
117
|
try {
|
|
118
118
|
let t = await this.fetchImpl(r, {
|
|
119
119
|
method: e.method ?? "GET",
|
|
120
|
-
headers:
|
|
120
|
+
headers: o,
|
|
121
121
|
body: e.body === void 0 ? void 0 : JSON.stringify(e.body),
|
|
122
122
|
signal: i.signal
|
|
123
123
|
}), n = await t.text();
|
|
@@ -126,29 +126,29 @@ var u = class {
|
|
|
126
126
|
} catch (e) {
|
|
127
127
|
throw e instanceof n ? e : e instanceof DOMException && e.name === "AbortError" ? new t(this.timeoutMs, { cause: e }) : e;
|
|
128
128
|
} finally {
|
|
129
|
-
clearTimeout(
|
|
129
|
+
clearTimeout(a);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
toHttpError(e, t,
|
|
133
|
-
let
|
|
132
|
+
toHttpError(e, t, s) {
|
|
133
|
+
let c = s && typeof s == "object" && "error" in s && typeof s.error == "string" ? s.error : typeof s == "string" && s.length > 0 ? s : `request failed with status ${t}`, l = {
|
|
134
134
|
status: t,
|
|
135
135
|
url: e,
|
|
136
|
-
body:
|
|
136
|
+
body: s
|
|
137
137
|
};
|
|
138
|
-
return t === 401 ? new r(
|
|
138
|
+
return t === 400 ? new i(c, l) : t === 401 ? new r(c, l) : t === 404 ? new a(c, l) : t === 503 ? new o(c, l) : new n(c, l);
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/internal/assert.ts
|
|
143
|
-
function
|
|
143
|
+
function p(e, t) {
|
|
144
144
|
if (!e) throw Error(t);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function m(e) {
|
|
147
147
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
148
148
|
}
|
|
149
149
|
//#endregion
|
|
150
150
|
//#region src/types/models.ts
|
|
151
|
-
function
|
|
151
|
+
function h(e, t, n) {
|
|
152
152
|
return {
|
|
153
153
|
type: "point",
|
|
154
154
|
lat: e,
|
|
@@ -156,55 +156,55 @@ function p(e, t, n) {
|
|
|
156
156
|
z: n
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function g(e) {
|
|
160
160
|
return {
|
|
161
161
|
type: "bounds",
|
|
162
162
|
bounds: e
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function _(e) {
|
|
166
166
|
return {
|
|
167
167
|
type: "hash",
|
|
168
168
|
value: e
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function v(e) {
|
|
172
172
|
return {
|
|
173
173
|
type: "geojson",
|
|
174
174
|
value: e
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function ee(e) {
|
|
178
178
|
return {
|
|
179
179
|
type: "string",
|
|
180
180
|
value: e
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function te(e) {
|
|
184
184
|
return {
|
|
185
185
|
type: "number",
|
|
186
186
|
value: e
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function ne(e) {
|
|
190
190
|
return {
|
|
191
191
|
type: "text",
|
|
192
192
|
value: e
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function y(e) {
|
|
196
196
|
return {
|
|
197
197
|
type: "json",
|
|
198
198
|
value: e
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function b(e) {
|
|
202
202
|
return Object.entries(e ?? {}).map(([e, t]) => ({
|
|
203
203
|
name: e,
|
|
204
204
|
value: t
|
|
205
205
|
}));
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function x(e) {
|
|
208
208
|
switch (e.type) {
|
|
209
209
|
case "number": return {
|
|
210
210
|
type: "number",
|
|
@@ -220,31 +220,31 @@ function re(e) {
|
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
223
|
+
function S(e) {
|
|
224
|
+
p(m(e), "field value must be an object");
|
|
225
225
|
let t = e.type, n = e.value;
|
|
226
|
-
if (
|
|
226
|
+
if (p(typeof t == "string", "field value type must be a string"), t === "number") return p(typeof n == "number", "field number value must be a number"), {
|
|
227
227
|
type: t,
|
|
228
228
|
value: n
|
|
229
229
|
};
|
|
230
|
-
if (
|
|
230
|
+
if (p(typeof n == "string", "field text/json value must be a string"), t === "text" || t === "json") return {
|
|
231
231
|
type: t,
|
|
232
232
|
value: n
|
|
233
233
|
};
|
|
234
234
|
throw Error(`unknown field value type: ${t}`);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
return e ? (Array.isArray(e) ? e :
|
|
236
|
+
function C(e) {
|
|
237
|
+
return e ? (Array.isArray(e) ? e : b(e)).map((e) => ({
|
|
238
238
|
name: e.name,
|
|
239
|
-
value:
|
|
239
|
+
value: x(e.value)
|
|
240
240
|
})) : [];
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
if (!
|
|
242
|
+
function w(e) {
|
|
243
|
+
if (!m(e)) return {};
|
|
244
244
|
let t = e.values;
|
|
245
|
-
return
|
|
245
|
+
return m(t) ? Object.fromEntries(Object.entries(t).map(([e, t]) => [e, S(t)])) : {};
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function T(e) {
|
|
248
248
|
switch (e.type) {
|
|
249
249
|
case "point": return { Point: {
|
|
250
250
|
lat: e.lat,
|
|
@@ -257,10 +257,10 @@ function S(e) {
|
|
|
257
257
|
case "string": return { String: e.value };
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
if (
|
|
260
|
+
function E(e) {
|
|
261
|
+
if (p(m(e), "geo object must be an object"), "Point" in e) {
|
|
262
262
|
let t = e.Point;
|
|
263
|
-
return
|
|
263
|
+
return p(m(t), "Point payload must be an object"), p(typeof t.lat == "number", "point lat must be a number"), p(typeof t.lon == "number", "point lon must be a number"), {
|
|
264
264
|
type: "point",
|
|
265
265
|
lat: t.lat,
|
|
266
266
|
lon: t.lon,
|
|
@@ -269,7 +269,7 @@ function C(e) {
|
|
|
269
269
|
}
|
|
270
270
|
if ("Bounds" in e) {
|
|
271
271
|
let t = e.Bounds;
|
|
272
|
-
return
|
|
272
|
+
return p(m(t), "Bounds payload must be an object"), {
|
|
273
273
|
type: "bounds",
|
|
274
274
|
bounds: {
|
|
275
275
|
min_lat: Number(t.min_lat),
|
|
@@ -279,7 +279,7 @@ function C(e) {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
if ("Hash" in e) return
|
|
282
|
+
if ("Hash" in e) return p(typeof e.Hash == "string", "Hash payload must be a string"), {
|
|
283
283
|
type: "hash",
|
|
284
284
|
value: e.Hash
|
|
285
285
|
};
|
|
@@ -287,13 +287,13 @@ function C(e) {
|
|
|
287
287
|
type: "geojson",
|
|
288
288
|
value: e.GeoJson
|
|
289
289
|
};
|
|
290
|
-
if ("String" in e) return
|
|
290
|
+
if ("String" in e) return p(typeof e.String == "string", "String payload must be a string"), {
|
|
291
291
|
type: "string",
|
|
292
292
|
value: e.String
|
|
293
293
|
};
|
|
294
294
|
throw Error("unknown geo object shape");
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function D(e) {
|
|
297
297
|
switch (e.type) {
|
|
298
298
|
case "circle": return { Circle: {
|
|
299
299
|
lat: e.lat,
|
|
@@ -322,10 +322,10 @@ function w(e) {
|
|
|
322
322
|
} };
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
325
|
+
function O(e) {
|
|
326
|
+
if (p(m(e), "area must be an object"), "Circle" in e) {
|
|
327
327
|
let t = e.Circle;
|
|
328
|
-
return
|
|
328
|
+
return p(m(t), "Circle payload must be an object"), p(typeof t.lat == "number", "circle lat must be a number"), p(typeof t.lon == "number", "circle lon must be a number"), p(typeof t.meters == "number", "circle meters must be a number"), {
|
|
329
329
|
type: "circle",
|
|
330
330
|
lat: t.lat,
|
|
331
331
|
lon: t.lon,
|
|
@@ -334,7 +334,7 @@ function T(e) {
|
|
|
334
334
|
}
|
|
335
335
|
if ("Bounds" in e) {
|
|
336
336
|
let t = e.Bounds;
|
|
337
|
-
return
|
|
337
|
+
return p(m(t), "Bounds payload must be an object"), {
|
|
338
338
|
type: "bounds",
|
|
339
339
|
bounds: {
|
|
340
340
|
min_lat: Number(t.min_lat),
|
|
@@ -344,7 +344,7 @@ function T(e) {
|
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
|
-
if ("Hash" in e) return
|
|
347
|
+
if ("Hash" in e) return p(typeof e.Hash == "string", "Hash payload must be a string"), {
|
|
348
348
|
type: "hash",
|
|
349
349
|
value: e.Hash
|
|
350
350
|
};
|
|
@@ -354,20 +354,20 @@ function T(e) {
|
|
|
354
354
|
};
|
|
355
355
|
if ("Tile" in e) {
|
|
356
356
|
let t = e.Tile;
|
|
357
|
-
return
|
|
357
|
+
return p(m(t), "Tile payload must be an object"), p(typeof t.x == "number", "tile x must be a number"), p(typeof t.y == "number", "tile y must be a number"), p(typeof t.z == "number", "tile z must be a number"), {
|
|
358
358
|
type: "tile",
|
|
359
359
|
x: t.x,
|
|
360
360
|
y: t.y,
|
|
361
361
|
z: t.z
|
|
362
362
|
};
|
|
363
363
|
}
|
|
364
|
-
if ("Quadkey" in e) return
|
|
364
|
+
if ("Quadkey" in e) return p(typeof e.Quadkey == "string", "Quadkey payload must be a string"), {
|
|
365
365
|
type: "quadkey",
|
|
366
366
|
value: e.Quadkey
|
|
367
367
|
};
|
|
368
368
|
if ("Sector" in e) {
|
|
369
369
|
let t = e.Sector;
|
|
370
|
-
return
|
|
370
|
+
return p(m(t), "Sector payload must be an object"), p(typeof t.lat == "number", "sector lat must be a number"), p(typeof t.lon == "number", "sector lon must be a number"), p(typeof t.meters == "number", "sector meters must be a number"), p(typeof t.bearing1 == "number", "sector bearing1 must be a number"), p(typeof t.bearing2 == "number", "sector bearing2 must be a number"), {
|
|
371
371
|
type: "sector",
|
|
372
372
|
lat: t.lat,
|
|
373
373
|
lon: t.lon,
|
|
@@ -378,7 +378,7 @@ function T(e) {
|
|
|
378
378
|
}
|
|
379
379
|
if ("Reference" in e) {
|
|
380
380
|
let t = e.Reference;
|
|
381
|
-
return
|
|
381
|
+
return p(m(t), "Reference payload must be an object"), p(typeof t.collection == "string", "reference collection must be a string"), p(typeof t.id == "string", "reference id must be a string"), {
|
|
382
382
|
type: "reference",
|
|
383
383
|
collection: t.collection,
|
|
384
384
|
id: t.id
|
|
@@ -386,7 +386,7 @@ function T(e) {
|
|
|
386
386
|
}
|
|
387
387
|
throw Error("unknown area shape");
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function re(e) {
|
|
390
390
|
return e === "desc" ? "Desc" : "Asc";
|
|
391
391
|
}
|
|
392
392
|
function ie(e) {
|
|
@@ -402,46 +402,49 @@ function ae(e) {
|
|
|
402
402
|
case "regex": return { Regex: e.value };
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function k(e) {
|
|
406
406
|
let t = e ?? {};
|
|
407
407
|
return {
|
|
408
408
|
cursor: t.cursor ?? 0,
|
|
409
409
|
limit: t.limit ?? 100,
|
|
410
410
|
nofields: t.nofields ?? !1,
|
|
411
411
|
match_pattern: t.matchPattern ?? null,
|
|
412
|
-
sort:
|
|
412
|
+
sort: re(t.sort),
|
|
413
413
|
where_filters: (t.whereFilters ?? []).map((e) => ({
|
|
414
414
|
field: e.field,
|
|
415
415
|
comparison: ae(e.comparison)
|
|
416
416
|
})),
|
|
417
|
-
where_in_filters: t.whereInFilters ?? []
|
|
418
|
-
|
|
417
|
+
where_in_filters: (t.whereInFilters ?? []).map((e) => ({
|
|
418
|
+
field: e.field,
|
|
419
|
+
values: e.values
|
|
420
|
+
})),
|
|
421
|
+
where_expr_filters: (t.whereExprFilters ?? []).map((e) => ({ expression: e.expression })),
|
|
419
422
|
clip: t.clip ?? !1,
|
|
420
423
|
output: ie(t.output)
|
|
421
424
|
};
|
|
422
425
|
}
|
|
423
426
|
function oe(e) {
|
|
424
|
-
return e == null ? null : (
|
|
427
|
+
return e == null ? null : (p(m(e), "object response must be an object"), p(typeof e.id == "string", "object id must be a string"), {
|
|
425
428
|
id: e.id,
|
|
426
|
-
geo:
|
|
427
|
-
fields:
|
|
429
|
+
geo: E(e.geo),
|
|
430
|
+
fields: w(e.fields),
|
|
428
431
|
expires_at: typeof e.expires_at == "number" ? e.expires_at : null
|
|
429
432
|
});
|
|
430
433
|
}
|
|
431
|
-
function
|
|
432
|
-
return
|
|
433
|
-
results: e.results.map((e) => (
|
|
434
|
+
function A(e) {
|
|
435
|
+
return p(m(e), "search results must be an object"), p(Array.isArray(e.results), "search results array is missing"), {
|
|
436
|
+
results: e.results.map((e) => (p(m(e), "search result item must be an object"), p(typeof e.id == "string", "search result id must be a string"), {
|
|
434
437
|
id: e.id,
|
|
435
|
-
object: e.object === null || e.object === void 0 ? void 0 :
|
|
436
|
-
fields: e.fields === null || e.fields === void 0 ? void 0 :
|
|
438
|
+
object: e.object === null || e.object === void 0 ? void 0 : E(e.object),
|
|
439
|
+
fields: e.fields === null || e.fields === void 0 ? void 0 : w(e.fields),
|
|
437
440
|
distance_meters: typeof e.distance_meters == "number" ? e.distance_meters : null
|
|
438
441
|
})),
|
|
439
442
|
cursor: Number(e.cursor ?? 0),
|
|
440
443
|
count: Number(e.count ?? 0)
|
|
441
444
|
};
|
|
442
445
|
}
|
|
443
|
-
function
|
|
444
|
-
return
|
|
446
|
+
function j(e) {
|
|
447
|
+
return p(m(e), "server info must be an object"), {
|
|
445
448
|
version: typeof e.version == "string" ? e.version : "",
|
|
446
449
|
api_version: typeof e.api_version == "string" ? e.api_version : "",
|
|
447
450
|
protocol_version: typeof e.protocol_version == "string" ? e.protocol_version : "",
|
|
@@ -461,7 +464,7 @@ function k(e) {
|
|
|
461
464
|
}
|
|
462
465
|
//#endregion
|
|
463
466
|
//#region src/types/events.ts
|
|
464
|
-
function
|
|
467
|
+
function M(e) {
|
|
465
468
|
switch (e) {
|
|
466
469
|
case "set": return "Set";
|
|
467
470
|
case "del": return "Del";
|
|
@@ -469,7 +472,7 @@ function A(e) {
|
|
|
469
472
|
case "fset": return "Fset";
|
|
470
473
|
}
|
|
471
474
|
}
|
|
472
|
-
function
|
|
475
|
+
function N(e) {
|
|
473
476
|
switch (e) {
|
|
474
477
|
case "inside": return "Inside";
|
|
475
478
|
case "outside": return "Outside";
|
|
@@ -479,7 +482,7 @@ function j(e) {
|
|
|
479
482
|
case "roam": return "Roam";
|
|
480
483
|
}
|
|
481
484
|
}
|
|
482
|
-
function
|
|
485
|
+
function P(e) {
|
|
483
486
|
switch (e) {
|
|
484
487
|
case "Set":
|
|
485
488
|
case "set": return "set";
|
|
@@ -492,7 +495,7 @@ function M(e) {
|
|
|
492
495
|
default: throw Error(`unknown mutation command: ${String(e)}`);
|
|
493
496
|
}
|
|
494
497
|
}
|
|
495
|
-
function
|
|
498
|
+
function F(e) {
|
|
496
499
|
switch (e) {
|
|
497
500
|
case "Inside":
|
|
498
501
|
case "inside": return "inside";
|
|
@@ -509,129 +512,129 @@ function N(e) {
|
|
|
509
512
|
default: throw Error(`unknown detect type: ${String(e)}`);
|
|
510
513
|
}
|
|
511
514
|
}
|
|
512
|
-
function
|
|
515
|
+
function I(e) {
|
|
513
516
|
switch (e.type) {
|
|
514
517
|
case "nearby": return { Nearby: {
|
|
515
518
|
lat: e.lat,
|
|
516
519
|
lon: e.lon,
|
|
517
520
|
meters: e.meters,
|
|
518
|
-
options:
|
|
521
|
+
options: k(e.options)
|
|
519
522
|
} };
|
|
520
523
|
case "within": return { Within: {
|
|
521
|
-
area:
|
|
522
|
-
options:
|
|
524
|
+
area: D(e.area),
|
|
525
|
+
options: k(e.options)
|
|
523
526
|
} };
|
|
524
527
|
case "intersects": return { Intersects: {
|
|
525
|
-
area:
|
|
526
|
-
options:
|
|
528
|
+
area: D(e.area),
|
|
529
|
+
options: k(e.options)
|
|
527
530
|
} };
|
|
528
531
|
case "roam": return { Roam: {
|
|
529
532
|
target_collection: e.targetCollection,
|
|
530
533
|
target_pattern: e.targetPattern,
|
|
531
534
|
meters: e.meters,
|
|
532
|
-
options:
|
|
535
|
+
options: k(e.options),
|
|
533
536
|
nodwell: e.nodwell ?? !1
|
|
534
537
|
} };
|
|
535
538
|
}
|
|
536
539
|
}
|
|
537
|
-
function
|
|
540
|
+
function L(e) {
|
|
538
541
|
return {
|
|
539
542
|
collection: e.collection,
|
|
540
|
-
query:
|
|
541
|
-
detect: e.detect.map(
|
|
542
|
-
commands: e.commands.map(
|
|
543
|
+
query: I(e.query),
|
|
544
|
+
detect: e.detect.map(N),
|
|
545
|
+
commands: e.commands.map(M)
|
|
543
546
|
};
|
|
544
547
|
}
|
|
545
|
-
function
|
|
546
|
-
return
|
|
548
|
+
function R(e) {
|
|
549
|
+
return p(Array.isArray(e), "hooks response must be an array"), e.map((e) => (p(m(e), "hook info must be an object"), p(typeof e.name == "string", "hook name must be a string"), p(typeof e.endpoint == "string", "hook endpoint must be a string"), p(typeof e.collection == "string", "hook collection must be a string"), {
|
|
547
550
|
name: e.name,
|
|
548
551
|
endpoint: e.endpoint,
|
|
549
552
|
collection: e.collection
|
|
550
553
|
}));
|
|
551
554
|
}
|
|
552
|
-
function
|
|
553
|
-
return
|
|
555
|
+
function z(e) {
|
|
556
|
+
return p(m(e), "channel definition must be an object"), p(typeof e.name == "string", "channel name must be a string"), {
|
|
554
557
|
name: e.name,
|
|
555
|
-
def:
|
|
558
|
+
def: H(e.def)
|
|
556
559
|
};
|
|
557
560
|
}
|
|
558
|
-
function
|
|
559
|
-
return
|
|
561
|
+
function B(e) {
|
|
562
|
+
return p(m(e), "hook definition must be an object"), p(typeof e.name == "string", "hook name must be a string"), p(typeof e.endpoint == "string", "hook endpoint must be a string"), {
|
|
560
563
|
name: e.name,
|
|
561
564
|
endpoint: e.endpoint,
|
|
562
|
-
def:
|
|
565
|
+
def: H(e.def)
|
|
563
566
|
};
|
|
564
567
|
}
|
|
565
|
-
function
|
|
566
|
-
return
|
|
567
|
-
command:
|
|
568
|
-
detect:
|
|
568
|
+
function V(e) {
|
|
569
|
+
return p(m(e), "geofence event must be an object"), p(typeof e.collection == "string", "event collection missing"), p(typeof e.id == "string", "event id missing"), p(typeof e.timestamp_ns == "number", "timestamp missing"), {
|
|
570
|
+
command: P(e.command),
|
|
571
|
+
detect: F(e.detect),
|
|
569
572
|
collection: e.collection,
|
|
570
573
|
id: e.id,
|
|
571
|
-
object:
|
|
572
|
-
fields:
|
|
574
|
+
object: E(e.object),
|
|
575
|
+
fields: w(e.fields),
|
|
573
576
|
timestamp_ns: e.timestamp_ns,
|
|
574
577
|
event_id: typeof e.event_id == "string" ? e.event_id : null,
|
|
575
578
|
job_id: typeof e.job_id == "string" ? e.job_id : null,
|
|
576
579
|
hook: typeof e.hook == "string" ? e.hook : null,
|
|
577
580
|
group: typeof e.group == "string" ? e.group : null,
|
|
578
|
-
nearby:
|
|
581
|
+
nearby: m(e.nearby) && typeof e.nearby.collection == "string" && typeof e.nearby.id == "string" && typeof e.nearby.meters == "number" ? {
|
|
579
582
|
collection: e.nearby.collection,
|
|
580
583
|
id: e.nearby.id,
|
|
581
584
|
meters: e.nearby.meters
|
|
582
585
|
} : null
|
|
583
586
|
};
|
|
584
587
|
}
|
|
585
|
-
function
|
|
586
|
-
return
|
|
588
|
+
function H(e) {
|
|
589
|
+
return p(m(e), "geofence definition must be an object"), p(typeof e.collection == "string", "geofence collection must be a string"), p(Array.isArray(e.detect), "geofence detect must be an array"), p(Array.isArray(e.commands), "geofence commands must be an array"), {
|
|
587
590
|
collection: e.collection,
|
|
588
|
-
query:
|
|
589
|
-
detect: e.detect.map(
|
|
590
|
-
commands: e.commands.map(
|
|
591
|
+
query: U(e.query),
|
|
592
|
+
detect: e.detect.map(F),
|
|
593
|
+
commands: e.commands.map(P)
|
|
591
594
|
};
|
|
592
595
|
}
|
|
593
|
-
function
|
|
594
|
-
if (
|
|
596
|
+
function U(e) {
|
|
597
|
+
if (p(m(e), "geofence query must be an object"), "Nearby" in e) {
|
|
595
598
|
let t = e.Nearby;
|
|
596
|
-
return
|
|
599
|
+
return p(m(t), "Nearby payload must be an object"), p(typeof t.lat == "number", "nearby lat must be a number"), p(typeof t.lon == "number", "nearby lon must be a number"), p(typeof t.meters == "number", "nearby meters must be a number"), {
|
|
597
600
|
type: "nearby",
|
|
598
601
|
lat: t.lat,
|
|
599
602
|
lon: t.lon,
|
|
600
603
|
meters: t.meters,
|
|
601
|
-
options:
|
|
604
|
+
options: W(t.options)
|
|
602
605
|
};
|
|
603
606
|
}
|
|
604
607
|
if ("Within" in e) {
|
|
605
608
|
let t = e.Within;
|
|
606
|
-
return
|
|
609
|
+
return p(m(t), "Within payload must be an object"), {
|
|
607
610
|
type: "within",
|
|
608
|
-
area:
|
|
609
|
-
options:
|
|
611
|
+
area: O(t.area),
|
|
612
|
+
options: W(t.options)
|
|
610
613
|
};
|
|
611
614
|
}
|
|
612
615
|
if ("Intersects" in e) {
|
|
613
616
|
let t = e.Intersects;
|
|
614
|
-
return
|
|
617
|
+
return p(m(t), "Intersects payload must be an object"), {
|
|
615
618
|
type: "intersects",
|
|
616
|
-
area:
|
|
617
|
-
options:
|
|
619
|
+
area: O(t.area),
|
|
620
|
+
options: W(t.options)
|
|
618
621
|
};
|
|
619
622
|
}
|
|
620
623
|
if ("Roam" in e) {
|
|
621
624
|
let t = e.Roam;
|
|
622
|
-
return
|
|
625
|
+
return p(m(t), "Roam payload must be an object"), p(typeof t.target_collection == "string", "roam target_collection must be a string"), p(typeof t.target_pattern == "string", "roam target_pattern must be a string"), p(typeof t.meters == "number", "roam meters must be a number"), {
|
|
623
626
|
type: "roam",
|
|
624
627
|
targetCollection: t.target_collection,
|
|
625
628
|
targetPattern: t.target_pattern,
|
|
626
629
|
meters: t.meters,
|
|
627
|
-
options:
|
|
630
|
+
options: W(t.options),
|
|
628
631
|
nodwell: typeof t.nodwell == "boolean" ? t.nodwell : void 0
|
|
629
632
|
};
|
|
630
633
|
}
|
|
631
634
|
throw Error("unknown geofence query shape");
|
|
632
635
|
}
|
|
633
|
-
function
|
|
634
|
-
if (!
|
|
636
|
+
function W(e) {
|
|
637
|
+
if (!m(e)) return;
|
|
635
638
|
let t = typeof e.limit == "number" ? e.limit : void 0, n = typeof e.cursor == "number" ? e.cursor : void 0, r = typeof e.nofields == "boolean" ? e.nofields : void 0, i = typeof e.match_pattern == "string" ? e.match_pattern : void 0, a = typeof e.clip == "boolean" ? e.clip : void 0, o;
|
|
636
639
|
return e.sort === "Desc" ? o = "desc" : e.sort === "Asc" && (o = "asc"), {
|
|
637
640
|
cursor: n,
|
|
@@ -644,40 +647,40 @@ function H(e) {
|
|
|
644
647
|
}
|
|
645
648
|
//#endregion
|
|
646
649
|
//#region src/internal/response-parsers.ts
|
|
647
|
-
function
|
|
650
|
+
function G(t) {
|
|
648
651
|
if (t && typeof t == "object" && "collections" in t && Array.isArray(t.collections)) return t.collections.filter((e) => typeof e == "string");
|
|
649
652
|
throw new e("invalid collections response");
|
|
650
653
|
}
|
|
651
|
-
function
|
|
654
|
+
function K(t) {
|
|
652
655
|
if (t && typeof t == "object" && "channels" in t && Array.isArray(t.channels)) return t.channels.filter((e) => typeof e == "string");
|
|
653
656
|
throw new e("invalid channels response");
|
|
654
657
|
}
|
|
655
|
-
function
|
|
658
|
+
function q(t) {
|
|
656
659
|
if (!Array.isArray(t)) throw new e("invalid stats response");
|
|
657
660
|
return t;
|
|
658
661
|
}
|
|
659
|
-
function
|
|
662
|
+
function se(t) {
|
|
660
663
|
if (!t || typeof t != "object" || !("server" in t)) throw new e("invalid info response");
|
|
661
664
|
let n = t;
|
|
662
665
|
return {
|
|
663
|
-
server:
|
|
666
|
+
server: j(n.server),
|
|
664
667
|
metrics: n.metrics && typeof n.metrics == "object" ? n.metrics : void 0,
|
|
665
668
|
section: typeof n.section == "string" ? n.section : void 0
|
|
666
669
|
};
|
|
667
670
|
}
|
|
668
|
-
function
|
|
671
|
+
function ce(t) {
|
|
669
672
|
if (t && typeof t == "object" && "bounds" in t && t.bounds && typeof t.bounds == "object") return t.bounds;
|
|
670
673
|
throw new e("invalid bounds response");
|
|
671
674
|
}
|
|
672
|
-
function
|
|
675
|
+
function le(t) {
|
|
673
676
|
if (!t || typeof t != "object" || !("name" in t) || typeof t.name != "string" || !("stats" in t) || !t.stats || typeof t.stats != "object") throw new e("invalid collection info response");
|
|
674
677
|
return t;
|
|
675
678
|
}
|
|
676
|
-
function
|
|
679
|
+
function ue(t) {
|
|
677
680
|
if (!t || typeof t != "object") throw new e("invalid webhook queue response");
|
|
678
681
|
return t;
|
|
679
682
|
}
|
|
680
|
-
function
|
|
683
|
+
function de(t) {
|
|
681
684
|
if (!t || typeof t != "object") throw new e("invalid compaction response");
|
|
682
685
|
return t;
|
|
683
686
|
}
|
|
@@ -685,41 +688,41 @@ function J(t) {
|
|
|
685
688
|
if (!t || typeof t != "object" || !("deleted" in t)) throw new e("invalid delete response");
|
|
686
689
|
return !!t.deleted;
|
|
687
690
|
}
|
|
688
|
-
function
|
|
691
|
+
function fe(t) {
|
|
689
692
|
if (!t || typeof t != "object" || !("deleted" in t)) throw new e("invalid delete response");
|
|
690
693
|
return Number(t.deleted ?? 0);
|
|
691
694
|
}
|
|
692
|
-
function
|
|
695
|
+
function pe(t) {
|
|
693
696
|
if (!t || typeof t != "object" || !("stored" in t)) throw new e("invalid set response");
|
|
694
697
|
return !!t.stored;
|
|
695
698
|
}
|
|
696
|
-
function
|
|
699
|
+
function me(t) {
|
|
697
700
|
if (!t || typeof t != "object" || !("updated" in t)) throw new e("invalid update response");
|
|
698
701
|
return !!t.updated;
|
|
699
702
|
}
|
|
700
|
-
function
|
|
703
|
+
function he(t) {
|
|
701
704
|
if (!t || typeof t != "object" || !("renamed" in t)) throw new e("invalid rename response");
|
|
702
705
|
return !!t.renamed;
|
|
703
706
|
}
|
|
704
|
-
function
|
|
707
|
+
function ge(t) {
|
|
705
708
|
if (!t || typeof t != "object" || !("dropped" in t)) throw new e("invalid drop response");
|
|
706
709
|
return !!t.dropped;
|
|
707
710
|
}
|
|
708
|
-
function
|
|
711
|
+
function _e(e) {
|
|
709
712
|
if (e === null) return null;
|
|
710
|
-
if (e && typeof e == "object" && "type" in e) return
|
|
713
|
+
if (e && typeof e == "object" && "type" in e) return S(e);
|
|
711
714
|
if (e && typeof e == "object" && "value" in e) {
|
|
712
715
|
let t = e.value;
|
|
713
|
-
return t == null ? null :
|
|
716
|
+
return t == null ? null : S(t);
|
|
714
717
|
}
|
|
715
|
-
return
|
|
718
|
+
return S(e);
|
|
716
719
|
}
|
|
717
|
-
function
|
|
720
|
+
function ve(t) {
|
|
718
721
|
if (!t || typeof t != "object" || !("ttl" in t)) throw new e("invalid ttl response");
|
|
719
722
|
let n = t.ttl;
|
|
720
723
|
return typeof n == "number" ? n : null;
|
|
721
724
|
}
|
|
722
|
-
function
|
|
725
|
+
function ye(e) {
|
|
723
726
|
if (e === null) return null;
|
|
724
727
|
let t = e && typeof e == "object" && "value" in e ? e.value : e;
|
|
725
728
|
if (t == null) return null;
|
|
@@ -734,23 +737,23 @@ function Y(t, n) {
|
|
|
734
737
|
if (!t || typeof t != "object" || !(n in t)) throw new e(`invalid ${n} response`);
|
|
735
738
|
return !!t[n];
|
|
736
739
|
}
|
|
737
|
-
function
|
|
740
|
+
function be(t) {
|
|
738
741
|
if (!t || typeof t != "object" || !("seconds" in t)) throw new e("invalid timeout response");
|
|
739
742
|
let n = t.seconds;
|
|
740
743
|
return typeof n == "number" ? n : null;
|
|
741
744
|
}
|
|
742
|
-
function
|
|
743
|
-
return
|
|
745
|
+
function xe(e) {
|
|
746
|
+
return z(e);
|
|
744
747
|
}
|
|
745
|
-
function
|
|
746
|
-
return
|
|
748
|
+
function Se(e) {
|
|
749
|
+
return B(e);
|
|
747
750
|
}
|
|
748
|
-
function
|
|
749
|
-
return
|
|
751
|
+
function Ce(e) {
|
|
752
|
+
return R(e);
|
|
750
753
|
}
|
|
751
754
|
//#endregion
|
|
752
755
|
//#region src/routing/read-preference.ts
|
|
753
|
-
function
|
|
756
|
+
function X(e, t, n) {
|
|
754
757
|
let r = e.filter((e) => e.eligible).map((e) => e.url);
|
|
755
758
|
if (r.length === 0) return [];
|
|
756
759
|
if (t === "roundRobinFollowers") {
|
|
@@ -761,7 +764,7 @@ function xe(e, t, n) {
|
|
|
761
764
|
}
|
|
762
765
|
//#endregion
|
|
763
766
|
//#region src/routing/replicas.ts
|
|
764
|
-
var
|
|
767
|
+
var we = class {
|
|
765
768
|
leaderUrl;
|
|
766
769
|
readReplicas;
|
|
767
770
|
readPreference;
|
|
@@ -775,7 +778,7 @@ var Se = class {
|
|
|
775
778
|
return this.leaderUrl;
|
|
776
779
|
}
|
|
777
780
|
async getReadCandidates(e) {
|
|
778
|
-
let t =
|
|
781
|
+
let t = X(await Promise.all(this.readReplicas.map(async (t) => ({
|
|
779
782
|
url: t,
|
|
780
783
|
eligible: await this.isEligibleReplica(t, e)
|
|
781
784
|
}))), this.readPreference, this.roundRobinCursor);
|
|
@@ -790,8 +793,8 @@ var Se = class {
|
|
|
790
793
|
try {
|
|
791
794
|
let r = await t.request({
|
|
792
795
|
baseUrl: e,
|
|
793
|
-
path:
|
|
794
|
-
parser:
|
|
796
|
+
path: l.server(),
|
|
797
|
+
parser: j
|
|
795
798
|
});
|
|
796
799
|
return this.statusCache.set(e, {
|
|
797
800
|
expiresAt: n + this.statusTtlMs,
|
|
@@ -801,7 +804,7 @@ var Se = class {
|
|
|
801
804
|
return this.statusCache.set(e, { expiresAt: n + this.statusTtlMs }), !1;
|
|
802
805
|
}
|
|
803
806
|
}
|
|
804
|
-
},
|
|
807
|
+
}, Te = class {
|
|
805
808
|
values = [];
|
|
806
809
|
resolvers = [];
|
|
807
810
|
closed = !1;
|
|
@@ -836,7 +839,7 @@ var Se = class {
|
|
|
836
839
|
});
|
|
837
840
|
}
|
|
838
841
|
}, Z = class {
|
|
839
|
-
events = new
|
|
842
|
+
events = new Te();
|
|
840
843
|
eventHandlers = /* @__PURE__ */ new Set();
|
|
841
844
|
closeHandlers = /* @__PURE__ */ new Set();
|
|
842
845
|
errorHandlers = /* @__PURE__ */ new Set();
|
|
@@ -972,7 +975,7 @@ var Se = class {
|
|
|
972
975
|
}
|
|
973
976
|
tryParseEvent(e) {
|
|
974
977
|
try {
|
|
975
|
-
return
|
|
978
|
+
return V(e);
|
|
976
979
|
} catch {
|
|
977
980
|
return null;
|
|
978
981
|
}
|
|
@@ -980,32 +983,32 @@ var Se = class {
|
|
|
980
983
|
};
|
|
981
984
|
//#endregion
|
|
982
985
|
//#region src/client.ts
|
|
983
|
-
function
|
|
986
|
+
function Ee(e) {
|
|
984
987
|
switch (e) {
|
|
985
988
|
case "nx": return "Nx";
|
|
986
989
|
case "xx": return "Xx";
|
|
987
990
|
default: return "Always";
|
|
988
991
|
}
|
|
989
992
|
}
|
|
990
|
-
function
|
|
993
|
+
function De(e) {
|
|
991
994
|
return !e || e === "objects" ? { format: "objects" } : e === "points" || e === "bounds" ? { format: e } : "hashes" in e ? {
|
|
992
995
|
format: "hashes",
|
|
993
996
|
hash_precision: e.hashes.precision
|
|
994
997
|
} : { format: "objects" };
|
|
995
998
|
}
|
|
996
|
-
var
|
|
999
|
+
var Oe = class {
|
|
997
1000
|
transport;
|
|
998
1001
|
replicaRouter;
|
|
999
1002
|
token;
|
|
1000
1003
|
webSocketFactory;
|
|
1001
1004
|
constructor(e) {
|
|
1002
|
-
this.transport = new
|
|
1005
|
+
this.transport = new f({
|
|
1003
1006
|
baseUrl: e.leaderUrl,
|
|
1004
1007
|
token: e.token,
|
|
1005
1008
|
timeoutMs: e.timeoutMs,
|
|
1006
1009
|
headers: e.headers,
|
|
1007
1010
|
fetch: e.fetch
|
|
1008
|
-
}), this.replicaRouter = new
|
|
1011
|
+
}), this.replicaRouter = new we({
|
|
1009
1012
|
leaderUrl: e.leaderUrl,
|
|
1010
1013
|
readReplicas: e.readReplicas,
|
|
1011
1014
|
readPreference: e.readPreference,
|
|
@@ -1014,49 +1017,49 @@ var Ee = class {
|
|
|
1014
1017
|
}
|
|
1015
1018
|
async ping() {
|
|
1016
1019
|
return this.requestLeader({
|
|
1017
|
-
path:
|
|
1020
|
+
path: l.ping(),
|
|
1018
1021
|
parser: (e) => e
|
|
1019
1022
|
});
|
|
1020
1023
|
}
|
|
1021
1024
|
async healthz() {
|
|
1022
1025
|
return this.requestLeader({
|
|
1023
|
-
path:
|
|
1026
|
+
path: l.healthz(),
|
|
1024
1027
|
parser: (e) => e
|
|
1025
1028
|
});
|
|
1026
1029
|
}
|
|
1027
1030
|
async server() {
|
|
1028
1031
|
return this.requestLeader({
|
|
1029
|
-
path:
|
|
1030
|
-
parser:
|
|
1032
|
+
path: l.server(),
|
|
1033
|
+
parser: j
|
|
1031
1034
|
});
|
|
1032
1035
|
}
|
|
1033
1036
|
async info(e) {
|
|
1034
1037
|
return this.requestLeader({
|
|
1035
|
-
path:
|
|
1036
|
-
parser:
|
|
1038
|
+
path: l.info(e),
|
|
1039
|
+
parser: se
|
|
1037
1040
|
});
|
|
1038
1041
|
}
|
|
1039
1042
|
async metrics() {
|
|
1040
|
-
return this.transport.requestText({ path:
|
|
1043
|
+
return this.transport.requestText({ path: l.metrics() });
|
|
1041
1044
|
}
|
|
1042
1045
|
async collections(e) {
|
|
1043
1046
|
return this.requestRead({
|
|
1044
|
-
path:
|
|
1045
|
-
parser:
|
|
1047
|
+
path: l.collections(e),
|
|
1048
|
+
parser: G
|
|
1046
1049
|
});
|
|
1047
1050
|
}
|
|
1048
1051
|
async createCollection(e) {
|
|
1049
1052
|
return this.requestWrite({
|
|
1050
1053
|
method: "POST",
|
|
1051
|
-
path:
|
|
1054
|
+
path: l.collection(e),
|
|
1052
1055
|
parser: (e) => Y(e, "created")
|
|
1053
1056
|
});
|
|
1054
1057
|
}
|
|
1055
1058
|
async getCollection(e) {
|
|
1056
1059
|
try {
|
|
1057
1060
|
return await this.requestRead({
|
|
1058
|
-
path:
|
|
1059
|
-
parser:
|
|
1061
|
+
path: l.collection(e),
|
|
1062
|
+
parser: le
|
|
1060
1063
|
});
|
|
1061
1064
|
} catch (e) {
|
|
1062
1065
|
if (e instanceof n && e.status === 404) return null;
|
|
@@ -1066,88 +1069,93 @@ var Ee = class {
|
|
|
1066
1069
|
async rename(e, t, n) {
|
|
1067
1070
|
return this.requestWrite({
|
|
1068
1071
|
method: "POST",
|
|
1069
|
-
path:
|
|
1072
|
+
path: l.renameCollection(e),
|
|
1070
1073
|
body: {
|
|
1071
1074
|
new_name: t,
|
|
1072
1075
|
nx: n?.nx ?? !1
|
|
1073
1076
|
},
|
|
1074
|
-
parser:
|
|
1077
|
+
parser: he
|
|
1075
1078
|
});
|
|
1076
1079
|
}
|
|
1077
1080
|
async bounds(e) {
|
|
1078
1081
|
return this.requestRead({
|
|
1079
|
-
path:
|
|
1080
|
-
parser:
|
|
1082
|
+
path: l.bounds(e),
|
|
1083
|
+
parser: ce
|
|
1081
1084
|
});
|
|
1082
1085
|
}
|
|
1083
1086
|
async stats(e) {
|
|
1084
1087
|
return this.requestRead({
|
|
1085
|
-
path:
|
|
1086
|
-
parser:
|
|
1088
|
+
path: l.stats(e),
|
|
1089
|
+
parser: q
|
|
1087
1090
|
});
|
|
1088
1091
|
}
|
|
1089
1092
|
async setObject(e, t, n, r) {
|
|
1090
1093
|
return this.requestWrite({
|
|
1091
1094
|
method: "POST",
|
|
1092
|
-
path:
|
|
1095
|
+
path: l.object(e, t),
|
|
1093
1096
|
body: {
|
|
1094
|
-
object:
|
|
1095
|
-
fields:
|
|
1097
|
+
object: T(n),
|
|
1098
|
+
fields: C(r?.fields),
|
|
1096
1099
|
expire_seconds: r?.expireSeconds,
|
|
1097
|
-
condition:
|
|
1100
|
+
condition: Ee(r?.condition)
|
|
1098
1101
|
},
|
|
1099
|
-
parser:
|
|
1102
|
+
parser: pe
|
|
1100
1103
|
});
|
|
1101
1104
|
}
|
|
1102
1105
|
async setPoint(e, t, n, r) {
|
|
1103
|
-
return this.setObject(e, t,
|
|
1106
|
+
return this.setObject(e, t, h(n.lat, n.lon, n.z), r);
|
|
1104
1107
|
}
|
|
1105
|
-
async get(e, t,
|
|
1106
|
-
let
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1108
|
+
async get(e, t, r) {
|
|
1109
|
+
let i = De(r?.format);
|
|
1110
|
+
try {
|
|
1111
|
+
return await this.requestRead({
|
|
1112
|
+
path: `${l.object(e, t)}${ke({
|
|
1113
|
+
with_fields: r?.withFields ?? !1,
|
|
1114
|
+
format: i.format,
|
|
1115
|
+
hash_precision: i.hash_precision
|
|
1116
|
+
})}`,
|
|
1117
|
+
parser: oe
|
|
1118
|
+
});
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
if (e instanceof n && e.status === 404) return null;
|
|
1121
|
+
throw e;
|
|
1122
|
+
}
|
|
1115
1123
|
}
|
|
1116
1124
|
async delete(e, t) {
|
|
1117
1125
|
return this.requestWrite({
|
|
1118
1126
|
method: "DELETE",
|
|
1119
|
-
path:
|
|
1127
|
+
path: l.object(e, t),
|
|
1120
1128
|
parser: J
|
|
1121
1129
|
});
|
|
1122
1130
|
}
|
|
1123
1131
|
async deleteMatching(e, t) {
|
|
1124
1132
|
return this.requestWrite({
|
|
1125
1133
|
method: "DELETE",
|
|
1126
|
-
path:
|
|
1127
|
-
parser:
|
|
1134
|
+
path: l.objects(e, t?.matchPattern),
|
|
1135
|
+
parser: fe
|
|
1128
1136
|
});
|
|
1129
1137
|
}
|
|
1130
1138
|
async setFields(e, t, n, r) {
|
|
1131
1139
|
return this.requestWrite({
|
|
1132
1140
|
method: "POST",
|
|
1133
|
-
path:
|
|
1141
|
+
path: l.fields(e, t),
|
|
1134
1142
|
body: {
|
|
1135
|
-
fields:
|
|
1143
|
+
fields: C(n),
|
|
1136
1144
|
xx: r?.xx ?? !1
|
|
1137
1145
|
},
|
|
1138
|
-
parser:
|
|
1146
|
+
parser: me
|
|
1139
1147
|
});
|
|
1140
1148
|
}
|
|
1141
1149
|
async getField(e, t, n) {
|
|
1142
1150
|
return this.requestRead({
|
|
1143
|
-
path:
|
|
1144
|
-
parser:
|
|
1151
|
+
path: l.field(e, t, n),
|
|
1152
|
+
parser: _e
|
|
1145
1153
|
});
|
|
1146
1154
|
}
|
|
1147
1155
|
async expire(e, t, n) {
|
|
1148
1156
|
await this.requestWrite({
|
|
1149
1157
|
method: "POST",
|
|
1150
|
-
path:
|
|
1158
|
+
path: l.expire(e, t),
|
|
1151
1159
|
body: { seconds: n },
|
|
1152
1160
|
parser: () => void 0
|
|
1153
1161
|
});
|
|
@@ -1155,20 +1163,20 @@ var Ee = class {
|
|
|
1155
1163
|
async persist(e, t) {
|
|
1156
1164
|
await this.requestWrite({
|
|
1157
1165
|
method: "DELETE",
|
|
1158
|
-
path:
|
|
1166
|
+
path: l.expire(e, t),
|
|
1159
1167
|
parser: () => void 0
|
|
1160
1168
|
});
|
|
1161
1169
|
}
|
|
1162
1170
|
async ttl(e, t) {
|
|
1163
1171
|
return this.requestRead({
|
|
1164
|
-
path:
|
|
1165
|
-
parser:
|
|
1172
|
+
path: l.ttl(e, t),
|
|
1173
|
+
parser: ve
|
|
1166
1174
|
});
|
|
1167
1175
|
}
|
|
1168
1176
|
async setJson(e, t, n, r, i) {
|
|
1169
1177
|
await this.requestWrite({
|
|
1170
1178
|
method: "POST",
|
|
1171
|
-
path:
|
|
1179
|
+
path: l.jsonRoot(e, t),
|
|
1172
1180
|
body: {
|
|
1173
1181
|
path: n,
|
|
1174
1182
|
value: r,
|
|
@@ -1179,75 +1187,75 @@ var Ee = class {
|
|
|
1179
1187
|
}
|
|
1180
1188
|
async getJson(e, t, n) {
|
|
1181
1189
|
return this.requestRead({
|
|
1182
|
-
path:
|
|
1183
|
-
parser:
|
|
1190
|
+
path: l.jsonPath(e, t, n),
|
|
1191
|
+
parser: ye
|
|
1184
1192
|
});
|
|
1185
1193
|
}
|
|
1186
1194
|
async deleteJson(e, t, n) {
|
|
1187
1195
|
return this.requestWrite({
|
|
1188
1196
|
method: "DELETE",
|
|
1189
|
-
path:
|
|
1197
|
+
path: l.jsonPath(e, t, n),
|
|
1190
1198
|
parser: (e) => Y(e, "deleted")
|
|
1191
1199
|
});
|
|
1192
1200
|
}
|
|
1193
1201
|
async nearby(e, t) {
|
|
1194
1202
|
return this.requestRead({
|
|
1195
1203
|
method: "POST",
|
|
1196
|
-
path:
|
|
1204
|
+
path: l.nearby(e),
|
|
1197
1205
|
body: {
|
|
1198
1206
|
lat: t.lat,
|
|
1199
1207
|
lon: t.lon,
|
|
1200
1208
|
meters: t.meters,
|
|
1201
|
-
options:
|
|
1209
|
+
options: k(t.options)
|
|
1202
1210
|
},
|
|
1203
|
-
parser:
|
|
1211
|
+
parser: A
|
|
1204
1212
|
});
|
|
1205
1213
|
}
|
|
1206
1214
|
async within(e, t) {
|
|
1207
1215
|
return this.requestRead({
|
|
1208
1216
|
method: "POST",
|
|
1209
|
-
path:
|
|
1217
|
+
path: l.within(e),
|
|
1210
1218
|
body: {
|
|
1211
|
-
area:
|
|
1212
|
-
options:
|
|
1219
|
+
area: D(t.area),
|
|
1220
|
+
options: k(t.options)
|
|
1213
1221
|
},
|
|
1214
|
-
parser:
|
|
1222
|
+
parser: A
|
|
1215
1223
|
});
|
|
1216
1224
|
}
|
|
1217
1225
|
async intersects(e, t) {
|
|
1218
1226
|
return this.requestRead({
|
|
1219
1227
|
method: "POST",
|
|
1220
|
-
path:
|
|
1228
|
+
path: l.intersects(e),
|
|
1221
1229
|
body: {
|
|
1222
|
-
area:
|
|
1223
|
-
options:
|
|
1230
|
+
area: D(t.area),
|
|
1231
|
+
options: k(t.options)
|
|
1224
1232
|
},
|
|
1225
|
-
parser:
|
|
1233
|
+
parser: A
|
|
1226
1234
|
});
|
|
1227
1235
|
}
|
|
1228
1236
|
async scan(e, t) {
|
|
1229
1237
|
return this.requestRead({
|
|
1230
1238
|
method: "POST",
|
|
1231
|
-
path:
|
|
1232
|
-
body:
|
|
1233
|
-
parser:
|
|
1239
|
+
path: l.scan(e),
|
|
1240
|
+
body: k(t),
|
|
1241
|
+
parser: A
|
|
1234
1242
|
});
|
|
1235
1243
|
}
|
|
1236
1244
|
async search(e, t) {
|
|
1237
1245
|
return this.requestRead({
|
|
1238
1246
|
method: "POST",
|
|
1239
|
-
path:
|
|
1240
|
-
body:
|
|
1241
|
-
parser:
|
|
1247
|
+
path: l.search(e),
|
|
1248
|
+
body: k(t),
|
|
1249
|
+
parser: A
|
|
1242
1250
|
});
|
|
1243
1251
|
}
|
|
1244
1252
|
async setChannel(t) {
|
|
1245
1253
|
return this.requestWrite({
|
|
1246
1254
|
method: "POST",
|
|
1247
|
-
path:
|
|
1255
|
+
path: l.channels(),
|
|
1248
1256
|
body: {
|
|
1249
1257
|
name: t.name,
|
|
1250
|
-
def:
|
|
1258
|
+
def: L(t.def)
|
|
1251
1259
|
},
|
|
1252
1260
|
parser: (t) => {
|
|
1253
1261
|
if (!t || typeof t != "object" || !("name" in t)) throw new e("invalid set channel response");
|
|
@@ -1258,21 +1266,21 @@ var Ee = class {
|
|
|
1258
1266
|
async deleteChannel(e) {
|
|
1259
1267
|
return this.requestWrite({
|
|
1260
1268
|
method: "DELETE",
|
|
1261
|
-
path:
|
|
1269
|
+
path: l.channel(e),
|
|
1262
1270
|
parser: J
|
|
1263
1271
|
});
|
|
1264
1272
|
}
|
|
1265
1273
|
async channels(e) {
|
|
1266
1274
|
return this.requestRead({
|
|
1267
|
-
path:
|
|
1268
|
-
parser:
|
|
1275
|
+
path: l.channels(e),
|
|
1276
|
+
parser: K
|
|
1269
1277
|
});
|
|
1270
1278
|
}
|
|
1271
1279
|
async getChannel(e) {
|
|
1272
1280
|
try {
|
|
1273
1281
|
return await this.requestRead({
|
|
1274
|
-
path:
|
|
1275
|
-
parser:
|
|
1282
|
+
path: l.channel(e),
|
|
1283
|
+
parser: xe
|
|
1276
1284
|
});
|
|
1277
1285
|
} catch (e) {
|
|
1278
1286
|
if (e instanceof n && e.status === 404) return null;
|
|
@@ -1282,11 +1290,11 @@ var Ee = class {
|
|
|
1282
1290
|
async setHook(e) {
|
|
1283
1291
|
await this.requestWrite({
|
|
1284
1292
|
method: "POST",
|
|
1285
|
-
path:
|
|
1293
|
+
path: l.hooks(),
|
|
1286
1294
|
body: {
|
|
1287
1295
|
name: e.name,
|
|
1288
1296
|
endpoint: e.endpoint,
|
|
1289
|
-
def:
|
|
1297
|
+
def: L(e.def)
|
|
1290
1298
|
},
|
|
1291
1299
|
parser: () => void 0
|
|
1292
1300
|
});
|
|
@@ -1294,21 +1302,21 @@ var Ee = class {
|
|
|
1294
1302
|
async deleteHook(e) {
|
|
1295
1303
|
return this.requestWrite({
|
|
1296
1304
|
method: "DELETE",
|
|
1297
|
-
path:
|
|
1305
|
+
path: l.hook(e),
|
|
1298
1306
|
parser: J
|
|
1299
1307
|
});
|
|
1300
1308
|
}
|
|
1301
1309
|
async hooks(e) {
|
|
1302
1310
|
return this.requestRead({
|
|
1303
|
-
path:
|
|
1304
|
-
parser:
|
|
1311
|
+
path: l.hooks(e),
|
|
1312
|
+
parser: Ce
|
|
1305
1313
|
});
|
|
1306
1314
|
}
|
|
1307
1315
|
async getHook(e) {
|
|
1308
1316
|
try {
|
|
1309
1317
|
return await this.requestRead({
|
|
1310
|
-
path:
|
|
1311
|
-
parser:
|
|
1318
|
+
path: l.hook(e),
|
|
1319
|
+
parser: Se
|
|
1312
1320
|
});
|
|
1313
1321
|
} catch (e) {
|
|
1314
1322
|
if (e instanceof n && e.status === 404) return null;
|
|
@@ -1317,7 +1325,7 @@ var Ee = class {
|
|
|
1317
1325
|
}
|
|
1318
1326
|
async configGet(t) {
|
|
1319
1327
|
return this.requestLeader({
|
|
1320
|
-
path:
|
|
1328
|
+
path: l.config(t),
|
|
1321
1329
|
parser: (t) => {
|
|
1322
1330
|
if (!t || typeof t != "object" || !("value" in t)) throw new e("invalid config response");
|
|
1323
1331
|
return String(t.value ?? "");
|
|
@@ -1327,7 +1335,7 @@ var Ee = class {
|
|
|
1327
1335
|
async configSet(e, t) {
|
|
1328
1336
|
await this.requestWrite({
|
|
1329
1337
|
method: "POST",
|
|
1330
|
-
path:
|
|
1338
|
+
path: l.config(e),
|
|
1331
1339
|
body: { value: t },
|
|
1332
1340
|
parser: () => void 0
|
|
1333
1341
|
});
|
|
@@ -1335,41 +1343,41 @@ var Ee = class {
|
|
|
1335
1343
|
async configRewrite() {
|
|
1336
1344
|
await this.requestWrite({
|
|
1337
1345
|
method: "POST",
|
|
1338
|
-
path:
|
|
1346
|
+
path: l.configRewrite(),
|
|
1339
1347
|
parser: () => void 0
|
|
1340
1348
|
});
|
|
1341
1349
|
}
|
|
1342
1350
|
async flushdb() {
|
|
1343
1351
|
await this.requestWrite({
|
|
1344
1352
|
method: "POST",
|
|
1345
|
-
path:
|
|
1353
|
+
path: l.flushdb(),
|
|
1346
1354
|
parser: () => void 0
|
|
1347
1355
|
});
|
|
1348
1356
|
}
|
|
1349
1357
|
async gc() {
|
|
1350
1358
|
await this.requestWrite({
|
|
1351
1359
|
method: "POST",
|
|
1352
|
-
path:
|
|
1360
|
+
path: l.gc(),
|
|
1353
1361
|
parser: () => void 0
|
|
1354
1362
|
});
|
|
1355
1363
|
}
|
|
1356
1364
|
async aofshrink() {
|
|
1357
1365
|
return this.requestWrite({
|
|
1358
1366
|
method: "POST",
|
|
1359
|
-
path:
|
|
1360
|
-
parser:
|
|
1367
|
+
path: l.aofshrink(),
|
|
1368
|
+
parser: de
|
|
1361
1369
|
});
|
|
1362
1370
|
}
|
|
1363
1371
|
async webhookQueue() {
|
|
1364
1372
|
return this.requestLeader({
|
|
1365
|
-
path:
|
|
1366
|
-
parser:
|
|
1373
|
+
path: l.webhookQueue(),
|
|
1374
|
+
parser: ue
|
|
1367
1375
|
});
|
|
1368
1376
|
}
|
|
1369
1377
|
async readonly(t) {
|
|
1370
1378
|
return this.requestWrite({
|
|
1371
1379
|
method: "POST",
|
|
1372
|
-
path:
|
|
1380
|
+
path: l.readonly(),
|
|
1373
1381
|
body: { enabled: t },
|
|
1374
1382
|
parser: (t) => {
|
|
1375
1383
|
if (!t || typeof t != "object" || !("read_only" in t)) throw new e("invalid readonly response");
|
|
@@ -1380,21 +1388,21 @@ var Ee = class {
|
|
|
1380
1388
|
async timeout(e) {
|
|
1381
1389
|
return this.requestWrite({
|
|
1382
1390
|
method: "POST",
|
|
1383
|
-
path:
|
|
1391
|
+
path: l.timeout(),
|
|
1384
1392
|
body: e,
|
|
1385
|
-
parser:
|
|
1393
|
+
parser: be
|
|
1386
1394
|
});
|
|
1387
1395
|
}
|
|
1388
1396
|
async dropCollection(e) {
|
|
1389
1397
|
return this.requestWrite({
|
|
1390
1398
|
method: "DELETE",
|
|
1391
|
-
path:
|
|
1392
|
-
parser:
|
|
1399
|
+
path: l.collection(e),
|
|
1400
|
+
parser: ge
|
|
1393
1401
|
});
|
|
1394
1402
|
}
|
|
1395
1403
|
async connectWebSocket(e) {
|
|
1396
1404
|
return Q.connect({
|
|
1397
|
-
url: e?.url ??
|
|
1405
|
+
url: e?.url ?? Ae(this.replicaRouter.getLeaderUrl()),
|
|
1398
1406
|
token: this.token,
|
|
1399
1407
|
webSocketFactory: this.webSocketFactory
|
|
1400
1408
|
});
|
|
@@ -1437,17 +1445,17 @@ var Ee = class {
|
|
|
1437
1445
|
}
|
|
1438
1446
|
};
|
|
1439
1447
|
function $(e) {
|
|
1440
|
-
return e instanceof
|
|
1448
|
+
return e instanceof o || e instanceof t || !(e instanceof n);
|
|
1441
1449
|
}
|
|
1442
|
-
function
|
|
1450
|
+
function ke(e) {
|
|
1443
1451
|
let t = new URLSearchParams();
|
|
1444
1452
|
for (let [n, r] of Object.entries(e)) r !== void 0 && t.set(n, String(r));
|
|
1445
1453
|
let n = t.toString();
|
|
1446
1454
|
return n ? `?${n}` : "";
|
|
1447
1455
|
}
|
|
1448
|
-
function
|
|
1456
|
+
function Ae(e) {
|
|
1449
1457
|
let t = new URL(e);
|
|
1450
|
-
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.pathname =
|
|
1458
|
+
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.pathname = l.ws(), t.search = "", t.hash = "", t.toString();
|
|
1451
1459
|
}
|
|
1452
1460
|
//#endregion
|
|
1453
|
-
export { r as AuthError, n as HttpError,
|
|
1461
|
+
export { r as AuthError, i as BadRequestError, n as HttpError, Oe as LatLngClient, e as LatLngError, Z as LatLngSubscription, Q as LatLngWebSocketClient, a as NotFoundError, o as ServerUnavailableError, t as TimeoutError, g as bounds, b as fieldEntries, v as geojson, _ as hash, y as jsonField, te as numberField, V as parseGeofenceEvent, h as point, ee as stringObject, ne as textField };
|