Dia antes primera install

This commit is contained in:
2025-12-08 15:20:28 -06:00
commit 1416478c9c
4130 changed files with 886376 additions and 0 deletions

14
node_modules/node-red-node-sqlite/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,14 @@
Copyright 2016 JS Foundation and other contributors, https://js.foundation/
Copyright 2013-2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

66
node_modules/node-red-node-sqlite/README.md generated vendored Normal file
View File

@@ -0,0 +1,66 @@
node-red-node-sqlite
====================
A Node-Red node to read and write a local sqlite database.
Install
-------
Run the following command in your Node-RED user directory - typically `~/.node-red`
npm i --unsafe-perm node-red-node-sqlite
**Notes**:
- Version 1.x requires nodejs v12 or greater.
- The install process requires a compile of native code. This can take 15-20 minutes on devices like a Raspberry Pi - please be prepared to wait a long time. Also if node.js is upgraded at any point you will need to rebuild the native part manually, for example.
cd ~/.node-red
npm rebuild
Usage
-----
Allows access to a SQLite database.
SQL Query sets how the query is passed to the node.
SQL Query Via msg.topic and Fixed Statement uses the db.all operation against the configured database.
This does allow INSERTS, UPDATES and DELETES. By its very nature it is SQL injection... so be careful out there...
SQL Type Prepared Statement also uses db.all but sanitizes parameters passed, eliminating the possibility of SQL injection.
SQL Type Batch without response uses db.exec which runs all SQL statements in the provided string. No result rows are returned.
When using Via msg.topic or Batch without response msg.topic must hold the query for the database.
When using Via msg.topic, parameters can be passed in the query using a msg.payload array. Ex:
```
msg.topic = `INSERT INTO user_table (name, surname) VALUES ($name, $surname)`
msg.payload = ["John", "Smith"]
return msg;
```
When using Normal or Prepared Statement, the query must be entered in the node config.
Pass in the parameters as an object in msg.params for Prepared Statement. Ex:
```
msg.params = {
$id:1,
$name:"John Doe"
}
```
Parameter object names must match parameters set up in the Prepared Statement. If you get the error SQLITE_RANGE: bind or column index out of range be sure to include $ on the parameter object key.
The SQL query for the example above could be: insert into user_table (user_id, user) VALUES ($id, $name);
Using any SQL Query, the result is returned in msg.payload
Typically the returned payload will be an array of the result rows, (or an error).
You can load SQLite extensions by inputting a msg.extension property containing the full path and filename.
The reconnect timeout in milliseconds can be changed by adding a line to `settings.js`
`sqliteReconnectTime: 20000,`

30
node_modules/node-red-node-sqlite/ext/half.c generated vendored Normal file
View File

@@ -0,0 +1,30 @@
/* Add your header comment here */
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1
/*
** The half() SQL function returns half of its input value.
*/
static void halfFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0]));
}
/* SQLite invokes this routine once when it loads the extension.
** Create new functions, collating sequences, and virtual table
** modules here. This is usually the only exported symbol in
** the shared library.
*/
int sqlite3_extension_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
SQLITE_EXTENSION_INIT2(pApi)
sqlite3_create_function(db, "half", 1, SQLITE_ANY, 0, halfFunc, 0, 0);
return 0;
}

BIN
node_modules/node-red-node-sqlite/ext/half.dylib generated vendored Executable file

Binary file not shown.

BIN
node_modules/node-red-node-sqlite/icons/sqlite.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,20 @@
{
"sqlite": {
"label": {
"database": "Datenbank",
"sqlQuery": "SQL-Abfrage",
"viaMsgTopic": "Via msg.topic",
"fixedStatement": "Fester Ausdruck",
"preparedStatement": "Vorbereiteter Ausdruck",
"batchWithoutResponse": "Batch ohne Antwort",
"sqlStatement": "SQL-Ausdruck (Statement)",
"mode": "Modus",
"readWriteCreate": "Lesen-Schreiben-Erzeugen",
"readWrite": "Lesen-Schreiben",
"readOnly": "Nur-Lesen"
},
"tips": {
"memoryDb": "<b>Hinweis:</b> Das Setzen der Datenbank auf <code>:memory:</code> erzeugt eine flüchtige (nicht-persistente) Datenbank im Speicher."
}
}
}

View File

@@ -0,0 +1,32 @@
<script type="text/html" data-help-name="sqlite">
<p>Allows access to a SQLite database.</p>
<p>SQL Query sets how the query is passed to the node.</p>
<p>SQL Query <i>Via msg.topic</i> and <i>Fixed Statement</i> uses the <b>db.all</b> operation against the configured database. This does allow INSERTS, UPDATES and DELETES.
By its very nature it is SQL injection... so <i>be careful out there...</i></p>
<p>SQL Type <i>Prepared Statement</i> also uses <b>db.all</b> but sanitizes parameters passed, eliminating the possibility of SQL injection.</p>
<p>SQL Type <i>Batch without response</i> uses <b>db.exec</b> which runs all SQL statements in the provided string. No result rows are returned.</p>
<p>When using <i>Via msg.topic</i> or <i>Batch without response</i> <code>msg.topic</code> must hold the <i>query</i> for the database.</p>
<p>When using <i>Via msg.topic</i>, parameters can be passed in the query using a <code>msg.payload</code> array. Ex:<br />
<code>msg.topic = `INSERT INTO user_table (name, surname) VALUES ($name, $surname)`<br />
msg.payload = ["John", "Smith"]<br />
return msg;</code><br />
<p>When using Normal or Prepared Statement, the <i>query</i> must be entered in the node config.</p>
<p>Pass in the parameters as an object in <code>msg.params</code> for Prepared Statement. Ex:<br />
<code>msg.params = {<br />
&nbsp;&nbsp;&nbsp;&nbsp;$id:1,<br />
&nbsp;&nbsp;&nbsp;&nbsp;$name:"John Doe"<br />
}</code><br />
Parameter object names must match parameters set up in the Prepared Statement. If you get the error <code>SQLITE_RANGE: bind or column index out of range</code>
be sure to include $ on the parameter object key.<br />
The SQL query for the example above could be: <code>insert into user_table (user_id, user) VALUES ($id, $name);</code></p>
<p>Using any SQL Query, the result is returned in <code>msg.payload</code></p>
<p>Typically the returned payload will be an array of the result rows, (or an error).</p>
<p>You can load SQLite extensions by inputting a <code>msg.extension</code> property containing the full
path and filename.</p>
<p>The reconnect timeout in milliseconds can be changed by adding a line to <b>settings.js</b>
<pre>sqliteReconnectTime: 20000,</pre></p>
</script>
<script type="text/html" data-help-name="sqlitedb">
<p>The default directory for the database file is the user's home directory through which the Node-RED process was started. You can specify absolute path to change it.</p>
</script>

View File

@@ -0,0 +1,20 @@
{
"sqlite": {
"label": {
"database": "Database",
"sqlQuery": "SQL Query",
"viaMsgTopic": "Via msg.topic",
"fixedStatement": "Fixed Statement",
"preparedStatement": "Prepared Statement",
"batchWithoutResponse": "Batch without response",
"sqlStatement": "SQL Statement",
"mode": "Mode",
"readWriteCreate": "Read-Write-Create",
"readWrite": "Read-Write",
"readOnly": "Read-Only"
},
"tips": {
"memoryDb": "<b>Note</b>: Setting the database name to <code>:memory:</code> will create a non-persistant in memory database."
}
}
}

View File

@@ -0,0 +1,26 @@
<script type="text/html" data-help-name="sqlite">
<p>SQLiteデータベースにアクセスする機能を提供します</p>
<p>SQLクエリには本ノードへどの様にクエリを渡すかを設定します</p>
<p><i>msg.topic経由</i> と <i>固定文</i> のSQLクエリは設定したデータベースに対して <b>db.all</b> 操作を実行します。これによって、INSERTSとUPDATES、DELETESを利用できます。性質上、SQLインジェクションに<i>注意してください</i></p>
<p><i>事前定義文</i> SQL <b>db.all</b> 使SQL</p>
<p><i>一括(応答なし)</i> SQLSQL <b>db.exec</b> 使</p>
<p><i>msg.topic経由</i> または <i>一括(応答なし)</i> を用いる時 <code>msg.topic</code> には、データベースに問い合わせるための <i>クエリ</i> が格納されている必要があります</p>
<p>通常の方法や事前定義文を用いる時 <i>クエリ</i> </p>
<p>事前定義文を用いるためには <code>msg.params</code> をオブジェクトとしてパラメータに渡します。例:<br />
<code>msg.params = {<br />
&nbsp;&nbsp;&nbsp;&nbsp;$id:1,<br />
&nbsp;&nbsp;&nbsp;&nbsp;$name:"John Doe"<br />
}</code><br />
パラメータのオブジェクト名は事前定義文に設定したパラメータと一致させる必要があります
もし <code>SQLITE_RANGE: bind or column index out of range</code> というエラーが発生した場合は、バラメータのオブジェクトのキーに$を含めてください。<br />
上の例で用いるSQLクエリは次の様になります: <code>insert into user_table (user_id, user) VALUES ($id, $name);</code></p>
<p>SQLクエリを使用すると <code>msg.payload</code> </p>
<p>通常返されるペイロードは結果の行から成る配列(またはエラー)になります</p>
<p>フルパスやファイル名を含む <code>msg.extension</code> SQLite</p>
<p>ミリ秒単位の再接続タイムアウトは<b>settings.js</b>
<pre>sqliteReconnectTime: 20000,</pre></p>
</script>
<script type="text/html" data-help-name="sqlitedb">
<p>データベースファイルのデフォルトディレクトリはNode-REDプロセスを開始したユーザのホームディレクトリですこれは絶対パスを用いることで変更できます</p>
</script>

View File

@@ -0,0 +1,20 @@
{
"sqlite": {
"label": {
"database": "データベース",
"sqlQuery": "SQLクエリ",
"viaMsgTopic": "msg.topic経由",
"fixedStatement": "固定文",
"preparedStatement": "事前定義文",
"batchWithoutResponse": "一括(応答なし)",
"sqlStatement": "SQL文",
"mode": "モード",
"readWriteCreate": "読み取り-書き込み-作成",
"readWrite": "読み取り-書き込み",
"readOnly": "読み取りのみ"
},
"tips": {
"memoryDb": "<b>注釈</b>: データベース名に <code>:memory:</code> を設定すると、非永続的なメモリデータベースを作成します。"
}
}
}

32
node_modules/node-red-node-sqlite/package.json generated vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"name": "node-red-node-sqlite",
"version": "1.1.1",
"description": "A sqlite node for Node-RED",
"dependencies": {
"sqlite3": "^5.1.7"
},
"repository": {
"type": "git",
"url": "https://github.com/node-red/node-red-nodes.git",
"directory": "tree/master/storage/sqlite"
},
"engines": {
"node": ">=12"
},
"license": "Apache-2.0",
"keywords": [
"node-red",
"sqlite"
],
"node-red": {
"version": ">=1.0.0",
"nodes": {
"sqlite": "sqlite.js"
}
},
"author": {
"name": "Dave Conway-Jones",
"email": "ceejay@vnet.ibm.com",
"url": "http://nodered.org"
}
}

131
node_modules/node-red-node-sqlite/sqlite.html generated vendored Normal file
View File

@@ -0,0 +1,131 @@
<script type="text/html" data-template-name="sqlitedb">
<div class="form-row">
<label for="node-config-input-db"><i class="fa fa-database"></i> <span data-i18n="sqlite.label.database"></label>
<input type="text" id="node-config-input-db" placeholder="/tmp/sqlite">
</div>
<div class="form-row">
<label for="node-config-input-mode" data-i18n="sqlite.label.mode"></label>
<select id="node-config-input-mode" style="width:70%">
<option value="RWC" data-i18n="sqlite.label.readWriteCreate"></option>
<option value="RW" data-i18n="sqlite.label.readWrite"></option>
<option value="RO" data-i18n="sqlite.label.readOnly"></option>
</select>
</div>
<div class="form-tips" data-i18n="[html]sqlite.tips.memoryDb"></div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sqlitedb',{
category: 'config',
defaults: {
db: {value:"", required:true},
mode: {value:"RWC"}
},
label: function() {
return this.db;
}
});
</script>
<script type="text/html" data-template-name="sqlite">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-mydb"><i class="fa fa-database"></i> <span data-i18n="sqlite.label.database"></label>
<input type="text" id="node-input-mydb">
</div>
<div class="form-row">
<label for=""><i class="fa fa-code"></i> <span data-i18n="sqlite.label.sqlQuery"></label>
<select id="node-input-sqlquery">
<option value="msg.topic" data-i18n="sqlite.label.viaMsgTopic"></option>
<option value="fixed" data-i18n="sqlite.label.fixedStatement"></option>
<option value="prepared" data-i18n="sqlite.label.preparedStatement"></option>
<option value="batch" data-i18n="sqlite.label.batchWithoutResponse"></option>
</select>
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="" style="width: unset;" id="node-input-sqllabel"><i class="fa fa-code"></i> <span data-i18n="sqlite.label.sqlStatement"></label>
</div>
<div>
<input type="hidden" id="node-input-sql" autofocus="autofocus">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-sql-editor" ></div>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sqlite',{
category: 'storage-input',
color:"#e97b00",
defaults: {
mydb: {type:"sqlitedb",required:true},
sqlquery: {value:"msg.topic",required:true},
sql: {value:""},
name: {value:""}
},
inputs:1,
outputs:1,
icon: "sqlite.png",
label: function() {
var dbNode = RED.nodes.node(this.mydb);
return this.name||(dbNode?dbNode.label():"sqlite");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
var ace = this;
this.editor = RED.editor.createEditor({
id: 'node-input-sql-editor',
mode: 'ace/mode/sql',
value: $("#node-input-sql").val(),
globals: {
msg:true,
context:true,
RED: true,
util: true,
flow: true,
global: true,
console: true,
Buffer: true,
setTimeout: true,
clearTimeout: true,
setInterval: true,
clearInterval: true
}
});
$("#node-input-sqlquery").change(function() {
if ($("#node-input-sqlquery").val() == "msg.topic" || $("#node-input-sqlquery").val() == "batch"){
$("#node-input-sqllabel").hide();
$("#node-input-sql-editor").hide();
}
else{
$("#node-input-sqllabel").show();
$("#node-input-sql-editor").show();
ace.editor.renderer.updateFull();
}
});
$("#node-input-sqlquery").change();
},
oneditsave: function() {
$("#node-input-sql").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditresize: function(size) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var height = $("#dialog-form").height();
for (var i=0; i<rows.size(); i++) {
height -= $(rows[i]).outerHeight(true);
}
var editorRow = $("#dialog-form>div.node-text-editor-row");
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#dialog-form .node-text-editor").css("height",height+"px");
this.editor.resize();
}
});
</script>

155
node_modules/node-red-node-sqlite/sqlite.js generated vendored Normal file
View File

@@ -0,0 +1,155 @@
module.exports = function(RED) {
"use strict";
var reconnect = RED.settings.sqliteReconnectTime || 20000;
var sqlite3 = require('sqlite3');
function SqliteNodeDB(n) {
RED.nodes.createNode(this,n);
this.dbname = n.db;
this.mod = n.mode;
if (n.mode === "RWC") { this.mode = sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE; }
if (n.mode === "RW") { this.mode = sqlite3.OPEN_READWRITE; }
if (n.mode === "RO") { this.mode = sqlite3.OPEN_READONLY; }
var node = this;
node.doConnect = function() {
if (node.db) { return; }
node.db = new sqlite3.Database(node.dbname,node.mode);
node.db.on('open', function() {
if (node.tick) { clearTimeout(node.tick); }
node.log("opened "+node.dbname+" ok");
});
node.db.on('error', function(err) {
node.error("failed to open "+node.dbname, err);
node.tick = setTimeout(function() { node.doConnect(); }, reconnect);
});
}
node.on('close', function (done) {
if (node.tick) { clearTimeout(node.tick); }
if (node.db) { node.db.close(done()); }
else { done(); }
});
}
RED.nodes.registerType("sqlitedb",SqliteNodeDB);
function SqliteNodeIn(n) {
RED.nodes.createNode(this,n);
this.mydb = n.mydb;
this.sqlquery = n.sqlquery||"msg.topic";
this.sql = n.sql;
this.mydbConfig = RED.nodes.getNode(this.mydb);
var node = this;
node.status({});
if (node.mydbConfig) {
node.mydbConfig.doConnect();
node.status({fill:"green",shape:"dot",text:this.mydbConfig.mod});
var bind = [];
var doQuery = function(msg) {
bind = []
if (node.sqlquery == "msg.topic") {
if (typeof msg.topic === 'string') {
if (msg.topic.length > 0) {
if (Array.isArray(msg.payload)) {
if (msg.payload.length === (msg.topic.split('$').length - 1) ) { bind = msg.payload; }
else { bind = []; }
}
node.mydbConfig.db.all(msg.topic, bind, function(err, row) {
if (err) { node.error(err,msg); }
else {
msg.payload = row;
node.send(msg);
}
});
}
}
else {
node.error("msg.topic : the query is not defined as a string",msg);
node.status({fill:"red",shape:"dot",text:"msg.topic error"});
}
}
if (node.sqlquery == "batch") {
if (typeof msg.topic === 'string') {
if (msg.topic.length > 0) {
node.mydbConfig.db.exec(msg.topic, function(err) {
if (err) { node.error(err,msg);}
else {
msg.payload = [];
node.send(msg);
}
});
}
}
else {
node.error("msg.topic : the query is not defined as string", msg);
node.status({fill:"red", shape:"dot",text:"msg.topic error"});
}
}
if (node.sqlquery == "fixed") {
if (typeof node.sql === 'string') {
if (node.sql.length > 0) {
node.mydbConfig.db.all(node.sql, bind, function(err, row) {
if (err) { node.error(err,msg); }
else {
msg.payload = row;
node.send(msg);
}
});
}
}
else {
if (node.sql === null || node.sql == "") {
node.error("SQL statement config not set up",msg);
node.status({fill:"red",shape:"dot",text:"SQL config not set up"});
}
}
}
if (node.sqlquery == "prepared") {
if (typeof node.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object") {
if (node.sql.length > 0) {
node.mydbConfig.db.all(node.sql, msg.params, function(err, row) {
if (err) { node.error(err,msg); }
else {
msg.payload = row;
node.send(msg);
}
});
}
}
else {
if (node.sql === null || node.sql == "") {
node.error("Prepared statement config not set up",msg);
node.status({fill:"red",shape:"dot",text:"Prepared statement not set up"});
}
if (typeof msg.params == "undefined") {
node.error("msg.params not passed");
node.status({fill:"red",shape:"dot",text:"msg.params not defined"});
}
else if (typeof msg.params != "object") {
node.error("msg.params not an object");
node.status({fill:"red",shape:"dot",text:"msg.params not an object"});
}
}
}
}
node.on("input", function(msg) {
if (msg.hasOwnProperty("extension")) {
node.mydbConfig.db.loadExtension(msg.extension, function(err) {
if (err) { node.error(err,msg); }
else { doQuery(msg); }
});
}
else { doQuery(msg); }
});
}
else {
node.error("Sqlite database not configured");
}
}
RED.nodes.registerType("sqlite",SqliteNodeIn);
}