angular-toolbox 0.11.0 → 0.11.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 +1 -1
- package/esm2022/lib/framework/mock/http/config/route-mock-config.mjs +1 -1
- package/esm2022/lib/framework/mock/http/util/data-storage.builder.mjs +2 -2
- package/esm2022/lib/framework/mock/http/util/fetch-client-response-type.enum.mjs +36 -0
- package/esm2022/lib/framework/mock/http/util/fetch-client.builder.mjs +51 -0
- package/esm2022/lib/framework/mock/http/util/index.mjs +3 -1
- package/esm2022/lib/framework/mock/http/xhr/delegate-xhr.mjs +13 -3
- package/esm2022/lib/model/business/mock/http/fetch-client.mjs +9 -0
- package/esm2022/lib/model/business/mock/http/index.mjs +2 -1
- package/esm2022/lib/model/service/mock/http/http-mock.service.mjs +3 -2
- package/esm2022/lib/model/service/version/angular-toolbox-version.service.mjs +3 -3
- package/fesm2022/angular-toolbox.mjs +111 -8
- package/fesm2022/angular-toolbox.mjs.map +1 -1
- package/lib/framework/mock/http/config/route-mock-config.d.ts +6 -0
- package/lib/framework/mock/http/util/data-storage.builder.d.ts +1 -1
- package/lib/framework/mock/http/util/fetch-client-response-type.enum.d.ts +34 -0
- package/lib/framework/mock/http/util/fetch-client.builder.d.ts +28 -0
- package/lib/framework/mock/http/util/index.d.ts +2 -0
- package/lib/framework/mock/http/xhr/delegate-xhr.d.ts +4 -0
- package/lib/model/business/mock/http/fetch-client.d.ts +13 -0
- package/lib/model/business/mock/http/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ import { Injectable, NgModule, EventEmitter, Component, Directive, Output, Input
|
|
|
3
3
|
import * as i1 from '@angular/router';
|
|
4
4
|
import { RouterModule } from '@angular/router';
|
|
5
5
|
import { DOCUMENT, XhrFactory } from '@angular/common';
|
|
6
|
-
import { HttpStatusCode, HttpHeaders, HttpRequest } from '@angular/common/http';
|
|
7
|
-
import { Observable, of } from 'rxjs';
|
|
6
|
+
import { HttpStatusCode, HttpHeaders, HttpErrorResponse, HttpParams, HttpRequest } from '@angular/common/http';
|
|
7
|
+
import { from, Observable, of } from 'rxjs';
|
|
8
8
|
import * as i1$1 from '@angular/platform-browser';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -543,8 +543,8 @@ class AbstractVersionManager {
|
|
|
543
543
|
const LAYERS_VERSION_CONFIG = {
|
|
544
544
|
major: 0,
|
|
545
545
|
minor: 11,
|
|
546
|
-
patch:
|
|
547
|
-
buildTimestamp:
|
|
546
|
+
patch: 1,
|
|
547
|
+
buildTimestamp: 1722003985958,
|
|
548
548
|
metadata: "beta"
|
|
549
549
|
};
|
|
550
550
|
/**
|
|
@@ -1393,6 +1393,14 @@ const DARK_MODE_CONFIG = {
|
|
|
1393
1393
|
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
1394
1394
|
*/
|
|
1395
1395
|
|
|
1396
|
+
/**
|
|
1397
|
+
* @license
|
|
1398
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
1399
|
+
*
|
|
1400
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
1401
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
1402
|
+
*/
|
|
1403
|
+
|
|
1396
1404
|
/**
|
|
1397
1405
|
* @license
|
|
1398
1406
|
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
@@ -2733,7 +2741,8 @@ class HttpMockService {
|
|
|
2733
2741
|
if (regexp.test(route)) {
|
|
2734
2742
|
result = {
|
|
2735
2743
|
methodConfig: methodMap.methodMock,
|
|
2736
|
-
parameters: this.buildParameters(regexp, methodMap.keys, route)
|
|
2744
|
+
parameters: this.buildParameters(regexp, methodMap.keys, route),
|
|
2745
|
+
searchParams: url.searchParams
|
|
2737
2746
|
};
|
|
2738
2747
|
break;
|
|
2739
2748
|
}
|
|
@@ -3137,6 +3146,90 @@ class HttpHeadersMockBuilder {
|
|
|
3137
3146
|
*/
|
|
3138
3147
|
const httpHeadersMock = () => new HttpHeadersMockBuilder();
|
|
3139
3148
|
|
|
3149
|
+
/**
|
|
3150
|
+
* @license
|
|
3151
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
3152
|
+
*
|
|
3153
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
3154
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
3155
|
+
*/
|
|
3156
|
+
/**
|
|
3157
|
+
* Defines the possible values for the `responseType` property of the
|
|
3158
|
+
* `FetchClientBuilder.buildFetchClient()` method.
|
|
3159
|
+
*/
|
|
3160
|
+
var FetchClientResponseType;
|
|
3161
|
+
(function (FetchClientResponseType) {
|
|
3162
|
+
/**
|
|
3163
|
+
* Allows to return the response as a promise that resolves with an `ArrayBuffer`.
|
|
3164
|
+
*/
|
|
3165
|
+
FetchClientResponseType["ARRAY_BUFFER"] = "arrayBuffer";
|
|
3166
|
+
/**
|
|
3167
|
+
* Allows to return the response as a promise that resolves with a `Blob`.
|
|
3168
|
+
*/
|
|
3169
|
+
FetchClientResponseType["BLOB"] = "blob";
|
|
3170
|
+
/**
|
|
3171
|
+
* Allows to return the response as a promise that resolves with a `FormData` object.
|
|
3172
|
+
*/
|
|
3173
|
+
FetchClientResponseType["FORM_DATA"] = "formData";
|
|
3174
|
+
/**
|
|
3175
|
+
* Allows to return the response as a promise which resolves with the result of parsing the body text as JSON.
|
|
3176
|
+
*/
|
|
3177
|
+
FetchClientResponseType["JSON"] = "json";
|
|
3178
|
+
/**
|
|
3179
|
+
* Allows to return the response as a promise that resolves with a `String`.
|
|
3180
|
+
* The response is always decoded using UTF-8.
|
|
3181
|
+
*/
|
|
3182
|
+
FetchClientResponseType["TEXT"] = "text";
|
|
3183
|
+
})(FetchClientResponseType || (FetchClientResponseType = {}));
|
|
3184
|
+
|
|
3185
|
+
/**
|
|
3186
|
+
* @license
|
|
3187
|
+
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
3188
|
+
*
|
|
3189
|
+
* Use of this source code is governed by an MIT-style license that can be found in
|
|
3190
|
+
* the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
|
|
3191
|
+
*/
|
|
3192
|
+
/**
|
|
3193
|
+
* A static utility class for building `FetchClient` objects.
|
|
3194
|
+
*/
|
|
3195
|
+
class FetchClientBuilder {
|
|
3196
|
+
/**
|
|
3197
|
+
* Builds and returns a new `FetchClient` object.
|
|
3198
|
+
*
|
|
3199
|
+
* @param input The definition of the resource to fetch.
|
|
3200
|
+
* @param init The object containing options to configure the request.
|
|
3201
|
+
* @param responseType Specifies the type of response for the resource to fetch.
|
|
3202
|
+
*
|
|
3203
|
+
* @returns A new `FetchClient` object.
|
|
3204
|
+
*/
|
|
3205
|
+
static buildFetchClient(input, init = null, responseType = FetchClientResponseType.JSON) {
|
|
3206
|
+
return from(fetch(input, init || undefined).then((response) => {
|
|
3207
|
+
if (response.ok)
|
|
3208
|
+
return FetchClientBuilder.buildResponseStrategy(response, responseType);
|
|
3209
|
+
throw new HttpErrorResponse({
|
|
3210
|
+
status: response.status,
|
|
3211
|
+
statusText: response.statusText
|
|
3212
|
+
});
|
|
3213
|
+
}));
|
|
3214
|
+
}
|
|
3215
|
+
/**
|
|
3216
|
+
* @private
|
|
3217
|
+
*/
|
|
3218
|
+
static buildResponseStrategy(response, responseType) {
|
|
3219
|
+
if (responseType === FetchClientResponseType.JSON)
|
|
3220
|
+
return response.json();
|
|
3221
|
+
if (responseType === FetchClientResponseType.BLOB)
|
|
3222
|
+
return response.blob();
|
|
3223
|
+
if (responseType === FetchClientResponseType.FORM_DATA)
|
|
3224
|
+
return response.formData();
|
|
3225
|
+
if (responseType === FetchClientResponseType.ARRAY_BUFFER)
|
|
3226
|
+
return response.arrayBuffer();
|
|
3227
|
+
if (responseType === FetchClientResponseType.TEXT)
|
|
3228
|
+
return response.text();
|
|
3229
|
+
return response.json();
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3140
3233
|
/**
|
|
3141
3234
|
* @license
|
|
3142
3235
|
* Copyright Pascal ECHEMANN. All Rights Reserved.
|
|
@@ -3501,7 +3594,7 @@ class DataStorageBuilder {
|
|
|
3501
3594
|
* @param httpResponse The `HttpResponseMock` to be stored by the framework.
|
|
3502
3595
|
* @param data The data of the HTTP response to be stored by the framework.
|
|
3503
3596
|
*
|
|
3504
|
-
* @returns A new `DataStorage`
|
|
3597
|
+
* @returns A new `DataStorage` object.
|
|
3505
3598
|
*/
|
|
3506
3599
|
static buildDataStorage(httpResponse, data) {
|
|
3507
3600
|
// TODO: add support for different data types (string, Blob, etc.)
|
|
@@ -3634,7 +3727,7 @@ class DelegateXhr extends XhrBase {
|
|
|
3634
3727
|
* @param body A body of data to be sent in the XHR request.
|
|
3635
3728
|
*/
|
|
3636
3729
|
send(body) {
|
|
3637
|
-
const request =
|
|
3730
|
+
const request = this.buildHttpRequest(body);
|
|
3638
3731
|
const rc = this._routeConfig;
|
|
3639
3732
|
const httpResponseMock = rc.methodConfig.data(request, rc.parameters);
|
|
3640
3733
|
let timer = httpResponseMock.delay || 0;
|
|
@@ -3835,6 +3928,16 @@ class DelegateXhr extends XhrBase {
|
|
|
3835
3928
|
setDataStorage(responseMock, data = null) {
|
|
3836
3929
|
this._dataStorage = DataStorageBuilder.buildDataStorage(responseMock, data);
|
|
3837
3930
|
}
|
|
3931
|
+
/**
|
|
3932
|
+
* @private
|
|
3933
|
+
*/
|
|
3934
|
+
buildHttpRequest(body) {
|
|
3935
|
+
let params = new HttpParams();
|
|
3936
|
+
const it = this._routeConfig.searchParams.entries();
|
|
3937
|
+
for (const pair of it)
|
|
3938
|
+
params = params.set(pair[0], pair[1]);
|
|
3939
|
+
return new HttpRequest(this._method, this._url, body, { params: params });
|
|
3940
|
+
}
|
|
3838
3941
|
}
|
|
3839
3942
|
|
|
3840
3943
|
/**
|
|
@@ -4100,5 +4203,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
|
|
|
4100
4203
|
* Generated bundle index. Do not edit.
|
|
4101
4204
|
*/
|
|
4102
4205
|
|
|
4103
|
-
export { APP_PRIDGE_REF, AbstractSubscriptionManager, AbstractVersionManager, AnchorLinklDirective, AngularToolboxLogoComponent, AngularToolboxModule, AngularToolboxVersionService, AppBridgeError, AppBrigeService, ArrayList, ArrayListEvent, ArrayListEventType, BIGINT, BOOLEAN, BUTTON_ROLE, ButtonRoleDirective, CSS_PROP, ContentRendererDirective, DARK_MODE_CONFIG, DarkModeService, EMPTY_STRING, FUNCTION, HTTP_MOCK_SERVICE, HttpHeadersMockBuilder, HttpMock, HttpMockService, HttpMockServiceError, HttpResponseMockBuilder, IdentifiableComponent, IntegrityError, LINK_ROLE, NUMBER, NavigateToUrlDirective, OBJECT, STORAGE_KEY, STRING, SYMBOL, SafeHtmlPipe, ScrollService, SubscriptionError, SubscriptionService, UNDEFINED, Uuid, VERSION_CONFIG, VersionService, httpHeadersMock, httpMockFactory, httpResponseMock };
|
|
4206
|
+
export { APP_PRIDGE_REF, AbstractSubscriptionManager, AbstractVersionManager, AnchorLinklDirective, AngularToolboxLogoComponent, AngularToolboxModule, AngularToolboxVersionService, AppBridgeError, AppBrigeService, ArrayList, ArrayListEvent, ArrayListEventType, BIGINT, BOOLEAN, BUTTON_ROLE, ButtonRoleDirective, CSS_PROP, ContentRendererDirective, DARK_MODE_CONFIG, DarkModeService, EMPTY_STRING, FUNCTION, FetchClientBuilder, FetchClientResponseType, HTTP_MOCK_SERVICE, HttpHeadersMockBuilder, HttpMock, HttpMockService, HttpMockServiceError, HttpResponseMockBuilder, IdentifiableComponent, IntegrityError, LINK_ROLE, NUMBER, NavigateToUrlDirective, OBJECT, STORAGE_KEY, STRING, SYMBOL, SafeHtmlPipe, ScrollService, SubscriptionError, SubscriptionService, UNDEFINED, Uuid, VERSION_CONFIG, VersionService, httpHeadersMock, httpMockFactory, httpResponseMock };
|
|
4104
4207
|
//# sourceMappingURL=angular-toolbox.mjs.map
|