@basis-theory/basis-theory-reactor-formulas-sdk-js 1.3.1 → 1.4.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory/basis-theory-reactor-formulas-sdk-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Javascript SDK for building Basis Theory reactor formulas",
|
|
5
5
|
"repository": "https://github.com/Basis-Theory/basistheory-reactor-formulas-sdk-js",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"test": "jest --coverage --passWithNoTests"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@basis-theory/eslint-config": "^1.0.5",
|
|
23
22
|
"@commitlint/cli": "^12.1.1",
|
|
24
23
|
"@commitlint/config-conventional": "^12.1.1",
|
|
25
24
|
"@semantic-release/changelog": "^5.0.1",
|
|
@@ -30,6 +29,10 @@
|
|
|
30
29
|
"@semantic-release/release-notes-generator": "^9.0.1",
|
|
31
30
|
"chance": "^1.1.8",
|
|
32
31
|
"eslint": "^7.32.0",
|
|
32
|
+
"eslint-config-get-off-my-lawn": "^6.0.1",
|
|
33
|
+
"eslint-config-prettier": "^8.3.0",
|
|
34
|
+
"eslint-import-resolver-node": "^0.3.6",
|
|
35
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
33
36
|
"husky": "^5.1.1",
|
|
34
37
|
"jest": "^27.1.0",
|
|
35
38
|
"prettier": "^2.3.2",
|
|
@@ -6,6 +6,15 @@ const sanitizeErrors = (errors) => {
|
|
|
6
6
|
|
|
7
7
|
if (Array.isArray(errors)) {
|
|
8
8
|
sanitizedErrors['error'] = errors;
|
|
9
|
+
} else if (errors instanceof Error) {
|
|
10
|
+
if (errors.message) {
|
|
11
|
+
sanitizedErrors['error'] = [errors.message];
|
|
12
|
+
} else if (errors.name !== 'Error') {
|
|
13
|
+
// "Error" is not helpful as a message
|
|
14
|
+
sanitizedErrors['error'] = [errors.name];
|
|
15
|
+
} else {
|
|
16
|
+
sanitizedErrors['error'] = [fallbackErrorMessage];
|
|
17
|
+
}
|
|
9
18
|
} else if (typeof errors === 'object') {
|
|
10
19
|
for (const property in errors) {
|
|
11
20
|
if (Array.isArray(errors[property])) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CustomHttpResponseError extends Error {
|
|
2
|
+
constructor({ status, headers, body }) {
|
|
3
|
+
super();
|
|
4
|
+
this.name = 'CustomHttpResponseError';
|
|
5
|
+
|
|
6
|
+
const parsedStatus = Number.parseInt(status);
|
|
7
|
+
|
|
8
|
+
if (parsedStatus !== status || parsedStatus < 100 || parsedStatus > 599)
|
|
9
|
+
throw new Error('status is not a valid integer');
|
|
10
|
+
|
|
11
|
+
this.status = parsedStatus;
|
|
12
|
+
this.headers = headers ?? {};
|
|
13
|
+
this.body = body ?? {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toResponseBody() {
|
|
17
|
+
return {
|
|
18
|
+
status: this.status,
|
|
19
|
+
headers: this.headers,
|
|
20
|
+
body: this.body,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = CustomHttpResponseError;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const BasisTheoryReactorError = require('./BasisTheoryReactorError');
|
|
2
2
|
|
|
3
3
|
class InvalidReactorFormulaError extends BasisTheoryReactorError {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(errors) {
|
|
5
5
|
super({
|
|
6
|
-
message,
|
|
6
|
+
message: 'Invalid Reactor Formula',
|
|
7
7
|
status: 422,
|
|
8
|
+
errors,
|
|
8
9
|
});
|
|
9
10
|
this.name = 'InvalidReactorFormulaError';
|
|
10
11
|
}
|
package/src/errors/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const AuthenticationError = require('./AuthenticationError');
|
|
2
2
|
const AuthorizationError = require('./AuthorizationError');
|
|
3
3
|
const BadRequestError = require('./BadRequestError');
|
|
4
|
+
const CustomHttpResponseError = require('./CustomHttpResponseError');
|
|
4
5
|
const InvalidPaymentMethodError = require('./InvalidPaymentMethodError');
|
|
5
6
|
const InvalidReactorConfigurationError = require('./InvalidReactorConfigurationError');
|
|
6
7
|
const RateLimitError = require('./RateLimitError');
|
|
@@ -10,6 +11,7 @@ module.exports = {
|
|
|
10
11
|
AuthenticationError,
|
|
11
12
|
AuthorizationError,
|
|
12
13
|
BadRequestError,
|
|
14
|
+
CustomHttpResponseError,
|
|
13
15
|
InvalidPaymentMethodError,
|
|
14
16
|
InvalidReactorConfigurationError,
|
|
15
17
|
RateLimitError,
|