admindb 2.2.1 → 2.3.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/README.md +368 -364
- package/dist/app.js +25 -16
- package/dist/auth/config.d.ts +1 -1
- package/dist/auth/config.js +18 -30
- package/dist/auth/crypto.js +11 -21
- package/dist/auth/middleware.js +9 -16
- package/dist/auth/routes.js +9 -15
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.js +20 -29
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.js +15 -18
- package/dist/cli/runner.js +13 -13
- package/dist/data/chain.d.ts +1 -1
- package/dist/data/chain.js +40 -617
- package/dist/data/datasets.d.ts +1 -1
- package/dist/data/datasets.js +43 -1
- package/dist/data/detector.js +45 -21
- package/dist/data/engine.d.ts +1 -1
- package/dist/data/engine.js +483 -142
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +8 -0
- package/dist/data/prng.d.ts +1 -0
- package/dist/data/prng.js +73 -0
- package/dist/data/registry.d.ts +1 -0
- package/dist/data/registry.js +805 -0
- package/dist/data/schema-graph.d.ts +1 -0
- package/dist/data/schema-graph.js +210 -0
- package/dist/data/strategies.d.ts +1 -1
- package/dist/data/strategies.js +44 -283
- package/dist/data/templates.d.ts +1 -0
- package/dist/data/templates.js +134 -0
- package/dist/data/types.d.ts +1 -1
- package/dist/data/validator.d.ts +1 -0
- package/dist/data/validator.js +160 -0
- package/dist/db/database.js +9 -14
- package/dist/db/export.js +32 -55
- package/dist/db/filters.d.ts +1 -1
- package/dist/db/filters.js +15 -38
- package/dist/db/introspection.js +4 -7
- package/dist/db/manager.d.ts +1 -1
- package/dist/db/manager.js +48 -53
- package/dist/db/migrations.js +7 -14
- package/dist/db/postgres.js +30 -78
- package/dist/index.d.ts +1 -1
- package/dist/public/css/app.css +1 -1
- package/dist/public/js/browse.js +1 -1
- package/dist/public/js/inspector.js +1 -1
- package/dist/public/js/query.js +1 -1
- package/dist/public/js/seed.js +1 -1
- package/dist/routes/api/erd.js +3 -8
- package/dist/routes/api/helpers.d.ts +1 -1
- package/dist/routes/api/helpers.js +75 -25
- package/dist/routes/api/import-export.js +1 -2
- package/dist/routes/api/query.js +2 -6
- package/dist/routes/api/rows.js +4 -8
- package/dist/routes/api/seed.js +35 -21
- package/dist/routes/api/tables.js +15 -30
- package/dist/routes/databases.js +8 -26
- package/dist/routes/pages.js +67 -18
- package/dist/serverless.js +31 -44
- package/dist/sql/generator.d.ts +1 -1
- package/dist/sql/generator.js +35 -109
- package/dist/types/api.d.ts +1 -1
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.js +45 -85
- package/dist/utils/csv.d.ts +1 -1
- package/dist/utils/csv.js +11 -17
- package/dist/utils/datatype.js +46 -60
- package/dist/utils/icons.js +8 -8
- package/dist/views/layouts/main.hbs +1 -87
- package/dist/views/pages/databases.hbs +1 -233
- package/dist/views/pages/designer.hbs +1 -89
- package/dist/views/pages/erd.hbs +1 -1241
- package/dist/views/pages/error.hbs +1 -10
- package/dist/views/pages/form.hbs +1 -59
- package/dist/views/pages/home.hbs +1 -220
- package/dist/views/pages/info.hbs +1 -107
- package/dist/views/pages/login.hbs +1 -98
- package/dist/views/pages/query.hbs +1 -129
- package/dist/views/pages/schema.hbs +1 -298
- package/dist/views/pages/seed-select.hbs +251 -0
- package/dist/views/pages/seed.hbs +256 -414
- package/dist/views/pages/table.hbs +1 -327
- package/dist/views/partials/navbar.hbs +1 -83
- package/dist/views/partials/sidebar.hbs +1 -129
- package/docs/API.md +149 -149
- package/docs/EXAMPLES.md +579 -579
- package/docs/SECURITY.md +265 -265
- package/package.json +80 -79
package/dist/cli/runner.js
CHANGED
|
@@ -38,9 +38,13 @@ function runCli() {
|
|
|
38
38
|
const authPassword = args.authPassword ?? env.authPassword;
|
|
39
39
|
const authSecret = args.authSecret ?? env.authSecret;
|
|
40
40
|
const serverless = args.serverless !== undefined ? args.serverless : env.serverless;
|
|
41
|
-
const
|
|
41
|
+
const explicitReadonly = args.explicitReadonly !== undefined ? args.explicitReadonly : env.explicitReadonly;
|
|
42
42
|
const connections = args.connections ?? env.connections;
|
|
43
43
|
const hasConnections = Boolean(connections && Object.keys(connections).length > 0);
|
|
44
|
+
const explicitFile = args.connection || args.dbPath || env.connection || env.dbPath;
|
|
45
|
+
const isPg = Boolean(explicitFile && (0, common_1.isPostgresConnectionString)(explicitFile));
|
|
46
|
+
const defaultReadonly = serverless ? !isPg : false;
|
|
47
|
+
const readonly = explicitReadonly !== undefined ? explicitReadonly : defaultReadonly;
|
|
44
48
|
const config = {
|
|
45
49
|
host: args.host ?? env.host,
|
|
46
50
|
port: args.port ?? env.port,
|
|
@@ -52,6 +56,7 @@ function runCli() {
|
|
|
52
56
|
basePath: (args.basePath ?? env.basePath).replace(/\/+$/, ''),
|
|
53
57
|
logLevel: args.logLevel ?? env.logLevel,
|
|
54
58
|
readonly,
|
|
59
|
+
explicitReadonly,
|
|
55
60
|
serverless,
|
|
56
61
|
auth: authEnabled
|
|
57
62
|
? {
|
|
@@ -66,9 +71,7 @@ function runCli() {
|
|
|
66
71
|
const app = (0, express_1.default)();
|
|
67
72
|
app.disable('x-powered-by');
|
|
68
73
|
const hasDir = Boolean(config.dbDir);
|
|
69
|
-
const hasFiles = Boolean(config.dbFiles
|
|
70
|
-
const explicitFile = args.connection || args.dbPath || config.connection || config.dbPath;
|
|
71
|
-
const isPg = Boolean(explicitFile && (0, common_1.isPostgresConnectionString)(explicitFile));
|
|
74
|
+
const hasFiles = Boolean(config.dbFiles?.length);
|
|
72
75
|
const singleFileOnly = !hasConnections && (Boolean(explicitFile) || isPg) && !hasDir && !hasFiles;
|
|
73
76
|
const useManager = !singleFileOnly;
|
|
74
77
|
const managerFiles = [...(config.dbFiles ?? [])];
|
|
@@ -79,10 +82,10 @@ function runCli() {
|
|
|
79
82
|
const browseRoot = hasDir ? node_path_1.default.resolve(config.dbDir) : undefined;
|
|
80
83
|
const router = useManager
|
|
81
84
|
? (0, app_1.createRouter)({
|
|
82
|
-
manager: new manager_1.DbManager({ dir: managerDir, files: managerFiles, connections, readonly: config.
|
|
85
|
+
manager: new manager_1.DbManager({ dir: managerDir, files: managerFiles, connections, readonly: explicitReadonly, serverless: config.serverless }, logger),
|
|
83
86
|
basePath: config.basePath,
|
|
84
87
|
logger,
|
|
85
|
-
readonly:
|
|
88
|
+
readonly: explicitReadonly,
|
|
86
89
|
serverless: config.serverless,
|
|
87
90
|
allowBrowse,
|
|
88
91
|
browseRoot,
|
|
@@ -93,7 +96,7 @@ function runCli() {
|
|
|
93
96
|
connection: explicitFile,
|
|
94
97
|
basePath: config.basePath,
|
|
95
98
|
logger,
|
|
96
|
-
readonly: config.
|
|
99
|
+
readonly: explicitReadonly !== undefined ? explicitReadonly : (!isPg && config.serverless),
|
|
97
100
|
serverless: config.serverless,
|
|
98
101
|
auth: config.auth,
|
|
99
102
|
});
|
|
@@ -103,14 +106,12 @@ function runCli() {
|
|
|
103
106
|
const nets = node_os_1.default.networkInterfaces();
|
|
104
107
|
for (const name of Object.keys(nets)) {
|
|
105
108
|
for (const net of nets[name] ?? []) {
|
|
106
|
-
if (net.family === 'IPv4' && !net.internal)
|
|
109
|
+
if (net.family === 'IPv4' && !net.internal)
|
|
107
110
|
return net.address;
|
|
108
|
-
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
|
-
catch {
|
|
113
|
-
}
|
|
114
|
+
catch { }
|
|
114
115
|
return undefined;
|
|
115
116
|
}
|
|
116
117
|
const server = app.listen(config.port, config.host, () => {
|
|
@@ -126,8 +127,7 @@ function runCli() {
|
|
|
126
127
|
if (isAnyHost) {
|
|
127
128
|
const netIp = getNetworkIp();
|
|
128
129
|
if (netIp) {
|
|
129
|
-
|
|
130
|
-
console.log(` ${colors_1.c.green('➜')} ${colors_1.c.bold('Network:')} ${colors_1.c.cyan(netUrl)}`);
|
|
130
|
+
console.log(` ${colors_1.c.green('➜')} ${colors_1.c.bold('Network:')} ${colors_1.c.cyan(`http://${netIp}:${config.port}${config.basePath}/`)}`);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
if (useManager) {
|
package/dist/data/chain.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import type {IDatabase,TableInfoData} from '../db/index';import{
|
|
1
|
+
import type {IDatabase,TableInfoData} from '../db/index';import{buildChainInsertSql} from './engine';import type {ColumnPlan,ErChainConfig,ErChainResult,ErChainScope,TableGenerationMode} from './types';export{buildChainInsertSql};export declare const buildErGraph:(tables:TableInfoData[])=>Map<string,import("./schema-graph").SchemaNode>;export declare const resolveErChain:(graph:Map<string,any>,rootTable:string,scope?:ErChainScope)=>import("./schema-graph").SchemaNode[];export declare const topologicalSort:(nodes:any[])=>{sorted:import("./schema-graph").SchemaNode[];cycleDetected:boolean;cycleTables:string[];};export declare function getErChainConfig(db:IDatabase,rootTable:string,scope?:ErChainScope):Promise<ErChainConfig>;export declare function generateChainRows(db:IDatabase,chainConfig:ErChainConfig,customPlans?:Record<string,Record<string,ColumnPlan>>,customCounts?:Record<string,number>,truncate?:boolean,modes?:Record<string,TableGenerationMode>,seed?:number|null):Promise<ErChainResult>;export declare function executeChainInsert(db:IDatabase,chainResult:ErChainResult,truncate?:boolean):Promise<{inserted:Record<string,number>;totalInserted:number;elapsedMs:number;warnings:string[];}>;
|