node-red-contrib-prib-functions 0.19.2 → 0.21.0
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.
- package/.github/workflows/codeql-analysis.yml +3 -3
- package/.github/workflows/npmpublish.yml +6 -6
- package/.vs/VSWorkspaceState.json +7 -0
- package/.vs/node-red-contrib-prib-functions/v17/.wsuo +0 -0
- package/README.md +84 -70
- package/dataAnalysis/arrayAllRowsSwap.js +15 -0
- package/dataAnalysis/arrayCompareToPrecision.js +34 -0
- package/dataAnalysis/arrayDifference.js +14 -0
- package/dataAnalysis/arrayDifferenceSeasonal.js +15 -0
- package/dataAnalysis/arrayDifferenceSeasonalSecondOrder.js +20 -0
- package/dataAnalysis/arrayDifferenceSecondOrder.js +14 -0
- package/dataAnalysis/arrayForEachRange.js +38 -0
- package/dataAnalysis/arrayOverlay.js +13 -0
- package/dataAnalysis/arrayProduct.js +11 -0
- package/dataAnalysis/arrayRandom.js +14 -0
- package/dataAnalysis/arrayReduceRange.js +11 -0
- package/dataAnalysis/arrayScale.js +11 -0
- package/dataAnalysis/arraySum.js +11 -0
- package/dataAnalysis/arraySumSquared.js +11 -0
- package/dataAnalysis/arraySwap.js +11 -0
- package/dataAnalysis/dataAnalysis.html +52 -21
- package/dataAnalysis/dataAnalysis.js +73 -44
- package/dataAnalysis/generateMatrixFunction.js +89 -0
- package/dataAnalysis/generateVectorFunction.js +25 -0
- package/dataAnalysis/pca.js +472 -325
- package/dataAnalysis/svd.js +239 -0
- package/documentation/DataAnalysisRealtime.JPG +0 -0
- package/documentation/monitorSystem.JPG +0 -0
- package/documentation/monitorSystemTest.JPG +0 -0
- package/echart/echart.html +68 -0
- package/echart/echart.js +85 -0
- package/echart/icons/chart-671.png +0 -0
- package/echart/lib/echarts.js +95886 -0
- package/lib/Chart.js +177 -0
- package/lib/Column.js +99 -0
- package/lib/GraphDB.js +14 -0
- package/lib/Table.js +185 -0
- package/lib/objectExtensions.js +361 -0
- package/matrix/matrix.js +95 -56
- package/matrix/matrixNode.html +88 -55
- package/matrix/matrixNode.js +12 -5
- package/monitor/BarGauge.js +8 -0
- package/monitor/Dataset.js +29 -0
- package/monitor/DialGauge.js +109 -0
- package/monitor/DialNeedle.js +36 -0
- package/monitor/Format.js +74 -0
- package/monitor/centerElement.js +14 -0
- package/monitor/compareElements.js +95 -0
- package/monitor/defs.js +23 -0
- package/monitor/extensions.js +906 -0
- package/monitor/functions.js +36 -0
- package/monitor/json2xml.js +103 -0
- package/monitor/monitorSystem.html +199 -0
- package/monitor/monitorSystem.js +322 -0
- package/monitor/svgHTML.js +179 -0
- package/monitor/svgObjects.js +64 -0
- package/package.json +20 -6
- package/test/00-objectExtensions.js +94 -0
- package/test/04-tables.js +33 -0
- package/test/data/.config.nodes.json +608 -0
- package/test/data/.config.nodes.json.backup +608 -0
- package/test/data/.config.runtime.json +4 -0
- package/test/data/.config.runtime.json.backup +3 -0
- package/test/data/.config.users.json +21 -0
- package/test/data/.config.users.json.backup +21 -0
- package/test/data/.flow.json.backup +2820 -2003
- package/test/data/float32vector10.npy +0 -0
- package/test/data/flow.json +2830 -2033
- package/test/data/int2matrix2x3.npy +0 -0
- package/test/data/package-lock.json +158 -0
- package/test/data/package.json +11 -0
- package/test/dataAnalysisExtensions.js +471 -0
- package/test/dataAnalysisPCA.js +54 -0
- package/test/dataAnalysisSVD.js +31 -0
- package/test/euclideanDistance.js +2 -2
- package/test/transformConfluence.js +1 -1
- package/test/transformNumPy.js +132 -0
- package/testing/test.html +1 -1
- package/testing/test.js +78 -53
- package/transform/NumPy.js +303 -0
- package/transform/transform.html +12 -0
- package/transform/transform.js +34 -2
package/transform/transform.html
CHANGED
|
@@ -57,6 +57,8 @@
|
|
|
57
57
|
{ value: "CSV", label: "CSV"},
|
|
58
58
|
{ value: "ISO8385", label: "ISO 8583"},
|
|
59
59
|
{ value: "JSON", label: "JSON"},
|
|
60
|
+
{ value: "npy", label: "npy"},
|
|
61
|
+
{ value: "NumPyObject", label: "NumPy Obect"},
|
|
60
62
|
{ value: "String", label: "String"},
|
|
61
63
|
{ value: "snappy", label: "Snappy"},
|
|
62
64
|
{ value: "path", label: "Path"},
|
|
@@ -137,11 +139,21 @@
|
|
|
137
139
|
options["HTML"]="HTML";
|
|
138
140
|
options["JSON"]="JSON";
|
|
139
141
|
options["Messages"]="Messages";
|
|
142
|
+
options["npy"]="npy";
|
|
143
|
+
options["NumPyObject"]="NumPy Object";
|
|
140
144
|
options["String"]="String";
|
|
141
145
|
options["XLSX"]="XLSX";
|
|
142
146
|
options["XLSXObject"]="XLSX Object";
|
|
143
147
|
options["XML"]="XML";
|
|
144
148
|
break;
|
|
149
|
+
case 'npy':
|
|
150
|
+
options["JSON"]="JSON";
|
|
151
|
+
options["NumPyObject"]="NumPy Object";
|
|
152
|
+
break;
|
|
153
|
+
case 'NumPyObject':
|
|
154
|
+
options["JSON"]="JSON";
|
|
155
|
+
break;
|
|
156
|
+
|
|
145
157
|
case 'path':
|
|
146
158
|
options["Basename"]="basename";
|
|
147
159
|
options["Dirname"]="dirname";
|
package/transform/transform.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const logger = new (require("node-red-contrib-logger"))("transform");
|
|
2
2
|
logger.sendInfo("Copyright 2020 Jaroslav Peter Prib");
|
|
3
3
|
const CompressionTool = require('compressiontool');
|
|
4
|
-
|
|
4
|
+
const NumPy = require("./NumPy.js")
|
|
5
5
|
const regexCSV=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/,
|
|
6
6
|
Buffer=require('buffer').Buffer,
|
|
7
7
|
os=require('os'),
|
|
@@ -332,6 +332,7 @@ const functions={
|
|
|
332
332
|
}
|
|
333
333
|
return data;
|
|
334
334
|
},
|
|
335
|
+
JSONToAVRO: (RED,node,msg,data)=>node.avroTransformer.toBuffer(data), // Encoded buffer.
|
|
335
336
|
JSONToCompressed: (RED,node,msg,data)=>compressor.compress(JSON.stringify(data),
|
|
336
337
|
(compressed)=>{
|
|
337
338
|
node.setData(RED,node,msg,compressed);
|
|
@@ -343,7 +344,6 @@ const functions={
|
|
|
343
344
|
),
|
|
344
345
|
JSONToConfluence:JSONToConfluence,
|
|
345
346
|
JSONToCSV: (RED,node,msg,data)=>Array2csv(node,data),
|
|
346
|
-
JSONToAVRO: (RED,node,msg,data)=>node.avroTransformer.toBuffer(data), // Encoded buffer.
|
|
347
347
|
JSONToHTML: (RED,node,msg,data,level=0)=>{
|
|
348
348
|
if(Array.isArray(data)) {
|
|
349
349
|
return data.length?"<table><tr>"+data.map((r)=>functions.JSONToHTML(RED,node,msg,r,++level)).join("</tr><tr>")+"</tr><table>":"";
|
|
@@ -375,10 +375,15 @@ const functions={
|
|
|
375
375
|
node.send(newMsg);
|
|
376
376
|
}
|
|
377
377
|
},
|
|
378
|
+
JSONTonpy: (RED,node,msg,data)=>new NumPy(data).toNpyBuffer(),
|
|
379
|
+
JSONToNumPyObject: (RED,node,msg,data)=>new NumPy(data),
|
|
378
380
|
JSONToString: (RED,node,msg,data)=>JSON.stringify(data),
|
|
379
381
|
JSONToXLSX:JSONToXLSX,
|
|
380
382
|
JSONToXLSXObject:JSONToXLSXObject,
|
|
381
383
|
JSONToXML: (RED,node,msg,data)=>json2xmlParser.parse(data),
|
|
384
|
+
npyToJSON: (RED,node,msg,data)=>new NumPy(data).toSerializable(),
|
|
385
|
+
npyToNumPyObject: (RED,node,msg,data)=>new NumPy(data),
|
|
386
|
+
NumPyObjectToJSON: (RED,node,msg,data)=> data.toSerializable(),
|
|
382
387
|
StringToCompressed: (RED,node,msg,data)=>compressor.compress(data,
|
|
383
388
|
(compressed)=>{
|
|
384
389
|
node.setData(RED,node,msg,compressed);
|
|
@@ -441,6 +446,23 @@ function evalFunction(id,mapping){
|
|
|
441
446
|
function is(node,value){
|
|
442
447
|
return node.actionSource==value||node.actionTarget==value;
|
|
443
448
|
}
|
|
449
|
+
let jsonata;
|
|
450
|
+
function JSONataTransform(data,ok,error){
|
|
451
|
+
/*
|
|
452
|
+
(async () => {
|
|
453
|
+
return result = await expression.evaluate(data);
|
|
454
|
+
})()
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
this.transformFuncionCompiled.evalFunction(data,{},(error, result) => {
|
|
458
|
+
if(error) {
|
|
459
|
+
console.error(error);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
console.log("Finished with", result);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
444
466
|
module.exports = function (RED) {
|
|
445
467
|
function transformNode(n) {
|
|
446
468
|
RED.nodes.createNode(this,n);
|
|
@@ -513,6 +535,16 @@ module.exports = function (RED) {
|
|
|
513
535
|
}
|
|
514
536
|
}
|
|
515
537
|
}
|
|
538
|
+
if(node.transformFuncion && ( node.actionSource=="JSON" || node.actionTarget=="JSON" )) {
|
|
539
|
+
try{
|
|
540
|
+
if(!jsonata) jsonata=require('jsonata')
|
|
541
|
+
node.transformFuncionCompiled = jsonata(node.transformFuncion);
|
|
542
|
+
} catch (ex) {
|
|
543
|
+
error(node,ex,"Transform function error");
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
516
548
|
const typeValidate="invalid"+node.actionSource;
|
|
517
549
|
node.invalidSourceType=typeValidate in functions &! ["XLSX","XLSXObject"].includes(node.actionTarget)?functions[typeValidate]:(()=>false);
|
|
518
550
|
try {
|