ironflock 1.5.3 → 1.6.0

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