javonet-nodejs-sdk 2.5.17 → 2.5.19
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 +23 -6
- package/dist/core/handler/ArrayGetItemHandler.cjs +4 -1
- package/dist/core/handler/ArrayGetRankHandler.cjs +3 -0
- package/dist/core/handler/ArrayGetSizeHandler.cjs +3 -0
- package/dist/core/handler/ArrayHandler.cjs +3 -0
- package/dist/core/handler/ArraySetItemHandler.cjs +4 -1
- package/dist/core/handler/CastingHandler.cjs +3 -1
- package/dist/core/handler/ConvertTypeHandler.cjs +4 -4
- package/dist/core/handler/CreateClassInstanceHandler.cjs +5 -2
- package/dist/core/handler/DestructReferenceHandler.cjs +3 -0
- package/dist/core/handler/EnableNamespaceHandler.cjs +3 -0
- package/dist/core/handler/EnableTypeHandler.cjs +3 -0
- package/dist/core/handler/GetGlobalStaticFieldHandler.cjs +3 -0
- package/dist/core/handler/GetInstanceFieldHandler.cjs +3 -0
- package/dist/core/handler/GetInstanceMethodAsDelegateHandler.cjs +15 -4
- package/dist/core/handler/GetStaticFieldHandler.cjs +4 -0
- package/dist/core/handler/GetStaticMethodAsDelegateHandler.cjs +8 -6
- package/dist/core/handler/GetTypeHandler.cjs +10 -2
- package/dist/core/handler/Handler.cjs +8 -11
- package/dist/core/handler/InvokeGlobalFunctionHandler.cjs +3 -0
- package/dist/core/handler/InvokeInstanceMethodHandler.cjs +3 -0
- package/dist/core/handler/InvokeStaticMethodHandler.cjs +3 -0
- package/dist/core/handler/LoadLibraryHandler.cjs +4 -0
- package/dist/core/handler/SetGlobalStaticFieldHandler.cjs +3 -0
- package/dist/core/handler/SetInstanceFieldHandler.cjs +3 -0
- package/dist/core/handler/SetStaticFieldHandler.cjs +3 -0
- package/dist/core/handler/ValueHandler.cjs +4 -0
- package/dist/core/interpreter/Interpreter.cjs +28 -12
- package/dist/core/namespaceCache/NamespaceCache.cjs +12 -0
- package/dist/core/protocol/CommandDeserializer.cjs +10 -2
- package/dist/core/protocol/CommandSerializer.cjs +24 -4
- package/dist/core/protocol/TypeDeserializer.cjs +35 -0
- package/dist/core/protocol/TypeSerializer.cjs +51 -7
- package/dist/core/receiver/Receiver.cjs +1 -1
- package/dist/core/receiver/ReceiverNative.cjs +6 -0
- package/dist/core/transmitter/Transmitter.cjs +18 -2
- package/dist/core/transmitter/TransmitterWebsocket.cjs +8 -5
- package/dist/core/transmitter/TransmitterWebsocketBrowser.cjs +1 -1
- package/dist/core/transmitter/TransmitterWrapper.cjs +25 -8
- package/dist/core/typeCache/TypeCache.cjs +8 -0
- package/dist/core/webSocketClient/WebSocketClient.cjs +22 -12
- package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +2 -2
- package/dist/sdk/ConfigRuntimeFactory.cjs +60 -55
- package/dist/sdk/InvocationContext.cjs +81 -23
- package/dist/sdk/Javonet.cjs +14 -33
- package/dist/sdk/RuntimeContext.cjs +89 -30
- package/dist/sdk/RuntimeFactory.cjs +3 -0
- package/dist/sdk/tools/ActivationHelper.cjs +66 -0
- package/dist/sdk/tools/JsonResolver.cjs +214 -0
- package/dist/types/core/handler/AbstractHandler.d.ts +23 -4
- package/dist/types/core/handler/ArrayGetItemHandler.d.ts +8 -1
- package/dist/types/core/handler/ArrayGetRankHandler.d.ts +8 -1
- package/dist/types/core/handler/ArrayGetSizeHandler.d.ts +8 -1
- package/dist/types/core/handler/ArrayHandler.d.ts +8 -1
- package/dist/types/core/handler/ArraySetItemHandler.d.ts +8 -1
- package/dist/types/core/handler/CastingHandler.d.ts +4 -0
- package/dist/types/core/handler/ConvertTypeHandler.d.ts +8 -4
- package/dist/types/core/handler/CreateClassInstanceHandler.d.ts +8 -1
- package/dist/types/core/handler/DestructReferenceHandler.d.ts +8 -1
- package/dist/types/core/handler/EnableNamespaceHandler.d.ts +8 -1
- package/dist/types/core/handler/EnableTypeHandler.d.ts +8 -1
- package/dist/types/core/handler/GetGlobalStaticFieldHandler.d.ts +8 -1
- package/dist/types/core/handler/GetInstanceFieldHandler.d.ts +8 -1
- package/dist/types/core/handler/GetStaticFieldHandler.d.ts +9 -1
- package/dist/types/core/handler/GetStaticMethodAsDelegateHandler.d.ts +4 -3
- package/dist/types/core/handler/GetTypeHandler.d.ts +17 -8
- package/dist/types/core/handler/Handler.d.ts +8 -8
- package/dist/types/core/handler/InvokeDelegateHandler.d.ts +4 -0
- package/dist/types/core/handler/InvokeGlobalFunctionHandler.d.ts +8 -1
- package/dist/types/core/handler/InvokeInstanceMethodHandler.d.ts +8 -1
- package/dist/types/core/handler/InvokeStaticMethodHandler.d.ts +8 -1
- package/dist/types/core/handler/LoadLibraryHandler.d.ts +8 -3
- package/dist/types/core/handler/SetGlobalStaticFieldHandler.d.ts +4 -0
- package/dist/types/core/handler/SetInstanceFieldHandler.d.ts +8 -1
- package/dist/types/core/handler/SetStaticFieldHandler.d.ts +8 -1
- package/dist/types/core/handler/ValueHandler.d.ts +9 -1
- package/dist/types/core/interpreter/Interpreter.d.ts +11 -10
- package/dist/types/core/namespaceCache/NamespaceCache.d.ts +17 -5
- package/dist/types/core/protocol/CommandDeserializer.d.ts +10 -3
- package/dist/types/core/protocol/CommandSerializer.d.ts +19 -2
- package/dist/types/core/protocol/TypeDeserializer.d.ts +46 -11
- package/dist/types/core/protocol/TypeSerializer.d.ts +53 -13
- package/dist/types/core/receiver/Receiver.d.ts +2 -2
- package/dist/types/core/receiver/ReceiverNative.d.ts +8 -2
- package/dist/types/core/transmitter/Transmitter.d.ts +20 -4
- package/dist/types/core/transmitter/TransmitterWebsocket.d.ts +8 -4
- package/dist/types/core/transmitter/TransmitterWebsocketBrowser.d.ts +4 -7
- package/dist/types/core/transmitter/TransmitterWrapper.d.ts +12 -3
- package/dist/types/core/typeCache/TypeCache.d.ts +15 -5
- package/dist/types/core/webSocketClient/WebSocketClient.d.ts +17 -21
- package/dist/types/sdk/ConfigRuntimeFactory.d.ts +9 -6
- package/dist/types/sdk/InvocationContext.d.ts +38 -6
- package/dist/types/sdk/Javonet.d.ts +12 -7
- package/dist/types/sdk/RuntimeContext.d.ts +23 -7
- package/dist/types/sdk/RuntimeFactory.d.ts +9 -2
- package/dist/types/sdk/tools/ActivationHelper.d.ts +20 -0
- package/dist/types/sdk/tools/JsonResolver.d.ts +87 -0
- package/dist/types/utils/Command.d.ts +18 -14
- package/dist/types/utils/CustomError.d.ts +5 -1
- package/dist/types/utils/Runtime.d.ts +1 -2
- package/dist/types/utils/RuntimeNameHandler.d.ts +6 -2
- package/dist/types/utils/Type.d.ts +1 -0
- package/dist/types/utils/TypesHandler.d.ts +16 -0
- package/dist/types/utils/UtilsConst.d.ts +32 -0
- package/dist/types/utils/connectionData/IConnectionData.d.ts +16 -3
- package/dist/types/utils/connectionData/InMemoryConnectionData.d.ts +4 -3
- package/dist/types/utils/connectionData/WsConnectionData.d.ts +7 -10
- package/dist/types/utils/nodejs/connectionData/TcpConnectionData.d.ts +17 -10
- package/dist/utils/Command.cjs +9 -9
- package/dist/utils/CustomError.cjs +4 -0
- package/dist/utils/RuntimeNameHandler.cjs +1 -1
- package/dist/utils/Type.cjs +2 -1
- package/dist/utils/TypesHandler.cjs +55 -0
- package/dist/utils/UtilsConst.cjs +101 -0
- package/dist/utils/connectionData/IConnectionData.cjs +9 -0
- package/dist/utils/connectionData/InMemoryConnectionData.cjs +10 -0
- package/dist/utils/connectionData/WsConnectionData.cjs +4 -0
- package/dist/utils/nodejs/connectionData/TcpConnectionData.cjs +33 -3
- package/lib/core/delegatesCache/DelegatesCache.js +1 -0
- package/lib/core/handler/AbstractHandler.js +27 -9
- package/lib/core/handler/ArrayGetItemHandler.js +9 -1
- package/lib/core/handler/ArrayGetRankHandler.js +9 -0
- package/lib/core/handler/ArrayGetSizeHandler.js +8 -0
- package/lib/core/handler/ArrayHandler.js +8 -0
- package/lib/core/handler/ArraySetItemHandler.js +11 -1
- package/lib/core/handler/CastingHandler.js +8 -1
- package/lib/core/handler/ConvertTypeHandler.js +9 -4
- package/lib/core/handler/CreateClassInstanceHandler.js +10 -4
- package/lib/core/handler/DestructReferenceHandler.js +8 -0
- package/lib/core/handler/EnableNamespaceHandler.js +8 -0
- package/lib/core/handler/EnableTypeHandler.js +8 -0
- package/lib/core/handler/GetGlobalStaticFieldHandler.js +9 -0
- package/lib/core/handler/GetInstanceFieldHandler.js +8 -0
- package/lib/core/handler/GetInstanceMethodAsDelegateHandler.js +9 -4
- package/lib/core/handler/GetStaticFieldHandler.js +9 -0
- package/lib/core/handler/GetStaticMethodAsDelegateHandler.js +8 -7
- package/lib/core/handler/GetTypeHandler.js +15 -5
- package/lib/core/handler/Handler.js +13 -18
- package/lib/core/handler/InvokeDelegateHandler.js +5 -0
- package/lib/core/handler/InvokeGlobalFunctionHandler.js +11 -1
- package/lib/core/handler/InvokeInstanceMethodHandler.js +8 -0
- package/lib/core/handler/InvokeStaticMethodHandler.js +8 -0
- package/lib/core/handler/LoadLibraryHandler.js +11 -0
- package/lib/core/handler/SetGlobalStaticFieldHandler.js +10 -0
- package/lib/core/handler/SetInstanceFieldHandler.js +7 -0
- package/lib/core/handler/SetStaticFieldHandler.js +8 -0
- package/lib/core/handler/ValueHandler.js +9 -0
- package/lib/core/interpreter/Interpreter.js +42 -24
- package/lib/core/namespaceCache/NamespaceCache.js +14 -0
- package/lib/core/protocol/CommandDeserializer.js +11 -2
- package/lib/core/protocol/CommandSerializer.js +40 -9
- package/lib/core/protocol/TypeDeserializer.js +36 -0
- package/lib/core/protocol/TypeSerializer.js +62 -7
- package/lib/core/receiver/Receiver.js +3 -2
- package/lib/core/receiver/ReceiverNative.js +8 -0
- package/lib/core/transmitter/Transmitter.js +18 -1
- package/lib/core/transmitter/TransmitterWebsocket.js +12 -5
- package/lib/core/transmitter/TransmitterWebsocketBrowser.js +2 -4
- package/lib/core/transmitter/TransmitterWrapper.js +27 -6
- package/lib/core/typeCache/TypeCache.js +9 -0
- package/lib/core/webSocketClient/WebSocketClient.js +33 -30
- package/lib/core/webSocketClient/WebSocketClientBrowser.js +5 -6
- package/lib/sdk/ConfigRuntimeFactory.js +70 -68
- package/lib/sdk/InvocationContext.js +94 -26
- package/lib/sdk/Javonet.js +18 -36
- package/lib/sdk/RuntimeContext.js +113 -29
- package/lib/sdk/RuntimeFactory.js +7 -0
- package/lib/sdk/tools/ActivationHelper.js +51 -0
- package/lib/sdk/tools/JsonResolver.js +226 -0
- package/lib/types.d.ts +57 -0
- package/lib/utils/Command.js +14 -9
- package/lib/utils/CustomError.js +5 -0
- package/lib/utils/Runtime.js +1 -1
- package/lib/utils/RuntimeLogger.js +3 -0
- package/lib/utils/RuntimeNameHandler.js +6 -1
- package/lib/utils/Type.js +2 -1
- package/lib/utils/TypesHandler.js +35 -0
- package/lib/utils/UtilsConst.js +88 -0
- package/lib/utils/connectionData/IConnectionData.js +14 -0
- package/lib/utils/connectionData/InMemoryConnectionData.js +15 -0
- package/lib/utils/connectionData/WsConnectionData.js +9 -0
- package/lib/utils/nodejs/connectionData/TcpConnectionData.js +35 -5
- package/package.json +4 -3
- package/dist/sdk/tools/browser/ConfigSourceResolver.cjs +0 -153
- package/dist/sdk/tools/nodejs/JsonFileResolver.cjs +0 -120
- package/dist/types/sdk/tools/browser/ConfigSourceResolver.d.ts +0 -46
- package/dist/types/sdk/tools/nodejs/JsonFileResolver.d.ts +0 -13
- package/dist/types/utils/nodejs/TypesConverter.d.ts +0 -48
- package/dist/utils/nodejs/TypesConverter.cjs +0 -102
- package/lib/declarations.d.ts +0 -35
- package/lib/sdk/tools/browser/ConfigSourceResolver.js +0 -146
- package/lib/sdk/tools/nodejs/JsonFileResolver.js +0 -106
- package/lib/utils/nodejs/TypesConverter.js +0 -91
package/lib/sdk/Javonet.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//@ts-check
|
|
1
2
|
import { ConfigRuntimeFactory } from './ConfigRuntimeFactory.js'
|
|
2
3
|
import { RuntimeFactory } from './RuntimeFactory.js'
|
|
3
4
|
import { InMemoryConnectionData } from '../utils/connectionData/InMemoryConnectionData.js'
|
|
@@ -7,10 +8,14 @@ import { CommandDeserializer } from '../core/protocol/CommandDeserializer.js'
|
|
|
7
8
|
import { RuntimeLogger } from '../utils/RuntimeLogger.js'
|
|
8
9
|
import { TcpConnectionData } from '../utils/nodejs/connectionData/TcpConnectionData.js'
|
|
9
10
|
import { WsConnectionData } from '../utils/connectionData/WsConnectionData.js'
|
|
11
|
+
import { ActivationHelper } from './tools/ActivationHelper.js'
|
|
12
|
+
import { UtilsConst } from '../utils/UtilsConst.js'
|
|
13
|
+
|
|
14
|
+
/** @typedef {import('../types.d.ts').ConfigSource} ConfigSource */
|
|
10
15
|
|
|
11
16
|
const requireDynamic = getRequire(import.meta.url)
|
|
12
17
|
|
|
13
|
-
/** @type {import('../core/transmitter/Transmitter') | null} */
|
|
18
|
+
/** @type {typeof import('../core/transmitter/Transmitter.js').Transmitter | null} */
|
|
14
19
|
let _Transmitter = null
|
|
15
20
|
|
|
16
21
|
if (isNodejsRuntime()) {
|
|
@@ -64,28 +69,28 @@ class Javonet {
|
|
|
64
69
|
/**
|
|
65
70
|
* Initializes Javonet with a custom configuration file taken from external source.
|
|
66
71
|
* Currentyl supported: Configuration file in JSON format
|
|
67
|
-
* @param config - Path to a configuration file.
|
|
72
|
+
* @param {string|ConfigSource} config - Path to a configuration file.
|
|
68
73
|
* @returns {ConfigRuntimeFactory} A ConfigRuntimeFactory instance with configuration data.
|
|
69
74
|
* @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/foundations/configure-channel)
|
|
70
75
|
*/
|
|
71
76
|
static withConfig(config) {
|
|
72
|
-
return new ConfigRuntimeFactory(config
|
|
77
|
+
return new ConfigRuntimeFactory(config)
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
/**
|
|
76
81
|
* Activates Javonet with the provided license key.
|
|
77
82
|
* @param {string} licenseKey - The license key to activate Javonet.
|
|
78
|
-
* @returns {
|
|
83
|
+
* @returns {void} The activation status code.
|
|
79
84
|
* @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/getting-started/activating-javonet)
|
|
80
85
|
*/
|
|
81
86
|
static activate(licenseKey) {
|
|
82
|
-
|
|
83
|
-
return _Transmitter?.activate(licenseKey)
|
|
84
|
-
} else {
|
|
85
|
-
throw new Error('Javonet.activate is allowed only to run in nodejs runtime')
|
|
86
|
-
}
|
|
87
|
+
UtilsConst.setLicenseKey(licenseKey)
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Gets the runtime information.
|
|
92
|
+
* @returns {string} The runtime information.
|
|
93
|
+
*/
|
|
89
94
|
static getRuntimeInfo() {
|
|
90
95
|
if (isNodejsRuntime()) {
|
|
91
96
|
return RuntimeLogger.getRuntimeInfo()
|
|
@@ -96,43 +101,20 @@ class Javonet {
|
|
|
96
101
|
|
|
97
102
|
/**
|
|
98
103
|
* Sets the configuration source for the Javonet SDK.
|
|
99
|
-
*
|
|
100
104
|
* @param {string} configSource - The configuration source.
|
|
105
|
+
* @returns {void}
|
|
101
106
|
*/
|
|
102
107
|
static setConfigSource(configSource) {
|
|
103
|
-
|
|
104
|
-
return _Transmitter?.setConfigSource(configSource)
|
|
105
|
-
} else {
|
|
106
|
-
throw new Error('Javonet.setConfigSource is allowed only to run in nodejs runtime')
|
|
107
|
-
}
|
|
108
|
+
UtilsConst.setConfigSource(configSource)
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
/**
|
|
111
112
|
* Sets the working directory for the Javonet SDK.
|
|
112
|
-
*
|
|
113
113
|
* @param {string} path - The working directory.
|
|
114
|
+
* @returns {void}
|
|
114
115
|
*/
|
|
115
116
|
static setJavonetWorkingDirectory(path) {
|
|
116
|
-
|
|
117
|
-
if (isNodejsRuntime()) {
|
|
118
|
-
const { mkdirSync } = requireDynamic('fs')
|
|
119
|
-
|
|
120
|
-
path = path.replace(/\\/g, '/')
|
|
121
|
-
if (!path.endsWith('/')) {
|
|
122
|
-
path += '/'
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
mkdirSync(path, { recursive: true, mode: 0o700 })
|
|
126
|
-
_Transmitter?.setJavonetWorkingDirectory(path)
|
|
127
|
-
} else {
|
|
128
|
-
throw new Error('Javonet.setJavonetWorkingDirectory is allowed only to run in nodejs runtime')
|
|
129
|
-
}
|
|
130
|
-
} catch (error) {
|
|
131
|
-
if (error.code === 'MODULE_NOT_FOUND') {
|
|
132
|
-
throw new Error('fs module not found. Please install it using npm install fs')
|
|
133
|
-
}
|
|
134
|
-
throw error
|
|
135
|
-
}
|
|
117
|
+
UtilsConst.setJavonetWorkingDirectory(path)
|
|
136
118
|
}
|
|
137
119
|
}
|
|
138
120
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
2
|
import { Command } from '../utils/Command.js'
|
|
3
3
|
import { CommandType } from '../utils/CommandType.js'
|
|
4
4
|
import { InvocationContext, InvocationWsContext } from './InvocationContext.js'
|
|
@@ -7,6 +7,20 @@ import { ExceptionThrower } from '../utils/exception/ExceptionThrower.js'
|
|
|
7
7
|
import { RuntimeName } from '../utils/RuntimeName.js'
|
|
8
8
|
import { Interpreter } from '../core/interpreter/Interpreter.js'
|
|
9
9
|
import { delegatesCacheInstance } from '../core/delegatesCache/DelegatesCache.js'
|
|
10
|
+
import { TypesHandler } from '../utils/TypesHandler.js'
|
|
11
|
+
import { UtilsConst } from '../utils/UtilsConst.js'
|
|
12
|
+
import { getRequire } from '../utils/Runtime.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import('../types.d.ts').RuntimeName} RuntimeNameType
|
|
16
|
+
* @typedef {import('../utils/connectionData/IConnectionData.js').IConnectionData} IConnectionData
|
|
17
|
+
* @typedef {typeof import('../core/transmitter/Transmitter.js').Transmitter} Transmitter
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** @type {typeof import('../core/transmitter/Transmitter.js').Transmitter | null} */
|
|
21
|
+
let _Transmitter = null
|
|
22
|
+
|
|
23
|
+
const requireDynamic = getRequire(import.meta.url)
|
|
10
24
|
|
|
11
25
|
/**
|
|
12
26
|
* Represents a single context which allows interaction with a selected technology.
|
|
@@ -20,54 +34,97 @@ import { delegatesCacheInstance } from '../core/delegatesCache/DelegatesCache.js
|
|
|
20
34
|
* @class
|
|
21
35
|
*/
|
|
22
36
|
class RuntimeContext {
|
|
37
|
+
/** @type {Map<string, RuntimeContext>} */
|
|
23
38
|
static memoryRuntimeContexts = new Map()
|
|
39
|
+
/** @type {Map<string, RuntimeContext>} */
|
|
24
40
|
static networkRuntimeContexts = new Map()
|
|
41
|
+
/** @type {Map<string, RuntimeContext>} */
|
|
25
42
|
static webSocketRuntimeContexts = new Map()
|
|
26
|
-
#currentCommand
|
|
27
|
-
#responseCommand
|
|
28
|
-
#interpreter
|
|
29
43
|
|
|
44
|
+
/** @type {Command | null} */
|
|
45
|
+
#currentCommand = null
|
|
46
|
+
/** @type {Command | null} */
|
|
47
|
+
#responseCommand = null
|
|
48
|
+
/** @type {Interpreter | null} */
|
|
49
|
+
#interpreter = null
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {RuntimeNameType} runtimeName
|
|
53
|
+
* @param {IConnectionData} connectionData
|
|
54
|
+
*/
|
|
30
55
|
constructor(runtimeName, connectionData) {
|
|
56
|
+
this._isExecuted = false
|
|
31
57
|
this.runtimeName = runtimeName
|
|
32
58
|
this.connectionData = connectionData
|
|
33
|
-
this.#currentCommand = null
|
|
34
|
-
this.#responseCommand = null
|
|
35
59
|
this.#interpreter = new Interpreter()
|
|
60
|
+
|
|
61
|
+
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
if (
|
|
65
|
+
this.runtimeName === RuntimeName.Nodejs &&
|
|
66
|
+
this.connectionData.connectionType === ConnectionType.IN_MEMORY
|
|
67
|
+
) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_Transmitter?.setJavonetWorkingDirectory(UtilsConst.getJavonetWorkingDirectory())
|
|
72
|
+
if (UtilsConst.getConfigSource() !== '') {
|
|
73
|
+
_Transmitter?.setConfigSource(UtilsConst.getConfigSource())
|
|
74
|
+
}
|
|
75
|
+
_Transmitter?.activate(UtilsConst.getLicenseKey())
|
|
36
76
|
}
|
|
37
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @param {RuntimeNameType} runtimeName
|
|
80
|
+
* @param {IConnectionData} connectionData
|
|
81
|
+
* @returns {RuntimeContext}
|
|
82
|
+
*/
|
|
38
83
|
static getInstance(runtimeName, connectionData) {
|
|
39
84
|
switch (connectionData.connectionType) {
|
|
40
85
|
case ConnectionType.IN_MEMORY:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
runtimeCtx
|
|
86
|
+
const key = String(runtimeName)
|
|
87
|
+
if (RuntimeContext.memoryRuntimeContexts.has(key)) {
|
|
88
|
+
const runtimeCtx = RuntimeContext.memoryRuntimeContexts.get(key)
|
|
89
|
+
if (!runtimeCtx) throw new Error('Runtime context not found')
|
|
90
|
+
runtimeCtx.#currentCommand = null
|
|
44
91
|
return runtimeCtx
|
|
45
92
|
} else {
|
|
46
|
-
|
|
47
|
-
|
|
93
|
+
if (!_Transmitter) {
|
|
94
|
+
const { Transmitter } = requireDynamic('../core/transmitter/Transmitter.js')
|
|
95
|
+
_Transmitter = Transmitter
|
|
96
|
+
}
|
|
97
|
+
const runtimeCtx = new RuntimeContext(runtimeName, connectionData)
|
|
98
|
+
RuntimeContext.memoryRuntimeContexts.set(key, runtimeCtx)
|
|
48
99
|
return runtimeCtx
|
|
49
100
|
}
|
|
50
101
|
case ConnectionType.TCP: {
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
runtimeCtx
|
|
102
|
+
const key1 = String(runtimeName) + JSON.stringify(connectionData)
|
|
103
|
+
if (RuntimeContext.networkRuntimeContexts.has(key1)) {
|
|
104
|
+
const runtimeCtx = RuntimeContext.networkRuntimeContexts.get(key1)
|
|
105
|
+
if (!runtimeCtx) throw new Error('Runtime context not found')
|
|
106
|
+
runtimeCtx.#currentCommand = null
|
|
55
107
|
return runtimeCtx
|
|
56
108
|
} else {
|
|
57
|
-
|
|
58
|
-
|
|
109
|
+
if (!_Transmitter) {
|
|
110
|
+
const { Transmitter } = requireDynamic('../core/transmitter/Transmitter.js')
|
|
111
|
+
_Transmitter = Transmitter
|
|
112
|
+
}
|
|
113
|
+
const runtimeCtx = new RuntimeContext(runtimeName, connectionData)
|
|
114
|
+
RuntimeContext.networkRuntimeContexts.set(key1, runtimeCtx)
|
|
59
115
|
return runtimeCtx
|
|
60
116
|
}
|
|
61
117
|
}
|
|
62
118
|
case ConnectionType.WEB_SOCKET: {
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
runtimeCtx
|
|
119
|
+
const key2 = String(runtimeName) + JSON.stringify(connectionData)
|
|
120
|
+
if (RuntimeContext.webSocketRuntimeContexts.has(key2)) {
|
|
121
|
+
const runtimeCtx = RuntimeContext.webSocketRuntimeContexts.get(key2)
|
|
122
|
+
if (!runtimeCtx) throw new Error('Runtime context not found')
|
|
123
|
+
runtimeCtx.#currentCommand = null
|
|
67
124
|
return runtimeCtx
|
|
68
125
|
} else {
|
|
69
|
-
|
|
70
|
-
RuntimeContext.webSocketRuntimeContexts
|
|
126
|
+
const runtimeCtx = new RuntimeContext(runtimeName, connectionData)
|
|
127
|
+
RuntimeContext.webSocketRuntimeContexts.set(key2, runtimeCtx)
|
|
71
128
|
return runtimeCtx
|
|
72
129
|
}
|
|
73
130
|
}
|
|
@@ -86,12 +143,13 @@ class RuntimeContext {
|
|
|
86
143
|
* @method
|
|
87
144
|
*/
|
|
88
145
|
execute() {
|
|
89
|
-
|
|
146
|
+
// @ts-expect-error
|
|
147
|
+
this.#responseCommand = this.#interpreter?.execute(this.#currentCommand, this.connectionData)
|
|
90
148
|
this.#currentCommand = null
|
|
91
149
|
if (this.#responseCommand === undefined) {
|
|
92
150
|
throw new Error('responseCommand is undefined in Runtime Context execute method')
|
|
93
151
|
}
|
|
94
|
-
if (this.#responseCommand
|
|
152
|
+
if (this.#responseCommand?.commandType === CommandType.Exception) {
|
|
95
153
|
throw ExceptionThrower.throwException(this.#responseCommand)
|
|
96
154
|
}
|
|
97
155
|
}
|
|
@@ -124,6 +182,7 @@ class RuntimeContext {
|
|
|
124
182
|
let localCommand = new Command(this.runtimeName, CommandType.GetType, [typeName, ...args])
|
|
125
183
|
this.#currentCommand = null
|
|
126
184
|
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
185
|
+
// @ts-expect-error
|
|
127
186
|
return new InvocationWsContext(
|
|
128
187
|
this.runtimeName,
|
|
129
188
|
this.connectionData,
|
|
@@ -146,6 +205,7 @@ class RuntimeContext {
|
|
|
146
205
|
let localCommand = new Command(this.runtimeName, CommandType.Cast, args)
|
|
147
206
|
this.#currentCommand = null
|
|
148
207
|
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
208
|
+
// @ts-expect-error
|
|
149
209
|
return new InvocationWsContext(
|
|
150
210
|
this.runtimeName,
|
|
151
211
|
this.connectionData,
|
|
@@ -168,6 +228,7 @@ class RuntimeContext {
|
|
|
168
228
|
let localCommand = new Command(this.runtimeName, CommandType.GetEnumItem, args)
|
|
169
229
|
this.#currentCommand = null
|
|
170
230
|
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
231
|
+
// @ts-expect-error
|
|
171
232
|
return new InvocationWsContext(
|
|
172
233
|
this.runtimeName,
|
|
173
234
|
this.connectionData,
|
|
@@ -190,6 +251,7 @@ class RuntimeContext {
|
|
|
190
251
|
let localCommand = new Command(this.runtimeName, CommandType.AsRef, args)
|
|
191
252
|
this.#currentCommand = null
|
|
192
253
|
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
254
|
+
// @ts-expect-error
|
|
193
255
|
return new InvocationWsContext(
|
|
194
256
|
this.runtimeName,
|
|
195
257
|
this.connectionData,
|
|
@@ -212,6 +274,7 @@ class RuntimeContext {
|
|
|
212
274
|
let localCommand = new Command(this.runtimeName, CommandType.AsOut, args)
|
|
213
275
|
this.#currentCommand = null
|
|
214
276
|
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
277
|
+
// @ts-expect-error
|
|
215
278
|
return new InvocationWsContext(
|
|
216
279
|
this.runtimeName,
|
|
217
280
|
this.connectionData,
|
|
@@ -238,6 +301,7 @@ class RuntimeContext {
|
|
|
238
301
|
])
|
|
239
302
|
this.#currentCommand = null
|
|
240
303
|
if (this.connectionData.connectionType === ConnectionType.WEB_SOCKET) {
|
|
304
|
+
// @ts-expect-error
|
|
241
305
|
return new InvocationWsContext(
|
|
242
306
|
this.runtimeName,
|
|
243
307
|
this.connectionData,
|
|
@@ -247,22 +311,35 @@ class RuntimeContext {
|
|
|
247
311
|
return new InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand))
|
|
248
312
|
}
|
|
249
313
|
|
|
250
|
-
|
|
314
|
+
/**
|
|
315
|
+
* @param {Command} command
|
|
316
|
+
* @returns {Command}
|
|
317
|
+
*/
|
|
318
|
+
#buildCommand(command) {
|
|
251
319
|
for (let i = 0; i < command.payload.length; i++) {
|
|
252
320
|
command.payload[i] = this.#encapsulatePayloadItem(command.payload[i])
|
|
253
321
|
}
|
|
254
322
|
return command.prependArgToPayload(this.#currentCommand)
|
|
255
323
|
}
|
|
256
324
|
|
|
257
|
-
|
|
325
|
+
/**
|
|
326
|
+
* @param {unknown} payloadItem
|
|
327
|
+
* @returns {Command}
|
|
328
|
+
*/
|
|
329
|
+
#encapsulatePayloadItem(payloadItem) {
|
|
258
330
|
if (payloadItem instanceof Command) {
|
|
259
331
|
for (let i = 0; i < payloadItem.payload.length; i++) {
|
|
260
332
|
payloadItem.payload[i] = this.#encapsulatePayloadItem(payloadItem.payload[i])
|
|
261
333
|
}
|
|
262
334
|
return payloadItem
|
|
263
335
|
} else if (payloadItem instanceof InvocationContext) {
|
|
264
|
-
|
|
336
|
+
const command = payloadItem?.get_current_command()
|
|
337
|
+
if (!command) {
|
|
338
|
+
throw new Error('Command not found')
|
|
339
|
+
}
|
|
340
|
+
return command
|
|
265
341
|
} else if (payloadItem instanceof Array) {
|
|
342
|
+
/** @type {Command[]} */
|
|
266
343
|
const copiedArray = payloadItem.map((item) => this.#encapsulatePayloadItem(item))
|
|
267
344
|
return new Command(this.runtimeName, CommandType.Array, copiedArray)
|
|
268
345
|
} else if (typeof payloadItem === 'function') {
|
|
@@ -274,8 +351,15 @@ class RuntimeContext {
|
|
|
274
351
|
...newArray
|
|
275
352
|
)
|
|
276
353
|
return new Command(this.runtimeName, CommandType.PassDelegate, args)
|
|
277
|
-
} else {
|
|
354
|
+
} else if (TypesHandler.isPrimitiveOrNullOrUndefined(payloadItem)) {
|
|
278
355
|
return new Command(this.runtimeName, CommandType.Value, [payloadItem])
|
|
356
|
+
} else {
|
|
357
|
+
throw Error(
|
|
358
|
+
'Unsupported payload item type: ' +
|
|
359
|
+
(payloadItem?.constructor?.name || typeof payloadItem) +
|
|
360
|
+
' for payload item: ' +
|
|
361
|
+
payloadItem
|
|
362
|
+
)
|
|
279
363
|
}
|
|
280
364
|
}
|
|
281
365
|
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
//@ts-check
|
|
1
2
|
import { RuntimeName } from '../utils/RuntimeName.js'
|
|
2
3
|
import { RuntimeContext } from './RuntimeContext.js'
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import('../utils/connectionData/IConnectionData.js').IConnectionData} IConnectionData
|
|
7
|
+
*/
|
|
4
8
|
/**
|
|
5
9
|
* The RuntimeFactory class provides methods for creating runtime contexts.
|
|
6
10
|
* Each method corresponds to a specific runtime (CLR, JVM, .NET Core, Perl, Ruby, Node.js, Python) and returns a RuntimeContext instance for that runtime.
|
|
7
11
|
* @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/foundations/runtime-context)
|
|
8
12
|
*/
|
|
9
13
|
export class RuntimeFactory {
|
|
14
|
+
/**
|
|
15
|
+
* @param {IConnectionData} connectionData
|
|
16
|
+
*/
|
|
10
17
|
constructor(connectionData) {
|
|
11
18
|
this.connectionData = connectionData
|
|
12
19
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { isBrowserRuntime } from '../../utils/Runtime.js'
|
|
3
|
+
|
|
4
|
+
class ActivationHelper {
|
|
5
|
+
/** @type {string} */
|
|
6
|
+
static temporaryLicenseKey = 'License key not set'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} value
|
|
10
|
+
*/
|
|
11
|
+
static setTemporaryLicenseKey(value) {
|
|
12
|
+
if (!value || value === 'your-license-key') {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
// TODO: Uncomment this when we have a way to send messages to App Insights
|
|
16
|
+
// if (ActivationHelper.temporaryLicenseKey !== value) {
|
|
17
|
+
// SdkMessageHelper.sendExceptionToAppInsights('SdkMessage', 'Activation');
|
|
18
|
+
// }
|
|
19
|
+
ActivationHelper.temporaryLicenseKey = value
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
static getTemporaryLicenseKey() {
|
|
26
|
+
return ActivationHelper.temporaryLicenseKey
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns {Promise<string>}
|
|
31
|
+
*/
|
|
32
|
+
static async getLicenseKey() {
|
|
33
|
+
try {
|
|
34
|
+
return ActivationHelper._getLicenseKeyFromFile()
|
|
35
|
+
} catch {
|
|
36
|
+
return ActivationHelper.temporaryLicenseKey
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
static _getLicenseKeyFromFile() {
|
|
44
|
+
if (!isBrowserRuntime()) {
|
|
45
|
+
throw new Error('ActivationHelper is not supported in the browser runtime.')
|
|
46
|
+
}
|
|
47
|
+
return ""
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { ActivationHelper }
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import { isNodejsRuntime, getRequire } from '../../utils/Runtime.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('../../types.d.ts').RuntimeChannelType} RuntimeChannelType
|
|
6
|
+
* @typedef {import('../../types.d.ts').ConfigSource} ConfigSource
|
|
7
|
+
* @typedef {import('../../types.d.ts').RuntimeChannel} RuntimeChannel
|
|
8
|
+
* @typedef {import('../../types.d.ts').Runtime} Runtime
|
|
9
|
+
* @typedef {import('../../types.d.ts').Runtimes} Runtimes
|
|
10
|
+
* @typedef {import('../../types.d.ts').RuntimeType} RuntimeType
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {any} param
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
function isValidObject(param) {
|
|
18
|
+
return typeof param === 'object' && param !== null && !Array.isArray(param)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string | ConfigSource} param
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
function isValidJson(param) {
|
|
26
|
+
try {
|
|
27
|
+
if (typeof param === 'string') {
|
|
28
|
+
const parsed = JSON.parse(param)
|
|
29
|
+
return typeof parsed === 'object' && parsed !== null
|
|
30
|
+
}
|
|
31
|
+
return false
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const requireDynamic = getRequire(import.meta.url)
|
|
38
|
+
|
|
39
|
+
/** @type {any | null} */
|
|
40
|
+
let fs = null
|
|
41
|
+
|
|
42
|
+
class JsonResolver {
|
|
43
|
+
/** @type {ConfigSource} */
|
|
44
|
+
jsonObject
|
|
45
|
+
/** @type {string | ConfigSource} */
|
|
46
|
+
configSource
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {string | ConfigSource} configSource
|
|
50
|
+
*/
|
|
51
|
+
constructor(configSource) {
|
|
52
|
+
this.configSource = JSON.stringify(configSource)
|
|
53
|
+
this.jsonObject = this._getJsonObject(configSource)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @returns {Partial<Runtimes>}
|
|
58
|
+
*/
|
|
59
|
+
get runtimes() {
|
|
60
|
+
return this.jsonObject?.runtimes || {}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
get licenseKey() {
|
|
67
|
+
return this.jsonObject?.licenseKey || 'your-license-key'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
get workingDirectory() {
|
|
74
|
+
return this.jsonObject?.workingDirectory || ''
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @returns {string}
|
|
79
|
+
*/
|
|
80
|
+
getLicenseKey() {
|
|
81
|
+
if (!this.licenseKey) {
|
|
82
|
+
throw new Error('License key not found in configuration source. Check your configuration source.')
|
|
83
|
+
}
|
|
84
|
+
return this.licenseKey
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @returns {string}
|
|
89
|
+
*/
|
|
90
|
+
getWorkingDirectory() {
|
|
91
|
+
return this.workingDirectory
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {RuntimeType} runtimeName
|
|
96
|
+
* @param {string} configName
|
|
97
|
+
* @returns {RuntimeChannelType}
|
|
98
|
+
*/
|
|
99
|
+
getChannelType(runtimeName, configName) {
|
|
100
|
+
const channel = this._getChannel(runtimeName, configName)
|
|
101
|
+
return channel.type
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {RuntimeType} runtimeName
|
|
106
|
+
* @param {string} configName
|
|
107
|
+
* @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
getChannelHost(runtimeName, configName) {
|
|
110
|
+
const channel = this._getChannel(runtimeName, configName)
|
|
111
|
+
if (channel.host === undefined) {
|
|
112
|
+
throw new Error(`Host not found for channel in runtime ${runtimeName}, config ${configName}`)
|
|
113
|
+
}
|
|
114
|
+
return channel.host
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @param {RuntimeType} runtimeName
|
|
119
|
+
* @param {string} configName
|
|
120
|
+
* @returns {number|string}
|
|
121
|
+
*/
|
|
122
|
+
getChannelPort(runtimeName, configName) {
|
|
123
|
+
const channel = this._getChannel(runtimeName, configName)
|
|
124
|
+
if (channel.port === undefined) {
|
|
125
|
+
throw new Error(`Port not found for channel in runtime ${runtimeName}, config ${configName}`)
|
|
126
|
+
}
|
|
127
|
+
return channel.port
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {RuntimeType} runtimeName
|
|
132
|
+
* @param {string} configName
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
getModules(runtimeName, configName) {
|
|
136
|
+
const runtime = this._getRuntime(runtimeName, configName)
|
|
137
|
+
return runtime.modules || ''
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @private
|
|
142
|
+
* @param {string | ConfigSource} configSource
|
|
143
|
+
* @returns {ConfigSource}
|
|
144
|
+
*/
|
|
145
|
+
_getJsonObject(configSource) {
|
|
146
|
+
if (isValidObject(configSource)) {
|
|
147
|
+
return /** @type {ConfigSource} */ (configSource)
|
|
148
|
+
}
|
|
149
|
+
if (typeof configSource === 'string' && isValidJson(configSource)) {
|
|
150
|
+
const parsedJson = JSON.parse(configSource)
|
|
151
|
+
if (isValidObject(parsedJson)) {
|
|
152
|
+
return parsedJson
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (isNodejsRuntime()) {
|
|
156
|
+
if (!fs) {
|
|
157
|
+
fs = requireDynamic('fs')
|
|
158
|
+
}
|
|
159
|
+
if (fs?.existsSync(configSource)) {
|
|
160
|
+
const jsonText = fs.readFileSync(configSource, 'utf8')
|
|
161
|
+
if (isValidJson(jsonText)) {
|
|
162
|
+
const parsedFromFile = JSON.parse(jsonText)
|
|
163
|
+
if (isValidObject(parsedFromFile)) {
|
|
164
|
+
return parsedFromFile
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Configuration source is not valid. Check your configuration:${String(this.configSource)}`
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @private
|
|
177
|
+
* @param {RuntimeType} runtimeName
|
|
178
|
+
* @param {string} configName
|
|
179
|
+
* @returns {Runtime}
|
|
180
|
+
*/
|
|
181
|
+
_getRuntime(runtimeName, configName) {
|
|
182
|
+
const runtimeList = this.runtimes[runtimeName]
|
|
183
|
+
|
|
184
|
+
if (Array.isArray(runtimeList)) {
|
|
185
|
+
const runtime = runtimeList.find((item) => item.name === configName)
|
|
186
|
+
if (runtime) {
|
|
187
|
+
return runtime
|
|
188
|
+
}
|
|
189
|
+
} else if (typeof runtimeList?.name === 'string' && runtimeList?.name === configName) {
|
|
190
|
+
return runtimeList
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Runtime config '${configName}' not found in configuration source for runtime '${runtimeName}'. Check your configuration source.`
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @private
|
|
200
|
+
* @param {RuntimeType} runtimeName
|
|
201
|
+
* @param {string} configName
|
|
202
|
+
* @returns {string}
|
|
203
|
+
*/
|
|
204
|
+
_getRuntimeName(runtimeName, configName) {
|
|
205
|
+
const runtime = this._getRuntime(runtimeName, configName)
|
|
206
|
+
return runtime.name
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @private
|
|
211
|
+
* @param {RuntimeType} runtimeName
|
|
212
|
+
* @param {string} configName
|
|
213
|
+
* @returns {RuntimeChannel}
|
|
214
|
+
*/
|
|
215
|
+
_getChannel(runtimeName, configName) {
|
|
216
|
+
const runtime = this._getRuntime(runtimeName, configName)
|
|
217
|
+
if (!runtime.channel) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Channel not found for runtime config '${configName}' and runtime '${runtimeName}'. Check your configuration source.`
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
return runtime.channel
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export { JsonResolver }
|