aotrautils-srv 0.0.1405 → 0.0.1406

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 (19/04/2025-21:27:31)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (19/04/2025-22:05:35)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4846,7 +4846,7 @@ window.parseJSON=function(strParam){
4846
4846
  }
4847
4847
 
4848
4848
  }
4849
- return null;
4849
+ throw new Error("ERROR : Error parsing string «" + strParam + "» as JSON. No parsing failback managed to parse it !");
4850
4850
  }
4851
4851
 
4852
4852
  window.stringifyObject=function(objectToStringify){
@@ -4894,7 +4894,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4894
4894
 
4895
4895
 
4896
4896
 
4897
- /*utils AI library associated with aotra version : «1_29072022-2359 (19/04/2025-21:27:31)»*/
4897
+ /*utils AI library associated with aotra version : «1_29072022-2359 (19/04/2025-22:05:35)»*/
4898
4898
  /*-----------------------------------------------------------------------------*/
4899
4899
 
4900
4900
 
@@ -5040,7 +5040,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
5040
5040
 
5041
5041
 
5042
5042
 
5043
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (19/04/2025-21:27:31)»*/
5043
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (19/04/2025-22:05:35)»*/
5044
5044
  /*-----------------------------------------------------------------------------*/
5045
5045
 
5046
5046
 
@@ -6775,11 +6775,22 @@ getListManager=function(config){
6775
6775
  // function performHTTPRequest(...){...
6776
6776
  // USE THIS INSTEAD :
6777
6777
  performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyOrNamedArgs=null,isNodeContext=false,addCORSHeader=ADD_CORS_HEADER){
6778
+
6779
+ let requestBodyOrNamedArgsStr;
6780
+ try{
6781
+ requestBodyOrNamedArgsStr=stringifyObject(requestBodyOrNamedArgs);
6782
+ }catch(parseErr){
6783
+ requestBodyOrNamedArgsStr=""+requestBodyOrNamedArgs;
6784
+ }
6785
+
6778
6786
 
6779
6787
  if(contains(["POST","PUT"],httpMethod)){
6780
6788
  headers["Content-Type"]="application/json";
6789
+ headers["Content-Length"]=Buffer.byteLength(requestBodyOrNamedArgsStr);
6790
+
6781
6791
  // To remove the CORS error message (cf. https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9)
6782
6792
  if(addCORSHeader) headers["Access-Control-Allow-Origin"]="*";
6793
+
6783
6794
  } else if(httpMethod==="GET" && requestBodyOrNamedArgs){
6784
6795
  // Not the same way to send parameters in GET http method :
6785
6796
  // DBG
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.1405",
3
+ "version": "0.0.1406",
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)",