javonet-nodejs-sdk 2.6.7 → 2.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/core/handler/Handler.cjs +2 -7
  2. package/dist/core/handler/LoadLibraryHandler.cjs +15 -9
  3. package/dist/core/handler/PassDelegateHandler.cjs +2 -2
  4. package/dist/core/interpreter/Interpreter.cjs +11 -33
  5. package/dist/core/protocol/CommandSerializer.cjs +3 -8
  6. package/dist/core/receiver/Receiver.cjs +6 -6
  7. package/dist/sdk/Activator.cjs +44 -0
  8. package/dist/sdk/ActivatorDetails.cjs +13 -3
  9. package/dist/sdk/ConfigRuntimeFactory.cjs +9 -0
  10. package/dist/sdk/InvocationContext.cjs +49 -56
  11. package/dist/sdk/Javonet.cjs +3 -0
  12. package/dist/sdk/RuntimeContext.cjs +8 -8
  13. package/dist/sdk/configuration/ConfigSourceResolver.cjs +43 -21
  14. package/dist/sdk/tools/ComplexTypeResolver.cjs +84 -34
  15. package/dist/types/core/handler/Handler.d.ts +2 -1
  16. package/dist/types/core/handler/PassDelegateHandler.d.ts +2 -2
  17. package/dist/types/core/interpreter/Interpreter.d.ts +2 -2
  18. package/dist/types/core/protocol/CommandSerializer.d.ts +3 -3
  19. package/dist/types/core/receiver/Receiver.d.ts +4 -4
  20. package/dist/types/sdk/Activator.d.ts +12 -0
  21. package/dist/types/sdk/ActivatorDetails.d.ts +5 -3
  22. package/dist/types/sdk/ConfigRuntimeFactory.d.ts +7 -0
  23. package/dist/types/sdk/InvocationContext.d.ts +11 -10
  24. package/dist/types/sdk/Javonet.d.ts +2 -1
  25. package/dist/types/sdk/RuntimeContext.d.ts +4 -3
  26. package/dist/types/sdk/configuration/ConfigSourceResolver.d.ts +21 -4
  27. package/dist/types/sdk/tools/ComplexTypeResolver.d.ts +21 -5
  28. package/dist/types/utils/Primitives.d.ts +5 -0
  29. package/dist/utils/Primitives.cjs +201 -0
  30. package/lib/core/handler/Handler.js +2 -7
  31. package/lib/core/handler/LoadLibraryHandler.js +28 -14
  32. package/lib/core/handler/PassDelegateHandler.js +2 -2
  33. package/lib/core/interpreter/Interpreter.js +11 -35
  34. package/lib/core/protocol/CommandSerializer.js +5 -10
  35. package/lib/core/receiver/Receiver.js +6 -6
  36. package/lib/sdk/Activator.js +22 -0
  37. package/lib/sdk/ActivatorDetails.js +18 -3
  38. package/lib/sdk/ConfigRuntimeFactory.js +10 -0
  39. package/lib/sdk/InvocationContext.js +51 -65
  40. package/lib/sdk/Javonet.js +2 -0
  41. package/lib/sdk/RuntimeContext.js +8 -8
  42. package/lib/sdk/configuration/ConfigSourceResolver.js +47 -14
  43. package/lib/sdk/tools/ComplexTypeResolver.js +104 -42
  44. package/lib/utils/Primitives.js +193 -0
  45. package/package.json +1 -1
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,32 +15,39 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var ConfigSourceResolver_exports = {};
30
20
  __export(ConfigSourceResolver_exports, {
31
21
  ConfigSourceResolver: () => ConfigSourceResolver
32
22
  });
33
23
  module.exports = __toCommonJS(ConfigSourceResolver_exports);
34
- var import_fs = __toESM(require("fs"), 1);
35
- var import_process = __toESM(require("process"), 1);
36
24
  var import_ConfigsDictionary = require("./ConfigsDictionary.cjs");
37
25
  var import_JsonConfigResolver = require("./configResolvers/JsonConfigResolver.cjs");
38
26
  var import_YamlConfigResolver = require("./configResolvers/YamlConfigResolver.cjs");
39
27
  var import_ConnectionStringConfigResolver = require("./configResolvers/ConnectionStringConfigResolver.cjs");
28
+ var import_Runtime = require("../../utils/Runtime.cjs");
29
+ const import_meta = {};
30
+ let fs = null;
31
+ let process = null;
32
+ const requireDynamic = (0, import_Runtime.getRequire)(import_meta.url);
40
33
  class ConfigSourceResolver {
34
+ /**
35
+ * @param {import('./ConfigPriority.js').ConfigPriority} priority
36
+ * @param {string | any} configSource
37
+ */
41
38
  static addConfigs(priority, configSource) {
42
39
  console.log(`Adding config from source: ${configSource} with priority '${priority}'`);
43
- const configString = ConfigSourceResolver._getConfigSourceAsString(configSource);
44
- ConfigSourceResolver._parseConfigsAndAddToCollection(priority, configString);
40
+ if (configSource && typeof configSource === "object") {
41
+ import_JsonConfigResolver.JsonConfigResolver.addConfigs(priority, configSource);
42
+ } else {
43
+ const configString = ConfigSourceResolver._getConfigSourceAsString(configSource);
44
+ ConfigSourceResolver._parseConfigsAndAddToCollection(priority, configString);
45
+ }
45
46
  }
47
+ /**
48
+ * @param {string} configName
49
+ * @returns {*}
50
+ */
46
51
  static getConfig(configName) {
47
52
  console.log(`Retrieving config ${configName}`);
48
53
  return import_ConfigsDictionary.ConfigsDictionary.getConfig(configName);
@@ -50,19 +55,36 @@ class ConfigSourceResolver {
50
55
  static clearConfigs() {
51
56
  import_ConfigsDictionary.ConfigsDictionary.clearConfigs();
52
57
  }
58
+ /**
59
+ * @param {string} configSource
60
+ * @returns {string}
61
+ */
53
62
  static _getConfigSourceAsString(configSource) {
54
63
  if (!configSource || configSource.trim() === "") {
55
64
  throw new Error("Config source cannot be null or whitespace.");
56
65
  }
57
- const envValue = import_process.default.env[configSource];
58
- if (envValue && envValue.trim() !== "") {
59
- configSource = envValue;
60
- }
61
- if (import_fs.default.existsSync(configSource) && import_fs.default.statSync(configSource).isFile()) {
62
- configSource = import_fs.default.readFileSync(configSource, { encoding: "utf-8" });
66
+ if ((0, import_Runtime.isNodejsRuntime)()) {
67
+ if (!process) {
68
+ process = requireDynamic("process");
69
+ }
70
+ if (!fs) {
71
+ fs = requireDynamic("fs");
72
+ }
73
+ const envValue = process?.env[configSource];
74
+ if (envValue && envValue.trim() !== "") {
75
+ configSource = envValue;
76
+ }
77
+ if (fs?.existsSync(configSource) && fs?.statSync(configSource).isFile()) {
78
+ configSource = fs.readFileSync(configSource, { encoding: "utf-8" });
79
+ }
63
80
  }
64
81
  return configSource.trim();
65
82
  }
83
+ /**
84
+ * @param {import('./ConfigPriority.js').ConfigPriority} priority
85
+ * @param {string} configString
86
+ * @returns
87
+ */
66
88
  static _parseConfigsAndAddToCollection(priority, configString) {
67
89
  try {
68
90
  const jsonObject = JSON.parse(configString);
@@ -78,7 +100,7 @@ class ConfigSourceResolver {
78
100
  import_YamlConfigResolver.YamlConfigResolver.addConfigs(priority, configString);
79
101
  return;
80
102
  } catch (ex) {
81
- if (ex.name === "SyntaxError") {
103
+ if (ex?.name === "SyntaxError") {
82
104
  } else {
83
105
  console.log("Failed to parse config source as YAML: " + ex);
84
106
  }
@@ -21,8 +21,10 @@ __export(ComplexTypeResolver_exports, {
21
21
  ComplexTypeResolver: () => ComplexTypeResolver
22
22
  });
23
23
  module.exports = __toCommonJS(ComplexTypeResolver_exports);
24
+ var import_Primitives = require("../../utils/Primitives.cjs");
24
25
  var import_Runtime = require("../../utils/Runtime.cjs");
25
26
  var import_RuntimeName = require("../../utils/RuntimeName.cjs");
27
+ var import_Activator = require("../Activator.cjs");
26
28
  var import_ActivatorDetails = require("../ActivatorDetails.cjs");
27
29
  var import_InvocationContext = require("../InvocationContext.cjs");
28
30
  var import_JavaTypeParsingFunctions = require("./typeParsingFunctions/JavaTypeParsingFunctions.cjs");
@@ -31,17 +33,19 @@ var import_NodejsTypeParsingFunctions = require("./typeParsingFunctions/NodejsTy
31
33
  var import_PythonTypeParsingFunctions = require("./typeParsingFunctions/PythonTypeParsingFunctions.cjs");
32
34
  const import_meta = {};
33
35
  const dynamicImport = (0, import_Runtime.getRequire)(import_meta.url);
36
+ const typeParsingFunctions = /* @__PURE__ */ new Map([
37
+ [import_RuntimeName.RuntimeName.Netcore, import_NetcoreTypeParsingFunctions.NetcoreTypeParsingFunctions],
38
+ [import_RuntimeName.RuntimeName.Jvm, import_JavaTypeParsingFunctions.JavaTypeParsingFunctions],
39
+ [import_RuntimeName.RuntimeName.Nodejs, import_NodejsTypeParsingFunctions.NodejsTypeParsingFunctions],
40
+ [import_RuntimeName.RuntimeName.Python, import_PythonTypeParsingFunctions.PythonTypeParsingFunctions],
41
+ [import_RuntimeName.RuntimeName.Python27, import_PythonTypeParsingFunctions.PythonTypeParsingFunctions]
42
+ ]);
34
43
  class ComplexTypeResolver {
35
44
  /** @type {Map<string, ActivatorDetails>} */
36
- #typeMap = /* @__PURE__ */ new Map();
37
- /** @type {Map<number, Map<string, Function>>} */
38
- #typeParsingFunctions = /* @__PURE__ */ new Map([
39
- [import_RuntimeName.RuntimeName.Netcore, import_NetcoreTypeParsingFunctions.NetcoreTypeParsingFunctions],
40
- [import_RuntimeName.RuntimeName.Jvm, import_JavaTypeParsingFunctions.JavaTypeParsingFunctions],
41
- [import_RuntimeName.RuntimeName.Nodejs, import_NodejsTypeParsingFunctions.NodejsTypeParsingFunctions],
42
- [import_RuntimeName.RuntimeName.Python, import_PythonTypeParsingFunctions.PythonTypeParsingFunctions],
43
- [import_RuntimeName.RuntimeName.Python27, import_PythonTypeParsingFunctions.PythonTypeParsingFunctions]
44
- ]);
45
+ #typeMap;
46
+ constructor() {
47
+ this.#typeMap = /* @__PURE__ */ new Map();
48
+ }
45
49
  /**
46
50
  * Register a custom type mapping
47
51
  * @param {string} resultType - The type name from the target runtime
@@ -56,38 +60,40 @@ class ComplexTypeResolver {
56
60
  /**
57
61
  * Convert InvocationContext result to appropriate JavaScript type
58
62
  * @param {InvocationContext} ic - The invocation context
59
- * @returns {Promise<any> | any} The converted result
63
+ * @returns {Promise<any>} The converted result
60
64
  */
61
- convertResult(ic) {
65
+ async convertResult(ic) {
62
66
  const runtimeName = ic.getRuntimeName();
63
- const resultType = ic.getResultType();
64
- const runtimeDict = this.#typeParsingFunctions.get(runtimeName);
65
- if (runtimeDict) {
66
- let parsingFunc = null;
67
- if (resultType instanceof Promise) {
68
- parsingFunc = resultType.then((result) => {
69
- parsingFunc = runtimeDict.get(result);
70
- });
71
- } else {
72
- parsingFunc = runtimeDict.get(resultType);
73
- }
74
- if (parsingFunc) {
75
- return parsingFunc(ic);
76
- }
67
+ const resultType = await ic.getResultType();
68
+ if (!resultType) {
69
+ throw new Error("resultType is not valid");
77
70
  }
78
- let activatorDetails = null;
79
- if (resultType instanceof Promise) {
80
- activatorDetails = resultType.then((result) => {
81
- activatorDetails = this.#typeMap.get(result);
82
- });
83
- } else {
84
- activatorDetails = this.#typeMap.get(resultType);
71
+ let underlyingType = ComplexTypeResolver.tryGetUnderlyingArrayType(resultType);
72
+ if (underlyingType !== null) {
73
+ const { Type } = (
74
+ /** @type {ActivatorDetails} */
75
+ this.#typeMap.get(underlyingType)
76
+ );
77
+ const complexTypesArray = await ic.retrieveArray();
78
+ return complexTypesArray.map((item) => import_Activator.Activator.createInstance(Type, item));
85
79
  }
80
+ const parsingFunction = ComplexTypeResolver.tryGetTypeParsingFunction(runtimeName, resultType);
81
+ if (parsingFunction) {
82
+ return parsingFunction(ic);
83
+ }
84
+ const activatorDetails = this.tryGetValueFromTypeMap(resultType);
86
85
  if (!activatorDetails) {
87
86
  throw new Error(`No type registered for key '${resultType}'.`);
88
87
  }
89
- return new /** @type {any} */
90
- activatorDetails.type(...activatorDetails.arguments);
88
+ if (runtimeName === import_RuntimeName.RuntimeName.Nodejs) {
89
+ const value = await ic.getValue();
90
+ if (value) {
91
+ if (value instanceof activatorDetails.Type) {
92
+ return value;
93
+ }
94
+ }
95
+ }
96
+ return import_Activator.Activator.createInstance(activatorDetails.Type, activatorDetails.arguments ?? null);
91
97
  }
92
98
  /**
93
99
  * Resolve type from string name and optional module
@@ -121,6 +127,50 @@ class ComplexTypeResolver {
121
127
  }
122
128
  return typeObj;
123
129
  }
130
+ /**
131
+ * Attempts to extract the underlying element type from an array type string
132
+ * @param {string} type - The type string to parse (e.g., "MyType[]")
133
+ * @returns {string | null} Object indicating success and the element type
134
+ * @throws {Error} If the array element type is a primitive type
135
+ */
136
+ static tryGetUnderlyingArrayType(type) {
137
+ if (typeof type !== "string" || !type.includes("[")) {
138
+ return null;
139
+ }
140
+ let trimmedType = type.trim();
141
+ if (!trimmedType) return null;
142
+ const commaIndex = trimmedType.indexOf(",");
143
+ if (commaIndex > 0) {
144
+ trimmedType = trimmedType.substring(0, commaIndex).trim();
145
+ }
146
+ const bracketIndex = trimmedType.indexOf("[");
147
+ if (bracketIndex > 0) {
148
+ trimmedType = trimmedType.substring(0, bracketIndex).trim();
149
+ }
150
+ if (import_Primitives.PrimitiveSet.has(trimmedType)) {
151
+ throw new Error("Primitive array element types are not supported.");
152
+ }
153
+ return trimmedType;
154
+ }
155
+ /**
156
+ * @param {RuntimeName} runtimeName
157
+ * @param {string} resultType
158
+ * @returns {any}
159
+ */
160
+ static tryGetTypeParsingFunction(runtimeName, resultType) {
161
+ const runtimeDict = typeParsingFunctions.get(runtimeName);
162
+ return runtimeDict ? runtimeDict.get(resultType) ?? null : null;
163
+ }
164
+ /**
165
+ * @param {string} resultType
166
+ * @returns {ActivatorDetails | null}
167
+ */
168
+ tryGetValueFromTypeMap(resultType) {
169
+ if (!resultType) {
170
+ throw new Error("resultType is not valid");
171
+ }
172
+ return this.#typeMap.get(resultType) ?? null;
173
+ }
124
174
  }
125
175
  // Annotate the CommonJS export names for ESM import in node:
126
176
  0 && (module.exports = {
@@ -7,8 +7,9 @@ export class Handler {
7
7
  interpreter: import("../interpreter/Interpreter.js").Interpreter;
8
8
  /**
9
9
  * @param {Command} command
10
+ * @returns {Promise<Command> | Command}
10
11
  */
11
- handleCommand(command: Command): Command | Promise<Command>;
12
+ handleCommand(command: Command): Promise<Command> | Command;
12
13
  /**
13
14
  * @param {any} response
14
15
  * @param {RuntimeName} runtimeName
@@ -68,9 +68,9 @@ export class PassDelegateHandler extends AbstractHandler {
68
68
  /**
69
69
  * Creates a method call to execute the command.
70
70
  * @param {Command} command - The command object.
71
- * @returns {any} The response object.
71
+ * @returns {Promise<any>} The response object.
72
72
  */
73
- createExecuteCall(command: Command): any;
73
+ createExecuteCall(command: Command): Promise<any>;
74
74
  /**
75
75
  * Retrieves the response payload from the execution call.
76
76
  * @param {Object<string, any>} executeCall - Object containing the execution call.
@@ -7,9 +7,9 @@ export class Interpreter {
7
7
  *
8
8
  * @param {Command} command
9
9
  * @param {IConnectionData} connectionData
10
- * @returns {Command | Promise<Command>}
10
+ * @returns {Promise<Command>}
11
11
  */
12
- execute(command: Command, connectionData: IConnectionData): Command | Promise<Command>;
12
+ execute(command: Command, connectionData: IConnectionData): Promise<Command>;
13
13
  /**
14
14
  *
15
15
  * @param {Uint8Array} messageByteArray
@@ -5,12 +5,12 @@ export type IConnectionData = import("../../utils/connectionData/IConnectionData
5
5
  export class CommandSerializer {
6
6
  /**
7
7
  * Serializes the root command with connection data and optional runtime version.
8
- * @param {Promise<Command> | Command} rootCommand
8
+ * @param {Command} rootCommand
9
9
  * @param {IConnectionData} connectionData
10
10
  * @param {number} runtimeVersion
11
- * @returns {Promise<Uint8Array> | Uint8Array}
11
+ * @returns {Uint8Array}
12
12
  */
13
- serialize(rootCommand: Promise<Command> | Command, connectionData: IConnectionData, runtimeVersion?: number): Promise<Uint8Array> | Uint8Array;
13
+ serialize(rootCommand: Command, connectionData: IConnectionData, runtimeVersion?: number): Uint8Array;
14
14
  /**
15
15
  * Recursively serializes command payload.
16
16
  * @param {Command} command
@@ -3,14 +3,14 @@ export class Receiver {
3
3
  static getRuntimeInfo(): string;
4
4
  /**
5
5
  * @param {Uint8Array} messageByteArray
6
- * @returns {Promise<Uint8Array> | Uint8Array}
6
+ * @returns {Promise<Uint8Array>}
7
7
  */
8
- static sendCommand(messageByteArray: Uint8Array): Promise<Uint8Array> | Uint8Array;
8
+ static sendCommand(messageByteArray: Uint8Array): Promise<Uint8Array>;
9
9
  /**
10
10
  * @param {Uint8Array} messageByteArray
11
- * @returns {Promise<Uint8Array> | Uint8Array}
11
+ * @returns {Promise<Uint8Array>}
12
12
  */
13
- static heartBeat(messageByteArray: Uint8Array): Promise<Uint8Array> | Uint8Array;
13
+ static heartBeat(messageByteArray: Uint8Array): Promise<Uint8Array>;
14
14
  Receiver(): void;
15
15
  }
16
16
  import { InMemoryConnectionData } from '../../utils/connectionData/InMemoryConnectionData.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Details for activating a type with constructor arguments
3
+ */
4
+ export class Activator {
5
+ /**
6
+ * Create a new instance of a type
7
+ * @param {Function} Type - The constructor function/class
8
+ * @param {any[] | any} args - The arguments to pass to the constructor
9
+ * @returns {any} The new instance
10
+ */
11
+ static createInstance(Type: Function, args: any[] | any): any;
12
+ }
@@ -4,9 +4,11 @@
4
4
  export class ActivatorDetails {
5
5
  /**
6
6
  * @param {Function} type - The constructor function/class
7
- * @param {any[]} [args] - Arguments to pass to constructor
7
+ * @param {any[]|any} [args] - Arguments to pass to constructor (array or single value)
8
8
  */
9
- constructor(type: Function, args?: any[]);
10
- type: Function;
9
+ constructor(type: Function, args?: any[] | any);
10
+ /** @type {Function} */
11
+ Type: Function;
12
+ /** @type {any[]} */
11
13
  arguments: any[];
12
14
  }
@@ -65,6 +65,13 @@ export class ConfigRuntimeFactory {
65
65
  * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/foundations/runtime-context)
66
66
  */
67
67
  nodejs(configName?: string): RuntimeContext;
68
+ /**
69
+ * Creates RuntimeContext instance to interact with the Php runtime.
70
+ * @param {string} [configName="default"] - The name of the configuration to use (optional).
71
+ * @return {RuntimeContext} a RuntimeContext instance for the Php runtime
72
+ * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/foundations/runtime-context)
73
+ */
74
+ php(configName?: string): RuntimeContext;
68
75
  /**
69
76
  * Creates RuntimeContext instance to interact with the Python 2.7 runtime.
70
77
  * @param {string} [configName="default"] - The name of the configuration to use (optional).
@@ -31,11 +31,11 @@ export class InvocationContext {
31
31
  * Commands are becoming nested through each invocation of methods on Invocation Context.
32
32
  * Each invocation triggers the creation of new Invocation Context instance wrapping the current command with new parent command valid for invoked method.
33
33
  * Developer can decide on any moment of the materialization for the context taking full control of the chunks of the expression being transferred and processed on target runtime.
34
- * @returns {Promise<InvocationContext> | InvocationContext} the InvocationContext after executing the command.
34
+ * @returns {Promise<InvocationContext>} the InvocationContext after executing the command.
35
35
  * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/foundations/execute-method)
36
36
  * @method
37
37
  */
38
- execute(): Promise<InvocationContext> | InvocationContext;
38
+ execute(): Promise<InvocationContext>;
39
39
  /**
40
40
  * Invokes a static method on the target runtime.
41
41
  * @param {string} methodName - The name of the method to invoke.
@@ -196,11 +196,11 @@ export class InvocationContext {
196
196
  getInstanceMethodAsDelegate(methodName: string, ...args: any[]): InvocationContext;
197
197
  /**
198
198
  * Retrieves the type of the object from the target runtime.
199
- * @returns {Promise<string> | string} The type of the object.
199
+ * @returns {Promise<string>} The type of the object.
200
200
  * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/type-handling/getting-object-type)
201
201
  * @method
202
202
  */
203
- getResultType(): Promise<string> | string;
203
+ getResultType(): Promise<string>;
204
204
  /**
205
205
  * Retrieves the name of the runtime where the command is executed.
206
206
  * @returns {number} The name of the runtime.
@@ -210,6 +210,7 @@ export class InvocationContext {
210
210
  getRuntimeName(): number;
211
211
  /**
212
212
  * Retrieves an array from the target runtime.
213
+ * @async
213
214
  * @returns {Promise<any[]>}
214
215
  * @method
215
216
  */
@@ -222,12 +223,12 @@ export class InvocationContext {
222
223
  * @method
223
224
  */
224
225
  getValue(): unknown;
225
- [Symbol.iterator]: () => {
226
- next: () => {
227
- value: InvocationContext;
228
- done: boolean;
229
- };
230
- };
226
+ /**
227
+ * Async iterator for InvocationContext arrays
228
+ * Use: for await (const item of invocationContext) { ... }
229
+ * @returns {AsyncGenerator<InvocationContext, void, unknown>}
230
+ */
231
+ [Symbol.asyncIterator](): AsyncGenerator<InvocationContext, void, unknown>;
231
232
  #private;
232
233
  }
233
234
  import { Command } from '../utils/Command.js';
@@ -77,7 +77,8 @@ import { WsConnectionData } from '../utils/connectionData/WsConnectionData.js';
77
77
  import { CommandSerializer } from '../core/protocol/CommandSerializer.js';
78
78
  import { CommandDeserializer } from '../core/protocol/CommandDeserializer.js';
79
79
  import { ConfigPriority } from './configuration/ConfigPriority.js';
80
+ import { ComplexTypeResolver } from './tools/ComplexTypeResolver.js';
80
81
  import { RuntimeFactory } from './RuntimeFactory.js';
81
82
  import { ConfigRuntimeFactory } from './ConfigRuntimeFactory.js';
82
83
  import { RuntimeContext } from './RuntimeContext.js';
83
- export { TcpConnectionData, WsConnectionData, CommandSerializer, CommandDeserializer, ConfigPriority };
84
+ export { TcpConnectionData, WsConnectionData, CommandSerializer, CommandDeserializer, ConfigPriority, ComplexTypeResolver };
@@ -40,20 +40,21 @@ export class RuntimeContext {
40
40
  * Each invocation triggers the creation of a new RuntimeContext instance wrapping the current command with a new parent command.
41
41
  * The developer can decide at any moment of the materialization for the context, taking full control of the chunks of the expression being transferred and processed on the target runtime.
42
42
  * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/foundations/execute-method)
43
+ * @returns {Promise<void>}
43
44
  * @method
44
45
  */
45
- execute(): void;
46
+ execute(): Promise<void>;
46
47
  /**
47
48
  * Adds a reference to a library. Javonet allows you to reference and use modules or packages written in various languages.
48
49
  * This method allows you to use any library from all supported technologies. The necessary libraries need to be referenced.
49
50
  * The argument is a relative or full path to the library. If the library has dependencies on other libraries, the latter needs to be added first.
50
51
  * After referencing the library, any objects stored in this package can be used. Use static classes, create instances, call methods, use fields and properties, and much more.
51
52
  * @param {string} libraryPath - The relative or full path to the library.
52
- * @returns {RuntimeContext} RuntimeContext instance.
53
+ * @returns {Promise<RuntimeContext>} RuntimeContext instance.
53
54
  * @see [Javonet Guides](https://www.javonet.com/guides/v2/javascript/getting-started/adding-references-to-libraries)
54
55
  * @method
55
56
  */
56
- loadLibrary(libraryPath: string): RuntimeContext;
57
+ loadLibrary(libraryPath: string): Promise<RuntimeContext>;
57
58
  /**
58
59
  * Retrieves a reference to a specific type. The type can be a class, interface or enum. The type can be retrieved from any referenced library.
59
60
  * @param {string} typeName - The full name of the type.
@@ -1,7 +1,24 @@
1
1
  export class ConfigSourceResolver {
2
- static addConfigs(priority: any, configSource: any): void;
3
- static getConfig(configName: any): any;
2
+ /**
3
+ * @param {import('./ConfigPriority.js').ConfigPriority} priority
4
+ * @param {string | any} configSource
5
+ */
6
+ static addConfigs(priority: any, configSource: string | any): void;
7
+ /**
8
+ * @param {string} configName
9
+ * @returns {*}
10
+ */
11
+ static getConfig(configName: string): any;
4
12
  static clearConfigs(): void;
5
- static _getConfigSourceAsString(configSource: any): any;
6
- static _parseConfigsAndAddToCollection(priority: any, configString: any): void;
13
+ /**
14
+ * @param {string} configSource
15
+ * @returns {string}
16
+ */
17
+ static _getConfigSourceAsString(configSource: string): string;
18
+ /**
19
+ * @param {import('./ConfigPriority.js').ConfigPriority} priority
20
+ * @param {string} configString
21
+ * @returns
22
+ */
23
+ static _parseConfigsAndAddToCollection(priority: any, configString: string): void;
7
24
  }
@@ -1,7 +1,4 @@
1
1
  export type RuntimeName = import("../../types.d.ts").RuntimeName;
2
- /**
3
- * @typedef {import('../../types.d.ts').RuntimeName} RuntimeName
4
- */
5
2
  export class ComplexTypeResolver {
6
3
  /**
7
4
  * Resolve type from string name and optional module
@@ -10,6 +7,19 @@ export class ComplexTypeResolver {
10
7
  * @returns {Function} The resolved type/constructor function
11
8
  */
12
9
  static resolveType(typeName: string, moduleName?: string): Function;
10
+ /**
11
+ * Attempts to extract the underlying element type from an array type string
12
+ * @param {string} type - The type string to parse (e.g., "MyType[]")
13
+ * @returns {string | null} Object indicating success and the element type
14
+ * @throws {Error} If the array element type is a primitive type
15
+ */
16
+ static tryGetUnderlyingArrayType(type: string): string | null;
17
+ /**
18
+ * @param {RuntimeName} runtimeName
19
+ * @param {string} resultType
20
+ * @returns {any}
21
+ */
22
+ static tryGetTypeParsingFunction(runtimeName: RuntimeName, resultType: string): any;
13
23
  /**
14
24
  * Register a custom type mapping
15
25
  * @param {string} resultType - The type name from the target runtime
@@ -20,9 +30,15 @@ export class ComplexTypeResolver {
20
30
  /**
21
31
  * Convert InvocationContext result to appropriate JavaScript type
22
32
  * @param {InvocationContext} ic - The invocation context
23
- * @returns {Promise<any> | any} The converted result
33
+ * @returns {Promise<any>} The converted result
34
+ */
35
+ convertResult(ic: InvocationContext): Promise<any>;
36
+ /**
37
+ * @param {string} resultType
38
+ * @returns {ActivatorDetails | null}
24
39
  */
25
- convertResult(ic: InvocationContext): Promise<any> | any;
40
+ tryGetValueFromTypeMap(resultType: string): ActivatorDetails | null;
26
41
  #private;
27
42
  }
28
43
  import { InvocationContext } from '../InvocationContext.js';
44
+ import { ActivatorDetails } from '../ActivatorDetails.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Set of primitive type names that are not supported as array element types
3
+ * @type {Set<string>}
4
+ */
5
+ export const PrimitiveSet: Set<string>;