javonet-nodejs-sdk 2.5.16 → 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 (204) hide show
  1. package/dist/core/delegatesCache/DelegatesCache.cjs +1 -5
  2. package/dist/core/handler/AbstractHandler.cjs +24 -9
  3. package/dist/core/handler/ArrayGetItemHandler.cjs +5 -4
  4. package/dist/core/handler/ArrayGetRankHandler.cjs +4 -3
  5. package/dist/core/handler/ArrayGetSizeHandler.cjs +4 -3
  6. package/dist/core/handler/ArrayHandler.cjs +3 -0
  7. package/dist/core/handler/ArraySetItemHandler.cjs +5 -4
  8. package/dist/core/handler/CastingHandler.cjs +3 -1
  9. package/dist/core/handler/ConvertTypeHandler.cjs +4 -4
  10. package/dist/core/handler/CreateClassInstanceHandler.cjs +6 -5
  11. package/dist/core/handler/DestructReferenceHandler.cjs +3 -0
  12. package/dist/core/handler/EnableNamespaceHandler.cjs +3 -0
  13. package/dist/core/handler/EnableTypeHandler.cjs +4 -3
  14. package/dist/core/handler/GetGlobalStaticFieldHandler.cjs +4 -3
  15. package/dist/core/handler/GetInstanceFieldHandler.cjs +4 -3
  16. package/dist/core/handler/GetInstanceMethodAsDelegateHandler.cjs +15 -4
  17. package/dist/core/handler/GetStaticFieldHandler.cjs +5 -3
  18. package/dist/core/handler/GetStaticMethodAsDelegateHandler.cjs +10 -10
  19. package/dist/core/handler/GetTypeHandler.cjs +10 -2
  20. package/dist/core/handler/Handler.cjs +8 -11
  21. package/dist/core/handler/InvokeGlobalFunctionHandler.cjs +4 -3
  22. package/dist/core/handler/InvokeInstanceMethodHandler.cjs +4 -3
  23. package/dist/core/handler/InvokeStaticMethodHandler.cjs +4 -3
  24. package/dist/core/handler/LoadLibraryHandler.cjs +11 -10
  25. package/dist/core/handler/PassDelegateHandler.cjs +2 -4
  26. package/dist/core/handler/SetGlobalStaticFieldHandler.cjs +4 -3
  27. package/dist/core/handler/SetInstanceFieldHandler.cjs +4 -3
  28. package/dist/core/handler/SetStaticFieldHandler.cjs +4 -3
  29. package/dist/core/handler/ValueHandler.cjs +4 -0
  30. package/dist/core/interpreter/Interpreter.cjs +29 -17
  31. package/dist/core/namespaceCache/NamespaceCache.cjs +19 -10
  32. package/dist/core/protocol/CommandDeserializer.cjs +10 -2
  33. package/dist/core/protocol/CommandSerializer.cjs +24 -4
  34. package/dist/core/protocol/TypeDeserializer.cjs +35 -0
  35. package/dist/core/protocol/TypeSerializer.cjs +51 -7
  36. package/dist/core/receiver/Receiver.cjs +3 -5
  37. package/dist/core/receiver/ReceiverNative.cjs +6 -0
  38. package/dist/core/transmitter/Transmitter.cjs +19 -5
  39. package/dist/core/transmitter/TransmitterWebsocket.cjs +8 -5
  40. package/dist/core/transmitter/TransmitterWebsocketBrowser.cjs +1 -1
  41. package/dist/core/transmitter/TransmitterWrapper.cjs +25 -8
  42. package/dist/core/typeCache/TypeCache.cjs +15 -10
  43. package/dist/core/webSocketClient/WebSocketClient.cjs +22 -12
  44. package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +2 -2
  45. package/dist/sdk/ConfigRuntimeFactory.cjs +92 -98
  46. package/dist/sdk/InvocationContext.cjs +229 -203
  47. package/dist/sdk/Javonet.cjs +14 -33
  48. package/dist/sdk/RuntimeContext.cjs +138 -99
  49. package/dist/sdk/RuntimeFactory.cjs +3 -0
  50. package/dist/sdk/tools/ActivationHelper.cjs +66 -0
  51. package/dist/sdk/tools/JsonResolver.cjs +214 -0
  52. package/dist/types/core/handler/AbstractHandler.d.ts +23 -4
  53. package/dist/types/core/handler/ArrayGetItemHandler.d.ts +8 -1
  54. package/dist/types/core/handler/ArrayGetRankHandler.d.ts +8 -1
  55. package/dist/types/core/handler/ArrayGetSizeHandler.d.ts +8 -1
  56. package/dist/types/core/handler/ArrayHandler.d.ts +8 -1
  57. package/dist/types/core/handler/ArraySetItemHandler.d.ts +8 -1
  58. package/dist/types/core/handler/CastingHandler.d.ts +4 -0
  59. package/dist/types/core/handler/ConvertTypeHandler.d.ts +8 -4
  60. package/dist/types/core/handler/CreateClassInstanceHandler.d.ts +8 -1
  61. package/dist/types/core/handler/DestructReferenceHandler.d.ts +8 -1
  62. package/dist/types/core/handler/EnableNamespaceHandler.d.ts +8 -1
  63. package/dist/types/core/handler/EnableTypeHandler.d.ts +8 -1
  64. package/dist/types/core/handler/GetGlobalStaticFieldHandler.d.ts +8 -1
  65. package/dist/types/core/handler/GetInstanceFieldHandler.d.ts +8 -1
  66. package/dist/types/core/handler/GetStaticFieldHandler.d.ts +9 -1
  67. package/dist/types/core/handler/GetStaticMethodAsDelegateHandler.d.ts +4 -3
  68. package/dist/types/core/handler/GetTypeHandler.d.ts +17 -8
  69. package/dist/types/core/handler/Handler.d.ts +8 -8
  70. package/dist/types/core/handler/InvokeDelegateHandler.d.ts +4 -0
  71. package/dist/types/core/handler/InvokeGlobalFunctionHandler.d.ts +8 -1
  72. package/dist/types/core/handler/InvokeInstanceMethodHandler.d.ts +8 -1
  73. package/dist/types/core/handler/InvokeStaticMethodHandler.d.ts +8 -1
  74. package/dist/types/core/handler/LoadLibraryHandler.d.ts +8 -3
  75. package/dist/types/core/handler/SetGlobalStaticFieldHandler.d.ts +4 -0
  76. package/dist/types/core/handler/SetInstanceFieldHandler.d.ts +8 -1
  77. package/dist/types/core/handler/SetStaticFieldHandler.d.ts +8 -1
  78. package/dist/types/core/handler/ValueHandler.d.ts +9 -1
  79. package/dist/types/core/interpreter/Interpreter.d.ts +11 -10
  80. package/dist/types/core/namespaceCache/NamespaceCache.d.ts +17 -5
  81. package/dist/types/core/protocol/CommandDeserializer.d.ts +10 -3
  82. package/dist/types/core/protocol/CommandSerializer.d.ts +19 -2
  83. package/dist/types/core/protocol/TypeDeserializer.d.ts +46 -11
  84. package/dist/types/core/protocol/TypeSerializer.d.ts +53 -13
  85. package/dist/types/core/receiver/Receiver.d.ts +2 -2
  86. package/dist/types/core/receiver/ReceiverNative.d.ts +8 -2
  87. package/dist/types/core/transmitter/Transmitter.d.ts +20 -4
  88. package/dist/types/core/transmitter/TransmitterWebsocket.d.ts +8 -4
  89. package/dist/types/core/transmitter/TransmitterWebsocketBrowser.d.ts +4 -7
  90. package/dist/types/core/transmitter/TransmitterWrapper.d.ts +12 -3
  91. package/dist/types/core/typeCache/TypeCache.d.ts +15 -5
  92. package/dist/types/core/webSocketClient/WebSocketClient.d.ts +17 -21
  93. package/dist/types/sdk/ConfigRuntimeFactory.d.ts +9 -6
  94. package/dist/types/sdk/InvocationContext.d.ts +38 -6
  95. package/dist/types/sdk/Javonet.d.ts +12 -7
  96. package/dist/types/sdk/RuntimeContext.d.ts +23 -7
  97. package/dist/types/sdk/RuntimeFactory.d.ts +9 -2
  98. package/dist/types/sdk/tools/ActivationHelper.d.ts +20 -0
  99. package/dist/types/sdk/tools/JsonResolver.d.ts +87 -0
  100. package/dist/types/utils/Command.d.ts +18 -14
  101. package/dist/types/utils/CreateRequire.browser.d.ts +1 -0
  102. package/dist/types/utils/CreateRequire.node.d.ts +2 -0
  103. package/dist/types/utils/CustomError.d.ts +5 -1
  104. package/dist/types/utils/Runtime.d.ts +2 -3
  105. package/dist/types/utils/RuntimeNameHandler.d.ts +6 -2
  106. package/dist/types/utils/Type.d.ts +1 -0
  107. package/dist/types/utils/TypesHandler.d.ts +16 -0
  108. package/dist/types/utils/UtilsConst.d.ts +32 -0
  109. package/dist/types/utils/connectionData/IConnectionData.d.ts +16 -3
  110. package/dist/types/utils/connectionData/InMemoryConnectionData.d.ts +4 -3
  111. package/dist/types/utils/connectionData/WsConnectionData.d.ts +7 -10
  112. package/dist/types/utils/nodejs/connectionData/TcpConnectionData.d.ts +17 -10
  113. package/dist/utils/Command.cjs +9 -9
  114. package/dist/utils/CreateRequire.browser.cjs +30 -0
  115. package/dist/utils/CreateRequire.node.cjs +28 -0
  116. package/dist/utils/CustomError.cjs +4 -0
  117. package/dist/utils/Runtime.cjs +24 -18
  118. package/dist/utils/RuntimeLogger.cjs +2 -4
  119. package/dist/utils/RuntimeLoggerBrowser.cjs +1 -3
  120. package/dist/utils/RuntimeNameHandler.cjs +1 -1
  121. package/dist/utils/Type.cjs +2 -1
  122. package/dist/utils/TypesHandler.cjs +55 -0
  123. package/dist/utils/UtilsConst.cjs +101 -0
  124. package/dist/utils/connectionData/IConnectionData.cjs +9 -0
  125. package/dist/utils/connectionData/InMemoryConnectionData.cjs +10 -0
  126. package/dist/utils/connectionData/WsConnectionData.cjs +4 -0
  127. package/dist/utils/nodejs/connectionData/TcpConnectionData.cjs +45 -25
  128. package/lib/core/delegatesCache/DelegatesCache.js +1 -0
  129. package/lib/core/handler/AbstractHandler.js +27 -9
  130. package/lib/core/handler/ArrayGetItemHandler.js +9 -1
  131. package/lib/core/handler/ArrayGetRankHandler.js +9 -0
  132. package/lib/core/handler/ArrayGetSizeHandler.js +8 -0
  133. package/lib/core/handler/ArrayHandler.js +8 -0
  134. package/lib/core/handler/ArraySetItemHandler.js +11 -1
  135. package/lib/core/handler/CastingHandler.js +8 -1
  136. package/lib/core/handler/ConvertTypeHandler.js +9 -4
  137. package/lib/core/handler/CreateClassInstanceHandler.js +10 -4
  138. package/lib/core/handler/DestructReferenceHandler.js +8 -0
  139. package/lib/core/handler/EnableNamespaceHandler.js +8 -0
  140. package/lib/core/handler/EnableTypeHandler.js +8 -0
  141. package/lib/core/handler/GetGlobalStaticFieldHandler.js +9 -0
  142. package/lib/core/handler/GetInstanceFieldHandler.js +8 -0
  143. package/lib/core/handler/GetInstanceMethodAsDelegateHandler.js +9 -4
  144. package/lib/core/handler/GetStaticFieldHandler.js +9 -0
  145. package/lib/core/handler/GetStaticMethodAsDelegateHandler.js +8 -7
  146. package/lib/core/handler/GetTypeHandler.js +15 -5
  147. package/lib/core/handler/Handler.js +13 -18
  148. package/lib/core/handler/InvokeDelegateHandler.js +5 -0
  149. package/lib/core/handler/InvokeGlobalFunctionHandler.js +11 -1
  150. package/lib/core/handler/InvokeInstanceMethodHandler.js +8 -0
  151. package/lib/core/handler/InvokeStaticMethodHandler.js +8 -0
  152. package/lib/core/handler/LoadLibraryHandler.js +11 -0
  153. package/lib/core/handler/SetGlobalStaticFieldHandler.js +10 -0
  154. package/lib/core/handler/SetInstanceFieldHandler.js +7 -0
  155. package/lib/core/handler/SetStaticFieldHandler.js +8 -0
  156. package/lib/core/handler/ValueHandler.js +9 -0
  157. package/lib/core/interpreter/Interpreter.js +42 -24
  158. package/lib/core/namespaceCache/NamespaceCache.js +14 -0
  159. package/lib/core/protocol/CommandDeserializer.js +11 -2
  160. package/lib/core/protocol/CommandSerializer.js +40 -9
  161. package/lib/core/protocol/TypeDeserializer.js +36 -0
  162. package/lib/core/protocol/TypeSerializer.js +62 -7
  163. package/lib/core/receiver/Receiver.js +3 -2
  164. package/lib/core/receiver/ReceiverNative.js +8 -0
  165. package/lib/core/transmitter/Transmitter.js +18 -1
  166. package/lib/core/transmitter/TransmitterWebsocket.js +12 -5
  167. package/lib/core/transmitter/TransmitterWebsocketBrowser.js +2 -4
  168. package/lib/core/transmitter/TransmitterWrapper.js +27 -6
  169. package/lib/core/typeCache/TypeCache.js +9 -0
  170. package/lib/core/webSocketClient/WebSocketClient.js +33 -30
  171. package/lib/core/webSocketClient/WebSocketClientBrowser.js +5 -6
  172. package/lib/sdk/ConfigRuntimeFactory.js +70 -68
  173. package/lib/sdk/InvocationContext.js +94 -26
  174. package/lib/sdk/Javonet.js +18 -36
  175. package/lib/sdk/RuntimeContext.js +109 -29
  176. package/lib/sdk/RuntimeFactory.js +7 -0
  177. package/lib/sdk/tools/ActivationHelper.js +51 -0
  178. package/lib/sdk/tools/JsonResolver.js +226 -0
  179. package/lib/types.d.ts +57 -0
  180. package/lib/utils/Command.js +14 -9
  181. package/lib/utils/CreateRequire.browser.js +5 -0
  182. package/lib/utils/CreateRequire.node.js +3 -0
  183. package/lib/utils/CustomError.js +5 -0
  184. package/lib/utils/Runtime.js +25 -6
  185. package/lib/utils/RuntimeLogger.js +3 -0
  186. package/lib/utils/RuntimeNameHandler.js +6 -1
  187. package/lib/utils/Type.js +2 -1
  188. package/lib/utils/TypesHandler.js +35 -0
  189. package/lib/utils/UtilsConst.js +88 -0
  190. package/lib/utils/connectionData/IConnectionData.js +14 -0
  191. package/lib/utils/connectionData/InMemoryConnectionData.js +15 -0
  192. package/lib/utils/connectionData/WsConnectionData.js +9 -0
  193. package/lib/utils/nodejs/connectionData/TcpConnectionData.js +35 -5
  194. package/package.json +13 -3
  195. package/dist/sdk/tools/browser/ConfigSourceResolver.cjs +0 -153
  196. package/dist/sdk/tools/nodejs/JsonFileResolver.cjs +0 -120
  197. package/dist/types/sdk/tools/browser/ConfigSourceResolver.d.ts +0 -46
  198. package/dist/types/sdk/tools/nodejs/JsonFileResolver.d.ts +0 -13
  199. package/dist/types/utils/nodejs/TypesConverter.d.ts +0 -48
  200. package/dist/utils/nodejs/TypesConverter.cjs +0 -102
  201. package/lib/declarations.d.ts +0 -35
  202. package/lib/sdk/tools/browser/ConfigSourceResolver.js +0 -146
  203. package/lib/sdk/tools/nodejs/JsonFileResolver.js +0 -106
  204. package/lib/utils/nodejs/TypesConverter.js +0 -91
@@ -1,6 +1,11 @@
1
+ // @ts-check
1
2
  import { ConnectionType } from '../ConnectionType.js'
2
3
  import { IConnectionData } from './IConnectionData.js'
3
4
 
5
+ /**
6
+ * @typedef {import('../ConnectionType.js').ConnectionType} ConnectionType
7
+ */
8
+
4
9
  /**
5
10
  * Represents WebSocket connection data.
6
11
  * @extends IConnectionData
@@ -40,6 +45,10 @@ class WsConnectionData extends IConnectionData {
40
45
  return [this.connectionType, 0, 0, 0, 0, 0, 0]
41
46
  }
42
47
 
48
+ /**
49
+ * @param {WsConnectionData} other
50
+ * @returns {boolean}
51
+ */
43
52
  equals(other) {
44
53
  return other instanceof WsConnectionData && this._hostname === other.hostname
45
54
  }
@@ -1,12 +1,28 @@
1
+ // @ts-check
1
2
  import { IConnectionData } from '../../connectionData/IConnectionData.js'
2
3
  import { ConnectionType } from '../../ConnectionType.js'
3
4
  import { getRequire, isNodejsRuntime } from '../../Runtime.js'
4
5
 
5
6
  const requireDynamic = getRequire(import.meta.url)
7
+
6
8
  /**
9
+ * @typedef {import('../../ConnectionType.js').ConnectionType} ConnectionType
7
10
  * @extends IConnectionData
8
11
  */
9
12
  export class TcpConnectionData extends IConnectionData {
13
+ /** @type {string} */
14
+ ipAddress = ''
15
+ /** @type {number} */
16
+ _port = 0
17
+ /** @type {string} */
18
+ _hostname = ''
19
+ /** @type {ConnectionType} */
20
+ _connectionType = ConnectionType.TCP
21
+
22
+ /**
23
+ * @param {string} hostname
24
+ * @param {number} port
25
+ */
10
26
  constructor(hostname, port) {
11
27
  super()
12
28
  this._port = port
@@ -19,6 +35,9 @@ export class TcpConnectionData extends IConnectionData {
19
35
  }
20
36
  }
21
37
 
38
+ /**
39
+ * @returns {ConnectionType}
40
+ */
22
41
  get connectionType() {
23
42
  return this._connectionType
24
43
  }
@@ -40,7 +59,7 @@ export class TcpConnectionData extends IConnectionData {
40
59
 
41
60
  /**
42
61
  * @param {string} hostname
43
- * @returns {string|null}
62
+ * @returns {string}
44
63
  */
45
64
  resolveIpAddress(hostname) {
46
65
  try {
@@ -54,24 +73,29 @@ export class TcpConnectionData extends IConnectionData {
54
73
  const dns = requireDynamic('dns')
55
74
 
56
75
  // If it's not an IP address, try to resolve it as a hostname
57
- return dns.resolve4(hostname, (err, addresses) => {
76
+ return dns.resolve4(hostname, (/** @type {Error | null} */ err, /** @type {string[]} */ addresses) => {
58
77
  if (err) {
59
78
  console.error(err)
60
- return null
79
+ return ''
61
80
  }
62
81
  return addresses[0]
63
82
  })
64
- // eslint-disable-next-line no-unused-vars
65
83
  }
66
84
  }
85
+ return ''
67
86
  } catch (error) {
68
- if (error.code === 'MODULE_NOT_FOUND') {
87
+ const err = /** @type {{code?: string}} */ (error)
88
+ if (err.code === 'MODULE_NOT_FOUND') {
69
89
  throw new Error('dns module not found. Please install it using npm install dns')
70
90
  }
71
91
  throw error
72
92
  }
73
93
  }
74
94
 
95
+ /**
96
+ * Serializes the connection data.
97
+ * @returns {number[]} An array of connection data values.
98
+ */
75
99
  serializeConnectionData() {
76
100
  let result = [this.connectionType]
77
101
  result = result.concat(this.#getAddressBytes())
@@ -79,10 +103,16 @@ export class TcpConnectionData extends IConnectionData {
79
103
  return result
80
104
  }
81
105
 
106
+ /**
107
+ * @returns {number[]} An array of address bytes.
108
+ */
82
109
  #getAddressBytes() {
83
110
  return this.ipAddress.split('.').map(Number)
84
111
  }
85
112
 
113
+ /**
114
+ * @returns {number[]} An array of port bytes.
115
+ */
86
116
  #getPortBytes() {
87
117
  return [this._port & 0xff, this._port >> 8]
88
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javonet-nodejs-sdk",
3
- "version": "2.5.16",
3
+ "version": "2.5.18",
4
4
  "description": "Javonet allows you to reference and use modules or packages written in (Java/Kotlin/Groovy/Clojure, C#/VB.NET, Ruby, Perl, Python, JavaScript/TypeScript) like they were created in your technology. It works on Linux/Windows and MacOS for applications created in JVM, CLR/Netcore, Perl, Python, Ruby, NodeJS, C++ or GoLang and gives you unparalleled freedom and flexibility with native performance in building your mixed-technologies products. Let it be accessing best AI or cryptography libraries, devices SDKs, legacy client modules, internal custom packages or anything from public repositories available on NPM, Nuget, PyPI, Maven/Gradle, RubyGems or GitHub. Get free from programming languages barriers today! For more information check out our guides at https://www.javonet.com/guides/v2/",
5
5
  "keywords": [],
6
6
  "author": "SdNCenter Sp. z o. o.",
@@ -8,6 +8,9 @@
8
8
  "main": "./dist/sdk/Javonet.cjs",
9
9
  "module": "./lib/sdk/Javonet.js",
10
10
  "types": "./dist/types/sdk/Javonet.d.ts",
11
+ "browser": {
12
+ "./lib/utils/CreateRequire.node.js": "./lib/utils/CreateRequire.browser.js"
13
+ },
11
14
  "type": "module",
12
15
  "files": [
13
16
  "dist",
@@ -18,7 +21,13 @@
18
21
  ".": {
19
22
  "types": "./dist/types/sdk/Javonet.d.ts",
20
23
  "import": "./lib/sdk/Javonet.js",
24
+ "browser": "./lib/sdk/Javonet.js",
21
25
  "require": "./dist/sdk/Javonet.cjs"
26
+ },
27
+ "./lib/utils/CreateRequire.node.js": {
28
+ "browser": "./lib/utils/CreateRequire.browser.js",
29
+ "node": "./lib/utils/CreateRequire.node.js",
30
+ "default": "./lib/utils/CreateRequire.node.js"
22
31
  }
23
32
  },
24
33
  "scripts": {
@@ -33,6 +42,7 @@
33
42
  "format": "prettier --write ."
34
43
  },
35
44
  "dependencies": {
45
+ "@types/ws": "^8.18.1",
36
46
  "buffer": "^6.0.3",
37
47
  "glob": "^10.4.5",
38
48
  "uuid": "^10.0.0"
@@ -69,8 +79,8 @@
69
79
  "peerDependencies": {
70
80
  "crypto": "^1.0.1",
71
81
  "dns": "^0.2.2",
72
- "ws": "^8.0.0",
73
- "fs-extra": "^11.2.0"
82
+ "fs-extra": "^11.2.0",
83
+ "ws": "^8.0.0"
74
84
  },
75
85
  "peerDependenciesMeta": {
76
86
  "ws": {
@@ -1,153 +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 ConfigSourceResolver_exports = {};
20
- __export(ConfigSourceResolver_exports, {
21
- ConfigSourceResolver: () => ConfigSourceResolver
22
- });
23
- module.exports = __toCommonJS(ConfigSourceResolver_exports);
24
- function hasOwnProperty(obj, key) {
25
- return Object.prototype.hasOwnProperty.call(obj, key);
26
- }
27
- class ConfigSourceResolver {
28
- /**
29
- *
30
- * @param {object | string} configSource
31
- */
32
- constructor(configSource) {
33
- if (typeof configSource === "string") {
34
- try {
35
- this.jsonObject = JSON.parse(configSource);
36
- } catch (err) {
37
- throw new Error(
38
- `Failed to parse configSource as JSON: ${err instanceof Error ? err.message : "Unknown error"}`
39
- );
40
- }
41
- } else if (configSource && typeof configSource === "object") {
42
- this.jsonObject = configSource;
43
- } else {
44
- throw new Error("configSource must be a JSON object or JSON string");
45
- }
46
- }
47
- getLicenseKey() {
48
- if (!hasOwnProperty(this.jsonObject, "licenseKey")) {
49
- throw new Error(
50
- "License key not found in configuration file. Please check your configuration file."
51
- );
52
- }
53
- return this.jsonObject.licenseKey;
54
- }
55
- getRuntimes() {
56
- return this.jsonObject.runtimes;
57
- }
58
- /**
59
- * @param {string} runtimeName
60
- * @param {string} configName
61
- * @returns {any}
62
- */
63
- getRuntime(runtimeName, configName) {
64
- const runtimes = this.getRuntimes();
65
- if (hasOwnProperty(runtimes, runtimeName)) {
66
- const runtime = runtimes[runtimeName];
67
- if (Array.isArray(runtime)) {
68
- for (let item of runtime) {
69
- if (item.name === configName) {
70
- return item;
71
- }
72
- }
73
- } else if (runtime?.name === configName) {
74
- return runtime;
75
- }
76
- }
77
- throw new Error(
78
- `Runtime config ${configName} not found in configuration file for runtime ${runtimeName}. Please check your configuration file.`
79
- );
80
- }
81
- /**
82
- * @param {string} runtimeName
83
- * @param {string} configName
84
- * @returns {any}
85
- */
86
- getChannel(runtimeName, configName) {
87
- const runtime = this.getRuntime(runtimeName, configName);
88
- if (!hasOwnProperty(runtime, "channel")) {
89
- throw new Error(
90
- `Channel key not found in configuration file for config ${configName}. Please check your configuration file.`
91
- );
92
- }
93
- return runtime.channel;
94
- }
95
- /**
96
- * @param {string} runtimeName
97
- * @param {string} configName
98
- * @returns {any}
99
- */
100
- getChannelType(runtimeName, configName) {
101
- const channel = this.getChannel(runtimeName, configName);
102
- if (!hasOwnProperty(channel, "type")) {
103
- throw new Error(
104
- `Channel type not found in configuration file for config ${configName}. Please check your configuration file.`
105
- );
106
- }
107
- return channel.type;
108
- }
109
- /**
110
- * @param {string} runtimeName
111
- * @param {string} configName
112
- * @returns {any}
113
- */
114
- getChannelHost(runtimeName, configName) {
115
- const channel = this.getChannel(runtimeName, configName);
116
- if (!hasOwnProperty(channel, "host")) {
117
- throw new Error(
118
- `Channel host not found in configuration file for config ${configName}. Please check your configuration file.`
119
- );
120
- }
121
- return channel.host;
122
- }
123
- /**
124
- * @param {string} runtimeName
125
- * @param {string} configName
126
- * @returns {any}
127
- */
128
- getChannelPort(runtimeName, configName) {
129
- const channel = this.getChannel(runtimeName, configName);
130
- if (!hasOwnProperty(channel, "port")) {
131
- throw new Error(
132
- `Channel port not found in configuration file for config ${configName}. Please check your configuration file.`
133
- );
134
- }
135
- return channel.port;
136
- }
137
- /**
138
- * @param {string} runtimeName
139
- * @param {string} configName
140
- * @returns {any}
141
- */
142
- getModules(runtimeName, configName) {
143
- const runtime = this.getRuntime(runtimeName, configName);
144
- if (hasOwnProperty(runtime, "modules")) {
145
- return runtime.modules;
146
- }
147
- return "";
148
- }
149
- }
150
- // Annotate the CommonJS export names for ESM import in node:
151
- 0 && (module.exports = {
152
- ConfigSourceResolver
153
- });
@@ -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
- }