aotrautils-srv 0.0.2036 → 0.0.2037

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 (13/10/2026-01:52:47)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:34)»*/
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 (13/10/2026-01:52:47)»*/
5488
+ /*utils AI library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:34)»*/
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 (13/10/2026-01:52:47)»*/
5752
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:34)»*/
5753
5753
  /*-----------------------------------------------------------------------------*/
5754
5754
 
5755
5755
 
@@ -8586,19 +8586,33 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
8586
8586
  if( requestHttpMethod=="GET" &&
8587
8587
  (!httpEndpoint.httpMethod || empty(httpEndpoint.httpMethod) || httpEndpoint.httpMethod.toUpperCase()=="GET")){
8588
8588
 
8589
- messageIn={...getRequestURLParameters(request)};
8589
+ messageIn={...getRequestURLParameters(request), ...getRequestHeaders(request)};
8590
8590
 
8591
8591
  }else if(requestHttpMethod=="POST"
8592
8592
  && contains(["POST","PUT","PATCH","DELETE"],httpEndpoint.httpMethod.toUpperCase())){
8593
8593
 
8594
- messageIn={...getRequestURLParameters(request), ...(await getRequestBody(request))};
8594
+ messageIn={...getRequestURLParameters(request), ...getRequestHeaders(request), ...(await getRequestBody(request))};
8595
8595
  }
8596
8596
 
8597
8597
  if(messageIn){
8598
8598
  let httpEndpointResultObject={httpStatus:200, body:{}};
8599
8599
  const serverReceptionEntryPoint=httpEndpoint.serverReceptionEntryPoint;
8600
8600
  if(serverReceptionEntryPoint){
8601
- httpEndpointResultObject.body=serverReceptionEntryPoint.execute(messageIn, null, false);
8601
+ const dataWrapped={data:messageIn};
8602
+ const eventOrMessage={data:dataWrapped};
8603
+
8604
+ // (we bypass the channel and message types filters !)
8605
+ try{
8606
+ httpEndpointResultObject.body=await serverReceptionEntryPoint.execute(eventOrMessage, null, false);
8607
+ }catch(treatmentsChannelError){
8608
+ // TODO : FIXME : DUPLICATED CODE !!!
8609
+ const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
8610
+ // TRACE
8611
+ lognow(errorMessage, treatmentsChannelError);
8612
+ const errorDataWrapped={errorMessage:errorMessage, cause:{message:treatmentsChannelError.message}};
8613
+ httpEndpointResultObject.body=errorDataWrapped;
8614
+ httpEndpointResultObject.httpStatus=500;
8615
+ }
8602
8616
  }
8603
8617
 
8604
8618
  response.writeHead(httpEndpointResultObject.httpStatus, { "Content-Type": "application/json" });
@@ -9281,6 +9295,17 @@ window.isURLLocalhost=(url)=>{
9281
9295
 
9282
9296
 
9283
9297
 
9298
+ window.assert={};
9299
+ window.assert.notNull=(value, errorMessage=null)=>{
9300
+ if(typeof(value)=="undefined" || value==null)
9301
+ throw new Error(nonull(errorMessage, "ERROR : Value is null."));
9302
+ };
9303
+
9304
+
9305
+
9306
+
9307
+
9308
+
9284
9309
  /* ## Utility network global methods in a javascript, console (nodejs), or vanilla javascript with no browser environment.
9285
9310
  *
9286
9311
  * This set of methods gathers utility generic-purpose methods usable in any JS project.
@@ -9768,25 +9793,25 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9768
9793
  foreach(this.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
9769
9794
 
9770
9795
  // All listeners are executed IN PARALLEL !
9771
- const p=serverReceptionEntryPoint.execute(eventOrMessageParam, clientSocket);
9772
- p.then((message)=>{
9796
+ serverReceptionEntryPoint.execute(eventOrMessageParam, clientSocket).then((message)=>{
9773
9797
  /*DO NOTHING*/
9774
9798
  }).catch(treatmentsChannelError=>{
9799
+ // TODO : FIXME : DUPLICATED CODE !!!
9775
9800
  const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
9776
-
9777
9801
  // TRACE
9778
9802
  lognow(errorMessage, treatmentsChannelError);
9779
-
9780
9803
  const errorDataWrapped={errorMessage:errorMessage, cause:treatmentsChannelError};
9781
- self.sendError(errorDataWrapped, clientSocketParam);
9782
-
9804
+ self.sendError(errorDataWrapped, clientSocket);
9783
9805
  });
9784
9806
 
9785
9807
  });
9786
9808
 
9787
9809
  }).catch(error=>{
9810
+ const errorMessage="ERROR : (.executeAllPrerequisites()) A prerequisite encountered an error :";
9788
9811
  // TRACE
9789
- lognow("ERROR : (.executeAllPrerequisites()) A prerequisite encountered an error :", error);
9812
+ lognow(errorMessage, error);
9813
+ const errorDataWrapped={errorMessage:errorMessage, cause:error};
9814
+ self.sendError(errorDataWrapped, clientSocket);
9790
9815
  });
9791
9816
 
9792
9817
  }
@@ -9822,7 +9847,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9822
9847
  const clientsRoomsTag=this.clientsRoomsTag;
9823
9848
  const messageTypes=(!messageType || empty(messageType) ? [] :
9824
9849
  (isArray(messageType) ? messageType : [messageType])
9825
- );
9850
+ );
9826
9851
  const listenerConfig={listenerMessageTypes:messageTypes, httpEndpointDefinition:httpEndpointDefinition};
9827
9852
  const serverReceptionEntryPoint=
9828
9853
  new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
@@ -9832,6 +9857,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9832
9857
  // TRACE
9833
9858
  lognow("INFO : Registered HTTP listener:",httpEndpointDefinition);
9834
9859
 
9860
+ httpEndpointDefinition.serverReceptionEntryPoint=serverReceptionEntryPoint;
9835
9861
  this.server.httpEndpoints.push(httpEndpointDefinition);
9836
9862
  }
9837
9863
 
@@ -9893,7 +9919,11 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
9893
9919
  const dataRestored=restoreClassesInformation(dataLocal);
9894
9920
 
9895
9921
  // CAUTION : This method can be ASYNC or NOT ASYNC !!!
9896
- this.asyncDoOnIncomingMessage(dataRestored, clientSocketParam);
9922
+ // DBG
9923
+ if(isAsyncFunction(this.asyncDoOnIncomingMessage))
9924
+ return await this.asyncDoOnIncomingMessage(dataRestored, clientSocketParam);
9925
+ return this.asyncDoOnIncomingMessage(dataRestored, clientSocketParam);
9926
+
9897
9927
  }
9898
9928
 
9899
9929
  }
@@ -9990,8 +10020,9 @@ window.NodeServerInstance=class NodeServerInstance{
9990
10020
  // Channel information is stored in exchanged data :
9991
10021
  let dataWrapped=saveClassesInformation({channelName:channelName, data:data});
9992
10022
 
9993
-
9994
- if(!clientSocketParam){
10023
+ if(!clientSocketParam) return dataWrapped;
10024
+
10025
+ if(isString(clientSocketParam) && clientSocketParam=="*"){
9995
10026
 
9996
10027
  // DBG
9997
10028
  lognow("(SERVER) (server sends to all clients)");
@@ -10113,7 +10144,15 @@ window.NodeServerInstance=class NodeServerInstance{
10113
10144
  foreach(self.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
10114
10145
  serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true).then(()=>{
10115
10146
  /*DO NOTHING*/
10147
+ }).catch(treatmentsChannelError=>{
10148
+ // TODO : FIXME : DUPLICATED CODE !!!
10149
+ const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
10150
+ // TRACE
10151
+ lognow(errorMessage, treatmentsChannelError);
10152
+ const errorDataWrapped={errorMessage:errorMessage, cause:treatmentsChannelError};
10153
+ self.sendError(errorDataWrapped, clientSocket);
10116
10154
  });
10155
+
10117
10156
  });
10118
10157
 
10119
10158
  // NEW API :
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.2036",
3
+ "version": "0.0.2037",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aotrautils-srv",
9
- "version": "0.0.2036",
9
+ "version": "0.0.2037",
10
10
  "license": "HGPL-1.0",
11
11
  "dependencies": {
12
12
  "atob": "^2.1.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.2036",
3
+ "version": "0.0.2037",
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)",