@opra/common 1.0.0-alpha.9 → 1.0.0-beta.1

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 (199) hide show
  1. package/browser/index.cjs +12 -0
  2. package/browser/index.mjs +12 -0
  3. package/cjs/document/api-document.js +11 -0
  4. package/cjs/document/common/api-base.js +1 -1
  5. package/cjs/document/common/document-element.js +2 -0
  6. package/cjs/document/data-type/api-field.js +8 -7
  7. package/cjs/document/data-type/complex-type-base.js +5 -3
  8. package/cjs/document/data-type/extended-types/date-string.type.js +2 -2
  9. package/cjs/document/data-type/extended-types/date-time-string.type.js +2 -2
  10. package/cjs/document/data-type/extended-types/date-time.type.js +2 -2
  11. package/cjs/document/data-type/extended-types/date.type.js +2 -2
  12. package/cjs/document/data-type/extended-types/email.type.js +2 -2
  13. package/cjs/document/data-type/extended-types/filter.type.js +1 -1
  14. package/cjs/document/data-type/extended-types/time.type.js +2 -2
  15. package/cjs/document/data-type/extended-types/url.type.js +2 -2
  16. package/cjs/document/data-type/omit-type.js +7 -2
  17. package/cjs/document/data-type/partial-type.js +7 -2
  18. package/cjs/document/data-type/pick-type.js +1 -2
  19. package/cjs/document/data-type/primitive-types/object.type.js +0 -3
  20. package/cjs/document/data-type/required-type.js +1 -2
  21. package/cjs/document/data-type/simple-type.js +1 -6
  22. package/cjs/document/data-type/utils/create-mapped-class.js +1 -2
  23. package/cjs/document/data-type/utils/get-is-inherited-predicate-fn.js +1 -2
  24. package/cjs/document/decorators/api-field-decorator.js +4 -6
  25. package/cjs/document/decorators/complex-type.decorator.js +1 -2
  26. package/cjs/document/decorators/http-controller.decorator.js +2 -3
  27. package/cjs/document/decorators/http-operation-entity.decorator.js +68 -74
  28. package/cjs/document/decorators/http-operation.decorator.js +4 -2
  29. package/cjs/document/decorators/simple-type.decorator.js +2 -3
  30. package/cjs/document/factory/api-document.factory.js +17 -8
  31. package/cjs/document/http/http-api.js +0 -1
  32. package/cjs/document/http/http-controller.js +4 -2
  33. package/cjs/document/http/http-media-type.js +17 -2
  34. package/cjs/document/http/http-multipart-field.js +0 -1
  35. package/cjs/document/http/http-operation-response.js +0 -1
  36. package/cjs/document/http/http-operation.js +12 -1
  37. package/cjs/document/http/http-parameter.js +2 -0
  38. package/cjs/document/http/http-request-body.js +0 -1
  39. package/cjs/document/http/http-status-range.js +5 -2
  40. package/cjs/document/utils/parse-regexp.util.js +1 -2
  41. package/cjs/document/utils/string-compare.util.js +1 -2
  42. package/cjs/exception/opra-exception.js +1 -0
  43. package/cjs/filter/build.js +21 -22
  44. package/cjs/filter/filter-rules.js +17 -16
  45. package/cjs/filter/parse.js +1 -2
  46. package/cjs/filter/utils.js +2 -3
  47. package/cjs/helpers/function-utils.js +1 -2
  48. package/cjs/helpers/get-stack-filename.js +2 -3
  49. package/cjs/helpers/index.js +1 -0
  50. package/cjs/helpers/mixin-utils.js +2 -3
  51. package/cjs/helpers/object-utils.js +5 -6
  52. package/cjs/helpers/parse-fields-projection.js +3 -3
  53. package/cjs/helpers/safe-json-stringify.js +16 -0
  54. package/cjs/helpers/type-guards.js +10 -11
  55. package/cjs/i18n/string-utils.js +2 -3
  56. package/cjs/i18n/translate.js +1 -2
  57. package/cjs/schema/index.js +2 -27
  58. package/cjs/schema/opra-schema.js +24 -0
  59. package/cjs/schema/type-guards.js +7 -8
  60. package/esm/document/api-document.js +11 -0
  61. package/esm/document/common/api-base.js +1 -1
  62. package/esm/document/common/document-element.js +2 -0
  63. package/esm/document/data-type/api-field.js +8 -7
  64. package/esm/document/data-type/complex-type-base.js +5 -3
  65. package/esm/document/data-type/extended-types/date-string.type.js +2 -2
  66. package/esm/document/data-type/extended-types/date-time-string.type.js +2 -2
  67. package/esm/document/data-type/extended-types/date-time.type.js +2 -2
  68. package/esm/document/data-type/extended-types/date.type.js +2 -2
  69. package/esm/document/data-type/extended-types/email.type.js +2 -2
  70. package/esm/document/data-type/extended-types/filter.type.js +1 -1
  71. package/esm/document/data-type/extended-types/time.type.js +2 -2
  72. package/esm/document/data-type/extended-types/url.type.js +2 -2
  73. package/esm/document/data-type/omit-type.js +6 -0
  74. package/esm/document/data-type/partial-type.js +6 -0
  75. package/esm/document/data-type/primitive-types/object.type.js +0 -3
  76. package/esm/document/data-type/simple-type.js +1 -6
  77. package/esm/document/decorators/api-field-decorator.js +1 -2
  78. package/esm/document/decorators/http-controller.decorator.js +1 -1
  79. package/esm/document/decorators/http-operation-entity.decorator.js +25 -31
  80. package/esm/document/decorators/http-operation.decorator.js +3 -0
  81. package/esm/document/factory/api-document.factory.js +17 -7
  82. package/esm/document/http/http-api.js +0 -1
  83. package/esm/document/http/http-controller.js +3 -2
  84. package/esm/document/http/http-media-type.js +16 -2
  85. package/esm/document/http/http-multipart-field.js +0 -1
  86. package/esm/document/http/http-operation-response.js +0 -1
  87. package/esm/document/http/http-operation.js +12 -1
  88. package/esm/document/http/http-parameter.js +2 -0
  89. package/esm/document/http/http-request-body.js +0 -1
  90. package/esm/document/http/http-status-range.js +5 -2
  91. package/esm/exception/opra-exception.js +1 -0
  92. package/esm/filter/filter-rules.js +10 -9
  93. package/esm/helpers/index.js +1 -0
  94. package/esm/helpers/object-utils.js +2 -2
  95. package/esm/helpers/safe-json-stringify.js +13 -0
  96. package/esm/package.json +3 -0
  97. package/esm/schema/index.js +2 -27
  98. package/esm/schema/opra-schema.js +21 -0
  99. package/package.json +47 -53
  100. package/types/document/api-document.d.ts +2 -1
  101. package/types/document/common/api-base.d.ts +2 -2
  102. package/types/document/common/data-type-map.d.ts +1 -1
  103. package/types/document/common/document-element.d.ts +1 -0
  104. package/types/document/common/document-node.d.ts +8 -8
  105. package/types/document/common/value.d.ts +1 -1
  106. package/types/document/data-type/api-field.d.ts +11 -1
  107. package/types/document/data-type/complex-type-base.d.ts +6 -7
  108. package/types/document/data-type/complex-type.d.ts +1 -1
  109. package/types/document/data-type/data-type.d.ts +3 -2
  110. package/types/document/data-type/enum-type.d.ts +2 -2
  111. package/types/document/data-type/extended-types/base64.type.d.ts +1 -1
  112. package/types/document/data-type/extended-types/date-string.type.d.ts +1 -1
  113. package/types/document/data-type/extended-types/date-time-string.type.d.ts +1 -1
  114. package/types/document/data-type/extended-types/date-time.type.d.ts +1 -1
  115. package/types/document/data-type/extended-types/date.type.d.ts +1 -1
  116. package/types/document/data-type/extended-types/email.type.d.ts +1 -1
  117. package/types/document/data-type/extended-types/field-path.type.d.ts +3 -3
  118. package/types/document/data-type/extended-types/filter.type.d.ts +3 -3
  119. package/types/document/data-type/extended-types/object-id.type.d.ts +1 -1
  120. package/types/document/data-type/extended-types/operation-result.type.d.ts +2 -2
  121. package/types/document/data-type/extended-types/time.type.d.ts +1 -1
  122. package/types/document/data-type/extended-types/url.type.d.ts +1 -1
  123. package/types/document/data-type/extended-types/uuid.type.d.ts +1 -1
  124. package/types/document/data-type/mapped-type.d.ts +3 -3
  125. package/types/document/data-type/mixin-type.d.ts +1 -1
  126. package/types/document/data-type/omit-type.d.ts +1 -7
  127. package/types/document/data-type/partial-type.d.ts +1 -7
  128. package/types/document/data-type/pick-type.d.ts +3 -3
  129. package/types/document/data-type/primitive-types/any.type.d.ts +1 -1
  130. package/types/document/data-type/primitive-types/bigint.type.d.ts +1 -1
  131. package/types/document/data-type/primitive-types/boolean.type.d.ts +1 -1
  132. package/types/document/data-type/primitive-types/integer.type.d.ts +1 -1
  133. package/types/document/data-type/primitive-types/null.type.d.ts +1 -1
  134. package/types/document/data-type/primitive-types/number.type.d.ts +1 -1
  135. package/types/document/data-type/primitive-types/string.type.d.ts +1 -1
  136. package/types/document/data-type/required-type.d.ts +8 -8
  137. package/types/document/data-type/simple-type.d.ts +2 -2
  138. package/types/document/data-type/utils/create-mapped-class.d.ts +2 -2
  139. package/types/document/decorators/api-field-decorator.d.ts +1 -1
  140. package/types/document/decorators/http-controller.decorator.d.ts +3 -3
  141. package/types/document/decorators/http-operation-entity.decorator.d.ts +5 -4
  142. package/types/document/decorators/http-operation.decorator.d.ts +1 -1
  143. package/types/document/factory/api-document.factory.d.ts +2 -1
  144. package/types/document/factory/data-type.factory.d.ts +1 -1
  145. package/types/document/factory/http-api.factory.d.ts +1 -1
  146. package/types/document/http/http-api.d.ts +2 -2
  147. package/types/document/http/http-controller.d.ts +1 -1
  148. package/types/document/http/http-media-type.d.ts +3 -2
  149. package/types/document/http/http-multipart-field.d.ts +1 -2
  150. package/types/document/http/http-operation-response.d.ts +1 -1
  151. package/types/document/http/http-operation.d.ts +6 -5
  152. package/types/document/http/http-parameter.d.ts +2 -2
  153. package/types/document/http/http-request-body.d.ts +1 -1
  154. package/types/document/http/http-status-range.d.ts +2 -1
  155. package/types/exception/http-errors/bad-request.error.d.ts +1 -1
  156. package/types/exception/http-errors/conflict.error.d.ts +1 -1
  157. package/types/exception/http-errors/failed-dependency.error.d.ts +1 -1
  158. package/types/exception/http-errors/forbidden.error.d.ts +1 -1
  159. package/types/exception/http-errors/internal-server.error.d.ts +1 -1
  160. package/types/exception/http-errors/method-not-allowed.error.d.ts +1 -1
  161. package/types/exception/http-errors/not-acceptable.error.d.ts +1 -1
  162. package/types/exception/http-errors/not-found.error.d.ts +1 -1
  163. package/types/exception/http-errors/permission.error.d.ts +1 -1
  164. package/types/exception/http-errors/unauthorized.error.d.ts +1 -1
  165. package/types/exception/http-errors/unprocessable-entity.error.d.ts +1 -1
  166. package/types/exception/opra-exception.d.ts +1 -1
  167. package/types/exception/opra-http-error.d.ts +1 -1
  168. package/types/filter/antlr/OpraFilterParser.d.ts +1 -1
  169. package/types/filter/ast/expressions/comparison-expression.d.ts +1 -1
  170. package/types/filter/errors.d.ts +3 -4
  171. package/types/filter/filter-rules.d.ts +5 -5
  172. package/types/filter/opra-error-listener.d.ts +1 -2
  173. package/types/helpers/function-utils.d.ts +1 -1
  174. package/types/helpers/index.d.ts +1 -0
  175. package/types/helpers/mixin-utils.d.ts +1 -1
  176. package/types/helpers/object-utils.d.ts +1 -1
  177. package/types/helpers/safe-json-stringify.d.ts +1 -0
  178. package/types/helpers/type-guards.d.ts +1 -3
  179. package/types/i18n/i18n.d.ts +2 -2
  180. package/types/i18n/translate.d.ts +1 -1
  181. package/types/index.d.cts +9 -0
  182. package/types/schema/{document.interface.d.ts → api-document.interface.d.ts} +4 -4
  183. package/types/schema/data-type/complex-type.interface.d.ts +1 -1
  184. package/types/schema/data-type/data-type.interface.d.ts +1 -1
  185. package/types/schema/data-type/enum-type.interface.d.ts +1 -1
  186. package/types/schema/data-type/mapped-type.interface.d.ts +3 -3
  187. package/types/schema/data-type/mixin-type.interface.d.ts +1 -1
  188. package/types/schema/data-type-container.interface.d.ts +1 -1
  189. package/types/schema/http/http-controller.interface.d.ts +2 -2
  190. package/types/schema/http/http-media-type.interface.d.ts +1 -1
  191. package/types/schema/http/http-operation-response.interface.d.ts +2 -2
  192. package/types/schema/http/http-operation.interface.d.ts +8 -4
  193. package/types/schema/http/http-parameter.interface.d.ts +2 -2
  194. package/types/schema/index.d.ts +2 -62
  195. package/types/schema/opra-schema.d.ts +21 -0
  196. package/types/schema/type-guards.d.ts +1 -1
  197. package/browser.js +0 -13393
  198. /package/cjs/schema/{document.interface.js → api-document.interface.js} +0 -0
  199. /package/esm/schema/{document.interface.js → api-document.interface.js} +0 -0
@@ -83,12 +83,12 @@ tslib_1.__decorate([
83
83
  tslib_1.__metadata("design:type", String)
84
84
  ], EmailType.prototype, "blacklistedChars", void 0);
85
85
  exports.EmailType = EmailType = tslib_1.__decorate([
86
- (0, simple_type_js_1.SimpleType)({
86
+ ((0, simple_type_js_1.SimpleType)({
87
87
  description: 'An email value',
88
88
  nameMappings: {
89
89
  js: 'string',
90
90
  json: 'string',
91
91
  },
92
- }).Example('some.body@example.com'),
92
+ }).Example('some.body@example.com')),
93
93
  tslib_1.__metadata("design:paramtypes", [Object])
94
94
  ], EmailType);
@@ -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
  }
@@ -41,7 +41,7 @@ tslib_1.__decorate([
41
41
  tslib_1.__metadata("design:type", String)
42
42
  ], TimeType.prototype, "maxValue", void 0);
43
43
  exports.TimeType = TimeType = tslib_1.__decorate([
44
- (0, simple_type_js_1.SimpleType)({
44
+ ((0, simple_type_js_1.SimpleType)({
45
45
  description: 'Time string in 24h format',
46
46
  nameMappings: {
47
47
  js: 'string',
@@ -49,6 +49,6 @@ exports.TimeType = TimeType = tslib_1.__decorate([
49
49
  },
50
50
  })
51
51
  .Example('18:23:00', 'Full time value')
52
- .Example('18:23:00', 'Time value without seconds'),
52
+ .Example('18:23:00', 'Time value without seconds')),
53
53
  tslib_1.__metadata("design:paramtypes", [Object])
54
54
  ], TimeType);
@@ -19,12 +19,12 @@ let UrlType = class UrlType {
19
19
  };
20
20
  exports.UrlType = UrlType;
21
21
  exports.UrlType = UrlType = tslib_1.__decorate([
22
- (0, simple_type_js_1.SimpleType)({
22
+ ((0, simple_type_js_1.SimpleType)({
23
23
  description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
24
24
  nameMappings: {
25
25
  js: 'string',
26
26
  json: 'string',
27
27
  },
28
- }).Example('http://tempuri.org'),
28
+ }).Example('http://tempuri.org')),
29
29
  tslib_1.__metadata("design:paramtypes", [Object])
30
30
  ], UrlType);
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OmitType = void 0;
3
+ exports.OmitType = OmitType;
4
4
  const create_mapped_class_js_1 = require("./utils/create-mapped-class.js");
5
+ /**
6
+ * Create a new MappedType that omits given fields from base type
7
+ * @param baseType
8
+ * @param keys
9
+ * @param options
10
+ */
5
11
  /**
6
12
  *
7
13
  */
8
14
  function OmitType(baseType, keys, options) {
9
15
  return (0, create_mapped_class_js_1.createMappedClass)(baseType, { omit: keys }, options);
10
16
  }
11
- exports.OmitType = OmitType;
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartialType = void 0;
3
+ exports.PartialType = PartialType;
4
4
  const create_mapped_class_js_1 = require("./utils/create-mapped-class.js");
5
+ /**
6
+ * Create a new MappedType that marks given or all fields as optional
7
+ * @param baseType
8
+ * @param keys
9
+ * @param options
10
+ */
5
11
  /**
6
12
  *
7
13
  */
@@ -10,4 +16,3 @@ function PartialType(base, ...args) {
10
16
  const options = Array.isArray(args[0]) ? args[1] : args[0];
11
17
  return (0, create_mapped_class_js_1.createMappedClass)(base, { partial: keys }, options);
12
18
  }
13
- exports.PartialType = PartialType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PickType = void 0;
3
+ exports.PickType = PickType;
4
4
  const create_mapped_class_js_1 = require("./utils/create-mapped-class.js");
5
5
  /**
6
6
  *
@@ -8,4 +8,3 @@ const create_mapped_class_js_1 = require("./utils/create-mapped-class.js");
8
8
  function PickType(baseType, keys, options) {
9
9
  return (0, create_mapped_class_js_1.createMappedClass)(baseType, { pick: keys }, options);
10
10
  }
11
- exports.PickType = PickType;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectType = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const constants_js_1 = require("../../constants.js");
6
5
  const complex_type_js_1 = require("../complex-type.js");
7
6
  let ObjectType = class ObjectType {
8
7
  constructor(properties) {
@@ -19,5 +18,3 @@ exports.ObjectType = ObjectType = tslib_1.__decorate([
19
18
  }),
20
19
  tslib_1.__metadata("design:paramtypes", [Object])
21
20
  ], ObjectType);
22
- const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, ObjectType);
23
- metadata.ctor = Object;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequiredType = void 0;
3
+ exports.RequiredType = RequiredType;
4
4
  const create_mapped_class_js_1 = require("./utils/create-mapped-class.js");
5
5
  /**
6
6
  *
@@ -10,4 +10,3 @@ function RequiredType(base, ...args) {
10
10
  const options = Array.isArray(args[0]) ? args[1] : args[0];
11
11
  return (0, create_mapped_class_js_1.createMappedClass)(base, { required: keys }, options);
12
12
  }
13
- exports.RequiredType = RequiredType;
@@ -86,12 +86,7 @@ class SimpleTypeClass extends data_type_js_1.DataType {
86
86
  properties = this.properties.toJSON(this.properties, this.owner);
87
87
  }
88
88
  else
89
- properties = this.properties || {};
90
- properties = Object.keys(this.attributes).reduce((o, k) => {
91
- if (properties[k] !== undefined)
92
- o[k] = properties[k];
93
- return o;
94
- }, {});
89
+ properties = this.properties ? (0, index_js_1.cloneObject)(this.properties) : {};
95
90
  const baseName = this.base ? this.node.getDataTypeNameWithNs(this.base) : undefined;
96
91
  const out = (0, index_js_1.omitUndefined)({
97
92
  ...data_type_js_1.DataType.prototype.toJSON.apply(this),
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMappedClass = void 0;
3
+ exports.createMappedClass = createMappedClass;
4
4
  const index_js_1 = require("../../../helpers/index.js");
5
5
  const index_js_2 = require("../../../schema/index.js");
6
6
  const constants_js_1 = require("../../constants.js");
@@ -52,4 +52,3 @@ function createMappedClass(source, config, options) {
52
52
  }
53
53
  return MappedClass;
54
54
  }
55
- exports.createMappedClass = createMappedClass;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIsInheritedPredicateFn = void 0;
3
+ exports.getIsInheritedPredicateFn = getIsInheritedPredicateFn;
4
4
  function getIsInheritedPredicateFn(pick, omit) {
5
5
  const pickKeys = pick?.map(x => String(x).toLowerCase());
6
6
  const omitKeys = omit?.map(x => String(x).toLowerCase());
@@ -12,4 +12,3 @@ function getIsInheritedPredicateFn(pick, omit) {
12
12
  return true;
13
13
  };
14
14
  }
15
- exports.getIsInheritedPredicateFn = getIsInheritedPredicateFn;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiFieldDecorator = void 0;
4
- const index_js_1 = require("../../helpers/index.js");
5
- const index_js_2 = require("../../schema/index.js");
3
+ exports.ApiFieldDecorator = ApiFieldDecorator;
4
+ const index_js_1 = require("../../schema/index.js");
6
5
  const constants_js_1 = require("../constants.js");
7
6
  function ApiFieldDecorator(options) {
8
7
  return function (target, propertyKey) {
9
8
  if (typeof propertyKey !== 'string')
10
9
  throw new TypeError(`Symbol properties can't be used as a field`);
11
10
  const metadata = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, target.constructor) || {};
12
- metadata.kind = index_js_2.OpraSchema.ComplexType.Kind;
11
+ metadata.kind = index_js_1.OpraSchema.ComplexType.Kind;
13
12
  metadata.fields = metadata.fields || {};
14
13
  const designType = Reflect.getMetadata('design:type', target, propertyKey);
15
14
  const elemMeta = (metadata.fields[propertyKey] = {
@@ -20,7 +19,6 @@ function ApiFieldDecorator(options) {
20
19
  }
21
20
  else
22
21
  elemMeta.type = elemMeta.type || designType;
23
- Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, (0, index_js_1.omitUndefined)(metadata), target.constructor);
22
+ Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target.constructor);
24
23
  };
25
24
  }
26
- exports.ApiFieldDecorator = ApiFieldDecorator;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComplexTypeDecorator = void 0;
3
+ exports.ComplexTypeDecorator = ComplexTypeDecorator;
4
4
  const tslib_1 = require("tslib");
5
5
  const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
6
  const index_js_1 = require("../../schema/index.js");
@@ -30,4 +30,3 @@ function ComplexTypeDecorator(options) {
30
30
  Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name', 'base', 'fields']));
31
31
  };
32
32
  }
33
- exports.ComplexTypeDecorator = ComplexTypeDecorator;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpControllerDecoratorFactory = void 0;
3
+ exports.HttpControllerDecoratorFactory = HttpControllerDecoratorFactory;
4
4
  const tslib_1 = require("tslib");
5
5
  const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
6
  const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
7
7
  const index_js_1 = require("../../schema/index.js");
8
8
  const constants_js_1 = require("../constants.js");
9
- const CLASS_NAME_PATTERN = /^(.*)(Collection|Singleton|Resource|Controller)$/;
9
+ const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
10
10
  function HttpControllerDecoratorFactory(options) {
11
11
  const decoratorChain = [];
12
12
  /**
@@ -139,4 +139,3 @@ function HttpControllerDecoratorFactory(options) {
139
139
  };
140
140
  return decorator;
141
141
  }
142
- exports.HttpControllerDecoratorFactory = HttpControllerDecoratorFactory;
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const filter_rules_js_1 = require("../../filter/filter-rules.js");
4
- const index_js_1 = require("../../helpers/index.js");
5
- const index_js_2 = require("../../http/index.js");
4
+ const index_js_1 = require("../../http/index.js");
6
5
  const constants_js_1 = require("../constants.js");
7
- const index_js_3 = require("../data-type/extended-types/index.js");
8
- const index_js_4 = require("../data-type/primitive-types/index.js");
6
+ const index_js_2 = require("../data-type/extended-types/index.js");
7
+ const index_js_3 = require("../data-type/primitive-types/index.js");
9
8
  const http_operation_js_1 = require("../http/http-operation.js");
10
9
  const http_operation_decorator_js_1 = require("./http-operation.decorator.js");
11
10
  /** Implementation **/
@@ -22,7 +21,7 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
22
21
  args = { ...arg1, type: arg0 };
23
22
  /** Initialize the decorator and the chain */
24
23
  const decoratorChain = [];
25
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
24
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
26
25
  method: 'POST',
27
26
  ...args,
28
27
  composition: 'Entity.Create',
@@ -31,11 +30,11 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
31
30
  ...args.requestBody,
32
31
  required: true,
33
32
  },
34
- }));
33
+ });
35
34
  decorator
36
35
  .QueryParam('projection', {
37
36
  description: 'Determines fields projection',
38
- type: new index_js_3.FieldPathType({
37
+ type: new index_js_2.FieldPathType({
39
38
  dataType: args.type,
40
39
  allowSigns: 'each',
41
40
  }),
@@ -43,18 +42,16 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
43
42
  arraySeparator: ',',
44
43
  })
45
44
  .RequestContent(args.requestBody?.type || args.type)
46
- .Response(index_js_2.HttpStatusCode.CREATED, {
45
+ .Response(index_js_1.HttpStatusCode.CREATED, {
47
46
  description: 'Operation is successful. Returns OperationResult with "payload" field that contains the created resource.',
48
- contentType: index_js_2.MimeTypes.opra_response_json,
47
+ contentType: index_js_1.MimeTypes.opra_response_json,
49
48
  type: args.type,
50
49
  partial: 'deep',
51
50
  })
52
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
51
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
53
52
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
54
- contentType: index_js_2.MimeTypes.opra_response_json,
53
+ contentType: index_js_1.MimeTypes.opra_response_json,
55
54
  });
56
- if (typeof args.type === 'function')
57
- decorator.UseType(args.type);
58
55
  decoratorChain.push((operationMeta) => {
59
56
  const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
60
57
  compositionOptions.type = getDataTypeName(args.type);
@@ -73,22 +70,20 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
73
70
  args = { ...arg1, type: arg0 };
74
71
  /** Initialize the decorator and the chain */
75
72
  const decoratorChain = [];
76
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
73
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
77
74
  method: 'DELETE',
78
75
  ...args,
79
76
  composition: 'Entity.Delete',
80
- }));
77
+ });
81
78
  decorator
82
- .Response(index_js_2.HttpStatusCode.OK, {
79
+ .Response(index_js_1.HttpStatusCode.OK, {
83
80
  description: 'Operation is successful. Returns OperationResult with "affected" field.',
84
- contentType: index_js_2.MimeTypes.opra_response_json,
81
+ contentType: index_js_1.MimeTypes.opra_response_json,
85
82
  })
86
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
83
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
87
84
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
88
- contentType: index_js_2.MimeTypes.opra_response_json,
85
+ contentType: index_js_1.MimeTypes.opra_response_json,
89
86
  });
90
- if (typeof args.type === 'function')
91
- decorator.UseType(args.type);
92
87
  /**
93
88
  *
94
89
  */
@@ -110,6 +105,7 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
110
105
  decoratorChain.push((meta) => {
111
106
  if (!meta.path?.includes(':' + name))
112
107
  meta.path = (meta.path || '') + '@:' + name;
108
+ meta.mergePath = true;
113
109
  });
114
110
  return decorator;
115
111
  };
@@ -132,28 +128,26 @@ http_operation_js_1.HttpOperation.Entity.DeleteMany = function (arg0, arg1) {
132
128
  /** Initialize the decorator and the chain */
133
129
  const decoratorChain = [];
134
130
  const filterRules = new filter_rules_js_1.FilterRules();
135
- const filterType = new index_js_3.FilterType({ dataType: args.type });
131
+ const filterType = new index_js_2.FilterType({ dataType: args.type });
136
132
  filterType.rules = {};
137
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
133
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
138
134
  method: 'DELETE',
139
135
  ...args,
140
136
  composition: 'Entity.DeleteMany',
141
- }));
137
+ });
142
138
  decorator
143
- .Response(index_js_2.HttpStatusCode.OK, {
139
+ .Response(index_js_1.HttpStatusCode.OK, {
144
140
  description: 'Operation is successful. Returns OperationResult with "affected" field.',
145
- contentType: index_js_2.MimeTypes.opra_response_json,
141
+ contentType: index_js_1.MimeTypes.opra_response_json,
146
142
  })
147
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
143
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
148
144
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
149
- contentType: index_js_2.MimeTypes.opra_response_json,
145
+ contentType: index_js_1.MimeTypes.opra_response_json,
150
146
  })
151
147
  .QueryParam('filter', {
152
148
  type: filterType,
153
149
  description: 'Determines filter fields',
154
150
  });
155
- if (typeof args.type === 'function')
156
- decorator.UseType(args.type);
157
151
  decoratorChain.push((operationMeta) => {
158
152
  const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
159
153
  compositionOptions.type = getDataTypeName(args.type);
@@ -180,32 +174,32 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
180
174
  /** Initialize the decorator and the chain */
181
175
  const decoratorChain = [];
182
176
  const filterRules = new filter_rules_js_1.FilterRules();
183
- const filterType = new index_js_3.FilterType({ dataType: args.type });
177
+ const filterType = new index_js_2.FilterType({ dataType: args.type });
184
178
  filterType.rules = {};
185
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
179
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
186
180
  method: 'GET',
187
181
  ...args,
188
182
  composition: 'Entity.FindMany',
189
- }));
183
+ });
190
184
  decorator
191
- .Response(index_js_2.HttpStatusCode.OK, {
185
+ .Response(index_js_1.HttpStatusCode.OK, {
192
186
  description: 'Operation is successful. Returns OperationResult with "payload" field that contains list of resources.',
193
- contentType: index_js_2.MimeTypes.opra_response_json,
187
+ contentType: index_js_1.MimeTypes.opra_response_json,
194
188
  type: args.type,
195
189
  partial: 'deep',
196
190
  isArray: true,
197
191
  })
198
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
192
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
199
193
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
200
- contentType: index_js_2.MimeTypes.opra_response_json,
194
+ contentType: index_js_1.MimeTypes.opra_response_json,
201
195
  })
202
196
  .QueryParam('limit', {
203
197
  description: 'Determines number of returning instances',
204
- type: new index_js_4.IntegerType({ minValue: 1 }),
198
+ type: new index_js_3.IntegerType({ minValue: 1, maxValue: args.maxLimit }),
205
199
  })
206
200
  .QueryParam('skip', {
207
201
  description: 'Determines number of returning instances',
208
- type: new index_js_4.IntegerType({ minValue: 1 }),
202
+ type: new index_js_3.IntegerType({ minValue: 1 }),
209
203
  })
210
204
  .QueryParam('count', {
211
205
  description: 'Counts all matching instances if enabled',
@@ -213,7 +207,7 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
213
207
  })
214
208
  .QueryParam('projection', {
215
209
  description: 'Determines fields projection',
216
- type: new index_js_3.FieldPathType({
210
+ type: new index_js_2.FieldPathType({
217
211
  dataType: args.type,
218
212
  allowSigns: 'each',
219
213
  }),
@@ -226,18 +220,22 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
226
220
  })
227
221
  .QueryParam('sort', {
228
222
  description: 'Determines sort fields',
229
- type: new index_js_3.FieldPathType({
223
+ type: new index_js_2.FieldPathType({
230
224
  dataType: args.type,
231
225
  allowSigns: 'first',
232
226
  }),
233
227
  isArray: true,
234
228
  arraySeparator: ',',
235
229
  });
236
- if (typeof args.type === 'function')
237
- decorator.UseType(args.type);
238
230
  decoratorChain.push((operationMeta) => {
239
231
  const compositionOptions = (operationMeta.compositionOptions = operationMeta.compositionOptions || {});
240
232
  compositionOptions.type = getDataTypeName(args.type);
233
+ if (args.defaultLimit)
234
+ compositionOptions.defaultLimit = args.defaultLimit;
235
+ if (args.defaultProjection)
236
+ compositionOptions.defaultProjection = args.defaultProjection;
237
+ if (args.maxLimit)
238
+ compositionOptions.maxLimit = args.maxLimit;
241
239
  });
242
240
  decorator.DefaultSort = (...fields) => {
243
241
  decoratorChain.push((operationMeta) => {
@@ -274,36 +272,34 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
274
272
  args = { ...arg1, type: arg0 };
275
273
  /** Initialize the decorator and the chain */
276
274
  const decoratorChain = [];
277
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
275
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
278
276
  method: 'GET',
279
277
  ...args,
280
278
  composition: 'Entity.Get',
281
- }));
279
+ });
282
280
  decorator
283
281
  .QueryParam('projection', {
284
282
  description: 'Determines fields projection',
285
- type: new index_js_3.FieldPathType({
283
+ type: new index_js_2.FieldPathType({
286
284
  dataType: args.type,
287
285
  allowSigns: 'each',
288
286
  }),
289
287
  isArray: true,
290
288
  arraySeparator: ',',
291
289
  })
292
- .Response(index_js_2.HttpStatusCode.OK, {
290
+ .Response(index_js_1.HttpStatusCode.OK, {
293
291
  description: 'Operation is successful. Returns OperationResult with "payload" field that contains the resource asked for.',
294
- contentType: index_js_2.MimeTypes.opra_response_json,
292
+ contentType: index_js_1.MimeTypes.opra_response_json,
295
293
  type: args.type,
296
294
  partial: 'deep',
297
295
  })
298
- .Response(index_js_2.HttpStatusCode.NO_CONTENT, {
296
+ .Response(index_js_1.HttpStatusCode.NO_CONTENT, {
299
297
  description: 'Operation is successful but no resource found',
300
298
  })
301
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
299
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
302
300
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
303
- contentType: index_js_2.MimeTypes.opra_response_json,
301
+ contentType: index_js_1.MimeTypes.opra_response_json,
304
302
  });
305
- if (typeof args.type === 'function')
306
- decorator.UseType(args.type);
307
303
  /**
308
304
  *
309
305
  */
@@ -325,6 +321,7 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
325
321
  decoratorChain.push((meta) => {
326
322
  if (!meta.path?.includes(':' + name))
327
323
  meta.path = (meta.path || '') + '@:' + name;
324
+ meta.mergePath = true;
328
325
  });
329
326
  return decorator;
330
327
  };
@@ -346,10 +343,10 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
346
343
  args = { ...arg1, type: arg0 };
347
344
  /** Initialize the decorator and the chain */
348
345
  const decoratorChain = [];
349
- const filterType = new index_js_3.FilterType({ dataType: args.type });
346
+ const filterType = new index_js_2.FilterType({ dataType: args.type });
350
347
  filterType.rules = {};
351
348
  const filterRules = new filter_rules_js_1.FilterRules();
352
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
349
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
353
350
  method: 'PATCH',
354
351
  ...args,
355
352
  composition: 'Entity.UpdateMany',
@@ -359,18 +356,16 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
359
356
  ...args.requestBody,
360
357
  required: true,
361
358
  },
362
- }));
363
- decorator.RequestContent(args.requestBody?.type || args.type);
364
- if (typeof args.type === 'function')
365
- decorator.UseType(args.type);
359
+ });
366
360
  decorator
367
- .Response(index_js_2.HttpStatusCode.OK, {
361
+ .RequestContent(args.requestBody?.type || args.type)
362
+ .Response(index_js_1.HttpStatusCode.OK, {
368
363
  description: 'Operation is successful. Returns OperationResult with "affected" field.',
369
- contentType: index_js_2.MimeTypes.opra_response_json,
364
+ contentType: index_js_1.MimeTypes.opra_response_json,
370
365
  })
371
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
366
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
372
367
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
373
- contentType: index_js_2.MimeTypes.opra_response_json,
368
+ contentType: index_js_1.MimeTypes.opra_response_json,
374
369
  })
375
370
  .QueryParam('filter', {
376
371
  type: filterType,
@@ -402,9 +397,9 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
402
397
  /** Initialize the decorator and the chain */
403
398
  const decoratorChain = [];
404
399
  const filterRules = new filter_rules_js_1.FilterRules();
405
- const filterType = new index_js_3.FilterType({ dataType: args.type });
400
+ const filterType = new index_js_2.FilterType({ dataType: args.type });
406
401
  filterType.rules = {};
407
- const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
402
+ const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, {
408
403
  method: 'PATCH',
409
404
  ...args,
410
405
  composition: 'Entity.Update',
@@ -414,11 +409,11 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
414
409
  ...args.requestBody,
415
410
  required: true,
416
411
  },
417
- }));
412
+ });
418
413
  decorator
419
414
  .QueryParam('projection', {
420
415
  description: 'Determines fields projection',
421
- type: new index_js_3.FieldPathType({
416
+ type: new index_js_2.FieldPathType({
422
417
  dataType: args.type,
423
418
  allowSigns: 'each',
424
419
  }),
@@ -430,21 +425,19 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
430
425
  description: 'Determines filter fields',
431
426
  })
432
427
  .RequestContent(args.requestBody?.type || args.type)
433
- .Response(index_js_2.HttpStatusCode.OK, {
428
+ .Response(index_js_1.HttpStatusCode.OK, {
434
429
  description: 'Operation is successful. Returns OperationResult with "payload" field that contains updated resource.',
435
- contentType: index_js_2.MimeTypes.opra_response_json,
430
+ contentType: index_js_1.MimeTypes.opra_response_json,
436
431
  type: args.type,
437
432
  partial: 'deep',
438
433
  })
439
- .Response(index_js_2.HttpStatusCode.NO_CONTENT, {
434
+ .Response(index_js_1.HttpStatusCode.NO_CONTENT, {
440
435
  description: 'Operation is successful but no resource found',
441
436
  })
442
- .Response(index_js_2.HttpStatusCode.UNPROCESSABLE_ENTITY, {
437
+ .Response(index_js_1.HttpStatusCode.UNPROCESSABLE_ENTITY, {
443
438
  description: 'The request was well-formed but was unable to process operation due to one or many errors.',
444
- contentType: index_js_2.MimeTypes.opra_response_json,
439
+ contentType: index_js_1.MimeTypes.opra_response_json,
445
440
  });
446
- if (typeof args.type === 'function')
447
- decorator.UseType(args.type);
448
441
  /**
449
442
  *
450
443
  */
@@ -466,6 +459,7 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
466
459
  decoratorChain.push((meta) => {
467
460
  if (!meta.path?.includes(':' + name))
468
461
  meta.path = (meta.path || '') + '@:' + name;
462
+ meta.mergePath = true;
469
463
  });
470
464
  return decorator;
471
465
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpOperationDecoratorFactory = void 0;
3
+ exports.HttpOperationDecoratorFactory = HttpOperationDecoratorFactory;
4
4
  const tslib_1 = require("tslib");
5
5
  const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
6
  const index_js_1 = require("../../http/index.js");
@@ -118,6 +118,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
118
118
  responseMeta.contentType = responseMeta.contentType || index_js_1.MimeTypes.opra_response_json;
119
119
  responseMeta.contentEncoding = responseMeta.contentEncoding || 'utf-8';
120
120
  }
121
+ if (responseMeta.contentType === index_js_1.MimeTypes.opra_response_json) {
122
+ responseMeta.contentEncoding = responseMeta.contentEncoding || 'utf-8';
123
+ }
121
124
  decoratorChain.push((meta) => {
122
125
  meta.responses = meta.responses || [];
123
126
  meta.responses.push(responseMeta);
@@ -184,4 +187,3 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
184
187
  };
185
188
  return decorator;
186
189
  }
187
- exports.HttpOperationDecoratorFactory = HttpOperationDecoratorFactory;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AttributeDecoratorFactory = exports.SimpleTypeDecoratorFactory = void 0;
3
+ exports.SimpleTypeDecoratorFactory = SimpleTypeDecoratorFactory;
4
+ exports.AttributeDecoratorFactory = AttributeDecoratorFactory;
4
5
  const tslib_1 = require("tslib");
5
6
  const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
6
7
  const index_js_1 = require("../../schema/index.js");
@@ -42,7 +43,6 @@ function SimpleTypeDecoratorFactory(options) {
42
43
  };
43
44
  return decorator;
44
45
  }
45
- exports.SimpleTypeDecoratorFactory = SimpleTypeDecoratorFactory;
46
46
  function AttributeDecoratorFactory(options) {
47
47
  return (target, propertyKey) => {
48
48
  if (typeof propertyKey !== 'string')
@@ -64,4 +64,3 @@ function AttributeDecoratorFactory(options) {
64
64
  Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, target.constructor);
65
65
  };
66
66
  }
67
- exports.AttributeDecoratorFactory = AttributeDecoratorFactory;