@web-atoms/core 2.4.71 → 2.5.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.
- package/dist/App.d.ts +1 -1
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +3 -3
- package/dist/App.js.map +1 -1
- package/dist/core/AtomLoader.d.ts.map +1 -1
- package/dist/core/AtomLoader.js +42 -16
- package/dist/core/AtomLoader.js.map +1 -1
- package/dist/core/types.d.ts +1 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +5 -1
- package/dist/core/types.js.map +1 -1
- package/dist/services/BusyIndicatorService.d.ts +1 -2
- package/dist/services/BusyIndicatorService.d.ts.map +1 -1
- package/dist/services/BusyIndicatorService.js +1 -1
- package/dist/services/BusyIndicatorService.js.map +1 -1
- package/dist/services/FetchBuilder.d.ts.map +1 -1
- package/dist/services/FetchBuilder.js +21 -12
- package/dist/services/FetchBuilder.js.map +1 -1
- package/dist/services/http/RestService.d.ts.map +1 -1
- package/dist/services/http/RestService.js +34 -26
- package/dist/services/http/RestService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/view-model/Action.d.ts.map +1 -1
- package/dist/view-model/Action.js +7 -4
- package/dist/view-model/Action.js.map +1 -1
- package/dist/web/services/WebBusyIndicatorService.d.ts +1 -2
- package/dist/web/services/WebBusyIndicatorService.d.ts.map +1 -1
- package/dist/web/services/WebBusyIndicatorService.js +5 -1
- package/dist/web/services/WebBusyIndicatorService.js.map +1 -1
- package/package.json +2 -2
- package/src/App.ts +4 -4
- package/src/core/AtomLoader.ts +139 -151
- package/src/core/types.ts +7 -0
- package/src/services/BusyIndicatorService.ts +2 -2
- package/src/services/FetchBuilder.ts +44 -49
- package/src/services/http/RestService.ts +119 -125
- package/src/view-model/Action.ts +6 -4
- package/src/web/services/WebBusyIndicatorService.ts +6 -2
- package/tsconfig.json +2 -1
|
@@ -456,157 +456,151 @@ export class BaseService {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
using _busyIndicator = this.showProgress ? ( this.app.createBusyIndicator({
|
|
460
460
|
title: url,
|
|
461
461
|
description: `${method} ${url}`
|
|
462
462
|
}) ) : null;
|
|
463
463
|
|
|
464
|
-
try {
|
|
465
464
|
|
|
466
|
-
|
|
465
|
+
url = UMD.resolvePath(url);
|
|
467
466
|
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
let options: AjaxOptions = new AjaxOptions();
|
|
468
|
+
options.method = method;
|
|
470
469
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
470
|
+
if (methodOptions) {
|
|
471
|
+
options.headers = methodOptions.headers;
|
|
472
|
+
options.dataType = methodOptions.accept;
|
|
473
|
+
}
|
|
475
474
|
|
|
476
|
-
|
|
475
|
+
const methodHeaders = (options.headers = options.headers || {});
|
|
477
476
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
477
|
+
const headers = this.headers
|
|
478
|
+
? ({ ... this.headers, ... methodHeaders })
|
|
479
|
+
: methodHeaders;
|
|
481
480
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
481
|
+
// this is necessary to support IsAjaxRequest in ASP.NET MVC
|
|
482
|
+
if (!headers["X-Requested-With"]) {
|
|
483
|
+
headers["X-Requested-With"] = "XMLHttpRequest";
|
|
484
|
+
}
|
|
486
485
|
|
|
487
|
-
|
|
486
|
+
options.dataType = options.dataType || "application/json";
|
|
488
487
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
const jsonOptions = {
|
|
489
|
+
... this.jsonOptions,
|
|
490
|
+
... (methodOptions ? methodOptions.jsonOptions : {})
|
|
491
|
+
};
|
|
493
492
|
|
|
494
|
-
|
|
493
|
+
if (bag) {
|
|
495
494
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
495
|
+
for (let i: number = 0; i < bag.length; i++) {
|
|
496
|
+
const p: ServiceParameter = bag[i];
|
|
497
|
+
const vi = values[i];
|
|
498
|
+
const v: any = vi === undefined ? p.defaultValue : vi;
|
|
499
|
+
if (v instanceof CancelToken) {
|
|
500
|
+
options.cancel = v;
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
switch (p.type) {
|
|
504
|
+
case "path":
|
|
505
|
+
if (v === undefined) {
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
const vs: string = v + "";
|
|
509
|
+
const replacer = `{${p.key}}`;
|
|
510
|
+
url = url.split(replacer).join(vs);
|
|
511
|
+
break;
|
|
512
|
+
case "query":
|
|
513
|
+
if (v === undefined) {
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (url.indexOf("?") === -1) {
|
|
517
|
+
url += "?";
|
|
518
|
+
}
|
|
519
|
+
if (! /(\&|\?)$/.test(url)) {
|
|
520
|
+
url += "&";
|
|
521
|
+
}
|
|
522
|
+
url += `${encodeURIComponent(p.key)}=${encodeURIComponent(v)}`;
|
|
523
|
+
break;
|
|
524
|
+
case "queries":
|
|
525
|
+
if (url.indexOf("?") === -1) {
|
|
526
|
+
url += "?";
|
|
527
|
+
}
|
|
528
|
+
if (! /(\&|\?)$/.test(url)) {
|
|
529
|
+
url += "&";
|
|
530
|
+
}
|
|
531
|
+
for (const key in v) {
|
|
532
|
+
if (v.hasOwnProperty(key)) {
|
|
533
|
+
const element = v[key];
|
|
534
|
+
if (element !== undefined) {
|
|
535
|
+
url += `${encodeURIComponent(key)}=${encodeURIComponent(element)}&`;
|
|
538
536
|
}
|
|
539
537
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
options.url = url;
|
|
568
|
-
|
|
569
|
-
const xhr = await this.ajax(url, options);
|
|
570
|
-
|
|
571
|
-
if (/json/i.test(xhr.responseType)) {
|
|
572
|
-
const text = xhr.responseText;
|
|
573
|
-
const response = this.jsonService.parse(text, jsonOptions );
|
|
574
|
-
|
|
575
|
-
if (xhr.status >= 400) {
|
|
576
|
-
throw new JsonError(
|
|
577
|
-
typeof response === "string"
|
|
578
|
-
? response
|
|
579
|
-
: ( response.title
|
|
580
|
-
?? response.detail
|
|
581
|
-
?? response.message
|
|
582
|
-
?? response.exceptionMessage
|
|
583
|
-
?? text
|
|
584
|
-
?? "Json Server Error"), response);
|
|
585
|
-
}
|
|
586
|
-
if (methodOptions && methodOptions.returnHeaders) {
|
|
587
|
-
return {
|
|
588
|
-
headers: this.parseHeaders(xhr.responseHeaders),
|
|
589
|
-
value: response
|
|
590
|
-
};
|
|
538
|
+
}
|
|
539
|
+
break;
|
|
540
|
+
case "body":
|
|
541
|
+
options.data = v;
|
|
542
|
+
options = this.encodeData(options);
|
|
543
|
+
break;
|
|
544
|
+
case "bodyformmodel":
|
|
545
|
+
options.data = v;
|
|
546
|
+
break;
|
|
547
|
+
case "rawbody":
|
|
548
|
+
options.data = v;
|
|
549
|
+
break;
|
|
550
|
+
case "xmlbody":
|
|
551
|
+
options.contentType = "text/xml";
|
|
552
|
+
options.data = v;
|
|
553
|
+
break;
|
|
554
|
+
case "cancel":
|
|
555
|
+
options.cancel = v as CancelToken;
|
|
556
|
+
break;
|
|
557
|
+
case "header":
|
|
558
|
+
if (v === undefined) {
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
headers[p.key] = v;
|
|
562
|
+
break;
|
|
591
563
|
}
|
|
592
|
-
return response;
|
|
593
564
|
}
|
|
565
|
+
}
|
|
566
|
+
options.url = url;
|
|
567
|
+
|
|
568
|
+
const xhr = await this.ajax(url, options);
|
|
569
|
+
|
|
570
|
+
if (/json/i.test(xhr.responseType)) {
|
|
571
|
+
const text = xhr.responseText;
|
|
572
|
+
const response = this.jsonService.parse(text, jsonOptions );
|
|
573
|
+
|
|
594
574
|
if (xhr.status >= 400) {
|
|
595
|
-
throw new
|
|
575
|
+
throw new JsonError(
|
|
576
|
+
typeof response === "string"
|
|
577
|
+
? response
|
|
578
|
+
: ( response.title
|
|
579
|
+
?? response.detail
|
|
580
|
+
?? response.message
|
|
581
|
+
?? response.exceptionMessage
|
|
582
|
+
?? text
|
|
583
|
+
?? "Json Server Error"), response);
|
|
596
584
|
}
|
|
597
|
-
|
|
598
585
|
if (methodOptions && methodOptions.returnHeaders) {
|
|
599
586
|
return {
|
|
600
587
|
headers: this.parseHeaders(xhr.responseHeaders),
|
|
601
|
-
value:
|
|
588
|
+
value: response
|
|
602
589
|
};
|
|
603
590
|
}
|
|
604
|
-
return
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
591
|
+
return response;
|
|
592
|
+
}
|
|
593
|
+
if (xhr.status >= 400) {
|
|
594
|
+
throw new Error(xhr.responseText || "Server Error");
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (methodOptions && methodOptions.returnHeaders) {
|
|
598
|
+
return {
|
|
599
|
+
headers: this.parseHeaders(xhr.responseHeaders),
|
|
600
|
+
value: xhr.responseText
|
|
601
|
+
};
|
|
609
602
|
}
|
|
603
|
+
return xhr.responseText;
|
|
610
604
|
|
|
611
605
|
}
|
|
612
606
|
|
package/src/view-model/Action.ts
CHANGED
|
@@ -3,7 +3,7 @@ import Command from "../core/Command";
|
|
|
3
3
|
import EventScope from "../core/EventScope";
|
|
4
4
|
import FormattedString from "../core/FormattedString";
|
|
5
5
|
import { StringHelper } from "../core/StringHelper";
|
|
6
|
-
import { CancelToken } from "../core/types";
|
|
6
|
+
import { CancelToken, errorHandled } from "../core/types";
|
|
7
7
|
import XNode from "../core/XNode";
|
|
8
8
|
import JsonError from "../services/http/JsonError";
|
|
9
9
|
import { NavigationService, NotifyType } from "../services/NavigationService";
|
|
@@ -384,12 +384,13 @@ export default function Action(
|
|
|
384
384
|
return result;
|
|
385
385
|
} catch (e) {
|
|
386
386
|
if (CancelToken.isCancelled(e)) {
|
|
387
|
-
|
|
387
|
+
throw e;
|
|
388
388
|
}
|
|
389
|
+
e[errorHandled] = true;
|
|
389
390
|
if (/^timeout$/i.test(e.toString().trim())) {
|
|
390
391
|
// tslint:disable-next-line: no-console
|
|
391
392
|
console.warn(e);
|
|
392
|
-
|
|
393
|
+
throw e;
|
|
393
394
|
}
|
|
394
395
|
if (e instanceof JsonError) {
|
|
395
396
|
if (e.details) {
|
|
@@ -398,10 +399,11 @@ export default function Action(
|
|
|
398
399
|
title: "Error",
|
|
399
400
|
detail: e.details
|
|
400
401
|
});
|
|
401
|
-
|
|
402
|
+
throw e;
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
await ns.alert(e, "Error");
|
|
406
|
+
throw e;
|
|
405
407
|
}
|
|
406
408
|
};
|
|
407
409
|
|
|
@@ -21,7 +21,7 @@ export class WebBusyIndicatorService extends BusyIndicatorService {
|
|
|
21
21
|
|
|
22
22
|
private indicators: number = 0;
|
|
23
23
|
|
|
24
|
-
public createIndicator():
|
|
24
|
+
public createIndicator(): Disposable {
|
|
25
25
|
|
|
26
26
|
const host = document.createElement("div");
|
|
27
27
|
const popup = new AtomControl(this.app, host);
|
|
@@ -70,6 +70,10 @@ export class WebBusyIndicatorService extends BusyIndicatorService {
|
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
return
|
|
73
|
+
return {
|
|
74
|
+
[Symbol.dispose]() {
|
|
75
|
+
popup.dispose();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
74
78
|
}
|
|
75
79
|
}
|