@colijnit/ioneconnector 2.0.3 → 2.0.6
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/build/connector.js +25 -57
- package/build/connector.unit.test.js +36 -67
- package/build/enum/backend-service-name.enum.js +4 -2
- package/build/enum/datasession-service-method.enum.js +4 -2
- package/build/enum/db-boolean-value-type.enum.js +15 -12
- package/build/enum/end-point.enum.js +4 -2
- package/build/enum/login-service-method.enum.js +4 -2
- package/build/enum/one-zero-bool-db-type.enum.js +6 -3
- package/build/enum/public-service-method.enum.js +4 -2
- package/build/enum/true-false-db-type.enum.js +6 -3
- package/build/enum/yes-no-db-type.enum.js +6 -3
- package/build/factory/decorators/boolean.decorator.js +34 -34
- package/build/factory/decorators/complex-array.decorator.js +18 -18
- package/build/factory/decorators/complex-field.decorator.js +18 -18
- package/build/factory/decorators/date-field.decorator.js +14 -14
- package/build/factory/decorators/db-field-alias.decorator.js +15 -15
- package/build/factory/decorators/json.decorator.js +12 -12
- package/build/factory/decorators/map-property.decorator.js +13 -13
- package/build/factory/decorators/no-db-field.decorator.js +13 -13
- package/build/factory/decorators/string-number.decorator.js +16 -16
- package/build/model/business-object.js +38 -39
- package/build/model/constant/java-constants.js +4 -2
- package/build/model/data-service-data.js +5 -6
- package/build/model/data-service-response-data.interface.js +2 -0
- package/build/model/data-service-response-data.js +31 -42
- package/build/model/data-service-response-exception.js +2 -0
- package/build/model/data-service-response-root.js +2 -0
- package/build/model/field-validation.interface.js +2 -0
- package/build/model/field-validation.js +14 -13
- package/build/model/field-validations-object.interface.js +2 -0
- package/build/model/field-validations-object.js +2 -0
- package/build/model/login-response.interface.js +2 -0
- package/build/model/login-response.js +6 -22
- package/build/model/login.js +20 -31
- package/build/model/options.js +6 -5
- package/build/model/paging-parameters.interface.js +5 -6
- package/build/model/paging-parameters.js +20 -23
- package/build/model/server-response-data.js +2 -0
- package/build/model/server-stack-trace-element.js +2 -0
- package/build/model/session.js +6 -5
- package/build/model/validation-message.interface.js +2 -0
- package/build/model/validation-message.js +22 -21
- package/build/model/validation-result.interface.js +2 -0
- package/build/model/validation-result.js +15 -15
- package/build/provider/ajax.service.js +70 -136
- package/build/provider/base-backend-connection.service.js +38 -73
- package/build/service/business-object-factory.js +47 -46
- package/build/service/datasession.service.js +18 -49
- package/build/service/encrypt.service.js +27 -18
- package/build/service/encrypt.service.unit.test.js +8 -6
- package/build/service/login.service.js +69 -110
- package/build/service/public.service.js +16 -16
- package/build/tests/int/connector.int.test.js +6 -4
- package/build/type/business-object-id-type.js +8 -6
- package/build/type/object-configuration-default-value-type.js +2 -0
- package/build/utils/array-utils.js +16 -17
- package/build/utils/business-object-utils.js +12 -13
- package/build/utils/date-utils.js +9 -10
- package/build/utils/function/is-nill.function.js +4 -1
- package/build/utils/function/not-nill.function.js +4 -1
- package/build/utils/image-utils.js +10 -11
- package/build/utils/number-utils.js +25 -28
- package/build/utils/object-utils.js +45 -51
- package/build/utils/parameter-value-conversion-utils.js +9 -10
- package/build/utils/promise-utils.js +14 -50
- package/build/utils/ref-code-utils.js +12 -17
- package/build/utils/string-utils.js +17 -19
- package/build/utils/url-utils.js +11 -12
- package/package.json +5 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,50 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { LoginServiceMethod } from "../enum/login-service-method.enum";
|
|
38
|
-
import { BackendServiceName } from "../enum/backend-service-name.enum";
|
|
39
|
-
import { Login } from "../model/login";
|
|
40
|
-
import { EncryptService } from "./encrypt.service";
|
|
41
|
-
import { DatasessionService } from "./datasession.service";
|
|
42
|
-
import { PublicService } from "./public.service";
|
|
43
|
-
import { BusinessObjectFactory } from "./business-object-factory";
|
|
44
|
-
import { LoginResponse } from "../model/login-response";
|
|
45
|
-
var LoginService = (function () {
|
|
46
|
-
function LoginService(backendConnection) {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const login_service_method_enum_1 = require("../enum/login-service-method.enum");
|
|
13
|
+
const backend_service_name_enum_1 = require("../enum/backend-service-name.enum");
|
|
14
|
+
const login_1 = require("../model/login");
|
|
15
|
+
const encrypt_service_1 = require("./encrypt.service");
|
|
16
|
+
const datasession_service_1 = require("./datasession.service");
|
|
17
|
+
const public_service_1 = require("./public.service");
|
|
18
|
+
const business_object_factory_1 = require("./business-object-factory");
|
|
19
|
+
const login_response_1 = require("../model/login-response");
|
|
20
|
+
class LoginService {
|
|
21
|
+
constructor(backendConnection) {
|
|
47
22
|
this.initialized = false;
|
|
48
23
|
this.loggingOut = false;
|
|
49
24
|
this.windowsSessionId = 1;
|
|
50
25
|
this._useEncryption = false;
|
|
51
|
-
this._boFactory = new BusinessObjectFactory();
|
|
26
|
+
this._boFactory = new business_object_factory_1.BusinessObjectFactory();
|
|
52
27
|
this.backendConnection = backendConnection;
|
|
53
|
-
this.loginModel = new Login();
|
|
28
|
+
this.loginModel = new login_1.Login();
|
|
54
29
|
if (this.backendConnection.options.schema === "") {
|
|
55
30
|
console.error("Schema is not provided");
|
|
56
31
|
}
|
|
@@ -65,109 +40,93 @@ var LoginService = (function () {
|
|
|
65
40
|
this.loginModel.clientVersion = this.backendConnection.options.version;
|
|
66
41
|
this.loginModel.clientLanguage = this.backendConnection.options.languageCode;
|
|
67
42
|
this._useEncryption = this.backendConnection.options.useLoginEncryption;
|
|
68
|
-
this._encryptionService = new EncryptService();
|
|
69
|
-
this._publicService = new PublicService(this.backendConnection, this._encryptionService);
|
|
70
|
-
this._datasessionService = new DatasessionService(this.backendConnection);
|
|
43
|
+
this._encryptionService = new encrypt_service_1.EncryptService();
|
|
44
|
+
this._publicService = new public_service_1.PublicService(this.backendConnection, this._encryptionService);
|
|
45
|
+
this._datasessionService = new datasession_service_1.DatasessionService(this.backendConnection);
|
|
71
46
|
}
|
|
72
|
-
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return [2];
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
this.logout();
|
|
91
|
-
throw new Error("Openening data session failed for session '"
|
|
92
|
-
+ "'. Logging out user.");
|
|
93
|
-
}
|
|
94
|
-
return [2];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
47
|
+
loginAndCreateDataSession() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
yield this._login();
|
|
50
|
+
const id = this.backendConnection.session.dataSessionId;
|
|
51
|
+
const datasessionCreated = yield this._datasessionService.createDataSession(id);
|
|
52
|
+
if (datasessionCreated === true) {
|
|
53
|
+
this.backendConnection.session.created = true;
|
|
54
|
+
this._startHeartBeat();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.logout();
|
|
59
|
+
throw new Error("Openening data session failed for session '"
|
|
60
|
+
+ "'. Logging out user.");
|
|
61
|
+
}
|
|
97
62
|
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var _this = this;
|
|
63
|
+
}
|
|
64
|
+
logout() {
|
|
101
65
|
this.loggingOut = true;
|
|
102
|
-
return this._call(LoginServiceMethod.LogoutUser, {}, false).then(
|
|
103
|
-
|
|
104
|
-
|
|
66
|
+
return this._call(login_service_method_enum_1.LoginServiceMethod.LogoutUser, {}, false).then((userData) => {
|
|
67
|
+
this.loggingOut = false;
|
|
68
|
+
this._stopHeartBeat();
|
|
105
69
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.
|
|
112
|
-
var loginResponse = _this._boFactory.makeWithRawBackendData(LoginResponse, result);
|
|
70
|
+
}
|
|
71
|
+
_login() {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
this._callLogin()
|
|
74
|
+
.then((result) => {
|
|
75
|
+
const loginResponse = this._boFactory.makeWithRawBackendData(login_response_1.LoginResponse, result);
|
|
113
76
|
if (loginResponse.loginStatus === "SUCCESS") {
|
|
114
|
-
|
|
77
|
+
this.loginModel.loggedIn = true;
|
|
115
78
|
resolve(loginResponse);
|
|
116
79
|
}
|
|
117
80
|
else {
|
|
118
81
|
reject(loginResponse);
|
|
119
82
|
}
|
|
120
83
|
})
|
|
121
|
-
.catch(
|
|
84
|
+
.catch((e) => {
|
|
122
85
|
return reject(e);
|
|
123
86
|
});
|
|
124
87
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var _this = this;
|
|
88
|
+
}
|
|
89
|
+
_startHeartBeat() {
|
|
128
90
|
if (!this.heartbeatTimer) {
|
|
129
|
-
this.heartbeatTimer = setInterval(
|
|
130
|
-
|
|
91
|
+
this.heartbeatTimer = setInterval(() => {
|
|
92
|
+
this._call(login_service_method_enum_1.LoginServiceMethod.GetHeartBeat, {}, false);
|
|
131
93
|
}, LoginService.HEARTBEAT_INTERVAL_MS);
|
|
132
94
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
95
|
+
}
|
|
96
|
+
_stopHeartBeat() {
|
|
135
97
|
if (this.heartbeatTimer) {
|
|
136
98
|
clearInterval(this.heartbeatTimer);
|
|
137
99
|
this.heartbeatTimer = null;
|
|
138
100
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
_this.loginModel.passWord = _this.loginModel.passWordClean;
|
|
101
|
+
}
|
|
102
|
+
_checkEncryption() {
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
if (!this._useEncryption) {
|
|
105
|
+
this.loginModel.passWord = this.loginModel.passWordClean;
|
|
145
106
|
resolve();
|
|
146
107
|
}
|
|
147
108
|
else {
|
|
148
|
-
|
|
149
|
-
|
|
109
|
+
this._publicService.getPublicKey().then(() => {
|
|
110
|
+
this.loginModel.passWord = this._encryptionService.encRsa(this.loginModel.passWordClean);
|
|
150
111
|
resolve();
|
|
151
112
|
});
|
|
152
113
|
}
|
|
153
114
|
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return _this._call(LoginServiceMethod.Login, _this.loginModel.getSerialized(), true);
|
|
115
|
+
}
|
|
116
|
+
_callLogin() {
|
|
117
|
+
return this._checkEncryption().then(() => {
|
|
118
|
+
return this._call(login_service_method_enum_1.LoginServiceMethod.Login, this.loginModel.getSerialized(), true);
|
|
159
119
|
});
|
|
160
|
-
}
|
|
161
|
-
|
|
120
|
+
}
|
|
121
|
+
_call(method, data, showLoader) {
|
|
162
122
|
if (data === undefined) {
|
|
163
123
|
data = {};
|
|
164
124
|
}
|
|
165
125
|
if (showLoader === undefined) {
|
|
166
126
|
showLoader = true;
|
|
167
127
|
}
|
|
168
|
-
return this.backendConnection.call(method, data, showLoader, BackendServiceName.LoginService);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
export { LoginService };
|
|
128
|
+
return this.backendConnection.call(method, data, showLoader, backend_service_name_enum_1.BackendServiceName.LoginService);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.LoginService = LoginService;
|
|
132
|
+
LoginService.HEARTBEAT_INTERVAL_MS = 59000;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const backend_service_name_enum_1 = require("../enum/backend-service-name.enum");
|
|
4
|
+
const public_service_method_enum_1 = require("../enum/public-service-method.enum");
|
|
5
|
+
class PublicService {
|
|
6
|
+
constructor(backendConnection, encryptionService) {
|
|
5
7
|
this.backendConnection = backendConnection;
|
|
6
8
|
this._encryptionService = encryptionService;
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_this._encryptionService.publicKey = result;
|
|
10
|
+
getPublicKey() {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
this._call(public_service_method_enum_1.PublicServiceMethod.GetPublicKey, {}, false).then((result) => {
|
|
13
|
+
this._encryptionService.publicKey = result;
|
|
13
14
|
resolve();
|
|
14
15
|
});
|
|
15
16
|
});
|
|
16
|
-
}
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
_call(method, data, showLoader) {
|
|
18
19
|
if (data === undefined) {
|
|
19
20
|
data = {};
|
|
20
21
|
}
|
|
21
22
|
if (showLoader === undefined) {
|
|
22
23
|
showLoader = true;
|
|
23
24
|
}
|
|
24
|
-
return this.backendConnection.call(method, data, showLoader, BackendServiceName.PublicService);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export { PublicService };
|
|
25
|
+
return this.backendConnection.call(method, data, showLoader, backend_service_name_enum_1.BackendServiceName.PublicService);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.PublicService = PublicService;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const connector_1 = require("../../connector");
|
|
4
|
+
const options = {
|
|
3
5
|
url: 'http://localhost:8080/ione',
|
|
4
6
|
ajaxUrl: 'http://localhost:8080/ione',
|
|
5
7
|
schema: '1',
|
|
6
8
|
version: "250",
|
|
7
9
|
useLoginEncryption: true
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
describe("Connector",
|
|
11
|
+
const connector = new connector_1.Connector(options);
|
|
12
|
+
describe("Connector", () => {
|
|
11
13
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const number_utils_1 = require("../utils/number-utils");
|
|
4
|
+
const string_utils_1 = require("../utils/string-utils");
|
|
5
|
+
const object_utils_1 = require("../utils/object-utils");
|
|
6
|
+
var BusinessObjectIDType;
|
|
5
7
|
(function (BusinessObjectIDType) {
|
|
6
8
|
function IsBoIDTypeVal(val) {
|
|
7
|
-
return NumberUtils.IsNumber(val) || StringUtils.IsString(val) || ObjectUtils.IsPlainObject(val);
|
|
9
|
+
return number_utils_1.NumberUtils.IsNumber(val) || string_utils_1.StringUtils.IsString(val) || object_utils_1.ObjectUtils.IsPlainObject(val);
|
|
8
10
|
}
|
|
9
11
|
BusinessObjectIDType.IsBoIDTypeVal = IsBoIDTypeVal;
|
|
10
|
-
})(BusinessObjectIDType || (BusinessObjectIDType = {}));
|
|
12
|
+
})(BusinessObjectIDType = exports.BusinessObjectIDType || (exports.BusinessObjectIDType = {}));
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const not_nill_function_1 = require("./function/not-nill.function");
|
|
4
|
+
class ArrayUtils {
|
|
5
|
+
static ContainsAnElementFoundBy(array, finder) {
|
|
6
6
|
if (!array || !finder) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
|
-
return notNill(this.Find(array, finder));
|
|
10
|
-
}
|
|
11
|
-
|
|
9
|
+
return not_nill_function_1.notNill(this.Find(array, finder));
|
|
10
|
+
}
|
|
11
|
+
static Find(array, foundBy) {
|
|
12
12
|
if (!array || !foundBy) {
|
|
13
13
|
return undefined;
|
|
14
14
|
}
|
|
15
|
-
for (
|
|
16
|
-
|
|
15
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
16
|
+
const itemCur = array[i];
|
|
17
17
|
if (foundBy(itemCur)) {
|
|
18
18
|
return itemCur;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
return undefined;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
}
|
|
23
|
+
static CloneArray(array) {
|
|
24
|
+
let answer = [];
|
|
25
25
|
if (array) {
|
|
26
26
|
answer = array.slice(0);
|
|
27
27
|
}
|
|
28
28
|
return answer;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export { ArrayUtils };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ArrayUtils = ArrayUtils;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (notNill(idA) && notNill(idB)) {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const not_nill_function_1 = require("./function/not-nill.function");
|
|
4
|
+
const object_utils_1 = require("./object-utils");
|
|
5
|
+
class BusinessObjectUtils {
|
|
6
|
+
static IsEqualBoId(idA, idB) {
|
|
7
|
+
let isEqualId = false;
|
|
8
|
+
if (not_nill_function_1.notNill(idA) && not_nill_function_1.notNill(idB)) {
|
|
9
9
|
if (idA === idB) {
|
|
10
10
|
isEqualId = true;
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
isEqualId = ObjectUtils.DeepEquals(idA, idB);
|
|
13
|
+
isEqualId = object_utils_1.ObjectUtils.DeepEquals(idA, idB);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
return isEqualId;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export { BusinessObjectUtils };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BusinessObjectUtils = BusinessObjectUtils;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (notNill(str)) {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const not_nill_function_1 = require("./function/not-nill.function");
|
|
4
|
+
class DateUtils {
|
|
5
|
+
static StringAsDate(str) {
|
|
6
|
+
if (not_nill_function_1.notNill(str)) {
|
|
7
7
|
return new Date(str);
|
|
8
8
|
}
|
|
9
9
|
else {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export { DateUtils };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DateUtils = DateUtils;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ImageUtils {
|
|
4
|
+
static getDocBodyWithMimeTypeDefinition(fileName, documentBody) {
|
|
5
5
|
if (documentBody === null) {
|
|
6
6
|
return documentBody;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1);
|
|
9
9
|
switch (fileExtension.toLowerCase()) {
|
|
10
10
|
case "jpg":
|
|
11
11
|
case "jpeg":
|
|
@@ -19,10 +19,9 @@ var ImageUtils = (function () {
|
|
|
19
19
|
default:
|
|
20
20
|
return "data:image/png;base64," + documentBody;
|
|
21
21
|
}
|
|
22
|
-
}
|
|
23
|
-
|
|
22
|
+
}
|
|
23
|
+
static getFixedImageFilepathUrl(imageFilepathUrl) {
|
|
24
24
|
return imageFilepathUrl.replace("/content/", "/content43/");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export { ImageUtils };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ImageUtils = ImageUtils;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const object_utils_1 = require("./object-utils");
|
|
4
|
+
class NumberUtils {
|
|
5
|
+
static ParseFloatKeepPrecision(arg) {
|
|
6
|
+
const decimalPrecision = this.GetDecimalPlaces(arg);
|
|
7
7
|
return this.ParseFloat(arg, decimalPrecision);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var match = ('' + arg).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
|
|
8
|
+
}
|
|
9
|
+
static GetDecimalPlaces(arg, maxAnswer = 1000) {
|
|
10
|
+
const match = ('' + arg).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
|
|
12
11
|
if (!match) {
|
|
13
12
|
return 0;
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
let answer = Math.max(0, (match[1] ? match[1].length : 0)
|
|
16
15
|
- (match[2] ? +match[2] : 0));
|
|
17
16
|
if (answer > maxAnswer) {
|
|
18
17
|
answer = maxAnswer;
|
|
19
18
|
}
|
|
20
19
|
return answer;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (decimalPrecision
|
|
24
|
-
if (!ObjectUtils.AllExist(arg, decimalPrecision) || Array.isArray(arg)) {
|
|
20
|
+
}
|
|
21
|
+
static ParseFloat(arg, decimalPrecision = 2) {
|
|
22
|
+
if (!object_utils_1.ObjectUtils.AllExist(arg, decimalPrecision) || Array.isArray(arg)) {
|
|
25
23
|
return NaN;
|
|
26
24
|
}
|
|
27
25
|
if (!this.IsInteger(decimalPrecision) || decimalPrecision < 0) {
|
|
@@ -31,15 +29,15 @@ var NumberUtils = (function () {
|
|
|
31
29
|
decimalPrecision = 20;
|
|
32
30
|
}
|
|
33
31
|
return parseFloat(parseFloat(arg).toFixed(decimalPrecision));
|
|
34
|
-
}
|
|
35
|
-
|
|
32
|
+
}
|
|
33
|
+
static IsInteger(arg) {
|
|
36
34
|
if (isNaN(arg) || Array.isArray(arg)) {
|
|
37
35
|
return false;
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
const argAsFloat = parseFloat(arg);
|
|
40
38
|
return ((argAsFloat | 0) === argAsFloat);
|
|
41
|
-
}
|
|
42
|
-
|
|
39
|
+
}
|
|
40
|
+
static NumIsComposedOfOtherPowTwoNum(bigNrToCheck, powTwoNumItShouldBeComposedOf) {
|
|
43
41
|
if (!bigNrToCheck) {
|
|
44
42
|
return false;
|
|
45
43
|
}
|
|
@@ -49,13 +47,12 @@ var NumberUtils = (function () {
|
|
|
49
47
|
else {
|
|
50
48
|
return ((bigNrToCheck & powTwoNumItShouldBeComposedOf) === powTwoNumItShouldBeComposedOf);
|
|
51
49
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
50
|
+
}
|
|
51
|
+
static IsNumber(arg) {
|
|
54
52
|
return typeof arg === 'number';
|
|
55
|
-
}
|
|
56
|
-
|
|
53
|
+
}
|
|
54
|
+
static IsNaN(arg) {
|
|
57
55
|
return isNaN(arg) || !this.IsNumber(arg);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export { NumberUtils };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.NumberUtils = NumberUtils;
|