@eway-crm/connector 1.0.264 → 1.0.266
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/README.md +72 -72
- package/lib/cjs/ApiConnection.d.ts +24 -3
- package/lib/cjs/ReturnCodes.d.ts +3 -0
- package/lib/cjs/constants/GlobalSettingsNames.d.ts +1 -0
- package/lib/cjs/constants/GroupNames.d.ts +7 -0
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +2 -2
- package/lib/esm/ApiConnection.d.ts +24 -3
- package/lib/esm/ReturnCodes.d.ts +3 -0
- package/lib/esm/constants/GlobalSettingsNames.d.ts +1 -0
- package/lib/esm/constants/GroupNames.d.ts +7 -0
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +2 -2
- package/lib/index.d.ts +36 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-

|
|
2
|
-
# eWay-CRM API
|
|
3
|
-
API used for communication with [eWay-CRM](http://www.eway-crm.com/) web service. This library is a wrapper over HTTP/S communication and sessions. See our [documentation](https://kb.eway-crm.com/documentation/6-add-ins/6-7-api-1) for more information.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
The simpliest way to start using this library is to get the [NPM Package](https://www.npmjs.com/package/@eway-crm/connector). To do that, just run this command in your NodeJS project's root dir:
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
npm i @eway-crm/connector
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
To get the best dev experience, we also recommend using [TypeScript](https://www.typescriptlang.org/) since this library contains the types headers.
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
This library wraps the communication with JSON API. For HTTP requests, it uses [Axios](https://github.com/axios/axios). To provide the most variability, it lets you input JSON data and fetch JSON data in the same structure as the server uses. The only thing you don't have to care about is the `sessionId`.
|
|
17
|
-
|
|
18
|
-
The actual usage is then the same as it would be for example with [PHP](https://github.com/rstefko/eway-crm-php-lib). See the [documentation](https://kb.eway-crm.com/documentation/6-add-ins/6-7-api-1) for more.
|
|
19
|
-
|
|
20
|
-
## Version Compatibility
|
|
21
|
-
|
|
22
|
-
This library is compatible with **eWay-CRM 6.0.1 and higher**. If you have got a lower version of your eWay-CRM, check the Updates section in the eWay-CRM Administration Application. If there is no update available, contact your eWay-CRM account manager or via other channel listed on our [web page](https://www.eway-crm.com/contact/).
|
|
23
|
-
|
|
24
|
-
## Establishing Connection
|
|
25
|
-
|
|
26
|
-
To communicate with eWay-CRM web service, we first have to establish connection. This must be done prior to every action we want to accomplish with use of the web service. To do that, we have to create new instance of ```ApiConnection``` with seven parameters:
|
|
27
|
-
1. Service url address (same as the one you use in Outlook)
|
|
28
|
-
2. Username
|
|
29
|
-
3. Password hash (md5 of the user's UTF8 password or hash created by the tool from eWay-CRM server component)
|
|
30
|
-
4. App version identifier (name and version of the connecting client app - must consist of alphabet string and digits at the end)
|
|
31
|
-
5. Client machine identifier (unique identifier of the connecting machine - MAC address for instance)
|
|
32
|
-
6. Client machine name (human readable client machine - PC name for instance)
|
|
33
|
-
7. Error handling callback (this callback is called everytime an unexpected error occurs)
|
|
34
|
-
|
|
35
|
-
```JS
|
|
36
|
-
import ApiConnection from '@eway-crm/connector';
|
|
37
|
-
|
|
38
|
-
const serviceUrl = 'https://free.eway-crm.com/31994';
|
|
39
|
-
const username = 'api';
|
|
40
|
-
const passwordHash = '470AE7216203E23E1983EF1851E72947';
|
|
41
|
-
|
|
42
|
-
const connection = ApiConnection.create(serviceUrl, username, passwordHash, 'JSSample1', '00:00:00:00:00', 'SampleTestMachine', (err) => console.error(err));
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
⚠️ The code above does not support [Microsoft Account Authenticaion](https://kb.eway-crm.com/documentation/2-installation/2-3-installation-the-server-part/adjust-eway-crm-web-service-for-azure-login-office-365?set_language=en). If you log into eWay-CRM with your Microsoft account, you need to implement your own OAuth2 client.
|
|
46
|
-
|
|
47
|
-
## CORS
|
|
48
|
-
|
|
49
|
-
If you are developing a web app running on a different host than your eWay-CRM web service, you need to configure your eWay-CRM web service to allow cross-origin requests. To achieve that, put the following setting into `appSettings` section of your web service's web.config file.
|
|
50
|
-
|
|
51
|
-
```XML
|
|
52
|
-
<add key="AccessControlAllowOrigin" value="https://YOUR-ORIGIN:PORT" />
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
⚠ If you add the setting above to your web.config, the web-based eWay-CRM Administration Center won't work in Internet Explorer, which will be a huge loss for the whole humankind.
|
|
56
|
-
|
|
57
|
-
## Using the Connection Object
|
|
58
|
-
|
|
59
|
-
Once having the `ApiConnection` instance, the API requests look like this searching of our user record.
|
|
60
|
-
|
|
61
|
-
```JS
|
|
62
|
-
connection.callMethod(
|
|
63
|
-
'SearchUsers',
|
|
64
|
-
{
|
|
65
|
-
transmitObject: { Username: username },
|
|
66
|
-
},
|
|
67
|
-
(result) => {
|
|
68
|
-
console.log('My user detail follows:');
|
|
69
|
-
console.log(result.Data[0]);
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
```
|
|
1
|
+

|
|
2
|
+
# eWay-CRM API
|
|
3
|
+
API used for communication with [eWay-CRM](http://www.eway-crm.com/) web service. This library is a wrapper over HTTP/S communication and sessions. See our [documentation](https://kb.eway-crm.com/documentation/6-add-ins/6-7-api-1) for more information.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
The simpliest way to start using this library is to get the [NPM Package](https://www.npmjs.com/package/@eway-crm/connector). To do that, just run this command in your NodeJS project's root dir:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
npm i @eway-crm/connector
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
To get the best dev experience, we also recommend using [TypeScript](https://www.typescriptlang.org/) since this library contains the types headers.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
This library wraps the communication with JSON API. For HTTP requests, it uses [Axios](https://github.com/axios/axios). To provide the most variability, it lets you input JSON data and fetch JSON data in the same structure as the server uses. The only thing you don't have to care about is the `sessionId`.
|
|
17
|
+
|
|
18
|
+
The actual usage is then the same as it would be for example with [PHP](https://github.com/rstefko/eway-crm-php-lib). See the [documentation](https://kb.eway-crm.com/documentation/6-add-ins/6-7-api-1) for more.
|
|
19
|
+
|
|
20
|
+
## Version Compatibility
|
|
21
|
+
|
|
22
|
+
This library is compatible with **eWay-CRM 6.0.1 and higher**. If you have got a lower version of your eWay-CRM, check the Updates section in the eWay-CRM Administration Application. If there is no update available, contact your eWay-CRM account manager or via other channel listed on our [web page](https://www.eway-crm.com/contact/).
|
|
23
|
+
|
|
24
|
+
## Establishing Connection
|
|
25
|
+
|
|
26
|
+
To communicate with eWay-CRM web service, we first have to establish connection. This must be done prior to every action we want to accomplish with use of the web service. To do that, we have to create new instance of ```ApiConnection``` with seven parameters:
|
|
27
|
+
1. Service url address (same as the one you use in Outlook)
|
|
28
|
+
2. Username
|
|
29
|
+
3. Password hash (md5 of the user's UTF8 password or hash created by the tool from eWay-CRM server component)
|
|
30
|
+
4. App version identifier (name and version of the connecting client app - must consist of alphabet string and digits at the end)
|
|
31
|
+
5. Client machine identifier (unique identifier of the connecting machine - MAC address for instance)
|
|
32
|
+
6. Client machine name (human readable client machine - PC name for instance)
|
|
33
|
+
7. Error handling callback (this callback is called everytime an unexpected error occurs)
|
|
34
|
+
|
|
35
|
+
```JS
|
|
36
|
+
import ApiConnection from '@eway-crm/connector';
|
|
37
|
+
|
|
38
|
+
const serviceUrl = 'https://free.eway-crm.com/31994';
|
|
39
|
+
const username = 'api';
|
|
40
|
+
const passwordHash = '470AE7216203E23E1983EF1851E72947';
|
|
41
|
+
|
|
42
|
+
const connection = ApiConnection.create(serviceUrl, username, passwordHash, 'JSSample1', '00:00:00:00:00', 'SampleTestMachine', (err) => console.error(err));
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
⚠️ The code above does not support [Microsoft Account Authenticaion](https://kb.eway-crm.com/documentation/2-installation/2-3-installation-the-server-part/adjust-eway-crm-web-service-for-azure-login-office-365?set_language=en). If you log into eWay-CRM with your Microsoft account, you need to implement your own OAuth2 client.
|
|
46
|
+
|
|
47
|
+
## CORS
|
|
48
|
+
|
|
49
|
+
If you are developing a web app running on a different host than your eWay-CRM web service, you need to configure your eWay-CRM web service to allow cross-origin requests. To achieve that, put the following setting into `appSettings` section of your web service's web.config file.
|
|
50
|
+
|
|
51
|
+
```XML
|
|
52
|
+
<add key="AccessControlAllowOrigin" value="https://YOUR-ORIGIN:PORT" />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
⚠ If you add the setting above to your web.config, the web-based eWay-CRM Administration Center won't work in Internet Explorer, which will be a huge loss for the whole humankind.
|
|
56
|
+
|
|
57
|
+
## Using the Connection Object
|
|
58
|
+
|
|
59
|
+
Once having the `ApiConnection` instance, the API requests look like this searching of our user record.
|
|
60
|
+
|
|
61
|
+
```JS
|
|
62
|
+
connection.callMethod(
|
|
63
|
+
'SearchUsers',
|
|
64
|
+
{
|
|
65
|
+
transmitObject: { Username: username },
|
|
66
|
+
},
|
|
67
|
+
(result) => {
|
|
68
|
+
console.log('My user detail follows:');
|
|
69
|
+
console.log(result.Data[0]);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
```
|
|
@@ -11,18 +11,31 @@ export interface ISessionHandler {
|
|
|
11
11
|
getSessionId(connection: ApiConnection, callback: (sessionId: string, loginResponse?: IApiLoginResponse) => void): void;
|
|
12
12
|
lastSuccessfulLoginResponse?: IApiLoginResponse;
|
|
13
13
|
}
|
|
14
|
+
/** Why a call failed - a result the eWay-API refused on the app level, or any other error. */
|
|
15
|
+
export type TCallFailure = TUnionError | IApiResult;
|
|
16
|
+
/**
|
|
17
|
+
* Notified of every failed ask or call method, so a consumer can react to failures of the connection as a whole.
|
|
18
|
+
* Left out: rcBadSession (recovered and repeated) and the token endpoint, which OAuthHelper posts on its own.
|
|
19
|
+
*/
|
|
20
|
+
export type TCallFailedCallback = (failure: TCallFailure, methodName: string) => void;
|
|
14
21
|
export declare class ApiConnection {
|
|
15
22
|
private readonly svcUri;
|
|
16
23
|
private readonly baseUri;
|
|
17
24
|
readonly sessionHandler: ISessionHandler;
|
|
18
25
|
private readonly errorCallback;
|
|
19
26
|
private readonly supportGetItemPreviewMethod;
|
|
27
|
+
private readonly callFailedCallback;
|
|
20
28
|
private sessionId;
|
|
21
|
-
constructor(apiServiceUri: string, sessionHandler: ISessionHandler, errorCallback?: (error: TUnionError, data?: TInputData | null) => void, supportGetItemPreviewMethod?: boolean);
|
|
29
|
+
constructor(apiServiceUri: string, sessionHandler: ISessionHandler, errorCallback?: (error: TUnionError, data?: TInputData | null) => void, supportGetItemPreviewMethod?: boolean, callFailedCallback?: TCallFailedCallback);
|
|
22
30
|
get supportsGetItemPreviewMethod(): boolean;
|
|
23
31
|
static create(apiServiceUri: string, username: string, passwordHash: string, appVersion: string, clientMachineIdentifier: string, clientMachineName: string, errorCallback?: (error: TUnionError) => void, supportGetItemPreviewMethod?: boolean): ApiConnection;
|
|
24
32
|
static createAnonymous(apiServiceUri: string, errorCallback?: (error: TUnionError) => void): ApiConnection;
|
|
25
|
-
static createUsingOAuth(apiServiceUri: string, username: string, clientId: string, clientSecret: string, refreshToken: string, accessToken: string, appVersion: string, errorCallback?: (error: TUnionError) => void, refreshTokenCallback?: (tokenData: ITokenData) => void, supportGetItemPreviewMethod?: boolean): ApiConnection;
|
|
33
|
+
static createUsingOAuth(apiServiceUri: string, username: string, clientId: string, clientSecret: string, refreshToken: string, accessToken: string, appVersion: string, errorCallback?: (error: TUnionError) => void, refreshTokenCallback?: (tokenData: ITokenData) => void, supportGetItemPreviewMethod?: boolean, callFailedCallback?: TCallFailedCallback): ApiConnection;
|
|
34
|
+
/**
|
|
35
|
+
* True when the failure means the web service has moved to another url. App level failures spell the code
|
|
36
|
+
* `ReturnCode`, errors spell it `returnCode`, so both are checked here instead of in every consumer.
|
|
37
|
+
*/
|
|
38
|
+
static isWebServiceMovedFailure(failure: unknown): boolean;
|
|
26
39
|
static normalizeWsUrl(wsUrl: string | null): string | null;
|
|
27
40
|
static isCloudUrl(wsUrl: string, allowDev: boolean): boolean;
|
|
28
41
|
static getRootDomain(hostname: string): string;
|
|
@@ -32,6 +45,10 @@ export declare class ApiConnection {
|
|
|
32
45
|
*/
|
|
33
46
|
readonly ensureLogin: () => Promise<void>;
|
|
34
47
|
readonly createOpenLink: (isDevEnvironment: boolean, folderName: TFolderName, guid?: string, fileAs?: string) => string;
|
|
48
|
+
/** Builds the rejection handler shared by the ask* methods. */
|
|
49
|
+
private readonly createAskRejectionHandler;
|
|
50
|
+
/** Announces a failed call. The callback only observes, so what it throws must not replace the failure itself. */
|
|
51
|
+
private readonly notifyCallFailed;
|
|
35
52
|
/**
|
|
36
53
|
* Creates a promise for async file upload using binary stream
|
|
37
54
|
* @param file Single file to be uploaded.
|
|
@@ -99,5 +116,9 @@ export declare class ApiConnection {
|
|
|
99
116
|
readonly getXsltTransformationDefinitionMethodUrl: (transformationGuid: string) => string;
|
|
100
117
|
readonly getActiveSessionId: () => string | null;
|
|
101
118
|
readonly setActiveSessionId: (sessionId: string | null) => void;
|
|
102
|
-
|
|
119
|
+
/**
|
|
120
|
+
* The single place every call of this connection ends in, ask* and call* alike, so callFailedCallback is
|
|
121
|
+
* announced from here to cover them all.
|
|
122
|
+
*/
|
|
123
|
+
private readonly handleCallPromise;
|
|
103
124
|
}
|
package/lib/cjs/ReturnCodes.d.ts
CHANGED
|
@@ -7,4 +7,7 @@ export declare class ReturnCodes {
|
|
|
7
7
|
static readonly rcLoginUserNameChanged = "rcLoginUserNameChanged";
|
|
8
8
|
static readonly rcLicenseExpired = "rcLicenseExpired";
|
|
9
9
|
static readonly rcBadAccessToken = "rcBadAccessToken";
|
|
10
|
+
static readonly rcExchangeWebServicesAccountAuthorizationRequired = "rcExchangeWebServicesAccountAuthorizationRequired";
|
|
11
|
+
static readonly rcGraphAuthorizationRequired = "rcGraphAuthorizationRequired";
|
|
12
|
+
static readonly rcConsentRequired = "rcConsentRequired";
|
|
10
13
|
}
|
|
@@ -49,6 +49,7 @@ declare class GlobalSettingsNames {
|
|
|
49
49
|
static readonly notifyAboutPaidInvoiceInPohodaGroup = "NotifyAboutPaidInvoiceInPohodaGroup";
|
|
50
50
|
static readonly notifyAboutProjectDeadline = "NotifyAboutProjectDeadline";
|
|
51
51
|
static readonly numberOfDecimalPlaces = "NumberOfDecimalPlaces";
|
|
52
|
+
static readonly openFileByDefault = "OpenFileByDefault";
|
|
52
53
|
static readonly phoneListTaskSolverGroup = "PhoneListTaskSolverGroup";
|
|
53
54
|
static readonly projectDeadlineAlert = "ProjectDeadlineAlert";
|
|
54
55
|
static readonly serverUpdateProgressNotificationGroup = "ServerUpdateProgressNotificationGroup";
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiConnection, ISessionHandler } from './ApiConnection';
|
|
1
|
+
import { ApiConnection, ISessionHandler, TCallFailedCallback, TCallFailure } from './ApiConnection';
|
|
2
2
|
import { HttpMethod } from './HttpMethod';
|
|
3
3
|
import { ReturnCodes } from './ReturnCodes';
|
|
4
4
|
import { ITokenizedApiResult } from './tokenizedServices/ITokenizedApiResult';
|
|
@@ -6,6 +6,7 @@ import { TokenizedServiceConnection } from './tokenizedServices/TokenizedService
|
|
|
6
6
|
import { CommonDataConnection } from './tokenizedServices/CommonDataConnection';
|
|
7
7
|
import { ApiMethods } from './ApiMethods';
|
|
8
8
|
import GlobalSettingsNames from './constants/GlobalSettingsNames';
|
|
9
|
+
import GroupNames from './constants/GroupNames';
|
|
9
10
|
import FieldNames from './constants/FieldNames';
|
|
10
11
|
import { FolderNames, TFolderName } from './constants/FolderNames';
|
|
11
12
|
import { OAuthHelper } from './helpers/OAuthHelper';
|
|
@@ -113,4 +114,4 @@ export * from './data/query/IApiQueryFilters';
|
|
|
113
114
|
export * from './constants/ImportResult';
|
|
114
115
|
export * from './interfaces/ITranslatableString';
|
|
115
116
|
export * from './interfaces/ITokenData';
|
|
116
|
-
export { OpenItemLinkHelper, ImportResult, SentimentTone, HttpMethod, ISessionHandler, ReturnCodes, ITokenizedApiResult, TokenizedServiceConnection, CommonDataConnection, ApiMethods, GlobalSettingsNames, FolderNames, TFolderName, OAuthHelper, HttpRequestError, TUnionError, TInputData, FieldNames, EnumTypes, RelationTypes, RelationTypeIds, TRelationType, ColumnPermissionPermissionRules, ColumnPermissionMandatoryRules, Edition, Feature, Functionality, CustomizationStatsItemKeys, LicenseRestrictionKeys, ExpirationReason, LicenseKeyInvoiceSeverity, ErrorHelper, VersionHelperBase, OAuthSessionHandlerBase, OAuthSessionHandler, FieldTypes, TFieldType, TNumericValidatorType, IApiEvent, IApiSetFieldValueAction, ObjectTypeIds, IApiHubItemsCountsQueryResponseItem, QueryHelper, QuerySources, IApiServiceAuthSettingsResponse, ApiConnection as ApiConnectionAsNonDefaultExport, IApiUnlinkInquiryResult, TApiUnlinkInquiryResultType, VersionHelper, Version, StringHelper, DateHelper, TransformItemFormats, EmailConversionSource, ApiFetchClient };
|
|
117
|
+
export { OpenItemLinkHelper, ImportResult, SentimentTone, HttpMethod, ISessionHandler, TCallFailure, TCallFailedCallback, ReturnCodes, ITokenizedApiResult, TokenizedServiceConnection, CommonDataConnection, ApiMethods, GlobalSettingsNames, GroupNames, FolderNames, TFolderName, OAuthHelper, HttpRequestError, TUnionError, TInputData, FieldNames, EnumTypes, RelationTypes, RelationTypeIds, TRelationType, ColumnPermissionPermissionRules, ColumnPermissionMandatoryRules, Edition, Feature, Functionality, CustomizationStatsItemKeys, LicenseRestrictionKeys, ExpirationReason, LicenseKeyInvoiceSeverity, ErrorHelper, VersionHelperBase, OAuthSessionHandlerBase, OAuthSessionHandler, FieldTypes, TFieldType, TNumericValidatorType, IApiEvent, IApiSetFieldValueAction, ObjectTypeIds, IApiHubItemsCountsQueryResponseItem, QueryHelper, QuerySources, IApiServiceAuthSettingsResponse, ApiConnection as ApiConnectionAsNonDefaultExport, IApiUnlinkInquiryResult, TApiUnlinkInquiryResultType, VersionHelper, Version, StringHelper, DateHelper, TransformItemFormats, EmailConversionSource, ApiFetchClient };
|