@opra/common 1.4.3 → 1.5.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/browser/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/api-document.js +16 -9
- package/cjs/document/common/api-base.js +4 -2
- package/cjs/document/common/data-type-map.js +14 -3
- package/cjs/document/common/document-init-context.js +5 -0
- package/cjs/document/common/document-node.js +25 -29
- package/cjs/document/common/value.js +9 -3
- package/cjs/document/constants.js +1 -2
- package/cjs/document/data-type/api-field.js +19 -4
- package/cjs/document/data-type/complex-type-base.js +24 -7
- package/cjs/document/data-type/complex-type.js +17 -6
- package/cjs/document/data-type/data-type.js +16 -1
- package/cjs/document/data-type/enum-type.js +12 -3
- package/cjs/document/data-type/extended-types/base64.type.js +1 -0
- package/cjs/document/data-type/extended-types/date-string.type.js +1 -0
- package/cjs/document/data-type/extended-types/date-time-string.type.js +1 -0
- package/cjs/document/data-type/extended-types/date-time.type.js +6 -1
- package/cjs/document/data-type/extended-types/date.type.js +6 -1
- package/cjs/document/data-type/extended-types/email.type.js +1 -0
- package/cjs/document/data-type/extended-types/field-path.type.js +9 -3
- package/cjs/document/data-type/extended-types/filter.type.js +14 -5
- package/cjs/document/data-type/extended-types/object-id.type.js +1 -0
- package/cjs/document/data-type/extended-types/operation-result.type.js +1 -0
- package/cjs/document/data-type/extended-types/time.type.js +1 -0
- package/cjs/document/data-type/extended-types/url.type.js +1 -0
- package/cjs/document/data-type/extended-types/uuid.type.js +1 -0
- package/cjs/document/data-type/mapped-type.js +21 -9
- package/cjs/document/data-type/mixin-type.js +10 -5
- package/cjs/document/data-type/primitive-types/any.type.js +1 -0
- package/cjs/document/data-type/primitive-types/bigint.type.js +4 -1
- package/cjs/document/data-type/primitive-types/boolean.type.js +1 -0
- package/cjs/document/data-type/primitive-types/integer.type.js +4 -1
- package/cjs/document/data-type/primitive-types/null.type.js +1 -0
- package/cjs/document/data-type/primitive-types/number.type.js +4 -1
- package/cjs/document/data-type/primitive-types/string.type.js +4 -1
- package/cjs/document/data-type/simple-type.js +17 -5
- package/cjs/document/data-type/utils/create-mapped-class.js +3 -1
- package/cjs/document/decorators/api-field-decorator.js +2 -1
- package/cjs/document/decorators/complex-type.decorator.js +1 -1
- package/cjs/document/decorators/http-controller.decorator.js +7 -1
- package/cjs/document/decorators/http-operation-entity.decorator.js +20 -10
- package/cjs/document/decorators/http-operation.decorator.js +23 -10
- package/cjs/document/decorators/rpc-operation.decorator.js +1 -2
- package/cjs/document/decorators/simple-type.decorator.js +3 -2
- package/cjs/document/factory/api-document.factory.js +12 -3
- package/cjs/document/factory/data-type.factory.js +19 -7
- package/cjs/document/factory/http-api.factory.js +13 -4
- package/cjs/document/http/http-api.js +2 -2
- package/cjs/document/http/http-controller.js +7 -6
- package/cjs/document/http/http-media-type.js +18 -8
- package/cjs/document/http/http-multipart-field.js +2 -2
- package/cjs/document/http/http-operation-response.js +11 -6
- package/cjs/document/http/http-operation.js +8 -6
- package/cjs/document/http/http-parameter.js +2 -2
- package/cjs/document/http/http-request-body.js +4 -2
- package/cjs/document/http/http-status-range.js +3 -1
- package/cjs/document/rpc/rpc-operation-response.js +11 -3
- package/cjs/document/rpc/rpc-operation.js +11 -3
- package/cjs/document/utils/parse-regexp.util.js +2 -2
- package/cjs/exception/opra-exception.js +3 -1
- package/cjs/filter/antlr/OpraFilterLexer.js +190 -123
- package/cjs/filter/antlr/OpraFilterParser.js +53 -35
- package/cjs/filter/ast/expressions/arithmetic-expression.js +3 -1
- package/cjs/filter/ast/terms/number-literal.js +3 -1
- package/cjs/filter/filter-rules.js +18 -8
- package/cjs/filter/filter-tree-visitor.js +2 -1
- package/cjs/filter/opra-error-listener.js +7 -1
- package/cjs/filter/parse.js +3 -1
- package/cjs/filter/utils.js +3 -1
- package/cjs/helpers/get-stack-filename.js +6 -2
- package/cjs/helpers/mixin-utils.js +7 -2
- package/cjs/helpers/object-utils.js +3 -1
- package/cjs/helpers/parse-fields-projection.js +4 -2
- package/cjs/helpers/type-guards.js +7 -2
- package/cjs/i18n/i18n.js +13 -3
- package/cjs/i18n/translate.js +3 -1
- package/cjs/polifils/array-find-last.js +0 -2
- package/esm/document/api-document.js +17 -10
- package/esm/document/common/api-base.js +4 -2
- package/esm/document/common/data-type-map.js +14 -3
- package/esm/document/common/document-init-context.js +5 -0
- package/esm/document/common/document-node.js +25 -29
- package/esm/document/common/value.js +9 -3
- package/esm/document/constants.js +0 -1
- package/esm/document/data-type/api-field.js +19 -4
- package/esm/document/data-type/complex-type-base.js +25 -8
- package/esm/document/data-type/complex-type.js +17 -6
- package/esm/document/data-type/data-type.js +17 -2
- package/esm/document/data-type/enum-type.js +12 -3
- package/esm/document/data-type/extended-types/base64.type.js +1 -0
- package/esm/document/data-type/extended-types/date-string.type.js +1 -0
- package/esm/document/data-type/extended-types/date-time-string.type.js +1 -0
- package/esm/document/data-type/extended-types/date-time.type.js +6 -1
- package/esm/document/data-type/extended-types/date.type.js +6 -1
- package/esm/document/data-type/extended-types/email.type.js +1 -0
- package/esm/document/data-type/extended-types/field-path.type.js +9 -3
- package/esm/document/data-type/extended-types/filter.type.js +14 -5
- package/esm/document/data-type/extended-types/object-id.type.js +1 -0
- package/esm/document/data-type/extended-types/operation-result.type.js +1 -0
- package/esm/document/data-type/extended-types/time.type.js +1 -0
- package/esm/document/data-type/extended-types/url.type.js +1 -0
- package/esm/document/data-type/extended-types/uuid.type.js +1 -0
- package/esm/document/data-type/mapped-type.js +21 -9
- package/esm/document/data-type/mixin-type.js +11 -6
- package/esm/document/data-type/primitive-types/any.type.js +1 -0
- package/esm/document/data-type/primitive-types/bigint.type.js +4 -1
- package/esm/document/data-type/primitive-types/boolean.type.js +1 -0
- package/esm/document/data-type/primitive-types/integer.type.js +4 -1
- package/esm/document/data-type/primitive-types/null.type.js +1 -0
- package/esm/document/data-type/primitive-types/number.type.js +4 -1
- package/esm/document/data-type/primitive-types/string.type.js +4 -1
- package/esm/document/data-type/simple-type.js +18 -6
- package/esm/document/data-type/utils/create-mapped-class.js +4 -2
- package/esm/document/decorators/api-field-decorator.js +2 -1
- package/esm/document/decorators/complex-type.decorator.js +2 -2
- package/esm/document/decorators/http-controller.decorator.js +7 -1
- package/esm/document/decorators/http-operation-entity.decorator.js +22 -12
- package/esm/document/decorators/http-operation.decorator.js +23 -10
- package/esm/document/decorators/rpc-operation.decorator.js +1 -2
- package/esm/document/decorators/simple-type.decorator.js +4 -3
- package/esm/document/factory/api-document.factory.js +12 -3
- package/esm/document/factory/data-type.factory.js +21 -9
- package/esm/document/factory/http-api.factory.js +13 -4
- package/esm/document/http/http-api.js +2 -2
- package/esm/document/http/http-controller.js +8 -7
- package/esm/document/http/http-media-type.js +18 -8
- package/esm/document/http/http-multipart-field.js +2 -2
- package/esm/document/http/http-operation-response.js +11 -6
- package/esm/document/http/http-operation.js +9 -7
- package/esm/document/http/http-parameter.js +3 -3
- package/esm/document/http/http-request-body.js +4 -2
- package/esm/document/http/http-status-range.js +3 -1
- package/esm/document/rpc/rpc-controller.js +1 -1
- package/esm/document/rpc/rpc-header.js +1 -1
- package/esm/document/rpc/rpc-operation-response.js +11 -3
- package/esm/document/rpc/rpc-operation.js +12 -4
- package/esm/document/utils/parse-regexp.util.js +2 -2
- package/esm/exception/opra-exception.js +3 -1
- package/esm/filter/antlr/OpraFilterLexer.js +190 -123
- package/esm/filter/antlr/OpraFilterParser.js +53 -35
- package/esm/filter/ast/expressions/arithmetic-expression.js +3 -1
- package/esm/filter/ast/terms/number-literal.js +3 -1
- package/esm/filter/filter-rules.js +18 -8
- package/esm/filter/filter-tree-visitor.js +2 -1
- package/esm/filter/opra-error-listener.js +8 -2
- package/esm/filter/parse.js +3 -1
- package/esm/filter/utils.js +3 -1
- package/esm/helpers/get-stack-filename.js +6 -2
- package/esm/helpers/mixin-utils.js +7 -2
- package/esm/helpers/object-utils.js +3 -1
- package/esm/helpers/parse-fields-projection.js +4 -2
- package/esm/helpers/type-guards.js +7 -2
- package/esm/i18n/i18n.js +13 -3
- package/esm/i18n/translate.js +3 -1
- package/esm/polifils/array-find-last.js +0 -2
- package/package.json +1 -1
- package/types/document/api-document.d.ts +8 -2
- package/types/document/common/api-base.d.ts +1 -1
- package/types/document/common/document-init-context.d.ts +2 -0
- package/types/document/common/document-node.d.ts +8 -14
- package/types/document/common/value.d.ts +2 -1
- package/types/document/constants.d.ts +0 -1
- package/types/document/data-type/api-field.d.ts +6 -11
- package/types/document/data-type/complex-type.d.ts +2 -1
- package/types/document/data-type/data-type.d.ts +7 -2
- package/types/document/data-type/enum-type.d.ts +2 -1
- package/types/document/data-type/extended-types/field-path.type.d.ts +2 -1
- package/types/document/data-type/extended-types/filter.type.d.ts +2 -1
- package/types/document/data-type/mapped-type.d.ts +2 -1
- package/types/document/data-type/mixin-type.d.ts +2 -1
- package/types/document/data-type/simple-type.d.ts +2 -1
- package/types/document/factory/api-document.factory.d.ts +2 -1
- package/types/document/http/http-api.d.ts +1 -1
- package/types/document/http/http-controller.d.ts +2 -1
- package/types/document/http/http-media-type.d.ts +2 -1
- package/types/document/http/http-multipart-field.d.ts +2 -1
- package/types/document/http/http-operation-response.d.ts +2 -1
- package/types/document/http/http-operation.d.ts +2 -1
- package/types/document/http/http-parameter.d.ts +2 -1
- package/types/document/http/http-request-body.d.ts +2 -1
- package/types/filter/filter-rules.d.ts +3 -3
|
@@ -6,7 +6,7 @@ import { OpraSchema } from '../../schema/index.js';
|
|
|
6
6
|
import { DataTypeMap } from '../common/data-type-map.js';
|
|
7
7
|
import { DocumentElement } from '../common/document-element.js';
|
|
8
8
|
import { CLASS_NAME_PATTERN, DECORATOR, kDataTypeMap } from '../constants.js';
|
|
9
|
-
import { HttpOperationDecoratorFactory } from '../decorators/http-operation.decorator.js';
|
|
9
|
+
import { HttpOperationDecoratorFactory, } from '../decorators/http-operation.decorator.js';
|
|
10
10
|
/**
|
|
11
11
|
* HttpOperation
|
|
12
12
|
*/
|
|
@@ -32,7 +32,9 @@ export const HttpOperation = function (...args) {
|
|
|
32
32
|
_this.method = initArgs.method || 'GET';
|
|
33
33
|
_this.description = initArgs.description;
|
|
34
34
|
_this.composition = initArgs.composition;
|
|
35
|
-
_this.compositionOptions = initArgs.compositionOptions
|
|
35
|
+
_this.compositionOptions = initArgs.compositionOptions
|
|
36
|
+
? cloneObject(initArgs.compositionOptions)
|
|
37
|
+
: undefined;
|
|
36
38
|
};
|
|
37
39
|
/**
|
|
38
40
|
* @class HttpOperation
|
|
@@ -65,7 +67,7 @@ class HttpOperationClass extends DocumentElement {
|
|
|
65
67
|
}
|
|
66
68
|
return this.path || '/';
|
|
67
69
|
}
|
|
68
|
-
toJSON() {
|
|
70
|
+
toJSON(options) {
|
|
69
71
|
const out = omitUndefined({
|
|
70
72
|
kind: OpraSchema.HttpOperation.Kind,
|
|
71
73
|
description: this.description,
|
|
@@ -73,22 +75,22 @@ class HttpOperationClass extends DocumentElement {
|
|
|
73
75
|
path: this.path,
|
|
74
76
|
mergePath: this.mergePath,
|
|
75
77
|
composition: this.composition,
|
|
76
|
-
requestBody: this.requestBody?.toJSON(),
|
|
78
|
+
requestBody: this.requestBody?.toJSON(options),
|
|
77
79
|
});
|
|
78
80
|
if (this.types.size) {
|
|
79
81
|
out.types = {};
|
|
80
82
|
for (const v of this.types.values()) {
|
|
81
|
-
out.types[v.name] = v.toJSON();
|
|
83
|
+
out.types[v.name] = v.toJSON(options);
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
if (this.parameters.length) {
|
|
85
87
|
out.parameters = [];
|
|
86
88
|
for (const prm of this.parameters) {
|
|
87
|
-
out.parameters.push(prm.toJSON());
|
|
89
|
+
out.parameters.push(prm.toJSON(options));
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
if (this.responses.length)
|
|
91
|
-
out.responses = this.responses.map(r => r.toJSON());
|
|
93
|
+
out.responses = this.responses.map(r => r.toJSON(options));
|
|
92
94
|
return out;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { omitUndefined } from '@jsopen/objects';
|
|
2
|
-
import { asMutable } from 'ts-gems';
|
|
2
|
+
import { asMutable, } from 'ts-gems';
|
|
3
3
|
import { Value } from '../common/value.js';
|
|
4
4
|
import { parseRegExp } from '../utils/parse-regexp.util.js';
|
|
5
5
|
export const HttpParameter = function (owner, initArgs) {
|
|
@@ -30,9 +30,9 @@ export const HttpParameter = function (owner, initArgs) {
|
|
|
30
30
|
* @class HttpParameter
|
|
31
31
|
*/
|
|
32
32
|
class HttpParameterClass extends Value {
|
|
33
|
-
toJSON() {
|
|
33
|
+
toJSON(options) {
|
|
34
34
|
return omitUndefined({
|
|
35
|
-
...super.toJSON(),
|
|
35
|
+
...super.toJSON(options),
|
|
36
36
|
name: this.name,
|
|
37
37
|
location: this.location,
|
|
38
38
|
arraySeparator: this.arraySeparator,
|
|
@@ -8,12 +8,14 @@ export class HttpRequestBody extends DocumentElement {
|
|
|
8
8
|
super(owner);
|
|
9
9
|
this.content = [];
|
|
10
10
|
}
|
|
11
|
-
toJSON() {
|
|
11
|
+
toJSON(options) {
|
|
12
12
|
return omitUndefined({
|
|
13
13
|
description: this.description,
|
|
14
14
|
required: this.required,
|
|
15
15
|
maxContentSize: this.maxContentSize,
|
|
16
|
-
content: this.content.length
|
|
16
|
+
content: this.content.length
|
|
17
|
+
? this.content.map(x => x.toJSON(options))
|
|
18
|
+
: [],
|
|
17
19
|
partial: this.partial,
|
|
18
20
|
allowPatchOperators: this.allowPatchOperators,
|
|
19
21
|
});
|
|
@@ -34,6 +34,8 @@ export class HttpStatusRange {
|
|
|
34
34
|
return String(this.start) + '-' + String(this.end);
|
|
35
35
|
}
|
|
36
36
|
toJSON() {
|
|
37
|
-
return !this.end || this.start === this.end
|
|
37
|
+
return !this.end || this.start === this.end
|
|
38
|
+
? this.start
|
|
39
|
+
: { start: this.start, end: this.end };
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -6,7 +6,7 @@ import { DataTypeMap } from '../common/data-type-map.js';
|
|
|
6
6
|
import { DocumentElement } from '../common/document-element.js';
|
|
7
7
|
import { CLASS_NAME_PATTERN, DECORATOR, kDataTypeMap } from '../constants.js';
|
|
8
8
|
import { RpcControllerDecoratorFactory } from '../decorators/rpc-controller.decorator.js';
|
|
9
|
-
import { colorFgMagenta, colorFgYellow, colorReset, nodeInspectCustom } from '../utils/inspect.util.js';
|
|
9
|
+
import { colorFgMagenta, colorFgYellow, colorReset, nodeInspectCustom, } from '../utils/inspect.util.js';
|
|
10
10
|
/**
|
|
11
11
|
* RpcController
|
|
12
12
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { omitUndefined } from '@jsopen/objects';
|
|
2
|
-
import { asMutable } from 'ts-gems';
|
|
2
|
+
import { asMutable, } from 'ts-gems';
|
|
3
3
|
import { Value } from '../common/value.js';
|
|
4
4
|
import { parseRegExp } from '../utils/parse-regexp.util.js';
|
|
5
5
|
export const RpcHeader = function (owner, initArgs) {
|
|
@@ -20,7 +20,9 @@ export class RpcOperationResponse extends DocumentElement {
|
|
|
20
20
|
this.payloadType = this.owner.node.getDataType('any');
|
|
21
21
|
if (initArgs?.keyType) {
|
|
22
22
|
this.keyType =
|
|
23
|
-
initArgs?.keyType instanceof DataType
|
|
23
|
+
initArgs?.keyType instanceof DataType
|
|
24
|
+
? initArgs.keyType
|
|
25
|
+
: this.owner.node.getDataType(initArgs.keyType);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
findHeader(paramName) {
|
|
@@ -40,8 +42,14 @@ export class RpcOperationResponse extends DocumentElement {
|
|
|
40
42
|
const out = omitUndefined({
|
|
41
43
|
description: this.description,
|
|
42
44
|
channel: this.channel,
|
|
43
|
-
payloadType: this.payloadType.name
|
|
44
|
-
|
|
45
|
+
payloadType: this.payloadType.name
|
|
46
|
+
? this.payloadType.name
|
|
47
|
+
: this.payloadType.toJSON(),
|
|
48
|
+
keyType: this.keyType
|
|
49
|
+
? this.keyType.name
|
|
50
|
+
? this.keyType.name
|
|
51
|
+
: this.keyType.toJSON()
|
|
52
|
+
: undefined,
|
|
45
53
|
});
|
|
46
54
|
if (this.headers.length) {
|
|
47
55
|
out.headers = [];
|
|
@@ -5,7 +5,7 @@ import { DataTypeMap } from '../common/data-type-map.js';
|
|
|
5
5
|
import { DocumentElement } from '../common/document-element.js';
|
|
6
6
|
import { CLASS_NAME_PATTERN, DECORATOR, kDataTypeMap } from '../constants.js';
|
|
7
7
|
import { DataType } from '../data-type/data-type.js';
|
|
8
|
-
import { RpcOperationDecoratorFactory } from '../decorators/rpc-operation.decorator.js';
|
|
8
|
+
import { RpcOperationDecoratorFactory, } from '../decorators/rpc-operation.decorator.js';
|
|
9
9
|
/**
|
|
10
10
|
* RpcOperation
|
|
11
11
|
*/
|
|
@@ -35,7 +35,9 @@ export const RpcOperation = function (...args) {
|
|
|
35
35
|
}
|
|
36
36
|
if (initArgs?.keyType) {
|
|
37
37
|
_this.keyType =
|
|
38
|
-
initArgs?.keyType instanceof DataType
|
|
38
|
+
initArgs?.keyType instanceof DataType
|
|
39
|
+
? initArgs.keyType
|
|
40
|
+
: _this.owner.node.getDataType(initArgs.keyType);
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
/**
|
|
@@ -60,8 +62,14 @@ class RpcOperationClass extends DocumentElement {
|
|
|
60
62
|
kind: OpraSchema.RpcOperation.Kind,
|
|
61
63
|
description: this.description,
|
|
62
64
|
channel: this.channel,
|
|
63
|
-
payloadType: this.payloadType.name
|
|
64
|
-
|
|
65
|
+
payloadType: this.payloadType.name
|
|
66
|
+
? this.payloadType.name
|
|
67
|
+
: this.payloadType.toJSON(),
|
|
68
|
+
keyType: this.keyType
|
|
69
|
+
? this.keyType.name
|
|
70
|
+
? this.keyType.name
|
|
71
|
+
: this.keyType.toJSON()
|
|
72
|
+
: undefined,
|
|
65
73
|
response: this.response?.toJSON(),
|
|
66
74
|
});
|
|
67
75
|
if (this.headers.length) {
|
|
@@ -4,12 +4,12 @@ export function parseRegExp(str, options) {
|
|
|
4
4
|
const s = str.substring(1, i);
|
|
5
5
|
let flags = str.substring(i + 1);
|
|
6
6
|
if (options?.includeFlags) {
|
|
7
|
-
for (const f of options
|
|
7
|
+
for (const f of options.includeFlags)
|
|
8
8
|
if (!flags.includes(f))
|
|
9
9
|
flags += f;
|
|
10
10
|
}
|
|
11
11
|
if (options?.excludeFlags) {
|
|
12
|
-
for (const f of options
|
|
12
|
+
for (const f of options.excludeFlags)
|
|
13
13
|
flags.replace(f, '');
|
|
14
14
|
}
|
|
15
15
|
return new RegExp(s, flags);
|
|
@@ -35,7 +35,9 @@ export class OpraException extends Error {
|
|
|
35
35
|
system: this.system,
|
|
36
36
|
code: this.code,
|
|
37
37
|
details: this.details,
|
|
38
|
-
stack: env === 'dev' || env === 'development' || env === 'test'
|
|
38
|
+
stack: env === 'dev' || env === 'development' || env === 'test'
|
|
39
|
+
? this.stack?.split('\n')
|
|
40
|
+
: undefined,
|
|
39
41
|
}, true);
|
|
40
42
|
}
|
|
41
43
|
init(issue) {
|