aotrautils-srv 0.0.2038 → 0.0.2040

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 (17/10/2026-01:27:15)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (18/10/2026-01:58:26)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -457,6 +457,30 @@ if(!window.aotestAllTestsManager){
457
457
  // Utility methods for aotest framework :
458
458
 
459
459
  // UI/CLI ONLY :
460
+
461
+ window.aotestMethods.getTestsMapForScenarii=(testsArray, scenariiNames=null/*(OPTIONAL)*/)=>{
462
+ const testsMap={};
463
+
464
+ if(!scenariiNames || scenariiNames=="" || scenariiNames=="*"){// Case we want all tests from all scenarii:
465
+ foreach(testsArray, (test, testName)=>{
466
+ // (to avoid doing this treatment several times unecessarily)
467
+ if(testsMap[testName]) return "continue";
468
+ testsMap[testName]=test;
469
+ });
470
+ }else{
471
+ foreach(scenariiNames,scenarioName=>{
472
+ foreach(testsArray,(test,testName)=>{
473
+ // (to avoid doing this treatment several times unecessarily)
474
+ if(testsMap[testName]) return "continue";
475
+ testsMap[testName]=test;
476
+ },(test, testName)=>(contains(Object.keys(test),scenarioName)));
477
+ });
478
+ }
479
+
480
+ return testsMap;
481
+ };
482
+
483
+
460
484
  window.aotestMethods.getParentTestByScenarioNameInTestsArray=function(testsArray, scenarioName){
461
485
  return foreach(testsArray,test=>{
462
486
  return window.aotestMethods.iterateOverScenariiInSingleTest(test, (parentTest, scenario)=>{
@@ -560,7 +584,7 @@ window.aotestMethods.getScenarioInSingleTest=function(test, scenarioName=null){
560
584
  window.aotestMethods.getScenariiInSingleTest=function(test, scenariiNames=null){
561
585
  let results={};
562
586
  window.aotestMethods.iterateOverScenariiInSingleTest(test,(t,s,sName)=>{
563
- if(!scenariiNames || contains(scenariiNames, sName)){
587
+ if(!scenariiNames || scenariiNames=="" || scenariiNames=="*" || contains(scenariiNames, sName)){
564
588
  results[sName]=s;
565
589
  }
566
590
  });
@@ -578,6 +602,7 @@ window.aotestMethods.iterateOverScenariiInSingleTest=function(test, doOnEachIter
578
602
 
579
603
 
580
604
 
605
+
581
606
  /*public*/window.aotestMethods.iterateOverValuesOnClonedObject=function(scenarioParam, doOnIterationForValue, visited=[], valuePath="", isValueFunction=null){
582
607
 
583
608
  // CAUTION : We ABSOLUTELY need to iterate over a deep copy, or else it will create weird incomprehensible bugs
@@ -5485,7 +5510,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
5485
5510
 
5486
5511
 
5487
5512
 
5488
- /*utils AI library associated with aotra version : «1_29072022-2359 (17/10/2026-01:27:15)»*/
5513
+ /*utils AI library associated with aotra version : «1_29072022-2359 (18/10/2026-01:58:26)»*/
5489
5514
  /*-----------------------------------------------------------------------------*/
5490
5515
 
5491
5516
 
@@ -5749,7 +5774,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
5749
5774
 
5750
5775
 
5751
5776
 
5752
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (17/10/2026-01:27:15)»*/
5777
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (18/10/2026-01:58:26)»*/
5753
5778
  /*-----------------------------------------------------------------------------*/
5754
5779
 
5755
5780
 
@@ -8603,7 +8628,7 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
8603
8628
 
8604
8629
  // (we bypass the channel and message types filters !)
8605
8630
  try{
8606
- httpEndpointResultObject.body=await serverReceptionEntryPoint.execute(eventOrMessage, null, false);
8631
+ httpEndpointResultObject.body=await serverReceptionEntryPoint.executeWithAllPrerequisites(dataWrapped, eventOrMessage, null);
8607
8632
  }catch(treatmentsChannelError){
8608
8633
  // TODO : FIXME : DUPLICATED CODE !!!
8609
8634
  const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
@@ -9296,9 +9321,9 @@ window.isURLLocalhost=(url)=>{
9296
9321
 
9297
9322
 
9298
9323
  window.assert={};
9299
- window.assert.notNull=(value, errorMessage=null)=>{
9324
+ window.assert.notNull=(value, variableName=null, errorMessage=null)=>{
9300
9325
  if(typeof(value)=="undefined" || value==null)
9301
- throw new Error(nonull(errorMessage, "ERROR : Value is null."));
9326
+ throw new Error(nonull(errorMessage, (variableName?"ERROR : "+variableName+" is null.":"ERROR : Value is null.")));
9302
9327
  };
9303
9328
 
9304
9329
 
@@ -9769,7 +9794,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9769
9794
  this.clientsRoomsTag=clientsRoomsTag;
9770
9795
 
9771
9796
  this.serverReceptionEntryPoints=[];
9772
- this.asyncPrerequisiteMethods=[];
9797
+ this.asyncPrerequisiteMethods=new Set();
9773
9798
  }
9774
9799
 
9775
9800
  // Executed whenever any message is received on any channel :
@@ -9817,8 +9842,9 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9817
9842
 
9818
9843
  }
9819
9844
 
9845
+
9820
9846
  addReceiveListenerPrerequisite(asyncPrerequisiteMethod){
9821
- this.asyncPrerequisiteMethods.push(asyncPrerequisiteMethod);
9847
+ this.asyncPrerequisiteMethods.add(asyncPrerequisiteMethod);
9822
9848
  // TRACE
9823
9849
  lognow("INFO : Added prerequisite: asyncPrerequisiteMethods:",asyncPrerequisiteMethod);
9824
9850
  return this;
@@ -9844,6 +9870,10 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9844
9870
  // I-
9845
9871
  // ASYNC
9846
9872
  addReceiveListener(messageType, asyncDoOnIncomingMessage, httpEndpointDefinition=null){
9873
+
9874
+ // DBG
9875
+ lognow("(SERVER) (ServerReceptionEntryPointsBag) Registering receive (NEW API) for message type «"+messageType+"»...");
9876
+
9847
9877
  const channelNameParam=this.channelNameParam;
9848
9878
  const clientsRoomsTag=this.clientsRoomsTag;
9849
9879
  const messageTypes=(!messageType || empty(messageType) ? [] :
@@ -9851,7 +9881,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9851
9881
  );
9852
9882
  const listenerConfig={listenerMessageTypes:messageTypes, httpEndpointDefinition:httpEndpointDefinition};
9853
9883
  const serverReceptionEntryPoint=
9854
- new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
9884
+ new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage, this);
9855
9885
  this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
9856
9886
 
9857
9887
  if(httpEndpointDefinition){
@@ -9871,11 +9901,12 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
9871
9901
 
9872
9902
  window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
9873
9903
 
9874
- constructor(channelNameParam, clientsRoomsTag, listenerConfig=null, asyncDoOnIncomingMessage){
9904
+ constructor(channelNameParam, clientsRoomsTag, listenerConfig=null, asyncDoOnIncomingMessage, parentServerReceptionEntryPointsBag=null){
9875
9905
  this.channelName=channelNameParam;
9876
9906
  this.clientsRoomsTag=clientsRoomsTag;
9877
9907
  this.listenerConfig=listenerConfig;
9878
9908
  this.asyncDoOnIncomingMessage=asyncDoOnIncomingMessage;
9909
+ this.parentServerReceptionEntryPointsBag=parentServerReceptionEntryPointsBag;
9879
9910
  }
9880
9911
 
9881
9912
  async execute(eventOrMessage, clientSocketParam=null){
@@ -9883,7 +9914,7 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
9883
9914
  if(!eventOrMessage){
9884
9915
  // TRACE
9885
9916
  lognow("ERROR : No message received.");
9886
- return;
9917
+ return null;
9887
9918
  }
9888
9919
 
9889
9920
  // OLD :
@@ -9902,7 +9933,7 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
9902
9933
 
9903
9934
  // Room information is stored in client socket object :
9904
9935
  const isClientInRoom=window.WebsocketImplementation.isInRoom(clientSocketParam, this.clientsRoomsTag);
9905
- if(!isClientInRoom) return;
9936
+ if(!isClientInRoom) return null;
9906
9937
 
9907
9938
 
9908
9939
  if(this.listenerConfig){
@@ -9911,7 +9942,7 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
9911
9942
  // Else we check if the message matches the required message types :
9912
9943
  if( dataWrapped.data && dataWrapped.data.type
9913
9944
  && !contains(this.listenerConfig.listenerMessageTypes, dataWrapped.data.type))
9914
- return;
9945
+ return null;
9915
9946
  }
9916
9947
  }
9917
9948
 
@@ -9928,6 +9959,13 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
9928
9959
  }
9929
9960
 
9930
9961
  }
9962
+
9963
+ async executeWithAllPrerequisites(dataWrapped, originalEventOrMessage, clientSocket){
9964
+ if(this.parentServerReceptionEntryPointsBag)
9965
+ await this.parentServerReceptionEntryPointsBag.executeAllPrerequisites(dataWrapped, originalEventOrMessage, clientSocket);
9966
+ return await this.execute(originalEventOrMessage, clientSocket);
9967
+ }
9968
+
9931
9969
  }
9932
9970
 
9933
9971
 
@@ -9981,10 +10019,10 @@ window.NodeServerInstance=class NodeServerInstance{
9981
10019
  receive(channelNameParam, doOnIncomingMessage, listenerConfig=null, clientsRoomsTag=null){
9982
10020
 
9983
10021
  // DBG
9984
- lognow("(SERVER) Registering receive (OLD API) for channel «"+channelNameParam+"»...");
10022
+ lognow("(SERVER) (NodeServerInstance) Registering receive (OLD API) for channel «"+channelNameParam+"»...");
9985
10023
 
9986
10024
  const serverReceptionEntryPoint=
9987
- new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, doOnIncomingMessage);
10025
+ new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, doOnIncomingMessage, null);
9988
10026
  this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
9989
10027
 
9990
10028
  //OLD: // SPECIAL FOR THE SOCKETIO IMPLEMENTATION :
@@ -10165,7 +10203,7 @@ window.NodeServerInstance=class NodeServerInstance{
10165
10203
  // We execute the events registration listeners entry points:
10166
10204
  // DEPRECATED : OLD API :
10167
10205
  foreach(self.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
10168
- serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true).then(()=>{
10206
+ serverReceptionEntryPoint.execute(eventOrMessage, clientSocket).then(()=>{
10169
10207
  /*DO NOTHING*/
10170
10208
  }).catch(treatmentsChannelError=>{
10171
10209
  // TODO : FIXME : DUPLICATED CODE !!!
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.2038",
3
+ "version": "0.0.2040",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aotrautils-srv",
9
- "version": "0.0.2038",
9
+ "version": "0.0.2040",
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.2038",
3
+ "version": "0.0.2040",
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)",