sql-dashboard 1.0.0

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +494 -0
  3. package/dist/base.driver-BKzf8BxS.d.mts +102 -0
  4. package/dist/base.driver-BdK7obt0.d.ts +102 -0
  5. package/dist/chunk-7YLO3OSN.mjs +19513 -0
  6. package/dist/chunk-BPXOTU3D.js +76 -0
  7. package/dist/chunk-HIQUIRDJ.mjs +76 -0
  8. package/dist/chunk-MTCZXLV5.mjs +232 -0
  9. package/dist/chunk-OCL5Y3AH.mjs +51 -0
  10. package/dist/chunk-OQJUWTZV.js +51 -0
  11. package/dist/chunk-P4QE6SGC.mjs +69 -0
  12. package/dist/chunk-TNHUK2FI.mjs +1033 -0
  13. package/dist/chunk-YGKUVVJT.mjs +5494 -0
  14. package/dist/connection-CzduPMhl.d.mts +68 -0
  15. package/dist/connection-CzduPMhl.d.ts +68 -0
  16. package/dist/dashboard-CkGz4ID-.d.mts +45 -0
  17. package/dist/dashboard-D9xSb-hQ.d.ts +45 -0
  18. package/dist/drivers/mssql.driver.d.mts +26 -0
  19. package/dist/drivers/mssql.driver.d.ts +26 -0
  20. package/dist/drivers/mssql.driver.js +64824 -0
  21. package/dist/drivers/mssql.driver.mjs +8 -0
  22. package/dist/drivers/mysql.driver.d.mts +29 -0
  23. package/dist/drivers/mysql.driver.d.ts +29 -0
  24. package/dist/drivers/mysql.driver.js +19672 -0
  25. package/dist/drivers/mysql.driver.mjs +9 -0
  26. package/dist/drivers/postgres.driver.d.mts +29 -0
  27. package/dist/drivers/postgres.driver.d.ts +29 -0
  28. package/dist/drivers/postgres.driver.js +5588 -0
  29. package/dist/drivers/postgres.driver.mjs +8 -0
  30. package/dist/export/index.d.mts +23 -0
  31. package/dist/export/index.d.ts +23 -0
  32. package/dist/export/index.js +102 -0
  33. package/dist/export/index.mjs +75 -0
  34. package/dist/index.d.mts +579 -0
  35. package/dist/index.d.ts +579 -0
  36. package/dist/index.js +26694 -0
  37. package/dist/index.mjs +26694 -0
  38. package/dist/middleware/express.d.mts +11 -0
  39. package/dist/middleware/express.d.ts +11 -0
  40. package/dist/middleware/express.js +90896 -0
  41. package/dist/middleware/express.mjs +91 -0
  42. package/dist/middleware/fastify.d.mts +10 -0
  43. package/dist/middleware/fastify.d.ts +10 -0
  44. package/dist/middleware/fastify.js +90860 -0
  45. package/dist/middleware/fastify.mjs +54 -0
  46. package/dist/open-JHAWMLA2.mjs +602 -0
  47. package/dist/open-T3PIT3AO.js +602 -0
  48. package/dist/query-BFhJHNeb.d.mts +16 -0
  49. package/dist/query-BFhJHNeb.d.ts +16 -0
  50. package/dist/tedious-LLE7JVQC.js +63830 -0
  51. package/dist/tedious-PHHFLMLD.mjs +63830 -0
  52. package/package.json +131 -0
@@ -0,0 +1,91 @@
1
+ import {
2
+ SQLDashboard
3
+ } from "../chunk-TNHUK2FI.mjs";
4
+ import "../chunk-MTCZXLV5.mjs";
5
+ import "../chunk-7YLO3OSN.mjs";
6
+ import "../chunk-YGKUVVJT.mjs";
7
+ import "../chunk-P4QE6SGC.mjs";
8
+ import "../chunk-HIQUIRDJ.mjs";
9
+ import {
10
+ __require
11
+ } from "../chunk-OCL5Y3AH.mjs";
12
+
13
+ // src/middleware/express.ts
14
+ function createExpressRouter(options) {
15
+ const { Router } = __require("express");
16
+ const router = Router();
17
+ const db = new SQLDashboard(options);
18
+ const basePath = options.basePath || "/sql-dashboard";
19
+ const handleQuery = async (req, res) => {
20
+ try {
21
+ const { sql, params } = req.body;
22
+ if (!sql) {
23
+ return res.status(400).json({ error: "SQL query is required" });
24
+ }
25
+ const result = await db.query(sql, { params });
26
+ return res.json(result);
27
+ } catch (error) {
28
+ return res.status(500).json({ error: error.message });
29
+ }
30
+ };
31
+ const handleSchema = async (_req, res) => {
32
+ try {
33
+ const schema = await db.schema.getSchema();
34
+ res.json(schema);
35
+ } catch (error) {
36
+ res.status(500).json({ error: error.message });
37
+ }
38
+ };
39
+ const handleTables = async (_req, res) => {
40
+ try {
41
+ const tables = await db.schema.getTables();
42
+ res.json(tables);
43
+ } catch (error) {
44
+ res.status(500).json({ error: error.message });
45
+ }
46
+ };
47
+ const handleTableDetail = async (req, res) => {
48
+ try {
49
+ const { tableName } = req.params;
50
+ const table = await db.schema.getTable(tableName);
51
+ res.json(table);
52
+ } catch (error) {
53
+ res.status(500).json({ error: error.message });
54
+ }
55
+ };
56
+ const handleHistory = async (req, res) => {
57
+ try {
58
+ const { page, pageSize, search } = req.query;
59
+ const history = db.history.list({
60
+ page: page ? parseInt(page) : 1,
61
+ pageSize: pageSize ? parseInt(pageSize) : 50,
62
+ search
63
+ });
64
+ res.json(history);
65
+ } catch (error) {
66
+ res.status(500).json({ error: error.message });
67
+ }
68
+ };
69
+ const handleStatus = async (_req, res) => {
70
+ try {
71
+ const status = await db.status();
72
+ res.json(status);
73
+ } catch (error) {
74
+ res.status(500).json({ error: error.message });
75
+ }
76
+ };
77
+ router.post(`${basePath}/query`, handleQuery);
78
+ router.get(`${basePath}/schema`, handleSchema);
79
+ router.get(`${basePath}/tables`, handleTables);
80
+ router.get(`${basePath}/tables/:tableName`, handleTableDetail);
81
+ router.get(`${basePath}/history`, handleHistory);
82
+ router.get(`${basePath}/status`, handleStatus);
83
+ return router;
84
+ }
85
+ function sqlDashboard(options) {
86
+ return createExpressRouter(options);
87
+ }
88
+ export {
89
+ createExpressRouter,
90
+ sqlDashboard
91
+ };
@@ -0,0 +1,10 @@
1
+ import { FastifyInstance, FastifyPluginOptions } from 'fastify';
2
+ import { D as DashboardOptions } from '../dashboard-CkGz4ID-.mjs';
3
+ import '../connection-CzduPMhl.mjs';
4
+
5
+ interface FastifyPluginConfig extends FastifyPluginOptions, DashboardOptions {
6
+ basePath?: string;
7
+ }
8
+ declare function registerFastifyPlugin(fastify: FastifyInstance, options: FastifyPluginConfig): Promise<void>;
9
+
10
+ export { registerFastifyPlugin as default, registerFastifyPlugin };
@@ -0,0 +1,10 @@
1
+ import { FastifyInstance, FastifyPluginOptions } from 'fastify';
2
+ import { D as DashboardOptions } from '../dashboard-D9xSb-hQ.js';
3
+ import '../connection-CzduPMhl.js';
4
+
5
+ interface FastifyPluginConfig extends FastifyPluginOptions, DashboardOptions {
6
+ basePath?: string;
7
+ }
8
+ declare function registerFastifyPlugin(fastify: FastifyInstance, options: FastifyPluginConfig): Promise<void>;
9
+
10
+ export { registerFastifyPlugin as default, registerFastifyPlugin };