ironflock 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -7
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +92 -6
- package/dist/index.mjs +977 -857
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,161 +1,188 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import C from "autobahn";
|
|
2
|
+
function Z(y) {
|
|
3
|
+
return y && y.__esModule && Object.prototype.hasOwnProperty.call(y, "default") ? y.default : y;
|
|
4
4
|
}
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
var
|
|
9
|
-
function
|
|
5
|
+
var S = { exports: {} }, L;
|
|
6
|
+
function z() {
|
|
7
|
+
return L || (L = 1, (function(y) {
|
|
8
|
+
var r = Object.prototype.hasOwnProperty, e = "~";
|
|
9
|
+
function n() {
|
|
10
10
|
}
|
|
11
|
-
Object.create && (
|
|
12
|
-
function l(
|
|
13
|
-
this.fn =
|
|
11
|
+
Object.create && (n.prototype = /* @__PURE__ */ Object.create(null), new n().__proto__ || (e = !1));
|
|
12
|
+
function l(a, s, o) {
|
|
13
|
+
this.fn = a, this.context = s, this.once = o || !1;
|
|
14
14
|
}
|
|
15
|
-
function i(
|
|
16
|
-
if (typeof
|
|
15
|
+
function i(a, s, o, f, d) {
|
|
16
|
+
if (typeof o != "function")
|
|
17
17
|
throw new TypeError("The listener must be a function");
|
|
18
|
-
var
|
|
19
|
-
return
|
|
18
|
+
var c = new l(o, f || a, d), h = e ? e + s : s;
|
|
19
|
+
return a._events[h] ? a._events[h].fn ? a._events[h] = [a._events[h], c] : a._events[h].push(c) : (a._events[h] = c, a._eventsCount++), a;
|
|
20
20
|
}
|
|
21
|
-
function u(
|
|
22
|
-
--
|
|
21
|
+
function u(a, s) {
|
|
22
|
+
--a._eventsCount === 0 ? a._events = new n() : delete a._events[s];
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
this._events = new
|
|
24
|
+
function t() {
|
|
25
|
+
this._events = new n(), this._eventsCount = 0;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
if (this._eventsCount === 0) return
|
|
30
|
-
for (
|
|
31
|
-
|
|
32
|
-
return Object.getOwnPropertySymbols ?
|
|
33
|
-
},
|
|
34
|
-
var
|
|
35
|
-
if (!
|
|
36
|
-
if (
|
|
37
|
-
for (var d = 0,
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
},
|
|
41
|
-
var
|
|
42
|
-
return
|
|
43
|
-
},
|
|
44
|
-
var
|
|
45
|
-
if (!this._events[
|
|
46
|
-
var v = this._events[
|
|
27
|
+
t.prototype.eventNames = function() {
|
|
28
|
+
var s = [], o, f;
|
|
29
|
+
if (this._eventsCount === 0) return s;
|
|
30
|
+
for (f in o = this._events)
|
|
31
|
+
r.call(o, f) && s.push(e ? f.slice(1) : f);
|
|
32
|
+
return Object.getOwnPropertySymbols ? s.concat(Object.getOwnPropertySymbols(o)) : s;
|
|
33
|
+
}, t.prototype.listeners = function(s) {
|
|
34
|
+
var o = e ? e + s : s, f = this._events[o];
|
|
35
|
+
if (!f) return [];
|
|
36
|
+
if (f.fn) return [f.fn];
|
|
37
|
+
for (var d = 0, c = f.length, h = new Array(c); d < c; d++)
|
|
38
|
+
h[d] = f[d].fn;
|
|
39
|
+
return h;
|
|
40
|
+
}, t.prototype.listenerCount = function(s) {
|
|
41
|
+
var o = e ? e + s : s, f = this._events[o];
|
|
42
|
+
return f ? f.fn ? 1 : f.length : 0;
|
|
43
|
+
}, t.prototype.emit = function(s, o, f, d, c, h) {
|
|
44
|
+
var m = e ? e + s : s;
|
|
45
|
+
if (!this._events[m]) return !1;
|
|
46
|
+
var v = this._events[m], w = arguments.length, E, g;
|
|
47
47
|
if (v.fn) {
|
|
48
|
-
switch (v.once && this.removeListener(
|
|
48
|
+
switch (v.once && this.removeListener(s, v.fn, void 0, !0), w) {
|
|
49
49
|
case 1:
|
|
50
50
|
return v.fn.call(v.context), !0;
|
|
51
51
|
case 2:
|
|
52
|
-
return v.fn.call(v.context,
|
|
52
|
+
return v.fn.call(v.context, o), !0;
|
|
53
53
|
case 3:
|
|
54
|
-
return v.fn.call(v.context,
|
|
54
|
+
return v.fn.call(v.context, o, f), !0;
|
|
55
55
|
case 4:
|
|
56
|
-
return v.fn.call(v.context,
|
|
56
|
+
return v.fn.call(v.context, o, f, d), !0;
|
|
57
57
|
case 5:
|
|
58
|
-
return v.fn.call(v.context,
|
|
58
|
+
return v.fn.call(v.context, o, f, d, c), !0;
|
|
59
59
|
case 6:
|
|
60
|
-
return v.fn.call(v.context,
|
|
60
|
+
return v.fn.call(v.context, o, f, d, c, h), !0;
|
|
61
61
|
}
|
|
62
|
-
for (
|
|
63
|
-
E[
|
|
62
|
+
for (g = 1, E = new Array(w - 1); g < w; g++)
|
|
63
|
+
E[g - 1] = arguments[g];
|
|
64
64
|
v.fn.apply(v.context, E);
|
|
65
65
|
} else {
|
|
66
|
-
var
|
|
67
|
-
for (
|
|
68
|
-
switch (v[
|
|
66
|
+
var G = v.length, I;
|
|
67
|
+
for (g = 0; g < G; g++)
|
|
68
|
+
switch (v[g].once && this.removeListener(s, v[g].fn, void 0, !0), w) {
|
|
69
69
|
case 1:
|
|
70
|
-
v[
|
|
70
|
+
v[g].fn.call(v[g].context);
|
|
71
71
|
break;
|
|
72
72
|
case 2:
|
|
73
|
-
v[
|
|
73
|
+
v[g].fn.call(v[g].context, o);
|
|
74
74
|
break;
|
|
75
75
|
case 3:
|
|
76
|
-
v[
|
|
76
|
+
v[g].fn.call(v[g].context, o, f);
|
|
77
77
|
break;
|
|
78
78
|
case 4:
|
|
79
|
-
v[
|
|
79
|
+
v[g].fn.call(v[g].context, o, f, d);
|
|
80
80
|
break;
|
|
81
81
|
default:
|
|
82
|
-
if (!E) for (I = 1, E = new Array(
|
|
82
|
+
if (!E) for (I = 1, E = new Array(w - 1); I < w; I++)
|
|
83
83
|
E[I - 1] = arguments[I];
|
|
84
|
-
v[
|
|
84
|
+
v[g].fn.apply(v[g].context, E);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
return !0;
|
|
88
|
-
},
|
|
89
|
-
return i(this,
|
|
90
|
-
},
|
|
91
|
-
return i(this,
|
|
92
|
-
},
|
|
93
|
-
var
|
|
94
|
-
if (!this._events[
|
|
95
|
-
if (!
|
|
96
|
-
return u(this,
|
|
97
|
-
var
|
|
98
|
-
if (
|
|
99
|
-
|
|
88
|
+
}, t.prototype.on = function(s, o, f) {
|
|
89
|
+
return i(this, s, o, f, !1);
|
|
90
|
+
}, t.prototype.once = function(s, o, f) {
|
|
91
|
+
return i(this, s, o, f, !0);
|
|
92
|
+
}, t.prototype.removeListener = function(s, o, f, d) {
|
|
93
|
+
var c = e ? e + s : s;
|
|
94
|
+
if (!this._events[c]) return this;
|
|
95
|
+
if (!o)
|
|
96
|
+
return u(this, c), this;
|
|
97
|
+
var h = this._events[c];
|
|
98
|
+
if (h.fn)
|
|
99
|
+
h.fn === o && (!d || h.once) && (!f || h.context === f) && u(this, c);
|
|
100
100
|
else {
|
|
101
|
-
for (var
|
|
102
|
-
(
|
|
103
|
-
v.length ? this._events[
|
|
101
|
+
for (var m = 0, v = [], w = h.length; m < w; m++)
|
|
102
|
+
(h[m].fn !== o || d && !h[m].once || f && h[m].context !== f) && v.push(h[m]);
|
|
103
|
+
v.length ? this._events[c] = v.length === 1 ? v[0] : v : u(this, c);
|
|
104
104
|
}
|
|
105
105
|
return this;
|
|
106
|
-
},
|
|
107
|
-
var
|
|
108
|
-
return
|
|
109
|
-
},
|
|
110
|
-
})(
|
|
106
|
+
}, t.prototype.removeAllListeners = function(s) {
|
|
107
|
+
var o;
|
|
108
|
+
return s ? (o = e ? e + s : s, this._events[o] && u(this, o)) : (this._events = new n(), this._eventsCount = 0), this;
|
|
109
|
+
}, t.prototype.off = t.prototype.removeListener, t.prototype.addListener = t.prototype.on, t.prefixed = e, t.EventEmitter = t, y.exports = t;
|
|
110
|
+
})(S)), S.exports;
|
|
111
111
|
}
|
|
112
|
-
var
|
|
113
|
-
const
|
|
114
|
-
"https://studio.datapods.io":
|
|
115
|
-
"https://studio.ironflock.dev":
|
|
116
|
-
"https://studio.ironflock.com":
|
|
117
|
-
"https://studio.record-evolution.com":
|
|
112
|
+
var X = z();
|
|
113
|
+
const q = /* @__PURE__ */ Z(X), ee = "wss://cbw.datapods.io/ws-ua-usr", B = "wss://cbw.ironflock.com/ws-ua-usr", re = "wss://cbw.ironflock.dev/ws-ua-usr", te = "wss://cbw.record-evolution.com/ws-ua-usr", K = "ws://localhost:8080/ws-ua-usr", se = "ws://host.docker.internal:8080/ws-ua-usr", D = {
|
|
114
|
+
"https://studio.datapods.io": ee,
|
|
115
|
+
"https://studio.ironflock.dev": re,
|
|
116
|
+
"https://studio.ironflock.com": B,
|
|
117
|
+
"https://studio.record-evolution.com": te,
|
|
118
118
|
"http://localhost:8085": K,
|
|
119
119
|
"http://localhost:8086": K,
|
|
120
|
-
"http://host.docker.internal:8086":
|
|
121
|
-
},
|
|
120
|
+
"http://host.docker.internal:8086": se
|
|
121
|
+
}, P = 6e3;
|
|
122
|
+
class ne extends Error {
|
|
123
|
+
constructor(r, e, n = [], l = {}) {
|
|
124
|
+
super(r), this.name = "WampError", this.error = e, this.args = n, this.kwargs = l;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function U(y) {
|
|
128
|
+
try {
|
|
129
|
+
return JSON.stringify(y) ?? String(y);
|
|
130
|
+
} catch {
|
|
131
|
+
return String(y);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function M(y, r, e) {
|
|
135
|
+
if (e instanceof Error) return e;
|
|
136
|
+
const n = e == null ? void 0 : e.error;
|
|
137
|
+
if (typeof n == "string") {
|
|
138
|
+
const l = Array.isArray(e.args) ? e.args : [], i = e.kwargs ?? {}, u = l.length > 0 ? ` — ${U(l)}` : "";
|
|
139
|
+
return new ne(
|
|
140
|
+
`${y} '${r}' failed with WAMP error '${n}'${u}`,
|
|
141
|
+
n,
|
|
142
|
+
l,
|
|
143
|
+
i
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return new Error(`${y} '${r}' failed: ${U(e)}`);
|
|
147
|
+
}
|
|
148
|
+
const oe = [
|
|
122
149
|
"wamp.error.not_authorized",
|
|
123
150
|
"wamp.error.authorization_failed",
|
|
124
151
|
"wamp.error.authentication_failed",
|
|
125
152
|
"wamp.error.no_auth_method"
|
|
126
153
|
];
|
|
127
|
-
class $ extends
|
|
154
|
+
class $ extends q {
|
|
128
155
|
constructor() {
|
|
129
156
|
super(), this.failOnAuthError = !1, this.subscriptions = [], this.registrations = [], this.firstResolver = () => {
|
|
130
157
|
}, this.firstRejecter = () => {
|
|
131
158
|
}, this.shouldReconnect = !1, this.isReconnecting = !1, this.hasOpenedOnce = !1;
|
|
132
159
|
}
|
|
133
|
-
static getWebSocketURI(
|
|
160
|
+
static getWebSocketURI(r) {
|
|
134
161
|
var l;
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
162
|
+
const e = typeof process < "u" ? (l = process.env) == null ? void 0 : l.DEVICE_ENDPOINT_URL : void 0;
|
|
163
|
+
if (e)
|
|
137
164
|
try {
|
|
138
|
-
const i = new URL(
|
|
165
|
+
const i = new URL(e);
|
|
139
166
|
return i.pathname = "/ws-ua-usr", i.toString().replace(/\/$/, "");
|
|
140
167
|
} catch {
|
|
141
168
|
}
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
169
|
+
if (!r) return B;
|
|
170
|
+
const n = D[r];
|
|
171
|
+
if (n === void 0)
|
|
145
172
|
throw new Error(
|
|
146
|
-
`Cannot resolve WebSocket URI for reswarmUrl=${JSON.stringify(
|
|
173
|
+
`Cannot resolve WebSocket URI for reswarmUrl=${JSON.stringify(r)}. 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(D))}`
|
|
147
174
|
);
|
|
148
|
-
return
|
|
175
|
+
return n;
|
|
149
176
|
}
|
|
150
|
-
configure(
|
|
151
|
-
this.realm = `realm-${
|
|
177
|
+
configure(r, e, n, l, i) {
|
|
178
|
+
this.realm = `realm-${r}-${e}-${n}`, this.serial_number = l, this.socketURI = i ?? $.getWebSocketURI();
|
|
152
179
|
}
|
|
153
180
|
async start() {
|
|
154
181
|
if (!this.realm || !this.serial_number || !this.socketURI)
|
|
155
182
|
throw new Error("CrossbarConnection must be configured before starting. Call configure() first.");
|
|
156
|
-
return this.shouldReconnect = !0, this.firstConnection = new Promise((
|
|
157
|
-
this.firstResolver =
|
|
158
|
-
}), this.connection = new
|
|
183
|
+
return this.shouldReconnect = !0, this.firstConnection = new Promise((r, e) => {
|
|
184
|
+
this.firstResolver = r, this.firstRejecter = e;
|
|
185
|
+
}), this.connection = new C.Connection({
|
|
159
186
|
realm: this.realm,
|
|
160
187
|
url: this.socketURI,
|
|
161
188
|
authmethods: ["wampcra"],
|
|
@@ -166,50 +193,60 @@ class $ extends G {
|
|
|
166
193
|
// @ts-ignore
|
|
167
194
|
autoping_interval: 2,
|
|
168
195
|
autoping_timeout: 4,
|
|
169
|
-
onchallenge: (
|
|
196
|
+
onchallenge: (r, e, n) => C.auth_cra.sign(this.serial_number, n.challenge)
|
|
170
197
|
}), this.connection.onopen = this.onOpen.bind(this), this.connection.onclose = this.onClose.bind(this), this.connection.open(), this.firstConnection;
|
|
171
198
|
}
|
|
172
|
-
onOpen(
|
|
173
|
-
this.session =
|
|
199
|
+
onOpen(r) {
|
|
200
|
+
this.session = r, this.session.caller_disclose_me = !0, this.hasOpenedOnce = !0, this.resubscribeAll().catch(
|
|
201
|
+
(e) => console.error("Failed to restore subscriptions after (re)connect:", e)
|
|
202
|
+
), this.reregisterAll().catch(
|
|
203
|
+
(e) => console.error("Failed to restore registrations after (re)connect:", e)
|
|
204
|
+
), this.emit("connected", this.serial_number), this.firstResolver(), this.firstResolver = () => {
|
|
174
205
|
};
|
|
175
206
|
}
|
|
176
|
-
onClose(
|
|
177
|
-
this.session = void 0, this.emit("disconnected"),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
)
|
|
181
|
-
), this.firstRejecter = () => {
|
|
182
|
-
}, console.warn("Connection closed:", {
|
|
183
|
-
reason: t,
|
|
184
|
-
details: s,
|
|
207
|
+
onClose(r, e) {
|
|
208
|
+
this.session = void 0, this.emit("disconnected"), console.warn("Connection closed:", {
|
|
209
|
+
reason: r,
|
|
210
|
+
details: e,
|
|
185
211
|
realm: this.realm,
|
|
186
212
|
url: this.socketURI,
|
|
187
213
|
authid: this.serial_number
|
|
188
214
|
});
|
|
189
|
-
const
|
|
190
|
-
return this.failOnAuthError && typeof
|
|
215
|
+
const n = (e == null ? void 0 : e.reason) ?? r;
|
|
216
|
+
return this.failOnAuthError && typeof n == "string" && oe.includes(n) ? (this.shouldReconnect = !1, this.firstRejecter(new Error(`Connection failed (auth denied): ${n}`)), this.firstRejecter = () => {
|
|
217
|
+
}, this.emit("auth_failure", n, e), !0) : this.failOnAuthError && !this.hasOpenedOnce ? (this.firstRejecter(
|
|
218
|
+
new Error(`Connection failed: ${r} - ${JSON.stringify(e, null, 2)}`)
|
|
219
|
+
), this.firstRejecter = () => {
|
|
220
|
+
}, !1) : (this.shouldReconnect && (e == null ? void 0 : e.will_retry) === !1 && this.handleManualReconnect(n), !1);
|
|
191
221
|
}
|
|
192
|
-
async handleManualReconnect(
|
|
222
|
+
async handleManualReconnect(r) {
|
|
193
223
|
if (!(this.isReconnecting || !this.shouldReconnect)) {
|
|
194
224
|
for (this.isReconnecting = !0; this.shouldReconnect && !this.session; )
|
|
195
|
-
if (await new Promise((
|
|
196
|
-
console.log(`Manually retrying connection after ${
|
|
225
|
+
if (await new Promise((e) => setTimeout(e, 1e3)), this.shouldReconnect && this.connection && !this.session) {
|
|
226
|
+
console.log(`Manually retrying connection after ${r}...`);
|
|
197
227
|
try {
|
|
198
|
-
this.connection.open(), await new Promise((
|
|
199
|
-
} catch (
|
|
200
|
-
console.error("Error during manual reconnection attempt:",
|
|
228
|
+
this.connection.open(), await new Promise((e) => setTimeout(e, 500));
|
|
229
|
+
} catch (e) {
|
|
230
|
+
console.error("Error during manual reconnection attempt:", e);
|
|
201
231
|
}
|
|
202
232
|
}
|
|
203
233
|
this.isReconnecting = !1;
|
|
204
234
|
}
|
|
205
235
|
}
|
|
206
|
-
|
|
207
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Waits for an open session; `context` names the pending operation so the
|
|
238
|
+
* timeout error explains what could not be performed and why.
|
|
239
|
+
*/
|
|
240
|
+
async sessionWait(r) {
|
|
241
|
+
const e = Date.now();
|
|
208
242
|
for (; !this.session; ) {
|
|
209
|
-
if (Date.now() -
|
|
210
|
-
throw new Error(
|
|
211
|
-
|
|
243
|
+
if (Date.now() - e > P)
|
|
244
|
+
throw new Error(
|
|
245
|
+
`Cannot ${r}: not connected to the IronFlock router (no session after ${P / 1e3}s, realm '${this.realm ?? "unconfigured"}'). Ensure start() was called and the connection is established.`
|
|
246
|
+
);
|
|
247
|
+
await new Promise((n) => setTimeout(n, 200));
|
|
212
248
|
}
|
|
249
|
+
return this.session;
|
|
213
250
|
}
|
|
214
251
|
async waitForConnection() {
|
|
215
252
|
return this.firstConnection;
|
|
@@ -218,267 +255,310 @@ class $ extends G {
|
|
|
218
255
|
return this.session;
|
|
219
256
|
}
|
|
220
257
|
get is_open() {
|
|
221
|
-
var
|
|
222
|
-
return !!((
|
|
258
|
+
var r;
|
|
259
|
+
return !!((r = this.session) != null && r.isOpen);
|
|
223
260
|
}
|
|
224
261
|
isConnected() {
|
|
225
262
|
return this.is_open;
|
|
226
263
|
}
|
|
227
264
|
stop() {
|
|
228
|
-
var
|
|
229
|
-
this.shouldReconnect = !1, (
|
|
265
|
+
var r;
|
|
266
|
+
this.shouldReconnect = !1, this.firstRejecter(new Error("Connection stopped before it opened")), this.firstRejecter = () => {
|
|
267
|
+
}, (r = this.connection) == null || r.close("wamp.close.normal", "Connection closed by client");
|
|
230
268
|
}
|
|
231
|
-
async subscribe(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
269
|
+
async subscribe(r, e) {
|
|
270
|
+
const n = await this.sessionWait(`subscribe to topic '${r}'`);
|
|
271
|
+
let l;
|
|
272
|
+
try {
|
|
273
|
+
l = await n.subscribe(r, e);
|
|
274
|
+
} catch (i) {
|
|
275
|
+
throw M("Subscribe to topic", r, i);
|
|
276
|
+
}
|
|
277
|
+
return l && this.subscriptions.push(l), l;
|
|
236
278
|
}
|
|
237
|
-
async unsubscribe(
|
|
238
|
-
var
|
|
239
|
-
await this.sessionWait();
|
|
240
|
-
const
|
|
241
|
-
|
|
279
|
+
async unsubscribe(r) {
|
|
280
|
+
var n;
|
|
281
|
+
await this.sessionWait(`unsubscribe from topic '${r.topic}'`);
|
|
282
|
+
const e = this.subscriptions.indexOf(r);
|
|
283
|
+
e !== -1 && (this.subscriptions.splice(e, 1), await ((n = this.session) == null ? void 0 : n.unsubscribe(r)));
|
|
242
284
|
}
|
|
243
|
-
async unsubscribeTopic(
|
|
244
|
-
const
|
|
245
|
-
for (const
|
|
246
|
-
await this.unsubscribe(
|
|
285
|
+
async unsubscribeTopic(r) {
|
|
286
|
+
const e = this.subscriptions.filter((n) => n.topic === r);
|
|
287
|
+
for (const n of e)
|
|
288
|
+
await this.unsubscribe(n);
|
|
247
289
|
}
|
|
248
290
|
async resubscribeAll() {
|
|
249
|
-
const
|
|
291
|
+
const r = [...this.subscriptions];
|
|
250
292
|
this.subscriptions = [], await Promise.all(
|
|
251
|
-
|
|
293
|
+
r.map((e) => this.subscribe(e.topic, e.handler))
|
|
252
294
|
);
|
|
253
295
|
}
|
|
254
296
|
async reregisterAll() {
|
|
255
|
-
const
|
|
297
|
+
const r = [...this.registrations];
|
|
256
298
|
this.registrations = [], await Promise.all(
|
|
257
|
-
|
|
299
|
+
r.map((e) => this.register(e.procedure, e.endpoint, e.options))
|
|
258
300
|
);
|
|
259
301
|
}
|
|
260
|
-
async register(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
302
|
+
async register(r, e, n) {
|
|
303
|
+
const l = await this.sessionWait(`register procedure '${r}'`), i = { force_reregister: !0, ...n ?? {} };
|
|
304
|
+
let u;
|
|
305
|
+
try {
|
|
306
|
+
u = await l.register(r, e, i);
|
|
307
|
+
} catch (t) {
|
|
308
|
+
throw M("Register of procedure", r, t);
|
|
309
|
+
}
|
|
310
|
+
return u && this.registrations.push(u), u;
|
|
265
311
|
}
|
|
266
|
-
async unregister(
|
|
267
|
-
var
|
|
268
|
-
await this.sessionWait(), await ((
|
|
269
|
-
const
|
|
270
|
-
|
|
312
|
+
async unregister(r) {
|
|
313
|
+
var n;
|
|
314
|
+
await this.sessionWait(`unregister procedure '${r.procedure}'`), await ((n = this.session) == null ? void 0 : n.unregister(r));
|
|
315
|
+
const e = this.registrations.indexOf(r);
|
|
316
|
+
e !== -1 && this.registrations.splice(e, 1);
|
|
271
317
|
}
|
|
272
|
-
async call(
|
|
273
|
-
|
|
274
|
-
|
|
318
|
+
async call(r, e, n, l) {
|
|
319
|
+
const i = await this.sessionWait(`call procedure '${r}'`);
|
|
320
|
+
try {
|
|
321
|
+
return await i.call(r, e, n, l);
|
|
322
|
+
} catch (u) {
|
|
323
|
+
throw M("Call of procedure", r, u);
|
|
324
|
+
}
|
|
275
325
|
}
|
|
276
|
-
async publish(
|
|
277
|
-
|
|
278
|
-
|
|
326
|
+
async publish(r, e, n, l) {
|
|
327
|
+
const i = await this.sessionWait(`publish to topic '${r}'`);
|
|
328
|
+
try {
|
|
329
|
+
return await i.publish(r, e, n, l);
|
|
330
|
+
} catch (u) {
|
|
331
|
+
throw M("Publish to topic", r, u);
|
|
332
|
+
}
|
|
279
333
|
}
|
|
280
334
|
}
|
|
281
|
-
const T = (
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
335
|
+
const T = (y) => Math.floor(y) === y && ae <= y && y <= ie, ae = 0, ie = 2 ** 32 - 1, O = (y) => ce.test(y), ce = /^[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 = (y) => {
|
|
336
|
+
const r = (e) => {
|
|
337
|
+
if (y.length === 0)
|
|
284
338
|
return !0;
|
|
285
|
-
const
|
|
286
|
-
return
|
|
339
|
+
const n = y[y.length - 1].path;
|
|
340
|
+
return e.length > n.length || n.substring(0, e.length) !== e;
|
|
287
341
|
};
|
|
288
|
-
return (
|
|
342
|
+
return (e, n) => (e && r(n.path) && (n.value === void 0 && (n.description ?? (n.description = [
|
|
289
343
|
"The value at this path is `undefined`.",
|
|
290
344
|
"",
|
|
291
|
-
`Please fill the \`${
|
|
345
|
+
`Please fill the \`${n.expected}\` typed value next time.`
|
|
292
346
|
].join(`
|
|
293
|
-
`))),
|
|
294
|
-
},
|
|
347
|
+
`))), y.push(n)), !1);
|
|
348
|
+
}, k = (y) => Object.assign(y, {
|
|
295
349
|
"~standard": {
|
|
296
350
|
version: 1,
|
|
297
351
|
vendor: "typia",
|
|
298
|
-
validate: (
|
|
299
|
-
const
|
|
300
|
-
return
|
|
301
|
-
value:
|
|
352
|
+
validate: (r) => {
|
|
353
|
+
const e = y(r);
|
|
354
|
+
return e.success ? {
|
|
355
|
+
value: e.data
|
|
302
356
|
} : {
|
|
303
|
-
issues:
|
|
304
|
-
message: `expected ${
|
|
305
|
-
path:
|
|
357
|
+
issues: e.errors.map((n) => ({
|
|
358
|
+
message: `expected ${n.expected}, got ${n.value}`,
|
|
359
|
+
path: le(n.path)
|
|
306
360
|
}))
|
|
307
361
|
};
|
|
308
362
|
}
|
|
309
363
|
}
|
|
310
364
|
});
|
|
311
|
-
var
|
|
312
|
-
(function(
|
|
313
|
-
|
|
314
|
-
})(
|
|
315
|
-
const
|
|
316
|
-
if (!
|
|
317
|
-
throw new Error(`Invalid path: ${JSON.stringify(
|
|
318
|
-
const
|
|
319
|
-
let
|
|
320
|
-
for (; l <
|
|
365
|
+
var A;
|
|
366
|
+
(function(y) {
|
|
367
|
+
y[y.Start = 0] = "Start", y[y.Property = 1] = "Property", y[y.StringKey = 2] = "StringKey", y[y.NumberKey = 3] = "NumberKey";
|
|
368
|
+
})(A || (A = {}));
|
|
369
|
+
const le = (y) => {
|
|
370
|
+
if (!y.startsWith("$input"))
|
|
371
|
+
throw new Error(`Invalid path: ${JSON.stringify(y)}`);
|
|
372
|
+
const r = [];
|
|
373
|
+
let e = "", n = A.Start, l = 5;
|
|
374
|
+
for (; l < y.length - 1; ) {
|
|
321
375
|
l++;
|
|
322
|
-
const i =
|
|
323
|
-
if (
|
|
324
|
-
key:
|
|
325
|
-
}),
|
|
326
|
-
key:
|
|
327
|
-
}), l++,
|
|
328
|
-
key: JSON.parse(
|
|
329
|
-
}), l += 2,
|
|
330
|
-
key: Number.parseInt(
|
|
331
|
-
}), l++,
|
|
332
|
-
const u =
|
|
333
|
-
if (
|
|
334
|
-
|
|
376
|
+
const i = y[l];
|
|
377
|
+
if (n === A.Property ? i === "." || i === "[" ? (r.push({
|
|
378
|
+
key: e
|
|
379
|
+
}), n = A.Start) : l === y.length - 1 ? (e += i, r.push({
|
|
380
|
+
key: e
|
|
381
|
+
}), l++, n = A.Start) : e += i : n === A.StringKey ? i === '"' ? (r.push({
|
|
382
|
+
key: JSON.parse(e + i)
|
|
383
|
+
}), l += 2, n = A.Start) : i === "\\" ? (e += y[l], l++, e += y[l]) : e += i : n === A.NumberKey && (i === "]" ? (r.push({
|
|
384
|
+
key: Number.parseInt(e)
|
|
385
|
+
}), l++, n = A.Start) : e += i), n === A.Start && l < y.length - 1) {
|
|
386
|
+
const u = y[l];
|
|
387
|
+
if (e = "", u === "[")
|
|
388
|
+
y[l + 1] === '"' ? (n = A.StringKey, l++, e = '"') : n = A.NumberKey;
|
|
335
389
|
else if (u === ".")
|
|
336
|
-
|
|
390
|
+
n = A.Property;
|
|
337
391
|
else
|
|
338
392
|
throw new Error("Unreachable: pointer points invalid character");
|
|
339
393
|
}
|
|
340
394
|
}
|
|
341
|
-
if (
|
|
342
|
-
throw new Error(`Failed to parse path: ${JSON.stringify(
|
|
343
|
-
return
|
|
395
|
+
if (n !== A.Start)
|
|
396
|
+
throw new Error(`Failed to parse path: ${JSON.stringify(y)}`);
|
|
397
|
+
return r;
|
|
344
398
|
};
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
|
|
399
|
+
var _ = /* @__PURE__ */ ((y) => (y.DEVELOPMENT = "dev", y.PRODUCTION = "prod", y))(_ || {});
|
|
400
|
+
function Y(y) {
|
|
401
|
+
const r = (y == null ? void 0 : y.filterAnd) ?? [];
|
|
402
|
+
for (const e of r)
|
|
403
|
+
if (e && (e.latest === !0 || e.column === "latest_flag"))
|
|
404
|
+
throw new Error("The 'latest' marker (and the legacy latest_flag filter) is not supported in series queries — use getHistory() with filterAnd: [{ latest: true }] to read current values.");
|
|
405
|
+
}
|
|
406
|
+
const H = (() => {
|
|
407
|
+
const y = (c) => typeof c.limit == "number" && T(c.limit) && 1 <= c.limit && c.limit <= 1e4 && (c.offset === void 0 || typeof c.offset == "number" && T(c.offset) && 0 <= c.offset) && (c.timeRange === void 0 || typeof c.timeRange == "object" && c.timeRange !== null && r(c.timeRange)) && (c.filterAnd === void 0 || Array.isArray(c.filterAnd) && c.filterAnd.every((h) => typeof h == "object" && h !== null && l(h))) && (c.columns === void 0 || Array.isArray(c.columns) && c.columns.every((h) => typeof h == "string")), r = (c) => typeof c.start == "string" && O(c.start) && typeof c.end == "string" && O(c.end), e = (c) => typeof c.column == "string" && 1 <= c.column.length && typeof c.operator == "string" && 1 <= c.operator.length && c.value !== null && c.value !== void 0 && (typeof c.value == "string" || typeof c.value == "number" || typeof c.value == "boolean" || Array.isArray(c.value) && c.value.every((h) => typeof h == "string" || typeof h == "number")), n = (c) => c.latest === !0, l = (c) => c.column !== void 0 ? e(c) : c.latest !== void 0 ? n(c) : !1, i = (c, h, m = !0) => [typeof c.limit == "number" && (T(c.limit) || d(m, {
|
|
408
|
+
path: h + ".limit",
|
|
349
409
|
expected: 'number & Type<"uint32">',
|
|
350
|
-
value:
|
|
351
|
-
})) && (1 <=
|
|
352
|
-
path:
|
|
410
|
+
value: c.limit
|
|
411
|
+
})) && (1 <= c.limit || d(m, {
|
|
412
|
+
path: h + ".limit",
|
|
353
413
|
expected: "number & Minimum<1>",
|
|
354
|
-
value:
|
|
355
|
-
})) && (
|
|
356
|
-
path:
|
|
414
|
+
value: c.limit
|
|
415
|
+
})) && (c.limit <= 1e4 || d(m, {
|
|
416
|
+
path: h + ".limit",
|
|
357
417
|
expected: "number & Maximum<10000>",
|
|
358
|
-
value:
|
|
359
|
-
})) ||
|
|
360
|
-
path:
|
|
418
|
+
value: c.limit
|
|
419
|
+
})) || d(m, {
|
|
420
|
+
path: h + ".limit",
|
|
361
421
|
expected: '(number & Type<"uint32"> & Minimum<1> & Maximum<10000>)',
|
|
362
|
-
value:
|
|
363
|
-
}),
|
|
364
|
-
path:
|
|
422
|
+
value: c.limit
|
|
423
|
+
}), c.offset === void 0 || typeof c.offset == "number" && (T(c.offset) || d(m, {
|
|
424
|
+
path: h + ".offset",
|
|
365
425
|
expected: 'number & Type<"uint32">',
|
|
366
|
-
value:
|
|
367
|
-
})) && (0 <=
|
|
368
|
-
path:
|
|
426
|
+
value: c.offset
|
|
427
|
+
})) && (0 <= c.offset || d(m, {
|
|
428
|
+
path: h + ".offset",
|
|
369
429
|
expected: "number & Minimum<0>",
|
|
370
|
-
value:
|
|
371
|
-
})) ||
|
|
372
|
-
path:
|
|
430
|
+
value: c.offset
|
|
431
|
+
})) || d(m, {
|
|
432
|
+
path: h + ".offset",
|
|
373
433
|
expected: '((number & Type<"uint32"> & Minimum<0>) | undefined)',
|
|
374
|
-
value:
|
|
375
|
-
}),
|
|
376
|
-
path:
|
|
434
|
+
value: c.offset
|
|
435
|
+
}), c.timeRange === void 0 || (typeof c.timeRange == "object" && c.timeRange !== null || d(m, {
|
|
436
|
+
path: h + ".timeRange",
|
|
377
437
|
expected: "(ISOTimeRange | undefined)",
|
|
378
|
-
value:
|
|
379
|
-
})) &&
|
|
380
|
-
path:
|
|
438
|
+
value: c.timeRange
|
|
439
|
+
})) && u(c.timeRange, h + ".timeRange", m) || d(m, {
|
|
440
|
+
path: h + ".timeRange",
|
|
381
441
|
expected: "(ISOTimeRange | undefined)",
|
|
382
|
-
value:
|
|
383
|
-
}),
|
|
384
|
-
path:
|
|
385
|
-
expected: "(Array<
|
|
386
|
-
value:
|
|
387
|
-
})) &&
|
|
388
|
-
path:
|
|
389
|
-
expected: "SQLFilterAnd",
|
|
390
|
-
value:
|
|
391
|
-
})) &&
|
|
392
|
-
path:
|
|
393
|
-
expected: "SQLFilterAnd",
|
|
394
|
-
value:
|
|
395
|
-
})).every((
|
|
396
|
-
path:
|
|
397
|
-
expected: "(Array<
|
|
398
|
-
value:
|
|
399
|
-
})
|
|
400
|
-
path:
|
|
442
|
+
value: c.timeRange
|
|
443
|
+
}), c.filterAnd === void 0 || (Array.isArray(c.filterAnd) || d(m, {
|
|
444
|
+
path: h + ".filterAnd",
|
|
445
|
+
expected: "(Array<TableFilter> | undefined)",
|
|
446
|
+
value: c.filterAnd
|
|
447
|
+
})) && c.filterAnd.map((v, w) => (typeof v == "object" && v !== null || d(m, {
|
|
448
|
+
path: h + ".filterAnd[" + w + "]",
|
|
449
|
+
expected: "(LatestMarker | SQLFilterAnd)",
|
|
450
|
+
value: v
|
|
451
|
+
})) && s(v, h + ".filterAnd[" + w + "]", m) || d(m, {
|
|
452
|
+
path: h + ".filterAnd[" + w + "]",
|
|
453
|
+
expected: "(LatestMarker | SQLFilterAnd)",
|
|
454
|
+
value: v
|
|
455
|
+
})).every((v) => v) || d(m, {
|
|
456
|
+
path: h + ".filterAnd",
|
|
457
|
+
expected: "(Array<TableFilter> | undefined)",
|
|
458
|
+
value: c.filterAnd
|
|
459
|
+
}), c.columns === void 0 || (Array.isArray(c.columns) || d(m, {
|
|
460
|
+
path: h + ".columns",
|
|
461
|
+
expected: "(Array<string> | undefined)",
|
|
462
|
+
value: c.columns
|
|
463
|
+
})) && c.columns.map((v, w) => typeof v == "string" || d(m, {
|
|
464
|
+
path: h + ".columns[" + w + "]",
|
|
465
|
+
expected: "string",
|
|
466
|
+
value: v
|
|
467
|
+
})).every((v) => v) || d(m, {
|
|
468
|
+
path: h + ".columns",
|
|
469
|
+
expected: "(Array<string> | undefined)",
|
|
470
|
+
value: c.columns
|
|
471
|
+
})].every((v) => v), u = (c, h, m = !0) => [typeof c.start == "string" && (O(c.start) || d(m, {
|
|
472
|
+
path: h + ".start",
|
|
401
473
|
expected: 'string & Format<"date-time">',
|
|
402
|
-
value:
|
|
403
|
-
})) ||
|
|
404
|
-
path:
|
|
474
|
+
value: c.start
|
|
475
|
+
})) || d(m, {
|
|
476
|
+
path: h + ".start",
|
|
405
477
|
expected: '(string & Format<"date-time">)',
|
|
406
|
-
value:
|
|
407
|
-
}), typeof
|
|
408
|
-
path:
|
|
478
|
+
value: c.start
|
|
479
|
+
}), typeof c.end == "string" && (O(c.end) || d(m, {
|
|
480
|
+
path: h + ".end",
|
|
409
481
|
expected: 'string & Format<"date-time">',
|
|
410
|
-
value:
|
|
411
|
-
})) ||
|
|
412
|
-
path:
|
|
482
|
+
value: c.end
|
|
483
|
+
})) || d(m, {
|
|
484
|
+
path: h + ".end",
|
|
413
485
|
expected: '(string & Format<"date-time">)',
|
|
414
|
-
value:
|
|
415
|
-
})].every((
|
|
416
|
-
path:
|
|
486
|
+
value: c.end
|
|
487
|
+
})].every((v) => v), t = (c, h, m = !0) => [typeof c.column == "string" && (1 <= c.column.length || d(m, {
|
|
488
|
+
path: h + ".column",
|
|
417
489
|
expected: "string & MinLength<1>",
|
|
418
|
-
value:
|
|
419
|
-
})) ||
|
|
420
|
-
path:
|
|
490
|
+
value: c.column
|
|
491
|
+
})) || d(m, {
|
|
492
|
+
path: h + ".column",
|
|
421
493
|
expected: "(string & MinLength<1>)",
|
|
422
|
-
value:
|
|
423
|
-
}), typeof
|
|
424
|
-
path:
|
|
494
|
+
value: c.column
|
|
495
|
+
}), typeof c.operator == "string" && (1 <= c.operator.length || d(m, {
|
|
496
|
+
path: h + ".operator",
|
|
425
497
|
expected: "string & MinLength<1>",
|
|
426
|
-
value:
|
|
427
|
-
})) ||
|
|
428
|
-
path:
|
|
498
|
+
value: c.operator
|
|
499
|
+
})) || d(m, {
|
|
500
|
+
path: h + ".operator",
|
|
429
501
|
expected: "(string & MinLength<1>)",
|
|
430
|
-
value:
|
|
431
|
-
}), (
|
|
432
|
-
path:
|
|
502
|
+
value: c.operator
|
|
503
|
+
}), (c.value !== null || d(m, {
|
|
504
|
+
path: h + ".value",
|
|
433
505
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
434
|
-
value:
|
|
435
|
-
})) && (
|
|
436
|
-
path:
|
|
506
|
+
value: c.value
|
|
507
|
+
})) && (c.value !== void 0 || d(m, {
|
|
508
|
+
path: h + ".value",
|
|
437
509
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
438
|
-
value:
|
|
439
|
-
})) && (typeof
|
|
440
|
-
path:
|
|
510
|
+
value: c.value
|
|
511
|
+
})) && (typeof c.value == "string" || typeof c.value == "number" || typeof c.value == "boolean" || (Array.isArray(c.value) || d(m, {
|
|
512
|
+
path: h + ".value",
|
|
441
513
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
442
|
-
value:
|
|
443
|
-
})) &&
|
|
444
|
-
path:
|
|
514
|
+
value: c.value
|
|
515
|
+
})) && c.value.map((v, w) => typeof v == "string" || typeof v == "number" || d(m, {
|
|
516
|
+
path: h + ".value[" + w + "]",
|
|
445
517
|
expected: "(number | string)",
|
|
446
|
-
value:
|
|
447
|
-
})).every((
|
|
448
|
-
path:
|
|
518
|
+
value: v
|
|
519
|
+
})).every((v) => v) || d(m, {
|
|
520
|
+
path: h + ".value",
|
|
449
521
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
450
|
-
value:
|
|
451
|
-
}))].every((
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
522
|
+
value: c.value
|
|
523
|
+
}))].every((v) => v), a = (c, h, m = !0) => [c.latest === !0 || d(m, {
|
|
524
|
+
path: h + ".latest",
|
|
525
|
+
expected: "true",
|
|
526
|
+
value: c.latest
|
|
527
|
+
})].every((v) => v), s = (c, h, m = !0) => c.column !== void 0 ? t(c, h, m) : c.latest !== void 0 ? a(c, h, m) : d(m, {
|
|
528
|
+
path: h,
|
|
529
|
+
expected: "(SQLFilterAnd | LatestMarker)",
|
|
530
|
+
value: c
|
|
531
|
+
}), o = (c) => typeof c == "object" && c !== null && y(c);
|
|
532
|
+
let f, d;
|
|
533
|
+
return k((c) => {
|
|
534
|
+
if (o(c) === !1) {
|
|
535
|
+
f = [], d = R(f), ((m, v, w = !0) => (typeof m == "object" && m !== null || d(!0, {
|
|
536
|
+
path: v + "",
|
|
457
537
|
expected: "TableQueryParams",
|
|
458
|
-
value:
|
|
459
|
-
})) &&
|
|
460
|
-
path:
|
|
538
|
+
value: m
|
|
539
|
+
})) && i(m, v + "", !0) || d(!0, {
|
|
540
|
+
path: v + "",
|
|
461
541
|
expected: "TableQueryParams",
|
|
462
|
-
value:
|
|
463
|
-
}))(
|
|
464
|
-
const
|
|
465
|
-
return
|
|
466
|
-
success:
|
|
467
|
-
data:
|
|
542
|
+
value: m
|
|
543
|
+
}))(c, "$input", !0);
|
|
544
|
+
const h = f.length === 0;
|
|
545
|
+
return h ? {
|
|
546
|
+
success: h,
|
|
547
|
+
data: c
|
|
468
548
|
} : {
|
|
469
|
-
success:
|
|
470
|
-
errors:
|
|
471
|
-
data:
|
|
549
|
+
success: h,
|
|
550
|
+
errors: f,
|
|
551
|
+
data: c
|
|
472
552
|
};
|
|
473
553
|
}
|
|
474
554
|
return {
|
|
475
555
|
success: !0,
|
|
476
|
-
data:
|
|
556
|
+
data: c
|
|
477
557
|
};
|
|
478
558
|
});
|
|
479
|
-
})(),
|
|
480
|
-
const
|
|
481
|
-
const
|
|
559
|
+
})(), Q = (() => {
|
|
560
|
+
const y = (s) => {
|
|
561
|
+
const o = s, f = [
|
|
482
562
|
[
|
|
483
563
|
(d) => d.length === 2 && (d[0] === null || typeof d[0] == "number") && (d[1] === null || typeof d[1] == "number"),
|
|
484
564
|
(d) => d.length === 2 && (d[0] === null || typeof d[0] == "number") && (d[1] === null || typeof d[1] == "number")
|
|
@@ -488,246 +568,246 @@ const F = (() => {
|
|
|
488
568
|
(d) => d.length === 2 && (d[0] === null || typeof d[0] == "string") && (d[1] === null || typeof d[1] == "string")
|
|
489
569
|
]
|
|
490
570
|
];
|
|
491
|
-
for (const d of
|
|
492
|
-
if (d[0](
|
|
493
|
-
return d[1](
|
|
571
|
+
for (const d of f)
|
|
572
|
+
if (d[0](o))
|
|
573
|
+
return d[1](o);
|
|
494
574
|
return !1;
|
|
495
|
-
},
|
|
496
|
-
const d =
|
|
575
|
+
}, r = (s, o, f = !0) => {
|
|
576
|
+
const d = s, c = [
|
|
497
577
|
[
|
|
498
|
-
(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
].every((
|
|
502
|
-
(
|
|
503
|
-
path:
|
|
578
|
+
(h) => h.length === 2 && [
|
|
579
|
+
h[0] === null || typeof h[0] == "number",
|
|
580
|
+
h[1] === null || typeof h[1] == "number"
|
|
581
|
+
].every((m) => m),
|
|
582
|
+
(h) => (h.length === 2 || a(f, {
|
|
583
|
+
path: o,
|
|
504
584
|
expected: "[(null | number), (null | number)]",
|
|
505
|
-
value:
|
|
585
|
+
value: h
|
|
506
586
|
})) && [
|
|
507
|
-
|
|
508
|
-
path:
|
|
587
|
+
h[0] === null || typeof h[0] == "number" || a(f, {
|
|
588
|
+
path: o + "[0]",
|
|
509
589
|
expected: "(null | number)",
|
|
510
|
-
value:
|
|
590
|
+
value: h[0]
|
|
511
591
|
}),
|
|
512
|
-
|
|
513
|
-
path:
|
|
592
|
+
h[1] === null || typeof h[1] == "number" || a(f, {
|
|
593
|
+
path: o + "[1]",
|
|
514
594
|
expected: "(null | number)",
|
|
515
|
-
value:
|
|
595
|
+
value: h[1]
|
|
516
596
|
})
|
|
517
|
-
].every((
|
|
597
|
+
].every((m) => m)
|
|
518
598
|
],
|
|
519
599
|
[
|
|
520
|
-
(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
].every((
|
|
524
|
-
(
|
|
525
|
-
path:
|
|
600
|
+
(h) => h.length === 2 && [
|
|
601
|
+
h[0] === null || typeof h[0] == "string",
|
|
602
|
+
h[1] === null || typeof h[1] == "string"
|
|
603
|
+
].every((m) => m),
|
|
604
|
+
(h) => (h.length === 2 || a(f, {
|
|
605
|
+
path: o,
|
|
526
606
|
expected: "[(null | string), (null | string)]",
|
|
527
|
-
value:
|
|
607
|
+
value: h
|
|
528
608
|
})) && [
|
|
529
|
-
|
|
530
|
-
path:
|
|
609
|
+
h[0] === null || typeof h[0] == "string" || a(f, {
|
|
610
|
+
path: o + "[0]",
|
|
531
611
|
expected: "(null | string)",
|
|
532
|
-
value:
|
|
612
|
+
value: h[0]
|
|
533
613
|
}),
|
|
534
|
-
|
|
535
|
-
path:
|
|
614
|
+
h[1] === null || typeof h[1] == "string" || a(f, {
|
|
615
|
+
path: o + "[1]",
|
|
536
616
|
expected: "(null | string)",
|
|
537
|
-
value:
|
|
617
|
+
value: h[1]
|
|
538
618
|
})
|
|
539
|
-
].every((
|
|
619
|
+
].every((m) => m)
|
|
540
620
|
]
|
|
541
621
|
];
|
|
542
|
-
for (const
|
|
543
|
-
if (
|
|
544
|
-
return
|
|
545
|
-
return
|
|
546
|
-
path:
|
|
622
|
+
for (const h of c)
|
|
623
|
+
if (h[0](d))
|
|
624
|
+
return h[1](d);
|
|
625
|
+
return a(f, {
|
|
626
|
+
path: o,
|
|
547
627
|
expected: "([number | null, number | null] | [string | null, string | null])",
|
|
548
|
-
value:
|
|
628
|
+
value: s
|
|
549
629
|
});
|
|
550
|
-
},
|
|
551
|
-
path:
|
|
630
|
+
}, e = (s) => Array.isArray(s.metrics) && s.metrics.every((o) => typeof o == "string") && (s.method === "AVG" || s.method === "SUM" || s.method === "COUNT" || s.method === "MIN" || s.method === "MAX" || s.method === "FIRST" || s.method === "LAST") && typeof s.limit == "number" && T(s.limit) && 1 <= s.limit && s.limit <= 1e4 && Array.isArray(s.timeRange) && (y(s.timeRange) || !1) && (s.groupBy === null || s.groupBy === void 0 || Array.isArray(s.groupBy) && s.groupBy.every((o) => typeof o == "string")) && (s.filterAnd === null || s.filterAnd === void 0 || Array.isArray(s.filterAnd) && s.filterAnd.every((o) => typeof o == "object" && o !== null && n(o))), n = (s) => typeof s.column == "string" && 1 <= s.column.length && typeof s.operator == "string" && 1 <= s.operator.length && s.value !== null && s.value !== void 0 && (typeof s.value == "string" || typeof s.value == "number" || typeof s.value == "boolean" || Array.isArray(s.value) && s.value.every((o) => typeof o == "string" || typeof o == "number")), l = (s, o, f = !0) => [(Array.isArray(s.metrics) || a(f, {
|
|
631
|
+
path: o + ".metrics",
|
|
552
632
|
expected: "Array<string>",
|
|
553
|
-
value:
|
|
554
|
-
})) &&
|
|
555
|
-
path:
|
|
633
|
+
value: s.metrics
|
|
634
|
+
})) && s.metrics.map((d, c) => typeof d == "string" || a(f, {
|
|
635
|
+
path: o + ".metrics[" + c + "]",
|
|
556
636
|
expected: "string",
|
|
557
637
|
value: d
|
|
558
|
-
})).every((d) => d) ||
|
|
559
|
-
path:
|
|
638
|
+
})).every((d) => d) || a(f, {
|
|
639
|
+
path: o + ".metrics",
|
|
560
640
|
expected: "Array<string>",
|
|
561
|
-
value:
|
|
562
|
-
}),
|
|
563
|
-
path:
|
|
641
|
+
value: s.metrics
|
|
642
|
+
}), s.method === "AVG" || s.method === "SUM" || s.method === "COUNT" || s.method === "MIN" || s.method === "MAX" || s.method === "FIRST" || s.method === "LAST" || a(f, {
|
|
643
|
+
path: o + ".method",
|
|
564
644
|
expected: '("AVG" | "COUNT" | "FIRST" | "LAST" | "MAX" | "MIN" | "SUM")',
|
|
565
|
-
value:
|
|
566
|
-
}), typeof
|
|
567
|
-
path:
|
|
645
|
+
value: s.method
|
|
646
|
+
}), typeof s.limit == "number" && (T(s.limit) || a(f, {
|
|
647
|
+
path: o + ".limit",
|
|
568
648
|
expected: 'number & Type<"uint32">',
|
|
569
|
-
value:
|
|
570
|
-
})) && (1 <=
|
|
571
|
-
path:
|
|
649
|
+
value: s.limit
|
|
650
|
+
})) && (1 <= s.limit || a(f, {
|
|
651
|
+
path: o + ".limit",
|
|
572
652
|
expected: "number & Minimum<1>",
|
|
573
|
-
value:
|
|
574
|
-
})) && (
|
|
575
|
-
path:
|
|
653
|
+
value: s.limit
|
|
654
|
+
})) && (s.limit <= 1e4 || a(f, {
|
|
655
|
+
path: o + ".limit",
|
|
576
656
|
expected: "number & Maximum<10000>",
|
|
577
|
-
value:
|
|
578
|
-
})) ||
|
|
579
|
-
path:
|
|
657
|
+
value: s.limit
|
|
658
|
+
})) || a(f, {
|
|
659
|
+
path: o + ".limit",
|
|
580
660
|
expected: '(number & Type<"uint32"> & Minimum<1> & Maximum<10000>)',
|
|
581
|
-
value:
|
|
582
|
-
}), (Array.isArray(
|
|
583
|
-
path:
|
|
661
|
+
value: s.limit
|
|
662
|
+
}), (Array.isArray(s.timeRange) || a(f, {
|
|
663
|
+
path: o + ".timeRange",
|
|
584
664
|
expected: "([number | null, number | null] | [string | null, string | null])",
|
|
585
|
-
value:
|
|
586
|
-
})) && (
|
|
587
|
-
path:
|
|
665
|
+
value: s.timeRange
|
|
666
|
+
})) && (r(s.timeRange, o + ".timeRange", f) || a(f, {
|
|
667
|
+
path: o + ".timeRange",
|
|
588
668
|
expected: "[number | null, number | null] | [string | null, string | null]",
|
|
589
|
-
value:
|
|
590
|
-
})) ||
|
|
591
|
-
path:
|
|
669
|
+
value: s.timeRange
|
|
670
|
+
})) || a(f, {
|
|
671
|
+
path: o + ".timeRange",
|
|
592
672
|
expected: "([number | null, number | null] | [string | null, string | null])",
|
|
593
|
-
value:
|
|
594
|
-
}),
|
|
595
|
-
path:
|
|
673
|
+
value: s.timeRange
|
|
674
|
+
}), s.groupBy === null || s.groupBy === void 0 || (Array.isArray(s.groupBy) || a(f, {
|
|
675
|
+
path: o + ".groupBy",
|
|
596
676
|
expected: "(Array<string> | null | undefined)",
|
|
597
|
-
value:
|
|
598
|
-
})) &&
|
|
599
|
-
path:
|
|
677
|
+
value: s.groupBy
|
|
678
|
+
})) && s.groupBy.map((d, c) => typeof d == "string" || a(f, {
|
|
679
|
+
path: o + ".groupBy[" + c + "]",
|
|
600
680
|
expected: "string",
|
|
601
681
|
value: d
|
|
602
|
-
})).every((d) => d) ||
|
|
603
|
-
path:
|
|
682
|
+
})).every((d) => d) || a(f, {
|
|
683
|
+
path: o + ".groupBy",
|
|
604
684
|
expected: "(Array<string> | null | undefined)",
|
|
605
|
-
value:
|
|
606
|
-
}),
|
|
607
|
-
path:
|
|
685
|
+
value: s.groupBy
|
|
686
|
+
}), s.filterAnd === null || s.filterAnd === void 0 || (Array.isArray(s.filterAnd) || a(f, {
|
|
687
|
+
path: o + ".filterAnd",
|
|
608
688
|
expected: "(Array<SQLFilterAnd> | null | undefined)",
|
|
609
|
-
value:
|
|
610
|
-
})) &&
|
|
611
|
-
path:
|
|
689
|
+
value: s.filterAnd
|
|
690
|
+
})) && s.filterAnd.map((d, c) => (typeof d == "object" && d !== null || a(f, {
|
|
691
|
+
path: o + ".filterAnd[" + c + "]",
|
|
612
692
|
expected: "SQLFilterAnd",
|
|
613
693
|
value: d
|
|
614
|
-
})) && i(d,
|
|
615
|
-
path:
|
|
694
|
+
})) && i(d, o + ".filterAnd[" + c + "]", f) || a(f, {
|
|
695
|
+
path: o + ".filterAnd[" + c + "]",
|
|
616
696
|
expected: "SQLFilterAnd",
|
|
617
697
|
value: d
|
|
618
|
-
})).every((d) => d) ||
|
|
619
|
-
path:
|
|
698
|
+
})).every((d) => d) || a(f, {
|
|
699
|
+
path: o + ".filterAnd",
|
|
620
700
|
expected: "(Array<SQLFilterAnd> | null | undefined)",
|
|
621
|
-
value:
|
|
622
|
-
})].every((d) => d), i = (
|
|
623
|
-
path:
|
|
701
|
+
value: s.filterAnd
|
|
702
|
+
})].every((d) => d), i = (s, o, f = !0) => [typeof s.column == "string" && (1 <= s.column.length || a(f, {
|
|
703
|
+
path: o + ".column",
|
|
624
704
|
expected: "string & MinLength<1>",
|
|
625
|
-
value:
|
|
626
|
-
})) ||
|
|
627
|
-
path:
|
|
705
|
+
value: s.column
|
|
706
|
+
})) || a(f, {
|
|
707
|
+
path: o + ".column",
|
|
628
708
|
expected: "(string & MinLength<1>)",
|
|
629
|
-
value:
|
|
630
|
-
}), typeof
|
|
631
|
-
path:
|
|
709
|
+
value: s.column
|
|
710
|
+
}), typeof s.operator == "string" && (1 <= s.operator.length || a(f, {
|
|
711
|
+
path: o + ".operator",
|
|
632
712
|
expected: "string & MinLength<1>",
|
|
633
|
-
value:
|
|
634
|
-
})) ||
|
|
635
|
-
path:
|
|
713
|
+
value: s.operator
|
|
714
|
+
})) || a(f, {
|
|
715
|
+
path: o + ".operator",
|
|
636
716
|
expected: "(string & MinLength<1>)",
|
|
637
|
-
value:
|
|
638
|
-
}), (
|
|
639
|
-
path:
|
|
717
|
+
value: s.operator
|
|
718
|
+
}), (s.value !== null || a(f, {
|
|
719
|
+
path: o + ".value",
|
|
640
720
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
641
|
-
value:
|
|
642
|
-
})) && (
|
|
643
|
-
path:
|
|
721
|
+
value: s.value
|
|
722
|
+
})) && (s.value !== void 0 || a(f, {
|
|
723
|
+
path: o + ".value",
|
|
644
724
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
645
|
-
value:
|
|
646
|
-
})) && (typeof
|
|
647
|
-
path:
|
|
725
|
+
value: s.value
|
|
726
|
+
})) && (typeof s.value == "string" || typeof s.value == "number" || typeof s.value == "boolean" || (Array.isArray(s.value) || a(f, {
|
|
727
|
+
path: o + ".value",
|
|
648
728
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
649
|
-
value:
|
|
650
|
-
})) &&
|
|
651
|
-
path:
|
|
729
|
+
value: s.value
|
|
730
|
+
})) && s.value.map((d, c) => typeof d == "string" || typeof d == "number" || a(f, {
|
|
731
|
+
path: o + ".value[" + c + "]",
|
|
652
732
|
expected: "(number | string)",
|
|
653
733
|
value: d
|
|
654
|
-
})).every((d) => d) ||
|
|
655
|
-
path:
|
|
734
|
+
})).every((d) => d) || a(f, {
|
|
735
|
+
path: o + ".value",
|
|
656
736
|
expected: "(Array<string | number> | boolean | number | string)",
|
|
657
|
-
value:
|
|
658
|
-
}))].every((d) => d), u = (
|
|
659
|
-
let
|
|
660
|
-
return
|
|
661
|
-
if (u(
|
|
662
|
-
|
|
737
|
+
value: s.value
|
|
738
|
+
}))].every((d) => d), u = (s) => typeof s == "object" && s !== null && e(s);
|
|
739
|
+
let t, a;
|
|
740
|
+
return k((s) => {
|
|
741
|
+
if (u(s) === !1) {
|
|
742
|
+
t = [], a = R(t), ((f, d, c = !0) => (typeof f == "object" && f !== null || a(!0, {
|
|
663
743
|
path: d + "",
|
|
664
744
|
expected: "SeriesQueryParams",
|
|
665
|
-
value:
|
|
666
|
-
})) && l(
|
|
745
|
+
value: f
|
|
746
|
+
})) && l(f, d + "", !0) || a(!0, {
|
|
667
747
|
path: d + "",
|
|
668
748
|
expected: "SeriesQueryParams",
|
|
669
|
-
value:
|
|
670
|
-
}))(
|
|
671
|
-
const
|
|
672
|
-
return
|
|
673
|
-
success:
|
|
674
|
-
data:
|
|
749
|
+
value: f
|
|
750
|
+
}))(s, "$input", !0);
|
|
751
|
+
const o = t.length === 0;
|
|
752
|
+
return o ? {
|
|
753
|
+
success: o,
|
|
754
|
+
data: s
|
|
675
755
|
} : {
|
|
676
|
-
success:
|
|
677
|
-
errors:
|
|
678
|
-
data:
|
|
756
|
+
success: o,
|
|
757
|
+
errors: t,
|
|
758
|
+
data: s
|
|
679
759
|
};
|
|
680
760
|
}
|
|
681
761
|
return {
|
|
682
762
|
success: !0,
|
|
683
|
-
data:
|
|
763
|
+
data: s
|
|
684
764
|
};
|
|
685
765
|
});
|
|
686
|
-
})(),
|
|
687
|
-
const
|
|
766
|
+
})(), ue = (() => {
|
|
767
|
+
const y = (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, {
|
|
688
768
|
path: u + ".longitude",
|
|
689
769
|
expected: "number & Minimum<-180>",
|
|
690
770
|
value: i.longitude
|
|
691
|
-
})) && (i.longitude <= 180 || l(
|
|
771
|
+
})) && (i.longitude <= 180 || l(t, {
|
|
692
772
|
path: u + ".longitude",
|
|
693
773
|
expected: "number & Maximum<180>",
|
|
694
774
|
value: i.longitude
|
|
695
|
-
})) || l(
|
|
775
|
+
})) || l(t, {
|
|
696
776
|
path: u + ".longitude",
|
|
697
777
|
expected: "(number & Minimum<-180> & Maximum<180>)",
|
|
698
778
|
value: i.longitude
|
|
699
|
-
}), typeof i.latitude == "number" && (-90 <= i.latitude || l(
|
|
779
|
+
}), typeof i.latitude == "number" && (-90 <= i.latitude || l(t, {
|
|
700
780
|
path: u + ".latitude",
|
|
701
781
|
expected: "number & Minimum<-90>",
|
|
702
782
|
value: i.latitude
|
|
703
|
-
})) && (i.latitude <= 90 || l(
|
|
783
|
+
})) && (i.latitude <= 90 || l(t, {
|
|
704
784
|
path: u + ".latitude",
|
|
705
785
|
expected: "number & Maximum<90>",
|
|
706
786
|
value: i.latitude
|
|
707
|
-
})) || l(
|
|
787
|
+
})) || l(t, {
|
|
708
788
|
path: u + ".latitude",
|
|
709
789
|
expected: "(number & Minimum<-90> & Maximum<90>)",
|
|
710
790
|
value: i.latitude
|
|
711
|
-
})].every((
|
|
712
|
-
let
|
|
713
|
-
return
|
|
714
|
-
if (
|
|
715
|
-
|
|
716
|
-
path:
|
|
791
|
+
})].every((a) => a), e = (i) => typeof i == "object" && i !== null && y(i);
|
|
792
|
+
let n, l;
|
|
793
|
+
return k((i) => {
|
|
794
|
+
if (e(i) === !1) {
|
|
795
|
+
n = [], l = R(n), ((t, a, s = !0) => (typeof t == "object" && t !== null || l(!0, {
|
|
796
|
+
path: a + "",
|
|
717
797
|
expected: "LocationParams",
|
|
718
|
-
value:
|
|
719
|
-
})) && t
|
|
720
|
-
path:
|
|
798
|
+
value: t
|
|
799
|
+
})) && r(t, a + "", !0) || l(!0, {
|
|
800
|
+
path: a + "",
|
|
721
801
|
expected: "LocationParams",
|
|
722
|
-
value:
|
|
802
|
+
value: t
|
|
723
803
|
}))(i, "$input", !0);
|
|
724
|
-
const u =
|
|
804
|
+
const u = n.length === 0;
|
|
725
805
|
return u ? {
|
|
726
806
|
success: u,
|
|
727
807
|
data: i
|
|
728
808
|
} : {
|
|
729
809
|
success: u,
|
|
730
|
-
errors:
|
|
810
|
+
errors: n,
|
|
731
811
|
data: i
|
|
732
812
|
};
|
|
733
813
|
}
|
|
@@ -736,227 +816,227 @@ const F = (() => {
|
|
|
736
816
|
data: i
|
|
737
817
|
};
|
|
738
818
|
});
|
|
739
|
-
})(),
|
|
740
|
-
const
|
|
741
|
-
path:
|
|
819
|
+
})(), de = (() => {
|
|
820
|
+
const y = (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)), e = (t, a, s = !0) => [typeof t.topic == "string" && (1 <= t.topic.length || u(s, {
|
|
821
|
+
path: a + ".topic",
|
|
742
822
|
expected: "string & MinLength<1>",
|
|
743
|
-
value:
|
|
744
|
-
})) || u(
|
|
745
|
-
path:
|
|
823
|
+
value: t.topic
|
|
824
|
+
})) || u(s, {
|
|
825
|
+
path: a + ".topic",
|
|
746
826
|
expected: "(string & MinLength<1>)",
|
|
747
|
-
value:
|
|
748
|
-
}),
|
|
749
|
-
path:
|
|
827
|
+
value: t.topic
|
|
828
|
+
}), t.args === void 0 || Array.isArray(t.args) || u(s, {
|
|
829
|
+
path: a + ".args",
|
|
750
830
|
expected: "(Array<unknown> | undefined)",
|
|
751
|
-
value:
|
|
752
|
-
}),
|
|
753
|
-
path:
|
|
831
|
+
value: t.args
|
|
832
|
+
}), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(s, {
|
|
833
|
+
path: a + ".kwargs",
|
|
754
834
|
expected: "(Record<string, unknown> | undefined)",
|
|
755
|
-
value:
|
|
756
|
-
})) &&
|
|
757
|
-
path:
|
|
835
|
+
value: t.kwargs
|
|
836
|
+
})) && n(t.kwargs, a + ".kwargs", s) || u(s, {
|
|
837
|
+
path: a + ".kwargs",
|
|
758
838
|
expected: "(Record<string, unknown> | undefined)",
|
|
759
|
-
value:
|
|
760
|
-
})].every((
|
|
839
|
+
value: t.kwargs
|
|
840
|
+
})].every((o) => o), n = (t, a, s = !0) => [s === !1 || Object.keys(t).map((o) => (t[o] === void 0, !0)).every((o) => o)].every((o) => o), l = (t) => typeof t == "object" && t !== null && y(t);
|
|
761
841
|
let i, u;
|
|
762
|
-
return
|
|
763
|
-
if (l(
|
|
764
|
-
i = [], u = R(i), ((
|
|
765
|
-
path:
|
|
842
|
+
return k((t) => {
|
|
843
|
+
if (l(t) === !1) {
|
|
844
|
+
i = [], u = R(i), ((s, o, f = !0) => (typeof s == "object" && s !== null || u(!0, {
|
|
845
|
+
path: o + "",
|
|
766
846
|
expected: "PublishParams",
|
|
767
|
-
value:
|
|
768
|
-
})) && s
|
|
769
|
-
path:
|
|
847
|
+
value: s
|
|
848
|
+
})) && e(s, o + "", !0) || u(!0, {
|
|
849
|
+
path: o + "",
|
|
770
850
|
expected: "PublishParams",
|
|
771
|
-
value:
|
|
772
|
-
}))(
|
|
773
|
-
const
|
|
774
|
-
return
|
|
775
|
-
success:
|
|
776
|
-
data:
|
|
851
|
+
value: s
|
|
852
|
+
}))(t, "$input", !0);
|
|
853
|
+
const a = i.length === 0;
|
|
854
|
+
return a ? {
|
|
855
|
+
success: a,
|
|
856
|
+
data: t
|
|
777
857
|
} : {
|
|
778
|
-
success:
|
|
858
|
+
success: a,
|
|
779
859
|
errors: i,
|
|
780
|
-
data:
|
|
860
|
+
data: t
|
|
781
861
|
};
|
|
782
862
|
}
|
|
783
863
|
return {
|
|
784
864
|
success: !0,
|
|
785
|
-
data:
|
|
865
|
+
data: t
|
|
786
866
|
};
|
|
787
867
|
});
|
|
788
|
-
})(),
|
|
789
|
-
const
|
|
790
|
-
path:
|
|
868
|
+
})(), me = (() => {
|
|
869
|
+
const y = (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)), e = (t, a, s = !0) => [typeof t.deviceKey == "string" && (1 <= t.deviceKey.length || u(s, {
|
|
870
|
+
path: a + ".deviceKey",
|
|
791
871
|
expected: "string & MinLength<1>",
|
|
792
|
-
value:
|
|
793
|
-
})) || u(
|
|
794
|
-
path:
|
|
872
|
+
value: t.deviceKey
|
|
873
|
+
})) || u(s, {
|
|
874
|
+
path: a + ".deviceKey",
|
|
795
875
|
expected: "(string & MinLength<1>)",
|
|
796
|
-
value:
|
|
797
|
-
}), typeof
|
|
798
|
-
path:
|
|
876
|
+
value: t.deviceKey
|
|
877
|
+
}), typeof t.topic == "string" && (1 <= t.topic.length || u(s, {
|
|
878
|
+
path: a + ".topic",
|
|
799
879
|
expected: "string & MinLength<1>",
|
|
800
|
-
value:
|
|
801
|
-
})) || u(
|
|
802
|
-
path:
|
|
880
|
+
value: t.topic
|
|
881
|
+
})) || u(s, {
|
|
882
|
+
path: a + ".topic",
|
|
803
883
|
expected: "(string & MinLength<1>)",
|
|
804
|
-
value:
|
|
805
|
-
}),
|
|
806
|
-
path:
|
|
884
|
+
value: t.topic
|
|
885
|
+
}), t.args === void 0 || Array.isArray(t.args) || u(s, {
|
|
886
|
+
path: a + ".args",
|
|
807
887
|
expected: "(Array<unknown> | undefined)",
|
|
808
|
-
value:
|
|
809
|
-
}),
|
|
810
|
-
path:
|
|
888
|
+
value: t.args
|
|
889
|
+
}), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(s, {
|
|
890
|
+
path: a + ".kwargs",
|
|
811
891
|
expected: "(Record<string, unknown> | undefined)",
|
|
812
|
-
value:
|
|
813
|
-
})) &&
|
|
814
|
-
path:
|
|
892
|
+
value: t.kwargs
|
|
893
|
+
})) && n(t.kwargs, a + ".kwargs", s) || u(s, {
|
|
894
|
+
path: a + ".kwargs",
|
|
815
895
|
expected: "(Record<string, unknown> | undefined)",
|
|
816
|
-
value:
|
|
817
|
-
})].every((
|
|
896
|
+
value: t.kwargs
|
|
897
|
+
})].every((o) => o), n = (t, a, s = !0) => [s === !1 || Object.keys(t).map((o) => (t[o] === void 0, !0)).every((o) => o)].every((o) => o), l = (t) => typeof t == "object" && t !== null && y(t);
|
|
818
898
|
let i, u;
|
|
819
|
-
return
|
|
820
|
-
if (l(
|
|
821
|
-
i = [], u = R(i), ((
|
|
822
|
-
path:
|
|
899
|
+
return k((t) => {
|
|
900
|
+
if (l(t) === !1) {
|
|
901
|
+
i = [], u = R(i), ((s, o, f = !0) => (typeof s == "object" && s !== null || u(!0, {
|
|
902
|
+
path: o + "",
|
|
823
903
|
expected: "CallParams",
|
|
824
|
-
value:
|
|
825
|
-
})) && s
|
|
826
|
-
path:
|
|
904
|
+
value: s
|
|
905
|
+
})) && e(s, o + "", !0) || u(!0, {
|
|
906
|
+
path: o + "",
|
|
827
907
|
expected: "CallParams",
|
|
828
|
-
value:
|
|
829
|
-
}))(
|
|
830
|
-
const
|
|
831
|
-
return
|
|
832
|
-
success:
|
|
833
|
-
data:
|
|
908
|
+
value: s
|
|
909
|
+
}))(t, "$input", !0);
|
|
910
|
+
const a = i.length === 0;
|
|
911
|
+
return a ? {
|
|
912
|
+
success: a,
|
|
913
|
+
data: t
|
|
834
914
|
} : {
|
|
835
|
-
success:
|
|
915
|
+
success: a,
|
|
836
916
|
errors: i,
|
|
837
|
-
data:
|
|
917
|
+
data: t
|
|
838
918
|
};
|
|
839
919
|
}
|
|
840
920
|
return {
|
|
841
921
|
success: !0,
|
|
842
|
-
data:
|
|
922
|
+
data: t
|
|
843
923
|
};
|
|
844
924
|
});
|
|
845
|
-
})(),
|
|
846
|
-
const
|
|
847
|
-
path:
|
|
925
|
+
})(), j = (() => {
|
|
926
|
+
const y = (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)), e = (t, a, s = !0) => [typeof t.tablename == "string" && (1 <= t.tablename.length || u(s, {
|
|
927
|
+
path: a + ".tablename",
|
|
848
928
|
expected: "string & MinLength<1>",
|
|
849
|
-
value:
|
|
850
|
-
})) || u(
|
|
851
|
-
path:
|
|
929
|
+
value: t.tablename
|
|
930
|
+
})) || u(s, {
|
|
931
|
+
path: a + ".tablename",
|
|
852
932
|
expected: "(string & MinLength<1>)",
|
|
853
|
-
value:
|
|
854
|
-
}),
|
|
855
|
-
path:
|
|
933
|
+
value: t.tablename
|
|
934
|
+
}), t.args === void 0 || Array.isArray(t.args) || u(s, {
|
|
935
|
+
path: a + ".args",
|
|
856
936
|
expected: "(Array<unknown> | undefined)",
|
|
857
|
-
value:
|
|
858
|
-
}),
|
|
859
|
-
path:
|
|
937
|
+
value: t.args
|
|
938
|
+
}), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(s, {
|
|
939
|
+
path: a + ".kwargs",
|
|
860
940
|
expected: "(Record<string, unknown> | undefined)",
|
|
861
|
-
value:
|
|
862
|
-
})) &&
|
|
863
|
-
path:
|
|
941
|
+
value: t.kwargs
|
|
942
|
+
})) && n(t.kwargs, a + ".kwargs", s) || u(s, {
|
|
943
|
+
path: a + ".kwargs",
|
|
864
944
|
expected: "(Record<string, unknown> | undefined)",
|
|
865
|
-
value:
|
|
866
|
-
})].every((
|
|
945
|
+
value: t.kwargs
|
|
946
|
+
})].every((o) => o), n = (t, a, s = !0) => [s === !1 || Object.keys(t).map((o) => (t[o] === void 0, !0)).every((o) => o)].every((o) => o), l = (t) => typeof t == "object" && t !== null && y(t);
|
|
867
947
|
let i, u;
|
|
868
|
-
return
|
|
869
|
-
if (l(
|
|
870
|
-
i = [], u = R(i), ((
|
|
871
|
-
path:
|
|
948
|
+
return k((t) => {
|
|
949
|
+
if (l(t) === !1) {
|
|
950
|
+
i = [], u = R(i), ((s, o, f = !0) => (typeof s == "object" && s !== null || u(!0, {
|
|
951
|
+
path: o + "",
|
|
872
952
|
expected: "TableParams",
|
|
873
|
-
value:
|
|
874
|
-
})) && s
|
|
875
|
-
path:
|
|
953
|
+
value: s
|
|
954
|
+
})) && e(s, o + "", !0) || u(!0, {
|
|
955
|
+
path: o + "",
|
|
876
956
|
expected: "TableParams",
|
|
877
|
-
value:
|
|
878
|
-
}))(
|
|
879
|
-
const
|
|
880
|
-
return
|
|
881
|
-
success:
|
|
882
|
-
data:
|
|
957
|
+
value: s
|
|
958
|
+
}))(t, "$input", !0);
|
|
959
|
+
const a = i.length === 0;
|
|
960
|
+
return a ? {
|
|
961
|
+
success: a,
|
|
962
|
+
data: t
|
|
883
963
|
} : {
|
|
884
|
-
success:
|
|
964
|
+
success: a,
|
|
885
965
|
errors: i,
|
|
886
|
-
data:
|
|
966
|
+
data: t
|
|
887
967
|
};
|
|
888
968
|
}
|
|
889
969
|
return {
|
|
890
970
|
success: !0,
|
|
891
|
-
data:
|
|
971
|
+
data: t
|
|
892
972
|
};
|
|
893
973
|
});
|
|
894
|
-
})(),
|
|
895
|
-
const
|
|
896
|
-
path:
|
|
974
|
+
})(), x = (() => {
|
|
975
|
+
const y = (t) => typeof t.tablename == "string" && 1 <= t.tablename.length && Array.isArray(t.rows) && 1 <= t.rows.length && t.rows.every((a) => typeof a == "object" && a !== null && Array.isArray(a) === !1 && r(a)) && (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)), e = (t, a, s = !0) => [typeof t.tablename == "string" && (1 <= t.tablename.length || u(s, {
|
|
976
|
+
path: a + ".tablename",
|
|
897
977
|
expected: "string & MinLength<1>",
|
|
898
|
-
value:
|
|
899
|
-
})) || u(
|
|
900
|
-
path:
|
|
978
|
+
value: t.tablename
|
|
979
|
+
})) || u(s, {
|
|
980
|
+
path: a + ".tablename",
|
|
901
981
|
expected: "(string & MinLength<1>)",
|
|
902
|
-
value:
|
|
903
|
-
}), (Array.isArray(
|
|
904
|
-
path:
|
|
982
|
+
value: t.tablename
|
|
983
|
+
}), (Array.isArray(t.rows) || u(s, {
|
|
984
|
+
path: a + ".rows",
|
|
905
985
|
expected: "(Array<Record<string, unknown>> & MinItems<1>)",
|
|
906
|
-
value:
|
|
907
|
-
})) && (1 <=
|
|
908
|
-
path:
|
|
986
|
+
value: t.rows
|
|
987
|
+
})) && (1 <= t.rows.length || u(s, {
|
|
988
|
+
path: a + ".rows",
|
|
909
989
|
expected: "Array<> & MinItems<1>",
|
|
910
|
-
value:
|
|
911
|
-
})) &&
|
|
912
|
-
path:
|
|
990
|
+
value: t.rows
|
|
991
|
+
})) && t.rows.map((o, f) => (typeof o == "object" && o !== null && Array.isArray(o) === !1 || u(s, {
|
|
992
|
+
path: a + ".rows[" + f + "]",
|
|
913
993
|
expected: "Record<string, unknown>",
|
|
914
|
-
value:
|
|
915
|
-
})) &&
|
|
916
|
-
path:
|
|
994
|
+
value: o
|
|
995
|
+
})) && n(o, a + ".rows[" + f + "]", s) || u(s, {
|
|
996
|
+
path: a + ".rows[" + f + "]",
|
|
917
997
|
expected: "Record<string, unknown>",
|
|
918
|
-
value:
|
|
919
|
-
})).every((
|
|
920
|
-
path:
|
|
998
|
+
value: o
|
|
999
|
+
})).every((o) => o) || u(s, {
|
|
1000
|
+
path: a + ".rows",
|
|
921
1001
|
expected: "(Array<Record<string, unknown>> & MinItems<1>)",
|
|
922
|
-
value:
|
|
923
|
-
}),
|
|
924
|
-
path:
|
|
1002
|
+
value: t.rows
|
|
1003
|
+
}), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(s, {
|
|
1004
|
+
path: a + ".kwargs",
|
|
925
1005
|
expected: "(Record<string, unknown> | undefined)",
|
|
926
|
-
value:
|
|
927
|
-
})) &&
|
|
928
|
-
path:
|
|
1006
|
+
value: t.kwargs
|
|
1007
|
+
})) && n(t.kwargs, a + ".kwargs", s) || u(s, {
|
|
1008
|
+
path: a + ".kwargs",
|
|
929
1009
|
expected: "(Record<string, unknown> | undefined)",
|
|
930
|
-
value:
|
|
931
|
-
})].every((
|
|
1010
|
+
value: t.kwargs
|
|
1011
|
+
})].every((o) => o), n = (t, a, s = !0) => [s === !1 || Object.keys(t).map((o) => (t[o] === void 0, !0)).every((o) => o)].every((o) => o), l = (t) => typeof t == "object" && t !== null && y(t);
|
|
932
1012
|
let i, u;
|
|
933
|
-
return
|
|
934
|
-
if (l(
|
|
935
|
-
i = [], u = R(i), ((
|
|
936
|
-
path:
|
|
1013
|
+
return k((t) => {
|
|
1014
|
+
if (l(t) === !1) {
|
|
1015
|
+
i = [], u = R(i), ((s, o, f = !0) => (typeof s == "object" && s !== null || u(!0, {
|
|
1016
|
+
path: o + "",
|
|
937
1017
|
expected: "BulkTableParams",
|
|
938
|
-
value:
|
|
939
|
-
})) && s
|
|
940
|
-
path:
|
|
1018
|
+
value: s
|
|
1019
|
+
})) && e(s, o + "", !0) || u(!0, {
|
|
1020
|
+
path: o + "",
|
|
941
1021
|
expected: "BulkTableParams",
|
|
942
|
-
value:
|
|
943
|
-
}))(
|
|
944
|
-
const
|
|
945
|
-
return
|
|
946
|
-
success:
|
|
947
|
-
data:
|
|
1022
|
+
value: s
|
|
1023
|
+
}))(t, "$input", !0);
|
|
1024
|
+
const a = i.length === 0;
|
|
1025
|
+
return a ? {
|
|
1026
|
+
success: a,
|
|
1027
|
+
data: t
|
|
948
1028
|
} : {
|
|
949
|
-
success:
|
|
1029
|
+
success: a,
|
|
950
1030
|
errors: i,
|
|
951
|
-
data:
|
|
1031
|
+
data: t
|
|
952
1032
|
};
|
|
953
1033
|
}
|
|
954
1034
|
return {
|
|
955
1035
|
success: !0,
|
|
956
|
-
data:
|
|
1036
|
+
data: t
|
|
957
1037
|
};
|
|
958
1038
|
});
|
|
959
|
-
})(),
|
|
1039
|
+
})(), fe = {
|
|
960
1040
|
"sys.appaccess.error.no_grant": "NO_GRANT",
|
|
961
1041
|
"sys.appaccess.error.provider_not_installed": "PROVIDER_NOT_INSTALLED",
|
|
962
1042
|
"sys.appaccess.error.unknown_app": "UNKNOWN_APP",
|
|
@@ -965,21 +1045,21 @@ const F = (() => {
|
|
|
965
1045
|
"wamp.error.authentication_failed": "NOT_AUTHORIZED"
|
|
966
1046
|
};
|
|
967
1047
|
class p extends Error {
|
|
968
|
-
constructor(
|
|
969
|
-
super(
|
|
1048
|
+
constructor(r, e) {
|
|
1049
|
+
super(e ?? r), this.name = "CrossAppAccessError", this.code = r;
|
|
970
1050
|
}
|
|
971
1051
|
}
|
|
972
|
-
function
|
|
973
|
-
const
|
|
974
|
-
if (typeof
|
|
975
|
-
const
|
|
976
|
-
if (!
|
|
977
|
-
const
|
|
978
|
-
return new p(
|
|
1052
|
+
function N(y) {
|
|
1053
|
+
const r = y == null ? void 0 : y.error;
|
|
1054
|
+
if (typeof r != "string") return null;
|
|
1055
|
+
const e = fe[r];
|
|
1056
|
+
if (!e) return null;
|
|
1057
|
+
const n = y.args, l = Array.isArray(n) && n.length > 0 ? `: ${JSON.stringify(n[0])}` : "";
|
|
1058
|
+
return new p(e, `${r}${l}`);
|
|
979
1059
|
}
|
|
980
|
-
class
|
|
981
|
-
constructor(
|
|
982
|
-
this.app =
|
|
1060
|
+
class he {
|
|
1061
|
+
constructor(r, e, n, l, i) {
|
|
1062
|
+
this.app = r, this.stage = e, this.tables = n.tables ?? [], this.transforms = n.transforms ?? [], this._connection = l, this._onClosed = i;
|
|
983
1063
|
}
|
|
984
1064
|
get connection() {
|
|
985
1065
|
return this._connection;
|
|
@@ -990,13 +1070,13 @@ class ce {
|
|
|
990
1070
|
// DX guard: names outside the shared catalog are either private or don't
|
|
991
1071
|
// exist — fail fast client-side instead of silently receiving nothing
|
|
992
1072
|
// (private publishes are filtered via exclude_authrole, not errors).
|
|
993
|
-
assertInCatalog(
|
|
994
|
-
if (!
|
|
995
|
-
const
|
|
996
|
-
if (!
|
|
1073
|
+
assertInCatalog(r) {
|
|
1074
|
+
if (!r) throw new Error("Tablename must not be empty!");
|
|
1075
|
+
const e = [...this.tables, ...this.transforms].map((n) => n.tablename);
|
|
1076
|
+
if (!e.includes(r))
|
|
997
1077
|
throw new p(
|
|
998
1078
|
"PRIVATE_TABLE",
|
|
999
|
-
`'${
|
|
1079
|
+
`'${r}' is not shared by app '${this.app}' (${this.stage}). Available tables/transforms: ${e.length > 0 ? e.join(", ") : "none"}`
|
|
1000
1080
|
);
|
|
1001
1081
|
}
|
|
1002
1082
|
/**
|
|
@@ -1004,84 +1084,102 @@ class ce {
|
|
|
1004
1084
|
* (`transformed.bulk.{t}`) are unrolled row-by-row through the same handler,
|
|
1005
1085
|
* so caller code always sees the single-row shape.
|
|
1006
1086
|
*/
|
|
1007
|
-
async subscribeToTable(
|
|
1008
|
-
this.assertInCatalog(
|
|
1009
|
-
const l = await this._connection.subscribe(`transformed.${
|
|
1010
|
-
const
|
|
1011
|
-
for (const
|
|
1012
|
-
|
|
1087
|
+
async subscribeToTable(r, e, n) {
|
|
1088
|
+
this.assertInCatalog(r);
|
|
1089
|
+
const l = await this._connection.subscribe(`transformed.${r}`, e), i = (u, t, a) => {
|
|
1090
|
+
const s = Array.isArray(u) ? u[0] : u, o = Array.isArray(s) ? s : s == null ? [] : [s];
|
|
1091
|
+
for (const f of o)
|
|
1092
|
+
e([f], t, a);
|
|
1013
1093
|
};
|
|
1014
|
-
return await this._connection.subscribe(`transformed.bulk.${
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1094
|
+
return await this._connection.subscribe(`transformed.bulk.${r}`, i), l;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Queries history rows of a shared table or transform. To read the CURRENT
|
|
1098
|
+
* value(s), add the `latest` marker to the filters:
|
|
1099
|
+
* `{ filterAnd: [{ latest: true }], limit: 100 }` — the provider's data
|
|
1100
|
+
* backend derives the latest row per entity in SQL (the physical
|
|
1101
|
+
* `latest_flag` column no longer exists).
|
|
1102
|
+
*/
|
|
1103
|
+
async getHistory(r, e = { limit: 10 }) {
|
|
1104
|
+
this.assertInCatalog(r), e.offset == null && (e.offset = 0);
|
|
1105
|
+
const n = H(e);
|
|
1106
|
+
if (!n.success)
|
|
1107
|
+
throw new Error(`Invalid query parameters: ${n.errors.map((l) => l.path + ": " + l.expected).join(", ")}`);
|
|
1022
1108
|
try {
|
|
1023
|
-
return await this._connection.call(`history.transformed.${
|
|
1109
|
+
return await this._connection.call(`history.transformed.${r}`, [e]);
|
|
1024
1110
|
} catch (l) {
|
|
1025
|
-
throw
|
|
1111
|
+
throw N(l) ?? l;
|
|
1026
1112
|
}
|
|
1027
1113
|
}
|
|
1028
|
-
/**
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1114
|
+
/**
|
|
1115
|
+
* Queries down-sampled series history of a shared table (tables only — no
|
|
1116
|
+
* series RPC exists for transforms). Series queries do not support the
|
|
1117
|
+
* `latest` marker; use {@link getHistory} with
|
|
1118
|
+
* `filterAnd: [{ latest: true }]` to read current values.
|
|
1119
|
+
*/
|
|
1120
|
+
async getSeriesHistory(r, e) {
|
|
1121
|
+
if (!r) throw new Error("Tablename must not be empty!");
|
|
1122
|
+
Y(e);
|
|
1123
|
+
const n = this.tables.map((i) => i.tablename);
|
|
1124
|
+
if (!n.includes(r))
|
|
1125
|
+
throw this.transforms.some((i) => i.tablename === r) ? new p(
|
|
1034
1126
|
"PRIVATE_TABLE",
|
|
1035
|
-
`'${
|
|
1127
|
+
`'${r}' is a transform of app '${this.app}' (${this.stage}); series history is available for tables only — use getHistory() instead.`
|
|
1036
1128
|
) : new p(
|
|
1037
1129
|
"PRIVATE_TABLE",
|
|
1038
|
-
`'${
|
|
1130
|
+
`'${r}' is not a shared table of app '${this.app}' (${this.stage}). Available tables: ${n.length > 0 ? n.join(", ") : "none"}`
|
|
1039
1131
|
);
|
|
1040
|
-
const l =
|
|
1132
|
+
const l = Q(e);
|
|
1041
1133
|
if (!l.success)
|
|
1042
1134
|
throw new Error(`Invalid series query parameters: ${l.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
1043
1135
|
try {
|
|
1044
|
-
return await this._connection.call(`history.transformed.series.${
|
|
1136
|
+
return await this._connection.call(`history.transformed.series.${r}`, [e]);
|
|
1045
1137
|
} catch (i) {
|
|
1046
|
-
throw
|
|
1138
|
+
throw N(i) ?? i;
|
|
1047
1139
|
}
|
|
1048
1140
|
}
|
|
1049
1141
|
/** Closes the underlying connection to the provider's realm. */
|
|
1050
1142
|
async close() {
|
|
1051
|
-
var
|
|
1052
|
-
this._connection.stop(), (
|
|
1143
|
+
var r;
|
|
1144
|
+
this._connection.stop(), (r = this._onClosed) == null || r.call(this), this._onClosed = void 0;
|
|
1053
1145
|
}
|
|
1054
1146
|
}
|
|
1055
|
-
const
|
|
1056
|
-
function
|
|
1057
|
-
var
|
|
1058
|
-
return typeof process < "u" ? (
|
|
1147
|
+
const F = "error-logs";
|
|
1148
|
+
function b(y) {
|
|
1149
|
+
var r;
|
|
1150
|
+
return typeof process < "u" ? (r = process.env) == null ? void 0 : r[y] : void 0;
|
|
1059
1151
|
}
|
|
1060
|
-
function
|
|
1061
|
-
var
|
|
1152
|
+
function V(y) {
|
|
1153
|
+
var r;
|
|
1062
1154
|
if (typeof process < "u")
|
|
1063
1155
|
try {
|
|
1064
|
-
const
|
|
1065
|
-
if (
|
|
1066
|
-
const
|
|
1156
|
+
const e = (r = process.getBuiltinModule) == null ? void 0 : r.call(process, "node:fs");
|
|
1157
|
+
if (e) {
|
|
1158
|
+
const n = b("IRONFLOCK_ENV_DIR") ?? "/data/env", l = e.readFileSync(`${n}/${y}.txt`, "utf8").trim();
|
|
1067
1159
|
if (l) return l;
|
|
1068
1160
|
}
|
|
1069
1161
|
} catch {
|
|
1070
1162
|
}
|
|
1071
|
-
return
|
|
1163
|
+
return b(y);
|
|
1072
1164
|
}
|
|
1073
|
-
function
|
|
1074
|
-
const
|
|
1075
|
-
if (!
|
|
1165
|
+
function ye(y) {
|
|
1166
|
+
const r = y ?? b("DEVICE_SERIAL_NUMBER");
|
|
1167
|
+
if (!r)
|
|
1076
1168
|
throw new Error("serialNumber option is required (or set DEVICE_SERIAL_NUMBER env var in Node.js)");
|
|
1077
|
-
return
|
|
1169
|
+
return r;
|
|
1170
|
+
}
|
|
1171
|
+
function W(y, r, e) {
|
|
1172
|
+
const n = e == null ? void 0 : e.error, l = e instanceof Error ? e.message : String(e);
|
|
1173
|
+
return typeof n == "string" && n.includes("no_such_procedure") || l.includes("no_such_procedure") || l.includes("no callee registered") ? new Error(
|
|
1174
|
+
`${y} failed: history procedure '${r}' is not registered. Check that the table is declared in the app's data-template and that the app's data backend is running.`
|
|
1175
|
+
) : e instanceof Error ? e : new Error(`${y} failed: ${l}`);
|
|
1078
1176
|
}
|
|
1079
|
-
class
|
|
1080
|
-
constructor(
|
|
1081
|
-
this._isConfigured = !1, this._consumedApps = /* @__PURE__ */ new Map(), this._serialNumber =
|
|
1082
|
-
const
|
|
1083
|
-
this._deviceKey ||
|
|
1084
|
-
`Warning: The following environment variables must be present: ${
|
|
1177
|
+
class J {
|
|
1178
|
+
constructor(r) {
|
|
1179
|
+
this._isConfigured = !1, this._consumedApps = /* @__PURE__ */ new Map(), this._serialNumber = ye(r == null ? void 0 : r.serialNumber), this._deviceName = (r == null ? void 0 : r.deviceName) ?? b("DEVICE_NAME"), this._deviceKey = (r == null ? void 0 : r.deviceKey) ?? b("DEVICE_KEY"), this._appName = (r == null ? void 0 : r.appName) ?? b("APP_NAME"), this._swarmKey = (r == null ? void 0 : r.swarmKey) ?? parseInt(b("SWARM_KEY") ?? "0", 10), this._appKey = (r == null ? void 0 : r.appKey) ?? parseInt(b("APP_KEY") ?? "0", 10), this._env = (r == null ? void 0 : r.env) ?? b("ENV"), this._reswarmUrl = (r == null ? void 0 : r.reswarmUrl) ?? b("RESWARM_URL"), this._cburl = (r == null ? void 0 : r.ironFlockUrl) ?? (r == null ? void 0 : r.cburl), this._connection = new $();
|
|
1180
|
+
const e = [];
|
|
1181
|
+
this._deviceKey || e.push("DEVICE_KEY"), this._appName || e.push("APP_NAME"), this._swarmKey || e.push("SWARM_KEY"), this._appKey || e.push("APP_KEY"), e.length > 0 && console.warn(
|
|
1182
|
+
`Warning: The following environment variables must be present: ${e.join(", ")}`
|
|
1085
1183
|
);
|
|
1086
1184
|
}
|
|
1087
1185
|
get connection() {
|
|
@@ -1090,12 +1188,12 @@ class W {
|
|
|
1090
1188
|
get isConnected() {
|
|
1091
1189
|
return this._connection.is_open;
|
|
1092
1190
|
}
|
|
1093
|
-
configureConnection(
|
|
1191
|
+
configureConnection(r) {
|
|
1094
1192
|
if (this._isConfigured) return;
|
|
1095
|
-
const
|
|
1096
|
-
DEV:
|
|
1097
|
-
PROD:
|
|
1098
|
-
}[
|
|
1193
|
+
const e = (this._env ?? "DEV").toUpperCase(), l = {
|
|
1194
|
+
DEV: _.DEVELOPMENT,
|
|
1195
|
+
PROD: _.PRODUCTION
|
|
1196
|
+
}[e] ?? _.DEVELOPMENT, i = r ?? this._cburl ?? $.getWebSocketURI(this._reswarmUrl);
|
|
1099
1197
|
this._connection.configure(
|
|
1100
1198
|
this._swarmKey,
|
|
1101
1199
|
this._appKey,
|
|
@@ -1104,13 +1202,13 @@ class W {
|
|
|
1104
1202
|
i
|
|
1105
1203
|
), this._isConfigured = !0;
|
|
1106
1204
|
}
|
|
1107
|
-
async start(
|
|
1108
|
-
this.configureConnection(
|
|
1205
|
+
async start(r) {
|
|
1206
|
+
this.configureConnection(r), await this._connection.start();
|
|
1109
1207
|
}
|
|
1110
1208
|
async stop() {
|
|
1111
|
-
const
|
|
1209
|
+
const r = [...this._consumedApps.values()];
|
|
1112
1210
|
this._consumedApps.clear(), await Promise.all(
|
|
1113
|
-
|
|
1211
|
+
r.map((e) => e.then((n) => n.close()).catch(() => {
|
|
1114
1212
|
}))
|
|
1115
1213
|
), this._connection.stop();
|
|
1116
1214
|
}
|
|
@@ -1127,15 +1225,15 @@ class W {
|
|
|
1127
1225
|
* @throws {CrossAppAccessError} NO_GRANT | PROVIDER_NOT_INSTALLED |
|
|
1128
1226
|
* UNKNOWN_APP | NOT_AUTHORIZED
|
|
1129
1227
|
*/
|
|
1130
|
-
async connectToApp(
|
|
1131
|
-
if (!
|
|
1132
|
-
const
|
|
1228
|
+
async connectToApp(r, e) {
|
|
1229
|
+
if (!r) throw new Error("appName must not be empty!");
|
|
1230
|
+
const n = (this._env ?? "DEV").toUpperCase() === "PROD" ? "prod" : "dev", l = (e == null ? void 0 : e.stage) ?? n, i = `${r.toLowerCase()}:${l}`, u = this._consumedApps.get(i);
|
|
1133
1231
|
if (u) return u;
|
|
1134
|
-
let
|
|
1135
|
-
const
|
|
1136
|
-
this._consumedApps.get(i) ===
|
|
1232
|
+
let t;
|
|
1233
|
+
const a = () => {
|
|
1234
|
+
this._consumedApps.get(i) === t && this._consumedApps.delete(i);
|
|
1137
1235
|
};
|
|
1138
|
-
return
|
|
1236
|
+
return t = this.openConsumedApp(r, l, a, e == null ? void 0 : e.onError), this._consumedApps.set(i, t), t.catch(a), t;
|
|
1139
1237
|
}
|
|
1140
1238
|
/**
|
|
1141
1239
|
* Lists every non-private provider catalog in this project for an app holding
|
|
@@ -1153,8 +1251,8 @@ class W {
|
|
|
1153
1251
|
"sys.appaccess.list",
|
|
1154
1252
|
[]
|
|
1155
1253
|
) ?? [];
|
|
1156
|
-
} catch (
|
|
1157
|
-
throw
|
|
1254
|
+
} catch (r) {
|
|
1255
|
+
throw N(r) ?? r;
|
|
1158
1256
|
}
|
|
1159
1257
|
}
|
|
1160
1258
|
/**
|
|
@@ -1167,47 +1265,47 @@ class W {
|
|
|
1167
1265
|
*
|
|
1168
1266
|
* @throws {CrossAppAccessError} NO_GRANT when this app holds no wildcard grant.
|
|
1169
1267
|
*/
|
|
1170
|
-
async connectToAllApps(
|
|
1171
|
-
var
|
|
1172
|
-
const
|
|
1173
|
-
for (const
|
|
1174
|
-
(
|
|
1175
|
-
const
|
|
1176
|
-
for (const
|
|
1177
|
-
if (
|
|
1178
|
-
|
|
1268
|
+
async connectToAllApps(r) {
|
|
1269
|
+
var s, o;
|
|
1270
|
+
const e = (this._env ?? "DEV").toUpperCase() === "PROD" ? "prod" : "dev", n = (r == null ? void 0 : r.stage) ?? e, l = (r == null ? void 0 : r.continueOnError) ?? !0, i = await this.listConsumableApps(), u = [];
|
|
1271
|
+
for (const f of i)
|
|
1272
|
+
(s = f.stages) != null && s[n] && u.push(this.openCachedFromInfo(f, n, r == null ? void 0 : r.onError));
|
|
1273
|
+
const t = await Promise.allSettled(u), a = [];
|
|
1274
|
+
for (const f of t)
|
|
1275
|
+
if (f.status === "fulfilled")
|
|
1276
|
+
a.push(f.value);
|
|
1179
1277
|
else if (l)
|
|
1180
|
-
(
|
|
1278
|
+
(o = r == null ? void 0 : r.onError) == null || o.call(r, f.reason);
|
|
1181
1279
|
else
|
|
1182
|
-
throw
|
|
1183
|
-
return
|
|
1280
|
+
throw f.reason;
|
|
1281
|
+
return a;
|
|
1184
1282
|
}
|
|
1185
|
-
async openConsumedApp(
|
|
1283
|
+
async openConsumedApp(r, e, n, l) {
|
|
1186
1284
|
let i;
|
|
1187
1285
|
try {
|
|
1188
1286
|
i = await this._connection.call("sys.appaccess.resolve", [
|
|
1189
|
-
{ app:
|
|
1287
|
+
{ app: r }
|
|
1190
1288
|
]);
|
|
1191
1289
|
} catch (u) {
|
|
1192
|
-
throw
|
|
1290
|
+
throw N(u) ?? u;
|
|
1193
1291
|
}
|
|
1194
1292
|
if (!i)
|
|
1195
1293
|
throw new p(
|
|
1196
1294
|
"PROVIDER_NOT_INSTALLED",
|
|
1197
|
-
`App '${
|
|
1295
|
+
`App '${r}' has no ${e} data backend in this project`
|
|
1198
1296
|
);
|
|
1199
|
-
return this.openFromInfo(i,
|
|
1297
|
+
return this.openFromInfo(i, e, n, l);
|
|
1200
1298
|
}
|
|
1201
1299
|
/** Caches (or reuses) a connection opened directly from a resolved provider
|
|
1202
1300
|
* info, using the same `${app}:${stage}` key as {@link connectToApp}. */
|
|
1203
|
-
openCachedFromInfo(
|
|
1204
|
-
const l = `${
|
|
1301
|
+
openCachedFromInfo(r, e, n) {
|
|
1302
|
+
const l = `${r.app}:${e}`, i = this._consumedApps.get(l);
|
|
1205
1303
|
if (i) return i;
|
|
1206
1304
|
let u;
|
|
1207
|
-
const
|
|
1305
|
+
const t = () => {
|
|
1208
1306
|
this._consumedApps.get(l) === u && this._consumedApps.delete(l);
|
|
1209
1307
|
};
|
|
1210
|
-
return u = this.openFromInfo(
|
|
1308
|
+
return u = this.openFromInfo(r, e, t, n), this._consumedApps.set(l, u), u.catch(t), u;
|
|
1211
1309
|
}
|
|
1212
1310
|
/**
|
|
1213
1311
|
* Opens the second CrossbarConnection to a provider realm from an already
|
|
@@ -1215,58 +1313,58 @@ class W {
|
|
|
1215
1313
|
* round-trip. Shared by {@link connectToApp} (which resolves one provider) and
|
|
1216
1314
|
* {@link connectToAllApps} (which lists every provider in one call).
|
|
1217
1315
|
*/
|
|
1218
|
-
async openFromInfo(
|
|
1219
|
-
var
|
|
1220
|
-
const i =
|
|
1316
|
+
async openFromInfo(r, e, n, l) {
|
|
1317
|
+
var o;
|
|
1318
|
+
const i = r.app, u = (o = r.stages) == null ? void 0 : o[e];
|
|
1221
1319
|
if (!u)
|
|
1222
1320
|
throw new p(
|
|
1223
1321
|
"PROVIDER_NOT_INSTALLED",
|
|
1224
|
-
`App '${i}' has no ${
|
|
1322
|
+
`App '${i}' has no ${e} data backend in this project`
|
|
1225
1323
|
);
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1324
|
+
const t = new $();
|
|
1325
|
+
t.failOnAuthError = !0, t.configure(
|
|
1228
1326
|
this._swarmKey,
|
|
1229
|
-
|
|
1230
|
-
|
|
1327
|
+
r.provider_app_key,
|
|
1328
|
+
e === "prod" ? _.PRODUCTION : _.DEVELOPMENT,
|
|
1231
1329
|
this._serialNumber,
|
|
1232
1330
|
// Reuse the own connection's resolved socket URI (set once start() ran).
|
|
1233
1331
|
this._connection.socketURI ?? this._cburl ?? $.getWebSocketURI(this._reswarmUrl)
|
|
1234
1332
|
);
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1237
|
-
|
|
1333
|
+
let a = !1, s;
|
|
1334
|
+
t.on("auth_failure", (f) => {
|
|
1335
|
+
s = new p(
|
|
1238
1336
|
"NOT_AUTHORIZED",
|
|
1239
|
-
`Access to app '${i}' (${
|
|
1240
|
-
),
|
|
1337
|
+
`Access to app '${i}' (${e}) denied: ${f}. The grant may have been revoked.`
|
|
1338
|
+
), n(), a && (l == null || l(s));
|
|
1241
1339
|
});
|
|
1242
1340
|
try {
|
|
1243
|
-
await
|
|
1244
|
-
} catch (
|
|
1245
|
-
throw
|
|
1341
|
+
await t.start();
|
|
1342
|
+
} catch (f) {
|
|
1343
|
+
throw s ?? f;
|
|
1246
1344
|
}
|
|
1247
|
-
return
|
|
1345
|
+
return a = !0, new he(i, e, u, t, n);
|
|
1248
1346
|
}
|
|
1249
|
-
async publish(
|
|
1250
|
-
const l =
|
|
1347
|
+
async publish(r, e, n) {
|
|
1348
|
+
const l = de({ topic: r, args: e, kwargs: n });
|
|
1251
1349
|
if (!l.success)
|
|
1252
|
-
throw new Error(`Invalid publish parameters: ${l.errors.map((
|
|
1350
|
+
throw new Error(`Invalid publish parameters: ${l.errors.map((t) => t.path + ": " + t.expected).join(", ")}`);
|
|
1253
1351
|
const u = { ...{
|
|
1254
1352
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
1255
1353
|
DEVICE_KEY: this._deviceKey,
|
|
1256
1354
|
DEVICE_NAME: this._deviceName
|
|
1257
|
-
}, ...
|
|
1258
|
-
return this._connection.publish(
|
|
1355
|
+
}, ...n ?? {} };
|
|
1356
|
+
return this._connection.publish(r, e, u, {
|
|
1259
1357
|
acknowledge: !0
|
|
1260
1358
|
});
|
|
1261
1359
|
}
|
|
1262
|
-
async publishToTable(
|
|
1263
|
-
const l =
|
|
1360
|
+
async publishToTable(r, e, n) {
|
|
1361
|
+
const l = j({ tablename: r, args: e, kwargs: n });
|
|
1264
1362
|
if (!l.success)
|
|
1265
1363
|
throw new Error(`Invalid table parameters: ${l.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
|
|
1266
1364
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
1267
1365
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
1268
|
-
const i = `${this._swarmKey}.${this._appKey}.${
|
|
1269
|
-
return this.publish(i,
|
|
1366
|
+
const i = `${this._swarmKey}.${this._appKey}.${r}`;
|
|
1367
|
+
return this.publish(i, e, n);
|
|
1270
1368
|
}
|
|
1271
1369
|
/**
|
|
1272
1370
|
* Reports an application error into the databackend's `error-logs` table.
|
|
@@ -1282,27 +1380,27 @@ class W {
|
|
|
1282
1380
|
* @param error An error message, or an Error whose stack/message is recorded.
|
|
1283
1381
|
* @param opts Optional level (default "error"), append flag, and tsp override.
|
|
1284
1382
|
*/
|
|
1285
|
-
async reportError(
|
|
1286
|
-
const
|
|
1287
|
-
tsp: (
|
|
1288
|
-
msg:
|
|
1383
|
+
async reportError(r, e) {
|
|
1384
|
+
const n = r instanceof Error ? r.stack ?? r.message : r, l = {
|
|
1385
|
+
tsp: (e == null ? void 0 : e.tsp) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1386
|
+
msg: n,
|
|
1289
1387
|
source: "app",
|
|
1290
|
-
level: (
|
|
1388
|
+
level: (e == null ? void 0 : e.level) ?? "error"
|
|
1291
1389
|
};
|
|
1292
|
-
return
|
|
1390
|
+
return e != null && e.append ? this.appendToTable(F, [l]) : this.publishToTable(F, [l]);
|
|
1293
1391
|
}
|
|
1294
|
-
async appendToTable(
|
|
1295
|
-
const l =
|
|
1392
|
+
async appendToTable(r, e, n) {
|
|
1393
|
+
const l = j({ tablename: r, args: e, kwargs: n });
|
|
1296
1394
|
if (!l.success)
|
|
1297
|
-
throw new Error(`Invalid table parameters: ${l.errors.map((
|
|
1395
|
+
throw new Error(`Invalid table parameters: ${l.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
|
|
1298
1396
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
1299
1397
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
1300
|
-
const i = `append.${this._swarmKey}.${this._appKey}.${
|
|
1398
|
+
const i = `append.${this._swarmKey}.${this._appKey}.${r}`, t = { ...{
|
|
1301
1399
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
1302
1400
|
DEVICE_KEY: this._deviceKey,
|
|
1303
1401
|
DEVICE_NAME: this._deviceName
|
|
1304
|
-
}, ...
|
|
1305
|
-
return this._connection.call(i,
|
|
1402
|
+
}, ...n ?? {} };
|
|
1403
|
+
return this._connection.call(i, e, t);
|
|
1306
1404
|
}
|
|
1307
1405
|
/**
|
|
1308
1406
|
* Publishes many rows in a single message (bulk insert) to the dedicated topic
|
|
@@ -1312,14 +1410,14 @@ class W {
|
|
|
1312
1410
|
* confirms delivery to the router, not the DB insert. Use appendRowsToTable when
|
|
1313
1411
|
* you need the insert outcome.
|
|
1314
1412
|
*/
|
|
1315
|
-
async publishRowsToTable(
|
|
1316
|
-
const l =
|
|
1413
|
+
async publishRowsToTable(r, e, n) {
|
|
1414
|
+
const l = x({ tablename: r, rows: e, kwargs: n });
|
|
1317
1415
|
if (!l.success)
|
|
1318
1416
|
throw new Error(`Invalid bulk table parameters: ${l.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
|
|
1319
1417
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
1320
1418
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
1321
|
-
const i = `bulk.${this._swarmKey}.${this._appKey}.${
|
|
1322
|
-
return this.publish(i, [
|
|
1419
|
+
const i = `bulk.${this._swarmKey}.${this._appKey}.${r}`;
|
|
1420
|
+
return this.publish(i, [e], n);
|
|
1323
1421
|
}
|
|
1324
1422
|
/**
|
|
1325
1423
|
* Appends many rows in a single RPC (bulk insert) by calling the dedicated
|
|
@@ -1329,104 +1427,124 @@ class W {
|
|
|
1329
1427
|
* (e.g. { success: true, count: N }). Prefer over publishRowsToTable when you
|
|
1330
1428
|
* need the insert outcome.
|
|
1331
1429
|
*/
|
|
1332
|
-
async appendRowsToTable(
|
|
1333
|
-
const l =
|
|
1430
|
+
async appendRowsToTable(r, e, n) {
|
|
1431
|
+
const l = x({ tablename: r, rows: e, kwargs: n });
|
|
1334
1432
|
if (!l.success)
|
|
1335
|
-
throw new Error(`Invalid bulk table parameters: ${l.errors.map((
|
|
1433
|
+
throw new Error(`Invalid bulk table parameters: ${l.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
|
|
1336
1434
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
1337
1435
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
1338
|
-
const i = `appendBulk.${this._swarmKey}.${this._appKey}.${
|
|
1436
|
+
const i = `appendBulk.${this._swarmKey}.${this._appKey}.${r}`, t = { ...{
|
|
1339
1437
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
1340
1438
|
DEVICE_KEY: this._deviceKey,
|
|
1341
1439
|
DEVICE_NAME: this._deviceName
|
|
1342
|
-
}, ...
|
|
1343
|
-
return this._connection.call(i, [
|
|
1440
|
+
}, ...n ?? {} };
|
|
1441
|
+
return this._connection.call(i, [e], t);
|
|
1344
1442
|
}
|
|
1345
|
-
async subscribe(
|
|
1346
|
-
return this._connection.subscribe(
|
|
1443
|
+
async subscribe(r, e, n) {
|
|
1444
|
+
return this._connection.subscribe(r, e);
|
|
1347
1445
|
}
|
|
1348
|
-
async subscribeToTable(
|
|
1446
|
+
async subscribeToTable(r, e, n) {
|
|
1349
1447
|
if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
|
|
1350
1448
|
if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
|
|
1351
|
-
const l = `transformed.${
|
|
1352
|
-
const
|
|
1353
|
-
for (const d of
|
|
1354
|
-
|
|
1449
|
+
const l = `transformed.${r}`, i = await this.subscribe(l, e, n), u = (t, a, s) => {
|
|
1450
|
+
const o = Array.isArray(t) ? t[0] : t, f = Array.isArray(o) ? o : o == null ? [] : [o];
|
|
1451
|
+
for (const d of f)
|
|
1452
|
+
e([d], a, s);
|
|
1355
1453
|
};
|
|
1356
|
-
return await this.subscribe(`transformed.bulk.${
|
|
1454
|
+
return await this.subscribe(`transformed.bulk.${r}`, u, n), i;
|
|
1357
1455
|
}
|
|
1358
|
-
async call(
|
|
1359
|
-
return this._connection.call(
|
|
1456
|
+
async call(r, e, n, l) {
|
|
1457
|
+
return this._connection.call(r, e, n, l);
|
|
1360
1458
|
}
|
|
1361
|
-
async callDeviceFunction(
|
|
1362
|
-
const u = `${this._swarmKey}.${
|
|
1363
|
-
return this._connection.call(u,
|
|
1459
|
+
async callDeviceFunction(r, e, n, l, i) {
|
|
1460
|
+
const u = `${this._swarmKey}.${r}.${this._appKey}.${this._env}.${e}`;
|
|
1461
|
+
return this._connection.call(u, n, l, i);
|
|
1364
1462
|
}
|
|
1365
1463
|
/** @deprecated Use callDeviceFunction() instead. */
|
|
1366
|
-
async callFunction(
|
|
1367
|
-
return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(
|
|
1464
|
+
async callFunction(r, e, n, l, i) {
|
|
1465
|
+
return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(r, e, n, l, i);
|
|
1368
1466
|
}
|
|
1369
|
-
async registerDeviceFunction(
|
|
1370
|
-
const l = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${
|
|
1371
|
-
return console.log(`Function registered for IronFlock topic '${
|
|
1467
|
+
async registerDeviceFunction(r, e, n) {
|
|
1468
|
+
const l = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${r}`, i = await this._connection.register(l, e, n);
|
|
1469
|
+
return console.log(`Function registered for IronFlock topic '${r}'. (Full WAMP topic: '${l}')`), i;
|
|
1372
1470
|
}
|
|
1373
1471
|
/** @deprecated Use registerDeviceFunction() instead. */
|
|
1374
|
-
async registerFunction(
|
|
1375
|
-
return console.warn("registerFunction() is deprecated and will be removed in a future version. Use registerDeviceFunction() instead."), this.registerDeviceFunction(
|
|
1376
|
-
}
|
|
1377
|
-
async register(
|
|
1378
|
-
return this.registerDeviceFunction(
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1472
|
+
async registerFunction(r, e, n) {
|
|
1473
|
+
return console.warn("registerFunction() is deprecated and will be removed in a future version. Use registerDeviceFunction() instead."), this.registerDeviceFunction(r, e, n);
|
|
1474
|
+
}
|
|
1475
|
+
async register(r, e, n) {
|
|
1476
|
+
return this.registerDeviceFunction(r, e, n);
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Queries history rows of an own table or transform via
|
|
1480
|
+
* `history.transformed.{tablename}`.
|
|
1481
|
+
*
|
|
1482
|
+
* To read the CURRENT value(s) instead of raw history, add the `latest`
|
|
1483
|
+
* marker to `filterAnd`: `{ filterAnd: [{ latest: true }], limit: 100 }`.
|
|
1484
|
+
* The data backend then derives the latest row per entity in SQL (the
|
|
1485
|
+
* entity key is the table's `maintainLatestFlagFor` columns; without one,
|
|
1486
|
+
* the single most recent row is returned). The former physical
|
|
1487
|
+
* `latest_flag` column no longer exists.
|
|
1488
|
+
*
|
|
1489
|
+
* @throws {Error} on invalid parameters, when the history procedure is not
|
|
1490
|
+
* registered (table missing / data backend down), or when the call fails.
|
|
1491
|
+
*/
|
|
1492
|
+
async getHistory(r, e = { limit: 10 }) {
|
|
1493
|
+
if (!r) throw new Error("Tablename must not be empty!");
|
|
1494
|
+
e.offset == null && (e.offset = 0);
|
|
1495
|
+
const n = H(e);
|
|
1496
|
+
if (!n.success)
|
|
1497
|
+
throw new Error(`Invalid query parameters: ${n.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
1498
|
+
const l = `history.transformed.${r}`;
|
|
1387
1499
|
try {
|
|
1388
|
-
return await this._connection.call(l, [
|
|
1500
|
+
return await this._connection.call(l, [e]);
|
|
1389
1501
|
} catch (i) {
|
|
1390
|
-
|
|
1391
|
-
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);
|
|
1502
|
+
throw W(`getHistory('${r}')`, l, i);
|
|
1392
1503
|
}
|
|
1393
1504
|
}
|
|
1394
1505
|
/**
|
|
1395
1506
|
* Queries down-sampled series history of an own table by calling
|
|
1396
1507
|
* `history.transformed.series.{tablename}` (tables only — no series RPC
|
|
1397
|
-
* exists for transforms).
|
|
1508
|
+
* exists for transforms). Series queries do not support the `latest`
|
|
1509
|
+
* marker; use {@link getHistory} with `filterAnd: [{ latest: true }]` to
|
|
1510
|
+
* read current values.
|
|
1511
|
+
*
|
|
1512
|
+
* @throws {Error} on invalid parameters, when the series procedure is not
|
|
1513
|
+
* registered (table missing / data backend down), or when the call fails.
|
|
1398
1514
|
*/
|
|
1399
|
-
async getSeriesHistory(
|
|
1400
|
-
if (!
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1515
|
+
async getSeriesHistory(r, e) {
|
|
1516
|
+
if (!r) throw new Error("Tablename must not be empty!");
|
|
1517
|
+
Y(e);
|
|
1518
|
+
const n = Q(e);
|
|
1519
|
+
if (!n.success)
|
|
1520
|
+
throw new Error(`Invalid series query parameters: ${n.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
|
|
1521
|
+
const l = `history.transformed.series.${r}`;
|
|
1405
1522
|
try {
|
|
1406
|
-
return await this._connection.call(l, [
|
|
1523
|
+
return await this._connection.call(l, [e]);
|
|
1407
1524
|
} catch (i) {
|
|
1408
|
-
|
|
1409
|
-
return u.includes("no_such_procedure") || u.includes("no callee registered") ? (console.error(`Get series history failed: History service procedure '${l}' not registered`), null) : (console.error(`Get series history failed: ${i}`), null);
|
|
1525
|
+
throw W(`getSeriesHistory('${r}')`, l, i);
|
|
1410
1526
|
}
|
|
1411
1527
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1528
|
+
/**
|
|
1529
|
+
* Updates the device's location in the platform master data.
|
|
1530
|
+
*
|
|
1531
|
+
* @throws {Error} on invalid coordinates or when the location service call
|
|
1532
|
+
* fails (e.g. not connected).
|
|
1533
|
+
*/
|
|
1534
|
+
async setDeviceLocation(r, e) {
|
|
1535
|
+
const n = ue({ longitude: r, latitude: e });
|
|
1536
|
+
if (!n.success)
|
|
1537
|
+
throw new Error(`Invalid location parameters: ${n.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
|
|
1538
|
+
const l = { long: r, lat: e }, i = {
|
|
1417
1539
|
DEVICE_SERIAL_NUMBER: this._serialNumber,
|
|
1418
1540
|
DEVICE_KEY: this._deviceKey,
|
|
1419
1541
|
DEVICE_NAME: this._deviceName
|
|
1420
1542
|
};
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
);
|
|
1427
|
-
} catch (u) {
|
|
1428
|
-
return console.error(`Set location failed: ${u}`), null;
|
|
1429
|
-
}
|
|
1543
|
+
return this._connection.call(
|
|
1544
|
+
"ironflock.location_service.update",
|
|
1545
|
+
[l],
|
|
1546
|
+
i
|
|
1547
|
+
);
|
|
1430
1548
|
}
|
|
1431
1549
|
/**
|
|
1432
1550
|
* Public URL under which a declared port (port-template.yml) is reachable
|
|
@@ -1458,30 +1576,30 @@ class W {
|
|
|
1458
1576
|
* the protocol is unknown, or the label is not a valid DNS label (longer
|
|
1459
1577
|
* than 63 characters, or a dot in the app name).
|
|
1460
1578
|
*/
|
|
1461
|
-
getRemoteAccessUrlForPort(
|
|
1462
|
-
const l =
|
|
1463
|
-
if (
|
|
1464
|
-
if (!
|
|
1579
|
+
getRemoteAccessUrlForPort(r, e = "http", n) {
|
|
1580
|
+
const l = b("INSTANCE_KEY");
|
|
1581
|
+
if (e === "tcp" || e === "udp") {
|
|
1582
|
+
if (!n)
|
|
1465
1583
|
return null;
|
|
1466
1584
|
if (l) {
|
|
1467
|
-
const
|
|
1468
|
-
if (
|
|
1469
|
-
const
|
|
1470
|
-
return `${
|
|
1585
|
+
const s = V(`${n}_CLOUD`);
|
|
1586
|
+
if (s) {
|
|
1587
|
+
const o = b("CLOUD_TUNNEL_DOMAIN") ?? "app.ironflock.com";
|
|
1588
|
+
return `${e}://${o}:${s}`;
|
|
1471
1589
|
}
|
|
1472
1590
|
}
|
|
1473
|
-
const
|
|
1474
|
-
if (!
|
|
1591
|
+
const t = V(n);
|
|
1592
|
+
if (!t)
|
|
1475
1593
|
return null;
|
|
1476
|
-
const
|
|
1477
|
-
return `${
|
|
1594
|
+
const a = b("TUNNEL_DOMAIN") ?? "app.ironflock.com";
|
|
1595
|
+
return `${e}://${a}:${t}`;
|
|
1478
1596
|
}
|
|
1479
|
-
if (
|
|
1597
|
+
if (e !== "http" && e !== "https" || !this._deviceKey || !this._appName)
|
|
1480
1598
|
return null;
|
|
1481
|
-
let i = `${this._deviceKey}-${this._appName.toLowerCase()}-${
|
|
1482
|
-
|
|
1599
|
+
let i = `${this._deviceKey}-${this._appName.toLowerCase()}-${r}`;
|
|
1600
|
+
e === "https" && (i = `secure-${i}`);
|
|
1483
1601
|
let u;
|
|
1484
|
-
return l ? (i = `i${l}-${i}`, u =
|
|
1602
|
+
return l ? (i = `i${l}-${i}`, u = b("CLOUD_TUNNEL_DOMAIN") ?? "app.ironflock.com") : u = b("TUNNEL_DOMAIN") ?? "app.ironflock.com", i.length > 63 || i.includes(".") ? null : `https://${i}.${u}`;
|
|
1485
1603
|
}
|
|
1486
1604
|
/**
|
|
1487
1605
|
* Create an IronFlock instance by fetching configuration from a server endpoint.
|
|
@@ -1493,27 +1611,29 @@ class W {
|
|
|
1493
1611
|
* await flock.start();
|
|
1494
1612
|
* ```
|
|
1495
1613
|
*/
|
|
1496
|
-
static async fromServer(
|
|
1497
|
-
const
|
|
1498
|
-
if (!
|
|
1499
|
-
throw new Error(`Failed to fetch IronFlock config from ${
|
|
1500
|
-
const
|
|
1501
|
-
return new
|
|
1614
|
+
static async fromServer(r) {
|
|
1615
|
+
const e = await fetch(r);
|
|
1616
|
+
if (!e.ok)
|
|
1617
|
+
throw new Error(`Failed to fetch IronFlock config from ${r}: ${e.status} ${e.statusText}`);
|
|
1618
|
+
const n = await e.json();
|
|
1619
|
+
return new J(n);
|
|
1502
1620
|
}
|
|
1503
1621
|
}
|
|
1504
1622
|
export {
|
|
1505
|
-
|
|
1623
|
+
he as ConsumedApp,
|
|
1506
1624
|
p as CrossAppAccessError,
|
|
1507
1625
|
$ as CrossbarConnection,
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1626
|
+
F as ERROR_LOGS_TABLE,
|
|
1627
|
+
J as IronFlock,
|
|
1628
|
+
_ as Stage,
|
|
1629
|
+
ne as WampError,
|
|
1630
|
+
Y as assertNoLatestMarker,
|
|
1631
|
+
x as validateBulkTableParams,
|
|
1632
|
+
me as validateCallParams,
|
|
1633
|
+
ue as validateLocationParams,
|
|
1634
|
+
de as validatePublishParams,
|
|
1635
|
+
Q as validateSeriesQueryParams,
|
|
1636
|
+
j as validateTableParams,
|
|
1637
|
+
H as validateTableQueryParams
|
|
1518
1638
|
};
|
|
1519
1639
|
//# sourceMappingURL=index.mjs.map
|