@kravc/dos 2.0.0-alpha.0 → 2.0.0-alpha.10

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.
Files changed (47) hide show
  1. package/dist/Document/Document.d.ts +12 -5
  2. package/dist/Document/Document.d.ts.map +1 -1
  3. package/dist/Document/Document.js +27 -10
  4. package/dist/Document/Document.js.map +1 -1
  5. package/dist/Document/MemoryDocument.d.ts +6 -5
  6. package/dist/Document/MemoryDocument.d.ts.map +1 -1
  7. package/dist/Document/MemoryDocument.js +14 -8
  8. package/dist/Document/MemoryDocument.js.map +1 -1
  9. package/dist/Document/index.d.ts +2 -2
  10. package/dist/Document/index.d.ts.map +1 -1
  11. package/dist/Document/index.js.map +1 -1
  12. package/dist/Operation/Operation.js +2 -2
  13. package/dist/Operation/errors/{UnprocessibleConditionError.d.ts → UnprocessableConditionError.d.ts} +6 -6
  14. package/dist/Operation/errors/{UnprocessibleConditionError.d.ts.map → UnprocessableConditionError.d.ts.map} +1 -1
  15. package/dist/Operation/errors/{UnprocessibleConditionError.js → UnprocessableConditionError.js} +8 -8
  16. package/dist/Operation/errors/{UnprocessibleConditionError.js.map → UnprocessableConditionError.js.map} +1 -1
  17. package/dist/Operation/errors/index.d.ts +2 -2
  18. package/dist/Operation/errors/index.js +3 -3
  19. package/dist/Operation/operations/Index.js +7 -7
  20. package/dist/Operation/operations/Index.js.map +1 -1
  21. package/dist/Operation/operations/List.js +2 -2
  22. package/dist/Operation/operations/List.js.map +1 -1
  23. package/dist/Service/errors/OperationError.d.ts +2 -2
  24. package/dist/Service/errors/OperationError.d.ts.map +1 -1
  25. package/dist/Service/errors/OperationError.js.map +1 -1
  26. package/dist/Service/errors/OperationError.yaml +29 -0
  27. package/package.json +8 -7
  28. package/src/Document/Document.ts +39 -15
  29. package/src/Document/MemoryDocument.ts +17 -9
  30. package/src/Document/__tests__/MemoryDocument.test.ts +16 -0
  31. package/src/Document/index.ts +2 -4
  32. package/src/Operation/Operation.ts +2 -2
  33. package/src/Operation/errors/{UnprocessibleConditionError.ts → UnprocessableConditionError.ts} +7 -7
  34. package/src/Operation/errors/__tests__/UnprocessableConditionError.test.ts +20 -0
  35. package/src/Operation/errors/index.ts +2 -2
  36. package/src/Operation/operations/Index.ts +8 -8
  37. package/src/Operation/operations/List.ts +2 -2
  38. package/src/Operation/operations/__tests__/Create.test.ts +1 -1
  39. package/src/Operation/operations/__tests__/Delete.test.ts +1 -1
  40. package/src/Operation/operations/__tests__/Index.test.ts +4 -4
  41. package/src/Operation/operations/__tests__/List.test.ts +1 -1
  42. package/src/Operation/operations/__tests__/Read.test.ts +1 -1
  43. package/src/Operation/operations/__tests__/Update.test.ts +1 -1
  44. package/src/Service/__tests__/Service.test.ts +1 -6
  45. package/src/Service/errors/OperationError.ts +2 -2
  46. package/src/Service/errors/OperationErrorAttributes.d.ts +1 -1
  47. package/src/Operation/errors/__tests__/UnprocessibleConditionError.test.ts +0 -20
@@ -0,0 +1,29 @@
1
+ error:
2
+ required: true
3
+
4
+ properties:
5
+ code:
6
+ required: true
7
+ description: Error code
8
+
9
+ message:
10
+ required: true
11
+ description: Error message
12
+
13
+ statusCode:
14
+ type: integer
15
+ required: true
16
+ description: HTTP error status code
17
+
18
+ validationErrors:
19
+ description: Validation errors
20
+ items:
21
+ properties:
22
+ code:
23
+ description: Validation error code
24
+
25
+ path:
26
+ description: Path of invalid attribute
27
+
28
+ message:
29
+ description: Validation error message
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.10",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
@@ -26,12 +26,13 @@
26
26
  "prebuild": "rimraf dist",
27
27
  "build": "tsc",
28
28
  "prepare": "npm run build",
29
- "prepublishOnly": "npm run build"
29
+ "prepublishOnly": "npm run build",
30
+ "postbuild": "cp -r src/Service/errors/*.yaml dist/Service/errors 2>/dev/null || true"
30
31
  },
31
32
  "author": "Alexander Kravets <a@kra.vc>",
32
33
  "license": "ISC",
33
34
  "dependencies": {
34
- "@kravc/schema": "^2.8.0-alpha.7",
35
+ "@kravc/schema": "^2.8.0-alpha.8",
35
36
  "@types/jsonwebtoken": "^9.0.10",
36
37
  "cookie": "^1.1.1",
37
38
  "jsonwebtoken": "^9.0.3",
@@ -49,14 +50,14 @@
49
50
  "@types/lodash": "^4.17.23",
50
51
  "@types/pluralize": "^0.0.33",
51
52
  "eslint": "^9.39.2",
52
- "eslint-plugin-jsdoc": "^62.4.1",
53
- "openapi-types": "^12.1.3",
53
+ "eslint-plugin-jsdoc": "^62.6.0",
54
54
  "globals": "^17.1.0",
55
55
  "jest": "^30.2.0",
56
- "rimraf": "^6.1.2",
56
+ "openapi-types": "^12.1.3",
57
+ "rimraf": "^6.1.3",
57
58
  "ts-jest": "^29.4.6",
58
59
  "ts-node": "^10.9.2",
59
60
  "typescript": "^5.9.3",
60
- "typescript-eslint": "^8.54.0"
61
+ "typescript-eslint": "^8.56.0"
61
62
  }
62
63
  }
@@ -5,23 +5,26 @@ import Context, { type QueryMap, type MutationMap } from '../Context';
5
5
  import { get, set, omit, pick, cloneDeep, capitalize } from 'lodash';
6
6
 
7
7
  const DEFAULT_INDEX_SORT = 'desc';
8
- const DEFAULT_INDEX_LIMIT = 300;
8
+ const DEFAULT_INDEX_LIMIT = 20;
9
+ const DEFAULT_INDEX_LIMIT_MAX = 100;
10
+
9
11
  const DEFAULT_PARTITION_KEY = 'partition';
10
12
 
11
13
  export type IndexOptions = {
12
14
  sort?: 'asc' | 'desc';
13
15
  limit?: number;
14
- index?: string;
16
+ indexName?: string;
15
17
  exclusiveStartKey?: string;
16
18
  }
17
19
 
18
20
  export type IndexAllOptions = {
19
21
  sort?: 'asc' | 'desc';
20
- index?: string;
22
+ indexName?: string;
21
23
  }
22
24
 
23
25
  export type DefaultAttributes = {
24
26
  id: string;
27
+ partition: string;
25
28
  createdAt: string;
26
29
  createdBy: string;
27
30
  createdByUserName?: string;
@@ -34,6 +37,7 @@ type Constructor<T, D extends Document<T> = Document<T>> = {
34
37
  new(context: Context, attributes: T): D;
35
38
 
36
39
  _index(query: QueryMap, options: IndexOptions): Promise<{
40
+ limit: number;
37
41
  count: number;
38
42
  items: T[];
39
43
  lastEvaluatedKey?: string;
@@ -46,11 +50,11 @@ type Constructor<T, D extends Document<T> = Document<T>> = {
46
50
 
47
51
  _read(query: QueryMap, options: unknown): Promise<T>;
48
52
 
49
- _create(attributes: T): Promise<void>;
53
+ _create(attributes: T, context?: Context): Promise<void>;
50
54
 
51
- _update<T>(query: QueryMap, mutation: MutationMap): Promise<T>;
55
+ _update<T>(query: QueryMap, mutation: MutationMap, context?: Context, previousAttributes?: T): Promise<T>;
52
56
 
53
- _delete(query: QueryMap): Promise<void>;
57
+ _delete(query: QueryMap, context?: Context, previousAttributes?: T): Promise<void>;
54
58
  };
55
59
 
56
60
  /** Abstract document class. */
@@ -84,6 +88,11 @@ class Document<Attributes> extends Component<Attributes> {
84
88
  return DEFAULT_INDEX_LIMIT;
85
89
  }
86
90
 
91
+ /** Defines limit maximum value for index action. */
92
+ static get indexLimitMax(): number {
93
+ return DEFAULT_INDEX_LIMIT_MAX;
94
+ }
95
+
87
96
  /** Generates ID for new document unless it's defined in parameters. */
88
97
  static createId(attributes: Record<string, unknown>): string {
89
98
  const id = get(attributes, this.idKey) as string;
@@ -196,6 +205,15 @@ class Document<Attributes> extends Component<Attributes> {
196
205
  mutation.updatedByUserName = context.identityName;
197
206
  }
198
207
 
208
+ /** Extends mutation with deleted stamps. */
209
+ static _extendWithDeletedStamps(context: Context, mutation: MutationMap) {
210
+ const timestamp = new Date().toJSON();
211
+
212
+ mutation.deletedAt = timestamp;
213
+ mutation.deletedBy = context.identityId;
214
+ mutation.deletedByUserName = context.identityName;
215
+ }
216
+
199
217
  /** Returns documents in batches. */
200
218
  static async index<T, D extends Document<T> = Document<T>>(
201
219
  this: Constructor<T, D>,
@@ -203,6 +221,7 @@ class Document<Attributes> extends Component<Attributes> {
203
221
  query: QueryMap = {},
204
222
  options: IndexOptions = {}
205
223
  ): Promise<{
224
+ limit: number;
206
225
  count: number;
207
226
  objects: D[];
208
227
  lastEvaluatedKey?: string;
@@ -218,10 +237,15 @@ class Document<Attributes> extends Component<Attributes> {
218
237
  options.sort = _this.indexDefaultSort;
219
238
  }
220
239
 
221
- const { items, count, lastEvaluatedKey, ...otherPagination } = await this._index(query, options);
240
+ const { count, limit, items, lastEvaluatedKey } = await this._index(query, options);
222
241
  const objects = items.map(attributes => new this(context, attributes));
223
242
 
224
- return { objects, count, lastEvaluatedKey, ...otherPagination };
243
+ return {
244
+ limit,
245
+ count,
246
+ objects,
247
+ lastEvaluatedKey,
248
+ };
225
249
  }
226
250
 
227
251
  /** Returns all documents. */
@@ -299,7 +323,7 @@ class Document<Attributes> extends Component<Attributes> {
299
323
 
300
324
  await _this.beforeCreate(context, query, attributes);
301
325
 
302
- await this._create(attributes as T);
326
+ await this._create(attributes as T, context);
303
327
  const object = new this(context, attributes as T);
304
328
 
305
329
  await _this.afterCreate(context, query, mutation, object);
@@ -349,7 +373,7 @@ class Document<Attributes> extends Component<Attributes> {
349
373
  previousAttributes = await this._read(query, {});
350
374
  }
351
375
 
352
- const updatedAttributes = await this._update(query, mutation) as T;
376
+ const updatedAttributes = await this._update(query, mutation, context, previousAttributes) as T;
353
377
  const object = new this(context, updatedAttributes);
354
378
 
355
379
  object._previousAttributes = previousAttributes;
@@ -383,14 +407,14 @@ class Document<Attributes> extends Component<Attributes> {
383
407
 
384
408
  await _this.beforeDelete(context, query);
385
409
 
386
- const attributes = await this._read(query, {});
387
- const object = new this(context, attributes);
410
+ const previousAttributes = await this._read(query, {});
388
411
 
389
- await this._delete(query);
412
+ await this._delete(query, context, previousAttributes);
390
413
 
391
- await _this.afterDelete(context, query, object);
414
+ const deletedObject = new this(context, previousAttributes);
415
+ await _this.afterDelete(context, query, deletedObject);
392
416
 
393
- return object;
417
+ return deletedObject;
394
418
  }
395
419
 
396
420
  /** Before delete hook. */
@@ -1,5 +1,5 @@
1
1
  import { got } from '@kravc/schema';
2
- import type { QueryMap, MutationMap } from '../Context';
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. */
@@ -35,6 +38,7 @@ class MemoryDocument<T> extends Document<T> {
35
38
 
36
39
  /** Implements interface to get documents in batches. */
37
40
  static async _index<T>(query: QueryMap, options: IndexOptions): Promise<{
41
+ limit: number;
38
42
  count: number;
39
43
  items: T[];
40
44
  lastEvaluatedKey?: string;
@@ -81,6 +85,7 @@ class MemoryDocument<T> extends Document<T> {
81
85
  }
82
86
 
83
87
  return {
88
+ limit: limit || count,
84
89
  items,
85
90
  count,
86
91
  lastEvaluatedKey,
@@ -102,7 +107,7 @@ class MemoryDocument<T> extends Document<T> {
102
107
 
103
108
  /** Implements interface to get a document. */
104
109
  static async _read<T>(query: QueryMap): Promise<T> {
105
- const idValue = got(query, this.idKey, 'Query parameter "$PATH" is required') as string;
110
+ const idValue = got(query, this.idKey, QUERY_ERROR_TEMPLATE) as string;
106
111
 
107
112
  const item = get(this.collection, idValue) as T;
108
113
 
@@ -113,9 +118,10 @@ class MemoryDocument<T> extends Document<T> {
113
118
  return cloneDeep(item);
114
119
  }
115
120
 
116
- /** Implements interface to save a document, returns false if document is not created. */
117
- static async _create<T>(attributes: T): Promise<void> {
118
- const idValue = got(attributes, this.idKey, 'Attribute "$PATH" is required') as string;
121
+ /** Implements interface to save a document. */
122
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
123
+ static async _create<T>(attributes: T, _context: Context): Promise<void> {
124
+ const idValue = got(attributes, this.idKey, ATTRIBUTE_ERROR_TEMPLATE) as string;
119
125
 
120
126
  const item = get(this.collection, idValue) as T;
121
127
 
@@ -127,8 +133,9 @@ class MemoryDocument<T> extends Document<T> {
127
133
  }
128
134
 
129
135
  /** Implements interface to update a document. */
130
- static async _update<T>(query: QueryMap, mutation: MutationMap): Promise<T> {
131
- const idValue = got(query, this.idKey, 'Query parameter "$PATH" is required') as string;
136
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
137
+ static async _update<T>(query: QueryMap, mutation: MutationMap, _context: Context, _previousAttributes: T): Promise<T> {
138
+ const idValue = got(query, this.idKey, QUERY_ERROR_TEMPLATE) as string;
132
139
 
133
140
  const componentTitle = this.getTitle();
134
141
  const item = got(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`) as T;
@@ -139,8 +146,9 @@ class MemoryDocument<T> extends Document<T> {
139
146
  }
140
147
 
141
148
  /** Implements interface to delete a document. */
142
- static async _delete<T>(query: QueryMap): Promise<void> {
143
- const idValue = got(query, this.idKey, 'Query parameter "$PATH" is required') as string;
149
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
150
+ static async _delete<T>(query: QueryMap, _context: Context, _previousAttributes: T): Promise<void> {
151
+ const idValue = got(query, this.idKey, QUERY_ERROR_TEMPLATE) as string;
144
152
 
145
153
  const componentTitle = this.getTitle();
146
154
  got(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`) as T;
@@ -53,6 +53,22 @@ describe('MemoryDocument', () => {
53
53
  });
54
54
  });
55
55
 
56
+ describe('MemoryDocument._extendWithDeletedStamps', () => {
57
+ it('returns document body schema', () => {
58
+ const mutation = {
59
+ deletedAt: undefined,
60
+ deletedBy: undefined,
61
+ deletedByUserName: undefined,
62
+ };
63
+
64
+ Profile._extendWithDeletedStamps(context, mutation);
65
+
66
+ expect(mutation.deletedAt).toBeDefined();
67
+ expect(mutation.deletedBy).toEqual('SYSTEM');
68
+ expect(mutation.deletedByUserName).toBeNull();
69
+ });
70
+ });
71
+
56
72
  describe('MemoryDocument.create(context, query, mutation)', () => {
57
73
  it('creates a document from mutation', async () => {
58
74
  const profile = await Profile.create(context, {}, attributes);
@@ -1,4 +1,4 @@
1
- import Document, { type DefaultAttributes } from './Document';
1
+ import Document from './Document';
2
2
  import MemoryDocument from './MemoryDocument';
3
3
 
4
4
  export {
@@ -6,6 +6,4 @@ export {
6
6
  MemoryDocument,
7
7
  };
8
8
 
9
- export type {
10
- DefaultAttributes,
11
- };
9
+ export type * from './Document';
@@ -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 processible'
187
+ ' but input values are not processable'
188
188
  };
189
189
  }
190
190
 
191
- errors.UnprocessibleConditionError = {
191
+ errors.UnprocessableConditionError = {
192
192
  statusCode: 422,
193
193
  description: 'Operation failed to process the request cause of expected' +
194
194
  ' exit condition'
@@ -1,9 +1,9 @@
1
1
  import CommonError from './CommonError';
2
2
 
3
3
  /**
4
- * Unprocessible Condition Error
4
+ * Unprocessable Condition Error
5
5
  *
6
- * `UnprocessibleConditionError` represents a **422 Unprocessable Entity** error that occurs
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 UnprocessibleConditionError extends CommonError {
26
- /** Creates an instance of unprocessible condition error. */
27
- constructor(message: string = 'Unprocessible condition') {
28
- super('UnprocessibleConditionError', message);
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 UnprocessibleConditionError;
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 UnprocessibleConditionError from './UnprocessibleConditionError';
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
- UnprocessibleConditionError,
16
+ UnprocessableConditionError,
17
17
  };
@@ -1,5 +1,5 @@
1
1
  import Component from '../../Component';
2
- import { capitalize } from 'lodash';
2
+ import { get, capitalize } from 'lodash';
3
3
  import Operation, { type Result } from '../Operation';
4
4
  import { type PropertiesSchemaSource } from '@kravc/schema';
5
5
 
@@ -9,7 +9,7 @@ const SORT_ORDER = {
9
9
  };
10
10
 
11
11
  const DEFAULT_LIMIT = 20;
12
- const DEFAULT_LIMIT_MAX = 999;
12
+ const DEFAULT_LIMIT_MAX = 100;
13
13
  const DEFAULT_SORT_ORDER = SORT_ORDER.DESC;
14
14
 
15
15
  export type PageInfo = {
@@ -53,12 +53,12 @@ const Index = (
53
53
 
54
54
  /** Returns default value for a limit parameter. */
55
55
  static get defaultLimit() {
56
- return DEFAULT_LIMIT;
56
+ return get(ComponentClass, 'indexDefaultLimit', DEFAULT_LIMIT);
57
57
  }
58
58
 
59
59
  /** Returns maximum number for a limit parameter. */
60
60
  static get limitMax() {
61
- return DEFAULT_LIMIT_MAX;
61
+ return get(ComponentClass, 'indexLimitMax', DEFAULT_LIMIT_MAX);
62
62
  }
63
63
 
64
64
  /** Returns default value for a sort parameter. */
@@ -106,12 +106,12 @@ const Index = (
106
106
  },
107
107
  count: {
108
108
  type: 'integer',
109
- example: 0,
109
+ example: 5,
110
110
  description: `Number of ${documentTitle}`,
111
111
  },
112
112
  limit: {
113
113
  type: 'integer',
114
- example: 100,
114
+ example: get(ComponentClass, 'indexDefaultLimit', DEFAULT_LIMIT),
115
115
  description: `Limit number of ${documentTitle} to be returned`,
116
116
  },
117
117
  lastEvaluatedKey: {
@@ -127,7 +127,7 @@ const Index = (
127
127
  const {
128
128
  sort,
129
129
  limit,
130
- index,
130
+ indexName,
131
131
  exclusiveStartKey,
132
132
  ...query
133
133
  } = parameters;
@@ -135,7 +135,7 @@ const Index = (
135
135
  const options = {
136
136
  sort,
137
137
  limit,
138
- index,
138
+ indexName,
139
139
  exclusiveStartKey,
140
140
  };
141
141
 
@@ -39,13 +39,13 @@ const List = (
39
39
  async action(parameters: Record<string, unknown>) {
40
40
  const {
41
41
  sort,
42
- index,
42
+ indexName,
43
43
  ...query
44
44
  } = parameters;
45
45
 
46
46
  const options = {
47
47
  sort,
48
- index,
48
+ indexName,
49
49
  };
50
50
 
51
51
  const { componentActionMethod } = this.constructor as typeof Operation;
@@ -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('UnprocessibleConditionError');
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('UnprocessibleConditionError');
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('UnprocessibleConditionError');
98
+ expect(errorCodes).toContain('UnprocessableConditionError');
99
99
  });
100
100
  });
101
101
 
@@ -107,7 +107,7 @@ describe('Index(Document, actionMethod)', () => {
107
107
  example: 20,
108
108
  default: 20,
109
109
  minimum: 1,
110
- maximum: 999,
110
+ maximum: 100,
111
111
  description: 'Limit number of profiles to be returned',
112
112
  },
113
113
  sort: {
@@ -146,12 +146,12 @@ describe('Index(Document, actionMethod)', () => {
146
146
  },
147
147
  count: {
148
148
  type: 'integer',
149
- example: 0,
149
+ example: 5,
150
150
  description: 'Number of profiles',
151
151
  },
152
152
  limit: {
153
153
  type: 'integer',
154
- example: 100,
154
+ example: 20,
155
155
  description: 'Limit number of profiles to be returned',
156
156
  },
157
157
  lastEvaluatedKey: {
@@ -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('UnprocessibleConditionError');
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('UnprocessibleConditionError');
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('UnprocessibleConditionError');
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.0',
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 { OperationErrorAttibutes } from './OperationErrorAttributes';
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<OperationErrorAttibutes> {
31
+ class OperationError extends Component<OperationErrorAttributes> {
32
32
  /** Returns schema of the operation error. */
33
33
  static get schema() {
34
34
  return operationErrorSchema;
@@ -1,4 +1,4 @@
1
- export type OperationErrorAttibutes = {
1
+ export type OperationErrorAttributes = {
2
2
  error: {
3
3
  code: string;
4
4
  message: string;
@@ -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
- });