javonet-nodejs-sdk 2.5.17 → 2.5.18

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 (193) hide show
  1. package/dist/core/handler/AbstractHandler.cjs +23 -6
  2. package/dist/core/handler/ArrayGetItemHandler.cjs +4 -1
  3. package/dist/core/handler/ArrayGetRankHandler.cjs +3 -0
  4. package/dist/core/handler/ArrayGetSizeHandler.cjs +3 -0
  5. package/dist/core/handler/ArrayHandler.cjs +3 -0
  6. package/dist/core/handler/ArraySetItemHandler.cjs +4 -1
  7. package/dist/core/handler/CastingHandler.cjs +3 -1
  8. package/dist/core/handler/ConvertTypeHandler.cjs +4 -4
  9. package/dist/core/handler/CreateClassInstanceHandler.cjs +5 -2
  10. package/dist/core/handler/DestructReferenceHandler.cjs +3 -0
  11. package/dist/core/handler/EnableNamespaceHandler.cjs +3 -0
  12. package/dist/core/handler/EnableTypeHandler.cjs +3 -0
  13. package/dist/core/handler/GetGlobalStaticFieldHandler.cjs +3 -0
  14. package/dist/core/handler/GetInstanceFieldHandler.cjs +3 -0
  15. package/dist/core/handler/GetInstanceMethodAsDelegateHandler.cjs +15 -4
  16. package/dist/core/handler/GetStaticFieldHandler.cjs +4 -0
  17. package/dist/core/handler/GetStaticMethodAsDelegateHandler.cjs +8 -6
  18. package/dist/core/handler/GetTypeHandler.cjs +10 -2
  19. package/dist/core/handler/Handler.cjs +8 -11
  20. package/dist/core/handler/InvokeGlobalFunctionHandler.cjs +3 -0
  21. package/dist/core/handler/InvokeInstanceMethodHandler.cjs +3 -0
  22. package/dist/core/handler/InvokeStaticMethodHandler.cjs +3 -0
  23. package/dist/core/handler/LoadLibraryHandler.cjs +4 -0
  24. package/dist/core/handler/SetGlobalStaticFieldHandler.cjs +3 -0
  25. package/dist/core/handler/SetInstanceFieldHandler.cjs +3 -0
  26. package/dist/core/handler/SetStaticFieldHandler.cjs +3 -0
  27. package/dist/core/handler/ValueHandler.cjs +4 -0
  28. package/dist/core/interpreter/Interpreter.cjs +28 -12
  29. package/dist/core/namespaceCache/NamespaceCache.cjs +12 -0
  30. package/dist/core/protocol/CommandDeserializer.cjs +10 -2
  31. package/dist/core/protocol/CommandSerializer.cjs +24 -4
  32. package/dist/core/protocol/TypeDeserializer.cjs +35 -0
  33. package/dist/core/protocol/TypeSerializer.cjs +51 -7
  34. package/dist/core/receiver/Receiver.cjs +1 -1
  35. package/dist/core/receiver/ReceiverNative.cjs +6 -0
  36. package/dist/core/transmitter/Transmitter.cjs +18 -2
  37. package/dist/core/transmitter/TransmitterWebsocket.cjs +8 -5
  38. package/dist/core/transmitter/TransmitterWebsocketBrowser.cjs +1 -1
  39. package/dist/core/transmitter/TransmitterWrapper.cjs +25 -8
  40. package/dist/core/typeCache/TypeCache.cjs +8 -0
  41. package/dist/core/webSocketClient/WebSocketClient.cjs +22 -12
  42. package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +2 -2
  43. package/dist/sdk/ConfigRuntimeFactory.cjs +60 -55
  44. package/dist/sdk/InvocationContext.cjs +81 -23
  45. package/dist/sdk/Javonet.cjs +14 -33
  46. package/dist/sdk/RuntimeContext.cjs +85 -30
  47. package/dist/sdk/RuntimeFactory.cjs +3 -0
  48. package/dist/sdk/tools/ActivationHelper.cjs +66 -0
  49. package/dist/sdk/tools/JsonResolver.cjs +214 -0
  50. package/dist/types/core/handler/AbstractHandler.d.ts +23 -4
  51. package/dist/types/core/handler/ArrayGetItemHandler.d.ts +8 -1
  52. package/dist/types/core/handler/ArrayGetRankHandler.d.ts +8 -1
  53. package/dist/types/core/handler/ArrayGetSizeHandler.d.ts +8 -1
  54. package/dist/types/core/handler/ArrayHandler.d.ts +8 -1
  55. package/dist/types/core/handler/ArraySetItemHandler.d.ts +8 -1
  56. package/dist/types/core/handler/CastingHandler.d.ts +4 -0
  57. package/dist/types/core/handler/ConvertTypeHandler.d.ts +8 -4
  58. package/dist/types/core/handler/CreateClassInstanceHandler.d.ts +8 -1
  59. package/dist/types/core/handler/DestructReferenceHandler.d.ts +8 -1
  60. package/dist/types/core/handler/EnableNamespaceHandler.d.ts +8 -1
  61. package/dist/types/core/handler/EnableTypeHandler.d.ts +8 -1
  62. package/dist/types/core/handler/GetGlobalStaticFieldHandler.d.ts +8 -1
  63. package/dist/types/core/handler/GetInstanceFieldHandler.d.ts +8 -1
  64. package/dist/types/core/handler/GetStaticFieldHandler.d.ts +9 -1
  65. package/dist/types/core/handler/GetStaticMethodAsDelegateHandler.d.ts +4 -3
  66. package/dist/types/core/handler/GetTypeHandler.d.ts +17 -8
  67. package/dist/types/core/handler/Handler.d.ts +8 -8
  68. package/dist/types/core/handler/InvokeDelegateHandler.d.ts +4 -0
  69. package/dist/types/core/handler/InvokeGlobalFunctionHandler.d.ts +8 -1
  70. package/dist/types/core/handler/InvokeInstanceMethodHandler.d.ts +8 -1
  71. package/dist/types/core/handler/InvokeStaticMethodHandler.d.ts +8 -1
  72. package/dist/types/core/handler/LoadLibraryHandler.d.ts +8 -3
  73. package/dist/types/core/handler/SetGlobalStaticFieldHandler.d.ts +4 -0
  74. package/dist/types/core/handler/SetInstanceFieldHandler.d.ts +8 -1
  75. package/dist/types/core/handler/SetStaticFieldHandler.d.ts +8 -1
  76. package/dist/types/core/handler/ValueHandler.d.ts +9 -1
  77. package/dist/types/core/interpreter/Interpreter.d.ts +11 -10
  78. package/dist/types/core/namespaceCache/NamespaceCache.d.ts +17 -5
  79. package/dist/types/core/protocol/CommandDeserializer.d.ts +10 -3
  80. package/dist/types/core/protocol/CommandSerializer.d.ts +19 -2
  81. package/dist/types/core/protocol/TypeDeserializer.d.ts +46 -11
  82. package/dist/types/core/protocol/TypeSerializer.d.ts +53 -13
  83. package/dist/types/core/receiver/Receiver.d.ts +2 -2
  84. package/dist/types/core/receiver/ReceiverNative.d.ts +8 -2
  85. package/dist/types/core/transmitter/Transmitter.d.ts +20 -4
  86. package/dist/types/core/transmitter/TransmitterWebsocket.d.ts +8 -4
  87. package/dist/types/core/transmitter/TransmitterWebsocketBrowser.d.ts +4 -7
  88. package/dist/types/core/transmitter/TransmitterWrapper.d.ts +12 -3
  89. package/dist/types/core/typeCache/TypeCache.d.ts +15 -5
  90. package/dist/types/core/webSocketClient/WebSocketClient.d.ts +17 -21
  91. package/dist/types/sdk/ConfigRuntimeFactory.d.ts +9 -6
  92. package/dist/types/sdk/InvocationContext.d.ts +38 -6
  93. package/dist/types/sdk/Javonet.d.ts +12 -7
  94. package/dist/types/sdk/RuntimeContext.d.ts +23 -7
  95. package/dist/types/sdk/RuntimeFactory.d.ts +9 -2
  96. package/dist/types/sdk/tools/ActivationHelper.d.ts +20 -0
  97. package/dist/types/sdk/tools/JsonResolver.d.ts +87 -0
  98. package/dist/types/utils/Command.d.ts +18 -14
  99. package/dist/types/utils/CustomError.d.ts +5 -1
  100. package/dist/types/utils/Runtime.d.ts +1 -2
  101. package/dist/types/utils/RuntimeNameHandler.d.ts +6 -2
  102. package/dist/types/utils/Type.d.ts +1 -0
  103. package/dist/types/utils/TypesHandler.d.ts +16 -0
  104. package/dist/types/utils/UtilsConst.d.ts +32 -0
  105. package/dist/types/utils/connectionData/IConnectionData.d.ts +16 -3
  106. package/dist/types/utils/connectionData/InMemoryConnectionData.d.ts +4 -3
  107. package/dist/types/utils/connectionData/WsConnectionData.d.ts +7 -10
  108. package/dist/types/utils/nodejs/connectionData/TcpConnectionData.d.ts +17 -10
  109. package/dist/utils/Command.cjs +9 -9
  110. package/dist/utils/CustomError.cjs +4 -0
  111. package/dist/utils/RuntimeNameHandler.cjs +1 -1
  112. package/dist/utils/Type.cjs +2 -1
  113. package/dist/utils/TypesHandler.cjs +55 -0
  114. package/dist/utils/UtilsConst.cjs +101 -0
  115. package/dist/utils/connectionData/IConnectionData.cjs +9 -0
  116. package/dist/utils/connectionData/InMemoryConnectionData.cjs +10 -0
  117. package/dist/utils/connectionData/WsConnectionData.cjs +4 -0
  118. package/dist/utils/nodejs/connectionData/TcpConnectionData.cjs +33 -3
  119. package/lib/core/delegatesCache/DelegatesCache.js +1 -0
  120. package/lib/core/handler/AbstractHandler.js +27 -9
  121. package/lib/core/handler/ArrayGetItemHandler.js +9 -1
  122. package/lib/core/handler/ArrayGetRankHandler.js +9 -0
  123. package/lib/core/handler/ArrayGetSizeHandler.js +8 -0
  124. package/lib/core/handler/ArrayHandler.js +8 -0
  125. package/lib/core/handler/ArraySetItemHandler.js +11 -1
  126. package/lib/core/handler/CastingHandler.js +8 -1
  127. package/lib/core/handler/ConvertTypeHandler.js +9 -4
  128. package/lib/core/handler/CreateClassInstanceHandler.js +10 -4
  129. package/lib/core/handler/DestructReferenceHandler.js +8 -0
  130. package/lib/core/handler/EnableNamespaceHandler.js +8 -0
  131. package/lib/core/handler/EnableTypeHandler.js +8 -0
  132. package/lib/core/handler/GetGlobalStaticFieldHandler.js +9 -0
  133. package/lib/core/handler/GetInstanceFieldHandler.js +8 -0
  134. package/lib/core/handler/GetInstanceMethodAsDelegateHandler.js +9 -4
  135. package/lib/core/handler/GetStaticFieldHandler.js +9 -0
  136. package/lib/core/handler/GetStaticMethodAsDelegateHandler.js +8 -7
  137. package/lib/core/handler/GetTypeHandler.js +15 -5
  138. package/lib/core/handler/Handler.js +13 -18
  139. package/lib/core/handler/InvokeDelegateHandler.js +5 -0
  140. package/lib/core/handler/InvokeGlobalFunctionHandler.js +11 -1
  141. package/lib/core/handler/InvokeInstanceMethodHandler.js +8 -0
  142. package/lib/core/handler/InvokeStaticMethodHandler.js +8 -0
  143. package/lib/core/handler/LoadLibraryHandler.js +11 -0
  144. package/lib/core/handler/SetGlobalStaticFieldHandler.js +10 -0
  145. package/lib/core/handler/SetInstanceFieldHandler.js +7 -0
  146. package/lib/core/handler/SetStaticFieldHandler.js +8 -0
  147. package/lib/core/handler/ValueHandler.js +9 -0
  148. package/lib/core/interpreter/Interpreter.js +42 -24
  149. package/lib/core/namespaceCache/NamespaceCache.js +14 -0
  150. package/lib/core/protocol/CommandDeserializer.js +11 -2
  151. package/lib/core/protocol/CommandSerializer.js +40 -9
  152. package/lib/core/protocol/TypeDeserializer.js +36 -0
  153. package/lib/core/protocol/TypeSerializer.js +62 -7
  154. package/lib/core/receiver/Receiver.js +3 -2
  155. package/lib/core/receiver/ReceiverNative.js +8 -0
  156. package/lib/core/transmitter/Transmitter.js +18 -1
  157. package/lib/core/transmitter/TransmitterWebsocket.js +12 -5
  158. package/lib/core/transmitter/TransmitterWebsocketBrowser.js +2 -4
  159. package/lib/core/transmitter/TransmitterWrapper.js +27 -6
  160. package/lib/core/typeCache/TypeCache.js +9 -0
  161. package/lib/core/webSocketClient/WebSocketClient.js +33 -30
  162. package/lib/core/webSocketClient/WebSocketClientBrowser.js +5 -6
  163. package/lib/sdk/ConfigRuntimeFactory.js +70 -68
  164. package/lib/sdk/InvocationContext.js +94 -26
  165. package/lib/sdk/Javonet.js +18 -36
  166. package/lib/sdk/RuntimeContext.js +109 -29
  167. package/lib/sdk/RuntimeFactory.js +7 -0
  168. package/lib/sdk/tools/ActivationHelper.js +51 -0
  169. package/lib/sdk/tools/JsonResolver.js +226 -0
  170. package/lib/types.d.ts +57 -0
  171. package/lib/utils/Command.js +14 -9
  172. package/lib/utils/CustomError.js +5 -0
  173. package/lib/utils/Runtime.js +1 -1
  174. package/lib/utils/RuntimeLogger.js +3 -0
  175. package/lib/utils/RuntimeNameHandler.js +6 -1
  176. package/lib/utils/Type.js +2 -1
  177. package/lib/utils/TypesHandler.js +35 -0
  178. package/lib/utils/UtilsConst.js +88 -0
  179. package/lib/utils/connectionData/IConnectionData.js +14 -0
  180. package/lib/utils/connectionData/InMemoryConnectionData.js +15 -0
  181. package/lib/utils/connectionData/WsConnectionData.js +9 -0
  182. package/lib/utils/nodejs/connectionData/TcpConnectionData.js +35 -5
  183. package/package.json +4 -3
  184. package/dist/sdk/tools/browser/ConfigSourceResolver.cjs +0 -153
  185. package/dist/sdk/tools/nodejs/JsonFileResolver.cjs +0 -120
  186. package/dist/types/sdk/tools/browser/ConfigSourceResolver.d.ts +0 -46
  187. package/dist/types/sdk/tools/nodejs/JsonFileResolver.d.ts +0 -13
  188. package/dist/types/utils/nodejs/TypesConverter.d.ts +0 -48
  189. package/dist/utils/nodejs/TypesConverter.cjs +0 -102
  190. package/lib/declarations.d.ts +0 -35
  191. package/lib/sdk/tools/browser/ConfigSourceResolver.js +0 -146
  192. package/lib/sdk/tools/nodejs/JsonFileResolver.js +0 -106
  193. package/lib/utils/nodejs/TypesConverter.js +0 -91
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var JsonFileResolver_exports = {};
20
- __export(JsonFileResolver_exports, {
21
- JsonFileResolver: () => JsonFileResolver
22
- });
23
- module.exports = __toCommonJS(JsonFileResolver_exports);
24
- var import_Runtime = require("../../../utils/Runtime.cjs");
25
- const import_meta = {};
26
- const requireDynamic = (0, import_Runtime.getRequire)(import_meta.url);
27
- let fsExtra = null;
28
- function hasOwnProperty(obj, key) {
29
- return Object.prototype.hasOwnProperty.call(obj, key);
30
- }
31
- class JsonFileResolver {
32
- constructor(path) {
33
- this.path = path;
34
- try {
35
- if (!fsExtra) {
36
- fsExtra = requireDynamic("fs-extra");
37
- }
38
- const data = fsExtra.readFileSync(this.path, "utf8");
39
- this.jsonObject = JSON.parse(data);
40
- } catch (err) {
41
- throw err;
42
- }
43
- }
44
- getLicenseKey() {
45
- if (!hasOwnProperty(this.jsonObject, "licenseKey")) {
46
- throw new Error(
47
- "License key not found in configuration file. Please check your configuration file."
48
- );
49
- }
50
- return this.jsonObject.licenseKey;
51
- }
52
- getRuntimes() {
53
- return this.jsonObject.runtimes;
54
- }
55
- getRuntime(runtimeName, configName) {
56
- const runtimes = this.getRuntimes();
57
- if (hasOwnProperty(runtimes, runtimeName)) {
58
- const runtime = runtimes[runtimeName];
59
- if (Array.isArray(runtime)) {
60
- for (let item of runtime) {
61
- if (item.name === configName) {
62
- return item;
63
- }
64
- }
65
- } else if (runtime.name === configName) {
66
- return runtime;
67
- }
68
- }
69
- throw new Error(
70
- `Runtime config ${configName} not found in configuration file for runtime ${runtimeName}. Please check your configuration file.`
71
- );
72
- }
73
- getChannel(runtimeName, configName) {
74
- const runtime = this.getRuntime(runtimeName, configName);
75
- if (!hasOwnProperty(runtime, "channel")) {
76
- throw new Error(
77
- `Channel key not found in configuration file for config ${configName}. Please check your configuration file.`
78
- );
79
- }
80
- return runtime.channel;
81
- }
82
- getChannelType(runtimeName, configName) {
83
- const channel = this.getChannel(runtimeName, configName);
84
- if (!hasOwnProperty(channel, "type")) {
85
- throw new Error(
86
- `Channel type not found in configuration file for config ${configName}. Please check your configuration file.`
87
- );
88
- }
89
- return channel.type;
90
- }
91
- getChannelHost(runtimeName, configName) {
92
- const channel = this.getChannel(runtimeName, configName);
93
- if (!hasOwnProperty(channel, "host")) {
94
- throw new Error(
95
- `Channel host not found in configuration file for config ${configName}. Please check your configuration file.`
96
- );
97
- }
98
- return channel.host;
99
- }
100
- getChannelPort(runtimeName, configName) {
101
- const channel = this.getChannel(runtimeName, configName);
102
- if (!hasOwnProperty(channel, "port")) {
103
- throw new Error(
104
- `Channel port not found in configuration file for config ${configName}. Please check your configuration file.`
105
- );
106
- }
107
- return channel.port;
108
- }
109
- getModules(runtimeName, configName) {
110
- const runtime = this.getRuntime(runtimeName, configName);
111
- if (hasOwnProperty(runtime, "modules")) {
112
- return runtime.modules;
113
- }
114
- return "";
115
- }
116
- }
117
- // Annotate the CommonJS export names for ESM import in node:
118
- 0 && (module.exports = {
119
- JsonFileResolver
120
- });
@@ -1,46 +0,0 @@
1
- export class ConfigSourceResolver {
2
- /**
3
- *
4
- * @param {object | string} configSource
5
- */
6
- constructor(configSource: object | string);
7
- jsonObject: any;
8
- getLicenseKey(): any;
9
- getRuntimes(): any;
10
- /**
11
- * @param {string} runtimeName
12
- * @param {string} configName
13
- * @returns {any}
14
- */
15
- getRuntime(runtimeName: string, configName: string): any;
16
- /**
17
- * @param {string} runtimeName
18
- * @param {string} configName
19
- * @returns {any}
20
- */
21
- getChannel(runtimeName: string, configName: string): any;
22
- /**
23
- * @param {string} runtimeName
24
- * @param {string} configName
25
- * @returns {any}
26
- */
27
- getChannelType(runtimeName: string, configName: string): any;
28
- /**
29
- * @param {string} runtimeName
30
- * @param {string} configName
31
- * @returns {any}
32
- */
33
- getChannelHost(runtimeName: string, configName: string): any;
34
- /**
35
- * @param {string} runtimeName
36
- * @param {string} configName
37
- * @returns {any}
38
- */
39
- getChannelPort(runtimeName: string, configName: string): any;
40
- /**
41
- * @param {string} runtimeName
42
- * @param {string} configName
43
- * @returns {any}
44
- */
45
- getModules(runtimeName: string, configName: string): any;
46
- }
@@ -1,13 +0,0 @@
1
- export class JsonFileResolver {
2
- constructor(path: any);
3
- path: any;
4
- jsonObject: any;
5
- getLicenseKey(): any;
6
- getRuntimes(): any;
7
- getRuntime(runtimeName: any, configName: any): any;
8
- getChannel(runtimeName: any, configName: any): any;
9
- getChannelType(runtimeName: any, configName: any): any;
10
- getChannelHost(runtimeName: any, configName: any): any;
11
- getChannelPort(runtimeName: any, configName: any): any;
12
- getModules(runtimeName: any, configName: any): any;
13
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * ConvertTypeHandler class handles the conversion of JType to Type.
3
- */
4
- export class ConvertTypeHandler {
5
- /**
6
- * Minimum required parameters count for the command.
7
- * @type {number}
8
- */
9
- requiredParametersCount: number;
10
- /**
11
- * Processes the given command to convert JType to Type.
12
- * @param {Object} command - The command to process.
13
- * @returns {any} The converted type.
14
- */
15
- process(command: Object): any;
16
- /**
17
- * Validates the command to ensure it has enough parameters.
18
- * @param {Object} command - The command to validate.
19
- */
20
- validateCommand(command: Object): void;
21
- }
22
- /**
23
- * TypesConverter class provides utilities for converting between types.
24
- */
25
- export class TypesConverter {
26
- /**
27
- * Converts a JavaScript type to a JType equivalent.
28
- * @param {Function} type - The JavaScript type.
29
- * @returns {number} The corresponding JType.
30
- */
31
- static convertTypeToJType(type: Function): number;
32
- /**
33
- * Converts a JType to a JavaScript type equivalent.
34
- * @param {number} type - The JType to convert.
35
- * @returns {Function} The corresponding JavaScript type.
36
- */
37
- static convertJTypeToType(type: number): Function;
38
- }
39
- /**
40
- * Enum for JType mappings.
41
- */
42
- export type JType = number;
43
- export namespace JType {
44
- let Boolean: number;
45
- let Float: number;
46
- let String: number;
47
- let Null: number;
48
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var TypesConverter_exports = {};
20
- __export(TypesConverter_exports, {
21
- ConvertTypeHandler: () => ConvertTypeHandler,
22
- JType: () => JType,
23
- TypesConverter: () => TypesConverter
24
- });
25
- module.exports = __toCommonJS(TypesConverter_exports);
26
- class ConvertTypeHandler {
27
- constructor() {
28
- this.requiredParametersCount = 1;
29
- }
30
- /**
31
- * Processes the given command to convert JType to Type.
32
- * @param {Object} command - The command to process.
33
- * @returns {any} The converted type.
34
- */
35
- process(command) {
36
- this.validateCommand(command);
37
- return TypesConverter.convertJTypeToType(command.payload[0]);
38
- }
39
- /**
40
- * Validates the command to ensure it has enough parameters.
41
- * @param {Object} command - The command to validate.
42
- */
43
- validateCommand(command) {
44
- if (command.payload.length < this.requiredParametersCount) {
45
- throw new Error("ConvertTypeHandler parameters mismatch");
46
- }
47
- }
48
- }
49
- class TypesConverter {
50
- /**
51
- * Converts a JavaScript type to a JType equivalent.
52
- * @param {Function} type - The JavaScript type.
53
- * @returns {number} The corresponding JType.
54
- */
55
- static convertTypeToJType(type) {
56
- switch (type) {
57
- case Boolean:
58
- return JType.Boolean;
59
- case Number:
60
- return JType.Float;
61
- // Assuming Number maps to Float
62
- case String:
63
- return JType.String;
64
- case Object:
65
- return JType.Null;
66
- // Assuming Object maps to Null
67
- default:
68
- return JType.Null;
69
- }
70
- }
71
- /**
72
- * Converts a JType to a JavaScript type equivalent.
73
- * @param {number} type - The JType to convert.
74
- * @returns {Function} The corresponding JavaScript type.
75
- */
76
- static convertJTypeToType(type) {
77
- switch (type) {
78
- case JType.Boolean:
79
- return Boolean;
80
- case JType.Float:
81
- return Number;
82
- case JType.String:
83
- return String;
84
- case JType.Null:
85
- return null;
86
- default:
87
- return null;
88
- }
89
- }
90
- }
91
- const JType = {
92
- Boolean: 1,
93
- Float: 2,
94
- String: 3,
95
- Null: 4
96
- };
97
- // Annotate the CommonJS export names for ESM import in node:
98
- 0 && (module.exports = {
99
- ConvertTypeHandler,
100
- JType,
101
- TypesConverter
102
- });
@@ -1,35 +0,0 @@
1
- declare enum RuntimeName {
2
- Clr = 0,
3
- Go = 1,
4
- Jvm = 2,
5
- Netcore = 3,
6
- Perl = 4,
7
- Python = 5,
8
- Ruby = 6,
9
- Nodejs = 7,
10
- Cpp = 8,
11
- }
12
-
13
- interface RuntimeChannel {
14
- type: 'inMemory' | 'tcp' | 'webSocket'
15
- host?: string
16
- port?: number
17
- }
18
-
19
- interface Runtime {
20
- name: string
21
- customOptions: string
22
- modules: string
23
- channel: RuntimeChannel
24
- runtimeName: RuntimeName
25
- }
26
-
27
- type Runtimes = {
28
- [Key in keyof typeof RuntimeName]: Runtime[]
29
- }
30
-
31
- export interface ConfigSource {
32
- [key: string]: any
33
- licenseKey: string
34
- runtimes: Partial<Runtimes>
35
- }
@@ -1,146 +0,0 @@
1
- /**
2
- *
3
- * @param {object} obj
4
- * @param {string} key
5
- * @returns
6
- */
7
- function hasOwnProperty(obj, key) {
8
- return Object.prototype.hasOwnProperty.call(obj, key)
9
- }
10
-
11
- class ConfigSourceResolver {
12
- /**
13
- *
14
- * @param {object | string} configSource
15
- */
16
- constructor(configSource) {
17
- if (typeof configSource === 'string') {
18
- try {
19
- // Parse string as JSON
20
- this.jsonObject = JSON.parse(configSource)
21
- } catch (err) {
22
- throw new Error(
23
- `Failed to parse configSource as JSON: ${err instanceof Error ? err.message : 'Unknown error'}`
24
- )
25
- }
26
- } else if (configSource && typeof configSource === 'object') {
27
- // It's already an object
28
- this.jsonObject = configSource
29
- } else {
30
- throw new Error('configSource must be a JSON object or JSON string')
31
- }
32
- }
33
-
34
- getLicenseKey() {
35
- if (!hasOwnProperty(this.jsonObject, 'licenseKey')) {
36
- throw new Error(
37
- 'License key not found in configuration file. Please check your configuration file.'
38
- )
39
- }
40
- return this.jsonObject.licenseKey
41
- }
42
-
43
- getRuntimes() {
44
- return this.jsonObject.runtimes
45
- }
46
-
47
- /**
48
- * @param {string} runtimeName
49
- * @param {string} configName
50
- * @returns {any}
51
- */
52
- getRuntime(runtimeName, configName) {
53
- const runtimes = this.getRuntimes()
54
- if (hasOwnProperty(runtimes, runtimeName)) {
55
- // @ts-ignore
56
- const runtime = runtimes[runtimeName]
57
- if (Array.isArray(runtime)) {
58
- for (let item of runtime) {
59
- if (item.name === configName) {
60
- return item
61
- }
62
- }
63
- } else if (runtime?.name === configName) {
64
- return runtime
65
- }
66
- }
67
- throw new Error(
68
- `Runtime config ${configName} not found in configuration file for runtime ${runtimeName}. Please check your configuration file.`
69
- )
70
- }
71
-
72
- /**
73
- * @param {string} runtimeName
74
- * @param {string} configName
75
- * @returns {any}
76
- */
77
- getChannel(runtimeName, configName) {
78
- const runtime = this.getRuntime(runtimeName, configName)
79
- if (!hasOwnProperty(runtime, 'channel')) {
80
- throw new Error(
81
- `Channel key not found in configuration file for config ${configName}. Please check your configuration file.`
82
- )
83
- }
84
- return runtime.channel
85
- }
86
-
87
- /**
88
- * @param {string} runtimeName
89
- * @param {string} configName
90
- * @returns {any}
91
- */
92
- getChannelType(runtimeName, configName) {
93
- const channel = this.getChannel(runtimeName, configName)
94
- if (!hasOwnProperty(channel, 'type')) {
95
- throw new Error(
96
- `Channel type not found in configuration file for config ${configName}. Please check your configuration file.`
97
- )
98
- }
99
- return channel.type
100
- }
101
-
102
- /**
103
- * @param {string} runtimeName
104
- * @param {string} configName
105
- * @returns {any}
106
- */
107
- getChannelHost(runtimeName, configName) {
108
- const channel = this.getChannel(runtimeName, configName)
109
- if (!hasOwnProperty(channel, 'host')) {
110
- throw new Error(
111
- `Channel host not found in configuration file for config ${configName}. Please check your configuration file.`
112
- )
113
- }
114
- return channel.host
115
- }
116
-
117
- /**
118
- * @param {string} runtimeName
119
- * @param {string} configName
120
- * @returns {any}
121
- */
122
- getChannelPort(runtimeName, configName) {
123
- const channel = this.getChannel(runtimeName, configName)
124
- if (!hasOwnProperty(channel, 'port')) {
125
- throw new Error(
126
- `Channel port not found in configuration file for config ${configName}. Please check your configuration file.`
127
- )
128
- }
129
- return channel.port
130
- }
131
-
132
- /**
133
- * @param {string} runtimeName
134
- * @param {string} configName
135
- * @returns {any}
136
- */
137
- getModules(runtimeName, configName) {
138
- const runtime = this.getRuntime(runtimeName, configName)
139
- if (hasOwnProperty(runtime, 'modules')) {
140
- return runtime.modules
141
- }
142
- return ''
143
- }
144
- }
145
-
146
- export { ConfigSourceResolver }
@@ -1,106 +0,0 @@
1
- import { isNodejsRuntime, getRequire } from '../../../utils/Runtime.js'
2
-
3
- const requireDynamic = getRequire(import.meta.url)
4
-
5
- let fsExtra = null
6
-
7
- function hasOwnProperty(obj, key) {
8
- return Object.prototype.hasOwnProperty.call(obj, key)
9
- }
10
-
11
- export class JsonFileResolver {
12
- constructor(path) {
13
- this.path = path
14
- try {
15
- if (!fsExtra) {
16
- fsExtra = requireDynamic('fs-extra')
17
- }
18
- const data = fsExtra.readFileSync(this.path, 'utf8')
19
- this.jsonObject = JSON.parse(data)
20
- // eslint-disable-next-line no-unused-vars
21
- } catch (err) {
22
- throw err
23
- }
24
- }
25
-
26
- getLicenseKey() {
27
- if (!hasOwnProperty(this.jsonObject, 'licenseKey')) {
28
- throw new Error(
29
- 'License key not found in configuration file. Please check your configuration file.'
30
- )
31
- }
32
- return this.jsonObject.licenseKey
33
- }
34
-
35
- getRuntimes() {
36
- return this.jsonObject.runtimes
37
- }
38
-
39
- getRuntime(runtimeName, configName) {
40
- const runtimes = this.getRuntimes()
41
- if (hasOwnProperty(runtimes, runtimeName)) {
42
- const runtime = runtimes[runtimeName]
43
- if (Array.isArray(runtime)) {
44
- for (let item of runtime) {
45
- if (item.name === configName) {
46
- return item
47
- }
48
- }
49
- } else if (runtime.name === configName) {
50
- return runtime
51
- }
52
- }
53
- throw new Error(
54
- `Runtime config ${configName} not found in configuration file for runtime ${runtimeName}. Please check your configuration file.`
55
- )
56
- }
57
-
58
- getChannel(runtimeName, configName) {
59
- const runtime = this.getRuntime(runtimeName, configName)
60
- if (!hasOwnProperty(runtime, 'channel')) {
61
- throw new Error(
62
- `Channel key not found in configuration file for config ${configName}. Please check your configuration file.`
63
- )
64
- }
65
- return runtime.channel
66
- }
67
-
68
- getChannelType(runtimeName, configName) {
69
- const channel = this.getChannel(runtimeName, configName)
70
- if (!hasOwnProperty(channel, 'type')) {
71
- throw new Error(
72
- `Channel type not found in configuration file for config ${configName}. Please check your configuration file.`
73
- )
74
- }
75
- return channel.type
76
- }
77
-
78
- getChannelHost(runtimeName, configName) {
79
- const channel = this.getChannel(runtimeName, configName)
80
- if (!hasOwnProperty(channel, 'host')) {
81
- throw new Error(
82
- `Channel host not found in configuration file for config ${configName}. Please check your configuration file.`
83
- )
84
- }
85
- return channel.host
86
- }
87
-
88
- getChannelPort(runtimeName, configName) {
89
- const channel = this.getChannel(runtimeName, configName)
90
- if (!hasOwnProperty(channel, 'port')) {
91
- throw new Error(
92
- `Channel port not found in configuration file for config ${configName}. Please check your configuration file.`
93
- )
94
- }
95
- return channel.port
96
- }
97
-
98
- getModules(runtimeName, configName) {
99
- const runtime = this.getRuntime(runtimeName, configName)
100
- if (hasOwnProperty(runtime, 'modules')) {
101
- return runtime.modules
102
- }
103
- return ''
104
- }
105
- }
106
-