@sqb/nestjs 4.12.0 → 4.13.0
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/cjs/sqb-core.module.js +14 -15
- package/cjs/sqb.utils.js +3 -4
- package/esm/sqb-core.module.js +14 -15
- package/esm/sqb.utils.js +1 -1
- package/package.json +11 -10
- package/types/sqb.utils.d.ts +1 -1
package/cjs/sqb-core.module.js
CHANGED
|
@@ -3,12 +3,12 @@ var SqbCoreModule_1;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.SqbCoreModule = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const crypto = tslib_1.__importStar(require("crypto"));
|
|
7
|
-
const rxjs_1 = require("rxjs");
|
|
8
|
-
const rxjs = tslib_1.__importStar(require("rxjs"));
|
|
9
6
|
const common_1 = require("@nestjs/common");
|
|
10
7
|
const core_1 = require("@nestjs/core");
|
|
11
8
|
const connect_1 = require("@sqb/connect");
|
|
9
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
10
|
+
const rxjs_1 = require("rxjs");
|
|
11
|
+
const rxjs = tslib_1.__importStar(require("rxjs"));
|
|
12
12
|
const sqb_constants_js_1 = require("./sqb.constants.js");
|
|
13
13
|
const sqb_utils_js_1 = require("./sqb.utils.js");
|
|
14
14
|
let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
@@ -60,7 +60,7 @@ let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
|
60
60
|
static createAsyncProviders(options) {
|
|
61
61
|
if (options.useExisting || options.useFactory)
|
|
62
62
|
return [this.createAsyncOptionsProvider(options)];
|
|
63
|
-
if (options.useClass)
|
|
63
|
+
if (options.useClass) {
|
|
64
64
|
return [
|
|
65
65
|
this.createAsyncOptionsProvider(options),
|
|
66
66
|
{
|
|
@@ -68,6 +68,7 @@ let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
|
68
68
|
useClass: options.useClass,
|
|
69
69
|
},
|
|
70
70
|
];
|
|
71
|
+
}
|
|
71
72
|
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
72
73
|
}
|
|
73
74
|
static createAsyncOptionsProvider(options) {
|
|
@@ -100,17 +101,15 @@ let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
|
100
101
|
return client;
|
|
101
102
|
}).pipe((0, sqb_utils_js_1.handleRetry)(connectionToken, options.retryAttempts, options.retryDelay, options.verboseRetryLog, options.toRetry)));
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.toPromise();
|
|
113
|
-
}
|
|
104
|
+
// NestJS 7
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
return await (0, rxjs_1.defer)(async () => {
|
|
107
|
+
const client = new connect_1.SqbClient(options);
|
|
108
|
+
await client.test();
|
|
109
|
+
return client;
|
|
110
|
+
})
|
|
111
|
+
.pipe((0, sqb_utils_js_1.handleRetry)(connectionToken, options.retryAttempts, options.retryDelay, options.verboseRetryLog, options.toRetry))
|
|
112
|
+
.toPromise();
|
|
114
113
|
}
|
|
115
114
|
};
|
|
116
115
|
exports.SqbCoreModule = SqbCoreModule;
|
package/cjs/sqb.utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.getSQBToken = getSQBToken;
|
|
4
|
+
exports.handleRetry = handleRetry;
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const connect_1 = require("@sqb/connect");
|
|
7
|
+
const operators_1 = require("rxjs/operators");
|
|
7
8
|
const logger = new common_1.Logger('SqbModule');
|
|
8
9
|
/**
|
|
9
10
|
* This function returns a Connection injection token for the given connection name.
|
|
@@ -18,7 +19,6 @@ function getSQBToken(name) {
|
|
|
18
19
|
return name;
|
|
19
20
|
return `${name}_SqbConnection`;
|
|
20
21
|
}
|
|
21
|
-
exports.getSQBToken = getSQBToken;
|
|
22
22
|
function handleRetry(connectionName, retryAttempts = 9, retryDelay = 3000, verboseRetryLog = false, toRetry) {
|
|
23
23
|
return (source) => source.pipe((0, operators_1.retryWhen)(e => e.pipe((0, operators_1.scan)((errorCount, error) => {
|
|
24
24
|
if (toRetry && !toRetry(error)) {
|
|
@@ -33,4 +33,3 @@ function handleRetry(connectionName, retryAttempts = 9, retryDelay = 3000, verbo
|
|
|
33
33
|
return errorCount + 1;
|
|
34
34
|
}, 0), (0, operators_1.delay)(retryDelay))));
|
|
35
35
|
}
|
|
36
|
-
exports.handleRetry = handleRetry;
|
package/esm/sqb-core.module.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var SqbCoreModule_1;
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
-
import * as crypto from 'crypto';
|
|
4
|
-
import { defer } from 'rxjs';
|
|
5
|
-
import * as rxjs from 'rxjs';
|
|
6
3
|
import { Global, Inject, Module } from '@nestjs/common';
|
|
7
4
|
import { ModuleRef } from '@nestjs/core';
|
|
8
5
|
import { SqbClient } from '@sqb/connect';
|
|
6
|
+
import * as crypto from 'crypto';
|
|
7
|
+
import { defer } from 'rxjs';
|
|
8
|
+
import * as rxjs from 'rxjs';
|
|
9
9
|
import { SQB_MODULE_ID, SQB_MODULE_OPTIONS } from './sqb.constants.js';
|
|
10
10
|
import { getSQBToken, handleRetry } from './sqb.utils.js';
|
|
11
11
|
let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
@@ -57,7 +57,7 @@ let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
|
57
57
|
static createAsyncProviders(options) {
|
|
58
58
|
if (options.useExisting || options.useFactory)
|
|
59
59
|
return [this.createAsyncOptionsProvider(options)];
|
|
60
|
-
if (options.useClass)
|
|
60
|
+
if (options.useClass) {
|
|
61
61
|
return [
|
|
62
62
|
this.createAsyncOptionsProvider(options),
|
|
63
63
|
{
|
|
@@ -65,6 +65,7 @@ let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
|
65
65
|
useClass: options.useClass,
|
|
66
66
|
},
|
|
67
67
|
];
|
|
68
|
+
}
|
|
68
69
|
throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
|
|
69
70
|
}
|
|
70
71
|
static createAsyncOptionsProvider(options) {
|
|
@@ -97,17 +98,15 @@ let SqbCoreModule = SqbCoreModule_1 = class SqbCoreModule {
|
|
|
97
98
|
return client;
|
|
98
99
|
}).pipe(handleRetry(connectionToken, options.retryAttempts, options.retryDelay, options.verboseRetryLog, options.toRetry)));
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.toPromise();
|
|
110
|
-
}
|
|
101
|
+
// NestJS 7
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
return await defer(async () => {
|
|
104
|
+
const client = new SqbClient(options);
|
|
105
|
+
await client.test();
|
|
106
|
+
return client;
|
|
107
|
+
})
|
|
108
|
+
.pipe(handleRetry(connectionToken, options.retryAttempts, options.retryDelay, options.verboseRetryLog, options.toRetry))
|
|
109
|
+
.toPromise();
|
|
111
110
|
}
|
|
112
111
|
};
|
|
113
112
|
SqbCoreModule = SqbCoreModule_1 = __decorate([
|
package/esm/sqb.utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { delay, retryWhen, scan } from 'rxjs/operators';
|
|
2
1
|
import { Logger } from '@nestjs/common';
|
|
3
2
|
import { SqbClient } from '@sqb/connect';
|
|
3
|
+
import { delay, retryWhen, scan } from 'rxjs/operators';
|
|
4
4
|
const logger = new Logger('SqbModule');
|
|
5
5
|
/**
|
|
6
6
|
* This function returns a Connection injection token for the given connection name.
|
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.
|
|
4
|
+
"version": "4.13.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -25,28 +25,29 @@
|
|
|
25
25
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
26
26
|
"postbuild": "cp README.md package.json ../../LICENSE ../../build/nestjs && cp ../../package.cjs.json ../../build/nestjs/cjs/package.json",
|
|
27
27
|
"lint": "eslint . --max-warnings=0",
|
|
28
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
29
|
+
"format": "prettier . --write --log-level=warn",
|
|
28
30
|
"test": "jest",
|
|
29
31
|
"cover": "jest --collect-coverage",
|
|
30
32
|
"clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
|
|
31
33
|
"clean:src": "ts-cleanup -s src --all",
|
|
32
34
|
"clean:dist": "rimraf ../../build/postgres",
|
|
33
|
-
"clean:cover": "rimraf ../../coverage/postgres"
|
|
34
|
-
"format": "prettier . --write --log-level=warn"
|
|
35
|
+
"clean:cover": "rimraf ../../coverage/postgres"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@nestjs/common": "^10.3.
|
|
38
|
-
"@nestjs/core": "^10.3.
|
|
39
|
-
"@nestjs/platform-express": "^10.3.
|
|
40
|
-
"@nestjs/testing": "^10.3.
|
|
41
|
-
"postgresql-client": "^2.
|
|
38
|
+
"@nestjs/common": "^10.3.10",
|
|
39
|
+
"@nestjs/core": "^10.3.10",
|
|
40
|
+
"@nestjs/platform-express": "^10.3.10",
|
|
41
|
+
"@nestjs/testing": "^10.3.10",
|
|
42
|
+
"postgresql-client": "^2.12.0",
|
|
42
43
|
"rxjs": "^7.8.1",
|
|
43
44
|
"supertest": "^7.0.0"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"@nestjs/common": ">=7.4.0",
|
|
47
48
|
"@nestjs/core": ">=7.4.0",
|
|
48
|
-
"@sqb/builder": "^4.
|
|
49
|
-
"@sqb/connect": "^4.
|
|
49
|
+
"@sqb/builder": "^4.13.0",
|
|
50
|
+
"@sqb/connect": "^4.13.0",
|
|
50
51
|
"reflect-metadata": "^0.2.2",
|
|
51
52
|
"rxjs": ">=6.6.0"
|
|
52
53
|
},
|
package/types/sqb.utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
1
|
import { Type } from '@nestjs/common';
|
|
3
2
|
import { SqbClient } from '@sqb/connect';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
4
|
/**
|
|
5
5
|
* This function returns a Connection injection token for the given connection name.
|
|
6
6
|
* @param {string | symbol} [name=SQB_DEFAULT_CONNECTION] This optional parameter is either
|