@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,29 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionType = 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 complex_type_js_1 = require("./complex-type.js");
|
|
8
|
+
const data_type_js_1 = require("./data-type.js");
|
|
9
|
+
const mapped_type_js_1 = require("./mapped-type.js");
|
|
7
10
|
/**
|
|
8
11
|
* @class UnionType
|
|
9
12
|
*/
|
|
10
|
-
|
|
13
|
+
exports.UnionType = function (...args) {
|
|
11
14
|
// UnionType helper
|
|
12
15
|
if (!this) {
|
|
13
16
|
return mapToUnionType(...args);
|
|
14
17
|
}
|
|
15
18
|
// Constructor
|
|
16
19
|
// call super()
|
|
17
|
-
DataType.apply(this, args);
|
|
20
|
+
data_type_js_1.DataType.apply(this, args);
|
|
18
21
|
const [, init] = args;
|
|
19
22
|
const _this = this;
|
|
20
|
-
_this.fields = new ResponsiveMap();
|
|
23
|
+
_this.fields = new index_js_1.ResponsiveMap();
|
|
21
24
|
const own = _this.own;
|
|
22
25
|
own.types = [];
|
|
23
26
|
for (const base of init.types) {
|
|
24
|
-
if (!(base instanceof ComplexType || base instanceof UnionType || base instanceof MappedType))
|
|
25
|
-
throw new TypeError(`${OpraSchema.UnionType.Kind} shall contain ${OpraSchema.ComplexType.Kind}, ` +
|
|
26
|
-
`${OpraSchema.UnionType.Kind} of ${OpraSchema.MappedType.Kind} types.`);
|
|
27
|
+
if (!(base instanceof complex_type_js_1.ComplexType || base instanceof exports.UnionType || base instanceof mapped_type_js_1.MappedType))
|
|
28
|
+
throw new TypeError(`${index_js_2.OpraSchema.UnionType.Kind} shall contain ${index_js_2.OpraSchema.ComplexType.Kind}, ` +
|
|
29
|
+
`${index_js_2.OpraSchema.UnionType.Kind} of ${index_js_2.OpraSchema.MappedType.Kind} types.`);
|
|
27
30
|
own.types.push(base);
|
|
28
31
|
if (base.additionalFields)
|
|
29
32
|
_this.additionalFields = true;
|
|
@@ -32,18 +35,18 @@ export const UnionType = function (...args) {
|
|
|
32
35
|
_this.kind = 'UnionType';
|
|
33
36
|
_this.types = [...own.types];
|
|
34
37
|
};
|
|
35
|
-
UnionType._applyMixin = () => void 0;
|
|
38
|
+
exports.UnionType._applyMixin = () => void 0;
|
|
36
39
|
const proto = {
|
|
37
40
|
exportSchema() {
|
|
38
|
-
const out = DataType.prototype.exportSchema.call(this);
|
|
39
|
-
Object.assign(out, omitUndefined({
|
|
41
|
+
const out = data_type_js_1.DataType.prototype.exportSchema.call(this);
|
|
42
|
+
Object.assign(out, (0, index_js_1.omitUndefined)({
|
|
40
43
|
types: this.own.types.map(t => t.name ? t.name : t.exportSchema())
|
|
41
44
|
}));
|
|
42
45
|
return out;
|
|
43
46
|
}
|
|
44
47
|
};
|
|
45
|
-
Object.assign(UnionType.prototype, proto);
|
|
46
|
-
Object.setPrototypeOf(UnionType.prototype, DataType.prototype);
|
|
48
|
+
Object.assign(exports.UnionType.prototype, proto);
|
|
49
|
+
Object.setPrototypeOf(exports.UnionType.prototype, data_type_js_1.DataType.prototype);
|
|
47
50
|
/**
|
|
48
51
|
*
|
|
49
52
|
*/
|
|
@@ -57,22 +60,22 @@ function mapToUnionType(...args) {
|
|
|
57
60
|
class UnionClass {
|
|
58
61
|
constructor() {
|
|
59
62
|
for (const c of clasRefs)
|
|
60
|
-
inheritPropertyInitializers(this, c);
|
|
63
|
+
(0, index_js_1.inheritPropertyInitializers)(this, c);
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
const metadata = {
|
|
64
|
-
kind: OpraSchema.UnionType.Kind,
|
|
67
|
+
kind: index_js_2.OpraSchema.UnionType.Kind,
|
|
65
68
|
types: []
|
|
66
69
|
};
|
|
67
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, UnionClass);
|
|
70
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, metadata, UnionClass);
|
|
68
71
|
for (const c of clasRefs) {
|
|
69
|
-
const itemMeta = Reflect.getMetadata(METADATA_KEY, c);
|
|
70
|
-
if (!(itemMeta && (itemMeta.kind === OpraSchema.ComplexType.Kind || itemMeta.kind === OpraSchema.UnionType.Kind ||
|
|
71
|
-
itemMeta.kind === OpraSchema.MappedType.Kind)))
|
|
72
|
-
throw new TypeError(`Class "${c.name}" is not a ${OpraSchema.ComplexType.Kind}, ${OpraSchema.UnionType.Kind} or ${OpraSchema.MappedType.Kind}`);
|
|
72
|
+
const itemMeta = Reflect.getMetadata(constants_js_1.METADATA_KEY, c);
|
|
73
|
+
if (!(itemMeta && (itemMeta.kind === index_js_2.OpraSchema.ComplexType.Kind || itemMeta.kind === index_js_2.OpraSchema.UnionType.Kind ||
|
|
74
|
+
itemMeta.kind === index_js_2.OpraSchema.MappedType.Kind)))
|
|
75
|
+
throw new TypeError(`Class "${c.name}" is not a ${index_js_2.OpraSchema.ComplexType.Kind}, ${index_js_2.OpraSchema.UnionType.Kind} or ${index_js_2.OpraSchema.MappedType.Kind}`);
|
|
73
76
|
metadata.types.push(c);
|
|
74
|
-
applyMixins(UnionClass, c);
|
|
77
|
+
(0, index_js_1.applyMixins)(UnionClass, c);
|
|
75
78
|
}
|
|
76
|
-
UnionType._applyMixin(UnionClass, ...clasRefs);
|
|
79
|
+
exports.UnionType._applyMixin(UnionClass, ...clasRefs);
|
|
77
80
|
return UnionClass;
|
|
78
81
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addReferences = void 0;
|
|
4
|
+
const api_document_js_1 = require("../api-document.js");
|
|
5
|
+
async function addReferences(references) {
|
|
3
6
|
const { document } = this;
|
|
4
7
|
for (const [ns, r] of Object.entries(references)) {
|
|
5
8
|
if (typeof r === 'string') {
|
|
6
9
|
document.references.set(ns, await this.createDocumentFromUrl(r));
|
|
7
10
|
}
|
|
8
|
-
else if (r instanceof ApiDocument)
|
|
11
|
+
else if (r instanceof api_document_js_1.ApiDocument)
|
|
9
12
|
document.references.set(ns, r);
|
|
10
13
|
else if (typeof r === 'object') {
|
|
11
14
|
document.references.set(ns, await this.createDocument(r));
|
|
@@ -14,3 +17,4 @@ export async function addReferences(references) {
|
|
|
14
17
|
throw new TypeError(`Invalid document reference (${ns}) in schema`);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
20
|
+
exports.addReferences = addReferences;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBuiltinTypeDocument = exports.createDocumentFromUrl = exports.createDocument = void 0;
|
|
4
|
+
const index_js_1 = require("../../schema/index.js");
|
|
5
|
+
const index_js_2 = require("../data-type/builtin/index.js");
|
|
6
|
+
async function createDocument(init, options) {
|
|
4
7
|
// const {document, typeQueue, curPath, resourceQueue} = this;
|
|
5
8
|
this.document.url = init.url;
|
|
6
9
|
if (init.info)
|
|
@@ -37,23 +40,25 @@ export async function createDocument(init, options) {
|
|
|
37
40
|
this.document.resources.sort();
|
|
38
41
|
return this.document;
|
|
39
42
|
}
|
|
43
|
+
exports.createDocument = createDocument;
|
|
40
44
|
/**
|
|
41
45
|
*
|
|
42
46
|
* @param url
|
|
43
47
|
* @protected
|
|
44
48
|
*/
|
|
45
|
-
|
|
49
|
+
async function createDocumentFromUrl(url) {
|
|
46
50
|
const resp = await fetch(url, { method: 'GET' });
|
|
47
51
|
const init = await resp.json();
|
|
48
52
|
if (!init)
|
|
49
53
|
throw new TypeError(`Invalid response returned from url: ${url}`);
|
|
50
54
|
return await this.createDocument({ ...init, url });
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
exports.createDocumentFromUrl = createDocumentFromUrl;
|
|
57
|
+
async function createBuiltinTypeDocument() {
|
|
53
58
|
const init = {
|
|
54
|
-
version: OpraSchema.SpecVersion,
|
|
59
|
+
version: index_js_1.OpraSchema.SpecVersion,
|
|
55
60
|
info: {
|
|
56
|
-
version: OpraSchema.SpecVersion,
|
|
61
|
+
version: index_js_1.OpraSchema.SpecVersion,
|
|
57
62
|
title: 'Opra built-in types',
|
|
58
63
|
contact: [{
|
|
59
64
|
url: 'https://github.com/oprajs/opra'
|
|
@@ -64,12 +69,13 @@ export async function createBuiltinTypeDocument() {
|
|
|
64
69
|
name: 'MIT'
|
|
65
70
|
}
|
|
66
71
|
},
|
|
67
|
-
types: [AnyType, Base64Type, BigIntType, BooleanType,
|
|
68
|
-
DateType, GuidType, IntegerType, NumberType,
|
|
69
|
-
ObjectType, StringType
|
|
72
|
+
types: [index_js_2.AnyType, index_js_2.Base64Type, index_js_2.BigIntType, index_js_2.BooleanType,
|
|
73
|
+
index_js_2.DateType, index_js_2.GuidType, index_js_2.IntegerType, index_js_2.NumberType,
|
|
74
|
+
index_js_2.ObjectType, index_js_2.StringType
|
|
70
75
|
]
|
|
71
76
|
};
|
|
72
77
|
const factoryClass = Object.getPrototypeOf(this).constructor;
|
|
73
78
|
const factory = new factoryClass();
|
|
74
79
|
return await factory.createDocument(init, { noBuiltinTypes: true });
|
|
75
80
|
}
|
|
81
|
+
exports.createBuiltinTypeDocument = createBuiltinTypeDocument;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentFactory = void 0;
|
|
4
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
+
const api_document_js_1 = require("../api-document.js");
|
|
6
|
+
const add_references_js_1 = require("./add-references.js");
|
|
7
|
+
const create_document_js_1 = require("./create-document.js");
|
|
8
|
+
const import_resource_class_js_1 = require("./import-resource-class.js");
|
|
9
|
+
const import_type_class_js_1 = require("./import-type-class.js");
|
|
10
|
+
const process_resources_js_1 = require("./process-resources.js");
|
|
11
|
+
const process_types_js_1 = require("./process-types.js");
|
|
9
12
|
/**
|
|
10
13
|
* @class DocumentFactory
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
class DocumentFactory {
|
|
13
16
|
constructor() {
|
|
14
|
-
this.document = new ApiDocument();
|
|
15
|
-
this.typeQueue = new ResponsiveMap();
|
|
16
|
-
this.resourceQueue = new ResponsiveMap();
|
|
17
|
-
this.circularRefs = new ResponsiveMap();
|
|
17
|
+
this.document = new api_document_js_1.ApiDocument();
|
|
18
|
+
this.typeQueue = new index_js_1.ResponsiveMap();
|
|
19
|
+
this.resourceQueue = new index_js_1.ResponsiveMap();
|
|
20
|
+
this.circularRefs = new index_js_1.ResponsiveMap();
|
|
18
21
|
this.curPath = [];
|
|
19
22
|
this.cache = new Map();
|
|
20
23
|
}
|
|
@@ -34,25 +37,26 @@ export class DocumentFactory {
|
|
|
34
37
|
return factory.createDocumentFromUrl(url);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
exports.DocumentFactory = DocumentFactory;
|
|
37
41
|
(() => {
|
|
38
|
-
DocumentFactory.prototype.createDocument = createDocument;
|
|
39
|
-
DocumentFactory.prototype.createDocumentFromUrl = createDocumentFromUrl;
|
|
40
|
-
DocumentFactory.prototype.createBuiltinTypeDocument = createBuiltinTypeDocument;
|
|
41
|
-
DocumentFactory.prototype.addReferences = addReferences;
|
|
42
|
-
DocumentFactory.prototype.importTypeClass = importTypeClass;
|
|
43
|
-
DocumentFactory.prototype.extractSimpleTypeSchema = extractSimpleTypeSchema;
|
|
44
|
-
DocumentFactory.prototype.extractComplexTypeSchema = extractComplexTypeSchema;
|
|
45
|
-
DocumentFactory.prototype.extractMappedTypeSchema = extractMappedTypeSchema;
|
|
46
|
-
DocumentFactory.prototype.extractUnionTypeSchema = extractUnionTypeSchema;
|
|
47
|
-
DocumentFactory.prototype.extractEnumTypeSchema = extractEnumTypeSchema;
|
|
48
|
-
DocumentFactory.prototype.extractFieldSchema = extractFieldSchema;
|
|
49
|
-
DocumentFactory.prototype.processTypes = processTypes;
|
|
50
|
-
DocumentFactory.prototype.createDataTypeInstance = createDataTypeInstance;
|
|
51
|
-
DocumentFactory.prototype.addDataType = addDataType;
|
|
52
|
-
DocumentFactory.prototype.importResourceClass = importResourceClass;
|
|
53
|
-
DocumentFactory.prototype.extractSingletonSchema = extractSingletonSchema;
|
|
54
|
-
DocumentFactory.prototype.extractCollectionSchema = extractCollectionSchema;
|
|
55
|
-
DocumentFactory.prototype.processResourceQueue = processResourceQueue;
|
|
56
|
-
DocumentFactory.prototype.createCollection = createCollection;
|
|
57
|
-
DocumentFactory.prototype.createSingleton = createSingleton;
|
|
42
|
+
DocumentFactory.prototype.createDocument = create_document_js_1.createDocument;
|
|
43
|
+
DocumentFactory.prototype.createDocumentFromUrl = create_document_js_1.createDocumentFromUrl;
|
|
44
|
+
DocumentFactory.prototype.createBuiltinTypeDocument = create_document_js_1.createBuiltinTypeDocument;
|
|
45
|
+
DocumentFactory.prototype.addReferences = add_references_js_1.addReferences;
|
|
46
|
+
DocumentFactory.prototype.importTypeClass = import_type_class_js_1.importTypeClass;
|
|
47
|
+
DocumentFactory.prototype.extractSimpleTypeSchema = import_type_class_js_1.extractSimpleTypeSchema;
|
|
48
|
+
DocumentFactory.prototype.extractComplexTypeSchema = import_type_class_js_1.extractComplexTypeSchema;
|
|
49
|
+
DocumentFactory.prototype.extractMappedTypeSchema = import_type_class_js_1.extractMappedTypeSchema;
|
|
50
|
+
DocumentFactory.prototype.extractUnionTypeSchema = import_type_class_js_1.extractUnionTypeSchema;
|
|
51
|
+
DocumentFactory.prototype.extractEnumTypeSchema = import_type_class_js_1.extractEnumTypeSchema;
|
|
52
|
+
DocumentFactory.prototype.extractFieldSchema = import_type_class_js_1.extractFieldSchema;
|
|
53
|
+
DocumentFactory.prototype.processTypes = process_types_js_1.processTypes;
|
|
54
|
+
DocumentFactory.prototype.createDataTypeInstance = process_types_js_1.createDataTypeInstance;
|
|
55
|
+
DocumentFactory.prototype.addDataType = process_types_js_1.addDataType;
|
|
56
|
+
DocumentFactory.prototype.importResourceClass = import_resource_class_js_1.importResourceClass;
|
|
57
|
+
DocumentFactory.prototype.extractSingletonSchema = import_resource_class_js_1.extractSingletonSchema;
|
|
58
|
+
DocumentFactory.prototype.extractCollectionSchema = import_resource_class_js_1.extractCollectionSchema;
|
|
59
|
+
DocumentFactory.prototype.processResourceQueue = process_resources_js_1.processResourceQueue;
|
|
60
|
+
DocumentFactory.prototype.createCollection = process_resources_js_1.createCollection;
|
|
61
|
+
DocumentFactory.prototype.createSingleton = process_resources_js_1.createSingleton;
|
|
58
62
|
})();
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractCollectionSchema = exports.extractSingletonSchema = exports.importResourceClass = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
6
|
+
const index_js_2 = require("../../schema/index.js");
|
|
7
|
+
const constants_js_1 = require("../constants.js");
|
|
8
|
+
async function importResourceClass(thunk) {
|
|
5
9
|
const { document, resourceQueue, cache } = this;
|
|
6
|
-
const controller = await resolveThunk(thunk);
|
|
10
|
+
const controller = await (0, index_js_1.resolveThunk)(thunk);
|
|
7
11
|
const cached = cache.get(controller);
|
|
8
12
|
if (cached)
|
|
9
13
|
return cached;
|
|
10
14
|
const ctor = typeof thunk === 'function' ? thunk : Object.getPrototypeOf(thunk).constructor;
|
|
11
|
-
let metadata = Reflect.getMetadata(METADATA_KEY, ctor);
|
|
12
|
-
if (!metadata && OpraSchema.isResource(metadata))
|
|
15
|
+
let metadata = Reflect.getMetadata(constants_js_1.METADATA_KEY, ctor);
|
|
16
|
+
if (!metadata && index_js_2.OpraSchema.isResource(metadata))
|
|
13
17
|
throw new TypeError(`Class "${ctor.name}" doesn't have a valid Resource metadata`);
|
|
14
18
|
// const controller = typeof thunk === 'function' ? new ctor() : thunk;
|
|
15
19
|
// Clone metadata to prevent changing its contents
|
|
16
|
-
metadata = cloneObject(metadata);
|
|
17
|
-
const schema = cloneObject(metadata);
|
|
20
|
+
metadata = (0, index_js_1.cloneObject)(metadata);
|
|
21
|
+
const schema = (0, index_js_1.cloneObject)(metadata);
|
|
18
22
|
schema.controller = controller;
|
|
19
23
|
cache.set(thunk, schema);
|
|
20
|
-
if (OpraSchema.isSingleton(schema) || OpraSchema.isCollection(schema)) {
|
|
24
|
+
if (index_js_2.OpraSchema.isSingleton(schema) || index_js_2.OpraSchema.isCollection(schema)) {
|
|
21
25
|
if (!document.getDataType(metadata.type, true) && (typeof metadata.type === 'function')) {
|
|
22
26
|
await this.importTypeClass(metadata.type);
|
|
23
27
|
await this.processTypes();
|
|
24
|
-
const dataTypeCtor = await resolveClass(metadata.type);
|
|
28
|
+
const dataTypeCtor = await (0, index_js_1.resolveClass)(metadata.type);
|
|
25
29
|
const dataType = document.getComplexType(dataTypeCtor);
|
|
26
30
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
31
|
schema.type = dataType.name;
|
|
@@ -29,19 +33,22 @@ export async function importResourceClass(thunk) {
|
|
|
29
33
|
// Check if data type exists
|
|
30
34
|
document.getComplexType(schema.type);
|
|
31
35
|
}
|
|
32
|
-
if (OpraSchema.isSingleton(schema))
|
|
36
|
+
if (index_js_2.OpraSchema.isSingleton(schema))
|
|
33
37
|
await this.extractSingletonSchema(schema, ctor, metadata, controller);
|
|
34
|
-
if (OpraSchema.isCollection(schema))
|
|
38
|
+
if (index_js_2.OpraSchema.isCollection(schema))
|
|
35
39
|
await this.extractCollectionSchema(schema, ctor, metadata, controller);
|
|
36
40
|
resourceQueue.set(metadata.name, schema);
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
exports.importResourceClass = importResourceClass;
|
|
43
|
+
async function extractSingletonSchema(
|
|
39
44
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
40
45
|
target, ctor, metadata, controller) {
|
|
41
46
|
// Do nothing. This method is used by external modules for extending the factory
|
|
42
47
|
}
|
|
43
|
-
|
|
48
|
+
exports.extractSingletonSchema = extractSingletonSchema;
|
|
49
|
+
async function extractCollectionSchema(
|
|
44
50
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
51
|
target, ctor, metadata, controller) {
|
|
46
52
|
// Do nothing. This method is used by external modules for extending the factory
|
|
47
53
|
}
|
|
54
|
+
exports.extractCollectionSchema = extractCollectionSchema;
|
|
@@ -1,41 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFieldSchema = exports.extractEnumTypeSchema = exports.extractUnionTypeSchema = exports.extractMappedTypeSchema = exports.extractComplexTypeSchema = exports.extractSimpleTypeSchema = exports.importTypeClass = 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
|
+
async function importTypeClass(typeThunk) {
|
|
5
8
|
const { document, typeQueue, cache } = this;
|
|
6
|
-
const thunk = await resolveThunk(typeThunk);
|
|
9
|
+
const thunk = await (0, index_js_1.resolveThunk)(typeThunk);
|
|
7
10
|
const cached = cache.get(thunk);
|
|
8
11
|
if (cached)
|
|
9
12
|
return cached;
|
|
10
13
|
const dt = document.getDataType(thunk, true);
|
|
11
14
|
if (dt && dt.name)
|
|
12
15
|
return dt.name;
|
|
13
|
-
const metadata = Reflect.getMetadata(METADATA_KEY, thunk);
|
|
14
|
-
if (!(metadata && OpraSchema.isDataType(metadata))) {
|
|
16
|
+
const metadata = Reflect.getMetadata(constants_js_1.METADATA_KEY, thunk);
|
|
17
|
+
if (!(metadata && index_js_2.OpraSchema.isDataType(metadata))) {
|
|
15
18
|
// If thunk is a Type class
|
|
16
|
-
if (isConstructor(thunk))
|
|
19
|
+
if ((0, index_js_1.isConstructor)(thunk))
|
|
17
20
|
throw new TypeError(`Class "${thunk.name}" doesn't have a valid DataType metadata`);
|
|
18
21
|
// If thunk is an Enum object
|
|
19
22
|
throw new TypeError(`No EnumType metadata found for object ${JSON.stringify(thunk).substring(0, 20)}...`);
|
|
20
23
|
}
|
|
21
24
|
// Clone metadata to prevent changing its contents
|
|
22
25
|
const name = metadata.name;
|
|
23
|
-
const schema = cloneObject(metadata);
|
|
26
|
+
const schema = (0, index_js_1.cloneObject)(metadata);
|
|
24
27
|
const result = name || schema;
|
|
25
28
|
if (name) {
|
|
29
|
+
if (this.document.types.has(name) || typeQueue.has(name))
|
|
30
|
+
throw new TypeError(`Type "${name}" already imported`);
|
|
26
31
|
cache.set(thunk, result);
|
|
27
32
|
typeQueue.set(name, schema);
|
|
28
33
|
}
|
|
29
34
|
// If thunk is a DataType class
|
|
30
|
-
if (isConstructor(thunk)) {
|
|
35
|
+
if ((0, index_js_1.isConstructor)(thunk)) {
|
|
31
36
|
const ctor = thunk;
|
|
32
|
-
if (OpraSchema.isSimpleType(schema))
|
|
37
|
+
if (index_js_2.OpraSchema.isSimpleType(schema))
|
|
33
38
|
await this.extractSimpleTypeSchema(schema, ctor, metadata);
|
|
34
|
-
else if (OpraSchema.isComplexType(schema))
|
|
39
|
+
else if (index_js_2.OpraSchema.isComplexType(schema))
|
|
35
40
|
await this.extractComplexTypeSchema(schema, ctor, metadata);
|
|
36
|
-
else if (OpraSchema.isMappedType(schema))
|
|
41
|
+
else if (index_js_2.OpraSchema.isMappedType(schema))
|
|
37
42
|
await this.extractMappedTypeSchema(schema, ctor, metadata);
|
|
38
|
-
else if (OpraSchema.isUnionType(schema))
|
|
43
|
+
else if (index_js_2.OpraSchema.isUnionType(schema))
|
|
39
44
|
await this.extractUnionTypeSchema(schema, ctor, metadata);
|
|
40
45
|
else
|
|
41
46
|
throw new TypeError(`Class "${ctor.name}" doesn't have a valid DataType metadata`);
|
|
@@ -43,9 +48,9 @@ export async function importTypeClass(typeThunk) {
|
|
|
43
48
|
}
|
|
44
49
|
// If thunk is a EnumType object
|
|
45
50
|
const enumObject = thunk;
|
|
46
|
-
if (OpraSchema.isEnumType(schema)) {
|
|
51
|
+
if (index_js_2.OpraSchema.isEnumType(schema)) {
|
|
47
52
|
let baseType;
|
|
48
|
-
if (metadata.base && Reflect.hasMetadata(METADATA_KEY, metadata.base)) {
|
|
53
|
+
if (metadata.base && Reflect.hasMetadata(constants_js_1.METADATA_KEY, metadata.base)) {
|
|
49
54
|
baseType = await this.importTypeClass(metadata.base);
|
|
50
55
|
}
|
|
51
56
|
schema.base = baseType;
|
|
@@ -54,17 +59,20 @@ export async function importTypeClass(typeThunk) {
|
|
|
54
59
|
}
|
|
55
60
|
throw new TypeError(`No EnumType metadata found for object ${JSON.stringify(enumObject).substring(0, 20)}...`);
|
|
56
61
|
}
|
|
57
|
-
|
|
62
|
+
exports.importTypeClass = importTypeClass;
|
|
63
|
+
// noinspection JSUnusedLocalSymbols
|
|
64
|
+
async function extractSimpleTypeSchema(target, ctor,
|
|
58
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
59
66
|
metadata) {
|
|
60
67
|
const baseClass = Object.getPrototypeOf(ctor.prototype).constructor;
|
|
61
|
-
if (Reflect.hasMetadata(METADATA_KEY, baseClass))
|
|
68
|
+
if (Reflect.hasMetadata(constants_js_1.METADATA_KEY, baseClass))
|
|
62
69
|
target.base = await this.importTypeClass(baseClass);
|
|
63
70
|
target.codec = Object.create(ctor.prototype);
|
|
64
71
|
}
|
|
65
|
-
|
|
72
|
+
exports.extractSimpleTypeSchema = extractSimpleTypeSchema;
|
|
73
|
+
async function extractComplexTypeSchema(target, ctor, metadata) {
|
|
66
74
|
const baseClass = Object.getPrototypeOf(ctor.prototype).constructor;
|
|
67
|
-
if (Reflect.hasMetadata(METADATA_KEY, baseClass))
|
|
75
|
+
if (Reflect.hasMetadata(constants_js_1.METADATA_KEY, baseClass))
|
|
68
76
|
target.base = await this.importTypeClass(baseClass);
|
|
69
77
|
target.ctor = ctor;
|
|
70
78
|
// Fields
|
|
@@ -80,12 +88,14 @@ export async function extractComplexTypeSchema(target, ctor, metadata) {
|
|
|
80
88
|
...elemMeta,
|
|
81
89
|
type
|
|
82
90
|
};
|
|
83
|
-
if (elemMeta.enum)
|
|
91
|
+
if (elemMeta.enum)
|
|
84
92
|
elemSchema.type = await this.importTypeClass(elemMeta.enum);
|
|
85
|
-
}
|
|
86
93
|
if (!elemSchema.type && elemMeta.designType)
|
|
87
94
|
elemSchema.type = await this.importTypeClass(elemMeta.designType);
|
|
88
95
|
await this.extractFieldSchema(elemSchema, ctor, elemMeta, elemName);
|
|
96
|
+
// Check enum again. External packages may modify enum value
|
|
97
|
+
if (elemMeta.enum)
|
|
98
|
+
elemSchema.type = await this.importTypeClass(elemMeta.enum);
|
|
89
99
|
if (typeof elemSchema.type === 'function')
|
|
90
100
|
elemSchema.type = await this.importTypeClass(elemSchema.type);
|
|
91
101
|
if (elemSchema.isArray && !elemSchema.type)
|
|
@@ -99,22 +109,29 @@ export async function extractComplexTypeSchema(target, ctor, metadata) {
|
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
|
-
|
|
112
|
+
exports.extractComplexTypeSchema = extractComplexTypeSchema;
|
|
113
|
+
async function extractMappedTypeSchema(target, ctor, metadata) {
|
|
103
114
|
target.type = await this.importTypeClass(metadata.type);
|
|
104
115
|
}
|
|
105
|
-
|
|
116
|
+
exports.extractMappedTypeSchema = extractMappedTypeSchema;
|
|
117
|
+
async function extractUnionTypeSchema(target, ctor, metadata) {
|
|
106
118
|
const oldTypes = metadata.types;
|
|
107
119
|
target.types = [];
|
|
108
120
|
for (const type of oldTypes)
|
|
109
121
|
target.types.push(await this.importTypeClass(type));
|
|
110
122
|
}
|
|
111
|
-
|
|
123
|
+
exports.extractUnionTypeSchema = extractUnionTypeSchema;
|
|
124
|
+
// noinspection JSUnusedLocalSymbols
|
|
125
|
+
async function extractEnumTypeSchema(
|
|
112
126
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
113
127
|
target, enumObject, metadata) {
|
|
114
128
|
// Do nothing. This method is used by external modules for extending the factory
|
|
115
129
|
}
|
|
116
|
-
|
|
130
|
+
exports.extractEnumTypeSchema = extractEnumTypeSchema;
|
|
131
|
+
// noinspection JSUnusedLocalSymbols
|
|
132
|
+
async function extractFieldSchema(
|
|
117
133
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
118
134
|
target, ctor, metadata, name) {
|
|
119
135
|
// Do nothing. This method is used by external modules for extending the factory
|
|
120
136
|
}
|
|
137
|
+
exports.extractFieldSchema = extractFieldSchema;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSingleton = exports.createCollection = exports.processResourceQueue = void 0;
|
|
4
|
+
const index_js_1 = require("../../schema/index.js");
|
|
5
|
+
const collection_js_1 = require("../resource/collection.js");
|
|
6
|
+
const singleton_js_1 = require("../resource/singleton.js");
|
|
7
|
+
async function processResourceQueue() {
|
|
5
8
|
const { document, resourceQueue } = this;
|
|
6
9
|
const resourceNames = Array.from(resourceQueue.keys());
|
|
7
10
|
for (const name of resourceNames) {
|
|
@@ -9,12 +12,12 @@ export async function processResourceQueue() {
|
|
|
9
12
|
if (!schema)
|
|
10
13
|
continue;
|
|
11
14
|
try {
|
|
12
|
-
if (OpraSchema.isCollection(schema)) {
|
|
15
|
+
if (index_js_1.OpraSchema.isCollection(schema)) {
|
|
13
16
|
const resource = await this.createCollection(name, schema);
|
|
14
17
|
document.resources.set(name, resource);
|
|
15
18
|
continue;
|
|
16
19
|
}
|
|
17
|
-
if (OpraSchema.isSingleton(schema)) {
|
|
20
|
+
if (index_js_1.OpraSchema.isSingleton(schema)) {
|
|
18
21
|
const resource = await this.createSingleton(name, schema);
|
|
19
22
|
document.resources.set(name, resource);
|
|
20
23
|
continue;
|
|
@@ -27,7 +30,8 @@ export async function processResourceQueue() {
|
|
|
27
30
|
throw new TypeError(`Invalid Resource schema: ${JSON.stringify(schema).substring(0, 20)}...`);
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
exports.processResourceQueue = processResourceQueue;
|
|
34
|
+
async function createCollection(name, schema) {
|
|
31
35
|
const { document } = this;
|
|
32
36
|
const dataType = document.getComplexType(schema.type);
|
|
33
37
|
const initArgs = {
|
|
@@ -35,9 +39,10 @@ export async function createCollection(name, schema) {
|
|
|
35
39
|
name,
|
|
36
40
|
type: dataType
|
|
37
41
|
};
|
|
38
|
-
return new Collection(document, initArgs);
|
|
42
|
+
return new collection_js_1.Collection(document, initArgs);
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
exports.createCollection = createCollection;
|
|
45
|
+
async function createSingleton(name, schema) {
|
|
41
46
|
const { document } = this;
|
|
42
47
|
const dataType = document.getComplexType(schema.type);
|
|
43
48
|
const initArgs = {
|
|
@@ -45,5 +50,6 @@ export async function createSingleton(name, schema) {
|
|
|
45
50
|
name,
|
|
46
51
|
type: dataType
|
|
47
52
|
};
|
|
48
|
-
return new Singleton(document, initArgs);
|
|
53
|
+
return new singleton_js_1.Singleton(document, initArgs);
|
|
49
54
|
}
|
|
55
|
+
exports.createSingleton = createSingleton;
|