@nxtedition/deepstream.io-client-js 28.1.15 → 28.1.16

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": "28.1.15",
3
+ "version": "28.1.16",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -14,12 +14,23 @@ export default class RpcHandler<Methods extends Record<string, RpcMethodDef>> {
14
14
  unprovide: <Name extends keyof Methods>(name: Name) => void
15
15
 
16
16
  make: {
17
- <Name extends keyof Methods>(
17
+ <
18
+ Name extends keyof Methods | string,
19
+ Args extends Name extends keyof Methods ? Methods[Name][0] : unknown,
20
+ ReturnValue extends Name extends keyof Methods ? Methods[Name][1] : unknown,
21
+ >(
18
22
  name: Name,
19
- args: Methods[Name][0],
20
- callback: (error: unknown, response: Methods[Name][1]) => void,
23
+ args: Args,
24
+ ): Promise<ReturnValue>
25
+ <
26
+ Name extends keyof Methods | string,
27
+ Args extends Name extends keyof Methods ? Methods[Name][0] : unknown,
28
+ ReturnValue extends Name extends keyof Methods ? Methods[Name][1] : unknown,
29
+ >(
30
+ name: Name,
31
+ args: Args,
32
+ callback: (error: unknown, response: ReturnValue) => void,
21
33
  ): void
22
- <Name extends keyof Methods>(name: Name, args: Methods[Name][0]): Promise<Methods[Name][1]>
23
34
  }
24
35
  }
25
36
 
@@ -4,14 +4,12 @@ import { h64ToString, findBigIntPaths } from '../utils/utils.js'
4
4
 
5
5
  const PIPE = rxjs.pipe(
6
6
  rxjs.map((value) => {
7
- if (value == null) {
8
- return null
9
- } else if (typeof value === 'string') {
7
+ if (typeof value === 'string') {
10
8
  if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
11
9
  throw new Error(`invalid value: ${value}`)
12
10
  }
13
11
  return value
14
- } else if (typeof value === 'object') {
12
+ } else if (value != null && typeof value === 'object') {
15
13
  try {
16
14
  return JSON.stringify(value)
17
15
  } catch (err) {
@@ -78,24 +76,18 @@ export default class Listener {
78
76
  if (value$) {
79
77
  const subscription = value$.pipe(PIPE).subscribe({
80
78
  next: (data) => {
81
- if (data != null) {
82
- const version = `INF-${h64ToString(data)}`
83
- this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
84
- } else {
85
- this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
86
- }
79
+ const version = `INF-${h64ToString(data)}`
80
+ this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
87
81
  },
88
82
  error: (err) => {
89
83
  this._error(name, err)
84
+
85
+ this._subscriptions.delete(name)
90
86
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
91
87
  },
92
88
  })
93
89
 
94
90
  this._subscriptions.set(name, subscription)
95
-
96
- subscription.add(() => {
97
- this._subscriptions.delete(name)
98
- })
99
91
  } else {
100
92
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
101
93
  }