@nxtedition/deepstream.io-client-js 31.2.4 → 31.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "31.2.4",
3
+ "version": "31.2.5",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -472,30 +472,31 @@ class RecordHandler {
472
472
  }
473
473
 
474
474
  /**
475
+ * @param {string} name
475
476
  * @param {...any} args
476
477
  * @returns {rxjs.Observable}
477
478
  */
478
- observe(...args) {
479
- return this._observe(OBSERVE_DEFAULTS, ...args)
479
+ observe(name, ...args) {
480
+ return this._observe(OBSERVE_DEFAULTS, name, ...args)
480
481
  }
481
482
 
482
483
  /**
484
+ * @param {string} name
483
485
  * @param {...any} args
484
486
  * @returns {rxjs.Observable<{ name: string, version: string, state: Number, data: any}>}
485
487
  */
486
- observe2(...args) {
487
- return this._observe(OBSERVE2_DEFAULTS, ...args)
488
+ observe2(name, ...args) {
489
+ return this._observe(OBSERVE2_DEFAULTS, name, ...args)
488
490
  }
489
491
 
490
492
  /**
491
- *
492
- * @param {*} name
493
+ * @param {string} name
493
494
  * @param {...any} args
494
495
  * @returns { { value: object, async: false } | { value: Promise<object>, async: true } }
495
496
  */
496
497
  getAsync(name, ...args) {
497
498
  let path
498
- let state = GET_DEFAULTS.state
499
+ let state = GET_DEFAULTS.state ?? C.RECORD_STATE.CLIENT
499
500
 
500
501
  let idx = 0
501
502
 
@@ -517,32 +518,40 @@ class RecordHandler {
517
518
  return { value: this.get(name, ...args), async: true }
518
519
  }
519
520
 
521
+ if (typeof state === 'string') {
522
+ state = C.RECORD_STATE[state.toUpperCase()]
523
+ }
524
+
525
+ if (!Number.isInteger(state) || state < 0) {
526
+ throw new Error('invalid argument: state')
527
+ }
528
+
520
529
  const rec = this.getRecord(name)
521
530
  try {
522
- if (rec.state >= state) {
523
- return { value: rec.get(path), async: false }
524
- }
531
+ return rec.state >= state
532
+ ? { value: rec.get(path), async: false }
533
+ : { value: this.get(name, ...args), async: true }
525
534
  } finally {
526
535
  rec.unref()
527
536
  }
528
-
529
- return { value: this.get(name, ...args), async: true }
530
537
  }
531
538
 
532
539
  /**
540
+ * @param {string} name
533
541
  * @param {...any} args
534
542
  * @returns {Promise<object>}
535
543
  */
536
- get(...args) {
537
- return rxjs.firstValueFrom(this._observe(GET_DEFAULTS, ...args))
544
+ get(name, ...args) {
545
+ return rxjs.firstValueFrom(this._observe(GET_DEFAULTS, name, ...args))
538
546
  }
539
547
 
540
548
  /**
549
+ * @param {string} name
541
550
  * @param {...any} args
542
551
  * @returns {Promise<object>}
543
552
  */
544
- get2(...args) {
545
- return rxjs.firstValueFrom(this._observe(GET2_DEFAULTS, ...args))
553
+ get2(name, ...args) {
554
+ return rxjs.firstValueFrom(this._observe(GET2_DEFAULTS, name, ...args))
546
555
  }
547
556
 
548
557
  /**
@@ -605,9 +614,6 @@ class RecordHandler {
605
614
  state = C.RECORD_STATE[state.toUpperCase()]
606
615
  }
607
616
 
608
- // TODO (fix): Validate path?
609
- // TODO (fix): Validate signal?
610
-
611
617
  if (!Number.isInteger(state) || state < 0) {
612
618
  throw new Error('invalid argument: state')
613
619
  }