@olane/o-tool 0.7.12-alpha.5 → 0.7.12-alpha.9
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { oAddress, oConnection, oCore, oRequest } from '@olane/o-core';
|
|
1
|
+
import { oAddress, oConnection, oCore, oRequest, oNotificationManager } from '@olane/o-core';
|
|
2
2
|
import { Stream } from '@olane/o-config';
|
|
3
3
|
import { RunResult } from './interfaces/run-result.interface.js';
|
|
4
4
|
import { ToolResult } from './interfaces/tool-result.interface.js';
|
|
@@ -15,6 +15,7 @@ export declare class oToolBase extends oCore {
|
|
|
15
15
|
initializeRouter(): Promise<void>;
|
|
16
16
|
unregister(): Promise<void>;
|
|
17
17
|
register(): Promise<void>;
|
|
18
|
+
protected createNotificationManager(): oNotificationManager;
|
|
18
19
|
execute(req: oRequest, stream?: Stream): Promise<RunResult>;
|
|
19
20
|
run(request: oRequest, stream?: Stream): Promise<RunResult>;
|
|
20
21
|
myTools(obj?: any): Promise<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-tool.base.d.ts","sourceRoot":"","sources":["../../src/o-tool.base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,KAAK,EAGL,QAAQ,
|
|
1
|
+
{"version":3,"file":"o-tool.base.d.ts","sourceRoot":"","sources":["../../src/o-tool.base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,KAAK,EAGL,QAAQ,EAER,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAInE;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,OAAO,CAAC,OAAO,CAAkB;IAEjC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAY7C,mBAAmB,IAAI,GAAG,EAAE;IAI5B,OAAO,CACL,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,QAAQ,GACtB,OAAO,CAAC,WAAW,CAAC;IAGvB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAG3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,SAAS,CAAC,yBAAyB,IAAI,oBAAoB;IAOrD,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA8B3D,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA2BjE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAS/B,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIvD,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAiBnE,KAAK;;;;;;;IA4FL,MAAM;;;;CAQb"}
|
package/dist/src/o-tool.base.js
CHANGED
|
@@ -38,6 +38,9 @@ export class oToolBase extends oCore {
|
|
|
38
38
|
register() {
|
|
39
39
|
throw new oError(oErrorCodes.NOT_IMPLEMENTED, 'Register not implemented');
|
|
40
40
|
}
|
|
41
|
+
createNotificationManager() {
|
|
42
|
+
throw new oError(oErrorCodes.NOT_IMPLEMENTED, 'createNotificationManager not implemented');
|
|
43
|
+
}
|
|
41
44
|
async execute(req, stream) {
|
|
42
45
|
let request = req;
|
|
43
46
|
const requestConfig = req.toJSON();
|
package/dist/src/o-tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-tool.d.ts","sourceRoot":"","sources":["../../src/o-tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"o-tool.d.ts","sourceRoot":"","sources":["../../src/o-tool.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAgQ7E"}
|
package/dist/src/o-tool.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { oError, oErrorCodes, oRequest, } from '@olane/o-core';
|
|
1
|
+
import { oAddress, oError, oErrorCodes, oRequest, oNotificationEvent, } from '@olane/o-core';
|
|
2
2
|
/**
|
|
3
3
|
* oTool is a mixin that extends the base class and implements the oTool interface
|
|
4
4
|
* @param Base - The base class to extend
|
|
@@ -96,5 +96,112 @@ export function oTool(Base) {
|
|
|
96
96
|
message: 'Request cancelled',
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Emit a notification event to all subscribers
|
|
101
|
+
* Can be called remotely to trigger events on this node
|
|
102
|
+
*/
|
|
103
|
+
async _tool_notify(request) {
|
|
104
|
+
const { eventType, eventData } = request.params;
|
|
105
|
+
if (!eventType) {
|
|
106
|
+
throw new oError(oErrorCodes.MISSING_PARAMETERS, 'eventType is required');
|
|
107
|
+
}
|
|
108
|
+
this.logger.debug(`Received remote notification: ${eventType}`);
|
|
109
|
+
// Create a generic notification event from the data
|
|
110
|
+
if (this.notificationManager) {
|
|
111
|
+
// Create a custom event class
|
|
112
|
+
class CustomNotificationEvent extends oNotificationEvent {
|
|
113
|
+
constructor(type, source, data) {
|
|
114
|
+
super({
|
|
115
|
+
type,
|
|
116
|
+
source,
|
|
117
|
+
metadata: data || {},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Emit as a custom event with the provided data
|
|
122
|
+
const sourceAddress = request.params.source
|
|
123
|
+
? new oAddress(request.params.source)
|
|
124
|
+
: new oAddress('o://unknown');
|
|
125
|
+
const event = new CustomNotificationEvent(eventType, sourceAddress, eventData);
|
|
126
|
+
this.notificationManager.emit(event);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
message: `Notification ${eventType} emitted`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get connection health status (for nodes with heartbeat monitoring)
|
|
135
|
+
*/
|
|
136
|
+
async _tool_get_connection_health(request) {
|
|
137
|
+
// Check if this node has a connectionHeartbeatManager
|
|
138
|
+
const heartbeatManager = this.connectionHeartbeatManager;
|
|
139
|
+
if (!heartbeatManager) {
|
|
140
|
+
return {
|
|
141
|
+
enabled: false,
|
|
142
|
+
message: 'Connection heartbeat not enabled on this node',
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const healthStatus = heartbeatManager.getHealthStatus();
|
|
146
|
+
return {
|
|
147
|
+
enabled: true,
|
|
148
|
+
connections: healthStatus.map((h) => ({
|
|
149
|
+
address: h.address.toString(),
|
|
150
|
+
peerId: h.peerId,
|
|
151
|
+
status: h.status,
|
|
152
|
+
lastSuccessfulPing: new Date(h.lastSuccessfulPing).toISOString(),
|
|
153
|
+
consecutiveFailures: h.consecutiveFailures,
|
|
154
|
+
averageLatencyMs: Math.round(h.averageLatency),
|
|
155
|
+
})),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get leader health status and retry configuration
|
|
160
|
+
*/
|
|
161
|
+
async _tool_get_leader_health(request) {
|
|
162
|
+
const heartbeatManager = this.connectionHeartbeatManager;
|
|
163
|
+
const leaderRequestWrapper = this.leaderRequestWrapper;
|
|
164
|
+
if (!heartbeatManager && !leaderRequestWrapper) {
|
|
165
|
+
return {
|
|
166
|
+
enabled: false,
|
|
167
|
+
message: 'Leader monitoring not available on this node',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const result = {
|
|
171
|
+
heartbeat: { enabled: false },
|
|
172
|
+
retry: { enabled: false },
|
|
173
|
+
};
|
|
174
|
+
// Get heartbeat health for leader
|
|
175
|
+
if (heartbeatManager) {
|
|
176
|
+
const config = heartbeatManager.getConfig();
|
|
177
|
+
result.heartbeat.enabled = config.checkLeader;
|
|
178
|
+
if (config.checkLeader) {
|
|
179
|
+
const healthStatus = heartbeatManager.getHealthStatus();
|
|
180
|
+
const leaderHealth = healthStatus.find((h) => h.address.toString().includes('leader'));
|
|
181
|
+
if (leaderHealth) {
|
|
182
|
+
result.heartbeat.status = leaderHealth.status;
|
|
183
|
+
result.heartbeat.lastSuccessfulPing = new Date(leaderHealth.lastSuccessfulPing).toISOString();
|
|
184
|
+
result.heartbeat.consecutiveFailures =
|
|
185
|
+
leaderHealth.consecutiveFailures;
|
|
186
|
+
result.heartbeat.averageLatencyMs = Math.round(leaderHealth.averageLatency);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
result.heartbeat.status = 'not_monitored';
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Get retry configuration
|
|
194
|
+
if (leaderRequestWrapper) {
|
|
195
|
+
const retryConfig = leaderRequestWrapper.getConfig();
|
|
196
|
+
result.retry = {
|
|
197
|
+
enabled: retryConfig.enabled,
|
|
198
|
+
maxAttempts: retryConfig.maxAttempts,
|
|
199
|
+
baseDelayMs: retryConfig.baseDelayMs,
|
|
200
|
+
maxDelayMs: retryConfig.maxDelayMs,
|
|
201
|
+
timeoutMs: retryConfig.timeoutMs,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
99
206
|
};
|
|
100
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-tool",
|
|
3
|
-
"version": "0.7.12-alpha.
|
|
3
|
+
"version": "0.7.12-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"typescript": "^5.8.3"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@olane/o-config": "0.7.12-alpha.
|
|
58
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
59
|
-
"@olane/o-protocol": "0.7.12-alpha.
|
|
57
|
+
"@olane/o-config": "0.7.12-alpha.9",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.9",
|
|
59
|
+
"@olane/o-protocol": "0.7.12-alpha.9",
|
|
60
60
|
"debug": "^4.4.1",
|
|
61
61
|
"dotenv": "^16.5.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "21427acbdc1d87ff9465bf19bda58cca89e8d3c7"
|
|
64
64
|
}
|