ironflock 1.2.8 → 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,25 +1,25 @@
1
- import O 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 $ = { exports: {} }, C;
5
+ var S = { exports: {} }, O;
6
6
  function j() {
7
- return C || (C = 1, (function(d) {
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 c(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, l, h) {
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 c(n, l || a, h), 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;
@@ -86,9 +86,9 @@ function j() {
86
86
  }
87
87
  return !0;
88
88
  }, t.prototype.on = function(e, n, l) {
89
- return i(this, e, n, l, !1);
89
+ return a(this, e, n, l, !1);
90
90
  }, t.prototype.once = function(e, n, l) {
91
- return i(this, e, n, l, !0);
91
+ return a(this, e, n, l, !0);
92
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;
@@ -107,44 +107,50 @@ function j() {
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
- })($)), $.exports;
110
+ })(S)), S.exports;
111
111
  }
112
- var D = j();
113
- const U = /* @__PURE__ */ L(D), F = "wss://cbw.datapods.io/ws-ua-usr", S = "wss://cbw.ironflock.com/ws-ua-usr", W = "wss://cbw.ironflock.dev/ws-ua-usr", V = "wss://cbw.record-evolution.com/ws-ua-usr", x = "ws://localhost:8080/ws-ua-usr", Y = {
114
- "https://studio.datapods.io": F,
115
- "https://studio.ironflock.dev": W,
116
- "https://studio.ironflock.com": S,
117
- "https://studio.record-evolution.com": V,
118
- "http://localhost:8085": x,
119
- "http://localhost:8086": x,
120
- "http://host.docker.internal:8086": x
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 I 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
- var o;
130
- const s = typeof process < "u" ? (o = process.env) == null ? void 0 : o.DEVICE_ENDPOINT_URL : void 0;
129
+ var c;
130
+ const s = typeof process < "u" ? (c = process.env) == null ? void 0 : c.DEVICE_ENDPOINT_URL : void 0;
131
131
  if (s)
132
132
  try {
133
- const c = new URL(s);
134
- return c.pathname = "/ws-ua-usr", c.toString().replace(/\/$/, "");
133
+ const a = new URL(s);
134
+ return a.pathname = "/ws-ua-usr", a.toString().replace(/\/$/, "");
135
135
  } catch {
136
136
  }
137
- return r ? Y[r] ?? S : S;
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;
138
144
  }
139
- configure(r, s, o, c, i) {
140
- this.realm = `realm-${r}-${s}-${o}`, this.serial_number = c, this.socketURI = i ?? I.getWebSocketURI();
145
+ configure(r, s, o, c, a) {
146
+ this.realm = `realm-${r}-${s}-${o}`, this.serial_number = c, this.socketURI = a ?? I.getWebSocketURI();
141
147
  }
142
148
  async start() {
143
149
  if (!this.realm || !this.serial_number || !this.socketURI)
144
150
  throw new Error("CrossbarConnection must be configured before starting. Call configure() first.");
145
151
  return this.shouldReconnect = !0, this.firstConnection = new Promise((r, s) => {
146
152
  this.firstResolver = r, this.firstRejecter = s;
147
- }), this.connection = new O.Connection({
153
+ }), this.connection = new x.Connection({
148
154
  realm: this.realm,
149
155
  url: this.socketURI,
150
156
  authmethods: ["wampcra"],
@@ -155,7 +161,7 @@ class I extends U {
155
161
  // @ts-ignore
156
162
  autoping_interval: 2,
157
163
  autoping_timeout: 4,
158
- onchallenge: (r, s, o) => O.auth_cra.sign(this.serial_number, o.challenge)
164
+ onchallenge: (r, s, o) => x.auth_cra.sign(this.serial_number, o.challenge)
159
165
  }), this.connection.onopen = this.onOpen.bind(this), this.connection.onclose = this.onClose.bind(this), this.connection.open(), this.firstConnection;
160
166
  }
161
167
  onOpen(r) {
@@ -247,8 +253,8 @@ class I extends U {
247
253
  async register(r, s, o) {
248
254
  var u;
249
255
  await this.sessionWait();
250
- const c = { force_reregister: !0, ...o ?? {} }, i = await ((u = this.session) == null ? void 0 : u.register(r, s, c));
251
- 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;
252
258
  }
253
259
  async unregister(r) {
254
260
  var o;
@@ -257,15 +263,15 @@ class I extends U {
257
263
  s !== -1 && this.registrations.splice(s, 1);
258
264
  }
259
265
  async call(r, s, o, c) {
260
- var i;
261
- return await this.sessionWait(), (i = this.session) == null ? void 0 : i.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);
262
268
  }
263
269
  async publish(r, s, o, c) {
264
- var i;
265
- return await this.sessionWait(), (i = this.session) == null ? void 0 : i.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);
266
272
  }
267
273
  }
268
- const R = (d) => Math.floor(d) === d && B <= d && d <= J, B = 0, J = 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) => {
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) => {
269
275
  const r = (s) => {
270
276
  if (d.length === 0)
271
277
  return !0;
@@ -306,16 +312,16 @@ const G = (d) => {
306
312
  let s = "", o = m.Start, c = 5;
307
313
  for (; c < d.length - 1; ) {
308
314
  c++;
309
- const i = d[c];
310
- if (o === m.Property ? i === "." || i === "[" ? (r.push({
315
+ const a = d[c];
316
+ if (o === m.Property ? a === "." || a === "[" ? (r.push({
311
317
  key: s
312
- }), o = m.Start) : c === d.length - 1 ? (s += i, r.push({
318
+ }), o = m.Start) : c === d.length - 1 ? (s += a, r.push({
313
319
  key: s
314
- }), c++, o = m.Start) : s += i : o === m.StringKey ? i === '"' ? (r.push({
315
- key: JSON.parse(s + i)
316
- }), c += 2, o = m.Start) : i === "\\" ? (s += d[c], c++, s += d[c]) : 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({
317
323
  key: Number.parseInt(s)
318
- }), c++, o = m.Start) : s += i), o === m.Start && c < d.length - 1) {
324
+ }), c++, o = m.Start) : s += a), o === m.Start && c < d.length - 1) {
319
325
  const u = d[c];
320
326
  if (s = "", u === "[")
321
327
  d[c + 1] === '"' ? (o = m.StringKey, c++, s = '"') : o = m.NumberKey;
@@ -331,119 +337,119 @@ const G = (d) => {
331
337
  };
332
338
  var M = /* @__PURE__ */ ((d) => (d.DEVELOPMENT = "dev", d.PRODUCTION = "prod", d))(M || {});
333
339
  const q = (() => {
334
- 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) || a(l, {
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, {
335
341
  path: n + ".limit",
336
342
  expected: 'number & Type<"uint32">',
337
343
  value: e.limit
338
- })) && (1 <= e.limit || a(l, {
344
+ })) && (1 <= e.limit || i(l, {
339
345
  path: n + ".limit",
340
346
  expected: "number & Minimum<1>",
341
347
  value: e.limit
342
- })) && (e.limit <= 1e4 || a(l, {
348
+ })) && (e.limit <= 1e4 || i(l, {
343
349
  path: n + ".limit",
344
350
  expected: "number & Maximum<10000>",
345
351
  value: e.limit
346
- })) || a(l, {
352
+ })) || i(l, {
347
353
  path: n + ".limit",
348
354
  expected: '(number & Type<"uint32"> & Minimum<1> & Maximum<10000>)',
349
355
  value: e.limit
350
- }), e.offset === void 0 || typeof e.offset == "number" && (R(e.offset) || a(l, {
356
+ }), e.offset === void 0 || typeof e.offset == "number" && (R(e.offset) || i(l, {
351
357
  path: n + ".offset",
352
358
  expected: 'number & Type<"uint32">',
353
359
  value: e.offset
354
- })) && (0 <= e.offset || a(l, {
360
+ })) && (0 <= e.offset || i(l, {
355
361
  path: n + ".offset",
356
362
  expected: "number & Minimum<0>",
357
363
  value: e.offset
358
- })) || a(l, {
364
+ })) || i(l, {
359
365
  path: n + ".offset",
360
366
  expected: '((number & Type<"uint32"> & Minimum<0>) | undefined)',
361
367
  value: e.offset
362
- }), e.timeRange === void 0 || (typeof e.timeRange == "object" && e.timeRange !== null || a(l, {
368
+ }), e.timeRange === void 0 || (typeof e.timeRange == "object" && e.timeRange !== null || i(l, {
363
369
  path: n + ".timeRange",
364
370
  expected: "(ISOTimeRange | undefined)",
365
371
  value: e.timeRange
366
- })) && c(e.timeRange, n + ".timeRange", l) || a(l, {
372
+ })) && c(e.timeRange, n + ".timeRange", l) || i(l, {
367
373
  path: n + ".timeRange",
368
374
  expected: "(ISOTimeRange | undefined)",
369
375
  value: e.timeRange
370
- }), e.filterAnd === void 0 || (Array.isArray(e.filterAnd) || a(l, {
376
+ }), e.filterAnd === void 0 || (Array.isArray(e.filterAnd) || i(l, {
371
377
  path: n + ".filterAnd",
372
378
  expected: "(Array<SQLFilterAnd> | undefined)",
373
379
  value: e.filterAnd
374
- })) && e.filterAnd.map((h, v) => (typeof h == "object" && h !== null || a(l, {
380
+ })) && e.filterAnd.map((h, v) => (typeof h == "object" && h !== null || i(l, {
375
381
  path: n + ".filterAnd[" + v + "]",
376
382
  expected: "SQLFilterAnd",
377
383
  value: h
378
- })) && i(h, n + ".filterAnd[" + v + "]", l) || a(l, {
384
+ })) && a(h, n + ".filterAnd[" + v + "]", l) || i(l, {
379
385
  path: n + ".filterAnd[" + v + "]",
380
386
  expected: "SQLFilterAnd",
381
387
  value: h
382
- })).every((h) => h) || a(l, {
388
+ })).every((h) => h) || i(l, {
383
389
  path: n + ".filterAnd",
384
390
  expected: "(Array<SQLFilterAnd> | undefined)",
385
391
  value: e.filterAnd
386
- })].every((h) => h), c = (e, n, l = !0) => [typeof e.start == "string" && (K(e.start) || a(l, {
392
+ })].every((h) => h), c = (e, n, l = !0) => [typeof e.start == "string" && (K(e.start) || i(l, {
387
393
  path: n + ".start",
388
394
  expected: 'string & Format<"date-time">',
389
395
  value: e.start
390
- })) || a(l, {
396
+ })) || i(l, {
391
397
  path: n + ".start",
392
398
  expected: '(string & Format<"date-time">)',
393
399
  value: e.start
394
- }), typeof e.end == "string" && (K(e.end) || a(l, {
400
+ }), typeof e.end == "string" && (K(e.end) || i(l, {
395
401
  path: n + ".end",
396
402
  expected: 'string & Format<"date-time">',
397
403
  value: e.end
398
- })) || a(l, {
404
+ })) || i(l, {
399
405
  path: n + ".end",
400
406
  expected: '(string & Format<"date-time">)',
401
407
  value: e.end
402
- })].every((h) => h), i = (e, n, l = !0) => [typeof e.column == "string" && (1 <= e.column.length || a(l, {
408
+ })].every((h) => h), a = (e, n, l = !0) => [typeof e.column == "string" && (1 <= e.column.length || i(l, {
403
409
  path: n + ".column",
404
410
  expected: "string & MinLength<1>",
405
411
  value: e.column
406
- })) || a(l, {
412
+ })) || i(l, {
407
413
  path: n + ".column",
408
414
  expected: "(string & MinLength<1>)",
409
415
  value: e.column
410
- }), typeof e.operator == "string" && (1 <= e.operator.length || a(l, {
416
+ }), typeof e.operator == "string" && (1 <= e.operator.length || i(l, {
411
417
  path: n + ".operator",
412
418
  expected: "string & MinLength<1>",
413
419
  value: e.operator
414
- })) || a(l, {
420
+ })) || i(l, {
415
421
  path: n + ".operator",
416
422
  expected: "(string & MinLength<1>)",
417
423
  value: e.operator
418
- }), (e.value !== null || a(l, {
424
+ }), (e.value !== null || i(l, {
419
425
  path: n + ".value",
420
426
  expected: "(Array<string | number> | boolean | number | string)",
421
427
  value: e.value
422
- })) && (e.value !== void 0 || a(l, {
428
+ })) && (e.value !== void 0 || i(l, {
423
429
  path: n + ".value",
424
430
  expected: "(Array<string | number> | boolean | number | string)",
425
431
  value: e.value
426
- })) && (typeof e.value == "string" || typeof e.value == "number" || typeof e.value == "boolean" || (Array.isArray(e.value) || a(l, {
432
+ })) && (typeof e.value == "string" || typeof e.value == "number" || typeof e.value == "boolean" || (Array.isArray(e.value) || i(l, {
427
433
  path: n + ".value",
428
434
  expected: "(Array<string | number> | boolean | number | string)",
429
435
  value: e.value
430
- })) && e.value.map((h, v) => typeof h == "string" || typeof h == "number" || a(l, {
436
+ })) && e.value.map((h, v) => typeof h == "string" || typeof h == "number" || i(l, {
431
437
  path: n + ".value[" + v + "]",
432
438
  expected: "(number | string)",
433
439
  value: h
434
- })).every((h) => h) || a(l, {
440
+ })).every((h) => h) || i(l, {
435
441
  path: n + ".value",
436
442
  expected: "(Array<string | number> | boolean | number | string)",
437
443
  value: e.value
438
444
  }))].every((h) => h), u = (e) => typeof e == "object" && e !== null && d(e);
439
- let t, a;
445
+ let t, i;
440
446
  return k((e) => {
441
447
  if (u(e) === !1) {
442
- t = [], a = p(t), ((l, h, v = !0) => (typeof l == "object" && l !== null || a(!0, {
448
+ t = [], i = p(t), ((l, h, v = !0) => (typeof l == "object" && l !== null || i(!0, {
443
449
  path: h + "",
444
450
  expected: "TableQueryParams",
445
451
  value: l
446
- })) && o(l, h + "", !0) || a(!0, {
452
+ })) && o(l, h + "", !0) || i(!0, {
447
453
  path: h + "",
448
454
  expected: "TableQueryParams",
449
455
  value: l
@@ -464,84 +470,84 @@ const q = (() => {
464
470
  };
465
471
  });
466
472
  })(), X = (() => {
467
- 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 || c(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, {
468
474
  path: u + ".longitude",
469
475
  expected: "number & Minimum<-180>",
470
- value: i.longitude
471
- })) && (i.longitude <= 180 || c(t, {
476
+ value: a.longitude
477
+ })) && (a.longitude <= 180 || c(t, {
472
478
  path: u + ".longitude",
473
479
  expected: "number & Maximum<180>",
474
- value: i.longitude
480
+ value: a.longitude
475
481
  })) || c(t, {
476
482
  path: u + ".longitude",
477
483
  expected: "(number & Minimum<-180> & Maximum<180>)",
478
- value: i.longitude
479
- }), typeof i.latitude == "number" && (-90 <= i.latitude || c(t, {
484
+ value: a.longitude
485
+ }), typeof a.latitude == "number" && (-90 <= a.latitude || c(t, {
480
486
  path: u + ".latitude",
481
487
  expected: "number & Minimum<-90>",
482
- value: i.latitude
483
- })) && (i.latitude <= 90 || c(t, {
488
+ value: a.latitude
489
+ })) && (a.latitude <= 90 || c(t, {
484
490
  path: u + ".latitude",
485
491
  expected: "number & Maximum<90>",
486
- value: i.latitude
492
+ value: a.latitude
487
493
  })) || c(t, {
488
494
  path: u + ".latitude",
489
495
  expected: "(number & Minimum<-90> & Maximum<90>)",
490
- value: i.latitude
491
- })].every((a) => a), s = (i) => typeof i == "object" && i !== null && d(i);
496
+ value: a.latitude
497
+ })].every((i) => i), s = (a) => typeof a == "object" && a !== null && d(a);
492
498
  let o, c;
493
- return k((i) => {
494
- if (s(i) === !1) {
495
- o = [], c = p(o), ((t, a, e = !0) => (typeof t == "object" && t !== null || c(!0, {
496
- path: a + "",
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 + "",
497
503
  expected: "LocationParams",
498
504
  value: t
499
- })) && r(t, a + "", !0) || c(!0, {
500
- path: a + "",
505
+ })) && r(t, i + "", !0) || c(!0, {
506
+ path: i + "",
501
507
  expected: "LocationParams",
502
508
  value: t
503
- }))(i, "$input", !0);
509
+ }))(a, "$input", !0);
504
510
  const u = o.length === 0;
505
511
  return u ? {
506
512
  success: u,
507
- data: i
513
+ data: a
508
514
  } : {
509
515
  success: u,
510
516
  errors: o,
511
- data: i
517
+ data: a
512
518
  };
513
519
  }
514
520
  return {
515
521
  success: !0,
516
- data: i
522
+ data: a
517
523
  };
518
524
  });
519
525
  })(), Z = (() => {
520
- 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, {
521
- 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",
522
528
  expected: "string & MinLength<1>",
523
529
  value: t.topic
524
530
  })) || u(e, {
525
- path: a + ".topic",
531
+ path: i + ".topic",
526
532
  expected: "(string & MinLength<1>)",
527
533
  value: t.topic
528
534
  }), t.args === void 0 || Array.isArray(t.args) || u(e, {
529
- path: a + ".args",
535
+ path: i + ".args",
530
536
  expected: "(Array<unknown> | undefined)",
531
537
  value: t.args
532
538
  }), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(e, {
533
- path: a + ".kwargs",
539
+ path: i + ".kwargs",
534
540
  expected: "(Record<string, unknown> | undefined)",
535
541
  value: t.kwargs
536
- })) && o(t.kwargs, a + ".kwargs", e) || u(e, {
537
- path: a + ".kwargs",
542
+ })) && o(t.kwargs, i + ".kwargs", e) || u(e, {
543
+ path: i + ".kwargs",
538
544
  expected: "(Record<string, unknown> | undefined)",
539
545
  value: t.kwargs
540
- })].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), c = (t) => typeof t == "object" && t !== null && d(t);
541
- let i, u;
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;
542
548
  return k((t) => {
543
549
  if (c(t) === !1) {
544
- i = [], u = p(i), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
550
+ a = [], u = p(a), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
545
551
  path: n + "",
546
552
  expected: "PublishParams",
547
553
  value: e
@@ -550,13 +556,13 @@ const q = (() => {
550
556
  expected: "PublishParams",
551
557
  value: e
552
558
  }))(t, "$input", !0);
553
- const a = i.length === 0;
554
- return a ? {
555
- success: a,
559
+ const i = a.length === 0;
560
+ return i ? {
561
+ success: i,
556
562
  data: t
557
563
  } : {
558
- success: a,
559
- errors: i,
564
+ success: i,
565
+ errors: a,
560
566
  data: t
561
567
  };
562
568
  }
@@ -566,39 +572,39 @@ const q = (() => {
566
572
  };
567
573
  });
568
574
  })(), te = (() => {
569
- 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, {
570
- 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",
571
577
  expected: "string & MinLength<1>",
572
578
  value: t.deviceKey
573
579
  })) || u(e, {
574
- path: a + ".deviceKey",
580
+ path: i + ".deviceKey",
575
581
  expected: "(string & MinLength<1>)",
576
582
  value: t.deviceKey
577
583
  }), typeof t.topic == "string" && (1 <= t.topic.length || u(e, {
578
- path: a + ".topic",
584
+ path: i + ".topic",
579
585
  expected: "string & MinLength<1>",
580
586
  value: t.topic
581
587
  })) || u(e, {
582
- path: a + ".topic",
588
+ path: i + ".topic",
583
589
  expected: "(string & MinLength<1>)",
584
590
  value: t.topic
585
591
  }), t.args === void 0 || Array.isArray(t.args) || u(e, {
586
- path: a + ".args",
592
+ path: i + ".args",
587
593
  expected: "(Array<unknown> | undefined)",
588
594
  value: t.args
589
595
  }), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(e, {
590
- path: a + ".kwargs",
596
+ path: i + ".kwargs",
591
597
  expected: "(Record<string, unknown> | undefined)",
592
598
  value: t.kwargs
593
- })) && o(t.kwargs, a + ".kwargs", e) || u(e, {
594
- path: a + ".kwargs",
599
+ })) && o(t.kwargs, i + ".kwargs", e) || u(e, {
600
+ path: i + ".kwargs",
595
601
  expected: "(Record<string, unknown> | undefined)",
596
602
  value: t.kwargs
597
- })].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), c = (t) => typeof t == "object" && t !== null && d(t);
598
- let i, u;
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;
599
605
  return k((t) => {
600
606
  if (c(t) === !1) {
601
- i = [], u = p(i), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
607
+ a = [], u = p(a), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
602
608
  path: n + "",
603
609
  expected: "CallParams",
604
610
  value: e
@@ -607,13 +613,13 @@ const q = (() => {
607
613
  expected: "CallParams",
608
614
  value: e
609
615
  }))(t, "$input", !0);
610
- const a = i.length === 0;
611
- return a ? {
612
- success: a,
616
+ const i = a.length === 0;
617
+ return i ? {
618
+ success: i,
613
619
  data: t
614
620
  } : {
615
- success: a,
616
- errors: i,
621
+ success: i,
622
+ errors: a,
617
623
  data: t
618
624
  };
619
625
  }
@@ -622,32 +628,32 @@ const q = (() => {
622
628
  data: t
623
629
  };
624
630
  });
625
- })(), N = (() => {
626
- 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, {
627
- 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",
628
634
  expected: "string & MinLength<1>",
629
635
  value: t.tablename
630
636
  })) || u(e, {
631
- path: a + ".tablename",
637
+ path: i + ".tablename",
632
638
  expected: "(string & MinLength<1>)",
633
639
  value: t.tablename
634
640
  }), t.args === void 0 || Array.isArray(t.args) || u(e, {
635
- path: a + ".args",
641
+ path: i + ".args",
636
642
  expected: "(Array<unknown> | undefined)",
637
643
  value: t.args
638
644
  }), t.kwargs === void 0 || (typeof t.kwargs == "object" && t.kwargs !== null && Array.isArray(t.kwargs) === !1 || u(e, {
639
- path: a + ".kwargs",
645
+ path: i + ".kwargs",
640
646
  expected: "(Record<string, unknown> | undefined)",
641
647
  value: t.kwargs
642
- })) && o(t.kwargs, a + ".kwargs", e) || u(e, {
643
- path: a + ".kwargs",
648
+ })) && o(t.kwargs, i + ".kwargs", e) || u(e, {
649
+ path: i + ".kwargs",
644
650
  expected: "(Record<string, unknown> | undefined)",
645
651
  value: t.kwargs
646
- })].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), c = (t) => typeof t == "object" && t !== null && d(t);
647
- let i, u;
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;
648
654
  return k((t) => {
649
655
  if (c(t) === !1) {
650
- i = [], u = p(i), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
656
+ a = [], u = p(a), ((e, n, l = !0) => (typeof e == "object" && e !== null || u(!0, {
651
657
  path: n + "",
652
658
  expected: "TableParams",
653
659
  value: e
@@ -656,13 +662,13 @@ const q = (() => {
656
662
  expected: "TableParams",
657
663
  value: e
658
664
  }))(t, "$input", !0);
659
- const a = i.length === 0;
660
- return a ? {
661
- success: a,
665
+ const i = a.length === 0;
666
+ return i ? {
667
+ success: i,
662
668
  data: t
663
669
  } : {
664
- success: a,
665
- errors: i,
670
+ success: i,
671
+ errors: a,
666
672
  data: t
667
673
  };
668
674
  }
@@ -682,7 +688,7 @@ function z(d) {
682
688
  throw new Error("serialNumber option is required (or set DEVICE_SERIAL_NUMBER env var in Node.js)");
683
689
  return r;
684
690
  }
685
- class T {
691
+ class L {
686
692
  constructor(r) {
687
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();
688
694
  const s = [];
@@ -701,13 +707,13 @@ class T {
701
707
  const s = (this._env ?? "DEV").toUpperCase(), c = {
702
708
  DEV: M.DEVELOPMENT,
703
709
  PROD: M.PRODUCTION
704
- }[s] ?? M.DEVELOPMENT, i = r ?? this._cburl ?? I.getWebSocketURI(this._reswarmUrl);
710
+ }[s] ?? M.DEVELOPMENT, a = r ?? this._cburl ?? I.getWebSocketURI(this._reswarmUrl);
705
711
  this._connection.configure(
706
712
  this._swarmKey,
707
713
  this._appKey,
708
714
  c,
709
715
  this._serialNumber,
710
- i
716
+ a
711
717
  ), this._isConfigured = !0;
712
718
  }
713
719
  async start(r) {
@@ -730,26 +736,26 @@ class T {
730
736
  });
731
737
  }
732
738
  async publishToTable(r, s, o) {
733
- const c = N({ tablename: r, args: s, kwargs: o });
739
+ const c = C({ tablename: r, args: s, kwargs: o });
734
740
  if (!c.success)
735
741
  throw new Error(`Invalid table parameters: ${c.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
736
742
  if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
737
743
  if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
738
- const i = `${this._swarmKey}.${this._appKey}.${r}`;
739
- return this.publish(i, s, o);
744
+ const a = `${this._swarmKey}.${this._appKey}.${r}`;
745
+ return this.publish(a, s, o);
740
746
  }
741
747
  async appendToTable(r, s, o) {
742
- const c = N({ tablename: r, args: s, kwargs: o });
748
+ const c = C({ tablename: r, args: s, kwargs: o });
743
749
  if (!c.success)
744
- throw new Error(`Invalid table parameters: ${c.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
750
+ throw new Error(`Invalid table parameters: ${c.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
745
751
  if (!this._swarmKey) throw new Error("SWARM_KEY not set in environment variables!");
746
752
  if (!this._appKey) throw new Error("APP_KEY not set in environment variables!");
747
- const i = `append.${this._swarmKey}.${this._appKey}.${r}`, t = { ...{
753
+ const a = `append.${this._swarmKey}.${this._appKey}.${r}`, t = { ...{
748
754
  DEVICE_SERIAL_NUMBER: this._serialNumber,
749
755
  DEVICE_KEY: this._deviceKey,
750
756
  DEVICE_NAME: this._deviceName
751
757
  }, ...o ?? {} };
752
- return this._connection.call(i, s, t);
758
+ return this._connection.call(a, s, t);
753
759
  }
754
760
  async subscribe(r, s, o) {
755
761
  return this._connection.subscribe(r, s);
@@ -763,17 +769,17 @@ class T {
763
769
  async call(r, s, o, c) {
764
770
  return this._connection.call(r, s, o, c);
765
771
  }
766
- async callDeviceFunction(r, s, o, c, i) {
772
+ async callDeviceFunction(r, s, o, c, a) {
767
773
  const u = `${this._swarmKey}.${r}.${this._appKey}.${this._env}.${s}`;
768
- return this._connection.call(u, o, c, i);
774
+ return this._connection.call(u, o, c, a);
769
775
  }
770
776
  /** @deprecated Use callDeviceFunction() instead. */
771
- async callFunction(r, s, o, c, i) {
772
- return console.warn("callFunction() is deprecated and will be removed in a future version. Use callDeviceFunction() instead."), this.callDeviceFunction(r, s, o, c, 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);
773
779
  }
774
780
  async registerDeviceFunction(r, s, o) {
775
- const c = `${this._swarmKey}.${this._deviceKey}.${this._appKey}.${this._env}.${r}`, i = await this._connection.register(c, s, o);
776
- return console.log(`Function registered for IronFlock topic '${r}'. (Full WAMP topic: '${c}')`), 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;
777
783
  }
778
784
  /** @deprecated Use registerDeviceFunction() instead. */
779
785
  async registerFunction(r, s, o) {
@@ -787,20 +793,20 @@ class T {
787
793
  s.offset == null && (s.offset = 0);
788
794
  const o = q(s);
789
795
  if (!o.success)
790
- throw new Error(`Invalid query parameters: ${o.errors.map((i) => i.path + ": " + i.expected).join(", ")}`);
796
+ throw new Error(`Invalid query parameters: ${o.errors.map((a) => a.path + ": " + a.expected).join(", ")}`);
791
797
  const c = `history.transformed.app.${this._appKey}.${r}`;
792
798
  try {
793
799
  return await this._connection.call(c, [s]);
794
- } catch (i) {
795
- const u = String(i);
796
- return u.includes("no_such_procedure") || u.includes("no callee registered") ? (console.error(`Get history failed: History service procedure '${c}' not registered`), null) : (console.error(`Get history failed: ${i}`), null);
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);
797
803
  }
798
804
  }
799
805
  async setDeviceLocation(r, s) {
800
806
  const o = X({ longitude: r, latitude: s });
801
807
  if (!o.success)
802
808
  throw new Error(`Invalid location parameters: ${o.errors.map((u) => u.path + ": " + u.expected).join(", ")}`);
803
- const c = { long: r, lat: s }, i = {
809
+ const c = { long: r, lat: s }, a = {
804
810
  DEVICE_SERIAL_NUMBER: this._serialNumber,
805
811
  DEVICE_KEY: this._deviceKey,
806
812
  DEVICE_NAME: this._deviceName
@@ -809,7 +815,7 @@ class T {
809
815
  return await this._connection.call(
810
816
  "ironflock.location_service.update",
811
817
  [c],
812
- i
818
+ a
813
819
  );
814
820
  } catch (u) {
815
821
  return console.error(`Set location failed: ${u}`), null;
@@ -833,17 +839,17 @@ class T {
833
839
  if (!s.ok)
834
840
  throw new Error(`Failed to fetch IronFlock config from ${r}: ${s.status} ${s.statusText}`);
835
841
  const o = await s.json();
836
- return new T(o);
842
+ return new L(o);
837
843
  }
838
844
  }
839
845
  export {
840
846
  I as CrossbarConnection,
841
- T as IronFlock,
847
+ L as IronFlock,
842
848
  M as Stage,
843
849
  te as validateCallParams,
844
850
  X as validateLocationParams,
845
851
  Z as validatePublishParams,
846
- N as validateTableParams,
852
+ C as validateTableParams,
847
853
  q as validateTableQueryParams
848
854
  };
849
855
  //# sourceMappingURL=index.mjs.map