@opra/common 1.11.0 → 1.12.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.
Files changed (31) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/exception/http-errors/bad-request.error.js +1 -2
  4. package/cjs/exception/http-errors/conflict.error.js +1 -2
  5. package/cjs/exception/http-errors/failed-dependency.error.js +1 -2
  6. package/cjs/exception/http-errors/forbidden.error.js +1 -2
  7. package/cjs/exception/http-errors/internal-server.error.js +1 -2
  8. package/cjs/exception/http-errors/method-not-allowed.error.js +1 -2
  9. package/cjs/exception/http-errors/not-acceptable.error.js +1 -2
  10. package/cjs/exception/http-errors/not-found.error.js +1 -2
  11. package/cjs/exception/http-errors/permission.error.js +1 -2
  12. package/cjs/exception/http-errors/resource-conflict.error.js +1 -2
  13. package/cjs/exception/http-errors/resource-not.available.error.js +1 -2
  14. package/cjs/exception/http-errors/unauthorized.error.js +1 -2
  15. package/cjs/exception/http-errors/unprocessable-entity.error.js +1 -2
  16. package/cjs/filter/filter-rules.js +13 -18
  17. package/esm/exception/http-errors/bad-request.error.js +1 -2
  18. package/esm/exception/http-errors/conflict.error.js +1 -2
  19. package/esm/exception/http-errors/failed-dependency.error.js +1 -2
  20. package/esm/exception/http-errors/forbidden.error.js +1 -2
  21. package/esm/exception/http-errors/internal-server.error.js +1 -2
  22. package/esm/exception/http-errors/method-not-allowed.error.js +1 -2
  23. package/esm/exception/http-errors/not-acceptable.error.js +1 -2
  24. package/esm/exception/http-errors/not-found.error.js +1 -2
  25. package/esm/exception/http-errors/permission.error.js +1 -2
  26. package/esm/exception/http-errors/resource-conflict.error.js +1 -2
  27. package/esm/exception/http-errors/resource-not.available.error.js +1 -2
  28. package/esm/exception/http-errors/unauthorized.error.js +1 -2
  29. package/esm/exception/http-errors/unprocessable-entity.error.js +1 -2
  30. package/esm/filter/filter-rules.js +2 -7
  31. package/package.json +2 -2
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BadRequestError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 400 Bad Request
@@ -15,7 +14,7 @@ class BadRequestError extends opra_http_error_js_1.OpraHttpError {
15
14
  }
16
15
  init(issue) {
17
16
  super.init({
18
- message: (0, index_js_1.translate)('error:BAD_REQUEST', 'Bad request'),
17
+ message: 'Bad request',
19
18
  code: 'BAD_REQUEST',
20
19
  ...issue,
21
20
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConflictError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 409 Conflict
@@ -14,7 +13,7 @@ class ConflictError extends opra_http_error_js_1.OpraHttpError {
14
13
  }
15
14
  init(issue) {
16
15
  super.init({
17
- message: (0, index_js_1.translate)('error:CONFLICT', 'Conflict'),
16
+ message: 'Conflict',
18
17
  code: 'CONFLICT',
19
18
  ...issue,
20
19
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FailedDependencyError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 424 Failed Dependency
@@ -14,7 +13,7 @@ class FailedDependencyError extends opra_http_error_js_1.OpraHttpError {
14
13
  }
15
14
  init(issue) {
16
15
  super.init({
17
- message: (0, index_js_1.translate)('error:FAILED_DEPENDENCY', 'The request failed due to failure of a previous request'),
16
+ message: 'The request failed due to failure of a previous request',
18
17
  code: 'FAILED_DEPENDENCY',
19
18
  ...issue,
20
19
  });
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ForbiddenError = void 0;
4
4
  const index_js_1 = require("../../enums/index.js");
5
- const index_js_2 = require("../../i18n/index.js");
6
5
  const opra_http_error_js_1 = require("../opra-http-error.js");
7
6
  /**
8
7
  * 403 Forbidden
@@ -17,7 +16,7 @@ class ForbiddenError extends opra_http_error_js_1.OpraHttpError {
17
16
  }
18
17
  init(issue) {
19
18
  super.init({
20
- message: (0, index_js_2.translate)('error:FORBIDDEN', 'You are not authorized to perform this action'),
19
+ message: 'You are not authorized to perform this action',
21
20
  code: 'FORBIDDEN',
22
21
  ...issue,
23
22
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InternalServerError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 500 Internal Server Error
@@ -14,7 +13,7 @@ class InternalServerError extends opra_http_error_js_1.OpraHttpError {
14
13
  }
15
14
  init(issue) {
16
15
  super.init({
17
- message: (0, index_js_1.translate)('error:INTERNAL_SERVER_ERROR', 'Internal server error'),
16
+ message: 'Internal server error',
18
17
  code: 'INTERNAL_SERVER_ERROR',
19
18
  severity: 'fatal',
20
19
  ...issue,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MethodNotAllowedError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 405 Method Not Allowed
@@ -15,7 +14,7 @@ class MethodNotAllowedError extends opra_http_error_js_1.OpraHttpError {
15
14
  }
16
15
  init(issue) {
17
16
  super.init({
18
- message: (0, index_js_1.translate)('error:METHOD_NOT_ALLOWED', 'Method not allowed'),
17
+ message: 'Method not allowed',
19
18
  code: 'METHOD_NOT_ALLOWED',
20
19
  ...issue,
21
20
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotAcceptableError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 406 Not Acceptable
@@ -15,7 +14,7 @@ class NotAcceptableError extends opra_http_error_js_1.OpraHttpError {
15
14
  }
16
15
  init(issue) {
17
16
  super.init({
18
- message: (0, index_js_1.translate)('error:NOT_ACCEPTABLE', 'Not Acceptable'),
17
+ message: 'Not Acceptable',
19
18
  code: 'NOT_ACCEPTABLE',
20
19
  ...issue,
21
20
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotFoundError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 404 Not Found
@@ -18,7 +17,7 @@ class NotFoundError extends opra_http_error_js_1.OpraHttpError {
18
17
  }
19
18
  init(issue) {
20
19
  super.init({
21
- message: (0, index_js_1.translate)('error:NOT_FOUND', 'Not found'),
20
+ message: 'Not found',
22
21
  code: 'NOT_FOUND',
23
22
  ...issue,
24
23
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PermissionError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const forbidden_error_js_1 = require("./forbidden.error.js");
6
5
  /**
7
6
  * 403 Forbidden
@@ -12,7 +11,7 @@ const forbidden_error_js_1 = require("./forbidden.error.js");
12
11
  class PermissionError extends forbidden_error_js_1.ForbiddenError {
13
12
  init(issue) {
14
13
  super.init({
15
- message: (0, index_js_1.translate)('error:PERMISSION_ERROR', 'You dont have permission for this operation'),
14
+ message: 'You dont have permission for this operation',
16
15
  code: 'PERMISSION_ERROR',
17
16
  ...issue,
18
17
  });
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ResourceConflictError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  class ResourceConflictError extends opra_http_error_js_1.OpraHttpError {
7
6
  constructor(resource, fields, cause) {
8
7
  super({
9
- message: (0, index_js_1.translate)(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same values ({{fields}})`),
8
+ message: `There is already an other "${resource}" resource with same values for field(s) [${fields}]`,
10
9
  severity: 'error',
11
10
  code: 'RESOURCE_CONFLICT',
12
11
  details: {
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ResourceNotAvailableError = void 0;
4
4
  const index_js_1 = require("../../enums/index.js");
5
- const index_js_2 = require("../../i18n/index.js");
6
5
  const opra_http_error_js_1 = require("../opra-http-error.js");
7
6
  /**
8
7
  * The server cannot find the requested resource.
@@ -11,7 +10,7 @@ const opra_http_error_js_1 = require("../opra-http-error.js");
11
10
  class ResourceNotAvailableError extends opra_http_error_js_1.OpraHttpError {
12
11
  constructor(resource, keyValue, cause) {
13
12
  super({
14
- message: (0, index_js_2.translate)(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available`),
13
+ message: `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available`,
15
14
  severity: 'error',
16
15
  code: 'RESOURCE_NOT_AVAILABLE',
17
16
  details: {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnauthorizedError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 401 Unauthorized
@@ -15,7 +14,7 @@ class UnauthorizedError extends opra_http_error_js_1.OpraHttpError {
15
14
  }
16
15
  init(issue) {
17
16
  super.init({
18
- message: (0, index_js_1.translate)('error:UNAUTHORIZED', 'You have not been authenticated to perform this action'),
17
+ message: `You don't have permission to perform this action`,
19
18
  code: 'UNAUTHORIZED',
20
19
  ...issue,
21
20
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnprocessableEntityError = void 0;
4
- const index_js_1 = require("../../i18n/index.js");
5
4
  const opra_http_error_js_1 = require("../opra-http-error.js");
6
5
  /**
7
6
  * 422 Unprocessable Entity
@@ -14,7 +13,7 @@ class UnprocessableEntityError extends opra_http_error_js_1.OpraHttpError {
14
13
  }
15
14
  init(issue) {
16
15
  super.init({
17
- message: (0, index_js_1.translate)('error:UNPROCESSABLE_ENTITY', 'Unprocessable entity'),
16
+ message: 'Unprocessable entity',
18
17
  severity: 'error',
19
18
  code: 'UNPROCESSABLE_ENTITY',
20
19
  ...issue,
@@ -6,8 +6,7 @@ const objects_1 = require("@jsopen/objects");
6
6
  const valgen_1 = require("valgen");
7
7
  const index_js_1 = require("../exception/index.js");
8
8
  const index_js_2 = require("../helpers/index.js");
9
- const index_js_3 = require("../i18n/index.js");
10
- const index_js_4 = require("./ast/index.js");
9
+ const index_js_3 = require("./ast/index.js");
11
10
  const parse_js_1 = require("./parse.js");
12
11
  class FilterRules {
13
12
  constructor(rules, options) {
@@ -37,19 +36,17 @@ class FilterRules {
37
36
  return this.normalizeFilterAst(ast, [], currentType, scope);
38
37
  }
39
38
  normalizeFilterAst(ast, stack, currentType, scope) {
40
- if (ast instanceof index_js_4.ComparisonExpression) {
39
+ if (ast instanceof index_js_3.ComparisonExpression) {
41
40
  stack.push(ast);
42
41
  this.normalizeFilterAst(ast.left, stack, currentType);
43
- if (!(ast.left instanceof index_js_4.QualifiedIdentifier && ast.left.field)) {
42
+ if (!(ast.left instanceof index_js_3.QualifiedIdentifier && ast.left.field)) {
44
43
  throw new TypeError(`Invalid filter query. Left side should be a data field.`);
45
44
  }
46
45
  // Check if filtering accepted for given field
47
46
  const rule = this._rules.get(ast.left.value);
48
47
  if (!rule) {
49
48
  throw new index_js_1.OpraException({
50
- message: (0, index_js_3.translate)('error:UNACCEPTED_FILTER_FIELD', {
51
- field: ast.left.value,
52
- }),
49
+ message: `Field '${ast.left.value}' is not available for filter operation`,
53
50
  code: 'UNACCEPTED_FILTER_FIELD',
54
51
  details: {
55
52
  field: ast.left.value,
@@ -59,9 +56,7 @@ class FilterRules {
59
56
  // Check if filtering endpoint accepted for given field
60
57
  if (rule.operators && !rule.operators.includes(ast.op)) {
61
58
  throw new index_js_1.OpraException({
62
- message: (0, index_js_3.translate)('error:UNACCEPTED_FILTER_OPERATION', {
63
- field: ast.left.value,
64
- }),
59
+ message: `'${ast.left.value}' field do not accept '${ast.op}' filter operator`,
65
60
  code: 'UNACCEPTED_FILTER_OPERATION',
66
61
  details: {
67
62
  field: ast.left.value,
@@ -77,46 +72,46 @@ class FilterRules {
77
72
  stack.pop();
78
73
  return ast;
79
74
  }
80
- if (ast instanceof index_js_4.LogicalExpression) {
75
+ if (ast instanceof index_js_3.LogicalExpression) {
81
76
  stack.push(ast);
82
77
  ast.items.forEach(item => this.normalizeFilterAst(item, stack, currentType));
83
78
  stack.pop();
84
79
  return ast;
85
80
  }
86
- if (ast instanceof index_js_4.ArithmeticExpression) {
81
+ if (ast instanceof index_js_3.ArithmeticExpression) {
87
82
  stack.push(ast);
88
83
  ast.items.forEach(item => this.normalizeFilterAst(item.expression, stack, currentType));
89
84
  stack.pop();
90
85
  return ast;
91
86
  }
92
- if (ast instanceof index_js_4.ArrayExpression) {
87
+ if (ast instanceof index_js_3.ArrayExpression) {
93
88
  stack.push(ast);
94
89
  ast.items.forEach(item => this.normalizeFilterAst(item, stack, currentType));
95
90
  stack.pop();
96
91
  return ast;
97
92
  }
98
- if (ast instanceof index_js_4.ParenthesizedExpression) {
93
+ if (ast instanceof index_js_3.ParenthesizedExpression) {
99
94
  stack.push(ast);
100
95
  this.normalizeFilterAst(ast.expression, stack, currentType);
101
96
  stack.pop();
102
97
  return ast;
103
98
  }
104
- if (ast instanceof index_js_4.QualifiedIdentifier && currentType) {
99
+ if (ast instanceof index_js_3.QualifiedIdentifier && currentType) {
105
100
  ast.value = currentType.normalizeFieldPath(ast.value, { scope });
106
101
  ast.field = currentType.getField(ast.value, scope);
107
102
  ast.dataType = ast.field.type;
108
103
  return ast;
109
104
  }
110
- if (ast instanceof index_js_4.Literal) {
105
+ if (ast instanceof index_js_3.Literal) {
111
106
  /** Check if comparison expression has in stack */
112
- const compIdx = stack.findLastIndex(x => x instanceof index_js_4.ComparisonExpression);
107
+ const compIdx = stack.findLastIndex(x => x instanceof index_js_3.ComparisonExpression);
113
108
  if (compIdx >= 0) {
114
109
  const comp = stack[compIdx];
115
110
  /** If calling for right side of comparison */
116
111
  if (ast === comp.right || stack[compIdx + 1] === comp.right) {
117
112
  /** Check if comparison expression left side is a field */
118
113
  if (comp &&
119
- comp.left instanceof index_js_4.QualifiedIdentifier &&
114
+ comp.left instanceof index_js_3.QualifiedIdentifier &&
120
115
  comp.left.field) {
121
116
  if (ast.value == null && !comp.left.field.required)
122
117
  return ast.value;
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 400 Bad Request
@@ -12,7 +11,7 @@ export class BadRequestError extends OpraHttpError {
12
11
  }
13
12
  init(issue) {
14
13
  super.init({
15
- message: translate('error:BAD_REQUEST', 'Bad request'),
14
+ message: 'Bad request',
16
15
  code: 'BAD_REQUEST',
17
16
  ...issue,
18
17
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 409 Conflict
@@ -11,7 +10,7 @@ export class ConflictError extends OpraHttpError {
11
10
  }
12
11
  init(issue) {
13
12
  super.init({
14
- message: translate('error:CONFLICT', 'Conflict'),
13
+ message: 'Conflict',
15
14
  code: 'CONFLICT',
16
15
  ...issue,
17
16
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 424 Failed Dependency
@@ -11,7 +10,7 @@ export class FailedDependencyError extends OpraHttpError {
11
10
  }
12
11
  init(issue) {
13
12
  super.init({
14
- message: translate('error:FAILED_DEPENDENCY', 'The request failed due to failure of a previous request'),
13
+ message: 'The request failed due to failure of a previous request',
15
14
  code: 'FAILED_DEPENDENCY',
16
15
  ...issue,
17
16
  });
@@ -1,5 +1,4 @@
1
1
  import { HttpStatusCode } from '../../enums/index.js';
2
- import { translate } from '../../i18n/index.js';
3
2
  import { OpraHttpError } from '../opra-http-error.js';
4
3
  /**
5
4
  * 403 Forbidden
@@ -14,7 +13,7 @@ export class ForbiddenError extends OpraHttpError {
14
13
  }
15
14
  init(issue) {
16
15
  super.init({
17
- message: translate('error:FORBIDDEN', 'You are not authorized to perform this action'),
16
+ message: 'You are not authorized to perform this action',
18
17
  code: 'FORBIDDEN',
19
18
  ...issue,
20
19
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 500 Internal Server Error
@@ -11,7 +10,7 @@ export class InternalServerError extends OpraHttpError {
11
10
  }
12
11
  init(issue) {
13
12
  super.init({
14
- message: translate('error:INTERNAL_SERVER_ERROR', 'Internal server error'),
13
+ message: 'Internal server error',
15
14
  code: 'INTERNAL_SERVER_ERROR',
16
15
  severity: 'fatal',
17
16
  ...issue,
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 405 Method Not Allowed
@@ -12,7 +11,7 @@ export class MethodNotAllowedError extends OpraHttpError {
12
11
  }
13
12
  init(issue) {
14
13
  super.init({
15
- message: translate('error:METHOD_NOT_ALLOWED', 'Method not allowed'),
14
+ message: 'Method not allowed',
16
15
  code: 'METHOD_NOT_ALLOWED',
17
16
  ...issue,
18
17
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 406 Not Acceptable
@@ -12,7 +11,7 @@ export class NotAcceptableError extends OpraHttpError {
12
11
  }
13
12
  init(issue) {
14
13
  super.init({
15
- message: translate('error:NOT_ACCEPTABLE', 'Not Acceptable'),
14
+ message: 'Not Acceptable',
16
15
  code: 'NOT_ACCEPTABLE',
17
16
  ...issue,
18
17
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 404 Not Found
@@ -15,7 +14,7 @@ export class NotFoundError extends OpraHttpError {
15
14
  }
16
15
  init(issue) {
17
16
  super.init({
18
- message: translate('error:NOT_FOUND', 'Not found'),
17
+ message: 'Not found',
19
18
  code: 'NOT_FOUND',
20
19
  ...issue,
21
20
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { ForbiddenError } from './forbidden.error.js';
3
2
  /**
4
3
  * 403 Forbidden
@@ -9,7 +8,7 @@ import { ForbiddenError } from './forbidden.error.js';
9
8
  export class PermissionError extends ForbiddenError {
10
9
  init(issue) {
11
10
  super.init({
12
- message: translate('error:PERMISSION_ERROR', 'You dont have permission for this operation'),
11
+ message: 'You dont have permission for this operation',
13
12
  code: 'PERMISSION_ERROR',
14
13
  ...issue,
15
14
  });
@@ -1,9 +1,8 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  export class ResourceConflictError extends OpraHttpError {
4
3
  constructor(resource, fields, cause) {
5
4
  super({
6
- message: translate(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same values ({{fields}})`),
5
+ message: `There is already an other "${resource}" resource with same values for field(s) [${fields}]`,
7
6
  severity: 'error',
8
7
  code: 'RESOURCE_CONFLICT',
9
8
  details: {
@@ -1,5 +1,4 @@
1
1
  import { HttpStatusCode } from '../../enums/index.js';
2
- import { translate } from '../../i18n/index.js';
3
2
  import { OpraHttpError } from '../opra-http-error.js';
4
3
  /**
5
4
  * The server cannot find the requested resource.
@@ -8,7 +7,7 @@ import { OpraHttpError } from '../opra-http-error.js';
8
7
  export class ResourceNotAvailableError extends OpraHttpError {
9
8
  constructor(resource, keyValue, cause) {
10
9
  super({
11
- message: translate(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available`),
10
+ message: `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available`,
12
11
  severity: 'error',
13
12
  code: 'RESOURCE_NOT_AVAILABLE',
14
13
  details: {
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 401 Unauthorized
@@ -12,7 +11,7 @@ export class UnauthorizedError extends OpraHttpError {
12
11
  }
13
12
  init(issue) {
14
13
  super.init({
15
- message: translate('error:UNAUTHORIZED', 'You have not been authenticated to perform this action'),
14
+ message: `You don't have permission to perform this action`,
16
15
  code: 'UNAUTHORIZED',
17
16
  ...issue,
18
17
  });
@@ -1,4 +1,3 @@
1
- import { translate } from '../../i18n/index.js';
2
1
  import { OpraHttpError } from '../opra-http-error.js';
3
2
  /**
4
3
  * 422 Unprocessable Entity
@@ -11,7 +10,7 @@ export class UnprocessableEntityError extends OpraHttpError {
11
10
  }
12
11
  init(issue) {
13
12
  super.init({
14
- message: translate('error:UNPROCESSABLE_ENTITY', 'Unprocessable entity'),
13
+ message: 'Unprocessable entity',
15
14
  severity: 'error',
16
15
  code: 'UNPROCESSABLE_ENTITY',
17
16
  ...issue,
@@ -3,7 +3,6 @@ import { omitUndefined } from '@jsopen/objects';
3
3
  import { isString } from 'valgen';
4
4
  import { OpraException } from '../exception/index.js';
5
5
  import { ResponsiveMap } from '../helpers/index.js';
6
- import { translate } from '../i18n/index.js';
7
6
  import { ArithmeticExpression, ArrayExpression, ComparisonExpression, Literal, LogicalExpression, ParenthesizedExpression, QualifiedIdentifier, } from './ast/index.js';
8
7
  import { parse } from './parse.js';
9
8
  export class FilterRules {
@@ -44,9 +43,7 @@ export class FilterRules {
44
43
  const rule = this._rules.get(ast.left.value);
45
44
  if (!rule) {
46
45
  throw new OpraException({
47
- message: translate('error:UNACCEPTED_FILTER_FIELD', {
48
- field: ast.left.value,
49
- }),
46
+ message: `Field '${ast.left.value}' is not available for filter operation`,
50
47
  code: 'UNACCEPTED_FILTER_FIELD',
51
48
  details: {
52
49
  field: ast.left.value,
@@ -56,9 +53,7 @@ export class FilterRules {
56
53
  // Check if filtering endpoint accepted for given field
57
54
  if (rule.operators && !rule.operators.includes(ast.op)) {
58
55
  throw new OpraException({
59
- message: translate('error:UNACCEPTED_FILTER_OPERATION', {
60
- field: ast.left.value,
61
- }),
56
+ message: `'${ast.left.value}' field do not accept '${ast.op}' filter operator`,
62
57
  code: 'UNACCEPTED_FILTER_OPERATION',
63
58
  details: {
64
59
  field: ast.left.value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "@browsery/http-parser": "^0.5.9-r4",
11
11
  "@browsery/i18next": "^24.2.1-r1",
12
12
  "@browsery/type-is": "^1.6.18-r8",
13
- "@jsopen/objects": "^1.5.0",
13
+ "@jsopen/objects": "^1.5.2",
14
14
  "fast-tokenizer": "^1.7.0",
15
15
  "putil-promisify": "^1.10.1",
16
16
  "putil-varhelpers": "^1.6.5",