@kravc/dos 1.4.7 → 1.4.9

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": "@kravc/dos",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
@@ -25,10 +25,10 @@
25
25
  "author": "Alexander Kravets <a@kra.vc>",
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@kravc/schema": "^2.3.2",
28
+ "@kravc/schema": "^2.3.3",
29
29
  "cookie": "^0.4.1",
30
30
  "js-yaml": "^4.1.0",
31
- "jsonwebtoken": "^8.5.1",
31
+ "jsonwebtoken": "^9.0.0",
32
32
  "lodash.capitalize": "^4.2.1",
33
33
  "lodash.clonedeep": "^4.5.0",
34
34
  "lodash.compact": "^3.0.1",
package/src/Operation.js CHANGED
@@ -58,6 +58,12 @@ class Operation {
58
58
  description: 'Invalid operation input, make sure operation parameters' +
59
59
  ' do match specification'
60
60
  }
61
+
62
+ errors.InvalidParametersError = {
63
+ statusCode: 400,
64
+ description: 'Invalid operation parameters, input syntax is correct,' +
65
+ ' but input values are not processible'
66
+ }
61
67
  }
62
68
 
63
69
  if (this.outputSchema) {
@@ -68,6 +74,12 @@ class Operation {
68
74
  }
69
75
  }
70
76
 
77
+ errors.UnprocessibleConditionError = {
78
+ statusCode: 422,
79
+ description: 'Operation failed to process the request cause of expected' +
80
+ ' exit condition'
81
+ }
82
+
71
83
  return errors
72
84
  }
73
85
 
@@ -115,6 +115,21 @@ describe('Service', () => {
115
115
  expect(response.result.error.code).to.eql('InvalidInputError')
116
116
  })
117
117
 
118
+ it('returns "InvalidParametersError / 400" if invalid parameters', async () => {
119
+ class InvalidIndexProfiles extends IndexProfiles {
120
+ action() {
121
+ throw new errors.InvalidParametersError()
122
+ }
123
+ }
124
+
125
+ const modules = [ InvalidIndexProfiles ]
126
+ const service = new Service(modules)
127
+ const response = await test.execute(service)('InvalidIndexProfiles')
128
+
129
+ expect(response.statusCode).to.eql(400)
130
+ expect(response.result.error.code).to.eql('InvalidParametersError')
131
+ })
132
+
118
133
  it('returns "OperationNotFoundError / 404" if operation not found', async () => {
119
134
  const response = await exec('DestroyProfile', {}, { authorization })
120
135
 
@@ -122,14 +137,10 @@ describe('Service', () => {
122
137
  expect(response.result.error.code).to.eql('OperationNotFoundError')
123
138
  })
124
139
 
125
- it('returns "InvalidParametersError / 422" if invalid parameters', async () => {
140
+ it('returns "UnprocessibleConditionError / 422" if unprocessible condition', async () => {
126
141
  class InvalidIndexProfiles extends IndexProfiles {
127
- static get errors() {
128
- return { ...super.errors, InvalidParametersError: { statusCode: 422 } }
129
- }
130
-
131
142
  action() {
132
- throw new errors.InvalidParametersError()
143
+ throw new errors.UnprocessibleConditionError()
133
144
  }
134
145
  }
135
146
 
@@ -138,7 +149,7 @@ describe('Service', () => {
138
149
  const response = await test.execute(service)('InvalidIndexProfiles')
139
150
 
140
151
  expect(response.statusCode).to.eql(422)
141
- expect(response.result.error.code).to.eql('InvalidParametersError')
152
+ expect(response.result.error.code).to.eql('UnprocessibleConditionError')
142
153
  })
143
154
 
144
155
  it('returns "InvalidOutputError / 500" if invalid output, logs an error', async () => {
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const CommonError = require('./CommonError')
4
+
5
+ class UnprocessibleConditionError extends CommonError {
6
+ constructor(message = 'Invalid parameters') {
7
+ super('UnprocessibleConditionError', message)
8
+ }
9
+ }
10
+
11
+ module.exports = UnprocessibleConditionError
@@ -6,5 +6,6 @@ module.exports = {
6
6
  AccessDeniedError: require('./AccessDeniedError'),
7
7
  DocumentExistsError: require('./DocumentExistsError'),
8
8
  DocumentNotFoundError: require('./DocumentNotFoundError'),
9
- InvalidParametersError: require('./InvalidParametersError')
9
+ InvalidParametersError: require('./InvalidParametersError'),
10
+ UnprocessibleConditionError: require('./UnprocessibleConditionError')
10
11
  }