aotrautils-srv 0.0.1592 → 0.0.1594
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 (12/05/2025-16:24:44)»*/
|
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
|
-
|
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(!
|
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
|
-
|
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(
|
545
|
+
if(mustTerminateFunction && mustTerminateFunction(scenario))
|
479
546
|
return scenario;
|
480
547
|
|
481
|
-
},(scenario, scenarioName)=>!
|
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 AI library associated with aotra version : «1_29072022-2359 (
|
4945
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (12/05/2025-16:24:44)»*/
|
4899
4946
|
/*-----------------------------------------------------------------------------*/
|
4900
4947
|
|
4901
4948
|
|
@@ -5041,7 +5088,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
|
|
5041
5088
|
|
5042
5089
|
|
5043
5090
|
|
5044
|
-
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (
|
5091
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (12/05/2025-16:24:44)»*/
|
5045
5092
|
/*-----------------------------------------------------------------------------*/
|
5046
5093
|
|
5047
5094
|
|
@@ -6091,7 +6138,7 @@ performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, requestBo
|
|
6091
6138
|
// DBG
|
6092
6139
|
lognow("unformatted API URL : "+completeURL);
|
6093
6140
|
|
6094
|
-
completeURL=appendGetParameters(completeURL,
|
6141
|
+
completeURL=appendGetParameters(completeURL, requestBodyOrNamedArgs);
|
6095
6142
|
|
6096
6143
|
// DBG
|
6097
6144
|
lognow("formatted API URL : "+completeURL);
|
@@ -6251,15 +6298,25 @@ replacePathVariablesNamesWithValuesIfPossible=function(apiURL, namedArgs){
|
|
6251
6298
|
return result;
|
6252
6299
|
};
|
6253
6300
|
|
6254
|
-
appendGetParameters=function(apiURL,
|
6255
|
-
|
6256
|
-
|
6257
|
-
|
6258
|
-
|
6259
|
-
|
6260
|
-
|
6261
|
-
|
6262
|
-
|
6301
|
+
appendGetParameters=function(apiURL, namedArgsParam){
|
6302
|
+
if(nothing(namedArgsParam)) return "";
|
6303
|
+
try{
|
6304
|
+
|
6305
|
+
const namedArgs=isString(namedArgsParam)?parseJSON(namedArgsParam):namedArgsParam;
|
6306
|
+
|
6307
|
+
let result=apiURL;
|
6308
|
+
|
6309
|
+
const paramCouples=[];
|
6310
|
+
foreach(namedArgs,(value,key)=>{paramCouples.push(key+"="+value);});
|
6311
|
+
|
6312
|
+
if(!empty(paramCouples)) result+=("?"+paramCouples.join("&"));
|
6313
|
+
|
6314
|
+
return result;
|
6315
|
+
}catch(parseError){
|
6316
|
+
// TRACE
|
6317
|
+
lognow("ERROR : Could not parse string parameters object «"+namedArgsParam+"», aborting GET parameter request string calculation:", parseError);
|
6318
|
+
return "";
|
6319
|
+
}
|
6263
6320
|
};
|
6264
6321
|
|
6265
6322
|
|
aotrautils-srv/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "aotrautils-srv",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.1594",
|
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)",
|