@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.
Files changed (109) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +11 -4
  4. package/cjs/document/constants.js +3 -1
  5. package/cjs/document/data-type/enum-type.js +4 -0
  6. package/cjs/document/decorators/{rpc-controller.decorator.js → mq-controller.decorator.js} +8 -8
  7. package/cjs/document/decorators/{rpc-operation.decorator.js → mq-operation.decorator.js} +6 -6
  8. package/cjs/document/decorators/ws-controller.decorator.js +51 -0
  9. package/cjs/document/decorators/ws-operation.decorator.js +43 -0
  10. package/cjs/document/factory/api-document.factory.js +3 -3
  11. package/cjs/document/factory/{rpc-api.factory.js → mq-api.factory.js} +28 -28
  12. package/cjs/document/factory/ws-api.factory.js +123 -0
  13. package/cjs/document/index.js +15 -8
  14. package/cjs/document/{rpc/rpc-api.js → mq/mq-api.js} +5 -5
  15. package/cjs/document/{rpc/rpc-controller.js → mq/mq-controller.js} +14 -14
  16. package/cjs/document/{rpc/rpc-header.js → mq/mq-header.js} +5 -5
  17. package/cjs/document/{rpc/rpc-operation-response.js → mq/mq-operation-response.js} +4 -4
  18. package/cjs/document/{rpc/rpc-operation.js → mq/mq-operation.js} +10 -10
  19. package/cjs/document/ws/ws-api.js +52 -0
  20. package/cjs/document/ws/ws-controller.js +78 -0
  21. package/cjs/document/ws/ws-operation.js +62 -0
  22. package/cjs/filter/antlr/OpraFilterLexer.js +361 -211
  23. package/cjs/filter/antlr/OpraFilterParser.js +174 -92
  24. package/cjs/schema/http/http-api.interface.js +2 -0
  25. package/cjs/schema/mq/mq-api.interface.js +2 -0
  26. package/cjs/schema/mq/mq-controller.interface.js +11 -0
  27. package/cjs/schema/mq/mq-header.interface.js +2 -0
  28. package/cjs/schema/mq/mq-operation.interface.js +7 -0
  29. package/cjs/schema/opra-schema.js +9 -3
  30. package/cjs/schema/ws/ws-api.interface.js +2 -0
  31. package/cjs/schema/ws/ws-controller.interface.js +11 -0
  32. package/cjs/schema/ws/ws-operation.interface.js +7 -0
  33. package/esm/document/api-document.js +11 -4
  34. package/esm/document/constants.js +2 -0
  35. package/esm/document/data-type/enum-type.js +4 -0
  36. package/esm/document/decorators/{rpc-controller.decorator.js → mq-controller.decorator.js} +8 -8
  37. package/esm/document/decorators/{rpc-operation.decorator.js → mq-operation.decorator.js} +6 -6
  38. package/esm/document/decorators/ws-controller.decorator.js +48 -0
  39. package/esm/document/decorators/ws-operation.decorator.js +40 -0
  40. package/esm/document/factory/api-document.factory.js +3 -3
  41. package/esm/document/factory/{rpc-api.factory.js → mq-api.factory.js} +27 -27
  42. package/esm/document/factory/ws-api.factory.js +119 -0
  43. package/esm/document/index.js +15 -8
  44. package/esm/document/{rpc/rpc-api.js → mq/mq-api.js} +3 -3
  45. package/esm/document/{rpc/rpc-controller.js → mq/mq-controller.js} +13 -13
  46. package/esm/document/{rpc/rpc-header.js → mq/mq-header.js} +4 -4
  47. package/esm/document/{rpc/rpc-operation-response.js → mq/mq-operation-response.js} +2 -2
  48. package/esm/document/{rpc/rpc-operation.js → mq/mq-operation.js} +9 -9
  49. package/esm/document/ws/ws-api.js +48 -0
  50. package/esm/document/ws/ws-controller.js +75 -0
  51. package/esm/document/ws/ws-operation.js +59 -0
  52. package/esm/filter/antlr/OpraFilterLexer.js +362 -212
  53. package/esm/filter/antlr/OpraFilterListener.js +1 -1
  54. package/esm/filter/antlr/OpraFilterParser.js +174 -92
  55. package/esm/schema/http/http-api.interface.js +1 -0
  56. package/esm/schema/mq/mq-api.interface.js +1 -0
  57. package/esm/schema/mq/mq-controller.interface.js +8 -0
  58. package/esm/schema/mq/mq-header.interface.js +1 -0
  59. package/esm/schema/mq/mq-operation.interface.js +4 -0
  60. package/esm/schema/opra-schema.js +9 -3
  61. package/esm/schema/ws/ws-api.interface.js +1 -0
  62. package/esm/schema/ws/ws-controller.interface.js +8 -0
  63. package/esm/schema/ws/ws-operation.interface.js +4 -0
  64. package/package.json +6 -6
  65. package/types/document/api-document.d.ts +5 -3
  66. package/types/document/constants.d.ts +2 -0
  67. package/types/document/decorators/mq-controller.decorator.d.ts +20 -0
  68. package/types/document/decorators/mq-operation.decorator.d.ts +32 -0
  69. package/types/document/decorators/ws-controller.decorator.d.ts +20 -0
  70. package/types/document/decorators/ws-operation.decorator.d.ts +24 -0
  71. package/types/document/factory/api-document.factory.d.ts +3 -2
  72. package/types/document/factory/mq-api.factory.d.ts +40 -0
  73. package/types/document/factory/ws-api.factory.d.ts +31 -0
  74. package/types/document/index.d.ts +20 -11
  75. package/types/document/mq/mq-api.d.ts +27 -0
  76. package/types/document/mq/mq-controller.d.ts +83 -0
  77. package/types/document/{rpc/rpc-header.d.ts → mq/mq-header.d.ts} +15 -15
  78. package/types/document/{rpc/rpc-operation-response.d.ts → mq/mq-operation-response.d.ts} +13 -13
  79. package/types/document/{rpc/rpc-operation.d.ts → mq/mq-operation.d.ts} +27 -27
  80. package/types/document/ws/ws-api.d.ts +26 -0
  81. package/types/document/ws/ws-controller.d.ts +79 -0
  82. package/types/document/ws/ws-operation.d.ts +70 -0
  83. package/types/filter/antlr/OpraFilterLexer.d.ts +1 -1
  84. package/types/filter/antlr/OpraFilterListener.d.ts +28 -28
  85. package/types/filter/antlr/OpraFilterVisitor.d.ts +27 -27
  86. package/types/schema/api-document.interface.d.ts +4 -46
  87. package/types/schema/api.interface.d.ts +13 -0
  88. package/types/schema/http/http-api.interface.d.ts +12 -0
  89. package/types/schema/mq/mq-api.interface.d.ts +15 -0
  90. package/types/schema/mq/mq-controller.interface.d.ts +22 -0
  91. package/types/schema/{rpc/rpc-header.interface.d.ts → mq/mq-header.interface.d.ts} +2 -2
  92. package/types/schema/{rpc/rpc-operation.interface.d.ts → mq/mq-operation.interface.d.ts} +11 -11
  93. package/types/schema/opra-schema.d.ts +9 -3
  94. package/types/schema/types.d.ts +11 -0
  95. package/types/schema/ws/ws-api.interface.d.ts +11 -0
  96. package/types/schema/ws/ws-controller.interface.d.ts +20 -0
  97. package/types/schema/ws/ws-operation.interface.d.ts +15 -0
  98. package/cjs/schema/rpc/rpc-controller.interface.js +0 -11
  99. package/cjs/schema/rpc/rpc-operation.interface.js +0 -7
  100. package/esm/schema/rpc/rpc-controller.interface.js +0 -8
  101. package/esm/schema/rpc/rpc-operation.interface.js +0 -4
  102. package/types/document/decorators/rpc-controller.decorator.d.ts +0 -20
  103. package/types/document/decorators/rpc-operation.decorator.d.ts +0 -32
  104. package/types/document/factory/rpc-api.factory.d.ts +0 -40
  105. package/types/document/rpc/rpc-api.d.ts +0 -27
  106. package/types/document/rpc/rpc-controller.d.ts +0 -83
  107. package/types/schema/rpc/rpc-controller.interface.d.ts +0 -22
  108. /package/cjs/schema/{rpc/rpc-header.interface.js → api.interface.js} +0 -0
  109. /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.RpcController = void 0;
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 rpc_controller_decorator_js_1 = require("../decorators/rpc-controller.decorator.js");
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
- * RpcController
14
+ * MQController
15
15
  */
16
- exports.RpcController = function (...args) {
16
+ exports.MQController = function (...args) {
17
17
  // ClassDecorator
18
18
  if (!this)
19
- return exports.RpcController[constants_js_1.DECORATOR].apply(undefined, args);
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.RpcController.Kind;
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 RpcController
39
+ * @class MQController
40
40
  */
41
- class RpcControllerClass extends document_element_js_1.DocumentElement {
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.RpcController) {
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 `[RpcController ${this.name}]`;
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}RpcController${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
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.RpcController.prototype = RpcControllerClass.prototype;
100
- Object.assign(exports.RpcController, rpc_controller_decorator_js_1.RpcControllerDecoratorFactory);
101
- exports.RpcController[constants_js_1.DECORATOR] = rpc_controller_decorator_js_1.RpcControllerDecoratorFactory;
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.RpcHeader = void 0;
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.RpcHeader = function (owner, initArgs) {
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 RpcHeader
28
+ * @class MQHeader
29
29
  */
30
- class RpcHeaderClass extends value_js_1.Value {
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.RpcHeader.prototype = RpcHeaderClass.prototype;
40
+ exports.MQHeader.prototype = MQHeaderClass.prototype;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RpcOperationResponse = void 0;
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 RpcOperationResponse
8
+ * @class MQOperationResponse
9
9
  */
10
- class RpcOperationResponse extends document_element_js_1.DocumentElement {
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.RpcOperationResponse = RpcOperationResponse;
66
+ exports.MQOperationResponse = MQOperationResponse;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RpcOperation = void 0;
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 rpc_operation_decorator_js_1 = require("../decorators/rpc-operation.decorator.js");
11
+ const mq_operation_decorator_js_1 = require("../decorators/mq-operation.decorator.js");
12
12
  /**
13
- * RpcOperation
13
+ * MQOperation
14
14
  */
15
- exports.RpcOperation = function (...args) {
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.RpcOperation[constants_js_1.DECORATOR].call(undefined, decoratorChain, payloadType, options);
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 RpcOperation
47
+ * @class MQOperation
48
48
  */
49
- class RpcOperationClass extends document_element_js_1.DocumentElement {
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.RpcOperation.Kind,
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.RpcOperation.prototype = RpcOperationClass.prototype;
88
- exports.RpcOperation[constants_js_1.DECORATOR] = rpc_operation_decorator_js_1.RpcOperationDecoratorFactory;
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;