@opra/common 1.0.0-alpha.38 → 1.0.0-alpha.39

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 (105) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/data-type/complex-type-base.js +1 -1
  4. package/cjs/document/data-type/extended-types/filter.type.js +1 -1
  5. package/cjs/filter/filter-rules.js +17 -16
  6. package/cjs/helpers/index.js +1 -0
  7. package/cjs/helpers/safe-json-stringify.js +16 -0
  8. package/cjs/schema/index.js +2 -27
  9. package/cjs/schema/opra-schema.js +24 -0
  10. package/esm/document/data-type/complex-type-base.js +1 -1
  11. package/esm/document/data-type/extended-types/filter.type.js +1 -1
  12. package/esm/filter/filter-rules.js +10 -9
  13. package/esm/helpers/index.js +1 -0
  14. package/esm/helpers/safe-json-stringify.js +13 -0
  15. package/esm/schema/index.js +2 -27
  16. package/esm/schema/opra-schema.js +21 -0
  17. package/package.json +2 -2
  18. package/types/document/api-document.d.ts +1 -1
  19. package/types/document/common/data-type-map.d.ts +1 -1
  20. package/types/document/common/document-node.d.ts +1 -1
  21. package/types/document/common/value.d.ts +1 -1
  22. package/types/document/data-type/api-field.d.ts +1 -1
  23. package/types/document/data-type/complex-type-base.d.ts +3 -4
  24. package/types/document/data-type/complex-type.d.ts +1 -1
  25. package/types/document/data-type/data-type.d.ts +2 -2
  26. package/types/document/data-type/enum-type.d.ts +2 -2
  27. package/types/document/data-type/extended-types/base64.type.d.ts +1 -1
  28. package/types/document/data-type/extended-types/date-string.type.d.ts +1 -1
  29. package/types/document/data-type/extended-types/date-time-string.type.d.ts +1 -1
  30. package/types/document/data-type/extended-types/date-time.type.d.ts +1 -1
  31. package/types/document/data-type/extended-types/date.type.d.ts +1 -1
  32. package/types/document/data-type/extended-types/email.type.d.ts +1 -1
  33. package/types/document/data-type/extended-types/field-path.type.d.ts +3 -3
  34. package/types/document/data-type/extended-types/filter.type.d.ts +3 -3
  35. package/types/document/data-type/extended-types/object-id.type.d.ts +1 -1
  36. package/types/document/data-type/extended-types/operation-result.type.d.ts +2 -2
  37. package/types/document/data-type/extended-types/time.type.d.ts +1 -1
  38. package/types/document/data-type/extended-types/url.type.d.ts +1 -1
  39. package/types/document/data-type/extended-types/uuid.type.d.ts +1 -1
  40. package/types/document/data-type/mapped-type.d.ts +1 -1
  41. package/types/document/data-type/mixin-type.d.ts +1 -1
  42. package/types/document/data-type/omit-type.d.ts +1 -1
  43. package/types/document/data-type/partial-type.d.ts +1 -1
  44. package/types/document/data-type/pick-type.d.ts +1 -1
  45. package/types/document/data-type/primitive-types/any.type.d.ts +1 -1
  46. package/types/document/data-type/primitive-types/bigint.type.d.ts +1 -1
  47. package/types/document/data-type/primitive-types/boolean.type.d.ts +1 -1
  48. package/types/document/data-type/primitive-types/integer.type.d.ts +1 -1
  49. package/types/document/data-type/primitive-types/null.type.d.ts +1 -1
  50. package/types/document/data-type/primitive-types/number.type.d.ts +1 -1
  51. package/types/document/data-type/primitive-types/string.type.d.ts +1 -1
  52. package/types/document/data-type/required-type.d.ts +1 -1
  53. package/types/document/data-type/simple-type.d.ts +2 -2
  54. package/types/document/data-type/utils/create-mapped-class.d.ts +1 -1
  55. package/types/document/decorators/http-controller.decorator.d.ts +1 -1
  56. package/types/document/decorators/http-operation-entity.decorator.d.ts +2 -2
  57. package/types/document/decorators/http-operation.decorator.d.ts +1 -1
  58. package/types/document/factory/api-document.factory.d.ts +1 -1
  59. package/types/document/factory/data-type.factory.d.ts +1 -1
  60. package/types/document/factory/http-api.factory.d.ts +1 -1
  61. package/types/document/http/http-api.d.ts +1 -1
  62. package/types/document/http/http-controller.d.ts +1 -1
  63. package/types/document/http/http-media-type.d.ts +2 -2
  64. package/types/document/http/http-multipart-field.d.ts +1 -1
  65. package/types/document/http/http-operation-response.d.ts +1 -1
  66. package/types/document/http/http-operation.d.ts +2 -2
  67. package/types/document/http/http-parameter.d.ts +1 -1
  68. package/types/document/http/http-request-body.d.ts +1 -1
  69. package/types/exception/http-errors/bad-request.error.d.ts +1 -1
  70. package/types/exception/http-errors/conflict.error.d.ts +1 -1
  71. package/types/exception/http-errors/failed-dependency.error.d.ts +1 -1
  72. package/types/exception/http-errors/forbidden.error.d.ts +1 -1
  73. package/types/exception/http-errors/internal-server.error.d.ts +1 -1
  74. package/types/exception/http-errors/method-not-allowed.error.d.ts +1 -1
  75. package/types/exception/http-errors/not-acceptable.error.d.ts +1 -1
  76. package/types/exception/http-errors/not-found.error.d.ts +1 -1
  77. package/types/exception/http-errors/permission.error.d.ts +1 -1
  78. package/types/exception/http-errors/unauthorized.error.d.ts +1 -1
  79. package/types/exception/http-errors/unprocessable-entity.error.d.ts +1 -1
  80. package/types/exception/opra-exception.d.ts +1 -1
  81. package/types/exception/opra-http-error.d.ts +1 -1
  82. package/types/filter/antlr/OpraFilterParser.d.ts +1 -1
  83. package/types/filter/ast/expressions/comparison-expression.d.ts +1 -1
  84. package/types/filter/errors.d.ts +1 -1
  85. package/types/filter/filter-rules.d.ts +5 -5
  86. package/types/filter/opra-error-listener.d.ts +1 -1
  87. package/types/helpers/function-utils.d.ts +1 -1
  88. package/types/helpers/index.d.ts +1 -0
  89. package/types/helpers/mixin-utils.d.ts +1 -1
  90. package/types/helpers/object-utils.d.ts +1 -1
  91. package/types/helpers/safe-json-stringify.d.ts +1 -0
  92. package/types/helpers/type-guards.d.ts +1 -1
  93. package/types/i18n/i18n.d.ts +2 -2
  94. package/types/i18n/translate.d.ts +1 -1
  95. package/types/schema/{document.interface.d.ts → api-document.interface.d.ts} +3 -3
  96. package/types/schema/data-type/complex-type.interface.d.ts +1 -1
  97. package/types/schema/data-type/enum-type.interface.d.ts +1 -1
  98. package/types/schema/data-type/mapped-type.interface.d.ts +1 -1
  99. package/types/schema/data-type/mixin-type.interface.d.ts +1 -1
  100. package/types/schema/http/http-parameter.interface.d.ts +1 -1
  101. package/types/schema/index.d.ts +2 -62
  102. package/types/schema/opra-schema.d.ts +21 -0
  103. package/types/schema/type-guards.d.ts +1 -1
  104. /package/cjs/schema/{document.interface.js → api-document.interface.js} +0 -0
  105. /package/esm/schema/{document.interface.js → api-document.interface.js} +0 -0
@@ -171,7 +171,7 @@ class ComplexTypeBaseClass extends data_type_js_1.DataType {
171
171
  const fn = this._generateFieldCodec(codec, field, {
172
172
  ...context,
173
173
  partial: context.partial === 'deep' ? context.partial : undefined,
174
- projection,
174
+ projection: typeof projection === 'object' ? projection[fieldName]?.projection || '*' : projection,
175
175
  currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
176
176
  });
177
177
  schema[fieldName] = context.partial || !field.required ? valgen_1.vg.optional(fn) : valgen_1.vg.required(fn);
@@ -65,7 +65,7 @@ const decodeFilter = (dataType, rules) => (0, valgen_1.validator)('decodeFilter'
65
65
  return filter;
66
66
  }
67
67
  catch (e) {
68
- context.fail(_this, `Not a valid filter expression. ${e.message}`, input, e.errors);
68
+ context.fail(_this, `Not a valid filter expression. ${e.message}`, input);
69
69
  return;
70
70
  }
71
71
  }
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FilterRules = void 0;
4
4
  const index_js_1 = require("../exception/index.js");
5
- const index_js_2 = require("../filter/index.js");
6
- const index_js_3 = require("../helpers/index.js");
7
- const index_js_4 = require("../i18n/index.js");
5
+ const index_js_2 = require("../helpers/index.js");
6
+ const index_js_3 = require("../i18n/index.js");
7
+ const index_js_4 = require("./ast/index.js");
8
+ const parse_js_1 = require("./parse.js");
8
9
  class FilterRules {
9
10
  constructor(rules, options) {
10
- this._rules = new index_js_3.ResponsiveMap();
11
+ this._rules = new index_js_2.ResponsiveMap();
11
12
  Object.defineProperty(this, '_rules', {
12
- value: new index_js_3.ResponsiveMap(null, { caseSensitive: options?.caseSensitive }),
13
+ value: new index_js_2.ResponsiveMap(null, { caseSensitive: options?.caseSensitive }),
13
14
  enumerable: false,
14
15
  });
15
16
  if (rules) {
@@ -22,7 +23,7 @@ class FilterRules {
22
23
  const operators = typeof options?.operators === 'string'
23
24
  ? options.operators.split(/\s*[,| ]\s*/)
24
25
  : options?.operators;
25
- this._rules.set(fieldName, (0, index_js_3.omitUndefined)({
26
+ this._rules.set(fieldName, (0, index_js_2.omitUndefined)({
26
27
  ...options,
27
28
  operators,
28
29
  }));
@@ -30,10 +31,10 @@ class FilterRules {
30
31
  normalizeFilter(filter, dataType) {
31
32
  if (!filter)
32
33
  return;
33
- const ast = typeof filter === 'string' ? index_js_2.OpraFilter.parse(filter) : filter;
34
- if (ast instanceof index_js_2.OpraFilter.ComparisonExpression) {
34
+ const ast = typeof filter === 'string' ? (0, parse_js_1.parse)(filter) : filter;
35
+ if (ast instanceof index_js_4.ComparisonExpression) {
35
36
  this.normalizeFilter(ast.left, dataType);
36
- if (!(ast.left instanceof index_js_2.OpraFilter.QualifiedIdentifier && ast.left.field)) {
37
+ if (!(ast.left instanceof index_js_4.QualifiedIdentifier && ast.left.field)) {
37
38
  throw new TypeError(`Invalid filter query. Left side should be a data field.`);
38
39
  }
39
40
  // Check if filtering accepted for given field
@@ -41,7 +42,7 @@ class FilterRules {
41
42
  const rule = this._rules.get(ast.left.value);
42
43
  if (!rule) {
43
44
  throw new index_js_1.OpraException({
44
- message: (0, index_js_4.translate)('error:UNACCEPTED_FILTER_FIELD', { field: ast.left.value }),
45
+ message: (0, index_js_3.translate)('error:UNACCEPTED_FILTER_FIELD', { field: ast.left.value }),
45
46
  code: 'UNACCEPTED_FILTER_FIELD',
46
47
  details: {
47
48
  field: ast.left.value,
@@ -51,7 +52,7 @@ class FilterRules {
51
52
  // Check if filtering endpoint accepted for given field
52
53
  if (rule.operators && !rule.operators.includes(ast.op)) {
53
54
  throw new index_js_1.OpraException({
54
- message: (0, index_js_4.translate)('error:UNACCEPTED_FILTER_OPERATION', { field: ast.left.value }),
55
+ message: (0, index_js_3.translate)('error:UNACCEPTED_FILTER_OPERATION', { field: ast.left.value }),
55
56
  code: 'UNACCEPTED_FILTER_OPERATION',
56
57
  details: {
57
58
  field: ast.left.value,
@@ -62,23 +63,23 @@ class FilterRules {
62
63
  this.normalizeFilter(ast.right, dataType);
63
64
  return ast;
64
65
  }
65
- if (ast instanceof index_js_2.OpraFilter.LogicalExpression) {
66
+ if (ast instanceof index_js_4.LogicalExpression) {
66
67
  ast.items.forEach(item => this.normalizeFilter(item, dataType));
67
68
  return ast;
68
69
  }
69
- if (ast instanceof index_js_2.OpraFilter.ArithmeticExpression) {
70
+ if (ast instanceof index_js_4.ArithmeticExpression) {
70
71
  ast.items.forEach(item => this.normalizeFilter(item.expression, dataType));
71
72
  return ast;
72
73
  }
73
- if (ast instanceof index_js_2.OpraFilter.ArrayExpression) {
74
+ if (ast instanceof index_js_4.ArrayExpression) {
74
75
  ast.items.forEach(item => this.normalizeFilter(item, dataType));
75
76
  return ast;
76
77
  }
77
- if (ast instanceof index_js_2.OpraFilter.ParenthesizedExpression) {
78
+ if (ast instanceof index_js_4.ParenthesizedExpression) {
78
79
  this.normalizeFilter(ast.expression, dataType);
79
80
  return ast;
80
81
  }
81
- if (ast instanceof index_js_2.OpraFilter.QualifiedIdentifier && dataType) {
82
+ if (ast instanceof index_js_4.QualifiedIdentifier && dataType) {
82
83
  ast.value = dataType.normalizeFieldPath(ast.value);
83
84
  ast.field = dataType.getField(ast.value);
84
85
  ast.dataType = ast.field.type;
@@ -8,4 +8,5 @@ tslib_1.__exportStar(require("./mixin-utils.js"), exports);
8
8
  tslib_1.__exportStar(require("./object-utils.js"), exports);
9
9
  tslib_1.__exportStar(require("./parse-fields-projection.js"), exports);
10
10
  tslib_1.__exportStar(require("./responsive-map.js"), exports);
11
+ tslib_1.__exportStar(require("./safe-json-stringify.js"), exports);
11
12
  tslib_1.__exportStar(require("./type-guards.js"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safeJsonStringify = safeJsonStringify;
4
+ function safeJsonStringify(value, replacer, space) {
5
+ const seen = new WeakSet();
6
+ return JSON.stringify(value, (k, v) => {
7
+ if (v !== null && typeof v === 'object') {
8
+ if (seen.has(v))
9
+ return;
10
+ seen.add(v);
11
+ }
12
+ if (replacer)
13
+ return replacer(k, v);
14
+ return v;
15
+ }, space);
16
+ }
@@ -2,30 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpraSchema = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const constants_ = tslib_1.__importStar(require("./constants.js"));
6
- const complexType_ = tslib_1.__importStar(require("./data-type/complex-type.interface.js"));
7
- const enumType_ = tslib_1.__importStar(require("./data-type/enum-type.interface.js"));
8
- const mappedType_ = tslib_1.__importStar(require("./data-type/mapped-type.interface.js"));
9
- const mixinType_ = tslib_1.__importStar(require("./data-type/mixin-type.interface.js"));
10
- const simpleType_ = tslib_1.__importStar(require("./data-type/simple-type.interface.js"));
11
- const controller_ = tslib_1.__importStar(require("./http/http-controller.interface.js"));
12
- const operation_ = tslib_1.__importStar(require("./http/http-operation.interface.js"));
13
- const typeGuards_ = tslib_1.__importStar(require("./type-guards.js"));
14
- var OpraSchema;
15
- (function (OpraSchema) {
16
- OpraSchema.SpecVersion = constants_.SpecVersion;
17
- OpraSchema.ComplexType = complexType_.ComplexType;
18
- OpraSchema.EnumType = enumType_.EnumType;
19
- OpraSchema.MappedType = mappedType_.MappedType;
20
- OpraSchema.MixinType = mixinType_.MixinType;
21
- OpraSchema.SimpleType = simpleType_.SimpleType;
22
- OpraSchema.HttpController = controller_.HttpController;
23
- OpraSchema.HttpOperation = operation_.HttpOperation;
24
- OpraSchema.isComplexType = typeGuards_.isComplexType;
25
- OpraSchema.isDataType = typeGuards_.isDataType;
26
- OpraSchema.isSimpleType = typeGuards_.isSimpleType;
27
- OpraSchema.isMixinType = typeGuards_.isMixinType;
28
- OpraSchema.isMappedType = typeGuards_.isMappedType;
29
- OpraSchema.isEnumType = typeGuards_.isEnumType;
30
- OpraSchema.isHttpController = typeGuards_.isHttpController;
31
- })(OpraSchema || (exports.OpraSchema = OpraSchema = {}));
5
+ const OpraSchema = tslib_1.__importStar(require("./opra-schema.js"));
6
+ exports.OpraSchema = OpraSchema;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./api-document.interface"), exports);
5
+ tslib_1.__exportStar(require("./constants.js"), exports);
6
+ tslib_1.__exportStar(require("./data-type/complex-type.interface.js"), exports);
7
+ tslib_1.__exportStar(require("./data-type/data-type.interface.js"), exports);
8
+ tslib_1.__exportStar(require("./data-type/enum-type.interface.js"), exports);
9
+ tslib_1.__exportStar(require("./data-type/field.interface.js"), exports);
10
+ tslib_1.__exportStar(require("./data-type/mapped-type.interface.js"), exports);
11
+ tslib_1.__exportStar(require("./data-type/mixin-type.interface.js"), exports);
12
+ tslib_1.__exportStar(require("./data-type/simple-type.interface.js"), exports);
13
+ tslib_1.__exportStar(require("./data-type-container.interface.js"), exports);
14
+ tslib_1.__exportStar(require("./http/http-controller.interface.js"), exports);
15
+ tslib_1.__exportStar(require("./http/http-media-type.interface.js"), exports);
16
+ tslib_1.__exportStar(require("./http/http-multipart-field.interface.js"), exports);
17
+ tslib_1.__exportStar(require("./http/http-operation.interface.js"), exports);
18
+ tslib_1.__exportStar(require("./http/http-operation-response.interface.js"), exports);
19
+ tslib_1.__exportStar(require("./http/http-parameter.interface.js"), exports);
20
+ tslib_1.__exportStar(require("./http/http-request-body.interface.js"), exports);
21
+ tslib_1.__exportStar(require("./http/http-status-range.interface.js"), exports);
22
+ tslib_1.__exportStar(require("./type-guards.js"), exports);
23
+ tslib_1.__exportStar(require("./types.js"), exports);
24
+ tslib_1.__exportStar(require("./value.interface.js"), exports);
@@ -168,7 +168,7 @@ class ComplexTypeBaseClass extends DataType {
168
168
  const fn = this._generateFieldCodec(codec, field, {
169
169
  ...context,
170
170
  partial: context.partial === 'deep' ? context.partial : undefined,
171
- projection,
171
+ projection: typeof projection === 'object' ? projection[fieldName]?.projection || '*' : projection,
172
172
  currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
173
173
  });
174
174
  schema[fieldName] = context.partial || !field.required ? vg.optional(fn) : vg.required(fn);
@@ -62,7 +62,7 @@ const decodeFilter = (dataType, rules) => validator('decodeFilter', (input, cont
62
62
  return filter;
63
63
  }
64
64
  catch (e) {
65
- context.fail(_this, `Not a valid filter expression. ${e.message}`, input, e.errors);
65
+ context.fail(_this, `Not a valid filter expression. ${e.message}`, input);
66
66
  return;
67
67
  }
68
68
  }
@@ -1,7 +1,8 @@
1
1
  import { OpraException } from '../exception/index.js';
2
- import { OpraFilter } from '../filter/index.js';
3
2
  import { omitUndefined, ResponsiveMap } from '../helpers/index.js';
4
3
  import { translate } from '../i18n/index.js';
4
+ import { ArithmeticExpression, ArrayExpression, ComparisonExpression, LogicalExpression, ParenthesizedExpression, QualifiedIdentifier, } from './ast/index.js';
5
+ import { parse } from './parse.js';
5
6
  export class FilterRules {
6
7
  constructor(rules, options) {
7
8
  this._rules = new ResponsiveMap();
@@ -27,10 +28,10 @@ export class FilterRules {
27
28
  normalizeFilter(filter, dataType) {
28
29
  if (!filter)
29
30
  return;
30
- const ast = typeof filter === 'string' ? OpraFilter.parse(filter) : filter;
31
- if (ast instanceof OpraFilter.ComparisonExpression) {
31
+ const ast = typeof filter === 'string' ? parse(filter) : filter;
32
+ if (ast instanceof ComparisonExpression) {
32
33
  this.normalizeFilter(ast.left, dataType);
33
- if (!(ast.left instanceof OpraFilter.QualifiedIdentifier && ast.left.field)) {
34
+ if (!(ast.left instanceof QualifiedIdentifier && ast.left.field)) {
34
35
  throw new TypeError(`Invalid filter query. Left side should be a data field.`);
35
36
  }
36
37
  // Check if filtering accepted for given field
@@ -59,23 +60,23 @@ export class FilterRules {
59
60
  this.normalizeFilter(ast.right, dataType);
60
61
  return ast;
61
62
  }
62
- if (ast instanceof OpraFilter.LogicalExpression) {
63
+ if (ast instanceof LogicalExpression) {
63
64
  ast.items.forEach(item => this.normalizeFilter(item, dataType));
64
65
  return ast;
65
66
  }
66
- if (ast instanceof OpraFilter.ArithmeticExpression) {
67
+ if (ast instanceof ArithmeticExpression) {
67
68
  ast.items.forEach(item => this.normalizeFilter(item.expression, dataType));
68
69
  return ast;
69
70
  }
70
- if (ast instanceof OpraFilter.ArrayExpression) {
71
+ if (ast instanceof ArrayExpression) {
71
72
  ast.items.forEach(item => this.normalizeFilter(item, dataType));
72
73
  return ast;
73
74
  }
74
- if (ast instanceof OpraFilter.ParenthesizedExpression) {
75
+ if (ast instanceof ParenthesizedExpression) {
75
76
  this.normalizeFilter(ast.expression, dataType);
76
77
  return ast;
77
78
  }
78
- if (ast instanceof OpraFilter.QualifiedIdentifier && dataType) {
79
+ if (ast instanceof QualifiedIdentifier && dataType) {
79
80
  ast.value = dataType.normalizeFieldPath(ast.value);
80
81
  ast.field = dataType.getField(ast.value);
81
82
  ast.dataType = ast.field.type;
@@ -5,4 +5,5 @@ export * from './mixin-utils.js';
5
5
  export * from './object-utils.js';
6
6
  export * from './parse-fields-projection.js';
7
7
  export * from './responsive-map.js';
8
+ export * from './safe-json-stringify.js';
8
9
  export * from './type-guards.js';
@@ -0,0 +1,13 @@
1
+ export function safeJsonStringify(value, replacer, space) {
2
+ const seen = new WeakSet();
3
+ return JSON.stringify(value, (k, v) => {
4
+ if (v !== null && typeof v === 'object') {
5
+ if (seen.has(v))
6
+ return;
7
+ seen.add(v);
8
+ }
9
+ if (replacer)
10
+ return replacer(k, v);
11
+ return v;
12
+ }, space);
13
+ }
@@ -1,27 +1,2 @@
1
- import * as constants_ from './constants.js';
2
- import * as complexType_ from './data-type/complex-type.interface.js';
3
- import * as enumType_ from './data-type/enum-type.interface.js';
4
- import * as mappedType_ from './data-type/mapped-type.interface.js';
5
- import * as mixinType_ from './data-type/mixin-type.interface.js';
6
- import * as simpleType_ from './data-type/simple-type.interface.js';
7
- import * as controller_ from './http/http-controller.interface.js';
8
- import * as operation_ from './http/http-operation.interface.js';
9
- import * as typeGuards_ from './type-guards.js';
10
- export var OpraSchema;
11
- (function (OpraSchema) {
12
- OpraSchema.SpecVersion = constants_.SpecVersion;
13
- OpraSchema.ComplexType = complexType_.ComplexType;
14
- OpraSchema.EnumType = enumType_.EnumType;
15
- OpraSchema.MappedType = mappedType_.MappedType;
16
- OpraSchema.MixinType = mixinType_.MixinType;
17
- OpraSchema.SimpleType = simpleType_.SimpleType;
18
- OpraSchema.HttpController = controller_.HttpController;
19
- OpraSchema.HttpOperation = operation_.HttpOperation;
20
- OpraSchema.isComplexType = typeGuards_.isComplexType;
21
- OpraSchema.isDataType = typeGuards_.isDataType;
22
- OpraSchema.isSimpleType = typeGuards_.isSimpleType;
23
- OpraSchema.isMixinType = typeGuards_.isMixinType;
24
- OpraSchema.isMappedType = typeGuards_.isMappedType;
25
- OpraSchema.isEnumType = typeGuards_.isEnumType;
26
- OpraSchema.isHttpController = typeGuards_.isHttpController;
27
- })(OpraSchema || (OpraSchema = {}));
1
+ import * as OpraSchema from './opra-schema.js';
2
+ export { OpraSchema };
@@ -0,0 +1,21 @@
1
+ export * from './api-document.interface';
2
+ export * from './constants.js';
3
+ export * from './data-type/complex-type.interface.js';
4
+ export * from './data-type/data-type.interface.js';
5
+ export * from './data-type/enum-type.interface.js';
6
+ export * from './data-type/field.interface.js';
7
+ export * from './data-type/mapped-type.interface.js';
8
+ export * from './data-type/mixin-type.interface.js';
9
+ export * from './data-type/simple-type.interface.js';
10
+ export * from './data-type-container.interface.js';
11
+ export * from './http/http-controller.interface.js';
12
+ export * from './http/http-media-type.interface.js';
13
+ export * from './http/http-multipart-field.interface.js';
14
+ export * from './http/http-operation.interface.js';
15
+ export * from './http/http-operation-response.interface.js';
16
+ export * from './http/http-parameter.interface.js';
17
+ export * from './http/http-request-body.interface.js';
18
+ export * from './http/http-status-range.interface.js';
19
+ export * from './type-guards.js';
20
+ export * from './types.js';
21
+ export * from './value.interface.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.0.0-alpha.38",
3
+ "version": "1.0.0-alpha.39",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "putil-varhelpers": "^1.6.5",
19
19
  "reflect-metadata": "^0.2.2",
20
20
  "super-fast-md5": "^1.0.3",
21
- "tslib": "^2.6.3",
21
+ "tslib": "^2.7.0",
22
22
  "uid": "^2.0.1",
23
23
  "valgen": "^5.9.0"
24
24
  },
@@ -1,4 +1,4 @@
1
- import { Type } from 'ts-gems';
1
+ import type { Type } from 'ts-gems';
2
2
  import { ResponsiveMap } from '../helpers/index.js';
3
3
  import { OpraSchema } from '../schema/index.js';
4
4
  import { DataTypeMap } from './common/data-type-map.js';
@@ -1,4 +1,4 @@
1
- import { Type } from 'ts-gems';
1
+ import type { Type } from 'ts-gems';
2
2
  import { ResponsiveMap } from '../../helpers/index.js';
3
3
  import { DataType } from '../data-type/data-type.js';
4
4
  declare const kMap: unique symbol;
@@ -1,4 +1,4 @@
1
- import { Type } from 'ts-gems';
1
+ import type { Type } from 'ts-gems';
2
2
  import type { ApiDocument } from '../api-document.js';
3
3
  import { kDataTypeMap } from '../constants.js';
4
4
  import type { ComplexType } from '../data-type/complex-type.js';
@@ -1,4 +1,4 @@
1
- import { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
1
+ import type { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
2
2
  import type { OpraSchema } from '../../schema/index.js';
3
3
  import { DataType } from '../data-type/data-type.js';
4
4
  import type { EnumType } from '../data-type/enum-type.js';
@@ -1,4 +1,4 @@
1
- import { Combine, TypeThunkAsync } from 'ts-gems';
1
+ import type { Combine, TypeThunkAsync } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
3
  import { DocumentElement } from '../common/document-element.js';
4
4
  import { ApiFieldDecorator } from '../decorators/api-field-decorator.js';
@@ -1,5 +1,5 @@
1
- import { StrictOmit, Type } from 'ts-gems';
2
- import { IsObject, Validator } from 'valgen';
1
+ import { type StrictOmit, type Type } from 'ts-gems';
2
+ import { type IsObject, type Validator } from 'valgen';
3
3
  import { FieldsProjection, ResponsiveMap } from '../../helpers/index.js';
4
4
  import { OpraSchema } from '../../schema/index.js';
5
5
  import type { DocumentElement } from '../common/document-element.js';
@@ -7,7 +7,6 @@ import { DocumentInitContext } from '../common/document-init-context.js';
7
7
  import type { ApiField } from './api-field.js';
8
8
  import type { ComplexType } from './complex-type.js';
9
9
  import { DataType } from './data-type.js';
10
- import Field = OpraSchema.Field;
11
10
  export declare const FIELD_PATH_PATTERN: RegExp;
12
11
  /**
13
12
  * Type definition of class constructor for ComplexTypeBase
@@ -43,7 +42,7 @@ declare abstract class ComplexTypeBaseClass extends DataType {
43
42
  readonly ctor?: Type;
44
43
  readonly fields: ResponsiveMap<ApiField>;
45
44
  readonly additionalFields?: boolean | DataType | ['error'] | ['error', string];
46
- readonly keyField?: Field.Name;
45
+ readonly keyField?: OpraSchema.Field.Name;
47
46
  /**
48
47
  *
49
48
  */
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { Combine, Type, TypeThunkAsync } from 'ts-gems';
2
+ import type { Combine, Type, TypeThunkAsync } from 'ts-gems';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
4
  import type { DocumentElement } from '../common/document-element.js';
5
5
  import { DocumentInitContext } from '../common/document-init-context.js';
@@ -1,5 +1,5 @@
1
- import { StrictOmit, Type } from 'ts-gems';
2
- import { ValidationOptions, Validator } from 'valgen';
1
+ import { type StrictOmit, type Type } from 'ts-gems';
2
+ import type { ValidationOptions, Validator } from 'valgen';
3
3
  import { FieldsProjection } from '../../helpers/index.js';
4
4
  import type { DataTypeBase } from '../../schema/data-type/data-type.interface.js';
5
5
  import { OpraSchema } from '../../schema/index.js';
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
- import { Combine, Type } from 'ts-gems';
3
- import { Validator } from 'valgen';
2
+ import { type Combine, type Type } from 'ts-gems';
3
+ import { type Validator } from 'valgen';
4
4
  import { OpraSchema } from '../../schema/index.js';
5
5
  import type { DocumentElement } from '../common/document-element.js';
6
6
  import { DataType } from './data-type.js';
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class Base64Type {
4
4
  constructor(attributes?: Partial<Base64Type>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class DateStringType {
4
4
  constructor(attributes?: Partial<DateStringType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class DateTimeStringType {
4
4
  constructor(attributes?: Partial<DateTimeStringType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class DateTimeType {
4
4
  constructor(attributes?: Partial<DateTimeType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class DateType {
4
4
  constructor(attributes?: Partial<DateType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class EmailType {
4
4
  constructor(attributes?: Partial<EmailType>);
@@ -1,5 +1,5 @@
1
- import { Type } from 'ts-gems';
2
- import { Validator } from 'valgen';
1
+ import type { Type } from 'ts-gems';
2
+ import { type Validator } from 'valgen';
3
3
  import { DocumentElement } from '../../common/document-element.js';
4
4
  import { DECODER, ENCODER } from '../../constants.js';
5
5
  export declare class FieldPathType {
@@ -9,7 +9,7 @@ export declare class FieldPathType {
9
9
  [DECODER](properties: Partial<this>, element: DocumentElement): Validator;
10
10
  [ENCODER](properties: Partial<this>, element: DocumentElement): Validator;
11
11
  toJSON(properties: Partial<FieldPathType>, element: DocumentElement): {
12
- dataType: string | import("../../../schema/data-type/complex-type.interface.js").ComplexType;
12
+ dataType: string | import("../../../schema/opra-schema.js").ComplexType;
13
13
  allowSigns: "first" | "each" | undefined;
14
14
  };
15
15
  }
@@ -1,5 +1,5 @@
1
- import { Type } from 'ts-gems';
2
- import { Validator } from 'valgen';
1
+ import type { Type } from 'ts-gems';
2
+ import { type Validator } from 'valgen';
3
3
  import { FilterRules } from '../../../filter/filter-rules.js';
4
4
  import type { DocumentElement } from '../../common/document-element.js';
5
5
  import { DECODER, ENCODER } from '../../constants.js';
@@ -10,7 +10,7 @@ export declare class FilterType {
10
10
  protected [DECODER](properties: Partial<this>, element: DocumentElement): Validator;
11
11
  protected [ENCODER](): Validator;
12
12
  toJSON(properties: Partial<FilterType>, element: DocumentElement): {
13
- dataType: string | import("../../../schema/data-type/complex-type.interface.js").ComplexType;
13
+ dataType: string | import("../../../schema/opra-schema.js").ComplexType;
14
14
  rules: Record<string, FilterRules.Rule> | undefined;
15
15
  };
16
16
  }
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class ObjectIdType {
4
4
  constructor(attributes?: Partial<ObjectIdType>);
@@ -1,5 +1,5 @@
1
- import { DeepPartial, Type } from 'ts-gems';
2
- import { ErrorIssue } from '../../../exception/index.js';
1
+ import type { DeepPartial, Type } from 'ts-gems';
2
+ import type { ErrorIssue } from '../../../exception/index.js';
3
3
  export declare class OperationResult<TPayload = any> {
4
4
  constructor(init?: DeepPartial<OperationResult>);
5
5
  affected?: number;
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class TimeType {
4
4
  constructor(attributes?: Partial<TimeType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class UrlType {
4
4
  constructor(attributes?: Partial<UrlType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class UuidType {
4
4
  constructor(attributes?: Partial<UuidType>);
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { Combine, Type } from 'ts-gems';
2
+ import { type Combine, type Type } from 'ts-gems';
3
3
  import type { Field } from '../../schema/data-type/field.interface.js';
4
4
  import { OpraSchema } from '../../schema/index.js';
5
5
  import { DocumentElement } from '../common/document-element.js';
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { Class, Combine, Type } from 'ts-gems';
2
+ import type { Class, Combine, Type } from 'ts-gems';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
4
  import type { DocumentElement } from '../common/document-element.js';
5
5
  import type { ComplexType } from './complex-type.js';
@@ -1,4 +1,4 @@
1
- import { Class, Type } from 'ts-gems';
1
+ import type { Class, Type } from 'ts-gems';
2
2
  import type { DataType } from './data-type.js';
3
3
  export declare function OmitType(baseType: string | Type, keys: string[], options?: DataType.Options): Type;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Class, PartialSome, Type } from 'ts-gems';
1
+ import type { Class, PartialSome, Type } from 'ts-gems';
2
2
  import type { DataType } from './data-type.js';
3
3
  export declare function PartialType(baseType: string | Type, keys: string[], options?: DataType.Options): Type;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Class, Type } from 'ts-gems';
1
+ import type { Class, Type } from 'ts-gems';
2
2
  import type { DataType } from './data-type.js';
3
3
  /**
4
4
  * Create a new MappedType that picks given fields from base type
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  export declare class AnyType {
4
4
  constructor(properties?: Partial<AnyType>);
@@ -1,4 +1,4 @@
1
- import { Validator } from 'valgen';
1
+ import { type Validator } from 'valgen';
2
2
  import { DECODER, ENCODER } from '../../constants.js';
3
3
  import { NumberType } from './number.type.js';
4
4
  export declare class BigintType extends NumberType {