aotrautils-srv 0.0.1584 → 0.0.1585

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-01:36:48)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (11/05/2025-14:04:02)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4895,7 +4895,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4895
4895
 
4896
4896
 
4897
4897
 
4898
- /*utils AI library associated with aotra version : «1_29072022-2359 (11/05/2025-01:36:48)»*/
4898
+ /*utils AI library associated with aotra version : «1_29072022-2359 (11/05/2025-14:04:02)»*/
4899
4899
  /*-----------------------------------------------------------------------------*/
4900
4900
 
4901
4901
 
@@ -5041,7 +5041,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
5041
5041
 
5042
5042
 
5043
5043
 
5044
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (11/05/2025-01:36:48)»*/
5044
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (11/05/2025-14:04:02)»*/
5045
5045
  /*-----------------------------------------------------------------------------*/
5046
5046
 
5047
5047
 
@@ -6052,7 +6052,7 @@ getListManager=function(config){
6052
6052
  // NO : IN A NODE CONTEXT WITH require("...") WILL RESULT IN AN UNDEFINED FUNCTION ERROR !!!
6053
6053
  // function performHTTPRequest(...){...
6054
6054
  // USE THIS INSTEAD :
6055
- performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyOrNamedArgs=null,isNodeContext=false,addCORSHeader=ADD_CORS_HEADER){
6055
+ performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, requestBodyOrNamedArgs=null, isNodeContext=false, addCORSHeader=ADD_CORS_HEADER, forceStringifyBody=true){
6056
6056
 
6057
6057
  // Body
6058
6058
  let requestBodyOrNamedArgsStr=null;
@@ -6067,9 +6067,10 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
6067
6067
  requestBodyOrNamedArgsStr=""+requestBodyOrNamedArgs;
6068
6068
  }
6069
6069
  }
6070
+
6070
6071
  let body=null;
6071
6072
  // Not the same way to send parameters, with POST/PUT http method :
6072
- if(contains(["POST","PUT"],httpMethod) && requestBodyOrNamedArgs){
6073
+ if(contains(["POST","PUT"],httpMethod) && requestBodyOrNamedArgs && forceStringifyBody){
6073
6074
  // CAUTION : IF POST/PUT METHOD THEN WE MUST NOT PASS A STRING, BUT A PLAIN OBJECT ! ELSE IT WILL CAUSE STRANGE BUGS !!!
6074
6075
  body=requestBodyOrNamedArgsStr;
6075
6076
  }
@@ -6077,8 +6078,10 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
6077
6078
  // Headers
6078
6079
  if(contains(["POST","PUT"],httpMethod)){
6079
6080
  headers["Content-Type"]="application/json";
6080
- if(requestBodyOrNamedArgsStr)
6081
+
6082
+ if(requestBodyOrNamedArgsStr && forceStringifyBody){
6081
6083
  headers["Content-Length"]=Buffer.byteLength(requestBodyOrNamedArgsStr);
6084
+ }
6082
6085
 
6083
6086
  // 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)
6084
6087
  if(addCORSHeader) headers["Access-Control-Allow-Origin"]="*";
@@ -6099,7 +6102,6 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
6099
6102
  // TRACE
6100
6103
  lognow("INFO : We are not running in a browser context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using browser library.");
6101
6104
 
6102
-
6103
6105
  return new Promise((resolve,reject)=>{
6104
6106
  fetch(completeURL, {
6105
6107
  method: httpMethod,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.1584",
3
+ "version": "0.0.1585",
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)",