@eway-crm/connector 1.0.121 → 1.0.122
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/lib/AnonymousSessionHandler.js +5 -10
- package/lib/ApiConnection.js +115 -129
- package/lib/ApiMethods.js +35 -40
- package/lib/CredentialsSessionHandler.js +22 -28
- package/lib/HttpMethod.js +2 -5
- package/lib/ISessionHandler.js +1 -2
- package/lib/OAuthSessionHandler.js +16 -39
- package/lib/OAuthSessionHandlerBase.js +30 -36
- package/lib/ReturnCodes.js +10 -15
- package/lib/axios/AxiosInstance.js +3 -5
- package/lib/constants/ActionEventTypes.js +9 -14
- package/lib/constants/ColumnPermissionRules.js +15 -22
- package/lib/constants/CompletionLevels.js +6 -11
- package/lib/constants/CustomizationStatsItemKeys.js +12 -17
- package/lib/constants/Edition.js +2 -5
- package/lib/constants/EnumTypes.js +33 -38
- package/lib/constants/ExpirationReason.js +1 -3
- package/lib/constants/Feature.js +2 -5
- package/lib/constants/FieldNames.js +421 -426
- package/lib/constants/FieldTypes.js +15 -20
- package/lib/constants/FolderNames.js +82 -87
- package/lib/constants/Functionality.js +55 -60
- package/lib/constants/GlobalSettingsNames.js +71 -76
- package/lib/constants/LicenseKeyInvoiceSeverity.js +1 -3
- package/lib/constants/LicenseRestrictionKeys.js +63 -68
- package/lib/constants/RelationTypes.js +11 -16
- package/lib/data/EWItem.js +29 -34
- package/lib/data/IApiAdditionalField.js +1 -2
- package/lib/data/IApiAvailableBundle.js +1 -2
- package/lib/data/IApiAvailableVersionResponse.js +1 -2
- package/lib/data/IApiBooleanResponse.js +1 -2
- package/lib/data/IApiCapacityAvailableBundle.js +1 -2
- package/lib/data/IApiCart.js +1 -2
- package/lib/data/IApiColumn.js +1 -2
- package/lib/data/IApiColumnPermission.js +1 -2
- package/lib/data/IApiCompany.js +1 -2
- package/lib/data/IApiContact.js +1 -2
- package/lib/data/IApiCurrencyExchangeRate.js +1 -2
- package/lib/data/IApiCustomizationStatsItem.js +1 -2
- package/lib/data/IApiDataResponse.js +1 -2
- package/lib/data/IApiDatumResponse.js +1 -2
- package/lib/data/IApiDocument.js +1 -2
- package/lib/data/IApiEmail.js +1 -2
- package/lib/data/IApiEnumType.js +2 -5
- package/lib/data/IApiEnumValue.js +1 -2
- package/lib/data/IApiEnumValuesRelation.js +1 -2
- package/lib/data/IApiFeature.js +1 -2
- package/lib/data/IApiFeaturesLicenseBundle.js +1 -2
- package/lib/data/IApiFlow.js +1 -2
- package/lib/data/IApiGlobalSetting.js +1 -2
- package/lib/data/IApiGoal.js +1 -2
- package/lib/data/IApiGood.js +1 -2
- package/lib/data/IApiGoodInCart.js +1 -2
- package/lib/data/IApiGroup.js +1 -2
- package/lib/data/IApiItemBase.js +1 -2
- package/lib/data/IApiItemIdentifier.js +1 -2
- package/lib/data/IApiItemUsageStatus.js +1 -2
- package/lib/data/IApiJournal.js +1 -2
- package/lib/data/IApiLead.js +1 -2
- package/lib/data/IApiLicense.js +1 -2
- package/lib/data/IApiLicenseBundleBase.js +1 -2
- package/lib/data/IApiLocalizedLicenseBundle.js +1 -2
- package/lib/data/IApiLoginResponse.js +1 -2
- package/lib/data/IApiMarketingCampaign.js +1 -2
- package/lib/data/IApiMarketingList.js +1 -2
- package/lib/data/IApiModulePermission.js +1 -2
- package/lib/data/IApiObjectType.js +1 -2
- package/lib/data/IApiPasswordStrength.js +1 -2
- package/lib/data/IApiPayment.js +1 -2
- package/lib/data/IApiProject.js +1 -2
- package/lib/data/IApiRecurrencePattern.js +1 -2
- package/lib/data/IApiResult.js +1 -2
- package/lib/data/IApiSaveResponse.js +1 -2
- package/lib/data/IApiTask.js +1 -2
- package/lib/data/IApiUser.js +1 -2
- package/lib/data/IApiUserSetting.js +1 -2
- package/lib/data/IApiWebServiceTaskStatus.js +1 -2
- package/lib/data/IApiWorkReport.js +1 -2
- package/lib/data/IApiWorkflowActionDerivedItem.js +1 -2
- package/lib/data/IApiWorkflowModel.js +1 -2
- package/lib/data/query/IApiQuery.js +1 -2
- package/lib/data/query/IApiQueryFilters.js +1 -2
- package/lib/data/workflowActions/IApiAction.js +1 -2
- package/lib/exceptions/HttpRequestError.js +6 -28
- package/lib/exceptions/WebServiceError.js +6 -28
- package/lib/helpers/ErrorHelper.js +15 -20
- package/lib/helpers/OAuthHelper.js +49 -54
- package/lib/helpers/VersionHelperBase.js +15 -20
- package/lib/index.js +83 -123
- package/lib/interfaces/IEWJwtPayload.js +1 -2
- package/lib/interfaces/IItemPreview.js +1 -2
- package/lib/interfaces/ITokenData.js +1 -2
- package/lib/interfaces/ITranslatableString.js +1 -2
- package/lib/interfaces/TNumericValidatorType.js +1 -2
- package/lib/tokenizedServices/CommonDataConnection.js +11 -17
- package/lib/tokenizedServices/ITokenizedApiResult.js +1 -2
- package/lib/tokenizedServices/TokenizedServiceConnection.js +53 -59
- package/package.json +1 -1
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var TokenizedServiceConnection_1 = require("./TokenizedServiceConnection");
|
|
5
|
-
var HttpMethod_1 = require("../HttpMethod");
|
|
6
|
-
var obtainer = function (result) {
|
|
1
|
+
import { TokenizedServiceConnection } from './TokenizedServiceConnection';
|
|
2
|
+
import { HttpMethod } from '../HttpMethod';
|
|
3
|
+
const obtainer = (result) => {
|
|
7
4
|
return { url: result.ServiceUrl, token: result.Token };
|
|
8
5
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_this.tokenizedConnection.isEnabled(enabledCallback, disabledCallback);
|
|
6
|
+
export class CommonDataConnection {
|
|
7
|
+
constructor(connection, errorCallback) {
|
|
8
|
+
this.isCommonDataApiEnabled = (enabledCallback, disabledCallback) => {
|
|
9
|
+
this.tokenizedConnection.isEnabled(enabledCallback, disabledCallback);
|
|
14
10
|
};
|
|
15
|
-
this.callCommonDataApi =
|
|
16
|
-
|
|
11
|
+
this.callCommonDataApi = (methodName, data, successCallback, unsuccessCallback) => {
|
|
12
|
+
this.tokenizedConnection.callTokenizedApi(methodName, data, successCallback, unsuccessCallback);
|
|
17
13
|
};
|
|
18
|
-
this.tokenizedConnection = new
|
|
14
|
+
this.tokenizedConnection = new TokenizedServiceConnection('ObtainCommonDataApiAccessToken', HttpMethod.get, false, 'InvalidCommonDataToken', obtainer, connection, errorCallback);
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
}());
|
|
22
|
-
exports.CommonDataConnection = CommonDataConnection;
|
|
16
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _this = this;
|
|
9
|
-
this.isEnabled = function (enabledCallback, disabledCallback) {
|
|
10
|
-
var check = function () {
|
|
11
|
-
if (!_this.url || !_this.token) {
|
|
1
|
+
import { HttpRequestError } from '..';
|
|
2
|
+
import axiosInstance from '../axios/AxiosInstance';
|
|
3
|
+
export class TokenizedServiceConnection {
|
|
4
|
+
constructor(obtainTokenMethodName, obtainTokenMethodType, needsSession, invalidTokenReturnCode, urlAndTokenObtainer, connection, errorCallback) {
|
|
5
|
+
this.isEnabled = (enabledCallback, disabledCallback) => {
|
|
6
|
+
const check = () => {
|
|
7
|
+
if (!this.url || !this.token) {
|
|
12
8
|
disabledCallback();
|
|
13
9
|
}
|
|
14
10
|
else {
|
|
15
|
-
enabledCallback(
|
|
11
|
+
enabledCallback(this.url, this.token);
|
|
16
12
|
}
|
|
17
13
|
};
|
|
18
|
-
if (!
|
|
19
|
-
|
|
14
|
+
if (!this.url || !this.token) {
|
|
15
|
+
this.obtainToken(check);
|
|
20
16
|
return;
|
|
21
17
|
}
|
|
22
18
|
else {
|
|
23
|
-
enabledCallback(
|
|
19
|
+
enabledCallback(this.url, this.token);
|
|
24
20
|
}
|
|
25
21
|
};
|
|
26
|
-
this.callTokenizedApi =
|
|
27
|
-
|
|
22
|
+
this.callTokenizedApi = (methodName, data, successCallback, unsuccessCallback) => {
|
|
23
|
+
this.isEnabled((url, token) => {
|
|
28
24
|
data.token = token;
|
|
29
|
-
TokenizedServiceConnection.call(url, methodName, data, successCallback,
|
|
30
|
-
if (result.ReturnCodeString ===
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
TokenizedServiceConnection.call(url, methodName, data, successCallback, (result) => {
|
|
26
|
+
if (result.ReturnCodeString === this.invalidTokenReturnCode) {
|
|
27
|
+
this.obtainToken(() => {
|
|
28
|
+
this.callTokenizedApi(methodName, data, successCallback, unsuccessCallback);
|
|
33
29
|
});
|
|
34
30
|
return;
|
|
35
31
|
}
|
|
@@ -37,56 +33,56 @@ var TokenizedServiceConnection = /** @class */ (function () {
|
|
|
37
33
|
unsuccessCallback(result);
|
|
38
34
|
}
|
|
39
35
|
else {
|
|
40
|
-
if (!!
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
if (!!this.generalErrorCallback) {
|
|
37
|
+
const error = new Error('Unhandled tokenized service connection return code ' + result.ReturnCodeString + '.\nDescription: ' + result.Description);
|
|
38
|
+
this.generalErrorCallback(error);
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
},
|
|
46
|
-
if (!!
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
}, (error) => {
|
|
42
|
+
if (!!this.generalErrorCallback) {
|
|
43
|
+
const err = new Error('Unhandled tokenized service connection communication error: ' + JSON.stringify(error));
|
|
44
|
+
this.generalErrorCallback(err);
|
|
49
45
|
}
|
|
50
46
|
});
|
|
51
|
-
},
|
|
47
|
+
}, () => {
|
|
52
48
|
if (unsuccessCallback) {
|
|
53
49
|
unsuccessCallback(null);
|
|
54
50
|
}
|
|
55
51
|
});
|
|
56
52
|
};
|
|
57
|
-
this.obtainToken =
|
|
58
|
-
if (!
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
this.obtainToken = (callback) => {
|
|
54
|
+
if (!this.isActive) {
|
|
55
|
+
this.url = null;
|
|
56
|
+
this.token = null;
|
|
61
57
|
callback();
|
|
62
58
|
return;
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const successClb = (result) => {
|
|
61
|
+
const obtainedResult = this.urlAndTokenObtainer(result);
|
|
66
62
|
if (!obtainedResult.url || !obtainedResult.token) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
this.url = null;
|
|
64
|
+
this.token = null;
|
|
65
|
+
this.isActive = false;
|
|
70
66
|
callback();
|
|
71
67
|
}
|
|
72
68
|
else {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
this.url = obtainedResult.url;
|
|
70
|
+
this.token = obtainedResult.token;
|
|
71
|
+
this.isActive = true;
|
|
76
72
|
callback();
|
|
77
73
|
}
|
|
78
74
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
const unsuccessClb = () => {
|
|
76
|
+
this.url = null;
|
|
77
|
+
this.token = null;
|
|
78
|
+
this.isActive = false;
|
|
83
79
|
callback();
|
|
84
80
|
};
|
|
85
|
-
if (
|
|
86
|
-
|
|
81
|
+
if (this.needsSession) {
|
|
82
|
+
this.connection.callMethod(this.obtainTokenMethodName, {}, successClb, unsuccessClb, this.obtainTokenMethodType);
|
|
87
83
|
}
|
|
88
84
|
else {
|
|
89
|
-
|
|
85
|
+
this.connection.callWithoutSession(this.obtainTokenMethodName, null, successClb, unsuccessClb, null, this.obtainTokenMethodType);
|
|
90
86
|
}
|
|
91
87
|
};
|
|
92
88
|
this.obtainTokenMethodName = obtainTokenMethodName;
|
|
@@ -100,11 +96,11 @@ var TokenizedServiceConnection = /** @class */ (function () {
|
|
|
100
96
|
this.token = null;
|
|
101
97
|
this.isActive = true;
|
|
102
98
|
}
|
|
103
|
-
|
|
99
|
+
static call(serviceUrl, methodName, data, successCallback, unsuccessCallback, errorCallback) {
|
|
104
100
|
// We count on that we are in Admin/Subdirectory.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.then(
|
|
101
|
+
const address = serviceUrl + '/' + methodName;
|
|
102
|
+
axiosInstance.post(address, data)
|
|
103
|
+
.then((response) => {
|
|
108
104
|
if (response.status === 200) {
|
|
109
105
|
if (response.data.ReturnCodeString === 'Success') {
|
|
110
106
|
successCallback(response.data);
|
|
@@ -114,17 +110,15 @@ var TokenizedServiceConnection = /** @class */ (function () {
|
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
112
|
else {
|
|
117
|
-
errorCallback(new
|
|
113
|
+
errorCallback(new HttpRequestError(response.status, response.statusText));
|
|
118
114
|
}
|
|
119
115
|
})
|
|
120
|
-
.catch(
|
|
116
|
+
.catch((error) => {
|
|
121
117
|
if (error.response) {
|
|
122
|
-
errorCallback(new
|
|
118
|
+
errorCallback(new HttpRequestError(error.response.status, error.response.statusText));
|
|
123
119
|
return;
|
|
124
120
|
}
|
|
125
121
|
errorCallback(error);
|
|
126
122
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
}());
|
|
130
|
-
exports.TokenizedServiceConnection = TokenizedServiceConnection;
|
|
123
|
+
}
|
|
124
|
+
}
|