ironflock 1.3.2 → 1.3.3
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 +36 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -0
- package/dist/index.mjs +378 -354
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import T from "autobahn";
|
|
2
|
+
function U(d) {
|
|
3
3
|
return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
|
|
4
4
|
}
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
var
|
|
9
|
-
function
|
|
5
|
+
var S = { exports: {} }, O;
|
|
6
|
+
function F() {
|
|
7
|
+
return O || (O = 1, (function(d) {
|
|
8
|
+
var s = Object.prototype.hasOwnProperty, t = "~";
|
|
9
|
+
function o() {
|
|
10
10
|
}
|
|
11
|
-
Object.create && (
|
|
12
|
-
function l(
|
|
13
|
-
this.fn =
|
|
11
|
+
Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (t = !1));
|
|
12
|
+
function l(a, r, n) {
|
|
13
|
+
this.fn = a, this.context = r, this.once = n || !1;
|
|
14
14
|
}
|
|
15
|
-
function i(
|
|
15
|
+
function i(a, r, n, u, h) {
|
|
16
16
|
if (typeof n != "function")
|
|
17
17
|
throw new TypeError("The listener must be a function");
|
|
18
|
-
var v = new l(n, u ||
|
|
19
|
-
return
|
|
18
|
+
var v = new l(n, u || a, h), y = t ? t + r : r;
|
|
19
|
+
return a._events[y] ? a._events[y].fn ? a._events[y] = [a._events[y], v] : a._events[y].push(v) : (a._events[y] = v, a._eventsCount++), a;
|
|
20
20
|
}
|
|
21
|
-
function c(
|
|
22
|
-
--
|
|
21
|
+
function c(a, r) {
|
|
22
|
+
--a._eventsCount === 0 ? a._events = new o() : delete a._events[r];
|
|
23
23
|
}
|
|
24
24
|
function e() {
|
|
25
|
-
this._events = new
|
|
25
|
+
this._events = new o(), this._eventsCount = 0;
|
|
26
26
|
}
|
|
27
27
|
e.prototype.eventNames = function() {
|
|
28
28
|
var r = [], n, u;
|
|
29
29
|
if (this._eventsCount === 0) return r;
|
|
30
30
|
for (u in n = this._events)
|
|
31
|
-
|
|
31
|
+
s.call(n, u) && r.push(t ? u.slice(1) : u);
|
|
32
32
|
return Object.getOwnPropertySymbols ? r.concat(Object.getOwnPropertySymbols(n)) : r;
|
|
33
33
|
}, e.prototype.listeners = function(r) {
|
|
34
|
-
var n =
|
|
34
|
+
var n = t ? t + r : r, u = this._events[n];
|
|
35
35
|
if (!u) return [];
|
|
36
36
|
if (u.fn) return [u.fn];
|
|
37
|
-
for (var
|
|
38
|
-
y[
|
|
37
|
+
for (var h = 0, v = u.length, y = new Array(v); h < v; h++)
|
|
38
|
+
y[h] = u[h].fn;
|
|
39
39
|
return y;
|
|
40
40
|
}, e.prototype.listenerCount = function(r) {
|
|
41
|
-
var n =
|
|
41
|
+
var n = t ? t + r : r, u = this._events[n];
|
|
42
42
|
return u ? u.fn ? 1 : u.length : 0;
|
|
43
|
-
}, e.prototype.emit = function(r, n, u,
|
|
44
|
-
var w =
|
|
43
|
+
}, e.prototype.emit = function(r, n, u, h, v, y) {
|
|
44
|
+
var w = t ? t + r : r;
|
|
45
45
|
if (!this._events[w]) return !1;
|
|
46
|
-
var
|
|
47
|
-
if (
|
|
48
|
-
switch (
|
|
46
|
+
var f = this._events[w], b = arguments.length, A, g;
|
|
47
|
+
if (f.fn) {
|
|
48
|
+
switch (f.once && this.removeListener(r, f.fn, void 0, !0), b) {
|
|
49
49
|
case 1:
|
|
50
|
-
return
|
|
50
|
+
return f.fn.call(f.context), !0;
|
|
51
51
|
case 2:
|
|
52
|
-
return
|
|
52
|
+
return f.fn.call(f.context, n), !0;
|
|
53
53
|
case 3:
|
|
54
|
-
return
|
|
54
|
+
return f.fn.call(f.context, n, u), !0;
|
|
55
55
|
case 4:
|
|
56
|
-
return
|
|
56
|
+
return f.fn.call(f.context, n, u, h), !0;
|
|
57
57
|
case 5:
|
|
58
|
-
return
|
|
58
|
+
return f.fn.call(f.context, n, u, h, v), !0;
|
|
59
59
|
case 6:
|
|
60
|
-
return
|
|
60
|
+
return f.fn.call(f.context, n, u, h, v, y), !0;
|
|
61
61
|
}
|
|
62
62
|
for (g = 1, A = new Array(b - 1); g < b; g++)
|
|
63
63
|
A[g - 1] = arguments[g];
|
|
64
|
-
|
|
64
|
+
f.fn.apply(f.context, A);
|
|
65
65
|
} else {
|
|
66
|
-
var
|
|
67
|
-
for (g = 0; g <
|
|
68
|
-
switch (
|
|
66
|
+
var D = f.length, R;
|
|
67
|
+
for (g = 0; g < D; g++)
|
|
68
|
+
switch (f[g].once && this.removeListener(r, f[g].fn, void 0, !0), b) {
|
|
69
69
|
case 1:
|
|
70
|
-
|
|
70
|
+
f[g].fn.call(f[g].context);
|
|
71
71
|
break;
|
|
72
72
|
case 2:
|
|
73
|
-
|
|
73
|
+
f[g].fn.call(f[g].context, n);
|
|
74
74
|
break;
|
|
75
75
|
case 3:
|
|
76
|
-
|
|
76
|
+
f[g].fn.call(f[g].context, n, u);
|
|
77
77
|
break;
|
|
78
78
|
case 4:
|
|
79
|
-
|
|
79
|
+
f[g].fn.call(f[g].context, n, u, h);
|
|
80
80
|
break;
|
|
81
81
|
default:
|
|
82
82
|
if (!A) for (R = 1, A = new Array(b - 1); R < b; R++)
|
|
83
83
|
A[R - 1] = arguments[R];
|
|
84
|
-
|
|
84
|
+
f[g].fn.apply(f[g].context, A);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
return !0;
|
|
@@ -89,68 +89,68 @@ function U() {
|
|
|
89
89
|
return i(this, r, n, u, !1);
|
|
90
90
|
}, e.prototype.once = function(r, n, u) {
|
|
91
91
|
return i(this, r, n, u, !0);
|
|
92
|
-
}, e.prototype.removeListener = function(r, n, u,
|
|
93
|
-
var v =
|
|
92
|
+
}, e.prototype.removeListener = function(r, n, u, h) {
|
|
93
|
+
var v = t ? t + r : r;
|
|
94
94
|
if (!this._events[v]) return this;
|
|
95
95
|
if (!n)
|
|
96
96
|
return c(this, v), this;
|
|
97
97
|
var y = this._events[v];
|
|
98
98
|
if (y.fn)
|
|
99
|
-
y.fn === n && (!
|
|
99
|
+
y.fn === n && (!h || y.once) && (!u || y.context === u) && c(this, v);
|
|
100
100
|
else {
|
|
101
|
-
for (var w = 0,
|
|
102
|
-
(y[w].fn !== n ||
|
|
103
|
-
|
|
101
|
+
for (var w = 0, f = [], b = y.length; w < b; w++)
|
|
102
|
+
(y[w].fn !== n || h && !y[w].once || u && y[w].context !== u) && f.push(y[w]);
|
|
103
|
+
f.length ? this._events[v] = f.length === 1 ? f[0] : f : c(this, v);
|
|
104
104
|
}
|
|
105
105
|
return this;
|
|
106
106
|
}, e.prototype.removeAllListeners = function(r) {
|
|
107
107
|
var n;
|
|
108
|
-
return r ? (n =
|
|
109
|
-
}, e.prototype.off = e.prototype.removeListener, e.prototype.addListener = e.prototype.on, e.prefixed =
|
|
110
|
-
})(
|
|
108
|
+
return r ? (n = t ? t + r : r, this._events[n] && c(this, n)) : (this._events = new o(), this._eventsCount = 0), this;
|
|
109
|
+
}, e.prototype.off = e.prototype.removeListener, e.prototype.addListener = e.prototype.on, e.prefixed = t, e.EventEmitter = e, d.exports = e;
|
|
110
|
+
})(S)), S.exports;
|
|
111
111
|
}
|
|
112
|
-
var
|
|
113
|
-
const
|
|
114
|
-
"https://studio.datapods.io":
|
|
115
|
-
"https://studio.ironflock.dev":
|
|
116
|
-
"https://studio.ironflock.com":
|
|
117
|
-
"https://studio.record-evolution.com":
|
|
118
|
-
"http://localhost:8085":
|
|
119
|
-
"http://localhost:8086":
|
|
120
|
-
"http://host.docker.internal:8086":
|
|
121
|
-
},
|
|
122
|
-
class I extends
|
|
112
|
+
var W = F();
|
|
113
|
+
const V = /* @__PURE__ */ U(W), Y = "wss://cbw.datapods.io/ws-ua-usr", P = "wss://cbw.ironflock.com/ws-ua-usr", B = "wss://cbw.ironflock.dev/ws-ua-usr", Q = "wss://cbw.record-evolution.com/ws-ua-usr", $ = "ws://localhost:8080/ws-ua-usr", N = {
|
|
114
|
+
"https://studio.datapods.io": Y,
|
|
115
|
+
"https://studio.ironflock.dev": B,
|
|
116
|
+
"https://studio.ironflock.com": P,
|
|
117
|
+
"https://studio.record-evolution.com": Q,
|
|
118
|
+
"http://localhost:8085": $,
|
|
119
|
+
"http://localhost:8086": $,
|
|
120
|
+
"http://host.docker.internal:8086": $
|
|
121
|
+
}, J = 6e3;
|
|
122
|
+
class I extends V {
|
|
123
123
|
constructor() {
|
|
124
124
|
super(), this.subscriptions = [], this.registrations = [], this.firstResolver = () => {
|
|
125
125
|
}, this.firstRejecter = () => {
|
|
126
126
|
}, this.shouldReconnect = !1, this.isReconnecting = !1, this.hasOpenedOnce = !1;
|
|
127
127
|
}
|
|
128
|
-
static getWebSocketURI(
|
|
128
|
+
static getWebSocketURI(s) {
|
|
129
129
|
var l;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
130
|
+
const t = typeof process < "u" ? (l = process.env) == null ? void 0 : l.DEVICE_ENDPOINT_URL : void 0;
|
|
131
|
+
if (t)
|
|
132
132
|
try {
|
|
133
|
-
const i = new URL(
|
|
133
|
+
const i = new URL(t);
|
|
134
134
|
return i.pathname = "/ws-ua-usr", i.toString().replace(/\/$/, "");
|
|
135
135
|
} catch {
|
|
136
136
|
}
|
|
137
|
-
if (!
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
137
|
+
if (!s) return P;
|
|
138
|
+
const o = N[s];
|
|
139
|
+
if (o === void 0)
|
|
140
140
|
throw new Error(
|
|
141
|
-
`Cannot resolve WebSocket URI for reswarmUrl=${JSON.stringify(
|
|
141
|
+
`Cannot resolve WebSocket URI for reswarmUrl=${JSON.stringify(s)}. Set DEVICE_ENDPOINT_URL to the deployment's WAMP router URL (e.g. ws://<host>:18080/ws-re-dev) or pass ironFlockUrl=… to IronFlock(). Known cloud URLs: ${JSON.stringify(Object.keys(N))}`
|
|
142
142
|
);
|
|
143
|
-
return
|
|
143
|
+
return o;
|
|
144
144
|
}
|
|
145
|
-
configure(
|
|
146
|
-
this.realm = `realm-${
|
|
145
|
+
configure(s, t, o, l, i) {
|
|
146
|
+
this.realm = `realm-${s}-${t}-${o}`, this.serial_number = l, this.socketURI = i ?? I.getWebSocketURI();
|
|
147
147
|
}
|
|
148
148
|
async start() {
|
|
149
149
|
if (!this.realm || !this.serial_number || !this.socketURI)
|
|
150
150
|
throw new Error("CrossbarConnection must be configured before starting. Call configure() first.");
|
|
151
|
-
return this.shouldReconnect = !0, this.firstConnection = new Promise((
|
|
152
|
-
this.firstResolver =
|
|
153
|
-
}), this.connection = new
|
|
151
|
+
return this.shouldReconnect = !0, this.firstConnection = new Promise((s, t) => {
|
|
152
|
+
this.firstResolver = s, this.firstRejecter = t;
|
|
153
|
+
}), this.connection = new T.Connection({
|
|
154
154
|
realm: this.realm,
|
|
155
155
|
url: this.socketURI,
|
|
156
156
|
authmethods: ["wampcra"],
|
|
@@ -161,47 +161,47 @@ class I extends W {
|
|
|
161
161
|
// @ts-ignore
|
|
162
162
|
autoping_interval: 2,
|
|
163
163
|
autoping_timeout: 4,
|
|
164
|
-
onchallenge: (
|
|
164
|
+
onchallenge: (s, t, o) => T.auth_cra.sign(this.serial_number, o.challenge)
|
|
165
165
|
}), this.connection.onopen = this.onOpen.bind(this), this.connection.onclose = this.onClose.bind(this), this.connection.open(), this.firstConnection;
|
|
166
166
|
}
|
|
167
|
-
onOpen(
|
|
168
|
-
this.session =
|
|
167
|
+
onOpen(s) {
|
|
168
|
+
this.session = s, this.session.caller_disclose_me = !0, this.hasOpenedOnce = !0, this.resubscribeAll(), this.reregisterAll(), this.emit("connected", this.serial_number), this.firstResolver(), this.firstResolver = () => {
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
onClose(
|
|
171
|
+
onClose(s, t) {
|
|
172
172
|
return this.session = void 0, this.emit("disconnected"), this.firstRejecter(
|
|
173
173
|
new Error(
|
|
174
|
-
`Connection failed: ${
|
|
174
|
+
`Connection failed: ${s} - ${JSON.stringify(t, null, 2)}`
|
|
175
175
|
)
|
|
176
176
|
), this.firstRejecter = () => {
|
|
177
177
|
}, console.warn("Connection closed:", {
|
|
178
|
-
reason:
|
|
179
|
-
details:
|
|
178
|
+
reason: s,
|
|
179
|
+
details: t,
|
|
180
180
|
realm: this.realm,
|
|
181
181
|
url: this.socketURI,
|
|
182
182
|
authid: this.serial_number
|
|
183
|
-
}), this.shouldReconnect && this.hasOpenedOnce && (
|
|
183
|
+
}), this.shouldReconnect && this.hasOpenedOnce && (t == null ? void 0 : t.will_retry) === !1 && this.handleManualReconnect((t == null ? void 0 : t.reason) ?? s), !1;
|
|
184
184
|
}
|
|
185
|
-
async handleManualReconnect(
|
|
185
|
+
async handleManualReconnect(s) {
|
|
186
186
|
if (!(this.isReconnecting || !this.shouldReconnect)) {
|
|
187
187
|
for (this.isReconnecting = !0; this.shouldReconnect && !this.session; )
|
|
188
|
-
if (await new Promise((
|
|
189
|
-
console.log(`Manually retrying connection after ${
|
|
188
|
+
if (await new Promise((t) => setTimeout(t, 1e3)), this.shouldReconnect && this.connection && !this.session) {
|
|
189
|
+
console.log(`Manually retrying connection after ${s}...`);
|
|
190
190
|
try {
|
|
191
|
-
this.connection.open(), await new Promise((
|
|
192
|
-
} catch (
|
|
193
|
-
console.error("Error during manual reconnection attempt:",
|
|
191
|
+
this.connection.open(), await new Promise((t) => setTimeout(t, 500));
|
|
192
|
+
} catch (t) {
|
|
193
|
+
console.error("Error during manual reconnection attempt:", t);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
this.isReconnecting = !1;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
async sessionWait() {
|
|
200
|
-
const
|
|
200
|
+
const s = Date.now();
|
|
201
201
|
for (; !this.session; ) {
|
|
202
|
-
if (Date.now() -
|
|
202
|
+
if (Date.now() - s > J)
|
|
203
203
|
throw new Error("Timeout waiting for session");
|
|
204
|
-
await new Promise((
|
|
204
|
+
await new Promise((t) => setTimeout(t, 200));
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
async waitForConnection() {
|
|
@@ -211,91 +211,91 @@ class I extends W {
|
|
|
211
211
|
return this.session;
|
|
212
212
|
}
|
|
213
213
|
get is_open() {
|
|
214
|
-
var
|
|
215
|
-
return !!((
|
|
214
|
+
var s;
|
|
215
|
+
return !!((s = this.session) != null && s.isOpen);
|
|
216
216
|
}
|
|
217
217
|
isConnected() {
|
|
218
218
|
return this.is_open;
|
|
219
219
|
}
|
|
220
220
|
stop() {
|
|
221
|
-
var
|
|
222
|
-
this.shouldReconnect = !1, (
|
|
221
|
+
var s;
|
|
222
|
+
this.shouldReconnect = !1, (s = this.connection) == null || s.close("wamp.close.normal", "Connection closed by client");
|
|
223
223
|
}
|
|
224
|
-
async subscribe(
|
|
224
|
+
async subscribe(s, t) {
|
|
225
225
|
var l;
|
|
226
226
|
await this.sessionWait();
|
|
227
|
-
const
|
|
228
|
-
return
|
|
227
|
+
const o = await ((l = this.session) == null ? void 0 : l.subscribe(s, t));
|
|
228
|
+
return o && this.subscriptions.push(o), o;
|
|
229
229
|
}
|
|
230
|
-
async unsubscribe(
|
|
231
|
-
var
|
|
230
|
+
async unsubscribe(s) {
|
|
231
|
+
var o;
|
|
232
232
|
await this.sessionWait();
|
|
233
|
-
const
|
|
234
|
-
|
|
233
|
+
const t = this.subscriptions.indexOf(s);
|
|
234
|
+
t !== -1 && (this.subscriptions.splice(t, 1), await ((o = this.session) == null ? void 0 : o.unsubscribe(s)));
|
|
235
235
|
}
|
|
236
|
-
async unsubscribeTopic(
|
|
237
|
-
const
|
|
238
|
-
for (const
|
|
239
|
-
await this.unsubscribe(
|
|
236
|
+
async unsubscribeTopic(s) {
|
|
237
|
+
const t = this.subscriptions.filter((o) => o.topic === s);
|
|
238
|
+
for (const o of t)
|
|
239
|
+
await this.unsubscribe(o);
|
|
240
240
|
}
|
|
241
241
|
async resubscribeAll() {
|
|
242
|
-
const
|
|
242
|
+
const s = [...this.subscriptions];
|
|
243
243
|
this.subscriptions = [], await Promise.all(
|
|
244
|
-
|
|
244
|
+
s.map((t) => this.subscribe(t.topic, t.handler))
|
|
245
245
|
);
|
|
246
246
|
}
|
|
247
247
|
async reregisterAll() {
|
|
248
|
-
const
|
|
248
|
+
const s = [...this.registrations];
|
|
249
249
|
this.registrations = [], await Promise.all(
|
|
250
|
-
|
|
250
|
+
s.map((t) => this.register(t.procedure, t.endpoint, t.options))
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
|
-
async register(
|
|
253
|
+
async register(s, t, o) {
|
|
254
254
|
var c;
|
|
255
255
|
await this.sessionWait();
|
|
256
|
-
const l = { force_reregister: !0, ...
|
|
256
|
+
const l = { force_reregister: !0, ...o ?? {} }, i = await ((c = this.session) == null ? void 0 : c.register(s, t, l));
|
|
257
257
|
return i && this.registrations.push(i), i;
|
|
258
258
|
}
|
|
259
|
-
async unregister(
|
|
260
|
-
var
|
|
261
|
-
await this.sessionWait(), await ((
|
|
262
|
-
const
|
|
263
|
-
|
|
259
|
+
async unregister(s) {
|
|
260
|
+
var o;
|
|
261
|
+
await this.sessionWait(), await ((o = this.session) == null ? void 0 : o.unregister(s));
|
|
262
|
+
const t = this.registrations.indexOf(s);
|
|
263
|
+
t !== -1 && this.registrations.splice(t, 1);
|
|
264
264
|
}
|
|
265
|
-
async call(
|
|
265
|
+
async call(s, t, o, l) {
|
|
266
266
|
var i;
|
|
267
|
-
return await this.sessionWait(), (i = this.session) == null ? void 0 : i.call(
|
|
267
|
+
return await this.sessionWait(), (i = this.session) == null ? void 0 : i.call(s, t, o, l);
|
|
268
268
|
}
|
|
269
|
-
async publish(
|
|
269
|
+
async publish(s, t, o, l) {
|
|
270
270
|
var i;
|
|
271
|
-
return await this.sessionWait(), (i = this.session) == null ? void 0 : i.publish(
|
|
271
|
+
return await this.sessionWait(), (i = this.session) == null ? void 0 : i.publish(s, t, o, l);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
const p = (d) => Math.floor(d) === d &&
|
|
275
|
-
const
|
|
274
|
+
const p = (d) => Math.floor(d) === d && H <= d && d <= G, H = 0, G = 2 ** 32 - 1, K = (d) => q.test(d), q = /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i, k = (d) => {
|
|
275
|
+
const s = (t) => {
|
|
276
276
|
if (d.length === 0)
|
|
277
277
|
return !0;
|
|
278
|
-
const
|
|
279
|
-
return
|
|
278
|
+
const o = d[d.length - 1].path;
|
|
279
|
+
return t.length > o.length || o.substring(0, t.length) !== t;
|
|
280
280
|
};
|
|
281
|
-
return (
|
|
281
|
+
return (t, o) => (t && s(o.path) && (o.value === void 0 && (o.description ?? (o.description = [
|
|
282
282
|
"The value at this path is `undefined`.",
|
|
283
283
|
"",
|
|
284
|
-
`Please fill the \`${
|
|
284
|
+
`Please fill the \`${o.expected}\` typed value next time.`
|
|
285
285
|
].join(`
|
|
286
|
-
`))), d.push(
|
|
286
|
+
`))), d.push(o)), !1);
|
|
287
287
|
}, _ = (d) => Object.assign(d, {
|
|
288
288
|
"~standard": {
|
|
289
289
|
version: 1,
|
|
290
290
|
vendor: "typia",
|
|
291
|
-
validate: (
|
|
292
|
-
const
|
|
293
|
-
return
|
|
294
|
-
value:
|
|
291
|
+
validate: (s) => {
|
|
292
|
+
const t = d(s);
|
|
293
|
+
return t.success ? {
|
|
294
|
+
value: t.data
|
|
295
295
|
} : {
|
|
296
|
-
issues:
|
|
297
|
-
message: `expected ${
|
|
298
|
-
path:
|
|
296
|
+
issues: t.errors.map((o) => ({
|
|
297
|
+
message: `expected ${o.expected}, got ${o.value}`,
|
|
298
|
+
path: X(o.path)
|
|
299
299
|
}))
|
|
300
300
|
};
|
|
301
301
|
}
|
|
@@ -305,152 +305,152 @@ var m;
|
|
|
305
305
|
(function(d) {
|
|
306
306
|
d[d.Start = 0] = "Start", d[d.Property = 1] = "Property", d[d.StringKey = 2] = "StringKey", d[d.NumberKey = 3] = "NumberKey";
|
|
307
307
|
})(m || (m = {}));
|
|
308
|
-
const
|
|
308
|
+
const X = (d) => {
|
|
309
309
|
if (!d.startsWith("$input"))
|
|
310
310
|
throw new Error(`Invalid path: ${JSON.stringify(d)}`);
|
|
311
|
-
const
|
|
312
|
-
let
|
|
311
|
+
const s = [];
|
|
312
|
+
let t = "", o = m.Start, l = 5;
|
|
313
313
|
for (; l < d.length - 1; ) {
|
|
314
314
|
l++;
|
|
315
315
|
const i = d[l];
|
|
316
|
-
if (
|
|
317
|
-
key:
|
|
318
|
-
}),
|
|
319
|
-
key:
|
|
320
|
-
}), l++,
|
|
321
|
-
key: JSON.parse(
|
|
322
|
-
}), l += 2,
|
|
323
|
-
key: Number.parseInt(
|
|
324
|
-
}), l++,
|
|
316
|
+
if (o === m.Property ? i === "." || i === "[" ? (s.push({
|
|
317
|
+
key: t
|
|
318
|
+
}), o = m.Start) : l === d.length - 1 ? (t += i, s.push({
|
|
319
|
+
key: t
|
|
320
|
+
}), l++, o = m.Start) : t += i : o === m.StringKey ? i === '"' ? (s.push({
|
|
321
|
+
key: JSON.parse(t + i)
|
|
322
|
+
}), l += 2, o = m.Start) : i === "\\" ? (t += d[l], l++, t += d[l]) : t += i : o === m.NumberKey && (i === "]" ? (s.push({
|
|
323
|
+
key: Number.parseInt(t)
|
|
324
|
+
}), l++, o = m.Start) : t += i), o === m.Start && l < d.length - 1) {
|
|
325
325
|
const c = d[l];
|
|
326
|
-
if (
|
|
327
|
-
d[l + 1] === '"' ? (
|
|
326
|
+
if (t = "", c === "[")
|
|
327
|
+
d[l + 1] === '"' ? (o = m.StringKey, l++, t = '"') : o = m.NumberKey;
|
|
328
328
|
else if (c === ".")
|
|
329
|
-
|
|
329
|
+
o = m.Property;
|
|
330
330
|
else
|
|
331
331
|
throw new Error("Unreachable: pointer points invalid character");
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
if (
|
|
334
|
+
if (o !== m.Start)
|
|
335
335
|
throw new Error(`Failed to parse path: ${JSON.stringify(d)}`);
|
|
336
|
-
return
|
|
336
|
+
return s;
|
|
337
337
|
};
|
|
338
338
|
var M = /* @__PURE__ */ ((d) => (d.DEVELOPMENT = "dev", d.PRODUCTION = "prod", d))(M || {});
|
|
339
|
-
const
|
|
340
|
-
const d = (r) => typeof r.limit == "number" && p(r.limit) && 1 <= r.limit && r.limit <= 1e4 && (r.offset === void 0 || typeof r.offset == "number" && p(r.offset) && 0 <= r.offset) && (r.timeRange === void 0 || typeof r.timeRange == "object" && r.timeRange !== null &&
|
|
339
|
+
const Z = (() => {
|
|
340
|
+
const d = (r) => typeof r.limit == "number" && p(r.limit) && 1 <= r.limit && r.limit <= 1e4 && (r.offset === void 0 || typeof r.offset == "number" && p(r.offset) && 0 <= r.offset) && (r.timeRange === void 0 || typeof r.timeRange == "object" && r.timeRange !== null && s(r.timeRange)) && (r.filterAnd === void 0 || Array.isArray(r.filterAnd) && r.filterAnd.every((n) => typeof n == "object" && n !== null && t(n))), s = (r) => typeof r.start == "string" && K(r.start) && typeof r.end == "string" && K(r.end), t = (r) => typeof r.column == "string" && 1 <= r.column.length && typeof r.operator == "string" && 1 <= r.operator.length && r.value !== null && r.value !== void 0 && (typeof r.value == "string" || typeof r.value == "number" || typeof r.value == "boolean" || Array.isArray(r.value) && r.value.every((n) => typeof n == "string" || typeof n == "number")), o = (r, n, u = !0) => [typeof r.limit == "number" && (p(r.limit) || a(u, {
|
|
341
341
|
path: n + ".limit",
|
|
342
342
|
expected: 'number & Type<"uint32">',
|
|
343
343
|
value: r.limit
|
|
344
|
-
})) && (1 <= r.limit ||
|
|
344
|
+
})) && (1 <= r.limit || a(u, {
|
|
345
345
|
path: n + ".limit",
|
|
346
346
|
expected: "number & Minimum<1>",
|
|
347
347
|
value: r.limit
|
|
348
|
-
})) && (r.limit <= 1e4 ||
|
|
348
|
+
})) && (r.limit <= 1e4 || a(u, {
|
|
349
349
|
path: n + ".limit",
|
|
350
350
|
expected: "number & Maximum<10000>",
|
|
351
351
|
value: r.limit
|
|
352
|
-
})) ||
|
|
352
|
+
})) || a(u, {
|
|
353
353
|
path: n + ".limit",
|
|
354
354
|
expected: '(number & Type<"uint32"> & Minimum<1> & Maximum<10000>)',
|
|
355
355
|
value: r.limit
|
|
356
|
-
}), r.offset === void 0 || typeof r.offset == "number" && (p(r.offset) ||
|
|
356
|
+
}), r.offset === void 0 || typeof r.offset == "number" && (p(r.offset) || a(u, {
|
|
357
357
|
path: n + ".offset",
|
|
358
358
|
expected: 'number & Type<"uint32">',
|
|
359
359
|
value: r.offset
|
|
360
|
-
})) && (0 <= r.offset ||
|
|
360
|
+
})) && (0 <= r.offset || a(u, {
|
|
361
361
|
path: n + ".offset",
|
|
362
362
|
expected: "number & Minimum<0>",
|
|
363
363
|
value: r.offset
|
|
364
|
-
})) ||
|
|
364
|
+
})) || a(u, {
|
|
365
365
|
path: n + ".offset",
|
|
366
366
|
expected: '((number & Type<"uint32"> & Minimum<0>) | undefined)',
|
|
367
367
|
value: r.offset
|
|
368
|
-
}), r.timeRange === void 0 || (typeof r.timeRange == "object" && r.timeRange !== null ||
|
|
368
|
+
}), r.timeRange === void 0 || (typeof r.timeRange == "object" && r.timeRange !== null || a(u, {
|
|
369
369
|
path: n + ".timeRange",
|
|
370
370
|
expected: "(ISOTimeRange | undefined)",
|
|
371
371
|
value: r.timeRange
|
|
372
|
-
})) && l(r.timeRange, n + ".timeRange", u) ||
|
|
372
|
+
})) && l(r.timeRange, n + ".timeRange", u) || a(u, {
|
|
373
373
|
path: n + ".timeRange",
|
|
374
374
|
expected: "(ISOTimeRange | undefined)",
|
|
375
375
|
value: r.timeRange
|
|
376
|
-
}), r.filterAnd === void 0 || (Array.isArray(r.filterAnd) ||
|
|
376
|
+
}), r.filterAnd === void 0 || (Array.isArray(r.filterAnd) || a(u, {
|
|
377
377
|
path: n + ".filterAnd",
|
|
378
378
|
expected: "(Array<SQLFilterAnd> | undefined)",
|
|
379
379
|
value: r.filterAnd
|
|
380
|
-
})) && r.filterAnd.map((
|
|
380
|
+
})) && r.filterAnd.map((h, v) => (typeof h == "object" && h !== null || a(u, {
|
|
381
381
|
path: n + ".filterAnd[" + v + "]",
|
|
382
382
|
expected: "SQLFilterAnd",
|
|
383
|
-
value:
|
|
384
|
-
})) && i(
|
|
383
|
+
value: h
|
|
384
|
+
})) && i(h, n + ".filterAnd[" + v + "]", u) || a(u, {
|
|
385
385
|
path: n + ".filterAnd[" + v + "]",
|
|
386
386
|
expected: "SQLFilterAnd",
|
|
387
|
-
value:
|
|
388
|
-
})).every((
|
|
387
|
+
value: h
|
|
388
|
+
})).every((h) => h) || a(u, {
|
|
389
389
|
path: n + ".filterAnd",
|
|
390
390
|
expected: "(Array<SQLFilterAnd> | undefined)",
|
|
391
391
|
value: r.filterAnd
|
|
392
|
-
})].every((
|
|
392
|
+
})].every((h) => h), l = (r, n, u = !0) => [typeof r.start == "string" && (K(r.start) || a(u, {
|
|
393
393
|
path: n + ".start",
|
|
394
394
|
expected: 'string & Format<"date-time">',
|
|
395
395
|
value: r.start
|
|
396
|
-
})) ||
|
|
396
|
+
})) || a(u, {
|
|
397
397
|
path: n + ".start",
|
|
398
398
|
expected: '(string & Format<"date-time">)',
|
|
399
399
|
value: r.start
|
|
400
|
-
}), typeof r.end == "string" && (K(r.end) ||
|
|
400
|
+
}), typeof r.end == "string" && (K(r.end) || a(u, {
|
|
401
401
|
path: n + ".end",
|
|
402
402
|
expected: 'string & Format<"date-time">',
|
|
403
403
|
value: r.end
|
|
404
|
-
})) ||
|
|
404
|
+
})) || a(u, {
|
|
405
405
|
path: n + ".end",
|
|
406
406
|
expected: '(string & Format<"date-time">)',
|
|
407
407
|
value: r.end
|
|
408
|
-
})].every((
|
|
408
|
+
})].every((h) => h), i = (r, n, u = !0) => [typeof r.column == "string" && (1 <= r.column.length || a(u, {
|
|
409
409
|
path: n + ".column",
|
|
410
410
|
expected: "string & MinLength<1>",
|
|
411
411
|
value: r.column
|
|
412
|
-
})) ||
|
|
412
|
+
})) || a(u, {
|
|
413
413
|
path: n + ".column",
|
|
414
414
|
expected: "(string & MinLength<1>)",
|
|
415
415
|
value: r.column
|
|
416
|
-
}), typeof r.operator == "string" && (1 <= r.operator.length ||
|
|
416
|
+
}), typeof r.operator == "string" && (1 <= r.operator.length || a(u, {
|
|
417
417
|
path: n + ".operator",
|
|
418
418
|
expected: "string & MinLength<1>",
|
|
419
419
|
value: r.operator
|
|
420
|
-
})) ||
|
|
420
|
+
})) || a(u, {
|
|
421
421
|
path: n + ".operator",
|
|
422
422
|
expected: "(string & MinLength<1>)",
|
|
423
423
|
value: r.operator
|
|
424
|
-
}), (r.value !== null ||
|
|
424
|
+
}), (r.value !== null || a(u, {
|
|
425
425
|
path: n + ".value",
|
|
426
426
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
427
427
|
value: r.value
|
|
428
|
-
})) && (r.value !== void 0 ||
|
|
428
|
+
})) && (r.value !== void 0 || a(u, {
|
|
429
429
|
path: n + ".value",
|
|
430
430
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
431
431
|
value: r.value
|
|
432
|
-
})) && (typeof r.value == "string" || typeof r.value == "number" || typeof r.value == "boolean" || (Array.isArray(r.value) ||
|
|
432
|
+
})) && (typeof r.value == "string" || typeof r.value == "number" || typeof r.value == "boolean" || (Array.isArray(r.value) || a(u, {
|
|
433
433
|
path: n + ".value",
|
|
434
434
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
435
435
|
value: r.value
|
|
436
|
-
})) && r.value.map((
|
|
436
|
+
})) && r.value.map((h, v) => typeof h == "string" || typeof h == "number" || a(u, {
|
|
437
437
|
path: n + ".value[" + v + "]",
|
|
438
438
|
expected: "(number | string)",
|
|
439
|
-
value:
|
|
440
|
-
})).every((
|
|
439
|
+
value: h
|
|
440
|
+
})).every((h) => h) || a(u, {
|
|
441
441
|
path: n + ".value",
|
|
442
442
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
443
443
|
value: r.value
|
|
444
|
-
}))].every((
|
|
445
|
-
let e,
|
|
444
|
+
}))].every((h) => h), c = (r) => typeof r == "object" && r !== null && d(r);
|
|
445
|
+
let e, a;
|
|
446
446
|
return _((r) => {
|
|
447
447
|
if (c(r) === !1) {
|
|
448
|
-
e = [],
|
|
449
|
-
path:
|
|
448
|
+
e = [], a = k(e), ((u, h, v = !0) => (typeof u == "object" && u !== null || a(!0, {
|
|
449
|
+
path: h + "",
|
|
450
450
|
expected: "TableQueryParams",
|
|
451
451
|
value: u
|
|
452
|
-
})) &&
|
|
453
|
-
path:
|
|
452
|
+
})) && o(u, h + "", !0) || a(!0, {
|
|
453
|
+
path: h + "",
|
|
454
454
|
expected: "TableQueryParams",
|
|
455
455
|
value: u
|
|
456
456
|
}))(r, "$input", !0);
|
|
@@ -469,8 +469,8 @@ const X = (() => {
|
|
|
469
469
|
data: r
|
|
470
470
|
};
|
|
471
471
|
});
|
|
472
|
-
})(),
|
|
473
|
-
const d = (i) => typeof i.longitude == "number" && -180 <= i.longitude && i.longitude <= 180 && typeof i.latitude == "number" && -90 <= i.latitude && i.latitude <= 90,
|
|
472
|
+
})(), z = (() => {
|
|
473
|
+
const d = (i) => typeof i.longitude == "number" && -180 <= i.longitude && i.longitude <= 180 && typeof i.latitude == "number" && -90 <= i.latitude && i.latitude <= 90, s = (i, c, e = !0) => [typeof i.longitude == "number" && (-180 <= i.longitude || l(e, {
|
|
474
474
|
path: c + ".longitude",
|
|
475
475
|
expected: "number & Minimum<-180>",
|
|
476
476
|
value: i.longitude
|
|
@@ -494,26 +494,26 @@ const X = (() => {
|
|
|
494
494
|
path: c + ".latitude",
|
|
495
495
|
expected: "(number & Minimum<-90> & Maximum<90>)",
|
|
496
496
|
value: i.latitude
|
|
497
|
-
})].every((
|
|
498
|
-
let
|
|
497
|
+
})].every((a) => a), t = (i) => typeof i == "object" && i !== null && d(i);
|
|
498
|
+
let o, l;
|
|
499
499
|
return _((i) => {
|
|
500
|
-
if (
|
|
501
|
-
|
|
502
|
-
path:
|
|
500
|
+
if (t(i) === !1) {
|
|
501
|
+
o = [], l = k(o), ((e, a, r = !0) => (typeof e == "object" && e !== null || l(!0, {
|
|
502
|
+
path: a + "",
|
|
503
503
|
expected: "LocationParams",
|
|
504
504
|
value: e
|
|
505
|
-
})) &&
|
|
506
|
-
path:
|
|
505
|
+
})) && s(e, a + "", !0) || l(!0, {
|
|
506
|
+
path: a + "",
|
|
507
507
|
expected: "LocationParams",
|
|
508
508
|
value: e
|
|
509
509
|
}))(i, "$input", !0);
|
|
510
|
-
const c =
|
|
510
|
+
const c = o.length === 0;
|
|
511
511
|
return c ? {
|
|
512
512
|
success: c,
|
|
513
513
|
data: i
|
|
514
514
|
} : {
|
|
515
515
|
success: c,
|
|
516
|
-
errors:
|
|
516
|
+
errors: o,
|
|
517
517
|
data: i
|
|
518
518
|
};
|
|
519
519
|
}
|
|
@@ -522,28 +522,28 @@ const X = (() => {
|
|
|
522
522
|
data: i
|
|
523
523
|
};
|
|
524
524
|
});
|
|
525
|
-
})(),
|
|
526
|
-
const d = (e) => typeof e.topic == "string" && 1 <= e.topic.length && (e.args === void 0 || Array.isArray(e.args)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 &&
|
|
527
|
-
path:
|
|
525
|
+
})(), ee = (() => {
|
|
526
|
+
const d = (e) => typeof e.topic == "string" && 1 <= e.topic.length && (e.args === void 0 || Array.isArray(e.args)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 && s(e.kwargs)), s = (e) => Object.keys(e).every((a) => (e[a] === void 0, !0)), t = (e, a, r = !0) => [typeof e.topic == "string" && (1 <= e.topic.length || c(r, {
|
|
527
|
+
path: a + ".topic",
|
|
528
528
|
expected: "string & MinLength<1>",
|
|
529
529
|
value: e.topic
|
|
530
530
|
})) || c(r, {
|
|
531
|
-
path:
|
|
531
|
+
path: a + ".topic",
|
|
532
532
|
expected: "(string & MinLength<1>)",
|
|
533
533
|
value: e.topic
|
|
534
534
|
}), e.args === void 0 || Array.isArray(e.args) || c(r, {
|
|
535
|
-
path:
|
|
535
|
+
path: a + ".args",
|
|
536
536
|
expected: "(Array<unknown> | undefined)",
|
|
537
537
|
value: e.args
|
|
538
538
|
}), e.kwargs === void 0 || (typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 || c(r, {
|
|
539
|
-
path:
|
|
539
|
+
path: a + ".kwargs",
|
|
540
540
|
expected: "(Record<string, unknown> | undefined)",
|
|
541
541
|
value: e.kwargs
|
|
542
|
-
})) &&
|
|
543
|
-
path:
|
|
542
|
+
})) && o(e.kwargs, a + ".kwargs", r) || c(r, {
|
|
543
|
+
path: a + ".kwargs",
|
|
544
544
|
expected: "(Record<string, unknown> | undefined)",
|
|
545
545
|
value: e.kwargs
|
|
546
|
-
})].every((n) => n),
|
|
546
|
+
})].every((n) => n), o = (e, a, r = !0) => [r === !1 || Object.keys(e).map((n) => (e[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (e) => typeof e == "object" && e !== null && d(e);
|
|
547
547
|
let i, c;
|
|
548
548
|
return _((e) => {
|
|
549
549
|
if (l(e) === !1) {
|
|
@@ -551,17 +551,17 @@ const X = (() => {
|
|
|
551
551
|
path: n + "",
|
|
552
552
|
expected: "PublishParams",
|
|
553
553
|
value: r
|
|
554
|
-
})) &&
|
|
554
|
+
})) && t(r, n + "", !0) || c(!0, {
|
|
555
555
|
path: n + "",
|
|
556
556
|
expected: "PublishParams",
|
|
557
557
|
value: r
|
|
558
558
|
}))(e, "$input", !0);
|
|
559
|
-
const
|
|
560
|
-
return
|
|
561
|
-
success:
|
|
559
|
+
const a = i.length === 0;
|
|
560
|
+
return a ? {
|
|
561
|
+
success: a,
|
|
562
562
|
data: e
|
|
563
563
|
} : {
|
|
564
|
-
success:
|
|
564
|
+
success: a,
|
|
565
565
|
errors: i,
|
|
566
566
|
data: e
|
|
567
567
|
};
|
|
@@ -571,36 +571,36 @@ const X = (() => {
|
|
|
571
571
|
data: e
|
|
572
572
|
};
|
|
573
573
|
});
|
|
574
|
-
})(),
|
|
575
|
-
const d = (e) => typeof e.deviceKey == "string" && 1 <= e.deviceKey.length && typeof e.topic == "string" && 1 <= e.topic.length && (e.args === void 0 || Array.isArray(e.args)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 &&
|
|
576
|
-
path:
|
|
574
|
+
})(), se = (() => {
|
|
575
|
+
const d = (e) => typeof e.deviceKey == "string" && 1 <= e.deviceKey.length && typeof e.topic == "string" && 1 <= e.topic.length && (e.args === void 0 || Array.isArray(e.args)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 && s(e.kwargs)), s = (e) => Object.keys(e).every((a) => (e[a] === void 0, !0)), t = (e, a, r = !0) => [typeof e.deviceKey == "string" && (1 <= e.deviceKey.length || c(r, {
|
|
576
|
+
path: a + ".deviceKey",
|
|
577
577
|
expected: "string & MinLength<1>",
|
|
578
578
|
value: e.deviceKey
|
|
579
579
|
})) || c(r, {
|
|
580
|
-
path:
|
|
580
|
+
path: a + ".deviceKey",
|
|
581
581
|
expected: "(string & MinLength<1>)",
|
|
582
582
|
value: e.deviceKey
|
|
583
583
|
}), typeof e.topic == "string" && (1 <= e.topic.length || c(r, {
|
|
584
|
-
path:
|
|
584
|
+
path: a + ".topic",
|
|
585
585
|
expected: "string & MinLength<1>",
|
|
586
586
|
value: e.topic
|
|
587
587
|
})) || c(r, {
|
|
588
|
-
path:
|
|
588
|
+
path: a + ".topic",
|
|
589
589
|
expected: "(string & MinLength<1>)",
|
|
590
590
|
value: e.topic
|
|
591
591
|
}), e.args === void 0 || Array.isArray(e.args) || c(r, {
|
|
592
|
-
path:
|
|
592
|
+
path: a + ".args",
|
|
593
593
|
expected: "(Array<unknown> | undefined)",
|
|
594
594
|
value: e.args
|
|
595
595
|
}), e.kwargs === void 0 || (typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 || c(r, {
|
|
596
|
-
path:
|
|
596
|
+
path: a + ".kwargs",
|
|
597
597
|
expected: "(Record<string, unknown> | undefined)",
|
|
598
598
|
value: e.kwargs
|
|
599
|
-
})) &&
|
|
600
|
-
path:
|
|
599
|
+
})) && o(e.kwargs, a + ".kwargs", r) || c(r, {
|
|
600
|
+
path: a + ".kwargs",
|
|
601
601
|
expected: "(Record<string, unknown> | undefined)",
|
|
602
602
|
value: e.kwargs
|
|
603
|
-
})].every((n) => n),
|
|
603
|
+
})].every((n) => n), o = (e, a, r = !0) => [r === !1 || Object.keys(e).map((n) => (e[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (e) => typeof e == "object" && e !== null && d(e);
|
|
604
604
|
let i, c;
|
|
605
605
|
return _((e) => {
|
|
606
606
|
if (l(e) === !1) {
|
|
@@ -608,17 +608,17 @@ const X = (() => {
|
|
|
608
608
|
path: n + "",
|
|
609
609
|
expected: "CallParams",
|
|
610
610
|
value: r
|
|
611
|
-
})) &&
|
|
611
|
+
})) && t(r, n + "", !0) || c(!0, {
|
|
612
612
|
path: n + "",
|
|
613
613
|
expected: "CallParams",
|
|
614
614
|
value: r
|
|
615
615
|
}))(e, "$input", !0);
|
|
616
|
-
const
|
|
617
|
-
return
|
|
618
|
-
success:
|
|
616
|
+
const a = i.length === 0;
|
|
617
|
+
return a ? {
|
|
618
|
+
success: a,
|
|
619
619
|
data: e
|
|
620
620
|
} : {
|
|
621
|
-
success:
|
|
621
|
+
success: a,
|
|
622
622
|
errors: i,
|
|
623
623
|
data: e
|
|
624
624
|
};
|
|
@@ -628,28 +628,28 @@ const X = (() => {
|
|
|
628
628
|
data: e
|
|
629
629
|
};
|
|
630
630
|
});
|
|
631
|
-
})(),
|
|
632
|
-
const d = (e) => typeof e.tablename == "string" && 1 <= e.tablename.length && (e.args === void 0 || Array.isArray(e.args)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 &&
|
|
633
|
-
path:
|
|
631
|
+
})(), x = (() => {
|
|
632
|
+
const d = (e) => typeof e.tablename == "string" && 1 <= e.tablename.length && (e.args === void 0 || Array.isArray(e.args)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 && s(e.kwargs)), s = (e) => Object.keys(e).every((a) => (e[a] === void 0, !0)), t = (e, a, r = !0) => [typeof e.tablename == "string" && (1 <= e.tablename.length || c(r, {
|
|
633
|
+
path: a + ".tablename",
|
|
634
634
|
expected: "string & MinLength<1>",
|
|
635
635
|
value: e.tablename
|
|
636
636
|
})) || c(r, {
|
|
637
|
-
path:
|
|
637
|
+
path: a + ".tablename",
|
|
638
638
|
expected: "(string & MinLength<1>)",
|
|
639
639
|
value: e.tablename
|
|
640
640
|
}), e.args === void 0 || Array.isArray(e.args) || c(r, {
|
|
641
|
-
path:
|
|
641
|
+
path: a + ".args",
|
|
642
642
|
expected: "(Array<unknown> | undefined)",
|
|
643
643
|
value: e.args
|
|
644
644
|
}), e.kwargs === void 0 || (typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 || c(r, {
|
|
645
|
-
path:
|
|
645
|
+
path: a + ".kwargs",
|
|
646
646
|
expected: "(Record<string, unknown> | undefined)",
|
|
647
647
|
value: e.kwargs
|
|
648
|
-
})) &&
|
|
649
|
-
path:
|
|
648
|
+
})) && o(e.kwargs, a + ".kwargs", r) || c(r, {
|
|
649
|
+
path: a + ".kwargs",
|
|
650
650
|
expected: "(Record<string, unknown> | undefined)",
|
|
651
651
|
value: e.kwargs
|
|
652
|
-
})].every((n) => n),
|
|
652
|
+
})].every((n) => n), o = (e, a, r = !0) => [r === !1 || Object.keys(e).map((n) => (e[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (e) => typeof e == "object" && e !== null && d(e);
|
|
653
653
|
let i, c;
|
|
654
654
|
return _((e) => {
|
|
655
655
|
if (l(e) === !1) {
|
|
@@ -657,17 +657,17 @@ const X = (() => {
|
|
|
657
657
|
path: n + "",
|
|
658
658
|
expected: "TableParams",
|
|
659
659
|
value: r
|
|
660
|
-
})) &&
|
|
660
|
+
})) && t(r, n + "", !0) || c(!0, {
|
|
661
661
|
path: n + "",
|
|
662
662
|
expected: "TableParams",
|
|
663
663
|
value: r
|
|
664
664
|
}))(e, "$input", !0);
|
|
665
|
-
const
|
|
666
|
-
return
|
|
667
|
-
success:
|
|
665
|
+
const a = i.length === 0;
|
|
666
|
+
return a ? {
|
|
667
|
+
success: a,
|
|
668
668
|
data: e
|
|
669
669
|
} : {
|
|
670
|
-
success:
|
|
670
|
+
success: a,
|
|
671
671
|
errors: i,
|
|
672
672
|
data: e
|
|
673
673
|
};
|
|
@@ -678,43 +678,43 @@ const X = (() => {
|
|
|
678
678
|
};
|
|
679
679
|
});
|
|
680
680
|
})(), C = (() => {
|
|
681
|
-
const d = (e) => typeof e.tablename == "string" && 1 <= e.tablename.length && Array.isArray(e.rows) && 1 <= e.rows.length && e.rows.every((
|
|
682
|
-
path:
|
|
681
|
+
const d = (e) => typeof e.tablename == "string" && 1 <= e.tablename.length && Array.isArray(e.rows) && 1 <= e.rows.length && e.rows.every((a) => typeof a == "object" && a !== null && Array.isArray(a) === !1 && s(a)) && (e.kwargs === void 0 || typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 && s(e.kwargs)), s = (e) => Object.keys(e).every((a) => (e[a] === void 0, !0)), t = (e, a, r = !0) => [typeof e.tablename == "string" && (1 <= e.tablename.length || c(r, {
|
|
682
|
+
path: a + ".tablename",
|
|
683
683
|
expected: "string & MinLength<1>",
|
|
684
684
|
value: e.tablename
|
|
685
685
|
})) || c(r, {
|
|
686
|
-
path:
|
|
686
|
+
path: a + ".tablename",
|
|
687
687
|
expected: "(string & MinLength<1>)",
|
|
688
688
|
value: e.tablename
|
|
689
689
|
}), (Array.isArray(e.rows) || c(r, {
|
|
690
|
-
path:
|
|
690
|
+
path: a + ".rows",
|
|
691
691
|
expected: "(Array<Record<string, unknown>> & MinItems<1>)",
|
|
692
692
|
value: e.rows
|
|
693
693
|
})) && (1 <= e.rows.length || c(r, {
|
|
694
|
-
path:
|
|
694
|
+
path: a + ".rows",
|
|
695
695
|
expected: "Array<> & MinItems<1>",
|
|
696
696
|
value: e.rows
|
|
697
697
|
})) && e.rows.map((n, u) => (typeof n == "object" && n !== null && Array.isArray(n) === !1 || c(r, {
|
|
698
|
-
path:
|
|
698
|
+
path: a + ".rows[" + u + "]",
|
|
699
699
|
expected: "Record<string, unknown>",
|
|
700
700
|
value: n
|
|
701
|
-
})) &&
|
|
702
|
-
path:
|
|
701
|
+
})) && o(n, a + ".rows[" + u + "]", r) || c(r, {
|
|
702
|
+
path: a + ".rows[" + u + "]",
|
|
703
703
|
expected: "Record<string, unknown>",
|
|
704
704
|
value: n
|
|
705
705
|
})).every((n) => n) || c(r, {
|
|
706
|
-
path:
|
|
706
|
+
path: a + ".rows",
|
|
707
707
|
expected: "(Array<Record<string, unknown>> & MinItems<1>)",
|
|
708
708
|
value: e.rows
|
|
709
709
|
}), e.kwargs === void 0 || (typeof e.kwargs == "object" && e.kwargs !== null && Array.isArray(e.kwargs) === !1 || c(r, {
|
|
710
|
-
path:
|
|
710
|
+
path: a + ".kwargs",
|
|
711
711
|
expected: "(Record<string, unknown> | undefined)",
|
|
712
712
|
value: e.kwargs
|
|
713
|
-
})) &&
|
|
714
|
-
path:
|
|
713
|
+
})) && o(e.kwargs, a + ".kwargs", r) || c(r, {
|
|
714
|
+
path: a + ".kwargs",
|
|
715
715
|
expected: "(Record<string, unknown> | undefined)",
|
|
716
716
|
value: e.kwargs
|
|
717
|
-
})].every((n) => n),
|
|
717
|
+
})].every((n) => n), o = (e, a, r = !0) => [r === !1 || Object.keys(e).map((n) => (e[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (e) => typeof e == "object" && e !== null && d(e);
|
|
718
718
|
let i, c;
|
|
719
719
|
return _((e) => {
|
|
720
720
|
if (l(e) === !1) {
|
|
@@ -722,17 +722,17 @@ const X = (() => {
|
|
|
722
722
|
path: n + "",
|
|
723
723
|
expected: "BulkTableParams",
|
|
724
724
|
value: r
|
|
725
|
-
})) &&
|
|
725
|
+
})) && t(r, n + "", !0) || c(!0, {
|
|
726
726
|
path: n + "",
|
|
727
727
|
expected: "BulkTableParams",
|
|
728
728
|
value: r
|
|
729
729
|
}))(e, "$input", !0);
|
|
730
|
-
const
|
|
731
|
-
return
|
|
732
|
-
success:
|
|
730
|
+
const a = i.length === 0;
|
|
731
|
+
return a ? {
|
|
732
|
+
success: a,
|
|
733
733
|
data: e
|
|
734
734
|
} : {
|
|
735
|
-
success:
|
|
735
|
+
success: a,
|
|
736
736
|
errors: i,
|
|
737
737
|
data: e
|
|
738
738
|
};
|
|
@@ -742,23 +742,23 @@ const X = (() => {
|
|
|
742
742
|
data: e
|
|
743
743
|
};
|
|
744
744
|
});
|
|
745
|
-
})();
|
|
745
|
+
})(), j = "error-logs";
|
|
746
746
|
function E(d) {
|
|
747
|
-
var
|
|
748
|
-
return typeof process < "u" ? (
|
|
747
|
+
var s;
|
|
748
|
+
return typeof process < "u" ? (s = process.env) == null ? void 0 : s[d] : void 0;
|
|
749
749
|
}
|
|
750
|
-
function
|
|
751
|
-
const
|
|
752
|
-
if (!
|
|
750
|
+
function re(d) {
|
|
751
|
+
const s = d ?? E("DEVICE_SERIAL_NUMBER");
|
|
752
|
+
if (!s)
|
|
753
753
|
throw new Error("serialNumber option is required (or set DEVICE_SERIAL_NUMBER env var in Node.js)");
|
|
754
|
-
return
|
|
754
|
+
return s;
|
|
755
755
|
}
|
|
756
|
-
class
|
|
757
|
-
constructor(
|
|
758
|
-
this._isConfigured = !1, this._serialNumber =
|
|
759
|
-
const
|
|
760
|
-
this._deviceKey ||
|
|
761
|
-
`Warning: The following environment variables must be present: ${
|
|
756
|
+
class L {
|
|
757
|
+
constructor(s) {
|
|
758
|
+
this._isConfigured = !1, this._serialNumber = re(s == null ? void 0 : s.serialNumber), this._deviceName = (s == null ? void 0 : s.deviceName) ?? E("DEVICE_NAME"), this._deviceKey = (s == null ? void 0 : s.deviceKey) ?? E("DEVICE_KEY"), this._appName = (s == null ? void 0 : s.appName) ?? E("APP_NAME"), this._swarmKey = (s == null ? void 0 : s.swarmKey) ?? parseInt(E("SWARM_KEY") ?? "0", 10), this._appKey = (s == null ? void 0 : s.appKey) ?? parseInt(E("APP_KEY") ?? "0", 10), this._env = (s == null ? void 0 : s.env) ?? E("ENV"), this._reswarmUrl = (s == null ? void 0 : s.reswarmUrl) ?? E("RESWARM_URL"), this._cburl = (s == null ? void 0 : s.ironFlockUrl) ?? (s == null ? void 0 : s.cburl), this._connection = new I();
|
|
759
|
+
const t = [];
|
|
760
|
+
this._deviceKey || t.push("DEVICE_KEY"), this._appName || t.push("APP_NAME"), this._swarmKey || t.push("SWARM_KEY"), this._appKey || t.push("APP_KEY"), t.length > 0 && console.warn(
|
|
761
|
+
`Warning: The following environment variables must be present: ${t.join(", ")}`
|
|
762
762
|
);
|
|
763
763
|
}
|
|
764
764
|
get connection() {
|
|
@@ -767,12 +767,12 @@ class P {
|
|
|
767
767
|
get isConnected() {
|
|
768
768
|
return this._connection.is_open;
|
|
769
769
|
}
|
|
770
|
-
configureConnection(
|
|
770
|
+
configureConnection(s) {
|
|
771
771
|
if (this._isConfigured) return;
|
|
772
|
-
const
|
|
772
|
+
const t = (this._env ?? "DEV").toUpperCase(), l = {
|
|
773
773
|
DEV: M.DEVELOPMENT,
|
|
774
774
|
PROD: M.PRODUCTION
|
|
775
|
-
}[
|
|
775
|
+
}[t] ?? M.DEVELOPMENT, i = s ?? this._cburl ?? I.getWebSocketURI(this._reswarmUrl);
|
|
776
776
|
this._connection.configure(
|
|
777
777
|
this._swarmKey,
|
|
778
778
|
this._appKey,
|
|
@@ -781,46 +781,69 @@ class P {
|
|
|
781
781
|
i
|
|
782
782
|
), this._isConfigured = !0;
|
|
783
783
|
}
|
|
784
|
-
async start(
|
|
785
|
-
this.configureConnection(
|
|
784
|
+
async start(s) {
|
|
785
|
+
this.configureConnection(s), await this._connection.start();
|
|
786
786
|
}
|
|
787
787
|
async stop() {
|
|
788
788
|
this._connection.stop();
|
|
789
789
|
}
|
|
790
|
-
async publish(
|
|
791
|
-
const l =
|
|
790
|
+
async publish(s, t, o) {
|
|
791
|
+
const l = ee({ topic: s, args: t, kwargs: o });
|
|
792
792
|
if (!l.success)
|
|
793
793
|
throw new Error(`Invalid publish parameters: ${l.errors.map((e) => e.path + ": " + e.expected).join(", ")}`);
|
|
794
794
|
const c = { ...{
|
|
795
795
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
796
796
|
DEVICE_KEY: this._deviceKey,
|
|
797
797
|
DEVICE_NAME: this._deviceName
|
|
798
|
-
}, ...
|
|
799
|
-
return this._connection.publish(
|
|
798
|
+
}, ...o ?? {} };
|
|
799
|
+
return this._connection.publish(s, t, c, {
|
|
800
800
|
acknowledge: !0
|
|
801
801
|
});
|
|
802
802
|
}
|
|
803
|
-
async publishToTable(
|
|
804
|
-
const l =
|
|
803
|
+
async publishToTable(s, t, o) {
|
|
804
|
+
const l = x({ tablename: s, args: t, kwargs: o });
|
|
805
805
|
if (!l.success)
|
|
806
806
|
throw new Error(`Invalid table parameters: ${l.errors.map((c) => c.path + ": " + c.expected).join(", ")}`);
|
|
807
807
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
808
808
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
809
|
-
const i = `${this._swarmKey}.${this._appKey}.${
|
|
810
|
-
return this.publish(i,
|
|
809
|
+
const i = `${this._swarmKey}.${this._appKey}.${s}`;
|
|
810
|
+
return this.publish(i, t, o);
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Reports an application error into the databackend's `error-logs` table.
|
|
814
|
+
*
|
|
815
|
+
* This is a thin convenience wrapper over {@link publishToTable} /
|
|
816
|
+
* {@link appendToTable}: it stamps the row with `source: "app"`, a severity
|
|
817
|
+
* `level`, and a timestamp, then writes it like any normal table row. The error
|
|
818
|
+
* therefore lands in the same `error-logs` table that fleetdb system errors use
|
|
819
|
+
* (tagged `source: "system"`), and is delivered in realtime on
|
|
820
|
+
* `transformed.error-logs` — the channel board-templates consume — without
|
|
821
|
+
* touching the platform error-toast channel (`databackend.errors.*`).
|
|
822
|
+
*
|
|
823
|
+
* @param error An error message, or an Error whose stack/message is recorded.
|
|
824
|
+
* @param opts Optional level (default "error"), append flag, and tsp override.
|
|
825
|
+
*/
|
|
826
|
+
async reportError(s, t) {
|
|
827
|
+
const o = s instanceof Error ? s.stack ?? s.message : s, l = {
|
|
828
|
+
tsp: (t == null ? void 0 : t.tsp) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
829
|
+
msg: o,
|
|
830
|
+
source: "app",
|
|
831
|
+
level: (t == null ? void 0 : t.level) ?? "error"
|
|
832
|
+
};
|
|
833
|
+
return t != null && t.append ? this.appendToTable(j, [l]) : this.publishToTable(j, [l]);
|
|
811
834
|
}
|
|
812
|
-
async appendToTable(
|
|
813
|
-
const l =
|
|
835
|
+
async appendToTable(s, t, o) {
|
|
836
|
+
const l = x({ tablename: s, args: t, kwargs: o });
|
|
814
837
|
if (!l.success)
|
|
815
|
-
throw new Error(`Invalid table parameters: ${l.errors.map((
|
|
838
|
+
throw new Error(`Invalid table parameters: ${l.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
|
|
816
839
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
817
840
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
818
|
-
const i = `append.${this._swarmKey}.${this._appKey}.${
|
|
841
|
+
const i = `append.${this._swarmKey}.${this._appKey}.${s}`, e = { ...{
|
|
819
842
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
820
843
|
DEVICE_KEY: this._deviceKey,
|
|
821
844
|
DEVICE_NAME: this._deviceName
|
|
822
|
-
}, ...
|
|
823
|
-
return this._connection.call(i,
|
|
845
|
+
}, ...o ?? {} };
|
|
846
|
+
return this._connection.call(i, t, e);
|
|
824
847
|
}
|
|
825
848
|
/**
|
|
826
849
|
* Publishes many rows in a single message (bulk insert) to the dedicated topic
|
|
@@ -830,14 +853,14 @@ class P {
|
|
|
830
853
|
* confirms delivery to the router, not the DB insert. Use appendRowsToTable when
|
|
831
854
|
* you need the insert outcome.
|
|
832
855
|
*/
|
|
833
|
-
async publishRowsToTable(
|
|
834
|
-
const l = C({ tablename:
|
|
856
|
+
async publishRowsToTable(s, t, o) {
|
|
857
|
+
const l = C({ tablename: s, rows: t, kwargs: o });
|
|
835
858
|
if (!l.success)
|
|
836
859
|
throw new Error(`Invalid bulk table parameters: ${l.errors.map((c) => c.path + ": " + c.expected).join(", ")}`);
|
|
837
860
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
838
861
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
839
|
-
const i = `bulk.${this._swarmKey}.${this._appKey}.${
|
|
840
|
-
return this.publish(i, [
|
|
862
|
+
const i = `bulk.${this._swarmKey}.${this._appKey}.${s}`;
|
|
863
|
+
return this.publish(i, [t], o);
|
|
841
864
|
}
|
|
842
865
|
/**
|
|
843
866
|
* Appends many rows in a single RPC (bulk insert) by calling the dedicated
|
|
@@ -847,73 +870,73 @@ class P {
|
|
|
847
870
|
* (e.g. { success: true, count: N }). Prefer over publishRowsToTable when you
|
|
848
871
|
* need the insert outcome.
|
|
849
872
|
*/
|
|
850
|
-
async appendRowsToTable(
|
|
851
|
-
const l = C({ tablename:
|
|
873
|
+
async appendRowsToTable(s, t, o) {
|
|
874
|
+
const l = C({ tablename: s, rows: t, kwargs: o });
|
|
852
875
|
if (!l.success)
|
|
853
|
-
throw new Error(`Invalid bulk table parameters: ${l.errors.map((
|
|
876
|
+
throw new Error(`Invalid bulk table parameters: ${l.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
|
|
854
877
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
855
878
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
856
|
-
const i = `appendBulk.${this._swarmKey}.${this._appKey}.${
|
|
879
|
+
const i = `appendBulk.${this._swarmKey}.${this._appKey}.${s}`, e = { ...{
|
|
857
880
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
858
881
|
DEVICE_KEY: this._deviceKey,
|
|
859
882
|
DEVICE_NAME: this._deviceName
|
|
860
|
-
}, ...
|
|
861
|
-
return this._connection.call(i, [
|
|
883
|
+
}, ...o ?? {} };
|
|
884
|
+
return this._connection.call(i, [t], e);
|
|
862
885
|
}
|
|
863
|
-
async subscribe(
|
|
864
|
-
return this._connection.subscribe(
|
|
886
|
+
async subscribe(s, t, o) {
|
|
887
|
+
return this._connection.subscribe(s, t);
|
|
865
888
|
}
|
|
866
|
-
async subscribeToTable(
|
|
889
|
+
async subscribeToTable(s, t, o) {
|
|
867
890
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
868
891
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
869
|
-
const l = `transformed.${
|
|
892
|
+
const l = `transformed.${s}`, i = await this.subscribe(l, t, o), c = (e, a, r) => {
|
|
870
893
|
const n = Array.isArray(e) ? e[0] : e, u = Array.isArray(n) ? n : n == null ? [] : [n];
|
|
871
|
-
for (const
|
|
872
|
-
|
|
894
|
+
for (const h of u)
|
|
895
|
+
t([h], a, r);
|
|
873
896
|
};
|
|
874
|
-
return await this.subscribe(`transformed.bulk.${
|
|
897
|
+
return await this.subscribe(`transformed.bulk.${s}`, c, o), i;
|
|
875
898
|
}
|
|
876
|
-
async call(
|
|
877
|
-
return this._connection.call(
|
|
899
|
+
async call(s, t, o, l) {
|
|
900
|
+
return this._connection.call(s, t, o, l);
|
|
878
901
|
}
|
|
879
|
-
async callDeviceFunction(
|
|
880
|
-
const c = `${this._swarmKey}.${
|
|
881
|
-
return this._connection.call(c,
|
|
902
|
+
async callDeviceFunction(s, t, o, l, i) {
|
|
903
|
+
const c = `${this._swarmKey}.${s}.${this._appKey}.${this._env}.${t}`;
|
|
904
|
+
return this._connection.call(c, o, l, i);
|
|
882
905
|
}
|
|
883
906
|
/** @deprecated Use callDeviceFunction() instead. */
|
|
884
|
-
async callFunction(
|
|
885
|
-
return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(
|
|
907
|
+
async callFunction(s, t, o, l, i) {
|
|
908
|
+
return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(s, t, o, l, i);
|
|
886
909
|
}
|
|
887
|
-
async registerDeviceFunction(
|
|
888
|
-
const l = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${
|
|
889
|
-
return console.log(`Function registered for IronFlock topic '${
|
|
910
|
+
async registerDeviceFunction(s, t, o) {
|
|
911
|
+
const l = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${s}`, i = await this._connection.register(l, t, o);
|
|
912
|
+
return console.log(`Function registered for IronFlock topic '${s}'. (Full WAMP topic: '${l}')`), i;
|
|
890
913
|
}
|
|
891
914
|
/** @deprecated Use registerDeviceFunction() instead. */
|
|
892
|
-
async registerFunction(
|
|
893
|
-
return console.warn("registerFunction() is deprecated and will be removed in a future version. Use registerDeviceFunction() instead."), this.registerDeviceFunction(
|
|
894
|
-
}
|
|
895
|
-
async register(
|
|
896
|
-
return this.registerDeviceFunction(
|
|
897
|
-
}
|
|
898
|
-
async getHistory(
|
|
899
|
-
if (!
|
|
900
|
-
|
|
901
|
-
const
|
|
902
|
-
if (!
|
|
903
|
-
throw new Error(`Invalid query parameters: ${
|
|
904
|
-
const l = `history.transformed.${
|
|
915
|
+
async registerFunction(s, t, o) {
|
|
916
|
+
return console.warn("registerFunction() is deprecated and will be removed in a future version. Use registerDeviceFunction() instead."), this.registerDeviceFunction(s, t, o);
|
|
917
|
+
}
|
|
918
|
+
async register(s, t, o) {
|
|
919
|
+
return this.registerDeviceFunction(s, t, o);
|
|
920
|
+
}
|
|
921
|
+
async getHistory(s, t = { limit: 10 }) {
|
|
922
|
+
if (!s) throw new Error("Tablename must not be empty!");
|
|
923
|
+
t.offset == null && (t.offset = 0);
|
|
924
|
+
const o = Z(t);
|
|
925
|
+
if (!o.success)
|
|
926
|
+
throw new Error(`Invalid query parameters: ${o.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
927
|
+
const l = `history.transformed.${s}`;
|
|
905
928
|
try {
|
|
906
|
-
return await this._connection.call(l, [
|
|
929
|
+
return await this._connection.call(l, [t]);
|
|
907
930
|
} catch (i) {
|
|
908
931
|
const c = String(i);
|
|
909
932
|
return c.includes("no_such_procedure") || c.includes("no callee registered") ? (console.error(`Get history failed: History service procedure '${l}' not registered`), null) : (console.error(`Get history failed: ${i}`), null);
|
|
910
933
|
}
|
|
911
934
|
}
|
|
912
|
-
async setDeviceLocation(
|
|
913
|
-
const
|
|
914
|
-
if (!
|
|
915
|
-
throw new Error(`Invalid location parameters: ${
|
|
916
|
-
const l = { long:
|
|
935
|
+
async setDeviceLocation(s, t) {
|
|
936
|
+
const o = z({ longitude: s, latitude: t });
|
|
937
|
+
if (!o.success)
|
|
938
|
+
throw new Error(`Invalid location parameters: ${o.errors.map((c) => c.path + ": " + c.expected).join(", ")}`);
|
|
939
|
+
const l = { long: s, lat: t }, i = {
|
|
917
940
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
918
941
|
DEVICE_KEY: this._deviceKey,
|
|
919
942
|
DEVICE_NAME: this._deviceName
|
|
@@ -928,8 +951,8 @@ class P {
|
|
|
928
951
|
return console.error(`Set location failed: ${c}`), null;
|
|
929
952
|
}
|
|
930
953
|
}
|
|
931
|
-
getRemoteAccessUrlForPort(
|
|
932
|
-
return this._deviceKey && this._appName ? `https://${this._deviceKey}-${this._appName.toLowerCase()}-${
|
|
954
|
+
getRemoteAccessUrlForPort(s) {
|
|
955
|
+
return this._deviceKey && this._appName ? `https://${this._deviceKey}-${this._appName.toLowerCase()}-${s}.app.ironflock.com` : null;
|
|
933
956
|
}
|
|
934
957
|
/**
|
|
935
958
|
* Create an IronFlock instance by fetching configuration from a server endpoint.
|
|
@@ -941,23 +964,24 @@ class P {
|
|
|
941
964
|
* await flock.start();
|
|
942
965
|
* ```
|
|
943
966
|
*/
|
|
944
|
-
static async fromServer(
|
|
945
|
-
const
|
|
946
|
-
if (!
|
|
947
|
-
throw new Error(`Failed to fetch IronFlock config from ${
|
|
948
|
-
const
|
|
949
|
-
return new
|
|
967
|
+
static async fromServer(s) {
|
|
968
|
+
const t = await fetch(s);
|
|
969
|
+
if (!t.ok)
|
|
970
|
+
throw new Error(`Failed to fetch IronFlock config from ${s}: ${t.status} ${t.statusText}`);
|
|
971
|
+
const o = await t.json();
|
|
972
|
+
return new L(o);
|
|
950
973
|
}
|
|
951
974
|
}
|
|
952
975
|
export {
|
|
953
976
|
I as CrossbarConnection,
|
|
954
|
-
|
|
977
|
+
j as ERROR_LOGS_TABLE,
|
|
978
|
+
L as IronFlock,
|
|
955
979
|
M as Stage,
|
|
956
980
|
C as validateBulkTableParams,
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
981
|
+
se as validateCallParams,
|
|
982
|
+
z as validateLocationParams,
|
|
983
|
+
ee as validatePublishParams,
|
|
984
|
+
x as validateTableParams,
|
|
985
|
+
Z as validateTableQueryParams
|
|
962
986
|
};
|
|
963
987
|
//# sourceMappingURL=index.mjs.map
|