@auxilium/datalynk-client 0.8.2 → 0.9.1

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
  ```
@@ -3,7 +3,7 @@
3
3
  import fs from 'fs';
4
4
  import {join} from 'path';
5
5
  import {Api} from '../dist/index.mjs';
6
- import * as readline from 'node:readline';
6
+ import {ask} from '@ztimson/node-utils';
7
7
 
8
8
  const FieldType = {
9
9
  'control_checkbox': 'checkbox',
@@ -28,48 +28,6 @@ const universalFields = [
28
28
  {id: 'modifierRef', readonly: true, type: 'number'}
29
29
  ]
30
30
 
31
- // Promise wrapper for reading console input
32
- function ask(prompt, hide = false) {
33
- const rl = readline.createInterface({
34
- input: process.stdin,
35
- output: process.stdout,
36
- terminal: true
37
- });
38
-
39
- return new Promise((resolve) => {
40
- if (!hide) {
41
- rl.question(prompt, (answer) => {
42
- rl.close();
43
- resolve(answer);
44
- });
45
- } else {
46
- rl.output.write(prompt);
47
- let input = '';
48
-
49
- // Listen for 'keypress' to handle masking
50
- rl.input.on('keypress', (char, key) => {
51
- if (key && key.name === 'return') {
52
- rl.output.write('\n'); // Submit on new line
53
- rl.close();
54
- resolve(input);
55
- } else if (key && key.name === 'backspace') {
56
- if (input.length > 0) {
57
- input = input.slice(0, -1);
58
- rl.output.write(`\r${prompt}${input.replaceAll(/./g, '*')} \b`);
59
- }
60
- } else {
61
- input += char;
62
- rl.output.write('\b*'); // Mask the input with '*'
63
- }
64
- });
65
-
66
- // Restore settings
67
- rl.input.setRawMode(true);
68
- rl.input.resume();
69
- }
70
- });
71
- }
72
-
73
31
  // Shorthand for getting spoke credentials
74
32
  async function getCredentials(out, spoke, login, password) {
75
33
  if(!out) out = await ask('Output (src/models): ') || 'src/models';
package/dist/auth.d.ts CHANGED
@@ -91,10 +91,13 @@ export declare class Auth {
91
91
  * @param {string} login Login username or email
92
92
  * @param {string} password Password for account
93
93
  * @param {string} spoke Override login spoke
94
- * @param {string} twoFactor 2FA code
94
+ * @param {twoFactor?: string, expire?: string} opts 2FA code & expire date (YYYY-MM-DD)
95
95
  * @returns {Promise<any>} Session information returned from login request
96
96
  */
97
- login(spoke: string, login: string, password: string, twoFactor?: string): Promise<any>;
97
+ login(spoke: string, login: string, password: string, opts?: {
98
+ twoFactor?: string;
99
+ expire?: null | string;
100
+ }): Promise<any>;
98
101
  /**
99
102
  * Login as guest user
100
103
  *
@@ -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,kBAA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,CAAC;IAqBxH;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAS1B;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;;;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
@@ -6,22 +6,22 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
8
  var __defProp2 = Object.defineProperty;
9
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ var __defNormalProp2 = (obj, key, value2) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
10
+ var __publicField2 = (obj, key, value2) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value2);
11
11
  function clean(obj, undefinedOnly = false) {
12
12
  if (obj == null) throw new Error("Cannot clean a NULL value");
13
13
  if (Array.isArray(obj)) {
14
14
  obj = obj.filter((o) => o != null);
15
15
  } else {
16
- Object.entries(obj).forEach(([key, value]) => {
17
- if (undefinedOnly && value === void 0 || !undefinedOnly && value == null) delete obj[key];
16
+ Object.entries(obj).forEach(([key, value2]) => {
17
+ if (undefinedOnly && value2 === void 0 || !undefinedOnly && value2 == null) delete obj[key];
18
18
  });
19
19
  }
20
20
  return obj;
21
21
  }
22
22
  function formData(target) {
23
23
  const data = new FormData();
24
- Object.entries(target).forEach(([key, value]) => data.append(key, value));
24
+ Object.entries(target).forEach(([key, value2]) => data.append(key, value2));
25
25
  return data;
26
26
  }
27
27
  function JSONAttemptParse(json) {
@@ -32,19 +32,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32
32
  }
33
33
  }
34
34
  function JSONSanitize(obj, space) {
35
- let cache = [];
36
- return JSON.stringify(obj, (key, value) => {
37
- if (typeof value === "object" && value !== null) {
38
- if (cache.includes(value)) return;
39
- cache.push(value);
40
- }
41
- return value;
35
+ return JSON.stringify(obj, (key, value2) => {
36
+ return value2;
42
37
  }, space);
43
38
  }
44
39
  class PromiseProgress extends Promise {
45
40
  constructor(executor) {
46
41
  super((resolve, reject) => executor(
47
- (value) => resolve(value),
42
+ (value2) => resolve(value2),
48
43
  (reason) => reject(reason),
49
44
  (progress) => this.progress = progress
50
45
  ));
@@ -54,10 +49,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
54
49
  get progress() {
55
50
  return this._progress;
56
51
  }
57
- set progress(p) {
58
- if (p == this._progress) return;
59
- this._progress = p;
60
- this.listeners.forEach((l) => l(p));
52
+ set progress(p2) {
53
+ if (p2 == this._progress) return;
54
+ this._progress = p2;
55
+ this.listeners.forEach((l) => l(p2));
61
56
  }
62
57
  static from(promise) {
63
58
  if (promise instanceof PromiseProgress) return promise;
@@ -65,7 +60,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
65
60
  }
66
61
  from(promise) {
67
62
  const newPromise = PromiseProgress.from(promise);
68
- this.onProgress((p) => newPromise.progress = p);
63
+ this.onProgress((p2) => newPromise.progress = p2);
69
64
  return newPromise;
70
65
  }
71
66
  onProgress(callback) {
@@ -467,6 +462,106 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
467
462
  }
468
463
  };
469
464
  __publicField2(_Logger, "LOG_LEVEL", 4);
465
+ function formatDate(format = "YYYY-MM-DD H:mm", date = /* @__PURE__ */ new Date(), tz) {
466
+ const timezones = [
467
+ ["IDLW", -12],
468
+ ["SST", -11],
469
+ ["HST", -10],
470
+ ["AKST", -9],
471
+ ["PST", -8],
472
+ ["MST", -7],
473
+ ["CST", -6],
474
+ ["EST", -5],
475
+ ["AST", -4],
476
+ ["BRT", -3],
477
+ ["MAT", -2],
478
+ ["AZOT", -1],
479
+ ["UTC", 0],
480
+ ["CET", 1],
481
+ ["EET", 2],
482
+ ["MSK", 3],
483
+ ["AST", 4],
484
+ ["PKT", 5],
485
+ ["IST", 5.5],
486
+ ["BST", 6],
487
+ ["ICT", 7],
488
+ ["CST", 8],
489
+ ["JST", 9],
490
+ ["AEST", 10],
491
+ ["SBT", 11],
492
+ ["FJT", 12],
493
+ ["TOT", 13],
494
+ ["LINT", 14]
495
+ ];
496
+ function adjustTz(date2, gmt) {
497
+ const currentOffset = date2.getTimezoneOffset();
498
+ const adjustedOffset = gmt * 60;
499
+ return new Date(date2.getTime() + (adjustedOffset + currentOffset) * 6e4);
500
+ }
501
+ function day(num) {
502
+ return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][num] || "Unknown";
503
+ }
504
+ function doy(date2) {
505
+ const start = /* @__PURE__ */ new Date(`${date2.getFullYear()}-01-01 0:00:00`);
506
+ return Math.ceil((date2.getTime() - start.getTime()) / (1e3 * 60 * 60 * 24));
507
+ }
508
+ function month(num) {
509
+ return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][num] || "Unknown";
510
+ }
511
+ function suffix(num) {
512
+ if (num % 100 >= 11 && num % 100 <= 13) return `${num}th`;
513
+ switch (num % 10) {
514
+ case 1:
515
+ return `${num}st`;
516
+ case 2:
517
+ return `${num}nd`;
518
+ case 3:
519
+ return `${num}rd`;
520
+ default:
521
+ return `${num}th`;
522
+ }
523
+ }
524
+ function tzOffset(offset) {
525
+ const hours = ~~(offset / 60);
526
+ const minutes = offset % 60;
527
+ return (offset > 0 ? "-" : "") + `${hours}:${minutes.toString().padStart(2, "0")}`;
528
+ }
529
+ if (typeof date == "number" || typeof date == "string") date = new Date(date);
530
+ let t;
531
+ if (tz == null) tz = -(date.getTimezoneOffset() / 60);
532
+ t = timezones.find((t2) => isNaN(tz) ? t2[0] == tz : t2[1] == tz);
533
+ if (!t) throw new Error(`Unknown timezone: ${tz}`);
534
+ date = adjustTz(date, t[1]);
535
+ const tokens = {
536
+ "YYYY": date.getFullYear().toString(),
537
+ "YY": date.getFullYear().toString().slice(2),
538
+ "MMMM": month(date.getMonth()),
539
+ "MMM": month(date.getMonth()).slice(0, 3),
540
+ "MM": (date.getMonth() + 1).toString().padStart(2, "0"),
541
+ "M": (date.getMonth() + 1).toString(),
542
+ "DDD": doy(date).toString(),
543
+ "DD": date.getDate().toString().padStart(2, "0"),
544
+ "Do": suffix(date.getDate()),
545
+ "D": date.getDate().toString(),
546
+ "dddd": day(date.getDay()),
547
+ "ddd": day(date.getDay()).slice(0, 3),
548
+ "HH": date.getHours().toString().padStart(2, "0"),
549
+ "H": date.getHours().toString(),
550
+ "hh": (date.getHours() % 12 || 12).toString().padStart(2, "0"),
551
+ "h": (date.getHours() % 12 || 12).toString(),
552
+ "mm": date.getMinutes().toString().padStart(2, "0"),
553
+ "m": date.getMinutes().toString(),
554
+ "ss": date.getSeconds().toString().padStart(2, "0"),
555
+ "s": date.getSeconds().toString(),
556
+ "SSS": date.getMilliseconds().toString().padStart(3, "0"),
557
+ "A": date.getHours() >= 12 ? "PM" : "AM",
558
+ "a": date.getHours() >= 12 ? "pm" : "am",
559
+ "ZZ": tzOffset(t[1] * 60).replace(":", ""),
560
+ "Z": tzOffset(t[1] * 60),
561
+ "z": typeof tz == "string" ? tz : t[0]
562
+ };
563
+ return format.replace(/YYYY|YY|MMMM|MMM|MM|M|DDD|DD|Do|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|SSS|A|a|ZZ|Z|z/g, (token) => tokens[token]);
564
+ }
470
565
  function sleep(ms) {
471
566
  return new Promise((res) => setTimeout(res, ms));
472
567
  }
@@ -1268,6 +1363,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1268
1363
  __publicField(this, "button");
1269
1364
  __publicField(this, "form");
1270
1365
  __publicField(this, "password");
1366
+ __publicField(this, "persist");
1271
1367
  __publicField(this, "username");
1272
1368
  __publicField(this, "_done");
1273
1369
  /** Promise which resolves once login is complete */
@@ -1282,7 +1378,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1282
1378
  this.alert = document.querySelector("#datalynk-login-alert");
1283
1379
  this.button = document.querySelector("#datalynk-login-form button");
1284
1380
  this.form = document.querySelector("#datalynk-login-form");
1285
- this.password = document.querySelector('#datalynk-login-form input[name="password"]'), this.username = document.querySelector('#datalynk-login-form input[name="username"]'), this.form.onsubmit = (event) => this.login(event);
1381
+ this.password = document.querySelector('#datalynk-login-form input[name="password"]');
1382
+ this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
1383
+ this.username = document.querySelector('#datalynk-login-form input[name="username"]');
1384
+ this.form.onsubmit = (event) => this.login(event);
1385
+ if (options.persist === false) this.persist.parentElement.style.display = "none";
1286
1386
  }
1287
1387
  /**
1288
1388
  * Close the login prompt
@@ -1303,8 +1403,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1303
1403
  this.alert.classList.add("hidden");
1304
1404
  this.username.disabled = true;
1305
1405
  this.password.disabled = true;
1406
+ this.persist.disabled = true;
1306
1407
  this.button.disabled = true;
1307
- return this.api.auth.login(this.spoke, data.get("username"), data.get("password")).then((data2) => {
1408
+ return this.api.auth.login(
1409
+ this.spoke,
1410
+ data.get("username"),
1411
+ data.get("password"),
1412
+ { expire: this.persist.checked ? null : void 0 }
1413
+ ).then((data2) => {
1308
1414
  this.close();
1309
1415
  this._done();
1310
1416
  return data2;
@@ -1314,6 +1420,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1314
1420
  this.password.value = "";
1315
1421
  this.username.disabled = false;
1316
1422
  this.password.disabled = false;
1423
+ this.persist.disabled = false;
1317
1424
  this.button.disabled = false;
1318
1425
  });
1319
1426
  }
@@ -1466,6 +1573,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1466
1573
  <input id="password" name="password" type="password" autocomplete="current-password">
1467
1574
  </div>
1468
1575
  <br>
1576
+ <label style="display: block; margin-bottom: 0.75rem;">
1577
+ <input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
1578
+ </label>
1469
1579
  <button>Login</button>
1470
1580
  </form>
1471
1581
  </div>
@@ -1593,17 +1703,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1593
1703
  * @param {string} login Login username or email
1594
1704
  * @param {string} password Password for account
1595
1705
  * @param {string} spoke Override login spoke
1596
- * @param {string} twoFactor 2FA code
1706
+ * @param {twoFactor?: string, expire?: string} opts 2FA code & expire date (YYYY-MM-DD)
1597
1707
  * @returns {Promise<any>} Session information returned from login request
1598
1708
  */
1599
- login(spoke, login, password, twoFactor) {
1709
+ login(spoke, login, password, opts) {
1710
+ const date = /* @__PURE__ */ new Date();
1711
+ date.setFullYear(date.getFullYear() + 1);
1600
1712
  return fetch(`${this.api.url}login`, {
1601
1713
  method: "POST",
1602
1714
  body: formData(clean({
1603
1715
  realm: spoke.trim(),
1604
1716
  login: login.trim(),
1605
1717
  password: password.trim(),
1606
- secret: twoFactor,
1718
+ secret: opts == null ? void 0 : opts.twoFactor,
1719
+ expireAt: (opts == null ? void 0 : opts.expire) == null ? formatDate("YYYY-MM-DD", date) : opts == null ? void 0 : opts.expire,
1607
1720
  dateFormat: "ISO8601"
1608
1721
  }))
1609
1722
  }).then(async (resp) => {
@@ -2013,6 +2126,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2013
2126
  alias(aliasKeyVals) {
2014
2127
  return this.fields(aliasKeyVals);
2015
2128
  }
2129
+ /**
2130
+ * Add an 'AND' condition inside the where argument
2131
+ */
2132
+ and() {
2133
+ var _a;
2134
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$and") return this;
2135
+ if (this.request.where) this.request.where = ["$and", this.request.where];
2136
+ else this.request.where = ["$and"];
2137
+ return this;
2138
+ }
2016
2139
  /**
2017
2140
  * Output the formed request to the console for inspection
2018
2141
  */
@@ -2077,6 +2200,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2077
2200
  limit(num) {
2078
2201
  this.request.limit = num;
2079
2202
  }
2203
+ /**
2204
+ * Add an 'OR' condition inside the where argument
2205
+ */
2206
+ or() {
2207
+ var _a;
2208
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or") return this;
2209
+ if (this.request.where) this.request.where = ["$or", this.request.where];
2210
+ else this.request.where = ["$or"];
2211
+ return this;
2212
+ }
2080
2213
  /**
2081
2214
  * Order rows by a field
2082
2215
  *
@@ -2137,39 +2270,45 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2137
2270
  * Add where condition to request. Chaining wheres creates an AND between them. To perform an OR look at
2138
2271
  * the filter function
2139
2272
  *
2140
- * @param {string} field property to compare
2273
+ * @param {string | object} field property to compare or a map of equality comparisons
2141
2274
  * @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
2142
2275
  * @param {any} value value to compare against
2143
2276
  */
2144
2277
  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;
2278
+ this.and();
2279
+ if (typeof field == "object") {
2280
+ Object.entries(field).forEach(([key, value2]) => this.request.where.push(["$eq", ["$field", key], value2]));
2281
+ } else if (operator == null) {
2282
+ throw new Error("Malformed where clause");
2283
+ } else {
2284
+ switch (operator) {
2285
+ case "==":
2286
+ operator = "$eq";
2287
+ break;
2288
+ case "!=":
2289
+ operator = "$neq";
2290
+ break;
2291
+ case ">":
2292
+ operator = "$gt";
2293
+ break;
2294
+ case ">=":
2295
+ operator = "$gte";
2296
+ break;
2297
+ case "<":
2298
+ operator = "$lt";
2299
+ break;
2300
+ case "<=":
2301
+ operator = "$lte";
2302
+ break;
2303
+ case "!":
2304
+ operator = "$not";
2305
+ break;
2306
+ case "%":
2307
+ operator = "$mod";
2308
+ break;
2309
+ }
2310
+ this.request.where.push([operator, ["$field", field], value]);
2170
2311
  }
2171
- if (!this.request.where) this.request.where = ["$and"];
2172
- this.request.where.push([operator, ["$field", field], value]);
2173
2312
  return this;
2174
2313
  }
2175
2314
  }
package/dist/index.mjs CHANGED
@@ -2,22 +2,22 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  var __defProp2 = Object.defineProperty;
5
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ var __defNormalProp2 = (obj, key, value2) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
6
+ var __publicField2 = (obj, key, value2) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value2);
7
7
  function clean(obj, undefinedOnly = false) {
8
8
  if (obj == null) throw new Error("Cannot clean a NULL value");
9
9
  if (Array.isArray(obj)) {
10
10
  obj = obj.filter((o) => o != null);
11
11
  } else {
12
- Object.entries(obj).forEach(([key, value]) => {
13
- if (undefinedOnly && value === void 0 || !undefinedOnly && value == null) delete obj[key];
12
+ Object.entries(obj).forEach(([key, value2]) => {
13
+ if (undefinedOnly && value2 === void 0 || !undefinedOnly && value2 == null) delete obj[key];
14
14
  });
15
15
  }
16
16
  return obj;
17
17
  }
18
18
  function formData(target) {
19
19
  const data = new FormData();
20
- Object.entries(target).forEach(([key, value]) => data.append(key, value));
20
+ Object.entries(target).forEach(([key, value2]) => data.append(key, value2));
21
21
  return data;
22
22
  }
23
23
  function JSONAttemptParse(json) {
@@ -28,19 +28,14 @@ function JSONAttemptParse(json) {
28
28
  }
29
29
  }
30
30
  function JSONSanitize(obj, space) {
31
- let cache = [];
32
- return JSON.stringify(obj, (key, value) => {
33
- if (typeof value === "object" && value !== null) {
34
- if (cache.includes(value)) return;
35
- cache.push(value);
36
- }
37
- return value;
31
+ return JSON.stringify(obj, (key, value2) => {
32
+ return value2;
38
33
  }, space);
39
34
  }
40
35
  class PromiseProgress extends Promise {
41
36
  constructor(executor) {
42
37
  super((resolve, reject) => executor(
43
- (value) => resolve(value),
38
+ (value2) => resolve(value2),
44
39
  (reason) => reject(reason),
45
40
  (progress) => this.progress = progress
46
41
  ));
@@ -50,10 +45,10 @@ class PromiseProgress extends Promise {
50
45
  get progress() {
51
46
  return this._progress;
52
47
  }
53
- set progress(p) {
54
- if (p == this._progress) return;
55
- this._progress = p;
56
- this.listeners.forEach((l) => l(p));
48
+ set progress(p2) {
49
+ if (p2 == this._progress) return;
50
+ this._progress = p2;
51
+ this.listeners.forEach((l) => l(p2));
57
52
  }
58
53
  static from(promise) {
59
54
  if (promise instanceof PromiseProgress) return promise;
@@ -61,7 +56,7 @@ class PromiseProgress extends Promise {
61
56
  }
62
57
  from(promise) {
63
58
  const newPromise = PromiseProgress.from(promise);
64
- this.onProgress((p) => newPromise.progress = p);
59
+ this.onProgress((p2) => newPromise.progress = p2);
65
60
  return newPromise;
66
61
  }
67
62
  onProgress(callback) {
@@ -463,6 +458,106 @@ const _Logger = class _Logger2 extends TypedEmitter {
463
458
  }
464
459
  };
465
460
  __publicField2(_Logger, "LOG_LEVEL", 4);
461
+ function formatDate(format = "YYYY-MM-DD H:mm", date = /* @__PURE__ */ new Date(), tz) {
462
+ const timezones = [
463
+ ["IDLW", -12],
464
+ ["SST", -11],
465
+ ["HST", -10],
466
+ ["AKST", -9],
467
+ ["PST", -8],
468
+ ["MST", -7],
469
+ ["CST", -6],
470
+ ["EST", -5],
471
+ ["AST", -4],
472
+ ["BRT", -3],
473
+ ["MAT", -2],
474
+ ["AZOT", -1],
475
+ ["UTC", 0],
476
+ ["CET", 1],
477
+ ["EET", 2],
478
+ ["MSK", 3],
479
+ ["AST", 4],
480
+ ["PKT", 5],
481
+ ["IST", 5.5],
482
+ ["BST", 6],
483
+ ["ICT", 7],
484
+ ["CST", 8],
485
+ ["JST", 9],
486
+ ["AEST", 10],
487
+ ["SBT", 11],
488
+ ["FJT", 12],
489
+ ["TOT", 13],
490
+ ["LINT", 14]
491
+ ];
492
+ function adjustTz(date2, gmt) {
493
+ const currentOffset = date2.getTimezoneOffset();
494
+ const adjustedOffset = gmt * 60;
495
+ return new Date(date2.getTime() + (adjustedOffset + currentOffset) * 6e4);
496
+ }
497
+ function day(num) {
498
+ return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][num] || "Unknown";
499
+ }
500
+ function doy(date2) {
501
+ const start = /* @__PURE__ */ new Date(`${date2.getFullYear()}-01-01 0:00:00`);
502
+ return Math.ceil((date2.getTime() - start.getTime()) / (1e3 * 60 * 60 * 24));
503
+ }
504
+ function month(num) {
505
+ return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][num] || "Unknown";
506
+ }
507
+ function suffix(num) {
508
+ if (num % 100 >= 11 && num % 100 <= 13) return `${num}th`;
509
+ switch (num % 10) {
510
+ case 1:
511
+ return `${num}st`;
512
+ case 2:
513
+ return `${num}nd`;
514
+ case 3:
515
+ return `${num}rd`;
516
+ default:
517
+ return `${num}th`;
518
+ }
519
+ }
520
+ function tzOffset(offset) {
521
+ const hours = ~~(offset / 60);
522
+ const minutes = offset % 60;
523
+ return (offset > 0 ? "-" : "") + `${hours}:${minutes.toString().padStart(2, "0")}`;
524
+ }
525
+ if (typeof date == "number" || typeof date == "string") date = new Date(date);
526
+ let t;
527
+ if (tz == null) tz = -(date.getTimezoneOffset() / 60);
528
+ t = timezones.find((t2) => isNaN(tz) ? t2[0] == tz : t2[1] == tz);
529
+ if (!t) throw new Error(`Unknown timezone: ${tz}`);
530
+ date = adjustTz(date, t[1]);
531
+ const tokens = {
532
+ "YYYY": date.getFullYear().toString(),
533
+ "YY": date.getFullYear().toString().slice(2),
534
+ "MMMM": month(date.getMonth()),
535
+ "MMM": month(date.getMonth()).slice(0, 3),
536
+ "MM": (date.getMonth() + 1).toString().padStart(2, "0"),
537
+ "M": (date.getMonth() + 1).toString(),
538
+ "DDD": doy(date).toString(),
539
+ "DD": date.getDate().toString().padStart(2, "0"),
540
+ "Do": suffix(date.getDate()),
541
+ "D": date.getDate().toString(),
542
+ "dddd": day(date.getDay()),
543
+ "ddd": day(date.getDay()).slice(0, 3),
544
+ "HH": date.getHours().toString().padStart(2, "0"),
545
+ "H": date.getHours().toString(),
546
+ "hh": (date.getHours() % 12 || 12).toString().padStart(2, "0"),
547
+ "h": (date.getHours() % 12 || 12).toString(),
548
+ "mm": date.getMinutes().toString().padStart(2, "0"),
549
+ "m": date.getMinutes().toString(),
550
+ "ss": date.getSeconds().toString().padStart(2, "0"),
551
+ "s": date.getSeconds().toString(),
552
+ "SSS": date.getMilliseconds().toString().padStart(3, "0"),
553
+ "A": date.getHours() >= 12 ? "PM" : "AM",
554
+ "a": date.getHours() >= 12 ? "pm" : "am",
555
+ "ZZ": tzOffset(t[1] * 60).replace(":", ""),
556
+ "Z": tzOffset(t[1] * 60),
557
+ "z": typeof tz == "string" ? tz : t[0]
558
+ };
559
+ return format.replace(/YYYY|YY|MMMM|MMM|MM|M|DDD|DD|Do|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|SSS|A|a|ZZ|Z|z/g, (token) => tokens[token]);
560
+ }
466
561
  function sleep(ms) {
467
562
  return new Promise((res) => setTimeout(res, ms));
468
563
  }
@@ -1264,6 +1359,7 @@ const _LoginPrompt = class _LoginPrompt {
1264
1359
  __publicField(this, "button");
1265
1360
  __publicField(this, "form");
1266
1361
  __publicField(this, "password");
1362
+ __publicField(this, "persist");
1267
1363
  __publicField(this, "username");
1268
1364
  __publicField(this, "_done");
1269
1365
  /** Promise which resolves once login is complete */
@@ -1278,7 +1374,11 @@ const _LoginPrompt = class _LoginPrompt {
1278
1374
  this.alert = document.querySelector("#datalynk-login-alert");
1279
1375
  this.button = document.querySelector("#datalynk-login-form button");
1280
1376
  this.form = document.querySelector("#datalynk-login-form");
1281
- this.password = document.querySelector('#datalynk-login-form input[name="password"]'), this.username = document.querySelector('#datalynk-login-form input[name="username"]'), this.form.onsubmit = (event) => this.login(event);
1377
+ this.password = document.querySelector('#datalynk-login-form input[name="password"]');
1378
+ this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
1379
+ this.username = document.querySelector('#datalynk-login-form input[name="username"]');
1380
+ this.form.onsubmit = (event) => this.login(event);
1381
+ if (options.persist === false) this.persist.parentElement.style.display = "none";
1282
1382
  }
1283
1383
  /**
1284
1384
  * Close the login prompt
@@ -1299,8 +1399,14 @@ const _LoginPrompt = class _LoginPrompt {
1299
1399
  this.alert.classList.add("hidden");
1300
1400
  this.username.disabled = true;
1301
1401
  this.password.disabled = true;
1402
+ this.persist.disabled = true;
1302
1403
  this.button.disabled = true;
1303
- return this.api.auth.login(this.spoke, data.get("username"), data.get("password")).then((data2) => {
1404
+ return this.api.auth.login(
1405
+ this.spoke,
1406
+ data.get("username"),
1407
+ data.get("password"),
1408
+ { expire: this.persist.checked ? null : void 0 }
1409
+ ).then((data2) => {
1304
1410
  this.close();
1305
1411
  this._done();
1306
1412
  return data2;
@@ -1310,6 +1416,7 @@ const _LoginPrompt = class _LoginPrompt {
1310
1416
  this.password.value = "";
1311
1417
  this.username.disabled = false;
1312
1418
  this.password.disabled = false;
1419
+ this.persist.disabled = false;
1313
1420
  this.button.disabled = false;
1314
1421
  });
1315
1422
  }
@@ -1462,6 +1569,9 @@ __publicField(_LoginPrompt, "template", (title = "Datalynk") => `
1462
1569
  <input id="password" name="password" type="password" autocomplete="current-password">
1463
1570
  </div>
1464
1571
  <br>
1572
+ <label style="display: block; margin-bottom: 0.75rem;">
1573
+ <input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
1574
+ </label>
1465
1575
  <button>Login</button>
1466
1576
  </form>
1467
1577
  </div>
@@ -1589,17 +1699,20 @@ class Auth {
1589
1699
  * @param {string} login Login username or email
1590
1700
  * @param {string} password Password for account
1591
1701
  * @param {string} spoke Override login spoke
1592
- * @param {string} twoFactor 2FA code
1702
+ * @param {twoFactor?: string, expire?: string} opts 2FA code & expire date (YYYY-MM-DD)
1593
1703
  * @returns {Promise<any>} Session information returned from login request
1594
1704
  */
1595
- login(spoke, login, password, twoFactor) {
1705
+ login(spoke, login, password, opts) {
1706
+ const date = /* @__PURE__ */ new Date();
1707
+ date.setFullYear(date.getFullYear() + 1);
1596
1708
  return fetch(`${this.api.url}login`, {
1597
1709
  method: "POST",
1598
1710
  body: formData(clean({
1599
1711
  realm: spoke.trim(),
1600
1712
  login: login.trim(),
1601
1713
  password: password.trim(),
1602
- secret: twoFactor,
1714
+ secret: opts == null ? void 0 : opts.twoFactor,
1715
+ expireAt: (opts == null ? void 0 : opts.expire) == null ? formatDate("YYYY-MM-DD", date) : opts == null ? void 0 : opts.expire,
1603
1716
  dateFormat: "ISO8601"
1604
1717
  }))
1605
1718
  }).then(async (resp) => {
@@ -2009,6 +2122,16 @@ class Slice {
2009
2122
  alias(aliasKeyVals) {
2010
2123
  return this.fields(aliasKeyVals);
2011
2124
  }
2125
+ /**
2126
+ * Add an 'AND' condition inside the where argument
2127
+ */
2128
+ and() {
2129
+ var _a;
2130
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$and") return this;
2131
+ if (this.request.where) this.request.where = ["$and", this.request.where];
2132
+ else this.request.where = ["$and"];
2133
+ return this;
2134
+ }
2012
2135
  /**
2013
2136
  * Output the formed request to the console for inspection
2014
2137
  */
@@ -2073,6 +2196,16 @@ class Slice {
2073
2196
  limit(num) {
2074
2197
  this.request.limit = num;
2075
2198
  }
2199
+ /**
2200
+ * Add an 'OR' condition inside the where argument
2201
+ */
2202
+ or() {
2203
+ var _a;
2204
+ if (((_a = this.request.where) == null ? void 0 : _a[0]) == "$or") return this;
2205
+ if (this.request.where) this.request.where = ["$or", this.request.where];
2206
+ else this.request.where = ["$or"];
2207
+ return this;
2208
+ }
2076
2209
  /**
2077
2210
  * Order rows by a field
2078
2211
  *
@@ -2133,39 +2266,45 @@ class Slice {
2133
2266
  * Add where condition to request. Chaining wheres creates an AND between them. To perform an OR look at
2134
2267
  * the filter function
2135
2268
  *
2136
- * @param {string} field property to compare
2269
+ * @param {string | object} field property to compare or a map of equality comparisons
2137
2270
  * @param {string} operator Operation to compare with. Accepts JS operators (>=, ==, !=, ...) as well as datalynk styax ($gte, $eq, $is, $not, ...)
2138
2271
  * @param {any} value value to compare against
2139
2272
  */
2140
2273
  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;
2274
+ this.and();
2275
+ if (typeof field == "object") {
2276
+ Object.entries(field).forEach(([key, value2]) => this.request.where.push(["$eq", ["$field", key], value2]));
2277
+ } else if (operator == null) {
2278
+ throw new Error("Malformed where clause");
2279
+ } else {
2280
+ switch (operator) {
2281
+ case "==":
2282
+ operator = "$eq";
2283
+ break;
2284
+ case "!=":
2285
+ operator = "$neq";
2286
+ break;
2287
+ case ">":
2288
+ operator = "$gt";
2289
+ break;
2290
+ case ">=":
2291
+ operator = "$gte";
2292
+ break;
2293
+ case "<":
2294
+ operator = "$lt";
2295
+ break;
2296
+ case "<=":
2297
+ operator = "$lte";
2298
+ break;
2299
+ case "!":
2300
+ operator = "$not";
2301
+ break;
2302
+ case "%":
2303
+ operator = "$mod";
2304
+ break;
2305
+ }
2306
+ this.request.where.push([operator, ["$field", field], value]);
2166
2307
  }
2167
- if (!this.request.where) this.request.where = ["$and"];
2168
- this.request.where.push([operator, ["$field", field], value]);
2169
2308
  return this;
2170
2309
  }
2171
2310
  }
@@ -6,6 +6,8 @@ export type LoginPromptOptions = {
6
6
  background?: string;
7
7
  /** Foreground color hex: `#000000` */
8
8
  color?: string;
9
+ /** Allow users to stay logged in */
10
+ persist?: boolean;
9
11
  /** Header, could be a simple string: 'Datalynk' or HTML: `<img src="...">`*/
10
12
  title?: string;
11
13
  /** Text color of header, only valid when passing a string to title */
@@ -24,6 +26,7 @@ export declare class LoginPrompt {
24
26
  private readonly button;
25
27
  private readonly form;
26
28
  private readonly password;
29
+ private readonly persist;
27
30
  private readonly username;
28
31
  private _done;
29
32
  /** Promise which resolves once login is complete */
@@ -1 +1 @@
1
- {"version":3,"file":"login-prompt.d.ts","sourceRoot":"","sources":["../src/login-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG;IAChC,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAA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6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,4BAA4B;AAC5B,qBAAa,WAAW;IA4LX,OAAO,CAAC,QAAQ,CAAC,GAAG;aAAuB,KAAK,EAAE,MAAM;IAAS,OAAO,EAAE,kBAAkB;IA3LxG,mCAAmC;IACnC,OAAO,CAAC,MAAM,CAAC,GAAG,CA4HR;IAEV,8BAA8B;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CA8CrB;IAEF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAO;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAO;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAO;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAO;IAEhC,OAAO,CAAC,KAAK,CAAY;IACzB,oDAAoD;IACpD,IAAI,gBAAmD;gBAE1B,GAAG,EAAE,GAAG,EAAkB,KAAK,EAAE,MAAM,EAAS,OAAO,GAAE,kBAAuB;IAgB7G;;OAEG;IACH,KAAK;IAKL,0CAA0C;IAC1C,MAAM;IAIN,8BAA8B;IAC9B,KAAK,CAAC,KAAK,EAAE,GAAG;CA4BhB"}
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,CAAC;AAEvD,MAAM,WAAW,SAAS;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,SAAS;aAQhB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;aAAkB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAN/F;;;;;OAKG;gBACyB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAkB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAE/F;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,CAAC,K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AAC,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/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.2",
5
+ "version": "0.9.1",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",
@@ -25,7 +25,8 @@
25
25
  "watch": "vite build --watch"
26
26
  },
27
27
  "dependencies": {
28
- "@ztimson/utils": "0.21.6",
28
+ "@ztimson/node-utils": "^1.0.0",
29
+ "@ztimson/utils": "0.23.8",
29
30
  "rxjs": "^7.8.1"
30
31
  },
31
32
  "devDependencies": {