@sqb/nestjs 4.10.0 → 4.10.1
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 +4 -3
- package/types/index.d.ts +5 -0
- package/types/sqb-core.module.d.ts +14 -0
- package/types/sqb.constants.d.ts +2 -0
- package/types/sqb.decorators.d.ts +1 -0
- package/types/sqb.interface.d.ts +50 -0
- package/types/sqb.module.d.ts +6 -0
- package/types/sqb.utils.d.ts +11 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/nestjs",
|
|
3
3
|
"description": "Nestjs module for data connection using SQB",
|
|
4
|
-
"version": "4.10.
|
|
4
|
+
"version": "4.10.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@nestjs/common": ">=7.4.0",
|
|
49
49
|
"@nestjs/core": ">=7.4.0",
|
|
50
|
-
"@sqb/builder": "^4.10.
|
|
51
|
-
"@sqb/connect": "^4.10.
|
|
50
|
+
"@sqb/builder": "^4.10.1",
|
|
51
|
+
"@sqb/connect": "^4.10.1",
|
|
52
52
|
"rxjs": ">=6.6.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"bin/",
|
|
60
60
|
"cjs/",
|
|
61
61
|
"esm/",
|
|
62
|
+
"types/",
|
|
62
63
|
"LICENSE",
|
|
63
64
|
"README.md"
|
|
64
65
|
],
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DynamicModule, OnApplicationShutdown } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
import { SqbModuleAsyncOptions, SqbModuleOptions } from './sqb.interface.js';
|
|
4
|
+
export declare class SqbCoreModule implements OnApplicationShutdown {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly moduleRef;
|
|
7
|
+
constructor(options: SqbModuleOptions, moduleRef: ModuleRef);
|
|
8
|
+
static forRoot(options?: SqbModuleOptions): DynamicModule;
|
|
9
|
+
static forRootAsync(options: SqbModuleAsyncOptions): DynamicModule;
|
|
10
|
+
onApplicationShutdown(): Promise<void>;
|
|
11
|
+
private static createAsyncProviders;
|
|
12
|
+
private static createAsyncOptionsProvider;
|
|
13
|
+
private static createConnection;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InjectSQB: (name?: string) => ParameterDecorator;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
3
|
+
import { ClientConfiguration } from '@sqb/connect';
|
|
4
|
+
export type SqbModuleOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Connection name
|
|
7
|
+
*/
|
|
8
|
+
name?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Number of times to retry connecting
|
|
11
|
+
* Default: 10
|
|
12
|
+
*/
|
|
13
|
+
retryAttempts?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Delay between connection retry attempts (ms)
|
|
16
|
+
* Default: 3000
|
|
17
|
+
*/
|
|
18
|
+
retryDelay?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Function that determines whether the module should
|
|
21
|
+
* attempt to connect upon failure.
|
|
22
|
+
*
|
|
23
|
+
* @param err error that was thrown
|
|
24
|
+
* @returns whether to retry connection or not
|
|
25
|
+
*/
|
|
26
|
+
toRetry?: (err: any) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* If `true`, connection will not be closed on application shutdown.
|
|
29
|
+
*/
|
|
30
|
+
keepConnectionAlive?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If `true`, will show verbose error messages on each connection retry.
|
|
33
|
+
*/
|
|
34
|
+
verboseRetryLog?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Number of ms to wait closing connection on shutdown
|
|
37
|
+
* Default: 10
|
|
38
|
+
*/
|
|
39
|
+
shutdownWaitMs?: number;
|
|
40
|
+
} & ClientConfiguration;
|
|
41
|
+
export interface SqbOptionsFactory {
|
|
42
|
+
createSqbOptions(connectionName?: string): Promise<SqbModuleOptions> | SqbModuleOptions;
|
|
43
|
+
}
|
|
44
|
+
export interface SqbModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
45
|
+
name?: string;
|
|
46
|
+
useExisting?: Type<SqbOptionsFactory>;
|
|
47
|
+
useClass?: Type<SqbOptionsFactory>;
|
|
48
|
+
useFactory?: (...args: any[]) => Promise<SqbModuleOptions> | SqbModuleOptions;
|
|
49
|
+
inject?: any[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { SqbModuleAsyncOptions, SqbModuleOptions } from './sqb.interface.js';
|
|
3
|
+
export declare class SqbModule {
|
|
4
|
+
static forRoot(options?: SqbModuleOptions): DynamicModule;
|
|
5
|
+
static forRootAsync(options: SqbModuleAsyncOptions): DynamicModule;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Type } from '@nestjs/common';
|
|
3
|
+
import { SqbClient } from '@sqb/connect';
|
|
4
|
+
/**
|
|
5
|
+
* This function returns a Connection injection token for the given connection name.
|
|
6
|
+
* @param {string | symbol} [name=SQB_DEFAULT_CONNECTION] This optional parameter is either
|
|
7
|
+
* a SqbClient, or a ConnectionOptions or a string.
|
|
8
|
+
* @returns {string | symbol} The Connection injection token.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSQBToken(name?: string | symbol | Type<SqbClient>): string | symbol | Type<SqbClient>;
|
|
11
|
+
export declare function handleRetry(connectionName?: string | symbol | Type<SqbClient>, retryAttempts?: number, retryDelay?: number, verboseRetryLog?: boolean, toRetry?: (err: any) => boolean): <T>(source: Observable<T>) => Observable<T>;
|