@web-atoms/core 2.1.479 → 2.2.0
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.js +189 -242
- package/dist/App.js.map +1 -1
- package/dist/Atom.js +123 -138
- package/dist/Atom.js.map +1 -1
- package/dist/MockApp.js +32 -32
- package/dist/MockApp.js.map +1 -1
- package/dist/Pack.js +11 -17
- package/dist/Pack.js.map +1 -1
- package/dist/core/AtomBinder.js +187 -199
- package/dist/core/AtomBinder.js.map +1 -1
- package/dist/core/AtomBridge.js +251 -274
- package/dist/core/AtomBridge.js.map +1 -1
- package/dist/core/AtomComponent.js +509 -592
- package/dist/core/AtomComponent.js.map +1 -1
- package/dist/core/AtomDispatcher.js +50 -54
- package/dist/core/AtomDispatcher.js.map +1 -1
- package/dist/core/AtomDisposableList.js +31 -36
- package/dist/core/AtomDisposableList.js.map +1 -1
- package/dist/core/AtomEnumerator.js +19 -21
- package/dist/core/AtomEnumerator.js.map +1 -1
- package/dist/core/AtomList.js +168 -232
- package/dist/core/AtomList.js.map +1 -1
- package/dist/core/AtomLoader.js +274 -257
- package/dist/core/AtomLoader.js.map +1 -1
- package/dist/core/AtomMap.js +15 -20
- package/dist/core/AtomMap.js.map +1 -1
- package/dist/core/AtomOnce.js +31 -71
- package/dist/core/AtomOnce.js.map +1 -1
- package/dist/core/AtomSelectableList.js +210 -223
- package/dist/core/AtomSelectableList.js.map +1 -1
- package/dist/core/AtomUri.js +78 -85
- package/dist/core/AtomUri.js.map +1 -1
- package/dist/core/AtomWatcher.js +112 -186
- package/dist/core/AtomWatcher.js.map +1 -1
- package/dist/core/Bind.js +288 -380
- package/dist/core/Bind.js.map +1 -1
- package/dist/core/BindableProperty.js +40 -59
- package/dist/core/BindableProperty.js.map +1 -1
- package/dist/core/CancelTokenFactory.js +42 -49
- package/dist/core/CancelTokenFactory.js.map +1 -1
- package/dist/core/Color.js +9 -13
- package/dist/core/Color.js.map +1 -1
- package/dist/core/Colors.js +254 -254
- package/dist/core/Colors.js.map +1 -1
- package/dist/core/Defer.js +37 -47
- package/dist/core/Defer.js.map +1 -1
- package/dist/core/EventScope.js +52 -49
- package/dist/core/EventScope.js.map +1 -1
- package/dist/core/ExpressionParser.js +152 -216
- package/dist/core/ExpressionParser.js.map +1 -1
- package/dist/core/FormattedError.js +17 -19
- package/dist/core/FormattedError.js.map +1 -1
- package/dist/core/FormattedString.js +14 -16
- package/dist/core/FormattedString.js.map +1 -1
- package/dist/core/IFetchEvent.js +9 -13
- package/dist/core/IFetchEvent.js.map +1 -1
- package/dist/core/IScreen.js +9 -13
- package/dist/core/IScreen.js.map +1 -1
- package/dist/core/IValueConverter.js +9 -13
- package/dist/core/IValueConverter.js.map +1 -1
- package/dist/core/InheritedProperty.js +83 -99
- package/dist/core/InheritedProperty.js.map +1 -1
- package/dist/core/InjectProperty.js +22 -29
- package/dist/core/InjectProperty.js.map +1 -1
- package/dist/core/KeyValuePairs.js +9 -13
- package/dist/core/KeyValuePairs.js.map +1 -1
- package/dist/core/Markdown.js +22 -24
- package/dist/core/Markdown.js.map +1 -1
- package/dist/core/MarkdownError.js +20 -20
- package/dist/core/MarkdownError.js.map +1 -1
- package/dist/core/PropertyBinding.js +11 -16
- package/dist/core/PropertyBinding.js.map +1 -1
- package/dist/core/PropertyMap.js +37 -44
- package/dist/core/PropertyMap.js.map +1 -1
- package/dist/core/SingleInvoker.js +51 -54
- package/dist/core/SingleInvoker.js.map +1 -1
- package/dist/core/StringHelper.js +36 -39
- package/dist/core/StringHelper.js.map +1 -1
- package/dist/core/TransientDisposable.js +23 -26
- package/dist/core/TransientDisposable.js.map +1 -1
- package/dist/core/WatchProperty.js +34 -34
- package/dist/core/WatchProperty.js.map +1 -1
- package/dist/core/WebImage.js +15 -17
- package/dist/core/WebImage.js.map +1 -1
- package/dist/core/XNode.js +129 -157
- package/dist/core/XNode.js.map +1 -1
- package/dist/core/sleep.js +34 -40
- package/dist/core/sleep.js.map +1 -1
- package/dist/core/types.js +80 -88
- package/dist/core/types.js.map +1 -1
- package/dist/di/DISingleton.js +23 -21
- package/dist/di/DISingleton.js.map +1 -1
- package/dist/di/DITransient.js +23 -21
- package/dist/di/DITransient.js.map +1 -1
- package/dist/di/IMockOrInject.js +9 -13
- package/dist/di/IMockOrInject.js.map +1 -1
- package/dist/di/IServiceProvider.js +9 -13
- package/dist/di/IServiceProvider.js.map +1 -1
- package/dist/di/Inject.js +79 -88
- package/dist/di/Inject.js.map +1 -1
- package/dist/di/Register.js +49 -51
- package/dist/di/Register.js.map +1 -1
- package/dist/di/RegisterScoped.js +20 -20
- package/dist/di/RegisterScoped.js.map +1 -1
- package/dist/di/RegisterSingleton.js +20 -20
- package/dist/di/RegisterSingleton.js.map +1 -1
- package/dist/di/ServiceCollection.js +46 -45
- package/dist/di/ServiceCollection.js.map +1 -1
- package/dist/di/ServiceProvider.js +111 -109
- package/dist/di/ServiceProvider.js.map +1 -1
- package/dist/di/TypeKey.js +20 -43
- package/dist/di/TypeKey.js.map +1 -1
- package/dist/services/BusyIndicatorService.js +26 -32
- package/dist/services/BusyIndicatorService.js.map +1 -1
- package/dist/services/CacheService.js +112 -98
- package/dist/services/CacheService.js.map +1 -1
- package/dist/services/JsonService.js +131 -133
- package/dist/services/JsonService.js.map +1 -1
- package/dist/services/MockNavigationService.js +152 -221
- package/dist/services/MockNavigationService.js.map +1 -1
- package/dist/services/NavigationService.js +140 -154
- package/dist/services/NavigationService.js.map +1 -1
- package/dist/services/ReferenceService.js +47 -50
- package/dist/services/ReferenceService.js.map +1 -1
- package/dist/services/http/AjaxOptions.js +12 -16
- package/dist/services/http/AjaxOptions.js.map +1 -1
- package/dist/services/http/JsonError.js +17 -19
- package/dist/services/http/JsonError.js.map +1 -1
- package/dist/services/http/RestService.js +395 -583
- package/dist/services/http/RestService.js.map +1 -1
- package/dist/style/StyleRule.js +1830 -1844
- package/dist/style/StyleRule.js.map +1 -1
- package/dist/test.js +9 -66
- package/dist/test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/unit/AtomTest.js +54 -36
- package/dist/unit/AtomTest.js.map +1 -1
- package/dist/unit/AtomWebTest.js +64 -43
- package/dist/unit/AtomWebTest.js.map +1 -1
- package/dist/view-model/Action.js +152 -134
- package/dist/view-model/Action.js.map +1 -1
- package/dist/view-model/AtomViewModel.js +318 -416
- package/dist/view-model/AtomViewModel.js.map +1 -1
- package/dist/view-model/AtomWindowViewModel.js +55 -90
- package/dist/view-model/AtomWindowViewModel.js.map +1 -1
- package/dist/view-model/BindableUrlParameter.js +25 -25
- package/dist/view-model/BindableUrlParameter.js.map +1 -1
- package/dist/view-model/Delay.js +34 -46
- package/dist/view-model/Delay.js.map +1 -1
- package/dist/view-model/Disposable.js +31 -39
- package/dist/view-model/Disposable.js.map +1 -1
- package/dist/view-model/Load.js +119 -123
- package/dist/view-model/Load.js.map +1 -1
- package/dist/view-model/Once.js +48 -53
- package/dist/view-model/Once.js.map +1 -1
- package/dist/view-model/baseTypes.js +15 -20
- package/dist/view-model/baseTypes.js.map +1 -1
- package/dist/view-model/bindPromise.js +42 -48
- package/dist/view-model/bindPromise.js.map +1 -1
- package/dist/view-model/bindProperty.js +17 -27
- package/dist/view-model/bindProperty.js.map +1 -1
- package/dist/view-model/bindUrlParameter.js +55 -66
- package/dist/view-model/bindUrlParameter.js.map +1 -1
- package/dist/web/WebApp.js +136 -135
- package/dist/web/WebApp.js.map +1 -1
- package/dist/web/controls/AtomAlertWindow.js +61 -90
- package/dist/web/controls/AtomAlertWindow.js.map +1 -1
- package/dist/web/controls/AtomComboBox.js +82 -86
- package/dist/web/controls/AtomComboBox.js.map +1 -1
- package/dist/web/controls/AtomContentControl.js +52 -50
- package/dist/web/controls/AtomContentControl.js.map +1 -1
- package/dist/web/controls/AtomControl.js +435 -476
- package/dist/web/controls/AtomControl.js.map +1 -1
- package/dist/web/controls/AtomFrame.js +224 -226
- package/dist/web/controls/AtomFrame.js.map +1 -1
- package/dist/web/controls/AtomGridSplitter.js +67 -65
- package/dist/web/controls/AtomGridSplitter.js.map +1 -1
- package/dist/web/controls/AtomGridView.js +228 -254
- package/dist/web/controls/AtomGridView.js.map +1 -1
- package/dist/web/controls/AtomItemsControl.js +622 -761
- package/dist/web/controls/AtomItemsControl.js.map +1 -1
- package/dist/web/controls/AtomListBox.js +56 -64
- package/dist/web/controls/AtomListBox.js.map +1 -1
- package/dist/web/controls/AtomNotification.js +59 -54
- package/dist/web/controls/AtomNotification.js.map +1 -1
- package/dist/web/controls/AtomPage.js +18 -20
- package/dist/web/controls/AtomPage.js.map +1 -1
- package/dist/web/controls/AtomPageLink.js +131 -107
- package/dist/web/controls/AtomPageLink.js.map +1 -1
- package/dist/web/controls/AtomTabbedPage.js +269 -246
- package/dist/web/controls/AtomTabbedPage.js.map +1 -1
- package/dist/web/controls/AtomTemplate.js +14 -17
- package/dist/web/controls/AtomTemplate.js.map +1 -1
- package/dist/web/controls/AtomTemplateControl.js +38 -40
- package/dist/web/controls/AtomTemplateControl.js.map +1 -1
- package/dist/web/controls/AtomToggleButtonBar.js +37 -37
- package/dist/web/controls/AtomToggleButtonBar.js.map +1 -1
- package/dist/web/controls/AtomViewPager.js +87 -67
- package/dist/web/controls/AtomViewPager.js.map +1 -1
- package/dist/web/controls/AtomViewStack.js +30 -32
- package/dist/web/controls/AtomViewStack.js.map +1 -1
- package/dist/web/controls/AtomWindow.js +218 -233
- package/dist/web/controls/AtomWindow.js.map +1 -1
- package/dist/web/core/AtomUI.js +160 -172
- package/dist/web/core/AtomUI.js.map +1 -1
- package/dist/web/core/Encoder.js +152 -199
- package/dist/web/core/Encoder.js.map +1 -1
- package/dist/web/core/HtmlNode.js +165 -161
- package/dist/web/core/HtmlNode.js.map +1 -1
- package/dist/web/images/Busy.js +13 -14
- package/dist/web/images/Busy.js.map +1 -1
- package/dist/web/images/BusyDataUrl.js +14 -882
- package/dist/web/images/BusyDataUrl.js.map +1 -1
- package/dist/web/images/Button.js +13 -15
- package/dist/web/images/Button.js.map +1 -1
- package/dist/web/images/ButtonDataUrl.js +14 -43
- package/dist/web/images/ButtonDataUrl.js.map +1 -1
- package/dist/web/images/CloseButton.js +13 -14
- package/dist/web/images/CloseButton.js.map +1 -1
- package/dist/web/images/CloseButtonDataUrl.js +14 -43
- package/dist/web/images/CloseButtonDataUrl.js.map +1 -1
- package/dist/web/images/CloseButtonHover.js +13 -14
- package/dist/web/images/CloseButtonHover.js.map +1 -1
- package/dist/web/images/CloseButtonHoverDataUrl.js +14 -37
- package/dist/web/images/CloseButtonHoverDataUrl.js.map +1 -1
- package/dist/web/samples/MovieService.js +60 -49
- package/dist/web/samples/MovieService.js.map +1 -1
- package/dist/web/samples/demo/app.js +23 -23
- package/dist/web/samples/demo/app.js.map +1 -1
- package/dist/web/samples/demo/views/MovieList.js +64 -67
- package/dist/web/samples/demo/views/MovieList.js.map +1 -1
- package/dist/web/samples/demo/views/MovieListViewModel.js +102 -82
- package/dist/web/samples/demo/views/MovieListViewModel.js.map +1 -1
- package/dist/web/samples/tabs/app.js +57 -39
- package/dist/web/samples/tabs/app.js.map +1 -1
- package/dist/web/samples/tabs/views/List.js +13 -14
- package/dist/web/samples/tabs/views/List.js.map +1 -1
- package/dist/web/samples/tabs/views/ListDataUrl.js +14 -18
- package/dist/web/samples/tabs/views/ListDataUrl.js.map +1 -1
- package/dist/web/samples/tabs/views/Page1.js +94 -74
- package/dist/web/samples/tabs/views/Page1.js.map +1 -1
- package/dist/web/samples/tabs/views/TabHost.js +82 -63
- package/dist/web/samples/tabs/views/TabHost.js.map +1 -1
- package/dist/web/samples/window/WindowSample.js +27 -23
- package/dist/web/samples/window/WindowSample.js.map +1 -1
- package/dist/web/services/MarkdownService.js +35 -51
- package/dist/web/services/MarkdownService.js.map +1 -1
- package/dist/web/services/NotificationPopup.js +48 -44
- package/dist/web/services/NotificationPopup.js.map +1 -1
- package/dist/web/services/PopupService.js +770 -940
- package/dist/web/services/PopupService.js.map +1 -1
- package/dist/web/services/WebBusyIndicatorService.js +80 -86
- package/dist/web/services/WebBusyIndicatorService.js.map +1 -1
- package/dist/web/services/WindowService.js +332 -418
- package/dist/web/services/WindowService.js.map +1 -1
- package/dist/web/styles/AtomAlertWindowStyle.js +44 -34
- package/dist/web/styles/AtomAlertWindowStyle.js.map +1 -1
- package/dist/web/styles/AtomFrameStyle.js +27 -20
- package/dist/web/styles/AtomFrameStyle.js.map +1 -1
- package/dist/web/styles/AtomListBoxStyle.js +34 -32
- package/dist/web/styles/AtomListBoxStyle.js.map +1 -1
- package/dist/web/styles/AtomNotificationStyle.js +33 -33
- package/dist/web/styles/AtomNotificationStyle.js.map +1 -1
- package/dist/web/styles/AtomPageLinkStyle.js +21 -22
- package/dist/web/styles/AtomPageLinkStyle.js.map +1 -1
- package/dist/web/styles/AtomPopupStyle.js +21 -23
- package/dist/web/styles/AtomPopupStyle.js.map +1 -1
- package/dist/web/styles/AtomStyle.js +69 -73
- package/dist/web/styles/AtomStyle.js.map +1 -1
- package/dist/web/styles/AtomStyleSheet.js +54 -57
- package/dist/web/styles/AtomStyleSheet.js.map +1 -1
- package/dist/web/styles/AtomTabbedPageStyle.js +110 -105
- package/dist/web/styles/AtomTabbedPageStyle.js.map +1 -1
- package/dist/web/styles/AtomTheme.js +62 -65
- package/dist/web/styles/AtomTheme.js.map +1 -1
- package/dist/web/styles/AtomToggleButtonBarStyle.js +68 -49
- package/dist/web/styles/AtomToggleButtonBarStyle.js.map +1 -1
- package/dist/web/styles/AtomWindowStyle.js +108 -117
- package/dist/web/styles/AtomWindowStyle.js.map +1 -1
- package/dist/web/styles/CSS.js +71 -81
- package/dist/web/styles/CSS.js.map +1 -1
- package/dist/web/styles/CommonStyles.js +60 -66
- package/dist/web/styles/CommonStyles.js.map +1 -1
- package/dist/web/styles/IStyleDeclaration.js +9 -13
- package/dist/web/styles/IStyleDeclaration.js.map +1 -1
- package/dist/web/styles/StyleBuilder.js +74 -75
- package/dist/web/styles/StyleBuilder.js.map +1 -1
- package/dist/xf/XFApp.js +54 -50
- package/dist/xf/XFApp.js.map +1 -1
- package/dist/xf/controls/AtomXFControl.js +233 -229
- package/dist/xf/controls/AtomXFControl.js.map +1 -1
- package/dist/xf/services/XFBusyIndicatorService.js +34 -34
- package/dist/xf/services/XFBusyIndicatorService.js.map +1 -1
- package/dist/xf/services/XFNavigationService.js +150 -133
- package/dist/xf/services/XFNavigationService.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,610 +1,422 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})(function (require, exports) {
|
|
31
|
-
"use strict";
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.BaseService = exports.ServiceParameter = exports.Cancel = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.XmlBody = exports.BodyFormModel = exports.RawBody = exports.Body = exports.Queries = exports.Query = exports.Header = exports.Path = void 0;
|
|
34
|
-
const AjaxOptions_1 = require("./AjaxOptions");
|
|
35
|
-
const App_1 = require("../../App");
|
|
36
|
-
const Atom_1 = require("../../Atom");
|
|
37
|
-
const AtomBridge_1 = require("../../core/AtomBridge");
|
|
38
|
-
const types_1 = require("../../core/types");
|
|
39
|
-
const Inject_1 = require("../../di/Inject");
|
|
40
|
-
const TypeKey_1 = require("../../di/TypeKey");
|
|
41
|
-
const CacheService_1 = require("../CacheService");
|
|
42
|
-
const JsonService_1 = require("../JsonService");
|
|
43
|
-
const JsonError_1 = require("./JsonError");
|
|
44
|
-
// tslint:disable-next-line
|
|
45
|
-
function methodBuilder(method) {
|
|
46
|
-
// tslint:disable-next-line
|
|
47
|
-
return function (url, options) {
|
|
48
|
-
// tslint:disable-next-line
|
|
49
|
-
return function (target, propertyKey, descriptor) {
|
|
50
|
-
target.methods = target.methods || {};
|
|
51
|
-
const a = target.methods[propertyKey];
|
|
52
|
-
const oldFunction = descriptor.value;
|
|
53
|
-
// tslint:disable-next-line:typedef
|
|
54
|
-
descriptor.value = function (...args) {
|
|
55
|
-
if (this.testMode || Atom_1.Atom.designMode) {
|
|
56
|
-
// tslint:disable-next-line:no-console
|
|
57
|
-
console.log(`Test Design Mode: ${url} .. ${args.join(",")}`);
|
|
58
|
-
const ro = oldFunction.apply(this, args);
|
|
59
|
-
if (ro) {
|
|
60
|
-
return ro;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const jsCache = options ? options.jsCacheSeconds : 0;
|
|
64
|
-
if (jsCache) {
|
|
65
|
-
const cacheService = this.app.resolve(CacheService_1.default);
|
|
66
|
-
const jArgs = args.map((arg) => arg instanceof types_1.CancelToken ? null : arg);
|
|
67
|
-
const key = `${this.constructor.name}:${method}:${url}:${JSON.stringify(jArgs)}`;
|
|
68
|
-
return cacheService.getOrCreate(key, (e) => {
|
|
69
|
-
e.ttlSeconds = jsCache;
|
|
70
|
-
return this.invoke(url, method, a, args, options);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return this.invoke(url, method, a, args, options);
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
// tslint:disable-next-line
|
|
79
|
-
function parameterBuilder(paramName, defaultValue) {
|
|
80
|
-
// tslint:disable-next-line
|
|
81
|
-
return function (key) {
|
|
82
|
-
// console.log("Declaration");
|
|
83
|
-
// console.log({ key:key});
|
|
84
|
-
// tslint:disable-next-line
|
|
85
|
-
return function (target, propertyKey, parameterIndex) {
|
|
86
|
-
// console.log("Instance");
|
|
87
|
-
// console.log({ key:key, propertyKey: propertyKey,parameterIndex: parameterIndex });
|
|
88
|
-
target.methods = target.methods || {};
|
|
89
|
-
let a = target.methods[propertyKey];
|
|
90
|
-
if (!a) {
|
|
91
|
-
a = [];
|
|
92
|
-
target.methods[propertyKey] = a;
|
|
93
|
-
}
|
|
94
|
-
a[parameterIndex] = new ServiceParameter(paramName, key, defaultValue);
|
|
95
|
-
};
|
|
1
|
+
System.register(["./AjaxOptions", "../../App", "../../Atom", "../../core/AtomBridge", "../../core/types", "../../di/Inject", "../../di/TypeKey", "../CacheService", "../JsonService", "./JsonError"], function (_export, _context) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var AjaxOptions, App, Atom, AtomBridge, CancelToken, Inject, TypeKey, CacheService, JsonService, JsonError, ServiceParameter, __decorate, __metadata, __param, __awaiter, Path, Header, Query, Queries, Body, RawBody, BodyFormModel, XmlBody, Post, Get, Delete, Put, Patch, globalNS, BaseService;
|
|
5
|
+
function methodBuilder(method) {
|
|
6
|
+
return function (url, options) {
|
|
7
|
+
return function (target, propertyKey, descriptor) {
|
|
8
|
+
target.methods = target.methods || {};
|
|
9
|
+
const a = target.methods[propertyKey];
|
|
10
|
+
const oldFunction = descriptor.value;
|
|
11
|
+
descriptor.value = function (...args) {
|
|
12
|
+
if (this.testMode || Atom.designMode) {
|
|
13
|
+
console.log(`Test Design Mode: ${url} .. ${args.join(",")}`);
|
|
14
|
+
const ro = oldFunction.apply(this, args);
|
|
15
|
+
if (ro) {
|
|
16
|
+
return ro;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const jsCache = options ? options.jsCacheSeconds : 0;
|
|
20
|
+
if (jsCache) {
|
|
21
|
+
const cacheService = this.app.resolve(CacheService);
|
|
22
|
+
const jArgs = args.map(arg => arg instanceof CancelToken ? null : arg);
|
|
23
|
+
const key = `${this.constructor.name}:${method}:${url}:${JSON.stringify(jArgs)}`;
|
|
24
|
+
return cacheService.getOrCreate(key, e => {
|
|
25
|
+
e.ttlSeconds = jsCache;
|
|
26
|
+
return this.invoke(url, method, a, args, options);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return this.invoke(url, method, a, args, options);
|
|
96
30
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* async getProducts(
|
|
105
|
-
* @Path("category") category: number
|
|
106
|
-
* ): Promise<Product[]> {
|
|
107
|
-
* }
|
|
108
|
-
*
|
|
109
|
-
* @export
|
|
110
|
-
* @function Path
|
|
111
|
-
* @param {name} - Name of the parameter
|
|
112
|
-
*/
|
|
113
|
-
exports.Path = parameterBuilder("Path");
|
|
114
|
-
/**
|
|
115
|
-
* This will register header on parameter.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
*
|
|
119
|
-
* @Get("/api/products/{category}")
|
|
120
|
-
* async getProducts(
|
|
121
|
-
* @Header("x-http-auth") category: number
|
|
122
|
-
* ): Promise<Product[]> {
|
|
123
|
-
* }
|
|
124
|
-
*
|
|
125
|
-
* @export
|
|
126
|
-
* @function Path
|
|
127
|
-
* @param {name} - Name of the parameter
|
|
128
|
-
*/
|
|
129
|
-
exports.Header = parameterBuilder("Header");
|
|
130
|
-
/**
|
|
131
|
-
* This will register Url query fragment on parameter.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
*
|
|
135
|
-
* @Get("/api/products")
|
|
136
|
-
* async getProducts(
|
|
137
|
-
* @Query("category") category: number
|
|
138
|
-
* ): Promise<Product[]> {
|
|
139
|
-
* }
|
|
140
|
-
*
|
|
141
|
-
* @export
|
|
142
|
-
* @function Query
|
|
143
|
-
* @param {name} - Name of the parameter
|
|
144
|
-
*/
|
|
145
|
-
exports.Query = parameterBuilder("Query");
|
|
146
|
-
/**
|
|
147
|
-
* This will register Url query fragments on parameter of type object
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
*
|
|
151
|
-
* @Get("/api/products")
|
|
152
|
-
* async getProducts(
|
|
153
|
-
* @Queries queries: { [key: string]: string | number | boolean | null }
|
|
154
|
-
* ): Promise<Product[]> {
|
|
155
|
-
* return null;
|
|
156
|
-
* }
|
|
157
|
-
*/
|
|
158
|
-
exports.Queries = parameterBuilder("Queries")("");
|
|
159
|
-
/**
|
|
160
|
-
* This will register data fragment on ajax.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
*
|
|
164
|
-
* @Post("/api/products")
|
|
165
|
-
* async getProducts(
|
|
166
|
-
* @Query("id") id: number,
|
|
167
|
-
* @Body product: Product
|
|
168
|
-
* ): Promise<Product[]> {
|
|
169
|
-
* }
|
|
170
|
-
*
|
|
171
|
-
* @export
|
|
172
|
-
* @function Body
|
|
173
|
-
*/
|
|
174
|
-
exports.Body = parameterBuilder("Body")("");
|
|
175
|
-
exports.RawBody = parameterBuilder("RawBody")("");
|
|
176
|
-
/**
|
|
177
|
-
* This will register data fragment on ajax in old formModel way.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
*
|
|
181
|
-
* @Post("/api/products")
|
|
182
|
-
* async getProducts(
|
|
183
|
-
* @Query("id") id: number,
|
|
184
|
-
* @BodyFormModel product: Product
|
|
185
|
-
* ): Promise<Product[]> {
|
|
186
|
-
* }
|
|
187
|
-
*
|
|
188
|
-
* @export
|
|
189
|
-
* @function BodyFormModel
|
|
190
|
-
*/
|
|
191
|
-
exports.BodyFormModel = parameterBuilder("BodyFormModel")("");
|
|
192
|
-
exports.XmlBody = parameterBuilder("XmlBody")("");
|
|
193
|
-
/**
|
|
194
|
-
* Http Post method
|
|
195
|
-
* @example
|
|
196
|
-
*
|
|
197
|
-
* @Post("/api/products")
|
|
198
|
-
* async saveProduct(
|
|
199
|
-
* @Body product: Product
|
|
200
|
-
* ): Promise<Product> {
|
|
201
|
-
* }
|
|
202
|
-
*
|
|
203
|
-
* @export
|
|
204
|
-
* @function Post
|
|
205
|
-
* @param {url} - Url for the operation
|
|
206
|
-
*/
|
|
207
|
-
exports.Post = methodBuilder("Post");
|
|
208
|
-
/**
|
|
209
|
-
* Http Get Method
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
*
|
|
213
|
-
* @Get("/api/products/{category}")
|
|
214
|
-
* async getProducts(
|
|
215
|
-
* @Path("category") category?:string
|
|
216
|
-
* ): Promise<Product[]> {
|
|
217
|
-
* }
|
|
218
|
-
*
|
|
219
|
-
* @export
|
|
220
|
-
* @function Body
|
|
221
|
-
*/
|
|
222
|
-
exports.Get = methodBuilder("Get");
|
|
223
|
-
/**
|
|
224
|
-
* Http Delete method
|
|
225
|
-
* @example
|
|
226
|
-
*
|
|
227
|
-
* @Delete("/api/products")
|
|
228
|
-
* async deleteProduct(
|
|
229
|
-
* @Body product: Product
|
|
230
|
-
* ): Promise<Product> {
|
|
231
|
-
* }
|
|
232
|
-
*
|
|
233
|
-
* @export
|
|
234
|
-
* @function Delete
|
|
235
|
-
* @param {url} - Url for the operation
|
|
236
|
-
*/
|
|
237
|
-
exports.Delete = methodBuilder("Delete");
|
|
238
|
-
/**
|
|
239
|
-
* Http Put method
|
|
240
|
-
* @example
|
|
241
|
-
*
|
|
242
|
-
* @Put("/api/products")
|
|
243
|
-
* async saveProduct(
|
|
244
|
-
* @Body product: Product
|
|
245
|
-
* ): Promise<Product> {
|
|
246
|
-
* }
|
|
247
|
-
*
|
|
248
|
-
* @export
|
|
249
|
-
* @function Put
|
|
250
|
-
* @param {url} - Url for the operation
|
|
251
|
-
*/
|
|
252
|
-
exports.Put = methodBuilder("Put");
|
|
253
|
-
/**
|
|
254
|
-
* Http Patch method
|
|
255
|
-
* @example
|
|
256
|
-
*
|
|
257
|
-
* @Patch("/api/products")
|
|
258
|
-
* async saveProduct(
|
|
259
|
-
* @Body product: any
|
|
260
|
-
* ): Promise<Product> {
|
|
261
|
-
* }
|
|
262
|
-
*
|
|
263
|
-
* @export
|
|
264
|
-
* @function Patch
|
|
265
|
-
* @param {url} - Url for the operation
|
|
266
|
-
*/
|
|
267
|
-
exports.Patch = methodBuilder("Patch");
|
|
268
|
-
/**
|
|
269
|
-
* Cancellation token
|
|
270
|
-
* @example
|
|
271
|
-
*
|
|
272
|
-
* @Put("/api/products")
|
|
273
|
-
* async saveProduct(
|
|
274
|
-
* @Body product: Product
|
|
275
|
-
* @Cancel cancel: CancelToken
|
|
276
|
-
* ): Promise<Product> {
|
|
277
|
-
* }
|
|
278
|
-
*
|
|
279
|
-
* @export
|
|
280
|
-
* @function Put
|
|
281
|
-
* @param {url} - Url for the operation
|
|
282
|
-
*/
|
|
283
|
-
function Cancel(target, propertyKey, parameterIndex) {
|
|
284
|
-
if (!target.methods) {
|
|
285
|
-
target.methods = {};
|
|
286
|
-
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function parameterBuilder(paramName, defaultValue) {
|
|
35
|
+
return function (key) {
|
|
36
|
+
return function (target, propertyKey, parameterIndex) {
|
|
37
|
+
target.methods = target.methods || {};
|
|
287
38
|
let a = target.methods[propertyKey];
|
|
288
39
|
if (!a) {
|
|
289
|
-
|
|
290
|
-
|
|
40
|
+
a = [];
|
|
41
|
+
target.methods[propertyKey] = a;
|
|
291
42
|
}
|
|
292
|
-
a[parameterIndex] = new ServiceParameter(
|
|
43
|
+
a[parameterIndex] = new ServiceParameter(paramName, key, defaultValue);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function Cancel(target, propertyKey, parameterIndex) {
|
|
48
|
+
if (!target.methods) {
|
|
49
|
+
target.methods = {};
|
|
293
50
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
this.key = key;
|
|
299
|
-
this.defaultValue = defaultValue;
|
|
300
|
-
this.type = type.toLowerCase();
|
|
301
|
-
this.key = key;
|
|
302
|
-
}
|
|
51
|
+
let a = target.methods[propertyKey];
|
|
52
|
+
if (!a) {
|
|
53
|
+
a = [];
|
|
54
|
+
target.methods[propertyKey] = a;
|
|
303
55
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
56
|
+
a[parameterIndex] = new ServiceParameter("cancel", "");
|
|
57
|
+
}
|
|
58
|
+
function BaseUrl(baseUrl) {
|
|
59
|
+
return target => {
|
|
60
|
+
const key = TypeKey.get(target);
|
|
61
|
+
BaseService.baseUrls[key] = baseUrl;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
_export({
|
|
65
|
+
Cancel: Cancel,
|
|
66
|
+
ServiceParameter: void 0,
|
|
67
|
+
default: BaseUrl
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
setters: [function (_AjaxOptions) {
|
|
71
|
+
AjaxOptions = _AjaxOptions.AjaxOptions;
|
|
72
|
+
}, function (_App) {
|
|
73
|
+
App = _App.App;
|
|
74
|
+
}, function (_Atom) {
|
|
75
|
+
Atom = _Atom.Atom;
|
|
76
|
+
}, function (_coreAtomBridge) {
|
|
77
|
+
AtomBridge = _coreAtomBridge.AtomBridge;
|
|
78
|
+
}, function (_coreTypes) {
|
|
79
|
+
CancelToken = _coreTypes.CancelToken;
|
|
80
|
+
}, function (_diInject) {
|
|
81
|
+
Inject = _diInject.Inject;
|
|
82
|
+
}, function (_diTypeKey) {
|
|
83
|
+
TypeKey = _diTypeKey.TypeKey;
|
|
84
|
+
}, function (_CacheService) {
|
|
85
|
+
CacheService = _CacheService.default;
|
|
86
|
+
}, function (_JsonService) {
|
|
87
|
+
JsonService = _JsonService.JsonService;
|
|
88
|
+
}, function (_JsonError) {
|
|
89
|
+
JsonError = _JsonError.default;
|
|
90
|
+
}],
|
|
91
|
+
execute: function () {
|
|
92
|
+
__decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
|
|
93
|
+
var c = arguments.length,
|
|
94
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
95
|
+
d;
|
|
96
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
97
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
98
|
+
};
|
|
99
|
+
__metadata = void 0 && (void 0).__metadata || function (k, v) {
|
|
100
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
101
|
+
};
|
|
102
|
+
__param = void 0 && (void 0).__param || function (paramIndex, decorator) {
|
|
103
|
+
return function (target, key) {
|
|
104
|
+
decorator(target, key, paramIndex);
|
|
309
105
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
106
|
+
};
|
|
107
|
+
__awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
108
|
+
function adopt(value) {
|
|
109
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
110
|
+
resolve(value);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
114
|
+
function fulfilled(value) {
|
|
115
|
+
try {
|
|
116
|
+
step(generator.next(value));
|
|
117
|
+
} catch (e) {
|
|
118
|
+
reject(e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function rejected(value) {
|
|
122
|
+
try {
|
|
123
|
+
step(generator["throw"](value));
|
|
124
|
+
} catch (e) {
|
|
125
|
+
reject(e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function step(result) {
|
|
129
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
130
|
+
}
|
|
131
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
_export("Path", Path = parameterBuilder("Path"));
|
|
135
|
+
_export("Header", Header = parameterBuilder("Header"));
|
|
136
|
+
_export("Query", Query = parameterBuilder("Query"));
|
|
137
|
+
_export("Queries", Queries = parameterBuilder("Queries")(""));
|
|
138
|
+
_export("Body", Body = parameterBuilder("Body")(""));
|
|
139
|
+
_export("RawBody", RawBody = parameterBuilder("RawBody")(""));
|
|
140
|
+
_export("BodyFormModel", BodyFormModel = parameterBuilder("BodyFormModel")(""));
|
|
141
|
+
_export("XmlBody", XmlBody = parameterBuilder("XmlBody")(""));
|
|
142
|
+
_export("Post", Post = methodBuilder("Post"));
|
|
143
|
+
_export("Get", Get = methodBuilder("Get"));
|
|
144
|
+
_export("Delete", Delete = methodBuilder("Delete"));
|
|
145
|
+
_export("Put", Put = methodBuilder("Put"));
|
|
146
|
+
_export("Patch", Patch = methodBuilder("Patch"));
|
|
147
|
+
_export("ServiceParameter", ServiceParameter = class ServiceParameter {
|
|
148
|
+
constructor(type, key, defaultValue) {
|
|
149
|
+
this.type = type;
|
|
150
|
+
this.key = key;
|
|
151
|
+
this.defaultValue = defaultValue;
|
|
152
|
+
this.type = type.toLowerCase();
|
|
153
|
+
this.key = key;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
globalNS = typeof global !== "undefined" ? global : window;
|
|
157
|
+
if (!globalNS.XMLHttpRequest) {
|
|
315
158
|
globalNS.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* @export
|
|
321
|
-
* @class BaseService
|
|
322
|
-
*/
|
|
323
|
-
let BaseService = class BaseService {
|
|
159
|
+
}
|
|
160
|
+
_export("BaseService", BaseService = class BaseService {
|
|
324
161
|
constructor(app, jsonService) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
this.jsonOptions = Object.assign({}, this.jsonService.options);
|
|
162
|
+
this.app = app;
|
|
163
|
+
this.jsonService = jsonService;
|
|
164
|
+
this.testMode = false;
|
|
165
|
+
this.showProgress = true;
|
|
166
|
+
this.showError = false;
|
|
167
|
+
this.methods = {};
|
|
168
|
+
this.methodReturns = {};
|
|
169
|
+
this.jsonOptions = null;
|
|
170
|
+
this.headers = null;
|
|
171
|
+
this.jsonOptions = Object.assign({}, this.jsonService.options);
|
|
336
172
|
}
|
|
337
173
|
encodeData(o) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
174
|
+
o.dataType = "application/json";
|
|
175
|
+
o.data = this.jsonService.stringify(o.data, this.jsonOptions);
|
|
176
|
+
o.contentType = "application/json";
|
|
177
|
+
return o;
|
|
342
178
|
}
|
|
343
179
|
sendResult(result, error) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
if (error) {
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
reject(error);
|
|
184
|
+
}, 1);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
resolve(result);
|
|
189
|
+
}, 1);
|
|
190
|
+
});
|
|
355
191
|
}
|
|
356
192
|
invoke(url, method, bag, values, methodOptions) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
p = Object.getPrototypeOf(p);
|
|
369
|
-
}
|
|
370
|
-
if (this.baseUrl === undefined) {
|
|
371
|
-
this.baseUrl = null;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (this.baseUrl) {
|
|
375
|
-
if (!/^\//.test(url)) {
|
|
376
|
-
url = `${this.baseUrl}${url}`;
|
|
377
|
-
}
|
|
193
|
+
var _a, _b, _c, _d, _e;
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
if (this.baseUrl === undefined) {
|
|
196
|
+
let p = Object.getPrototypeOf(this);
|
|
197
|
+
while (p) {
|
|
198
|
+
const t = TypeKey.get(p.constructor || p);
|
|
199
|
+
const bu = BaseService.baseUrls[t];
|
|
200
|
+
if (bu) {
|
|
201
|
+
this.baseUrl = bu;
|
|
202
|
+
break;
|
|
378
203
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
options.data = v;
|
|
453
|
-
break;
|
|
454
|
-
case "rawbody":
|
|
455
|
-
options.data = v;
|
|
456
|
-
break;
|
|
457
|
-
case "xmlbody":
|
|
458
|
-
options.contentType = "text/xml";
|
|
459
|
-
options.data = v;
|
|
460
|
-
break;
|
|
461
|
-
case "cancel":
|
|
462
|
-
options.cancel = v;
|
|
463
|
-
break;
|
|
464
|
-
case "header":
|
|
465
|
-
if (v === undefined) {
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
headers[p.key] = v;
|
|
469
|
-
break;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
options.url = url;
|
|
474
|
-
const xhr = yield this.ajax(url, options);
|
|
475
|
-
if (/json/i.test(xhr.responseType)) {
|
|
476
|
-
const text = xhr.responseText;
|
|
477
|
-
const response = this.jsonService.parse(text, jsonOptions);
|
|
478
|
-
if (xhr.status >= 400) {
|
|
479
|
-
throw new JsonError_1.default(typeof response === "string"
|
|
480
|
-
? response
|
|
481
|
-
: ((_e = (_d = (_c = (_b = (_a = response.title) !== null && _a !== void 0 ? _a : response.detail) !== null && _b !== void 0 ? _b : response.message) !== null && _c !== void 0 ? _c : response.exceptionMessage) !== null && _d !== void 0 ? _d : text) !== null && _e !== void 0 ? _e : "Json Server Error"), response);
|
|
482
|
-
}
|
|
483
|
-
if (methodOptions && methodOptions.returnHeaders) {
|
|
484
|
-
return {
|
|
485
|
-
headers: this.parseHeaders(xhr.responseHeaders),
|
|
486
|
-
value: response
|
|
487
|
-
};
|
|
204
|
+
p = Object.getPrototypeOf(p);
|
|
205
|
+
}
|
|
206
|
+
if (this.baseUrl === undefined) {
|
|
207
|
+
this.baseUrl = null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (this.baseUrl) {
|
|
211
|
+
if (!/^\//.test(url)) {
|
|
212
|
+
url = `${this.baseUrl}${url}`;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const busyIndicator = this.showProgress ? this.app.createBusyIndicator({
|
|
216
|
+
title: url,
|
|
217
|
+
description: `${method} ${url}`
|
|
218
|
+
}) : null;
|
|
219
|
+
try {
|
|
220
|
+
url = UMD.resolvePath(url);
|
|
221
|
+
let options = new AjaxOptions();
|
|
222
|
+
options.method = method;
|
|
223
|
+
if (methodOptions) {
|
|
224
|
+
options.headers = methodOptions.headers;
|
|
225
|
+
options.dataType = methodOptions.accept;
|
|
226
|
+
}
|
|
227
|
+
const methodHeaders = options.headers = options.headers || {};
|
|
228
|
+
const headers = this.headers ? Object.assign(Object.assign({}, this.headers), methodHeaders) : methodHeaders;
|
|
229
|
+
if (!headers["X-Requested-With"]) {
|
|
230
|
+
headers["X-Requested-With"] = "XMLHttpRequest";
|
|
231
|
+
}
|
|
232
|
+
options.dataType = options.dataType || "application/json";
|
|
233
|
+
const jsonOptions = Object.assign(Object.assign({}, this.jsonOptions), methodOptions ? methodOptions.jsonOptions : {});
|
|
234
|
+
if (bag) {
|
|
235
|
+
for (let i = 0; i < bag.length; i++) {
|
|
236
|
+
const p = bag[i];
|
|
237
|
+
const vi = values[i];
|
|
238
|
+
const v = vi === undefined ? p.defaultValue : vi;
|
|
239
|
+
if (v instanceof CancelToken) {
|
|
240
|
+
options.cancel = v;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
switch (p.type) {
|
|
244
|
+
case "path":
|
|
245
|
+
if (v === undefined) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const vs = v + "";
|
|
249
|
+
const replacer = `{${p.key}}`;
|
|
250
|
+
url = url.split(replacer).join(vs);
|
|
251
|
+
break;
|
|
252
|
+
case "query":
|
|
253
|
+
if (v === undefined) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (url.indexOf("?") === -1) {
|
|
257
|
+
url += "?";
|
|
258
|
+
}
|
|
259
|
+
if (!/(\&|\?)$/.test(url)) {
|
|
260
|
+
url += "&";
|
|
261
|
+
}
|
|
262
|
+
url += `${encodeURIComponent(p.key)}=${encodeURIComponent(v)}`;
|
|
263
|
+
break;
|
|
264
|
+
case "queries":
|
|
265
|
+
if (url.indexOf("?") === -1) {
|
|
266
|
+
url += "?";
|
|
267
|
+
}
|
|
268
|
+
if (!/(\&|\?)$/.test(url)) {
|
|
269
|
+
url += "&";
|
|
270
|
+
}
|
|
271
|
+
for (const key in v) {
|
|
272
|
+
if (v.hasOwnProperty(key)) {
|
|
273
|
+
const element = v[key];
|
|
274
|
+
if (element !== undefined) {
|
|
275
|
+
url += `${encodeURIComponent(key)}=${encodeURIComponent(element)}&`;
|
|
276
|
+
}
|
|
488
277
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
case "body":
|
|
281
|
+
options.data = v;
|
|
282
|
+
options = this.encodeData(options);
|
|
283
|
+
break;
|
|
284
|
+
case "bodyformmodel":
|
|
285
|
+
options.data = v;
|
|
286
|
+
break;
|
|
287
|
+
case "rawbody":
|
|
288
|
+
options.data = v;
|
|
289
|
+
break;
|
|
290
|
+
case "xmlbody":
|
|
291
|
+
options.contentType = "text/xml";
|
|
292
|
+
options.data = v;
|
|
293
|
+
break;
|
|
294
|
+
case "cancel":
|
|
295
|
+
options.cancel = v;
|
|
296
|
+
break;
|
|
297
|
+
case "header":
|
|
298
|
+
if (v === undefined) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
headers[p.key] = v;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
501
304
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
305
|
+
}
|
|
306
|
+
options.url = url;
|
|
307
|
+
const xhr = yield this.ajax(url, options);
|
|
308
|
+
if (/json/i.test(xhr.responseType)) {
|
|
309
|
+
const text = xhr.responseText;
|
|
310
|
+
const response = this.jsonService.parse(text, jsonOptions);
|
|
311
|
+
if (xhr.status >= 400) {
|
|
312
|
+
throw new JsonError(typeof response === "string" ? response : (_e = (_d = (_c = (_b = (_a = response.title) !== null && _a !== void 0 ? _a : response.detail) !== null && _b !== void 0 ? _b : response.message) !== null && _c !== void 0 ? _c : response.exceptionMessage) !== null && _d !== void 0 ? _d : text) !== null && _e !== void 0 ? _e : "Json Server Error", response);
|
|
506
313
|
}
|
|
507
|
-
|
|
314
|
+
if (methodOptions && methodOptions.returnHeaders) {
|
|
315
|
+
return {
|
|
316
|
+
headers: this.parseHeaders(xhr.responseHeaders),
|
|
317
|
+
value: response
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
return response;
|
|
321
|
+
}
|
|
322
|
+
if (xhr.status >= 400) {
|
|
323
|
+
throw new Error(xhr.responseText || "Server Error");
|
|
324
|
+
}
|
|
325
|
+
if (methodOptions && methodOptions.returnHeaders) {
|
|
326
|
+
return {
|
|
327
|
+
headers: this.parseHeaders(xhr.responseHeaders),
|
|
328
|
+
value: xhr.responseText
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return xhr.responseText;
|
|
332
|
+
} finally {
|
|
333
|
+
if (busyIndicator) {
|
|
334
|
+
busyIndicator.dispose();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
508
338
|
}
|
|
509
339
|
parseHeaders(headers) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
return pv;
|
|
519
|
-
}, {});
|
|
340
|
+
if (typeof headers === "object") {
|
|
341
|
+
return headers;
|
|
342
|
+
}
|
|
343
|
+
return (headers || "").split("\n").reduce((pv, c) => {
|
|
344
|
+
const cv = c.split(":");
|
|
345
|
+
pv[cv[0]] = (cv[1] || "").trim();
|
|
346
|
+
return pv;
|
|
347
|
+
}, {});
|
|
520
348
|
}
|
|
521
349
|
ajax(url, options) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
350
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
url = url || options.url;
|
|
352
|
+
if (options.cancel && options.cancel.cancelled) {
|
|
353
|
+
throw new Error("cancelled");
|
|
354
|
+
}
|
|
355
|
+
if (AtomBridge.instance.ajax) {
|
|
356
|
+
return yield new Promise((resolve, reject) => {
|
|
357
|
+
AtomBridge.instance.ajax(url, options, r => {
|
|
358
|
+
resolve(options);
|
|
359
|
+
}, e => {
|
|
360
|
+
reject(e);
|
|
361
|
+
}, null);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
const xhr = new XMLHttpRequest();
|
|
365
|
+
return yield new Promise((resolve, reject) => {
|
|
366
|
+
if (options.cancel && options.cancel.cancelled) {
|
|
367
|
+
reject(options.cancel.cancelled);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (options.cancel) {
|
|
371
|
+
options.cancel.registerForCancel(r => {
|
|
372
|
+
xhr.abort();
|
|
373
|
+
reject(r);
|
|
374
|
+
return;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
xhr.onreadystatechange = e => {
|
|
378
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
379
|
+
options.status = xhr.status;
|
|
380
|
+
options.responseText = xhr.responseText;
|
|
381
|
+
options.responseHeaders = xhr.getAllResponseHeaders();
|
|
382
|
+
const ct = xhr.getResponseHeader("content-type");
|
|
383
|
+
options.responseType = ct || xhr.responseType;
|
|
384
|
+
resolve(options);
|
|
529
385
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
386
|
+
};
|
|
387
|
+
xhr.open(options.method, url, true);
|
|
388
|
+
if (options.dataType) {
|
|
389
|
+
xhr.setRequestHeader("accept", options.dataType);
|
|
390
|
+
}
|
|
391
|
+
if (options.contentType) {
|
|
392
|
+
xhr.setRequestHeader("content-type", options.contentType);
|
|
393
|
+
}
|
|
394
|
+
const h = options.headers;
|
|
395
|
+
if (h) {
|
|
396
|
+
for (const key in h) {
|
|
397
|
+
if (h.hasOwnProperty(key)) {
|
|
398
|
+
const element = h[key];
|
|
399
|
+
xhr.setRequestHeader(key, element.toString());
|
|
400
|
+
}
|
|
538
401
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
xhr.onreadystatechange = (e) => {
|
|
553
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
554
|
-
options.status = xhr.status;
|
|
555
|
-
options.responseText = xhr.responseText;
|
|
556
|
-
// options.responseHeaders = (xhr.getAllResponseHeaders())
|
|
557
|
-
// .split("\n")
|
|
558
|
-
// .map((s) => s.trim().split(":"))
|
|
559
|
-
// .reduce((pv, cv) => pv[cv[0]] = cv[1], {});
|
|
560
|
-
options.responseHeaders = xhr.getAllResponseHeaders();
|
|
561
|
-
const ct = xhr.getResponseHeader("content-type");
|
|
562
|
-
options.responseType = ct || xhr.responseType;
|
|
563
|
-
resolve(options);
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
xhr.open(options.method, url, true);
|
|
567
|
-
if (options.dataType) {
|
|
568
|
-
xhr.setRequestHeader("accept", options.dataType);
|
|
569
|
-
}
|
|
570
|
-
if (options.contentType) {
|
|
571
|
-
xhr.setRequestHeader("content-type", options.contentType);
|
|
572
|
-
}
|
|
573
|
-
const h = options.headers;
|
|
574
|
-
if (h) {
|
|
575
|
-
for (const key in h) {
|
|
576
|
-
if (h.hasOwnProperty(key)) {
|
|
577
|
-
const element = h[key];
|
|
578
|
-
xhr.setRequestHeader(key, element.toString());
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
try {
|
|
583
|
-
xhr.send(options.data);
|
|
584
|
-
}
|
|
585
|
-
catch (e) {
|
|
586
|
-
options.status = xhr.status;
|
|
587
|
-
options.responseText = xhr.responseText;
|
|
588
|
-
// options.responseHeaders = (xhr.getAllResponseHeaders())
|
|
589
|
-
// .split("\n")
|
|
590
|
-
// .map((s) => s.trim().split(":"))
|
|
591
|
-
// .reduce((pv, cv) => pv[cv[0]] = cv[1], {});
|
|
592
|
-
options.responseHeaders = xhr.getAllResponseHeaders();
|
|
593
|
-
const ct = xhr.getResponseHeader("content-type");
|
|
594
|
-
options.responseType = ct || xhr.responseType;
|
|
595
|
-
resolve(options);
|
|
596
|
-
}
|
|
597
|
-
});
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
xhr.send(options.data);
|
|
405
|
+
} catch (e) {
|
|
406
|
+
options.status = xhr.status;
|
|
407
|
+
options.responseText = xhr.responseText;
|
|
408
|
+
options.responseHeaders = xhr.getAllResponseHeaders();
|
|
409
|
+
const ct = xhr.getResponseHeader("content-type");
|
|
410
|
+
options.responseType = ct || xhr.responseType;
|
|
411
|
+
resolve(options);
|
|
412
|
+
}
|
|
598
413
|
});
|
|
414
|
+
});
|
|
599
415
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
], BaseService);
|
|
608
|
-
exports.BaseService = BaseService;
|
|
609
|
-
});
|
|
610
|
-
//# sourceMappingURL=RestService.js.map
|
|
416
|
+
});
|
|
417
|
+
BaseService.baseUrls = {};
|
|
418
|
+
_export("BaseService", BaseService = __decorate([__param(0, Inject), __param(1, Inject), __metadata("design:paramtypes", [App, JsonService])], BaseService));
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
});
|
|
422
|
+
//# sourceMappingURL=/home/runner/work/core/core/dist/services/http/RestService.js.map
|