javonet-nodejs-sdk 2.6.11 → 2.6.13
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/DestructReferenceHandler.cjs +9 -2
- package/dist/core/referenceCache/ReferencesCache.cjs +8 -5
- package/dist/sdk/InvocationContext.cjs +1 -11
- package/dist/sdk/Javonet.cjs +3 -0
- package/dist/types/core/handler/DestructReferenceHandler.d.ts +2 -1
- package/dist/types/core/referenceCache/ReferencesCache.d.ts +3 -3
- package/dist/types/sdk/Javonet.d.ts +2 -1
- package/lib/core/handler/DestructReferenceHandler.js +11 -3
- package/lib/core/referenceCache/ReferencesCache.js +9 -5
- package/lib/sdk/InvocationContext.js +4 -16
- package/lib/sdk/Javonet.js +2 -0
- package/package.json +1 -1
|
@@ -26,14 +26,21 @@ var import_AbstractHandler = require("./AbstractHandler.cjs");
|
|
|
26
26
|
class DestructReferenceHandler extends import_AbstractHandler.AbstractHandler {
|
|
27
27
|
constructor() {
|
|
28
28
|
super();
|
|
29
|
+
this.requiredParametersCount = 1;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* @param {Command} command
|
|
32
33
|
*/
|
|
33
34
|
process(command) {
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if (command.payload.length < this.requiredParametersCount) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const referenceId = command.payload[0];
|
|
40
|
+
if (referenceId == null || typeof referenceId !== "string") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return import_ReferencesCache.ReferencesCache.getInstance().deleteReference(referenceId);
|
|
37
44
|
} catch (error) {
|
|
38
45
|
throw this.process_stack_trace(error, this.constructor.name);
|
|
39
46
|
}
|
|
@@ -51,12 +51,15 @@ class ReferencesCache {
|
|
|
51
51
|
return _cache[id];
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* @param {string}
|
|
55
|
-
* @returns {
|
|
54
|
+
* @param {string} reference_guid
|
|
55
|
+
* @returns {boolean}
|
|
56
56
|
*/
|
|
57
|
-
deleteReference(
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
deleteReference(reference_guid) {
|
|
58
|
+
if (reference_guid == null || typeof reference_guid !== "string") {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
delete _cache[reference_guid];
|
|
62
|
+
return true;
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -486,20 +486,10 @@ class InvocationContext {
|
|
|
486
486
|
this.#buildCommand(localCommand)
|
|
487
487
|
);
|
|
488
488
|
await localInvCtx.execute();
|
|
489
|
-
const resolve = (item) => {
|
|
490
|
-
return item?.commandType === import_CommandType.CommandType.Reference ? new InvocationContext(
|
|
491
|
-
this.#runtimeName,
|
|
492
|
-
this.#connectionData,
|
|
493
|
-
item
|
|
494
|
-
) : item;
|
|
495
|
-
};
|
|
496
489
|
const respCommand = localInvCtx.#responseCommand;
|
|
497
|
-
if (!respCommand) {
|
|
490
|
+
if (!respCommand || !respCommand.payload || respCommand.payload.length === 0) {
|
|
498
491
|
return [];
|
|
499
492
|
}
|
|
500
|
-
if (respCommand.payload) {
|
|
501
|
-
return respCommand.payload.map((item) => resolve(item));
|
|
502
|
-
}
|
|
503
493
|
return respCommand.payload || [];
|
|
504
494
|
}
|
|
505
495
|
/**
|
package/dist/sdk/Javonet.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __export(Javonet_exports, {
|
|
|
22
22
|
CommandSerializer: () => import_CommandSerializer.CommandSerializer,
|
|
23
23
|
ComplexTypeResolver: () => import_ComplexTypeResolver.ComplexTypeResolver,
|
|
24
24
|
ConfigPriority: () => import_ConfigPriority.ConfigPriority,
|
|
25
|
+
InvocationContext: () => import_InvocationContext.InvocationContext,
|
|
25
26
|
Javonet: () => Javonet,
|
|
26
27
|
RuntimeContext: () => import_RuntimeContext.RuntimeContext,
|
|
27
28
|
TcpConnectionData: () => import_TcpConnectionData.TcpConnectionData,
|
|
@@ -42,6 +43,7 @@ var import_UtilsConst = require("../utils/UtilsConst.cjs");
|
|
|
42
43
|
var import_ConfigSourceResolver = require("./configuration/ConfigSourceResolver.cjs");
|
|
43
44
|
var import_ConfigPriority = require("./configuration/ConfigPriority.cjs");
|
|
44
45
|
var import_ComplexTypeResolver = require("./tools/ComplexTypeResolver.cjs");
|
|
46
|
+
var import_InvocationContext = require("./InvocationContext.cjs");
|
|
45
47
|
class Javonet {
|
|
46
48
|
/**
|
|
47
49
|
* Initializes Javonet using an in-memory channel on the same machine.
|
|
@@ -139,6 +141,7 @@ class Javonet {
|
|
|
139
141
|
CommandSerializer,
|
|
140
142
|
ComplexTypeResolver,
|
|
141
143
|
ConfigPriority,
|
|
144
|
+
InvocationContext,
|
|
142
145
|
Javonet,
|
|
143
146
|
RuntimeContext,
|
|
144
147
|
TcpConnectionData,
|
|
@@ -3,9 +3,10 @@ export type Command = import("../../utils/Command.js").Command;
|
|
|
3
3
|
* @typedef {import('../../utils/Command.js').Command} Command
|
|
4
4
|
*/
|
|
5
5
|
export class DestructReferenceHandler extends AbstractHandler {
|
|
6
|
+
requiredParametersCount: number;
|
|
6
7
|
/**
|
|
7
8
|
* @param {Command} command
|
|
8
9
|
*/
|
|
9
|
-
process(command: Command):
|
|
10
|
+
process(command: Command): boolean;
|
|
10
11
|
}
|
|
11
12
|
import { AbstractHandler } from './AbstractHandler.js';
|
|
@@ -17,8 +17,8 @@ export class ReferencesCache {
|
|
|
17
17
|
*/
|
|
18
18
|
resolveReference(id: string): any;
|
|
19
19
|
/**
|
|
20
|
-
* @param {string}
|
|
21
|
-
* @returns {
|
|
20
|
+
* @param {string} reference_guid
|
|
21
|
+
* @returns {boolean}
|
|
22
22
|
*/
|
|
23
|
-
deleteReference(
|
|
23
|
+
deleteReference(reference_guid: string): boolean;
|
|
24
24
|
}
|
|
@@ -73,6 +73,7 @@ export class Javonet {
|
|
|
73
73
|
static initializeRc(configName: string): RuntimeContext;
|
|
74
74
|
}
|
|
75
75
|
import { RuntimeContext } from './RuntimeContext.js';
|
|
76
|
+
import { InvocationContext } from './InvocationContext.js';
|
|
76
77
|
import { TcpConnectionData } from '../utils/nodejs/connectionData/TcpConnectionData.js';
|
|
77
78
|
import { WsConnectionData } from '../utils/connectionData/WsConnectionData.js';
|
|
78
79
|
import { CommandSerializer } from '../core/protocol/CommandSerializer.js';
|
|
@@ -81,4 +82,4 @@ import { ConfigPriority } from './configuration/ConfigPriority.js';
|
|
|
81
82
|
import { ComplexTypeResolver } from './tools/ComplexTypeResolver.js';
|
|
82
83
|
import { RuntimeFactory } from './RuntimeFactory.js';
|
|
83
84
|
import { ConfigRuntimeFactory } from './ConfigRuntimeFactory.js';
|
|
84
|
-
export { RuntimeContext, TcpConnectionData, WsConnectionData, CommandSerializer, CommandDeserializer, ConfigPriority, ComplexTypeResolver };
|
|
85
|
+
export { RuntimeContext, InvocationContext, TcpConnectionData, WsConnectionData, CommandSerializer, CommandDeserializer, ConfigPriority, ComplexTypeResolver };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { ReferencesCache } from '../referenceCache/ReferencesCache.js'
|
|
3
2
|
import { AbstractHandler } from './AbstractHandler.js'
|
|
4
3
|
|
|
@@ -9,6 +8,7 @@ import { AbstractHandler } from './AbstractHandler.js'
|
|
|
9
8
|
class DestructReferenceHandler extends AbstractHandler {
|
|
10
9
|
constructor() {
|
|
11
10
|
super()
|
|
11
|
+
this.requiredParametersCount = 1
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -16,8 +16,16 @@ class DestructReferenceHandler extends AbstractHandler {
|
|
|
16
16
|
*/
|
|
17
17
|
process(command) {
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (command.payload.length < this.requiredParametersCount) {
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const referenceId = command.payload[0]
|
|
24
|
+
if (referenceId == null || typeof referenceId !== 'string') {
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return ReferencesCache.getInstance().deleteReference(referenceId)
|
|
21
29
|
} catch (error) {
|
|
22
30
|
throw this.process_stack_trace(error, this.constructor.name)
|
|
23
31
|
}
|
|
@@ -41,12 +41,16 @@ class ReferencesCache {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @param {string}
|
|
45
|
-
* @returns {
|
|
44
|
+
* @param {string} reference_guid
|
|
45
|
+
* @returns {boolean}
|
|
46
46
|
*/
|
|
47
|
-
deleteReference(
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
deleteReference(reference_guid) {
|
|
48
|
+
if (reference_guid == null || typeof reference_guid !== 'string') {
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
delete _cache[reference_guid]
|
|
53
|
+
return true
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -166,7 +166,7 @@ class InvocationContext {
|
|
|
166
166
|
throw ExceptionThrower.throwException(this.#responseCommand)
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
// Process ValueForUpdate commands
|
|
169
|
+
// Process ValueForUpdate commands in response payload
|
|
170
170
|
this.#responseCommand = this.#processUpdateInvocationContextCommands(this.#responseCommand)
|
|
171
171
|
|
|
172
172
|
if (this.#responseCommand.commandType === CommandType.CreateClassInstance) {
|
|
@@ -176,7 +176,7 @@ class InvocationContext {
|
|
|
176
176
|
}
|
|
177
177
|
return new InvocationContext(this.#runtimeName, this.#connectionData, this.#responseCommand, true)
|
|
178
178
|
} finally {
|
|
179
|
-
//
|
|
179
|
+
// Release all locks in reverse order
|
|
180
180
|
for (let i = releases.length - 1; i >= 0; i--) {
|
|
181
181
|
try { releases[i]() } catch { /* ignore */ }
|
|
182
182
|
}
|
|
@@ -536,24 +536,12 @@ class InvocationContext {
|
|
|
536
536
|
|
|
537
537
|
await localInvCtx.execute()
|
|
538
538
|
|
|
539
|
-
const resolve = (/** @type {any} */ item) => {
|
|
540
|
-
return item?.commandType === CommandType.Reference ?
|
|
541
|
-
new InvocationContext(
|
|
542
|
-
this.#runtimeName,
|
|
543
|
-
this.#connectionData,
|
|
544
|
-
item
|
|
545
|
-
) : item
|
|
546
|
-
}
|
|
547
|
-
|
|
548
539
|
const respCommand = localInvCtx.#responseCommand
|
|
549
|
-
if (!respCommand) {
|
|
540
|
+
if (!respCommand || !respCommand.payload || respCommand.payload.length === 0) {
|
|
550
541
|
return []
|
|
551
542
|
}
|
|
552
543
|
|
|
553
|
-
|
|
554
|
-
return respCommand.payload.map((/** @type {any} */ item) => resolve(item))
|
|
555
|
-
}
|
|
556
|
-
|
|
544
|
+
// Return a shallow copy of the payload, mirroring the C# logic of copying to an object[]
|
|
557
545
|
return respCommand.payload || []
|
|
558
546
|
}
|
|
559
547
|
|
package/lib/sdk/Javonet.js
CHANGED
|
@@ -13,6 +13,7 @@ import { UtilsConst } from '../utils/UtilsConst.js'
|
|
|
13
13
|
import { ConfigSourceResolver } from './configuration/ConfigSourceResolver.js'
|
|
14
14
|
import { ConfigPriority } from './configuration/ConfigPriority.js'
|
|
15
15
|
import { ComplexTypeResolver } from './tools/ComplexTypeResolver.js'
|
|
16
|
+
import { InvocationContext } from './InvocationContext.js'
|
|
16
17
|
|
|
17
18
|
/** @typedef {import('../types.d.ts').ConfigSource} ConfigSource */
|
|
18
19
|
|
|
@@ -129,6 +130,7 @@ class Javonet {
|
|
|
129
130
|
export {
|
|
130
131
|
Javonet,
|
|
131
132
|
RuntimeContext,
|
|
133
|
+
InvocationContext,
|
|
132
134
|
TcpConnectionData,
|
|
133
135
|
WsConnectionData,
|
|
134
136
|
CommandSerializer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "javonet-nodejs-sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.13",
|
|
4
4
|
"description": "Javonet allows you to reference and use modules or packages written in (Java/Kotlin/Groovy/Clojure, C#/VB.NET, Ruby, Perl, Python, JavaScript/TypeScript) like they were created in your technology. It works on Linux/Windows and MacOS for applications created in JVM, CLR/Netcore, Perl, Python, Ruby, NodeJS, C++ or GoLang and gives you unparalleled freedom and flexibility with native performance in building your mixed-technologies products. Let it be accessing best AI or cryptography libraries, devices SDKs, legacy client modules, internal custom packages or anything from public repositories available on NPM, Nuget, PyPI, Maven/Gradle, RubyGems or GitHub. Get free from programming languages barriers today! For more information check out our guides at https://www.javonet.com/guides/v2/",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "SdNCenter Sp. z o. o.",
|