@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
|
@@ -4,6 +4,7 @@ import { omitUndefined } from '../../helpers/index.js';
|
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import { ApiField } from './api-field.js';
|
|
6
6
|
import { ComplexTypeBase } from './complex-type-base.js';
|
|
7
|
+
import { DataType } from './data-type.js';
|
|
7
8
|
import { getIsInheritedPredicateFn } from './utils/get-is-inherited-predicate-fn.js';
|
|
8
9
|
/**
|
|
9
10
|
* MappedType constructor
|
|
@@ -18,22 +19,25 @@ export const MappedType = function (...args) {
|
|
|
18
19
|
_this.kind = OpraSchema.MappedType.Kind;
|
|
19
20
|
if (initArgs.base) {
|
|
20
21
|
// noinspection SuspiciousTypeOfGuard
|
|
21
|
-
if (!(initArgs.base instanceof ComplexTypeBase))
|
|
22
|
+
if (!(initArgs.base instanceof ComplexTypeBase)) {
|
|
22
23
|
throw new TypeError(`"${initArgs.base.kind}" can't be set as base for a "${this.kind}"`);
|
|
24
|
+
}
|
|
23
25
|
_this.base = initArgs.base;
|
|
24
26
|
_this.ctor = initArgs.ctor || _this.base.ctor;
|
|
25
27
|
if (initArgs.pick)
|
|
26
28
|
_this.pick = initArgs.pick.map(f => _this.base.normalizeFieldPath(f));
|
|
27
29
|
else if (initArgs.omit)
|
|
28
30
|
_this.omit = initArgs.omit.map(f => _this.base.normalizeFieldPath(f));
|
|
29
|
-
else if (initArgs.partial)
|
|
31
|
+
else if (initArgs.partial) {
|
|
30
32
|
_this.partial = Array.isArray(initArgs.partial)
|
|
31
33
|
? initArgs.partial.map(f => _this.base.normalizeFieldPath(f))
|
|
32
34
|
: initArgs.partial;
|
|
33
|
-
|
|
35
|
+
}
|
|
36
|
+
else if (initArgs.required) {
|
|
34
37
|
_this.required = Array.isArray(initArgs.required)
|
|
35
38
|
? initArgs.required.map(f => _this.base.normalizeFieldPath(f))
|
|
36
39
|
: initArgs.required;
|
|
40
|
+
}
|
|
37
41
|
/** Copy fields from base */
|
|
38
42
|
const isInheritedPredicate = getIsInheritedPredicateFn(_this.pick, _this.omit);
|
|
39
43
|
const partial = Array.isArray(_this.partial) ? _this.partial.map(x => x.toLowerCase()) : _this.partial;
|
|
@@ -53,8 +57,9 @@ export const MappedType = function (...args) {
|
|
|
53
57
|
}
|
|
54
58
|
if (!_this.pick ||
|
|
55
59
|
_this.base.additionalFields === false ||
|
|
56
|
-
(Array.isArray(_this.base.additionalFields) && _this.base.additionalFields?.[0] === 'error'))
|
|
60
|
+
(Array.isArray(_this.base.additionalFields) && _this.base.additionalFields?.[0] === 'error')) {
|
|
57
61
|
_this.additionalFields = _this.base.additionalFields;
|
|
62
|
+
}
|
|
58
63
|
if (initArgs.base.keyField && isInheritedPredicate(initArgs.base.keyField))
|
|
59
64
|
_this.keyField = initArgs.base.keyField;
|
|
60
65
|
}
|
|
@@ -65,6 +70,8 @@ export const MappedType = function (...args) {
|
|
|
65
70
|
*/
|
|
66
71
|
class MappedTypeClass extends ComplexTypeBase {
|
|
67
72
|
extendsFrom(baseType) {
|
|
73
|
+
if (!(baseType instanceof DataType))
|
|
74
|
+
baseType = this.node.getDataType(baseType);
|
|
68
75
|
if (!(baseType instanceof ComplexTypeBase))
|
|
69
76
|
return false;
|
|
70
77
|
if (baseType === this)
|
|
@@ -85,4 +92,4 @@ class MappedTypeClass extends ComplexTypeBase {
|
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
MappedType.prototype = MappedTypeClass.prototype;
|
|
88
|
-
MappedType._applyMixin = () =>
|
|
95
|
+
MappedType._applyMixin = () => undefined;
|
|
@@ -5,6 +5,7 @@ import { OpraSchema } from '../../schema/index.js';
|
|
|
5
5
|
import { DATATYPE_METADATA, DECORATOR } from '../constants.js';
|
|
6
6
|
import { ApiField } from './api-field.js';
|
|
7
7
|
import { ComplexTypeBase } from './complex-type-base.js';
|
|
8
|
+
import { DataType } from './data-type.js';
|
|
8
9
|
/**
|
|
9
10
|
* @class MixinType
|
|
10
11
|
*/
|
|
@@ -40,6 +41,8 @@ export const MixinType = function (...args) {
|
|
|
40
41
|
*/
|
|
41
42
|
class MixinTypeClass extends ComplexTypeBase {
|
|
42
43
|
extendsFrom(baseType) {
|
|
44
|
+
if (!(baseType instanceof DataType))
|
|
45
|
+
baseType = this.node.getDataType(baseType);
|
|
43
46
|
if (!(baseType instanceof ComplexTypeBase))
|
|
44
47
|
return false;
|
|
45
48
|
if (baseType === this)
|
|
@@ -94,8 +97,9 @@ function MixinTypeFactory(...args) {
|
|
|
94
97
|
if (!(itemMeta &&
|
|
95
98
|
(itemMeta.kind === OpraSchema.ComplexType.Kind ||
|
|
96
99
|
itemMeta.kind === OpraSchema.MixinType.Kind ||
|
|
97
|
-
itemMeta.kind === OpraSchema.MappedType.Kind)))
|
|
100
|
+
itemMeta.kind === OpraSchema.MappedType.Kind))) {
|
|
98
101
|
throw new TypeError(`Class "${c.name}" is not a ${OpraSchema.ComplexType.Kind}, ${OpraSchema.MixinType.Kind} or ${OpraSchema.MappedType.Kind}`);
|
|
102
|
+
}
|
|
99
103
|
metadata.types.push(c);
|
|
100
104
|
mergePrototype(MixinClass.prototype, c.prototype);
|
|
101
105
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { isAny } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -17,6 +17,7 @@ let AnyType = class AnyType {
|
|
|
17
17
|
AnyType = __decorate([
|
|
18
18
|
SimpleType({
|
|
19
19
|
description: 'Represents any value',
|
|
20
|
-
})
|
|
20
|
+
}),
|
|
21
|
+
__metadata("design:paramtypes", [Object])
|
|
21
22
|
], AnyType);
|
|
22
23
|
export { AnyType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { toBigint, vg } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -22,6 +22,11 @@ let BigintType = class BigintType extends NumberType {
|
|
|
22
22
|
BigintType = __decorate([
|
|
23
23
|
SimpleType({
|
|
24
24
|
description: 'BigInt number',
|
|
25
|
-
|
|
25
|
+
nameMappings: {
|
|
26
|
+
js: 'bigint',
|
|
27
|
+
json: 'string',
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
__metadata("design:paramtypes", [Object])
|
|
26
31
|
], BigintType);
|
|
27
32
|
export { BigintType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { toBoolean } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -17,6 +17,11 @@ let BooleanType = class BooleanType {
|
|
|
17
17
|
BooleanType = __decorate([
|
|
18
18
|
SimpleType({
|
|
19
19
|
description: 'Simple true/false value',
|
|
20
|
-
|
|
20
|
+
nameMappings: {
|
|
21
|
+
js: 'boolean',
|
|
22
|
+
json: 'boolean',
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
__metadata("design:paramtypes", [Object])
|
|
21
26
|
], BooleanType);
|
|
22
27
|
export { BooleanType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { toInteger, vg } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -22,6 +22,11 @@ let IntegerType = class IntegerType extends NumberType {
|
|
|
22
22
|
IntegerType = __decorate([
|
|
23
23
|
SimpleType({
|
|
24
24
|
description: 'An integer number',
|
|
25
|
-
|
|
25
|
+
nameMappings: {
|
|
26
|
+
js: 'number',
|
|
27
|
+
json: 'number',
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
__metadata("design:paramtypes", [Object])
|
|
26
31
|
], IntegerType);
|
|
27
32
|
export { IntegerType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { isNull } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -17,6 +17,11 @@ let NullType = class NullType {
|
|
|
17
17
|
NullType = __decorate([
|
|
18
18
|
SimpleType({
|
|
19
19
|
description: 'A Null value',
|
|
20
|
-
|
|
20
|
+
nameMappings: {
|
|
21
|
+
js: 'null',
|
|
22
|
+
json: 'null',
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
__metadata("design:paramtypes", [Object])
|
|
21
26
|
], NullType);
|
|
22
27
|
export { NullType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { toNumber, vg } from 'valgen';
|
|
3
3
|
import { DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -22,16 +22,23 @@ let NumberType = class NumberType {
|
|
|
22
22
|
__decorate([
|
|
23
23
|
SimpleType.Attribute({
|
|
24
24
|
description: 'Determines the minimum value',
|
|
25
|
-
})
|
|
25
|
+
}),
|
|
26
|
+
__metadata("design:type", Number)
|
|
26
27
|
], NumberType.prototype, "minValue", void 0);
|
|
27
28
|
__decorate([
|
|
28
29
|
SimpleType.Attribute({
|
|
29
30
|
description: 'Determines the maximum value',
|
|
30
|
-
})
|
|
31
|
+
}),
|
|
32
|
+
__metadata("design:type", Number)
|
|
31
33
|
], NumberType.prototype, "maxValue", void 0);
|
|
32
34
|
NumberType = __decorate([
|
|
33
35
|
SimpleType({
|
|
34
36
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
35
|
-
|
|
37
|
+
nameMappings: {
|
|
38
|
+
js: 'number',
|
|
39
|
+
json: 'number',
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
__metadata("design:paramtypes", [Object])
|
|
36
43
|
], NumberType);
|
|
37
44
|
export { NumberType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { DATATYPE_METADATA } from '../../constants.js';
|
|
3
3
|
import { ComplexType } from '../complex-type.js';
|
|
4
4
|
let ObjectType = class ObjectType {
|
|
@@ -12,7 +12,8 @@ ObjectType = __decorate([
|
|
|
12
12
|
name: 'object',
|
|
13
13
|
description: 'A non modelled object',
|
|
14
14
|
additionalFields: true,
|
|
15
|
-
})
|
|
15
|
+
}),
|
|
16
|
+
__metadata("design:paramtypes", [Object])
|
|
16
17
|
], ObjectType);
|
|
17
18
|
export { ObjectType };
|
|
18
19
|
const metadata = Reflect.getMetadata(DATATYPE_METADATA, ObjectType);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { toString, vg } from 'valgen';
|
|
3
3
|
import { DATATYPE_METADATA, DECODER, ENCODER } from '../../constants.js';
|
|
4
4
|
import { SimpleType } from '../simple-type.js';
|
|
@@ -30,26 +30,35 @@ let StringType = class StringType {
|
|
|
30
30
|
__decorate([
|
|
31
31
|
SimpleType.Attribute({
|
|
32
32
|
description: 'Regex pattern to be used for validation',
|
|
33
|
-
})
|
|
33
|
+
}),
|
|
34
|
+
__metadata("design:type", Object)
|
|
34
35
|
], StringType.prototype, "pattern", void 0);
|
|
35
36
|
__decorate([
|
|
36
37
|
SimpleType.Attribute({
|
|
37
38
|
description: 'Name of the pattern',
|
|
38
|
-
})
|
|
39
|
+
}),
|
|
40
|
+
__metadata("design:type", String)
|
|
39
41
|
], StringType.prototype, "patternName", void 0);
|
|
40
42
|
__decorate([
|
|
41
43
|
SimpleType.Attribute({
|
|
42
44
|
description: 'Minimum number of characters',
|
|
43
|
-
})
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", Number)
|
|
44
47
|
], StringType.prototype, "minLength", void 0);
|
|
45
48
|
__decorate([
|
|
46
49
|
SimpleType.Attribute({
|
|
47
50
|
description: 'Minimum number of characters',
|
|
48
|
-
})
|
|
51
|
+
}),
|
|
52
|
+
__metadata("design:type", Number)
|
|
49
53
|
], StringType.prototype, "maxLength", void 0);
|
|
50
54
|
StringType = __decorate([
|
|
51
55
|
SimpleType({
|
|
52
56
|
description: 'A sequence of characters',
|
|
53
|
-
|
|
57
|
+
nameMappings: {
|
|
58
|
+
js: 'string',
|
|
59
|
+
json: 'string',
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
__metadata("design:paramtypes", [Object])
|
|
54
63
|
], StringType);
|
|
55
64
|
export { StringType };
|
|
@@ -20,11 +20,14 @@ export const SimpleType = function (...args) {
|
|
|
20
20
|
_this.kind = OpraSchema.SimpleType.Kind;
|
|
21
21
|
if (initArgs.base) {
|
|
22
22
|
// noinspection SuspiciousTypeOfGuard
|
|
23
|
-
if (!(initArgs.base instanceof SimpleType))
|
|
23
|
+
if (!(initArgs.base instanceof SimpleType)) {
|
|
24
24
|
throw new TypeError(`"${initArgs.base.kind}" can't be set as base for a "${this.kind}"`);
|
|
25
|
+
}
|
|
25
26
|
_this.base = initArgs.base;
|
|
26
27
|
}
|
|
27
28
|
_this.properties = initArgs.properties;
|
|
29
|
+
_this.ownNameMappings = { ...initArgs.nameMappings };
|
|
30
|
+
_this.nameMappings = { ..._this.base?.nameMappings, ...initArgs.nameMappings };
|
|
28
31
|
_this.ownAttributes = cloneObject(initArgs.attributes || {});
|
|
29
32
|
_this.attributes = _this.base ? cloneObject(_this.base.attributes) : {};
|
|
30
33
|
if (_this.ownAttributes) {
|
|
@@ -43,6 +46,8 @@ export const SimpleType = function (...args) {
|
|
|
43
46
|
*/
|
|
44
47
|
class SimpleTypeClass extends DataType {
|
|
45
48
|
extendsFrom(baseType) {
|
|
49
|
+
if (!(baseType instanceof DataType))
|
|
50
|
+
baseType = this.node.getDataType(baseType);
|
|
46
51
|
if (!(baseType instanceof SimpleType))
|
|
47
52
|
return false;
|
|
48
53
|
if (baseType === this)
|
|
@@ -63,15 +68,13 @@ class SimpleTypeClass extends DataType {
|
|
|
63
68
|
}
|
|
64
69
|
return isAny;
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
t = this.base;
|
|
72
|
-
}
|
|
73
|
-
return isAny;
|
|
71
|
+
let t = this;
|
|
72
|
+
while (t) {
|
|
73
|
+
if (t._generateEncoder)
|
|
74
|
+
return t._generateEncoder(prop, options?.documentElement || this.owner);
|
|
75
|
+
t = this.base;
|
|
74
76
|
}
|
|
77
|
+
return isAny;
|
|
75
78
|
}
|
|
76
79
|
toJSON() {
|
|
77
80
|
const attributes = omitUndefined(this.ownAttributes);
|
|
@@ -87,12 +90,15 @@ class SimpleTypeClass extends DataType {
|
|
|
87
90
|
return o;
|
|
88
91
|
}, {});
|
|
89
92
|
const baseName = this.base ? this.node.getDataTypeNameWithNs(this.base) : undefined;
|
|
90
|
-
|
|
93
|
+
const out = omitUndefined({
|
|
91
94
|
...DataType.prototype.toJSON.apply(this),
|
|
92
95
|
base: this.base ? (baseName ? baseName : this.base.toJSON()) : undefined,
|
|
93
96
|
attributes: attributes && Object.keys(attributes).length ? attributes : undefined,
|
|
94
97
|
properties: Object.keys(properties).length ? properties : undefined,
|
|
95
98
|
});
|
|
99
|
+
if (Object.keys(this.ownNameMappings).length)
|
|
100
|
+
out.nameMappings = { ...this.ownNameMappings };
|
|
101
|
+
return out;
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
SimpleType.prototype = SimpleTypeClass.prototype;
|
|
@@ -23,8 +23,9 @@ export function createMappedClass(source, config, options) {
|
|
|
23
23
|
throw new TypeError(`Class "${source}" doesn't have datatype metadata information`);
|
|
24
24
|
if (!(m.kind === OpraSchema.ComplexType.Kind ||
|
|
25
25
|
m.kind === OpraSchema.MappedType.Kind ||
|
|
26
|
-
m.kind === OpraSchema.MixinType.Kind))
|
|
26
|
+
m.kind === OpraSchema.MixinType.Kind)) {
|
|
27
27
|
throw new TypeError(`Class "${source}" is not a ${OpraSchema.ComplexType.Kind}`);
|
|
28
|
+
}
|
|
28
29
|
}
|
|
29
30
|
const metadata = {
|
|
30
31
|
...options,
|
|
@@ -98,6 +98,31 @@ export function HttpControllerDecoratorFactory(options) {
|
|
|
98
98
|
});
|
|
99
99
|
return decorator;
|
|
100
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
decorator.KeyParam = (name, arg1) => {
|
|
105
|
+
decoratorChain.push((meta) => {
|
|
106
|
+
if (!meta.path?.includes(':' + name))
|
|
107
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
108
|
+
const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
|
|
109
|
+
? {
|
|
110
|
+
name,
|
|
111
|
+
location: 'path',
|
|
112
|
+
type: arg1,
|
|
113
|
+
keyParam: true,
|
|
114
|
+
}
|
|
115
|
+
: {
|
|
116
|
+
...arg1,
|
|
117
|
+
name,
|
|
118
|
+
location: 'path',
|
|
119
|
+
keyParam: true,
|
|
120
|
+
};
|
|
121
|
+
meta.parameters = meta.parameters || [];
|
|
122
|
+
meta.parameters.push(paramMeta);
|
|
123
|
+
});
|
|
124
|
+
return decorator;
|
|
125
|
+
};
|
|
101
126
|
/**
|
|
102
127
|
*
|
|
103
128
|
*/
|
|
@@ -21,8 +21,8 @@ HttpOperation.Entity.Create = function (arg0, arg1) {
|
|
|
21
21
|
/** Initialize the decorator and the chain */
|
|
22
22
|
const decoratorChain = [];
|
|
23
23
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
24
|
-
description: args.description,
|
|
25
24
|
method: 'POST',
|
|
25
|
+
...args,
|
|
26
26
|
composition: 'Entity.Create',
|
|
27
27
|
requestBody: {
|
|
28
28
|
immediateFetch: true,
|
|
@@ -72,8 +72,8 @@ HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
72
72
|
/** Initialize the decorator and the chain */
|
|
73
73
|
const decoratorChain = [];
|
|
74
74
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
75
|
-
description: args.description,
|
|
76
75
|
method: 'DELETE',
|
|
76
|
+
...args,
|
|
77
77
|
composition: 'Entity.Delete',
|
|
78
78
|
}));
|
|
79
79
|
decorator
|
|
@@ -91,11 +91,23 @@ HttpOperation.Entity.Delete = function (arg0, arg1) {
|
|
|
91
91
|
*
|
|
92
92
|
*/
|
|
93
93
|
decorator.KeyParam = (name, prmOptions) => {
|
|
94
|
-
|
|
94
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
95
|
+
? {
|
|
96
|
+
name,
|
|
97
|
+
location: 'path',
|
|
98
|
+
type: prmOptions,
|
|
99
|
+
keyParam: true,
|
|
100
|
+
}
|
|
101
|
+
: {
|
|
102
|
+
...prmOptions,
|
|
103
|
+
name,
|
|
104
|
+
location: 'path',
|
|
105
|
+
keyParam: true,
|
|
106
|
+
};
|
|
107
|
+
decorator.PathParam(name, paramMeta);
|
|
95
108
|
decoratorChain.push((meta) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
meta.compositionOptions.keyParameter = name;
|
|
109
|
+
if (!meta.path?.includes(':' + name))
|
|
110
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
99
111
|
});
|
|
100
112
|
return decorator;
|
|
101
113
|
};
|
|
@@ -121,8 +133,8 @@ HttpOperation.Entity.DeleteMany = function (arg0, arg1) {
|
|
|
121
133
|
const filterType = new FilterType({ dataType: args.type });
|
|
122
134
|
filterType.rules = {};
|
|
123
135
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
124
|
-
description: args.description,
|
|
125
136
|
method: 'DELETE',
|
|
137
|
+
...args,
|
|
126
138
|
composition: 'Entity.DeleteMany',
|
|
127
139
|
}));
|
|
128
140
|
decorator
|
|
@@ -169,8 +181,8 @@ HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
169
181
|
const filterType = new FilterType({ dataType: args.type });
|
|
170
182
|
filterType.rules = {};
|
|
171
183
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
172
|
-
description: args.description,
|
|
173
184
|
method: 'GET',
|
|
185
|
+
...args,
|
|
174
186
|
composition: 'Entity.FindMany',
|
|
175
187
|
}));
|
|
176
188
|
decorator
|
|
@@ -261,8 +273,8 @@ HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
261
273
|
/** Initialize the decorator and the chain */
|
|
262
274
|
const decoratorChain = [];
|
|
263
275
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
264
|
-
description: args.description,
|
|
265
276
|
method: 'GET',
|
|
277
|
+
...args,
|
|
266
278
|
composition: 'Entity.Get',
|
|
267
279
|
}));
|
|
268
280
|
decorator
|
|
@@ -294,11 +306,23 @@ HttpOperation.Entity.Get = function (arg0, arg1) {
|
|
|
294
306
|
*
|
|
295
307
|
*/
|
|
296
308
|
decorator.KeyParam = (name, prmOptions) => {
|
|
297
|
-
|
|
309
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
310
|
+
? {
|
|
311
|
+
name,
|
|
312
|
+
location: 'path',
|
|
313
|
+
type: prmOptions,
|
|
314
|
+
keyParam: true,
|
|
315
|
+
}
|
|
316
|
+
: {
|
|
317
|
+
...prmOptions,
|
|
318
|
+
name,
|
|
319
|
+
location: 'path',
|
|
320
|
+
keyParam: true,
|
|
321
|
+
};
|
|
322
|
+
decorator.PathParam(name, paramMeta);
|
|
298
323
|
decoratorChain.push((meta) => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
meta.compositionOptions.keyParameter = name;
|
|
324
|
+
if (!meta.path?.includes(':' + name))
|
|
325
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
302
326
|
});
|
|
303
327
|
return decorator;
|
|
304
328
|
};
|
|
@@ -324,8 +348,8 @@ HttpOperation.Entity.UpdateMany = function (arg0, arg1) {
|
|
|
324
348
|
filterType.rules = {};
|
|
325
349
|
const filterRules = new FilterRules();
|
|
326
350
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
327
|
-
description: args.description,
|
|
328
351
|
method: 'PATCH',
|
|
352
|
+
...args,
|
|
329
353
|
composition: 'Entity.UpdateMany',
|
|
330
354
|
requestBody: {
|
|
331
355
|
immediateFetch: true,
|
|
@@ -379,8 +403,8 @@ HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
379
403
|
const filterType = new FilterType({ dataType: args.type });
|
|
380
404
|
filterType.rules = {};
|
|
381
405
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
382
|
-
description: args.description,
|
|
383
406
|
method: 'PATCH',
|
|
407
|
+
...args,
|
|
384
408
|
composition: 'Entity.Update',
|
|
385
409
|
requestBody: {
|
|
386
410
|
partial: 'deep',
|
|
@@ -423,11 +447,23 @@ HttpOperation.Entity.Update = function (arg0, arg1) {
|
|
|
423
447
|
*
|
|
424
448
|
*/
|
|
425
449
|
decorator.KeyParam = (name, prmOptions) => {
|
|
426
|
-
|
|
450
|
+
const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
|
|
451
|
+
? {
|
|
452
|
+
name,
|
|
453
|
+
location: 'path',
|
|
454
|
+
type: prmOptions,
|
|
455
|
+
keyParam: true,
|
|
456
|
+
}
|
|
457
|
+
: {
|
|
458
|
+
...prmOptions,
|
|
459
|
+
name,
|
|
460
|
+
location: 'path',
|
|
461
|
+
keyParam: true,
|
|
462
|
+
};
|
|
463
|
+
decorator.PathParam(name, paramMeta);
|
|
427
464
|
decoratorChain.push((meta) => {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
meta.compositionOptions.keyParameter = name;
|
|
465
|
+
if (!meta.path?.includes(':' + name))
|
|
466
|
+
meta.path = (meta.path || '') + '@:' + name;
|
|
431
467
|
});
|
|
432
468
|
return decorator;
|
|
433
469
|
};
|
|
@@ -33,8 +33,9 @@ export function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
33
33
|
type: arg1,
|
|
34
34
|
}
|
|
35
35
|
: { ...arg1, name, location: 'cookie' };
|
|
36
|
-
if (meta.parameters)
|
|
36
|
+
if (meta.parameters) {
|
|
37
37
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'cookie' && String(p.name) === String(name)));
|
|
38
|
+
}
|
|
38
39
|
else
|
|
39
40
|
meta.parameters = [];
|
|
40
41
|
meta.parameters.push(paramMeta);
|
|
@@ -53,8 +54,9 @@ export function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
53
54
|
type: arg1,
|
|
54
55
|
}
|
|
55
56
|
: { ...arg1, name, location: 'header' };
|
|
56
|
-
if (meta.parameters)
|
|
57
|
+
if (meta.parameters) {
|
|
57
58
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'header' && String(p.name) === String(name)));
|
|
59
|
+
}
|
|
58
60
|
else
|
|
59
61
|
meta.parameters = [];
|
|
60
62
|
meta.parameters.push(paramMeta);
|
|
@@ -73,8 +75,9 @@ export function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
73
75
|
type: arg1,
|
|
74
76
|
}
|
|
75
77
|
: { ...arg1, name, location: 'query' };
|
|
76
|
-
if (meta.parameters)
|
|
78
|
+
if (meta.parameters) {
|
|
77
79
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'query' && String(p.name) === String(name)));
|
|
80
|
+
}
|
|
78
81
|
else
|
|
79
82
|
meta.parameters = [];
|
|
80
83
|
meta.parameters.push(paramMeta);
|
|
@@ -93,8 +96,9 @@ export function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
93
96
|
type: arg1,
|
|
94
97
|
}
|
|
95
98
|
: { ...arg1, name, location: 'path' };
|
|
96
|
-
if (meta.parameters)
|
|
99
|
+
if (meta.parameters) {
|
|
97
100
|
meta.parameters = meta.parameters.filter(p => !(p.location === 'path' && String(p.name) === String(name)));
|
|
101
|
+
}
|
|
98
102
|
else
|
|
99
103
|
meta.parameters = [];
|
|
100
104
|
meta.parameters.push(paramMeta);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { asMutable } from 'ts-gems';
|
|
1
3
|
import { resolveThunk } from '../../helpers/index.js';
|
|
2
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
5
|
import { ApiDocument } from '../api-document.js';
|
|
@@ -40,9 +42,7 @@ export class ApiDocumentFactory {
|
|
|
40
42
|
context.error.message = `(${l}) error${l > 1 ? 's' : ''} found in document schema.`;
|
|
41
43
|
if (context.showErrorDetails) {
|
|
42
44
|
context.error.message += context.error.details
|
|
43
|
-
.map(d => {
|
|
44
|
-
return `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : '');
|
|
45
|
-
})
|
|
45
|
+
.map(d => `\n\n - ${d.message}` + (d.path ? `\n @${d.path}` : ''))
|
|
46
46
|
.join('');
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -109,6 +109,8 @@ export class ApiDocumentFactory {
|
|
|
109
109
|
context.addError(`Unknown service protocol (${init.api.protocol})`);
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
+
const x = document.export();
|
|
113
|
+
asMutable(document).id = crypto.createHash('md5').update(JSON.stringify(x)).digest('base64url');
|
|
112
114
|
}
|
|
113
115
|
/**
|
|
114
116
|
*
|