@nestjs/common 8.4.4 → 9.0.0-next.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/Readme.md +3 -2
- package/cache/cache.constants.d.ts +0 -1
- package/cache/cache.constants.js +1 -2
- package/cache/cache.module-definition.d.ts +2 -0
- package/cache/cache.module-definition.js +10 -0
- package/cache/cache.module.d.ts +2 -3
- package/cache/cache.module.js +6 -43
- package/cache/cache.providers.js +2 -1
- package/cache/interfaces/cache-module.interface.d.ts +6 -2
- package/decorators/core/controller.decorator.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/interfaces/http/http-server.interface.d.ts +2 -2
- package/interfaces/http/index.d.ts +1 -0
- package/interfaces/http/index.js +1 -0
- package/interfaces/http/raw-body-request.interface.d.ts +4 -0
- package/{http/interfaces/http-module.interface.js → interfaces/http/raw-body-request.interface.js} +0 -0
- package/interfaces/modules/provider.interface.d.ts +27 -1
- package/interfaces/nest-application-options.interface.d.ts +4 -0
- package/interfaces/nest-application.interface.d.ts +0 -16
- package/interfaces/nest-microservice.interface.d.ts +0 -7
- package/interfaces/scope-options.interface.d.ts +7 -0
- package/module-utils/configurable-module.builder.d.ts +93 -0
- package/module-utils/configurable-module.builder.js +195 -0
- package/module-utils/constants.d.ts +4 -0
- package/module-utils/constants.js +7 -0
- package/module-utils/index.d.ts +2 -0
- package/{http → module-utils}/index.js +1 -2
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +36 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +13 -0
- package/module-utils/interfaces/configurable-module-cls.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +62 -0
- package/module-utils/interfaces/configurable-module-host.interface.js +2 -0
- package/module-utils/interfaces/index.d.ts +3 -0
- package/module-utils/interfaces/index.js +6 -0
- package/module-utils/utils/generate-options-injection-token.util.d.ts +1 -0
- package/module-utils/utils/generate-options-injection-token.util.js +9 -0
- package/package.json +2 -3
- package/pipes/parse-bool.pipe.d.ts +12 -0
- package/pipes/parse-bool.pipe.js +18 -2
- package/pipes/parse-float.pipe.d.ts +5 -0
- package/pipes/parse-float.pipe.js +10 -4
- package/pipes/parse-int.pipe.d.ts +5 -0
- package/pipes/parse-int.pipe.js +10 -4
- package/pipes/parse-uuid.pipe.d.ts +7 -0
- package/pipes/parse-uuid.pipe.js +19 -5
- package/utils/shared.utils.d.ts +0 -5
- package/utils/shared.utils.js +1 -6
- package/http/http.constants.d.ts +0 -3
- package/http/http.constants.js +0 -6
- package/http/http.module.d.ts +0 -11
- package/http/http.module.js +0 -88
- package/http/http.service.d.ts +0 -19
- package/http/http.service.js +0 -74
- package/http/index.d.ts +0 -3
- package/http/interfaces/http-module.interface.d.ts +0 -13
- package/http/interfaces/index.d.ts +0 -1
- package/http/interfaces/index.js +0 -4
- package/utils/is-uuid.d.ts +0 -1
- package/utils/is-uuid.js +0 -19
package/http/http.module.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var HttpModule_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.HttpModule = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const axios_1 = require("axios");
|
|
7
|
-
const module_decorator_1 = require("../decorators/modules/module.decorator");
|
|
8
|
-
const random_string_generator_util_1 = require("../utils/random-string-generator.util");
|
|
9
|
-
const http_constants_1 = require("./http.constants");
|
|
10
|
-
const http_service_1 = require("./http.service");
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated "HttpModule" (from the "@nestjs/common" package) is deprecated and will be removed in the next major release. Please, use the "@nestjs/axios" package instead.
|
|
13
|
-
*/
|
|
14
|
-
let HttpModule = HttpModule_1 = class HttpModule {
|
|
15
|
-
static register(config) {
|
|
16
|
-
return {
|
|
17
|
-
module: HttpModule_1,
|
|
18
|
-
providers: [
|
|
19
|
-
{
|
|
20
|
-
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
|
21
|
-
useValue: axios_1.default.create(config),
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
provide: http_constants_1.HTTP_MODULE_ID,
|
|
25
|
-
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
static registerAsync(options) {
|
|
31
|
-
return {
|
|
32
|
-
module: HttpModule_1,
|
|
33
|
-
imports: options.imports,
|
|
34
|
-
providers: [
|
|
35
|
-
...this.createAsyncProviders(options),
|
|
36
|
-
{
|
|
37
|
-
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
|
38
|
-
useFactory: (config) => axios_1.default.create(config),
|
|
39
|
-
inject: [http_constants_1.HTTP_MODULE_OPTIONS],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
provide: http_constants_1.HTTP_MODULE_ID,
|
|
43
|
-
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
44
|
-
},
|
|
45
|
-
...(options.extraProviders || []),
|
|
46
|
-
],
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
static createAsyncProviders(options) {
|
|
50
|
-
if (options.useExisting || options.useFactory) {
|
|
51
|
-
return [this.createAsyncOptionsProvider(options)];
|
|
52
|
-
}
|
|
53
|
-
return [
|
|
54
|
-
this.createAsyncOptionsProvider(options),
|
|
55
|
-
{
|
|
56
|
-
provide: options.useClass,
|
|
57
|
-
useClass: options.useClass,
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
-
static createAsyncOptionsProvider(options) {
|
|
62
|
-
if (options.useFactory) {
|
|
63
|
-
return {
|
|
64
|
-
provide: http_constants_1.HTTP_MODULE_OPTIONS,
|
|
65
|
-
useFactory: options.useFactory,
|
|
66
|
-
inject: options.inject || [],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
provide: http_constants_1.HTTP_MODULE_OPTIONS,
|
|
71
|
-
useFactory: async (optionsFactory) => optionsFactory.createHttpOptions(),
|
|
72
|
-
inject: [options.useExisting || options.useClass],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
HttpModule = HttpModule_1 = tslib_1.__decorate([
|
|
77
|
-
(0, module_decorator_1.Module)({
|
|
78
|
-
providers: [
|
|
79
|
-
http_service_1.HttpService,
|
|
80
|
-
{
|
|
81
|
-
provide: http_constants_1.AXIOS_INSTANCE_TOKEN,
|
|
82
|
-
useValue: axios_1.default,
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
exports: [http_service_1.HttpService],
|
|
86
|
-
})
|
|
87
|
-
], HttpModule);
|
|
88
|
-
exports.HttpModule = HttpModule;
|
package/http/http.service.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated "HttpModule" (from the "@nestjs/common" package) is deprecated and will be removed in the next major release. Please, use the "@nestjs/axios" package instead.
|
|
5
|
-
*/
|
|
6
|
-
export declare class HttpService {
|
|
7
|
-
private readonly instance;
|
|
8
|
-
private readonly logger;
|
|
9
|
-
constructor(instance?: AxiosInstance);
|
|
10
|
-
request<T = any>(config: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
11
|
-
get<T = any>(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
12
|
-
delete<T = any>(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
13
|
-
head<T = any>(url: string, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
14
|
-
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
15
|
-
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
16
|
-
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Observable<AxiosResponse<T>>;
|
|
17
|
-
get axiosRef(): AxiosInstance;
|
|
18
|
-
private makeObservable;
|
|
19
|
-
}
|
package/http/http.service.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const axios_1 = require("axios");
|
|
6
|
-
const rxjs_1 = require("rxjs");
|
|
7
|
-
const decorators_1 = require("../decorators");
|
|
8
|
-
const services_1 = require("../services");
|
|
9
|
-
const http_constants_1 = require("./http.constants");
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated "HttpModule" (from the "@nestjs/common" package) is deprecated and will be removed in the next major release. Please, use the "@nestjs/axios" package instead.
|
|
12
|
-
*/
|
|
13
|
-
let HttpService = class HttpService {
|
|
14
|
-
constructor(instance = axios_1.default) {
|
|
15
|
-
this.instance = instance;
|
|
16
|
-
this.logger = new services_1.Logger(HttpService.name);
|
|
17
|
-
this.logger.warn('DEPRECATED! "HttpModule" (from the "@nestjs/common" package) is deprecated and will be removed in the next major release. Please, use the "@nestjs/axios" package instead.');
|
|
18
|
-
}
|
|
19
|
-
request(config) {
|
|
20
|
-
return this.makeObservable(this.instance.request, config);
|
|
21
|
-
}
|
|
22
|
-
get(url, config) {
|
|
23
|
-
return this.makeObservable(this.instance.get, url, config);
|
|
24
|
-
}
|
|
25
|
-
delete(url, config) {
|
|
26
|
-
return this.makeObservable(this.instance.delete, url, config);
|
|
27
|
-
}
|
|
28
|
-
head(url, config) {
|
|
29
|
-
return this.makeObservable(this.instance.head, url, config);
|
|
30
|
-
}
|
|
31
|
-
post(url, data, config) {
|
|
32
|
-
return this.makeObservable(this.instance.post, url, data, config);
|
|
33
|
-
}
|
|
34
|
-
put(url, data, config) {
|
|
35
|
-
return this.makeObservable(this.instance.put, url, data, config);
|
|
36
|
-
}
|
|
37
|
-
patch(url, data, config) {
|
|
38
|
-
return this.makeObservable(this.instance.patch, url, data, config);
|
|
39
|
-
}
|
|
40
|
-
get axiosRef() {
|
|
41
|
-
return this.instance;
|
|
42
|
-
}
|
|
43
|
-
makeObservable(axios, ...args) {
|
|
44
|
-
return new rxjs_1.Observable(subscriber => {
|
|
45
|
-
const config = Object.assign({}, (args[args.length - 1] || {}));
|
|
46
|
-
let cancelSource;
|
|
47
|
-
if (!config.cancelToken) {
|
|
48
|
-
cancelSource = axios_1.default.CancelToken.source();
|
|
49
|
-
config.cancelToken = cancelSource.token;
|
|
50
|
-
}
|
|
51
|
-
axios(...args)
|
|
52
|
-
.then(res => {
|
|
53
|
-
subscriber.next(res);
|
|
54
|
-
subscriber.complete();
|
|
55
|
-
})
|
|
56
|
-
.catch(err => {
|
|
57
|
-
subscriber.error(err);
|
|
58
|
-
});
|
|
59
|
-
return () => {
|
|
60
|
-
if (config.responseType === 'stream') {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (cancelSource) {
|
|
64
|
-
cancelSource.cancel();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
HttpService = tslib_1.__decorate([
|
|
71
|
-
tslib_1.__param(0, (0, decorators_1.Inject)(http_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
72
|
-
tslib_1.__metadata("design:paramtypes", [Function])
|
|
73
|
-
], HttpService);
|
|
74
|
-
exports.HttpService = HttpService;
|
package/http/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { ModuleMetadata, Provider, Type } from '../../interfaces';
|
|
3
|
-
export declare type HttpModuleOptions = AxiosRequestConfig;
|
|
4
|
-
export interface HttpModuleOptionsFactory {
|
|
5
|
-
createHttpOptions(): Promise<HttpModuleOptions> | HttpModuleOptions;
|
|
6
|
-
}
|
|
7
|
-
export interface HttpModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
8
|
-
useExisting?: Type<HttpModuleOptionsFactory>;
|
|
9
|
-
useClass?: Type<HttpModuleOptionsFactory>;
|
|
10
|
-
useFactory?: (...args: any[]) => Promise<HttpModuleOptions> | HttpModuleOptions;
|
|
11
|
-
inject?: any[];
|
|
12
|
-
extraProviders?: Provider[];
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './http-module.interface';
|
package/http/interfaces/index.js
DELETED
package/utils/is-uuid.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUUID(str: any, version?: string): any;
|
package/utils/is-uuid.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUUID = void 0;
|
|
4
|
-
const exceptions_1 = require("../exceptions");
|
|
5
|
-
const shared_utils_1 = require("./shared.utils");
|
|
6
|
-
const uuid = {
|
|
7
|
-
3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
|
|
8
|
-
4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
|
9
|
-
5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
|
10
|
-
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
|
|
11
|
-
};
|
|
12
|
-
function isUUID(str, version = 'all') {
|
|
13
|
-
if (!(0, shared_utils_1.isString)(str)) {
|
|
14
|
-
throw new exceptions_1.BadRequestException('The value passed as UUID is not a string');
|
|
15
|
-
}
|
|
16
|
-
const pattern = uuid[version];
|
|
17
|
-
return pattern && pattern.test(str);
|
|
18
|
-
}
|
|
19
|
-
exports.isUUID = isUUID;
|