@opra/common 0.15.0 → 0.16.0
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/cjs/document/factory/import-resource-class.js +1 -0
- package/cjs/document/factory/import-type-class.js +9 -2
- package/cjs/document/resource/collection.js +9 -9
- package/cjs/document/resource/singleton.js +4 -4
- package/cjs/url/opra-url.js +7 -7
- package/esm/document/api-document.js +37 -33
- package/esm/document/constants.js +6 -3
- package/esm/document/data-type/api-field.js +15 -12
- package/esm/document/data-type/builtin/any.type.js +8 -5
- package/esm/document/data-type/builtin/base64.type.js +8 -5
- package/esm/document/data-type/builtin/bigint.type.js +8 -5
- package/esm/document/data-type/builtin/boolean.type.js +11 -8
- package/esm/document/data-type/builtin/date.type.js +10 -7
- package/esm/document/data-type/builtin/guid.type.js +12 -9
- package/esm/document/data-type/builtin/index.js +13 -10
- package/esm/document/data-type/builtin/integer.type.js +13 -10
- package/esm/document/data-type/builtin/number.type.js +10 -7
- package/esm/document/data-type/builtin/object.type.js +8 -5
- package/esm/document/data-type/builtin/string.type.js +11 -8
- package/esm/document/data-type/builtin/time.type.js +10 -7
- package/esm/document/data-type/builtin/timestamp.type.js +12 -9
- package/esm/document/data-type/complex-type.js +34 -30
- package/esm/document/data-type/data-type.js +12 -9
- package/esm/document/data-type/enum-type.js +19 -15
- package/esm/document/data-type/mapped-type.js +29 -24
- package/esm/document/data-type/simple-type.js +21 -17
- package/esm/document/data-type/union-type.js +29 -26
- package/esm/document/factory/add-references.js +7 -3
- package/esm/document/factory/create-document.js +16 -10
- package/esm/document/factory/factory.js +37 -33
- package/esm/document/factory/import-resource-class.js +22 -15
- package/esm/document/factory/import-type-class.js +43 -26
- package/esm/document/factory/index.js +4 -1
- package/esm/document/factory/process-resources.js +16 -10
- package/esm/document/factory/process-types.js +37 -31
- package/esm/document/index.js +17 -14
- package/esm/document/resource/collection.js +50 -46
- package/esm/document/resource/resource.js +12 -9
- package/esm/document/resource/singleton.js +29 -25
- package/esm/document/utils/inspect.util.js +7 -4
- package/esm/document/utils/string-compare.util.js +5 -1
- package/esm/exception/enums/issue-severity.enum.js +5 -2
- package/esm/exception/error-issue.js +2 -1
- package/esm/exception/http-errors/bad-request.error.js +8 -4
- package/esm/exception/http-errors/failed-dependency.error.js +8 -4
- package/esm/exception/http-errors/forbidden.error.js +8 -4
- package/esm/exception/http-errors/internal-server.error.js +8 -4
- package/esm/exception/http-errors/method-not-allowed.error.js +8 -4
- package/esm/exception/http-errors/not-acceptable.error.js +8 -4
- package/esm/exception/http-errors/not-found.error.js +8 -4
- package/esm/exception/http-errors/unauthorized.error.js +8 -4
- package/esm/exception/http-errors/unprocessable-entity.error.js +8 -4
- package/esm/exception/index.js +18 -15
- package/esm/exception/opra-exception.js +7 -3
- package/esm/exception/resource-errors/resource-conflict.error.js +8 -4
- package/esm/exception/resource-errors/resource-not-found.error.js +8 -4
- package/esm/exception/wrap-exception.js +24 -20
- package/esm/filter/antlr/OpraFilterLexer.js +9 -6
- package/esm/filter/antlr/OpraFilterListener.js +5 -2
- package/esm/filter/antlr/OpraFilterParser.js +126 -79
- package/esm/filter/antlr/OpraFilterVisitor.js +5 -2
- package/esm/filter/ast/abstract/ast.js +5 -1
- package/esm/filter/ast/abstract/expression.js +6 -2
- package/esm/filter/ast/abstract/literal.js +6 -2
- package/esm/filter/ast/abstract/term.js +6 -2
- package/esm/filter/ast/expressions/arithmetic-expression.js +8 -3
- package/esm/filter/ast/expressions/array-expression.js +6 -2
- package/esm/filter/ast/expressions/comparison-expression.js +6 -2
- package/esm/filter/ast/expressions/logical-expression.js +6 -2
- package/esm/filter/ast/expressions/parentheses-expression.js +6 -2
- package/esm/filter/ast/index.js +19 -16
- package/esm/filter/ast/terms/boolean-literal.js +6 -2
- package/esm/filter/ast/terms/date-literal.js +12 -8
- package/esm/filter/ast/terms/external-constant.js +6 -2
- package/esm/filter/ast/terms/null-literal.js +6 -2
- package/esm/filter/ast/terms/number-literal.js +8 -4
- package/esm/filter/ast/terms/qualified-identifier.js +6 -2
- package/esm/filter/ast/terms/string-literal.js +8 -4
- package/esm/filter/ast/terms/time-literal.js +10 -6
- package/esm/filter/build.js +69 -45
- package/esm/filter/errors.js +9 -3
- package/esm/filter/filter-tree-visitor.js +31 -26
- package/esm/filter/index.js +8 -5
- package/esm/filter/opra-error-listener.js +8 -4
- package/esm/filter/parse.js +19 -14
- package/esm/filter/utils.js +7 -2
- package/esm/helpers/function-utils.js +14 -8
- package/esm/helpers/get-stack-filename.js +5 -1
- package/esm/helpers/index.js +11 -8
- package/esm/helpers/is-url.js +5 -1
- package/esm/helpers/mixin-utils.js +7 -2
- package/esm/helpers/object-utils.js +12 -6
- package/esm/helpers/path-to-object-tree.js +5 -1
- package/esm/helpers/responsive-map.js +5 -1
- package/esm/helpers/type-guards.js +17 -7
- package/esm/http/codecs/boolean-codec.js +5 -1
- package/esm/http/codecs/date-codec.js +5 -1
- package/esm/http/codecs/filter-codec.js +9 -5
- package/esm/http/codecs/integer-codec.js +6 -2
- package/esm/http/codecs/number-codec.js +5 -1
- package/esm/http/codecs/string-codec.js +5 -1
- package/esm/http/enums/http-headers-codes.enum.js +5 -2
- package/esm/http/enums/http-status-codes.enum.js +5 -2
- package/esm/http/enums/http-status-messages.js +4 -1
- package/esm/http/http-headers.js +9 -5
- package/esm/http/http-message.host.js +18 -13
- package/esm/http/http-params.js +25 -20
- package/esm/http/http-request-message.js +22 -18
- package/esm/http/http-response-message.js +28 -23
- package/esm/http/index.js +17 -14
- package/esm/http/interfaces/client-http-headers.interface.js +2 -1
- package/esm/http/interfaces/cookie-options.interface.js +2 -1
- package/esm/http/interfaces/server-http-headers.interface.js +2 -1
- package/esm/i18n/i18n.js +28 -23
- package/esm/i18n/index.js +9 -5
- package/esm/i18n/string-utils.js +7 -2
- package/esm/i18n/translate.js +7 -3
- package/esm/index.js +16 -11
- package/esm/schema/constants.js +4 -1
- package/esm/schema/data-type/complex-type.interface.js +5 -2
- package/esm/schema/data-type/data-type.interface.js +2 -1
- package/esm/schema/data-type/enum-type.interface.js +5 -2
- package/esm/schema/data-type/field.interface.js +2 -1
- package/esm/schema/data-type/mapped-type.interface.js +5 -2
- package/esm/schema/data-type/simple-type.interface.js +5 -2
- package/esm/schema/data-type/union-type.interface.js +5 -2
- package/esm/schema/document.interface.js +2 -1
- package/esm/schema/index.js +34 -31
- package/esm/schema/resource/collection.interface.js +5 -2
- package/esm/schema/resource/container.interface.js +5 -2
- package/esm/schema/resource/endpoint.interface.js +2 -1
- package/esm/schema/resource/resource.interface.js +2 -1
- package/esm/schema/resource/singleton.interface.js +5 -2
- package/esm/schema/type-guards.js +53 -40
- package/esm/types.js +2 -1
- package/esm/url/index.js +8 -5
- package/esm/url/opra-url-path-component.js +7 -3
- package/esm/url/opra-url-path.js +18 -14
- package/esm/url/opra-url.js +25 -21
- package/esm/url/utils/decode-path-component.js +8 -4
- package/esm/url/utils/encode-path-component.js +8 -3
- package/esm/utils/path-utils.js +7 -2
- package/package.json +5 -4
- package/{esm → types}/document/factory/import-resource-class.d.ts +1 -0
- package/{esm → types}/document/resource/collection.d.ts +10 -10
- package/{esm → types}/document/resource/singleton.d.ts +4 -4
- package/{esm → types}/schema/resource/collection.interface.d.ts +6 -6
- package/{esm → types}/url/opra-url.d.ts +3 -3
- package/{esm → types}/document/api-document.d.ts +0 -0
- package/{esm → types}/document/constants.d.ts +0 -0
- package/{esm → types}/document/data-type/api-field.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/any.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/base64.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/bigint.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/boolean.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/date.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/guid.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/index.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/integer.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/number.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/object.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/string.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/time.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/timestamp.type.d.ts +0 -0
- package/{esm → types}/document/data-type/complex-type.d.ts +0 -0
- package/{esm → types}/document/data-type/data-type.d.ts +0 -0
- package/{esm → types}/document/data-type/enum-type.d.ts +0 -0
- package/{esm → types}/document/data-type/mapped-type.d.ts +0 -0
- package/{esm → types}/document/data-type/simple-type.d.ts +0 -0
- package/{esm → types}/document/data-type/union-type.d.ts +0 -0
- package/{esm → types}/document/factory/add-references.d.ts +0 -0
- package/{esm → types}/document/factory/create-document.d.ts +0 -0
- package/{esm → types}/document/factory/factory.d.ts +0 -0
- package/{esm → types}/document/factory/import-type-class.d.ts +0 -0
- package/{esm → types}/document/factory/index.d.ts +0 -0
- package/{esm → types}/document/factory/process-resources.d.ts +0 -0
- package/{esm → types}/document/factory/process-types.d.ts +0 -0
- package/{esm → types}/document/index.d.ts +0 -0
- package/{esm → types}/document/resource/resource.d.ts +0 -0
- package/{esm → types}/document/utils/inspect.util.d.ts +0 -0
- package/{esm → types}/document/utils/string-compare.util.d.ts +0 -0
- package/{esm → types}/exception/enums/issue-severity.enum.d.ts +0 -0
- package/{esm → types}/exception/error-issue.d.ts +0 -0
- package/{esm → types}/exception/http-errors/bad-request.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/failed-dependency.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/forbidden.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/internal-server.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/method-not-allowed.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/not-acceptable.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/not-found.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/unauthorized.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/unprocessable-entity.error.d.ts +0 -0
- package/{esm → types}/exception/index.d.ts +0 -0
- package/{esm → types}/exception/opra-exception.d.ts +0 -0
- package/{esm → types}/exception/resource-errors/resource-conflict.error.d.ts +0 -0
- package/{esm → types}/exception/resource-errors/resource-not-found.error.d.ts +0 -0
- package/{esm → types}/exception/wrap-exception.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterLexer.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterListener.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterParser.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterVisitor.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/ast.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/expression.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/literal.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/term.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/arithmetic-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/array-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/comparison-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/logical-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/parentheses-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/index.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/boolean-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/date-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/external-constant.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/null-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/number-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/qualified-identifier.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/string-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/time-literal.d.ts +0 -0
- package/{esm → types}/filter/build.d.ts +0 -0
- package/{esm → types}/filter/errors.d.ts +0 -0
- package/{esm → types}/filter/filter-tree-visitor.d.ts +0 -0
- package/{esm → types}/filter/index.d.ts +0 -0
- package/{esm → types}/filter/opra-error-listener.d.ts +0 -0
- package/{esm → types}/filter/parse.d.ts +0 -0
- package/{esm → types}/filter/utils.d.ts +0 -0
- package/{esm → types}/helpers/function-utils.d.ts +0 -0
- package/{esm → types}/helpers/get-stack-filename.d.ts +0 -0
- package/{esm → types}/helpers/index.d.ts +0 -0
- package/{esm → types}/helpers/is-url.d.ts +0 -0
- package/{esm → types}/helpers/mixin-utils.d.ts +0 -0
- package/{esm → types}/helpers/object-utils.d.ts +0 -0
- package/{esm → types}/helpers/path-to-object-tree.d.ts +0 -0
- package/{esm → types}/helpers/responsive-map.d.ts +0 -0
- package/{esm → types}/helpers/type-guards.d.ts +0 -0
- package/{esm → types}/http/codecs/boolean-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/date-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/filter-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/integer-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/number-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/string-codec.d.ts +0 -0
- package/{esm → types}/http/enums/http-headers-codes.enum.d.ts +0 -0
- package/{esm → types}/http/enums/http-status-codes.enum.d.ts +0 -0
- package/{esm → types}/http/enums/http-status-messages.d.ts +0 -0
- package/{esm → types}/http/http-headers.d.ts +0 -0
- package/{esm → types}/http/http-message.host.d.ts +0 -0
- package/{esm → types}/http/http-params.d.ts +0 -0
- package/{esm → types}/http/http-request-message.d.ts +0 -0
- package/{esm → types}/http/http-response-message.d.ts +0 -0
- package/{esm → types}/http/index.d.ts +0 -0
- package/{esm → types}/http/interfaces/client-http-headers.interface.d.ts +0 -0
- package/{esm → types}/http/interfaces/cookie-options.interface.d.ts +0 -0
- package/{esm → types}/http/interfaces/server-http-headers.interface.d.ts +0 -0
- package/{esm → types}/http/multipart/batch-multipart.d.ts +0 -0
- package/{esm → types}/http/multipart/http-request-content.d.ts +0 -0
- package/{esm → types}/http/multipart/http-response-content.d.ts +0 -0
- package/{esm → types}/http/multipart/index.d.ts +0 -0
- package/{esm → types}/i18n/i18n.d.ts +0 -0
- package/{esm → types}/i18n/index.d.ts +0 -0
- package/{esm → types}/i18n/string-utils.d.ts +0 -0
- package/{esm → types}/i18n/translate.d.ts +0 -0
- package/{esm → types}/index.d.ts +0 -0
- package/{esm → types}/schema/constants.d.ts +0 -0
- package/{esm → types}/schema/data-type/complex-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/data-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/enum-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/field.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/mapped-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/simple-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/union-type.interface.d.ts +0 -0
- package/{esm → types}/schema/document.interface.d.ts +0 -0
- package/{esm → types}/schema/index.d.ts +0 -0
- package/{esm → types}/schema/resource/container.interface.d.ts +0 -0
- package/{esm → types}/schema/resource/endpoint.interface.d.ts +0 -0
- package/{esm → types}/schema/resource/resource.interface.d.ts +0 -0
- package/{esm → types}/schema/resource/singleton.interface.d.ts +2 -2
- /package/{esm → types}/schema/type-guards.d.ts +0 -0
- /package/{esm → types}/types.d.ts +0 -0
- /package/{esm → types}/url/index.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path-component.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path.d.ts +0 -0
- /package/{esm → types}/url/utils/decode-path-component.d.ts +0 -0
- /package/{esm → types}/url/utils/encode-path-component.d.ts +0 -0
- /package/{esm → types}/utils/path-utils.d.ts +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
4
7
|
let NumberType = class NumberType {
|
|
5
8
|
decode(v) {
|
|
6
9
|
if (v == null)
|
|
7
10
|
return v;
|
|
8
|
-
const x = toNumber(v);
|
|
11
|
+
const x = (0, putil_varhelpers_1.toNumber)(v);
|
|
9
12
|
if (x)
|
|
10
13
|
this.validate(x);
|
|
11
14
|
return x;
|
|
@@ -21,10 +24,10 @@ let NumberType = class NumberType {
|
|
|
21
24
|
throw new TypeError(`Invalid number value "${v}"`);
|
|
22
25
|
}
|
|
23
26
|
};
|
|
24
|
-
NumberType = __decorate([
|
|
25
|
-
SimpleType({
|
|
27
|
+
NumberType = tslib_1.__decorate([
|
|
28
|
+
(0, simple_type_js_1.SimpleType)({
|
|
26
29
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
27
30
|
ctor: Number
|
|
28
31
|
})
|
|
29
32
|
], NumberType);
|
|
30
|
-
|
|
33
|
+
exports.NumberType = NumberType;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const complex_type_js_1 = require("../complex-type.js");
|
|
3
6
|
let ObjectType = class ObjectType {
|
|
4
7
|
coerce(v) {
|
|
5
8
|
if (v == null)
|
|
@@ -7,11 +10,11 @@ let ObjectType = class ObjectType {
|
|
|
7
10
|
return typeof v === 'object' ? v : {};
|
|
8
11
|
}
|
|
9
12
|
};
|
|
10
|
-
ObjectType = __decorate([
|
|
11
|
-
ComplexType({
|
|
13
|
+
ObjectType = tslib_1.__decorate([
|
|
14
|
+
(0, complex_type_js_1.ComplexType)({
|
|
12
15
|
name: 'object',
|
|
13
16
|
description: 'A non modelled object',
|
|
14
17
|
additionalFields: true
|
|
15
18
|
})
|
|
16
19
|
], ObjectType);
|
|
17
|
-
|
|
20
|
+
exports.ObjectType = ObjectType;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
4
7
|
let StringType = class StringType {
|
|
5
8
|
decode(v) {
|
|
6
|
-
return toString(v);
|
|
9
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
7
10
|
}
|
|
8
11
|
encode(v) {
|
|
9
|
-
return toString(v);
|
|
12
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
10
13
|
}
|
|
11
14
|
coerce(v) {
|
|
12
15
|
return this.decode(v);
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
|
-
StringType = __decorate([
|
|
16
|
-
SimpleType({
|
|
18
|
+
StringType = tslib_1.__decorate([
|
|
19
|
+
(0, simple_type_js_1.SimpleType)({
|
|
17
20
|
description: 'A sequence of characters',
|
|
18
21
|
ctor: String
|
|
19
22
|
})
|
|
20
23
|
], StringType);
|
|
21
|
-
|
|
24
|
+
exports.StringType = StringType;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
const string_type_js_1 = require("./string.type.js");
|
|
4
7
|
const TIME_PATTERN = /^([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?$/;
|
|
5
|
-
let TimeType = class TimeType extends StringType {
|
|
8
|
+
let TimeType = class TimeType extends string_type_js_1.StringType {
|
|
6
9
|
decode(v) {
|
|
7
10
|
if (v == null)
|
|
8
11
|
return v;
|
|
@@ -21,9 +24,9 @@ let TimeType = class TimeType extends StringType {
|
|
|
21
24
|
throw new TypeError(`Invalid Time value "${v}"`);
|
|
22
25
|
}
|
|
23
26
|
};
|
|
24
|
-
TimeType = __decorate([
|
|
25
|
-
SimpleType({
|
|
27
|
+
TimeType = tslib_1.__decorate([
|
|
28
|
+
(0, simple_type_js_1.SimpleType)({
|
|
26
29
|
description: 'Time formatted string',
|
|
27
30
|
})
|
|
28
31
|
], TimeType);
|
|
29
|
-
|
|
32
|
+
exports.TimeType = TimeType;
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimestampType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
4
7
|
let TimestampType = class TimestampType {
|
|
5
8
|
constructor() {
|
|
6
9
|
this.format = 'YYYY-MM-DDTHH:mm:ss';
|
|
7
10
|
}
|
|
8
11
|
decode(v) {
|
|
9
|
-
return
|
|
12
|
+
return (0, dayjs_1.default)(v).toDate();
|
|
10
13
|
}
|
|
11
14
|
encode(v) {
|
|
12
15
|
if (!v)
|
|
13
16
|
return undefined;
|
|
14
|
-
const d =
|
|
17
|
+
const d = (0, dayjs_1.default)(v);
|
|
15
18
|
if (!d.isValid())
|
|
16
19
|
throw new TypeError(`Invalid date value ${v}`);
|
|
17
|
-
return
|
|
20
|
+
return (0, dayjs_1.default)(v).format(this.format);
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
|
-
TimestampType = __decorate([
|
|
21
|
-
SimpleType({
|
|
23
|
+
TimestampType = tslib_1.__decorate([
|
|
24
|
+
(0, simple_type_js_1.SimpleType)({
|
|
22
25
|
description: 'date-time notation as defined by RFC 3339, section 5.6, for example, 2021-04-18T09:12:53',
|
|
23
26
|
ctor: Date
|
|
24
27
|
})
|
|
25
28
|
], TimestampType);
|
|
26
|
-
|
|
29
|
+
exports.TimestampType = TimestampType;
|
|
@@ -1,62 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComplexType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
7
|
+
const index_js_2 = require("../../schema/index.js");
|
|
8
|
+
const constants_js_1 = require("../constants.js");
|
|
9
|
+
const api_field_js_1 = require("./api-field.js");
|
|
10
|
+
const data_type_js_1 = require("./data-type.js");
|
|
7
11
|
/**
|
|
8
12
|
* @class ComplexType
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
exports.ComplexType = function (...args) {
|
|
11
15
|
// ClassDecorator
|
|
12
16
|
if (!this) {
|
|
13
17
|
const [options] = args;
|
|
14
18
|
return function (target) {
|
|
15
|
-
const name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
16
|
-
let metadata = Reflect.getOwnMetadata(METADATA_KEY, target);
|
|
19
|
+
const name = options?.name || target.name.match(constants_js_1.TYPENAME_PATTERN)?.[1] || target.name;
|
|
20
|
+
let metadata = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, target);
|
|
17
21
|
if (!metadata) {
|
|
18
22
|
metadata = {};
|
|
19
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
23
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, metadata, target);
|
|
20
24
|
}
|
|
21
|
-
metadata.kind = OpraSchema.ComplexType.Kind;
|
|
25
|
+
metadata.kind = index_js_2.OpraSchema.ComplexType.Kind;
|
|
22
26
|
metadata.name = name;
|
|
23
27
|
// Merge options
|
|
24
28
|
if (options)
|
|
25
|
-
Object.assign(metadata,
|
|
29
|
+
Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name', 'base', 'ctor', 'fields']));
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
// Constructor
|
|
29
33
|
// call super()
|
|
30
|
-
DataType.apply(this, args);
|
|
34
|
+
data_type_js_1.DataType.apply(this, args);
|
|
31
35
|
const [, init] = args;
|
|
32
36
|
const _this = this;
|
|
33
37
|
const own = _this.own;
|
|
34
38
|
own.ctor = init?.ctor;
|
|
35
|
-
own.fields = new ResponsiveMap();
|
|
39
|
+
own.fields = new index_js_1.ResponsiveMap();
|
|
36
40
|
own.abstract = init?.abstract;
|
|
37
41
|
own.additionalFields = init?.additionalFields;
|
|
38
|
-
_this.kind = OpraSchema.ComplexType.Kind;
|
|
42
|
+
_this.kind = index_js_2.OpraSchema.ComplexType.Kind;
|
|
39
43
|
_this.base = init?.base;
|
|
40
44
|
_this.ctor = own.ctor || Object;
|
|
41
45
|
_this.abstract = own.abstract;
|
|
42
46
|
_this.additionalFields = own.additionalFields;
|
|
43
|
-
_this.fields = new ResponsiveMap();
|
|
47
|
+
_this.fields = new index_js_1.ResponsiveMap();
|
|
44
48
|
if (_this.base) {
|
|
45
49
|
if (_this.additionalFields == null)
|
|
46
50
|
_this.additionalFields = _this.base.additionalFields;
|
|
47
|
-
if (own.ctor == null && _this.base instanceof ComplexType)
|
|
51
|
+
if (own.ctor == null && _this.base instanceof exports.ComplexType)
|
|
48
52
|
_this.ctor = _this.base.ctor;
|
|
49
53
|
if (_this.base.fields)
|
|
50
54
|
for (const [k, el] of _this.base.fields.entries()) {
|
|
51
|
-
const newEl = new ApiField(_this, el);
|
|
55
|
+
const newEl = new api_field_js_1.ApiField(_this, el);
|
|
52
56
|
_this.fields.set(k, newEl);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
};
|
|
56
|
-
Object.setPrototypeOf(ComplexType.prototype, DataType.prototype);
|
|
60
|
+
Object.setPrototypeOf(exports.ComplexType.prototype, data_type_js_1.DataType.prototype);
|
|
57
61
|
const proto = {
|
|
58
62
|
extendsFrom(t) {
|
|
59
|
-
const base = t instanceof DataType ? t : this.document.getDataType(t);
|
|
63
|
+
const base = t instanceof data_type_js_1.DataType ? t : this.document.getDataType(t);
|
|
60
64
|
if (this.base) {
|
|
61
65
|
if (this.base === base)
|
|
62
66
|
return true;
|
|
@@ -65,8 +69,8 @@ const proto = {
|
|
|
65
69
|
return false;
|
|
66
70
|
},
|
|
67
71
|
exportSchema() {
|
|
68
|
-
const out = DataType.prototype.exportSchema.call(this);
|
|
69
|
-
Object.assign(out, omitUndefined({
|
|
72
|
+
const out = data_type_js_1.DataType.prototype.exportSchema.call(this);
|
|
73
|
+
Object.assign(out, (0, index_js_1.omitUndefined)({
|
|
70
74
|
base: this.base ?
|
|
71
75
|
(this.base.name ? this.base.name : this.base.exportSchema()) : undefined,
|
|
72
76
|
abstract: this.own.abstract,
|
|
@@ -78,10 +82,10 @@ const proto = {
|
|
|
78
82
|
fields[field.name] = field.exportSchema();
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
|
-
return omitUndefined(out);
|
|
85
|
+
return (0, index_js_1.omitUndefined)(out);
|
|
82
86
|
},
|
|
83
87
|
addField(init) {
|
|
84
|
-
const field = new ApiField(this, init);
|
|
88
|
+
const field = new api_field_js_1.ApiField(this, init);
|
|
85
89
|
this.own.fields.set(field.name, field);
|
|
86
90
|
this.fields.set(field.name, field);
|
|
87
91
|
return field;
|
|
@@ -93,8 +97,8 @@ const proto = {
|
|
|
93
97
|
const l = arr.length;
|
|
94
98
|
let field;
|
|
95
99
|
for (let i = 0; i < l; i++) {
|
|
96
|
-
if (!(dt instanceof ComplexType))
|
|
97
|
-
throw new TypeError(`"${arr.slice(0, i - 1)}" field is not a ${OpraSchema.ComplexType.Kind} and has no child fields`);
|
|
100
|
+
if (!(dt instanceof exports.ComplexType))
|
|
101
|
+
throw new TypeError(`"${arr.slice(0, i - 1)}" field is not a ${index_js_2.OpraSchema.ComplexType.Kind} and has no child fields`);
|
|
98
102
|
field = dt.getField(arr[i]);
|
|
99
103
|
dt = field.type;
|
|
100
104
|
}
|
|
@@ -107,13 +111,13 @@ const proto = {
|
|
|
107
111
|
return t;
|
|
108
112
|
},
|
|
109
113
|
normalizeFieldNames(fields) {
|
|
110
|
-
const fieldsTree = (fields && pathToObjectTree(Array.isArray(fields) ? fields : [fields])) || {};
|
|
114
|
+
const fieldsTree = (fields && (0, index_js_1.pathToObjectTree)(Array.isArray(fields) ? fields : [fields])) || {};
|
|
111
115
|
const out = _normalizeFieldsNames([], this.document, this, fieldsTree, '', '');
|
|
112
116
|
return out.length ? out : undefined;
|
|
113
117
|
}
|
|
114
118
|
};
|
|
115
|
-
Object.assign(ComplexType.prototype, proto);
|
|
116
|
-
Object.setPrototypeOf(ComplexType.prototype, DataType.prototype);
|
|
119
|
+
Object.assign(exports.ComplexType.prototype, proto);
|
|
120
|
+
Object.setPrototypeOf(exports.ComplexType.prototype, data_type_js_1.DataType.prototype);
|
|
117
121
|
/**
|
|
118
122
|
* Normalizes field names
|
|
119
123
|
*/
|
|
@@ -134,7 +138,7 @@ function _normalizeFieldsNames(target, document, dataType, node, parentPath = ''
|
|
|
134
138
|
}
|
|
135
139
|
curPath = parentPath ? parentPath + '.' + field.name : field.name;
|
|
136
140
|
if (typeof nodeVal === 'object') {
|
|
137
|
-
if (!(field.type instanceof ComplexType))
|
|
141
|
+
if (!(field.type instanceof exports.ComplexType))
|
|
138
142
|
throw new TypeError(`"${(actualPath ? actualPath + '.' + curPath : curPath)}" is not a complex type and has no sub fields`);
|
|
139
143
|
if (target.findIndex(x => x === parentPath) >= 0)
|
|
140
144
|
continue;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataType = void 0;
|
|
4
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
+
const inspect_util_js_1 = require("../utils/inspect.util.js");
|
|
6
|
+
exports.DataType = function (document, init) {
|
|
7
|
+
if (!(this instanceof exports.DataType)) {
|
|
5
8
|
throw new TypeError(`Class constructor must be called with "new" keyword`);
|
|
6
9
|
// noinspection UnreachableCodeJS
|
|
7
10
|
return;
|
|
@@ -27,7 +30,7 @@ const proto = {
|
|
|
27
30
|
return false;
|
|
28
31
|
},
|
|
29
32
|
exportSchema() {
|
|
30
|
-
return omitUndefined({
|
|
33
|
+
return (0, index_js_1.omitUndefined)({
|
|
31
34
|
kind: this.kind,
|
|
32
35
|
description: this.own.description
|
|
33
36
|
});
|
|
@@ -35,9 +38,9 @@ const proto = {
|
|
|
35
38
|
toString() {
|
|
36
39
|
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name || '#anonymous'}]`;
|
|
37
40
|
},
|
|
38
|
-
[nodeInspectCustom]() {
|
|
39
|
-
return `[${colorFgYellow + Object.getPrototypeOf(this).constructor.name + colorReset}` +
|
|
40
|
-
` ${colorFgMagenta + this.name + colorReset}]`;
|
|
41
|
+
[inspect_util_js_1.nodeInspectCustom]() {
|
|
42
|
+
return `[${inspect_util_js_1.colorFgYellow + Object.getPrototypeOf(this).constructor.name + inspect_util_js_1.colorReset}` +
|
|
43
|
+
` ${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
|
-
Object.assign(DataType.prototype, proto);
|
|
46
|
+
Object.assign(exports.DataType.prototype, proto);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnumType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
7
|
+
const index_js_2 = require("../../schema/index.js");
|
|
8
|
+
const constants_js_1 = require("../constants.js");
|
|
9
|
+
const data_type_js_1 = require("./data-type.js");
|
|
6
10
|
/**
|
|
7
11
|
* @class EnumType
|
|
8
12
|
*/
|
|
9
|
-
|
|
13
|
+
exports.EnumType = function (...args) {
|
|
10
14
|
// Injector
|
|
11
15
|
if (!this) {
|
|
12
16
|
const [source, options] = args;
|
|
@@ -17,20 +21,20 @@ export const EnumType = function (...args) {
|
|
|
17
21
|
}, {})
|
|
18
22
|
: source;
|
|
19
23
|
const metadata = {
|
|
20
|
-
kind: OpraSchema.EnumType.Kind,
|
|
24
|
+
kind: index_js_2.OpraSchema.EnumType.Kind,
|
|
21
25
|
values
|
|
22
26
|
};
|
|
23
27
|
if (options)
|
|
24
|
-
Object.assign(metadata,
|
|
25
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, source);
|
|
28
|
+
Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'values']));
|
|
29
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, metadata, source);
|
|
26
30
|
return values;
|
|
27
31
|
}
|
|
28
32
|
// Constructor
|
|
29
33
|
const [, init] = args;
|
|
30
34
|
// call super()
|
|
31
|
-
DataType.apply(this, args);
|
|
35
|
+
data_type_js_1.DataType.apply(this, args);
|
|
32
36
|
const _this = this;
|
|
33
|
-
_this.kind = OpraSchema.EnumType.Kind;
|
|
37
|
+
_this.kind = index_js_2.OpraSchema.EnumType.Kind;
|
|
34
38
|
_this.base = init.base;
|
|
35
39
|
const own = _this.own;
|
|
36
40
|
own.values = init.values;
|
|
@@ -40,8 +44,8 @@ export const EnumType = function (...args) {
|
|
|
40
44
|
};
|
|
41
45
|
const proto = {
|
|
42
46
|
exportSchema() {
|
|
43
|
-
const out = DataType.prototype.exportSchema.call(this);
|
|
44
|
-
Object.assign(out, omitUndefined({
|
|
47
|
+
const out = data_type_js_1.DataType.prototype.exportSchema.call(this);
|
|
48
|
+
Object.assign(out, (0, index_js_1.omitUndefined)({
|
|
45
49
|
base: this.base ?
|
|
46
50
|
(this.base.name ? this.base.name : this.base.exportSchema()) : undefined,
|
|
47
51
|
values: this.own.values,
|
|
@@ -54,5 +58,5 @@ const proto = {
|
|
|
54
58
|
throw new Error(`'${v}' is not a valid'${this.name ? ' ' + this.name : ''}' value`);
|
|
55
59
|
}
|
|
56
60
|
};
|
|
57
|
-
Object.assign(EnumType.prototype, proto);
|
|
58
|
-
Object.setPrototypeOf(EnumType.prototype, DataType.prototype);
|
|
61
|
+
Object.assign(exports.EnumType.prototype, proto);
|
|
62
|
+
Object.setPrototypeOf(exports.EnumType.prototype, data_type_js_1.DataType.prototype);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmitType = exports.PickType = exports.MappedType = void 0;
|
|
4
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
+
const index_js_2 = require("../../schema/index.js");
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const data_type_js_1 = require("./data-type.js");
|
|
5
8
|
/**
|
|
6
9
|
* @class MappedType
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
exports.MappedType = function (...args) {
|
|
9
12
|
let pickKeys;
|
|
10
13
|
let omitKeys;
|
|
11
14
|
const isInheritedPredicate = (propertyName) => {
|
|
@@ -22,16 +25,16 @@ export const MappedType = function (...args) {
|
|
|
22
25
|
omitKeys = options.omit && options.omit.map(x => String(x).toLowerCase());
|
|
23
26
|
class MappedClass {
|
|
24
27
|
constructor() {
|
|
25
|
-
inheritPropertyInitializers(this, source, isInheritedPredicate);
|
|
28
|
+
(0, index_js_1.inheritPropertyInitializers)(this, source, isInheritedPredicate);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
applyMixins(MappedClass, source);
|
|
31
|
+
(0, index_js_1.applyMixins)(MappedClass, source);
|
|
29
32
|
// const mappedTypeMetadata: MappedType.TypeMapping[] = [];
|
|
30
|
-
const m = Reflect.getOwnMetadata(METADATA_KEY, source);
|
|
33
|
+
const m = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, source);
|
|
31
34
|
if (!m)
|
|
32
35
|
throw new TypeError(`Class "${source}" doesn't have datatype metadata information`);
|
|
33
|
-
if (!(m.kind === OpraSchema.ComplexType.Kind))
|
|
34
|
-
throw new TypeError(`Class "${source}" is not a ${OpraSchema.ComplexType.Kind}`);
|
|
36
|
+
if (!(m.kind === index_js_2.OpraSchema.ComplexType.Kind))
|
|
37
|
+
throw new TypeError(`Class "${source}" is not a ${index_js_2.OpraSchema.ComplexType.Kind}`);
|
|
35
38
|
const metadata = {
|
|
36
39
|
kind: 'MappedType',
|
|
37
40
|
type: source
|
|
@@ -40,8 +43,8 @@ export const MappedType = function (...args) {
|
|
|
40
43
|
metadata.pick = options.pick;
|
|
41
44
|
if (options.omit)
|
|
42
45
|
metadata.omit = options.omit;
|
|
43
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, MappedClass);
|
|
44
|
-
MappedType._applyMixin(MappedClass, source, {
|
|
46
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, metadata, MappedClass);
|
|
47
|
+
exports.MappedType._applyMixin(MappedClass, source, {
|
|
45
48
|
...options,
|
|
46
49
|
isInheritedPredicate
|
|
47
50
|
});
|
|
@@ -49,7 +52,7 @@ export const MappedType = function (...args) {
|
|
|
49
52
|
}
|
|
50
53
|
// Constructor
|
|
51
54
|
// call super()
|
|
52
|
-
DataType.apply(this, args);
|
|
55
|
+
data_type_js_1.DataType.apply(this, args);
|
|
53
56
|
const [, init] = args;
|
|
54
57
|
pickKeys = init.pick && init.pick.map(x => String(x).toLowerCase());
|
|
55
58
|
omitKeys = init.omit && init.omit.map(x => String(x).toLowerCase());
|
|
@@ -58,22 +61,22 @@ export const MappedType = function (...args) {
|
|
|
58
61
|
own.type = init.type;
|
|
59
62
|
own.pick = init.pick;
|
|
60
63
|
own.omit = init.omit;
|
|
61
|
-
_this.kind = OpraSchema.MappedType.Kind;
|
|
64
|
+
_this.kind = index_js_2.OpraSchema.MappedType.Kind;
|
|
62
65
|
_this.type = own.type;
|
|
63
66
|
_this.pick = own.pick;
|
|
64
67
|
_this.omit = own.omit;
|
|
65
|
-
_this.fields = new ResponsiveMap();
|
|
68
|
+
_this.fields = new index_js_1.ResponsiveMap();
|
|
66
69
|
_this.additionalFields = _this.type.additionalFields;
|
|
67
70
|
for (const [elemName, elem] of own.type.fields.entries()) {
|
|
68
71
|
if (isInheritedPredicate(elemName))
|
|
69
72
|
_this.fields.set(elemName, elem);
|
|
70
73
|
}
|
|
71
74
|
};
|
|
72
|
-
MappedType._applyMixin = () => void 0;
|
|
75
|
+
exports.MappedType._applyMixin = () => void 0;
|
|
73
76
|
const proto = {
|
|
74
77
|
exportSchema() {
|
|
75
|
-
const out = DataType.prototype.exportSchema.call(this);
|
|
76
|
-
Object.assign(out, omitUndefined({
|
|
78
|
+
const out = data_type_js_1.DataType.prototype.exportSchema.call(this);
|
|
79
|
+
Object.assign(out, (0, index_js_1.omitUndefined)({
|
|
77
80
|
type: this.own.type.name ? this.own.type.name : this.own.type.exportSchema(),
|
|
78
81
|
pick: this.own.pick,
|
|
79
82
|
omit: this.own.omit,
|
|
@@ -81,11 +84,13 @@ const proto = {
|
|
|
81
84
|
return out;
|
|
82
85
|
}
|
|
83
86
|
};
|
|
84
|
-
Object.assign(MappedType.prototype, proto);
|
|
85
|
-
Object.setPrototypeOf(MappedType.prototype, DataType.prototype);
|
|
86
|
-
|
|
87
|
-
return MappedType(classRef, { pick: keys });
|
|
87
|
+
Object.assign(exports.MappedType.prototype, proto);
|
|
88
|
+
Object.setPrototypeOf(exports.MappedType.prototype, data_type_js_1.DataType.prototype);
|
|
89
|
+
function PickType(classRef, keys) {
|
|
90
|
+
return (0, exports.MappedType)(classRef, { pick: keys });
|
|
88
91
|
}
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
exports.PickType = PickType;
|
|
93
|
+
function OmitType(classRef, keys) {
|
|
94
|
+
return (0, exports.MappedType)(classRef, { omit: keys });
|
|
91
95
|
}
|
|
96
|
+
exports.OmitType = OmitType;
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
|
|
6
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
7
|
+
const index_js_2 = require("../../schema/index.js");
|
|
8
|
+
const constants_js_1 = require("../constants.js");
|
|
9
|
+
const data_type_js_1 = require("./data-type.js");
|
|
6
10
|
/**
|
|
7
11
|
* @class SimpleType
|
|
8
12
|
*/
|
|
9
|
-
|
|
13
|
+
exports.SimpleType = function (...args) {
|
|
10
14
|
// ClassDecorator
|
|
11
15
|
if (!this) {
|
|
12
16
|
const [options] = args;
|
|
13
17
|
return function (target) {
|
|
14
|
-
let name = options?.name || target.name.match(TYPENAME_PATTERN)?.[1] || target.name;
|
|
18
|
+
let name = options?.name || target.name.match(constants_js_1.TYPENAME_PATTERN)?.[1] || target.name;
|
|
15
19
|
name = name.charAt(0).toLowerCase() + name.substring(1);
|
|
16
|
-
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target) || {};
|
|
17
|
-
metadata.kind = OpraSchema.SimpleType.Kind;
|
|
20
|
+
const metadata = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, target) || {};
|
|
21
|
+
metadata.kind = index_js_2.OpraSchema.SimpleType.Kind;
|
|
18
22
|
metadata.name = name;
|
|
19
23
|
if (options)
|
|
20
|
-
Object.assign(metadata,
|
|
21
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
24
|
+
Object.assign(metadata, (0, lodash_omit_1.default)(options, ['kind', 'name', 'base']));
|
|
25
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, metadata, target);
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
// Constructor
|
|
25
29
|
const [, options] = args;
|
|
26
30
|
// call super()
|
|
27
|
-
DataType.apply(this, args);
|
|
31
|
+
data_type_js_1.DataType.apply(this, args);
|
|
28
32
|
const _this = this;
|
|
29
|
-
_this.kind = OpraSchema.SimpleType.Kind;
|
|
33
|
+
_this.kind = index_js_2.OpraSchema.SimpleType.Kind;
|
|
30
34
|
_this.base = options?.base;
|
|
31
35
|
const own = _this.own;
|
|
32
36
|
own.codec = options?.codec;
|
|
@@ -43,8 +47,8 @@ export const SimpleType = function (...args) {
|
|
|
43
47
|
};
|
|
44
48
|
const proto = {
|
|
45
49
|
exportSchema() {
|
|
46
|
-
const out = DataType.prototype.exportSchema.call(this);
|
|
47
|
-
Object.assign(out, omitUndefined({
|
|
50
|
+
const out = data_type_js_1.DataType.prototype.exportSchema.call(this);
|
|
51
|
+
Object.assign(out, (0, index_js_1.omitUndefined)({
|
|
48
52
|
base: this.base ?
|
|
49
53
|
(this.base.name ? this.base.name : this.base.exportSchema()) : undefined,
|
|
50
54
|
codec: this.own.codec,
|
|
@@ -53,5 +57,5 @@ const proto = {
|
|
|
53
57
|
return out;
|
|
54
58
|
}
|
|
55
59
|
};
|
|
56
|
-
Object.assign(SimpleType.prototype, proto);
|
|
57
|
-
Object.setPrototypeOf(SimpleType.prototype, DataType.prototype);
|
|
60
|
+
Object.assign(exports.SimpleType.prototype, proto);
|
|
61
|
+
Object.setPrototypeOf(exports.SimpleType.prototype, data_type_js_1.DataType.prototype);
|