aotrautils 0.0.1592 → 0.0.1593

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 (11/05/2025-17:25:45)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (12/05/2025-16:11:18)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -447,17 +447,63 @@ if(!window.aotestAllTestsManager){
447
447
  window.aotestAllTestsManager.currentRunningScenario=null;
448
448
  };
449
449
 
450
+
451
+
450
452
  // Utility methods for aotest framework :
451
- window.aotestMethods.getScenariiInTest=function(test, filterByScenariiNames=null){
453
+
454
+ window.aotestMethods.getParentTestByScenarioName=function(scenarioName){
455
+ return foreach(this.getTests(),test=>{
456
+ return window.aotestMethods.iterateOverScenariiInTest(test, (parentTest, scenario)=>{
457
+ if(scenario.name===scenarioName)
458
+ return parentTest;
459
+ });
460
+ });
461
+ }
462
+
463
+
464
+ window.aotestMethods.getScenarioByName=function(allTests, scenarioName){
465
+ const result=window.aotestMethods.iterateOverScenarii(allTests, null, null, null, scenario=>scenario.name===scenarioName);
466
+ if(result) return result;
467
+ return null;
468
+ }
469
+
470
+ window.aotestMethods.getScenariiByName=function(allTests, scenariiNames){
471
+ const results=[];
472
+ window.aotestMethods.iterateOverScenarii(allTests, (scenario, test)=>{
473
+ results.push(scenario);
474
+ }, null, null, scenario=>contains(scenariiNames,scenario.name));
475
+ return results;
476
+ }
477
+
478
+
479
+ window.aotestMethods.getScenarioInTest=function(test, scenarioName=null){
480
+ if(!scenarioName) return null;
481
+ return window.aotestMethods.iterateOverScenariiInTest(test,(t,s,sName)=>{
482
+ if(sName===scenarioName){
483
+ return s;
484
+ }
485
+ });
486
+ };
487
+
488
+ window.aotestMethods.getScenariiInTest=function(test, scenariiNames=null){
452
489
  let results={};
453
490
  window.aotestMethods.iterateOverScenariiInTest(test,(t,s,sName)=>{
454
- if(!filterByScenariiNames || contains(filterByScenariiNames, sName)){
491
+ if(!scenariiNames || contains(scenariiNames, sName)){
455
492
  results[sName]=s;
456
493
  }
457
494
  });
458
495
  return results;
459
496
  };
460
497
 
498
+ window.aotestMethods.getNumberOfScenariiInGlobal=function(allTestsBagForClientReadOnly, testsType){
499
+ let currentScenariiNumber=0;
500
+ window.aotestMethods.iterateOverScenarii(allTestsBagForClientReadOnly, (scenario)=>{
501
+ currentScenariiNumber++;
502
+ }, testsType);
503
+ return currentScenariiNumber;
504
+ }
505
+
506
+
461
507
  window.aotestMethods.iterateOverScenariiInTest=function(test, doOnEachIteration=null){
462
508
  if(!doOnEachIteration) return;
463
509
  return foreach(test,(scenario,scenarioName)=>{
@@ -466,7 +512,28 @@ window.aotestMethods.iterateOverScenariiInTest=function(test, doOnEachIteration=
466
512
  },(scenario,scenarioName)=>{ return window.aotestMethods.isScenarioName(scenarioName); });
467
513
  };
468
514
 
469
- /*private*/window.aotestMethods.doForAllTestsByType=function(allTestsByType, doOnIteration, filter=null, mustTerminate=null){
515
+
516
+ /*public*/window.aotestMethods.iterateOverScenarii=function(allTests, doOnIteration, testsType=null, filterFunction=null, mustTerminateFunction=null){
517
+
518
+ if(testsType){
519
+ if(testsType==="*"){
520
+ return foreach(allTests,(allTestsByType,t)=>{
521
+ const loopResult=window.aotestMethods.doForAllTestsByType(allTestsByType, doOnIteration, filterFunction, mustTerminateFunction);
522
+ if(loopResult)
523
+ return loopResult;
524
+ });
525
+ }
526
+
527
+ const allTestsByType=allTests[testsType];
528
+ return window.aotestMethods.doForAllTestsByType(allTestsByType, doOnIteration, filterFunction, mustTerminateFunction);
529
+ }
530
+
531
+ const allTestsByType=allTests;
532
+ return window.aotestMethods.doForAllTestsByType(allTestsByType, doOnIteration, filterFunction, mustTerminateFunction);
533
+ };
534
+
535
+
536
+ /*private*/window.aotestMethods.doForAllTestsByType=function(allTestsByType, doOnIteration, filterFunction=null, mustTerminateFunction=null){
470
537
 
471
538
  const loopResultI=foreach(allTestsByType,(testsByFunction,methodName)=>{
472
539
  const loopResultJ=foreach(testsByFunction,(test,executionCoupleName)=>{ // (execution couple IS test)
@@ -475,10 +542,10 @@ window.aotestMethods.iterateOverScenariiInTest=function(test, doOnEachIteration=
475
542
  const loopResultK=foreach(scenarii,(scenario, scenarioName)=>{
476
543
 
477
544
  if(doOnIteration) doOnIteration(scenario, test);
478
- if(mustTerminate && mustTerminate(scenario))
545
+ if(mustTerminateFunction && mustTerminateFunction(scenario))
479
546
  return scenario;
480
547
 
481
- },(scenario, scenarioName)=>!filter || filter(scenario));
548
+ },(scenario, scenarioName)=>!filterFunction || filterFunction(scenario));
482
549
 
483
550
  if(loopResultK)
484
551
  return loopResultK;
@@ -493,24 +560,7 @@ window.aotestMethods.iterateOverScenariiInTest=function(test, doOnEachIteration=
493
560
  return loopResultI;
494
561
  }
495
562
 
496
- /*public*/window.aotestMethods.iterateOverScenarii=function(allTests, doOnIteration, testsType=null, filter=null, mustTerminate=null){
497
-
498
- if(testsType){
499
- if(testsType==="*"){
500
- return foreach(allTests,(allTestsByType,t)=>{
501
- const loopResult=window.aotestMethods.doForAllTestsByType(allTestsByType, doOnIteration, filter, mustTerminate);
502
- if(loopResult)
503
- return loopResult;
504
- });
505
- }
506
-
507
- const allTestsByType=allTests[testsType];
508
- return window.aotestMethods.doForAllTestsByType(allTestsByType, doOnIteration, filter, mustTerminate);
509
- }
510
563
 
511
- const allTestsByType=allTests;
512
- return window.aotestMethods.doForAllTestsByType(allTestsByType, doOnIteration, filter, mustTerminate);
513
- };
514
564
 
515
565
  /*public*/window.aotestMethods.iterateOverValuesOnClonedObject=function(scenarioParam, doOnIterationForValue, visited=[], valuePath="", isValueFunction=null){
516
566
 
@@ -555,9 +605,6 @@ window.aotestMethods.iterateOverScenariiInTest=function(test, doOnEachIteration=
555
605
 
556
606
 
557
607
 
558
-
559
-
560
-
561
608
  window.aotestMethods.isScenarioName=function(scenarioName){
562
609
  return contains(scenarioName,"_scenario");
563
610
  };
@@ -4895,7 +4942,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4895
4942
 
4896
4943
 
4897
4944
 
4898
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (11/05/2025-17:25:45)»*/
4945
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (12/05/2025-16:11:18)»*/
4899
4946
  /*-----------------------------------------------------------------------------*/
4900
4947
  /* ## Utility global methods in a browser (htmljs) client environment.
4901
4948
  *
@@ -13497,7 +13544,7 @@ getAORTACClient=function(clientId=getUUID(), serverNodeOrigin="ws://127.0.0.1:40
13497
13544
 
13498
13545
 
13499
13546
 
13500
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (11/05/2025-17:25:45)»*/
13547
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (12/05/2025-16:11:18)»*/
13501
13548
  /*-----------------------------------------------------------------------------*/
13502
13549
 
13503
13550
 
@@ -14736,7 +14783,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14736
14783
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14737
14784
 
14738
14785
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14739
- /*utils AI library associated with aotra version : «1_29072022-2359 (11/05/2025-17:25:45)»*/
14786
+ /*utils AI library associated with aotra version : «1_29072022-2359 (12/05/2025-16:11:18)»*/
14740
14787
  /*-----------------------------------------------------------------------------*/
14741
14788
 
14742
14789
 
@@ -14882,7 +14929,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
14882
14929
 
14883
14930
 
14884
14931
 
14885
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (11/05/2025-17:25:45)»*/
14932
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (12/05/2025-16:11:18)»*/
14886
14933
  /*-----------------------------------------------------------------------------*/
14887
14934
 
14888
14935
 
@@ -15932,7 +15979,7 @@ performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, requestBo
15932
15979
  // DBG
15933
15980
  lognow("unformatted API URL : "+completeURL);
15934
15981
 
15935
- completeURL=appendGetParameters(completeURL, isString(requestBodyOrNamedArgs)?parseJSON(requestBodyOrNamedArgs):requestBodyOrNamedArgs);
15982
+ completeURL=appendGetParameters(completeURL, requestBodyOrNamedArgs);
15936
15983
 
15937
15984
  // DBG
15938
15985
  lognow("formatted API URL : "+completeURL);
@@ -16092,15 +16139,25 @@ replacePathVariablesNamesWithValuesIfPossible=function(apiURL, namedArgs){
16092
16139
  return result;
16093
16140
  };
16094
16141
 
16095
- appendGetParameters=function(apiURL, namedArgs){
16096
- let result=apiURL;
16097
-
16098
- const paramCouples=[];
16099
- foreach(namedArgs,(value,key)=>{paramCouples.push(key+"="+value);});
16100
-
16101
- if(!empty(paramCouples)) result+=("?"+paramCouples.join("&"));
16102
-
16103
- return result;
16142
+ appendGetParameters=function(apiURL, namedArgsParam){
16143
+ if(nothing(namedArgsParam)) return "";
16144
+ try{
16145
+
16146
+ const namedArgs=isString(namedArgsParam)?parseJSON(namedArgsParam):namedArgsParam;
16147
+
16148
+ let result=apiURL;
16149
+
16150
+ const paramCouples=[];
16151
+ foreach(namedArgs,(value,key)=>{paramCouples.push(key+"="+value);});
16152
+
16153
+ if(!empty(paramCouples)) result+=("?"+paramCouples.join("&"));
16154
+
16155
+ return result;
16156
+ }catch(parseError){
16157
+ // TRACE
16158
+ lognow("ERROR : Could not parse string parameters object «"+namedArgsParam+"», aborting GET parameter request string calculation:", parseError);
16159
+ return "";
16160
+ }
16104
16161
  };
16105
16162
 
16106
16163
 
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.1592",
3
+ "version": "0.0.1593",
4
4
  "main": "aotrautils.build.js",
5
5
  "description": "A library for vanilla javascript utils (client-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",