@auxilium/datalynk-client 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ Datalynk client library to integrate JavaScript clients with the Datalynk API.
11
11
  - [Table of Contents](#Table-of-Contents)
12
12
  - [Quick Start](#quick-start)
13
13
  - [Documentation](#documentation)
14
- - [API Documentation](https://auxilium.pages.gitlab.auxiliumgroup.com/datalynk/datalynk-client)
14
+ - [API Documentation](https://datalynk-client.scarborough.auxilium.world)
15
15
  - [Integration](#integration)
16
16
  - [Angular](#integration)
17
17
  - [Node / Vue](#integration)
@@ -46,7 +46,7 @@ const resp = await api.request({'$/auth/current':{}});
46
46
 
47
47
  ## Documentation
48
48
 
49
- [Full API Documentation](https://auxilium.pages.gitlab.auxiliumgroup.com/datalynk/datalynk-client)
49
+ [Full API Documentation](https://datalynk-client.scarborough.auxilium.world)
50
50
 
51
51
  <details>
52
52
  <summary>
@@ -227,9 +227,11 @@ const rows = await api.slice<T>(12345)
227
227
  // Advanced queries
228
228
  const rows = await api.slice<T>(12345)
229
229
  .select()
230
- .where('field1', '==', 'value')
230
+ .where('field1', '<', 0)
231
+ .or()
232
+ .where({field1: 0, field2: false})
231
233
  .fields({'field1': 'field2'})
232
- .order('field2', true /* ascending */)
234
+ .order('field2', true) // ascending
233
235
  .limit(10)
234
236
  .exec().rows();
235
237
  ```
package/dist/index.cjs CHANGED
@@ -2013,6 +2013,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2013
2013
  alias(aliasKeyVals) {
2014
2014
  return this.fields(aliasKeyVals);
2015
2015
  }
2016
+ /**
2017
+ * Add an 'AND' condition inside the where argument
2018
+ */
2019
+ and() {
2020
+ var _a;
2021
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$and") return this;
2022
+ if (this.request.where) this.request.where = ["$and", this.request.where];
2023
+ else this.request.where = ["$and"];
2024
+ return this;
2025
+ }
2016
2026
  /**
2017
2027
  * Output the formed request to the console for inspection
2018
2028
  */
@@ -2077,6 +2087,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2077
2087
  limit(num) {
2078
2088
  this.request.limit = num;
2079
2089
  }
2090
+ /**
2091
+ * Add an 'OR' condition inside the where argument
2092
+ */
2093
+ or() {
2094
+ var _a;
2095
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or") return this;
2096
+ if (this.request.where) this.request.where = ["$or", this.request.where];
2097
+ else this.request.where = ["$or"];
2098
+ return this;
2099
+ }
2080
2100
  /**
2081
2101
  * Order rows by a field
2082
2102
  *
@@ -2137,48 +2157,54 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2137
2157
  * Add where condition to request. Chaining wheres creates an AND between them. To perform an OR look at
2138
2158
  * the filter function
2139
2159
  *
2140
- * @param {string} field property to compare
2160
+ * @param {string | object} field property to compare or a map of equality comparisons
2141
2161
  * @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
2142
2162
  * @param {any} value value to compare against
2143
2163
  */
2144
2164
  where(field, operator, value) {
2145
- switch (operator) {
2146
- case "==":
2147
- operator = "$eq";
2148
- break;
2149
- case "!=":
2150
- operator = "$neq";
2151
- break;
2152
- case ">":
2153
- operator = "$gt";
2154
- break;
2155
- case ">=":
2156
- operator = "$gte";
2157
- break;
2158
- case "<":
2159
- operator = "$lt";
2160
- break;
2161
- case "<=":
2162
- operator = "$lte";
2163
- break;
2164
- case "!":
2165
- operator = "$not";
2166
- break;
2167
- case "%":
2168
- operator = "$mod";
2169
- break;
2165
+ this.and();
2166
+ if (typeof field == "object") {
2167
+ Object.entries(field).forEach(([key, value2]) => this.request.where.push(["$eq", ["$field", key], value2]));
2168
+ } else if (operator == null) {
2169
+ throw new Error("Malformed where clause");
2170
+ } else {
2171
+ switch (operator) {
2172
+ case "==":
2173
+ operator = "$eq";
2174
+ break;
2175
+ case "!=":
2176
+ operator = "$neq";
2177
+ break;
2178
+ case ">":
2179
+ operator = "$gt";
2180
+ break;
2181
+ case ">=":
2182
+ operator = "$gte";
2183
+ break;
2184
+ case "<":
2185
+ operator = "$lt";
2186
+ break;
2187
+ case "<=":
2188
+ operator = "$lte";
2189
+ break;
2190
+ case "!":
2191
+ operator = "$not";
2192
+ break;
2193
+ case "%":
2194
+ operator = "$mod";
2195
+ break;
2196
+ }
2197
+ this.request.where.push([operator, ["$field", field], value]);
2170
2198
  }
2171
- if (!this.request.where) this.request.where = ["$and"];
2172
- this.request.where.push([operator, ["$field", field], value]);
2173
2199
  return this;
2174
2200
  }
2175
2201
  }
2176
2202
  class Socket {
2177
2203
  constructor(api, options = {}) {
2178
2204
  __publicField(this, "listeners", []);
2179
- __publicField(this, "reconnect", false);
2205
+ __publicField(this, "retry");
2180
2206
  __publicField(this, "socket");
2181
- __publicField(this, "_connected", false);
2207
+ __publicField(this, "open", false);
2182
2208
  this.api = api;
2183
2209
  this.options = options;
2184
2210
  const url = new URL(this.api.url.replace("http", "ws"));
@@ -2190,9 +2216,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2190
2216
  if (this.options.url !== false)
2191
2217
  api.token$.pipe(distinctUntilChanged()).subscribe(() => this.connect());
2192
2218
  }
2193
- get connected() {
2194
- return this._connected;
2195
- }
2196
2219
  /**
2197
2220
  * Add listener for all socket events
2198
2221
  *
@@ -2207,46 +2230,46 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2207
2230
  * Close socket connection
2208
2231
  */
2209
2232
  close() {
2210
- this._connected = false;
2211
- this.reconnect = false;
2212
- this.socket.close();
2233
+ var _a;
2234
+ if (this.open) console.debug("Datalynk socket: disconnected");
2235
+ this.open = false;
2236
+ (_a = this.socket) == null ? void 0 : _a.close();
2237
+ this.socket = void 0;
2238
+ if (this.retry) clearTimeout(this.retry);
2239
+ this.retry = null;
2213
2240
  }
2214
2241
  /**
2215
2242
  * Connect socket client to socket server
2216
- *
2217
- * @param {number} timeout Retry interval, defaults to 30s
2243
+ * @param {number} timeout Retry to connect every x seconds
2218
2244
  */
2219
- connect(timeout = 3e4) {
2220
- if (!this.options.url) throw new Error("Socket is disabled");
2221
- if (this.connected) {
2222
- this.reconnect = false;
2223
- this.socket.close();
2224
- }
2225
- this.socket = new WebSocket(this.options.url + (this.api.token ? `?token=${this.api.token}` : ""));
2226
- let t = setTimeout(() => {
2227
- if (this.reconnect && !this.connected) this.connect();
2228
- }, timeout);
2229
- this.socket.onmessage = (message) => {
2230
- const payload = JSON.parse(message.data);
2231
- if (payload.connected != void 0) {
2232
- if (payload.connected) {
2233
- clearTimeout(t);
2234
- t = null;
2235
- this._connected = true;
2236
- this.reconnect = true;
2237
- console.debug("Datalynk Socket: Connected");
2245
+ connect(timeout = 30) {
2246
+ if (!this.options.url) throw new Error("Datalynk socket disabled");
2247
+ if (this.open) this.close();
2248
+ this.retry = setTimeout(() => {
2249
+ if (this.open) return;
2250
+ this.close();
2251
+ this.connect();
2252
+ }, timeout * 1e3);
2253
+ if (navigator.onLine) {
2254
+ this.socket = new WebSocket(this.options.url + (this.api.token ? `?token=${this.api.token}` : ""));
2255
+ this.socket.onopen = () => clearTimeout(this.retry);
2256
+ this.socket.onclose = () => {
2257
+ if (this.open) this.connect(timeout);
2258
+ };
2259
+ this.socket.onmessage = (message) => {
2260
+ const payload = JSON.parse(message.data);
2261
+ if (payload.connected != void 0) {
2262
+ if (payload.connected) {
2263
+ this.open = true;
2264
+ console.debug("Datalynk socket: connected");
2265
+ } else {
2266
+ throw new Error(`Datalynk socket failed: ${payload.error}`);
2267
+ }
2238
2268
  } else {
2239
- throw new Error(`Socket failed to connect: ${payload.error}`);
2269
+ this.listeners.forEach((l) => l(payload));
2240
2270
  }
2241
- } else {
2242
- this.listeners.forEach((l) => l(payload));
2243
- }
2244
- };
2245
- this.socket.onclose = () => {
2246
- this._connected = false;
2247
- if (this.reconnect && !t) this.connect();
2248
- console.debug("Datalynk Socket: Disconnected");
2249
- };
2271
+ };
2272
+ }
2250
2273
  }
2251
2274
  /**
2252
2275
  * Send data to socket server
@@ -2254,7 +2277,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2254
2277
  * @param payload Data that will be serialized
2255
2278
  */
2256
2279
  send(payload) {
2257
- this.socket.send(JSON.stringify(payload));
2280
+ var _a;
2281
+ if (!this.open) throw new Error("Datalynk socket not connected");
2282
+ (_a = this.socket) == null ? void 0 : _a.send(JSON.stringify(payload));
2258
2283
  }
2259
2284
  /**
2260
2285
  * Run callback whenever the server notifies us of slice changes
@@ -2265,7 +2290,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2265
2290
  */
2266
2291
  sliceEvents(slice, callback) {
2267
2292
  let cancelled = false;
2268
- sleepWhile(() => !this.connected).then(() => {
2293
+ sleepWhile(() => !this.open).then(() => {
2269
2294
  if (!cancelled) this.send({ onSliceEvents: slice });
2270
2295
  });
2271
2296
  const unsubscribe = this.addListener((event) => {
package/dist/index.mjs CHANGED
@@ -2009,6 +2009,16 @@ class Slice {
2009
2009
  alias(aliasKeyVals) {
2010
2010
  return this.fields(aliasKeyVals);
2011
2011
  }
2012
+ /**
2013
+ * Add an 'AND' condition inside the where argument
2014
+ */
2015
+ and() {
2016
+ var _a;
2017
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$and") return this;
2018
+ if (this.request.where) this.request.where = ["$and", this.request.where];
2019
+ else this.request.where = ["$and"];
2020
+ return this;
2021
+ }
2012
2022
  /**
2013
2023
  * Output the formed request to the console for inspection
2014
2024
  */
@@ -2073,6 +2083,16 @@ class Slice {
2073
2083
  limit(num) {
2074
2084
  this.request.limit = num;
2075
2085
  }
2086
+ /**
2087
+ * Add an 'OR' condition inside the where argument
2088
+ */
2089
+ or() {
2090
+ var _a;
2091
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or") return this;
2092
+ if (this.request.where) this.request.where = ["$or", this.request.where];
2093
+ else this.request.where = ["$or"];
2094
+ return this;
2095
+ }
2076
2096
  /**
2077
2097
  * Order rows by a field
2078
2098
  *
@@ -2133,48 +2153,54 @@ class Slice {
2133
2153
  * Add where condition to request. Chaining wheres creates an AND between them. To perform an OR look at
2134
2154
  * the filter function
2135
2155
  *
2136
- * @param {string} field property to compare
2156
+ * @param {string | object} field property to compare or a map of equality comparisons
2137
2157
  * @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
2138
2158
  * @param {any} value value to compare against
2139
2159
  */
2140
2160
  where(field, operator, value) {
2141
- switch (operator) {
2142
- case "==":
2143
- operator = "$eq";
2144
- break;
2145
- case "!=":
2146
- operator = "$neq";
2147
- break;
2148
- case ">":
2149
- operator = "$gt";
2150
- break;
2151
- case ">=":
2152
- operator = "$gte";
2153
- break;
2154
- case "<":
2155
- operator = "$lt";
2156
- break;
2157
- case "<=":
2158
- operator = "$lte";
2159
- break;
2160
- case "!":
2161
- operator = "$not";
2162
- break;
2163
- case "%":
2164
- operator = "$mod";
2165
- break;
2161
+ this.and();
2162
+ if (typeof field == "object") {
2163
+ Object.entries(field).forEach(([key, value2]) => this.request.where.push(["$eq", ["$field", key], value2]));
2164
+ } else if (operator == null) {
2165
+ throw new Error("Malformed where clause");
2166
+ } else {
2167
+ switch (operator) {
2168
+ case "==":
2169
+ operator = "$eq";
2170
+ break;
2171
+ case "!=":
2172
+ operator = "$neq";
2173
+ break;
2174
+ case ">":
2175
+ operator = "$gt";
2176
+ break;
2177
+ case ">=":
2178
+ operator = "$gte";
2179
+ break;
2180
+ case "<":
2181
+ operator = "$lt";
2182
+ break;
2183
+ case "<=":
2184
+ operator = "$lte";
2185
+ break;
2186
+ case "!":
2187
+ operator = "$not";
2188
+ break;
2189
+ case "%":
2190
+ operator = "$mod";
2191
+ break;
2192
+ }
2193
+ this.request.where.push([operator, ["$field", field], value]);
2166
2194
  }
2167
- if (!this.request.where) this.request.where = ["$and"];
2168
- this.request.where.push([operator, ["$field", field], value]);
2169
2195
  return this;
2170
2196
  }
2171
2197
  }
2172
2198
  class Socket {
2173
2199
  constructor(api, options = {}) {
2174
2200
  __publicField(this, "listeners", []);
2175
- __publicField(this, "reconnect", false);
2201
+ __publicField(this, "retry");
2176
2202
  __publicField(this, "socket");
2177
- __publicField(this, "_connected", false);
2203
+ __publicField(this, "open", false);
2178
2204
  this.api = api;
2179
2205
  this.options = options;
2180
2206
  const url = new URL(this.api.url.replace("http", "ws"));
@@ -2186,9 +2212,6 @@ class Socket {
2186
2212
  if (this.options.url !== false)
2187
2213
  api.token$.pipe(distinctUntilChanged()).subscribe(() => this.connect());
2188
2214
  }
2189
- get connected() {
2190
- return this._connected;
2191
- }
2192
2215
  /**
2193
2216
  * Add listener for all socket events
2194
2217
  *
@@ -2203,46 +2226,46 @@ class Socket {
2203
2226
  * Close socket connection
2204
2227
  */
2205
2228
  close() {
2206
- this._connected = false;
2207
- this.reconnect = false;
2208
- this.socket.close();
2229
+ var _a;
2230
+ if (this.open) console.debug("Datalynk socket: disconnected");
2231
+ this.open = false;
2232
+ (_a = this.socket) == null ? void 0 : _a.close();
2233
+ this.socket = void 0;
2234
+ if (this.retry) clearTimeout(this.retry);
2235
+ this.retry = null;
2209
2236
  }
2210
2237
  /**
2211
2238
  * Connect socket client to socket server
2212
- *
2213
- * @param {number} timeout Retry interval, defaults to 30s
2239
+ * @param {number} timeout Retry to connect every x seconds
2214
2240
  */
2215
- connect(timeout = 3e4) {
2216
- if (!this.options.url) throw new Error("Socket is disabled");
2217
- if (this.connected) {
2218
- this.reconnect = false;
2219
- this.socket.close();
2220
- }
2221
- this.socket = new WebSocket(this.options.url + (this.api.token ? `?token=${this.api.token}` : ""));
2222
- let t = setTimeout(() => {
2223
- if (this.reconnect && !this.connected) this.connect();
2224
- }, timeout);
2225
- this.socket.onmessage = (message) => {
2226
- const payload = JSON.parse(message.data);
2227
- if (payload.connected != void 0) {
2228
- if (payload.connected) {
2229
- clearTimeout(t);
2230
- t = null;
2231
- this._connected = true;
2232
- this.reconnect = true;
2233
- console.debug("Datalynk Socket: Connected");
2241
+ connect(timeout = 30) {
2242
+ if (!this.options.url) throw new Error("Datalynk socket disabled");
2243
+ if (this.open) this.close();
2244
+ this.retry = setTimeout(() => {
2245
+ if (this.open) return;
2246
+ this.close();
2247
+ this.connect();
2248
+ }, timeout * 1e3);
2249
+ if (navigator.onLine) {
2250
+ this.socket = new WebSocket(this.options.url + (this.api.token ? `?token=${this.api.token}` : ""));
2251
+ this.socket.onopen = () => clearTimeout(this.retry);
2252
+ this.socket.onclose = () => {
2253
+ if (this.open) this.connect(timeout);
2254
+ };
2255
+ this.socket.onmessage = (message) => {
2256
+ const payload = JSON.parse(message.data);
2257
+ if (payload.connected != void 0) {
2258
+ if (payload.connected) {
2259
+ this.open = true;
2260
+ console.debug("Datalynk socket: connected");
2261
+ } else {
2262
+ throw new Error(`Datalynk socket failed: ${payload.error}`);
2263
+ }
2234
2264
  } else {
2235
- throw new Error(`Socket failed to connect: ${payload.error}`);
2265
+ this.listeners.forEach((l) => l(payload));
2236
2266
  }
2237
- } else {
2238
- this.listeners.forEach((l) => l(payload));
2239
- }
2240
- };
2241
- this.socket.onclose = () => {
2242
- this._connected = false;
2243
- if (this.reconnect && !t) this.connect();
2244
- console.debug("Datalynk Socket: Disconnected");
2245
- };
2267
+ };
2268
+ }
2246
2269
  }
2247
2270
  /**
2248
2271
  * Send data to socket server
@@ -2250,7 +2273,9 @@ class Socket {
2250
2273
  * @param payload Data that will be serialized
2251
2274
  */
2252
2275
  send(payload) {
2253
- this.socket.send(JSON.stringify(payload));
2276
+ var _a;
2277
+ if (!this.open) throw new Error("Datalynk socket not connected");
2278
+ (_a = this.socket) == null ? void 0 : _a.send(JSON.stringify(payload));
2254
2279
  }
2255
2280
  /**
2256
2281
  * Run callback whenever the server notifies us of slice changes
@@ -2261,7 +2286,7 @@ class Socket {
2261
2286
  */
2262
2287
  sliceEvents(slice, callback) {
2263
2288
  let cancelled = false;
2264
- sleepWhile(() => !this.connected).then(() => {
2289
+ sleepWhile(() => !this.open).then(() => {
2265
2290
  if (!cancelled) this.send({ onSliceEvents: slice });
2266
2291
  });
2267
2292
  const unsubscribe = this.addListener((event) => {
package/dist/slice.d.ts CHANGED
@@ -117,6 +117,10 @@ export declare class Slice<T extends SliceMeta> {
117
117
  alias(aliasKeyVals: {
118
118
  [key: string]: string | object;
119
119
  }): Slice<T>;
120
+ /**
121
+ * Add an 'AND' condition inside the where argument
122
+ */
123
+ and(): this;
120
124
  /**
121
125
  * Output the formed request to the console for inspection
122
126
  */
@@ -161,6 +165,10 @@ export declare class Slice<T extends SliceMeta> {
161
165
  * @param {number} num Number of rows to return
162
166
  */
163
167
  limit(num: number): void;
168
+ /**
169
+ * Add an 'OR' condition inside the where argument
170
+ */
171
+ or(): this;
164
172
  /**
165
173
  * Order rows by a field
166
174
  *
@@ -191,10 +199,10 @@ export declare class Slice<T extends SliceMeta> {
191
199
  * Add where condition to request. Chaining wheres creates an AND between them. To perform an OR look at
192
200
  * the filter function
193
201
  *
194
- * @param {string} field property to compare
202
+ * @param {string | object} field property to compare or a map of equality comparisons
195
203
  * @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
196
204
  * @param {any} value value to compare against
197
205
  */
198
- where(field: string, operator: string, value: any): Slice<T>;
206
+ where(field: string | object, operator?: string, value?: any): Slice<T>;
199
207
  }
200
208
  //# sourceMappingURL=slice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slice.d.ts","sourceRoot":"","sources":["../src/slice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAmB,WAAW,EAAC,MAAM,UAAU,CAA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C,CAAC,CAAC;IAMlD;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAQzD;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IAQ/B;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM;IAIjB;;OAEG;IACH,EAAE;IAOF;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IAMhD;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;IASxC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAO;IAoBd;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE;IAQpB;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;CAsCvE"}
package/dist/socket.d.ts CHANGED
@@ -27,10 +27,9 @@ export declare class Socket {
27
27
  private readonly api;
28
28
  readonly options: SocketOptions;
29
29
  private listeners;
30
- private reconnect;
31
- private socket;
32
- private _connected;
33
- get connected(): boolean;
30
+ private retry?;
31
+ private socket?;
32
+ open: boolean;
34
33
  constructor(api: Api, options?: SocketOptions);
35
34
  /**
36
35
  * Add listener for all socket events
@@ -45,8 +44,7 @@ export declare class Socket {
45
44
  close(): void;
46
45
  /**
47
46
  * Connect socket client to socket server
48
- *
49
- * @param {number} timeout Retry interval, defaults to 30s
47
+ * @param {number} timeout Retry to connect every x seconds
50
48
  */
51
49
  connect(timeout?: number): void;
52
50
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAA;CACP,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH,yBAAyB;AACzB,MAAM,MAAM,aAAa,GAAG;IAC3B,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;CACpB,CAAA;AAED,qBAAqB;AACrB,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC;AACrE,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,iCAAiC;AACjC,qBAAa,MAAM;IAQN,OAAO,CAAC,QAAQ,CAAC,GAAG;aAAuB,OAAO,EAAE,aAAa;IAP7E,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAa;IAE3B,OAAO,CAAC,UAAU,CAAS;IAC3B,IAAI,SAAS,YAA8B;gBAEd,GAAG,EAAE,GAAG,EAAkB,OAAO,GAAE,aAAkB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CAAC,QAAQ,CAAC,GAAG;aAAuB,OAAO,EAAE,aAAa;IAN7E,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,KAAK,CAAC,CAAM;IACpB,OAAO,CAAC,MAAM,CAAC,CAAY;IAE3B,IAAI,UAAS;gBAEgB,GAAG,EAAE,GAAG,EAAkB,OAAO,GAAE,aAAkB;IAalF;;;;;OAKG;IACH,WAAW,CAAC,EAAE,EAAE,cAAc,GAAG,WAAW;IAK5C;;OAEG;IACH,KAAK;IASL;;;OAGG;IACH,OAAO,CAAC,OAAO,GAAE,MAAW;IA8B5B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG;IAKjB;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,gBAAgB,CAAC,GAAG,WAAW;CAmBlH"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@auxilium/datalynk-client",
3
3
  "description": "Datalynk client library",
4
4
  "repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
5
- "version": "0.8.1",
5
+ "version": "0.9.0",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",