ironflock 1.2.6 → 1.2.9

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,142 +1,156 @@
1
- import C from "autobahn";
2
- function L(d) {
1
+ import x from "autobahn";
2
+ function D(d) {
3
3
  return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
4
4
  }
5
- var I = { exports: {} }, N;
6
- function D() {
7
- return N || (N = 1, (function(d) {
5
+ var S = { exports: {} }, O;
6
+ function j() {
7
+ return O || (O = 1, (function(d) {
8
8
  var r = Object.prototype.hasOwnProperty, s = "~";
9
9
  function o() {
10
10
  }
11
11
  Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (s = !1));
12
- function l(a, e, n) {
13
- this.fn = a, this.context = e, this.once = n || !1;
12
+ function c(i, e, n) {
13
+ this.fn = i, this.context = e, this.once = n || !1;
14
14
  }
15
- function i(a, e, n, c, f) {
15
+ function a(i, e, n, l, h) {
16
16
  if (typeof n != "function")
17
17
  throw new TypeError("The listener must be a function");
18
- var v = new l(n, c || a, f), g = s ? s + e : e;
19
- return a._events[g] ? a._events[g].fn ? a._events[g] = [a._events[g], v] : a._events[g].push(v) : (a._events[g] = v, a._eventsCount++), a;
18
+ var v = new c(n, l || i, h), g = s ? s + e : e;
19
+ return i._events[g] ? i._events[g].fn ? i._events[g] = [i._events[g], v] : i._events[g].push(v) : (i._events[g] = v, i._eventsCount++), i;
20
20
  }
21
- function u(a, e) {
22
- --a._eventsCount === 0 ? a._events = new o() : delete a._events[e];
21
+ function u(i, e) {
22
+ --i._eventsCount === 0 ? i._events = new o() : delete i._events[e];
23
23
  }
24
24
  function t() {
25
25
  this._events = new o(), this._eventsCount = 0;
26
26
  }
27
27
  t.prototype.eventNames = function() {
28
- var e = [], n, c;
28
+ var e = [], n, l;
29
29
  if (this._eventsCount === 0) return e;
30
- for (c in n = this._events)
31
- r.call(n, c) && e.push(s ? c.slice(1) : c);
30
+ for (l in n = this._events)
31
+ r.call(n, l) && e.push(s ? l.slice(1) : l);
32
32
  return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(n)) : e;
33
33
  }, t.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 f = 0, v = c.length, g = new Array(v); f < v; f++)
38
- g[f] = c[f].fn;
34
+ var n = s ? s + e : e, l = this._events[n];
35
+ if (!l) return [];
36
+ if (l.fn) return [l.fn];
37
+ for (var h = 0, v = l.length, g = new Array(v); h < v; h++)
38
+ g[h] = l[h].fn;
39
39
  return g;
40
40
  }, t.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
- }, t.prototype.emit = function(e, n, c, f, v, g) {
41
+ var n = s ? s + e : e, l = this._events[n];
42
+ return l ? l.fn ? 1 : l.length : 0;
43
+ }, t.prototype.emit = function(e, n, l, h, v, g) {
44
44
  var w = s ? s + e : e;
45
45
  if (!this._events[w]) return !1;
46
- var h = this._events[w], b = arguments.length, _, y;
47
- if (h.fn) {
48
- switch (h.once && this.removeListener(e, h.fn, void 0, !0), b) {
46
+ var f = this._events[w], b = arguments.length, _, y;
47
+ if (f.fn) {
48
+ switch (f.once && this.removeListener(e, f.fn, void 0, !0), b) {
49
49
  case 1:
50
- return h.fn.call(h.context), !0;
50
+ return f.fn.call(f.context), !0;
51
51
  case 2:
52
- return h.fn.call(h.context, n), !0;
52
+ return f.fn.call(f.context, n), !0;
53
53
  case 3:
54
- return h.fn.call(h.context, n, c), !0;
54
+ return f.fn.call(f.context, n, l), !0;
55
55
  case 4:
56
- return h.fn.call(h.context, n, c, f), !0;
56
+ return f.fn.call(f.context, n, l, h), !0;
57
57
  case 5:
58
- return h.fn.call(h.context, n, c, f, v), !0;
58
+ return f.fn.call(f.context, n, l, h, v), !0;
59
59
  case 6:
60
- return h.fn.call(h.context, n, c, f, v, g), !0;
60
+ return f.fn.call(f.context, n, l, h, v, g), !0;
61
61
  }
62
62
  for (y = 1, _ = new Array(b - 1); y < b; y++)
63
63
  _[y - 1] = arguments[y];
64
- h.fn.apply(h.context, _);
64
+ f.fn.apply(f.context, _);
65
65
  } else {
66
- var j = h.length, A;
67
- for (y = 0; y < j; y++)
68
- switch (h[y].once && this.removeListener(e, h[y].fn, void 0, !0), b) {
66
+ var P = f.length, A;
67
+ for (y = 0; y < P; y++)
68
+ switch (f[y].once && this.removeListener(e, f[y].fn, void 0, !0), b) {
69
69
  case 1:
70
- h[y].fn.call(h[y].context);
70
+ f[y].fn.call(f[y].context);
71
71
  break;
72
72
  case 2:
73
- h[y].fn.call(h[y].context, n);
73
+ f[y].fn.call(f[y].context, n);
74
74
  break;
75
75
  case 3:
76
- h[y].fn.call(h[y].context, n, c);
76
+ f[y].fn.call(f[y].context, n, l);
77
77
  break;
78
78
  case 4:
79
- h[y].fn.call(h[y].context, n, c, f);
79
+ f[y].fn.call(f[y].context, n, l, h);
80
80
  break;
81
81
  default:
82
82
  if (!_) for (A = 1, _ = new Array(b - 1); A < b; A++)
83
83
  _[A - 1] = arguments[A];
84
- h[y].fn.apply(h[y].context, _);
84
+ f[y].fn.apply(f[y].context, _);
85
85
  }
86
86
  }
87
87
  return !0;
88
- }, t.prototype.on = function(e, n, c) {
89
- return i(this, e, n, c, !1);
90
- }, t.prototype.once = function(e, n, c) {
91
- return i(this, e, n, c, !0);
92
- }, t.prototype.removeListener = function(e, n, c, f) {
88
+ }, t.prototype.on = function(e, n, l) {
89
+ return a(this, e, n, l, !1);
90
+ }, t.prototype.once = function(e, n, l) {
91
+ return a(this, e, n, l, !0);
92
+ }, t.prototype.removeListener = function(e, n, l, h) {
93
93
  var v = s ? s + e : e;
94
94
  if (!this._events[v]) return this;
95
95
  if (!n)
96
96
  return u(this, v), this;
97
97
  var g = this._events[v];
98
98
  if (g.fn)
99
- g.fn === n && (!f || g.once) && (!c || g.context === c) && u(this, v);
99
+ g.fn === n && (!h || g.once) && (!l || g.context === l) && u(this, v);
100
100
  else {
101
- for (var w = 0, h = [], b = g.length; w < b; w++)
102
- (g[w].fn !== n || f && !g[w].once || c && g[w].context !== c) && h.push(g[w]);
103
- h.length ? this._events[v] = h.length === 1 ? h[0] : h : u(this, v);
101
+ for (var w = 0, f = [], b = g.length; w < b; w++)
102
+ (g[w].fn !== n || h && !g[w].once || l && g[w].context !== l) && f.push(g[w]);
103
+ f.length ? this._events[v] = f.length === 1 ? f[0] : f : u(this, v);
104
104
  }
105
105
  return this;
106
106
  }, t.prototype.removeAllListeners = function(e) {
107
107
  var n;
108
108
  return e ? (n = s ? s + e : e, this._events[n] && u(this, n)) : (this._events = new o(), this._eventsCount = 0), this;
109
109
  }, t.prototype.off = t.prototype.removeListener, t.prototype.addListener = t.prototype.on, t.prefixed = s, t.EventEmitter = t, d.exports = t;
110
- })(I)), I.exports;
110
+ })(S)), S.exports;
111
111
  }
112
- var P = D();
113
- const U = /* @__PURE__ */ L(P), F = "wss://cbw.datapods.io/ws-ua-usr", $ = "wss://cbw.ironflock.com/ws-ua-usr", W = "wss://cbw.ironflock.dev/ws-ua-usr", V = "wss://cbw.record-evolution.com/ws-ua-usr", S = "ws://localhost:8080/ws-ua-usr", Y = {
114
- "https://studio.datapods.io": F,
115
- "https://studio.ironflock.dev": W,
116
- "https://studio.ironflock.com": $,
117
- "https://studio.record-evolution.com": V,
118
- "http://localhost:8085": S,
119
- "http://localhost:8086": S,
120
- "http://host.docker.internal:8086": S
112
+ var U = j();
113
+ const F = /* @__PURE__ */ D(U), W = "wss://cbw.datapods.io/ws-ua-usr", T = "wss://cbw.ironflock.com/ws-ua-usr", V = "wss://cbw.ironflock.dev/ws-ua-usr", Y = "wss://cbw.record-evolution.com/ws-ua-usr", $ = "ws://localhost:8080/ws-ua-usr", N = {
114
+ "https://studio.datapods.io": W,
115
+ "https://studio.ironflock.dev": V,
116
+ "https://studio.ironflock.com": T,
117
+ "https://studio.record-evolution.com": Y,
118
+ "http://localhost:8085": $,
119
+ "http://localhost:8086": $,
120
+ "http://host.docker.internal:8086": $
121
121
  }, Q = 6e3;
122
- class x extends U {
122
+ class I extends F {
123
123
  constructor() {
124
124
  super(), this.subscriptions = [], this.registrations = [], this.firstResolver = () => {
125
125
  }, this.firstRejecter = () => {
126
- };
126
+ }, this.shouldReconnect = !1, this.isReconnecting = !1, this.hasOpenedOnce = !1;
127
127
  }
128
128
  static getWebSocketURI(r) {
129
- return r ? Y[r] ?? $ : $;
129
+ var c;
130
+ const s = typeof process < "u" ? (c = process.env) == null ? void 0 : c.DEVICE_ENDPOINT_URL : void 0;
131
+ if (s)
132
+ try {
133
+ const a = new URL(s);
134
+ return a.pathname = "/ws-ua-usr", a.toString().replace(/\/$/, "");
135
+ } catch {
136
+ }
137
+ if (!r) return T;
138
+ const o = N[r];
139
+ if (o === void 0)
140
+ throw new Error(
141
+ `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(N))}`
142
+ );
143
+ return o;
130
144
  }
131
- configure(r, s, o, l, i) {
132
- this.realm = `realm-${r}-${s}-${o}`, this.serial_number = l, this.socketURI = i ?? x.getWebSocketURI();
145
+ configure(r, s, o, c, a) {
146
+ this.realm = `realm-${r}-${s}-${o}`, this.serial_number = c, this.socketURI = a ?? I.getWebSocketURI();
133
147
  }
134
148
  async start() {
135
149
  if (!this.realm || !this.serial_number || !this.socketURI)
136
150
  throw new Error("CrossbarConnection must be configured before starting. Call configure() first.");
137
- return this.firstConnection = new Promise((r, s) => {
151
+ return this.shouldReconnect = !0, this.firstConnection = new Promise((r, s) => {
138
152
  this.firstResolver = r, this.firstRejecter = s;
139
- }), this.connection = new C.Connection({
153
+ }), this.connection = new x.Connection({
140
154
  realm: this.realm,
141
155
  url: this.socketURI,
142
156
  authmethods: ["wampcra"],
@@ -147,11 +161,11 @@ class x extends U {
147
161
  // @ts-ignore
148
162
  autoping_interval: 2,
149
163
  autoping_timeout: 4,
150
- onchallenge: (r, s, o) => C.auth_cra.sign(this.serial_number, o.challenge)
164
+ onchallenge: (r, s, o) => x.auth_cra.sign(this.serial_number, o.challenge)
151
165
  }), this.connection.onopen = this.onOpen.bind(this), this.connection.onclose = this.onClose.bind(this), this.connection.open(), this.firstConnection;
152
166
  }
153
167
  onOpen(r) {
154
- this.session = r, this.session.caller_disclose_me = !0, this.resubscribeAll(), this.emit("connected", this.serial_number), this.firstResolver(), this.firstResolver = () => {
168
+ this.session = r, this.session.caller_disclose_me = !0, this.hasOpenedOnce = !0, this.resubscribeAll(), this.reregisterAll(), this.emit("connected", this.serial_number), this.firstResolver(), this.firstResolver = () => {
155
169
  };
156
170
  }
157
171
  onClose(r, s) {
@@ -166,7 +180,21 @@ class x extends U {
166
180
  realm: this.realm,
167
181
  url: this.socketURI,
168
182
  authid: this.serial_number
169
- }), !1;
183
+ }), this.shouldReconnect && this.hasOpenedOnce && (s == null ? void 0 : s.will_retry) === !1 && this.handleManualReconnect((s == null ? void 0 : s.reason) ?? r), !1;
184
+ }
185
+ async handleManualReconnect(r) {
186
+ if (!(this.isReconnecting || !this.shouldReconnect)) {
187
+ for (this.isReconnecting = !0; this.shouldReconnect && !this.session; )
188
+ if (await new Promise((s) => setTimeout(s, 1e3)), this.shouldReconnect && this.connection && !this.session) {
189
+ console.log(`Manually retrying connection after ${r}...`);
190
+ try {
191
+ this.connection.open(), await new Promise((s) => setTimeout(s, 500));
192
+ } catch (s) {
193
+ console.error("Error during manual reconnection attempt:", s);
194
+ }
195
+ }
196
+ this.isReconnecting = !1;
197
+ }
170
198
  }
171
199
  async sessionWait() {
172
200
  const r = Date.now();
@@ -191,12 +219,12 @@ class x extends U {
191
219
  }
192
220
  stop() {
193
221
  var r;
194
- (r = this.connection) == null || r.close("wamp.close.normal", "Connection closed by client");
222
+ this.shouldReconnect = !1, (r = this.connection) == null || r.close("wamp.close.normal", "Connection closed by client");
195
223
  }
196
224
  async subscribe(r, s) {
197
- var l;
225
+ var c;
198
226
  await this.sessionWait();
199
- const o = await ((l = this.session) == null ? void 0 : l.subscribe(r, s));
227
+ const o = await ((c = this.session) == null ? void 0 : c.subscribe(r, s));
200
228
  return o && this.subscriptions.push(o), o;
201
229
  }
202
230
  async unsubscribe(r) {
@@ -216,11 +244,17 @@ class x extends U {
216
244
  r.map((s) => this.subscribe(s.topic, s.handler))
217
245
  );
218
246
  }
247
+ async reregisterAll() {
248
+ const r = [...this.registrations];
249
+ this.registrations = [], await Promise.all(
250
+ r.map((s) => this.register(s.procedure, s.endpoint, s.options))
251
+ );
252
+ }
219
253
  async register(r, s, o) {
220
254
  var u;
221
255
  await this.sessionWait();
222
- const l = { force_reregister: !0, ...o ?? {} }, i = await ((u = this.session) == null ? void 0 : u.register(r, s, l));
223
- return i && this.registrations.push(i), i;
256
+ const c = { force_reregister: !0, ...o ?? {} }, a = await ((u = this.session) == null ? void 0 : u.register(r, s, c));
257
+ return a && this.registrations.push(a), a;
224
258
  }
225
259
  async unregister(r) {
226
260
  var o;
@@ -228,16 +262,16 @@ class x extends U {
228
262
  const s = this.registrations.indexOf(r);
229
263
  s !== -1 && this.registrations.splice(s, 1);
230
264
  }
231
- async call(r, s, o, l) {
232
- var i;
233
- return await this.sessionWait(), (i = this.session) == null ? void 0 : i.call(r, s, o, l);
265
+ async call(r, s, o, c) {
266
+ var a;
267
+ return await this.sessionWait(), (a = this.session) == null ? void 0 : a.call(r, s, o, c);
234
268
  }
235
- async publish(r, s, o, l) {
236
- var i;
237
- return await this.sessionWait(), (i = this.session) == null ? void 0 : i.publish(r, s, o, l);
269
+ async publish(r, s, o, c) {
270
+ var a;
271
+ return await this.sessionWait(), (a = this.session) == null ? void 0 : a.publish(r, s, o, c);
238
272
  }
239
273
  }
240
- const K = (d) => Math.floor(d) === d && B <= d && d <= J, B = 0, J = 2 ** 32 - 1, R = (d) => H.test(d), H = /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i, k = (d) => {
274
+ const R = (d) => Math.floor(d) === d && J <= d && d <= B, J = 0, B = 2 ** 32 - 1, K = (d) => H.test(d), H = /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i, p = (d) => {
241
275
  const r = (s) => {
242
276
  if (d.length === 0)
243
277
  return !0;
@@ -250,7 +284,7 @@ const K = (d) => Math.floor(d) === d && B <= d && d <= J, B = 0, J = 2 ** 32 - 1
250
284
  `Please fill the \`${o.expected}\` typed value next time.`
251
285
  ].join(`
252
286
  `))), d.push(o)), !1);
253
- }, p = (d) => Object.assign(d, {
287
+ }, k = (d) => Object.assign(d, {
254
288
  "~standard": {
255
289
  version: 1,
256
290
  vendor: "typia",
@@ -275,22 +309,22 @@ const G = (d) => {
275
309
  if (!d.startsWith("$input"))
276
310
  throw new Error(`Invalid path: ${JSON.stringify(d)}`);
277
311
  const r = [];
278
- let s = "", o = m.Start, l = 5;
279
- for (; l < d.length - 1; ) {
280
- l++;
281
- const i = d[l];
282
- if (o === m.Property ? i === "." || i === "[" ? (r.push({
312
+ let s = "", o = m.Start, c = 5;
313
+ for (; c < d.length - 1; ) {
314
+ c++;
315
+ const a = d[c];
316
+ if (o === m.Property ? a === "." || a === "[" ? (r.push({
283
317
  key: s
284
- }), o = m.Start) : l === d.length - 1 ? (s += i, r.push({
318
+ }), o = m.Start) : c === d.length - 1 ? (s += a, r.push({
285
319
  key: s
286
- }), l++, o = m.Start) : s += i : o === m.StringKey ? i === '"' ? (r.push({
287
- key: JSON.parse(s + i)
288
- }), l += 2, o = m.Start) : i === "\\" ? (s += d[l], l++, s += d[l]) : s += i : o === m.NumberKey && (i === "]" ? (r.push({
320
+ }), c++, o = m.Start) : s += a : o === m.StringKey ? a === '"' ? (r.push({
321
+ key: JSON.parse(s + a)
322
+ }), c += 2, o = m.Start) : a === "\\" ? (s += d[c], c++, s += d[c]) : s += a : o === m.NumberKey && (a === "]" ? (r.push({
289
323
  key: Number.parseInt(s)
290
- }), l++, o = m.Start) : s += i), o === m.Start && l < d.length - 1) {
291
- const u = d[l];
324
+ }), c++, o = m.Start) : s += a), o === m.Start && c < d.length - 1) {
325
+ const u = d[c];
292
326
  if (s = "", u === "[")
293
- d[l + 1] === '"' ? (o = m.StringKey, l++, s = '"') : o = m.NumberKey;
327
+ d[c + 1] === '"' ? (o = m.StringKey, c++, s = '"') : o = m.NumberKey;
294
328
  else if (u === ".")
295
329
  o = m.Property;
296
330
  else
@@ -303,122 +337,122 @@ const G = (d) => {
303
337
  };
304
338
  var M = /* @__PURE__ */ ((d) => (d.DEVELOPMENT = "dev", d.PRODUCTION = "prod", d))(M || {});
305
339
  const q = (() => {
306
- const d = (e) => typeof e.limit == "number" && K(e.limit) && 1 <= e.limit && e.limit <= 1e4 && (e.offset === void 0 || typeof e.offset == "number" && K(e.offset) && 0 <= e.offset) && (e.timeRange === void 0 || typeof e.timeRange == "object" && e.timeRange !== null && r(e.timeRange)) && (e.filterAnd === void 0 || Array.isArray(e.filterAnd) && e.filterAnd.every((n) => typeof n == "object" && n !== null && s(n))), r = (e) => typeof e.start == "string" && R(e.start) && typeof e.end == "string" && R(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")), o = (e, n, c = !0) => [typeof e.limit == "number" && (K(e.limit) || a(c, {
340
+ const d = (e) => typeof e.limit == "number" && R(e.limit) && 1 <= e.limit && e.limit <= 1e4 && (e.offset === void 0 || typeof e.offset == "number" && R(e.offset) && 0 <= e.offset) && (e.timeRange === void 0 || typeof e.timeRange == "object" && e.timeRange !== null && r(e.timeRange)) && (e.filterAnd === void 0 || Array.isArray(e.filterAnd) && e.filterAnd.every((n) => typeof n == "object" && n !== null && s(n))), r = (e) => typeof e.start == "string" && K(e.start) && typeof e.end == "string" && K(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")), o = (e, n, l = !0) => [typeof e.limit == "number" && (R(e.limit) || i(l, {
307
341
  path: n + ".limit",
308
342
  expected: 'number & Type<"uint32">',
309
343
  value: e.limit
310
- })) && (1 <= e.limit || a(c, {
344
+ })) && (1 <= e.limit || i(l, {
311
345
  path: n + ".limit",
312
346
  expected: "number & Minimum<1>",
313
347
  value: e.limit
314
- })) && (e.limit <= 1e4 || a(c, {
348
+ })) && (e.limit <= 1e4 || i(l, {
315
349
  path: n + ".limit",
316
350
  expected: "number & Maximum<10000>",
317
351
  value: e.limit
318
- })) || a(c, {
352
+ })) || i(l, {
319
353
  path: n + ".limit",
320
354
  expected: '(number & Type<"uint32"> & Minimum<1> & Maximum<10000>)',
321
355
  value: e.limit
322
- }), e.offset === void 0 || typeof e.offset == "number" && (K(e.offset) || a(c, {
356
+ }), e.offset === void 0 || typeof e.offset == "number" && (R(e.offset) || i(l, {
323
357
  path: n + ".offset",
324
358
  expected: 'number & Type<"uint32">',
325
359
  value: e.offset
326
- })) && (0 <= e.offset || a(c, {
360
+ })) && (0 <= e.offset || i(l, {
327
361
  path: n + ".offset",
328
362
  expected: "number & Minimum<0>",
329
363
  value: e.offset
330
- })) || a(c, {
364
+ })) || i(l, {
331
365
  path: n + ".offset",
332
366
  expected: '((number & Type<"uint32"> & Minimum<0>) | undefined)',
333
367
  value: e.offset
334
- }), e.timeRange === void 0 || (typeof e.timeRange == "object" && e.timeRange !== null || a(c, {
368
+ }), e.timeRange === void 0 || (typeof e.timeRange == "object" && e.timeRange !== null || i(l, {
335
369
  path: n + ".timeRange",
336
370
  expected: "(ISOTimeRange | undefined)",
337
371
  value: e.timeRange
338
- })) && l(e.timeRange, n + ".timeRange", c) || a(c, {
372
+ })) && c(e.timeRange, n + ".timeRange", l) || i(l, {
339
373
  path: n + ".timeRange",
340
374
  expected: "(ISOTimeRange | undefined)",
341
375
  value: e.timeRange
342
- }), e.filterAnd === void 0 || (Array.isArray(e.filterAnd) || a(c, {
376
+ }), e.filterAnd === void 0 || (Array.isArray(e.filterAnd) || i(l, {
343
377
  path: n + ".filterAnd",
344
378
  expected: "(Array<SQLFilterAnd> | undefined)",
345
379
  value: e.filterAnd
346
- })) && e.filterAnd.map((f, v) => (typeof f == "object" && f !== null || a(c, {
380
+ })) && e.filterAnd.map((h, v) => (typeof h == "object" && h !== null || i(l, {
347
381
  path: n + ".filterAnd[" + v + "]",
348
382
  expected: "SQLFilterAnd",
349
- value: f
350
- })) && i(f, n + ".filterAnd[" + v + "]", c) || a(c, {
383
+ value: h
384
+ })) && a(h, n + ".filterAnd[" + v + "]", l) || i(l, {
351
385
  path: n + ".filterAnd[" + v + "]",
352
386
  expected: "SQLFilterAnd",
353
- value: f
354
- })).every((f) => f) || a(c, {
387
+ value: h
388
+ })).every((h) => h) || i(l, {
355
389
  path: n + ".filterAnd",
356
390
  expected: "(Array<SQLFilterAnd> | undefined)",
357
391
  value: e.filterAnd
358
- })].every((f) => f), l = (e, n, c = !0) => [typeof e.start == "string" && (R(e.start) || a(c, {
392
+ })].every((h) => h), c = (e, n, l = !0) => [typeof e.start == "string" && (K(e.start) || i(l, {
359
393
  path: n + ".start",
360
394
  expected: 'string & Format<"date-time">',
361
395
  value: e.start
362
- })) || a(c, {
396
+ })) || i(l, {
363
397
  path: n + ".start",
364
398
  expected: '(string & Format<"date-time">)',
365
399
  value: e.start
366
- }), typeof e.end == "string" && (R(e.end) || a(c, {
400
+ }), typeof e.end == "string" && (K(e.end) || i(l, {
367
401
  path: n + ".end",
368
402
  expected: 'string & Format<"date-time">',
369
403
  value: e.end
370
- })) || a(c, {
404
+ })) || i(l, {
371
405
  path: n + ".end",
372
406
  expected: '(string & Format<"date-time">)',
373
407
  value: e.end
374
- })].every((f) => f), i = (e, n, c = !0) => [typeof e.column == "string" && (1 <= e.column.length || a(c, {
408
+ })].every((h) => h), a = (e, n, l = !0) => [typeof e.column == "string" && (1 <= e.column.length || i(l, {
375
409
  path: n + ".column",
376
410
  expected: "string & MinLength<1>",
377
411
  value: e.column
378
- })) || a(c, {
412
+ })) || i(l, {
379
413
  path: n + ".column",
380
414
  expected: "(string & MinLength<1>)",
381
415
  value: e.column
382
- }), typeof e.operator == "string" && (1 <= e.operator.length || a(c, {
416
+ }), typeof e.operator == "string" && (1 <= e.operator.length || i(l, {
383
417
  path: n + ".operator",
384
418
  expected: "string & MinLength<1>",
385
419
  value: e.operator
386
- })) || a(c, {
420
+ })) || i(l, {
387
421
  path: n + ".operator",
388
422
  expected: "(string & MinLength<1>)",
389
423
  value: e.operator
390
- }), (e.value !== null || a(c, {
424
+ }), (e.value !== null || i(l, {
391
425
  path: n + ".value",
392
426
  expected: "(Array<string | number> | boolean | number | string)",
393
427
  value: e.value
394
- })) && (e.value !== void 0 || a(c, {
428
+ })) && (e.value !== void 0 || i(l, {
395
429
  path: n + ".value",
396
430
  expected: "(Array<string | number> | boolean | number | string)",
397
431
  value: e.value
398
- })) && (typeof e.value == "string" || typeof e.value == "number" || typeof e.value == "boolean" || (Array.isArray(e.value) || a(c, {
432
+ })) && (typeof e.value == "string" || typeof e.value == "number" || typeof e.value == "boolean" || (Array.isArray(e.value) || i(l, {
399
433
  path: n + ".value",
400
434
  expected: "(Array<string | number> | boolean | number | string)",
401
435
  value: e.value
402
- })) && e.value.map((f, v) => typeof f == "string" || typeof f == "number" || a(c, {
436
+ })) && e.value.map((h, v) => typeof h == "string" || typeof h == "number" || i(l, {
403
437
  path: n + ".value[" + v + "]",
404
438
  expected: "(number | string)",
405
- value: f
406
- })).every((f) => f) || a(c, {
439
+ value: h
440
+ })).every((h) => h) || i(l, {
407
441
  path: n + ".value",
408
442
  expected: "(Array<string | number> | boolean | number | string)",
409
443
  value: e.value
410
- }))].every((f) => f), u = (e) => typeof e == "object" && e !== null && d(e);
411
- let t, a;
412
- return p((e) => {
444
+ }))].every((h) => h), u = (e) => typeof e == "object" && e !== null && d(e);
445
+ let t, i;
446
+ return k((e) => {
413
447
  if (u(e) === !1) {
414
- t = [], a = k(t), ((c, f, v = !0) => (typeof c == "object" && c !== null || a(!0, {
415
- path: f + "",
448
+ t = [], i = p(t), ((l, h, v = !0) => (typeof l == "object" && l !== null || i(!0, {
449
+ path: h + "",
416
450
  expected: "TableQueryParams",
417
- value: c
418
- })) && o(c, f + "", !0) || a(!0, {
419
- path: f + "",
451
+ value: l
452
+ })) && o(l, h + "", !0) || i(!0, {
453
+ path: h + "",
420
454
  expected: "TableQueryParams",
421
- value: c
455
+ value: l
422
456
  }))(e, "$input", !0);
423
457
  const n = t.length === 0;
424
458
  return n ? {
@@ -436,84 +470,84 @@ const q = (() => {
436
470
  };
437
471
  });
438
472
  })(), X = (() => {
439
- const d = (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, {
473
+ const d = (a) => typeof a.longitude == "number" && -180 <= a.longitude && a.longitude <= 180 && typeof a.latitude == "number" && -90 <= a.latitude && a.latitude <= 90, r = (a, u, t = !0) => [typeof a.longitude == "number" && (-180 <= a.longitude || c(t, {
440
474
  path: u + ".longitude",
441
475
  expected: "number & Minimum<-180>",
442
- value: i.longitude
443
- })) && (i.longitude <= 180 || l(t, {
476
+ value: a.longitude
477
+ })) && (a.longitude <= 180 || c(t, {
444
478
  path: u + ".longitude",
445
479
  expected: "number & Maximum<180>",
446
- value: i.longitude
447
- })) || l(t, {
480
+ value: a.longitude
481
+ })) || c(t, {
448
482
  path: u + ".longitude",
449
483
  expected: "(number & Minimum<-180> & Maximum<180>)",
450
- value: i.longitude
451
- }), typeof i.latitude == "number" && (-90 <= i.latitude || l(t, {
484
+ value: a.longitude
485
+ }), typeof a.latitude == "number" && (-90 <= a.latitude || c(t, {
452
486
  path: u + ".latitude",
453
487
  expected: "number & Minimum<-90>",
454
- value: i.latitude
455
- })) && (i.latitude <= 90 || l(t, {
488
+ value: a.latitude
489
+ })) && (a.latitude <= 90 || c(t, {
456
490
  path: u + ".latitude",
457
491
  expected: "number & Maximum<90>",
458
- value: i.latitude
459
- })) || l(t, {
492
+ value: a.latitude
493
+ })) || c(t, {
460
494
  path: u + ".latitude",
461
495
  expected: "(number & Minimum<-90> & Maximum<90>)",
462
- value: i.latitude
463
- })].every((a) => a), s = (i) => typeof i == "object" && i !== null && d(i);
464
- let o, l;
465
- return p((i) => {
466
- if (s(i) === !1) {
467
- o = [], l = k(o), ((t, a, e = !0) => (typeof t == "object" && t !== null || l(!0, {
468
- path: a + "",
496
+ value: a.latitude
497
+ })].every((i) => i), s = (a) => typeof a == "object" && a !== null && d(a);
498
+ let o, c;
499
+ return k((a) => {
500
+ if (s(a) === !1) {
501
+ o = [], c = p(o), ((t, i, e = !0) => (typeof t == "object" && t !== null || c(!0, {
502
+ path: i + "",
469
503
  expected: "LocationParams",
470
504
  value: t
471
- })) && r(t, a + "", !0) || l(!0, {
472
- path: a + "",
505
+ })) && r(t, i + "", !0) || c(!0, {
506
+ path: i + "",
473
507
  expected: "LocationParams",
474
508
  value: t
475
- }))(i, "$input", !0);
509
+ }))(a, "$input", !0);
476
510
  const u = o.length === 0;
477
511
  return u ? {
478
512
  success: u,
479
- data: i
513
+ data: a
480
514
  } : {
481
515
  success: u,
482
516
  errors: o,
483
- data: i
517
+ data: a
484
518
  };
485
519
  }
486
520
  return {
487
521
  success: !0,
488
- data: i
522
+ data: a
489
523
  };
490
524
  });
491
525
  })(), Z = (() => {
492
- const d = (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)), s = (t, a, e = !0) => [typeof t.topic == "string" && (1 <= t.topic.length || u(e, {
493
- path: a + ".topic",
526
+ const d = (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((i) => (t[i] === void 0, !0)), s = (t, i, e = !0) => [typeof t.topic == "string" && (1 <= t.topic.length || u(e, {
527
+ path: i + ".topic",
494
528
  expected: "string & MinLength<1>",
495
529
  value: t.topic
496
530
  })) || u(e, {
497
- path: a + ".topic",
531
+ path: i + ".topic",
498
532
  expected: "(string & MinLength<1>)",
499
533
  value: t.topic
500
534
  }), t.args === void 0 || Array.isArray(t.args) || u(e, {
501
- path: a + ".args",
535
+ path: i + ".args",
502
536
  expected: "(Array<unknown> | undefined)",
503
537
  value: t.args
504
538
  }), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(e, {
505
- path: a + ".kwargs",
539
+ path: i + ".kwargs",
506
540
  expected: "(Record<string, unknown> | undefined)",
507
541
  value: t.kwargs
508
- })) && o(t.kwargs, a + ".kwargs", e) || u(e, {
509
- path: a + ".kwargs",
542
+ })) && o(t.kwargs, i + ".kwargs", e) || u(e, {
543
+ path: i + ".kwargs",
510
544
  expected: "(Record<string, unknown> | undefined)",
511
545
  value: t.kwargs
512
- })].every((n) => n), o = (t, a, e = !0) => [e === !1 || Object.keys(t).map((n) => (t[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (t) => typeof t == "object" && t !== null && d(t);
513
- let i, u;
514
- return p((t) => {
515
- if (l(t) === !1) {
516
- i = [], u = k(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
546
+ })].every((n) => n), o = (t, i, e = !0) => [e === !1 || Object.keys(t).map((n) => (t[n] === void 0, !0)).every((n) => n)].every((n) => n), c = (t) => typeof t == "object" && t !== null && d(t);
547
+ let a, u;
548
+ return k((t) => {
549
+ if (c(t) === !1) {
550
+ a = [], u = p(a), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
517
551
  path: n + "",
518
552
  expected: "PublishParams",
519
553
  value: e
@@ -522,13 +556,13 @@ const q = (() => {
522
556
  expected: "PublishParams",
523
557
  value: e
524
558
  }))(t, "$input", !0);
525
- const a = i.length === 0;
526
- return a ? {
527
- success: a,
559
+ const i = a.length === 0;
560
+ return i ? {
561
+ success: i,
528
562
  data: t
529
563
  } : {
530
- success: a,
531
- errors: i,
564
+ success: i,
565
+ errors: a,
532
566
  data: t
533
567
  };
534
568
  }
@@ -538,39 +572,39 @@ const q = (() => {
538
572
  };
539
573
  });
540
574
  })(), te = (() => {
541
- const d = (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)), s = (t, a, e = !0) => [typeof t.deviceKey == "string" && (1 <= t.deviceKey.length || u(e, {
542
- path: a + ".deviceKey",
575
+ const d = (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((i) => (t[i] === void 0, !0)), s = (t, i, e = !0) => [typeof t.deviceKey == "string" && (1 <= t.deviceKey.length || u(e, {
576
+ path: i + ".deviceKey",
543
577
  expected: "string & MinLength<1>",
544
578
  value: t.deviceKey
545
579
  })) || u(e, {
546
- path: a + ".deviceKey",
580
+ path: i + ".deviceKey",
547
581
  expected: "(string & MinLength<1>)",
548
582
  value: t.deviceKey
549
583
  }), typeof t.topic == "string" && (1 <= t.topic.length || u(e, {
550
- path: a + ".topic",
584
+ path: i + ".topic",
551
585
  expected: "string & MinLength<1>",
552
586
  value: t.topic
553
587
  })) || u(e, {
554
- path: a + ".topic",
588
+ path: i + ".topic",
555
589
  expected: "(string & MinLength<1>)",
556
590
  value: t.topic
557
591
  }), t.args === void 0 || Array.isArray(t.args) || u(e, {
558
- path: a + ".args",
592
+ path: i + ".args",
559
593
  expected: "(Array<unknown> | undefined)",
560
594
  value: t.args
561
595
  }), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(e, {
562
- path: a + ".kwargs",
596
+ path: i + ".kwargs",
563
597
  expected: "(Record<string, unknown> | undefined)",
564
598
  value: t.kwargs
565
- })) && o(t.kwargs, a + ".kwargs", e) || u(e, {
566
- path: a + ".kwargs",
599
+ })) && o(t.kwargs, i + ".kwargs", e) || u(e, {
600
+ path: i + ".kwargs",
567
601
  expected: "(Record<string, unknown> | undefined)",
568
602
  value: t.kwargs
569
- })].every((n) => n), o = (t, a, e = !0) => [e === !1 || Object.keys(t).map((n) => (t[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (t) => typeof t == "object" && t !== null && d(t);
570
- let i, u;
571
- return p((t) => {
572
- if (l(t) === !1) {
573
- i = [], u = k(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
603
+ })].every((n) => n), o = (t, i, e = !0) => [e === !1 || Object.keys(t).map((n) => (t[n] === void 0, !0)).every((n) => n)].every((n) => n), c = (t) => typeof t == "object" && t !== null && d(t);
604
+ let a, u;
605
+ return k((t) => {
606
+ if (c(t) === !1) {
607
+ a = [], u = p(a), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
574
608
  path: n + "",
575
609
  expected: "CallParams",
576
610
  value: e
@@ -579,13 +613,13 @@ const q = (() => {
579
613
  expected: "CallParams",
580
614
  value: e
581
615
  }))(t, "$input", !0);
582
- const a = i.length === 0;
583
- return a ? {
584
- success: a,
616
+ const i = a.length === 0;
617
+ return i ? {
618
+ success: i,
585
619
  data: t
586
620
  } : {
587
- success: a,
588
- errors: i,
621
+ success: i,
622
+ errors: a,
589
623
  data: t
590
624
  };
591
625
  }
@@ -594,32 +628,32 @@ const q = (() => {
594
628
  data: t
595
629
  };
596
630
  });
597
- })(), T = (() => {
598
- const d = (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)), s = (t, a, e = !0) => [typeof t.tablename == "string" && (1 <= t.tablename.length || u(e, {
599
- path: a + ".tablename",
631
+ })(), C = (() => {
632
+ const d = (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((i) => (t[i] === void 0, !0)), s = (t, i, e = !0) => [typeof t.tablename == "string" && (1 <= t.tablename.length || u(e, {
633
+ path: i + ".tablename",
600
634
  expected: "string & MinLength<1>",
601
635
  value: t.tablename
602
636
  })) || u(e, {
603
- path: a + ".tablename",
637
+ path: i + ".tablename",
604
638
  expected: "(string & MinLength<1>)",
605
639
  value: t.tablename
606
640
  }), t.args === void 0 || Array.isArray(t.args) || u(e, {
607
- path: a + ".args",
641
+ path: i + ".args",
608
642
  expected: "(Array<unknown> | undefined)",
609
643
  value: t.args
610
644
  }), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(e, {
611
- path: a + ".kwargs",
645
+ path: i + ".kwargs",
612
646
  expected: "(Record<string, unknown> | undefined)",
613
647
  value: t.kwargs
614
- })) && o(t.kwargs, a + ".kwargs", e) || u(e, {
615
- path: a + ".kwargs",
648
+ })) && o(t.kwargs, i + ".kwargs", e) || u(e, {
649
+ path: i + ".kwargs",
616
650
  expected: "(Record<string, unknown> | undefined)",
617
651
  value: t.kwargs
618
- })].every((n) => n), o = (t, a, e = !0) => [e === !1 || Object.keys(t).map((n) => (t[n] === void 0, !0)).every((n) => n)].every((n) => n), l = (t) => typeof t == "object" && t !== null && d(t);
619
- let i, u;
620
- return p((t) => {
621
- if (l(t) === !1) {
622
- i = [], u = k(i), ((e, n, c = !0) => (typeof e == "object" && e !== null || u(!0, {
652
+ })].every((n) => n), o = (t, i, e = !0) => [e === !1 || Object.keys(t).map((n) => (t[n] === void 0, !0)).every((n) => n)].every((n) => n), c = (t) => typeof t == "object" && t !== null && d(t);
653
+ let a, u;
654
+ return k((t) => {
655
+ if (c(t) === !1) {
656
+ a = [], u = p(a), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
623
657
  path: n + "",
624
658
  expected: "TableParams",
625
659
  value: e
@@ -628,13 +662,13 @@ const q = (() => {
628
662
  expected: "TableParams",
629
663
  value: e
630
664
  }))(t, "$input", !0);
631
- const a = i.length === 0;
632
- return a ? {
633
- success: a,
665
+ const i = a.length === 0;
666
+ return i ? {
667
+ success: i,
634
668
  data: t
635
669
  } : {
636
- success: a,
637
- errors: i,
670
+ success: i,
671
+ errors: a,
638
672
  data: t
639
673
  };
640
674
  }
@@ -654,9 +688,9 @@ function z(d) {
654
688
  throw new Error("serialNumber option is required (or set DEVICE_SERIAL_NUMBER env var in Node.js)");
655
689
  return r;
656
690
  }
657
- class O {
691
+ class L {
658
692
  constructor(r) {
659
- this._isConfigured = !1, this._serialNumber = z(r == null ? void 0 : r.serialNumber), this._deviceName = (r == null ? void 0 : r.deviceName) ?? E("DEVICE_NAME"), this._deviceKey = (r == null ? void 0 : r.deviceKey) ?? E("DEVICE_KEY"), this._appName = (r == null ? void 0 : r.appName) ?? E("APP_NAME"), this._swarmKey = (r == null ? void 0 : r.swarmKey) ?? parseInt(E("SWARM_KEY") ?? "0", 10), this._appKey = (r == null ? void 0 : r.appKey) ?? parseInt(E("APP_KEY") ?? "0", 10), this._env = (r == null ? void 0 : r.env) ?? E("ENV"), this._reswarmUrl = (r == null ? void 0 : r.reswarmUrl) ?? E("RESWARM_URL"), this._cburl = r == null ? void 0 : r.cburl, this._connection = new x();
693
+ this._isConfigured = !1, this._serialNumber = z(r == null ? void 0 : r.serialNumber), this._deviceName = (r == null ? void 0 : r.deviceName) ?? E("DEVICE_NAME"), this._deviceKey = (r == null ? void 0 : r.deviceKey) ?? E("DEVICE_KEY"), this._appName = (r == null ? void 0 : r.appName) ?? E("APP_NAME"), this._swarmKey = (r == null ? void 0 : r.swarmKey) ?? parseInt(E("SWARM_KEY") ?? "0", 10), this._appKey = (r == null ? void 0 : r.appKey) ?? parseInt(E("APP_KEY") ?? "0", 10), this._env = (r == null ? void 0 : r.env) ?? E("ENV"), this._reswarmUrl = (r == null ? void 0 : r.reswarmUrl) ?? E("RESWARM_URL"), this._cburl = (r == null ? void 0 : r.ironFlockUrl) ?? (r == null ? void 0 : r.cburl), this._connection = new I();
660
694
  const s = [];
661
695
  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(
662
696
  `Warning: The following environment variables must be present: ${s.join(", ")}`
@@ -670,16 +704,16 @@ class O {
670
704
  }
671
705
  configureConnection(r) {
672
706
  if (this._isConfigured) return;
673
- const s = (this._env ?? "DEV").toUpperCase(), l = {
707
+ const s = (this._env ?? "DEV").toUpperCase(), c = {
674
708
  DEV: M.DEVELOPMENT,
675
709
  PROD: M.PRODUCTION
676
- }[s] ?? M.DEVELOPMENT, i = r ?? this._cburl ?? x.getWebSocketURI(this._reswarmUrl);
710
+ }[s] ?? M.DEVELOPMENT, a = r ?? this._cburl ?? I.getWebSocketURI(this._reswarmUrl);
677
711
  this._connection.configure(
678
712
  this._swarmKey,
679
713
  this._appKey,
680
- l,
714
+ c,
681
715
  this._serialNumber,
682
- i
716
+ a
683
717
  ), this._isConfigured = !0;
684
718
  }
685
719
  async start(r) {
@@ -689,9 +723,9 @@ class O {
689
723
  this._connection.stop();
690
724
  }
691
725
  async publish(r, s, o) {
692
- const l = Z({ topic: r, args: s, kwargs: o });
693
- if (!l.success)
694
- throw new Error(`Invalid publish parameters: ${l.errors.map((t) => t.path + ": " + t.expected).join(", ")}`);
726
+ const c = Z({ topic: r, args: s, kwargs: o });
727
+ if (!c.success)
728
+ throw new Error(`Invalid publish parameters: ${c.errors.map((t) => t.path + ": " + t.expected).join(", ")}`);
695
729
  const u = { ...{
696
730
  DEVICE_SERIAL_NUMBER: this._serialNumber,
697
731
  DEVICE_KEY: this._deviceKey,
@@ -702,26 +736,26 @@ class O {
702
736
  });
703
737
  }
704
738
  async publishToTable(r, s, o) {
705
- const l = T({ tablename: r, args: s, kwargs: o });
706
- if (!l.success)
707
- throw new Error(`Invalid table parameters: ${l.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
739
+ const c = C({ tablename: r, args: s, kwargs: o });
740
+ if (!c.success)
741
+ throw new Error(`Invalid table parameters: ${c.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
708
742
  if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
709
743
  if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
710
- const i = `${this._swarmKey}.${this._appKey}.${r}`;
711
- return this.publish(i, s, o);
744
+ const a = `${this._swarmKey}.${this._appKey}.${r}`;
745
+ return this.publish(a, s, o);
712
746
  }
713
747
  async appendToTable(r, s, o) {
714
- const l = T({ tablename: r, args: s, kwargs: o });
715
- if (!l.success)
716
- throw new Error(`Invalid table parameters: ${l.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
748
+ const c = C({ tablename: r, args: s, kwargs: o });
749
+ if (!c.success)
750
+ throw new Error(`Invalid table parameters: ${c.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
717
751
  if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
718
752
  if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
719
- const i = `append.${this._swarmKey}.${this._appKey}.${r}`, t = { ...{
753
+ const a = `append.${this._swarmKey}.${this._appKey}.${r}`, t = { ...{
720
754
  DEVICE_SERIAL_NUMBER: this._serialNumber,
721
755
  DEVICE_KEY: this._deviceKey,
722
756
  DEVICE_NAME: this._deviceName
723
757
  }, ...o ?? {} };
724
- return this._connection.call(i, s, t);
758
+ return this._connection.call(a, s, t);
725
759
  }
726
760
  async subscribe(r, s, o) {
727
761
  return this._connection.subscribe(r, s);
@@ -729,23 +763,23 @@ class O {
729
763
  async subscribeToTable(r, s, o) {
730
764
  if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
731
765
  if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
732
- const l = `${this._swarmKey}.${this._appKey}.${r}`;
733
- return this.subscribe(l, s, o);
766
+ const c = `${this._swarmKey}.${this._appKey}.${r}`;
767
+ return this.subscribe(c, s, o);
734
768
  }
735
- async call(r, s, o, l) {
736
- return this._connection.call(r, s, o, l);
769
+ async call(r, s, o, c) {
770
+ return this._connection.call(r, s, o, c);
737
771
  }
738
- async callDeviceFunction(r, s, o, l, i) {
772
+ async callDeviceFunction(r, s, o, c, a) {
739
773
  const u = `${this._swarmKey}.${r}.${this._appKey}.${this._env}.${s}`;
740
- return this._connection.call(u, o, l, i);
774
+ return this._connection.call(u, o, c, a);
741
775
  }
742
776
  /** @deprecated Use callDeviceFunction() instead. */
743
- async callFunction(r, s, o, l, i) {
744
- return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(r, s, o, l, i);
777
+ async callFunction(r, s, o, c, a) {
778
+ return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(r, s, o, c, a);
745
779
  }
746
780
  async registerDeviceFunction(r, s, o) {
747
- const l = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${r}`, i = await this._connection.register(l, s, o);
748
- return console.log(`Function registered for IronFlock topic '${r}'. (Full WAMP topic: '${l}')`), i;
781
+ const c = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${r}`, a = await this._connection.register(c, s, o);
782
+ return console.log(`Function registered for IronFlock topic '${r}'. (Full WAMP topic: '${c}')`), a;
749
783
  }
750
784
  /** @deprecated Use registerDeviceFunction() instead. */
751
785
  async registerFunction(r, s, o) {
@@ -759,20 +793,20 @@ class O {
759
793
  s.offset == null && (s.offset = 0);
760
794
  const o = q(s);
761
795
  if (!o.success)
762
- throw new Error(`Invalid query parameters: ${o.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
763
- const l = `history.transformed.app.${this._appKey}.${r}`;
796
+ throw new Error(`Invalid query parameters: ${o.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
797
+ const c = `history.transformed.app.${this._appKey}.${r}`;
764
798
  try {
765
- return await this._connection.call(l, [s]);
766
- } catch (i) {
767
- const u = String(i);
768
- 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);
799
+ return await this._connection.call(c, [s]);
800
+ } catch (a) {
801
+ const u = String(a);
802
+ return u.includes("no_such_procedure") || u.includes("no callee registered") ? (console.error(`Get history failed: History service procedure '${c}' not registered`), null) : (console.error(`Get history failed: ${a}`), null);
769
803
  }
770
804
  }
771
805
  async setDeviceLocation(r, s) {
772
806
  const o = X({ longitude: r, latitude: s });
773
807
  if (!o.success)
774
808
  throw new Error(`Invalid location parameters: ${o.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
775
- const l = { long: r, lat: s }, i = {
809
+ const c = { long: r, lat: s }, a = {
776
810
  DEVICE_SERIAL_NUMBER: this._serialNumber,
777
811
  DEVICE_KEY: this._deviceKey,
778
812
  DEVICE_NAME: this._deviceName
@@ -780,8 +814,8 @@ class O {
780
814
  try {
781
815
  return await this._connection.call(
782
816
  "ironflock.location_service.update",
783
- [l],
784
- i
817
+ [c],
818
+ a
785
819
  );
786
820
  } catch (u) {
787
821
  return console.error(`Set location failed: ${u}`), null;
@@ -805,17 +839,17 @@ class O {
805
839
  if (!s.ok)
806
840
  throw new Error(`Failed to fetch IronFlock config from ${r}: ${s.status} ${s.statusText}`);
807
841
  const o = await s.json();
808
- return new O(o);
842
+ return new L(o);
809
843
  }
810
844
  }
811
845
  export {
812
- x as CrossbarConnection,
813
- O as IronFlock,
846
+ I as CrossbarConnection,
847
+ L as IronFlock,
814
848
  M as Stage,
815
849
  te as validateCallParams,
816
850
  X as validateLocationParams,
817
851
  Z as validatePublishParams,
818
- T as validateTableParams,
852
+ C as validateTableParams,
819
853
  q as validateTableQueryParams
820
854
  };
821
855
  //# sourceMappingURL=index.mjs.map