aotrautils-srv 0.0.1575 → 0.0.1576
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-
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (11/05/2025-01:11:54)»*/
|
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-
|
4898
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (11/05/2025-01:11:54)»*/
|
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-
|
5044
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (11/05/2025-01:11:54)»*/
|
5045
5045
|
/*-----------------------------------------------------------------------------*/
|
5046
5046
|
|
5047
5047
|
|
@@ -6054,6 +6054,7 @@ getListManager=function(config){
|
|
6054
6054
|
// USE THIS INSTEAD :
|
6055
6055
|
performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyOrNamedArgs=null,isNodeContext=false,addCORSHeader=ADD_CORS_HEADER){
|
6056
6056
|
|
6057
|
+
// Body
|
6057
6058
|
let requestBodyOrNamedArgsStr=null;
|
6058
6059
|
if(requestBodyOrNamedArgs){
|
6059
6060
|
try{
|
@@ -6064,7 +6065,14 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
|
|
6064
6065
|
requestBodyOrNamedArgsStr=""+requestBodyOrNamedArgs;
|
6065
6066
|
}
|
6066
6067
|
}
|
6067
|
-
|
6068
|
+
let body=null;
|
6069
|
+
// Not the same way to send parameters, with POST/PUT http method :
|
6070
|
+
if(contains(["POST","PUT"],httpMethod) && requestBodyOrNamedArgs){
|
6071
|
+
// CAUTION : IF POST/PUT METHOD THEN WE MUST NOT PASS A STRING, BUT A PLAIN OBJECT ! ELSE IT WILL CAUSE STRANGE BUGS !!!
|
6072
|
+
body=requestBodyOrNamedArgs;
|
6073
|
+
}
|
6074
|
+
|
6075
|
+
// Headers
|
6068
6076
|
if(contains(["POST","PUT"],httpMethod)){
|
6069
6077
|
headers["Content-Type"]="application/json";
|
6070
6078
|
if(requestBodyOrNamedArgsStr)
|
@@ -6083,13 +6091,13 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
|
|
6083
6091
|
// DBG
|
6084
6092
|
lognow("formatted API URL : "+completeURL);
|
6085
6093
|
}
|
6086
|
-
|
6094
|
+
|
6087
6095
|
// CASE BROWSER CONTEXT :
|
6088
6096
|
if(!isNodeContext || typeof(require)=="undefined"){
|
6089
6097
|
// TRACE
|
6090
6098
|
lognow("INFO : We are not running in a browser context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using browser library.");
|
6091
6099
|
|
6092
|
-
|
6100
|
+
|
6093
6101
|
return new Promise((resolve,reject)=>{
|
6094
6102
|
fetch(completeURL, {
|
6095
6103
|
method: httpMethod,
|
@@ -6164,12 +6172,9 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
|
|
6164
6172
|
// A chunk of data has been received.
|
6165
6173
|
response.on("data", (chunk) => {
|
6166
6174
|
responseDataStr += chunk;
|
6167
|
-
|
6168
|
-
//
|
6169
|
-
|
6170
|
-
lognow(">>>str:"+str);
|
6171
|
-
|
6172
|
-
|
6175
|
+
// // DEBUG ONLY
|
6176
|
+
// const str = Buffer.from(chunk).toString("utf8");
|
6177
|
+
// lognow(">>>str:"+str);
|
6173
6178
|
});
|
6174
6179
|
|
6175
6180
|
// The whole response has been received.
|
@@ -6219,12 +6224,9 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
|
|
6219
6224
|
reject({error:error, httpStatus:null});
|
6220
6225
|
});
|
6221
6226
|
|
6222
|
-
|
6223
|
-
|
6224
|
-
|
6225
|
-
// (We need to stringify parameters or else we'll have an error :)
|
6226
|
-
if(requestBodyOrNamedArgs)
|
6227
|
-
request.write(requestBodyOrNamedArgsStr);
|
6227
|
+
// Not the same way to send parameters, with POST/PUT http method :
|
6228
|
+
if(contains(["POST","PUT"],httpMethod) && body){
|
6229
|
+
request.write(body);
|
6228
6230
|
}
|
6229
6231
|
|
6230
6232
|
// End the request
|
aotrautils-srv/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "aotrautils-srv",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.1576",
|
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)",
|