@stemy/ngx-utils 13.2.1 → 13.2.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/bundles/stemy-ngx-utils.umd.js +65 -50
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/directives/async-method.base.js +14 -2
- package/esm2015/ngx-utils/directives/async-method.directive.js +2 -9
- package/esm2015/ngx-utils/ngx-utils.module.js +3 -1
- package/esm2015/ngx-utils/pipes/replace.pipe.js +3 -2
- package/esm2015/ngx-utils/services/universal.service.js +2 -2
- package/esm2015/ngx-utils/utils/date.utils.js +8 -7
- package/esm2015/ngx-utils/utils/object.utils.js +3 -3
- package/esm2015/public_api.js +2 -1
- package/esm2015/stemy-ngx-utils.js +1 -2
- package/esm2020/ngx-utils/common-types.mjs +1 -1
- package/esm2020/ngx-utils/pipes/replace.pipe.mjs +3 -2
- package/esm2020/ngx-utils/services/base-http.service.mjs +6 -5
- package/esm2020/ngx-utils/services/universal.service.mjs +2 -2
- package/esm2020/ngx-utils/utils/date.utils.mjs +5 -4
- package/esm2020/ngx-utils/utils/object.utils.mjs +3 -3
- package/fesm2015/stemy-ngx-utils.js +58 -51
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/fesm2015/stemy-ngx-utils.mjs +13 -11
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +13 -11
- package/fesm2020/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +2 -1
- package/ngx-utils/utils/date.utils.d.ts +1 -1
- package/package.json +1 -1
- package/stemy-ngx-utils.metadata.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, TemplateRef, PLATFORM_ID, Injectable, Inject, Optional, Injector, EventEmitter, isDevMode, ErrorHandler, NgZone, Pipe, Directive, Input, Output, HostBinding, HostListener, Component, ContentChildren, ViewChild, ContentChild, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
|
-
import
|
|
4
|
+
import moment from 'moment';
|
|
5
5
|
import { first, skipWhile, mergeMap, timeout, map } from 'rxjs/operators';
|
|
6
6
|
import { Subject, BehaviorSubject, Observable, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
|
|
7
7
|
import { Invokable } from 'invokable';
|
|
@@ -21,8 +21,8 @@ import * as i4 from '@angular/forms';
|
|
|
21
21
|
import { FormsModule } from '@angular/forms';
|
|
22
22
|
|
|
23
23
|
const defaultPredicate = () => true;
|
|
24
|
-
const hasBlob = typeof Blob !== "undefined";
|
|
25
|
-
const hasFile = typeof File !== "undefined";
|
|
24
|
+
const hasBlob = typeof Blob !== "undefined" && !!Blob;
|
|
25
|
+
const hasFile = typeof File !== "undefined" && !!File;
|
|
26
26
|
class ObjectUtils {
|
|
27
27
|
static compare(a, b) {
|
|
28
28
|
if ((a === null || b === null) || (typeof a != typeof b)) {
|
|
@@ -487,13 +487,14 @@ class DateUtils {
|
|
|
487
487
|
static add(date, amount, unit) {
|
|
488
488
|
return moment(date).add(amount, unit).toDate();
|
|
489
489
|
}
|
|
490
|
-
static businessAdd(date, amount, unit) {
|
|
490
|
+
static businessAdd(date, amount, unit, freeDays = []) {
|
|
491
491
|
const signal = amount < 0 ? -1 : 1;
|
|
492
|
+
const freeMoments = freeDays.map(d => moment(d));
|
|
492
493
|
let remaining = Math.abs(amount);
|
|
493
494
|
let day = date;
|
|
494
495
|
while (remaining) {
|
|
495
496
|
day = DateUtils.add(day, signal, unit);
|
|
496
|
-
if (DateUtils.isBusinessDay(day)) {
|
|
497
|
+
if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
|
|
497
498
|
remaining--;
|
|
498
499
|
}
|
|
499
500
|
}
|
|
@@ -1279,7 +1280,7 @@ class UniversalService {
|
|
|
1279
1280
|
this.platformId = platformId;
|
|
1280
1281
|
this.dds = dds;
|
|
1281
1282
|
const info = this.dds.getDeviceInfo();
|
|
1282
|
-
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST)/gi.test(info.userAgent);
|
|
1283
|
+
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
|
|
1283
1284
|
}
|
|
1284
1285
|
get isBrowser() {
|
|
1285
1286
|
return isPlatformBrowser(this.platformId);
|
|
@@ -2410,15 +2411,16 @@ class BaseHttpService {
|
|
|
2410
2411
|
}
|
|
2411
2412
|
const headers = options.headers;
|
|
2412
2413
|
const authKey = "Authorization";
|
|
2413
|
-
// If an authorization header exists and we still have an Unauthorized response prompt the user to log in again
|
|
2414
|
+
// If an authorization header exists, and we still have an Unauthorized response prompt the user to log in again
|
|
2414
2415
|
if (headers.has(authKey) && response.status == 401) {
|
|
2415
2416
|
const pushed = this.pushFailedRequest(url, options, () => {
|
|
2416
2417
|
options.headers = this.makeHeaders(options.originalHeaders);
|
|
2417
2418
|
this.toPromise(url, options, listener).then(resolve, reject);
|
|
2418
2419
|
});
|
|
2419
|
-
if (pushed)
|
|
2420
|
+
if (pushed) {
|
|
2420
2421
|
this.handleUnauthorizedError(absoluteUrl, options, () => reject(response));
|
|
2421
|
-
|
|
2422
|
+
return;
|
|
2423
|
+
}
|
|
2422
2424
|
}
|
|
2423
2425
|
reject(response);
|
|
2424
2426
|
});
|
|
@@ -2426,7 +2428,7 @@ class BaseHttpService {
|
|
|
2426
2428
|
});
|
|
2427
2429
|
}
|
|
2428
2430
|
pushFailedRequest(url, options, req) {
|
|
2429
|
-
if (url.indexOf("
|
|
2431
|
+
if (url.indexOf("token") >= 0 || url === "user")
|
|
2430
2432
|
return false;
|
|
2431
2433
|
BaseHttpService.failedRequests.push(req);
|
|
2432
2434
|
return true;
|
|
@@ -3809,7 +3811,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
3809
3811
|
|
|
3810
3812
|
class ReplacePipe {
|
|
3811
3813
|
transform(value, from, to) {
|
|
3812
|
-
return value ? value
|
|
3814
|
+
return ObjectUtils.isDefined(value) ? `${value}`.replace(from, to) : ``;
|
|
3813
3815
|
}
|
|
3814
3816
|
}
|
|
3815
3817
|
ReplacePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ReplacePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|