@aaqu/fromcubes-db 0.0.0-stage → 0.1.1
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/LICENSE +201 -0
- package/NOTICE +24 -0
- package/README.md +442 -2
- package/SECURITY.md +75 -0
- package/THIRD-PARTY-NOTICES.md +151 -0
- package/examples/Quick Start/All Databases.json +1719 -0
- package/examples/Quick Start/ClickHouse.json +278 -0
- package/examples/Quick Start/CockroachDB.json +280 -0
- package/examples/Quick Start/Firebird.json +278 -0
- package/examples/Quick Start/MariaDB.json +281 -0
- package/examples/Quick Start/MySQL.json +281 -0
- package/examples/Quick Start/Oracle.json +280 -0
- package/examples/Quick Start/PostgreSQL.json +280 -0
- package/examples/Quick Start/SQL Server.json +282 -0
- package/examples/Quick Start/SQLite.json +278 -0
- package/examples/Quick Start/TiDB.json +281 -0
- package/examples/Quick Start/YugabyteDB.json +280 -0
- package/examples/SQLite Sensor Log With Portal.json +391 -0
- package/examples/Select With Parameters.json +130 -0
- package/index.js +32 -0
- package/lib/adapters/clickhouse.js +254 -0
- package/lib/adapters/firebird.js +416 -0
- package/lib/adapters/index.js +37 -0
- package/lib/adapters/mssql.js +178 -0
- package/lib/adapters/mysql.js +171 -0
- package/lib/adapters/oracle.js +272 -0
- package/lib/adapters/postgres.js +161 -0
- package/lib/adapters/read.js +57 -0
- package/lib/adapters/sqlite.js +193 -0
- package/lib/adapters/time.js +89 -0
- package/lib/bound.js +29 -0
- package/lib/editor-api.js +134 -0
- package/lib/editor-preview.js +191 -0
- package/lib/errors.js +66 -0
- package/lib/params.js +966 -0
- package/lib/pool.js +391 -0
- package/lib/settings.js +302 -0
- package/lib/sql/compile.js +160 -0
- package/lib/sql/dialect.js +194 -0
- package/lib/sql/parse.js +202 -0
- package/lib/sql/types.js +1071 -0
- package/lib/sqlite-files.js +137 -0
- package/nodes/connection.html +728 -0
- package/nodes/connection.js +179 -0
- package/nodes/editor/ark-pixel.LICENSE.txt +96 -0
- package/nodes/editor/ark-pixel.woff2 +0 -0
- package/nodes/editor/mark.svg +5 -0
- package/nodes/editor/sql-editor.css +604 -0
- package/nodes/editor/sql-editor.js +1490 -0
- package/nodes/editor/sql-model.js +203 -0
- package/nodes/icons/fromcubes-db.svg +24 -0
- package/nodes/query.html +662 -0
- package/nodes/query.js +195 -0
- package/package.json +81 -4
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ManagedPool } = require("../lib/pool");
|
|
4
|
+
const { isProduct, PRODUCTS, PRODUCT_IDS } = require("../lib/sql/dialect");
|
|
5
|
+
const { typesFor } = require("../lib/sql/types");
|
|
6
|
+
const { driverConfigFor } = require("../lib/settings");
|
|
7
|
+
const { listDatabases } = require("../lib/sqlite-files");
|
|
8
|
+
|
|
9
|
+
module.exports = function (RED) {
|
|
10
|
+
// The edit dialog builds its database picker from this rather than carrying
|
|
11
|
+
// its own list, so lib/sql/dialect.js stays the only place a product is
|
|
12
|
+
// declared. Read-only, and it exposes nothing a palette user cannot see
|
|
13
|
+
// anyway, but it still sits behind the editor's read permission.
|
|
14
|
+
RED.httpAdmin.get("/fromcubes-db/products", RED.auth.needsPermission("nodes.read"), function (req, res) {
|
|
15
|
+
res.json(
|
|
16
|
+
PRODUCT_IDS.map((id) => ({
|
|
17
|
+
id,
|
|
18
|
+
label: PRODUCTS[id].label,
|
|
19
|
+
engine: PRODUCTS[id].engine,
|
|
20
|
+
defaultPort: PRODUCTS[id].defaultPort,
|
|
21
|
+
})),
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// The query node's parameter type picker is built from this, for the same
|
|
26
|
+
// reason: lib/sql/types.js stays the only place a column type is declared.
|
|
27
|
+
// Limits are left out — the browser needs the name and what the brackets
|
|
28
|
+
// hold, and the checking happens on this side anyway.
|
|
29
|
+
RED.httpAdmin.get("/fromcubes-db/types/:product", RED.auth.needsPermission("nodes.read"), function (req, res) {
|
|
30
|
+
if (!isProduct(req.params.product)) {
|
|
31
|
+
res.status(404).json({ error: `Unknown database: ${req.params.product}` });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const types = typesFor(req.params.product);
|
|
35
|
+
res.json(
|
|
36
|
+
Object.keys(types)
|
|
37
|
+
.sort()
|
|
38
|
+
.map((name) => ({
|
|
39
|
+
name,
|
|
40
|
+
category: types[name].category,
|
|
41
|
+
args: types[name].args,
|
|
42
|
+
allowsMax: types[name].allowsMax === true,
|
|
43
|
+
// A vector's storage format, the second argument: vector(3, float32).
|
|
44
|
+
formats: types[name].formats || [],
|
|
45
|
+
// The first server version that has it: the picker says so, since
|
|
46
|
+
// it lists the newest catalogue whatever the server runs.
|
|
47
|
+
since: types[name].sinceName || types[name].since || null,
|
|
48
|
+
})),
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// The SQLite databases already in <userDir>/fromcubes-db, for the dialog's
|
|
53
|
+
// picker. Names and sizes only — never a file's contents, never a path
|
|
54
|
+
// outside that folder.
|
|
55
|
+
RED.httpAdmin.get("/fromcubes-db/sqlite/databases", RED.auth.needsPermission("nodes.read"), function (req, res) {
|
|
56
|
+
try {
|
|
57
|
+
res.json(listDatabases(RED.settings.userDir));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
RED.log.warn(`fromcubes-db: cannot list SQLite databases: ${err.message}`);
|
|
60
|
+
res.status(500).json({ error: "Cannot list SQLite databases" });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Holds one connection pool shared by every query node that points at it.
|
|
66
|
+
* The pool itself connects lazily, so an unused connection costs nothing.
|
|
67
|
+
*/
|
|
68
|
+
function FromcubesDbConnectionNode(config) {
|
|
69
|
+
RED.nodes.createNode(this, config);
|
|
70
|
+
const node = this;
|
|
71
|
+
|
|
72
|
+
node.dialect = config.dialect;
|
|
73
|
+
node.label = config.name || `${config.dialect}://${config.host}/${config.database}`;
|
|
74
|
+
|
|
75
|
+
if (!isProduct(config.dialect)) {
|
|
76
|
+
node.error(`Unsupported database: ${config.dialect}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let advanced = {};
|
|
81
|
+
if (config.options && String(config.options).trim() !== "") {
|
|
82
|
+
try {
|
|
83
|
+
advanced = JSON.parse(config.options);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
node.error(`Advanced options must be valid JSON: ${err.message}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// The dialect-specific dialog fields become driver configuration here;
|
|
91
|
+
// Advanced JSON is merged on top for anything no field covers.
|
|
92
|
+
let driverConfig;
|
|
93
|
+
try {
|
|
94
|
+
driverConfig = driverConfigFor(config.dialect, config, advanced, { userDir: RED.settings.userDir });
|
|
95
|
+
} catch (err) {
|
|
96
|
+
node.error(err.message);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const credentials = node.credentials || {};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* User and password normally come from the encrypted credentials, which is
|
|
104
|
+
* where a secret belongs and why it never appears in an exported flow. A
|
|
105
|
+
* flow built into an image has nothing to type in, though — the device's
|
|
106
|
+
* password does not exist until it is provisioned — so either field can
|
|
107
|
+
* instead name an environment variable.
|
|
108
|
+
*
|
|
109
|
+
* Read through evaluateNodeProperty rather than process.env, so a variable
|
|
110
|
+
* set on the group or the flow counts exactly as it does everywhere else in
|
|
111
|
+
* Node-RED. An unset variable stops the node here rather than building a
|
|
112
|
+
* pool that would fail on the first query, far away from the cause; an
|
|
113
|
+
* unset one reads back as '', which is why empty counts as missing.
|
|
114
|
+
*/
|
|
115
|
+
function resolveSecret(label, source, envName, fallback) {
|
|
116
|
+
if (source !== "env") return fallback;
|
|
117
|
+
const name = String(envName || "").trim();
|
|
118
|
+
if (name === "") {
|
|
119
|
+
throw new Error(`${label} is set to read an environment variable, but none is named`);
|
|
120
|
+
}
|
|
121
|
+
const value = RED.util.evaluateNodeProperty(name, "env", node);
|
|
122
|
+
if (value === undefined || value === null || value === "") {
|
|
123
|
+
throw new Error(`${label}: environment variable ${name} is not set`);
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let user;
|
|
129
|
+
let password;
|
|
130
|
+
try {
|
|
131
|
+
user = resolveSecret("User", config.userSource, config.userEnv, credentials.user);
|
|
132
|
+
password = resolveSecret("Password", config.passwordSource, config.passwordEnv, credentials.password);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
node.status({ fill: "red", shape: "ring", text: err.message });
|
|
135
|
+
node.error(err.message);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
node.pool = new ManagedPool({
|
|
140
|
+
dialect: config.dialect,
|
|
141
|
+
host: config.host,
|
|
142
|
+
port: config.port === "" || config.port === undefined ? undefined : Number(config.port),
|
|
143
|
+
database: config.database,
|
|
144
|
+
user,
|
|
145
|
+
password,
|
|
146
|
+
poolMin: config.poolMin,
|
|
147
|
+
poolMax: config.poolMax,
|
|
148
|
+
idleTimeoutMs: config.idleTimeoutMs,
|
|
149
|
+
connectTimeoutMs: config.connectTimeoutMs,
|
|
150
|
+
queryTimeoutMs: config.queryTimeoutMs,
|
|
151
|
+
queueMax: config.queueMax,
|
|
152
|
+
undefinedAsNull: config.undefinedAsNull === true,
|
|
153
|
+
...driverConfig,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
/** Query nodes call this so the pool lives exactly as long as it is used. */
|
|
157
|
+
node.acquire = function acquire() {
|
|
158
|
+
node.pool.retain();
|
|
159
|
+
return node.pool;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
node.on("close", function (removed, done) {
|
|
163
|
+
const finish = typeof done === "function" ? done : removed;
|
|
164
|
+
// close() always resolves, so done() is never skipped and Node-RED does
|
|
165
|
+
// not have to fall back on its 15 s timeout.
|
|
166
|
+
node.pool
|
|
167
|
+
.close()
|
|
168
|
+
.catch((err) => node.error(`Error closing connection: ${err.message}`))
|
|
169
|
+
.then(() => finish());
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
RED.nodes.registerType("fromcubes-db-connection", FromcubesDbConnectionNode, {
|
|
174
|
+
credentials: {
|
|
175
|
+
user: { type: "text" },
|
|
176
|
+
password: { type: "password" },
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Ark Pixel Font
|
|
2
|
+
https://github.com/TakWolf/ark-pixel-font
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021, TakWolf (https://takwolf.com).
|
|
5
|
+
|
|
6
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
7
|
+
This license is copied below, and is also available with a FAQ at:
|
|
8
|
+
https://openfontlicense.org
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
-----------------------------------------------------------
|
|
12
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
13
|
+
-----------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
PREAMBLE
|
|
16
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
17
|
+
development of collaborative font projects, to support the font creation
|
|
18
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
19
|
+
open framework in which fonts may be shared and improved in partnership
|
|
20
|
+
with others.
|
|
21
|
+
|
|
22
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
23
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
24
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
25
|
+
redistributed and/or sold with any software provided that any reserved
|
|
26
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
27
|
+
however, cannot be released under any other type of license. The
|
|
28
|
+
requirement for fonts to remain under this license does not apply
|
|
29
|
+
to any document created using the fonts or their derivatives.
|
|
30
|
+
|
|
31
|
+
DEFINITIONS
|
|
32
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
33
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
34
|
+
include source files, build scripts and documentation.
|
|
35
|
+
|
|
36
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
37
|
+
copyright statement(s).
|
|
38
|
+
|
|
39
|
+
"Original Version" refers to the collection of Font Software components as
|
|
40
|
+
distributed by the Copyright Holder(s).
|
|
41
|
+
|
|
42
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
43
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
44
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
45
|
+
new environment.
|
|
46
|
+
|
|
47
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
48
|
+
writer or other person who contributed to the Font Software.
|
|
49
|
+
|
|
50
|
+
PERMISSION & CONDITIONS
|
|
51
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
52
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
53
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
54
|
+
Software, subject to the following conditions:
|
|
55
|
+
|
|
56
|
+
1) Neither the Font Software nor any of its individual components,
|
|
57
|
+
in Original or Modified Versions, may be sold by itself.
|
|
58
|
+
|
|
59
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
60
|
+
redistributed and/or sold with any software, provided that each copy
|
|
61
|
+
contains the above copyright notice and this license. These can be
|
|
62
|
+
included either as stand-alone text files, human-readable headers or
|
|
63
|
+
in the appropriate machine-readable metadata fields within text or
|
|
64
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
65
|
+
|
|
66
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
67
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
68
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
69
|
+
presented to the users.
|
|
70
|
+
|
|
71
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
72
|
+
Software shall not be used to promote, endorse or advertise any
|
|
73
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
74
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
75
|
+
permission.
|
|
76
|
+
|
|
77
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
78
|
+
must be distributed entirely under this license, and must not be
|
|
79
|
+
distributed under any other license. The requirement for fonts to
|
|
80
|
+
remain under this license does not apply to any document created
|
|
81
|
+
using the Font Software.
|
|
82
|
+
|
|
83
|
+
TERMINATION
|
|
84
|
+
This license becomes null and void if any of the above conditions are
|
|
85
|
+
not met.
|
|
86
|
+
|
|
87
|
+
DISCLAIMER
|
|
88
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
89
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
90
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
91
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
92
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
93
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
94
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
95
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
96
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
|
2
|
+
<!-- The fromcubes mark, traced from the project artwork by tools/build-icon.mjs.
|
|
3
|
+
currentColor so the editor chrome can recolour it per surface. -->
|
|
4
|
+
<path fill="currentColor" fill-rule="evenodd" d="M31.03 1.00L32.97 1.00L34.91 1.97L49.11 10.69L57.83 15.21L59.13 16.50L59.13 47.50L57.83 48.79L49.11 53.31L34.91 62.03L32.97 63.00L30.39 62.68L17.15 54.60L8.43 50.08L4.88 47.50L4.88 16.50L12.95 11.33L31.03 1.32ZM31.68 3.91L9.07 16.82L9.40 17.47L10.69 17.47L15.21 14.56L20.70 13.27L23.28 13.27L33.61 19.08L37.17 21.34L37.49 23.93L36.20 25.22L35.23 27.48L31.35 29.42L31.68 30.39L54.93 17.15L53.64 16.50L48.79 19.73L41.04 21.02L30.71 15.21L28.77 13.59L26.83 12.95L26.51 10.36L29.09 6.49L32.97 4.55L32.00 3.91ZM35.55 6.17L31.35 8.43L29.74 11.33L41.69 18.11L47.18 17.15L51.05 14.56L35.88 6.17ZM21.02 16.18L16.18 17.15L12.95 19.41L22.96 24.90L24.90 26.51L27.48 27.48L27.80 28.13L33.29 25.22L34.26 22.96L25.22 17.47L22.64 16.18L21.34 16.18ZM7.78 19.73L7.46 21.02L12.63 23.60L17.79 29.42L18.11 46.21L16.82 47.50L11.98 47.50L8.43 45.24L7.46 45.24L7.46 46.21L13.27 49.11L30.39 59.45L30.39 57.51L25.54 55.25L20.70 50.08L20.05 32.65L21.34 31.35L26.51 31.35L30.06 33.61L30.71 33.61L30.71 32.65L8.10 19.73ZM56.22 19.73L54.93 20.38L54.93 27.16L52.67 33.61L39.43 41.69L37.81 42.01L36.20 41.36L34.26 37.81L33.94 32.65L33.29 32.97L33.29 59.13L34.58 58.80L34.26 52.99L36.52 45.89L50.73 37.17L53.31 38.14L55.25 41.69L55.25 46.53L56.54 46.21L56.54 19.73ZM52.02 21.99L36.84 30.71L37.17 37.17L37.81 38.46L38.78 38.78L41.69 36.52L50.41 31.68L52.02 26.83L52.02 22.31ZM7.78 24.25L7.46 41.69L11.98 43.95L12.30 44.59L15.21 44.59L14.89 30.06L11.98 27.48L11.33 26.19L7.78 24.57ZM23.28 34.26L23.28 48.47L27.48 52.99L30.39 54.60L30.71 37.17L25.86 34.26L23.60 34.26ZM50.73 40.72L38.78 47.82L37.17 52.99L37.17 57.19L52.34 48.47L52.34 42.33L51.05 40.72Z"/>
|
|
5
|
+
</svg>
|