@nxtedition/lib 22.1.3 → 22.1.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.
- package/couch.d.ts +68 -0
- package/deepstream.d.ts +19 -0
- package/errors.d.ts +46 -0
- package/logger.d.ts +18 -0
- package/package.json +5 -1
- package/rxjs/firstValueFrom.d.ts +12 -0
package/couch.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Logger } from './logger.js'
|
|
2
|
+
import { HttpError } from 'http-errors'
|
|
3
|
+
|
|
4
|
+
export interface CouchOptions {
|
|
5
|
+
url?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function makeCouch(opts: string | CouchOptions): CouchClient
|
|
9
|
+
|
|
10
|
+
export interface CouchRequestOptions<Stream extends boolean = false> {
|
|
11
|
+
url?: URL
|
|
12
|
+
pathname?: string
|
|
13
|
+
path?: string
|
|
14
|
+
method?: string
|
|
15
|
+
body?: unknown
|
|
16
|
+
query?: {
|
|
17
|
+
startkey?: string
|
|
18
|
+
endkey?: string
|
|
19
|
+
update?: boolean
|
|
20
|
+
}
|
|
21
|
+
signal?: AbortSignal
|
|
22
|
+
logger?: Logger
|
|
23
|
+
stream?: Stream
|
|
24
|
+
// TODO add more or extend undicii type?
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface CouchResponse<T> {
|
|
28
|
+
rows: T[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function request<T, Stream extends boolean = false>(
|
|
32
|
+
url: string | URL | { origin: string; path?: string; pathname?: string },
|
|
33
|
+
opts?: CouchRequestOptions<Stream> | null,
|
|
34
|
+
): Stream extends true ? AsyncGenerator<T> & { length: number } : Promise<CouchResponse<T>>
|
|
35
|
+
|
|
36
|
+
interface ChangesOptions {
|
|
37
|
+
signal?: AbortSignal | null
|
|
38
|
+
descending?: boolean
|
|
39
|
+
include_docs?: boolean
|
|
40
|
+
seq_interval?: number | null
|
|
41
|
+
live?: boolean
|
|
42
|
+
heartbeat?: number
|
|
43
|
+
retry?: (
|
|
44
|
+
err: HttpError,
|
|
45
|
+
retryCount: number,
|
|
46
|
+
params: {
|
|
47
|
+
since?: string | 0 | null
|
|
48
|
+
},
|
|
49
|
+
ac: { signal: AbortSignal },
|
|
50
|
+
next: () => void,
|
|
51
|
+
) => void | null | Promise<void>
|
|
52
|
+
since?: string | 0 | null
|
|
53
|
+
selector?: object | null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface ChangeItem {
|
|
57
|
+
id: string
|
|
58
|
+
seq?: string
|
|
59
|
+
doc?: object
|
|
60
|
+
deleted?: boolean
|
|
61
|
+
changes: Array<{ rev: string }>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface CouchClient {
|
|
65
|
+
changes: (
|
|
66
|
+
options?: ChangesOptions & { client?: unknown; logger?: Logger },
|
|
67
|
+
) => AsyncGenerator<ChangeItem[] & { lastSeq?: string | 0 | null }, void, unknown>
|
|
68
|
+
}
|
package/deepstream.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DeepstreamClient, RecordHandler } from '@nxtedition/deepstream.io-client-js'
|
|
2
|
+
|
|
3
|
+
export function makeDeepstream<Records, RpcMethods>(
|
|
4
|
+
client: DeepstreamClient<Records, RpcMethods>,
|
|
5
|
+
): NxtDeepstreamClient<Records, RpcMethods>
|
|
6
|
+
|
|
7
|
+
export interface NxtDeepstreamClient<Records, RpcMethods> {
|
|
8
|
+
ds: DeepstreamClient<Records, RpcMethods> & { nxt: NxtDeepstreamClient<Records, RpcMethods> }
|
|
9
|
+
record: {
|
|
10
|
+
provide: RecordHandler<Records>['provide']
|
|
11
|
+
observe: RecordHandler<Records>['observe']
|
|
12
|
+
observe2: RecordHandler<Records>['observe2']
|
|
13
|
+
query: RecordHandler<Records>['query']
|
|
14
|
+
set: RecordHandler<Records>['set']
|
|
15
|
+
get: RecordHandler<Records>['get']
|
|
16
|
+
getRecord: RecordHandler<Records>['getRecord']
|
|
17
|
+
update: RecordHandler<Records>['update']
|
|
18
|
+
}
|
|
19
|
+
}
|
package/errors.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class AbortError extends Error {
|
|
2
|
+
constructor(message: string)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function parseError(err: unknown): Error | null
|
|
6
|
+
|
|
7
|
+
export interface NxtError {
|
|
8
|
+
message: string
|
|
9
|
+
type?: string
|
|
10
|
+
code?: string
|
|
11
|
+
exitCode?: number
|
|
12
|
+
signalCode?: number
|
|
13
|
+
statusCode?: number
|
|
14
|
+
headers?: Record<string, string>
|
|
15
|
+
data?: object
|
|
16
|
+
cause?: NxtError | null
|
|
17
|
+
errors?: NxtError[] | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function serializeError(err: Error | string): NxtError[] | null
|
|
21
|
+
|
|
22
|
+
export type Message = {
|
|
23
|
+
msg: string
|
|
24
|
+
title?: string
|
|
25
|
+
id: string
|
|
26
|
+
level: number
|
|
27
|
+
code?: string
|
|
28
|
+
data?: object
|
|
29
|
+
expose?: boolean | null
|
|
30
|
+
index?: object | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type MessageOptions = {
|
|
34
|
+
id?: string
|
|
35
|
+
level?: number
|
|
36
|
+
code?: string
|
|
37
|
+
codes?: Record<string, string>
|
|
38
|
+
index?: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function makeMessages(
|
|
42
|
+
error: MessageError | MessageError[],
|
|
43
|
+
options?: MessageOptions,
|
|
44
|
+
): Message[]
|
|
45
|
+
|
|
46
|
+
export function makeErrorString(err: unknown): string
|
package/logger.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { pino } from 'pino'
|
|
2
|
+
|
|
3
|
+
export type Logger = pino.Logger
|
|
4
|
+
|
|
5
|
+
interface LoggerOptions extends pino.LoggerOptions {
|
|
6
|
+
flushInterval?: number
|
|
7
|
+
stream?: ReturnType<(typeof pino)['destination']> | (typeof process)['stdout'] | null
|
|
8
|
+
}
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "22.1.
|
|
3
|
+
"version": "22.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
"time.js",
|
|
21
21
|
"mutex.js",
|
|
22
22
|
"deepstream.js",
|
|
23
|
+
"deepstream.d.ts",
|
|
23
24
|
"sequence.js",
|
|
24
25
|
"logger.js",
|
|
26
|
+
"logger.d.ts",
|
|
25
27
|
"mime.js",
|
|
26
28
|
"proxy.js",
|
|
27
29
|
"timers.js",
|
|
@@ -29,8 +31,10 @@
|
|
|
29
31
|
"weakCache.js",
|
|
30
32
|
"weakCache.d.ts",
|
|
31
33
|
"couch.js",
|
|
34
|
+
"couch.d.ts",
|
|
32
35
|
"app.js",
|
|
33
36
|
"errors.js",
|
|
37
|
+
"errors.d.ts",
|
|
34
38
|
"worker.js",
|
|
35
39
|
"stream.js",
|
|
36
40
|
"timeline.js",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Observable } from 'rxjs'
|
|
2
|
+
|
|
3
|
+
interface FirstValueFromConfig<T> {
|
|
4
|
+
signal?: AbortSignal
|
|
5
|
+
timeout?: number
|
|
6
|
+
defaultValue?: T
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function firstValueFrom<T>(
|
|
10
|
+
source: Observable<T>,
|
|
11
|
+
config?: FirstValueFromConfig<T>,
|
|
12
|
+
): Promise<T>
|