sfmc-sdk 2.0.0 → 2.1.0
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/.github/workflows/codeql-analysis.yml +3 -7
- package/.github/workflows/prvalidation.yml +10 -6
- package/.github/workflows/release.yml +4 -7
- package/.husky/commit-msg +1 -3
- package/.husky/post-checkout +34 -4
- package/.husky/pre-commit +3 -0
- package/.prettierrc +2 -1
- package/.vscode/settings.json +5 -2
- package/@types/auth.d.ts +46 -0
- package/@types/auth.d.ts.map +1 -0
- package/@types/index.d.ts +26 -0
- package/@types/index.d.ts.map +1 -0
- package/@types/rest.d.ts +100 -0
- package/@types/rest.d.ts.map +1 -0
- package/@types/soap.d.ts +112 -0
- package/@types/soap.d.ts.map +1 -0
- package/@types/util.d.ts +79 -0
- package/@types/util.d.ts.map +1 -0
- package/eslint.config.js +76 -0
- package/jsconfig.json +10 -1
- package/lib/auth.js +12 -4
- package/lib/index.js +2 -1
- package/lib/rest.js +28 -14
- package/lib/soap.js +29 -14
- package/lib/util.js +21 -3
- package/package.json +37 -23
- package/test/auth.test.js +10 -0
- package/test/rest.test.js +20 -0
- package/test/soap.test.js +20 -0
- package/tsconfig.json +21 -0
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -60
|
@@ -27,19 +27,15 @@ jobs:
|
|
|
27
27
|
fail-fast: false
|
|
28
28
|
matrix:
|
|
29
29
|
language: ['javascript']
|
|
30
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
|
31
|
-
# Learn more:
|
|
32
|
-
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
|
33
|
-
|
|
34
30
|
steps:
|
|
35
31
|
- name: Checkout repository
|
|
36
|
-
uses: actions/checkout@
|
|
32
|
+
uses: actions/checkout@v4
|
|
37
33
|
|
|
38
34
|
# Initializes the CodeQL tools for scanning.
|
|
39
35
|
- name: Initialize CodeQL
|
|
40
|
-
uses: github/codeql-action/init@
|
|
36
|
+
uses: github/codeql-action/init@v3
|
|
41
37
|
with:
|
|
42
38
|
languages: ${{ matrix.language }}
|
|
43
39
|
|
|
44
40
|
- name: Perform CodeQL Analysis
|
|
45
|
-
uses: github/codeql-action/analyze@
|
|
41
|
+
uses: github/codeql-action/analyze@v3
|
|
@@ -7,20 +7,24 @@ jobs:
|
|
|
7
7
|
pr-labeler:
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
9
|
steps:
|
|
10
|
-
- uses: TimonVS/pr-labeler-action@
|
|
10
|
+
- uses: TimonVS/pr-labeler-action@v5
|
|
11
11
|
with:
|
|
12
12
|
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
|
|
13
13
|
env:
|
|
14
14
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
15
|
+
|
|
15
16
|
test:
|
|
16
17
|
runs-on: ubuntu-latest
|
|
17
|
-
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
node: [18, 20, 22]
|
|
21
|
+
name: Run Tests with node ${{ matrix.node }}
|
|
18
22
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
20
|
-
-
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- name: Setup node
|
|
25
|
+
uses: actions/setup-node@v4
|
|
21
26
|
with:
|
|
22
|
-
node-version:
|
|
23
|
-
registry-url: https://registry.npmjs.org/
|
|
27
|
+
node-version: ${{ matrix.node }}
|
|
24
28
|
- run: npm install
|
|
25
29
|
- run: npm run lint
|
|
26
30
|
- run: npm run test
|
|
@@ -11,18 +11,15 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
13
|
# Drafts your next Release notes as Pull Requests are merged into "main"
|
|
14
|
-
- uses: release-drafter/release-drafter@
|
|
14
|
+
- uses: release-drafter/release-drafter@v6
|
|
15
15
|
id: create_release
|
|
16
16
|
env:
|
|
17
17
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
18
|
-
- uses: actions/checkout@
|
|
19
|
-
- uses: actions/setup-node@
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-node@v4
|
|
20
20
|
with:
|
|
21
|
-
node-version:
|
|
21
|
+
node-version: 22
|
|
22
22
|
registry-url: https://registry.npmjs.org/
|
|
23
|
-
- uses: HarmvZ/set-package-json-version-action@v0.2.5
|
|
24
|
-
with:
|
|
25
|
-
version: ${{ steps.create_release.outputs.tag_name }}
|
|
26
23
|
- run: npm i
|
|
27
24
|
- run: npm ci
|
|
28
25
|
- run: npm publish
|
package/.husky/commit-msg
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
. "$(dirname "$0")/_/husky.sh"
|
|
3
1
|
INPUT_FILE=$1
|
|
4
2
|
START_LINE=`head -n1 $INPUT_FILE`
|
|
5
|
-
PATTERN="^(#[[:digit:]]|Merge)"
|
|
3
|
+
PATTERN="^(#[[:digit:]]|Merge|Revert)"
|
|
6
4
|
|
|
7
5
|
if ! [[ "$START_LINE" =~ $PATTERN ]] ; then
|
|
8
6
|
echo "Bad commit message, see example: \"#431 commit message\", you provided: \"$START_LINE\""
|
package/.husky/post-checkout
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
# ### git commit message template ###
|
|
2
2
|
git config commit.template .git/templatemessage
|
|
3
|
-
TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '((feature|bug|bugfix|fix|hotfix|task|chore)\/)
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '^((feature|bug|bugfix|fix|hotfix|task|chore)\/)?\K\d{1,7}' || true`
|
|
4
|
+
if [ -z "$TICKETID" ]
|
|
5
|
+
then
|
|
6
|
+
TICKETID="0"
|
|
7
|
+
fi
|
|
8
|
+
TEMPLATE="#$TICKETID: "
|
|
9
|
+
echo "[POST_CHECKOUT] Setting template commit to '$TEMPLATE'"
|
|
10
|
+
# wrap $TEMPLATE in quotes or else it is trimmed automatically
|
|
11
|
+
echo "$TEMPLATE" > ".git/templatemessage"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# ### run npm install ###
|
|
15
|
+
echo "[POST-CHECKOUT] 📦 Checking for changes to dependencies"
|
|
16
|
+
# define how to split strings into array elements
|
|
17
|
+
IFS=$'\n'
|
|
18
|
+
# $1 is the new HEAD pointer
|
|
19
|
+
NEWHEAD=$1
|
|
20
|
+
# $2 is the previous HEAD pointer
|
|
21
|
+
OLDHEAD=$2
|
|
22
|
+
# extract all paths to package-lock.json files
|
|
23
|
+
PACKAGE_LOCK_REGEX="(^package-lock\.json)"
|
|
24
|
+
PACKAGES=$(git diff --name-only $NEWHEAD $OLDHEAD | grep -E $PACKAGE_LOCK_REGEX || true)
|
|
25
|
+
|
|
26
|
+
if [[ ${PACKAGES[@]} ]]; then
|
|
27
|
+
for package in $PACKAGES; do
|
|
28
|
+
echo "📦 $package was changed."
|
|
29
|
+
done
|
|
30
|
+
echo "📦 Running npm install to update your dependencies..."
|
|
31
|
+
npm install
|
|
32
|
+
npm run lint:fix
|
|
33
|
+
else
|
|
34
|
+
echo "📦 All packages up-to-date. No need to run npm install."
|
|
35
|
+
fi
|
package/.prettierrc
CHANGED
package/.vscode/settings.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"editor.formatOnSave": true,
|
|
3
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
4
|
-
|
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
4
|
+
"js/ts.implicitProjectConfig.checkJs": true,
|
|
5
|
+
"javascript.validate.enable": true,
|
|
6
|
+
"eslint.useESLintClass": true
|
|
7
|
+
}
|
package/@types/auth.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class which handles authentication logic
|
|
3
|
+
*/
|
|
4
|
+
export default class Auth {
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of Auth.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} authObject Auth Payload
|
|
9
|
+
* @param {string} authObject.client_id Client Id from SFMC config
|
|
10
|
+
* @param {string} authObject.client_secret Client Secret from SFMC config
|
|
11
|
+
* @param {number} authObject.account_id MID of Business Unit used for API Calls
|
|
12
|
+
* @param {string} authObject.auth_url Auth URL from SFMC config
|
|
13
|
+
* @param {string[]} [authObject.scope] Array of scopes used for requests
|
|
14
|
+
* @param {object} options options for the SDK as a whole, for example collection of handler functions, or retry settings
|
|
15
|
+
*/
|
|
16
|
+
constructor(authObject: {
|
|
17
|
+
client_id: string;
|
|
18
|
+
client_secret: string;
|
|
19
|
+
account_id: number;
|
|
20
|
+
auth_url: string;
|
|
21
|
+
scope?: string[];
|
|
22
|
+
}, options: object);
|
|
23
|
+
authObject: {
|
|
24
|
+
client_id: string;
|
|
25
|
+
client_secret: string;
|
|
26
|
+
account_id: number;
|
|
27
|
+
auth_url: string;
|
|
28
|
+
scope?: string[];
|
|
29
|
+
};
|
|
30
|
+
options: any;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @param {boolean} [forceRefresh] used to enforce a refresh of token
|
|
35
|
+
* @param {number} [remainingAttempts] number of retries in case of issues
|
|
36
|
+
* @returns {Promise.<object>} current session information
|
|
37
|
+
*/
|
|
38
|
+
getAccessToken(forceRefresh?: boolean, remainingAttempts?: number): Promise<object>;
|
|
39
|
+
/**
|
|
40
|
+
* Helper to get back list of scopes supported by SDK
|
|
41
|
+
*
|
|
42
|
+
* @returns {string[]} array of potential scopes
|
|
43
|
+
*/
|
|
44
|
+
getSupportedScopes(): string[];
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../lib/auth.js"],"names":[],"mappings":"AA0FA;;GAEG;AACH;IACI;;;;;;;;;;OAUG;IACH;QAP8B,SAAS,EAA5B,MAAM;QACa,aAAa,EAAhC,MAAM;QACa,UAAU,EAA7B,MAAM;QACa,QAAQ,EAA3B,MAAM;QACgB,KAAK,GAA3B,MAAM,EAAE;gBACR,MAAM,EA8ChB;IAFG;mBAjDO,MAAM;uBACN,MAAM;oBACN,MAAM;kBACN,MAAM;gBACN,MAAM,EAAE;MA6CmD;IAClE,aAAsB;IAE1B;;;;;;OAMG;IACH,8BAJW,OAAO,sBACP,MAAM,GACJ,QAAS,MAAM,CAAC,CA8B5B;IAED;;;;OAIG;IACH,sBAFa,MAAM,EAAE,CAIpB;CACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class main handler for the SDK
|
|
3
|
+
*/
|
|
4
|
+
export default class SDK {
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of SDK.
|
|
7
|
+
*
|
|
8
|
+
* @param {object} authObject Auth Object for making requests
|
|
9
|
+
* @param {object} [options] options for the SDK as a whole, for example collection of handler functions, or retry settings
|
|
10
|
+
* @param {number} [options.requestAttempts] number of retries which should be done, defaulted to 1
|
|
11
|
+
* @param {boolean} [options.retryOnConnectionError] should request be retried in case of connection issues
|
|
12
|
+
* @param {object} [options.eventHandlers] collection of functions which are executed on certain events
|
|
13
|
+
*/
|
|
14
|
+
constructor(authObject: object, options?: {
|
|
15
|
+
requestAttempts?: number;
|
|
16
|
+
retryOnConnectionError?: boolean;
|
|
17
|
+
eventHandlers?: object;
|
|
18
|
+
});
|
|
19
|
+
auth: Auth;
|
|
20
|
+
rest: Rest;
|
|
21
|
+
soap: Soap;
|
|
22
|
+
}
|
|
23
|
+
import Auth from './auth.js';
|
|
24
|
+
import Rest from './rest.js';
|
|
25
|
+
import Soap from './soap.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IACI;;;;;;;;OAQG;IACH,wBANW,MAAM;QAEW,eAAe,GAAhC,MAAM;QACY,sBAAsB,GAAxC,OAAO;QACU,aAAa,GAA9B,MAAM;OAehB;IAHG,WAAyC;IACzC,WAAwC;IACxC,WAAwC;CAE/C;iBA/BgB,WAAW;iBACX,WAAW;iBACX,WAAW"}
|
package/@types/rest.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class which handles rest endpoints
|
|
3
|
+
*/
|
|
4
|
+
export default class Rest {
|
|
5
|
+
/**
|
|
6
|
+
* Constuctor of Rest object
|
|
7
|
+
*
|
|
8
|
+
* @function Object() { [native code] }
|
|
9
|
+
* @param {object} authObject Auth object used for initializing
|
|
10
|
+
* @param {object} options options for the SDK as a whole, for example collection of handler functions, or retry settings
|
|
11
|
+
*/
|
|
12
|
+
constructor(authObject: object, options: object);
|
|
13
|
+
auth: any;
|
|
14
|
+
options: any;
|
|
15
|
+
transactionalApis: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Method that makes the GET API request
|
|
18
|
+
*
|
|
19
|
+
* @param {string} url of the resource to retrieve
|
|
20
|
+
* @returns {Promise.<object>} API response
|
|
21
|
+
*/
|
|
22
|
+
get(url: string): Promise<object>;
|
|
23
|
+
/**
|
|
24
|
+
* helper for {@link this.getBulk} to determine if the url is a transactional message API
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
* @param {string} url url without query params
|
|
28
|
+
* @returns {boolean} true if the url is a transactional message API
|
|
29
|
+
*/
|
|
30
|
+
private _isTransactionalMessageApi;
|
|
31
|
+
/**
|
|
32
|
+
* helper for {@link this.getBulk} to determine if the url is a legacy API
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
* @param {string} url url without query params
|
|
36
|
+
* @returns {boolean} true if the url is a legacy API
|
|
37
|
+
*/
|
|
38
|
+
private _isLegacyApi;
|
|
39
|
+
/**
|
|
40
|
+
* Method that makes paginated GET API Requests using $pageSize and $page parameters
|
|
41
|
+
*
|
|
42
|
+
* @param {string} url of the resource to retrieve
|
|
43
|
+
* @param {number} [pageSize] of the response, defaults to 50
|
|
44
|
+
* @param {string} [iteratorField] attribute of the response to iterate over (only required if it's not 'items'|'definitions'|'entry')
|
|
45
|
+
* @returns {Promise.<object>} API response combined items
|
|
46
|
+
*/
|
|
47
|
+
getBulk(url: string, pageSize?: number, iteratorField?: string): Promise<object>;
|
|
48
|
+
/**
|
|
49
|
+
* Method that makes a GET API request for each URL (including rate limiting)
|
|
50
|
+
*
|
|
51
|
+
* @param {string[]} urlArray of the resource to retrieve
|
|
52
|
+
* @param {number} [concurrentLimit] number of requests to execute at once
|
|
53
|
+
* @returns {Promise.<Array>} API response
|
|
54
|
+
*/
|
|
55
|
+
getCollection(urlArray: string[], concurrentLimit?: number): Promise<any[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Method that makes the POST api request
|
|
58
|
+
*
|
|
59
|
+
* @param {string} url of the resource to create
|
|
60
|
+
* @param {object} payload for the POST request body
|
|
61
|
+
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
|
|
62
|
+
* @returns {Promise.<object>} API response
|
|
63
|
+
*/
|
|
64
|
+
post(url: string, payload: object, headers?: object): Promise<object>;
|
|
65
|
+
/**
|
|
66
|
+
* Method that makes the PUT api request
|
|
67
|
+
*
|
|
68
|
+
* @param {string} url of the resource to replace
|
|
69
|
+
* @param {object} payload for the PUT request body
|
|
70
|
+
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
|
|
71
|
+
* @returns {Promise.<object>} API response
|
|
72
|
+
*/
|
|
73
|
+
put(url: string, payload: object, headers?: object): Promise<object>;
|
|
74
|
+
/**
|
|
75
|
+
* Method that makes the PATCH api request
|
|
76
|
+
*
|
|
77
|
+
* @param {string} url of the resource to update
|
|
78
|
+
* @param {object} payload for the PATCH request body
|
|
79
|
+
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
|
|
80
|
+
* @returns {Promise.<object>} API response
|
|
81
|
+
*/
|
|
82
|
+
patch(url: string, payload: object, headers?: object): Promise<object>;
|
|
83
|
+
/**
|
|
84
|
+
* Method that makes the DELETE api request
|
|
85
|
+
*
|
|
86
|
+
* @param {string} url of the resource to delete
|
|
87
|
+
* @returns {Promise.<object>} API response
|
|
88
|
+
*/
|
|
89
|
+
delete(url: string): Promise<object>;
|
|
90
|
+
/**
|
|
91
|
+
* Method that makes the api request
|
|
92
|
+
*
|
|
93
|
+
* @param {object} requestOptions configuration for the request including body
|
|
94
|
+
* @param {number} remainingAttempts number of times this request should be reattempted in case of error
|
|
95
|
+
* @param {object} [headers] optional headers to include in the request; note that Authorization-header is always overwritten
|
|
96
|
+
* @returns {Promise.<object>} Results from the Rest request in Object format
|
|
97
|
+
*/
|
|
98
|
+
_apiRequest(requestOptions: object, remainingAttempts: number, headers?: object): Promise<object>;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=rest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../lib/rest.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IACI;;;;;;OAMG;IACH,wBAHW,MAAM,WACN,MAAM,EAUhB;IAPG,UAAsB;IACtB,aAAsB;IACtB,4BAIC;IAGL;;;;;OAKG;IACH,SAHW,MAAM,GACJ,QAAS,MAAM,CAAC,CAU5B;IACD;;;;;;OAMG;IACH,mCAEC;IACD;;;;;;OAMG;IACH,qBAEC;IACD;;;;;;;OAOG;IACH,aALW,MAAM,aACN,MAAM,kBACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAmF5B;IACD;;;;;;OAMG;IACH,wBAJW,MAAM,EAAE,oBACR,MAAM,GACJ,cAAe,CAmB3B;IACD;;;;;;;OAOG;IACH,UALW,MAAM,WACN,MAAM,YACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAU5B;IACD;;;;;;;OAOG;IACH,SALW,MAAM,WACN,MAAM,YACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAU5B;IACD;;;;;;;OAOG;IACH,WALW,MAAM,WACN,MAAM,YACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAU5B;IACD;;;;;OAKG;IACH,YAHW,MAAM,GACJ,QAAS,MAAM,CAAC,CAW5B;IACD;;;;;;;OAOG;IACH,4BALW,MAAM,qBACN,MAAM,YACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAiD5B;CACJ"}
|
package/@types/soap.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class which handles SOAP endpoints
|
|
3
|
+
*/
|
|
4
|
+
export default class Soap {
|
|
5
|
+
/**
|
|
6
|
+
* Constuctor of Soap object
|
|
7
|
+
*
|
|
8
|
+
* @function Object() { [native code] }
|
|
9
|
+
* @param {object} auth Auth object used for initializing
|
|
10
|
+
* @param {object} options options for the SDK as a whole, for example collection of handler functions, or retry settings
|
|
11
|
+
*/
|
|
12
|
+
constructor(auth: object, options: object);
|
|
13
|
+
auth: any;
|
|
14
|
+
options: any;
|
|
15
|
+
/**
|
|
16
|
+
* Method used to retrieve data via SOAP API
|
|
17
|
+
*
|
|
18
|
+
* @param {string} type - SOAP Object type
|
|
19
|
+
* @param {string[]} propertiesList - Properties which should be retrieved
|
|
20
|
+
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
|
|
21
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
22
|
+
*/
|
|
23
|
+
retrieve(type: string, propertiesList: string[], requestParameters?: object): Promise<object>;
|
|
24
|
+
/**
|
|
25
|
+
* Method used to retrieve all data via SOAP API
|
|
26
|
+
*
|
|
27
|
+
* @param {string} type - SOAP Object type
|
|
28
|
+
* @param {string[]} propertiesList - Properties which should be retrieved
|
|
29
|
+
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
|
|
30
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
31
|
+
*/
|
|
32
|
+
retrieveBulk(type: string, propertiesList: string[], requestParameters?: object): Promise<object>;
|
|
33
|
+
/**
|
|
34
|
+
* Method used to create data via SOAP API
|
|
35
|
+
*
|
|
36
|
+
* @param {string} type - SOAP Object type
|
|
37
|
+
* @param {object} properties - Properties with values which should be created
|
|
38
|
+
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
|
|
39
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
40
|
+
*/
|
|
41
|
+
create(type: string, properties: object, requestParameters?: object): Promise<object>;
|
|
42
|
+
/**
|
|
43
|
+
* Method used to update data via SOAP API
|
|
44
|
+
*
|
|
45
|
+
* @param {string} type - SOAP Object type
|
|
46
|
+
* @param {object} properties - Properties with values which should be updated
|
|
47
|
+
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
|
|
48
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
49
|
+
*/
|
|
50
|
+
update(type: string, properties: object, requestParameters?: object): Promise<object>;
|
|
51
|
+
/**
|
|
52
|
+
* Method used to delete data via SOAP API
|
|
53
|
+
*
|
|
54
|
+
* @param {string} type - SOAP Object type
|
|
55
|
+
* @param {object} properties - Properties with values
|
|
56
|
+
* @param {object} [requestParameters] - additional RetrieveRequest parameters, for example filter or options
|
|
57
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
58
|
+
*/
|
|
59
|
+
delete(type: string, properties: object, requestParameters?: object): Promise<object>;
|
|
60
|
+
/**
|
|
61
|
+
* Method used to schedule data via SOAP API
|
|
62
|
+
*
|
|
63
|
+
* @param {string} type - SOAP Object type
|
|
64
|
+
* @param {object} schedule - object for what the schedule should be
|
|
65
|
+
* @param {Array | object} interactions - Object or array of interactions
|
|
66
|
+
* @param {string} action - type of schedule
|
|
67
|
+
* @param {object} [options] - additional options for the request
|
|
68
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
69
|
+
*/
|
|
70
|
+
schedule(type: string, schedule: object, interactions: any[] | object, action: string, options?: object): Promise<object>;
|
|
71
|
+
/**
|
|
72
|
+
* Method used to describe metadata via SOAP API
|
|
73
|
+
*
|
|
74
|
+
* @param {string} type - SOAP Object type
|
|
75
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
76
|
+
*/
|
|
77
|
+
describe(type: string): Promise<object>;
|
|
78
|
+
/**
|
|
79
|
+
* Method used to execute data via SOAP API
|
|
80
|
+
*
|
|
81
|
+
* @param {string} type - SOAP Object type
|
|
82
|
+
* @param {object} properties - Properties with values
|
|
83
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
84
|
+
*/
|
|
85
|
+
execute(type: string, properties: object): Promise<object>;
|
|
86
|
+
/**
|
|
87
|
+
* Method used to execute data via SOAP API
|
|
88
|
+
*
|
|
89
|
+
* @param {string} type - SOAP Object type
|
|
90
|
+
* @param {string} action - type of action, for example 'Start'
|
|
91
|
+
* @param {object} payload - relevant payload to perform, for example query Definition
|
|
92
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
93
|
+
*/
|
|
94
|
+
perform(type: string, action: string, payload: object): Promise<object>;
|
|
95
|
+
/**
|
|
96
|
+
* Method used to configure data via SOAP API
|
|
97
|
+
*
|
|
98
|
+
* @param {string} type - SOAP Object type
|
|
99
|
+
* @param {object[]} configArray - Properties which should be updated
|
|
100
|
+
* @returns {Promise.<object>} SOAP object converted from XML
|
|
101
|
+
*/
|
|
102
|
+
configure(type: string, configArray: object[]): Promise<object>;
|
|
103
|
+
/**
|
|
104
|
+
* Method that makes the api request
|
|
105
|
+
*
|
|
106
|
+
* @param {object} options configuration for the request including body
|
|
107
|
+
* @param {number} remainingAttempts number of times this request should be reattempted in case of error
|
|
108
|
+
* @returns {Promise.<object>} Results from the SOAP request in Object format
|
|
109
|
+
*/
|
|
110
|
+
_apiRequest(options: object, remainingAttempts: number): Promise<object>;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=soap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"soap.d.ts","sourceRoot":"","sources":["../lib/soap.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI;;;;;;OAMG;IACH,kBAHW,MAAM,WACN,MAAM,EAKhB;IAFG,UAAgB;IAChB,aAAsB;IAG1B;;;;;;;OAOG;IACH,eALW,MAAM,kBACN,MAAM,EAAE,sBACR,MAAM,GACJ,QAAS,MAAM,CAAC,CAsD5B;IACD;;;;;;;OAOG;IACH,mBALW,MAAM,kBACN,MAAM,EAAE,sBACR,MAAM,GACJ,QAAS,MAAM,CAAC,CAwB5B;IACD;;;;;;;OAOG;IACH,aALW,MAAM,cACN,MAAM,sBACN,MAAM,GACJ,QAAS,MAAM,CAAC,CA0B5B;IACD;;;;;;;OAOG;IACH,aALW,MAAM,cACN,MAAM,sBACN,MAAM,GACJ,QAAS,MAAM,CAAC,CA2B5B;IACD;;;;;;;OAOG;IACH,aALW,MAAM,cACN,MAAM,sBACN,MAAM,GACJ,QAAS,MAAM,CAAC,CA0B5B;IACD;;;;;;;;;OASG;IACH,eAPW,MAAM,YACN,MAAM,gBACN,QAAQ,MAAM,UACd,MAAM,YACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAiC5B;IACD;;;;;OAKG;IACH,eAHW,MAAM,GACJ,QAAS,MAAM,CAAC,CAuB5B;IACD;;;;;;OAMG;IACH,cAJW,MAAM,cACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAsB5B;IACD;;;;;;;OAOG;IACH,cALW,MAAM,UACN,MAAM,WACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAiC5B;IACD;;;;;;OAMG;IACH,gBAJW,MAAM,eACN,MAAM,EAAE,GACN,QAAS,MAAM,CAAC,CA4B5B;IAED;;;;;;OAMG;IACH,qBAJW,MAAM,qBACN,MAAM,GACJ,QAAS,MAAM,CAAC,CAsE5B;CACJ"}
|
package/@types/util.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method to check if Object passed is a simple object
|
|
3
|
+
*
|
|
4
|
+
* @param {object} object Object to check
|
|
5
|
+
* @returns {boolean} true if is simple Object
|
|
6
|
+
*/
|
|
7
|
+
export function isObject(object: object): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Method to check if Object passed is a valid payload for API calls
|
|
10
|
+
*
|
|
11
|
+
* @param {object} object Object to check
|
|
12
|
+
* @returns {boolean} true if is a valid payload
|
|
13
|
+
*/
|
|
14
|
+
export function isPayload(object: object): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Method to check if it is a connection error
|
|
17
|
+
*
|
|
18
|
+
* @param {string} code returned code from exception
|
|
19
|
+
* @returns {boolean} true if a connection error
|
|
20
|
+
*/
|
|
21
|
+
export function isConnectionError(code: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {object} EnhancedRestError - Error object
|
|
24
|
+
* @augments {Error}
|
|
25
|
+
* @property {object} response -
|
|
26
|
+
* @property {string} code -
|
|
27
|
+
* @property {string} endpoint -
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* CustomError type for handling REST (including Auth) based errors
|
|
31
|
+
*
|
|
32
|
+
* @class RestError
|
|
33
|
+
* @augments {Error}
|
|
34
|
+
*/
|
|
35
|
+
export class RestError extends Error {
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {EnhancedRestError} ex Error object
|
|
39
|
+
*/
|
|
40
|
+
constructor(ex: EnhancedRestError);
|
|
41
|
+
code: any;
|
|
42
|
+
endpoint: any;
|
|
43
|
+
response: any;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {object} EnhancedSoapError - Error object
|
|
47
|
+
* @augments {Error}
|
|
48
|
+
* @property {object} response -
|
|
49
|
+
* @property {string} code -
|
|
50
|
+
* @property {string} endpoint -
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* CustomError type for handling SOAP based errors
|
|
54
|
+
*
|
|
55
|
+
* @class SOAPError
|
|
56
|
+
* @augments {Error}
|
|
57
|
+
*/
|
|
58
|
+
export class SOAPError extends Error {
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {EnhancedSoapError} ex Error object
|
|
62
|
+
* @param {object} response api respone
|
|
63
|
+
* @param {object} soapBody soap body
|
|
64
|
+
*/
|
|
65
|
+
constructor(ex: EnhancedSoapError, response: object, soapBody: object);
|
|
66
|
+
code: any;
|
|
67
|
+
response: any;
|
|
68
|
+
json: any;
|
|
69
|
+
}
|
|
70
|
+
export const axiosInstance: import("axios").AxiosInstance;
|
|
71
|
+
/**
|
|
72
|
+
* - Error object
|
|
73
|
+
*/
|
|
74
|
+
export type EnhancedRestError = object;
|
|
75
|
+
/**
|
|
76
|
+
* - Error object
|
|
77
|
+
*/
|
|
78
|
+
export type EnhancedSoapError = object;
|
|
79
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../lib/util.js"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,iCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;GAKG;AACH,wCAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;GAMG;AACH;;;;;GAKG;AACH;IACI;;;OAGG;IACH,gBAFW,iBAAiB,EAwB3B;IAlBO,UAAiD;IAWjD,cAA2B;IAE/B,cAA2B;CAMlC;AACD;;;;;;GAMG;AACH;;;;;GAKG;AACH;IACI;;;;;OAKG;IACH,gBAJW,iBAAiB,YACjB,MAAM,YACN,MAAM,EAwChB;IAlCO,UAAkC;IA4BtC,cAAwB;IACxB,UAAoB;CAM3B;AAED,0DAA4C;;;;gCAtG/B,MAAM;;;;gCA0CN,MAAM"}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
2
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
3
|
+
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
4
|
+
import mochaPlugin from 'eslint-plugin-mocha';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
import js from '@eslint/js';
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
js.configs.recommended,
|
|
10
|
+
mochaPlugin.configs.flat.recommended,
|
|
11
|
+
jsdoc.configs['flat/recommended'],
|
|
12
|
+
eslintPluginUnicorn.configs['flat/recommended'],
|
|
13
|
+
{
|
|
14
|
+
files: ['**/*.js'],
|
|
15
|
+
plugins: {
|
|
16
|
+
jsdoc,
|
|
17
|
+
},
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2022,
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
globals: {
|
|
22
|
+
...globals.nodeBuiltin,
|
|
23
|
+
...globals.mocha,
|
|
24
|
+
Atomics: 'readonly',
|
|
25
|
+
SharedArrayBuffer: 'readonly',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
ignores: ['/node_modules/**'],
|
|
29
|
+
rules: {
|
|
30
|
+
'unicorn/prefer-module': 'off',
|
|
31
|
+
'unicorn/numeric-separators-style': 'off',
|
|
32
|
+
'jsdoc/check-line-alignment': 2,
|
|
33
|
+
'jsdoc/require-jsdoc': [
|
|
34
|
+
'warn',
|
|
35
|
+
{
|
|
36
|
+
require: {
|
|
37
|
+
FunctionDeclaration: true,
|
|
38
|
+
MethodDefinition: true,
|
|
39
|
+
ClassDeclaration: true,
|
|
40
|
+
ArrowFunctionExpression: false,
|
|
41
|
+
FunctionExpression: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
'jsdoc/require-param-type': 'error',
|
|
46
|
+
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
|
|
47
|
+
'jsdoc/no-undefined-types': 'error',
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
settings: {
|
|
51
|
+
jsdoc: {
|
|
52
|
+
mode: 'jsdoc',
|
|
53
|
+
preferredTypes: {
|
|
54
|
+
array: 'Array',
|
|
55
|
+
'array.<>': '[]',
|
|
56
|
+
'Array.<>': '[]',
|
|
57
|
+
'array<>': '[]',
|
|
58
|
+
'Array<>': '[]',
|
|
59
|
+
Object: 'object',
|
|
60
|
+
'object.<>': 'Object.<>',
|
|
61
|
+
'object<>': 'Object.<>',
|
|
62
|
+
'Object<>': 'Object.<>',
|
|
63
|
+
set: 'Set',
|
|
64
|
+
'set.<>': 'Set.<>',
|
|
65
|
+
'set<>': 'Set.<>',
|
|
66
|
+
'Set<>': 'Set.<>',
|
|
67
|
+
promise: 'Promise',
|
|
68
|
+
'promise.<>': 'Promise.<>',
|
|
69
|
+
'promise<>': 'Promise.<>',
|
|
70
|
+
'Promise<>': 'Promise.<>',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
eslintConfigPrettier,
|
|
76
|
+
];
|
package/jsconfig.json
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": ["lib/**/*.js"]
|
|
2
|
+
"include": ["lib/**/*.js", "test/**/*.js"],
|
|
3
|
+
"exclude": ["node_modules"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "nodenext",
|
|
7
|
+
"target": "es2022",
|
|
8
|
+
"checkJs": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"noEmit": true
|
|
11
|
+
}
|
|
3
12
|
}
|