@nxtedition/deepstream.io-client-js 31.2.9 → 31.2.11

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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run test:types:*)"
5
+ ],
6
+ "deny": [],
7
+ "ask": []
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "31.2.9",
3
+ "version": "31.2.11",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import make, { type DeepstreamClient } from './client.js'
3
- import { expectAssignable, expectError } from 'tsd'
3
+ import { expectAssignable, expectError, expectType } from 'tsd'
4
4
  import type { Observable } from 'rxjs'
5
5
 
6
6
  interface Records extends Record<string, unknown> {
@@ -195,6 +195,11 @@ rec.set('o0.o1', {})
195
195
  expectError(rec.update((x) => 'x'))
196
196
  expectError(rec.update('o0', (x) => ({ ...x, o1: '22' })))
197
197
 
198
+ expectType<string | undefined>(rec.get('o0.o1.o2.o3'))
199
+ expectType<{ o0?: { o1?: { o2?: { o3?: string } } } }>(rec.get())
200
+ const pathOrUndefined: 'o0.01.02.03' | undefined = undefined
201
+ expectType<unknown>(rec.get(pathOrUndefined))
202
+
198
203
  // when with options
199
204
  expectAssignable<Promise<typeof rec>>(rec.when())
200
205
  expectAssignable<Promise<typeof rec>>(rec.when(2))
@@ -214,3 +219,8 @@ expectAssignable<Promise<void>>(
214
219
  )
215
220
  expectAssignable<Promise<void>>(rec.update('o0', (x) => x, { timeout: 5000 }))
216
221
  expectAssignable<Promise<void>>(rec.update('o0', (x) => x, { state: 2 }))
222
+
223
+ const state = 'VOID'
224
+ expectType<0>(ds.record.STATE[state])
225
+ const unknownState: string = 'VOID'
226
+ expectType<number>(ds.record.STATE[unknownState])
@@ -17,10 +17,19 @@ export default class RecordHandler<Records = Record<string, unknown>> {
17
17
  STALE: 3
18
18
  PROVIDER: 4
19
19
 
20
+ STATE: {
21
+ VOID: 0
22
+ CLIENT: 1
23
+ SERVER: 2
24
+ STALE: 3
25
+ PROVIDER: 4
26
+ [key: string]: number
27
+ }
28
+
20
29
  JSON: {
21
30
  EMPTY: EmptyObject
22
31
  EMPTY_OBJ: EmptyObject
23
- EMPTY_ARR: Readonly<unknown[]>
32
+ EMPTY_ARR: []
24
33
  }
25
34
 
26
35
  connected: boolean
@@ -75,6 +75,7 @@ export default class Record<Data = unknown> {
75
75
  <P extends string | string[]>(path: P): Get<Data, P>
76
76
  // without path
77
77
  (): Data
78
+ (path: undefined | string | string[]): unknown
78
79
  }
79
80
 
80
81
  set: {