@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';
|
|
@@ -22,8 +22,8 @@ import * as i4 from '@angular/forms';
|
|
|
22
22
|
import { FormsModule } from '@angular/forms';
|
|
23
23
|
|
|
24
24
|
const defaultPredicate = () => true;
|
|
25
|
-
const hasBlob = typeof Blob !== "undefined";
|
|
26
|
-
const hasFile = typeof File !== "undefined";
|
|
25
|
+
const hasBlob = typeof Blob !== "undefined" && !!Blob;
|
|
26
|
+
const hasFile = typeof File !== "undefined" && !!File;
|
|
27
27
|
class ObjectUtils {
|
|
28
28
|
static compare(a, b) {
|
|
29
29
|
if ((a === null || b === null) || (typeof a != typeof b)) {
|
|
@@ -488,13 +488,14 @@ class DateUtils {
|
|
|
488
488
|
static add(date, amount, unit) {
|
|
489
489
|
return moment(date).add(amount, unit).toDate();
|
|
490
490
|
}
|
|
491
|
-
static businessAdd(date, amount, unit) {
|
|
491
|
+
static businessAdd(date, amount, unit, freeDays = []) {
|
|
492
492
|
const signal = amount < 0 ? -1 : 1;
|
|
493
|
+
const freeMoments = freeDays.map(d => moment(d));
|
|
493
494
|
let remaining = Math.abs(amount);
|
|
494
495
|
let day = date;
|
|
495
496
|
while (remaining) {
|
|
496
497
|
day = DateUtils.add(day, signal, unit);
|
|
497
|
-
if (DateUtils.isBusinessDay(day)) {
|
|
498
|
+
if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
|
|
498
499
|
remaining--;
|
|
499
500
|
}
|
|
500
501
|
}
|
|
@@ -1281,7 +1282,7 @@ class UniversalService {
|
|
|
1281
1282
|
this.platformId = platformId;
|
|
1282
1283
|
this.dds = dds;
|
|
1283
1284
|
const info = this.dds.getDeviceInfo();
|
|
1284
|
-
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST)/gi.test(info.userAgent);
|
|
1285
|
+
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
|
|
1285
1286
|
}
|
|
1286
1287
|
get isBrowser() {
|
|
1287
1288
|
return isPlatformBrowser(this.platformId);
|
|
@@ -2434,15 +2435,16 @@ class BaseHttpService {
|
|
|
2434
2435
|
}
|
|
2435
2436
|
const headers = options.headers;
|
|
2436
2437
|
const authKey = "Authorization";
|
|
2437
|
-
// If an authorization header exists and we still have an Unauthorized response prompt the user to log in again
|
|
2438
|
+
// If an authorization header exists, and we still have an Unauthorized response prompt the user to log in again
|
|
2438
2439
|
if (headers.has(authKey) && response.status == 401) {
|
|
2439
2440
|
const pushed = this.pushFailedRequest(url, options, () => {
|
|
2440
2441
|
options.headers = this.makeHeaders(options.originalHeaders);
|
|
2441
2442
|
this.toPromise(url, options, listener).then(resolve, reject);
|
|
2442
2443
|
});
|
|
2443
|
-
if (pushed)
|
|
2444
|
+
if (pushed) {
|
|
2444
2445
|
this.handleUnauthorizedError(absoluteUrl, options, () => reject(response));
|
|
2445
|
-
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2446
2448
|
}
|
|
2447
2449
|
reject(response);
|
|
2448
2450
|
});
|
|
@@ -2450,7 +2452,7 @@ class BaseHttpService {
|
|
|
2450
2452
|
});
|
|
2451
2453
|
}
|
|
2452
2454
|
pushFailedRequest(url, options, req) {
|
|
2453
|
-
if (url.indexOf("
|
|
2455
|
+
if (url.indexOf("token") >= 0 || url === "user")
|
|
2454
2456
|
return false;
|
|
2455
2457
|
BaseHttpService.failedRequests.push(req);
|
|
2456
2458
|
return true;
|
|
@@ -3869,7 +3871,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
3869
3871
|
|
|
3870
3872
|
class ReplacePipe {
|
|
3871
3873
|
transform(value, from, to) {
|
|
3872
|
-
return value ? value
|
|
3874
|
+
return ObjectUtils.isDefined(value) ? `${value}`.replace(from, to) : ``;
|
|
3873
3875
|
}
|
|
3874
3876
|
}
|
|
3875
3877
|
ReplacePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ReplacePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|