@opra/common 1.19.4 → 1.19.7
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 +11 -4
- package/cjs/document/constants.js +3 -1
- package/cjs/document/data-type/enum-type.js +4 -0
- package/cjs/document/decorators/{rpc-controller.decorator.js → mq-controller.decorator.js} +8 -8
- package/cjs/document/decorators/{rpc-operation.decorator.js → mq-operation.decorator.js} +6 -6
- package/cjs/document/decorators/ws-controller.decorator.js +51 -0
- package/cjs/document/decorators/ws-operation.decorator.js +43 -0
- package/cjs/document/factory/api-document.factory.js +3 -3
- package/cjs/document/factory/{rpc-api.factory.js → mq-api.factory.js} +28 -28
- package/cjs/document/factory/ws-api.factory.js +123 -0
- package/cjs/document/index.js +15 -8
- package/cjs/document/{rpc/rpc-api.js → mq/mq-api.js} +5 -5
- package/cjs/document/{rpc/rpc-controller.js → mq/mq-controller.js} +14 -14
- package/cjs/document/{rpc/rpc-header.js → mq/mq-header.js} +5 -5
- package/cjs/document/{rpc/rpc-operation-response.js → mq/mq-operation-response.js} +4 -4
- package/cjs/document/{rpc/rpc-operation.js → mq/mq-operation.js} +10 -10
- package/cjs/document/ws/ws-api.js +52 -0
- package/cjs/document/ws/ws-controller.js +78 -0
- package/cjs/document/ws/ws-operation.js +62 -0
- package/cjs/filter/antlr/OpraFilterLexer.js +361 -211
- package/cjs/filter/antlr/OpraFilterParser.js +174 -92
- package/cjs/schema/http/http-api.interface.js +2 -0
- package/cjs/schema/mq/mq-api.interface.js +2 -0
- package/cjs/schema/mq/mq-controller.interface.js +11 -0
- package/cjs/schema/mq/mq-header.interface.js +2 -0
- package/cjs/schema/mq/mq-operation.interface.js +7 -0
- package/cjs/schema/opra-schema.js +9 -3
- package/cjs/schema/ws/ws-api.interface.js +2 -0
- package/cjs/schema/ws/ws-controller.interface.js +11 -0
- package/cjs/schema/ws/ws-operation.interface.js +7 -0
- package/esm/document/api-document.js +11 -4
- package/esm/document/constants.js +2 -0
- package/esm/document/data-type/enum-type.js +4 -0
- package/esm/document/decorators/{rpc-controller.decorator.js → mq-controller.decorator.js} +8 -8
- package/esm/document/decorators/{rpc-operation.decorator.js → mq-operation.decorator.js} +6 -6
- package/esm/document/decorators/ws-controller.decorator.js +48 -0
- package/esm/document/decorators/ws-operation.decorator.js +40 -0
- package/esm/document/factory/api-document.factory.js +3 -3
- package/esm/document/factory/{rpc-api.factory.js → mq-api.factory.js} +27 -27
- package/esm/document/factory/ws-api.factory.js +119 -0
- package/esm/document/index.js +15 -8
- package/esm/document/{rpc/rpc-api.js → mq/mq-api.js} +3 -3
- package/esm/document/{rpc/rpc-controller.js → mq/mq-controller.js} +13 -13
- package/esm/document/{rpc/rpc-header.js → mq/mq-header.js} +4 -4
- package/esm/document/{rpc/rpc-operation-response.js → mq/mq-operation-response.js} +2 -2
- package/esm/document/{rpc/rpc-operation.js → mq/mq-operation.js} +9 -9
- package/esm/document/ws/ws-api.js +48 -0
- package/esm/document/ws/ws-controller.js +75 -0
- package/esm/document/ws/ws-operation.js +59 -0
- package/esm/filter/antlr/OpraFilterLexer.js +362 -212
- package/esm/filter/antlr/OpraFilterListener.js +1 -1
- package/esm/filter/antlr/OpraFilterParser.js +174 -92
- package/esm/schema/http/http-api.interface.js +1 -0
- package/esm/schema/mq/mq-api.interface.js +1 -0
- package/esm/schema/mq/mq-controller.interface.js +8 -0
- package/esm/schema/mq/mq-header.interface.js +1 -0
- package/esm/schema/mq/mq-operation.interface.js +4 -0
- package/esm/schema/opra-schema.js +9 -3
- package/esm/schema/ws/ws-api.interface.js +1 -0
- package/esm/schema/ws/ws-controller.interface.js +8 -0
- package/esm/schema/ws/ws-operation.interface.js +4 -0
- package/package.json +6 -6
- package/types/document/api-document.d.ts +5 -3
- package/types/document/constants.d.ts +2 -0
- package/types/document/decorators/mq-controller.decorator.d.ts +20 -0
- package/types/document/decorators/mq-operation.decorator.d.ts +32 -0
- package/types/document/decorators/ws-controller.decorator.d.ts +20 -0
- package/types/document/decorators/ws-operation.decorator.d.ts +24 -0
- package/types/document/factory/api-document.factory.d.ts +3 -2
- package/types/document/factory/mq-api.factory.d.ts +40 -0
- package/types/document/factory/ws-api.factory.d.ts +31 -0
- package/types/document/index.d.ts +20 -11
- package/types/document/mq/mq-api.d.ts +27 -0
- package/types/document/mq/mq-controller.d.ts +83 -0
- package/types/document/{rpc/rpc-header.d.ts → mq/mq-header.d.ts} +15 -15
- package/types/document/{rpc/rpc-operation-response.d.ts → mq/mq-operation-response.d.ts} +13 -13
- package/types/document/{rpc/rpc-operation.d.ts → mq/mq-operation.d.ts} +27 -27
- package/types/document/ws/ws-api.d.ts +26 -0
- package/types/document/ws/ws-controller.d.ts +79 -0
- package/types/document/ws/ws-operation.d.ts +70 -0
- package/types/filter/antlr/OpraFilterLexer.d.ts +1 -1
- package/types/filter/antlr/OpraFilterListener.d.ts +28 -28
- package/types/filter/antlr/OpraFilterVisitor.d.ts +27 -27
- package/types/schema/api-document.interface.d.ts +4 -46
- package/types/schema/api.interface.d.ts +13 -0
- package/types/schema/http/http-api.interface.d.ts +12 -0
- package/types/schema/mq/mq-api.interface.d.ts +15 -0
- package/types/schema/mq/mq-controller.interface.d.ts +22 -0
- package/types/schema/{rpc/rpc-header.interface.d.ts → mq/mq-header.interface.d.ts} +2 -2
- package/types/schema/{rpc/rpc-operation.interface.d.ts → mq/mq-operation.interface.d.ts} +11 -11
- package/types/schema/opra-schema.d.ts +9 -3
- package/types/schema/types.d.ts +11 -0
- package/types/schema/ws/ws-api.interface.d.ts +11 -0
- package/types/schema/ws/ws-controller.interface.d.ts +20 -0
- package/types/schema/ws/ws-operation.interface.d.ts +15 -0
- package/cjs/schema/rpc/rpc-controller.interface.js +0 -11
- package/cjs/schema/rpc/rpc-operation.interface.js +0 -7
- package/esm/schema/rpc/rpc-controller.interface.js +0 -8
- package/esm/schema/rpc/rpc-operation.interface.js +0 -4
- package/types/document/decorators/rpc-controller.decorator.d.ts +0 -20
- package/types/document/decorators/rpc-operation.decorator.d.ts +0 -32
- package/types/document/factory/rpc-api.factory.d.ts +0 -40
- package/types/document/rpc/rpc-api.d.ts +0 -27
- package/types/document/rpc/rpc-controller.d.ts +0 -83
- package/types/schema/rpc/rpc-controller.interface.d.ts +0 -22
- /package/cjs/schema/{rpc/rpc-header.interface.js → api.interface.js} +0 -0
- /package/esm/schema/{rpc/rpc-header.interface.js → api.interface.js} +0 -0
|
@@ -5,11 +5,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.PolarityOperatorContext = exports.LogicalOperatorContext = exports.ComparisonOperatorContext = exports.ArithmeticOperatorContext = exports.InfinityContext = exports.NullContext = exports.BooleanContext = exports.ArrayValueContext = exports.IdentifierContext = exports.ExternalConstantContext = exports.QualifiedIdentifierContext = exports.NumberLiteralContext = exports.BooleanLiteralContext = exports.InfinityLiteralContext = exports.DateLiteralContext = exports.StringLiteralContext = exports.DateTimeLiteralContext = exports.NullLiteralContext = exports.TimeLiteralContext = exports.ValueContext = exports.ParenthesizedItemContext = exports.ComparisonRightContext = exports.ComparisonLeftContext = exports.LogicalExpressionContext = exports.ComparisonExpressionContext = exports.NegativeExpressionContext = exports.ParenthesizedExpressionContext = exports.ExpressionContext = exports.RootContext = void 0;
|
|
6
6
|
const antlr4_1 = require("@browsery/antlr4");
|
|
7
7
|
class OpraFilterParser extends antlr4_1.Parser {
|
|
8
|
-
get grammarFileName() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
get
|
|
12
|
-
|
|
8
|
+
get grammarFileName() {
|
|
9
|
+
return 'OpraFilter.g4';
|
|
10
|
+
}
|
|
11
|
+
get literalNames() {
|
|
12
|
+
return OpraFilterParser.literalNames;
|
|
13
|
+
}
|
|
14
|
+
get symbolicNames() {
|
|
15
|
+
return OpraFilterParser.symbolicNames;
|
|
16
|
+
}
|
|
17
|
+
get ruleNames() {
|
|
18
|
+
return OpraFilterParser.ruleNames;
|
|
19
|
+
}
|
|
20
|
+
get serializedATN() {
|
|
21
|
+
return OpraFilterParser._serializedATN;
|
|
22
|
+
}
|
|
13
23
|
createFailedPredicateException(predicate, message) {
|
|
14
24
|
return new antlr4_1.FailedPredicateException(this, predicate, message);
|
|
15
25
|
}
|
|
@@ -70,11 +80,14 @@ class OpraFilterParser extends antlr4_1.Parser {
|
|
|
70
80
|
this._ctx = localctx;
|
|
71
81
|
_prevctx = localctx;
|
|
72
82
|
this.state = 38;
|
|
73
|
-
localctx._left =
|
|
83
|
+
localctx._left =
|
|
84
|
+
this.comparisonLeft();
|
|
74
85
|
this.state = 39;
|
|
75
|
-
localctx._operator =
|
|
86
|
+
localctx._operator =
|
|
87
|
+
this.comparisonOperator();
|
|
76
88
|
this.state = 40;
|
|
77
|
-
localctx._right =
|
|
89
|
+
localctx._right =
|
|
90
|
+
this.comparisonRight();
|
|
78
91
|
}
|
|
79
92
|
break;
|
|
80
93
|
case 1:
|
|
@@ -127,11 +140,12 @@ class OpraFilterParser extends antlr4_1.Parser {
|
|
|
127
140
|
localctx = new LogicalExpressionContext(this, new ExpressionContext(this, _parentctx, _parentState));
|
|
128
141
|
this.pushNewRecursionContext(localctx, _startState, OpraFilterParser.RULE_expression);
|
|
129
142
|
this.state = 50;
|
|
130
|
-
if (!
|
|
131
|
-
throw this.createFailedPredicateException(
|
|
143
|
+
if (!this.precpred(this._ctx, 3)) {
|
|
144
|
+
throw this.createFailedPredicateException('this.precpred(this._ctx, 3)');
|
|
132
145
|
}
|
|
133
146
|
this.state = 51;
|
|
134
|
-
localctx._op =
|
|
147
|
+
localctx._op =
|
|
148
|
+
this.logicalOperator();
|
|
135
149
|
this.state = 52;
|
|
136
150
|
this.expression(4);
|
|
137
151
|
}
|
|
@@ -617,7 +631,7 @@ class OpraFilterParser extends antlr4_1.Parser {
|
|
|
617
631
|
{
|
|
618
632
|
this.state = 111;
|
|
619
633
|
_la = this._input.LA(1);
|
|
620
|
-
if (!((
|
|
634
|
+
if (!((_la & ~0x1f) === 0 && ((1 << _la) & 491520) !== 0)) {
|
|
621
635
|
this._errHandler.recoverInline(this);
|
|
622
636
|
}
|
|
623
637
|
else {
|
|
@@ -651,7 +665,7 @@ class OpraFilterParser extends antlr4_1.Parser {
|
|
|
651
665
|
{
|
|
652
666
|
this.state = 113;
|
|
653
667
|
_la = this._input.LA(1);
|
|
654
|
-
if (!((
|
|
668
|
+
if (!((_la & ~0x1f) === 0 && ((1 << _la) & 2146959360) !== 0)) {
|
|
655
669
|
this._errHandler.recoverInline(this);
|
|
656
670
|
}
|
|
657
671
|
else {
|
|
@@ -685,7 +699,7 @@ class OpraFilterParser extends antlr4_1.Parser {
|
|
|
685
699
|
{
|
|
686
700
|
this.state = 115;
|
|
687
701
|
_la = this._input.LA(1);
|
|
688
|
-
if (!(((
|
|
702
|
+
if (!(((_la - 31) & ~0x1f) === 0 && ((1 << (_la - 31)) & 15) !== 0)) {
|
|
689
703
|
this._errHandler.recoverInline(this);
|
|
690
704
|
}
|
|
691
705
|
else {
|
|
@@ -817,88 +831,156 @@ OpraFilterParser.RULE_arithmeticOperator = 13;
|
|
|
817
831
|
OpraFilterParser.RULE_comparisonOperator = 14;
|
|
818
832
|
OpraFilterParser.RULE_logicalOperator = 15;
|
|
819
833
|
OpraFilterParser.RULE_polarityOperator = 16;
|
|
820
|
-
OpraFilterParser.literalNames = [
|
|
821
|
-
|
|
822
|
-
"'
|
|
823
|
-
"'
|
|
824
|
-
"'
|
|
825
|
-
"'
|
|
826
|
-
"'
|
|
834
|
+
OpraFilterParser.literalNames = [
|
|
835
|
+
null,
|
|
836
|
+
"'('",
|
|
837
|
+
"')'",
|
|
838
|
+
"'not'",
|
|
839
|
+
"'!'",
|
|
840
|
+
"'.'",
|
|
841
|
+
"'@'",
|
|
842
|
+
"'['",
|
|
843
|
+
"','",
|
|
844
|
+
"']'",
|
|
845
|
+
"'true'",
|
|
846
|
+
"'false'",
|
|
847
|
+
"'null'",
|
|
848
|
+
"'Infinity'",
|
|
827
849
|
"'infinity'",
|
|
828
|
-
"'+'",
|
|
829
|
-
"'
|
|
830
|
-
"'
|
|
831
|
-
"'
|
|
832
|
-
"'
|
|
833
|
-
"'
|
|
834
|
-
"'
|
|
835
|
-
"'
|
|
836
|
-
"'
|
|
837
|
-
"'
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
null,
|
|
851
|
-
null,
|
|
852
|
-
null,
|
|
853
|
-
null,
|
|
854
|
-
null,
|
|
855
|
-
null,
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
850
|
+
"'+'",
|
|
851
|
+
"'-'",
|
|
852
|
+
"'*'",
|
|
853
|
+
"'/'",
|
|
854
|
+
"'<='",
|
|
855
|
+
"'<'",
|
|
856
|
+
"'>'",
|
|
857
|
+
"'>='",
|
|
858
|
+
"'='",
|
|
859
|
+
"'!='",
|
|
860
|
+
"'in'",
|
|
861
|
+
"'!in'",
|
|
862
|
+
"'like'",
|
|
863
|
+
"'!like'",
|
|
864
|
+
"'ilike'",
|
|
865
|
+
"'!ilike'",
|
|
866
|
+
"'and'",
|
|
867
|
+
"'or'",
|
|
868
|
+
"'&&'",
|
|
869
|
+
"'||'",
|
|
870
|
+
];
|
|
871
|
+
OpraFilterParser.symbolicNames = [
|
|
872
|
+
null,
|
|
873
|
+
null,
|
|
874
|
+
null,
|
|
875
|
+
null,
|
|
876
|
+
null,
|
|
877
|
+
null,
|
|
878
|
+
null,
|
|
879
|
+
null,
|
|
880
|
+
null,
|
|
881
|
+
null,
|
|
882
|
+
null,
|
|
883
|
+
null,
|
|
884
|
+
null,
|
|
885
|
+
null,
|
|
886
|
+
null,
|
|
887
|
+
null,
|
|
888
|
+
null,
|
|
889
|
+
null,
|
|
890
|
+
null,
|
|
891
|
+
null,
|
|
892
|
+
null,
|
|
893
|
+
null,
|
|
894
|
+
null,
|
|
895
|
+
null,
|
|
896
|
+
null,
|
|
897
|
+
null,
|
|
898
|
+
null,
|
|
899
|
+
null,
|
|
900
|
+
null,
|
|
901
|
+
null,
|
|
902
|
+
null,
|
|
903
|
+
null,
|
|
904
|
+
null,
|
|
905
|
+
null,
|
|
906
|
+
null,
|
|
907
|
+
'IDENTIFIER',
|
|
908
|
+
'POLAR_OP',
|
|
909
|
+
'DATE',
|
|
910
|
+
'DATETIME',
|
|
911
|
+
'TIME',
|
|
912
|
+
'NUMBER',
|
|
913
|
+
'INTEGER',
|
|
914
|
+
'STRING',
|
|
915
|
+
'WHITESPACE',
|
|
916
|
+
];
|
|
861
917
|
// tslint:disable:no-trailing-whitespace
|
|
862
918
|
OpraFilterParser.ruleNames = [
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
919
|
+
'root',
|
|
920
|
+
'expression',
|
|
921
|
+
'comparisonLeft',
|
|
922
|
+
'comparisonRight',
|
|
923
|
+
'parenthesizedItem',
|
|
924
|
+
'value',
|
|
925
|
+
'qualifiedIdentifier',
|
|
926
|
+
'externalConstant',
|
|
927
|
+
'identifier',
|
|
928
|
+
'arrayValue',
|
|
929
|
+
'boolean',
|
|
930
|
+
'null',
|
|
931
|
+
'infinity',
|
|
932
|
+
'arithmeticOperator',
|
|
933
|
+
'comparisonOperator',
|
|
934
|
+
'logicalOperator',
|
|
935
|
+
'polarityOperator',
|
|
936
|
+
];
|
|
937
|
+
OpraFilterParser._serializedATN = [
|
|
938
|
+
4, 1, 43, 120, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4,
|
|
939
|
+
2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2,
|
|
940
|
+
11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7,
|
|
941
|
+
16, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
942
|
+
1, 1, 1, 1, 3, 1, 49, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 55, 8, 1, 10, 1,
|
|
943
|
+
12, 1, 58, 9, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 66, 8, 3, 1, 4,
|
|
944
|
+
1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 78, 8, 5, 1, 6,
|
|
945
|
+
1, 6, 1, 6, 5, 6, 83, 8, 6, 10, 6, 12, 6, 86, 9, 6, 1, 6, 1, 6, 1, 7, 1, 7,
|
|
946
|
+
1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 99, 8, 9, 10, 9, 12, 9, 102,
|
|
947
|
+
9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1,
|
|
948
|
+
14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 1, 2, 17, 0, 2, 4, 6, 8,
|
|
949
|
+
10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6, 1, 0, 3, 4, 1, 0, 10,
|
|
950
|
+
11, 1, 0, 13, 14, 1, 0, 15, 18, 1, 0, 19, 30, 1, 0, 31, 34, 117, 0, 34, 1,
|
|
951
|
+
0, 0, 0, 2, 48, 1, 0, 0, 0, 4, 59, 1, 0, 0, 0, 6, 65, 1, 0, 0, 0, 8, 67, 1,
|
|
952
|
+
0, 0, 0, 10, 77, 1, 0, 0, 0, 12, 84, 1, 0, 0, 0, 14, 89, 1, 0, 0, 0, 16, 92,
|
|
953
|
+
1, 0, 0, 0, 18, 94, 1, 0, 0, 0, 20, 105, 1, 0, 0, 0, 22, 107, 1, 0, 0, 0,
|
|
954
|
+
24, 109, 1, 0, 0, 0, 26, 111, 1, 0, 0, 0, 28, 113, 1, 0, 0, 0, 30, 115, 1,
|
|
955
|
+
0, 0, 0, 32, 117, 1, 0, 0, 0, 34, 35, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1,
|
|
956
|
+
1, 0, 0, 0, 37, 38, 6, 1, -1, 0, 38, 39, 3, 4, 2, 0, 39, 40, 3, 28, 14, 0,
|
|
957
|
+
40, 41, 3, 6, 3, 0, 41, 49, 1, 0, 0, 0, 42, 43, 5, 1, 0, 0, 43, 44, 3, 8, 4,
|
|
958
|
+
0, 44, 45, 5, 2, 0, 0, 45, 49, 1, 0, 0, 0, 46, 47, 7, 0, 0, 0, 47, 49, 3, 2,
|
|
959
|
+
1, 1, 48, 37, 1, 0, 0, 0, 48, 42, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 49, 56, 1,
|
|
960
|
+
0, 0, 0, 50, 51, 10, 3, 0, 0, 51, 52, 3, 30, 15, 0, 52, 53, 3, 2, 1, 4, 53,
|
|
961
|
+
55, 1, 0, 0, 0, 54, 50, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0,
|
|
962
|
+
56, 57, 1, 0, 0, 0, 57, 3, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 60, 3, 12, 6,
|
|
963
|
+
0, 60, 5, 1, 0, 0, 0, 61, 66, 3, 10, 5, 0, 62, 66, 3, 12, 6, 0, 63, 66, 3,
|
|
964
|
+
14, 7, 0, 64, 66, 3, 18, 9, 0, 65, 61, 1, 0, 0, 0, 65, 62, 1, 0, 0, 0, 65,
|
|
965
|
+
63, 1, 0, 0, 0, 65, 64, 1, 0, 0, 0, 66, 7, 1, 0, 0, 0, 67, 68, 3, 2, 1, 0,
|
|
966
|
+
68, 9, 1, 0, 0, 0, 69, 78, 5, 40, 0, 0, 70, 78, 3, 24, 12, 0, 71, 78, 3, 20,
|
|
967
|
+
10, 0, 72, 78, 3, 22, 11, 0, 73, 78, 5, 38, 0, 0, 74, 78, 5, 37, 0, 0, 75,
|
|
968
|
+
78, 5, 39, 0, 0, 76, 78, 5, 42, 0, 0, 77, 69, 1, 0, 0, 0, 77, 70, 1, 0, 0,
|
|
969
|
+
0, 77, 71, 1, 0, 0, 0, 77, 72, 1, 0, 0, 0, 77, 73, 1, 0, 0, 0, 77, 74, 1, 0,
|
|
970
|
+
0, 0, 77, 75, 1, 0, 0, 0, 77, 76, 1, 0, 0, 0, 78, 11, 1, 0, 0, 0, 79, 80, 3,
|
|
971
|
+
16, 8, 0, 80, 81, 5, 5, 0, 0, 81, 83, 1, 0, 0, 0, 82, 79, 1, 0, 0, 0, 83,
|
|
972
|
+
86, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 87, 1, 0, 0, 0,
|
|
973
|
+
86, 84, 1, 0, 0, 0, 87, 88, 3, 16, 8, 0, 88, 13, 1, 0, 0, 0, 89, 90, 5, 6,
|
|
974
|
+
0, 0, 90, 91, 3, 16, 8, 0, 91, 15, 1, 0, 0, 0, 92, 93, 5, 35, 0, 0, 93, 17,
|
|
975
|
+
1, 0, 0, 0, 94, 95, 5, 7, 0, 0, 95, 100, 3, 10, 5, 0, 96, 97, 5, 8, 0, 0,
|
|
976
|
+
97, 99, 3, 10, 5, 0, 98, 96, 1, 0, 0, 0, 99, 102, 1, 0, 0, 0, 100, 98, 1, 0,
|
|
977
|
+
0, 0, 100, 101, 1, 0, 0, 0, 101, 103, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 103,
|
|
978
|
+
104, 5, 9, 0, 0, 104, 19, 1, 0, 0, 0, 105, 106, 7, 1, 0, 0, 106, 21, 1, 0,
|
|
979
|
+
0, 0, 107, 108, 5, 12, 0, 0, 108, 23, 1, 0, 0, 0, 109, 110, 7, 2, 0, 0, 110,
|
|
980
|
+
25, 1, 0, 0, 0, 111, 112, 7, 3, 0, 0, 112, 27, 1, 0, 0, 0, 113, 114, 7, 4,
|
|
981
|
+
0, 0, 114, 29, 1, 0, 0, 0, 115, 116, 7, 5, 0, 0, 116, 31, 1, 0, 0, 0, 117,
|
|
982
|
+
118, 5, 36, 0, 0, 118, 33, 1, 0, 0, 0, 6, 48, 56, 65, 77, 84, 100,
|
|
867
983
|
];
|
|
868
|
-
OpraFilterParser._serializedATN = [4, 1, 43, 120, 2, 0, 7, 0, 2,
|
|
869
|
-
1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2,
|
|
870
|
-
10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 1, 0,
|
|
871
|
-
1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 49, 8, 1, 1, 1, 1, 1,
|
|
872
|
-
1, 1, 1, 1, 5, 1, 55, 8, 1, 10, 1, 12, 1, 58, 9, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 66, 8, 3,
|
|
873
|
-
1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 78, 8, 5, 1, 6, 1, 6, 1, 6, 5, 6, 83, 8,
|
|
874
|
-
6, 10, 6, 12, 6, 86, 9, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 99, 8,
|
|
875
|
-
9, 10, 9, 12, 9, 102, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14,
|
|
876
|
-
1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 1, 2, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24,
|
|
877
|
-
26, 28, 30, 32, 0, 6, 1, 0, 3, 4, 1, 0, 10, 11, 1, 0, 13, 14, 1, 0, 15, 18, 1, 0, 19, 30, 1, 0, 31,
|
|
878
|
-
34, 117, 0, 34, 1, 0, 0, 0, 2, 48, 1, 0, 0, 0, 4, 59, 1, 0, 0, 0, 6, 65, 1, 0, 0, 0, 8, 67, 1, 0, 0, 0,
|
|
879
|
-
10, 77, 1, 0, 0, 0, 12, 84, 1, 0, 0, 0, 14, 89, 1, 0, 0, 0, 16, 92, 1, 0, 0, 0, 18, 94, 1, 0, 0, 0, 20,
|
|
880
|
-
105, 1, 0, 0, 0, 22, 107, 1, 0, 0, 0, 24, 109, 1, 0, 0, 0, 26, 111, 1, 0, 0, 0, 28, 113, 1, 0, 0, 0,
|
|
881
|
-
30, 115, 1, 0, 0, 0, 32, 117, 1, 0, 0, 0, 34, 35, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0,
|
|
882
|
-
37, 38, 6, 1, -1, 0, 38, 39, 3, 4, 2, 0, 39, 40, 3, 28, 14, 0, 40, 41, 3, 6, 3, 0, 41, 49, 1, 0, 0,
|
|
883
|
-
0, 42, 43, 5, 1, 0, 0, 43, 44, 3, 8, 4, 0, 44, 45, 5, 2, 0, 0, 45, 49, 1, 0, 0, 0, 46, 47, 7, 0, 0, 0,
|
|
884
|
-
47, 49, 3, 2, 1, 1, 48, 37, 1, 0, 0, 0, 48, 42, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 49, 56, 1, 0, 0, 0, 50,
|
|
885
|
-
51, 10, 3, 0, 0, 51, 52, 3, 30, 15, 0, 52, 53, 3, 2, 1, 4, 53, 55, 1, 0, 0, 0, 54, 50, 1, 0, 0, 0, 55,
|
|
886
|
-
58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 3, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 60,
|
|
887
|
-
3, 12, 6, 0, 60, 5, 1, 0, 0, 0, 61, 66, 3, 10, 5, 0, 62, 66, 3, 12, 6, 0, 63, 66, 3, 14, 7, 0, 64, 66,
|
|
888
|
-
3, 18, 9, 0, 65, 61, 1, 0, 0, 0, 65, 62, 1, 0, 0, 0, 65, 63, 1, 0, 0, 0, 65, 64, 1, 0, 0, 0, 66, 7, 1,
|
|
889
|
-
0, 0, 0, 67, 68, 3, 2, 1, 0, 68, 9, 1, 0, 0, 0, 69, 78, 5, 40, 0, 0, 70, 78, 3, 24, 12, 0, 71, 78, 3,
|
|
890
|
-
20, 10, 0, 72, 78, 3, 22, 11, 0, 73, 78, 5, 38, 0, 0, 74, 78, 5, 37, 0, 0, 75, 78, 5, 39, 0, 0, 76,
|
|
891
|
-
78, 5, 42, 0, 0, 77, 69, 1, 0, 0, 0, 77, 70, 1, 0, 0, 0, 77, 71, 1, 0, 0, 0, 77, 72, 1, 0, 0, 0, 77,
|
|
892
|
-
73, 1, 0, 0, 0, 77, 74, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 77, 76, 1, 0, 0, 0, 78, 11, 1, 0, 0, 0, 79, 80,
|
|
893
|
-
3, 16, 8, 0, 80, 81, 5, 5, 0, 0, 81, 83, 1, 0, 0, 0, 82, 79, 1, 0, 0, 0, 83, 86, 1, 0, 0, 0, 84, 82,
|
|
894
|
-
1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 87, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 87, 88, 3, 16, 8, 0, 88, 13,
|
|
895
|
-
1, 0, 0, 0, 89, 90, 5, 6, 0, 0, 90, 91, 3, 16, 8, 0, 91, 15, 1, 0, 0, 0, 92, 93, 5, 35, 0, 0, 93, 17,
|
|
896
|
-
1, 0, 0, 0, 94, 95, 5, 7, 0, 0, 95, 100, 3, 10, 5, 0, 96, 97, 5, 8, 0, 0, 97, 99, 3, 10, 5, 0, 98, 96,
|
|
897
|
-
1, 0, 0, 0, 99, 102, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 103, 1, 0, 0, 0, 102,
|
|
898
|
-
100, 1, 0, 0, 0, 103, 104, 5, 9, 0, 0, 104, 19, 1, 0, 0, 0, 105, 106, 7, 1, 0, 0, 106, 21, 1, 0, 0,
|
|
899
|
-
0, 107, 108, 5, 12, 0, 0, 108, 23, 1, 0, 0, 0, 109, 110, 7, 2, 0, 0, 110, 25, 1, 0, 0, 0, 111, 112,
|
|
900
|
-
7, 3, 0, 0, 112, 27, 1, 0, 0, 0, 113, 114, 7, 4, 0, 0, 114, 29, 1, 0, 0, 0, 115, 116, 7, 5, 0, 0, 116,
|
|
901
|
-
31, 1, 0, 0, 0, 117, 118, 5, 36, 0, 0, 118, 33, 1, 0, 0, 0, 6, 48, 56, 65, 77, 84, 100];
|
|
902
984
|
OpraFilterParser.DecisionsToDFA = OpraFilterParser._ATN.decisionToState.map((ds, index) => new antlr4_1.DFA(ds, index));
|
|
903
985
|
exports.default = OpraFilterParser;
|
|
904
986
|
class RootContext extends antlr4_1.ParserRuleContext {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MQController = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @namespace MQController
|
|
7
|
+
*/
|
|
8
|
+
var MQController;
|
|
9
|
+
(function (MQController) {
|
|
10
|
+
MQController.Kind = 'MQController';
|
|
11
|
+
})(MQController || (exports.MQController = MQController = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./api.interface.js"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./api-document.interface.js"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./data-type/complex-type.interface.js"), exports);
|
|
@@ -12,6 +13,7 @@ tslib_1.__exportStar(require("./data-type/mixin-type.interface.js"), exports);
|
|
|
12
13
|
tslib_1.__exportStar(require("./data-type/simple-type.interface.js"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./data-type/union-type.interface.js"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./data-type-container.interface.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./http/http-api.interface.js"), exports);
|
|
15
17
|
tslib_1.__exportStar(require("./http/http-controller.interface.js"), exports);
|
|
16
18
|
tslib_1.__exportStar(require("./http/http-media-type.interface.js"), exports);
|
|
17
19
|
tslib_1.__exportStar(require("./http/http-multipart-field.interface.js"), exports);
|
|
@@ -20,9 +22,13 @@ tslib_1.__exportStar(require("./http/http-operation-response.interface.js"), exp
|
|
|
20
22
|
tslib_1.__exportStar(require("./http/http-parameter.interface.js"), exports);
|
|
21
23
|
tslib_1.__exportStar(require("./http/http-request-body.interface.js"), exports);
|
|
22
24
|
tslib_1.__exportStar(require("./http/http-status-range.interface.js"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./
|
|
24
|
-
tslib_1.__exportStar(require("./
|
|
25
|
-
tslib_1.__exportStar(require("./
|
|
25
|
+
tslib_1.__exportStar(require("./mq/mq-api.interface.js"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./mq/mq-controller.interface.js"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./mq/mq-header.interface.js"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./mq/mq-operation.interface.js"), exports);
|
|
26
29
|
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
27
30
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
28
31
|
tslib_1.__exportStar(require("./value.interface.js"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./ws/ws-api.interface.js"), exports);
|
|
33
|
+
tslib_1.__exportStar(require("./ws/ws-controller.interface.js"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./ws/ws-operation.interface.js"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WSController = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @namespace WSController
|
|
7
|
+
*/
|
|
8
|
+
var WSController;
|
|
9
|
+
(function (WSController) {
|
|
10
|
+
WSController.Kind = 'WSController';
|
|
11
|
+
})(WSController || (exports.WSController = WSController = {}));
|
|
@@ -8,7 +8,8 @@ import { DocumentElement } from './common/document-element.js';
|
|
|
8
8
|
import { BUILTIN, kDataTypeMap, kTypeNSMap, NAMESPACE_PATTERN, } from './constants.js';
|
|
9
9
|
import { DataType } from './data-type/data-type.js';
|
|
10
10
|
import { HttpApi } from './http/http-api.js';
|
|
11
|
-
import {
|
|
11
|
+
import { MQApi } from './mq/mq-api.js';
|
|
12
|
+
import { WSApi } from './ws/ws-api.js';
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
14
15
|
* @class ApiDocument
|
|
@@ -52,9 +53,15 @@ export class ApiDocument extends DocumentElement {
|
|
|
52
53
|
}
|
|
53
54
|
return this.api;
|
|
54
55
|
}
|
|
55
|
-
get
|
|
56
|
-
if (!(this.api && this.api instanceof
|
|
57
|
-
throw new TypeError('The document do not contains
|
|
56
|
+
get mqApi() {
|
|
57
|
+
if (!(this.api && this.api instanceof MQApi)) {
|
|
58
|
+
throw new TypeError('The document do not contains MQApi instance');
|
|
59
|
+
}
|
|
60
|
+
return this.api;
|
|
61
|
+
}
|
|
62
|
+
get wsApi() {
|
|
63
|
+
if (!(this.api && this.api instanceof WSApi)) {
|
|
64
|
+
throw new TypeError('The document do not contains WSApi instance');
|
|
58
65
|
}
|
|
59
66
|
return this.api;
|
|
60
67
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const DATATYPE_METADATA = Symbol.for('opra.type.metadata');
|
|
2
2
|
export const HTTP_CONTROLLER_METADATA = Symbol('opra.http-controller.metadata');
|
|
3
|
+
export const MQ_CONTROLLER_METADATA = Symbol('opra.mq-controller.metadata');
|
|
4
|
+
export const WS_CONTROLLER_METADATA = Symbol('opra.ws-controller.metadata');
|
|
3
5
|
export const RPC_CONTROLLER_METADATA = Symbol('opra.rpc-controller.metadata');
|
|
4
6
|
export const DECODER = Symbol.for('opra.type.decoder');
|
|
5
7
|
export const ENCODER = Symbol('opra.type.encoder');
|
|
@@ -87,6 +87,8 @@ function EnumTypeFactory(enumSource, ...args) {
|
|
|
87
87
|
}
|
|
88
88
|
attributes = {};
|
|
89
89
|
enumSource.forEach(k => {
|
|
90
|
+
if (!isNaN(Number(k)))
|
|
91
|
+
return;
|
|
90
92
|
const description = options?.meanings?.[k];
|
|
91
93
|
attributes[k] = omitUndefined({ description });
|
|
92
94
|
});
|
|
@@ -98,6 +100,8 @@ function EnumTypeFactory(enumSource, ...args) {
|
|
|
98
100
|
out = { ...base, ...enumSource };
|
|
99
101
|
}
|
|
100
102
|
Object.keys(enumSource).forEach(k => {
|
|
103
|
+
if (!isNaN(Number(k)))
|
|
104
|
+
return;
|
|
101
105
|
const description = options?.meanings?.[k];
|
|
102
106
|
attributes[enumSource[k]] = omitUndefined({ alias: k, description });
|
|
103
107
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { merge } from '@jsopen/objects';
|
|
2
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { MQ_CONTROLLER_METADATA } from '../constants.js';
|
|
4
4
|
const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
|
|
5
5
|
const augmentationRegistry = [];
|
|
6
|
-
export function
|
|
6
|
+
export function MQControllerDecoratorFactory(options) {
|
|
7
7
|
const decoratorChain = [];
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -13,22 +13,22 @@ export function RpcControllerDecoratorFactory(options) {
|
|
|
13
13
|
if (!name)
|
|
14
14
|
name = CLASS_NAME_PATTERN.exec(target.name)?.[1] || target.name;
|
|
15
15
|
const metadata = {};
|
|
16
|
-
const baseMetadata = Reflect.getOwnMetadata(
|
|
16
|
+
const baseMetadata = Reflect.getOwnMetadata(MQ_CONTROLLER_METADATA, Object.getPrototypeOf(target));
|
|
17
17
|
if (baseMetadata)
|
|
18
18
|
merge(metadata, baseMetadata, { deep: true });
|
|
19
|
-
const oldMetadata = Reflect.getOwnMetadata(
|
|
19
|
+
const oldMetadata = Reflect.getOwnMetadata(MQ_CONTROLLER_METADATA, target);
|
|
20
20
|
if (oldMetadata)
|
|
21
21
|
merge(metadata, oldMetadata, { deep: true });
|
|
22
22
|
merge(metadata, {
|
|
23
23
|
...options,
|
|
24
|
-
kind: OpraSchema.
|
|
24
|
+
kind: OpraSchema.MQController.Kind,
|
|
25
25
|
name,
|
|
26
26
|
path: name,
|
|
27
27
|
}, { deep: true });
|
|
28
|
-
Reflect.defineMetadata(
|
|
28
|
+
Reflect.defineMetadata(MQ_CONTROLLER_METADATA, metadata, target);
|
|
29
29
|
for (const fn of decoratorChain)
|
|
30
30
|
fn(metadata, target);
|
|
31
|
-
Reflect.defineMetadata(
|
|
31
|
+
Reflect.defineMetadata(MQ_CONTROLLER_METADATA, metadata, target);
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
*
|
|
@@ -59,6 +59,6 @@ export function RpcControllerDecoratorFactory(options) {
|
|
|
59
59
|
augmentationRegistry.forEach(fn => fn(decorator, decoratorChain, options));
|
|
60
60
|
return decorator;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
MQControllerDecoratorFactory.augment = function (fn) {
|
|
63
63
|
augmentationRegistry.push(fn);
|
|
64
64
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { omit } from '@jsopen/objects';
|
|
2
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { MQ_CONTROLLER_METADATA } from '../constants.js';
|
|
4
4
|
const augmentationRegistry = [];
|
|
5
|
-
export function
|
|
5
|
+
export function MQOperationDecoratorFactory(decoratorChain, payloadType, options) {
|
|
6
6
|
let inResponse = false;
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -11,17 +11,17 @@ export function RpcOperationDecoratorFactory(decoratorChain, payloadType, option
|
|
|
11
11
|
if (typeof propertyKey !== 'string')
|
|
12
12
|
throw new TypeError(`Symbol properties can not be decorated`);
|
|
13
13
|
const operationMetadata = {
|
|
14
|
-
kind: OpraSchema.
|
|
14
|
+
kind: OpraSchema.MQOperation.Kind,
|
|
15
15
|
channel: propertyKey,
|
|
16
16
|
payloadType,
|
|
17
17
|
...omit(options, ['kind', 'payloadType']),
|
|
18
18
|
};
|
|
19
|
-
const controllerMetadata = (Reflect.getOwnMetadata(
|
|
19
|
+
const controllerMetadata = (Reflect.getOwnMetadata(MQ_CONTROLLER_METADATA, target.constructor) || {});
|
|
20
20
|
controllerMetadata.operations = controllerMetadata.operations || {};
|
|
21
21
|
controllerMetadata.operations[propertyKey] = operationMetadata;
|
|
22
22
|
for (const fn of decoratorChain)
|
|
23
23
|
fn(operationMetadata, target, propertyKey);
|
|
24
|
-
Reflect.defineMetadata(
|
|
24
|
+
Reflect.defineMetadata(MQ_CONTROLLER_METADATA, controllerMetadata, target.constructor);
|
|
25
25
|
});
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
@@ -70,6 +70,6 @@ export function RpcOperationDecoratorFactory(decoratorChain, payloadType, option
|
|
|
70
70
|
augmentationRegistry.forEach(fn => fn(decorator, decoratorChain, payloadType, options));
|
|
71
71
|
return decorator;
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
MQOperationDecoratorFactory.augment = function (fn) {
|
|
74
74
|
augmentationRegistry.push(fn);
|
|
75
75
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { merge } from '@jsopen/objects';
|
|
2
|
+
import { OpraSchema } from '../../schema/index.js';
|
|
3
|
+
import { MQ_CONTROLLER_METADATA } from '../constants.js';
|
|
4
|
+
const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
|
|
5
|
+
const augmentationRegistry = [];
|
|
6
|
+
export function WSControllerDecoratorFactory(options) {
|
|
7
|
+
const decoratorChain = [];
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
const decorator = function (target) {
|
|
12
|
+
let name = options?.name;
|
|
13
|
+
if (!name)
|
|
14
|
+
name = CLASS_NAME_PATTERN.exec(target.name)?.[1] || target.name;
|
|
15
|
+
const metadata = {};
|
|
16
|
+
const baseMetadata = Reflect.getOwnMetadata(MQ_CONTROLLER_METADATA, Object.getPrototypeOf(target));
|
|
17
|
+
if (baseMetadata)
|
|
18
|
+
merge(metadata, baseMetadata, { deep: true });
|
|
19
|
+
const oldMetadata = Reflect.getOwnMetadata(MQ_CONTROLLER_METADATA, target);
|
|
20
|
+
if (oldMetadata)
|
|
21
|
+
merge(metadata, oldMetadata, { deep: true });
|
|
22
|
+
merge(metadata, {
|
|
23
|
+
...options,
|
|
24
|
+
kind: OpraSchema.WSController.Kind,
|
|
25
|
+
name,
|
|
26
|
+
path: name,
|
|
27
|
+
}, { deep: true });
|
|
28
|
+
Reflect.defineMetadata(MQ_CONTROLLER_METADATA, metadata, target);
|
|
29
|
+
for (const fn of decoratorChain)
|
|
30
|
+
fn(metadata, target);
|
|
31
|
+
Reflect.defineMetadata(MQ_CONTROLLER_METADATA, metadata, target);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
decorator.UseType = (...type) => {
|
|
37
|
+
decoratorChain.push((meta) => {
|
|
38
|
+
meta.types = meta.types || [];
|
|
39
|
+
meta.types.push(...type);
|
|
40
|
+
});
|
|
41
|
+
return decorator;
|
|
42
|
+
};
|
|
43
|
+
augmentationRegistry.forEach(fn => fn(decorator, decoratorChain, options));
|
|
44
|
+
return decorator;
|
|
45
|
+
}
|
|
46
|
+
WSControllerDecoratorFactory.augment = function (fn) {
|
|
47
|
+
augmentationRegistry.push(fn);
|
|
48
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { omit } from '@jsopen/objects';
|
|
2
|
+
import { OpraSchema } from '../../schema/index.js';
|
|
3
|
+
import { MQ_CONTROLLER_METADATA } from '../constants.js';
|
|
4
|
+
const augmentationRegistry = [];
|
|
5
|
+
export function WSOperationDecoratorFactory(decoratorChain, payloadType, options) {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
const decorator = ((target, propertyKey) => {
|
|
10
|
+
if (typeof propertyKey !== 'string')
|
|
11
|
+
throw new TypeError(`Symbol properties can not be decorated`);
|
|
12
|
+
const operationMetadata = {
|
|
13
|
+
kind: OpraSchema.WSOperation.Kind,
|
|
14
|
+
channel: propertyKey,
|
|
15
|
+
payloadType,
|
|
16
|
+
...omit(options, ['kind', 'payloadType']),
|
|
17
|
+
};
|
|
18
|
+
const controllerMetadata = (Reflect.getOwnMetadata(MQ_CONTROLLER_METADATA, target.constructor) || {});
|
|
19
|
+
controllerMetadata.operations = controllerMetadata.operations || {};
|
|
20
|
+
controllerMetadata.operations[propertyKey] = operationMetadata;
|
|
21
|
+
for (const fn of decoratorChain)
|
|
22
|
+
fn(operationMetadata, target, propertyKey);
|
|
23
|
+
Reflect.defineMetadata(MQ_CONTROLLER_METADATA, controllerMetadata, target.constructor);
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
decorator.UseType = (...type) => {
|
|
29
|
+
decoratorChain.push((meta) => {
|
|
30
|
+
meta.types = meta.types || [];
|
|
31
|
+
meta.types.push(...type);
|
|
32
|
+
});
|
|
33
|
+
return decorator;
|
|
34
|
+
};
|
|
35
|
+
augmentationRegistry.forEach(fn => fn(decorator, decoratorChain, payloadType, options));
|
|
36
|
+
return decorator;
|
|
37
|
+
}
|
|
38
|
+
WSOperationDecoratorFactory.augment = function (fn) {
|
|
39
|
+
augmentationRegistry.push(fn);
|
|
40
|
+
};
|