@nxtedition/lib 26.8.3 → 26.8.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/app.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DeepstreamClient } from '@nxtedition/deepstream.io-client-js'
1
+ import type { DeepstreamClient, RpcMethodDef } from '@nxtedition/deepstream.io-client-js'
2
2
  import type { NxtDeepstreamClient } from './deepstream.js'
3
3
  import type { Logger } from './logger.js'
4
4
  import type { CouchClient } from './couch.js'
@@ -6,7 +6,11 @@ import type { Server } from 'http'
6
6
  import type { BehaviorSubject } from 'rxjs'
7
7
  import type { Subscription } from 'rxjs'
8
8
 
9
- export function makeApp<Records, RpcMethods, Config = Record<string, unknown>>(
9
+ export function makeApp<
10
+ Records,
11
+ RpcMethods extends Record<string, RpcMethodDef> = Record<string, RpcMethodDef>,
12
+ Config = Record<string, unknown>,
13
+ >(
10
14
  appConfig: AppConfig<Config>,
11
15
  onTerminate?: (logger: Logger) => Promise<void>,
12
16
  ): App<Records, RpcMethods, Config>
@@ -26,7 +30,11 @@ export interface AppConfig<Config = Record<string, unknown>> {
26
30
  [key: string]: unknown
27
31
  }
28
32
 
29
- export interface App<Records, RpcMethods, Config = Record<string, unknown>> {
33
+ export interface App<
34
+ Records,
35
+ RpcMethods extends Record<string, RpcMethodDef>,
36
+ Config = Record<string, unknown>,
37
+ > {
30
38
  ds: DeepstreamClientWithNxt<Records, RpcMethods>
31
39
  nxt: NxtDeepstreamClient<Records, RpcMethods>
32
40
  couch: CouchClient
@@ -53,7 +61,7 @@ export interface App<Records, RpcMethods, Config = Record<string, unknown>> {
53
61
  signal: AbortSignal
54
62
  }
55
63
 
56
- export interface DeepstreamClientWithNxt<Records, RpcMethods>
64
+ export interface DeepstreamClientWithNxt<Records, RpcMethods extends Record<string, RpcMethodDef>>
57
65
  extends DeepstreamClient<Records, RpcMethods> {
58
66
  nxt: NxtDeepstreamClient<Records, RpcMethods>
59
67
  }
package/couch.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Logger } from './logger.js'
2
- import { HttpError } from 'http-errors'
2
+ import type { HttpError } from 'http-errors'
3
3
  import type { Readable } from 'node:stream'
4
+ import type { Dispatcher } from 'undici'
4
5
 
5
6
  export interface CouchOptions {
6
7
  url?: string
@@ -18,7 +19,7 @@ export interface CouchRequestOptions<Stream extends boolean = false> {
18
19
  body?: unknown
19
20
  headersTimeout?: number
20
21
  bodyTimeout?: number
21
- dispatcher?: undici.Dispatcher
22
+ dispatcher?: Dispatcher
22
23
  query?: {
23
24
  startkey?: string
24
25
  endkey?: string
@@ -39,7 +40,7 @@ export interface CouchResponse<T> {
39
40
 
40
41
  export function request<T, Stream extends boolean = false>(
41
42
  url: string | URL | { origin: string; path?: string; pathname?: string },
42
- opts?: CouchRequestOptione<Stream> | null,
43
+ opts?: CouchRequestOptions<Stream> | null,
43
44
  ): Stream extends true ? Readable : Promise<CouchResponse<T>>
44
45
 
45
46
  interface ChangesOptions {
package/deepstream.d.ts CHANGED
@@ -1,19 +1,27 @@
1
- import { DeepstreamClient, RecordHandler } from '@nxtedition/deepstream.io-client-js'
1
+ import type {
2
+ DeepstreamClient,
3
+ RecordHandler,
4
+ RpcMethodDef,
5
+ } from '@nxtedition/deepstream.io-client-js'
2
6
 
3
7
  type Paths<T> = keyof T & string
4
8
  type Get<Data, Path extends string> = Path extends keyof Data ? Data[Path] : unknown
5
9
 
6
- export function makeDeepstream<Records, RpcMethods>(
7
- client: DeepstreamClient<Records, RpcMethods>,
8
- ): NxtDeepstreamClient<Records, RpcMethods>
10
+ export function makeDeepstream<
11
+ Records,
12
+ RpcMethods extends Record<string, RpcMethodDef> = Record<string, RpcMethodDef>,
13
+ >(client: DeepstreamClient<Records, RpcMethods>): NxtDeepstreamClient<Records, RpcMethods>
9
14
 
10
- export interface NxtDeepstreamClient<Records, RpcMethods> {
15
+ export interface NxtDeepstreamClient<
16
+ Records,
17
+ RpcMethods extends Record<string, RpcMethodDef> = Record<string, RpcMethodDef>,
18
+ > {
11
19
  ds: DeepstreamClient<Records, RpcMethods> & { nxt: NxtDeepstreamClient<Records, RpcMethods> }
12
20
  record: {
13
21
  provide: RecordHandler<Records>['provide']
14
22
  observe: RecordHandler<Records>['observe'] // TODO type with query
15
23
  observe2: RecordHandler<Records>['observe2'] // TODO type with query
16
- query: RecordHandler<Records>['query']
24
+ query: (designId: string, params?: Query, state?: number) => Promise<string[]>
17
25
  set: RecordHandler<Records>['set']
18
26
  get: {
19
27
  // without query and path:
package/errors.d.ts CHANGED
@@ -22,7 +22,7 @@ type SerializableError = null | undefined | Error | string | NxtError | Serializ
22
22
 
23
23
  export function serializeError(err: SerializableError): NxtError[] | null
24
24
 
25
- export type Message = {
25
+ export interface Message {
26
26
  msg: string
27
27
  title?: string
28
28
  id: string
@@ -33,7 +33,7 @@ export type Message = {
33
33
  index?: object | null
34
34
  }
35
35
 
36
- export type MessageOptions = {
36
+ export interface MessageOptions {
37
37
  id?: string
38
38
  level?: number
39
39
  code?: string
@@ -46,4 +46,6 @@ export function makeMessages(
46
46
  options?: MessageOptions,
47
47
  ): Message[]
48
48
 
49
+ export type MessageError = unknown
50
+
49
51
  export function makeErrorString(err: unknown): string
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ // dummy file required for tsd to work
package/logger.d.ts CHANGED
@@ -1,18 +1,10 @@
1
- import { pino } from 'pino'
1
+ import type { Logger as PinoLogger, LoggerOptions as PinoLoggerOptions } from 'pino'
2
2
 
3
- export type Logger = pino.Logger
3
+ export type Logger = PinoLogger
4
4
 
5
- interface LoggerOptions extends pino.LoggerOptions {
5
+ interface LoggerOptions extends PinoLoggerOptions {
6
6
  flushInterval?: number
7
- stream?: ReturnType<(typeof pino)['destination']> | (typeof process)['stdout'] | null
7
+ stream?: NodeJS.WriteStream | null
8
8
  }
9
9
 
10
- export function createLogger(
11
- {
12
- level = isProduction ? 'debug' : 'trace',
13
- flushInterval = 1e3,
14
- stream = null,
15
- ...options
16
- }?: LoggerOptions,
17
- onTerminate?: unknown,
18
- ): Logger
10
+ export function createLogger(options?: LoggerOptions, onTerminate?: unknown): Logger
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.8.3",
3
+ "version": "26.8.5",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
7
7
  "files": [
8
+ "index.d.ts",
8
9
  "hash.js",
9
10
  "ass.js",
10
11
  "rxjs/*",
@@ -51,6 +52,7 @@
51
52
  ],
52
53
  "scripts": {
53
54
  "test": "node --test-timeout 60000 --test",
55
+ "test:types": "tsd",
54
56
  "prepare": "husky"
55
57
  },
56
58
  "lint-staged": {
@@ -112,6 +114,7 @@
112
114
  "lint-staged": "^16.2.6",
113
115
  "prettier": "^3.6.2",
114
116
  "rxjs": "^7.8.2",
117
+ "tsd": "^0.33.0",
115
118
  "typescript": "^5.9.3",
116
119
  "typescript-eslint": "^8.46.2"
117
120
  },
package/s3.js CHANGED
@@ -212,7 +212,7 @@ export async function upload({
212
212
  } catch (err) {
213
213
  logger?.warn({ err }, 'part upload failed')
214
214
 
215
- if (retryCount < 16) {
215
+ if (retryCount < 16 && err.name !== 'NotImplemented') {
216
216
  logger?.debug({ retryCount }, 'part upload retry')
217
217
  await tp.setTimeout(retryCount * retryCount * 1e3, undefined, {
218
218
  signal: uploader.signal,
@@ -1,31 +1,32 @@
1
1
  import type { FirstValueFromConfig } from 'rxjs/internal/firstValueFrom'
2
2
  import type * as rx from 'rxjs'
3
- import { DeepstreamClient } from '@nxtedition/deepstream.io-client-js'
3
+ import type { DeepstreamClient } from '@nxtedition/deepstream.io-client-js'
4
+ import type { Logger } from '../../logger.js'
4
5
 
5
6
  export interface MakeTemplateCompilerParams {
6
- ds?: DeepstreamClient
7
+ ds?: DeepstreamClient<unknown>
7
8
  proxify?: unknown
8
- logger?: unknown
9
+ logger?: Logger
9
10
  platform?: unknown
10
11
  }
11
12
 
12
- export function makeTemplateCompiler(params: MakeTemplateCompilerParams): TemplateCompiler
13
+ export declare function makeTemplateCompiler(params: MakeTemplateCompilerParams): TemplateCompiler
13
14
 
14
15
  export interface TemplateCompiler {
15
16
  current: null
16
17
 
17
- resolveTemplate: <ReturnValue, Context>(
18
+ resolveTemplate: <ReturnValue, Context extends Record<string, unknown>>(
18
19
  template: Nxtpression<ReturnValue, Context> | string,
19
20
  args$?: Context | rx.Observable<Context>,
20
- options?: FirstValueFromConfig,
21
+ options?: FirstValueFromConfig<ReturnValue>,
21
22
  ) => Promise<unknown>
22
23
 
23
- onResolveTemplate: <ReturnValue, Context>(
24
+ onResolveTemplate: <ReturnValue, Context extends Record<string, unknown>>(
24
25
  template: Nxtpression<ReturnValue, Context> | string,
25
26
  args$?: Context | rx.Observable<Context>,
26
27
  ) => rx.Observable<unknown>
27
28
 
28
- compileTemplate: <ReturnValue, Context>(
29
+ compileTemplate: <ReturnValue, Context extends Record<string, unknown>>(
29
30
  template: Nxtpression<ReturnValue, Context> | string,
30
31
  ) => null | ((args$?: Context | rx.Observable<Context>) => rx.Observable<unknown>)
31
32
 
@@ -1 +1 @@
1
- export * from './index-common.d.ts'
1
+ export * from './index-common.js'
@@ -1 +1 @@
1
- export * from './index-common.d.ts'
1
+ export * from './index-common.js'