admindb 2.6.0 → 2.6.2
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 +20 -20
- package/dist/db/dialects/postgres/introspector.js +70 -70
- package/dist/public/css/app.css +2 -1
- package/dist/views/pages/error.hbs +1 -10
- package/dist/views/pages/seed-select.hbs +252 -1
- package/dist/views/pages/seed.hbs +307 -1
- package/dist/views/pages/sync.hbs +1 -409
- package/docs/EXAMPLES.md +579 -579
- package/docs/SECURITY.md +265 -265
- package/package.json +9 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Muhammad Bin Khalid
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Muhammad Bin Khalid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
@@ -16,9 +16,9 @@ class PostgresIntrospector {
|
|
|
16
16
|
async listTables(driver) {
|
|
17
17
|
try {
|
|
18
18
|
const pool = this.getPool(driver);
|
|
19
|
-
const res = await pool.query(`SELECT table_name
|
|
20
|
-
FROM information_schema.tables
|
|
21
|
-
WHERE table_schema = $1 AND table_type = 'BASE TABLE'
|
|
19
|
+
const res = await pool.query(`SELECT table_name
|
|
20
|
+
FROM information_schema.tables
|
|
21
|
+
WHERE table_schema = $1 AND table_type = 'BASE TABLE'
|
|
22
22
|
ORDER BY table_name;`, [this.schema]);
|
|
23
23
|
return { success: true, data: res.rows.map((r) => ({ name: r.table_name })) };
|
|
24
24
|
}
|
|
@@ -45,21 +45,21 @@ class PostgresIntrospector {
|
|
|
45
45
|
async getTableInfo(driver, table) {
|
|
46
46
|
try {
|
|
47
47
|
const pool = this.getPool(driver);
|
|
48
|
-
const colRes = await pool.query(`SELECT ordinal_position, column_name, data_type, udt_name, is_nullable, column_default
|
|
49
|
-
FROM information_schema.columns
|
|
50
|
-
WHERE table_schema = $1 AND table_name = $2
|
|
48
|
+
const colRes = await pool.query(`SELECT ordinal_position, column_name, data_type, udt_name, is_nullable, column_default
|
|
49
|
+
FROM information_schema.columns
|
|
50
|
+
WHERE table_schema = $1 AND table_name = $2
|
|
51
51
|
ORDER BY ordinal_position;`, [this.schema, table]);
|
|
52
52
|
if (!colRes.rows.length) {
|
|
53
53
|
return { success: false, error: `Table "${table}" does not exist.` };
|
|
54
54
|
}
|
|
55
|
-
const pkRes = await pool.query(`SELECT kcu.column_name
|
|
56
|
-
FROM information_schema.table_constraints tc
|
|
57
|
-
JOIN information_schema.key_column_usage kcu
|
|
58
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
59
|
-
AND tc.table_schema = kcu.table_schema
|
|
60
|
-
WHERE tc.constraint_type = 'PRIMARY KEY'
|
|
61
|
-
AND tc.table_schema = $1
|
|
62
|
-
AND tc.table_name = $2
|
|
55
|
+
const pkRes = await pool.query(`SELECT kcu.column_name
|
|
56
|
+
FROM information_schema.table_constraints tc
|
|
57
|
+
JOIN information_schema.key_column_usage kcu
|
|
58
|
+
ON tc.constraint_name = kcu.constraint_name
|
|
59
|
+
AND tc.table_schema = kcu.table_schema
|
|
60
|
+
WHERE tc.constraint_type = 'PRIMARY KEY'
|
|
61
|
+
AND tc.table_schema = $1
|
|
62
|
+
AND tc.table_name = $2
|
|
63
63
|
ORDER BY kcu.ordinal_position;`, [this.schema, table]);
|
|
64
64
|
const primaryKey = pkRes.rows.map((r) => r.column_name);
|
|
65
65
|
const columns = colRes.rows.map((r) => {
|
|
@@ -74,24 +74,24 @@ class PostgresIntrospector {
|
|
|
74
74
|
pk: pkIdx >= 0 ? pkIdx + 1 : 0,
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
|
-
const fkRes = await pool.query(`SELECT
|
|
78
|
-
row_number() OVER () AS id,
|
|
79
|
-
ccu.table_name AS table,
|
|
80
|
-
kcu.column_name AS "from",
|
|
81
|
-
ccu.column_name AS "to",
|
|
82
|
-
rc.update_rule AS on_update,
|
|
83
|
-
rc.delete_rule AS on_delete
|
|
84
|
-
FROM information_schema.table_constraints AS tc
|
|
85
|
-
JOIN information_schema.key_column_usage AS kcu
|
|
86
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
87
|
-
AND tc.table_schema = kcu.table_schema
|
|
88
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
|
89
|
-
ON ccu.constraint_name = tc.constraint_name
|
|
90
|
-
AND ccu.table_schema = tc.table_schema
|
|
91
|
-
JOIN information_schema.referential_constraints AS rc
|
|
92
|
-
ON rc.constraint_name = tc.constraint_name
|
|
93
|
-
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
94
|
-
AND tc.table_schema = $1
|
|
77
|
+
const fkRes = await pool.query(`SELECT
|
|
78
|
+
row_number() OVER () AS id,
|
|
79
|
+
ccu.table_name AS table,
|
|
80
|
+
kcu.column_name AS "from",
|
|
81
|
+
ccu.column_name AS "to",
|
|
82
|
+
rc.update_rule AS on_update,
|
|
83
|
+
rc.delete_rule AS on_delete
|
|
84
|
+
FROM information_schema.table_constraints AS tc
|
|
85
|
+
JOIN information_schema.key_column_usage AS kcu
|
|
86
|
+
ON tc.constraint_name = kcu.constraint_name
|
|
87
|
+
AND tc.table_schema = kcu.table_schema
|
|
88
|
+
JOIN information_schema.constraint_column_usage AS ccu
|
|
89
|
+
ON ccu.constraint_name = tc.constraint_name
|
|
90
|
+
AND ccu.table_schema = tc.table_schema
|
|
91
|
+
JOIN information_schema.referential_constraints AS rc
|
|
92
|
+
ON rc.constraint_name = tc.constraint_name
|
|
93
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
94
|
+
AND tc.table_schema = $1
|
|
95
95
|
AND tc.table_name = $2;`, [this.schema, table]);
|
|
96
96
|
const foreignKeys = fkRes.rows.map((r, idx) => ({
|
|
97
97
|
id: Number(r.id || idx + 1),
|
|
@@ -102,18 +102,18 @@ class PostgresIntrospector {
|
|
|
102
102
|
on_update: r.on_update,
|
|
103
103
|
on_delete: r.on_delete,
|
|
104
104
|
}));
|
|
105
|
-
const idxRes = await pool.query(`SELECT
|
|
106
|
-
i.relname AS indexname,
|
|
107
|
-
ix.indisunique,
|
|
108
|
-
ix.indisprimary,
|
|
109
|
-
array_agg(a.attname ORDER BY array_position(ix.indkey, a.attnum)) AS columns,
|
|
110
|
-
pg_get_indexdef(ix.indexrelid) AS indexdef
|
|
111
|
-
FROM pg_class t
|
|
112
|
-
JOIN pg_index ix ON t.oid = ix.indrelid
|
|
113
|
-
JOIN pg_class i ON i.oid = ix.indexrelid
|
|
114
|
-
JOIN pg_namespace n ON n.oid = t.relnamespace
|
|
115
|
-
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
|
|
116
|
-
WHERE n.nspname = $1 AND t.relname = $2
|
|
105
|
+
const idxRes = await pool.query(`SELECT
|
|
106
|
+
i.relname AS indexname,
|
|
107
|
+
ix.indisunique,
|
|
108
|
+
ix.indisprimary,
|
|
109
|
+
array_agg(a.attname ORDER BY array_position(ix.indkey, a.attnum)) AS columns,
|
|
110
|
+
pg_get_indexdef(ix.indexrelid) AS indexdef
|
|
111
|
+
FROM pg_class t
|
|
112
|
+
JOIN pg_index ix ON t.oid = ix.indrelid
|
|
113
|
+
JOIN pg_class i ON i.oid = ix.indexrelid
|
|
114
|
+
JOIN pg_namespace n ON n.oid = t.relnamespace
|
|
115
|
+
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
|
|
116
|
+
WHERE n.nspname = $1 AND t.relname = $2
|
|
117
117
|
GROUP BY i.relname, ix.indisunique, ix.indisprimary, ix.indexrelid;`, [this.schema, table]);
|
|
118
118
|
const indexes = idxRes.rows.map((r) => ({
|
|
119
119
|
name: r.indexname,
|
|
@@ -161,19 +161,19 @@ class PostgresIntrospector {
|
|
|
161
161
|
if (!infoR.success || !infoR.data)
|
|
162
162
|
throw new Error(infoR.error || `Table ${table} not found.`);
|
|
163
163
|
const { columns, foreignKeys, indexes, primaryKey } = infoR.data;
|
|
164
|
-
const refRes = await pool.query(`SELECT
|
|
165
|
-
tc.table_name AS table,
|
|
166
|
-
kcu.column_name AS "from",
|
|
167
|
-
ccu.column_name AS "to"
|
|
168
|
-
FROM information_schema.table_constraints AS tc
|
|
169
|
-
JOIN information_schema.key_column_usage AS kcu
|
|
170
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
171
|
-
AND tc.table_schema = kcu.table_schema
|
|
172
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
|
173
|
-
ON ccu.constraint_name = tc.constraint_name
|
|
174
|
-
AND ccu.table_schema = tc.table_schema
|
|
175
|
-
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
176
|
-
AND tc.table_schema = $1
|
|
164
|
+
const refRes = await pool.query(`SELECT
|
|
165
|
+
tc.table_name AS table,
|
|
166
|
+
kcu.column_name AS "from",
|
|
167
|
+
ccu.column_name AS "to"
|
|
168
|
+
FROM information_schema.table_constraints AS tc
|
|
169
|
+
JOIN information_schema.key_column_usage AS kcu
|
|
170
|
+
ON tc.constraint_name = kcu.constraint_name
|
|
171
|
+
AND tc.table_schema = kcu.table_schema
|
|
172
|
+
JOIN information_schema.constraint_column_usage AS ccu
|
|
173
|
+
ON ccu.constraint_name = tc.constraint_name
|
|
174
|
+
AND ccu.table_schema = tc.table_schema
|
|
175
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
176
|
+
AND tc.table_schema = $1
|
|
177
177
|
AND ccu.table_name = $2;`, [this.schema, table]);
|
|
178
178
|
const references = refRes.rows;
|
|
179
179
|
const columnDetails = columns.map((col) => {
|
|
@@ -219,19 +219,19 @@ class PostgresIntrospector {
|
|
|
219
219
|
async getReferencingTables(driver, table) {
|
|
220
220
|
try {
|
|
221
221
|
const pool = this.getPool(driver);
|
|
222
|
-
const refRes = await pool.query(`SELECT
|
|
223
|
-
tc.table_name AS table,
|
|
224
|
-
kcu.column_name AS "from",
|
|
225
|
-
ccu.column_name AS "to"
|
|
226
|
-
FROM information_schema.table_constraints AS tc
|
|
227
|
-
JOIN information_schema.key_column_usage AS kcu
|
|
228
|
-
ON tc.constraint_name = kcu.constraint_name
|
|
229
|
-
AND tc.table_schema = kcu.table_schema
|
|
230
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
|
231
|
-
ON ccu.constraint_name = tc.constraint_name
|
|
232
|
-
AND ccu.table_schema = tc.table_schema
|
|
233
|
-
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
234
|
-
AND tc.table_schema = $1
|
|
222
|
+
const refRes = await pool.query(`SELECT
|
|
223
|
+
tc.table_name AS table,
|
|
224
|
+
kcu.column_name AS "from",
|
|
225
|
+
ccu.column_name AS "to"
|
|
226
|
+
FROM information_schema.table_constraints AS tc
|
|
227
|
+
JOIN information_schema.key_column_usage AS kcu
|
|
228
|
+
ON tc.constraint_name = kcu.constraint_name
|
|
229
|
+
AND tc.table_schema = kcu.table_schema
|
|
230
|
+
JOIN information_schema.constraint_column_usage AS ccu
|
|
231
|
+
ON ccu.constraint_name = tc.constraint_name
|
|
232
|
+
AND ccu.table_schema = tc.table_schema
|
|
233
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
234
|
+
AND tc.table_schema = $1
|
|
235
235
|
AND ccu.table_name = $2;`, [this.schema, table]);
|
|
236
236
|
const byTable = new Map();
|
|
237
237
|
for (const r of refRes.rows) {
|