clawsql 0.1.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.
- package/.env.example +97 -0
- package/README.md +372 -0
- package/dist/__tests__/config/settings.test.d.ts +5 -0
- package/dist/__tests__/config/settings.test.d.ts.map +1 -0
- package/dist/__tests__/config/settings.test.js +154 -0
- package/dist/__tests__/config/settings.test.js.map +1 -0
- package/dist/__tests__/core/discovery/topology.test.d.ts +5 -0
- package/dist/__tests__/core/discovery/topology.test.d.ts.map +1 -0
- package/dist/__tests__/core/discovery/topology.test.js +191 -0
- package/dist/__tests__/core/discovery/topology.test.js.map +1 -0
- package/dist/__tests__/core/failover/executor.test.d.ts +5 -0
- package/dist/__tests__/core/failover/executor.test.d.ts.map +1 -0
- package/dist/__tests__/core/failover/executor.test.js +256 -0
- package/dist/__tests__/core/failover/executor.test.js.map +1 -0
- package/dist/__tests__/core/monitoring/collector.test.d.ts +5 -0
- package/dist/__tests__/core/monitoring/collector.test.d.ts.map +1 -0
- package/dist/__tests__/core/monitoring/collector.test.js +131 -0
- package/dist/__tests__/core/monitoring/collector.test.js.map +1 -0
- package/dist/__tests__/core/monitoring/exporters.test.d.ts +5 -0
- package/dist/__tests__/core/monitoring/exporters.test.d.ts.map +1 -0
- package/dist/__tests__/core/monitoring/exporters.test.js +90 -0
- package/dist/__tests__/core/monitoring/exporters.test.js.map +1 -0
- package/dist/__tests__/core/routing/proxysql-manager.test.d.ts +5 -0
- package/dist/__tests__/core/routing/proxysql-manager.test.d.ts.map +1 -0
- package/dist/__tests__/core/routing/proxysql-manager.test.js +155 -0
- package/dist/__tests__/core/routing/proxysql-manager.test.js.map +1 -0
- package/dist/__tests__/types/index.test.d.ts +5 -0
- package/dist/__tests__/types/index.test.d.ts.map +1 -0
- package/dist/__tests__/types/index.test.js +290 -0
- package/dist/__tests__/types/index.test.js.map +1 -0
- package/dist/__tests__/utils/exceptions.test.d.ts +5 -0
- package/dist/__tests__/utils/exceptions.test.d.ts.map +1 -0
- package/dist/__tests__/utils/exceptions.test.js +142 -0
- package/dist/__tests__/utils/exceptions.test.js.map +1 -0
- package/dist/api/routes/clusters.d.ts +7 -0
- package/dist/api/routes/clusters.d.ts.map +1 -0
- package/dist/api/routes/clusters.js +123 -0
- package/dist/api/routes/clusters.js.map +1 -0
- package/dist/api/routes/config.d.ts +7 -0
- package/dist/api/routes/config.d.ts.map +1 -0
- package/dist/api/routes/config.js +65 -0
- package/dist/api/routes/config.js.map +1 -0
- package/dist/api/routes/failover.d.ts +7 -0
- package/dist/api/routes/failover.d.ts.map +1 -0
- package/dist/api/routes/failover.js +100 -0
- package/dist/api/routes/failover.js.map +1 -0
- package/dist/api/routes/instances.d.ts +11 -0
- package/dist/api/routes/instances.d.ts.map +1 -0
- package/dist/api/routes/instances.js +315 -0
- package/dist/api/routes/instances.js.map +1 -0
- package/dist/api/routes/monitoring.d.ts +7 -0
- package/dist/api/routes/monitoring.d.ts.map +1 -0
- package/dist/api/routes/monitoring.js +72 -0
- package/dist/api/routes/monitoring.js.map +1 -0
- package/dist/api/routes/webhooks.d.ts +12 -0
- package/dist/api/routes/webhooks.d.ts.map +1 -0
- package/dist/api/routes/webhooks.js +232 -0
- package/dist/api/routes/webhooks.js.map +1 -0
- package/dist/api/schemas/index.d.ts +965 -0
- package/dist/api/schemas/index.d.ts.map +1 -0
- package/dist/api/schemas/index.js +171 -0
- package/dist/api/schemas/index.js.map +1 -0
- package/dist/app.d.ts +13 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +197 -0
- package/dist/app.js.map +1 -0
- package/dist/bin/clawsql.d.ts +12 -0
- package/dist/bin/clawsql.d.ts.map +1 -0
- package/dist/bin/clawsql.js +43 -0
- package/dist/bin/clawsql.js.map +1 -0
- package/dist/cli/agent/handler.d.ts +73 -0
- package/dist/cli/agent/handler.d.ts.map +1 -0
- package/dist/cli/agent/handler.js +258 -0
- package/dist/cli/agent/handler.js.map +1 -0
- package/dist/cli/agent/index.d.ts +14 -0
- package/dist/cli/agent/index.d.ts.map +1 -0
- package/dist/cli/agent/index.js +30 -0
- package/dist/cli/agent/index.js.map +1 -0
- package/dist/cli/agent/openclaw-integration.d.ts +81 -0
- package/dist/cli/agent/openclaw-integration.d.ts.map +1 -0
- package/dist/cli/agent/openclaw-integration.js +341 -0
- package/dist/cli/agent/openclaw-integration.js.map +1 -0
- package/dist/cli/agent/providers/anthropic.d.ts +27 -0
- package/dist/cli/agent/providers/anthropic.d.ts.map +1 -0
- package/dist/cli/agent/providers/anthropic.js +106 -0
- package/dist/cli/agent/providers/anthropic.js.map +1 -0
- package/dist/cli/agent/providers/base.d.ts +91 -0
- package/dist/cli/agent/providers/base.d.ts.map +1 -0
- package/dist/cli/agent/providers/base.js +24 -0
- package/dist/cli/agent/providers/base.js.map +1 -0
- package/dist/cli/agent/providers/openai.d.ts +27 -0
- package/dist/cli/agent/providers/openai.d.ts.map +1 -0
- package/dist/cli/agent/providers/openai.js +98 -0
- package/dist/cli/agent/providers/openai.js.map +1 -0
- package/dist/cli/agent/tools/index.d.ts +32 -0
- package/dist/cli/agent/tools/index.d.ts.map +1 -0
- package/dist/cli/agent/tools/index.js +263 -0
- package/dist/cli/agent/tools/index.js.map +1 -0
- package/dist/cli/commands/cleanup.d.ts +12 -0
- package/dist/cli/commands/cleanup.d.ts.map +1 -0
- package/dist/cli/commands/cleanup.js +205 -0
- package/dist/cli/commands/cleanup.js.map +1 -0
- package/dist/cli/commands/clusters.d.ts +12 -0
- package/dist/cli/commands/clusters.d.ts.map +1 -0
- package/dist/cli/commands/clusters.js +468 -0
- package/dist/cli/commands/clusters.js.map +1 -0
- package/dist/cli/commands/config.d.ts +12 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +406 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/cron.d.ts +12 -0
- package/dist/cli/commands/cron.d.ts.map +1 -0
- package/dist/cli/commands/cron.js +215 -0
- package/dist/cli/commands/cron.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +13 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +687 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/failover.d.ts +16 -0
- package/dist/cli/commands/failover.d.ts.map +1 -0
- package/dist/cli/commands/failover.js +333 -0
- package/dist/cli/commands/failover.js.map +1 -0
- package/dist/cli/commands/health.d.ts +12 -0
- package/dist/cli/commands/health.d.ts.map +1 -0
- package/dist/cli/commands/health.js +125 -0
- package/dist/cli/commands/health.js.map +1 -0
- package/dist/cli/commands/help.d.ts +12 -0
- package/dist/cli/commands/help.d.ts.map +1 -0
- package/dist/cli/commands/help.js +52 -0
- package/dist/cli/commands/help.js.map +1 -0
- package/dist/cli/commands/instances.d.ts +12 -0
- package/dist/cli/commands/instances.d.ts.map +1 -0
- package/dist/cli/commands/instances.js +801 -0
- package/dist/cli/commands/instances.js.map +1 -0
- package/dist/cli/commands/notify.d.ts +12 -0
- package/dist/cli/commands/notify.d.ts.map +1 -0
- package/dist/cli/commands/notify.js +43 -0
- package/dist/cli/commands/notify.js.map +1 -0
- package/dist/cli/commands/sql.d.ts +12 -0
- package/dist/cli/commands/sql.d.ts.map +1 -0
- package/dist/cli/commands/sql.js +90 -0
- package/dist/cli/commands/sql.js.map +1 -0
- package/dist/cli/commands/start.d.ts +12 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +174 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +12 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +218 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +12 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +128 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/commands/topology.d.ts +12 -0
- package/dist/cli/commands/topology.d.ts.map +1 -0
- package/dist/cli/commands/topology.js +106 -0
- package/dist/cli/commands/topology.js.map +1 -0
- package/dist/cli/completer.d.ts +47 -0
- package/dist/cli/completer.d.ts.map +1 -0
- package/dist/cli/completer.js +332 -0
- package/dist/cli/completer.js.map +1 -0
- package/dist/cli/formatter.d.ts +165 -0
- package/dist/cli/formatter.d.ts.map +1 -0
- package/dist/cli/formatter.js +408 -0
- package/dist/cli/formatter.js.map +1 -0
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +79 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/raw-input.d.ts +97 -0
- package/dist/cli/raw-input.d.ts.map +1 -0
- package/dist/cli/raw-input.js +493 -0
- package/dist/cli/raw-input.js.map +1 -0
- package/dist/cli/registry.d.ts +103 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +205 -0
- package/dist/cli/registry.js.map +1 -0
- package/dist/cli/repl.d.ts +83 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +447 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/ui/components.d.ts +144 -0
- package/dist/cli/ui/components.d.ts.map +1 -0
- package/dist/cli/ui/components.js +331 -0
- package/dist/cli/ui/components.js.map +1 -0
- package/dist/cli/ui/index.d.ts +7 -0
- package/dist/cli/ui/index.d.ts.map +1 -0
- package/dist/cli/ui/index.js +23 -0
- package/dist/cli/ui/index.js.map +1 -0
- package/dist/cli/utils/docker-files.d.ts +39 -0
- package/dist/cli/utils/docker-files.d.ts.map +1 -0
- package/dist/cli/utils/docker-files.js +223 -0
- package/dist/cli/utils/docker-files.js.map +1 -0
- package/dist/cli/utils/docker-prereq.d.ts +48 -0
- package/dist/cli/utils/docker-prereq.d.ts.map +1 -0
- package/dist/cli/utils/docker-prereq.js +203 -0
- package/dist/cli/utils/docker-prereq.js.map +1 -0
- package/dist/config/settings.d.ts +594 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +250 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/core/discovery/cluster-view.d.ts +50 -0
- package/dist/core/discovery/cluster-view.d.ts.map +1 -0
- package/dist/core/discovery/cluster-view.js +235 -0
- package/dist/core/discovery/cluster-view.js.map +1 -0
- package/dist/core/discovery/scanner.d.ts +70 -0
- package/dist/core/discovery/scanner.d.ts.map +1 -0
- package/dist/core/discovery/scanner.js +197 -0
- package/dist/core/discovery/scanner.js.map +1 -0
- package/dist/core/discovery/topology.d.ts +118 -0
- package/dist/core/discovery/topology.d.ts.map +1 -0
- package/dist/core/discovery/topology.js +550 -0
- package/dist/core/discovery/topology.js.map +1 -0
- package/dist/core/failover/candidate-selector.d.ts +46 -0
- package/dist/core/failover/candidate-selector.d.ts.map +1 -0
- package/dist/core/failover/candidate-selector.js +70 -0
- package/dist/core/failover/candidate-selector.js.map +1 -0
- package/dist/core/failover/executor.d.ts +104 -0
- package/dist/core/failover/executor.d.ts.map +1 -0
- package/dist/core/failover/executor.js +248 -0
- package/dist/core/failover/executor.js.map +1 -0
- package/dist/core/failover/operation-builder.d.ts +71 -0
- package/dist/core/failover/operation-builder.d.ts.map +1 -0
- package/dist/core/failover/operation-builder.js +157 -0
- package/dist/core/failover/operation-builder.js.map +1 -0
- package/dist/core/failover/operation-runner.d.ts +75 -0
- package/dist/core/failover/operation-runner.d.ts.map +1 -0
- package/dist/core/failover/operation-runner.js +191 -0
- package/dist/core/failover/operation-runner.js.map +1 -0
- package/dist/core/failover/promoter.d.ts +33 -0
- package/dist/core/failover/promoter.d.ts.map +1 -0
- package/dist/core/failover/promoter.js +97 -0
- package/dist/core/failover/promoter.js.map +1 -0
- package/dist/core/failover/recovery-manager.d.ts +47 -0
- package/dist/core/failover/recovery-manager.d.ts.map +1 -0
- package/dist/core/failover/recovery-manager.js +145 -0
- package/dist/core/failover/recovery-manager.js.map +1 -0
- package/dist/core/failover/types.d.ts +54 -0
- package/dist/core/failover/types.d.ts.map +1 -0
- package/dist/core/failover/types.js +8 -0
- package/dist/core/failover/types.js.map +1 -0
- package/dist/core/monitoring/collector.d.ts +25 -0
- package/dist/core/monitoring/collector.d.ts.map +1 -0
- package/dist/core/monitoring/collector.js +115 -0
- package/dist/core/monitoring/collector.js.map +1 -0
- package/dist/core/monitoring/exporters.d.ts +49 -0
- package/dist/core/monitoring/exporters.d.ts.map +1 -0
- package/dist/core/monitoring/exporters.js +126 -0
- package/dist/core/monitoring/exporters.js.map +1 -0
- package/dist/core/routing/proxysql-manager.d.ts +213 -0
- package/dist/core/routing/proxysql-manager.d.ts.map +1 -0
- package/dist/core/routing/proxysql-manager.js +632 -0
- package/dist/core/routing/proxysql-manager.js.map +1 -0
- package/dist/core/sync/replica-recovery.d.ts +40 -0
- package/dist/core/sync/replica-recovery.d.ts.map +1 -0
- package/dist/core/sync/replica-recovery.js +134 -0
- package/dist/core/sync/replica-recovery.js.map +1 -0
- package/dist/core/sync/sync-coordinator.d.ts +83 -0
- package/dist/core/sync/sync-coordinator.d.ts.map +1 -0
- package/dist/core/sync/sync-coordinator.js +254 -0
- package/dist/core/sync/sync-coordinator.js.map +1 -0
- package/dist/core/sync/topology-watcher.d.ts +76 -0
- package/dist/core/sync/topology-watcher.d.ts.map +1 -0
- package/dist/core/sync/topology-watcher.js +222 -0
- package/dist/core/sync/topology-watcher.js.map +1 -0
- package/dist/core/sync/types.d.ts +85 -0
- package/dist/core/sync/types.d.ts.map +1 -0
- package/dist/core/sync/types.js +8 -0
- package/dist/core/sync/types.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +212 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +153 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/database.d.ts +62 -0
- package/dist/utils/database.d.ts.map +1 -0
- package/dist/utils/database.js +257 -0
- package/dist/utils/database.js.map +1 -0
- package/dist/utils/exceptions.d.ts +69 -0
- package/dist/utils/exceptions.d.ts.map +1 -0
- package/dist/utils/exceptions.js +121 -0
- package/dist/utils/exceptions.js.map +1 -0
- package/dist/utils/logger.d.ts +20 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +90 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mysql-client.d.ts +43 -0
- package/dist/utils/mysql-client.d.ts.map +1 -0
- package/dist/utils/mysql-client.js +125 -0
- package/dist/utils/mysql-client.js.map +1 -0
- package/docker/Dockerfile +61 -0
- package/docker/Dockerfile.node +41 -0
- package/docker/grafana/dashboards/clawsql.json +212 -0
- package/docker/grafana/provisioning/dashboards/dashboards.yml +13 -0
- package/docker/grafana/provisioning/datasources/datasources.yml +12 -0
- package/docker/init/primary.sql +26 -0
- package/docker/init/replica.sql +16 -0
- package/docker/orchestrator/orchestrator.conf.json +98 -0
- package/docker/prometheus/prometheus.yml +45 -0
- package/docker/proxysql/entrypoint.sh +8 -0
- package/docker/proxysql/init.sql.demo +30 -0
- package/docker/proxysql/proxysql.cnf +38 -0
- package/docker-compose.demo.yml +115 -0
- package/docker-compose.yml +217 -0
- package/init/primary.sql +19 -0
- package/init/replica.sql +13 -0
- package/package.json +84 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ClawSQL - Core Types and Models
|
|
4
|
+
*
|
|
5
|
+
* TypeScript interfaces and enums converted from Python dataclasses.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.FailureType = exports.FailoverState = exports.AlertSeverity = exports.HealthStatus = exports.InstanceState = exports.InstanceRole = void 0;
|
|
9
|
+
exports.createInstanceId = createInstanceId;
|
|
10
|
+
exports.createMySQLInstance = createMySQLInstance;
|
|
11
|
+
exports.createMySQLCluster = createMySQLCluster;
|
|
12
|
+
exports.isPrimary = isPrimary;
|
|
13
|
+
exports.isReplica = isReplica;
|
|
14
|
+
exports.isOnline = isOnline;
|
|
15
|
+
exports.isHealthy = isHealthy;
|
|
16
|
+
exports.getInstanceCount = getInstanceCount;
|
|
17
|
+
exports.getHealthyCount = getHealthyCount;
|
|
18
|
+
exports.getClusterHealthStatus = getClusterHealthStatus;
|
|
19
|
+
// =============================================================================
|
|
20
|
+
// Enums
|
|
21
|
+
// =============================================================================
|
|
22
|
+
/** MySQL instance role in the cluster */
|
|
23
|
+
var InstanceRole;
|
|
24
|
+
(function (InstanceRole) {
|
|
25
|
+
InstanceRole["PRIMARY"] = "primary";
|
|
26
|
+
InstanceRole["REPLICA"] = "replica";
|
|
27
|
+
InstanceRole["UNKNOWN"] = "unknown";
|
|
28
|
+
})(InstanceRole || (exports.InstanceRole = InstanceRole = {}));
|
|
29
|
+
/** MySQL instance operational state */
|
|
30
|
+
var InstanceState;
|
|
31
|
+
(function (InstanceState) {
|
|
32
|
+
InstanceState["ONLINE"] = "online";
|
|
33
|
+
InstanceState["OFFLINE"] = "offline";
|
|
34
|
+
InstanceState["RECOVERING"] = "recovering";
|
|
35
|
+
InstanceState["FAILED"] = "failed";
|
|
36
|
+
InstanceState["MAINTENANCE"] = "maintenance";
|
|
37
|
+
})(InstanceState || (exports.InstanceState = InstanceState = {}));
|
|
38
|
+
/** Health status for instances and clusters */
|
|
39
|
+
var HealthStatus;
|
|
40
|
+
(function (HealthStatus) {
|
|
41
|
+
HealthStatus["HEALTHY"] = "healthy";
|
|
42
|
+
HealthStatus["DEGRADED"] = "degraded";
|
|
43
|
+
HealthStatus["UNHEALTHY"] = "unhealthy";
|
|
44
|
+
HealthStatus["UNKNOWN"] = "unknown";
|
|
45
|
+
})(HealthStatus || (exports.HealthStatus = HealthStatus = {}));
|
|
46
|
+
/** Alert severity levels */
|
|
47
|
+
var AlertSeverity;
|
|
48
|
+
(function (AlertSeverity) {
|
|
49
|
+
AlertSeverity["INFO"] = "info";
|
|
50
|
+
AlertSeverity["WARNING"] = "warning";
|
|
51
|
+
AlertSeverity["CRITICAL"] = "critical";
|
|
52
|
+
})(AlertSeverity || (exports.AlertSeverity = AlertSeverity = {}));
|
|
53
|
+
/** Failover operation states */
|
|
54
|
+
var FailoverState;
|
|
55
|
+
(function (FailoverState) {
|
|
56
|
+
FailoverState["IDLE"] = "idle";
|
|
57
|
+
FailoverState["DETECTING"] = "detecting";
|
|
58
|
+
FailoverState["CANDIDATE_SELECTION"] = "candidate_selection";
|
|
59
|
+
FailoverState["PROMOTING"] = "promoting";
|
|
60
|
+
FailoverState["RECONFIGURING"] = "reconfiguring";
|
|
61
|
+
FailoverState["COMPLETED"] = "completed";
|
|
62
|
+
FailoverState["FAILED"] = "failed";
|
|
63
|
+
})(FailoverState || (exports.FailoverState = FailoverState = {}));
|
|
64
|
+
/** Types of failures that can be detected */
|
|
65
|
+
var FailureType;
|
|
66
|
+
(function (FailureType) {
|
|
67
|
+
FailureType["PRIMARY_UNREACHABLE"] = "primary_unreachable";
|
|
68
|
+
FailureType["PRIMARY_NOT_WRITING"] = "primary_not_writing";
|
|
69
|
+
FailureType["REPLICATION_STOPPED"] = "replication_stopped";
|
|
70
|
+
FailureType["REPLICATION_LAG_HIGH"] = "replication_lag_high";
|
|
71
|
+
FailureType["DISK_FULL"] = "disk_full";
|
|
72
|
+
FailureType["MEMORY_EXHAUSTED"] = "memory_exhausted";
|
|
73
|
+
})(FailureType || (exports.FailureType = FailureType = {}));
|
|
74
|
+
// =============================================================================
|
|
75
|
+
// Helper Functions
|
|
76
|
+
// =============================================================================
|
|
77
|
+
/** Create a unique instance ID from host and port */
|
|
78
|
+
function createInstanceId(host, port) {
|
|
79
|
+
return `${host}:${port}`;
|
|
80
|
+
}
|
|
81
|
+
/** Create a default MySQL instance */
|
|
82
|
+
function createMySQLInstance(host, port, overrides) {
|
|
83
|
+
return {
|
|
84
|
+
host,
|
|
85
|
+
port,
|
|
86
|
+
serverId: overrides?.serverId,
|
|
87
|
+
role: overrides?.role ?? InstanceRole.UNKNOWN,
|
|
88
|
+
state: overrides?.state ?? InstanceState.OFFLINE,
|
|
89
|
+
version: overrides?.version,
|
|
90
|
+
replicationLag: overrides?.replicationLag,
|
|
91
|
+
lastSeen: overrides?.lastSeen ?? new Date(),
|
|
92
|
+
clusterId: overrides?.clusterId,
|
|
93
|
+
labels: overrides?.labels ?? {},
|
|
94
|
+
extra: overrides?.extra ?? {},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Create a default MySQL cluster */
|
|
98
|
+
function createMySQLCluster(clusterId, name, overrides) {
|
|
99
|
+
return {
|
|
100
|
+
clusterId,
|
|
101
|
+
name,
|
|
102
|
+
primary: overrides?.primary,
|
|
103
|
+
replicas: overrides?.replicas ?? [],
|
|
104
|
+
createdAt: overrides?.createdAt ?? new Date(),
|
|
105
|
+
updatedAt: overrides?.updatedAt ?? new Date(),
|
|
106
|
+
description: overrides?.description,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Check if instance is a primary */
|
|
110
|
+
function isPrimary(instance) {
|
|
111
|
+
return instance.role === InstanceRole.PRIMARY;
|
|
112
|
+
}
|
|
113
|
+
/** Check if instance is a replica */
|
|
114
|
+
function isReplica(instance) {
|
|
115
|
+
return instance.role === InstanceRole.REPLICA;
|
|
116
|
+
}
|
|
117
|
+
/** Check if instance is online */
|
|
118
|
+
function isOnline(instance) {
|
|
119
|
+
return instance.state === InstanceState.ONLINE;
|
|
120
|
+
}
|
|
121
|
+
/** Check if instance is healthy */
|
|
122
|
+
function isHealthy(instance) {
|
|
123
|
+
return instance.state === InstanceState.ONLINE && instance.role !== InstanceRole.UNKNOWN;
|
|
124
|
+
}
|
|
125
|
+
/** Get instance count for a cluster */
|
|
126
|
+
function getInstanceCount(cluster) {
|
|
127
|
+
let count = 0;
|
|
128
|
+
if (cluster.primary)
|
|
129
|
+
count += 1;
|
|
130
|
+
count += cluster.replicas.length;
|
|
131
|
+
return count;
|
|
132
|
+
}
|
|
133
|
+
/** Get healthy instance count for a cluster */
|
|
134
|
+
function getHealthyCount(cluster) {
|
|
135
|
+
let count = 0;
|
|
136
|
+
if (cluster.primary && isHealthy(cluster.primary))
|
|
137
|
+
count += 1;
|
|
138
|
+
count += cluster.replicas.filter(isHealthy).length;
|
|
139
|
+
return count;
|
|
140
|
+
}
|
|
141
|
+
/** Get overall cluster health status */
|
|
142
|
+
function getClusterHealthStatus(cluster) {
|
|
143
|
+
const instanceCount = getInstanceCount(cluster);
|
|
144
|
+
if (instanceCount === 0)
|
|
145
|
+
return HealthStatus.UNKNOWN;
|
|
146
|
+
const healthyRatio = getHealthyCount(cluster) / instanceCount;
|
|
147
|
+
if (healthyRatio >= 1.0)
|
|
148
|
+
return HealthStatus.HEALTHY;
|
|
149
|
+
if (healthyRatio >= 0.5)
|
|
150
|
+
return HealthStatus.DEGRADED;
|
|
151
|
+
return HealthStatus.UNHEALTHY;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAgKH,4CAEC;AAGD,kDAkBC;AAGD,gDAcC;AAGD,8BAEC;AAGD,8BAEC;AAGD,4BAEC;AAGD,8BAEC;AAGD,4CAKC;AAGD,0CAKC;AAGD,wDASC;AAtPD,gFAAgF;AAChF,QAAQ;AACR,gFAAgF;AAEhF,yCAAyC;AACzC,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;AACrB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,uCAAuC;AACvC,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,0CAAyB,CAAA;IACzB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB;AA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CAAC,OAAqB;IACpD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,OAAO,CAAC,OAAO;QAAE,KAAK,IAAI,CAAC,CAAC;IAChC,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACjC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+CAA+C;AAC/C,SAAgB,eAAe,CAAC,OAAqB;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,KAAK,IAAI,CAAC,CAAC;IAC9D,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,wCAAwC;AACxC,SAAgB,sBAAsB,CAAC,OAAqB;IAC1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,aAAa,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC;IAErD,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC;IAE9D,IAAI,YAAY,IAAI,GAAG;QAAE,OAAO,YAAY,CAAC,OAAO,CAAC;IACrD,IAAI,YAAY,IAAI,GAAG;QAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;IACtD,OAAO,YAAY,CAAC,SAAS,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawSQL - Database Utility
|
|
3
|
+
*
|
|
4
|
+
* MySQL database connection for metadata storage.
|
|
5
|
+
* Shared with Orchestrator - extends Orchestrator's schema with ClawSQL-specific tables.
|
|
6
|
+
*/
|
|
7
|
+
import mysql from 'mysql2/promise';
|
|
8
|
+
/**
|
|
9
|
+
* MySQL connection pool
|
|
10
|
+
*/
|
|
11
|
+
export type MySQLConnection = mysql.Pool;
|
|
12
|
+
/**
|
|
13
|
+
* Database manager for MySQL metadata storage
|
|
14
|
+
*/
|
|
15
|
+
export declare class DatabaseManager {
|
|
16
|
+
private pool;
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the database connection
|
|
19
|
+
*/
|
|
20
|
+
connect(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Initialize ClawSQL-specific tables
|
|
23
|
+
* Note: Orchestrator creates its own tables automatically
|
|
24
|
+
*/
|
|
25
|
+
private initializeSchema;
|
|
26
|
+
/**
|
|
27
|
+
* Execute a query and return results
|
|
28
|
+
*/
|
|
29
|
+
query<T = unknown>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Execute a statement (INSERT, UPDATE, DELETE)
|
|
32
|
+
*/
|
|
33
|
+
execute(sql: string, params?: unknown[]): Promise<{
|
|
34
|
+
changes: number;
|
|
35
|
+
lastId: unknown;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a single row
|
|
39
|
+
*/
|
|
40
|
+
get<T = unknown>(sql: string, params?: unknown[]): Promise<T | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Get a connection from the pool for transactions
|
|
43
|
+
*/
|
|
44
|
+
getConnection(): Promise<mysql.PoolConnection>;
|
|
45
|
+
/**
|
|
46
|
+
* Close the database connection
|
|
47
|
+
*/
|
|
48
|
+
close(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Check if connected
|
|
51
|
+
*/
|
|
52
|
+
isConnected(): boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the database manager instance
|
|
56
|
+
*/
|
|
57
|
+
export declare function getDatabase(): DatabaseManager;
|
|
58
|
+
/**
|
|
59
|
+
* Initialize database connection
|
|
60
|
+
*/
|
|
61
|
+
export declare function initDatabase(): Promise<DatabaseManager>;
|
|
62
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,gBAAgB,CAAC;AAMnC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC;AAEzC;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,IAAI,CAAgC;IAE5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC9B;;;OAGG;YACW,gBAAgB;IA4H9B;;OAEG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAS3E;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAUjG;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAUnF;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC;IAOpD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;OAEG;IACH,WAAW,IAAI,OAAO;CAGvB;AAKD;;GAEG;AACH,wBAAgB,WAAW,IAAI,eAAe,CAK7C;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC,CAM7D"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ClawSQL - Database Utility
|
|
4
|
+
*
|
|
5
|
+
* MySQL database connection for metadata storage.
|
|
6
|
+
* Shared with Orchestrator - extends Orchestrator's schema with ClawSQL-specific tables.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DatabaseManager = void 0;
|
|
13
|
+
exports.getDatabase = getDatabase;
|
|
14
|
+
exports.initDatabase = initDatabase;
|
|
15
|
+
const promise_1 = __importDefault(require("mysql2/promise"));
|
|
16
|
+
const settings_js_1 = require("../config/settings.js");
|
|
17
|
+
const logger_js_1 = require("./logger.js");
|
|
18
|
+
const logger = (0, logger_js_1.getLogger)('database');
|
|
19
|
+
/**
|
|
20
|
+
* Database manager for MySQL metadata storage
|
|
21
|
+
*/
|
|
22
|
+
class DatabaseManager {
|
|
23
|
+
pool = null;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the database connection
|
|
26
|
+
*/
|
|
27
|
+
async connect() {
|
|
28
|
+
const settings = (0, settings_js_1.getSettings)();
|
|
29
|
+
const metadataDb = settings.metadataDb;
|
|
30
|
+
const host = metadataDb.host || 'metadata-mysql';
|
|
31
|
+
logger.info({ host, port: metadataDb.port, database: metadataDb.name }, 'Connecting to MySQL metadata database');
|
|
32
|
+
this.pool = promise_1.default.createPool({
|
|
33
|
+
host,
|
|
34
|
+
port: metadataDb.port,
|
|
35
|
+
database: metadataDb.name,
|
|
36
|
+
user: metadataDb.user,
|
|
37
|
+
password: metadataDb.password,
|
|
38
|
+
connectionLimit: metadataDb.poolSize,
|
|
39
|
+
waitForConnections: true,
|
|
40
|
+
});
|
|
41
|
+
// Test connection
|
|
42
|
+
const conn = await this.pool.getConnection();
|
|
43
|
+
await conn.ping();
|
|
44
|
+
conn.release();
|
|
45
|
+
logger.info('MySQL connection established');
|
|
46
|
+
// Initialize ClawSQL-specific tables
|
|
47
|
+
await this.initializeSchema();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initialize ClawSQL-specific tables
|
|
51
|
+
* Note: Orchestrator creates its own tables automatically
|
|
52
|
+
*/
|
|
53
|
+
async initializeSchema() {
|
|
54
|
+
const schema = `
|
|
55
|
+
-- Alerts table for ClawSQL alerting
|
|
56
|
+
CREATE TABLE IF NOT EXISTS alerts (
|
|
57
|
+
alert_id VARCHAR(36) PRIMARY KEY,
|
|
58
|
+
severity ENUM('info', 'warning', 'critical') NOT NULL,
|
|
59
|
+
instance_id VARCHAR(128),
|
|
60
|
+
cluster_id VARCHAR(128),
|
|
61
|
+
message TEXT NOT NULL,
|
|
62
|
+
details JSON,
|
|
63
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
64
|
+
acknowledged BOOLEAN DEFAULT FALSE,
|
|
65
|
+
acknowledged_at TIMESTAMP NULL,
|
|
66
|
+
acknowledged_by VARCHAR(128),
|
|
67
|
+
INDEX idx_alerts_severity (severity),
|
|
68
|
+
INDEX idx_alerts_instance (instance_id),
|
|
69
|
+
INDEX idx_alerts_cluster (cluster_id),
|
|
70
|
+
INDEX idx_alerts_created (created_at)
|
|
71
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
72
|
+
|
|
73
|
+
-- Schema metadata for NL2SQL processing
|
|
74
|
+
CREATE TABLE IF NOT EXISTS schema_metadata (
|
|
75
|
+
schema_id VARCHAR(36) PRIMARY KEY,
|
|
76
|
+
instance_id VARCHAR(128) NOT NULL,
|
|
77
|
+
database_name VARCHAR(64) NOT NULL,
|
|
78
|
+
table_name VARCHAR(64) NOT NULL,
|
|
79
|
+
column_name VARCHAR(64),
|
|
80
|
+
column_type VARCHAR(64),
|
|
81
|
+
is_nullable BOOLEAN,
|
|
82
|
+
column_comment TEXT,
|
|
83
|
+
table_comment TEXT,
|
|
84
|
+
sample_values JSON,
|
|
85
|
+
business_context TEXT,
|
|
86
|
+
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
87
|
+
UNIQUE KEY uk_schema (instance_id, database_name, table_name, column_name),
|
|
88
|
+
INDEX idx_schema_instance (instance_id),
|
|
89
|
+
INDEX idx_schema_database (database_name),
|
|
90
|
+
INDEX idx_schema_table (table_name)
|
|
91
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
92
|
+
|
|
93
|
+
-- Instance metadata (labels, extra fields extending Orchestrator's database_instance)
|
|
94
|
+
CREATE TABLE IF NOT EXISTS instance_metadata (
|
|
95
|
+
instance_id VARCHAR(128) PRIMARY KEY,
|
|
96
|
+
labels JSON DEFAULT ('{}'),
|
|
97
|
+
extra JSON DEFAULT ('{}'),
|
|
98
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
99
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
100
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
101
|
+
|
|
102
|
+
-- Configuration snapshots for version control
|
|
103
|
+
CREATE TABLE IF NOT EXISTS config_snapshots (
|
|
104
|
+
snapshot_id VARCHAR(36) PRIMARY KEY,
|
|
105
|
+
config_type VARCHAR(64) NOT NULL,
|
|
106
|
+
config_data JSON NOT NULL,
|
|
107
|
+
version VARCHAR(64) NOT NULL,
|
|
108
|
+
description TEXT,
|
|
109
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
110
|
+
created_by VARCHAR(128),
|
|
111
|
+
INDEX idx_config_type (config_type),
|
|
112
|
+
INDEX idx_config_version (version)
|
|
113
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
114
|
+
|
|
115
|
+
-- ProxySQL server configuration mirror
|
|
116
|
+
CREATE TABLE IF NOT EXISTS proxysql_servers (
|
|
117
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
118
|
+
hostgroup_id INT NOT NULL,
|
|
119
|
+
hostname VARCHAR(255) NOT NULL,
|
|
120
|
+
port INT NOT NULL,
|
|
121
|
+
status ENUM('ONLINE', 'OFFLINE_SOFT', 'OFFLINE_HARD') DEFAULT 'ONLINE',
|
|
122
|
+
weight INT DEFAULT 1,
|
|
123
|
+
max_connections INT DEFAULT 1000,
|
|
124
|
+
max_replication_lag INT DEFAULT 0,
|
|
125
|
+
use_ssl TINYINT DEFAULT 0,
|
|
126
|
+
comment VARCHAR(255),
|
|
127
|
+
synced_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
128
|
+
UNIQUE KEY uk_server (hostgroup_id, hostname, port),
|
|
129
|
+
INDEX idx_hostgroup (hostgroup_id)
|
|
130
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
131
|
+
|
|
132
|
+
-- ProxySQL replication hostgroups mirror
|
|
133
|
+
CREATE TABLE IF NOT EXISTS proxysql_hostgroups (
|
|
134
|
+
writer_hostgroup INT PRIMARY KEY,
|
|
135
|
+
reader_hostgroup INT NOT NULL,
|
|
136
|
+
cluster_id VARCHAR(128),
|
|
137
|
+
comment VARCHAR(255),
|
|
138
|
+
synced_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
139
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
140
|
+
|
|
141
|
+
-- ProxySQL query rules mirror
|
|
142
|
+
CREATE TABLE IF NOT EXISTS proxysql_query_rules (
|
|
143
|
+
rule_id INT PRIMARY KEY,
|
|
144
|
+
active TINYINT DEFAULT 1,
|
|
145
|
+
match_pattern VARCHAR(2048),
|
|
146
|
+
replace_pattern VARCHAR(2048),
|
|
147
|
+
destination_hostgroup INT,
|
|
148
|
+
apply TINYINT DEFAULT 1,
|
|
149
|
+
comment VARCHAR(255),
|
|
150
|
+
synced_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
151
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
152
|
+
|
|
153
|
+
-- ProxySQL configuration change audit log
|
|
154
|
+
CREATE TABLE IF NOT EXISTS proxysql_audit_log (
|
|
155
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
156
|
+
action VARCHAR(32) NOT NULL,
|
|
157
|
+
entity_type VARCHAR(32) NOT NULL,
|
|
158
|
+
entity_id VARCHAR(128),
|
|
159
|
+
old_value JSON,
|
|
160
|
+
new_value JSON,
|
|
161
|
+
changed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
162
|
+
changed_by VARCHAR(128),
|
|
163
|
+
INDEX idx_audit_action (action),
|
|
164
|
+
INDEX idx_audit_entity (entity_type, entity_id),
|
|
165
|
+
INDEX idx_audit_time (changed_at)
|
|
166
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
167
|
+
`;
|
|
168
|
+
const statements = schema.split(';').filter(s => s.trim());
|
|
169
|
+
for (const statement of statements) {
|
|
170
|
+
await this.pool.execute(statement);
|
|
171
|
+
}
|
|
172
|
+
logger.info('ClawSQL schema initialized');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Execute a query and return results
|
|
176
|
+
*/
|
|
177
|
+
async query(sql, params = []) {
|
|
178
|
+
if (!this.pool) {
|
|
179
|
+
throw new Error('Database not connected');
|
|
180
|
+
}
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
+
const [rows] = await this.pool.execute(sql, params);
|
|
183
|
+
return rows;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Execute a statement (INSERT, UPDATE, DELETE)
|
|
187
|
+
*/
|
|
188
|
+
async execute(sql, params = []) {
|
|
189
|
+
if (!this.pool) {
|
|
190
|
+
throw new Error('Database not connected');
|
|
191
|
+
}
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
193
|
+
const [result] = await this.pool.execute(sql, params);
|
|
194
|
+
const r = result;
|
|
195
|
+
return { changes: r.affectedRows, lastId: r.insertId };
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get a single row
|
|
199
|
+
*/
|
|
200
|
+
async get(sql, params = []) {
|
|
201
|
+
if (!this.pool) {
|
|
202
|
+
throw new Error('Database not connected');
|
|
203
|
+
}
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
+
const [rows] = await this.pool.execute(sql, params);
|
|
206
|
+
const r = rows;
|
|
207
|
+
return r[0];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get a connection from the pool for transactions
|
|
211
|
+
*/
|
|
212
|
+
async getConnection() {
|
|
213
|
+
if (!this.pool) {
|
|
214
|
+
throw new Error('Database not connected');
|
|
215
|
+
}
|
|
216
|
+
return this.pool.getConnection();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Close the database connection
|
|
220
|
+
*/
|
|
221
|
+
async close() {
|
|
222
|
+
if (this.pool) {
|
|
223
|
+
await this.pool.end();
|
|
224
|
+
this.pool = null;
|
|
225
|
+
logger.info('MySQL connection closed');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Check if connected
|
|
230
|
+
*/
|
|
231
|
+
isConnected() {
|
|
232
|
+
return this.pool !== null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.DatabaseManager = DatabaseManager;
|
|
236
|
+
// Singleton instance
|
|
237
|
+
let dbManager = null;
|
|
238
|
+
/**
|
|
239
|
+
* Get the database manager instance
|
|
240
|
+
*/
|
|
241
|
+
function getDatabase() {
|
|
242
|
+
if (!dbManager) {
|
|
243
|
+
dbManager = new DatabaseManager();
|
|
244
|
+
}
|
|
245
|
+
return dbManager;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Initialize database connection
|
|
249
|
+
*/
|
|
250
|
+
async function initDatabase() {
|
|
251
|
+
const db = getDatabase();
|
|
252
|
+
if (!db.isConnected()) {
|
|
253
|
+
await db.connect();
|
|
254
|
+
}
|
|
255
|
+
return db;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AA+PH,kCAKC;AAKD,oCAMC;AA7QD,6DAAmC;AACnC,uDAAoD;AACpD,2CAAwC;AAExC,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,UAAU,CAAC,CAAC;AAOrC;;GAEG;AACH,MAAa,eAAe;IAClB,IAAI,GAA2B,IAAI,CAAC;IAE5C;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QAEvC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,gBAAgB,CAAC;QAEjD,MAAM,CAAC,IAAI,CACT,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1D,uCAAuC,CACxC,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,iBAAK,CAAC,UAAU,CAAC;YAC3B,IAAI;YACJ,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,QAAQ,EAAE,UAAU,CAAC,IAAI;YACzB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,eAAe,EAAE,UAAU,CAAC,QAAQ;YACpC,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;QAEH,kBAAkB;QAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,IAA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IAAI,CAAC;AAE7C;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;QACtB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawSQL - Custom Exceptions
|
|
3
|
+
*
|
|
4
|
+
* Custom error classes for ClawSQL.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base ClawSQL error class
|
|
8
|
+
*/
|
|
9
|
+
export declare class ClawSQLError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly details: Record<string, unknown>;
|
|
12
|
+
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
13
|
+
toJSON(): Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Validation error
|
|
17
|
+
*/
|
|
18
|
+
export declare class ValidationError extends ClawSQLError {
|
|
19
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Not found error
|
|
23
|
+
*/
|
|
24
|
+
export declare class NotFoundError extends ClawSQLError {
|
|
25
|
+
constructor(resource: string, identifier: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Already exists error
|
|
29
|
+
*/
|
|
30
|
+
export declare class AlreadyExistsError extends ClawSQLError {
|
|
31
|
+
constructor(resource: string, identifier: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Connection error
|
|
35
|
+
*/
|
|
36
|
+
export declare class ConnectionError extends ClawSQLError {
|
|
37
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Orchestrator error
|
|
41
|
+
*/
|
|
42
|
+
export declare class OrchestratorError extends ClawSQLError {
|
|
43
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ProxySQL error
|
|
47
|
+
*/
|
|
48
|
+
export declare class ProxySQLError extends ClawSQLError {
|
|
49
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Failover error
|
|
53
|
+
*/
|
|
54
|
+
export declare class FailoverError extends ClawSQLError {
|
|
55
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Authentication error
|
|
59
|
+
*/
|
|
60
|
+
export declare class AuthenticationError extends ClawSQLError {
|
|
61
|
+
constructor(message?: string);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Authorization error
|
|
65
|
+
*/
|
|
66
|
+
export declare class AuthorizationError extends ClawSQLError {
|
|
67
|
+
constructor(message?: string);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/utils/exceptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAG/C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IASvC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOlC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAInE;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,YAAY;gBACjC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAIjD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAIjD;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAInE;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;gBACrC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAInE;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,YAAY;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAInE;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,YAAY;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAInE;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,OAAO,GAAE,MAAgC;CAItD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,GAAE,MAAwB;CAI9C"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ClawSQL - Custom Exceptions
|
|
4
|
+
*
|
|
5
|
+
* Custom error classes for ClawSQL.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AuthorizationError = exports.AuthenticationError = exports.FailoverError = exports.ProxySQLError = exports.OrchestratorError = exports.ConnectionError = exports.AlreadyExistsError = exports.NotFoundError = exports.ValidationError = exports.ClawSQLError = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Base ClawSQL error class
|
|
11
|
+
*/
|
|
12
|
+
class ClawSQLError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
details;
|
|
15
|
+
constructor(code, message, details = {}) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'ClawSQLError';
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.details = details;
|
|
20
|
+
Error.captureStackTrace(this, this.constructor);
|
|
21
|
+
}
|
|
22
|
+
toJSON() {
|
|
23
|
+
return {
|
|
24
|
+
error: this.code,
|
|
25
|
+
message: this.message,
|
|
26
|
+
details: this.details,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ClawSQLError = ClawSQLError;
|
|
31
|
+
/**
|
|
32
|
+
* Validation error
|
|
33
|
+
*/
|
|
34
|
+
class ValidationError extends ClawSQLError {
|
|
35
|
+
constructor(message, details = {}) {
|
|
36
|
+
super('VALIDATION_ERROR', message, details);
|
|
37
|
+
this.name = 'ValidationError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ValidationError = ValidationError;
|
|
41
|
+
/**
|
|
42
|
+
* Not found error
|
|
43
|
+
*/
|
|
44
|
+
class NotFoundError extends ClawSQLError {
|
|
45
|
+
constructor(resource, identifier) {
|
|
46
|
+
super('NOT_FOUND', `${resource} not found: ${identifier}`, { resource, identifier });
|
|
47
|
+
this.name = 'NotFoundError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.NotFoundError = NotFoundError;
|
|
51
|
+
/**
|
|
52
|
+
* Already exists error
|
|
53
|
+
*/
|
|
54
|
+
class AlreadyExistsError extends ClawSQLError {
|
|
55
|
+
constructor(resource, identifier) {
|
|
56
|
+
super('ALREADY_EXISTS', `${resource} already exists: ${identifier}`, { resource, identifier });
|
|
57
|
+
this.name = 'AlreadyExistsError';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.AlreadyExistsError = AlreadyExistsError;
|
|
61
|
+
/**
|
|
62
|
+
* Connection error
|
|
63
|
+
*/
|
|
64
|
+
class ConnectionError extends ClawSQLError {
|
|
65
|
+
constructor(message, details = {}) {
|
|
66
|
+
super('CONNECTION_ERROR', message, details);
|
|
67
|
+
this.name = 'ConnectionError';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ConnectionError = ConnectionError;
|
|
71
|
+
/**
|
|
72
|
+
* Orchestrator error
|
|
73
|
+
*/
|
|
74
|
+
class OrchestratorError extends ClawSQLError {
|
|
75
|
+
constructor(message, details = {}) {
|
|
76
|
+
super('ORCHESTRATOR_ERROR', message, details);
|
|
77
|
+
this.name = 'OrchestratorError';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.OrchestratorError = OrchestratorError;
|
|
81
|
+
/**
|
|
82
|
+
* ProxySQL error
|
|
83
|
+
*/
|
|
84
|
+
class ProxySQLError extends ClawSQLError {
|
|
85
|
+
constructor(message, details = {}) {
|
|
86
|
+
super('PROXYSQL_ERROR', message, details);
|
|
87
|
+
this.name = 'ProxySQLError';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ProxySQLError = ProxySQLError;
|
|
91
|
+
/**
|
|
92
|
+
* Failover error
|
|
93
|
+
*/
|
|
94
|
+
class FailoverError extends ClawSQLError {
|
|
95
|
+
constructor(message, details = {}) {
|
|
96
|
+
super('FAILOVER_ERROR', message, details);
|
|
97
|
+
this.name = 'FailoverError';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.FailoverError = FailoverError;
|
|
101
|
+
/**
|
|
102
|
+
* Authentication error
|
|
103
|
+
*/
|
|
104
|
+
class AuthenticationError extends ClawSQLError {
|
|
105
|
+
constructor(message = 'Authentication failed') {
|
|
106
|
+
super('AUTHENTICATION_ERROR', message, {});
|
|
107
|
+
this.name = 'AuthenticationError';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.AuthenticationError = AuthenticationError;
|
|
111
|
+
/**
|
|
112
|
+
* Authorization error
|
|
113
|
+
*/
|
|
114
|
+
class AuthorizationError extends ClawSQLError {
|
|
115
|
+
constructor(message = 'Access denied') {
|
|
116
|
+
super('AUTHORIZATION_ERROR', message, {});
|
|
117
|
+
this.name = 'AuthorizationError';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.AuthorizationError = AuthorizationError;
|
|
121
|
+
//# sourceMappingURL=exceptions.js.map
|