javonet-nodejs-sdk 2.6.3 → 2.6.4
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/dist/core/handler/AbstractHandler.cjs +4 -4
- package/dist/core/handler/GetInstanceMethodAsDelegateHandler.cjs +2 -4
- package/dist/core/handler/GetStaticMethodAsDelegateHandler.cjs +4 -2
- package/dist/core/handler/GetTypeHandler.cjs +3 -3
- package/dist/core/transmitter/Transmitter.cjs +4 -4
- package/dist/sdk/ConfigRuntimeFactory.cjs +50 -47
- package/dist/sdk/InvocationContext.cjs +10 -2
- package/dist/sdk/Javonet.cjs +22 -0
- package/dist/sdk/RuntimeFactory.cjs +33 -1
- package/dist/sdk/configuration/Config.cjs +55 -0
- package/dist/sdk/configuration/ConfigPriority.cjs +38 -0
- package/dist/sdk/configuration/ConfigSourceResolver.cjs +100 -0
- package/dist/sdk/configuration/ConfigsDictionary.cjs +121 -0
- package/dist/sdk/configuration/configResolvers/ConfigResolver.cjs +121 -0
- package/dist/sdk/configuration/configResolvers/ConnectionStringConfigResolver.cjs +123 -0
- package/dist/sdk/configuration/configResolvers/JsonConfigResolver.cjs +125 -0
- package/dist/sdk/configuration/configResolvers/YamlConfigResolver.cjs +125 -0
- package/dist/sdk/tools/JsonResolver.cjs +4 -1
- package/dist/types/core/transmitter/Transmitter.d.ts +1 -1
- package/dist/types/sdk/ConfigRuntimeFactory.d.ts +3 -0
- package/dist/types/sdk/Javonet.d.ts +15 -1
- package/dist/types/sdk/RuntimeFactory.d.ts +14 -0
- package/dist/types/sdk/configuration/Config.d.ts +14 -0
- package/dist/types/sdk/configuration/ConfigPriority.d.ts +8 -0
- package/dist/types/sdk/configuration/ConfigSourceResolver.d.ts +7 -0
- package/dist/types/sdk/configuration/ConfigsDictionary.d.ts +30 -0
- package/dist/types/sdk/configuration/configResolvers/ConfigResolver.d.ts +30 -0
- package/dist/types/sdk/configuration/configResolvers/ConnectionStringConfigResolver.d.ts +23 -0
- package/dist/types/sdk/configuration/configResolvers/JsonConfigResolver.d.ts +26 -0
- package/dist/types/sdk/configuration/configResolvers/YamlConfigResolver.d.ts +32 -0
- package/dist/types/sdk/tools/JsonResolver.d.ts +4 -2
- package/dist/types/utils/Runtime.d.ts +4 -3
- package/dist/types/utils/RuntimeNameHandler.d.ts +5 -0
- package/dist/utils/RuntimeNameHandler.cjs +34 -0
- package/dist/utils/connectionData/InMemoryConnectionData.cjs +7 -1
- package/dist/utils/connectionData/WsConnectionData.cjs +6 -0
- package/dist/utils/exception/ExceptionSerializer.cjs +6 -2
- package/dist/utils/nodejs/connectionData/TcpConnectionData.cjs +15 -6
- package/lib/core/handler/AbstractHandler.js +7 -5
- package/lib/core/handler/AddEventListenerHandler.js +2 -3
- package/lib/core/handler/ArrayReferenceHandler.js +2 -3
- package/lib/core/handler/AsKwargsHandler.js +2 -2
- package/lib/core/handler/AsOutHandler.js +2 -3
- package/lib/core/handler/AsRefHandler.js +2 -3
- package/lib/core/handler/CreateNullHandler.js +2 -3
- package/lib/core/handler/ExceptionHandler.js +2 -3
- package/lib/core/handler/GenerateLibHandler.js +2 -3
- package/lib/core/handler/GetAsyncOperationResultHandler.js +2 -3
- package/lib/core/handler/GetEnumItemHandler.js +2 -3
- package/lib/core/handler/GetEnumNameHandler.js +2 -2
- package/lib/core/handler/GetEnumValueHandler.js +2 -3
- package/lib/core/handler/GetInstanceMethodAsDelegateHandler.js +3 -3
- package/lib/core/handler/GetModuleHandler.js +2 -2
- package/lib/core/handler/GetRefValueHandler.js +2 -3
- package/lib/core/handler/GetStaticFieldHandler.js +0 -1
- package/lib/core/handler/GetStaticMethodAsDelegateHandler.js +3 -1
- package/lib/core/handler/GetTypeHandler.js +3 -3
- package/lib/core/handler/Handler.js +29 -29
- package/lib/core/handler/HeartBeatHandler.js +2 -3
- package/lib/core/handler/InvokeGenericMethodHandler.js +2 -4
- package/lib/core/handler/InvokeGenericStaticMethodHandler.js +2 -3
- package/lib/core/handler/InvokeStaticMethodHandler.js +1 -1
- package/lib/core/handler/OptimizeHandler.js +2 -3
- package/lib/core/handler/PluginWrapperHandler.js +2 -3
- package/lib/core/handler/ResolveReferenceHandler.js +1 -3
- package/lib/core/handler/RetrieveArrayHandler.js +2 -3
- package/lib/core/receiver/Receiver.js +5 -7
- package/lib/core/transmitter/Transmitter.js +5 -5
- package/lib/core/webSocketClient/WebSocketClientBrowser.js +2 -2
- package/lib/sdk/ActivatorDetails.js +1 -1
- package/lib/sdk/ConfigRuntimeFactory.js +65 -48
- package/lib/sdk/InvocationContext.js +10 -2
- package/lib/sdk/Javonet.js +31 -2
- package/lib/sdk/RuntimeFactory.js +49 -1
- package/lib/sdk/configuration/Config.js +37 -0
- package/lib/sdk/configuration/ConfigPriority.js +9 -0
- package/lib/sdk/configuration/ConfigSourceResolver.js +84 -0
- package/lib/sdk/configuration/ConfigsDictionary.js +118 -0
- package/lib/sdk/configuration/configResolvers/ConfigResolver.js +109 -0
- package/lib/sdk/configuration/configResolvers/ConnectionStringConfigResolver.js +119 -0
- package/lib/sdk/configuration/configResolvers/JsonConfigResolver.js +99 -0
- package/lib/sdk/configuration/configResolvers/YamlConfigResolver.js +109 -0
- package/lib/sdk/tools/ActivationHelper.js +1 -1
- package/lib/sdk/tools/JsonResolver.js +5 -1
- package/lib/sdk/tools/typeParsingFunctions/NetcoreTypeParsingFunctions.js +1 -1
- package/lib/sdk/tools/typeParsingFunctions/NodejsTypeParsingFunctions.js +1 -1
- package/lib/sdk/tools/typeParsingFunctions/TypeParsingUtils.js +4 -1
- package/lib/utils/CommandType.js +1 -1
- package/lib/utils/CustomError.js +1 -1
- package/lib/utils/Runtime.js +11 -4
- package/lib/utils/RuntimeLoggerBrowser.js +0 -1
- package/lib/utils/RuntimeNameHandler.js +37 -0
- package/lib/utils/TypesHandler.js +11 -5
- package/lib/utils/connectionData/InMemoryConnectionData.js +8 -1
- package/lib/utils/connectionData/WsConnectionData.js +7 -0
- package/lib/utils/exception/ExceptionSerializer.js +6 -2
- package/lib/utils/nodejs/connectionData/TcpConnectionData.js +16 -6
- package/lib/utils/nodejs/uuid/v4.js +0 -1
- package/package.json +3 -1
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { isThenable } from '../../../utils/IsThenable.js'
|
|
4
4
|
|
|
5
|
-
export const handleResultWithAction = (
|
|
5
|
+
export const handleResultWithAction = (
|
|
6
|
+
/** @type {any} */ result,
|
|
7
|
+
/** @type {function(any): any} */ action
|
|
8
|
+
) => {
|
|
6
9
|
if (isThenable(result)) {
|
|
7
10
|
return result.then((/** @type {any} */ result) => action(result.getValue()))
|
|
8
11
|
}
|
package/lib/utils/CommandType.js
CHANGED
package/lib/utils/CustomError.js
CHANGED
package/lib/utils/Runtime.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
// javascript
|
|
2
|
+
/** @typedef {import('../types.js').ConfigSource} ConfigSource */
|
|
3
|
+
|
|
1
4
|
import { createRequire } from './CreateRequire.node.js'
|
|
2
5
|
|
|
3
6
|
/** @type {import('url').pathToFileURL | null} */
|
|
4
7
|
let pathToFileURL = null
|
|
5
8
|
/** @type {import('url').fileURLToPath | null} */
|
|
6
9
|
let fileURLToPath = null
|
|
7
|
-
/** @type {import('path').
|
|
10
|
+
/** @type {import('path').PlatformPath | null} */
|
|
8
11
|
let path = null
|
|
9
12
|
|
|
10
13
|
/**
|
|
@@ -41,7 +44,7 @@ export function getRuntimeExtension() {
|
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
* Get the require function
|
|
44
|
-
* @param {string} callerPath - The path to the caller
|
|
47
|
+
* @param {string} [callerPath] - The path to the caller
|
|
45
48
|
* @returns {any}
|
|
46
49
|
*/
|
|
47
50
|
export const getRequire = (callerPath) => {
|
|
@@ -62,6 +65,10 @@ export const getRequire = (callerPath) => {
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Get current directory name in both CJS and ESM
|
|
70
|
+
* @returns {string | Error}
|
|
71
|
+
*/
|
|
65
72
|
export const getDirname = () => {
|
|
66
73
|
if (isBrowserRuntime()) {
|
|
67
74
|
return new Error('Runtime not supported')
|
|
@@ -78,7 +85,7 @@ export const getDirname = () => {
|
|
|
78
85
|
/**
|
|
79
86
|
* Resolves the path to a dependency using Node.js module resolution.
|
|
80
87
|
* @param {string} dependencyName - The name or path of the dependency to resolve.
|
|
81
|
-
* @param {string} callerPathOrUrl - The `import.meta.url` (ESM) or `__filename` (CJS) of the calling module.
|
|
88
|
+
* @param {string} [callerPathOrUrl] - The `import.meta.url` (ESM) or `__filename` (CJS) of the calling module.
|
|
82
89
|
* @returns {string} The resolved path to the dependency.
|
|
83
90
|
* @throws {Error} If the dependency cannot be resolved.
|
|
84
91
|
*/
|
|
@@ -86,13 +93,13 @@ export const getDependency = (dependencyName, callerPathOrUrl) => {
|
|
|
86
93
|
try {
|
|
87
94
|
let baseUrl = callerPathOrUrl
|
|
88
95
|
if (!baseUrl && typeof __filename !== 'undefined') {
|
|
96
|
+
// eslint-disable-next-line no-undef
|
|
89
97
|
baseUrl = __filename
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
const contextualRequire = getRequire(baseUrl)
|
|
93
101
|
return contextualRequire.resolve(dependencyName)
|
|
94
102
|
} catch (error) {
|
|
95
|
-
// Provide a more informative error message
|
|
96
103
|
throw new Error(
|
|
97
104
|
`Failed to resolve dependency '${dependencyName}' from '${callerPathOrUrl}': ${error.message}`
|
|
98
105
|
)
|
|
@@ -38,6 +38,43 @@ class RuntimeNameHandler {
|
|
|
38
38
|
throw new Error('Invalid runtime name.')
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} name
|
|
44
|
+
* @returns {number}
|
|
45
|
+
*/
|
|
46
|
+
static getRuntime = (name) => {
|
|
47
|
+
if (!name || name.trim() === '') {
|
|
48
|
+
throw new Error('Runtime name cannot be null or whitespace.')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const normalized = name.trim().toLowerCase()
|
|
52
|
+
|
|
53
|
+
switch (normalized) {
|
|
54
|
+
case 'clr':
|
|
55
|
+
return RuntimeName.Clr
|
|
56
|
+
case 'go':
|
|
57
|
+
return RuntimeName.Go
|
|
58
|
+
case 'jvm':
|
|
59
|
+
return RuntimeName.Jvm
|
|
60
|
+
case 'netcore':
|
|
61
|
+
return RuntimeName.Netcore
|
|
62
|
+
case 'perl':
|
|
63
|
+
return RuntimeName.Perl
|
|
64
|
+
case 'python':
|
|
65
|
+
return RuntimeName.Python
|
|
66
|
+
case 'ruby':
|
|
67
|
+
return RuntimeName.Ruby
|
|
68
|
+
case 'nodejs':
|
|
69
|
+
return RuntimeName.Nodejs
|
|
70
|
+
case 'php':
|
|
71
|
+
return RuntimeName.Php
|
|
72
|
+
case 'python27':
|
|
73
|
+
return RuntimeName.Python27
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`${name} is not a supported runtime.`)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
41
78
|
}
|
|
42
79
|
|
|
43
80
|
export { RuntimeNameHandler }
|
|
@@ -11,11 +11,11 @@ class TypesHandler {
|
|
|
11
11
|
static convertTypeToJType(type) {
|
|
12
12
|
switch (type) {
|
|
13
13
|
case Boolean:
|
|
14
|
-
return
|
|
14
|
+
return 'JType.Boolean'
|
|
15
15
|
case Number:
|
|
16
|
-
return
|
|
16
|
+
return 'JType.Float'
|
|
17
17
|
case String:
|
|
18
|
-
return
|
|
18
|
+
return 'JType.String'
|
|
19
19
|
case Object:
|
|
20
20
|
return typeof type
|
|
21
21
|
default:
|
|
@@ -28,8 +28,14 @@ class TypesHandler {
|
|
|
28
28
|
* @returns {boolean}
|
|
29
29
|
*/
|
|
30
30
|
static isPrimitiveOrNullOrUndefined(value) {
|
|
31
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
value === null ||
|
|
33
|
+
value === undefined ||
|
|
34
|
+
typeof value === 'string' ||
|
|
35
|
+
typeof value === 'number' ||
|
|
36
|
+
typeof value === 'boolean'
|
|
37
|
+
)
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
export {TypesHandler}
|
|
41
|
+
export { TypesHandler }
|
|
@@ -13,7 +13,7 @@ class InMemoryConnectionData extends IConnectionData {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super()
|
|
15
15
|
this._connectionType = ConnectionType.IN_MEMORY
|
|
16
|
-
this._hostname = ''
|
|
16
|
+
this._hostname = 'inMemory'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -45,6 +45,13 @@ class InMemoryConnectionData extends IConnectionData {
|
|
|
45
45
|
equals(other) {
|
|
46
46
|
return other instanceof InMemoryConnectionData
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
toString() {
|
|
53
|
+
return this.hostname
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export { InMemoryConnectionData }
|
|
@@ -52,6 +52,13 @@ class WsConnectionData extends IConnectionData {
|
|
|
52
52
|
equals(other) {
|
|
53
53
|
return other instanceof WsConnectionData && this._hostname === other.hostname
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
59
|
+
toString() {
|
|
60
|
+
return this.hostname
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
export { WsConnectionData }
|
|
@@ -16,7 +16,9 @@ class ExceptionSerializer {
|
|
|
16
16
|
this.serializeStackTrace(exception, stackClasses, stackMethods, stackLines, stackFiles)
|
|
17
17
|
|
|
18
18
|
exceptionCommand = exceptionCommand.addArgToPayload(this.getExceptionCode(exception))
|
|
19
|
-
exceptionCommand = exceptionCommand.addArgToPayload(
|
|
19
|
+
exceptionCommand = exceptionCommand.addArgToPayload(
|
|
20
|
+
command ? command.toString() : 'Command is null'
|
|
21
|
+
)
|
|
20
22
|
exceptionCommand = exceptionCommand.addArgToPayload(exception.name)
|
|
21
23
|
exceptionCommand = exceptionCommand.addArgToPayload(exception.message)
|
|
22
24
|
exceptionCommand = exceptionCommand.addArgToPayload(stackClasses.join('|'))
|
|
@@ -26,7 +28,9 @@ class ExceptionSerializer {
|
|
|
26
28
|
} catch (e) {
|
|
27
29
|
exceptionCommand = new Command(RuntimeName.Nodejs, CommandType.Exception, [])
|
|
28
30
|
exceptionCommand = exceptionCommand.addArgToPayload(this.getExceptionCode(e))
|
|
29
|
-
exceptionCommand = exceptionCommand.addArgToPayload(
|
|
31
|
+
exceptionCommand = exceptionCommand.addArgToPayload(
|
|
32
|
+
command ? command.toString() : 'Command is null'
|
|
33
|
+
)
|
|
30
34
|
exceptionCommand = exceptionCommand.addArgToPayload('Node.js Exception Serialization Error')
|
|
31
35
|
exceptionCommand = exceptionCommand.addArgToPayload(e.message)
|
|
32
36
|
exceptionCommand = exceptionCommand.addArgToPayload('ExceptionSerializer')
|
|
@@ -73,13 +73,16 @@ export class TcpConnectionData extends IConnectionData {
|
|
|
73
73
|
const dns = requireDynamic('dns')
|
|
74
74
|
|
|
75
75
|
// If it's not an IP address, try to resolve it as a hostname
|
|
76
|
-
return dns.resolve4(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
return dns.resolve4(
|
|
77
|
+
hostname,
|
|
78
|
+
(/** @type {Error | null} */ err, /** @type {string[]} */ addresses) => {
|
|
79
|
+
if (err) {
|
|
80
|
+
console.error(err)
|
|
81
|
+
return ''
|
|
82
|
+
}
|
|
83
|
+
return addresses[0]
|
|
80
84
|
}
|
|
81
|
-
|
|
82
|
-
})
|
|
85
|
+
)
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
return ''
|
|
@@ -116,4 +119,11 @@ export class TcpConnectionData extends IConnectionData {
|
|
|
116
119
|
#getPortBytes() {
|
|
117
120
|
return [this._port & 0xff, this._port >> 8]
|
|
118
121
|
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
toString() {
|
|
127
|
+
return `${this.ipAddress}:${this._port}`
|
|
128
|
+
}
|
|
119
129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "javonet-nodejs-sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.4",
|
|
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.",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@types/ws": "^8.18.1",
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
55
|
"glob": "^10.4.5",
|
|
56
|
+
"js-yaml": "^4.1.0",
|
|
56
57
|
"uuid": "^10.0.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
"@babel/preset-env": "^7.26.0",
|
|
64
65
|
"@eslint/js": "^9.15.0",
|
|
65
66
|
"@jest/globals": "^29.7.0",
|
|
67
|
+
"@types/js-yaml": "^4.0.9",
|
|
66
68
|
"babel-loader": "^9.2.1",
|
|
67
69
|
"cross-env": "^7.0.3",
|
|
68
70
|
"esbuild": "^0.24.0",
|