@auxilium/datalynk-client 1.0.5 → 1.0.6

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,17 +65,7 @@ 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;
80
70
  /** API Session token */
81
71
  token$: BehaviorSubject<string | null>;
@@ -83,6 +73,17 @@ export declare class Api {
83
73
  set token(token: string | null);
84
74
  /** Get session info from JWT payload */
85
75
  get jwtPayload(): JwtPayload | null;
76
+ /** Helpers */
77
+ /** Authentication */
78
+ readonly auth: Auth;
79
+ /** File */
80
+ readonly files: Files;
81
+ /** PDF */
82
+ readonly pdf: Pdf;
83
+ /** Socket */
84
+ readonly socket: Socket;
85
+ /** Superuser */
86
+ readonly superuser: Superuser;
86
87
  /**
87
88
  * Connect to Datalynk & send requests
88
89
  *
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,CAAC;AAEtC,M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ACI,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 @@
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I,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
@@ -2370,7 +2403,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2370
2403
  * @param {number} timeout Retry to connect every x seconds
2371
2404
  */
2372
2405
  connect(timeout = 30) {
2373
- if (!this.options.url) throw new Error("Datalynk socket disabled");
2406
+ if (this.options.url === false) return console.warn("Datalynk socket disabled");
2374
2407
  if (this.open) this.close();
2375
2408
  this.retry = setTimeout(() => {
2376
2409
  if (this.open) return;
@@ -2479,20 +2512,21 @@ 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
+ /** API Session token */
2518
+ __publicField(this, "token$", new BehaviorSubject(null));
2519
+ /** Helpers */
2520
+ /** Authentication */
2483
2521
  __publicField(this, "auth", new Auth(this));
2484
- /** File helpers */
2522
+ /** File */
2485
2523
  __publicField(this, "files", new Files(this));
2486
- /** PDF helpers */
2524
+ /** PDF */
2487
2525
  __publicField(this, "pdf", new Pdf(this));
2488
- /** Socket object */
2526
+ /** Socket */
2489
2527
  __publicField(this, "socket");
2490
- /** Superuser helpers */
2528
+ /** Superuser */
2491
2529
  __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
2530
  this.options = options;
2497
2531
  this.url = `${new URL(url).origin}/api/`;
2498
2532
  this.options = {
@@ -2511,7 +2545,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2511
2545
  });
2512
2546
  }
2513
2547
  Slice.api = this;
2514
- this.token$.subscribe(() => this.auth.current());
2515
2548
  this.socket = new Socket(this, { url: options.socket });
2516
2549
  }
2517
2550
  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
@@ -2366,7 +2399,7 @@ class Socket {
2366
2399
  * @param {number} timeout Retry to connect every x seconds
2367
2400
  */
2368
2401
  connect(timeout = 30) {
2369
- if (!this.options.url) throw new Error("Datalynk socket disabled");
2402
+ if (this.options.url === false) return console.warn("Datalynk socket disabled");
2370
2403
  if (this.open) this.close();
2371
2404
  this.retry = setTimeout(() => {
2372
2405
  if (this.open) return;
@@ -2475,20 +2508,21 @@ 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
+ /** API Session token */
2514
+ __publicField(this, "token$", new BehaviorSubject(null));
2515
+ /** Helpers */
2516
+ /** Authentication */
2479
2517
  __publicField(this, "auth", new Auth(this));
2480
- /** File helpers */
2518
+ /** File */
2481
2519
  __publicField(this, "files", new Files(this));
2482
- /** PDF helpers */
2520
+ /** PDF */
2483
2521
  __publicField(this, "pdf", new Pdf(this));
2484
- /** Socket object */
2522
+ /** Socket */
2485
2523
  __publicField(this, "socket");
2486
- /** Superuser helpers */
2524
+ /** Superuser */
2487
2525
  __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
2526
  this.options = options;
2493
2527
  this.url = `${new URL(url).origin}/api/`;
2494
2528
  this.options = {
@@ -2507,7 +2541,6 @@ class Api {
2507
2541
  });
2508
2542
  }
2509
2543
  Slice.api = this;
2510
- this.token$.subscribe(() => this.auth.current());
2511
2544
  this.socket = new Socket(this, { url: options.socket });
2512
2545
  }
2513
2546
  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
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.6",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",