angular-toolbox 0.11.1 → 0.11.3
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 +1 -1
- package/esm2022/lib/framework/mock/http/util/fetch-client-response-type.enum.mjs +5 -1
- package/esm2022/lib/framework/mock/http/util/fetch-client.builder.mjs +3 -2
- package/esm2022/lib/model/business/mock/http/config/http-mock-production-policy.enum.mjs +27 -0
- package/esm2022/lib/model/business/mock/http/config/http-mocking-framework-config.mjs +9 -0
- package/esm2022/lib/model/business/mock/http/config/http-mocking-framework-config.provider.mjs +33 -0
- package/esm2022/lib/model/business/mock/http/config/index.mjs +4 -0
- package/esm2022/lib/model/business/mock/http/index.mjs +2 -1
- package/esm2022/lib/model/service/mock/http/http-mock.service.mjs +45 -6
- package/esm2022/lib/model/service/version/angular-toolbox-version.service.mjs +3 -3
- package/esm2022/lib/util/http-mocking-framework-config.manager.mjs +129 -0
- package/fesm2022/angular-toolbox.mjs +243 -9
- package/fesm2022/angular-toolbox.mjs.map +1 -1
- package/lib/framework/mock/http/util/fetch-client-response-type.enum.d.ts +5 -1
- package/lib/model/business/mock/http/config/http-mock-production-policy.enum.d.ts +24 -0
- package/lib/model/business/mock/http/config/http-mocking-framework-config.d.ts +21 -0
- package/lib/model/business/mock/http/config/http-mocking-framework-config.provider.d.ts +21 -0
- package/lib/model/business/mock/http/config/index.d.ts +3 -0
- package/lib/model/business/mock/http/index.d.ts +1 -0
- package/lib/model/service/mock/http/http-mock.service.d.ts +35 -2
- package/lib/util/http-mocking-framework-config.manager.d.ts +66 -0
- package/package.json +1 -1
|
@@ -30,5 +30,9 @@ export declare enum FetchClientResponseType {
|
|
|
30
30
|
* Allows to return the response as a promise that resolves with a `String`.
|
|
31
31
|
* The response is always decoded using UTF-8.
|
|
32
32
|
*/
|
|
33
|
-
TEXT = "text"
|
|
33
|
+
TEXT = "text",
|
|
34
|
+
/**
|
|
35
|
+
* Allows to return the response as a promise that resolves with a `Response` object.
|
|
36
|
+
*/
|
|
37
|
+
RESPONSE = "response"
|
|
34
38
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
6
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The list of constant values that can be passed to the `productionPolicy` of the `HttpMockingFrameworkConfig` interface.
|
|
10
|
+
*/
|
|
11
|
+
export declare enum HttpMockProductionPolicy {
|
|
12
|
+
/**
|
|
13
|
+
* Indicates that the framework intercepts requests silently in producion mode.
|
|
14
|
+
*/
|
|
15
|
+
SILENT = 0,
|
|
16
|
+
/**
|
|
17
|
+
* Indicates that the framework has to send a warning message to the console when a request is intercetped in producion mode.
|
|
18
|
+
*/
|
|
19
|
+
WARNING = 1,
|
|
20
|
+
/**
|
|
21
|
+
* Indicates that the framework trhows an error when a request is intercetped in producion mode.
|
|
22
|
+
*/
|
|
23
|
+
ERROR = 2
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
6
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
7
|
+
*/
|
|
8
|
+
import { HttpMockProductionPolicy } from "./http-mock-production-policy.enum";
|
|
9
|
+
/**
|
|
10
|
+
* Defines properties for the HTTP Mocking framework configuration.
|
|
11
|
+
*/
|
|
12
|
+
export interface HttpMockingFrameworkConfig {
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether the visual flag is visible (`false`), or not (`true`).
|
|
15
|
+
*/
|
|
16
|
+
disableVisualFlag?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Indicates the behavior of the framework when it is used in production mode.
|
|
19
|
+
*/
|
|
20
|
+
productionPolicy?: HttpMockProductionPolicy;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
6
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
7
|
+
*/
|
|
8
|
+
import { HttpMockingFrameworkConfig } from "./http-mocking-framework-config";
|
|
9
|
+
/**
|
|
10
|
+
* The default provider for the HTTP Mocking Framework configuration. You typically define
|
|
11
|
+
* the custom properties in the main NgModule declaration to initialize the HTTP Mocking Framework:
|
|
12
|
+
*
|
|
13
|
+
* @NgModule({
|
|
14
|
+
* ...
|
|
15
|
+
* providers: [
|
|
16
|
+
* { provide: HTTP_MOCKING_FRAMEWORK_CONFIG, useValue: { disableVisualFlag: true, productionPolicy: HttpMockProductionPolicy.WARNING } }
|
|
17
|
+
* ],
|
|
18
|
+
* ...
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
export declare const HTTP_MOCKING_FRAMEWORK_CONFIG: HttpMockingFrameworkConfig;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
6
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
7
|
+
*/
|
|
8
|
+
import { OnDestroy } from '@angular/core';
|
|
1
9
|
import { HttpMockConfig } from '../../../business';
|
|
2
10
|
import { HTTPMethodRef } from '../../../../framework/mock/http/util/http-method-ref.enum';
|
|
3
11
|
import { RouteMockConfig } from '../../../../framework/mock/http/config/route-mock-config';
|
|
4
12
|
import { Uuid } from '../../../../util';
|
|
13
|
+
import { HttpMockingFrameworkConfigManager } from '../../../../util/http-mocking-framework-config.manager';
|
|
14
|
+
import { HttpMockingFrameworkConfig } from '../../../business/mock/http/config/http-mocking-framework-config';
|
|
15
|
+
import { IdentifiableComponent } from '../../../../core';
|
|
5
16
|
import * as i0 from "@angular/core";
|
|
6
17
|
/**
|
|
7
18
|
* @private
|
|
@@ -11,7 +22,7 @@ export declare const HTTP_MOCK_SERVICE: string;
|
|
|
11
22
|
/**
|
|
12
23
|
* The `HttpMockService` class provides the API for managing HTTP mock configuration objects.
|
|
13
24
|
*/
|
|
14
|
-
export declare class HttpMockService {
|
|
25
|
+
export declare class HttpMockService extends IdentifiableComponent implements OnDestroy {
|
|
15
26
|
/**
|
|
16
27
|
* @private
|
|
17
28
|
* Ensures that class type is still accessible after TypeScript compilation.
|
|
@@ -32,6 +43,28 @@ export declare class HttpMockService {
|
|
|
32
43
|
* The reference to the current app URL origin.
|
|
33
44
|
*/
|
|
34
45
|
private readonly APP_ORIGIN;
|
|
46
|
+
/**
|
|
47
|
+
* @private
|
|
48
|
+
* The reference to the èHttpMockingFrameworkConfigManager` instance.
|
|
49
|
+
*/
|
|
50
|
+
private readonly _configMmanager;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the vreference to the `HttpMockingFrameworkConfigManager` instance,
|
|
53
|
+
* associated with this service.
|
|
54
|
+
*/
|
|
55
|
+
get configMmanager(): HttpMockingFrameworkConfigManager;
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
* Creates a new `HttpMockService` instance.
|
|
59
|
+
*
|
|
60
|
+
* @param _document The reference to the app document.
|
|
61
|
+
* @param config The optional config provider for the HTTP Mocking Framework.
|
|
62
|
+
*/
|
|
63
|
+
constructor(document: Document, config: HttpMockingFrameworkConfig);
|
|
64
|
+
/**
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
ngOnDestroy(): void;
|
|
35
68
|
/**
|
|
36
69
|
* Adds the specified `HttpMockConfig` object to this `HttpMockService` instance.
|
|
37
70
|
*
|
|
@@ -96,6 +129,6 @@ export declare class HttpMockService {
|
|
|
96
129
|
* @rivate
|
|
97
130
|
*/
|
|
98
131
|
private cleanConfig;
|
|
99
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<HttpMockService,
|
|
132
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HttpMockService, [null, { optional: true; }]>;
|
|
100
133
|
static ɵprov: i0.ɵɵInjectableDeclaration<HttpMockService>;
|
|
101
134
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
6
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
7
|
+
*/
|
|
8
|
+
import { Destroyable, HttpMockProductionPolicy } from "../model";
|
|
9
|
+
import { HttpMockingFrameworkConfig } from "../model/business/mock/http/config/http-mocking-framework-config";
|
|
10
|
+
import { HTTPMethodRef } from "../framework/mock/http/util/http-method-ref.enum";
|
|
11
|
+
/**
|
|
12
|
+
* The object that manages the HTTP Mocking Framework options.
|
|
13
|
+
*/
|
|
14
|
+
export declare class HttpMockingFrameworkConfigManager implements Destroyable {
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
private _document;
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
private _config?;
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
private readonly _isProdMode;
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
private readonly _prodPolicy;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the value specified by the `disableVisualFlag` of the `HttpMockingFrameworkConfig` provider,
|
|
33
|
+
* or `false` when no provider is defined.
|
|
34
|
+
*/
|
|
35
|
+
get disableVisualFlag(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the value specified by the `productionPolicy` of the `HttpMockingFrameworkConfig` provider,
|
|
38
|
+
* or `HttpMockProductionPolicy.ERROR` when no provider is defined.
|
|
39
|
+
*/
|
|
40
|
+
get productionPolicy(): HttpMockProductionPolicy;
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
* Creates and Initializes the manager with the specified config.
|
|
44
|
+
*
|
|
45
|
+
* @param document The reference to the `Document` object, injected by Angular.
|
|
46
|
+
* @param isDevMode Indicates wheter Angular runs in development mode (`true`), or in production mode (`false`).
|
|
47
|
+
* @param config The `HttpMockingFrameworkConfi` provider.
|
|
48
|
+
*/
|
|
49
|
+
constructor(document: Document, isDevMode: boolean, config?: HttpMockingFrameworkConfig);
|
|
50
|
+
/**
|
|
51
|
+
* Apply a strategy depending on the current production policy and environment.
|
|
52
|
+
* @param route An optional parameter used when the methhod is associated to a HTTP request.
|
|
53
|
+
* Must be the representation of the intercepted route path.
|
|
54
|
+
* @param method An optional parameter used when the methhod is associated to a HTTP request.
|
|
55
|
+
* Must be the representation of the intercepted HTTP method.
|
|
56
|
+
*/
|
|
57
|
+
checkPolicy(route?: string, method?: HTTPMethodRef | undefined): void;
|
|
58
|
+
/**
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
destroy(): void;
|
|
62
|
+
/**
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
private createVisualFlag;
|
|
66
|
+
}
|