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