@nxtedition/lib 23.0.3 → 23.0.4

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.
Files changed (3) hide show
  1. package/app.d.ts +36 -0
  2. package/couch.js +4 -4
  3. package/package.json +2 -1
package/app.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { DeepstreamClient } from '@nxtedition/deepstream.io-client-js'
2
+ import type { NxtDeepstreamClient } from './deepstream.js'
3
+ import type { Logger } from './logger.js'
4
+ import type { CouchClient } from './couch.js'
5
+ import type { Server } from 'http'
6
+
7
+ export function makeApp<AC extends AppConfig, Records, RpcMethods>(
8
+ appConfig: AC,
9
+ onTerminate?: (logger: Logger) => Promise<void>,
10
+ ): App<AC, Records, RpcMethods>
11
+
12
+ export interface AppConfig {
13
+ name: string
14
+ module?: string
15
+ version?: string
16
+ config: {
17
+ [key: string]: unknown
18
+ }
19
+ [key: string]: unknown
20
+ }
21
+
22
+ export interface App<AC extends AppConfig, Records, RpcMethods> {
23
+ ds: DeepstreamClientWithNxt<Records, RpcMethods>
24
+ nxt: NxtDeepstreamClient<Records, RpcMethods>
25
+ couch: CouchClient
26
+ server: Server
27
+ compiler: unkonwn
28
+ config: AC
29
+ logger: Logger
30
+ trace: unknown
31
+ }
32
+
33
+ export interface DeepstreamClientWithNxt<Records, RpcMethods>
34
+ extends DeepstreamClient<Records, RpcMethods> {
35
+ nxt: NxtDeepstreamClient<Records, RpcMethods>
36
+ }
package/couch.js CHANGED
@@ -212,7 +212,7 @@ export function makeCouch(opts) {
212
212
  const live = options.live == null || !!options.live
213
213
  const retry =
214
214
  options.retry ??
215
- (async (err, retryCount, params, { signal }, next) => {
215
+ (async (err, retryCount, params, { signal, logger }, next) => {
216
216
  logger?.error({ err, retryCount, params }, 'changes error')
217
217
  return next()
218
218
  })
@@ -391,13 +391,13 @@ export function makeCouch(opts) {
391
391
  const retryState = { since: params.since }
392
392
  Object.assign(
393
393
  retryState,
394
- await retry(err, retryCount++, retryState, { signal }, () =>
395
- delay(err, retryCount, { signal }),
394
+ await retry(err, retryCount++, retryState, { signal, logger }, () =>
395
+ delay(err, retryCount, { signal, logger }),
396
396
  ),
397
397
  )
398
398
  params.since = retryState.since ?? 0
399
399
  } else {
400
- await delay(err, retryCount, { signal })
400
+ await delay(err, retryCount, { signal, logger })
401
401
  }
402
402
  } finally {
403
403
  src?.on('error', () => {}).destroy()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.0.3",
3
+ "version": "23.0.4",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -33,6 +33,7 @@
33
33
  "couch.js",
34
34
  "couch.d.ts",
35
35
  "app.js",
36
+ "app.d.ts",
36
37
  "errors.js",
37
38
  "errors.d.ts",
38
39
  "worker.js",