@opra/common 1.0.0-alpha.8 → 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
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAsyncIterable = exports.isIterable = exports.isURL = exports.isFormData = exports.isBlob = exports.isReadableStream = exports.isWritable = exports.isReadable = exports.isStream = exports.isConstructor = void 0;
3
+ exports.isConstructor = isConstructor;
4
+ exports.isStream = isStream;
5
+ exports.isReadable = isReadable;
6
+ exports.isWritable = isWritable;
7
+ exports.isReadableStream = isReadableStream;
8
+ exports.isBlob = isBlob;
9
+ exports.isFormData = isFormData;
10
+ exports.isURL = isURL;
11
+ exports.isIterable = isIterable;
12
+ exports.isAsyncIterable = isAsyncIterable;
4
13
  function isConstructor(fn) {
5
14
  return (typeof fn === 'function' &&
6
15
  fn.prototype &&
@@ -8,26 +17,21 @@ function isConstructor(fn) {
8
17
  fn.prototype.constructor.name !== 'Function' &&
9
18
  fn.prototype.constructor.name !== 'embedded');
10
19
  }
11
- exports.isConstructor = isConstructor;
12
20
  function isStream(x) {
13
21
  return x !== null && typeof x === 'object' && typeof x.pipe === 'function';
14
22
  }
15
- exports.isStream = isStream;
16
23
  function isReadable(x) {
17
24
  return isStream(x) && typeof x._read === 'function' && typeof x._readableState === 'object';
18
25
  }
19
- exports.isReadable = isReadable;
20
26
  function isWritable(x) {
21
27
  return isStream(x) && typeof x._write === 'function';
22
28
  }
23
- exports.isWritable = isWritable;
24
29
  function isReadableStream(x) {
25
30
  return (isStream(x) &&
26
31
  typeof x.getReader === 'function' &&
27
32
  typeof x.pipeThrough === 'function' &&
28
33
  typeof x.pipeTo === 'function');
29
34
  }
30
- exports.isReadableStream = isReadableStream;
31
35
  function isBlob(x) {
32
36
  return (x !== null &&
33
37
  typeof x === 'object' &&
@@ -35,7 +39,6 @@ function isBlob(x) {
35
39
  typeof x.arrayBuffer === 'function' &&
36
40
  typeof x.stream === 'function');
37
41
  }
38
- exports.isBlob = isBlob;
39
42
  function isFormData(x) {
40
43
  return (x !== null &&
41
44
  typeof x.constructor === 'function' &&
@@ -43,16 +46,12 @@ function isFormData(x) {
43
46
  typeof x.append === 'function' &&
44
47
  typeof x.getAll === 'function');
45
48
  }
46
- exports.isFormData = isFormData;
47
49
  function isURL(x) {
48
50
  return x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string';
49
51
  }
50
- exports.isURL = isURL;
51
52
  function isIterable(x) {
52
53
  return Symbol.iterator in x;
53
54
  }
54
- exports.isIterable = isIterable;
55
55
  function isAsyncIterable(x) {
56
56
  return Symbol.asyncIterator in x;
57
57
  }
58
- exports.isAsyncIterable = isAsyncIterable;
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unescapeString = exports.escapeString = void 0;
3
+ exports.escapeString = escapeString;
4
+ exports.unescapeString = unescapeString;
4
5
  const unescapeRegEx = /\\(.)/g;
5
6
  const escapeRegEx = /(\\)/g;
6
7
  function escapeString(s) {
7
8
  return s.replace(escapeRegEx, '\\\\');
8
9
  }
9
- exports.escapeString = escapeString;
10
10
  function unescapeString(s) {
11
11
  return s.replace(unescapeRegEx, '$1');
12
12
  }
13
- exports.unescapeString = unescapeString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.translate = void 0;
3
+ exports.translate = translate;
4
4
  const string_utils_js_1 = require("./string-utils.js");
5
5
  const bracketRegEx = /(\))/g;
6
6
  function translate(key, arg0, arg1) {
@@ -12,4 +12,3 @@ function translate(key, arg0, arg1) {
12
12
  (fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') +
13
13
  ')');
14
14
  }
15
- exports.translate = translate;
@@ -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.js"), 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);
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHttpController = exports.isEnumType = exports.isMappedType = exports.isMixinType = exports.isSimpleType = exports.isComplexType = exports.isDataType = void 0;
3
+ exports.isDataType = isDataType;
4
+ exports.isComplexType = isComplexType;
5
+ exports.isSimpleType = isSimpleType;
6
+ exports.isMixinType = isMixinType;
7
+ exports.isMappedType = isMappedType;
8
+ exports.isEnumType = isEnumType;
9
+ exports.isHttpController = isHttpController;
4
10
  const complex_type_interface_js_1 = require("./data-type/complex-type.interface.js");
5
11
  const enum_type_interface_js_1 = require("./data-type/enum-type.interface.js");
6
12
  const mapped_type_interface_js_1 = require("./data-type/mapped-type.interface.js");
@@ -16,28 +22,21 @@ function isDataType(obj) {
16
22
  obj.kind === simple_type_interface_js_1.SimpleType.Kind ||
17
23
  obj.kind === mixin_type_interface_js_1.MixinType.Kind));
18
24
  }
19
- exports.isDataType = isDataType;
20
25
  function isComplexType(obj) {
21
26
  return obj && typeof obj === 'object' && obj.kind === complex_type_interface_js_1.ComplexType.Kind;
22
27
  }
23
- exports.isComplexType = isComplexType;
24
28
  function isSimpleType(obj) {
25
29
  return obj && typeof obj === 'object' && obj.kind === simple_type_interface_js_1.SimpleType.Kind;
26
30
  }
27
- exports.isSimpleType = isSimpleType;
28
31
  function isMixinType(obj) {
29
32
  return obj && typeof obj === 'object' && obj.kind === mixin_type_interface_js_1.MixinType.Kind;
30
33
  }
31
- exports.isMixinType = isMixinType;
32
34
  function isMappedType(obj) {
33
35
  return obj && typeof obj === 'object' && obj.kind === mapped_type_interface_js_1.MappedType.Kind;
34
36
  }
35
- exports.isMappedType = isMappedType;
36
37
  function isEnumType(obj) {
37
38
  return obj && typeof obj === 'object' && obj.kind === enum_type_interface_js_1.EnumType.Kind;
38
39
  }
39
- exports.isEnumType = isEnumType;
40
40
  function isHttpController(obj) {
41
41
  return obj && typeof obj === 'object' && obj.kind === http_controller_interface_js_1.HttpController.Kind;
42
42
  }
43
- exports.isHttpController = isHttpController;
@@ -1,4 +1,5 @@
1
1
  var _a;
2
+ import { md5 } from 'super-fast-md5';
2
3
  import { cloneObject, omitUndefined, ResponsiveMap } from '../helpers/index.js';
3
4
  import { OpraSchema } from '../schema/index.js';
4
5
  import { DataTypeMap } from './common/data-type-map.js';
@@ -13,6 +14,8 @@ export class ApiDocument extends DocumentElement {
13
14
  constructor() {
14
15
  super(null);
15
16
  this[_a] = new WeakMap();
17
+ this.id = '';
18
+ this.info = {};
16
19
  this.references = new ResponsiveMap();
17
20
  this.types = new DataTypeMap();
18
21
  this.node[kDataTypeMap] = this.types;
@@ -77,6 +80,14 @@ export class ApiDocument extends DocumentElement {
77
80
  out.api = this.api.toJSON();
78
81
  return out;
79
82
  }
83
+ invalidate() {
84
+ /** Generate id */
85
+ const x = this.export();
86
+ delete x.id;
87
+ this.id = md5(JSON.stringify(x));
88
+ /** Clear [kTypeNSMap] */
89
+ this[kTypeNSMap] = new WeakMap();
90
+ }
80
91
  _findDataType(nameOrCtor, visitedRefs) {
81
92
  let result = this.types.get(nameOrCtor);
82
93
  if (result || !this.references.size)
@@ -4,7 +4,7 @@ import { DocumentElement } from './document-element.js';
4
4
  export class ApiBase extends DocumentElement {
5
5
  constructor(owner) {
6
6
  super(owner);
7
- this.owner = owner;
7
+ this.name = 'OpraApi';
8
8
  }
9
9
  toJSON() {
10
10
  return omitUndefined({
@@ -1,4 +1,5 @@
1
1
  import { asMutable } from 'ts-gems';
2
+ import { uid } from 'uid';
2
3
  import { DocumentNode } from './document-node.js';
3
4
  /**
4
5
  *
@@ -8,6 +9,7 @@ export const DocumentElement = function (owner) {
8
9
  if (!this)
9
10
  throw new TypeError('"this" should be passed to call class constructor');
10
11
  const _this = asMutable(this);
12
+ _this.id = uid(16);
11
13
  Object.defineProperty(_this, 'node', {
12
14
  value: new DocumentNode(this, owner?.node),
13
15
  enumerable: false,
@@ -37,6 +37,7 @@ export const ApiField = function (...args) {
37
37
  _this.readonly = initArgs.readonly;
38
38
  _this.writeonly = initArgs.writeonly;
39
39
  _this.examples = initArgs.examples;
40
+ _this.hidden = initArgs.hidden;
40
41
  };
41
42
  /**
42
43
  *
@@ -48,15 +49,15 @@ class ApiFieldClass extends DocumentElement {
48
49
  return omitUndefined({
49
50
  type: typeName ? typeName : this.type?.toJSON(),
50
51
  description: this.description,
51
- isArray: this.isArray,
52
+ isArray: this.isArray || undefined,
52
53
  default: this.default,
53
54
  fixed: this.fixed,
54
- required: this.required,
55
- exclusive: this.exclusive,
56
- translatable: this.translatable,
57
- deprecated: this.deprecated,
58
- readonly: this.readonly,
59
- writeonly: this.writeonly,
55
+ required: this.required || undefined,
56
+ exclusive: this.exclusive || undefined,
57
+ translatable: this.translatable || undefined,
58
+ deprecated: this.deprecated || undefined,
59
+ readonly: this.readonly || undefined,
60
+ writeonly: this.writeonly || undefined,
60
61
  examples: this.examples,
61
62
  });
62
63
  }
@@ -129,7 +129,7 @@ class ComplexTypeBaseClass extends DataType {
129
129
  }
130
130
  }
131
131
  return vg.isObject(schema, {
132
- ctor: this.ctor,
132
+ ctor: this.name === 'object' ? Object : this.ctor,
133
133
  additionalFields,
134
134
  name: this.name,
135
135
  coerce: true,
@@ -144,7 +144,9 @@ class ComplexTypeBaseClass extends DataType {
144
144
  // Process fields
145
145
  let fieldName;
146
146
  for (const field of this.fields.values()) {
147
- if ((context.ignoreReadonlyFields && field.readonly) || (context.ignoreWriteonlyFields && field.writeonly)) {
147
+ if ((context.ignoreReadonlyFields && field.readonly) ||
148
+ (context.ignoreWriteonlyFields && field.writeonly) ||
149
+ (context.ignoreHiddenFields && field.hidden)) {
148
150
  schema[field.name] = vg.isUndefined({ coerce: true });
149
151
  continue;
150
152
  }
@@ -166,7 +168,7 @@ class ComplexTypeBaseClass extends DataType {
166
168
  const fn = this._generateFieldCodec(codec, field, {
167
169
  ...context,
168
170
  partial: context.partial === 'deep' ? context.partial : undefined,
169
- projection: projection !== '*' ? projection : p?.projection,
171
+ projection: typeof projection === 'object' ? projection[fieldName]?.projection || '*' : projection,
170
172
  currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
171
173
  });
172
174
  schema[fieldName] = context.partial || !field.required ? vg.optional(fn) : vg.required(fn);
@@ -33,7 +33,7 @@ __decorate([
33
33
  __metadata("design:type", String)
34
34
  ], DateStringType.prototype, "maxValue", void 0);
35
35
  DateStringType = __decorate([
36
- SimpleType({
36
+ (SimpleType({
37
37
  description: 'Date string value',
38
38
  nameMappings: {
39
39
  js: 'string',
@@ -42,7 +42,7 @@ DateStringType = __decorate([
42
42
  })
43
43
  .Example('2021-04-18', 'Full date value')
44
44
  .Example('2021-04', 'Date value without day')
45
- .Example('2021', 'Year only value'),
45
+ .Example('2021', 'Year only value')),
46
46
  __metadata("design:paramtypes", [Object])
47
47
  ], DateStringType);
48
48
  export { DateStringType };
@@ -33,7 +33,7 @@ __decorate([
33
33
  __metadata("design:type", String)
34
34
  ], DateTimeStringType.prototype, "maxValue", void 0);
35
35
  DateTimeStringType = __decorate([
36
- SimpleType({
36
+ (SimpleType({
37
37
  description: 'DateTime string value',
38
38
  nameMappings: {
39
39
  js: 'string',
@@ -45,7 +45,7 @@ DateTimeStringType = __decorate([
45
45
  .Example('2021-04-18 22:30', 'Date-time value')
46
46
  .Example('2021-04-18', 'Date value')
47
47
  .Example('2021-04', 'Date value without day')
48
- .Example('2021', 'Year only value'),
48
+ .Example('2021', 'Year only value')),
49
49
  __metadata("design:paramtypes", [Object])
50
50
  ], DateTimeStringType);
51
51
  export { DateTimeStringType };
@@ -47,7 +47,7 @@ __decorate([
47
47
  __metadata("design:type", String)
48
48
  ], DateTimeType.prototype, "maxValue", void 0);
49
49
  DateTimeType = __decorate([
50
- SimpleType({
50
+ (SimpleType({
51
51
  description: 'A full datetime value',
52
52
  nameMappings: {
53
53
  js: 'string',
@@ -56,7 +56,7 @@ DateTimeType = __decorate([
56
56
  })
57
57
  .Example('2021-04-18T22:30:15')
58
58
  .Example('2021-04-18 22:30:15')
59
- .Example('2021-04-18 22:30'),
59
+ .Example('2021-04-18 22:30')),
60
60
  __metadata("design:paramtypes", [Object])
61
61
  ], DateTimeType);
62
62
  export { DateTimeType };
@@ -47,13 +47,13 @@ __decorate([
47
47
  __metadata("design:type", String)
48
48
  ], DateType.prototype, "maxValue", void 0);
49
49
  DateType = __decorate([
50
- SimpleType({
50
+ (SimpleType({
51
51
  description: 'A date without time',
52
52
  nameMappings: {
53
53
  js: 'Date',
54
54
  json: 'string',
55
55
  },
56
- }).Example('2021-04-18', 'Full date value'),
56
+ }).Example('2021-04-18', 'Full date value')),
57
57
  __metadata("design:paramtypes", [Object])
58
58
  ], DateType);
59
59
  export { DateType };
@@ -79,13 +79,13 @@ __decorate([
79
79
  __metadata("design:type", String)
80
80
  ], EmailType.prototype, "blacklistedChars", void 0);
81
81
  EmailType = __decorate([
82
- SimpleType({
82
+ (SimpleType({
83
83
  description: 'An email value',
84
84
  nameMappings: {
85
85
  js: 'string',
86
86
  json: 'string',
87
87
  },
88
- }).Example('some.body@example.com'),
88
+ }).Example('some.body@example.com')),
89
89
  __metadata("design:paramtypes", [Object])
90
90
  ], EmailType);
91
91
  export { EmailType };
@@ -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
  }
@@ -37,7 +37,7 @@ __decorate([
37
37
  __metadata("design:type", String)
38
38
  ], TimeType.prototype, "maxValue", void 0);
39
39
  TimeType = __decorate([
40
- SimpleType({
40
+ (SimpleType({
41
41
  description: 'Time string in 24h format',
42
42
  nameMappings: {
43
43
  js: 'string',
@@ -45,7 +45,7 @@ TimeType = __decorate([
45
45
  },
46
46
  })
47
47
  .Example('18:23:00', 'Full time value')
48
- .Example('18:23:00', 'Time value without seconds'),
48
+ .Example('18:23:00', 'Time value without seconds')),
49
49
  __metadata("design:paramtypes", [Object])
50
50
  ], TimeType);
51
51
  export { TimeType };
@@ -15,13 +15,13 @@ let UrlType = class UrlType {
15
15
  }
16
16
  };
17
17
  UrlType = __decorate([
18
- SimpleType({
18
+ (SimpleType({
19
19
  description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
20
20
  nameMappings: {
21
21
  js: 'string',
22
22
  json: 'string',
23
23
  },
24
- }).Example('http://tempuri.org'),
24
+ }).Example('http://tempuri.org')),
25
25
  __metadata("design:paramtypes", [Object])
26
26
  ], UrlType);
27
27
  export { UrlType };
@@ -1,4 +1,10 @@
1
1
  import { createMappedClass } from './utils/create-mapped-class.js';
2
+ /**
3
+ * Create a new MappedType that omits given fields from base type
4
+ * @param baseType
5
+ * @param keys
6
+ * @param options
7
+ */
2
8
  /**
3
9
  *
4
10
  */
@@ -1,4 +1,10 @@
1
1
  import { createMappedClass } from './utils/create-mapped-class.js';
2
+ /**
3
+ * Create a new MappedType that marks given or all fields as optional
4
+ * @param baseType
5
+ * @param keys
6
+ * @param options
7
+ */
2
8
  /**
3
9
  *
4
10
  */
@@ -1,5 +1,4 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { DATATYPE_METADATA } from '../../constants.js';
3
2
  import { ComplexType } from '../complex-type.js';
4
3
  let ObjectType = class ObjectType {
5
4
  constructor(properties) {
@@ -16,5 +15,3 @@ ObjectType = __decorate([
16
15
  __metadata("design:paramtypes", [Object])
17
16
  ], ObjectType);
18
17
  export { ObjectType };
19
- const metadata = Reflect.getMetadata(DATATYPE_METADATA, ObjectType);
20
- metadata.ctor = Object;
@@ -83,12 +83,7 @@ class SimpleTypeClass extends DataType {
83
83
  properties = this.properties.toJSON(this.properties, this.owner);
84
84
  }
85
85
  else
86
- properties = this.properties || {};
87
- properties = Object.keys(this.attributes).reduce((o, k) => {
88
- if (properties[k] !== undefined)
89
- o[k] = properties[k];
90
- return o;
91
- }, {});
86
+ properties = this.properties ? cloneObject(this.properties) : {};
92
87
  const baseName = this.base ? this.node.getDataTypeNameWithNs(this.base) : undefined;
93
88
  const out = omitUndefined({
94
89
  ...DataType.prototype.toJSON.apply(this),
@@ -1,4 +1,3 @@
1
- import { omitUndefined } from '../../helpers/index.js';
2
1
  import { OpraSchema } from '../../schema/index.js';
3
2
  import { DATATYPE_METADATA } from '../constants.js';
4
3
  export function ApiFieldDecorator(options) {
@@ -17,6 +16,6 @@ export function ApiFieldDecorator(options) {
17
16
  }
18
17
  else
19
18
  elemMeta.type = elemMeta.type || designType;
20
- Reflect.defineMetadata(DATATYPE_METADATA, omitUndefined(metadata), target.constructor);
19
+ Reflect.defineMetadata(DATATYPE_METADATA, metadata, target.constructor);
21
20
  };
22
21
  }
@@ -2,7 +2,7 @@ import omit from 'lodash.omit';
2
2
  import merge from 'putil-merge';
3
3
  import { OpraSchema } from '../../schema/index.js';
4
4
  import { HTTP_CONTROLLER_METADATA } from '../constants.js';
5
- const CLASS_NAME_PATTERN = /^(.*)(Collection|Singleton|Resource|Controller)$/;
5
+ const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
6
6
  export function HttpControllerDecoratorFactory(options) {
7
7
  const decoratorChain = [];
8
8
  /**