@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MQController = void 0;
|
|
4
4
|
const objects_1 = require("@jsopen/objects");
|
|
5
5
|
const ts_gems_1 = require("ts-gems");
|
|
6
6
|
const index_js_1 = require("../../helpers/index.js");
|
|
@@ -8,22 +8,22 @@ const index_js_2 = require("../../schema/index.js");
|
|
|
8
8
|
const data_type_map_js_1 = require("../common/data-type-map.js");
|
|
9
9
|
const document_element_js_1 = require("../common/document-element.js");
|
|
10
10
|
const constants_js_1 = require("../constants.js");
|
|
11
|
-
const
|
|
11
|
+
const mq_controller_decorator_js_1 = require("../decorators/mq-controller.decorator.js");
|
|
12
12
|
const inspect_util_js_1 = require("../utils/inspect.util.js");
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* MQController
|
|
15
15
|
*/
|
|
16
|
-
exports.
|
|
16
|
+
exports.MQController = function (...args) {
|
|
17
17
|
// ClassDecorator
|
|
18
18
|
if (!this)
|
|
19
|
-
return exports.
|
|
19
|
+
return exports.MQController[constants_js_1.DECORATOR].apply(undefined, args);
|
|
20
20
|
// Constructor
|
|
21
21
|
const [owner, initArgs] = args;
|
|
22
22
|
document_element_js_1.DocumentElement.call(this, owner);
|
|
23
23
|
if (!constants_js_1.CLASS_NAME_PATTERN.test(initArgs.name))
|
|
24
24
|
throw new TypeError(`Invalid resource name (${initArgs.name})`);
|
|
25
25
|
const _this = (0, ts_gems_1.asMutable)(this);
|
|
26
|
-
_this.kind = index_js_2.OpraSchema.
|
|
26
|
+
_this.kind = index_js_2.OpraSchema.MQController.Kind;
|
|
27
27
|
_this.types = _this.node[constants_js_1.kDataTypeMap] = new data_type_map_js_1.DataTypeMap();
|
|
28
28
|
_this.operations = new index_js_1.ResponsiveMap();
|
|
29
29
|
_this.headers = [];
|
|
@@ -36,9 +36,9 @@ exports.RpcController = function (...args) {
|
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
*
|
|
39
|
-
* @class
|
|
39
|
+
* @class MQController
|
|
40
40
|
*/
|
|
41
|
-
class
|
|
41
|
+
class MQControllerClass extends document_element_js_1.DocumentElement {
|
|
42
42
|
findHeader(paramName, location) {
|
|
43
43
|
const paramNameLower = paramName.toLowerCase();
|
|
44
44
|
let prm;
|
|
@@ -51,7 +51,7 @@ class RpcControllerClass extends document_element_js_1.DocumentElement {
|
|
|
51
51
|
if (prm.name instanceof RegExp && prm.name.test(paramName))
|
|
52
52
|
return prm;
|
|
53
53
|
}
|
|
54
|
-
if (this.node.parent && this.node.parent.element instanceof exports.
|
|
54
|
+
if (this.node.parent && this.node.parent.element instanceof exports.MQController) {
|
|
55
55
|
return this.node.parent.element.findHeader(paramName, location);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -59,7 +59,7 @@ class RpcControllerClass extends document_element_js_1.DocumentElement {
|
|
|
59
59
|
*
|
|
60
60
|
*/
|
|
61
61
|
toString() {
|
|
62
|
-
return `[
|
|
62
|
+
return `[MQController ${this.name}]`;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
*
|
|
@@ -93,9 +93,9 @@ class RpcControllerClass extends document_element_js_1.DocumentElement {
|
|
|
93
93
|
*
|
|
94
94
|
*/
|
|
95
95
|
[inspect_util_js_1.nodeInspectCustom]() {
|
|
96
|
-
return `[${inspect_util_js_1.colorFgYellow}
|
|
96
|
+
return `[${inspect_util_js_1.colorFgYellow}MQController${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
exports.
|
|
100
|
-
Object.assign(exports.
|
|
101
|
-
exports.
|
|
99
|
+
exports.MQController.prototype = MQControllerClass.prototype;
|
|
100
|
+
Object.assign(exports.MQController, mq_controller_decorator_js_1.MQControllerDecoratorFactory);
|
|
101
|
+
exports.MQController[constants_js_1.DECORATOR] = mq_controller_decorator_js_1.MQControllerDecoratorFactory;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MQHeader = void 0;
|
|
4
4
|
const objects_1 = require("@jsopen/objects");
|
|
5
5
|
const ts_gems_1 = require("ts-gems");
|
|
6
6
|
const value_js_1 = require("../common/value.js");
|
|
7
7
|
const parse_regexp_util_js_1 = require("../utils/parse-regexp.util.js");
|
|
8
|
-
exports.
|
|
8
|
+
exports.MQHeader = function (owner, initArgs) {
|
|
9
9
|
if (!this)
|
|
10
10
|
throw new TypeError('"this" should be passed to call class constructor');
|
|
11
11
|
value_js_1.Value.call(this, owner, initArgs);
|
|
@@ -25,9 +25,9 @@ exports.RpcHeader = function (owner, initArgs) {
|
|
|
25
25
|
_this.required = initArgs.required;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
|
-
* @class
|
|
28
|
+
* @class MQHeader
|
|
29
29
|
*/
|
|
30
|
-
class
|
|
30
|
+
class MQHeaderClass extends value_js_1.Value {
|
|
31
31
|
toJSON() {
|
|
32
32
|
return (0, objects_1.omitUndefined)({
|
|
33
33
|
...super.toJSON(),
|
|
@@ -37,4 +37,4 @@ class RpcHeaderClass extends value_js_1.Value {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
40
|
+
exports.MQHeader.prototype = MQHeaderClass.prototype;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MQOperationResponse = void 0;
|
|
4
4
|
const objects_1 = require("@jsopen/objects");
|
|
5
5
|
const document_element_js_1 = require("../common/document-element.js");
|
|
6
6
|
const data_type_js_1 = require("../data-type/data-type.js");
|
|
7
7
|
/**
|
|
8
|
-
* @class
|
|
8
|
+
* @class MQOperationResponse
|
|
9
9
|
*/
|
|
10
|
-
class
|
|
10
|
+
class MQOperationResponse extends document_element_js_1.DocumentElement {
|
|
11
11
|
constructor(owner, initArgs) {
|
|
12
12
|
super(owner);
|
|
13
13
|
this.headers = [];
|
|
@@ -63,4 +63,4 @@ class RpcOperationResponse extends document_element_js_1.DocumentElement {
|
|
|
63
63
|
return out;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
exports.
|
|
66
|
+
exports.MQOperationResponse = MQOperationResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MQOperation = void 0;
|
|
4
4
|
const objects_1 = require("@jsopen/objects");
|
|
5
5
|
const ts_gems_1 = require("ts-gems");
|
|
6
6
|
const index_js_1 = require("../../schema/index.js");
|
|
@@ -8,16 +8,16 @@ const data_type_map_js_1 = require("../common/data-type-map.js");
|
|
|
8
8
|
const document_element_js_1 = require("../common/document-element.js");
|
|
9
9
|
const constants_js_1 = require("../constants.js");
|
|
10
10
|
const data_type_js_1 = require("../data-type/data-type.js");
|
|
11
|
-
const
|
|
11
|
+
const mq_operation_decorator_js_1 = require("../decorators/mq-operation.decorator.js");
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* MQOperation
|
|
14
14
|
*/
|
|
15
|
-
exports.
|
|
15
|
+
exports.MQOperation = function (...args) {
|
|
16
16
|
// Decorator
|
|
17
17
|
if (!this) {
|
|
18
18
|
const [payloadType, options] = args;
|
|
19
19
|
const decoratorChain = [];
|
|
20
|
-
return exports.
|
|
20
|
+
return exports.MQOperation[constants_js_1.DECORATOR].call(undefined, decoratorChain, payloadType, options);
|
|
21
21
|
}
|
|
22
22
|
// Constructor
|
|
23
23
|
const [resource, initArgs] = args;
|
|
@@ -44,9 +44,9 @@ exports.RpcOperation = function (...args) {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
|
-
* @class
|
|
47
|
+
* @class MQOperation
|
|
48
48
|
*/
|
|
49
|
-
class
|
|
49
|
+
class MQOperationClass extends document_element_js_1.DocumentElement {
|
|
50
50
|
findHeader(paramName) {
|
|
51
51
|
const paramNameLower = paramName.toLowerCase();
|
|
52
52
|
let prm;
|
|
@@ -62,7 +62,7 @@ class RpcOperationClass extends document_element_js_1.DocumentElement {
|
|
|
62
62
|
}
|
|
63
63
|
toJSON() {
|
|
64
64
|
const out = (0, objects_1.omitUndefined)({
|
|
65
|
-
kind: index_js_1.OpraSchema.
|
|
65
|
+
kind: index_js_1.OpraSchema.MQOperation.Kind,
|
|
66
66
|
description: this.description,
|
|
67
67
|
channel: this.channel,
|
|
68
68
|
payloadType: this.payloadType.name
|
|
@@ -84,5 +84,5 @@ class RpcOperationClass extends document_element_js_1.DocumentElement {
|
|
|
84
84
|
return out;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
87
|
+
exports.MQOperation.prototype = MQOperationClass.prototype;
|
|
88
|
+
exports.MQOperation[constants_js_1.DECORATOR] = mq_operation_decorator_js_1.MQOperationDecoratorFactory;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WSApi = void 0;
|
|
4
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
+
const api_base_js_1 = require("../common/api-base.js");
|
|
6
|
+
/**
|
|
7
|
+
* @class WSApi
|
|
8
|
+
*/
|
|
9
|
+
class WSApi extends api_base_js_1.ApiBase {
|
|
10
|
+
constructor(init) {
|
|
11
|
+
super(init);
|
|
12
|
+
// noinspection JSUnusedGlobalSymbols
|
|
13
|
+
this._controllerReverseMap = new WeakMap();
|
|
14
|
+
this.transport = 'ws';
|
|
15
|
+
this.controllers = new index_js_1.ResponsiveMap();
|
|
16
|
+
}
|
|
17
|
+
findController(arg0) {
|
|
18
|
+
if (typeof arg0 === 'function') {
|
|
19
|
+
/** Check for cached mapping */
|
|
20
|
+
const controller = this._controllerReverseMap.get(arg0);
|
|
21
|
+
if (controller != null)
|
|
22
|
+
return controller;
|
|
23
|
+
/** Lookup for ctor in all controllers */
|
|
24
|
+
for (const c of this.controllers.values()) {
|
|
25
|
+
if (c.ctor === arg0) {
|
|
26
|
+
this._controllerReverseMap.set(arg0, c);
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
this._controllerReverseMap.set(arg0, null);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return this.controllers.get(arg0);
|
|
34
|
+
}
|
|
35
|
+
findOperation(arg0, operationName) {
|
|
36
|
+
const controller = this.findController(arg0);
|
|
37
|
+
return controller?.operations.get(operationName);
|
|
38
|
+
}
|
|
39
|
+
toJSON() {
|
|
40
|
+
const schema = super.toJSON();
|
|
41
|
+
const out = {
|
|
42
|
+
...schema,
|
|
43
|
+
transport: this.transport,
|
|
44
|
+
controllers: {},
|
|
45
|
+
};
|
|
46
|
+
for (const v of this.controllers.values()) {
|
|
47
|
+
out.controllers[v.name] = v.toJSON();
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.WSApi = WSApi;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WSController = void 0;
|
|
4
|
+
const objects_1 = require("@jsopen/objects");
|
|
5
|
+
const ts_gems_1 = require("ts-gems");
|
|
6
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
7
|
+
const index_js_2 = require("../../schema/index.js");
|
|
8
|
+
const data_type_map_js_1 = require("../common/data-type-map.js");
|
|
9
|
+
const document_element_js_1 = require("../common/document-element.js");
|
|
10
|
+
const constants_js_1 = require("../constants.js");
|
|
11
|
+
const ws_controller_decorator_js_1 = require("../decorators/ws-controller.decorator.js");
|
|
12
|
+
const inspect_util_js_1 = require("../utils/inspect.util.js");
|
|
13
|
+
/**
|
|
14
|
+
* WSController
|
|
15
|
+
*/
|
|
16
|
+
exports.WSController = function (...args) {
|
|
17
|
+
// ClassDecorator
|
|
18
|
+
if (!this)
|
|
19
|
+
return exports.WSController[constants_js_1.DECORATOR].apply(undefined, args);
|
|
20
|
+
// Constructor
|
|
21
|
+
const [owner, initArgs] = args;
|
|
22
|
+
document_element_js_1.DocumentElement.call(this, owner);
|
|
23
|
+
if (!constants_js_1.CLASS_NAME_PATTERN.test(initArgs.name))
|
|
24
|
+
throw new TypeError(`Invalid resource name (${initArgs.name})`);
|
|
25
|
+
const _this = (0, ts_gems_1.asMutable)(this);
|
|
26
|
+
_this.kind = index_js_2.OpraSchema.WSController.Kind;
|
|
27
|
+
_this.types = _this.node[constants_js_1.kDataTypeMap] = new data_type_map_js_1.DataTypeMap();
|
|
28
|
+
_this.operations = new index_js_1.ResponsiveMap();
|
|
29
|
+
_this.name = initArgs.name;
|
|
30
|
+
_this.description = initArgs.description;
|
|
31
|
+
_this.instance = initArgs.instance;
|
|
32
|
+
_this.ctor = initArgs.ctor;
|
|
33
|
+
_this._controllerReverseMap = new WeakMap();
|
|
34
|
+
_this._initialize?.(initArgs);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @class WSController
|
|
39
|
+
*/
|
|
40
|
+
class WSControllerClass extends document_element_js_1.DocumentElement {
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
toString() {
|
|
45
|
+
return `[WSController ${this.name}]`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
toJSON() {
|
|
51
|
+
const out = (0, objects_1.omitUndefined)({
|
|
52
|
+
kind: this.kind,
|
|
53
|
+
description: this.description,
|
|
54
|
+
});
|
|
55
|
+
if (this.operations.size) {
|
|
56
|
+
out.operations = {};
|
|
57
|
+
for (const v of this.operations.values()) {
|
|
58
|
+
out.operations[v.name] = v.toJSON();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (this.types.size) {
|
|
62
|
+
out.types = {};
|
|
63
|
+
for (const v of this.types.values()) {
|
|
64
|
+
out.types[v.name] = v.toJSON();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
[inspect_util_js_1.nodeInspectCustom]() {
|
|
73
|
+
return `[${inspect_util_js_1.colorFgYellow}WSController${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.WSController.prototype = WSControllerClass.prototype;
|
|
77
|
+
Object.assign(exports.WSController, ws_controller_decorator_js_1.WSControllerDecoratorFactory);
|
|
78
|
+
exports.WSController[constants_js_1.DECORATOR] = ws_controller_decorator_js_1.WSControllerDecoratorFactory;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WSOperation = void 0;
|
|
4
|
+
const objects_1 = require("@jsopen/objects");
|
|
5
|
+
const ts_gems_1 = require("ts-gems");
|
|
6
|
+
const index_js_1 = require("../../schema/index.js");
|
|
7
|
+
const data_type_map_js_1 = require("../common/data-type-map.js");
|
|
8
|
+
const document_element_js_1 = require("../common/document-element.js");
|
|
9
|
+
const constants_js_1 = require("../constants.js");
|
|
10
|
+
const data_type_js_1 = require("../data-type/data-type.js");
|
|
11
|
+
const ws_operation_decorator_js_1 = require("../decorators/ws-operation.decorator.js");
|
|
12
|
+
/**
|
|
13
|
+
* WSOperation
|
|
14
|
+
*/
|
|
15
|
+
exports.WSOperation = function (...args) {
|
|
16
|
+
// Decorator
|
|
17
|
+
if (!this) {
|
|
18
|
+
const [payloadType, options] = args;
|
|
19
|
+
const decoratorChain = [];
|
|
20
|
+
return exports.WSOperation[constants_js_1.DECORATOR].call(undefined, decoratorChain, payloadType, options);
|
|
21
|
+
}
|
|
22
|
+
// Constructor
|
|
23
|
+
const [resource, initArgs] = args;
|
|
24
|
+
document_element_js_1.DocumentElement.call(this, resource);
|
|
25
|
+
if (!constants_js_1.CLASS_NAME_PATTERN.test(initArgs.name))
|
|
26
|
+
throw new TypeError(`Invalid operation name (${initArgs.name})`);
|
|
27
|
+
const _this = (0, ts_gems_1.asMutable)(this);
|
|
28
|
+
_this.types = _this.node[constants_js_1.kDataTypeMap] = new data_type_map_js_1.DataTypeMap();
|
|
29
|
+
_this.name = initArgs.name;
|
|
30
|
+
_this.description = initArgs.description;
|
|
31
|
+
_this.channel = initArgs.channel;
|
|
32
|
+
if (initArgs?.payloadType) {
|
|
33
|
+
_this.payloadType =
|
|
34
|
+
initArgs?.payloadType instanceof data_type_js_1.DataType
|
|
35
|
+
? initArgs.payloadType
|
|
36
|
+
: _this.owner.node.getDataType(initArgs.payloadType);
|
|
37
|
+
}
|
|
38
|
+
if (initArgs?.keyType) {
|
|
39
|
+
_this.keyType =
|
|
40
|
+
initArgs?.keyType instanceof data_type_js_1.DataType
|
|
41
|
+
? initArgs.keyType
|
|
42
|
+
: _this.owner.node.getDataType(initArgs.keyType);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @class WSOperation
|
|
47
|
+
*/
|
|
48
|
+
class WSOperationClass extends document_element_js_1.DocumentElement {
|
|
49
|
+
toJSON() {
|
|
50
|
+
const out = (0, objects_1.omitUndefined)({
|
|
51
|
+
kind: index_js_1.OpraSchema.WSOperation.Kind,
|
|
52
|
+
description: this.description,
|
|
53
|
+
channel: this.channel,
|
|
54
|
+
payloadType: this.payloadType.name
|
|
55
|
+
? this.payloadType.name
|
|
56
|
+
: this.payloadType.toJSON(),
|
|
57
|
+
});
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.WSOperation.prototype = WSOperationClass.prototype;
|
|
62
|
+
exports.WSOperation[constants_js_1.DECORATOR] = ws_operation_decorator_js_1.WSOperationDecoratorFactory;
|