ironflock 1.1.1 → 1.2.2

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