@kravc/dos 2.0.0-alpha.2 → 2.0.0-alpha.4
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/dist/Document/MemoryDocument.d.ts +4 -4
- package/dist/Document/MemoryDocument.d.ts.map +1 -1
- package/dist/Document/MemoryDocument.js +12 -7
- package/dist/Document/MemoryDocument.js.map +1 -1
- package/dist/Operation/Operation.js +2 -2
- package/dist/Operation/errors/{UnprocessibleConditionError.d.ts → UnprocessableConditionError.d.ts} +6 -6
- package/dist/Operation/errors/{UnprocessibleConditionError.d.ts.map → UnprocessableConditionError.d.ts.map} +1 -1
- package/dist/Operation/errors/{UnprocessibleConditionError.js → UnprocessableConditionError.js} +8 -8
- package/dist/Operation/errors/{UnprocessibleConditionError.js.map → UnprocessableConditionError.js.map} +1 -1
- package/dist/Operation/errors/index.d.ts +2 -2
- package/dist/Operation/errors/index.js +3 -3
- package/dist/Service/errors/OperationError.d.ts +2 -2
- package/dist/Service/errors/OperationError.d.ts.map +1 -1
- package/dist/Service/errors/OperationError.js.map +1 -1
- package/package.json +1 -1
- package/src/Document/MemoryDocument.ts +14 -8
- package/src/Operation/Operation.ts +2 -2
- package/src/Operation/errors/{UnprocessibleConditionError.ts → UnprocessableConditionError.ts} +7 -7
- package/src/Operation/errors/__tests__/UnprocessableConditionError.test.ts +20 -0
- package/src/Operation/errors/index.ts +2 -2
- package/src/Operation/operations/__tests__/Create.test.ts +1 -1
- package/src/Operation/operations/__tests__/Delete.test.ts +1 -1
- package/src/Operation/operations/__tests__/Index.test.ts +1 -1
- package/src/Operation/operations/__tests__/List.test.ts +1 -1
- package/src/Operation/operations/__tests__/Read.test.ts +1 -1
- package/src/Operation/operations/__tests__/Update.test.ts +1 -1
- package/src/Service/__tests__/Service.test.ts +1 -6
- package/src/Service/errors/OperationError.ts +2 -2
- package/src/Service/errors/OperationErrorAttributes.d.ts +1 -1
- package/src/Operation/errors/__tests__/UnprocessibleConditionError.test.ts +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Context, { type QueryMap, type MutationMap } from '../Context';
|
|
2
2
|
import Document, { type IndexOptions, type IndexAllOptions } from './Document';
|
|
3
3
|
type Item = {
|
|
4
4
|
id: string;
|
|
@@ -24,11 +24,11 @@ declare class MemoryDocument<T> extends Document<T> {
|
|
|
24
24
|
/** Implements interface to get a document. */
|
|
25
25
|
static _read<T>(query: QueryMap): Promise<T>;
|
|
26
26
|
/** Implements interface to save a document. */
|
|
27
|
-
static _create<T>(attributes: T): Promise<void>;
|
|
27
|
+
static _create<T>(attributes: T, _context: Context): Promise<void>;
|
|
28
28
|
/** Implements interface to update a document. */
|
|
29
|
-
static _update<T>(query: QueryMap, mutation: MutationMap): Promise<T>;
|
|
29
|
+
static _update<T>(query: QueryMap, mutation: MutationMap, _context: Context): Promise<T>;
|
|
30
30
|
/** Implements interface to delete a document. */
|
|
31
|
-
static _delete<T>(query: QueryMap): Promise<void>;
|
|
31
|
+
static _delete<T>(query: QueryMap, _context: Context): Promise<void>;
|
|
32
32
|
}
|
|
33
33
|
export default MemoryDocument;
|
|
34
34
|
//# sourceMappingURL=MemoryDocument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryDocument.d.ts","sourceRoot":"","sources":["../../src/Document/MemoryDocument.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"MemoryDocument.d.ts","sourceRoot":"","sources":["../../src/Document/MemoryDocument.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,EAAE,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAGtE,OAAO,QAAQ,EAAE,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/E,KAAK,IAAI,GAAG;IACV,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO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_STORE = {};
|
|
11
|
+
const QUERY_ERROR_TEMPLATE = 'Query parameter "$PATH" is required';
|
|
12
|
+
const ATTRIBUTE_ERROR_TEMPLATE = 'Attribute "$PATH" is required';
|
|
11
13
|
/** Example implementation of a document class stored in memory. */
|
|
12
14
|
class MemoryDocument extends Document_1.default {
|
|
13
15
|
/** Returns collection where documents are stored. */
|
|
@@ -67,7 +69,7 @@ class MemoryDocument extends Document_1.default {
|
|
|
67
69
|
}
|
|
68
70
|
/** Implements interface to get a document. */
|
|
69
71
|
static async _read(query) {
|
|
70
|
-
const idValue = (0, schema_1.got)(query, this.idKey,
|
|
72
|
+
const idValue = (0, schema_1.got)(query, this.idKey, QUERY_ERROR_TEMPLATE);
|
|
71
73
|
const item = (0, lodash_1.get)(this.collection, idValue);
|
|
72
74
|
if (!item) {
|
|
73
75
|
throw new Operation_1.DocumentNotFoundError(this, query);
|
|
@@ -75,8 +77,9 @@ class MemoryDocument extends Document_1.default {
|
|
|
75
77
|
return (0, lodash_1.cloneDeep)(item);
|
|
76
78
|
}
|
|
77
79
|
/** Implements interface to save a document. */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
81
|
+
static async _create(attributes, _context) {
|
|
82
|
+
const idValue = (0, schema_1.got)(attributes, this.idKey, ATTRIBUTE_ERROR_TEMPLATE);
|
|
80
83
|
const item = (0, lodash_1.get)(this.collection, idValue);
|
|
81
84
|
if (item) {
|
|
82
85
|
throw new Operation_1.DocumentExistsError(this, attributes);
|
|
@@ -84,16 +87,18 @@ class MemoryDocument extends Document_1.default {
|
|
|
84
87
|
(0, lodash_1.set)(this.collection, idValue, attributes);
|
|
85
88
|
}
|
|
86
89
|
/** Implements interface to update a document. */
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
+
static async _update(query, mutation, _context) {
|
|
92
|
+
const idValue = (0, schema_1.got)(query, this.idKey, QUERY_ERROR_TEMPLATE);
|
|
89
93
|
const componentTitle = this.getTitle();
|
|
90
94
|
const item = (0, schema_1.got)(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`);
|
|
91
95
|
(0, lodash_1.set)(this.collection, idValue, { ...item, ...mutation });
|
|
92
96
|
return (0, lodash_1.cloneDeep)({ ...item, ...mutation });
|
|
93
97
|
}
|
|
94
98
|
/** Implements interface to delete a document. */
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
100
|
+
static async _delete(query, _context) {
|
|
101
|
+
const idValue = (0, schema_1.got)(query, this.idKey, QUERY_ERROR_TEMPLATE);
|
|
97
102
|
const componentTitle = this.getTitle();
|
|
98
103
|
(0, schema_1.got)(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`);
|
|
99
104
|
(0, lodash_1.unset)(this.collection, idValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryDocument.js","sourceRoot":"","sources":["../../src/Document/MemoryDocument.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoC;AAEpC,mCAAmE;AACnE,4CAA0E;AAC1E,0DAA+E;AAO/E,MAAM,aAAa,GAAG,EAA0C,CAAC;AAEjE,mEAAmE;AACnE,MAAM,cAAkB,SAAQ,kBAAW;IACzC,qDAAqD;IACrD,MAAM,KAAK,UAAU;QACnB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC;QAEjC,MAAM,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAEtD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,aAAa,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;QACrC,CAAC;QAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC;IAED,yBAAyB;IACzB,MAAM,CAAC,KAAK,CAAC,KAAK;QAChB,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC;QAEjC,OAA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,CAAC,CAAC;QAExD,OAAO,IAAA,kBAAS,EAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,iDAAiD;IACjD,6DAA6D;IAC7D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAI,KAAe,EAAE,QAAiB;QACxD,MAAM,OAAO,GAAG,IAAA,YAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAW,CAAC;QAEvE,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAA,YAAG,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,cAAc,+BAA+B,CAAM,CAAC;QAErF,IAAA,cAAK,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;CACF;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -136,10 +136,10 @@ class Operation {
|
|
|
136
136
|
errors.InvalidParametersError = {
|
|
137
137
|
statusCode: 400,
|
|
138
138
|
description: 'Invalid operation parameters, input syntax is correct,' +
|
|
139
|
-
' but input values are not
|
|
139
|
+
' but input values are not processable'
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
errors.
|
|
142
|
+
errors.UnprocessableConditionError = {
|
|
143
143
|
statusCode: 422,
|
|
144
144
|
description: 'Operation failed to process the request cause of expected' +
|
|
145
145
|
' exit condition'
|
package/dist/Operation/errors/{UnprocessibleConditionError.d.ts → UnprocessableConditionError.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import CommonError from './CommonError';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Unprocessable Condition Error
|
|
4
4
|
*
|
|
5
|
-
* `
|
|
5
|
+
* `UnprocessableConditionError` represents a **422 Unprocessable Entity** error that occurs
|
|
6
6
|
* when an operation encounters an expected exit condition that prevents it from processing
|
|
7
7
|
* the request. This error indicates that the request is well-formed and valid, but the
|
|
8
8
|
* operation cannot proceed due to business logic constraints or state conditions.
|
|
@@ -21,9 +21,9 @@ import CommonError from './CommonError';
|
|
|
21
21
|
* The 422 status code indicates that the server understands the request but cannot process
|
|
22
22
|
* it due to semantic errors or business logic constraints.
|
|
23
23
|
*/
|
|
24
|
-
declare class
|
|
25
|
-
/** Creates an instance of
|
|
24
|
+
declare class UnprocessableConditionError extends CommonError {
|
|
25
|
+
/** Creates an instance of unprocessable condition error. */
|
|
26
26
|
constructor(message?: string);
|
|
27
27
|
}
|
|
28
|
-
export default
|
|
29
|
-
//# sourceMappingURL=
|
|
28
|
+
export default UnprocessableConditionError;
|
|
29
|
+
//# sourceMappingURL=UnprocessableConditionError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"UnprocessableConditionError.d.ts","sourceRoot":"","sources":["../../../src/Operation/errors/UnprocessableConditionError.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,cAAM,2BAA4B,SAAQ,WAAW;IACnD,4DAA4D;gBAChD,OAAO,GAAE,MAAkC;CAGxD;AAED,eAAe,2BAA2B,CAAC"}
|
package/dist/Operation/errors/{UnprocessibleConditionError.js → UnprocessableConditionError.js}
RENAMED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const CommonError_1 = __importDefault(require("./CommonError"));
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Unprocessable Condition Error
|
|
9
9
|
*
|
|
10
|
-
* `
|
|
10
|
+
* `UnprocessableConditionError` represents a **422 Unprocessable Entity** error that occurs
|
|
11
11
|
* when an operation encounters an expected exit condition that prevents it from processing
|
|
12
12
|
* the request. This error indicates that the request is well-formed and valid, but the
|
|
13
13
|
* operation cannot proceed due to business logic constraints or state conditions.
|
|
@@ -26,11 +26,11 @@ const CommonError_1 = __importDefault(require("./CommonError"));
|
|
|
26
26
|
* The 422 status code indicates that the server understands the request but cannot process
|
|
27
27
|
* it due to semantic errors or business logic constraints.
|
|
28
28
|
*/
|
|
29
|
-
class
|
|
30
|
-
/** Creates an instance of
|
|
31
|
-
constructor(message = '
|
|
32
|
-
super('
|
|
29
|
+
class UnprocessableConditionError extends CommonError_1.default {
|
|
30
|
+
/** Creates an instance of unprocessable condition error. */
|
|
31
|
+
constructor(message = 'Unprocessable condition') {
|
|
32
|
+
super('UnprocessableConditionError', message);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
exports.default =
|
|
36
|
-
//# sourceMappingURL=
|
|
35
|
+
exports.default = UnprocessableConditionError;
|
|
36
|
+
//# sourceMappingURL=UnprocessableConditionError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"UnprocessableConditionError.js","sourceRoot":"","sources":["../../../src/Operation/errors/UnprocessableConditionError.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,2BAA4B,SAAQ,qBAAW;IACnD,4DAA4D;IAC5D,YAAY,UAAkB,yBAAyB;QACrD,KAAK,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF;AAED,kBAAe,2BAA2B,CAAC"}
|
|
@@ -4,6 +4,6 @@ import AccessDeniedError from './AccessDeniedError';
|
|
|
4
4
|
import DocumentExistsError from './DocumentExistsError';
|
|
5
5
|
import DocumentNotFoundError from './DocumentNotFoundError';
|
|
6
6
|
import InvalidParametersError from './InvalidParametersError';
|
|
7
|
-
import
|
|
8
|
-
export { CommonError, UnauthorizedError, AccessDeniedError, DocumentExistsError, DocumentNotFoundError, InvalidParametersError,
|
|
7
|
+
import UnprocessableConditionError from './UnprocessableConditionError';
|
|
8
|
+
export { CommonError, UnauthorizedError, AccessDeniedError, DocumentExistsError, DocumentNotFoundError, InvalidParametersError, UnprocessableConditionError, };
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.UnprocessableConditionError = exports.InvalidParametersError = exports.DocumentNotFoundError = exports.DocumentExistsError = exports.AccessDeniedError = exports.UnauthorizedError = exports.CommonError = void 0;
|
|
7
7
|
const CommonError_1 = __importDefault(require("./CommonError"));
|
|
8
8
|
exports.CommonError = CommonError_1.default;
|
|
9
9
|
const UnauthorizedError_1 = __importDefault(require("./UnauthorizedError"));
|
|
@@ -16,6 +16,6 @@ const DocumentNotFoundError_1 = __importDefault(require("./DocumentNotFoundError
|
|
|
16
16
|
exports.DocumentNotFoundError = DocumentNotFoundError_1.default;
|
|
17
17
|
const InvalidParametersError_1 = __importDefault(require("./InvalidParametersError"));
|
|
18
18
|
exports.InvalidParametersError = InvalidParametersError_1.default;
|
|
19
|
-
const
|
|
20
|
-
exports.
|
|
19
|
+
const UnprocessableConditionError_1 = __importDefault(require("./UnprocessableConditionError"));
|
|
20
|
+
exports.UnprocessableConditionError = UnprocessableConditionError_1.default;
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Component from '../../Component';
|
|
2
2
|
import { Context } from '../../Context';
|
|
3
|
-
import {
|
|
3
|
+
import { OperationErrorAttributes } from './OperationErrorAttributes';
|
|
4
4
|
import { type OriginalError } from './logOperationError';
|
|
5
5
|
/**
|
|
6
6
|
* Operation Error
|
|
@@ -20,7 +20,7 @@ import { type OriginalError } from './logOperationError';
|
|
|
20
20
|
* This class acts as the final error handler in the operation processing pipeline,
|
|
21
21
|
* transforming any thrown error into a standardized, schema-validated response format.
|
|
22
22
|
*/
|
|
23
|
-
declare class OperationError extends Component<
|
|
23
|
+
declare class OperationError extends Component<OperationErrorAttributes> {
|
|
24
24
|
/** Returns schema of the operation error. */
|
|
25
25
|
static get schema(): import("@kravc/schema").Schema;
|
|
26
26
|
/** Creates instance of an operation error. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationError.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/OperationError.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OperationError.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/OperationError.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAA0B,EAAE,KAAK,aAAa,EAAwB,MAAM,qBAAqB,CAAC;AAOlG;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,cAAe,SAAQ,SAAS,CAAC,wBAAwB,CAAC;IAC9D,6CAA6C;IAC7C,MAAM,KAAK,MAAM,mCAEhB;IAED,8CAA8C;gBAClC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa;CAkC/E;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationError.js","sourceRoot":"","sources":["../../../src/Service/errors/OperationError.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,gEAAwC;AAExC,0CAAyC;AAEzC,4EAAkG;AAElG,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,sBAAsB,CAAC;AACrE,MAAM,oBAAoB,GAAG,IAAA,iBAAQ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AmB,CAAC;QAE1D,IAAI,cAAc,EAAE,CAAC;YACnB,IAAA,2BAAiB,EAAC,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AAED,kBAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { got } from '@kravc/schema';
|
|
2
|
-
import
|
|
2
|
+
import Context, { type QueryMap, type MutationMap } from '../Context';
|
|
3
3
|
import { get, set, last, unset, cloneDeep, sortBy } from 'lodash';
|
|
4
4
|
import { DocumentExistsError, DocumentNotFoundError } from '../Operation';
|
|
5
5
|
import Document, { type IndexOptions, type IndexAllOptions } from './Document';
|
|
@@ -11,6 +11,9 @@ type Item = {
|
|
|
11
11
|
|
|
12
12
|
const _MEMORY_STORE = {} as Record<string, Record<string, Item>>;
|
|
13
13
|
|
|
14
|
+
const QUERY_ERROR_TEMPLATE = 'Query parameter "$PATH" is required';
|
|
15
|
+
const ATTRIBUTE_ERROR_TEMPLATE = 'Attribute "$PATH" is required';
|
|
16
|
+
|
|
14
17
|
/** Example implementation of a document class stored in memory. */
|
|
15
18
|
class MemoryDocument<T> extends Document<T> {
|
|
16
19
|
/** Returns collection where documents are stored. */
|
|
@@ -102,7 +105,7 @@ class MemoryDocument<T> extends Document<T> {
|
|
|
102
105
|
|
|
103
106
|
/** Implements interface to get a document. */
|
|
104
107
|
static async _read<T>(query: QueryMap): Promise<T> {
|
|
105
|
-
const idValue = got(query, this.idKey,
|
|
108
|
+
const idValue = got(query, this.idKey, QUERY_ERROR_TEMPLATE) as string;
|
|
106
109
|
|
|
107
110
|
const item = get(this.collection, idValue) as T;
|
|
108
111
|
|
|
@@ -114,8 +117,9 @@ class MemoryDocument<T> extends Document<T> {
|
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
/** Implements interface to save a document. */
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
121
|
+
static async _create<T>(attributes: T, _context: Context): Promise<void> {
|
|
122
|
+
const idValue = got(attributes, this.idKey, ATTRIBUTE_ERROR_TEMPLATE) as string;
|
|
119
123
|
|
|
120
124
|
const item = get(this.collection, idValue) as T;
|
|
121
125
|
|
|
@@ -127,8 +131,9 @@ class MemoryDocument<T> extends Document<T> {
|
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
/** Implements interface to update a document. */
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
135
|
+
static async _update<T>(query: QueryMap, mutation: MutationMap, _context: Context): Promise<T> {
|
|
136
|
+
const idValue = got(query, this.idKey, QUERY_ERROR_TEMPLATE) as string;
|
|
132
137
|
|
|
133
138
|
const componentTitle = this.getTitle();
|
|
134
139
|
const item = got(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`) as T;
|
|
@@ -139,8 +144,9 @@ class MemoryDocument<T> extends Document<T> {
|
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
/** Implements interface to delete a document. */
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
148
|
+
static async _delete<T>(query: QueryMap, _context: Context): Promise<void> {
|
|
149
|
+
const idValue = got(query, this.idKey, QUERY_ERROR_TEMPLATE) as string;
|
|
144
150
|
|
|
145
151
|
const componentTitle = this.getTitle();
|
|
146
152
|
got(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`) as T;
|
|
@@ -184,11 +184,11 @@ class Operation {
|
|
|
184
184
|
errors.InvalidParametersError = {
|
|
185
185
|
statusCode: 400,
|
|
186
186
|
description: 'Invalid operation parameters, input syntax is correct,' +
|
|
187
|
-
' but input values are not
|
|
187
|
+
' but input values are not processable'
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
errors.
|
|
191
|
+
errors.UnprocessableConditionError = {
|
|
192
192
|
statusCode: 422,
|
|
193
193
|
description: 'Operation failed to process the request cause of expected' +
|
|
194
194
|
' exit condition'
|
package/src/Operation/errors/{UnprocessibleConditionError.ts → UnprocessableConditionError.ts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import CommonError from './CommonError';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Unprocessable Condition Error
|
|
5
5
|
*
|
|
6
|
-
* `
|
|
6
|
+
* `UnprocessableConditionError` represents a **422 Unprocessable Entity** error that occurs
|
|
7
7
|
* when an operation encounters an expected exit condition that prevents it from processing
|
|
8
8
|
* the request. This error indicates that the request is well-formed and valid, but the
|
|
9
9
|
* operation cannot proceed due to business logic constraints or state conditions.
|
|
@@ -22,11 +22,11 @@ import CommonError from './CommonError';
|
|
|
22
22
|
* The 422 status code indicates that the server understands the request but cannot process
|
|
23
23
|
* it due to semantic errors or business logic constraints.
|
|
24
24
|
*/
|
|
25
|
-
class
|
|
26
|
-
/** Creates an instance of
|
|
27
|
-
constructor(message: string = '
|
|
28
|
-
super('
|
|
25
|
+
class UnprocessableConditionError extends CommonError {
|
|
26
|
+
/** Creates an instance of unprocessable condition error. */
|
|
27
|
+
constructor(message: string = 'Unprocessable condition') {
|
|
28
|
+
super('UnprocessableConditionError', message);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export default
|
|
32
|
+
export default UnprocessableConditionError;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import UnprocessableConditionError from '../UnprocessableConditionError';
|
|
2
|
+
|
|
3
|
+
describe('UnprocessableConditionError', () => {
|
|
4
|
+
describe('UnprocessableConditionError.constructor(message)', () => {
|
|
5
|
+
it('creates an instance with default message when no message is provided', () => {
|
|
6
|
+
const err = new UnprocessableConditionError();
|
|
7
|
+
|
|
8
|
+
expect(err.code).toBe('UnprocessableConditionError');
|
|
9
|
+
expect(err.message).toBe('Unprocessable condition');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('creates an instance with custom message when provided', () => {
|
|
13
|
+
const customMessage = 'Order is already canceled';
|
|
14
|
+
const err = new UnprocessableConditionError(customMessage);
|
|
15
|
+
|
|
16
|
+
expect(err.code).toBe('UnprocessableConditionError');
|
|
17
|
+
expect(err.message).toBe(customMessage);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -4,7 +4,7 @@ import AccessDeniedError from './AccessDeniedError';
|
|
|
4
4
|
import DocumentExistsError from './DocumentExistsError';
|
|
5
5
|
import DocumentNotFoundError from './DocumentNotFoundError';
|
|
6
6
|
import InvalidParametersError from './InvalidParametersError';
|
|
7
|
-
import
|
|
7
|
+
import UnprocessableConditionError from './UnprocessableConditionError';
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
10
|
CommonError,
|
|
@@ -13,5 +13,5 @@ export {
|
|
|
13
13
|
DocumentExistsError,
|
|
14
14
|
DocumentNotFoundError,
|
|
15
15
|
InvalidParametersError,
|
|
16
|
-
|
|
16
|
+
UnprocessableConditionError,
|
|
17
17
|
};
|
|
@@ -100,7 +100,7 @@ describe('Create(Document, actionMethod)', () => {
|
|
|
100
100
|
const errorCodes = Object.keys(CreateProfile.errors);
|
|
101
101
|
expect(errorCodes).toContain('InvalidInputError');
|
|
102
102
|
expect(errorCodes).toContain('InvalidOutputError');
|
|
103
|
-
expect(errorCodes).toContain('
|
|
103
|
+
expect(errorCodes).toContain('UnprocessableConditionError');
|
|
104
104
|
expect(errorCodes).toContain('DocumentExistsError');
|
|
105
105
|
});
|
|
106
106
|
});
|
|
@@ -99,7 +99,7 @@ describe('Delete(Document, actionMethod)', () => {
|
|
|
99
99
|
it('includes related errors', () => {
|
|
100
100
|
const errorCodes = Object.keys(DeleteProfile.errors);
|
|
101
101
|
expect(errorCodes).toContain('InvalidInputError');
|
|
102
|
-
expect(errorCodes).toContain('
|
|
102
|
+
expect(errorCodes).toContain('UnprocessableConditionError');
|
|
103
103
|
expect(errorCodes).toContain('DocumentNotFoundError');
|
|
104
104
|
});
|
|
105
105
|
});
|
|
@@ -95,7 +95,7 @@ describe('Index(Document, actionMethod)', () => {
|
|
|
95
95
|
const errorCodes = Object.keys(IndexProfiles.errors);
|
|
96
96
|
expect(errorCodes).toContain('InvalidInputError');
|
|
97
97
|
expect(errorCodes).toContain('InvalidOutputError');
|
|
98
|
-
expect(errorCodes).toContain('
|
|
98
|
+
expect(errorCodes).toContain('UnprocessableConditionError');
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
|
|
@@ -93,7 +93,7 @@ describe('List(Document, actionMethod)', () => {
|
|
|
93
93
|
it('includes related errors', () => {
|
|
94
94
|
const errorCodes = Object.keys(ListProfiles.errors);
|
|
95
95
|
expect(errorCodes).toContain('InvalidOutputError');
|
|
96
|
-
expect(errorCodes).toContain('
|
|
96
|
+
expect(errorCodes).toContain('UnprocessableConditionError');
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
|
|
@@ -94,7 +94,7 @@ describe('Read(Document, actionMethod)', () => {
|
|
|
94
94
|
const errorCodes = Object.keys(ReadProfile.errors);
|
|
95
95
|
expect(errorCodes).toContain('InvalidInputError');
|
|
96
96
|
expect(errorCodes).toContain('InvalidOutputError');
|
|
97
|
-
expect(errorCodes).toContain('
|
|
97
|
+
expect(errorCodes).toContain('UnprocessableConditionError');
|
|
98
98
|
expect(errorCodes).toContain('DocumentNotFoundError');
|
|
99
99
|
});
|
|
100
100
|
});
|
|
@@ -100,7 +100,7 @@ describe('Update(Document, actionMethod)', () => {
|
|
|
100
100
|
const errorCodes = Object.keys(UpdateProfile.errors);
|
|
101
101
|
expect(errorCodes).toContain('InvalidInputError');
|
|
102
102
|
expect(errorCodes).toContain('InvalidOutputError');
|
|
103
|
-
expect(errorCodes).toContain('
|
|
103
|
+
expect(errorCodes).toContain('UnprocessableConditionError');
|
|
104
104
|
expect(errorCodes).toContain('DocumentNotFoundError');
|
|
105
105
|
});
|
|
106
106
|
});
|
|
@@ -178,12 +178,7 @@ describe('Service', () => {
|
|
|
178
178
|
|
|
179
179
|
const body = JSON.parse(json!);
|
|
180
180
|
|
|
181
|
-
expect(body).toEqual(
|
|
182
|
-
info: {
|
|
183
|
-
title: '@kravc/dos',
|
|
184
|
-
version: '2.0.0-alpha.2',
|
|
185
|
-
},
|
|
186
|
-
});
|
|
181
|
+
expect(body.info.title).toEqual('@kravc/dos');
|
|
187
182
|
});
|
|
188
183
|
|
|
189
184
|
it('returns composer file for /Enums.yaml path', async () => {
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import Component from '../../Component';
|
|
3
3
|
import { Context } from '../../Context';
|
|
4
4
|
import { loadSync } from '@kravc/schema';
|
|
5
|
-
import {
|
|
5
|
+
import { OperationErrorAttributes } from './OperationErrorAttributes';
|
|
6
6
|
import logOperationError, { type OriginalError, type ErrorAttributes } from './logOperationError';
|
|
7
7
|
|
|
8
8
|
const SCHEMA_PATH = path.resolve(__dirname) + '/OperationError.yaml';
|
|
@@ -28,7 +28,7 @@ const INTERNAL_ERROR_CODE = 500;
|
|
|
28
28
|
* This class acts as the final error handler in the operation processing pipeline,
|
|
29
29
|
* transforming any thrown error into a standardized, schema-validated response format.
|
|
30
30
|
*/
|
|
31
|
-
class OperationError extends Component<
|
|
31
|
+
class OperationError extends Component<OperationErrorAttributes> {
|
|
32
32
|
/** Returns schema of the operation error. */
|
|
33
33
|
static get schema() {
|
|
34
34
|
return operationErrorSchema;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import UnprocessibleConditionError from '../UnprocessibleConditionError';
|
|
2
|
-
|
|
3
|
-
describe('UnprocessibleConditionError', () => {
|
|
4
|
-
describe('UnprocessibleConditionError.constructor(message)', () => {
|
|
5
|
-
it('creates an instance with default message when no message is provided', () => {
|
|
6
|
-
const err = new UnprocessibleConditionError();
|
|
7
|
-
|
|
8
|
-
expect(err.code).toBe('UnprocessibleConditionError');
|
|
9
|
-
expect(err.message).toBe('Unprocessible condition');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('creates an instance with custom message when provided', () => {
|
|
13
|
-
const customMessage = 'Order is already cancelled';
|
|
14
|
-
const err = new UnprocessibleConditionError(customMessage);
|
|
15
|
-
|
|
16
|
-
expect(err.code).toBe('UnprocessibleConditionError');
|
|
17
|
-
expect(err.message).toBe(customMessage);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|