@opra/common 1.0.0-alpha.1 → 1.0.0-alpha.11
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.
- package/browser.js +5535 -5248
- package/cjs/document/api-document.js +18 -12
- package/cjs/document/common/data-type-map.js +1 -1
- package/cjs/document/common/document-element.js +2 -1
- package/cjs/document/constants.js +1 -1
- package/cjs/document/data-type/api-field.js +7 -2
- package/cjs/document/data-type/complex-type-base.js +6 -1
- package/cjs/document/data-type/complex-type.js +8 -5
- package/cjs/document/data-type/data-type.js +2 -1
- package/cjs/document/data-type/enum-type.js +5 -2
- package/cjs/document/data-type/extended-types/base64.type.js +6 -1
- package/cjs/document/data-type/extended-types/date-string.type.js +10 -3
- package/cjs/document/data-type/extended-types/date-time-string.type.js +10 -3
- package/cjs/document/data-type/extended-types/date-time.type.js +10 -3
- package/cjs/document/data-type/extended-types/date.type.js +10 -3
- package/cjs/document/data-type/extended-types/email.type.js +24 -10
- package/cjs/document/data-type/extended-types/field-path.type.js +13 -7
- package/cjs/document/data-type/extended-types/filter.type.js +25 -20
- package/cjs/document/data-type/extended-types/object-id.type.js +6 -1
- package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
- package/cjs/document/data-type/extended-types/time.type.js +10 -3
- package/cjs/document/data-type/extended-types/url.type.js +6 -1
- package/cjs/document/data-type/extended-types/uuid.type.js +8 -2
- package/cjs/document/data-type/mapped-type.js +12 -5
- package/cjs/document/data-type/mixin-type.js +5 -1
- package/cjs/document/data-type/primitive-types/any.type.js +2 -1
- package/cjs/document/data-type/primitive-types/bigint.type.js +6 -1
- package/cjs/document/data-type/primitive-types/boolean.type.js +6 -1
- package/cjs/document/data-type/primitive-types/integer.type.js +6 -1
- package/cjs/document/data-type/primitive-types/null.type.js +6 -1
- package/cjs/document/data-type/primitive-types/number.type.js +10 -3
- package/cjs/document/data-type/primitive-types/object.type.js +2 -1
- package/cjs/document/data-type/primitive-types/string.type.js +14 -5
- package/cjs/document/data-type/simple-type.js +16 -10
- package/cjs/document/data-type/utils/create-mapped-class.js +2 -1
- package/cjs/document/decorators/http-controller.decorator.js +25 -0
- package/cjs/document/decorators/http-operation-entity.decorator.js +55 -19
- package/cjs/document/decorators/http-operation.decorator.js +8 -4
- package/cjs/document/factory/api-document.factory.js +6 -3
- package/cjs/document/factory/data-type.factory.js +98 -57
- package/cjs/document/factory/http-api.factory.js +4 -2
- package/cjs/document/http/http-api.js +2 -2
- package/cjs/document/http/http-controller.js +25 -13
- package/cjs/document/http/http-media-type.js +4 -2
- package/cjs/document/http/http-operation-response.js +2 -1
- package/cjs/document/http/http-operation.js +18 -4
- package/cjs/document/http/http-parameter.js +2 -0
- package/cjs/document/http/http-status-range.js +1 -2
- package/cjs/document/index.js +5 -5
- package/cjs/exception/index.js +5 -5
- package/cjs/filter/antlr/OpraFilterParser.js +28 -82
- package/cjs/filter/ast/index.js +1 -1
- package/cjs/filter/build.js +1 -3
- package/cjs/filter/filter-rules.js +4 -2
- package/cjs/filter/opra-filter.ns.js +2 -2
- package/cjs/filter/parse.js +1 -3
- package/cjs/helpers/mixin-utils.js +2 -1
- package/cjs/helpers/monkey-patches.js +4 -2
- package/cjs/helpers/parse-fields-projection.js +1 -3
- package/cjs/helpers/responsive-map.js +5 -4
- package/cjs/i18n/i18n.js +4 -3
- package/cjs/i18n/index.js +1 -1
- package/cjs/index.js +1 -1
- package/esm/document/api-document.js +18 -12
- package/esm/document/common/data-type-map.js +1 -1
- package/esm/document/common/document-element.js +2 -1
- package/esm/document/constants.js +1 -1
- package/esm/document/data-type/api-field.js +7 -2
- package/esm/document/data-type/complex-type-base.js +6 -1
- package/esm/document/data-type/complex-type.js +8 -5
- package/esm/document/data-type/data-type.js +2 -1
- package/esm/document/data-type/enum-type.js +5 -2
- package/esm/document/data-type/extended-types/base64.type.js +7 -2
- package/esm/document/data-type/extended-types/date-string.type.js +11 -4
- package/esm/document/data-type/extended-types/date-time-string.type.js +11 -4
- package/esm/document/data-type/extended-types/date-time.type.js +11 -4
- package/esm/document/data-type/extended-types/date.type.js +11 -4
- package/esm/document/data-type/extended-types/email.type.js +25 -11
- package/esm/document/data-type/extended-types/field-path.type.js +14 -8
- package/esm/document/data-type/extended-types/filter.type.js +26 -21
- package/esm/document/data-type/extended-types/object-id.type.js +7 -2
- package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
- package/esm/document/data-type/extended-types/time.type.js +11 -4
- package/esm/document/data-type/extended-types/url.type.js +7 -2
- package/esm/document/data-type/extended-types/uuid.type.js +9 -3
- package/esm/document/data-type/mapped-type.js +12 -5
- package/esm/document/data-type/mixin-type.js +5 -1
- package/esm/document/data-type/primitive-types/any.type.js +3 -2
- package/esm/document/data-type/primitive-types/bigint.type.js +7 -2
- package/esm/document/data-type/primitive-types/boolean.type.js +7 -2
- package/esm/document/data-type/primitive-types/integer.type.js +7 -2
- package/esm/document/data-type/primitive-types/null.type.js +7 -2
- package/esm/document/data-type/primitive-types/number.type.js +11 -4
- package/esm/document/data-type/primitive-types/object.type.js +3 -2
- package/esm/document/data-type/primitive-types/string.type.js +15 -6
- package/esm/document/data-type/simple-type.js +16 -10
- package/esm/document/data-type/utils/create-mapped-class.js +2 -1
- package/esm/document/decorators/http-controller.decorator.js +25 -0
- package/esm/document/decorators/http-operation-entity.decorator.js +55 -19
- package/esm/document/decorators/http-operation.decorator.js +8 -4
- package/esm/document/factory/api-document.factory.js +5 -3
- package/esm/document/factory/data-type.factory.js +98 -57
- package/esm/document/factory/http-api.factory.js +4 -2
- package/esm/document/http/http-api.js +2 -2
- package/esm/document/http/http-controller.js +24 -13
- package/esm/document/http/http-media-type.js +4 -2
- package/esm/document/http/http-operation-response.js +2 -1
- package/esm/document/http/http-operation.js +17 -4
- package/esm/document/http/http-parameter.js +2 -0
- package/esm/document/http/http-status-range.js +1 -2
- package/esm/document/index.js +5 -5
- package/esm/exception/index.js +5 -5
- package/esm/filter/antlr/OpraFilterParser.js +28 -82
- package/esm/filter/ast/index.js +1 -1
- package/esm/filter/build.js +1 -3
- package/esm/filter/filter-rules.js +4 -2
- package/esm/filter/opra-filter.ns.js +2 -2
- package/esm/filter/parse.js +1 -3
- package/esm/helpers/mixin-utils.js +2 -1
- package/esm/helpers/monkey-patches.js +4 -2
- package/esm/helpers/parse-fields-projection.js +1 -3
- package/esm/helpers/responsive-map.js +5 -4
- package/esm/i18n/i18n.js +4 -3
- package/esm/i18n/index.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +8 -7
- package/types/document/api-document.d.ts +3 -6
- package/types/document/data-type/api-field.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +4 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/mapped-type.d.ts +2 -2
- package/types/document/data-type/mixin-type.d.ts +2 -2
- package/types/document/data-type/simple-type.d.ts +4 -2
- package/types/document/decorators/http-controller.decorator.d.ts +1 -0
- package/types/document/factory/api-document.factory.d.ts +1 -1
- package/types/document/factory/data-type.factory.d.ts +5 -0
- package/types/document/http/http-controller.d.ts +1 -0
- package/types/document/http/http-operation.d.ts +1 -0
- package/types/document/http/http-parameter.d.ts +3 -2
- package/types/document/index.d.ts +5 -5
- package/types/exception/index.d.ts +5 -5
- package/types/filter/ast/index.d.ts +1 -1
- package/types/filter/opra-filter.ns.d.ts +2 -2
- package/types/i18n/i18n.d.ts +21 -19
- package/types/index.d.ts +1 -1
- package/types/schema/data-type/simple-type.interface.d.ts +4 -0
- package/types/schema/document.interface.d.ts +13 -1
- package/types/schema/http/http-parameter.interface.d.ts +4 -0
- package/types/schema/index.d.ts +1 -0
- package/cjs/document/data-type/decorators/api-field-decorator.js +0 -26
- package/cjs/document/data-type/decorators/complex-type.decorator.js +0 -33
- package/cjs/document/data-type/decorators/simple-type.decorator.js +0 -67
- package/cjs/document/http/decorators/http-controller.decorator.js +0 -117
- package/cjs/document/http/decorators/http-operation-entity.decorator.js +0 -461
- package/cjs/document/http/decorators/http-operation.decorator.js +0 -183
- package/cjs/helpers/is-url-string.js +0 -12
- package/cjs/http/opra-url-path.js +0 -266
- package/cjs/http/opra-url.js +0 -253
- package/esm/document/data-type/decorators/api-field-decorator.js +0 -22
- package/esm/document/data-type/decorators/complex-type.decorator.js +0 -28
- package/esm/document/data-type/decorators/simple-type.decorator.js +0 -61
- package/esm/document/http/decorators/http-controller.decorator.js +0 -112
- package/esm/document/http/decorators/http-operation-entity.decorator.js +0 -459
- package/esm/document/http/decorators/http-operation.decorator.js +0 -178
- package/esm/helpers/is-url-string.js +0 -7
- package/esm/http/opra-url-path.js +0 -260
- package/esm/http/opra-url.js +0 -249
- package/types/document/data-type/decorators/api-field-decorator.d.ts +0 -5
- package/types/document/data-type/decorators/complex-type.decorator.d.ts +0 -2
- package/types/document/data-type/decorators/simple-type.decorator.d.ts +0 -20
- package/types/document/http/decorators/http-controller.decorator.d.ts +0 -14
- package/types/document/http/decorators/http-operation-entity.decorator.d.ts +0 -100
- package/types/document/http/decorators/http-operation.decorator.d.ts +0 -30
- package/types/helpers/is-url-string.d.ts +0 -2
- package/types/http/opra-url-path.d.ts +0 -55
- package/types/http/opra-url.d.ts +0 -66
|
@@ -21,5 +21,10 @@ exports.UrlType = UrlType;
|
|
|
21
21
|
exports.UrlType = UrlType = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'string',
|
|
26
|
+
json: 'string',
|
|
27
|
+
},
|
|
28
|
+
}).Example('http://tempuri.org'),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], UrlType);
|
|
@@ -21,10 +21,16 @@ exports.UuidType = UuidType;
|
|
|
21
21
|
tslib_1.__decorate([
|
|
22
22
|
simple_type_js_1.SimpleType.Attribute({
|
|
23
23
|
description: 'Version of the UUID',
|
|
24
|
-
})
|
|
24
|
+
}),
|
|
25
|
+
tslib_1.__metadata("design:type", Number)
|
|
25
26
|
], UuidType.prototype, "version", void 0);
|
|
26
27
|
exports.UuidType = UuidType = tslib_1.__decorate([
|
|
27
28
|
(0, simple_type_js_1.SimpleType)({
|
|
28
29
|
description: 'A Universal Unique Identifier (UUID) value',
|
|
29
|
-
|
|
30
|
+
nameMappings: {
|
|
31
|
+
js: 'string',
|
|
32
|
+
json: 'string',
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
36
|
], UuidType);
|
|
@@ -7,6 +7,7 @@ const index_js_1 = require("../../helpers/index.js");
|
|
|
7
7
|
const index_js_2 = require("../../schema/index.js");
|
|
8
8
|
const api_field_js_1 = require("./api-field.js");
|
|
9
9
|
const complex_type_base_js_1 = require("./complex-type-base.js");
|
|
10
|
+
const data_type_js_1 = require("./data-type.js");
|
|
10
11
|
const get_is_inherited_predicate_fn_js_1 = require("./utils/get-is-inherited-predicate-fn.js");
|
|
11
12
|
/**
|
|
12
13
|
* MappedType constructor
|
|
@@ -21,22 +22,25 @@ exports.MappedType = function (...args) {
|
|
|
21
22
|
_this.kind = index_js_2.OpraSchema.MappedType.Kind;
|
|
22
23
|
if (initArgs.base) {
|
|
23
24
|
// noinspection SuspiciousTypeOfGuard
|
|
24
|
-
if (!(initArgs.base instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
25
|
+
if (!(initArgs.base instanceof complex_type_base_js_1.ComplexTypeBase)) {
|
|
25
26
|
throw new TypeError(`"${initArgs.base.kind}" can't be set as base for a "${this.kind}"`);
|
|
27
|
+
}
|
|
26
28
|
_this.base = initArgs.base;
|
|
27
29
|
_this.ctor = initArgs.ctor || _this.base.ctor;
|
|
28
30
|
if (initArgs.pick)
|
|
29
31
|
_this.pick = initArgs.pick.map(f => _this.base.normalizeFieldPath(f));
|
|
30
32
|
else if (initArgs.omit)
|
|
31
33
|
_this.omit = initArgs.omit.map(f => _this.base.normalizeFieldPath(f));
|
|
32
|
-
else if (initArgs.partial)
|
|
34
|
+
else if (initArgs.partial) {
|
|
33
35
|
_this.partial = Array.isArray(initArgs.partial)
|
|
34
36
|
? initArgs.partial.map(f => _this.base.normalizeFieldPath(f))
|
|
35
37
|
: initArgs.partial;
|
|
36
|
-
|
|
38
|
+
}
|
|
39
|
+
else if (initArgs.required) {
|
|
37
40
|
_this.required = Array.isArray(initArgs.required)
|
|
38
41
|
? initArgs.required.map(f => _this.base.normalizeFieldPath(f))
|
|
39
42
|
: initArgs.required;
|
|
43
|
+
}
|
|
40
44
|
/** Copy fields from base */
|
|
41
45
|
const isInheritedPredicate = (0, get_is_inherited_predicate_fn_js_1.getIsInheritedPredicateFn)(_this.pick, _this.omit);
|
|
42
46
|
const partial = Array.isArray(_this.partial) ? _this.partial.map(x => x.toLowerCase()) : _this.partial;
|
|
@@ -56,8 +60,9 @@ exports.MappedType = function (...args) {
|
|
|
56
60
|
}
|
|
57
61
|
if (!_this.pick ||
|
|
58
62
|
_this.base.additionalFields === false ||
|
|
59
|
-
(Array.isArray(_this.base.additionalFields) && _this.base.additionalFields?.[0] === 'error'))
|
|
63
|
+
(Array.isArray(_this.base.additionalFields) && _this.base.additionalFields?.[0] === 'error')) {
|
|
60
64
|
_this.additionalFields = _this.base.additionalFields;
|
|
65
|
+
}
|
|
61
66
|
if (initArgs.base.keyField && isInheritedPredicate(initArgs.base.keyField))
|
|
62
67
|
_this.keyField = initArgs.base.keyField;
|
|
63
68
|
}
|
|
@@ -68,6 +73,8 @@ exports.MappedType = function (...args) {
|
|
|
68
73
|
*/
|
|
69
74
|
class MappedTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
70
75
|
extendsFrom(baseType) {
|
|
76
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
77
|
+
baseType = this.node.getDataType(baseType);
|
|
71
78
|
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
72
79
|
return false;
|
|
73
80
|
if (baseType === this)
|
|
@@ -88,4 +95,4 @@ class MappedTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
exports.MappedType.prototype = MappedTypeClass.prototype;
|
|
91
|
-
exports.MappedType._applyMixin = () =>
|
|
98
|
+
exports.MappedType._applyMixin = () => undefined;
|
|
@@ -8,6 +8,7 @@ const index_js_2 = require("../../schema/index.js");
|
|
|
8
8
|
const constants_js_1 = require("../constants.js");
|
|
9
9
|
const api_field_js_1 = require("./api-field.js");
|
|
10
10
|
const complex_type_base_js_1 = require("./complex-type-base.js");
|
|
11
|
+
const data_type_js_1 = require("./data-type.js");
|
|
11
12
|
/**
|
|
12
13
|
* @class MixinType
|
|
13
14
|
*/
|
|
@@ -43,6 +44,8 @@ exports.MixinType = function (...args) {
|
|
|
43
44
|
*/
|
|
44
45
|
class MixinTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
45
46
|
extendsFrom(baseType) {
|
|
47
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
48
|
+
baseType = this.node.getDataType(baseType);
|
|
46
49
|
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
47
50
|
return false;
|
|
48
51
|
if (baseType === this)
|
|
@@ -97,8 +100,9 @@ function MixinTypeFactory(...args) {
|
|
|
97
100
|
if (!(itemMeta &&
|
|
98
101
|
(itemMeta.kind === index_js_2.OpraSchema.ComplexType.Kind ||
|
|
99
102
|
itemMeta.kind === index_js_2.OpraSchema.MixinType.Kind ||
|
|
100
|
-
itemMeta.kind === index_js_2.OpraSchema.MappedType.Kind)))
|
|
103
|
+
itemMeta.kind === index_js_2.OpraSchema.MappedType.Kind))) {
|
|
101
104
|
throw new TypeError(`Class "${c.name}" is not a ${index_js_2.OpraSchema.ComplexType.Kind}, ${index_js_2.OpraSchema.MixinType.Kind} or ${index_js_2.OpraSchema.MappedType.Kind}`);
|
|
105
|
+
}
|
|
102
106
|
metadata.types.push(c);
|
|
103
107
|
(0, index_js_1.mergePrototype)(MixinClass.prototype, c.prototype);
|
|
104
108
|
}
|
|
@@ -26,5 +26,10 @@ exports.BigintType = BigintType;
|
|
|
26
26
|
exports.BigintType = BigintType = tslib_1.__decorate([
|
|
27
27
|
(0, simple_type_js_1.SimpleType)({
|
|
28
28
|
description: 'BigInt number',
|
|
29
|
-
|
|
29
|
+
nameMappings: {
|
|
30
|
+
js: 'bigint',
|
|
31
|
+
json: 'string',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
35
|
], BigintType);
|
|
@@ -21,5 +21,10 @@ exports.BooleanType = BooleanType;
|
|
|
21
21
|
exports.BooleanType = BooleanType = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'Simple true/false value',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'boolean',
|
|
26
|
+
json: 'boolean',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], BooleanType);
|
|
@@ -26,5 +26,10 @@ exports.IntegerType = IntegerType;
|
|
|
26
26
|
exports.IntegerType = IntegerType = tslib_1.__decorate([
|
|
27
27
|
(0, simple_type_js_1.SimpleType)({
|
|
28
28
|
description: 'An integer number',
|
|
29
|
-
|
|
29
|
+
nameMappings: {
|
|
30
|
+
js: 'number',
|
|
31
|
+
json: 'number',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
35
|
], IntegerType);
|
|
@@ -21,5 +21,10 @@ exports.NullType = NullType;
|
|
|
21
21
|
exports.NullType = NullType = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'A Null value',
|
|
24
|
-
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'null',
|
|
26
|
+
json: 'null',
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
30
|
], NullType);
|
|
@@ -26,15 +26,22 @@ exports.NumberType = NumberType;
|
|
|
26
26
|
tslib_1.__decorate([
|
|
27
27
|
simple_type_js_1.SimpleType.Attribute({
|
|
28
28
|
description: 'Determines the minimum value',
|
|
29
|
-
})
|
|
29
|
+
}),
|
|
30
|
+
tslib_1.__metadata("design:type", Number)
|
|
30
31
|
], NumberType.prototype, "minValue", void 0);
|
|
31
32
|
tslib_1.__decorate([
|
|
32
33
|
simple_type_js_1.SimpleType.Attribute({
|
|
33
34
|
description: 'Determines the maximum value',
|
|
34
|
-
})
|
|
35
|
+
}),
|
|
36
|
+
tslib_1.__metadata("design:type", Number)
|
|
35
37
|
], NumberType.prototype, "maxValue", void 0);
|
|
36
38
|
exports.NumberType = NumberType = tslib_1.__decorate([
|
|
37
39
|
(0, simple_type_js_1.SimpleType)({
|
|
38
40
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
39
|
-
|
|
41
|
+
nameMappings: {
|
|
42
|
+
js: 'number',
|
|
43
|
+
json: 'number',
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
40
47
|
], NumberType);
|
|
@@ -16,7 +16,8 @@ exports.ObjectType = ObjectType = tslib_1.__decorate([
|
|
|
16
16
|
name: 'object',
|
|
17
17
|
description: 'A non modelled object',
|
|
18
18
|
additionalFields: true,
|
|
19
|
-
})
|
|
19
|
+
}),
|
|
20
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
20
21
|
], ObjectType);
|
|
21
22
|
const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, ObjectType);
|
|
22
23
|
metadata.ctor = Object;
|
|
@@ -34,25 +34,34 @@ exports.StringType = StringType;
|
|
|
34
34
|
tslib_1.__decorate([
|
|
35
35
|
simple_type_js_1.SimpleType.Attribute({
|
|
36
36
|
description: 'Regex pattern to be used for validation',
|
|
37
|
-
})
|
|
37
|
+
}),
|
|
38
|
+
tslib_1.__metadata("design:type", Object)
|
|
38
39
|
], StringType.prototype, "pattern", void 0);
|
|
39
40
|
tslib_1.__decorate([
|
|
40
41
|
simple_type_js_1.SimpleType.Attribute({
|
|
41
42
|
description: 'Name of the pattern',
|
|
42
|
-
})
|
|
43
|
+
}),
|
|
44
|
+
tslib_1.__metadata("design:type", String)
|
|
43
45
|
], StringType.prototype, "patternName", void 0);
|
|
44
46
|
tslib_1.__decorate([
|
|
45
47
|
simple_type_js_1.SimpleType.Attribute({
|
|
46
48
|
description: 'Minimum number of characters',
|
|
47
|
-
})
|
|
49
|
+
}),
|
|
50
|
+
tslib_1.__metadata("design:type", Number)
|
|
48
51
|
], StringType.prototype, "minLength", void 0);
|
|
49
52
|
tslib_1.__decorate([
|
|
50
53
|
simple_type_js_1.SimpleType.Attribute({
|
|
51
54
|
description: 'Minimum number of characters',
|
|
52
|
-
})
|
|
55
|
+
}),
|
|
56
|
+
tslib_1.__metadata("design:type", Number)
|
|
53
57
|
], StringType.prototype, "maxLength", void 0);
|
|
54
58
|
exports.StringType = StringType = tslib_1.__decorate([
|
|
55
59
|
(0, simple_type_js_1.SimpleType)({
|
|
56
60
|
description: 'A sequence of characters',
|
|
57
|
-
|
|
61
|
+
nameMappings: {
|
|
62
|
+
js: 'string',
|
|
63
|
+
json: 'string',
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
58
67
|
], StringType);
|
|
@@ -23,11 +23,14 @@ exports.SimpleType = function (...args) {
|
|
|
23
23
|
_this.kind = index_js_2.OpraSchema.SimpleType.Kind;
|
|
24
24
|
if (initArgs.base) {
|
|
25
25
|
// noinspection SuspiciousTypeOfGuard
|
|
26
|
-
if (!(initArgs.base instanceof exports.SimpleType))
|
|
26
|
+
if (!(initArgs.base instanceof exports.SimpleType)) {
|
|
27
27
|
throw new TypeError(`"${initArgs.base.kind}" can't be set as base for a "${this.kind}"`);
|
|
28
|
+
}
|
|
28
29
|
_this.base = initArgs.base;
|
|
29
30
|
}
|
|
30
31
|
_this.properties = initArgs.properties;
|
|
32
|
+
_this.ownNameMappings = { ...initArgs.nameMappings };
|
|
33
|
+
_this.nameMappings = { ..._this.base?.nameMappings, ...initArgs.nameMappings };
|
|
31
34
|
_this.ownAttributes = (0, index_js_1.cloneObject)(initArgs.attributes || {});
|
|
32
35
|
_this.attributes = _this.base ? (0, index_js_1.cloneObject)(_this.base.attributes) : {};
|
|
33
36
|
if (_this.ownAttributes) {
|
|
@@ -46,6 +49,8 @@ exports.SimpleType = function (...args) {
|
|
|
46
49
|
*/
|
|
47
50
|
class SimpleTypeClass extends data_type_js_1.DataType {
|
|
48
51
|
extendsFrom(baseType) {
|
|
52
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
53
|
+
baseType = this.node.getDataType(baseType);
|
|
49
54
|
if (!(baseType instanceof exports.SimpleType))
|
|
50
55
|
return false;
|
|
51
56
|
if (baseType === this)
|
|
@@ -66,15 +71,13 @@ class SimpleTypeClass extends data_type_js_1.DataType {
|
|
|
66
71
|
}
|
|
67
72
|
return valgen_1.isAny;
|
|
68
73
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
t = this.base;
|
|
75
|
-
}
|
|
76
|
-
return valgen_1.isAny;
|
|
74
|
+
let t = this;
|
|
75
|
+
while (t) {
|
|
76
|
+
if (t._generateEncoder)
|
|
77
|
+
return t._generateEncoder(prop, options?.documentElement || this.owner);
|
|
78
|
+
t = this.base;
|
|
77
79
|
}
|
|
80
|
+
return valgen_1.isAny;
|
|
78
81
|
}
|
|
79
82
|
toJSON() {
|
|
80
83
|
const attributes = (0, index_js_1.omitUndefined)(this.ownAttributes);
|
|
@@ -90,12 +93,15 @@ class SimpleTypeClass extends data_type_js_1.DataType {
|
|
|
90
93
|
return o;
|
|
91
94
|
}, {});
|
|
92
95
|
const baseName = this.base ? this.node.getDataTypeNameWithNs(this.base) : undefined;
|
|
93
|
-
|
|
96
|
+
const out = (0, index_js_1.omitUndefined)({
|
|
94
97
|
...data_type_js_1.DataType.prototype.toJSON.apply(this),
|
|
95
98
|
base: this.base ? (baseName ? baseName : this.base.toJSON()) : undefined,
|
|
96
99
|
attributes: attributes && Object.keys(attributes).length ? attributes : undefined,
|
|
97
100
|
properties: Object.keys(properties).length ? properties : undefined,
|
|
98
101
|
});
|
|
102
|
+
if (Object.keys(this.ownNameMappings).length)
|
|
103
|
+
out.nameMappings = { ...this.ownNameMappings };
|
|
104
|
+
return out;
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
exports.SimpleType.prototype = SimpleTypeClass.prototype;
|
|
@@ -26,8 +26,9 @@ function createMappedClass(source, config, options) {
|
|
|
26
26
|
throw new TypeError(`Class "${source}" doesn't have datatype metadata information`);
|
|
27
27
|
if (!(m.kind === index_js_2.OpraSchema.ComplexType.Kind ||
|
|
28
28
|
m.kind === index_js_2.OpraSchema.MappedType.Kind ||
|
|
29
|
-
m.kind === index_js_2.OpraSchema.MixinType.Kind))
|
|
29
|
+
m.kind === index_js_2.OpraSchema.MixinType.Kind)) {
|
|
30
30
|
throw new TypeError(`Class "${source}" is not a ${index_js_2.OpraSchema.ComplexType.Kind}`);
|
|
31
|
+
}
|
|
31
32
|
}
|
|
32
33
|
const metadata = {
|
|
33
34
|
...options,
|
|
@@ -102,6 +102,31 @@ function HttpControllerDecoratorFactory(options) {
|
|
|
102
102
|
});
|
|
103
103
|
return decorator;
|
|
104
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
decorator.KeyParam = (name, arg1) => {
|
|
109
|
+
decoratorChain.push((meta) => {
|
|
110
|
+
if (!meta.path?.includes(':' + name))
|
|
111
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
112
|
+
const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
|
|
113
|
+
? {
|
|
114
|
+
name,
|
|
115
|
+
location: 'path',
|
|
116
|
+
type: arg1,
|
|
117
|
+
keyParam: true,
|
|
118
|
+
}
|
|
119
|
+
: {
|
|
120
|
+
...arg1,
|
|
121
|
+
name,
|
|
122
|
+
location: 'path',
|
|
123
|
+
keyParam: true,
|
|
124
|
+
};
|
|
125
|
+
meta.parameters = meta.parameters || [];
|
|
126
|
+
meta.parameters.push(paramMeta);
|
|
127
|
+
});
|
|
128
|
+
return decorator;
|
|
129
|
+
};
|
|
105
130
|
/**
|
|
106
131
|
*
|
|
107
132
|
*/
|
|
@@ -23,8 +23,8 @@ http_operation_js_1.HttpOperation.Entity.Create = function (arg0, arg1) {
|
|
|
23
23
|
/** Initialize the decorator and the chain */
|
|
24
24
|
const decoratorChain = [];
|
|
25
25
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
26
|
-
description: args.description,
|
|
27
26
|
method: 'POST',
|
|
27
|
+
...args,
|
|
28
28
|
composition: 'Entity.Create',
|
|
29
29
|
requestBody: {
|
|
30
30
|
immediateFetch: true,
|
|
@@ -74,8 +74,8 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
74
74
|
/** Initialize the decorator and the chain */
|
|
75
75
|
const decoratorChain = [];
|
|
76
76
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
77
|
-
description: args.description,
|
|
78
77
|
method: 'DELETE',
|
|
78
|
+
...args,
|
|
79
79
|
composition: 'Entity.Delete',
|
|
80
80
|
}));
|
|
81
81
|
decorator
|
|
@@ -93,11 +93,23 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
93
93
|
*
|
|
94
94
|
*/
|
|
95
95
|
decorator.KeyParam = (name, prmOptions) => {
|
|
96
|
-
|
|
96
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
97
|
+
? {
|
|
98
|
+
name,
|
|
99
|
+
location: 'path',
|
|
100
|
+
type: prmOptions,
|
|
101
|
+
keyParam: true,
|
|
102
|
+
}
|
|
103
|
+
: {
|
|
104
|
+
...prmOptions,
|
|
105
|
+
name,
|
|
106
|
+
location: 'path',
|
|
107
|
+
keyParam: true,
|
|
108
|
+
};
|
|
109
|
+
decorator.PathParam(name, paramMeta);
|
|
97
110
|
decoratorChain.push((meta) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
meta.compositionOptions.keyParameter = name;
|
|
111
|
+
if (!meta.path?.includes(':' + name))
|
|
112
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
101
113
|
});
|
|
102
114
|
return decorator;
|
|
103
115
|
};
|
|
@@ -123,8 +135,8 @@ http_operation_js_1.HttpOperation.Entity.DeleteMany = function (arg0, arg1) {
|
|
|
123
135
|
const filterType = new index_js_3.FilterType({ dataType: args.type });
|
|
124
136
|
filterType.rules = {};
|
|
125
137
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
126
|
-
description: args.description,
|
|
127
138
|
method: 'DELETE',
|
|
139
|
+
...args,
|
|
128
140
|
composition: 'Entity.DeleteMany',
|
|
129
141
|
}));
|
|
130
142
|
decorator
|
|
@@ -171,8 +183,8 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
171
183
|
const filterType = new index_js_3.FilterType({ dataType: args.type });
|
|
172
184
|
filterType.rules = {};
|
|
173
185
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
174
|
-
description: args.description,
|
|
175
186
|
method: 'GET',
|
|
187
|
+
...args,
|
|
176
188
|
composition: 'Entity.FindMany',
|
|
177
189
|
}));
|
|
178
190
|
decorator
|
|
@@ -263,8 +275,8 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
263
275
|
/** Initialize the decorator and the chain */
|
|
264
276
|
const decoratorChain = [];
|
|
265
277
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
266
|
-
description: args.description,
|
|
267
278
|
method: 'GET',
|
|
279
|
+
...args,
|
|
268
280
|
composition: 'Entity.Get',
|
|
269
281
|
}));
|
|
270
282
|
decorator
|
|
@@ -296,11 +308,23 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
296
308
|
*
|
|
297
309
|
*/
|
|
298
310
|
decorator.KeyParam = (name, prmOptions) => {
|
|
299
|
-
|
|
311
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
312
|
+
? {
|
|
313
|
+
name,
|
|
314
|
+
location: 'path',
|
|
315
|
+
type: prmOptions,
|
|
316
|
+
keyParam: true,
|
|
317
|
+
}
|
|
318
|
+
: {
|
|
319
|
+
...prmOptions,
|
|
320
|
+
name,
|
|
321
|
+
location: 'path',
|
|
322
|
+
keyParam: true,
|
|
323
|
+
};
|
|
324
|
+
decorator.PathParam(name, paramMeta);
|
|
300
325
|
decoratorChain.push((meta) => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
meta.compositionOptions.keyParameter = name;
|
|
326
|
+
if (!meta.path?.includes(':' + name))
|
|
327
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
304
328
|
});
|
|
305
329
|
return decorator;
|
|
306
330
|
};
|
|
@@ -326,8 +350,8 @@ http_operation_js_1.HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
|
|
|
326
350
|
filterType.rules = {};
|
|
327
351
|
const filterRules = new filter_rules_js_1.FilterRules();
|
|
328
352
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
329
|
-
description: args.description,
|
|
330
353
|
method: 'PATCH',
|
|
354
|
+
...args,
|
|
331
355
|
composition: 'Entity.UpdateMany',
|
|
332
356
|
requestBody: {
|
|
333
357
|
immediateFetch: true,
|
|
@@ -381,8 +405,8 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
381
405
|
const filterType = new index_js_3.FilterType({ dataType: args.type });
|
|
382
406
|
filterType.rules = {};
|
|
383
407
|
const decorator = (0, http_operation_decorator_js_1.HttpOperationDecoratorFactory)(decoratorChain, (0, index_js_1.omitUndefined)({
|
|
384
|
-
description: args.description,
|
|
385
408
|
method: 'PATCH',
|
|
409
|
+
...args,
|
|
386
410
|
composition: 'Entity.Update',
|
|
387
411
|
requestBody: {
|
|
388
412
|
partial: 'deep',
|
|
@@ -425,11 +449,23 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
425
449
|
*
|
|
426
450
|
*/
|
|
427
451
|
decorator.KeyParam = (name, prmOptions) => {
|
|
428
|
-
|
|
452
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
453
|
+
? {
|
|
454
|
+
name,
|
|
455
|
+
location: 'path',
|
|
456
|
+
type: prmOptions,
|
|
457
|
+
keyParam: true,
|
|
458
|
+
}
|
|
459
|
+
: {
|
|
460
|
+
...prmOptions,
|
|
461
|
+
name,
|
|
462
|
+
location: 'path',
|
|
463
|
+
keyParam: true,
|
|
464
|
+
};
|
|
465
|
+
decorator.PathParam(name, paramMeta);
|
|
429
466
|
decoratorChain.push((meta) => {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
meta.compositionOptions.keyParameter = name;
|
|
467
|
+
if (!meta.path?.includes(':' + name))
|
|
468
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
433
469
|
});
|
|
434
470
|
return decorator;
|
|
435
471
|
};
|
|
@@ -37,8 +37,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
37
37
|
type: arg1,
|
|
38
38
|
}
|
|
39
39
|
: { ...arg1, name, location: 'cookie' };
|
|
40
|
-
if (meta.parameters)
|
|
40
|
+
if (meta.parameters) {
|
|
41
41
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'cookie' && String(p.name) === String(name)));
|
|
42
|
+
}
|
|
42
43
|
else
|
|
43
44
|
meta.parameters = [];
|
|
44
45
|
meta.parameters.push(paramMeta);
|
|
@@ -57,8 +58,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
57
58
|
type: arg1,
|
|
58
59
|
}
|
|
59
60
|
: { ...arg1, name, location: 'header' };
|
|
60
|
-
if (meta.parameters)
|
|
61
|
+
if (meta.parameters) {
|
|
61
62
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'header' && String(p.name) === String(name)));
|
|
63
|
+
}
|
|
62
64
|
else
|
|
63
65
|
meta.parameters = [];
|
|
64
66
|
meta.parameters.push(paramMeta);
|
|
@@ -77,8 +79,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
77
79
|
type: arg1,
|
|
78
80
|
}
|
|
79
81
|
: { ...arg1, name, location: 'query' };
|
|
80
|
-
if (meta.parameters)
|
|
82
|
+
if (meta.parameters) {
|
|
81
83
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'query' && String(p.name) === String(name)));
|
|
84
|
+
}
|
|
82
85
|
else
|
|
83
86
|
meta.parameters = [];
|
|
84
87
|
meta.parameters.push(paramMeta);
|
|
@@ -97,8 +100,9 @@ function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
97
100
|
type: arg1,
|
|
98
101
|
}
|
|
99
102
|
: { ...arg1, name, location: 'path' };
|
|
100
|
-
if (meta.parameters)
|
|
103
|
+
if (meta.parameters) {
|
|
101
104
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'path' && String(p.name) === String(name)));
|
|
105
|
+
}
|
|
102
106
|
else
|
|
103
107
|
meta.parameters = [];
|
|
104
108
|
meta.parameters.push(paramMeta);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiDocumentFactory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
6
|
+
const ts_gems_1 = require("ts-gems");
|
|
4
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
5
8
|
const index_js_2 = require("../../schema/index.js");
|
|
6
9
|
const api_document_js_1 = require("../api-document.js");
|
|
@@ -43,9 +46,7 @@ class ApiDocumentFactory {
|
|
|
43
46
|
context.error.message = `(${l}) error${l > 1 ? 's' : ''} found in document schema.`;
|
|
44
47
|
if (context.showErrorDetails) {
|
|
45
48
|
context.error.message += context.error.details
|
|
46
|
-
.map(d => {
|
|
47
|
-
return `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : '');
|
|
48
|
-
})
|
|
49
|
+
.map(d => `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : ''))
|
|
49
50
|
.join('');
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -112,6 +113,8 @@ class ApiDocumentFactory {
|
|
|
112
113
|
context.addError(`Unknown service protocol (${init.api.protocol})`);
|
|
113
114
|
});
|
|
114
115
|
}
|
|
116
|
+
const x = document.export();
|
|
117
|
+
(0, ts_gems_1.asMutable)(document).id = node_crypto_1.default.createHash('md5').update(JSON.stringify(x)).digest('base64url');
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
120
|
*
|