@eway-crm/connector 1.0.126 → 1.0.128
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/{index.js → cjs/index.d.ts} +7 -6
- package/lib/cjs/index.js +8 -0
- package/lib/esm/AnonymousSessionHandler.d.ts +5 -0
- package/lib/esm/ApiConnection.d.ts +66 -0
- package/lib/esm/ApiMethods.d.ts +16 -0
- package/lib/esm/CredentialsSessionHandler.d.ts +16 -0
- package/lib/esm/HttpMethod.d.ts +4 -0
- package/lib/esm/ISessionHandler.d.ts +7 -0
- package/lib/esm/OAuthSessionHandler.d.ts +12 -0
- package/lib/esm/OAuthSessionHandlerBase.d.ts +16 -0
- package/lib/esm/ReturnCodes.d.ts +9 -0
- package/lib/esm/constants/ActionEventTypes.d.ts +9 -0
- package/lib/esm/constants/ColumnPermissionRules.d.ts +14 -0
- package/lib/esm/constants/CompletionLevels.d.ts +6 -0
- package/lib/esm/constants/CustomizationStatsItemKeys.d.ts +11 -0
- package/lib/esm/constants/Edition.d.ts +6 -0
- package/lib/esm/constants/EnumTypes.d.ts +32 -0
- package/lib/esm/constants/ExpirationReason.d.ts +7 -0
- package/lib/esm/constants/Feature.d.ts +6 -0
- package/lib/esm/constants/FieldNames.d.ts +389 -0
- package/lib/esm/constants/FieldTypes.d.ts +15 -0
- package/lib/esm/constants/FolderNames.d.ts +80 -0
- package/lib/esm/constants/Functionality.d.ts +54 -0
- package/lib/esm/constants/GlobalSettingsNames.d.ts +71 -0
- package/lib/esm/constants/LicenseKeyInvoiceSeverity.d.ts +8 -0
- package/lib/esm/constants/LicenseRestrictionKeys.d.ts +62 -0
- package/lib/esm/constants/RelationTypes.d.ts +11 -0
- package/lib/esm/data/EWItem.d.ts +12 -0
- package/lib/esm/data/IApiAdditionalField.d.ts +21 -0
- package/lib/esm/data/IApiAvailableBundle.d.ts +4 -0
- package/lib/esm/data/IApiAvailableVersionResponse.d.ts +9 -0
- package/lib/esm/data/IApiBooleanResponse.d.ts +4 -0
- package/lib/esm/data/IApiCapacityAvailableBundle.d.ts +5 -0
- package/lib/esm/data/IApiCart.d.ts +48 -0
- package/lib/esm/data/IApiColumn.d.ts +51 -0
- package/lib/esm/data/IApiColumnPermission.d.ts +15 -0
- package/lib/esm/data/IApiCompany.d.ts +55 -0
- package/lib/esm/data/IApiContact.d.ts +58 -0
- package/lib/esm/data/IApiCurrencyExchangeRate.d.ts +9 -0
- package/lib/esm/data/IApiCustomizationStatsItem.d.ts +6 -0
- package/lib/esm/data/IApiDataResponse.d.ts +4 -0
- package/lib/esm/data/IApiDatumResponse.d.ts +4 -0
- package/lib/esm/data/IApiDocument.d.ts +22 -0
- package/lib/esm/data/IApiEmail.d.ts +26 -0
- package/lib/esm/data/IApiEnumType.d.ts +26 -0
- package/lib/esm/data/IApiEnumValue.d.ts +18 -0
- package/lib/esm/data/IApiEnumValuesRelation.d.ts +8 -0
- package/lib/esm/data/IApiFeature.d.ts +5 -0
- package/lib/esm/data/IApiFeaturesLicenseBundle.d.ts +10 -0
- package/lib/esm/data/IApiFlow.d.ts +9 -0
- package/lib/esm/data/IApiGlobalSetting.d.ts +33 -0
- package/lib/esm/data/IApiGoal.d.ts +22 -0
- package/lib/esm/data/IApiGood.d.ts +26 -0
- package/lib/esm/data/IApiGoodInCart.d.ts +62 -0
- package/lib/esm/data/IApiGroup.d.ts +16 -0
- package/lib/esm/data/IApiItemBase.d.ts +14 -0
- package/lib/esm/data/IApiItemIdentifier.d.ts +5 -0
- package/lib/esm/data/IApiItemUsageStatus.d.ts +4 -0
- package/lib/esm/data/IApiJournal.d.ts +25 -0
- package/lib/esm/data/IApiLead.d.ts +36 -0
- package/lib/esm/data/IApiLicense.d.ts +65 -0
- package/lib/esm/data/IApiLicenseBundleBase.d.ts +6 -0
- package/lib/esm/data/IApiLocalizedLicenseBundle.d.ts +4 -0
- package/lib/esm/data/IApiLoginResponse.d.ts +8 -0
- package/lib/esm/data/IApiMarketingCampaign.d.ts +32 -0
- package/lib/esm/data/IApiMarketingList.d.ts +17 -0
- package/lib/esm/data/IApiModulePermission.d.ts +14 -0
- package/lib/esm/data/IApiObjectType.d.ts +9 -0
- package/lib/esm/data/IApiPasswordStrength.d.ts +5 -0
- package/lib/esm/data/IApiPayment.d.ts +9 -0
- package/lib/esm/data/IApiProject.d.ts +59 -0
- package/lib/esm/data/IApiRecurrencePattern.d.ts +16 -0
- package/lib/{IApiResult.d.ts → esm/data/IApiResult.d.ts} +4 -4
- package/lib/esm/data/IApiSaveResponse.d.ts +4 -0
- package/lib/esm/data/IApiTask.d.ts +34 -0
- package/lib/esm/data/IApiUser.d.ts +22 -0
- package/lib/esm/data/IApiUserSetting.d.ts +6 -0
- package/lib/esm/data/IApiWebServiceTaskStatus.d.ts +10 -0
- package/lib/esm/data/IApiWorkReport.d.ts +36 -0
- package/lib/esm/data/IApiWorkflowActionDerivedItem.d.ts +21 -0
- package/lib/esm/data/IApiWorkflowModel.d.ts +8 -0
- package/lib/esm/data/query/IApiQuery.d.ts +42 -0
- package/lib/esm/data/query/IApiQueryFilters.d.ts +43 -0
- package/lib/esm/data/workflowActions/IApiAction.d.ts +106 -0
- package/lib/esm/exceptions/HttpRequestError.d.ts +7 -0
- package/lib/esm/exceptions/WebServiceError.d.ts +5 -0
- package/lib/esm/helpers/ErrorHelper.d.ts +4 -0
- package/lib/esm/helpers/OAuthHelper.d.ts +8 -0
- package/lib/esm/helpers/VersionHelperBase.d.ts +5 -0
- package/lib/esm/index.d.ts +85 -0
- package/lib/esm/index.js +8 -0
- package/lib/esm/interfaces/IEWJwtPayload.d.ts +4 -0
- package/lib/esm/interfaces/IItemPreview.d.ts +5 -0
- package/lib/esm/interfaces/ITokenData.d.ts +9 -0
- package/lib/esm/interfaces/ITranslatableString.d.ts +8 -0
- package/lib/esm/interfaces/TNumericValidatorType.d.ts +1 -0
- package/lib/esm/tokenizedServices/CommonDataConnection.d.ts +9 -0
- package/lib/esm/tokenizedServices/ITokenizedApiResult.d.ts +4 -0
- package/lib/esm/tokenizedServices/TokenizedServiceConnection.d.ts +25 -0
- package/lib/index.d.ts +2164 -85
- package/package.json +14 -4
- package/lib/AnonymousSessionHandler.js +0 -10
- package/lib/ApiConnection.js +0 -307
- package/lib/ApiMethods.js +0 -36
- package/lib/CredentialsSessionHandler.js +0 -54
- package/lib/HttpMethod.js +0 -5
- package/lib/IApiResult.js +0 -2
- package/lib/ISessionHandler.js +0 -1
- package/lib/OAuthSessionHandler.js +0 -29
- package/lib/OAuthSessionHandlerBase.js +0 -72
- package/lib/ReturnCodes.js +0 -10
- package/lib/axios/AxiosInstance.d.ts +0 -2
- package/lib/axios/AxiosInstance.js +0 -3
- package/lib/constants/ActionEventTypes.js +0 -9
- package/lib/constants/ColumnPermissionRules.js +0 -15
- package/lib/constants/CompletionLevels.js +0 -6
- package/lib/constants/CustomizationStatsItemKeys.js +0 -12
- package/lib/constants/Edition.js +0 -7
- package/lib/constants/EnumTypes.js +0 -33
- package/lib/constants/ExpirationReason.js +0 -8
- package/lib/constants/Feature.js +0 -7
- package/lib/constants/FieldNames.js +0 -422
- package/lib/constants/FieldTypes.js +0 -15
- package/lib/constants/FolderNames.js +0 -82
- package/lib/constants/Functionality.js +0 -55
- package/lib/constants/GlobalSettingsNames.js +0 -71
- package/lib/constants/LicenseKeyInvoiceSeverity.js +0 -9
- package/lib/constants/LicenseRestrictionKeys.js +0 -63
- package/lib/constants/RelationTypes.js +0 -11
- package/lib/data/EWItem.js +0 -86
- package/lib/data/IApiAdditionalField.js +0 -1
- package/lib/data/IApiAvailableBundle.js +0 -1
- package/lib/data/IApiAvailableVersionResponse.js +0 -1
- package/lib/data/IApiBooleanResponse.js +0 -1
- package/lib/data/IApiCapacityAvailableBundle.js +0 -1
- package/lib/data/IApiCart.js +0 -7
- package/lib/data/IApiColumn.js +0 -1
- package/lib/data/IApiColumnPermission.js +0 -1
- package/lib/data/IApiCompany.js +0 -7
- package/lib/data/IApiContact.js +0 -7
- package/lib/data/IApiCurrencyExchangeRate.js +0 -7
- package/lib/data/IApiCustomizationStatsItem.js +0 -1
- package/lib/data/IApiDataResponse.js +0 -1
- package/lib/data/IApiDatumResponse.js +0 -1
- package/lib/data/IApiDocument.js +0 -7
- package/lib/data/IApiEmail.js +0 -7
- package/lib/data/IApiEnumType.js +0 -6
- package/lib/data/IApiEnumValue.js +0 -1
- package/lib/data/IApiEnumValuesRelation.js +0 -7
- package/lib/data/IApiFeature.js +0 -1
- package/lib/data/IApiFeaturesLicenseBundle.js +0 -1
- package/lib/data/IApiFlow.js +0 -7
- package/lib/data/IApiGlobalSetting.js +0 -1
- package/lib/data/IApiGoal.js +0 -7
- package/lib/data/IApiGood.js +0 -7
- package/lib/data/IApiGoodInCart.js +0 -7
- package/lib/data/IApiGroup.js +0 -1
- package/lib/data/IApiItemBase.js +0 -1
- package/lib/data/IApiItemIdentifier.js +0 -1
- package/lib/data/IApiItemUsageStatus.js +0 -1
- package/lib/data/IApiJournal.js +0 -7
- package/lib/data/IApiLead.js +0 -7
- package/lib/data/IApiLicense.js +0 -1
- package/lib/data/IApiLicenseBundleBase.js +0 -1
- package/lib/data/IApiLocalizedLicenseBundle.js +0 -1
- package/lib/data/IApiLoginResponse.js +0 -1
- package/lib/data/IApiMarketingCampaign.js +0 -7
- package/lib/data/IApiMarketingList.js +0 -7
- package/lib/data/IApiModulePermission.js +0 -1
- package/lib/data/IApiObjectType.js +0 -1
- package/lib/data/IApiPasswordStrength.js +0 -1
- package/lib/data/IApiPayment.js +0 -7
- package/lib/data/IApiProject.js +0 -7
- package/lib/data/IApiRecurrencePattern.js +0 -7
- package/lib/data/IApiResult.js +0 -1
- package/lib/data/IApiSaveResponse.js +0 -1
- package/lib/data/IApiTask.js +0 -7
- package/lib/data/IApiUser.js +0 -1
- package/lib/data/IApiUserSetting.js +0 -1
- package/lib/data/IApiWebServiceTaskStatus.js +0 -1
- package/lib/data/IApiWorkReport.js +0 -7
- package/lib/data/IApiWorkflowActionDerivedItem.js +0 -1
- package/lib/data/IApiWorkflowModel.js +0 -1
- package/lib/data/query/IApiQuery.js +0 -1
- package/lib/data/query/IApiQueryFilters.js +0 -1
- package/lib/data/workflowActions/IApiAction.js +0 -1
- package/lib/exceptions/HttpRequestError.js +0 -7
- package/lib/exceptions/WebServiceError.js +0 -7
- package/lib/helpers/ErrorHelper.js +0 -16
- package/lib/helpers/OAuthHelper.js +0 -52
- package/lib/helpers/VersionHelperBase.js +0 -16
- package/lib/interfaces/IEWJwtPayload.js +0 -1
- package/lib/interfaces/IItemPreview.js +0 -1
- package/lib/interfaces/ITokenData.js +0 -1
- package/lib/interfaces/ITranslatableString.js +0 -1
- package/lib/interfaces/TNumericValidatorType.js +0 -1
- package/lib/tokenizedServices/CommonDataConnection.js +0 -16
- package/lib/tokenizedServices/ITokenizedApiResult.js +0 -1
- package/lib/tokenizedServices/TokenizedServiceConnection.js +0 -124
- /package/lib/{AnonymousSessionHandler.d.ts → cjs/AnonymousSessionHandler.d.ts} +0 -0
- /package/lib/{ApiConnection.d.ts → cjs/ApiConnection.d.ts} +0 -0
- /package/lib/{ApiMethods.d.ts → cjs/ApiMethods.d.ts} +0 -0
- /package/lib/{CredentialsSessionHandler.d.ts → cjs/CredentialsSessionHandler.d.ts} +0 -0
- /package/lib/{HttpMethod.d.ts → cjs/HttpMethod.d.ts} +0 -0
- /package/lib/{ISessionHandler.d.ts → cjs/ISessionHandler.d.ts} +0 -0
- /package/lib/{OAuthSessionHandler.d.ts → cjs/OAuthSessionHandler.d.ts} +0 -0
- /package/lib/{OAuthSessionHandlerBase.d.ts → cjs/OAuthSessionHandlerBase.d.ts} +0 -0
- /package/lib/{ReturnCodes.d.ts → cjs/ReturnCodes.d.ts} +0 -0
- /package/lib/{constants → cjs/constants}/ActionEventTypes.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/ColumnPermissionRules.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/CompletionLevels.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/CustomizationStatsItemKeys.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/Edition.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/EnumTypes.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/ExpirationReason.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/Feature.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/FieldNames.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/FieldTypes.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/FolderNames.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/Functionality.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/GlobalSettingsNames.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/LicenseKeyInvoiceSeverity.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/LicenseRestrictionKeys.d.ts +0 -0
- /package/lib/{constants → cjs/constants}/RelationTypes.d.ts +0 -0
- /package/lib/{data → cjs/data}/EWItem.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiAdditionalField.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiAvailableBundle.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiAvailableVersionResponse.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiBooleanResponse.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiCapacityAvailableBundle.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiCart.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiColumn.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiColumnPermission.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiCompany.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiContact.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiCurrencyExchangeRate.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiCustomizationStatsItem.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiDataResponse.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiDatumResponse.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiDocument.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiEmail.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiEnumType.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiEnumValue.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiEnumValuesRelation.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiFeature.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiFeaturesLicenseBundle.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiFlow.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiGlobalSetting.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiGoal.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiGood.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiGoodInCart.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiGroup.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiItemBase.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiItemIdentifier.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiItemUsageStatus.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiJournal.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiLead.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiLicense.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiLicenseBundleBase.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiLocalizedLicenseBundle.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiLoginResponse.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiMarketingCampaign.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiMarketingList.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiModulePermission.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiObjectType.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiPasswordStrength.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiPayment.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiProject.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiRecurrencePattern.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiResult.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiSaveResponse.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiTask.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiUser.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiUserSetting.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiWebServiceTaskStatus.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiWorkReport.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiWorkflowActionDerivedItem.d.ts +0 -0
- /package/lib/{data → cjs/data}/IApiWorkflowModel.d.ts +0 -0
- /package/lib/{data → cjs/data}/query/IApiQuery.d.ts +0 -0
- /package/lib/{data → cjs/data}/query/IApiQueryFilters.d.ts +0 -0
- /package/lib/{data → cjs/data}/workflowActions/IApiAction.d.ts +0 -0
- /package/lib/{exceptions → cjs/exceptions}/HttpRequestError.d.ts +0 -0
- /package/lib/{exceptions → cjs/exceptions}/WebServiceError.d.ts +0 -0
- /package/lib/{helpers → cjs/helpers}/ErrorHelper.d.ts +0 -0
- /package/lib/{helpers → cjs/helpers}/OAuthHelper.d.ts +0 -0
- /package/lib/{helpers → cjs/helpers}/VersionHelperBase.d.ts +0 -0
- /package/lib/{interfaces → cjs/interfaces}/IEWJwtPayload.d.ts +0 -0
- /package/lib/{interfaces → cjs/interfaces}/IItemPreview.d.ts +0 -0
- /package/lib/{interfaces → cjs/interfaces}/ITokenData.d.ts +0 -0
- /package/lib/{interfaces → cjs/interfaces}/ITranslatableString.d.ts +0 -0
- /package/lib/{interfaces → cjs/interfaces}/TNumericValidatorType.d.ts +0 -0
- /package/lib/{tokenizedServices → cjs/tokenizedServices}/CommonDataConnection.d.ts +0 -0
- /package/lib/{tokenizedServices → cjs/tokenizedServices}/ITokenizedApiResult.d.ts +0 -0
- /package/lib/{tokenizedServices → cjs/tokenizedServices}/TokenizedServiceConnection.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eway-crm/connector",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.128",
|
|
4
4
|
"description": "eWay-CRM API JavaScript connector library.",
|
|
5
|
-
"main": "lib/index.js",
|
|
5
|
+
"main": "lib/cjs/index.js",
|
|
6
|
+
"module": "lib/esm/index.js",
|
|
6
7
|
"types": "lib/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
7
9
|
"scripts": {
|
|
8
10
|
"test": "jest --config jestconfig.json",
|
|
9
|
-
"build": "
|
|
11
|
+
"build": "rollup -c",
|
|
10
12
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
11
13
|
"lint": "eslint -c .eslintrc.json --ext .ts src",
|
|
12
14
|
"prepare": "npm run build",
|
|
@@ -41,7 +43,15 @@
|
|
|
41
43
|
"jest": "^29.5.0",
|
|
42
44
|
"prettier": "^2.8.8",
|
|
43
45
|
"ts-jest": "^29.1.0",
|
|
44
|
-
"typescript": "^5.0.4"
|
|
46
|
+
"typescript": "^5.0.4",
|
|
47
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
48
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
50
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
51
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
52
|
+
"rollup": "^3.19.1",
|
|
53
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
54
|
+
"rollup-plugin-dts": "^5.3.0"
|
|
45
55
|
},
|
|
46
56
|
"files": [
|
|
47
57
|
"lib/**/*"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export class AnonymousSessionHandler {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.getSessionId = (connection, callback) => {
|
|
4
|
-
throw new Error('With anonymous session handler, use only connection methods without session.');
|
|
5
|
-
};
|
|
6
|
-
this.invalidateSessionId = (sessionId, callback) => {
|
|
7
|
-
throw new Error('With anonymous session handler, use only connection methods without session.');
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
package/lib/ApiConnection.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import Axios from 'axios';
|
|
2
|
-
import { ReturnCodes } from './ReturnCodes';
|
|
3
|
-
import { HttpMethod } from './HttpMethod';
|
|
4
|
-
import { CredentialsSessionHandler } from './CredentialsSessionHandler';
|
|
5
|
-
import { AnonymousSessionHandler } from './AnonymousSessionHandler';
|
|
6
|
-
import { ApiMethods } from './ApiMethods';
|
|
7
|
-
import { OAuthSessionHandler } from './OAuthSessionHandler';
|
|
8
|
-
import { HttpRequestError } from './exceptions/HttpRequestError';
|
|
9
|
-
import * as base64url from 'universal-base64url';
|
|
10
|
-
import ErrorHelper from './helpers/ErrorHelper';
|
|
11
|
-
export class ApiConnection {
|
|
12
|
-
constructor(apiServiceUri, sessionHandler, errorCallback, supportGetItemPreviewMethod) {
|
|
13
|
-
this.createOpenLink = (folderName, guid, fileAs) => {
|
|
14
|
-
const ws = base64url.encode(this.baseUri);
|
|
15
|
-
let legacyLink = "eway://" + folderName;
|
|
16
|
-
if (guid) {
|
|
17
|
-
legacyLink += "/" + (guid === null || guid === void 0 ? void 0 : guid.toLowerCase());
|
|
18
|
-
}
|
|
19
|
-
legacyLink = base64url.encode(legacyLink);
|
|
20
|
-
let url = "https://open.eway-crm.com/?ws=" + ws + "&l=" + legacyLink;
|
|
21
|
-
if (fileAs) {
|
|
22
|
-
url += "&n=" + encodeURIComponent(fileAs);
|
|
23
|
-
}
|
|
24
|
-
return url;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Creates a promise for async file upload using binary stream
|
|
28
|
-
* @param itemGuid Item identificator. Ex. '9ac561be-9b7d-4938-8e55-4cce97142483'.
|
|
29
|
-
* @param fileName File name, ex. 'picture.img'.
|
|
30
|
-
* @param data Single file to be uploaded.
|
|
31
|
-
* @param config Optional. Additional config for the request.
|
|
32
|
-
* @param catchGlobally Optional. If true, raises this the global error handler each time the promise is rejected.
|
|
33
|
-
*/
|
|
34
|
-
this.askUploadMethod = (itemGuid, fileName, data, config, catchGlobally) => {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
const errClb = catchGlobally
|
|
37
|
-
? (e) => {
|
|
38
|
-
reject(e);
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
41
|
-
: reject;
|
|
42
|
-
this.callUploadMethod(itemGuid, fileName, data, resolve, errClb, errClb, config);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Asynchronously uploads file using binary stream
|
|
47
|
-
* @param itemGuid Item identificator. Ex. '9ac561be-9b7d-4938-8e55-4cce97142483'.
|
|
48
|
-
* @param fileName File name, ex. 'picture.img'.
|
|
49
|
-
* @param data Single file to be uploaded.
|
|
50
|
-
* @param successCallback Handler callback when the method executes well. Gets the whole response JSON object as the only argument.
|
|
51
|
-
* @param unsuccessCallback Optional. Handler callback for eWay-API app level failures. Gets the whole response JSON object as the only argument. If not supplied, the global error handler is used.
|
|
52
|
-
* @param errorCallback Optional. Handler callback for any other failures. If not supplied, the global error handler is used.
|
|
53
|
-
* @param config Optional. Additional config for the request.
|
|
54
|
-
*/
|
|
55
|
-
this.callUploadMethod = (itemGuid, fileName, data, successCallback, unsuccessCallback, errorCallback, config) => {
|
|
56
|
-
const noSessionCallback = () => {
|
|
57
|
-
this.sessionHandler.getSessionId(this, (newSessionId) => {
|
|
58
|
-
this.sessionId = newSessionId;
|
|
59
|
-
this.callUploadMethod(itemGuid, fileName, data, successCallback, unsuccessCallback, errorCallback, config);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
const sessionId = this.sessionId;
|
|
63
|
-
if (!sessionId) {
|
|
64
|
-
noSessionCallback();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const unsuccessClb = (result) => {
|
|
68
|
-
if (result.ReturnCode === ReturnCodes.rcBadSession) {
|
|
69
|
-
this.sessionId = null;
|
|
70
|
-
this.sessionHandler.invalidateSessionId(sessionId, noSessionCallback);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (unsuccessCallback) {
|
|
74
|
-
unsuccessCallback(result);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
const error = new Error('Unhandled connection return code ' + result.ReturnCode + ': ' + result.Description);
|
|
78
|
-
if (this.errorCallback) {
|
|
79
|
-
this.errorCallback(error);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const errorClb = (error) => {
|
|
87
|
-
let err = new Error('Unhandled connection error when calling ' + methodUrl + ': ' + ErrorHelper.stringifyError(error));
|
|
88
|
-
if ('statusCode' in error && error.statusCode === 413) {
|
|
89
|
-
err = new Error('The file has exceeded the maximum allowed file size for uploading. You can contact your IT administrator or eWay-CRM support if you would like to increase the limit.');
|
|
90
|
-
}
|
|
91
|
-
if (errorCallback) {
|
|
92
|
-
errorCallback(err);
|
|
93
|
-
}
|
|
94
|
-
else if (this.errorCallback) {
|
|
95
|
-
this.errorCallback(err);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const methodUrl = `${this.svcUri}/SaveBinaryAttachment?sessionId=${this.sessionId}&itemGuid=${itemGuid}&fileName=${encodeURIComponent(fileName)}`;
|
|
102
|
-
const promise = Axios.post(methodUrl, data, config);
|
|
103
|
-
ApiConnection.handleCallPromise(promise, successCallback, unsuccessClb, errorClb);
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Creates a promise for async API method call.
|
|
107
|
-
* @param methodName API method name. Ex. 'GetUsers'.
|
|
108
|
-
* @param data Input data or empty object. Ex. {transmitObject: {FileAs: 'Peter File'}} or {itemGuids: ['9ac561be-9b7d-4938-8e55-4cce97142483']}.
|
|
109
|
-
* @param httpMethod Optional. The used HTTP method. POST or GET. Default is POST.
|
|
110
|
-
* @param catchGlobally Optional. If true, raises this the global error handler each time the promise is rejected.
|
|
111
|
-
*/
|
|
112
|
-
this.askMethod = (methodName, data, httpMethod, catchGlobally) => {
|
|
113
|
-
return new Promise((resolve, reject) => {
|
|
114
|
-
const errClb = catchGlobally
|
|
115
|
-
? (e) => {
|
|
116
|
-
reject(e);
|
|
117
|
-
throw e;
|
|
118
|
-
}
|
|
119
|
-
: reject;
|
|
120
|
-
this.callMethod(methodName, data, resolve, errClb, httpMethod, errClb);
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Asynchronously calls API method with automatically added session data.
|
|
125
|
-
* @param methodName API method name. Ex. 'GetUsers'.
|
|
126
|
-
* @param data Input data or empty object. Ex. {transmitObject: {FileAs: 'Peter File'}} or {itemGuids: ['9ac561be-9b7d-4938-8e55-4cce97142483']}.
|
|
127
|
-
* @param successCallback Handler callback when the method executes well. Gets the whole response JSON object as the only argument.
|
|
128
|
-
* @param unsuccessCallback Optional. Handler callback for eWay-API app level failures. Gets the whole response JSON object as the only argument. If not supplied, the global error handler is used.
|
|
129
|
-
* @param httpMethod Optional. The used HTTP method. POST or GET. Default is POST.
|
|
130
|
-
* @param errorCallback Optional. Handler callback for any other failures. If not supplied, the global error handler is used.
|
|
131
|
-
*/
|
|
132
|
-
this.callMethod = (methodName, data, successCallback, unsuccessCallback, httpMethod, errorCallback) => {
|
|
133
|
-
if (!httpMethod) {
|
|
134
|
-
httpMethod = HttpMethod.post;
|
|
135
|
-
}
|
|
136
|
-
const noSessionCallback = () => {
|
|
137
|
-
this.sessionHandler.getSessionId(this, (newSessionId) => {
|
|
138
|
-
this.sessionId = newSessionId;
|
|
139
|
-
this.callMethod(methodName, data, successCallback, unsuccessCallback, httpMethod, errorCallback);
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
const sessionId = this.sessionId;
|
|
143
|
-
if (!sessionId) {
|
|
144
|
-
noSessionCallback();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
data.sessionId = sessionId;
|
|
148
|
-
const unsuccessClb = (result) => {
|
|
149
|
-
if (result.ReturnCode === ReturnCodes.rcBadSession) {
|
|
150
|
-
this.sessionId = null;
|
|
151
|
-
if (methodName !== ApiMethods.logOut) {
|
|
152
|
-
this.sessionHandler.invalidateSessionId(sessionId, noSessionCallback);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (unsuccessCallback) {
|
|
157
|
-
unsuccessCallback(result);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
const error = new Error('Unhandled connection return code ' + result.ReturnCode + ': ' + result.Description);
|
|
161
|
-
if (this.errorCallback) {
|
|
162
|
-
this.errorCallback(error, data);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
throw error;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
const successClb = methodName !== ApiMethods.logOut
|
|
170
|
-
? successCallback
|
|
171
|
-
: (result) => {
|
|
172
|
-
this.sessionId = null;
|
|
173
|
-
successCallback(result);
|
|
174
|
-
};
|
|
175
|
-
this.callWithoutSession(methodName, data, successClb, unsuccessClb, null, httpMethod, errorCallback);
|
|
176
|
-
};
|
|
177
|
-
this.callWithoutSession = (methodName, data, successCallback, unsuccessCallback, headers, httpMethod, errorCallback) => {
|
|
178
|
-
var _a;
|
|
179
|
-
if (!httpMethod) {
|
|
180
|
-
httpMethod = HttpMethod.post;
|
|
181
|
-
}
|
|
182
|
-
const methodUrl = this.svcUri + '/' + methodName;
|
|
183
|
-
let config;
|
|
184
|
-
if (!!headers) {
|
|
185
|
-
config = {
|
|
186
|
-
headers,
|
|
187
|
-
withCredentials: (_a = this.supportGetItemPreviewMethod) !== null && _a !== void 0 ? _a : methodName == ApiMethods.logIn
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
let promise;
|
|
191
|
-
switch (httpMethod) {
|
|
192
|
-
case HttpMethod.get:
|
|
193
|
-
if (data) {
|
|
194
|
-
throw new Error('Calling api get method with data specified does not make any sense.');
|
|
195
|
-
}
|
|
196
|
-
promise = Axios.get(methodUrl, config);
|
|
197
|
-
break;
|
|
198
|
-
case HttpMethod.post:
|
|
199
|
-
promise = Axios.post(methodUrl, data, config);
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
throw new Error(`Unknown http method '${httpMethod}'.`);
|
|
203
|
-
}
|
|
204
|
-
const errorClb = (error) => {
|
|
205
|
-
if (errorCallback) {
|
|
206
|
-
try {
|
|
207
|
-
errorCallback(error);
|
|
208
|
-
}
|
|
209
|
-
catch (e) {
|
|
210
|
-
if (this.errorCallback) {
|
|
211
|
-
this.errorCallback(e, data);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
throw e;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
const err = new Error('Unhandled connection error when calling ' + methodUrl + ': ' + ErrorHelper.stringifyError(error));
|
|
220
|
-
if (this.errorCallback) {
|
|
221
|
-
this.errorCallback(err, data);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
throw err;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
ApiConnection.handleCallPromise(promise, successCallback, unsuccessCallback, errorClb);
|
|
229
|
-
};
|
|
230
|
-
this.getItemPreviewGetMethodUrl = (folderName, itemGuid, itemVersion) => {
|
|
231
|
-
return this.svcUri + '/' + ApiMethods.getItemPreview + '?folderName=' + encodeURIComponent(folderName) + '&itemGuid=' + encodeURIComponent(itemGuid) + (!!itemVersion || itemVersion === 0 ? '&itemVersion=' + encodeURIComponent(itemVersion.toString()) : '');
|
|
232
|
-
};
|
|
233
|
-
this.getEmailAttachmentGetMethodUrl = (itemGuid, contentId) => {
|
|
234
|
-
return this.svcUri + '/' + ApiMethods.getEmailAttachment + '?itemGuid=' + encodeURIComponent(itemGuid) + '&contentId=' + encodeURIComponent(contentId);
|
|
235
|
-
};
|
|
236
|
-
this.getAllEmailAttachmentsZipGetMethodUrl = (itemGuid) => {
|
|
237
|
-
return this.svcUri + '/' + ApiMethods.getAllEmailAttachments + '?itemGuid=' + encodeURIComponent(itemGuid);
|
|
238
|
-
};
|
|
239
|
-
this.getActiveSessionId = () => {
|
|
240
|
-
return this.sessionId;
|
|
241
|
-
};
|
|
242
|
-
if (!apiServiceUri) {
|
|
243
|
-
throw new Error("The argument 'apiServiceUri' cannot be empty.");
|
|
244
|
-
}
|
|
245
|
-
if (apiServiceUri.length < 8 || (apiServiceUri.substr(0, 8).toLowerCase() !== 'https://' && apiServiceUri.substr(0, 7).toLowerCase() !== 'http://')) {
|
|
246
|
-
throw new Error("Api service uri must start either with 'https://' or with 'http://'.");
|
|
247
|
-
}
|
|
248
|
-
if (apiServiceUri.substr(apiServiceUri.length - 4).toLowerCase() === '.svc') {
|
|
249
|
-
this.svcUri = apiServiceUri;
|
|
250
|
-
const apiServiceOptions = ['/API.svc', '/InsecureAPI.svc', '/WcfService/Service.svc'];
|
|
251
|
-
const apiOption = apiServiceOptions.find((option) => option.toLowerCase() === apiServiceUri.substr(apiServiceUri.length - option.length).toLowerCase()) || '';
|
|
252
|
-
this.baseUri = apiServiceUri.substr(0, apiServiceUri.length - apiOption.length);
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
this.baseUri = apiServiceUri;
|
|
256
|
-
if (this.baseUri.substr(this.baseUri.length - 1) === '/') {
|
|
257
|
-
this.baseUri = this.baseUri.substr(0, this.baseUri.length - 1);
|
|
258
|
-
}
|
|
259
|
-
if (apiServiceUri.substr(0, 8).toLowerCase() === 'https://') {
|
|
260
|
-
this.svcUri = this.baseUri + '/API.svc';
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
this.svcUri = this.baseUri + '/InsecureAPI.svc';
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
this.sessionHandler = sessionHandler;
|
|
267
|
-
this.errorCallback = errorCallback;
|
|
268
|
-
this.sessionId = null;
|
|
269
|
-
this.supportGetItemPreviewMethod = supportGetItemPreviewMethod !== null && supportGetItemPreviewMethod !== void 0 ? supportGetItemPreviewMethod : false;
|
|
270
|
-
}
|
|
271
|
-
get supportsGetItemPreviewMethod() {
|
|
272
|
-
return this.supportGetItemPreviewMethod;
|
|
273
|
-
}
|
|
274
|
-
static create(apiServiceUri, username, passwordHash, appVersion, clientMachineIdentifier, clientMachineName, errorCallback, supportGetItemPreviewMethod) {
|
|
275
|
-
return new ApiConnection(apiServiceUri, new CredentialsSessionHandler(username, passwordHash, appVersion, clientMachineIdentifier, clientMachineName, errorCallback), errorCallback, supportGetItemPreviewMethod);
|
|
276
|
-
}
|
|
277
|
-
static createAnonymous(apiServiceUri, errorCallback) {
|
|
278
|
-
return new ApiConnection(apiServiceUri, new AnonymousSessionHandler(), errorCallback);
|
|
279
|
-
}
|
|
280
|
-
static createUsingOAuth(apiServiceUri, username, clientId, clientSecret, refreshToken, accessToken, appVersion, errorCallback, refreshTokenCallback, supportGetItemPreviewMethod) {
|
|
281
|
-
return new ApiConnection(apiServiceUri, new OAuthSessionHandler(username, clientId, clientSecret, refreshToken, accessToken, appVersion, errorCallback, refreshTokenCallback), errorCallback, supportGetItemPreviewMethod);
|
|
282
|
-
}
|
|
283
|
-
get wsUrl() {
|
|
284
|
-
return this.baseUri;
|
|
285
|
-
}
|
|
286
|
-
static handleCallPromise(call, successCallback, unsuccessCallback, errorCallback) {
|
|
287
|
-
call.then((response) => {
|
|
288
|
-
if (response.status === 200) {
|
|
289
|
-
if (response.data.ReturnCode === ReturnCodes.rcSuccess) {
|
|
290
|
-
successCallback(response.data);
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
unsuccessCallback(response.data);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
errorCallback(new HttpRequestError(response.status, response.statusText));
|
|
298
|
-
}
|
|
299
|
-
}).catch((error) => {
|
|
300
|
-
if (error.response) {
|
|
301
|
-
errorCallback(new HttpRequestError(error.response.status, error.response.statusText));
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
errorCallback(error);
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
package/lib/ApiMethods.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { FolderNames } from "./constants/FolderNames";
|
|
2
|
-
class ApiMethods {
|
|
3
|
-
}
|
|
4
|
-
ApiMethods.getAllEmailAttachments = 'GetAllEmailAttachments';
|
|
5
|
-
ApiMethods.getCalendarsByItemGuids = 'GetCalendarsByItemGuids';
|
|
6
|
-
ApiMethods.getEmailAttachment = 'GetEmailAttachment';
|
|
7
|
-
ApiMethods.getItemPreview = 'GetItemPreview';
|
|
8
|
-
ApiMethods.getJournalsByItemGuids = 'GetJournalsByItemGuids';
|
|
9
|
-
ApiMethods.getMarketingCampaignsByItemGuids = 'GetMarketingCampaignsByItemGuids';
|
|
10
|
-
ApiMethods.getMarketingListsRecordsByItemGuids = 'GetMarketingListsRecordsByItemGuids';
|
|
11
|
-
ApiMethods.getRevisionHistoryRecordsByItemGuids = 'GetRevisionHistoryRecordsByItemGuids';
|
|
12
|
-
ApiMethods.getVacationsByItemGuids = 'GetVacationsByItemGuids';
|
|
13
|
-
ApiMethods.getWorkflowHistoryRecordsByItemGuids = 'GetWorkflowHistoryRecordsByItemGuids';
|
|
14
|
-
ApiMethods.logIn = 'LogIn';
|
|
15
|
-
ApiMethods.logOut = 'LogOut';
|
|
16
|
-
ApiMethods.getGetFolderNameByItemGuidsMethodName = (folderName) => {
|
|
17
|
-
switch (folderName) {
|
|
18
|
-
case FolderNames.calendar:
|
|
19
|
-
return ApiMethods.getCalendarsByItemGuids;
|
|
20
|
-
case FolderNames.journal:
|
|
21
|
-
return ApiMethods.getJournalsByItemGuids;
|
|
22
|
-
case FolderNames.marketing:
|
|
23
|
-
return ApiMethods.getMarketingCampaignsByItemGuids;
|
|
24
|
-
case FolderNames.marketingList:
|
|
25
|
-
return ApiMethods.getMarketingListsRecordsByItemGuids;
|
|
26
|
-
case FolderNames.revisionsHistory:
|
|
27
|
-
return ApiMethods.getRevisionHistoryRecordsByItemGuids;
|
|
28
|
-
case FolderNames.vacation:
|
|
29
|
-
return ApiMethods.getVacationsByItemGuids;
|
|
30
|
-
case FolderNames.workflowHistory:
|
|
31
|
-
return ApiMethods.getWorkflowHistoryRecordsByItemGuids;
|
|
32
|
-
default:
|
|
33
|
-
return `Get${folderName}ByItemGuids`;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export { ApiMethods };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ApiMethods } from './ApiMethods';
|
|
2
|
-
export class CredentialsSessionHandler {
|
|
3
|
-
constructor(username, passwordHash, appVersion, clientMachineIdentifier, clientMachineName, errorCallback) {
|
|
4
|
-
this.invalidateSessionId = (_, callback) => {
|
|
5
|
-
// Nothing to invalidate.
|
|
6
|
-
if (callback) {
|
|
7
|
-
callback();
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
this.getSessionId = (connection, callback) => {
|
|
11
|
-
connection.callWithoutSession(ApiMethods.logIn, {
|
|
12
|
-
userName: this.username,
|
|
13
|
-
passwordHash: this.passwordHash,
|
|
14
|
-
appVersion: this.appVersion,
|
|
15
|
-
clientMachineIdentifier: this.clientMachineIdentifier,
|
|
16
|
-
clientMachineName: this.clientMachineName,
|
|
17
|
-
createSessionCookie: connection.supportsGetItemPreviewMethod
|
|
18
|
-
}, (result) => {
|
|
19
|
-
this.lastSuccessfulLoginResponse = result;
|
|
20
|
-
const newSessionId = result.SessionId;
|
|
21
|
-
if (!newSessionId) {
|
|
22
|
-
const error = new Error('Successful login but no session came.');
|
|
23
|
-
if (this.errorCallback) {
|
|
24
|
-
this.errorCallback(error);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (callback) {
|
|
32
|
-
callback(newSessionId);
|
|
33
|
-
}
|
|
34
|
-
}, (result) => {
|
|
35
|
-
const error = new Error('Unable to login. Error response follows.\n' + JSON.stringify(result));
|
|
36
|
-
if (this.errorCallback) {
|
|
37
|
-
this.errorCallback(error);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
if (!username || !passwordHash) {
|
|
45
|
-
throw new Error("Non of the arguments 'username', 'passwordHash' can be empty.");
|
|
46
|
-
}
|
|
47
|
-
this.username = username;
|
|
48
|
-
this.passwordHash = passwordHash;
|
|
49
|
-
this.appVersion = appVersion;
|
|
50
|
-
this.clientMachineIdentifier = clientMachineIdentifier;
|
|
51
|
-
this.clientMachineName = clientMachineName;
|
|
52
|
-
this.errorCallback = errorCallback;
|
|
53
|
-
}
|
|
54
|
-
}
|
package/lib/HttpMethod.js
DELETED
package/lib/IApiResult.js
DELETED
package/lib/ISessionHandler.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { OAuthHelper } from '.';
|
|
2
|
-
import { OAuthSessionHandlerBase } from './OAuthSessionHandlerBase';
|
|
3
|
-
export class OAuthSessionHandler extends OAuthSessionHandlerBase {
|
|
4
|
-
constructor(username, clientId, clientSecret, refreshToken, accessToken, appVersion, errorCallback, refreshTokenCallback) {
|
|
5
|
-
if (!username || !refreshToken || !clientId || !clientSecret) {
|
|
6
|
-
throw new Error("Non of the arguments 'username', 'clientId', 'clientSecret', 'refreshToken' can be empty.");
|
|
7
|
-
}
|
|
8
|
-
const getNewAccessToken = (connection, callback) => {
|
|
9
|
-
OAuthHelper.refreshToken(connection.wsUrl, this.clientId, this.clientSecret, this.refreshToken, (tokenData) => {
|
|
10
|
-
try {
|
|
11
|
-
if (this.refreshTokenCallback) {
|
|
12
|
-
this.refreshTokenCallback(tokenData);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
if (this.errorCallback) {
|
|
17
|
-
this.errorCallback(new Error('Refresh token callback failed.\n' + JSON.stringify(error)));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
callback(tokenData.access_token, tokenData.error);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
super(username, accessToken, appVersion, getNewAccessToken, errorCallback);
|
|
24
|
-
this.refreshToken = refreshToken;
|
|
25
|
-
this.clientId = clientId;
|
|
26
|
-
this.clientSecret = clientSecret;
|
|
27
|
-
this.refreshTokenCallback = refreshTokenCallback;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ApiMethods } from '.';
|
|
2
|
-
import { WebServiceError } from './exceptions/WebServiceError';
|
|
3
|
-
export class OAuthSessionHandlerBase {
|
|
4
|
-
constructor(username, accessToken, appVersion, getNewAccessTokenCallback, errorCallback) {
|
|
5
|
-
this.invalidateSessionId = (_, callback) => {
|
|
6
|
-
// Nothing to invalidate.
|
|
7
|
-
if (callback) {
|
|
8
|
-
callback();
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
this.getSessionId = (connection, callback) => {
|
|
12
|
-
const successCallbackHandler = (result) => {
|
|
13
|
-
this.lastSuccessfulLoginResponse = result;
|
|
14
|
-
const newSessionId = result.SessionId;
|
|
15
|
-
if (!newSessionId) {
|
|
16
|
-
const error = new Error('Successful login but no session came.');
|
|
17
|
-
if (this.errorCallback) {
|
|
18
|
-
this.errorCallback(error);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (callback) {
|
|
26
|
-
callback(newSessionId);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const unsuccessCallbackHandler = (result) => {
|
|
30
|
-
const error = new WebServiceError(result.ReturnCode, 'Unable to login. Error response follows.\n' + JSON.stringify(result));
|
|
31
|
-
if (this.errorCallback) {
|
|
32
|
-
this.errorCallback(error);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const errorCallbackHandler = (error) => {
|
|
39
|
-
if ((error === null || error === void 0 ? void 0 : error.statusCode) === 401) {
|
|
40
|
-
this.getNewAccessTokenCallback(connection, (accessToken, error) => {
|
|
41
|
-
this.accessToken = accessToken;
|
|
42
|
-
if (!error) {
|
|
43
|
-
this.getSessionId(connection, callback);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (!this.errorCallback)
|
|
49
|
-
throw error;
|
|
50
|
-
this.errorCallback(error);
|
|
51
|
-
};
|
|
52
|
-
const loginInputData = {
|
|
53
|
-
userName: this.username,
|
|
54
|
-
appVersion: this.appVersion,
|
|
55
|
-
createSessionCookie: connection.supportsGetItemPreviewMethod
|
|
56
|
-
};
|
|
57
|
-
const loginHeaders = {
|
|
58
|
-
'Authorization': 'Bearer ' + this.accessToken
|
|
59
|
-
};
|
|
60
|
-
connection.callWithoutSession(ApiMethods.logIn, loginInputData, successCallbackHandler, unsuccessCallbackHandler, loginHeaders, undefined, errorCallbackHandler);
|
|
61
|
-
};
|
|
62
|
-
if (!username) {
|
|
63
|
-
throw new Error("Non of the arguments 'username', 'clientId', 'clientSecret', 'refreshToken' can be empty.");
|
|
64
|
-
}
|
|
65
|
-
this.username = username;
|
|
66
|
-
this.accessToken = accessToken;
|
|
67
|
-
this.appVersion = appVersion;
|
|
68
|
-
this.getNewAccessTokenCallback = getNewAccessTokenCallback;
|
|
69
|
-
this.errorCallback = errorCallback;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export default OAuthSessionHandlerBase;
|
package/lib/ReturnCodes.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
class ReturnCodes {
|
|
2
|
-
}
|
|
3
|
-
ReturnCodes.rcSuccess = 'rcSuccess';
|
|
4
|
-
ReturnCodes.rcBadSession = 'rcBadSession';
|
|
5
|
-
ReturnCodes.rcDuplicateContact = 'rcDuplicateContact';
|
|
6
|
-
ReturnCodes.rcWebServiceMoved = 'rcWebServiceMoved';
|
|
7
|
-
ReturnCodes.rcAccessDenied = 'rcAccessDenied';
|
|
8
|
-
ReturnCodes.rcLoginUserNameChanged = 'rcLoginUserNameChanged';
|
|
9
|
-
ReturnCodes.rcLicenseExpired = 'rcLicenseExpired';
|
|
10
|
-
export { ReturnCodes };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
class ActionEventTypes {
|
|
2
|
-
}
|
|
3
|
-
ActionEventTypes.onValueChanging = 'OnValueChanging';
|
|
4
|
-
ActionEventTypes.onValueChanged = 'OnValueChanged';
|
|
5
|
-
ActionEventTypes.onSaving = 'OnSaving';
|
|
6
|
-
ActionEventTypes.onSaved = 'OnSaved';
|
|
7
|
-
ActionEventTypes.onLoad = 'OnLoad';
|
|
8
|
-
ActionEventTypes.onLoading = 'OnLoading';
|
|
9
|
-
export default ActionEventTypes;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
class ColumnPermissionPermissionRules {
|
|
2
|
-
}
|
|
3
|
-
ColumnPermissionPermissionRules.all = 'All';
|
|
4
|
-
ColumnPermissionPermissionRules.own = 'Own';
|
|
5
|
-
ColumnPermissionPermissionRules.readonly = 'Readonly';
|
|
6
|
-
ColumnPermissionPermissionRules.invisible = 'Invisible';
|
|
7
|
-
ColumnPermissionPermissionRules.none = 'None';
|
|
8
|
-
export { ColumnPermissionPermissionRules };
|
|
9
|
-
class ColumnPermissionMandatoryRules {
|
|
10
|
-
}
|
|
11
|
-
ColumnPermissionMandatoryRules.mandatory = 'Mandatory';
|
|
12
|
-
ColumnPermissionMandatoryRules.optional = 'Optional';
|
|
13
|
-
ColumnPermissionMandatoryRules.unique = 'Unique';
|
|
14
|
-
ColumnPermissionMandatoryRules.none = 'None';
|
|
15
|
-
export { ColumnPermissionMandatoryRules };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
class CustomizationStatsItemKeys {
|
|
2
|
-
}
|
|
3
|
-
CustomizationStatsItemKeys.customAdditionalFieldsCount = 'CustomAdditionalFieldsCount';
|
|
4
|
-
CustomizationStatsItemKeys.customEnabledAdvancedWorkflowsCount = 'CustomEnabledAdvancedWorkflowsCount';
|
|
5
|
-
CustomizationStatsItemKeys.customEnabledBasicWorkflowsCount = 'CustomEnabledBasicWorkflowsCount';
|
|
6
|
-
CustomizationStatsItemKeys.customMandatoryFieldsCount = 'CustomMandatoryFieldsCount';
|
|
7
|
-
CustomizationStatsItemKeys.customOptionalFieldsCount = 'CustomOptionalFieldsCount';
|
|
8
|
-
CustomizationStatsItemKeys.customReadonlyFieldsCount = 'CustomReadonlyFieldsCount';
|
|
9
|
-
CustomizationStatsItemKeys.customUniqueFieldsCount = 'CustomUniqueFieldsCount';
|
|
10
|
-
CustomizationStatsItemKeys.customVisibleTypesCount = 'CustomVisibleTypesCount';
|
|
11
|
-
CustomizationStatsItemKeys.visibleCurrenciesCount = 'VisibleCurrenciesCount';
|
|
12
|
-
export default CustomizationStatsItemKeys;
|