admindb 2.5.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/app.js +13 -1
- package/dist/core/diff/data-differ.d.ts +1 -0
- package/dist/core/diff/data-differ.js +243 -0
- package/dist/core/diff/patch-generator.d.ts +1 -0
- package/dist/core/diff/patch-generator.js +77 -0
- package/dist/core/diff/schema-differ.d.ts +1 -0
- package/dist/core/diff/schema-differ.js +229 -0
- package/dist/core/router.d.ts +1 -1
- package/dist/core/transfer/dialect-mapper.d.ts +1 -0
- package/dist/core/transfer/dialect-mapper.js +303 -0
- package/dist/core/transfer/masking.d.ts +1 -0
- package/dist/core/transfer/masking.js +49 -0
- package/dist/core/transfer/sync-engine.d.ts +1 -0
- package/dist/core/transfer/sync-engine.js +234 -0
- package/dist/core/transfer/topological-sort.d.ts +1 -0
- package/dist/core/transfer/topological-sort.js +55 -0
- package/dist/db/dialects/postgres/introspector.js +71 -71
- package/dist/db/dialects/sqlite/introspector.js +6 -3
- package/dist/modules/index.d.ts +1 -1
- package/dist/modules/index.js +9 -1
- package/dist/modules/search/index.d.ts +1 -0
- package/dist/modules/search/index.js +19 -0
- package/dist/modules/search/search.routes.d.ts +1 -0
- package/dist/modules/search/search.routes.js +38 -0
- package/dist/modules/search/search.service.d.ts +1 -0
- package/dist/modules/search/search.service.js +458 -0
- package/dist/modules/search/search.types.d.ts +1 -0
- package/dist/modules/search/search.types.js +2 -0
- package/dist/modules/sync/index.d.ts +1 -0
- package/dist/modules/sync/index.js +18 -0
- package/dist/modules/sync/sync.routes.d.ts +1 -0
- package/dist/modules/sync/sync.routes.js +135 -0
- package/dist/modules/sync/sync.service.d.ts +1 -0
- package/dist/modules/sync/sync.service.js +41 -0
- package/dist/public/css/app.css +2 -1
- package/dist/public/js/browse.js +1 -1
- package/dist/public/js/search.js +1 -0
- package/dist/public/js/sync.js +1 -0
- package/dist/utils/icons.js +3 -0
- package/dist/views/layouts/main.hbs +1 -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 -0
- package/dist/views/pages/table.hbs +1 -1
- package/dist/views/partials/navbar.hbs +1 -1
- package/dist/views/partials/sidebar.hbs +1 -1
- package/docs/EXAMPLES.md +579 -579
- package/docs/SECURITY.md +265 -265
- package/package.json +14 -9
|
@@ -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,25 +102,25 @@ 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,
|
|
120
120
|
unique: Boolean(r.indisunique),
|
|
121
121
|
partial: 0,
|
|
122
122
|
origin: r.indisprimary ? 'pk' : r.indisunique ? 'u' : 'c',
|
|
123
|
-
columns: r.columns
|
|
123
|
+
columns: Array.isArray(r.columns) ? r.columns.filter((c) => typeof c === 'string' && c.length > 0) : [],
|
|
124
124
|
sql: r.indexdef,
|
|
125
125
|
}));
|
|
126
126
|
const ddlCols = columns.map((c) => {
|
|
@@ -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) {
|
|
@@ -55,7 +55,9 @@ class SqliteIntrospector {
|
|
|
55
55
|
.prepare(`PRAGMA index_list(${(0, generator_1.quoteIdentifier)(table)})`)
|
|
56
56
|
.all();
|
|
57
57
|
const indexes = indexRows.map((ix) => {
|
|
58
|
-
const ixCols = db.prepare(`PRAGMA index_info(${(0, generator_1.quoteIdentifier)(ix.name)})`).all()
|
|
58
|
+
const ixCols = db.prepare(`PRAGMA index_info(${(0, generator_1.quoteIdentifier)(ix.name)})`).all()
|
|
59
|
+
.map((c) => c.name)
|
|
60
|
+
.filter((n) => Boolean(n));
|
|
59
61
|
const sqlRow = db
|
|
60
62
|
.prepare("SELECT sql FROM sqlite_master WHERE type = 'index' AND name = ?")
|
|
61
63
|
.get(ix.name);
|
|
@@ -114,10 +116,11 @@ class SqliteIntrospector {
|
|
|
114
116
|
const uniqueCols = new Set();
|
|
115
117
|
const indexedCols = new Set();
|
|
116
118
|
for (const ix of indexes) {
|
|
119
|
+
const cols = Array.isArray(ix.columns) ? ix.columns.filter(Boolean) : [];
|
|
117
120
|
if (ix.unique)
|
|
118
|
-
|
|
121
|
+
cols.forEach((c) => uniqueCols.add(c));
|
|
119
122
|
if (ix.origin === 'c')
|
|
120
|
-
|
|
123
|
+
cols.forEach((c) => indexedCols.add(c));
|
|
121
124
|
}
|
|
122
125
|
const refs = this.getIncomingFks(db, table);
|
|
123
126
|
const refsByTo = new Map();
|
package/dist/modules/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import type {Router} from 'express';import type {RouteContext} from '../core/router';export * from './databases/index';export * from './tables/index';export * from './rows/index';export * from './query/index';export * from './schema/index';export * from './seed/index';export * from './erd/index';export declare function registerModules(router:Router,ctx:RouteContext):void;
|
|
1
|
+
import type {Router} from 'express';import type {RouteContext} from '../core/router';export * from './databases/index';export * from './tables/index';export * from './rows/index';export * from './query/index';export * from './schema/index';export * from './seed/index';export * from './erd/index';export * from './sync/index';export * from './search/index';export declare function registerModules(router:Router,ctx:RouteContext):void;
|
package/dist/modules/index.js
CHANGED
|
@@ -21,6 +21,8 @@ const schema_routes_1 = require("./schema/schema.routes");
|
|
|
21
21
|
const query_routes_1 = require("./query/query.routes");
|
|
22
22
|
const seed_routes_1 = require("./seed/seed.routes");
|
|
23
23
|
const erd_routes_1 = require("./erd/erd.routes");
|
|
24
|
+
const sync_routes_1 = require("./sync/sync.routes");
|
|
25
|
+
const search_routes_1 = require("./search/search.routes");
|
|
24
26
|
__exportStar(require("./databases/index"), exports);
|
|
25
27
|
__exportStar(require("./tables/index"), exports);
|
|
26
28
|
__exportStar(require("./rows/index"), exports);
|
|
@@ -28,6 +30,8 @@ __exportStar(require("./query/index"), exports);
|
|
|
28
30
|
__exportStar(require("./schema/index"), exports);
|
|
29
31
|
__exportStar(require("./seed/index"), exports);
|
|
30
32
|
__exportStar(require("./erd/index"), exports);
|
|
33
|
+
__exportStar(require("./sync/index"), exports);
|
|
34
|
+
__exportStar(require("./search/index"), exports);
|
|
31
35
|
function registerModules(router, ctx) {
|
|
32
36
|
router.use((req, res, next) => {
|
|
33
37
|
if (req.method === 'GET')
|
|
@@ -37,7 +41,9 @@ function registerModules(router, ctx) {
|
|
|
37
41
|
p.endsWith('/preview') ||
|
|
38
42
|
p.includes('/api/query/') ||
|
|
39
43
|
p.endsWith('/rows/bulk-impact') ||
|
|
40
|
-
p.endsWith('/rows/bulk-export')
|
|
44
|
+
p.endsWith('/rows/bulk-export') ||
|
|
45
|
+
p.startsWith('/api/sync/') ||
|
|
46
|
+
p.startsWith('/api/search/')) {
|
|
41
47
|
return next();
|
|
42
48
|
}
|
|
43
49
|
try {
|
|
@@ -59,4 +65,6 @@ function registerModules(router, ctx) {
|
|
|
59
65
|
(0, query_routes_1.registerQueryRoutes)(router, ctx);
|
|
60
66
|
(0, seed_routes_1.registerSeedRoutes)(router, ctx);
|
|
61
67
|
(0, erd_routes_1.registerErdRoutes)(router, ctx);
|
|
68
|
+
(0, sync_routes_1.registerSyncRoutes)(router, ctx);
|
|
69
|
+
(0, search_routes_1.registerSearchRoutes)(router, ctx);
|
|
62
70
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './search.types';export * from './search.service';export * from './search.routes';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./search.types"), exports);
|
|
18
|
+
__exportStar(require("./search.service"), exports);
|
|
19
|
+
__exportStar(require("./search.routes"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import type {Router} from 'express';import{type RouteContext} from '../../core/router';export declare function registerSearchRoutes(router:Router,ctx:RouteContext):void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSearchRoutes = registerSearchRoutes;
|
|
4
|
+
const router_1 = require("../../core/router");
|
|
5
|
+
const search_service_1 = require("./search.service");
|
|
6
|
+
function registerSearchRoutes(router, ctx) {
|
|
7
|
+
router.get('/api/search/:db', (0, router_1.wrap)(async (req, res) => {
|
|
8
|
+
const db = ctx.getContext(req);
|
|
9
|
+
const query = String(req.query.q ?? '');
|
|
10
|
+
const type = req.query.type ? String(req.query.type) : undefined;
|
|
11
|
+
const limit = req.query.limit ? parseInt(String(req.query.limit), 10) : 50;
|
|
12
|
+
const includeRows = req.query.includeRows !== 'false';
|
|
13
|
+
const basePath = String(res.locals.basePath ?? '');
|
|
14
|
+
try {
|
|
15
|
+
const results = await search_service_1.SearchService.search(db, query, {
|
|
16
|
+
type,
|
|
17
|
+
limit,
|
|
18
|
+
includeRows,
|
|
19
|
+
basePath,
|
|
20
|
+
});
|
|
21
|
+
(0, router_1.ok)(res, results);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
(0, router_1.fail)(res, err.message ?? 'Failed to execute global search.', 500);
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
router.get('/api/search/:db/metadata', (0, router_1.wrap)(async (req, res) => {
|
|
28
|
+
const db = ctx.getContext(req);
|
|
29
|
+
const basePath = String(res.locals.basePath ?? '');
|
|
30
|
+
try {
|
|
31
|
+
const index = await search_service_1.SearchService.getMetadataIndex(db, basePath);
|
|
32
|
+
(0, router_1.ok)(res, index);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
(0, router_1.fail)(res, err.message ?? 'Failed to fetch search metadata.', 500);
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import type {DatabaseContext} from '../../core/context';import type {SearchOptions,SearchResponse,SearchMetadataIndex,CommandItem} from './search.types';export declare class SearchService{static getCommands(dbId:string,basePath?:string,isReadOnly?:boolean):CommandItem[];static getMetadataIndex(ctx:DatabaseContext,basePath?:string):Promise<SearchMetadataIndex>;private static calculateScore;static search(ctx:DatabaseContext,rawQuery:string,options?:SearchOptions):Promise<SearchResponse>;private static searchRowData;}
|