@auxilium/datalynk-client 1.0.5 → 1.0.8

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/api.d.ts CHANGED
@@ -65,24 +65,27 @@ export declare class Api {
65
65
  private localStorageKey;
66
66
  /** Pending requests cache */
67
67
  private pending;
68
- /** Authentication helpers */
69
- readonly auth: Auth;
70
- /** File helpers */
71
- readonly files: Files;
72
- /** PDF helpers */
73
- readonly pdf: Pdf;
74
- /** Socket object */
75
- readonly socket: Socket;
76
- /** Superuser helpers */
77
- readonly superuser: Superuser;
78
- /** API URL endpoint */
68
+ /** API URL */
79
69
  readonly url: string;
70
+ /** Package version */
71
+ version: string;
80
72
  /** API Session token */
81
73
  token$: BehaviorSubject<string | null>;
82
74
  get token(): string | null;
83
75
  set token(token: string | null);
84
76
  /** Get session info from JWT payload */
85
77
  get jwtPayload(): JwtPayload | null;
78
+ /** Helpers */
79
+ /** Authentication */
80
+ readonly auth: Auth;
81
+ /** File */
82
+ readonly files: Files;
83
+ /** PDF */
84
+ readonly pdf: Pdf;
85
+ /** Socket */
86
+ readonly socket: Socket;
87
+ /** Superuser */
88
+ readonly superuser: Superuser;
86
89
  /**
87
90
  * Connect to Datalynk & send requests
88
91
  *
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CA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MG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAsB9B;;;;OAIG;IACI,KAAK,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE;IAe9C;;;;OAIG;IACI,QAAQ,CAAC,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAiB7C;;;;;;OAMG;IACI,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;IAU7E;;;;;;;;;;;OAWG;IACI,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;IAqC/E;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAG5C"}
package/dist/auth.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
2
  import { Api } from './api';
3
- import { LoginPromptOptions } from './login-prompt';
3
+ import { LoginPrompt, LoginPromptOptions } from './login-prompt';
4
4
  /** User Account */
5
5
  export type User = {
6
6
  /** User ID */
@@ -96,7 +96,7 @@ export declare class Auth {
96
96
  login(spoke: string, login: string, password: string, opts?: {
97
97
  twoFactor?: string;
98
98
  expire?: null | string;
99
- }): Promise<any>;
99
+ }): Promise<User>;
100
100
  /**
101
101
  * Login as guest user
102
102
  *
@@ -108,9 +108,9 @@ export declare class Auth {
108
108
  *
109
109
  * @param {string} spoke Desired spoke
110
110
  * @param {LoginPromptOptions} options Aesthetic options
111
- * @return {Promise<void>} Login complete
111
+ * @return {LoginPrompt} Login prompt
112
112
  */
113
- loginPrompt(spoke: string, options?: LoginPromptOptions): Promise<void>;
113
+ loginPrompt(spoke: string, options?: LoginPromptOptions): LoginPrompt;
114
114
  /**
115
115
  * Logout current user
116
116
  *
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE/D,mBAAmB;AACnB,MAAM,MAAM,IAAI,GAAG;IAClB,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;CACd,CAAA;AAED;;GAEG;AACH,qBAAa,IAAI;IAUJ,OAAO,CAAC,QAAQ,CAAC,GAAG;IAThC,oCAAoC;IACpC,KAAK,2CAA2D;IAChE,mBAAmB;IACnB,IAAI,IAAI,IAEO,IAAI,GAAG,IAAI,GAAG,SAAS,CAFM;IAC5C,4BAA4B;IAC5B,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,EAA4B;IAElE,IAAI,KAAK,kBAAiD;gBAE7B,GAAG,EAAE,GAAG;IAErC;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,I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I,OAAO,CAAC,OAAO,CAAC;IAOpC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAOtC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAOrC;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzH;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAS1B;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IAIrE;;;;OAIG;IACH,MAAM;gBAC6B,MAAM;aAAO,MAAM;;IAOtD;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAWvD;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO;CAI3D"}
package/dist/index.cjs CHANGED
@@ -1308,6 +1308,38 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1308
1308
  };
1309
1309
  return BehaviorSubject2;
1310
1310
  }(Subject);
1311
+ var EmptyError = createErrorClass(function(_super) {
1312
+ return function EmptyErrorImpl() {
1313
+ _super(this);
1314
+ this.name = "EmptyError";
1315
+ this.message = "no elements in sequence";
1316
+ };
1317
+ });
1318
+ function firstValueFrom(source, config2) {
1319
+ return new Promise(function(resolve, reject) {
1320
+ var subscriber = new SafeSubscriber({
1321
+ next: function(value) {
1322
+ resolve(value);
1323
+ subscriber.unsubscribe();
1324
+ },
1325
+ error: reject,
1326
+ complete: function() {
1327
+ {
1328
+ reject(new EmptyError());
1329
+ }
1330
+ }
1331
+ });
1332
+ source.subscribe(subscriber);
1333
+ });
1334
+ }
1335
+ function filter(predicate, thisArg) {
1336
+ return operate(function(source, subscriber) {
1337
+ var index = 0;
1338
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1339
+ return predicate.call(thisArg, value, index++) && subscriber.next(value);
1340
+ }));
1341
+ });
1342
+ }
1311
1343
  function distinctUntilChanged(comparator, keySelector) {
1312
1344
  if (keySelector === void 0) {
1313
1345
  keySelector = identity;
@@ -1578,6 +1610,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1578
1610
  /** Current user as an observable */
1579
1611
  __publicField(this, "user$", new BehaviorSubject(void 0));
1580
1612
  this.api = api;
1613
+ this.api.token$.subscribe(() => this.current());
1581
1614
  }
1582
1615
  /** Current user */
1583
1616
  get user() {
@@ -1625,7 +1658,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1625
1658
  location.reload();
1626
1659
  });
1627
1660
  } else {
1628
- await this.loginPrompt(spoke, options);
1661
+ await this.loginPrompt(spoke, options).done;
1629
1662
  location.reload();
1630
1663
  }
1631
1664
  }
@@ -1697,7 +1730,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1697
1730
  const data = await resp.json().catch(() => ({}));
1698
1731
  if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
1699
1732
  this.api.token = data["token"];
1700
- return data;
1733
+ return await firstValueFrom(this.user$.pipe(filter((u) => (u == null ? void 0 : u.token) == data["token"])));
1701
1734
  });
1702
1735
  }
1703
1736
  /**
@@ -1718,10 +1751,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1718
1751
  *
1719
1752
  * @param {string} spoke Desired spoke
1720
1753
  * @param {LoginPromptOptions} options Aesthetic options
1721
- * @return {Promise<void>} Login complete
1754
+ * @return {LoginPrompt} Login prompt
1722
1755
  */
1723
1756
  loginPrompt(spoke, options) {
1724
- return new LoginPrompt(this.api, spoke, options).done;
1757
+ return new LoginPrompt(this.api, spoke, options);
1725
1758
  }
1726
1759
  /**
1727
1760
  * Logout current user
@@ -2334,12 +2367,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2334
2367
  __publicField(this, "open", false);
2335
2368
  this.api = api;
2336
2369
  this.options = options;
2337
- const url = new URL(this.api.url.replace("http", "ws"));
2338
- url.port = "9390";
2339
- this.options = {
2340
- url: url.origin,
2341
- ...this.options
2342
- };
2370
+ if (!options.url && options.url !== false) {
2371
+ const url = new URL(this.api.url.replace("http", "ws"));
2372
+ url.port = "9390";
2373
+ this.options.url = url.origin;
2374
+ }
2343
2375
  if (this.options.url !== false)
2344
2376
  api.token$.pipe(distinctUntilChanged()).subscribe(() => this.connect());
2345
2377
  }
@@ -2370,7 +2402,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2370
2402
  * @param {number} timeout Retry to connect every x seconds
2371
2403
  */
2372
2404
  connect(timeout = 30) {
2373
- if (!this.options.url) throw new Error("Datalynk socket disabled");
2405
+ if (this.options.url === false) return console.warn("Datalynk socket disabled");
2374
2406
  if (this.open) this.close();
2375
2407
  this.retry = setTimeout(() => {
2376
2408
  if (this.open) return;
@@ -2458,6 +2490,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2458
2490
  } });
2459
2491
  }
2460
2492
  }
2493
+ const version = "1.0.8";
2461
2494
  class Api {
2462
2495
  /**
2463
2496
  * Connect to Datalynk & send requests
@@ -2479,20 +2512,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2479
2512
  __publicField(this, "localStorageKey", "datalynk-token");
2480
2513
  /** Pending requests cache */
2481
2514
  __publicField(this, "pending", {});
2482
- /** Authentication helpers */
2515
+ /** API URL */
2516
+ __publicField(this, "url");
2517
+ /** Package version */
2518
+ __publicField(this, "version", version);
2519
+ /** API Session token */
2520
+ __publicField(this, "token$", new BehaviorSubject(null));
2521
+ /** Helpers */
2522
+ /** Authentication */
2483
2523
  __publicField(this, "auth", new Auth(this));
2484
- /** File helpers */
2524
+ /** File */
2485
2525
  __publicField(this, "files", new Files(this));
2486
- /** PDF helpers */
2526
+ /** PDF */
2487
2527
  __publicField(this, "pdf", new Pdf(this));
2488
- /** Socket object */
2528
+ /** Socket */
2489
2529
  __publicField(this, "socket");
2490
- /** Superuser helpers */
2530
+ /** Superuser */
2491
2531
  __publicField(this, "superuser", new Superuser(this));
2492
- /** API URL endpoint */
2493
- __publicField(this, "url");
2494
- /** API Session token */
2495
- __publicField(this, "token$", new BehaviorSubject(null));
2496
2532
  this.options = options;
2497
2533
  this.url = `${new URL(url).origin}/api/`;
2498
2534
  this.options = {
@@ -2511,7 +2547,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2511
2547
  });
2512
2548
  }
2513
2549
  Slice.api = this;
2514
- this.token$.subscribe(() => this.auth.current());
2515
2550
  this.socket = new Socket(this, { url: options.socket });
2516
2551
  }
2517
2552
  get token() {
package/dist/index.mjs CHANGED
@@ -1304,6 +1304,38 @@ var BehaviorSubject = function(_super) {
1304
1304
  };
1305
1305
  return BehaviorSubject2;
1306
1306
  }(Subject);
1307
+ var EmptyError = createErrorClass(function(_super) {
1308
+ return function EmptyErrorImpl() {
1309
+ _super(this);
1310
+ this.name = "EmptyError";
1311
+ this.message = "no elements in sequence";
1312
+ };
1313
+ });
1314
+ function firstValueFrom(source, config2) {
1315
+ return new Promise(function(resolve, reject) {
1316
+ var subscriber = new SafeSubscriber({
1317
+ next: function(value) {
1318
+ resolve(value);
1319
+ subscriber.unsubscribe();
1320
+ },
1321
+ error: reject,
1322
+ complete: function() {
1323
+ {
1324
+ reject(new EmptyError());
1325
+ }
1326
+ }
1327
+ });
1328
+ source.subscribe(subscriber);
1329
+ });
1330
+ }
1331
+ function filter(predicate, thisArg) {
1332
+ return operate(function(source, subscriber) {
1333
+ var index = 0;
1334
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1335
+ return predicate.call(thisArg, value, index++) && subscriber.next(value);
1336
+ }));
1337
+ });
1338
+ }
1307
1339
  function distinctUntilChanged(comparator, keySelector) {
1308
1340
  if (keySelector === void 0) {
1309
1341
  keySelector = identity;
@@ -1574,6 +1606,7 @@ class Auth {
1574
1606
  /** Current user as an observable */
1575
1607
  __publicField(this, "user$", new BehaviorSubject(void 0));
1576
1608
  this.api = api;
1609
+ this.api.token$.subscribe(() => this.current());
1577
1610
  }
1578
1611
  /** Current user */
1579
1612
  get user() {
@@ -1621,7 +1654,7 @@ class Auth {
1621
1654
  location.reload();
1622
1655
  });
1623
1656
  } else {
1624
- await this.loginPrompt(spoke, options);
1657
+ await this.loginPrompt(spoke, options).done;
1625
1658
  location.reload();
1626
1659
  }
1627
1660
  }
@@ -1693,7 +1726,7 @@ class Auth {
1693
1726
  const data = await resp.json().catch(() => ({}));
1694
1727
  if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
1695
1728
  this.api.token = data["token"];
1696
- return data;
1729
+ return await firstValueFrom(this.user$.pipe(filter((u) => (u == null ? void 0 : u.token) == data["token"])));
1697
1730
  });
1698
1731
  }
1699
1732
  /**
@@ -1714,10 +1747,10 @@ class Auth {
1714
1747
  *
1715
1748
  * @param {string} spoke Desired spoke
1716
1749
  * @param {LoginPromptOptions} options Aesthetic options
1717
- * @return {Promise<void>} Login complete
1750
+ * @return {LoginPrompt} Login prompt
1718
1751
  */
1719
1752
  loginPrompt(spoke, options) {
1720
- return new LoginPrompt(this.api, spoke, options).done;
1753
+ return new LoginPrompt(this.api, spoke, options);
1721
1754
  }
1722
1755
  /**
1723
1756
  * Logout current user
@@ -2330,12 +2363,11 @@ class Socket {
2330
2363
  __publicField(this, "open", false);
2331
2364
  this.api = api;
2332
2365
  this.options = options;
2333
- const url = new URL(this.api.url.replace("http", "ws"));
2334
- url.port = "9390";
2335
- this.options = {
2336
- url: url.origin,
2337
- ...this.options
2338
- };
2366
+ if (!options.url && options.url !== false) {
2367
+ const url = new URL(this.api.url.replace("http", "ws"));
2368
+ url.port = "9390";
2369
+ this.options.url = url.origin;
2370
+ }
2339
2371
  if (this.options.url !== false)
2340
2372
  api.token$.pipe(distinctUntilChanged()).subscribe(() => this.connect());
2341
2373
  }
@@ -2366,7 +2398,7 @@ class Socket {
2366
2398
  * @param {number} timeout Retry to connect every x seconds
2367
2399
  */
2368
2400
  connect(timeout = 30) {
2369
- if (!this.options.url) throw new Error("Datalynk socket disabled");
2401
+ if (this.options.url === false) return console.warn("Datalynk socket disabled");
2370
2402
  if (this.open) this.close();
2371
2403
  this.retry = setTimeout(() => {
2372
2404
  if (this.open) return;
@@ -2454,6 +2486,7 @@ class Superuser {
2454
2486
  } });
2455
2487
  }
2456
2488
  }
2489
+ const version = "1.0.8";
2457
2490
  class Api {
2458
2491
  /**
2459
2492
  * Connect to Datalynk & send requests
@@ -2475,20 +2508,23 @@ class Api {
2475
2508
  __publicField(this, "localStorageKey", "datalynk-token");
2476
2509
  /** Pending requests cache */
2477
2510
  __publicField(this, "pending", {});
2478
- /** Authentication helpers */
2511
+ /** API URL */
2512
+ __publicField(this, "url");
2513
+ /** Package version */
2514
+ __publicField(this, "version", version);
2515
+ /** API Session token */
2516
+ __publicField(this, "token$", new BehaviorSubject(null));
2517
+ /** Helpers */
2518
+ /** Authentication */
2479
2519
  __publicField(this, "auth", new Auth(this));
2480
- /** File helpers */
2520
+ /** File */
2481
2521
  __publicField(this, "files", new Files(this));
2482
- /** PDF helpers */
2522
+ /** PDF */
2483
2523
  __publicField(this, "pdf", new Pdf(this));
2484
- /** Socket object */
2524
+ /** Socket */
2485
2525
  __publicField(this, "socket");
2486
- /** Superuser helpers */
2526
+ /** Superuser */
2487
2527
  __publicField(this, "superuser", new Superuser(this));
2488
- /** API URL endpoint */
2489
- __publicField(this, "url");
2490
- /** API Session token */
2491
- __publicField(this, "token$", new BehaviorSubject(null));
2492
2528
  this.options = options;
2493
2529
  this.url = `${new URL(url).origin}/api/`;
2494
2530
  this.options = {
@@ -2507,7 +2543,6 @@ class Api {
2507
2543
  });
2508
2544
  }
2509
2545
  Slice.api = this;
2510
- this.token$.subscribe(() => this.auth.current());
2511
2546
  this.socket = new Socket(this, { url: options.socket });
2512
2547
  }
2513
2548
  get token() {
@@ -38,6 +38,6 @@ export declare class LoginPrompt {
38
38
  /** Check if login prompt is still open */
39
39
  isOpen(): boolean;
40
40
  /** Login form submit event */
41
- login(event: any): Promise<any>;
41
+ login(event: any): Promise<void | import('./auth').User>;
42
42
  }
43
43
  //# sourceMappingURL=login-prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AACA,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;AACr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AC;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;IAON,OAAO,CAAC,QAAQ,CAAC,GAAG;aAAuB,OAAO,EAAE,aAAa;IAN7E,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,KAAK,CAAC,CAAM;IACpB,OAAO,CAAC,MAAM,CAAC,CAAY;IAE3B,IAAI,UAAS;gBAEgB,GAAG,EAAE,GAAG,EAAkB,OAAO,GAAE,aAAkB;IAYlF;;;;;OAKG;IACH,WAAW,CAAC,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,IAAI,GAAG,WAAW;IAKnE;;OAEG;IACH,KAAK;IASL;;;OAGG;IACH,OAAO,CAAC,OAAO,GAAE,MAAW;IAgC5B;;;;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;CAclH"}
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": "1.0.5",
5
+ "version": "1.0.8",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",