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