aotrautils 0.0.1584 → 0.0.1586

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:44)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (11/05/2025-14:10:29)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4895,7 +4895,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4895
4895
 
4896
4896
 
4897
4897
 
4898
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (11/05/2025-01:36:44)»*/
4898
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (11/05/2025-14:10:29)»*/
4899
4899
  /*-----------------------------------------------------------------------------*/
4900
4900
  /* ## Utility global methods in a browser (htmljs) client environment.
4901
4901
  *
@@ -13497,7 +13497,7 @@ getAORTACClient=function(clientId=getUUID(), serverNodeOrigin="ws://127.0.0.1:40
13497
13497
 
13498
13498
 
13499
13499
 
13500
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (11/05/2025-01:36:44)»*/
13500
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (11/05/2025-14:10:29)»*/
13501
13501
  /*-----------------------------------------------------------------------------*/
13502
13502
 
13503
13503
 
@@ -14736,7 +14736,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14736
14736
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14737
14737
 
14738
14738
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14739
- /*utils AI library associated with aotra version : «1_29072022-2359 (11/05/2025-01:36:44)»*/
14739
+ /*utils AI library associated with aotra version : «1_29072022-2359 (11/05/2025-14:10:29)»*/
14740
14740
  /*-----------------------------------------------------------------------------*/
14741
14741
 
14742
14742
 
@@ -14882,7 +14882,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
14882
14882
 
14883
14883
 
14884
14884
 
14885
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (11/05/2025-01:36:44)»*/
14885
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (11/05/2025-14:10:29)»*/
14886
14886
  /*-----------------------------------------------------------------------------*/
14887
14887
 
14888
14888
 
@@ -15893,7 +15893,7 @@ getListManager=function(config){
15893
15893
  // NO : IN A NODE CONTEXT WITH require("...") WILL RESULT IN AN UNDEFINED FUNCTION ERROR !!!
15894
15894
  // function performHTTPRequest(...){...
15895
15895
  // USE THIS INSTEAD :
15896
- performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyOrNamedArgs=null,isNodeContext=false,addCORSHeader=ADD_CORS_HEADER){
15896
+ performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, requestBodyOrNamedArgs=null, isNodeContext=false, addCORSHeader=ADD_CORS_HEADER, forceStringifyBody=true){
15897
15897
 
15898
15898
  // Body
15899
15899
  let requestBodyOrNamedArgsStr=null;
@@ -15908,18 +15908,24 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
15908
15908
  requestBodyOrNamedArgsStr=""+requestBodyOrNamedArgs;
15909
15909
  }
15910
15910
  }
15911
+
15911
15912
  let body=null;
15912
15913
  // Not the same way to send parameters, with POST/PUT http method :
15913
15914
  if(contains(["POST","PUT"],httpMethod) && requestBodyOrNamedArgs){
15914
- // CAUTION : IF POST/PUT METHOD THEN WE MUST NOT PASS A STRING, BUT A PLAIN OBJECT ! ELSE IT WILL CAUSE STRANGE BUGS !!!
15915
- body=requestBodyOrNamedArgsStr;
15915
+ if(forceStringifyBody){
15916
+ body=requestBodyOrNamedArgsStr;
15917
+ }else{
15918
+ body=requestBodyOrNamedArgs;
15919
+ }
15916
15920
  }
15917
15921
 
15918
15922
  // Headers
15919
15923
  if(contains(["POST","PUT"],httpMethod)){
15920
15924
  headers["Content-Type"]="application/json";
15921
- if(requestBodyOrNamedArgsStr)
15925
+
15926
+ if(requestBodyOrNamedArgsStr && forceStringifyBody){
15922
15927
  headers["Content-Length"]=Buffer.byteLength(requestBodyOrNamedArgsStr);
15928
+ }
15923
15929
 
15924
15930
  // 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)
15925
15931
  if(addCORSHeader) headers["Access-Control-Allow-Origin"]="*";
@@ -15940,7 +15946,6 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
15940
15946
  // TRACE
15941
15947
  lognow("INFO : We are not running in a browser context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using browser library.");
15942
15948
 
15943
-
15944
15949
  return new Promise((resolve,reject)=>{
15945
15950
  fetch(completeURL, {
15946
15951
  method: httpMethod,
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.1584",
3
+ "version": "0.0.1586",
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)",