aotrautils-srv 0.0.2037 → 0.0.2039
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,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (17/10/2026-02:53:54)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -5485,7 +5485,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5485
5485
|
|
|
5486
5486
|
|
|
5487
5487
|
|
|
5488
|
-
/*utils AI library associated with aotra version : «1_29072022-2359 (
|
|
5488
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (17/10/2026-02:53:54)»*/
|
|
5489
5489
|
/*-----------------------------------------------------------------------------*/
|
|
5490
5490
|
|
|
5491
5491
|
|
|
@@ -5749,7 +5749,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
|
|
|
5749
5749
|
|
|
5750
5750
|
|
|
5751
5751
|
|
|
5752
|
-
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (
|
|
5752
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (17/10/2026-02:53:54)»*/
|
|
5753
5753
|
/*-----------------------------------------------------------------------------*/
|
|
5754
5754
|
|
|
5755
5755
|
|
|
@@ -8603,7 +8603,7 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
|
|
|
8603
8603
|
|
|
8604
8604
|
// (we bypass the channel and message types filters !)
|
|
8605
8605
|
try{
|
|
8606
|
-
httpEndpointResultObject.body=await serverReceptionEntryPoint.
|
|
8606
|
+
httpEndpointResultObject.body=await serverReceptionEntryPoint.executeWithAllPrerequisites(dataWrapped, eventOrMessage, null);
|
|
8607
8607
|
}catch(treatmentsChannelError){
|
|
8608
8608
|
// TODO : FIXME : DUPLICATED CODE !!!
|
|
8609
8609
|
const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
|
|
@@ -9374,7 +9374,7 @@ if(typeof(window)==="undefined") window=global;
|
|
|
9374
9374
|
// clientSocket.isConnectionAlive=true;
|
|
9375
9375
|
//});
|
|
9376
9376
|
|
|
9377
|
-
|
|
9377
|
+
const ERRORS_CHANNEL_NAME="errors";
|
|
9378
9378
|
|
|
9379
9379
|
|
|
9380
9380
|
// ==================================================================================================================
|
|
@@ -9769,11 +9769,12 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9769
9769
|
this.clientsRoomsTag=clientsRoomsTag;
|
|
9770
9770
|
|
|
9771
9771
|
this.serverReceptionEntryPoints=[];
|
|
9772
|
-
this.asyncPrerequisiteMethods=
|
|
9772
|
+
this.asyncPrerequisiteMethods=new Set();
|
|
9773
9773
|
}
|
|
9774
9774
|
|
|
9775
9775
|
// Executed whenever any message is received on any channel :
|
|
9776
9776
|
executeAll(eventOrMessage, clientSocket=null){ // FOR REAL-TIME ONLY :
|
|
9777
|
+
const self=this;
|
|
9777
9778
|
|
|
9778
9779
|
const clientsRoomsTag=this.clientsRoomsTag;
|
|
9779
9780
|
if(!window.WebsocketImplementation.isInRoom(clientSocket, clientsRoomsTag)) return;
|
|
@@ -9801,7 +9802,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9801
9802
|
// TRACE
|
|
9802
9803
|
lognow(errorMessage, treatmentsChannelError);
|
|
9803
9804
|
const errorDataWrapped={errorMessage:errorMessage, cause:treatmentsChannelError};
|
|
9804
|
-
self.sendError(errorDataWrapped, clientSocket);
|
|
9805
|
+
self.server.sendError(errorDataWrapped, clientSocket);
|
|
9805
9806
|
});
|
|
9806
9807
|
|
|
9807
9808
|
});
|
|
@@ -9811,13 +9812,14 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9811
9812
|
// TRACE
|
|
9812
9813
|
lognow(errorMessage, error);
|
|
9813
9814
|
const errorDataWrapped={errorMessage:errorMessage, cause:error};
|
|
9814
|
-
self.sendError(errorDataWrapped, clientSocket);
|
|
9815
|
+
self.server.sendError(errorDataWrapped, clientSocket);
|
|
9815
9816
|
});
|
|
9816
9817
|
|
|
9817
9818
|
}
|
|
9818
9819
|
|
|
9820
|
+
|
|
9819
9821
|
addReceiveListenerPrerequisite(asyncPrerequisiteMethod){
|
|
9820
|
-
this.asyncPrerequisiteMethods.
|
|
9822
|
+
this.asyncPrerequisiteMethods.add(asyncPrerequisiteMethod);
|
|
9821
9823
|
// TRACE
|
|
9822
9824
|
lognow("INFO : Added prerequisite: asyncPrerequisiteMethods:",asyncPrerequisiteMethod);
|
|
9823
9825
|
return this;
|
|
@@ -9843,6 +9845,10 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9843
9845
|
// I-
|
|
9844
9846
|
// ASYNC
|
|
9845
9847
|
addReceiveListener(messageType, asyncDoOnIncomingMessage, httpEndpointDefinition=null){
|
|
9848
|
+
|
|
9849
|
+
// DBG
|
|
9850
|
+
lognow("(SERVER) (ServerReceptionEntryPointsBag) Registering receive (NEW API) for message type «"+messageType+"»...");
|
|
9851
|
+
|
|
9846
9852
|
const channelNameParam=this.channelNameParam;
|
|
9847
9853
|
const clientsRoomsTag=this.clientsRoomsTag;
|
|
9848
9854
|
const messageTypes=(!messageType || empty(messageType) ? [] :
|
|
@@ -9850,7 +9856,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9850
9856
|
);
|
|
9851
9857
|
const listenerConfig={listenerMessageTypes:messageTypes, httpEndpointDefinition:httpEndpointDefinition};
|
|
9852
9858
|
const serverReceptionEntryPoint=
|
|
9853
|
-
new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
|
|
9859
|
+
new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage, this);
|
|
9854
9860
|
this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
|
|
9855
9861
|
|
|
9856
9862
|
if(httpEndpointDefinition){
|
|
@@ -9870,11 +9876,12 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9870
9876
|
|
|
9871
9877
|
window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
9872
9878
|
|
|
9873
|
-
constructor(channelNameParam, clientsRoomsTag, listenerConfig=null, asyncDoOnIncomingMessage){
|
|
9879
|
+
constructor(channelNameParam, clientsRoomsTag, listenerConfig=null, asyncDoOnIncomingMessage, parentServerReceptionEntryPointsBag=null){
|
|
9874
9880
|
this.channelName=channelNameParam;
|
|
9875
9881
|
this.clientsRoomsTag=clientsRoomsTag;
|
|
9876
9882
|
this.listenerConfig=listenerConfig;
|
|
9877
9883
|
this.asyncDoOnIncomingMessage=asyncDoOnIncomingMessage;
|
|
9884
|
+
this.parentServerReceptionEntryPointsBag=parentServerReceptionEntryPointsBag;
|
|
9878
9885
|
}
|
|
9879
9886
|
|
|
9880
9887
|
async execute(eventOrMessage, clientSocketParam=null){
|
|
@@ -9882,7 +9889,7 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
|
9882
9889
|
if(!eventOrMessage){
|
|
9883
9890
|
// TRACE
|
|
9884
9891
|
lognow("ERROR : No message received.");
|
|
9885
|
-
return;
|
|
9892
|
+
return null;
|
|
9886
9893
|
}
|
|
9887
9894
|
|
|
9888
9895
|
// OLD :
|
|
@@ -9901,7 +9908,7 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
|
9901
9908
|
|
|
9902
9909
|
// Room information is stored in client socket object :
|
|
9903
9910
|
const isClientInRoom=window.WebsocketImplementation.isInRoom(clientSocketParam, this.clientsRoomsTag);
|
|
9904
|
-
if(!isClientInRoom) return;
|
|
9911
|
+
if(!isClientInRoom) return null;
|
|
9905
9912
|
|
|
9906
9913
|
|
|
9907
9914
|
if(this.listenerConfig){
|
|
@@ -9910,7 +9917,7 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
|
9910
9917
|
// Else we check if the message matches the required message types :
|
|
9911
9918
|
if( dataWrapped.data && dataWrapped.data.type
|
|
9912
9919
|
&& !contains(this.listenerConfig.listenerMessageTypes, dataWrapped.data.type))
|
|
9913
|
-
return;
|
|
9920
|
+
return null;
|
|
9914
9921
|
}
|
|
9915
9922
|
}
|
|
9916
9923
|
|
|
@@ -9927,6 +9934,13 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
|
9927
9934
|
}
|
|
9928
9935
|
|
|
9929
9936
|
}
|
|
9937
|
+
|
|
9938
|
+
async executeWithAllPrerequisites(dataWrapped, originalEventOrMessage, clientSocket){
|
|
9939
|
+
if(this.parentServerReceptionEntryPointsBag)
|
|
9940
|
+
await this.parentServerReceptionEntryPointsBag.executeAllPrerequisites(dataWrapped, originalEventOrMessage, clientSocket);
|
|
9941
|
+
return await this.execute(originalEventOrMessage, clientSocket);
|
|
9942
|
+
}
|
|
9943
|
+
|
|
9930
9944
|
}
|
|
9931
9945
|
|
|
9932
9946
|
|
|
@@ -9980,10 +9994,10 @@ window.NodeServerInstance=class NodeServerInstance{
|
|
|
9980
9994
|
receive(channelNameParam, doOnIncomingMessage, listenerConfig=null, clientsRoomsTag=null){
|
|
9981
9995
|
|
|
9982
9996
|
// DBG
|
|
9983
|
-
lognow("(SERVER) Registering receive (OLD API) for channel «"+channelNameParam+"»...");
|
|
9997
|
+
lognow("(SERVER) (NodeServerInstance) Registering receive (OLD API) for channel «"+channelNameParam+"»...");
|
|
9984
9998
|
|
|
9985
9999
|
const serverReceptionEntryPoint=
|
|
9986
|
-
new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, doOnIncomingMessage);
|
|
10000
|
+
new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, doOnIncomingMessage, null);
|
|
9987
10001
|
this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
|
|
9988
10002
|
|
|
9989
10003
|
//OLD: // SPECIAL FOR THE SOCKETIO IMPLEMENTATION :
|
|
@@ -10102,7 +10116,29 @@ window.NodeServerInstance=class NodeServerInstance{
|
|
|
10102
10116
|
|
|
10103
10117
|
return dataWrapped;
|
|
10104
10118
|
}
|
|
10105
|
-
|
|
10119
|
+
|
|
10120
|
+
|
|
10121
|
+
/*private*/sendError(error, clientSocketParam=null){
|
|
10122
|
+
// CAUTION ! NEVER DO THIS : clientSocketParam.send(...) ! (because it directly calls a single socket implementation !)
|
|
10123
|
+
|
|
10124
|
+
let errorMessageToSend=error;
|
|
10125
|
+
if(contains(typeof(error),"Error")){
|
|
10126
|
+
errorMessageToSend={
|
|
10127
|
+
type: error.type,
|
|
10128
|
+
httpStatus:error.httpStatus,
|
|
10129
|
+
error:(isString(error) ?
|
|
10130
|
+
{errorMessage:error}
|
|
10131
|
+
: {errorMessage:error.errorMessage, cause:(error.cause?{message:error.cause.message}:null)})
|
|
10132
|
+
};
|
|
10133
|
+
}
|
|
10134
|
+
|
|
10135
|
+
if(clientSocketParam){
|
|
10136
|
+
return this.send(ERRORS_CHANNEL_NAME, errorMessageToSend, null, clientSocketParam);
|
|
10137
|
+
}
|
|
10138
|
+
return errorMessageToSend;
|
|
10139
|
+
}
|
|
10140
|
+
|
|
10141
|
+
|
|
10106
10142
|
|
|
10107
10143
|
onConnectionToClient(doOnConnection, doOnConnectionLost=null){
|
|
10108
10144
|
const self=this;
|
|
@@ -10142,7 +10178,7 @@ window.NodeServerInstance=class NodeServerInstance{
|
|
|
10142
10178
|
// We execute the events registration listeners entry points:
|
|
10143
10179
|
// DEPRECATED : OLD API :
|
|
10144
10180
|
foreach(self.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
|
|
10145
|
-
serverReceptionEntryPoint.execute(eventOrMessage, clientSocket
|
|
10181
|
+
serverReceptionEntryPoint.execute(eventOrMessage, clientSocket).then(()=>{
|
|
10146
10182
|
/*DO NOTHING*/
|
|
10147
10183
|
}).catch(treatmentsChannelError=>{
|
|
10148
10184
|
// TODO : FIXME : DUPLICATED CODE !!!
|
aotrautils-srv/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2039",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "aotrautils-srv",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.2039",
|
|
10
10
|
"license": "HGPL-1.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"atob": "^2.1.2",
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2039",
|
|
4
4
|
"main": "aotrautils-srv.build.js",
|
|
5
5
|
"description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
|
|
6
6
|
"author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
|