@opra/common 1.0.0-alpha.9 → 1.0.0-beta.2
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/index.cjs +12 -0
- package/browser/index.mjs +12 -0
- package/cjs/document/api-document.js +11 -0
- package/cjs/document/common/api-base.js +1 -1
- package/cjs/document/common/document-element.js +2 -0
- package/cjs/document/data-type/api-field.js +8 -7
- package/cjs/document/data-type/complex-type-base.js +5 -3
- package/cjs/document/data-type/extended-types/date-string.type.js +2 -2
- package/cjs/document/data-type/extended-types/date-time-string.type.js +2 -2
- package/cjs/document/data-type/extended-types/date-time.type.js +2 -2
- package/cjs/document/data-type/extended-types/date.type.js +2 -2
- package/cjs/document/data-type/extended-types/email.type.js +2 -2
- package/cjs/document/data-type/extended-types/filter.type.js +1 -1
- package/cjs/document/data-type/extended-types/time.type.js +2 -2
- package/cjs/document/data-type/extended-types/url.type.js +2 -2
- package/cjs/document/data-type/omit-type.js +7 -2
- package/cjs/document/data-type/partial-type.js +7 -2
- package/cjs/document/data-type/pick-type.js +1 -2
- package/cjs/document/data-type/primitive-types/object.type.js +0 -3
- package/cjs/document/data-type/required-type.js +1 -2
- package/cjs/document/data-type/simple-type.js +1 -6
- package/cjs/document/data-type/utils/create-mapped-class.js +1 -2
- package/cjs/document/data-type/utils/get-is-inherited-predicate-fn.js +1 -2
- package/cjs/document/decorators/api-field-decorator.js +4 -6
- package/cjs/document/decorators/complex-type.decorator.js +1 -2
- package/cjs/document/decorators/http-controller.decorator.js +2 -3
- package/cjs/document/decorators/http-operation-entity.decorator.js +68 -74
- package/cjs/document/decorators/http-operation.decorator.js +4 -2
- package/cjs/document/decorators/simple-type.decorator.js +2 -3
- package/cjs/document/factory/api-document.factory.js +17 -8
- package/cjs/document/http/http-api.js +0 -1
- package/cjs/document/http/http-controller.js +4 -2
- package/cjs/document/http/http-media-type.js +17 -2
- package/cjs/document/http/http-multipart-field.js +0 -1
- package/cjs/document/http/http-operation-response.js +0 -1
- package/cjs/document/http/http-operation.js +12 -1
- package/cjs/document/http/http-parameter.js +2 -0
- package/cjs/document/http/http-request-body.js +0 -1
- package/cjs/document/http/http-status-range.js +5 -2
- package/cjs/document/utils/parse-regexp.util.js +1 -2
- package/cjs/document/utils/string-compare.util.js +1 -2
- package/cjs/exception/opra-exception.js +1 -0
- package/cjs/filter/build.js +21 -22
- package/cjs/filter/filter-rules.js +17 -16
- package/cjs/filter/parse.js +1 -2
- package/cjs/filter/utils.js +2 -3
- package/cjs/helpers/function-utils.js +1 -2
- package/cjs/helpers/get-stack-filename.js +2 -3
- package/cjs/helpers/index.js +1 -0
- package/cjs/helpers/mixin-utils.js +2 -3
- package/cjs/helpers/object-utils.js +5 -6
- package/cjs/helpers/parse-fields-projection.js +3 -3
- package/cjs/helpers/safe-json-stringify.js +16 -0
- package/cjs/helpers/type-guards.js +10 -11
- package/cjs/i18n/string-utils.js +2 -3
- package/cjs/i18n/translate.js +1 -2
- package/cjs/schema/index.js +2 -27
- package/cjs/schema/opra-schema.js +24 -0
- package/cjs/schema/type-guards.js +7 -8
- package/esm/document/api-document.js +11 -0
- package/esm/document/common/api-base.js +1 -1
- package/esm/document/common/document-element.js +2 -0
- package/esm/document/data-type/api-field.js +8 -7
- package/esm/document/data-type/complex-type-base.js +5 -3
- package/esm/document/data-type/extended-types/date-string.type.js +2 -2
- package/esm/document/data-type/extended-types/date-time-string.type.js +2 -2
- package/esm/document/data-type/extended-types/date-time.type.js +2 -2
- package/esm/document/data-type/extended-types/date.type.js +2 -2
- package/esm/document/data-type/extended-types/email.type.js +2 -2
- package/esm/document/data-type/extended-types/filter.type.js +1 -1
- package/esm/document/data-type/extended-types/time.type.js +2 -2
- package/esm/document/data-type/extended-types/url.type.js +2 -2
- package/esm/document/data-type/omit-type.js +6 -0
- package/esm/document/data-type/partial-type.js +6 -0
- package/esm/document/data-type/primitive-types/object.type.js +0 -3
- package/esm/document/data-type/simple-type.js +1 -6
- package/esm/document/decorators/api-field-decorator.js +1 -2
- package/esm/document/decorators/http-controller.decorator.js +1 -1
- package/esm/document/decorators/http-operation-entity.decorator.js +25 -31
- package/esm/document/decorators/http-operation.decorator.js +3 -0
- package/esm/document/factory/api-document.factory.js +17 -7
- package/esm/document/http/http-api.js +0 -1
- package/esm/document/http/http-controller.js +3 -2
- package/esm/document/http/http-media-type.js +16 -2
- package/esm/document/http/http-multipart-field.js +0 -1
- package/esm/document/http/http-operation-response.js +0 -1
- package/esm/document/http/http-operation.js +12 -1
- package/esm/document/http/http-parameter.js +2 -0
- package/esm/document/http/http-request-body.js +0 -1
- package/esm/document/http/http-status-range.js +5 -2
- package/esm/exception/opra-exception.js +1 -0
- package/esm/filter/filter-rules.js +10 -9
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/object-utils.js +2 -2
- package/esm/helpers/safe-json-stringify.js +13 -0
- package/esm/package.json +3 -0
- package/esm/schema/index.js +2 -27
- package/esm/schema/opra-schema.js +21 -0
- package/package.json +47 -53
- package/types/document/api-document.d.ts +2 -1
- package/types/document/common/api-base.d.ts +2 -2
- package/types/document/common/data-type-map.d.ts +1 -1
- package/types/document/common/document-element.d.ts +1 -0
- package/types/document/common/document-node.d.ts +8 -8
- package/types/document/common/value.d.ts +1 -1
- package/types/document/data-type/api-field.d.ts +11 -1
- package/types/document/data-type/complex-type-base.d.ts +6 -7
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +3 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/extended-types/base64.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date-string.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date-time-string.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date-time.type.d.ts +1 -1
- package/types/document/data-type/extended-types/date.type.d.ts +1 -1
- package/types/document/data-type/extended-types/email.type.d.ts +1 -1
- package/types/document/data-type/extended-types/field-path.type.d.ts +3 -3
- package/types/document/data-type/extended-types/filter.type.d.ts +3 -3
- package/types/document/data-type/extended-types/object-id.type.d.ts +1 -1
- package/types/document/data-type/extended-types/operation-result.type.d.ts +2 -2
- package/types/document/data-type/extended-types/time.type.d.ts +1 -1
- package/types/document/data-type/extended-types/url.type.d.ts +1 -1
- package/types/document/data-type/extended-types/uuid.type.d.ts +1 -1
- package/types/document/data-type/mapped-type.d.ts +3 -3
- package/types/document/data-type/mixin-type.d.ts +1 -1
- package/types/document/data-type/omit-type.d.ts +1 -7
- package/types/document/data-type/partial-type.d.ts +1 -7
- package/types/document/data-type/pick-type.d.ts +3 -3
- package/types/document/data-type/primitive-types/any.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/bigint.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/boolean.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/integer.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/null.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/number.type.d.ts +1 -1
- package/types/document/data-type/primitive-types/string.type.d.ts +1 -1
- package/types/document/data-type/required-type.d.ts +8 -8
- package/types/document/data-type/simple-type.d.ts +2 -2
- package/types/document/data-type/utils/create-mapped-class.d.ts +2 -2
- package/types/document/decorators/api-field-decorator.d.ts +1 -1
- package/types/document/decorators/http-controller.decorator.d.ts +3 -3
- package/types/document/decorators/http-operation-entity.decorator.d.ts +5 -4
- package/types/document/decorators/http-operation.decorator.d.ts +1 -1
- package/types/document/factory/api-document.factory.d.ts +2 -1
- package/types/document/factory/data-type.factory.d.ts +1 -1
- package/types/document/factory/http-api.factory.d.ts +1 -1
- package/types/document/http/http-api.d.ts +2 -2
- package/types/document/http/http-controller.d.ts +1 -1
- package/types/document/http/http-media-type.d.ts +3 -2
- package/types/document/http/http-multipart-field.d.ts +1 -2
- package/types/document/http/http-operation-response.d.ts +1 -1
- package/types/document/http/http-operation.d.ts +6 -5
- package/types/document/http/http-parameter.d.ts +2 -2
- package/types/document/http/http-request-body.d.ts +1 -1
- package/types/document/http/http-status-range.d.ts +2 -1
- package/types/exception/http-errors/bad-request.error.d.ts +1 -1
- package/types/exception/http-errors/conflict.error.d.ts +1 -1
- package/types/exception/http-errors/failed-dependency.error.d.ts +1 -1
- package/types/exception/http-errors/forbidden.error.d.ts +1 -1
- package/types/exception/http-errors/internal-server.error.d.ts +1 -1
- package/types/exception/http-errors/method-not-allowed.error.d.ts +1 -1
- package/types/exception/http-errors/not-acceptable.error.d.ts +1 -1
- package/types/exception/http-errors/not-found.error.d.ts +1 -1
- package/types/exception/http-errors/permission.error.d.ts +1 -1
- package/types/exception/http-errors/unauthorized.error.d.ts +1 -1
- package/types/exception/http-errors/unprocessable-entity.error.d.ts +1 -1
- package/types/exception/opra-exception.d.ts +1 -1
- package/types/exception/opra-http-error.d.ts +1 -1
- package/types/filter/antlr/OpraFilterParser.d.ts +1 -1
- package/types/filter/ast/expressions/comparison-expression.d.ts +1 -1
- package/types/filter/errors.d.ts +3 -4
- package/types/filter/filter-rules.d.ts +5 -5
- package/types/filter/opra-error-listener.d.ts +1 -2
- package/types/helpers/function-utils.d.ts +1 -1
- package/types/helpers/index.d.ts +1 -0
- package/types/helpers/mixin-utils.d.ts +1 -1
- package/types/helpers/object-utils.d.ts +1 -1
- package/types/helpers/safe-json-stringify.d.ts +1 -0
- package/types/helpers/type-guards.d.ts +1 -3
- package/types/i18n/i18n.d.ts +2 -2
- package/types/i18n/translate.d.ts +1 -1
- package/types/index.d.cts +9 -0
- package/types/schema/{document.interface.d.ts → api-document.interface.d.ts} +4 -4
- package/types/schema/data-type/complex-type.interface.d.ts +1 -1
- package/types/schema/data-type/data-type.interface.d.ts +1 -1
- package/types/schema/data-type/enum-type.interface.d.ts +1 -1
- package/types/schema/data-type/mapped-type.interface.d.ts +3 -3
- package/types/schema/data-type/mixin-type.interface.d.ts +1 -1
- package/types/schema/data-type-container.interface.d.ts +1 -1
- package/types/schema/http/http-controller.interface.d.ts +2 -2
- package/types/schema/http/http-media-type.interface.d.ts +1 -1
- package/types/schema/http/http-operation-response.interface.d.ts +2 -2
- package/types/schema/http/http-operation.interface.d.ts +8 -4
- package/types/schema/http/http-parameter.interface.d.ts +2 -2
- package/types/schema/index.d.ts +2 -62
- package/types/schema/opra-schema.d.ts +21 -0
- package/types/schema/type-guards.d.ts +1 -1
- package/browser.js +0 -13393
- /package/cjs/schema/{document.interface.js → api-document.interface.js} +0 -0
- /package/esm/schema/{document.interface.js → api-document.interface.js} +0 -0
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isConstructor = isConstructor;
|
|
4
|
+
exports.isStream = isStream;
|
|
5
|
+
exports.isReadable = isReadable;
|
|
6
|
+
exports.isWritable = isWritable;
|
|
7
|
+
exports.isReadableStream = isReadableStream;
|
|
8
|
+
exports.isBlob = isBlob;
|
|
9
|
+
exports.isFormData = isFormData;
|
|
10
|
+
exports.isURL = isURL;
|
|
11
|
+
exports.isIterable = isIterable;
|
|
12
|
+
exports.isAsyncIterable = isAsyncIterable;
|
|
4
13
|
function isConstructor(fn) {
|
|
5
14
|
return (typeof fn === 'function' &&
|
|
6
15
|
fn.prototype &&
|
|
@@ -8,26 +17,21 @@ function isConstructor(fn) {
|
|
|
8
17
|
fn.prototype.constructor.name !== 'Function' &&
|
|
9
18
|
fn.prototype.constructor.name !== 'embedded');
|
|
10
19
|
}
|
|
11
|
-
exports.isConstructor = isConstructor;
|
|
12
20
|
function isStream(x) {
|
|
13
21
|
return x !== null && typeof x === 'object' && typeof x.pipe === 'function';
|
|
14
22
|
}
|
|
15
|
-
exports.isStream = isStream;
|
|
16
23
|
function isReadable(x) {
|
|
17
24
|
return isStream(x) && typeof x._read === 'function' && typeof x._readableState === 'object';
|
|
18
25
|
}
|
|
19
|
-
exports.isReadable = isReadable;
|
|
20
26
|
function isWritable(x) {
|
|
21
27
|
return isStream(x) && typeof x._write === 'function';
|
|
22
28
|
}
|
|
23
|
-
exports.isWritable = isWritable;
|
|
24
29
|
function isReadableStream(x) {
|
|
25
30
|
return (isStream(x) &&
|
|
26
31
|
typeof x.getReader === 'function' &&
|
|
27
32
|
typeof x.pipeThrough === 'function' &&
|
|
28
33
|
typeof x.pipeTo === 'function');
|
|
29
34
|
}
|
|
30
|
-
exports.isReadableStream = isReadableStream;
|
|
31
35
|
function isBlob(x) {
|
|
32
36
|
return (x !== null &&
|
|
33
37
|
typeof x === 'object' &&
|
|
@@ -35,7 +39,6 @@ function isBlob(x) {
|
|
|
35
39
|
typeof x.arrayBuffer === 'function' &&
|
|
36
40
|
typeof x.stream === 'function');
|
|
37
41
|
}
|
|
38
|
-
exports.isBlob = isBlob;
|
|
39
42
|
function isFormData(x) {
|
|
40
43
|
return (x !== null &&
|
|
41
44
|
typeof x.constructor === 'function' &&
|
|
@@ -43,16 +46,12 @@ function isFormData(x) {
|
|
|
43
46
|
typeof x.append === 'function' &&
|
|
44
47
|
typeof x.getAll === 'function');
|
|
45
48
|
}
|
|
46
|
-
exports.isFormData = isFormData;
|
|
47
49
|
function isURL(x) {
|
|
48
50
|
return x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string';
|
|
49
51
|
}
|
|
50
|
-
exports.isURL = isURL;
|
|
51
52
|
function isIterable(x) {
|
|
52
53
|
return Symbol.iterator in x;
|
|
53
54
|
}
|
|
54
|
-
exports.isIterable = isIterable;
|
|
55
55
|
function isAsyncIterable(x) {
|
|
56
56
|
return Symbol.asyncIterator in x;
|
|
57
57
|
}
|
|
58
|
-
exports.isAsyncIterable = isAsyncIterable;
|
package/cjs/i18n/string-utils.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.escapeString = escapeString;
|
|
4
|
+
exports.unescapeString = unescapeString;
|
|
4
5
|
const unescapeRegEx = /\\(.)/g;
|
|
5
6
|
const escapeRegEx = /(\\)/g;
|
|
6
7
|
function escapeString(s) {
|
|
7
8
|
return s.replace(escapeRegEx, '\\\\');
|
|
8
9
|
}
|
|
9
|
-
exports.escapeString = escapeString;
|
|
10
10
|
function unescapeString(s) {
|
|
11
11
|
return s.replace(unescapeRegEx, '$1');
|
|
12
12
|
}
|
|
13
|
-
exports.unescapeString = unescapeString;
|
package/cjs/i18n/translate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translate =
|
|
3
|
+
exports.translate = translate;
|
|
4
4
|
const string_utils_js_1 = require("./string-utils.js");
|
|
5
5
|
const bracketRegEx = /(\))/g;
|
|
6
6
|
function translate(key, arg0, arg1) {
|
|
@@ -12,4 +12,3 @@ function translate(key, arg0, arg1) {
|
|
|
12
12
|
(fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') +
|
|
13
13
|
')');
|
|
14
14
|
}
|
|
15
|
-
exports.translate = translate;
|
package/cjs/schema/index.js
CHANGED
|
@@ -2,30 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpraSchema = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const enumType_ = tslib_1.__importStar(require("./data-type/enum-type.interface.js"));
|
|
8
|
-
const mappedType_ = tslib_1.__importStar(require("./data-type/mapped-type.interface.js"));
|
|
9
|
-
const mixinType_ = tslib_1.__importStar(require("./data-type/mixin-type.interface.js"));
|
|
10
|
-
const simpleType_ = tslib_1.__importStar(require("./data-type/simple-type.interface.js"));
|
|
11
|
-
const controller_ = tslib_1.__importStar(require("./http/http-controller.interface.js"));
|
|
12
|
-
const operation_ = tslib_1.__importStar(require("./http/http-operation.interface.js"));
|
|
13
|
-
const typeGuards_ = tslib_1.__importStar(require("./type-guards.js"));
|
|
14
|
-
var OpraSchema;
|
|
15
|
-
(function (OpraSchema) {
|
|
16
|
-
OpraSchema.SpecVersion = constants_.SpecVersion;
|
|
17
|
-
OpraSchema.ComplexType = complexType_.ComplexType;
|
|
18
|
-
OpraSchema.EnumType = enumType_.EnumType;
|
|
19
|
-
OpraSchema.MappedType = mappedType_.MappedType;
|
|
20
|
-
OpraSchema.MixinType = mixinType_.MixinType;
|
|
21
|
-
OpraSchema.SimpleType = simpleType_.SimpleType;
|
|
22
|
-
OpraSchema.HttpController = controller_.HttpController;
|
|
23
|
-
OpraSchema.HttpOperation = operation_.HttpOperation;
|
|
24
|
-
OpraSchema.isComplexType = typeGuards_.isComplexType;
|
|
25
|
-
OpraSchema.isDataType = typeGuards_.isDataType;
|
|
26
|
-
OpraSchema.isSimpleType = typeGuards_.isSimpleType;
|
|
27
|
-
OpraSchema.isMixinType = typeGuards_.isMixinType;
|
|
28
|
-
OpraSchema.isMappedType = typeGuards_.isMappedType;
|
|
29
|
-
OpraSchema.isEnumType = typeGuards_.isEnumType;
|
|
30
|
-
OpraSchema.isHttpController = typeGuards_.isHttpController;
|
|
31
|
-
})(OpraSchema || (exports.OpraSchema = OpraSchema = {}));
|
|
5
|
+
const OpraSchema = tslib_1.__importStar(require("./opra-schema.js"));
|
|
6
|
+
exports.OpraSchema = OpraSchema;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./api-document.interface.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./data-type/complex-type.interface.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./data-type/data-type.interface.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./data-type/enum-type.interface.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./data-type/field.interface.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./data-type/mapped-type.interface.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./data-type/mixin-type.interface.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./data-type/simple-type.interface.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./data-type-container.interface.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./http/http-controller.interface.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./http/http-media-type.interface.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./http/http-multipart-field.interface.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./http/http-operation.interface.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./http/http-operation-response.interface.js"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./http/http-parameter.interface.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./http/http-request-body.interface.js"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./http/http-status-range.interface.js"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./value.interface.js"), exports);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isDataType = isDataType;
|
|
4
|
+
exports.isComplexType = isComplexType;
|
|
5
|
+
exports.isSimpleType = isSimpleType;
|
|
6
|
+
exports.isMixinType = isMixinType;
|
|
7
|
+
exports.isMappedType = isMappedType;
|
|
8
|
+
exports.isEnumType = isEnumType;
|
|
9
|
+
exports.isHttpController = isHttpController;
|
|
4
10
|
const complex_type_interface_js_1 = require("./data-type/complex-type.interface.js");
|
|
5
11
|
const enum_type_interface_js_1 = require("./data-type/enum-type.interface.js");
|
|
6
12
|
const mapped_type_interface_js_1 = require("./data-type/mapped-type.interface.js");
|
|
@@ -16,28 +22,21 @@ function isDataType(obj) {
|
|
|
16
22
|
obj.kind === simple_type_interface_js_1.SimpleType.Kind ||
|
|
17
23
|
obj.kind === mixin_type_interface_js_1.MixinType.Kind));
|
|
18
24
|
}
|
|
19
|
-
exports.isDataType = isDataType;
|
|
20
25
|
function isComplexType(obj) {
|
|
21
26
|
return obj && typeof obj === 'object' && obj.kind === complex_type_interface_js_1.ComplexType.Kind;
|
|
22
27
|
}
|
|
23
|
-
exports.isComplexType = isComplexType;
|
|
24
28
|
function isSimpleType(obj) {
|
|
25
29
|
return obj && typeof obj === 'object' && obj.kind === simple_type_interface_js_1.SimpleType.Kind;
|
|
26
30
|
}
|
|
27
|
-
exports.isSimpleType = isSimpleType;
|
|
28
31
|
function isMixinType(obj) {
|
|
29
32
|
return obj && typeof obj === 'object' && obj.kind === mixin_type_interface_js_1.MixinType.Kind;
|
|
30
33
|
}
|
|
31
|
-
exports.isMixinType = isMixinType;
|
|
32
34
|
function isMappedType(obj) {
|
|
33
35
|
return obj && typeof obj === 'object' && obj.kind === mapped_type_interface_js_1.MappedType.Kind;
|
|
34
36
|
}
|
|
35
|
-
exports.isMappedType = isMappedType;
|
|
36
37
|
function isEnumType(obj) {
|
|
37
38
|
return obj && typeof obj === 'object' && obj.kind === enum_type_interface_js_1.EnumType.Kind;
|
|
38
39
|
}
|
|
39
|
-
exports.isEnumType = isEnumType;
|
|
40
40
|
function isHttpController(obj) {
|
|
41
41
|
return obj && typeof obj === 'object' && obj.kind === http_controller_interface_js_1.HttpController.Kind;
|
|
42
42
|
}
|
|
43
|
-
exports.isHttpController = isHttpController;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import { md5 } from 'super-fast-md5';
|
|
2
3
|
import { cloneObject, omitUndefined, ResponsiveMap } from '../helpers/index.js';
|
|
3
4
|
import { OpraSchema } from '../schema/index.js';
|
|
4
5
|
import { DataTypeMap } from './common/data-type-map.js';
|
|
@@ -13,6 +14,8 @@ export class ApiDocument extends DocumentElement {
|
|
|
13
14
|
constructor() {
|
|
14
15
|
super(null);
|
|
15
16
|
this[_a] = new WeakMap();
|
|
17
|
+
this.id = '';
|
|
18
|
+
this.info = {};
|
|
16
19
|
this.references = new ResponsiveMap();
|
|
17
20
|
this.types = new DataTypeMap();
|
|
18
21
|
this.node[kDataTypeMap] = this.types;
|
|
@@ -77,6 +80,14 @@ export class ApiDocument extends DocumentElement {
|
|
|
77
80
|
out.api = this.api.toJSON();
|
|
78
81
|
return out;
|
|
79
82
|
}
|
|
83
|
+
invalidate() {
|
|
84
|
+
/** Generate id */
|
|
85
|
+
const x = this.export();
|
|
86
|
+
delete x.id;
|
|
87
|
+
this.id = md5(JSON.stringify(x));
|
|
88
|
+
/** Clear [kTypeNSMap] */
|
|
89
|
+
this[kTypeNSMap] = new WeakMap();
|
|
90
|
+
}
|
|
80
91
|
_findDataType(nameOrCtor, visitedRefs) {
|
|
81
92
|
let result = this.types.get(nameOrCtor);
|
|
82
93
|
if (result || !this.references.size)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { asMutable } from 'ts-gems';
|
|
2
|
+
import { uid } from 'uid';
|
|
2
3
|
import { DocumentNode } from './document-node.js';
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -8,6 +9,7 @@ export const DocumentElement = function (owner) {
|
|
|
8
9
|
if (!this)
|
|
9
10
|
throw new TypeError('"this" should be passed to call class constructor');
|
|
10
11
|
const _this = asMutable(this);
|
|
12
|
+
_this.id = uid(16);
|
|
11
13
|
Object.defineProperty(_this, 'node', {
|
|
12
14
|
value: new DocumentNode(this, owner?.node),
|
|
13
15
|
enumerable: false,
|
|
@@ -37,6 +37,7 @@ export const ApiField = function (...args) {
|
|
|
37
37
|
_this.readonly = initArgs.readonly;
|
|
38
38
|
_this.writeonly = initArgs.writeonly;
|
|
39
39
|
_this.examples = initArgs.examples;
|
|
40
|
+
_this.hidden = initArgs.hidden;
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
42
43
|
*
|
|
@@ -48,15 +49,15 @@ class ApiFieldClass extends DocumentElement {
|
|
|
48
49
|
return omitUndefined({
|
|
49
50
|
type: typeName ? typeName : this.type?.toJSON(),
|
|
50
51
|
description: this.description,
|
|
51
|
-
isArray: this.isArray,
|
|
52
|
+
isArray: this.isArray || undefined,
|
|
52
53
|
default: this.default,
|
|
53
54
|
fixed: this.fixed,
|
|
54
|
-
required: this.required,
|
|
55
|
-
exclusive: this.exclusive,
|
|
56
|
-
translatable: this.translatable,
|
|
57
|
-
deprecated: this.deprecated,
|
|
58
|
-
readonly: this.readonly,
|
|
59
|
-
writeonly: this.writeonly,
|
|
55
|
+
required: this.required || undefined,
|
|
56
|
+
exclusive: this.exclusive || undefined,
|
|
57
|
+
translatable: this.translatable || undefined,
|
|
58
|
+
deprecated: this.deprecated || undefined,
|
|
59
|
+
readonly: this.readonly || undefined,
|
|
60
|
+
writeonly: this.writeonly || undefined,
|
|
60
61
|
examples: this.examples,
|
|
61
62
|
});
|
|
62
63
|
}
|
|
@@ -129,7 +129,7 @@ class ComplexTypeBaseClass extends DataType {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
return vg.isObject(schema, {
|
|
132
|
-
ctor: this.ctor,
|
|
132
|
+
ctor: this.name === 'object' ? Object : this.ctor,
|
|
133
133
|
additionalFields,
|
|
134
134
|
name: this.name,
|
|
135
135
|
coerce: true,
|
|
@@ -144,7 +144,9 @@ class ComplexTypeBaseClass extends DataType {
|
|
|
144
144
|
// Process fields
|
|
145
145
|
let fieldName;
|
|
146
146
|
for (const field of this.fields.values()) {
|
|
147
|
-
if ((context.ignoreReadonlyFields && field.readonly) ||
|
|
147
|
+
if ((context.ignoreReadonlyFields && field.readonly) ||
|
|
148
|
+
(context.ignoreWriteonlyFields && field.writeonly) ||
|
|
149
|
+
(context.ignoreHiddenFields && field.hidden)) {
|
|
148
150
|
schema[field.name] = vg.isUndefined({ coerce: true });
|
|
149
151
|
continue;
|
|
150
152
|
}
|
|
@@ -166,7 +168,7 @@ class ComplexTypeBaseClass extends DataType {
|
|
|
166
168
|
const fn = this._generateFieldCodec(codec, field, {
|
|
167
169
|
...context,
|
|
168
170
|
partial: context.partial === 'deep' ? context.partial : undefined,
|
|
169
|
-
projection: projection
|
|
171
|
+
projection: typeof projection === 'object' ? projection[fieldName]?.projection || '*' : projection,
|
|
170
172
|
currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
|
|
171
173
|
});
|
|
172
174
|
schema[fieldName] = context.partial || !field.required ? vg.optional(fn) : vg.required(fn);
|
|
@@ -33,7 +33,7 @@ __decorate([
|
|
|
33
33
|
__metadata("design:type", String)
|
|
34
34
|
], DateStringType.prototype, "maxValue", void 0);
|
|
35
35
|
DateStringType = __decorate([
|
|
36
|
-
SimpleType({
|
|
36
|
+
(SimpleType({
|
|
37
37
|
description: 'Date string value',
|
|
38
38
|
nameMappings: {
|
|
39
39
|
js: 'string',
|
|
@@ -42,7 +42,7 @@ DateStringType = __decorate([
|
|
|
42
42
|
})
|
|
43
43
|
.Example('2021-04-18', 'Full date value')
|
|
44
44
|
.Example('2021-04', 'Date value without day')
|
|
45
|
-
.Example('2021', 'Year only value'),
|
|
45
|
+
.Example('2021', 'Year only value')),
|
|
46
46
|
__metadata("design:paramtypes", [Object])
|
|
47
47
|
], DateStringType);
|
|
48
48
|
export { DateStringType };
|
|
@@ -33,7 +33,7 @@ __decorate([
|
|
|
33
33
|
__metadata("design:type", String)
|
|
34
34
|
], DateTimeStringType.prototype, "maxValue", void 0);
|
|
35
35
|
DateTimeStringType = __decorate([
|
|
36
|
-
SimpleType({
|
|
36
|
+
(SimpleType({
|
|
37
37
|
description: 'DateTime string value',
|
|
38
38
|
nameMappings: {
|
|
39
39
|
js: 'string',
|
|
@@ -45,7 +45,7 @@ DateTimeStringType = __decorate([
|
|
|
45
45
|
.Example('2021-04-18 22:30', 'Date-time value')
|
|
46
46
|
.Example('2021-04-18', 'Date value')
|
|
47
47
|
.Example('2021-04', 'Date value without day')
|
|
48
|
-
.Example('2021', 'Year only value'),
|
|
48
|
+
.Example('2021', 'Year only value')),
|
|
49
49
|
__metadata("design:paramtypes", [Object])
|
|
50
50
|
], DateTimeStringType);
|
|
51
51
|
export { DateTimeStringType };
|
|
@@ -47,7 +47,7 @@ __decorate([
|
|
|
47
47
|
__metadata("design:type", String)
|
|
48
48
|
], DateTimeType.prototype, "maxValue", void 0);
|
|
49
49
|
DateTimeType = __decorate([
|
|
50
|
-
SimpleType({
|
|
50
|
+
(SimpleType({
|
|
51
51
|
description: 'A full datetime value',
|
|
52
52
|
nameMappings: {
|
|
53
53
|
js: 'string',
|
|
@@ -56,7 +56,7 @@ DateTimeType = __decorate([
|
|
|
56
56
|
})
|
|
57
57
|
.Example('2021-04-18T22:30:15')
|
|
58
58
|
.Example('2021-04-18 22:30:15')
|
|
59
|
-
.Example('2021-04-18 22:30'),
|
|
59
|
+
.Example('2021-04-18 22:30')),
|
|
60
60
|
__metadata("design:paramtypes", [Object])
|
|
61
61
|
], DateTimeType);
|
|
62
62
|
export { DateTimeType };
|
|
@@ -47,13 +47,13 @@ __decorate([
|
|
|
47
47
|
__metadata("design:type", String)
|
|
48
48
|
], DateType.prototype, "maxValue", void 0);
|
|
49
49
|
DateType = __decorate([
|
|
50
|
-
SimpleType({
|
|
50
|
+
(SimpleType({
|
|
51
51
|
description: 'A date without time',
|
|
52
52
|
nameMappings: {
|
|
53
53
|
js: 'Date',
|
|
54
54
|
json: 'string',
|
|
55
55
|
},
|
|
56
|
-
}).Example('2021-04-18', 'Full date value'),
|
|
56
|
+
}).Example('2021-04-18', 'Full date value')),
|
|
57
57
|
__metadata("design:paramtypes", [Object])
|
|
58
58
|
], DateType);
|
|
59
59
|
export { DateType };
|
|
@@ -79,13 +79,13 @@ __decorate([
|
|
|
79
79
|
__metadata("design:type", String)
|
|
80
80
|
], EmailType.prototype, "blacklistedChars", void 0);
|
|
81
81
|
EmailType = __decorate([
|
|
82
|
-
SimpleType({
|
|
82
|
+
(SimpleType({
|
|
83
83
|
description: 'An email value',
|
|
84
84
|
nameMappings: {
|
|
85
85
|
js: 'string',
|
|
86
86
|
json: 'string',
|
|
87
87
|
},
|
|
88
|
-
}).Example('some.body@example.com'),
|
|
88
|
+
}).Example('some.body@example.com')),
|
|
89
89
|
__metadata("design:paramtypes", [Object])
|
|
90
90
|
], EmailType);
|
|
91
91
|
export { EmailType };
|
|
@@ -62,7 +62,7 @@ const decodeFilter = (dataType, rules) => validator('decodeFilter', (input, cont
|
|
|
62
62
|
return filter;
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
context.fail(_this, `Not a valid filter expression. ${e.message}`, input
|
|
65
|
+
context.fail(_this, `Not a valid filter expression. ${e.message}`, input);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -37,7 +37,7 @@ __decorate([
|
|
|
37
37
|
__metadata("design:type", String)
|
|
38
38
|
], TimeType.prototype, "maxValue", void 0);
|
|
39
39
|
TimeType = __decorate([
|
|
40
|
-
SimpleType({
|
|
40
|
+
(SimpleType({
|
|
41
41
|
description: 'Time string in 24h format',
|
|
42
42
|
nameMappings: {
|
|
43
43
|
js: 'string',
|
|
@@ -45,7 +45,7 @@ TimeType = __decorate([
|
|
|
45
45
|
},
|
|
46
46
|
})
|
|
47
47
|
.Example('18:23:00', 'Full time value')
|
|
48
|
-
.Example('18:23:00', 'Time value without seconds'),
|
|
48
|
+
.Example('18:23:00', 'Time value without seconds')),
|
|
49
49
|
__metadata("design:paramtypes", [Object])
|
|
50
50
|
], TimeType);
|
|
51
51
|
export { TimeType };
|
|
@@ -15,13 +15,13 @@ let UrlType = class UrlType {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
UrlType = __decorate([
|
|
18
|
-
SimpleType({
|
|
18
|
+
(SimpleType({
|
|
19
19
|
description: 'A Uniform Resource Identifier Reference (RFC 3986 icon) value',
|
|
20
20
|
nameMappings: {
|
|
21
21
|
js: 'string',
|
|
22
22
|
json: 'string',
|
|
23
23
|
},
|
|
24
|
-
}).Example('http://tempuri.org'),
|
|
24
|
+
}).Example('http://tempuri.org')),
|
|
25
25
|
__metadata("design:paramtypes", [Object])
|
|
26
26
|
], UrlType);
|
|
27
27
|
export { UrlType };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { DATATYPE_METADATA } from '../../constants.js';
|
|
3
2
|
import { ComplexType } from '../complex-type.js';
|
|
4
3
|
let ObjectType = class ObjectType {
|
|
5
4
|
constructor(properties) {
|
|
@@ -16,5 +15,3 @@ ObjectType = __decorate([
|
|
|
16
15
|
__metadata("design:paramtypes", [Object])
|
|
17
16
|
], ObjectType);
|
|
18
17
|
export { ObjectType };
|
|
19
|
-
const metadata = Reflect.getMetadata(DATATYPE_METADATA, ObjectType);
|
|
20
|
-
metadata.ctor = Object;
|
|
@@ -83,12 +83,7 @@ class SimpleTypeClass extends DataType {
|
|
|
83
83
|
properties = this.properties.toJSON(this.properties, this.owner);
|
|
84
84
|
}
|
|
85
85
|
else
|
|
86
|
-
properties = this.properties
|
|
87
|
-
properties = Object.keys(this.attributes).reduce((o, k) => {
|
|
88
|
-
if (properties[k] !== undefined)
|
|
89
|
-
o[k] = properties[k];
|
|
90
|
-
return o;
|
|
91
|
-
}, {});
|
|
86
|
+
properties = this.properties ? cloneObject(this.properties) : {};
|
|
92
87
|
const baseName = this.base ? this.node.getDataTypeNameWithNs(this.base) : undefined;
|
|
93
88
|
const out = omitUndefined({
|
|
94
89
|
...DataType.prototype.toJSON.apply(this),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
2
1
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
2
|
import { DATATYPE_METADATA } from '../constants.js';
|
|
4
3
|
export function ApiFieldDecorator(options) {
|
|
@@ -17,6 +16,6 @@ export function ApiFieldDecorator(options) {
|
|
|
17
16
|
}
|
|
18
17
|
else
|
|
19
18
|
elemMeta.type = elemMeta.type || designType;
|
|
20
|
-
Reflect.defineMetadata(DATATYPE_METADATA,
|
|
19
|
+
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target.constructor);
|
|
21
20
|
};
|
|
22
21
|
}
|
|
@@ -2,7 +2,7 @@ import omit from 'lodash.omit';
|
|
|
2
2
|
import merge from 'putil-merge';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import { HTTP_CONTROLLER_METADATA } from '../constants.js';
|
|
5
|
-
const CLASS_NAME_PATTERN = /^(.*)(
|
|
5
|
+
const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
|
|
6
6
|
export function HttpControllerDecoratorFactory(options) {
|
|
7
7
|
const decoratorChain = [];
|
|
8
8
|
/**
|