ironflock 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.mjs +210 -145
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import S from "autobahn";
|
|
2
|
+
function Y(h) {
|
|
3
3
|
return h && h.__esModule && Object.prototype.hasOwnProperty.call(h, "default") ? h.default : h;
|
|
4
4
|
}
|
|
5
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var N = { exports: {} }, C;
|
|
6
|
+
function H() {
|
|
7
7
|
return C || (C = 1, (function(h) {
|
|
8
8
|
var t = Object.prototype.hasOwnProperty, s = "~";
|
|
9
9
|
function a() {
|
|
@@ -15,8 +15,8 @@ function Y() {
|
|
|
15
15
|
function i(o, e, n, c, d) {
|
|
16
16
|
if (typeof n != "function")
|
|
17
17
|
throw new TypeError("The listener must be a function");
|
|
18
|
-
var
|
|
19
|
-
return o._events[f] ? o._events[f].fn ? o._events[f] = [o._events[f],
|
|
18
|
+
var y = new l(n, c || o, d), f = s ? s + e : e;
|
|
19
|
+
return o._events[f] ? o._events[f].fn ? o._events[f] = [o._events[f], y] : o._events[f].push(y) : (o._events[f] = y, o._eventsCount++), o;
|
|
20
20
|
}
|
|
21
21
|
function u(o, e) {
|
|
22
22
|
--o._eventsCount === 0 ? o._events = new a() : delete o._events[e];
|
|
@@ -34,54 +34,54 @@ function Y() {
|
|
|
34
34
|
var n = s ? s + e : e, c = this._events[n];
|
|
35
35
|
if (!c) return [];
|
|
36
36
|
if (c.fn) return [c.fn];
|
|
37
|
-
for (var d = 0,
|
|
37
|
+
for (var d = 0, y = c.length, f = new Array(y); d < y; d++)
|
|
38
38
|
f[d] = c[d].fn;
|
|
39
39
|
return f;
|
|
40
40
|
}, r.prototype.listenerCount = function(e) {
|
|
41
41
|
var n = s ? s + e : e, c = this._events[n];
|
|
42
42
|
return c ? c.fn ? 1 : c.length : 0;
|
|
43
|
-
}, r.prototype.emit = function(e, n, c, d,
|
|
43
|
+
}, r.prototype.emit = function(e, n, c, d, y, f) {
|
|
44
44
|
var g = s ? s + e : e;
|
|
45
45
|
if (!this._events[g]) return !1;
|
|
46
|
-
var
|
|
47
|
-
if (
|
|
48
|
-
switch (
|
|
46
|
+
var v = this._events[g], b = arguments.length, E, m;
|
|
47
|
+
if (v.fn) {
|
|
48
|
+
switch (v.once && this.removeListener(e, v.fn, void 0, !0), b) {
|
|
49
49
|
case 1:
|
|
50
|
-
return
|
|
50
|
+
return v.fn.call(v.context), !0;
|
|
51
51
|
case 2:
|
|
52
|
-
return
|
|
52
|
+
return v.fn.call(v.context, n), !0;
|
|
53
53
|
case 3:
|
|
54
|
-
return
|
|
54
|
+
return v.fn.call(v.context, n, c), !0;
|
|
55
55
|
case 4:
|
|
56
|
-
return
|
|
56
|
+
return v.fn.call(v.context, n, c, d), !0;
|
|
57
57
|
case 5:
|
|
58
|
-
return
|
|
58
|
+
return v.fn.call(v.context, n, c, d, y), !0;
|
|
59
59
|
case 6:
|
|
60
|
-
return
|
|
60
|
+
return v.fn.call(v.context, n, c, d, y, f), !0;
|
|
61
61
|
}
|
|
62
|
-
for (m = 1, E = new Array(
|
|
62
|
+
for (m = 1, E = new Array(b - 1); m < b; m++)
|
|
63
63
|
E[m - 1] = arguments[m];
|
|
64
|
-
|
|
64
|
+
v.fn.apply(v.context, E);
|
|
65
65
|
} else {
|
|
66
|
-
var
|
|
67
|
-
for (m = 0; m <
|
|
68
|
-
switch (
|
|
66
|
+
var B = v.length, I;
|
|
67
|
+
for (m = 0; m < B; m++)
|
|
68
|
+
switch (v[m].once && this.removeListener(e, v[m].fn, void 0, !0), b) {
|
|
69
69
|
case 1:
|
|
70
|
-
|
|
70
|
+
v[m].fn.call(v[m].context);
|
|
71
71
|
break;
|
|
72
72
|
case 2:
|
|
73
|
-
|
|
73
|
+
v[m].fn.call(v[m].context, n);
|
|
74
74
|
break;
|
|
75
75
|
case 3:
|
|
76
|
-
|
|
76
|
+
v[m].fn.call(v[m].context, n, c);
|
|
77
77
|
break;
|
|
78
78
|
case 4:
|
|
79
|
-
|
|
79
|
+
v[m].fn.call(v[m].context, n, c, d);
|
|
80
80
|
break;
|
|
81
81
|
default:
|
|
82
|
-
if (!E) for (
|
|
83
|
-
E[
|
|
84
|
-
|
|
82
|
+
if (!E) for (I = 1, E = new Array(b - 1); I < b; I++)
|
|
83
|
+
E[I - 1] = arguments[I];
|
|
84
|
+
v[m].fn.apply(v[m].context, E);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
return !0;
|
|
@@ -90,41 +90,41 @@ function Y() {
|
|
|
90
90
|
}, r.prototype.once = function(e, n, c) {
|
|
91
91
|
return i(this, e, n, c, !0);
|
|
92
92
|
}, r.prototype.removeListener = function(e, n, c, d) {
|
|
93
|
-
var
|
|
94
|
-
if (!this._events[
|
|
93
|
+
var y = s ? s + e : e;
|
|
94
|
+
if (!this._events[y]) return this;
|
|
95
95
|
if (!n)
|
|
96
|
-
return u(this,
|
|
97
|
-
var f = this._events[
|
|
96
|
+
return u(this, y), this;
|
|
97
|
+
var f = this._events[y];
|
|
98
98
|
if (f.fn)
|
|
99
|
-
f.fn === n && (!d || f.once) && (!c || f.context === c) && u(this,
|
|
99
|
+
f.fn === n && (!d || f.once) && (!c || f.context === c) && u(this, y);
|
|
100
100
|
else {
|
|
101
|
-
for (var g = 0,
|
|
102
|
-
(f[g].fn !== n || d && !f[g].once || c && f[g].context !== c) &&
|
|
103
|
-
|
|
101
|
+
for (var g = 0, v = [], b = f.length; g < b; g++)
|
|
102
|
+
(f[g].fn !== n || d && !f[g].once || c && f[g].context !== c) && v.push(f[g]);
|
|
103
|
+
v.length ? this._events[y] = v.length === 1 ? v[0] : v : u(this, y);
|
|
104
104
|
}
|
|
105
105
|
return this;
|
|
106
106
|
}, r.prototype.removeAllListeners = function(e) {
|
|
107
107
|
var n;
|
|
108
108
|
return e ? (n = s ? s + e : e, this._events[n] && u(this, n)) : (this._events = new a(), this._eventsCount = 0), this;
|
|
109
109
|
}, r.prototype.off = r.prototype.removeListener, r.prototype.addListener = r.prototype.on, r.prefixed = s, r.EventEmitter = r, h.exports = r;
|
|
110
|
-
})(
|
|
110
|
+
})(N)), N.exports;
|
|
111
111
|
}
|
|
112
|
-
var
|
|
113
|
-
const
|
|
114
|
-
"https://studio.datapods.io":
|
|
115
|
-
"https://studio.ironflock.dev":
|
|
112
|
+
var Q = H();
|
|
113
|
+
const G = /* @__PURE__ */ Y(Q), J = "wss://cbw.datapods.io/ws-ua-usr", j = "wss://cbw.ironflock.com/ws-ua-usr", Z = "wss://cbw.ironflock.dev/ws-ua-usr", z = "wss://cbw.record-evolution.com/ws-ua-usr", K = "ws://localhost:8080/ws-ua-usr", X = "ws://host.docker.internal:8080/ws-ua-usr", L = {
|
|
114
|
+
"https://studio.datapods.io": J,
|
|
115
|
+
"https://studio.ironflock.dev": Z,
|
|
116
116
|
"https://studio.ironflock.com": j,
|
|
117
|
-
"https://studio.record-evolution.com":
|
|
118
|
-
"http://localhost:8085":
|
|
119
|
-
"http://localhost:8086":
|
|
120
|
-
"http://host.docker.internal:8086":
|
|
121
|
-
},
|
|
117
|
+
"https://studio.record-evolution.com": z,
|
|
118
|
+
"http://localhost:8085": K,
|
|
119
|
+
"http://localhost:8086": K,
|
|
120
|
+
"http://host.docker.internal:8086": X
|
|
121
|
+
}, q = 6e3, ee = [
|
|
122
122
|
"wamp.error.not_authorized",
|
|
123
123
|
"wamp.error.authorization_failed",
|
|
124
124
|
"wamp.error.authentication_failed",
|
|
125
125
|
"wamp.error.no_auth_method"
|
|
126
126
|
];
|
|
127
|
-
class
|
|
127
|
+
class $ extends G {
|
|
128
128
|
constructor() {
|
|
129
129
|
super(), this.failOnAuthError = !1, this.subscriptions = [], this.registrations = [], this.firstResolver = () => {
|
|
130
130
|
}, this.firstRejecter = () => {
|
|
@@ -148,14 +148,14 @@ class T extends Q {
|
|
|
148
148
|
return a;
|
|
149
149
|
}
|
|
150
150
|
configure(t, s, a, l, i) {
|
|
151
|
-
this.realm = `realm-${t}-${s}-${a}`, this.serial_number = l, this.socketURI = i ??
|
|
151
|
+
this.realm = `realm-${t}-${s}-${a}`, this.serial_number = l, this.socketURI = i ?? $.getWebSocketURI();
|
|
152
152
|
}
|
|
153
153
|
async start() {
|
|
154
154
|
if (!this.realm || !this.serial_number || !this.socketURI)
|
|
155
155
|
throw new Error("CrossbarConnection must be configured before starting. Call configure() first.");
|
|
156
156
|
return this.shouldReconnect = !0, this.firstConnection = new Promise((t, s) => {
|
|
157
157
|
this.firstResolver = t, this.firstRejecter = s;
|
|
158
|
-
}), this.connection = new
|
|
158
|
+
}), this.connection = new S.Connection({
|
|
159
159
|
realm: this.realm,
|
|
160
160
|
url: this.socketURI,
|
|
161
161
|
authmethods: ["wampcra"],
|
|
@@ -166,7 +166,7 @@ class T extends Q {
|
|
|
166
166
|
// @ts-ignore
|
|
167
167
|
autoping_interval: 2,
|
|
168
168
|
autoping_timeout: 4,
|
|
169
|
-
onchallenge: (t, s, a) =>
|
|
169
|
+
onchallenge: (t, s, a) => S.auth_cra.sign(this.serial_number, a.challenge)
|
|
170
170
|
}), this.connection.onopen = this.onOpen.bind(this), this.connection.onclose = this.onClose.bind(this), this.connection.open(), this.firstConnection;
|
|
171
171
|
}
|
|
172
172
|
onOpen(t) {
|
|
@@ -187,7 +187,7 @@ class T extends Q {
|
|
|
187
187
|
authid: this.serial_number
|
|
188
188
|
});
|
|
189
189
|
const a = (s == null ? void 0 : s.reason) ?? t;
|
|
190
|
-
return this.failOnAuthError && typeof a == "string" &&
|
|
190
|
+
return this.failOnAuthError && typeof a == "string" && ee.includes(a) ? (this.shouldReconnect = !1, this.emit("auth_failure", a, s), !0) : (this.shouldReconnect && this.hasOpenedOnce && (s == null ? void 0 : s.will_retry) === !1 && this.handleManualReconnect((s == null ? void 0 : s.reason) ?? t), !1);
|
|
191
191
|
}
|
|
192
192
|
async handleManualReconnect(t) {
|
|
193
193
|
if (!(this.isReconnecting || !this.shouldReconnect)) {
|
|
@@ -206,7 +206,7 @@ class T extends Q {
|
|
|
206
206
|
async sessionWait() {
|
|
207
207
|
const t = Date.now();
|
|
208
208
|
for (; !this.session; ) {
|
|
209
|
-
if (Date.now() - t >
|
|
209
|
+
if (Date.now() - t > q)
|
|
210
210
|
throw new Error("Timeout waiting for session");
|
|
211
211
|
await new Promise((s) => setTimeout(s, 200));
|
|
212
212
|
}
|
|
@@ -278,7 +278,7 @@ class T extends Q {
|
|
|
278
278
|
return await this.sessionWait(), (i = this.session) == null ? void 0 : i.publish(t, s, a, l);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
const
|
|
281
|
+
const T = (h) => Math.floor(h) === h && re <= h && h <= te, re = 0, te = 2 ** 32 - 1, O = (h) => se.test(h), se = /^[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, R = (h) => {
|
|
282
282
|
const t = (s) => {
|
|
283
283
|
if (h.length === 0)
|
|
284
284
|
return !0;
|
|
@@ -291,7 +291,7 @@ const I = (h) => Math.floor(h) === h && q <= h && h <= ee, q = 0, ee = 2 ** 32 -
|
|
|
291
291
|
`Please fill the \`${a.expected}\` typed value next time.`
|
|
292
292
|
].join(`
|
|
293
293
|
`))), h.push(a)), !1);
|
|
294
|
-
},
|
|
294
|
+
}, _ = (h) => Object.assign(h, {
|
|
295
295
|
"~standard": {
|
|
296
296
|
version: 1,
|
|
297
297
|
vendor: "typia",
|
|
@@ -302,7 +302,7 @@ const I = (h) => Math.floor(h) === h && q <= h && h <= ee, q = 0, ee = 2 ** 32 -
|
|
|
302
302
|
} : {
|
|
303
303
|
issues: s.errors.map((a) => ({
|
|
304
304
|
message: `expected ${a.expected}, got ${a.value}`,
|
|
305
|
-
path:
|
|
305
|
+
path: ne(a.path)
|
|
306
306
|
}))
|
|
307
307
|
};
|
|
308
308
|
}
|
|
@@ -312,7 +312,7 @@ var w;
|
|
|
312
312
|
(function(h) {
|
|
313
313
|
h[h.Start = 0] = "Start", h[h.Property = 1] = "Property", h[h.StringKey = 2] = "StringKey", h[h.NumberKey = 3] = "NumberKey";
|
|
314
314
|
})(w || (w = {}));
|
|
315
|
-
const
|
|
315
|
+
const ne = (h) => {
|
|
316
316
|
if (!h.startsWith("$input"))
|
|
317
317
|
throw new Error(`Invalid path: ${JSON.stringify(h)}`);
|
|
318
318
|
const t = [];
|
|
@@ -342,9 +342,9 @@ const te = (h) => {
|
|
|
342
342
|
throw new Error(`Failed to parse path: ${JSON.stringify(h)}`);
|
|
343
343
|
return t;
|
|
344
344
|
};
|
|
345
|
-
var
|
|
346
|
-
const
|
|
347
|
-
const h = (e) => typeof e.limit == "number" &&
|
|
345
|
+
var k = /* @__PURE__ */ ((h) => (h.DEVELOPMENT = "dev", h.PRODUCTION = "prod", h))(k || {});
|
|
346
|
+
const F = (() => {
|
|
347
|
+
const h = (e) => typeof e.limit == "number" && T(e.limit) && 1 <= e.limit && e.limit <= 1e4 && (e.offset === void 0 || typeof e.offset == "number" && T(e.offset) && 0 <= e.offset) && (e.timeRange === void 0 || typeof e.timeRange == "object" && e.timeRange !== null && t(e.timeRange)) && (e.filterAnd === void 0 || Array.isArray(e.filterAnd) && e.filterAnd.every((n) => typeof n == "object" && n !== null && s(n))), t = (e) => typeof e.start == "string" && O(e.start) && typeof e.end == "string" && O(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")), a = (e, n, c = !0) => [typeof e.limit == "number" && (T(e.limit) || o(c, {
|
|
348
348
|
path: n + ".limit",
|
|
349
349
|
expected: 'number & Type<"uint32">',
|
|
350
350
|
value: e.limit
|
|
@@ -360,7 +360,7 @@ const U = (() => {
|
|
|
360
360
|
path: n + ".limit",
|
|
361
361
|
expected: '(number & Type<"uint32"> & Minimum<1> & Maximum<10000>)',
|
|
362
362
|
value: e.limit
|
|
363
|
-
}), e.offset === void 0 || typeof e.offset == "number" && (
|
|
363
|
+
}), e.offset === void 0 || typeof e.offset == "number" && (T(e.offset) || o(c, {
|
|
364
364
|
path: n + ".offset",
|
|
365
365
|
expected: 'number & Type<"uint32">',
|
|
366
366
|
value: e.offset
|
|
@@ -384,19 +384,19 @@ const U = (() => {
|
|
|
384
384
|
path: n + ".filterAnd",
|
|
385
385
|
expected: "(Array<SQLFilterAnd> | undefined)",
|
|
386
386
|
value: e.filterAnd
|
|
387
|
-
})) && e.filterAnd.map((d,
|
|
388
|
-
path: n + ".filterAnd[" +
|
|
387
|
+
})) && e.filterAnd.map((d, y) => (typeof d == "object" && d !== null || o(c, {
|
|
388
|
+
path: n + ".filterAnd[" + y + "]",
|
|
389
389
|
expected: "SQLFilterAnd",
|
|
390
390
|
value: d
|
|
391
|
-
})) && i(d, n + ".filterAnd[" +
|
|
392
|
-
path: n + ".filterAnd[" +
|
|
391
|
+
})) && i(d, n + ".filterAnd[" + y + "]", c) || o(c, {
|
|
392
|
+
path: n + ".filterAnd[" + y + "]",
|
|
393
393
|
expected: "SQLFilterAnd",
|
|
394
394
|
value: d
|
|
395
395
|
})).every((d) => d) || o(c, {
|
|
396
396
|
path: n + ".filterAnd",
|
|
397
397
|
expected: "(Array<SQLFilterAnd> | undefined)",
|
|
398
398
|
value: e.filterAnd
|
|
399
|
-
})].every((d) => d), l = (e, n, c = !0) => [typeof e.start == "string" && (
|
|
399
|
+
})].every((d) => d), l = (e, n, c = !0) => [typeof e.start == "string" && (O(e.start) || o(c, {
|
|
400
400
|
path: n + ".start",
|
|
401
401
|
expected: 'string & Format<"date-time">',
|
|
402
402
|
value: e.start
|
|
@@ -404,7 +404,7 @@ const U = (() => {
|
|
|
404
404
|
path: n + ".start",
|
|
405
405
|
expected: '(string & Format<"date-time">)',
|
|
406
406
|
value: e.start
|
|
407
|
-
}), typeof e.end == "string" && (
|
|
407
|
+
}), typeof e.end == "string" && (O(e.end) || o(c, {
|
|
408
408
|
path: n + ".end",
|
|
409
409
|
expected: 'string & Format<"date-time">',
|
|
410
410
|
value: e.end
|
|
@@ -440,8 +440,8 @@ const U = (() => {
|
|
|
440
440
|
path: n + ".value",
|
|
441
441
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
442
442
|
value: e.value
|
|
443
|
-
})) && e.value.map((d,
|
|
444
|
-
path: n + ".value[" +
|
|
443
|
+
})) && e.value.map((d, y) => typeof d == "string" || typeof d == "number" || o(c, {
|
|
444
|
+
path: n + ".value[" + y + "]",
|
|
445
445
|
expected: "(number | string)",
|
|
446
446
|
value: d
|
|
447
447
|
})).every((d) => d) || o(c, {
|
|
@@ -450,9 +450,9 @@ const U = (() => {
|
|
|
450
450
|
value: e.value
|
|
451
451
|
}))].every((d) => d), u = (e) => typeof e == "object" && e !== null && h(e);
|
|
452
452
|
let r, o;
|
|
453
|
-
return
|
|
453
|
+
return _((e) => {
|
|
454
454
|
if (u(e) === !1) {
|
|
455
|
-
r = [], o = R(r), ((c, d,
|
|
455
|
+
r = [], o = R(r), ((c, d, y = !0) => (typeof c == "object" && c !== null || o(!0, {
|
|
456
456
|
path: d + "",
|
|
457
457
|
expected: "TableQueryParams",
|
|
458
458
|
value: c
|
|
@@ -476,7 +476,7 @@ const U = (() => {
|
|
|
476
476
|
data: e
|
|
477
477
|
};
|
|
478
478
|
});
|
|
479
|
-
})(),
|
|
479
|
+
})(), V = (() => {
|
|
480
480
|
const h = (e) => {
|
|
481
481
|
const n = e, c = [
|
|
482
482
|
[
|
|
@@ -493,7 +493,7 @@ const U = (() => {
|
|
|
493
493
|
return d[1](n);
|
|
494
494
|
return !1;
|
|
495
495
|
}, t = (e, n, c = !0) => {
|
|
496
|
-
const d = e,
|
|
496
|
+
const d = e, y = [
|
|
497
497
|
[
|
|
498
498
|
(f) => f.length === 2 && [
|
|
499
499
|
f[0] === null || typeof f[0] == "number",
|
|
@@ -539,7 +539,7 @@ const U = (() => {
|
|
|
539
539
|
].every((g) => g)
|
|
540
540
|
]
|
|
541
541
|
];
|
|
542
|
-
for (const f of
|
|
542
|
+
for (const f of y)
|
|
543
543
|
if (f[0](d))
|
|
544
544
|
return f[1](d);
|
|
545
545
|
return o(c, {
|
|
@@ -547,12 +547,12 @@ const U = (() => {
|
|
|
547
547
|
expected: "([number | null, number | null] | [string | null, string | null])",
|
|
548
548
|
value: e
|
|
549
549
|
});
|
|
550
|
-
}, s = (e) => Array.isArray(e.metrics) && e.metrics.every((n) => typeof n == "string") && (e.method === "AVG" || e.method === "SUM" || e.method === "COUNT" || e.method === "MIN" || e.method === "MAX" || e.method === "FIRST" || e.method === "LAST") && typeof e.limit == "number" &&
|
|
550
|
+
}, s = (e) => Array.isArray(e.metrics) && e.metrics.every((n) => typeof n == "string") && (e.method === "AVG" || e.method === "SUM" || e.method === "COUNT" || e.method === "MIN" || e.method === "MAX" || e.method === "FIRST" || e.method === "LAST") && typeof e.limit == "number" && T(e.limit) && 1 <= e.limit && e.limit <= 1e4 && Array.isArray(e.timeRange) && (h(e.timeRange) || !1) && (e.groupBy === null || e.groupBy === void 0 || Array.isArray(e.groupBy) && e.groupBy.every((n) => typeof n == "string")) && (e.filterAnd === null || e.filterAnd === void 0 || Array.isArray(e.filterAnd) && e.filterAnd.every((n) => typeof n == "object" && n !== null && a(n))), a = (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")), l = (e, n, c = !0) => [(Array.isArray(e.metrics) || o(c, {
|
|
551
551
|
path: n + ".metrics",
|
|
552
552
|
expected: "Array<string>",
|
|
553
553
|
value: e.metrics
|
|
554
|
-
})) && e.metrics.map((d,
|
|
555
|
-
path: n + ".metrics[" +
|
|
554
|
+
})) && e.metrics.map((d, y) => typeof d == "string" || o(c, {
|
|
555
|
+
path: n + ".metrics[" + y + "]",
|
|
556
556
|
expected: "string",
|
|
557
557
|
value: d
|
|
558
558
|
})).every((d) => d) || o(c, {
|
|
@@ -563,7 +563,7 @@ const U = (() => {
|
|
|
563
563
|
path: n + ".method",
|
|
564
564
|
expected: '("AVG" | "COUNT" | "FIRST" | "LAST" | "MAX" | "MIN" | "SUM")',
|
|
565
565
|
value: e.method
|
|
566
|
-
}), typeof e.limit == "number" && (
|
|
566
|
+
}), typeof e.limit == "number" && (T(e.limit) || o(c, {
|
|
567
567
|
path: n + ".limit",
|
|
568
568
|
expected: 'number & Type<"uint32">',
|
|
569
569
|
value: e.limit
|
|
@@ -595,8 +595,8 @@ const U = (() => {
|
|
|
595
595
|
path: n + ".groupBy",
|
|
596
596
|
expected: "(Array<string> | null | undefined)",
|
|
597
597
|
value: e.groupBy
|
|
598
|
-
})) && e.groupBy.map((d,
|
|
599
|
-
path: n + ".groupBy[" +
|
|
598
|
+
})) && e.groupBy.map((d, y) => typeof d == "string" || o(c, {
|
|
599
|
+
path: n + ".groupBy[" + y + "]",
|
|
600
600
|
expected: "string",
|
|
601
601
|
value: d
|
|
602
602
|
})).every((d) => d) || o(c, {
|
|
@@ -607,12 +607,12 @@ const U = (() => {
|
|
|
607
607
|
path: n + ".filterAnd",
|
|
608
608
|
expected: "(Array<SQLFilterAnd> | null | undefined)",
|
|
609
609
|
value: e.filterAnd
|
|
610
|
-
})) && e.filterAnd.map((d,
|
|
611
|
-
path: n + ".filterAnd[" +
|
|
610
|
+
})) && e.filterAnd.map((d, y) => (typeof d == "object" && d !== null || o(c, {
|
|
611
|
+
path: n + ".filterAnd[" + y + "]",
|
|
612
612
|
expected: "SQLFilterAnd",
|
|
613
613
|
value: d
|
|
614
|
-
})) && i(d, n + ".filterAnd[" +
|
|
615
|
-
path: n + ".filterAnd[" +
|
|
614
|
+
})) && i(d, n + ".filterAnd[" + y + "]", c) || o(c, {
|
|
615
|
+
path: n + ".filterAnd[" + y + "]",
|
|
616
616
|
expected: "SQLFilterAnd",
|
|
617
617
|
value: d
|
|
618
618
|
})).every((d) => d) || o(c, {
|
|
@@ -647,8 +647,8 @@ const U = (() => {
|
|
|
647
647
|
path: n + ".value",
|
|
648
648
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
649
649
|
value: e.value
|
|
650
|
-
})) && e.value.map((d,
|
|
651
|
-
path: n + ".value[" +
|
|
650
|
+
})) && e.value.map((d, y) => typeof d == "string" || typeof d == "number" || o(c, {
|
|
651
|
+
path: n + ".value[" + y + "]",
|
|
652
652
|
expected: "(number | string)",
|
|
653
653
|
value: d
|
|
654
654
|
})).every((d) => d) || o(c, {
|
|
@@ -657,9 +657,9 @@ const U = (() => {
|
|
|
657
657
|
value: e.value
|
|
658
658
|
}))].every((d) => d), u = (e) => typeof e == "object" && e !== null && s(e);
|
|
659
659
|
let r, o;
|
|
660
|
-
return
|
|
660
|
+
return _((e) => {
|
|
661
661
|
if (u(e) === !1) {
|
|
662
|
-
r = [], o = R(r), ((c, d,
|
|
662
|
+
r = [], o = R(r), ((c, d, y = !0) => (typeof c == "object" && c !== null || o(!0, {
|
|
663
663
|
path: d + "",
|
|
664
664
|
expected: "SeriesQueryParams",
|
|
665
665
|
value: c
|
|
@@ -683,7 +683,7 @@ const U = (() => {
|
|
|
683
683
|
data: e
|
|
684
684
|
};
|
|
685
685
|
});
|
|
686
|
-
})(),
|
|
686
|
+
})(), oe = (() => {
|
|
687
687
|
const h = (i) => typeof i.longitude == "number" && -180 <= i.longitude && i.longitude <= 180 && typeof i.latitude == "number" && -90 <= i.latitude && i.latitude <= 90, t = (i, u, r = !0) => [typeof i.longitude == "number" && (-180 <= i.longitude || l(r, {
|
|
688
688
|
path: u + ".longitude",
|
|
689
689
|
expected: "number & Minimum<-180>",
|
|
@@ -710,7 +710,7 @@ const U = (() => {
|
|
|
710
710
|
value: i.latitude
|
|
711
711
|
})].every((o) => o), s = (i) => typeof i == "object" && i !== null && h(i);
|
|
712
712
|
let a, l;
|
|
713
|
-
return
|
|
713
|
+
return _((i) => {
|
|
714
714
|
if (s(i) === !1) {
|
|
715
715
|
a = [], l = R(a), ((r, o, e = !0) => (typeof r == "object" && r !== null || l(!0, {
|
|
716
716
|
path: o + "",
|
|
@@ -736,7 +736,7 @@ const U = (() => {
|
|
|
736
736
|
data: i
|
|
737
737
|
};
|
|
738
738
|
});
|
|
739
|
-
})(),
|
|
739
|
+
})(), ae = (() => {
|
|
740
740
|
const h = (r) => typeof r.topic == "string" && 1 <= r.topic.length && (r.args === void 0 || Array.isArray(r.args)) && (r.kwargs === void 0 || typeof r.kwargs == "object" && r.kwargs !== null && Array.isArray(r.kwargs) === !1 && t(r.kwargs)), t = (r) => Object.keys(r).every((o) => (r[o] === void 0, !0)), s = (r, o, e = !0) => [typeof r.topic == "string" && (1 <= r.topic.length || u(e, {
|
|
741
741
|
path: o + ".topic",
|
|
742
742
|
expected: "string & MinLength<1>",
|
|
@@ -759,7 +759,7 @@ const U = (() => {
|
|
|
759
759
|
value: r.kwargs
|
|
760
760
|
})].every((n) => n), a = (r, o, e = !0) => [e === !1 || Object.keys(r).map((n) => (r[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (r) => typeof r == "object" && r !== null && h(r);
|
|
761
761
|
let i, u;
|
|
762
|
-
return
|
|
762
|
+
return _((r) => {
|
|
763
763
|
if (l(r) === !1) {
|
|
764
764
|
i = [], u = R(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
|
|
765
765
|
path: n + "",
|
|
@@ -785,7 +785,7 @@ const U = (() => {
|
|
|
785
785
|
data: r
|
|
786
786
|
};
|
|
787
787
|
});
|
|
788
|
-
})(),
|
|
788
|
+
})(), de = (() => {
|
|
789
789
|
const h = (r) => typeof r.deviceKey == "string" && 1 <= r.deviceKey.length && typeof r.topic == "string" && 1 <= r.topic.length && (r.args === void 0 || Array.isArray(r.args)) && (r.kwargs === void 0 || typeof r.kwargs == "object" && r.kwargs !== null && Array.isArray(r.kwargs) === !1 && t(r.kwargs)), t = (r) => Object.keys(r).every((o) => (r[o] === void 0, !0)), s = (r, o, e = !0) => [typeof r.deviceKey == "string" && (1 <= r.deviceKey.length || u(e, {
|
|
790
790
|
path: o + ".deviceKey",
|
|
791
791
|
expected: "string & MinLength<1>",
|
|
@@ -816,7 +816,7 @@ const U = (() => {
|
|
|
816
816
|
value: r.kwargs
|
|
817
817
|
})].every((n) => n), a = (r, o, e = !0) => [e === !1 || Object.keys(r).map((n) => (r[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (r) => typeof r == "object" && r !== null && h(r);
|
|
818
818
|
let i, u;
|
|
819
|
-
return
|
|
819
|
+
return _((r) => {
|
|
820
820
|
if (l(r) === !1) {
|
|
821
821
|
i = [], u = R(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
|
|
822
822
|
path: n + "",
|
|
@@ -842,7 +842,7 @@ const U = (() => {
|
|
|
842
842
|
data: r
|
|
843
843
|
};
|
|
844
844
|
});
|
|
845
|
-
})(),
|
|
845
|
+
})(), D = (() => {
|
|
846
846
|
const h = (r) => typeof r.tablename == "string" && 1 <= r.tablename.length && (r.args === void 0 || Array.isArray(r.args)) && (r.kwargs === void 0 || typeof r.kwargs == "object" && r.kwargs !== null && Array.isArray(r.kwargs) === !1 && t(r.kwargs)), t = (r) => Object.keys(r).every((o) => (r[o] === void 0, !0)), s = (r, o, e = !0) => [typeof r.tablename == "string" && (1 <= r.tablename.length || u(e, {
|
|
847
847
|
path: o + ".tablename",
|
|
848
848
|
expected: "string & MinLength<1>",
|
|
@@ -865,7 +865,7 @@ const U = (() => {
|
|
|
865
865
|
value: r.kwargs
|
|
866
866
|
})].every((n) => n), a = (r, o, e = !0) => [e === !1 || Object.keys(r).map((n) => (r[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (r) => typeof r == "object" && r !== null && h(r);
|
|
867
867
|
let i, u;
|
|
868
|
-
return
|
|
868
|
+
return _((r) => {
|
|
869
869
|
if (l(r) === !1) {
|
|
870
870
|
i = [], u = R(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
|
|
871
871
|
path: n + "",
|
|
@@ -891,7 +891,7 @@ const U = (() => {
|
|
|
891
891
|
data: r
|
|
892
892
|
};
|
|
893
893
|
});
|
|
894
|
-
})(),
|
|
894
|
+
})(), P = (() => {
|
|
895
895
|
const h = (r) => typeof r.tablename == "string" && 1 <= r.tablename.length && Array.isArray(r.rows) && 1 <= r.rows.length && r.rows.every((o) => typeof o == "object" && o !== null && Array.isArray(o) === !1 && t(o)) && (r.kwargs === void 0 || typeof r.kwargs == "object" && r.kwargs !== null && Array.isArray(r.kwargs) === !1 && t(r.kwargs)), t = (r) => Object.keys(r).every((o) => (r[o] === void 0, !0)), s = (r, o, e = !0) => [typeof r.tablename == "string" && (1 <= r.tablename.length || u(e, {
|
|
896
896
|
path: o + ".tablename",
|
|
897
897
|
expected: "string & MinLength<1>",
|
|
@@ -930,7 +930,7 @@ const U = (() => {
|
|
|
930
930
|
value: r.kwargs
|
|
931
931
|
})].every((n) => n), a = (r, o, e = !0) => [e === !1 || Object.keys(r).map((n) => (r[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (r) => typeof r == "object" && r !== null && h(r);
|
|
932
932
|
let i, u;
|
|
933
|
-
return
|
|
933
|
+
return _((r) => {
|
|
934
934
|
if (l(r) === !1) {
|
|
935
935
|
i = [], u = R(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
|
|
936
936
|
path: n + "",
|
|
@@ -956,7 +956,7 @@ const U = (() => {
|
|
|
956
956
|
data: r
|
|
957
957
|
};
|
|
958
958
|
});
|
|
959
|
-
})(),
|
|
959
|
+
})(), ie = {
|
|
960
960
|
"sys.appaccess.error.no_grant": "NO_GRANT",
|
|
961
961
|
"sys.appaccess.error.provider_not_installed": "PROVIDER_NOT_INSTALLED",
|
|
962
962
|
"sys.appaccess.error.unknown_app": "UNKNOWN_APP",
|
|
@@ -969,15 +969,15 @@ class p extends Error {
|
|
|
969
969
|
super(s ?? t), this.name = "CrossAppAccessError", this.code = t;
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
|
-
function
|
|
972
|
+
function M(h) {
|
|
973
973
|
const t = h == null ? void 0 : h.error;
|
|
974
974
|
if (typeof t != "string") return null;
|
|
975
|
-
const s =
|
|
975
|
+
const s = ie[t];
|
|
976
976
|
if (!s) return null;
|
|
977
977
|
const a = h.args, l = Array.isArray(a) && a.length > 0 ? `: ${JSON.stringify(a[0])}` : "";
|
|
978
978
|
return new p(s, `${t}${l}`);
|
|
979
979
|
}
|
|
980
|
-
class
|
|
980
|
+
class ce {
|
|
981
981
|
constructor(t, s, a, l, i) {
|
|
982
982
|
this.app = t, this.stage = s, this.tables = a.tables ?? [], this.transforms = a.transforms ?? [], this._connection = l, this._onClosed = i;
|
|
983
983
|
}
|
|
@@ -1016,13 +1016,13 @@ class ae {
|
|
|
1016
1016
|
/** Queries history rows of a shared table or transform. */
|
|
1017
1017
|
async getHistory(t, s = { limit: 10 }) {
|
|
1018
1018
|
this.assertInCatalog(t), s.offset == null && (s.offset = 0);
|
|
1019
|
-
const a =
|
|
1019
|
+
const a = F(s);
|
|
1020
1020
|
if (!a.success)
|
|
1021
1021
|
throw new Error(`Invalid query parameters: ${a.errors.map((l) => l.path + ": " + l.expected).join(", ")}`);
|
|
1022
1022
|
try {
|
|
1023
1023
|
return await this._connection.call(`history.transformed.${t}`, [s]);
|
|
1024
1024
|
} catch (l) {
|
|
1025
|
-
throw
|
|
1025
|
+
throw M(l) ?? l;
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
1028
|
/** Queries down-sampled series history of a shared table (tables only — no series RPC exists for transforms). */
|
|
@@ -1037,13 +1037,13 @@ class ae {
|
|
|
1037
1037
|
"PRIVATE_TABLE",
|
|
1038
1038
|
`'${t}' is not a shared table of app '${this.app}' (${this.stage}). Available tables: ${a.length > 0 ? a.join(", ") : "none"}`
|
|
1039
1039
|
);
|
|
1040
|
-
const l =
|
|
1040
|
+
const l = V(s);
|
|
1041
1041
|
if (!l.success)
|
|
1042
1042
|
throw new Error(`Invalid series query parameters: ${l.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
1043
1043
|
try {
|
|
1044
1044
|
return await this._connection.call(`history.transformed.series.${t}`, [s]);
|
|
1045
1045
|
} catch (i) {
|
|
1046
|
-
throw
|
|
1046
|
+
throw M(i) ?? i;
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
1049
|
/** Closes the underlying connection to the provider's realm. */
|
|
@@ -1052,20 +1052,33 @@ class ae {
|
|
|
1052
1052
|
this._connection.stop(), (t = this._onClosed) == null || t.call(this), this._onClosed = void 0;
|
|
1053
1053
|
}
|
|
1054
1054
|
}
|
|
1055
|
-
const
|
|
1056
|
-
function
|
|
1055
|
+
const U = "error-logs";
|
|
1056
|
+
function A(h) {
|
|
1057
1057
|
var t;
|
|
1058
1058
|
return typeof process < "u" ? (t = process.env) == null ? void 0 : t[h] : void 0;
|
|
1059
1059
|
}
|
|
1060
|
-
function
|
|
1061
|
-
|
|
1060
|
+
function x(h) {
|
|
1061
|
+
var t;
|
|
1062
|
+
if (typeof process < "u")
|
|
1063
|
+
try {
|
|
1064
|
+
const s = (t = process.getBuiltinModule) == null ? void 0 : t.call(process, "node:fs");
|
|
1065
|
+
if (s) {
|
|
1066
|
+
const a = A("IRONFLOCK_ENV_DIR") ?? "/data/env", l = s.readFileSync(`${a}/${h}.txt`, "utf8").trim();
|
|
1067
|
+
if (l) return l;
|
|
1068
|
+
}
|
|
1069
|
+
} catch {
|
|
1070
|
+
}
|
|
1071
|
+
return A(h);
|
|
1072
|
+
}
|
|
1073
|
+
function le(h) {
|
|
1074
|
+
const t = h ?? A("DEVICE_SERIAL_NUMBER");
|
|
1062
1075
|
if (!t)
|
|
1063
1076
|
throw new Error("serialNumber option is required (or set DEVICE_SERIAL_NUMBER env var in Node.js)");
|
|
1064
1077
|
return t;
|
|
1065
1078
|
}
|
|
1066
|
-
class
|
|
1079
|
+
class W {
|
|
1067
1080
|
constructor(t) {
|
|
1068
|
-
this._isConfigured = !1, this._consumedApps = /* @__PURE__ */ new Map(), this._serialNumber =
|
|
1081
|
+
this._isConfigured = !1, this._consumedApps = /* @__PURE__ */ new Map(), this._serialNumber = le(t == null ? void 0 : t.serialNumber), this._deviceName = (t == null ? void 0 : t.deviceName) ?? A("DEVICE_NAME"), this._deviceKey = (t == null ? void 0 : t.deviceKey) ?? A("DEVICE_KEY"), this._appName = (t == null ? void 0 : t.appName) ?? A("APP_NAME"), this._swarmKey = (t == null ? void 0 : t.swarmKey) ?? parseInt(A("SWARM_KEY") ?? "0", 10), this._appKey = (t == null ? void 0 : t.appKey) ?? parseInt(A("APP_KEY") ?? "0", 10), this._env = (t == null ? void 0 : t.env) ?? A("ENV"), this._reswarmUrl = (t == null ? void 0 : t.reswarmUrl) ?? A("RESWARM_URL"), this._cburl = (t == null ? void 0 : t.ironFlockUrl) ?? (t == null ? void 0 : t.cburl), this._connection = new $();
|
|
1069
1082
|
const s = [];
|
|
1070
1083
|
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(
|
|
1071
1084
|
`Warning: The following environment variables must be present: ${s.join(", ")}`
|
|
@@ -1080,9 +1093,9 @@ class V {
|
|
|
1080
1093
|
configureConnection(t) {
|
|
1081
1094
|
if (this._isConfigured) return;
|
|
1082
1095
|
const s = (this._env ?? "DEV").toUpperCase(), l = {
|
|
1083
|
-
DEV:
|
|
1084
|
-
PROD:
|
|
1085
|
-
}[s] ??
|
|
1096
|
+
DEV: k.DEVELOPMENT,
|
|
1097
|
+
PROD: k.PRODUCTION
|
|
1098
|
+
}[s] ?? k.DEVELOPMENT, i = t ?? this._cburl ?? $.getWebSocketURI(this._reswarmUrl);
|
|
1086
1099
|
this._connection.configure(
|
|
1087
1100
|
this._swarmKey,
|
|
1088
1101
|
this._appKey,
|
|
@@ -1141,7 +1154,7 @@ class V {
|
|
|
1141
1154
|
[]
|
|
1142
1155
|
) ?? [];
|
|
1143
1156
|
} catch (t) {
|
|
1144
|
-
throw
|
|
1157
|
+
throw M(t) ?? t;
|
|
1145
1158
|
}
|
|
1146
1159
|
}
|
|
1147
1160
|
/**
|
|
@@ -1176,7 +1189,7 @@ class V {
|
|
|
1176
1189
|
{ app: t }
|
|
1177
1190
|
]);
|
|
1178
1191
|
} catch (u) {
|
|
1179
|
-
throw
|
|
1192
|
+
throw M(u) ?? u;
|
|
1180
1193
|
}
|
|
1181
1194
|
if (!i)
|
|
1182
1195
|
throw new p(
|
|
@@ -1210,14 +1223,14 @@ class V {
|
|
|
1210
1223
|
"PROVIDER_NOT_INSTALLED",
|
|
1211
1224
|
`App '${i}' has no ${s} data backend in this project`
|
|
1212
1225
|
);
|
|
1213
|
-
const r = new
|
|
1226
|
+
const r = new $();
|
|
1214
1227
|
r.failOnAuthError = !0, r.configure(
|
|
1215
1228
|
this._swarmKey,
|
|
1216
1229
|
t.provider_app_key,
|
|
1217
|
-
s === "prod" ?
|
|
1230
|
+
s === "prod" ? k.PRODUCTION : k.DEVELOPMENT,
|
|
1218
1231
|
this._serialNumber,
|
|
1219
1232
|
// Reuse the own connection's resolved socket URI (set once start() ran).
|
|
1220
|
-
this._connection.socketURI ?? this._cburl ??
|
|
1233
|
+
this._connection.socketURI ?? this._cburl ?? $.getWebSocketURI(this._reswarmUrl)
|
|
1221
1234
|
);
|
|
1222
1235
|
let o = !1, e;
|
|
1223
1236
|
r.on("auth_failure", (c) => {
|
|
@@ -1231,10 +1244,10 @@ class V {
|
|
|
1231
1244
|
} catch (c) {
|
|
1232
1245
|
throw e ?? c;
|
|
1233
1246
|
}
|
|
1234
|
-
return o = !0, new
|
|
1247
|
+
return o = !0, new ce(i, s, u, r, a);
|
|
1235
1248
|
}
|
|
1236
1249
|
async publish(t, s, a) {
|
|
1237
|
-
const l =
|
|
1250
|
+
const l = ae({ topic: t, args: s, kwargs: a });
|
|
1238
1251
|
if (!l.success)
|
|
1239
1252
|
throw new Error(`Invalid publish parameters: ${l.errors.map((r) => r.path + ": " + r.expected).join(", ")}`);
|
|
1240
1253
|
const u = { ...{
|
|
@@ -1247,7 +1260,7 @@ class V {
|
|
|
1247
1260
|
});
|
|
1248
1261
|
}
|
|
1249
1262
|
async publishToTable(t, s, a) {
|
|
1250
|
-
const l =
|
|
1263
|
+
const l = D({ tablename: t, args: s, kwargs: a });
|
|
1251
1264
|
if (!l.success)
|
|
1252
1265
|
throw new Error(`Invalid table parameters: ${l.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
|
|
1253
1266
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
@@ -1276,10 +1289,10 @@ class V {
|
|
|
1276
1289
|
source: "app",
|
|
1277
1290
|
level: (s == null ? void 0 : s.level) ?? "error"
|
|
1278
1291
|
};
|
|
1279
|
-
return s != null && s.append ? this.appendToTable(
|
|
1292
|
+
return s != null && s.append ? this.appendToTable(U, [l]) : this.publishToTable(U, [l]);
|
|
1280
1293
|
}
|
|
1281
1294
|
async appendToTable(t, s, a) {
|
|
1282
|
-
const l =
|
|
1295
|
+
const l = D({ tablename: t, args: s, kwargs: a });
|
|
1283
1296
|
if (!l.success)
|
|
1284
1297
|
throw new Error(`Invalid table parameters: ${l.errors.map((o) => o.path + ": " + o.expected).join(", ")}`);
|
|
1285
1298
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
@@ -1300,7 +1313,7 @@ class V {
|
|
|
1300
1313
|
* you need the insert outcome.
|
|
1301
1314
|
*/
|
|
1302
1315
|
async publishRowsToTable(t, s, a) {
|
|
1303
|
-
const l =
|
|
1316
|
+
const l = P({ tablename: t, rows: s, kwargs: a });
|
|
1304
1317
|
if (!l.success)
|
|
1305
1318
|
throw new Error(`Invalid bulk table parameters: ${l.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
|
|
1306
1319
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
@@ -1317,7 +1330,7 @@ class V {
|
|
|
1317
1330
|
* need the insert outcome.
|
|
1318
1331
|
*/
|
|
1319
1332
|
async appendRowsToTable(t, s, a) {
|
|
1320
|
-
const l =
|
|
1333
|
+
const l = P({ tablename: t, rows: s, kwargs: a });
|
|
1321
1334
|
if (!l.success)
|
|
1322
1335
|
throw new Error(`Invalid bulk table parameters: ${l.errors.map((o) => o.path + ": " + o.expected).join(", ")}`);
|
|
1323
1336
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
@@ -1367,7 +1380,7 @@ class V {
|
|
|
1367
1380
|
async getHistory(t, s = { limit: 10 }) {
|
|
1368
1381
|
if (!t) throw new Error("Tablename must not be empty!");
|
|
1369
1382
|
s.offset == null && (s.offset = 0);
|
|
1370
|
-
const a =
|
|
1383
|
+
const a = F(s);
|
|
1371
1384
|
if (!a.success)
|
|
1372
1385
|
throw new Error(`Invalid query parameters: ${a.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
1373
1386
|
const l = `history.transformed.${t}`;
|
|
@@ -1385,7 +1398,7 @@ class V {
|
|
|
1385
1398
|
*/
|
|
1386
1399
|
async getSeriesHistory(t, s) {
|
|
1387
1400
|
if (!t) throw new Error("Tablename must not be empty!");
|
|
1388
|
-
const a =
|
|
1401
|
+
const a = V(s);
|
|
1389
1402
|
if (!a.success)
|
|
1390
1403
|
throw new Error(`Invalid series query parameters: ${a.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
1391
1404
|
const l = `history.transformed.series.${t}`;
|
|
@@ -1397,7 +1410,7 @@ class V {
|
|
|
1397
1410
|
}
|
|
1398
1411
|
}
|
|
1399
1412
|
async setDeviceLocation(t, s) {
|
|
1400
|
-
const a =
|
|
1413
|
+
const a = oe({ longitude: t, latitude: s });
|
|
1401
1414
|
if (!a.success)
|
|
1402
1415
|
throw new Error(`Invalid location parameters: ${a.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
|
|
1403
1416
|
const l = { long: t, lat: s }, i = {
|
|
@@ -1415,8 +1428,60 @@ class V {
|
|
|
1415
1428
|
return console.error(`Set location failed: ${u}`), null;
|
|
1416
1429
|
}
|
|
1417
1430
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1431
|
+
/**
|
|
1432
|
+
* Public URL under which a declared port (port-template.yml) is reachable
|
|
1433
|
+
* from the internet once its tunnel is active.
|
|
1434
|
+
*
|
|
1435
|
+
* For `http`/`https` ports, composes the platform's tunnel label
|
|
1436
|
+
* `{device_key}-{app_name}-{port}` (`https` ports carry the platform's
|
|
1437
|
+
* `secure-` prefix) on the tunnel domain the device agent injects
|
|
1438
|
+
* (`TUNNEL_DOMAIN`; the cloud edge, or the operator's appliance domain).
|
|
1439
|
+
* On devices that belong to an instance (appliance), the agent injects
|
|
1440
|
+
* `INSTANCE_KEY` and the cloud-forwarded route
|
|
1441
|
+
* `https://i{instance_key}-{label}.{cloud edge}` is returned instead —
|
|
1442
|
+
* reachable while the instance forwards its tunnels to the cloud.
|
|
1443
|
+
*
|
|
1444
|
+
* For `tcp`/`udp` ports, the URL uses the tunnel-assigned public port,
|
|
1445
|
+
* which the platform injects under the port-template's
|
|
1446
|
+
* `remote_port_environment` name — pass that name here. On instance
|
|
1447
|
+
* devices the internet-facing port arrives as `{name}_CLOUD`; when it is
|
|
1448
|
+
* not (yet) present, the instance-local URL built from `{name}` is
|
|
1449
|
+
* returned as a fallback.
|
|
1450
|
+
*
|
|
1451
|
+
* Port values are read live from the agent-maintained files under
|
|
1452
|
+
* `/data/env` (falling back to the process environment), so this method
|
|
1453
|
+
* returns the CURRENT url: the instance cloud port is allocated shortly
|
|
1454
|
+
* after the tunnel first connects and appears here within seconds — call
|
|
1455
|
+
* the method again rather than caching its result.
|
|
1456
|
+
*
|
|
1457
|
+
* Returns null when the identity or required env vars are unavailable,
|
|
1458
|
+
* the protocol is unknown, or the label is not a valid DNS label (longer
|
|
1459
|
+
* than 63 characters, or a dot in the app name).
|
|
1460
|
+
*/
|
|
1461
|
+
getRemoteAccessUrlForPort(t, s = "http", a) {
|
|
1462
|
+
const l = A("INSTANCE_KEY");
|
|
1463
|
+
if (s === "tcp" || s === "udp") {
|
|
1464
|
+
if (!a)
|
|
1465
|
+
return null;
|
|
1466
|
+
if (l) {
|
|
1467
|
+
const e = x(`${a}_CLOUD`);
|
|
1468
|
+
if (e) {
|
|
1469
|
+
const n = A("CLOUD_TUNNEL_DOMAIN") ?? "app.ironflock.com";
|
|
1470
|
+
return `${s}://${n}:${e}`;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
const r = x(a);
|
|
1474
|
+
if (!r)
|
|
1475
|
+
return null;
|
|
1476
|
+
const o = A("TUNNEL_DOMAIN") ?? "app.ironflock.com";
|
|
1477
|
+
return `${s}://${o}:${r}`;
|
|
1478
|
+
}
|
|
1479
|
+
if (s !== "http" && s !== "https" || !this._deviceKey || !this._appName)
|
|
1480
|
+
return null;
|
|
1481
|
+
let i = `${this._deviceKey}-${this._appName.toLowerCase()}-${t}`;
|
|
1482
|
+
s === "https" && (i = `secure-${i}`);
|
|
1483
|
+
let u;
|
|
1484
|
+
return l ? (i = `i${l}-${i}`, u = A("CLOUD_TUNNEL_DOMAIN") ?? "app.ironflock.com") : u = A("TUNNEL_DOMAIN") ?? "app.ironflock.com", i.length > 63 || i.includes(".") ? null : `https://${i}.${u}`;
|
|
1420
1485
|
}
|
|
1421
1486
|
/**
|
|
1422
1487
|
* Create an IronFlock instance by fetching configuration from a server endpoint.
|
|
@@ -1433,22 +1498,22 @@ class V {
|
|
|
1433
1498
|
if (!s.ok)
|
|
1434
1499
|
throw new Error(`Failed to fetch IronFlock config from ${t}: ${s.status} ${s.statusText}`);
|
|
1435
1500
|
const a = await s.json();
|
|
1436
|
-
return new
|
|
1501
|
+
return new W(a);
|
|
1437
1502
|
}
|
|
1438
1503
|
}
|
|
1439
1504
|
export {
|
|
1440
|
-
|
|
1505
|
+
ce as ConsumedApp,
|
|
1441
1506
|
p as CrossAppAccessError,
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1507
|
+
$ as CrossbarConnection,
|
|
1508
|
+
U as ERROR_LOGS_TABLE,
|
|
1509
|
+
W as IronFlock,
|
|
1510
|
+
k as Stage,
|
|
1511
|
+
P as validateBulkTableParams,
|
|
1512
|
+
de as validateCallParams,
|
|
1513
|
+
oe as validateLocationParams,
|
|
1514
|
+
ae as validatePublishParams,
|
|
1515
|
+
V as validateSeriesQueryParams,
|
|
1516
|
+
D as validateTableParams,
|
|
1517
|
+
F as validateTableQueryParams
|
|
1453
1518
|
};
|
|
1454
1519
|
//# sourceMappingURL=index.mjs.map
|