javonet-nodejs-sdk 2.6.13 → 2.6.15
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/ArraySetItemHandler.cjs +9 -8
- package/dist/core/handler/AsDtoHandler.cjs +36 -0
- package/dist/core/handler/AsKwargsHandler.cjs +1 -1
- package/dist/core/handler/DtoPropertyHandler.cjs +36 -0
- package/dist/core/handler/Handler.cjs +14 -9
- package/dist/core/handler/PassDelegateHandler.cjs +1 -1
- package/dist/core/handler/ProjectResultAsDtoHandler.cjs +66 -0
- package/dist/core/handler/SetInstanceFieldHandler.cjs +1 -1
- package/dist/core/handler/SetStaticFieldHandler.cjs +6 -6
- package/dist/core/interpreter/Interpreter.cjs +14 -2
- package/dist/core/protocol/CommandDeserializer.cjs +8 -0
- package/dist/core/protocol/TypeDeserializer.cjs +4 -0
- package/dist/core/protocol/TypeSerializer.cjs +10 -5
- package/dist/core/webSocketClient/WebSocketClient.cjs +23 -5
- package/dist/core/webSocketClient/WebSocketClientBrowser.cjs +23 -5
- package/dist/plugins/PluginImplementationRegistry.cjs +214 -0
- package/dist/plugins/PluginPayloadBuilder.cjs +76 -0
- package/dist/plugins/PluginRegistry.cjs +255 -0
- package/dist/plugins/index.cjs +51 -0
- package/dist/plugins/interfaces/ICommunityPlugin.cjs +44 -0
- package/dist/plugins/interfaces/ICommunityReceivingPlugin.cjs +62 -0
- package/dist/plugins/interfaces/ICommunitySendingPlugin.cjs +59 -0
- package/dist/plugins/settings/BasePluginSettings.cjs +67 -0
- package/dist/plugins/settings/JwtGraftocodePluginSettings.cjs +40 -0
- package/dist/sdk/InvocationContext.cjs +133 -12
- package/dist/sdk/RuntimeContext.cjs +27 -9
- package/dist/sdk/configuration/configResolvers/ConfigResolver.cjs +7 -6
- package/dist/sdk/configuration/configResolvers/ConnectionStringConfigResolver.cjs +2 -2
- package/dist/sdk/configuration/configResolvers/JsonConfigResolver.cjs +2 -2
- package/dist/sdk/configuration/configResolvers/YamlConfigResolver.cjs +3 -3
- package/dist/sdk/tools/DtoHelper.cjs +100 -0
- package/dist/types/core/handler/ArraySetItemHandler.d.ts +1 -1
- package/dist/types/core/handler/AsDtoHandler.d.ts +7 -0
- package/dist/types/core/handler/AsKwargsHandler.d.ts +1 -1
- package/dist/types/core/handler/DtoPropertyHandler.d.ts +7 -0
- package/dist/types/core/handler/ProjectResultAsDtoHandler.d.ts +9 -0
- package/dist/types/core/handler/SetInstanceFieldHandler.d.ts +1 -1
- package/dist/types/core/handler/SetStaticFieldHandler.d.ts +1 -1
- package/dist/types/core/interpreter/Interpreter.d.ts +3 -3
- package/dist/types/core/protocol/CommandDeserializer.d.ts +1 -0
- package/dist/types/core/protocol/TypeDeserializer.d.ts +1 -0
- package/dist/types/core/protocol/TypeSerializer.d.ts +1 -0
- package/dist/types/plugins/PluginImplementationRegistry.d.ts +121 -0
- package/dist/types/plugins/PluginPayloadBuilder.d.ts +32 -0
- package/dist/types/plugins/PluginRegistry.d.ts +157 -0
- package/dist/types/plugins/index.d.ts +8 -0
- package/dist/types/plugins/interfaces/ICommunityPlugin.d.ts +14 -0
- package/dist/types/plugins/interfaces/ICommunityReceivingPlugin.d.ts +50 -0
- package/dist/types/plugins/interfaces/ICommunitySendingPlugin.d.ts +27 -0
- package/dist/types/plugins/settings/BasePluginSettings.d.ts +45 -0
- package/dist/types/plugins/settings/JwtGraftocodePluginSettings.d.ts +32 -0
- package/dist/types/sdk/InvocationContext.d.ts +20 -2
- package/dist/types/sdk/RuntimeContext.d.ts +6 -0
- package/dist/types/sdk/configuration/configResolvers/ConfigResolver.d.ts +3 -6
- package/dist/types/sdk/configuration/configResolvers/YamlConfigResolver.d.ts +2 -1
- package/dist/types/sdk/tools/DtoHelper.d.ts +35 -0
- package/dist/types/utils/Command.d.ts +5 -0
- package/dist/types/utils/CommandType.d.ts +3 -0
- package/dist/types/utils/Type.d.ts +2 -1
- package/dist/utils/Command.cjs +40 -0
- package/dist/utils/CommandType.cjs +4 -1
- package/dist/utils/Type.cjs +2 -1
- package/lib/core/handler/ArraySetItemHandler.js +11 -10
- package/lib/core/handler/AsDtoHandler.js +11 -0
- package/lib/core/handler/AsKwargsHandler.js +1 -1
- package/lib/core/handler/DtoPropertyHandler.js +11 -0
- package/lib/core/handler/Handler.js +16 -7
- package/lib/core/handler/PassDelegateHandler.js +2 -1
- package/lib/core/handler/ProjectResultAsDtoHandler.js +47 -0
- package/lib/core/handler/SetInstanceFieldHandler.js +1 -1
- package/lib/core/handler/SetStaticFieldHandler.js +6 -6
- package/lib/core/interpreter/Interpreter.js +18 -4
- package/lib/core/protocol/CommandDeserializer.js +9 -0
- package/lib/core/protocol/TypeDeserializer.js +5 -0
- package/lib/core/protocol/TypeSerializer.js +11 -8
- package/lib/core/webSocketClient/WebSocketClient.js +30 -5
- package/lib/core/webSocketClient/WebSocketClientBrowser.js +29 -5
- package/lib/plugins/PluginImplementationRegistry.js +231 -0
- package/lib/plugins/PluginPayloadBuilder.js +60 -0
- package/lib/plugins/PluginRegistry.js +295 -0
- package/lib/plugins/index.js +29 -0
- package/lib/plugins/interfaces/ICommunityPlugin.js +25 -0
- package/lib/plugins/interfaces/ICommunityReceivingPlugin.js +57 -0
- package/lib/plugins/interfaces/ICommunitySendingPlugin.js +42 -0
- package/lib/plugins/settings/BasePluginSettings.js +79 -0
- package/lib/plugins/settings/JwtGraftocodePluginSettings.js +43 -0
- package/lib/sdk/InvocationContext.js +149 -14
- package/lib/sdk/RuntimeContext.js +33 -9
- package/lib/sdk/configuration/configResolvers/ConfigResolver.js +14 -8
- package/lib/sdk/configuration/configResolvers/ConnectionStringConfigResolver.js +2 -2
- package/lib/sdk/configuration/configResolvers/JsonConfigResolver.js +2 -2
- package/lib/sdk/configuration/configResolvers/YamlConfigResolver.js +5 -5
- package/lib/sdk/tools/DtoHelper.js +90 -0
- package/lib/utils/Command.js +47 -0
- package/lib/utils/CommandType.js +3 -0
- package/lib/utils/Type.js +2 -1
- package/package.json +5 -1
- package/dist/sdk/tools/ActivationHelper.cjs +0 -66
- package/dist/types/sdk/tools/ActivationHelper.d.ts +0 -20
- package/lib/sdk/tools/ActivationHelper.js +0 -51
|
@@ -0,0 +1,62 @@
|
|
|
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 ICommunityReceivingPlugin_exports = {};
|
|
20
|
+
__export(ICommunityReceivingPlugin_exports, {
|
|
21
|
+
ICommunityReceivingPlugin: () => ICommunityReceivingPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ICommunityReceivingPlugin_exports);
|
|
24
|
+
var import_ICommunityPlugin = require("./ICommunityPlugin.cjs");
|
|
25
|
+
class ICommunityReceivingPlugin extends import_ICommunityPlugin.ICommunityPlugin {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of ICommunityReceivingPlugin
|
|
28
|
+
* This is a base class and should not be instantiated directly.
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
if (new.target === ICommunityReceivingPlugin) {
|
|
33
|
+
throw new TypeError("Cannot construct ICommunityReceivingPlugin instances directly");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Executes the plugin using the provided payload as input.
|
|
38
|
+
* This method is called after receiving commands from the target runtime.
|
|
39
|
+
*
|
|
40
|
+
* @abstract
|
|
41
|
+
* @param {object} commandPayload - The input payload used during execution.
|
|
42
|
+
* @param {ExecutionTarget} executionTarget - Defines the execution target, including the target type name
|
|
43
|
+
* and the method name that will be invoked just before execution.
|
|
44
|
+
* @returns {IExecutionContext} An execution context representing the execution result.
|
|
45
|
+
* @throws {Error} If not implemented by derived class
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* class ValidationPlugin extends ICommunityReceivingPlugin {
|
|
49
|
+
* execute(commandPayload, executionTarget) {
|
|
50
|
+
* console.log('Validating:', executionTarget)
|
|
51
|
+
* return { isValid: true, result: commandPayload }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
*/
|
|
55
|
+
execute(commandPayload, executionTarget) {
|
|
56
|
+
throw new Error("Method execute(commandPayload, executionTarget) must be implemented by derived class");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
ICommunityReceivingPlugin
|
|
62
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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 ICommunitySendingPlugin_exports = {};
|
|
20
|
+
__export(ICommunitySendingPlugin_exports, {
|
|
21
|
+
ICommunitySendingPlugin: () => ICommunitySendingPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ICommunitySendingPlugin_exports);
|
|
24
|
+
var import_ICommunityPlugin = require("./ICommunityPlugin.cjs");
|
|
25
|
+
class ICommunitySendingPlugin extends import_ICommunityPlugin.ICommunityPlugin {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of ICommunitySendingPlugin
|
|
28
|
+
* This is a base class and should not be instantiated directly.
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
if (new.target === ICommunitySendingPlugin) {
|
|
33
|
+
throw new TypeError("Cannot construct ICommunitySendingPlugin instances directly");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Executes the plugin and returns the result.
|
|
38
|
+
* This method is called before sending commands to the target runtime.
|
|
39
|
+
* The returned object will be serialized and included in the command payload.
|
|
40
|
+
*
|
|
41
|
+
* @abstract
|
|
42
|
+
* @returns {object} The result of plugin execution as an object.
|
|
43
|
+
* @throws {Error} If not implemented by derived class
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* class JwtPlugin extends ICommunitySendingPlugin {
|
|
47
|
+
* execute() {
|
|
48
|
+
* return { token: 'abc123', timestamp: Date.now() }
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
execute() {
|
|
53
|
+
throw new Error("Method execute() must be implemented by derived class");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
ICommunitySendingPlugin
|
|
59
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
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 BasePluginSettings_exports = {};
|
|
20
|
+
__export(BasePluginSettings_exports, {
|
|
21
|
+
BasePluginSettings: () => BasePluginSettings,
|
|
22
|
+
PluginLangType: () => PluginLangType
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(BasePluginSettings_exports);
|
|
25
|
+
class BasePluginSettings {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of BasePluginSettings.
|
|
28
|
+
* This is a base class and should not be instantiated directly.
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
if (new.target === BasePluginSettings) {
|
|
32
|
+
throw new TypeError("Cannot construct BasePluginSettings instances directly");
|
|
33
|
+
}
|
|
34
|
+
this.pluginId = "";
|
|
35
|
+
this.pluginPath = "";
|
|
36
|
+
this.pluginLangType = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const PluginLangType = {
|
|
40
|
+
/** .NET Framework (legacy) implementation */
|
|
41
|
+
Clr: 0,
|
|
42
|
+
/** Go implementation */
|
|
43
|
+
Go: 1,
|
|
44
|
+
/** Java class or JAR-based plugin */
|
|
45
|
+
Jvm: 2,
|
|
46
|
+
/** .NET Core / .NET 5+ implementation */
|
|
47
|
+
Netcore: 3,
|
|
48
|
+
/** Perl script or module */
|
|
49
|
+
Perl: 4,
|
|
50
|
+
/** Python script or module */
|
|
51
|
+
Python: 5,
|
|
52
|
+
/** Ruby script or library */
|
|
53
|
+
Ruby: 6,
|
|
54
|
+
/** Node.js JavaScript module */
|
|
55
|
+
Nodejs: 7,
|
|
56
|
+
/** C++ script or class-based plugin */
|
|
57
|
+
Cpp: 8,
|
|
58
|
+
/** PHP script or class-based plugin */
|
|
59
|
+
Php: 9,
|
|
60
|
+
/** Python 2.7 script or class-based plugin */
|
|
61
|
+
Python27: 10
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
BasePluginSettings,
|
|
66
|
+
PluginLangType
|
|
67
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
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 JwtGraftocodePluginSettings_exports = {};
|
|
20
|
+
__export(JwtGraftocodePluginSettings_exports, {
|
|
21
|
+
JwtGraftocodePluginSettings: () => JwtGraftocodePluginSettings
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(JwtGraftocodePluginSettings_exports);
|
|
24
|
+
var import_BasePluginSettings = require("./BasePluginSettings.cjs");
|
|
25
|
+
class JwtGraftocodePluginSettings extends import_BasePluginSettings.BasePluginSettings {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of JwtGraftocodePluginSettings.
|
|
28
|
+
*/
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this.username = "";
|
|
32
|
+
this.secretKey = "";
|
|
33
|
+
this.useAttributes = false;
|
|
34
|
+
this.jwtAuthorizeClass = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
JwtGraftocodePluginSettings
|
|
40
|
+
});
|
|
@@ -28,6 +28,7 @@ var import_CommandType = require("../utils/CommandType.cjs");
|
|
|
28
28
|
var import_ExceptionThrower = require("../utils/exception/ExceptionThrower.cjs");
|
|
29
29
|
var import_RuntimeName = require("../utils/RuntimeName.cjs");
|
|
30
30
|
var import_TypesHandler = require("../utils/TypesHandler.cjs");
|
|
31
|
+
var import_DtoHelper = require("./tools/DtoHelper.cjs");
|
|
31
32
|
var import_uuid = require("uuid");
|
|
32
33
|
class AsyncLock {
|
|
33
34
|
constructor() {
|
|
@@ -42,6 +43,8 @@ class AsyncLock {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
class InvocationContext {
|
|
46
|
+
/** @type {string} */
|
|
47
|
+
#runtimeContextId;
|
|
45
48
|
/** @type {RuntimeNameType} */
|
|
46
49
|
#runtimeName;
|
|
47
50
|
/** @type {IConnectionData} */
|
|
@@ -52,6 +55,8 @@ class InvocationContext {
|
|
|
52
55
|
#responseCommand = null;
|
|
53
56
|
/** @type {boolean} */
|
|
54
57
|
#isExecuted = false;
|
|
58
|
+
/** @type {boolean} */
|
|
59
|
+
#isDto = false;
|
|
55
60
|
/** @type {string | null} */
|
|
56
61
|
#guid = null;
|
|
57
62
|
/** @type {AsyncLock} */
|
|
@@ -61,18 +66,22 @@ class InvocationContext {
|
|
|
61
66
|
//
|
|
62
67
|
/**
|
|
63
68
|
*
|
|
69
|
+
* @param {string} runtimeContextId
|
|
64
70
|
* @param {RuntimeNameType} runtimeName
|
|
65
71
|
* @param {IConnectionData} connectionData
|
|
66
|
-
* @param {Command} command
|
|
72
|
+
* @param {Command | null} command
|
|
67
73
|
* @param {boolean} isExecuted
|
|
74
|
+
* @param {boolean} isDto
|
|
68
75
|
*/
|
|
69
|
-
constructor(runtimeName, connectionData, command, isExecuted = false) {
|
|
76
|
+
constructor(runtimeContextId, runtimeName, connectionData, command, isExecuted = false, isDto = false) {
|
|
77
|
+
this.#runtimeContextId = runtimeContextId;
|
|
70
78
|
this.#runtimeName = runtimeName;
|
|
71
79
|
this.#connectionData = connectionData;
|
|
72
80
|
this.#currentCommand = command;
|
|
73
81
|
this.#responseCommand = null;
|
|
74
82
|
this.#isExecuted = isExecuted;
|
|
75
83
|
this.#guid = (0, import_uuid.v4)();
|
|
84
|
+
this.#isDto = isDto;
|
|
76
85
|
}
|
|
77
86
|
/**
|
|
78
87
|
* @returns {string} guid of this InvocationContext
|
|
@@ -86,9 +95,12 @@ class InvocationContext {
|
|
|
86
95
|
*/
|
|
87
96
|
#createInstanceContext(localCommand) {
|
|
88
97
|
return new InvocationContext(
|
|
98
|
+
this.#runtimeContextId,
|
|
89
99
|
this.#runtimeName,
|
|
90
100
|
this.#connectionData,
|
|
91
|
-
this.#buildCommand(localCommand)
|
|
101
|
+
this.#buildCommand(localCommand),
|
|
102
|
+
this.#isExecuted,
|
|
103
|
+
this.#isDto
|
|
92
104
|
);
|
|
93
105
|
}
|
|
94
106
|
/**
|
|
@@ -132,6 +144,9 @@ class InvocationContext {
|
|
|
132
144
|
if (this.#currentCommand === null) {
|
|
133
145
|
throw new Error("currentCommand is undefined in Invocation Context execute method");
|
|
134
146
|
}
|
|
147
|
+
if (this.#isDto) {
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
135
150
|
const entries = Array.from(InvocationContext._invocationContexts.entries());
|
|
136
151
|
entries.sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
137
152
|
const releases = [];
|
|
@@ -141,6 +156,7 @@ class InvocationContext {
|
|
|
141
156
|
}
|
|
142
157
|
try {
|
|
143
158
|
this.#responseCommand = await import_Interpreter.Interpreter.execute(
|
|
159
|
+
this.#runtimeContextId,
|
|
144
160
|
this.#currentCommand,
|
|
145
161
|
this.#connectionData
|
|
146
162
|
);
|
|
@@ -151,12 +167,17 @@ class InvocationContext {
|
|
|
151
167
|
throw import_ExceptionThrower.ExceptionThrower.throwException(this.#responseCommand);
|
|
152
168
|
}
|
|
153
169
|
this.#responseCommand = this.#processUpdateInvocationContextCommands(this.#responseCommand);
|
|
154
|
-
if (this.#
|
|
155
|
-
|
|
156
|
-
this.#isExecuted = true;
|
|
157
|
-
return this;
|
|
170
|
+
if (this.#currentCommand.commandType === import_CommandType.CommandType.ProjectResultAsDto) {
|
|
171
|
+
return this.#convertResponseToDto();
|
|
158
172
|
}
|
|
159
|
-
return new InvocationContext(
|
|
173
|
+
return new InvocationContext(
|
|
174
|
+
this.#runtimeContextId,
|
|
175
|
+
this.#runtimeName,
|
|
176
|
+
this.#connectionData,
|
|
177
|
+
this.#responseCommand,
|
|
178
|
+
true,
|
|
179
|
+
this.#isDto
|
|
180
|
+
);
|
|
160
181
|
} finally {
|
|
161
182
|
for (let i = releases.length - 1; i >= 0; i--) {
|
|
162
183
|
try {
|
|
@@ -194,7 +215,9 @@ class InvocationContext {
|
|
|
194
215
|
const instanceGuid = String(cmdPayload[1]);
|
|
195
216
|
const invCtx = InvocationContext._invocationContexts.get(contextGuid);
|
|
196
217
|
if (invCtx) {
|
|
197
|
-
invCtx.#currentCommand = new import_Command.Command(invCtx.#runtimeName, import_CommandType.CommandType.Reference, [
|
|
218
|
+
invCtx.#currentCommand = new import_Command.Command(invCtx.#runtimeName, import_CommandType.CommandType.Reference, [
|
|
219
|
+
instanceGuid
|
|
220
|
+
]);
|
|
198
221
|
InvocationContext._invocationContexts.delete(contextGuid);
|
|
199
222
|
}
|
|
200
223
|
}
|
|
@@ -252,6 +275,9 @@ class InvocationContext {
|
|
|
252
275
|
createInstance(...args) {
|
|
253
276
|
const localCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.CreateClassInstance, [...args]);
|
|
254
277
|
const createInstanceInvCtx = this.#createInstanceContext(localCommand);
|
|
278
|
+
if (this.#isDto) {
|
|
279
|
+
return createInstanceInvCtx;
|
|
280
|
+
}
|
|
255
281
|
return createInstanceInvCtx.#registerForUpdate();
|
|
256
282
|
}
|
|
257
283
|
/**
|
|
@@ -259,7 +285,9 @@ class InvocationContext {
|
|
|
259
285
|
* @returns {InvocationContext}
|
|
260
286
|
*/
|
|
261
287
|
#registerForUpdate() {
|
|
262
|
-
this.#currentCommand = this.#buildCommand(
|
|
288
|
+
this.#currentCommand = this.#buildCommand(
|
|
289
|
+
new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.RegisterForUpdate, [this.getGuid()])
|
|
290
|
+
);
|
|
263
291
|
InvocationContext._invocationContexts.set(this.getGuid(), this);
|
|
264
292
|
return this;
|
|
265
293
|
}
|
|
@@ -271,6 +299,18 @@ class InvocationContext {
|
|
|
271
299
|
* @method
|
|
272
300
|
*/
|
|
273
301
|
getInstanceField(fieldName) {
|
|
302
|
+
if (this.#isDto) {
|
|
303
|
+
const value = import_DtoHelper.DtoHelper.tryGetDtoFieldValue(this.#currentCommand, fieldName);
|
|
304
|
+
const valueCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.Value, [value]);
|
|
305
|
+
return new InvocationContext(
|
|
306
|
+
this.#runtimeContextId,
|
|
307
|
+
this.#runtimeName,
|
|
308
|
+
this.#connectionData,
|
|
309
|
+
valueCommand,
|
|
310
|
+
false,
|
|
311
|
+
this.#isDto
|
|
312
|
+
);
|
|
313
|
+
}
|
|
274
314
|
let localCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.GetInstanceField, [fieldName]);
|
|
275
315
|
return this.#createInstanceContext(localCommand);
|
|
276
316
|
}
|
|
@@ -284,7 +324,19 @@ class InvocationContext {
|
|
|
284
324
|
*/
|
|
285
325
|
setInstanceField(fieldName, value) {
|
|
286
326
|
let localCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.SetInstanceField, [fieldName, value]);
|
|
287
|
-
|
|
327
|
+
const newCommand = this.#buildCommand(localCommand);
|
|
328
|
+
if (this.#isDto) {
|
|
329
|
+
this.#currentCommand = newCommand;
|
|
330
|
+
return this;
|
|
331
|
+
}
|
|
332
|
+
return new InvocationContext(
|
|
333
|
+
this.#runtimeContextId,
|
|
334
|
+
this.#runtimeName,
|
|
335
|
+
this.#connectionData,
|
|
336
|
+
newCommand,
|
|
337
|
+
this.#isExecuted,
|
|
338
|
+
this.#isDto
|
|
339
|
+
);
|
|
288
340
|
}
|
|
289
341
|
/**
|
|
290
342
|
* Invokes an instance method on the target runtime.
|
|
@@ -447,6 +499,44 @@ class InvocationContext {
|
|
|
447
499
|
]);
|
|
448
500
|
return this.#createInstanceContext(localCommand);
|
|
449
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Returns a new InvocationContext that acts as a DTO (Data Transfer Object).
|
|
504
|
+
* When actAsDto is true, field get/set operate on local state without remote calls.
|
|
505
|
+
* @param {boolean} actAsDto - Whether to treat this context as a DTO.
|
|
506
|
+
* @returns {InvocationContext} A new InvocationContext with the DTO flag set.
|
|
507
|
+
* @method
|
|
508
|
+
*/
|
|
509
|
+
asDto(actAsDto = true) {
|
|
510
|
+
return new InvocationContext(
|
|
511
|
+
this.#runtimeContextId,
|
|
512
|
+
this.#runtimeName,
|
|
513
|
+
this.#connectionData,
|
|
514
|
+
this.#currentCommand,
|
|
515
|
+
false,
|
|
516
|
+
actAsDto
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Projects the result as a DTO with the specified property names.
|
|
521
|
+
* When propertiesNames is a single empty string, returns this context unchanged.
|
|
522
|
+
* @param {...string} propertiesNames - Names of properties to include in the DTO.
|
|
523
|
+
* @returns {InvocationContext} A new InvocationContext that will materialize as a DTO.
|
|
524
|
+
* @method
|
|
525
|
+
*/
|
|
526
|
+
projectResultAsDto(...propertiesNames) {
|
|
527
|
+
if (propertiesNames.length === 1 && (propertiesNames[0] === null || propertiesNames[0] === "")) {
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
let localCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.ProjectResultAsDto, propertiesNames);
|
|
531
|
+
return new InvocationContext(
|
|
532
|
+
this.#runtimeContextId,
|
|
533
|
+
this.#runtimeName,
|
|
534
|
+
this.#connectionData,
|
|
535
|
+
this.#buildCommand(localCommand),
|
|
536
|
+
false,
|
|
537
|
+
false
|
|
538
|
+
);
|
|
539
|
+
}
|
|
450
540
|
/**
|
|
451
541
|
* Retrieves the type of the object from the target runtime.
|
|
452
542
|
* @returns {Promise<string>} The type of the object.
|
|
@@ -456,6 +546,7 @@ class InvocationContext {
|
|
|
456
546
|
async getResultType() {
|
|
457
547
|
const localCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.GetResultType, []);
|
|
458
548
|
const invocationContext = new InvocationContext(
|
|
549
|
+
this.#runtimeContextId,
|
|
459
550
|
this.#runtimeName,
|
|
460
551
|
this.#connectionData,
|
|
461
552
|
this.#buildCommand(localCommand)
|
|
@@ -481,6 +572,7 @@ class InvocationContext {
|
|
|
481
572
|
async retrieveArray() {
|
|
482
573
|
const localCommand = new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.RetrieveArray, []);
|
|
483
574
|
const localInvCtx = new InvocationContext(
|
|
575
|
+
this.#runtimeContextId,
|
|
484
576
|
this.#runtimeName,
|
|
485
577
|
this.#connectionData,
|
|
486
578
|
this.#buildCommand(localCommand)
|
|
@@ -504,9 +596,12 @@ class InvocationContext {
|
|
|
504
596
|
}
|
|
505
597
|
/**
|
|
506
598
|
* @param {Command} command
|
|
507
|
-
* @returns {Command}
|
|
599
|
+
* @returns {Command | null}
|
|
508
600
|
*/
|
|
509
601
|
#buildCommand(command) {
|
|
602
|
+
if (!command) {
|
|
603
|
+
return this.#currentCommand;
|
|
604
|
+
}
|
|
510
605
|
for (let i = 0; i < command.payload.length; i++) {
|
|
511
606
|
command.payload[i] = this.#encapsulatePayloadItem(command.payload[i]);
|
|
512
607
|
}
|
|
@@ -543,6 +638,32 @@ class InvocationContext {
|
|
|
543
638
|
);
|
|
544
639
|
}
|
|
545
640
|
}
|
|
641
|
+
#convertResponseToDto() {
|
|
642
|
+
const responseCommand = this.#responseCommand;
|
|
643
|
+
const getTypeCommand = responseCommand.payload[1];
|
|
644
|
+
let projectResultAsDtoInvCtx = new InvocationContext(
|
|
645
|
+
this.#runtimeContextId,
|
|
646
|
+
this.#runtimeName,
|
|
647
|
+
this.#connectionData,
|
|
648
|
+
new import_Command.Command(this.#runtimeName, import_CommandType.CommandType.CreateClassInstance, [getTypeCommand]),
|
|
649
|
+
true,
|
|
650
|
+
true
|
|
651
|
+
);
|
|
652
|
+
if (responseCommand.payload.length >= 3) {
|
|
653
|
+
for (let i = 2; i < responseCommand.payload.length; i++) {
|
|
654
|
+
const item = responseCommand.payload[i];
|
|
655
|
+
if (item instanceof import_Command.Command && item.commandType === import_CommandType.CommandType.DtoProperty) {
|
|
656
|
+
const propertyName = item.payload[0] ? String(item.payload[0]) : "";
|
|
657
|
+
const propertyValue = item.payload.length > 1 ? item.payload[1] : "";
|
|
658
|
+
projectResultAsDtoInvCtx = projectResultAsDtoInvCtx.setInstanceField(
|
|
659
|
+
propertyName,
|
|
660
|
+
propertyValue
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return projectResultAsDtoInvCtx;
|
|
666
|
+
}
|
|
546
667
|
}
|
|
547
668
|
// Annotate the CommonJS export names for ESM import in node:
|
|
548
669
|
0 && (module.exports = {
|
|
@@ -33,6 +33,7 @@ var import_TypesHandler = require("../utils/TypesHandler.cjs");
|
|
|
33
33
|
var import_UtilsConst = require("../utils/UtilsConst.cjs");
|
|
34
34
|
var import_Config = require("./configuration/Config.cjs");
|
|
35
35
|
var import_Runtime = require("../utils/Runtime.cjs");
|
|
36
|
+
var import_generateGuid = require("../utils/guid/generateGuid.cjs");
|
|
36
37
|
const import_meta = {};
|
|
37
38
|
let _Transmitter = null;
|
|
38
39
|
const requireDynamic = (0, import_Runtime.getRequire)(import_meta.url);
|
|
@@ -47,6 +48,8 @@ class RuntimeContext {
|
|
|
47
48
|
#currentCommand = null;
|
|
48
49
|
/** @type {Command | null} */
|
|
49
50
|
#responseCommand = null;
|
|
51
|
+
/** @type {string} Unique identifier for this runtime context instance */
|
|
52
|
+
#runtimeContextId = "";
|
|
50
53
|
/**
|
|
51
54
|
* @param {RuntimeNameType} runtimeName
|
|
52
55
|
* @param {IConnectionData} connectionData
|
|
@@ -55,6 +58,7 @@ class RuntimeContext {
|
|
|
55
58
|
this._isExecuted = false;
|
|
56
59
|
this.runtimeName = runtimeName;
|
|
57
60
|
this.connectionData = connectionData;
|
|
61
|
+
this.#runtimeContextId = (0, import_generateGuid.generateGUID)();
|
|
58
62
|
if (this.connectionData.connectionType === import_ConnectionType.ConnectionType.WEB_SOCKET) {
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
@@ -105,6 +109,7 @@ class RuntimeContext {
|
|
|
105
109
|
const runtimeCtx = RuntimeContext.memoryRuntimeContexts.get(key);
|
|
106
110
|
if (!runtimeCtx) throw new Error("Runtime context not found");
|
|
107
111
|
runtimeCtx.#currentCommand = null;
|
|
112
|
+
runtimeCtx.#runtimeContextId = (0, import_generateGuid.generateGUID)();
|
|
108
113
|
return runtimeCtx;
|
|
109
114
|
} else {
|
|
110
115
|
if (!_Transmitter) {
|
|
@@ -121,6 +126,7 @@ class RuntimeContext {
|
|
|
121
126
|
const runtimeCtx = RuntimeContext.networkRuntimeContexts.get(key1);
|
|
122
127
|
if (!runtimeCtx) throw new Error("Runtime context not found");
|
|
123
128
|
runtimeCtx.#currentCommand = null;
|
|
129
|
+
runtimeCtx.#runtimeContextId = (0, import_generateGuid.generateGUID)();
|
|
124
130
|
return runtimeCtx;
|
|
125
131
|
} else {
|
|
126
132
|
if (!_Transmitter) {
|
|
@@ -138,6 +144,7 @@ class RuntimeContext {
|
|
|
138
144
|
const runtimeCtx = RuntimeContext.webSocketRuntimeContexts.get(key2);
|
|
139
145
|
if (!runtimeCtx) throw new Error("Runtime context not found");
|
|
140
146
|
runtimeCtx.#currentCommand = null;
|
|
147
|
+
runtimeCtx.#runtimeContextId = (0, import_generateGuid.generateGUID)();
|
|
141
148
|
return runtimeCtx;
|
|
142
149
|
} else {
|
|
143
150
|
const runtimeCtx = new RuntimeContext(runtimeName, connectionData);
|
|
@@ -149,6 +156,14 @@ class RuntimeContext {
|
|
|
149
156
|
throw new Error("Invalid connection type");
|
|
150
157
|
}
|
|
151
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Gets the unique runtime context ID for this instance.
|
|
161
|
+
* This ID is used to associate plugins with specific runtime contexts.
|
|
162
|
+
* @returns {string} The runtime context ID (GUID/UUID string)
|
|
163
|
+
*/
|
|
164
|
+
get runtimeContextId() {
|
|
165
|
+
return this.#runtimeContextId;
|
|
166
|
+
}
|
|
152
167
|
/**
|
|
153
168
|
* Executes the current command. The initial state of RuntimeContext is non-materialized,
|
|
154
169
|
* wrapping either a single command or a chain of recursively nested commands.
|
|
@@ -163,7 +178,7 @@ class RuntimeContext {
|
|
|
163
178
|
if (!this.#currentCommand) {
|
|
164
179
|
throw new Error("currentCommand is undefined in Runtime Context execute method");
|
|
165
180
|
}
|
|
166
|
-
this.#responseCommand = await import_Interpreter.Interpreter.execute(this.#currentCommand, this.connectionData);
|
|
181
|
+
this.#responseCommand = await import_Interpreter.Interpreter.execute(this.#runtimeContextId, this.#currentCommand, this.connectionData);
|
|
167
182
|
this.#currentCommand = null;
|
|
168
183
|
if (this.#responseCommand === void 0) {
|
|
169
184
|
throw new Error("responseCommand is undefined in Runtime Context execute method");
|
|
@@ -198,7 +213,7 @@ class RuntimeContext {
|
|
|
198
213
|
getType(typeName, ...args) {
|
|
199
214
|
let localCommand = new import_Command.Command(this.runtimeName, import_CommandType.CommandType.GetType, [typeName, ...args]);
|
|
200
215
|
this.#currentCommand = null;
|
|
201
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
216
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
202
217
|
}
|
|
203
218
|
/**
|
|
204
219
|
* Casts the provided value to a specific type. This method is used when invoking methods that require specific types of arguments.
|
|
@@ -212,7 +227,7 @@ class RuntimeContext {
|
|
|
212
227
|
cast(...args) {
|
|
213
228
|
let localCommand = new import_Command.Command(this.runtimeName, import_CommandType.CommandType.Cast, args);
|
|
214
229
|
this.#currentCommand = null;
|
|
215
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
230
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
216
231
|
}
|
|
217
232
|
/**
|
|
218
233
|
* Retrieves a specific item from an enum type. This method is used when working with enums from the called runtime.
|
|
@@ -226,7 +241,7 @@ class RuntimeContext {
|
|
|
226
241
|
getEnumItem(...args) {
|
|
227
242
|
let localCommand = new import_Command.Command(this.runtimeName, import_CommandType.CommandType.GetEnumItem, args);
|
|
228
243
|
this.#currentCommand = null;
|
|
229
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
244
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
230
245
|
}
|
|
231
246
|
/**
|
|
232
247
|
* Creates a reference type argument that can be passed to a method with a ref parameter modifier. This method is used when working with methods from the called runtime that require arguments to be passed by reference.
|
|
@@ -240,7 +255,7 @@ class RuntimeContext {
|
|
|
240
255
|
asRef(...args) {
|
|
241
256
|
let localCommand = new import_Command.Command(this.runtimeName, import_CommandType.CommandType.AsRef, args);
|
|
242
257
|
this.#currentCommand = null;
|
|
243
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
258
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
244
259
|
}
|
|
245
260
|
/**
|
|
246
261
|
* Creates a reference type argument that can be passed to a method with an out parameter modifier. This method is used when working with methods from the called runtime that require arguments to be passed by reference.
|
|
@@ -254,7 +269,7 @@ class RuntimeContext {
|
|
|
254
269
|
asOut(...args) {
|
|
255
270
|
let localCommand = new import_Command.Command(this.runtimeName, import_CommandType.CommandType.AsOut, args);
|
|
256
271
|
this.#currentCommand = null;
|
|
257
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
272
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
258
273
|
}
|
|
259
274
|
/**
|
|
260
275
|
* Retrieves the value of a global field from the target runtime.
|
|
@@ -266,7 +281,7 @@ class RuntimeContext {
|
|
|
266
281
|
getGlobalField(fieldName) {
|
|
267
282
|
let localCommand = new import_Command.Command(this.runtimeName, import_CommandType.CommandType.GetGlobalField, [fieldName]);
|
|
268
283
|
this.#currentCommand = null;
|
|
269
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
284
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
270
285
|
}
|
|
271
286
|
/**
|
|
272
287
|
* Invokes a function from the called runtime. This method is used when working with functions from the called runtime.
|
|
@@ -284,13 +299,16 @@ class RuntimeContext {
|
|
|
284
299
|
...args
|
|
285
300
|
]);
|
|
286
301
|
this.#currentCommand = null;
|
|
287
|
-
return new import_InvocationContext.InvocationContext(this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
302
|
+
return new import_InvocationContext.InvocationContext(this.#runtimeContextId, this.runtimeName, this.connectionData, this.#buildCommand(localCommand));
|
|
288
303
|
}
|
|
289
304
|
/**
|
|
290
305
|
* @param {Command} command
|
|
291
|
-
* @returns {Command}
|
|
306
|
+
* @returns {Command | null}
|
|
292
307
|
*/
|
|
293
308
|
#buildCommand(command) {
|
|
309
|
+
if (!command) {
|
|
310
|
+
return this.#currentCommand;
|
|
311
|
+
}
|
|
294
312
|
for (let i = 0; i < command.payload.length; i++) {
|
|
295
313
|
command.payload[i] = this.#encapsulatePayloadItem(command.payload[i]);
|
|
296
314
|
}
|