aotrautils 0.0.2041 → 0.0.2042

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 (13/10/2026-01:52:42)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:11)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5485,7 +5485,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
5485
5485
 
5486
5486
 
5487
5487
 
5488
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (13/10/2026-01:52:42)»*/
5488
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:11)»*/
5489
5489
  /*-----------------------------------------------------------------------------*/
5490
5490
  /* ## Utility global methods in a browser (htmljs) client environment.
5491
5491
  *
@@ -5580,6 +5580,18 @@ window.getRequestURLParameters=(request)=>{
5580
5580
  return parameters;
5581
5581
  };
5582
5582
 
5583
+ window.getRequestHeaders=(request)=>{
5584
+ const results={};
5585
+ const visited=new Set();
5586
+ for(let i=0; i<request.rawHeaders.length; i+=2){ // Because req.rawHeaders isn’t an array of pairs. It’s a single flat list where names and values alternate !
5587
+ const headerName=request.rawHeaders[i].toLowerCase();
5588
+ if(visited.has(headerName)) continue;
5589
+ if(headerName in results) continue;
5590
+ visited.add(headerName);
5591
+ results[headerName]=request.rawHeaders[i+1];
5592
+ }
5593
+ return results;
5594
+ }
5583
5595
 
5584
5596
  window.getRequestBody=async function(request, maxSize = 1_000_000){
5585
5597
  const chunks=[];
@@ -13041,7 +13053,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
13041
13053
 
13042
13054
 
13043
13055
 
13044
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (13/10/2026-01:52:42)»*/
13056
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:11)»*/
13045
13057
  /*-----------------------------------------------------------------------------*/
13046
13058
 
13047
13059
 
@@ -14130,10 +14142,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
14130
14142
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14131
14143
 
14132
14144
  window.AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14133
- /*utils 3D library associated with aotra version : «1_29072022-2359 (13/10/2026-01:52:42)»*/
14145
+ /*utils 3D library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:11)»*/
14134
14146
  /*-----------------------------------------------------------------------------*/
14135
14147
 
14136
- /*utils AI library associated with aotra version : «1_29072022-2359 (13/10/2026-01:52:42)»*/
14148
+ /*utils AI library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:11)»*/
14137
14149
  /*-----------------------------------------------------------------------------*/
14138
14150
 
14139
14151
 
@@ -14397,7 +14409,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
14397
14409
 
14398
14410
 
14399
14411
 
14400
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (13/10/2026-01:52:42)»*/
14412
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (15/10/2026-21:45:11)»*/
14401
14413
  /*-----------------------------------------------------------------------------*/
14402
14414
 
14403
14415
 
@@ -17234,19 +17246,33 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
17234
17246
  if( requestHttpMethod=="GET" &&
17235
17247
  (!httpEndpoint.httpMethod || empty(httpEndpoint.httpMethod) || httpEndpoint.httpMethod.toUpperCase()=="GET")){
17236
17248
 
17237
- messageIn={...getRequestURLParameters(request)};
17249
+ messageIn={...getRequestURLParameters(request), ...getRequestHeaders(request)};
17238
17250
 
17239
17251
  }else if(requestHttpMethod=="POST"
17240
17252
  && contains(["POST","PUT","PATCH","DELETE"],httpEndpoint.httpMethod.toUpperCase())){
17241
17253
 
17242
- messageIn={...getRequestURLParameters(request), ...(await getRequestBody(request))};
17254
+ messageIn={...getRequestURLParameters(request), ...getRequestHeaders(request), ...(await getRequestBody(request))};
17243
17255
  }
17244
17256
 
17245
17257
  if(messageIn){
17246
17258
  let httpEndpointResultObject={httpStatus:200, body:{}};
17247
17259
  const serverReceptionEntryPoint=httpEndpoint.serverReceptionEntryPoint;
17248
17260
  if(serverReceptionEntryPoint){
17249
- httpEndpointResultObject.body=serverReceptionEntryPoint.execute(messageIn, null, false);
17261
+ const dataWrapped={data:messageIn};
17262
+ const eventOrMessage={data:dataWrapped};
17263
+
17264
+ // (we bypass the channel and message types filters !)
17265
+ try{
17266
+ httpEndpointResultObject.body=await serverReceptionEntryPoint.execute(eventOrMessage, null, false);
17267
+ }catch(treatmentsChannelError){
17268
+ // TODO : FIXME : DUPLICATED CODE !!!
17269
+ const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
17270
+ // TRACE
17271
+ lognow(errorMessage, treatmentsChannelError);
17272
+ const errorDataWrapped={errorMessage:errorMessage, cause:{message:treatmentsChannelError.message}};
17273
+ httpEndpointResultObject.body=errorDataWrapped;
17274
+ httpEndpointResultObject.httpStatus=500;
17275
+ }
17250
17276
  }
17251
17277
 
17252
17278
  response.writeHead(httpEndpointResultObject.httpStatus, { "Content-Type": "application/json" });
@@ -17929,6 +17955,17 @@ window.isURLLocalhost=(url)=>{
17929
17955
 
17930
17956
 
17931
17957
 
17958
+ window.assert={};
17959
+ window.assert.notNull=(value, errorMessage=null)=>{
17960
+ if(typeof(value)=="undefined" || value==null)
17961
+ throw new Error(nonull(errorMessage, "ERROR : Value is null."));
17962
+ };
17963
+
17964
+
17965
+
17966
+
17967
+
17968
+
17932
17969
  /* ## Utility network global methods in a javascript, console (nodejs), or vanilla javascript with no browser environment.
17933
17970
  *
17934
17971
  * This set of methods gathers utility generic-purpose methods usable in any JS project.
@@ -18416,25 +18453,25 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18416
18453
  foreach(this.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
18417
18454
 
18418
18455
  // All listeners are executed IN PARALLEL !
18419
- const p=serverReceptionEntryPoint.execute(eventOrMessageParam, clientSocket);
18420
- p.then((message)=>{
18456
+ serverReceptionEntryPoint.execute(eventOrMessageParam, clientSocket).then((message)=>{
18421
18457
  /*DO NOTHING*/
18422
18458
  }).catch(treatmentsChannelError=>{
18459
+ // TODO : FIXME : DUPLICATED CODE !!!
18423
18460
  const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
18424
-
18425
18461
  // TRACE
18426
18462
  lognow(errorMessage, treatmentsChannelError);
18427
-
18428
18463
  const errorDataWrapped={errorMessage:errorMessage, cause:treatmentsChannelError};
18429
- self.sendError(errorDataWrapped, clientSocketParam);
18430
-
18464
+ self.sendError(errorDataWrapped, clientSocket);
18431
18465
  });
18432
18466
 
18433
18467
  });
18434
18468
 
18435
18469
  }).catch(error=>{
18470
+ const errorMessage="ERROR : (.executeAllPrerequisites()) A prerequisite encountered an error :";
18436
18471
  // TRACE
18437
- lognow("ERROR : (.executeAllPrerequisites()) A prerequisite encountered an error :", error);
18472
+ lognow(errorMessage, error);
18473
+ const errorDataWrapped={errorMessage:errorMessage, cause:error};
18474
+ self.sendError(errorDataWrapped, clientSocket);
18438
18475
  });
18439
18476
 
18440
18477
  }
@@ -18470,7 +18507,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18470
18507
  const clientsRoomsTag=this.clientsRoomsTag;
18471
18508
  const messageTypes=(!messageType || empty(messageType) ? [] :
18472
18509
  (isArray(messageType) ? messageType : [messageType])
18473
- );
18510
+ );
18474
18511
  const listenerConfig={listenerMessageTypes:messageTypes, httpEndpointDefinition:httpEndpointDefinition};
18475
18512
  const serverReceptionEntryPoint=
18476
18513
  new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
@@ -18480,6 +18517,7 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18480
18517
  // TRACE
18481
18518
  lognow("INFO : Registered HTTP listener:",httpEndpointDefinition);
18482
18519
 
18520
+ httpEndpointDefinition.serverReceptionEntryPoint=serverReceptionEntryPoint;
18483
18521
  this.server.httpEndpoints.push(httpEndpointDefinition);
18484
18522
  }
18485
18523
 
@@ -18541,7 +18579,11 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
18541
18579
  const dataRestored=restoreClassesInformation(dataLocal);
18542
18580
 
18543
18581
  // CAUTION : This method can be ASYNC or NOT ASYNC !!!
18544
- this.asyncDoOnIncomingMessage(dataRestored, clientSocketParam);
18582
+ // DBG
18583
+ if(isAsyncFunction(this.asyncDoOnIncomingMessage))
18584
+ return await this.asyncDoOnIncomingMessage(dataRestored, clientSocketParam);
18585
+ return this.asyncDoOnIncomingMessage(dataRestored, clientSocketParam);
18586
+
18545
18587
  }
18546
18588
 
18547
18589
  }
@@ -18638,8 +18680,9 @@ window.NodeServerInstance=class NodeServerInstance{
18638
18680
  // Channel information is stored in exchanged data :
18639
18681
  let dataWrapped=saveClassesInformation({channelName:channelName, data:data});
18640
18682
 
18641
-
18642
- if(!clientSocketParam){
18683
+ if(!clientSocketParam) return dataWrapped;
18684
+
18685
+ if(isString(clientSocketParam) && clientSocketParam=="*"){
18643
18686
 
18644
18687
  // DBG
18645
18688
  lognow("(SERVER) (server sends to all clients)");
@@ -18761,7 +18804,15 @@ window.NodeServerInstance=class NodeServerInstance{
18761
18804
  foreach(self.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
18762
18805
  serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true).then(()=>{
18763
18806
  /*DO NOTHING*/
18807
+ }).catch(treatmentsChannelError=>{
18808
+ // TODO : FIXME : DUPLICATED CODE !!!
18809
+ const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
18810
+ // TRACE
18811
+ lognow(errorMessage, treatmentsChannelError);
18812
+ const errorDataWrapped={errorMessage:errorMessage, cause:treatmentsChannelError};
18813
+ self.sendError(errorDataWrapped, clientSocket);
18764
18814
  });
18815
+
18765
18816
  });
18766
18817
 
18767
18818
  // NEW API :
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.2041",
3
+ "version": "0.0.2042",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aotrautils",
9
- "version": "0.0.2041",
9
+ "version": "0.0.2042",
10
10
  "license": "HGPL-1.0",
11
11
  "dependencies": {
12
12
  "atob": "^2.1.2",
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.2041",
3
+ "version": "0.0.2042",
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)",