@eway-crm/connector 1.0.119 → 1.0.121
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.d.ts +5 -5
- package/lib/AnonymousSessionHandler.js +15 -15
- package/lib/ApiConnection.d.ts +66 -66
- package/lib/ApiConnection.js +321 -321
- package/lib/ApiMethods.d.ts +16 -16
- package/lib/ApiMethods.js +41 -42
- package/lib/CredentialsSessionHandler.d.ts +16 -16
- package/lib/CredentialsSessionHandler.js +60 -60
- package/lib/HttpMethod.d.ts +4 -4
- package/lib/HttpMethod.js +8 -8
- package/lib/ISessionHandler.d.ts +7 -7
- package/lib/ISessionHandler.js +2 -2
- package/lib/OAuthSessionHandler.d.ts +12 -12
- package/lib/OAuthSessionHandler.js +52 -52
- package/lib/OAuthSessionHandlerBase.d.ts +16 -16
- package/lib/OAuthSessionHandlerBase.js +78 -78
- package/lib/ReturnCodes.d.ts +9 -9
- package/lib/ReturnCodes.js +15 -16
- package/lib/axios/AxiosInstance.d.ts +2 -0
- package/lib/axios/AxiosInstance.js +5 -0
- package/lib/constants/ActionEventTypes.d.ts +9 -9
- package/lib/constants/ActionEventTypes.js +14 -14
- package/lib/constants/ColumnPermissionRules.d.ts +14 -14
- package/lib/constants/ColumnPermissionRules.js +22 -24
- package/lib/constants/CompletionLevels.d.ts +6 -6
- package/lib/constants/CompletionLevels.js +11 -11
- package/lib/constants/CustomizationStatsItemKeys.d.ts +11 -11
- package/lib/constants/CustomizationStatsItemKeys.js +17 -17
- package/lib/constants/Edition.d.ts +6 -6
- package/lib/constants/Edition.js +10 -10
- package/lib/constants/EnumTypes.d.ts +32 -32
- package/lib/constants/EnumTypes.js +38 -38
- package/lib/constants/ExpirationReason.d.ts +7 -7
- package/lib/constants/ExpirationReason.js +10 -10
- package/lib/constants/Feature.d.ts +6 -6
- package/lib/constants/Feature.js +10 -10
- package/lib/constants/FieldNames.d.ts +389 -389
- package/lib/constants/FieldNames.js +427 -427
- package/lib/constants/FieldTypes.d.ts +15 -15
- package/lib/constants/FieldTypes.js +20 -20
- package/lib/constants/FolderNames.d.ts +80 -80
- package/lib/constants/FolderNames.js +87 -88
- package/lib/constants/Functionality.d.ts +54 -54
- package/lib/constants/Functionality.js +60 -60
- package/lib/constants/GlobalSettingsNames.d.ts +71 -71
- package/lib/constants/GlobalSettingsNames.js +76 -76
- package/lib/constants/LicenseKeyInvoiceSeverity.d.ts +8 -8
- package/lib/constants/LicenseKeyInvoiceSeverity.js +11 -11
- package/lib/constants/LicenseRestrictionKeys.d.ts +62 -62
- package/lib/constants/LicenseRestrictionKeys.js +68 -68
- package/lib/constants/RelationTypes.d.ts +11 -11
- package/lib/constants/RelationTypes.js +16 -16
- package/lib/data/EWItem.d.ts +12 -12
- package/lib/data/EWItem.js +91 -91
- package/lib/data/IApiAdditionalField.d.ts +21 -21
- package/lib/data/IApiAdditionalField.js +2 -2
- package/lib/data/IApiAvailableBundle.d.ts +4 -4
- package/lib/data/IApiAvailableBundle.js +2 -2
- package/lib/data/IApiAvailableVersionResponse.d.ts +9 -9
- package/lib/data/IApiAvailableVersionResponse.js +2 -2
- package/lib/data/IApiBooleanResponse.d.ts +4 -4
- package/lib/data/IApiBooleanResponse.js +2 -2
- package/lib/data/IApiCapacityAvailableBundle.d.ts +5 -5
- package/lib/data/IApiCapacityAvailableBundle.js +2 -2
- package/lib/data/IApiCart.d.ts +48 -48
- package/lib/data/IApiCart.js +8 -8
- package/lib/data/IApiColumn.d.ts +51 -51
- package/lib/data/IApiColumn.js +2 -2
- package/lib/data/IApiColumnPermission.d.ts +15 -15
- package/lib/data/IApiColumnPermission.js +2 -2
- package/lib/data/IApiCompany.d.ts +55 -55
- package/lib/data/IApiCompany.js +8 -8
- package/lib/data/IApiContact.d.ts +58 -58
- package/lib/data/IApiContact.js +8 -8
- package/lib/data/IApiCurrencyExchangeRate.d.ts +9 -9
- package/lib/data/IApiCurrencyExchangeRate.js +8 -8
- package/lib/data/IApiCustomizationStatsItem.d.ts +6 -6
- package/lib/data/IApiCustomizationStatsItem.js +2 -2
- package/lib/data/IApiDataResponse.d.ts +4 -4
- package/lib/data/IApiDataResponse.js +2 -2
- package/lib/data/IApiDatumResponse.d.ts +4 -4
- package/lib/data/IApiDatumResponse.js +2 -2
- package/lib/data/IApiDocument.d.ts +22 -22
- package/lib/data/IApiDocument.js +8 -8
- package/lib/data/IApiEmail.d.ts +26 -26
- package/lib/data/IApiEmail.js +8 -8
- package/lib/data/IApiEnumType.d.ts +26 -26
- package/lib/data/IApiEnumType.js +9 -9
- package/lib/data/IApiEnumValue.d.ts +18 -18
- package/lib/data/IApiEnumValue.js +2 -2
- package/lib/data/IApiEnumValuesRelation.d.ts +8 -8
- package/lib/data/IApiEnumValuesRelation.js +8 -8
- package/lib/data/IApiFeature.d.ts +5 -5
- package/lib/data/IApiFeature.js +2 -2
- package/lib/data/IApiFeaturesLicenseBundle.d.ts +10 -10
- package/lib/data/IApiFeaturesLicenseBundle.js +2 -2
- package/lib/data/IApiFlow.d.ts +9 -9
- package/lib/data/IApiFlow.js +8 -8
- package/lib/data/IApiGlobalSetting.d.ts +33 -33
- package/lib/data/IApiGlobalSetting.js +2 -2
- package/lib/data/IApiGoal.d.ts +22 -22
- package/lib/data/IApiGoal.js +8 -8
- package/lib/data/IApiGood.d.ts +26 -26
- package/lib/data/IApiGood.js +8 -8
- package/lib/data/IApiGoodInCart.d.ts +62 -62
- package/lib/data/IApiGoodInCart.js +8 -8
- package/lib/data/IApiGroup.d.ts +16 -16
- package/lib/data/IApiGroup.js +2 -2
- package/lib/data/IApiItemBase.d.ts +14 -14
- package/lib/data/IApiItemBase.js +2 -2
- package/lib/data/IApiItemIdentifier.d.ts +5 -5
- package/lib/data/IApiItemIdentifier.js +2 -2
- package/lib/data/IApiItemUsageStatus.d.ts +4 -4
- package/lib/data/IApiItemUsageStatus.js +2 -2
- package/lib/data/IApiJournal.d.ts +25 -25
- package/lib/data/IApiJournal.js +8 -8
- package/lib/data/IApiLead.d.ts +36 -36
- package/lib/data/IApiLead.js +8 -8
- package/lib/data/IApiLicense.d.ts +65 -65
- package/lib/data/IApiLicense.js +2 -2
- package/lib/data/IApiLicenseBundleBase.d.ts +6 -6
- package/lib/data/IApiLicenseBundleBase.js +2 -2
- package/lib/data/IApiLocalizedLicenseBundle.d.ts +4 -4
- package/lib/data/IApiLocalizedLicenseBundle.js +2 -2
- package/lib/data/IApiLoginResponse.d.ts +8 -8
- package/lib/data/IApiLoginResponse.js +2 -2
- package/lib/data/IApiMarketingCampaign.d.ts +32 -32
- package/lib/data/IApiMarketingCampaign.js +8 -8
- package/lib/data/IApiMarketingList.d.ts +17 -17
- package/lib/data/IApiMarketingList.js +8 -8
- package/lib/data/IApiModulePermission.d.ts +14 -14
- package/lib/data/IApiModulePermission.js +2 -2
- package/lib/data/IApiObjectType.d.ts +9 -9
- package/lib/data/IApiObjectType.js +2 -2
- package/lib/data/IApiPasswordStrength.d.ts +5 -5
- package/lib/data/IApiPasswordStrength.js +2 -2
- package/lib/data/IApiPayment.d.ts +9 -9
- package/lib/data/IApiPayment.js +8 -8
- package/lib/data/IApiProject.d.ts +59 -59
- package/lib/data/IApiProject.js +8 -8
- package/lib/data/IApiRecurrencePattern.d.ts +16 -16
- package/lib/data/IApiRecurrencePattern.js +8 -8
- package/lib/data/IApiResult.d.ts +4 -4
- package/lib/data/IApiResult.js +2 -2
- package/lib/data/IApiSaveResponse.d.ts +4 -4
- package/lib/data/IApiSaveResponse.js +2 -2
- package/lib/data/IApiTask.d.ts +34 -34
- package/lib/data/IApiTask.js +8 -8
- package/lib/data/IApiUser.d.ts +22 -22
- package/lib/data/IApiUser.js +2 -2
- package/lib/data/IApiUserSetting.d.ts +6 -6
- package/lib/data/IApiUserSetting.js +2 -2
- package/lib/data/IApiWebServiceTaskStatus.d.ts +10 -10
- package/lib/data/IApiWebServiceTaskStatus.js +2 -2
- package/lib/data/IApiWorkReport.d.ts +36 -36
- package/lib/data/IApiWorkReport.js +8 -8
- package/lib/data/IApiWorkflowActionDerivedItem.d.ts +21 -21
- package/lib/data/IApiWorkflowActionDerivedItem.js +2 -2
- package/lib/data/IApiWorkflowModel.d.ts +8 -8
- package/lib/data/IApiWorkflowModel.js +2 -2
- package/lib/data/query/IApiQuery.d.ts +42 -42
- package/lib/data/query/IApiQuery.js +2 -2
- package/lib/data/query/IApiQueryFilters.d.ts +43 -43
- package/lib/data/query/IApiQueryFilters.js +2 -2
- package/lib/data/workflowActions/IApiAction.d.ts +106 -106
- package/lib/data/workflowActions/IApiAction.js +2 -2
- package/lib/exceptions/HttpRequestError.d.ts +7 -7
- package/lib/exceptions/HttpRequestError.js +29 -29
- package/lib/exceptions/WebServiceError.d.ts +5 -5
- package/lib/exceptions/WebServiceError.js +29 -29
- package/lib/helpers/ErrorHelper.d.ts +4 -4
- package/lib/helpers/ErrorHelper.js +21 -21
- package/lib/helpers/OAuthHelper.d.ts +8 -8
- package/lib/helpers/OAuthHelper.js +57 -60
- package/lib/helpers/VersionHelperBase.d.ts +5 -5
- package/lib/helpers/VersionHelperBase.js +21 -21
- package/lib/index.d.ts +85 -85
- package/lib/index.js +124 -124
- package/lib/interfaces/IEWJwtPayload.d.ts +4 -4
- package/lib/interfaces/IEWJwtPayload.js +2 -2
- package/lib/interfaces/IItemPreview.d.ts +5 -5
- package/lib/interfaces/IItemPreview.js +2 -2
- package/lib/interfaces/ITokenData.d.ts +9 -9
- package/lib/interfaces/ITokenData.js +2 -2
- package/lib/interfaces/ITranslatableString.d.ts +8 -8
- package/lib/interfaces/ITranslatableString.js +2 -2
- package/lib/interfaces/TNumericValidatorType.d.ts +1 -1
- package/lib/interfaces/TNumericValidatorType.js +2 -2
- package/lib/tokenizedServices/CommonDataConnection.d.ts +9 -9
- package/lib/tokenizedServices/CommonDataConnection.js +22 -22
- package/lib/tokenizedServices/ITokenizedApiResult.d.ts +4 -4
- package/lib/tokenizedServices/ITokenizedApiResult.js +2 -2
- package/lib/tokenizedServices/TokenizedServiceConnection.d.ts +25 -25
- package/lib/tokenizedServices/TokenizedServiceConnection.js +130 -130
- package/package.json +10 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface IItemPreview {
|
|
2
|
-
imageData: string;
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
}
|
|
1
|
+
export interface IItemPreview {
|
|
2
|
+
imageData: string;
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export interface ITokenData {
|
|
2
|
-
access_token: string;
|
|
3
|
-
expires_in: number;
|
|
4
|
-
id_token?: string;
|
|
5
|
-
token_type: string;
|
|
6
|
-
refresh_token: string;
|
|
7
|
-
error: string;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
1
|
+
export interface ITokenData {
|
|
2
|
+
access_token: string;
|
|
3
|
+
expires_in: number;
|
|
4
|
+
id_token?: string;
|
|
5
|
+
token_type: string;
|
|
6
|
+
refresh_token: string;
|
|
7
|
+
error: string;
|
|
8
|
+
}
|
|
9
|
+
export type TInputData = Record<string, Object | null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface ITranslatableString {
|
|
2
|
-
En: string | null;
|
|
3
|
-
Cs: string | null;
|
|
4
|
-
De: string | null;
|
|
5
|
-
Ru: string | null;
|
|
6
|
-
Sk: string | null;
|
|
7
|
-
No: string | null;
|
|
8
|
-
}
|
|
1
|
+
export interface ITranslatableString {
|
|
2
|
+
En: string | null;
|
|
3
|
+
Cs: string | null;
|
|
4
|
+
De: string | null;
|
|
5
|
+
Ru: string | null;
|
|
6
|
+
Sk: string | null;
|
|
7
|
+
No: string | null;
|
|
8
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type TNumericValidatorType = 'None' | 'Double' | 'Currency' | 'Int' | 'Percent' | 'FileSize';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ApiConnection } from '../ApiConnection';
|
|
2
|
-
import { ITokenizedApiResult } from './ITokenizedApiResult';
|
|
3
|
-
import { TInputData } from '../interfaces/ITokenData';
|
|
4
|
-
export declare class CommonDataConnection {
|
|
5
|
-
private readonly tokenizedConnection;
|
|
6
|
-
constructor(connection: ApiConnection, errorCallback?: (error: Error) => void);
|
|
7
|
-
readonly isCommonDataApiEnabled: (enabledCallback: (url: string, token: string) => void, disabledCallback: () => void) => void;
|
|
8
|
-
readonly callCommonDataApi: <TResult extends ITokenizedApiResult>(methodName: string, data: TInputData, successCallback: (data: TResult) => void, unsuccessCallback?: ((data: TResult | null) => void) | null | undefined) => void;
|
|
9
|
-
}
|
|
1
|
+
import { ApiConnection } from '../ApiConnection';
|
|
2
|
+
import { ITokenizedApiResult } from './ITokenizedApiResult';
|
|
3
|
+
import { TInputData } from '../interfaces/ITokenData';
|
|
4
|
+
export declare class CommonDataConnection {
|
|
5
|
+
private readonly tokenizedConnection;
|
|
6
|
+
constructor(connection: ApiConnection, errorCallback?: (error: Error) => void);
|
|
7
|
+
readonly isCommonDataApiEnabled: (enabledCallback: (url: string, token: string) => void, disabledCallback: () => void) => void;
|
|
8
|
+
readonly callCommonDataApi: <TResult extends ITokenizedApiResult>(methodName: string, data: TInputData, successCallback: (data: TResult) => void, unsuccessCallback?: ((data: TResult | null) => void) | null | undefined) => void;
|
|
9
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommonDataConnection = void 0;
|
|
4
|
-
var TokenizedServiceConnection_1 = require("./TokenizedServiceConnection");
|
|
5
|
-
var HttpMethod_1 = require("../HttpMethod");
|
|
6
|
-
var obtainer = function (result) {
|
|
7
|
-
return { url: result.ServiceUrl, token: result.Token };
|
|
8
|
-
};
|
|
9
|
-
var CommonDataConnection = /** @class */ (function () {
|
|
10
|
-
function CommonDataConnection(connection, errorCallback) {
|
|
11
|
-
var _this = this;
|
|
12
|
-
this.isCommonDataApiEnabled = function (enabledCallback, disabledCallback) {
|
|
13
|
-
_this.tokenizedConnection.isEnabled(enabledCallback, disabledCallback);
|
|
14
|
-
};
|
|
15
|
-
this.callCommonDataApi = function (methodName, data, successCallback, unsuccessCallback) {
|
|
16
|
-
_this.tokenizedConnection.callTokenizedApi(methodName, data, successCallback, unsuccessCallback);
|
|
17
|
-
};
|
|
18
|
-
this.tokenizedConnection = new TokenizedServiceConnection_1.TokenizedServiceConnection('ObtainCommonDataApiAccessToken', HttpMethod_1.HttpMethod.get, false, 'InvalidCommonDataToken', obtainer, connection, errorCallback);
|
|
19
|
-
}
|
|
20
|
-
return CommonDataConnection;
|
|
21
|
-
}());
|
|
22
|
-
exports.CommonDataConnection = CommonDataConnection;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonDataConnection = void 0;
|
|
4
|
+
var TokenizedServiceConnection_1 = require("./TokenizedServiceConnection");
|
|
5
|
+
var HttpMethod_1 = require("../HttpMethod");
|
|
6
|
+
var obtainer = function (result) {
|
|
7
|
+
return { url: result.ServiceUrl, token: result.Token };
|
|
8
|
+
};
|
|
9
|
+
var CommonDataConnection = /** @class */ (function () {
|
|
10
|
+
function CommonDataConnection(connection, errorCallback) {
|
|
11
|
+
var _this = this;
|
|
12
|
+
this.isCommonDataApiEnabled = function (enabledCallback, disabledCallback) {
|
|
13
|
+
_this.tokenizedConnection.isEnabled(enabledCallback, disabledCallback);
|
|
14
|
+
};
|
|
15
|
+
this.callCommonDataApi = function (methodName, data, successCallback, unsuccessCallback) {
|
|
16
|
+
_this.tokenizedConnection.callTokenizedApi(methodName, data, successCallback, unsuccessCallback);
|
|
17
|
+
};
|
|
18
|
+
this.tokenizedConnection = new TokenizedServiceConnection_1.TokenizedServiceConnection('ObtainCommonDataApiAccessToken', HttpMethod_1.HttpMethod.get, false, 'InvalidCommonDataToken', obtainer, connection, errorCallback);
|
|
19
|
+
}
|
|
20
|
+
return CommonDataConnection;
|
|
21
|
+
}());
|
|
22
|
+
exports.CommonDataConnection = CommonDataConnection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface ITokenizedApiResult {
|
|
2
|
-
ReturnCodeString: string;
|
|
3
|
-
Description: string;
|
|
4
|
-
}
|
|
1
|
+
export interface ITokenizedApiResult {
|
|
2
|
+
ReturnCodeString: string;
|
|
3
|
+
Description: string;
|
|
4
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { HttpMethod } from '../HttpMethod';
|
|
2
|
-
import { ApiConnection } from '../ApiConnection';
|
|
3
|
-
import { ITokenizedApiResult } from './ITokenizedApiResult';
|
|
4
|
-
import { IApiResult } from '../data/IApiResult';
|
|
5
|
-
import { TInputData } from '../interfaces/ITokenData';
|
|
6
|
-
export declare class TokenizedServiceConnection<TObtainResponse extends IApiResult> {
|
|
7
|
-
private readonly obtainTokenMethodName;
|
|
8
|
-
private readonly obtainTokenMethodType;
|
|
9
|
-
private readonly needsSession;
|
|
10
|
-
private readonly invalidTokenReturnCode;
|
|
11
|
-
private readonly urlAndTokenObtainer;
|
|
12
|
-
private readonly connection;
|
|
13
|
-
private readonly generalErrorCallback;
|
|
14
|
-
private url;
|
|
15
|
-
private token;
|
|
16
|
-
private isActive;
|
|
17
|
-
constructor(obtainTokenMethodName: string, obtainTokenMethodType: HttpMethod, needsSession: boolean, invalidTokenReturnCode: string, urlAndTokenObtainer: (response: TObtainResponse) => {
|
|
18
|
-
url: string | null;
|
|
19
|
-
token: string | null;
|
|
20
|
-
}, connection: ApiConnection, errorCallback?: (error: Error) => void);
|
|
21
|
-
readonly isEnabled: (enabledCallback: (url: string, token: string) => void, disabledCallback: () => void) => void;
|
|
22
|
-
readonly callTokenizedApi: <TResult extends ITokenizedApiResult>(methodName: string, data: TInputData, successCallback: (data: TResult) => void, unsuccessCallback?: ((data: TResult | null) => void) | null | undefined) => void;
|
|
23
|
-
private readonly obtainToken;
|
|
24
|
-
private static call;
|
|
25
|
-
}
|
|
1
|
+
import { HttpMethod } from '../HttpMethod';
|
|
2
|
+
import { ApiConnection } from '../ApiConnection';
|
|
3
|
+
import { ITokenizedApiResult } from './ITokenizedApiResult';
|
|
4
|
+
import { IApiResult } from '../data/IApiResult';
|
|
5
|
+
import { TInputData } from '../interfaces/ITokenData';
|
|
6
|
+
export declare class TokenizedServiceConnection<TObtainResponse extends IApiResult> {
|
|
7
|
+
private readonly obtainTokenMethodName;
|
|
8
|
+
private readonly obtainTokenMethodType;
|
|
9
|
+
private readonly needsSession;
|
|
10
|
+
private readonly invalidTokenReturnCode;
|
|
11
|
+
private readonly urlAndTokenObtainer;
|
|
12
|
+
private readonly connection;
|
|
13
|
+
private readonly generalErrorCallback;
|
|
14
|
+
private url;
|
|
15
|
+
private token;
|
|
16
|
+
private isActive;
|
|
17
|
+
constructor(obtainTokenMethodName: string, obtainTokenMethodType: HttpMethod, needsSession: boolean, invalidTokenReturnCode: string, urlAndTokenObtainer: (response: TObtainResponse) => {
|
|
18
|
+
url: string | null;
|
|
19
|
+
token: string | null;
|
|
20
|
+
}, connection: ApiConnection, errorCallback?: (error: Error) => void);
|
|
21
|
+
readonly isEnabled: (enabledCallback: (url: string, token: string) => void, disabledCallback: () => void) => void;
|
|
22
|
+
readonly callTokenizedApi: <TResult extends ITokenizedApiResult>(methodName: string, data: TInputData, successCallback: (data: TResult) => void, unsuccessCallback?: ((data: TResult | null) => void) | null | undefined) => void;
|
|
23
|
+
private readonly obtainToken;
|
|
24
|
+
private static call;
|
|
25
|
+
}
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenizedServiceConnection = void 0;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var TokenizedServiceConnection = /** @class */ (function () {
|
|
7
|
-
function TokenizedServiceConnection(obtainTokenMethodName, obtainTokenMethodType, needsSession, invalidTokenReturnCode, urlAndTokenObtainer, connection, errorCallback) {
|
|
8
|
-
var _this = this;
|
|
9
|
-
this.isEnabled = function (enabledCallback, disabledCallback) {
|
|
10
|
-
var check = function () {
|
|
11
|
-
if (!_this.url || !_this.token) {
|
|
12
|
-
disabledCallback();
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
enabledCallback(_this.url, _this.token);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
if (!_this.url || !_this.token) {
|
|
19
|
-
_this.obtainToken(check);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
enabledCallback(_this.url, _this.token);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
this.callTokenizedApi = function (methodName, data, successCallback, unsuccessCallback) {
|
|
27
|
-
_this.isEnabled(function (url, token) {
|
|
28
|
-
data.token = token;
|
|
29
|
-
TokenizedServiceConnection.call(url, methodName, data, successCallback, function (result) {
|
|
30
|
-
if (result.ReturnCodeString === _this.invalidTokenReturnCode) {
|
|
31
|
-
_this.obtainToken(function () {
|
|
32
|
-
_this.callTokenizedApi(methodName, data, successCallback, unsuccessCallback);
|
|
33
|
-
});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (unsuccessCallback) {
|
|
37
|
-
unsuccessCallback(result);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
if (!!_this.generalErrorCallback) {
|
|
41
|
-
var error = new Error('Unhandled tokenized service connection return code ' + result.ReturnCodeString + '.\nDescription: ' + result.Description);
|
|
42
|
-
_this.generalErrorCallback(error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, function (error) {
|
|
46
|
-
if (!!_this.generalErrorCallback) {
|
|
47
|
-
var err = new Error('Unhandled tokenized service connection communication error: ' + JSON.stringify(error));
|
|
48
|
-
_this.generalErrorCallback(err);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}, function () {
|
|
52
|
-
if (unsuccessCallback) {
|
|
53
|
-
unsuccessCallback(null);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
this.obtainToken = function (callback) {
|
|
58
|
-
if (!_this.isActive) {
|
|
59
|
-
_this.url = null;
|
|
60
|
-
_this.token = null;
|
|
61
|
-
callback();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
var successClb = function (result) {
|
|
65
|
-
var obtainedResult = _this.urlAndTokenObtainer(result);
|
|
66
|
-
if (!obtainedResult.url || !obtainedResult.token) {
|
|
67
|
-
_this.url = null;
|
|
68
|
-
_this.token = null;
|
|
69
|
-
_this.isActive = false;
|
|
70
|
-
callback();
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
_this.url = obtainedResult.url;
|
|
74
|
-
_this.token = obtainedResult.token;
|
|
75
|
-
_this.isActive = true;
|
|
76
|
-
callback();
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var unsuccessClb = function () {
|
|
80
|
-
_this.url = null;
|
|
81
|
-
_this.token = null;
|
|
82
|
-
_this.isActive = false;
|
|
83
|
-
callback();
|
|
84
|
-
};
|
|
85
|
-
if (_this.needsSession) {
|
|
86
|
-
_this.connection.callMethod(_this.obtainTokenMethodName, {}, successClb, unsuccessClb, _this.obtainTokenMethodType);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
_this.connection.callWithoutSession(_this.obtainTokenMethodName, null, successClb, unsuccessClb, null, _this.obtainTokenMethodType);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
this.obtainTokenMethodName = obtainTokenMethodName;
|
|
93
|
-
this.obtainTokenMethodType = obtainTokenMethodType;
|
|
94
|
-
this.needsSession = needsSession;
|
|
95
|
-
this.invalidTokenReturnCode = invalidTokenReturnCode;
|
|
96
|
-
this.urlAndTokenObtainer = urlAndTokenObtainer;
|
|
97
|
-
this.connection = connection;
|
|
98
|
-
this.generalErrorCallback = errorCallback || null;
|
|
99
|
-
this.url = null;
|
|
100
|
-
this.token = null;
|
|
101
|
-
this.isActive = true;
|
|
102
|
-
}
|
|
103
|
-
TokenizedServiceConnection.call = function (serviceUrl, methodName, data, successCallback, unsuccessCallback, errorCallback) {
|
|
104
|
-
// We count on that we are in Admin/Subdirectory.
|
|
105
|
-
var address = serviceUrl + '/' + methodName;
|
|
106
|
-
|
|
107
|
-
.then(function (response) {
|
|
108
|
-
if (response.status === 200) {
|
|
109
|
-
if (response.data.ReturnCodeString === 'Success') {
|
|
110
|
-
successCallback(response.data);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
unsuccessCallback(response.data);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
errorCallback(new __1.HttpRequestError(response.status, response.statusText));
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
.catch(function (error) {
|
|
121
|
-
if (error.response) {
|
|
122
|
-
errorCallback(new __1.HttpRequestError(error.response.status, error.response.statusText));
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
errorCallback(error);
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
return TokenizedServiceConnection;
|
|
129
|
-
}());
|
|
130
|
-
exports.TokenizedServiceConnection = TokenizedServiceConnection;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenizedServiceConnection = void 0;
|
|
4
|
+
var __1 = require("..");
|
|
5
|
+
var AxiosInstance_1 = require("../axios/AxiosInstance");
|
|
6
|
+
var TokenizedServiceConnection = /** @class */ (function () {
|
|
7
|
+
function TokenizedServiceConnection(obtainTokenMethodName, obtainTokenMethodType, needsSession, invalidTokenReturnCode, urlAndTokenObtainer, connection, errorCallback) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
this.isEnabled = function (enabledCallback, disabledCallback) {
|
|
10
|
+
var check = function () {
|
|
11
|
+
if (!_this.url || !_this.token) {
|
|
12
|
+
disabledCallback();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
enabledCallback(_this.url, _this.token);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
if (!_this.url || !_this.token) {
|
|
19
|
+
_this.obtainToken(check);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
enabledCallback(_this.url, _this.token);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this.callTokenizedApi = function (methodName, data, successCallback, unsuccessCallback) {
|
|
27
|
+
_this.isEnabled(function (url, token) {
|
|
28
|
+
data.token = token;
|
|
29
|
+
TokenizedServiceConnection.call(url, methodName, data, successCallback, function (result) {
|
|
30
|
+
if (result.ReturnCodeString === _this.invalidTokenReturnCode) {
|
|
31
|
+
_this.obtainToken(function () {
|
|
32
|
+
_this.callTokenizedApi(methodName, data, successCallback, unsuccessCallback);
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (unsuccessCallback) {
|
|
37
|
+
unsuccessCallback(result);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (!!_this.generalErrorCallback) {
|
|
41
|
+
var error = new Error('Unhandled tokenized service connection return code ' + result.ReturnCodeString + '.\nDescription: ' + result.Description);
|
|
42
|
+
_this.generalErrorCallback(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, function (error) {
|
|
46
|
+
if (!!_this.generalErrorCallback) {
|
|
47
|
+
var err = new Error('Unhandled tokenized service connection communication error: ' + JSON.stringify(error));
|
|
48
|
+
_this.generalErrorCallback(err);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}, function () {
|
|
52
|
+
if (unsuccessCallback) {
|
|
53
|
+
unsuccessCallback(null);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
this.obtainToken = function (callback) {
|
|
58
|
+
if (!_this.isActive) {
|
|
59
|
+
_this.url = null;
|
|
60
|
+
_this.token = null;
|
|
61
|
+
callback();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var successClb = function (result) {
|
|
65
|
+
var obtainedResult = _this.urlAndTokenObtainer(result);
|
|
66
|
+
if (!obtainedResult.url || !obtainedResult.token) {
|
|
67
|
+
_this.url = null;
|
|
68
|
+
_this.token = null;
|
|
69
|
+
_this.isActive = false;
|
|
70
|
+
callback();
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
_this.url = obtainedResult.url;
|
|
74
|
+
_this.token = obtainedResult.token;
|
|
75
|
+
_this.isActive = true;
|
|
76
|
+
callback();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var unsuccessClb = function () {
|
|
80
|
+
_this.url = null;
|
|
81
|
+
_this.token = null;
|
|
82
|
+
_this.isActive = false;
|
|
83
|
+
callback();
|
|
84
|
+
};
|
|
85
|
+
if (_this.needsSession) {
|
|
86
|
+
_this.connection.callMethod(_this.obtainTokenMethodName, {}, successClb, unsuccessClb, _this.obtainTokenMethodType);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
_this.connection.callWithoutSession(_this.obtainTokenMethodName, null, successClb, unsuccessClb, null, _this.obtainTokenMethodType);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this.obtainTokenMethodName = obtainTokenMethodName;
|
|
93
|
+
this.obtainTokenMethodType = obtainTokenMethodType;
|
|
94
|
+
this.needsSession = needsSession;
|
|
95
|
+
this.invalidTokenReturnCode = invalidTokenReturnCode;
|
|
96
|
+
this.urlAndTokenObtainer = urlAndTokenObtainer;
|
|
97
|
+
this.connection = connection;
|
|
98
|
+
this.generalErrorCallback = errorCallback || null;
|
|
99
|
+
this.url = null;
|
|
100
|
+
this.token = null;
|
|
101
|
+
this.isActive = true;
|
|
102
|
+
}
|
|
103
|
+
TokenizedServiceConnection.call = function (serviceUrl, methodName, data, successCallback, unsuccessCallback, errorCallback) {
|
|
104
|
+
// We count on that we are in Admin/Subdirectory.
|
|
105
|
+
var address = serviceUrl + '/' + methodName;
|
|
106
|
+
AxiosInstance_1.default.post(address, data)
|
|
107
|
+
.then(function (response) {
|
|
108
|
+
if (response.status === 200) {
|
|
109
|
+
if (response.data.ReturnCodeString === 'Success') {
|
|
110
|
+
successCallback(response.data);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
unsuccessCallback(response.data);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
errorCallback(new __1.HttpRequestError(response.status, response.statusText));
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
.catch(function (error) {
|
|
121
|
+
if (error.response) {
|
|
122
|
+
errorCallback(new __1.HttpRequestError(error.response.status, error.response.statusText));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
errorCallback(error);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
return TokenizedServiceConnection;
|
|
129
|
+
}());
|
|
130
|
+
exports.TokenizedServiceConnection = TokenizedServiceConnection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eway-crm/connector",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.121",
|
|
4
4
|
"description": "eWay-CRM API JavaScript connector library.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"homepage": "https://github.com/eway-crm/js-lib#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@eway-crm/eslint-config": "^1.0.6",
|
|
37
|
-
"@types/jest": "^
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
39
|
-
"@typescript-eslint/parser": "^5.
|
|
40
|
-
"eslint": "^8.
|
|
41
|
-
"jest": "^
|
|
42
|
-
"prettier": "^2.
|
|
43
|
-
"ts-jest": "^
|
|
44
|
-
"typescript": "^
|
|
37
|
+
"@types/jest": "^29.5.1",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
39
|
+
"@typescript-eslint/parser": "^5.59.5",
|
|
40
|
+
"eslint": "^8.40.0",
|
|
41
|
+
"jest": "^29.5.0",
|
|
42
|
+
"prettier": "^2.8.8",
|
|
43
|
+
"ts-jest": "^29.1.0",
|
|
44
|
+
"typescript": "^5.0.4"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"lib/**/*"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"axios": "^
|
|
50
|
+
"axios": "^1.4.0",
|
|
51
51
|
"compare-versions": "^5.0.3",
|
|
52
52
|
"es6-promise": "^4.2.8",
|
|
53
53
|
"jwt-decode": "^3.1.2",
|