aotrautils-srv 0.0.2031 → 0.0.2032
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 (13/10/2026-01:16:06)»*/
|
|
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 (13/10/2026-01:16:06)»*/
|
|
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 (13/10/2026-01:16:06)»*/
|
|
5753
5753
|
/*-----------------------------------------------------------------------------*/
|
|
5754
5754
|
|
|
5755
5755
|
|
|
@@ -8162,11 +8162,11 @@ window.WebsocketImplementation={
|
|
|
8162
8162
|
|| contains(clientsRoomsTag, clientSocket.clientRoomTag));
|
|
8163
8163
|
},
|
|
8164
8164
|
|
|
8165
|
-
/*public static*/isInRightChannel(
|
|
8166
|
-
return (!
|
|
8167
|
-
|| !
|
|
8165
|
+
/*public static*/isInRightChannel(dataWrapped, channelName){
|
|
8166
|
+
return (!dataWrapped || empty(dataWrapped)
|
|
8167
|
+
|| !dataWrapped.channelName || empty(dataWrapped.channelName)
|
|
8168
8168
|
|| !channelName || empty(channelName)
|
|
8169
|
-
||
|
|
8169
|
+
|| dataWrapped.channelName==channelName);
|
|
8170
8170
|
},
|
|
8171
8171
|
|
|
8172
8172
|
//
|
|
@@ -8569,15 +8569,10 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
|
|
|
8569
8569
|
};
|
|
8570
8570
|
|
|
8571
8571
|
|
|
8572
|
-
/*private static*/
|
|
8572
|
+
const /*private static*/HANDLE_HTTP_ENDPOINTS=async function(request, response){
|
|
8573
8573
|
const url=new URL(request.url, `https://${request.headers.host}`);
|
|
8574
8574
|
|
|
8575
8575
|
|
|
8576
|
-
// DBG
|
|
8577
|
-
lognow(" DEBUG : handler.httpEndpoints:",handler.httpEndpoints);
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
8576
|
for(const httpEndpoint of handler.httpEndpoints){
|
|
8582
8577
|
|
|
8583
8578
|
|
|
@@ -8593,7 +8588,6 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
|
|
|
8593
8588
|
|
|
8594
8589
|
messageIn={...getRequestURLParameters(request)};
|
|
8595
8590
|
|
|
8596
|
-
return true;
|
|
8597
8591
|
}else if(requestHttpMethod=="POST"
|
|
8598
8592
|
&& contains(["POST","PUT","PATCH","DELETE"],httpEndpoint.httpMethod.toUpperCase())){
|
|
8599
8593
|
|
|
@@ -8609,6 +8603,8 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
|
|
|
8609
8603
|
|
|
8610
8604
|
response.writeHead(httpEndpointResultObject.httpStatus, { "Content-Type": "application/json" });
|
|
8611
8605
|
response.end(JSON.stringify(httpEndpointResultObject.body));
|
|
8606
|
+
|
|
8607
|
+
return true;
|
|
8612
8608
|
}
|
|
8613
8609
|
|
|
8614
8610
|
|
|
@@ -8623,13 +8619,13 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
|
|
|
8623
8619
|
return false;
|
|
8624
8620
|
};
|
|
8625
8621
|
|
|
8626
|
-
const handler=function(request, response){
|
|
8622
|
+
const handler=nonull(httpHandlerParam, function(request, response){
|
|
8627
8623
|
|
|
8628
8624
|
try{
|
|
8629
8625
|
EXCLUSION_HANDLER(request, response);
|
|
8630
|
-
|
|
8626
|
+
HANDLE_HTTP_ENDPOINTS(request, response).then(httpEndpointHasInterceptedRequest=>{
|
|
8631
8627
|
if(!httpEndpointHasInterceptedRequest){
|
|
8632
|
-
|
|
8628
|
+
DEFAULT_HANDLER_HTTP_FILE_RETRIEVAL(request, response);
|
|
8633
8629
|
}
|
|
8634
8630
|
}).catch(error=>{
|
|
8635
8631
|
// TRACE
|
|
@@ -8640,7 +8636,7 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
|
|
|
8640
8636
|
lognow("ERROR : An error occurred when trying to process request :error:",error);
|
|
8641
8637
|
}
|
|
8642
8638
|
|
|
8643
|
-
};
|
|
8639
|
+
});
|
|
8644
8640
|
|
|
8645
8641
|
|
|
8646
8642
|
let listenableServer;
|
|
@@ -9484,10 +9480,8 @@ window.ClientReceptionEntryPoint=class ClientReceptionEntryPoint{
|
|
|
9484
9480
|
const dataWrapped=window.WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
|
|
9485
9481
|
|
|
9486
9482
|
// We check if the message is in the right channel (channel information is stored in exchanged wrapped data) :
|
|
9487
|
-
|
|
9488
|
-
if(dataWrapped
|
|
9489
|
-
return;
|
|
9490
|
-
}
|
|
9483
|
+
// Channel information is stored in wrapped exchanged data :
|
|
9484
|
+
if(!window.WebsocketImplementation.isInRightChannel(dataWrapped, this.channelName)) return;
|
|
9491
9485
|
|
|
9492
9486
|
// We check if the message is in the right room (r)oom information is stored in client socket object) :
|
|
9493
9487
|
if(!window.WebsocketImplementation.isInRoom(clientSocket, this.clientsRoomsTag)) return;
|
|
@@ -9756,24 +9750,30 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9756
9750
|
// Executed whenever any message is received on any channel :
|
|
9757
9751
|
executeAll(eventOrMessage, clientSocket=null){ // FOR REAL-TIME ONLY :
|
|
9758
9752
|
|
|
9759
|
-
|
|
9760
9753
|
const clientsRoomsTag=this.clientsRoomsTag;
|
|
9761
9754
|
if(!window.WebsocketImplementation.isInRoom(clientSocket, clientsRoomsTag)) return;
|
|
9762
9755
|
|
|
9763
9756
|
const channelName=this.channelName;
|
|
9764
|
-
|
|
9757
|
+
|
|
9758
|
+
const dataWrapped=window.WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
|
|
9759
|
+
|
|
9760
|
+
// Channel information is stored in wrapped exchanged data :
|
|
9761
|
+
if(!window.WebsocketImplementation.isInRightChannel(dataWrapped, channelName)) return;
|
|
9765
9762
|
|
|
9766
|
-
executeAllPrerequisites(eventOrMessage).then(
|
|
9767
|
-
|
|
9763
|
+
this.executeAllPrerequisites(dataWrapped, eventOrMessage, clientSocket).then(eventOrMessageParam=>{
|
|
9764
|
+
|
|
9765
|
+
//DBG
|
|
9766
|
+
lognow("DEBUG : Prerequisite passed, executing server reception points...");
|
|
9767
|
+
|
|
9768
9768
|
foreach(this.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
|
|
9769
9769
|
|
|
9770
9770
|
// All listeners are executed IN PARALLEL !
|
|
9771
|
-
serverReceptionEntryPoint.execute(
|
|
9771
|
+
const p=serverReceptionEntryPoint.execute(eventOrMessageParam, clientSocket);
|
|
9772
|
+
p.then((message)=>{
|
|
9772
9773
|
/*DO NOTHING*/
|
|
9773
9774
|
lognow("SERVER : DEBUG : Server sent message:",message);
|
|
9774
9775
|
}).catch(treatmentsChannelError=>{
|
|
9775
|
-
|
|
9776
|
-
const errorMessage="INFO : An error has occured during the processing of a client message on channel treatments.";
|
|
9776
|
+
const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
|
|
9777
9777
|
|
|
9778
9778
|
// TRACE
|
|
9779
9779
|
lognow(errorMessage, treatmentsChannelError);
|
|
@@ -9787,11 +9787,9 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9787
9787
|
|
|
9788
9788
|
}).catch(error=>{
|
|
9789
9789
|
// TRACE
|
|
9790
|
-
lognow("ERROR : (.
|
|
9790
|
+
lognow("ERROR : (.executeAllPrerequisites()) A prerequisite encountered an error :", error);
|
|
9791
9791
|
});
|
|
9792
9792
|
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
9793
|
}
|
|
9796
9794
|
|
|
9797
9795
|
addReceiveListenerPrerequisite(asyncPrerequisiteMethod){
|
|
@@ -9801,21 +9799,24 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9801
9799
|
return this;
|
|
9802
9800
|
}
|
|
9803
9801
|
|
|
9804
|
-
async executeAllPrerequisites(
|
|
9805
|
-
|
|
9802
|
+
async executeAllPrerequisites(dataWrapped, originalEventOrMessage, clientSocket){
|
|
9803
|
+
|
|
9804
|
+
const message=dataWrapped.data
|
|
9806
9805
|
let i=1;
|
|
9807
9806
|
try {
|
|
9808
|
-
for(const asyncPrerequisiteMethod of this.asyncPrerequisiteMethods)
|
|
9809
|
-
|
|
9807
|
+
for(const asyncPrerequisiteMethod of this.asyncPrerequisiteMethods){
|
|
9808
|
+
await asyncPrerequisiteMethod(message, clientSocket);
|
|
9810
9809
|
i++;
|
|
9811
9810
|
}
|
|
9812
9811
|
}catch(error){
|
|
9813
9812
|
// TRACE
|
|
9814
9813
|
lognow("ERROR : (.executeAllPrerequisites()) Prerequisite #"+i+" encountered an error :", error);
|
|
9814
|
+
throw error;
|
|
9815
9815
|
}
|
|
9816
|
-
return
|
|
9816
|
+
return originalEventOrMessage;
|
|
9817
9817
|
}
|
|
9818
9818
|
|
|
9819
|
+
// I-
|
|
9819
9820
|
// ASYNC
|
|
9820
9821
|
addReceiveListener(messageType, asyncDoOnIncomingMessage, httpEndpointDefinition=null){
|
|
9821
9822
|
const channelNameParam=this.channelNameParam;
|
|
@@ -9824,7 +9825,8 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
|
|
|
9824
9825
|
(isArray(messageType) ? messageType : [messageType])
|
|
9825
9826
|
);
|
|
9826
9827
|
const listenerConfig={listenerMessageTypes:messageTypes, httpEndpointDefinition:httpEndpointDefinition};
|
|
9827
|
-
const serverReceptionEntryPoint=
|
|
9828
|
+
const serverReceptionEntryPoint=
|
|
9829
|
+
new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
|
|
9828
9830
|
this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
|
|
9829
9831
|
|
|
9830
9832
|
if(httpEndpointDefinition){
|
|
@@ -9850,7 +9852,11 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
|
9850
9852
|
this.asyncDoOnIncomingMessage=asyncDoOnIncomingMessage;
|
|
9851
9853
|
}
|
|
9852
9854
|
|
|
9853
|
-
execute(eventOrMessage, clientSocketParam=null){
|
|
9855
|
+
async execute(eventOrMessage, clientSocketParam=null){
|
|
9856
|
+
|
|
9857
|
+
// DBG
|
|
9858
|
+
lognow("DEBUG : ServerReceptionEntryPoint.execute()");
|
|
9859
|
+
|
|
9854
9860
|
|
|
9855
9861
|
if(!eventOrMessage){
|
|
9856
9862
|
// TRACE
|
|
@@ -9869,9 +9875,9 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
|
|
|
9869
9875
|
|
|
9870
9876
|
const dataWrapped=window.WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
|
|
9871
9877
|
|
|
9872
|
-
// Channel information is stored in exchanged data :
|
|
9873
|
-
if(dataWrapped
|
|
9874
|
-
|
|
9878
|
+
// Channel information is stored in wrapped exchanged data :
|
|
9879
|
+
if(!window.WebsocketImplementation.isInRightChannel(dataWrapped, this.channelName)) return;
|
|
9880
|
+
|
|
9875
9881
|
// Room information is stored in client socket object :
|
|
9876
9882
|
const isClientInRoom=window.WebsocketImplementation.isInRoom(clientSocketParam, this.clientsRoomsTag);
|
|
9877
9883
|
if(!isClientInRoom) return;
|
|
@@ -9943,15 +9949,16 @@ window.NodeServerInstance=class NodeServerInstance{
|
|
|
9943
9949
|
//sendChainable(channelNameParam, data, clientsRoomsTag=null){
|
|
9944
9950
|
//}
|
|
9945
9951
|
|
|
9946
|
-
// I-
|
|
9952
|
+
// I-
|
|
9953
|
+
// NOT ASYNC
|
|
9947
9954
|
// DEPRECATED, USE THE NEW API INSTEAD :
|
|
9948
9955
|
receive(channelNameParam, doOnIncomingMessage, listenerConfig=null, clientsRoomsTag=null){
|
|
9949
9956
|
|
|
9950
9957
|
// DBG
|
|
9951
9958
|
lognow("(SERVER) Registering receive (OLD API) for channel «"+channelNameParam+"»...");
|
|
9952
9959
|
|
|
9953
|
-
const serverReceptionEntryPoint=
|
|
9954
|
-
|
|
9960
|
+
const serverReceptionEntryPoint=
|
|
9961
|
+
new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, doOnIncomingMessage);
|
|
9955
9962
|
this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
|
|
9956
9963
|
|
|
9957
9964
|
//OLD: // SPECIAL FOR THE SOCKETIO IMPLEMENTATION :
|
|
@@ -10109,7 +10116,9 @@ window.NodeServerInstance=class NodeServerInstance{
|
|
|
10109
10116
|
// We execute the events registration listeners entry points:
|
|
10110
10117
|
// DEPRECATED : OLD API :
|
|
10111
10118
|
foreach(self.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
|
|
10112
|
-
serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true)
|
|
10119
|
+
serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true).then(()=>{
|
|
10120
|
+
/*DO NOTHING*/
|
|
10121
|
+
});
|
|
10113
10122
|
});
|
|
10114
10123
|
|
|
10115
10124
|
// NEW API :
|
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.2032",
|
|
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.2032",
|
|
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.2032",
|
|
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)",
|