angular-toolbox 0.11.0 → 0.11.2

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.
@@ -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: 0,
547
- buildTimestamp: 1721903923427,
546
+ patch: 2,
547
+ buildTimestamp: 1722064682009,
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,95 @@ 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
+ /**
3184
+ * Allows to return the response as a promise that resolves with a `Response` object.
3185
+ */
3186
+ FetchClientResponseType["RESPONSE"] = "response";
3187
+ })(FetchClientResponseType || (FetchClientResponseType = {}));
3188
+
3189
+ /**
3190
+ * @license
3191
+ * Copyright Pascal ECHEMANN. All Rights Reserved.
3192
+ *
3193
+ * Use of this source code is governed by an MIT-style license that can be found in
3194
+ * the LICENSE file at https://pascalechemann.com/angular-toolbox/resources/license
3195
+ */
3196
+ /**
3197
+ * A static utility class for building `FetchClient` objects.
3198
+ */
3199
+ class FetchClientBuilder {
3200
+ /**
3201
+ * Builds and returns a new `FetchClient` object.
3202
+ *
3203
+ * @param input The definition of the resource to fetch.
3204
+ * @param init The object containing options to configure the request.
3205
+ * @param responseType Specifies the type of response for the resource to fetch.
3206
+ *
3207
+ * @returns A new `FetchClient` object.
3208
+ */
3209
+ static buildFetchClient(input, init = null, responseType = FetchClientResponseType.JSON) {
3210
+ return from(fetch(input, init || undefined).then((response) => {
3211
+ const rspType = responseType;
3212
+ if (response.ok)
3213
+ return rspType !== FetchClientResponseType.RESPONSE ? FetchClientBuilder.buildResponseStrategy(response, rspType) : response;
3214
+ throw new HttpErrorResponse({
3215
+ status: response.status,
3216
+ statusText: response.statusText
3217
+ });
3218
+ }));
3219
+ }
3220
+ /**
3221
+ * @private
3222
+ */
3223
+ static buildResponseStrategy(response, responseType) {
3224
+ if (responseType === FetchClientResponseType.JSON)
3225
+ return response.json();
3226
+ if (responseType === FetchClientResponseType.BLOB)
3227
+ return response.blob();
3228
+ if (responseType === FetchClientResponseType.FORM_DATA)
3229
+ return response.formData();
3230
+ if (responseType === FetchClientResponseType.ARRAY_BUFFER)
3231
+ return response.arrayBuffer();
3232
+ if (responseType === FetchClientResponseType.TEXT)
3233
+ return response.text();
3234
+ return response.json();
3235
+ }
3236
+ }
3237
+
3140
3238
  /**
3141
3239
  * @license
3142
3240
  * Copyright Pascal ECHEMANN. All Rights Reserved.
@@ -3501,7 +3599,7 @@ class DataStorageBuilder {
3501
3599
  * @param httpResponse The `HttpResponseMock` to be stored by the framework.
3502
3600
  * @param data The data of the HTTP response to be stored by the framework.
3503
3601
  *
3504
- * @returns A new `DataStorage` objects.
3602
+ * @returns A new `DataStorage` object.
3505
3603
  */
3506
3604
  static buildDataStorage(httpResponse, data) {
3507
3605
  // TODO: add support for different data types (string, Blob, etc.)
@@ -3634,7 +3732,7 @@ class DelegateXhr extends XhrBase {
3634
3732
  * @param body A body of data to be sent in the XHR request.
3635
3733
  */
3636
3734
  send(body) {
3637
- const request = new HttpRequest(this._method, this._url, body);
3735
+ const request = this.buildHttpRequest(body);
3638
3736
  const rc = this._routeConfig;
3639
3737
  const httpResponseMock = rc.methodConfig.data(request, rc.parameters);
3640
3738
  let timer = httpResponseMock.delay || 0;
@@ -3835,6 +3933,16 @@ class DelegateXhr extends XhrBase {
3835
3933
  setDataStorage(responseMock, data = null) {
3836
3934
  this._dataStorage = DataStorageBuilder.buildDataStorage(responseMock, data);
3837
3935
  }
3936
+ /**
3937
+ * @private
3938
+ */
3939
+ buildHttpRequest(body) {
3940
+ let params = new HttpParams();
3941
+ const it = this._routeConfig.searchParams.entries();
3942
+ for (const pair of it)
3943
+ params = params.set(pair[0], pair[1]);
3944
+ return new HttpRequest(this._method, this._url, body, { params: params });
3945
+ }
3838
3946
  }
3839
3947
 
3840
3948
  /**
@@ -4100,5 +4208,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.3", ngImpor
4100
4208
  * Generated bundle index. Do not edit.
4101
4209
  */
4102
4210
 
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 };
4211
+ 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
4212
  //# sourceMappingURL=angular-toolbox.mjs.map