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