ironflock 1.3.3 → 1.5.2

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