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.
Files changed (311) hide show
  1. package/.env.example +97 -0
  2. package/README.md +372 -0
  3. package/dist/__tests__/config/settings.test.d.ts +5 -0
  4. package/dist/__tests__/config/settings.test.d.ts.map +1 -0
  5. package/dist/__tests__/config/settings.test.js +154 -0
  6. package/dist/__tests__/config/settings.test.js.map +1 -0
  7. package/dist/__tests__/core/discovery/topology.test.d.ts +5 -0
  8. package/dist/__tests__/core/discovery/topology.test.d.ts.map +1 -0
  9. package/dist/__tests__/core/discovery/topology.test.js +191 -0
  10. package/dist/__tests__/core/discovery/topology.test.js.map +1 -0
  11. package/dist/__tests__/core/failover/executor.test.d.ts +5 -0
  12. package/dist/__tests__/core/failover/executor.test.d.ts.map +1 -0
  13. package/dist/__tests__/core/failover/executor.test.js +256 -0
  14. package/dist/__tests__/core/failover/executor.test.js.map +1 -0
  15. package/dist/__tests__/core/monitoring/collector.test.d.ts +5 -0
  16. package/dist/__tests__/core/monitoring/collector.test.d.ts.map +1 -0
  17. package/dist/__tests__/core/monitoring/collector.test.js +131 -0
  18. package/dist/__tests__/core/monitoring/collector.test.js.map +1 -0
  19. package/dist/__tests__/core/monitoring/exporters.test.d.ts +5 -0
  20. package/dist/__tests__/core/monitoring/exporters.test.d.ts.map +1 -0
  21. package/dist/__tests__/core/monitoring/exporters.test.js +90 -0
  22. package/dist/__tests__/core/monitoring/exporters.test.js.map +1 -0
  23. package/dist/__tests__/core/routing/proxysql-manager.test.d.ts +5 -0
  24. package/dist/__tests__/core/routing/proxysql-manager.test.d.ts.map +1 -0
  25. package/dist/__tests__/core/routing/proxysql-manager.test.js +155 -0
  26. package/dist/__tests__/core/routing/proxysql-manager.test.js.map +1 -0
  27. package/dist/__tests__/types/index.test.d.ts +5 -0
  28. package/dist/__tests__/types/index.test.d.ts.map +1 -0
  29. package/dist/__tests__/types/index.test.js +290 -0
  30. package/dist/__tests__/types/index.test.js.map +1 -0
  31. package/dist/__tests__/utils/exceptions.test.d.ts +5 -0
  32. package/dist/__tests__/utils/exceptions.test.d.ts.map +1 -0
  33. package/dist/__tests__/utils/exceptions.test.js +142 -0
  34. package/dist/__tests__/utils/exceptions.test.js.map +1 -0
  35. package/dist/api/routes/clusters.d.ts +7 -0
  36. package/dist/api/routes/clusters.d.ts.map +1 -0
  37. package/dist/api/routes/clusters.js +123 -0
  38. package/dist/api/routes/clusters.js.map +1 -0
  39. package/dist/api/routes/config.d.ts +7 -0
  40. package/dist/api/routes/config.d.ts.map +1 -0
  41. package/dist/api/routes/config.js +65 -0
  42. package/dist/api/routes/config.js.map +1 -0
  43. package/dist/api/routes/failover.d.ts +7 -0
  44. package/dist/api/routes/failover.d.ts.map +1 -0
  45. package/dist/api/routes/failover.js +100 -0
  46. package/dist/api/routes/failover.js.map +1 -0
  47. package/dist/api/routes/instances.d.ts +11 -0
  48. package/dist/api/routes/instances.d.ts.map +1 -0
  49. package/dist/api/routes/instances.js +315 -0
  50. package/dist/api/routes/instances.js.map +1 -0
  51. package/dist/api/routes/monitoring.d.ts +7 -0
  52. package/dist/api/routes/monitoring.d.ts.map +1 -0
  53. package/dist/api/routes/monitoring.js +72 -0
  54. package/dist/api/routes/monitoring.js.map +1 -0
  55. package/dist/api/routes/webhooks.d.ts +12 -0
  56. package/dist/api/routes/webhooks.d.ts.map +1 -0
  57. package/dist/api/routes/webhooks.js +232 -0
  58. package/dist/api/routes/webhooks.js.map +1 -0
  59. package/dist/api/schemas/index.d.ts +965 -0
  60. package/dist/api/schemas/index.d.ts.map +1 -0
  61. package/dist/api/schemas/index.js +171 -0
  62. package/dist/api/schemas/index.js.map +1 -0
  63. package/dist/app.d.ts +13 -0
  64. package/dist/app.d.ts.map +1 -0
  65. package/dist/app.js +197 -0
  66. package/dist/app.js.map +1 -0
  67. package/dist/bin/clawsql.d.ts +12 -0
  68. package/dist/bin/clawsql.d.ts.map +1 -0
  69. package/dist/bin/clawsql.js +43 -0
  70. package/dist/bin/clawsql.js.map +1 -0
  71. package/dist/cli/agent/handler.d.ts +73 -0
  72. package/dist/cli/agent/handler.d.ts.map +1 -0
  73. package/dist/cli/agent/handler.js +258 -0
  74. package/dist/cli/agent/handler.js.map +1 -0
  75. package/dist/cli/agent/index.d.ts +14 -0
  76. package/dist/cli/agent/index.d.ts.map +1 -0
  77. package/dist/cli/agent/index.js +30 -0
  78. package/dist/cli/agent/index.js.map +1 -0
  79. package/dist/cli/agent/openclaw-integration.d.ts +81 -0
  80. package/dist/cli/agent/openclaw-integration.d.ts.map +1 -0
  81. package/dist/cli/agent/openclaw-integration.js +341 -0
  82. package/dist/cli/agent/openclaw-integration.js.map +1 -0
  83. package/dist/cli/agent/providers/anthropic.d.ts +27 -0
  84. package/dist/cli/agent/providers/anthropic.d.ts.map +1 -0
  85. package/dist/cli/agent/providers/anthropic.js +106 -0
  86. package/dist/cli/agent/providers/anthropic.js.map +1 -0
  87. package/dist/cli/agent/providers/base.d.ts +91 -0
  88. package/dist/cli/agent/providers/base.d.ts.map +1 -0
  89. package/dist/cli/agent/providers/base.js +24 -0
  90. package/dist/cli/agent/providers/base.js.map +1 -0
  91. package/dist/cli/agent/providers/openai.d.ts +27 -0
  92. package/dist/cli/agent/providers/openai.d.ts.map +1 -0
  93. package/dist/cli/agent/providers/openai.js +98 -0
  94. package/dist/cli/agent/providers/openai.js.map +1 -0
  95. package/dist/cli/agent/tools/index.d.ts +32 -0
  96. package/dist/cli/agent/tools/index.d.ts.map +1 -0
  97. package/dist/cli/agent/tools/index.js +263 -0
  98. package/dist/cli/agent/tools/index.js.map +1 -0
  99. package/dist/cli/commands/cleanup.d.ts +12 -0
  100. package/dist/cli/commands/cleanup.d.ts.map +1 -0
  101. package/dist/cli/commands/cleanup.js +205 -0
  102. package/dist/cli/commands/cleanup.js.map +1 -0
  103. package/dist/cli/commands/clusters.d.ts +12 -0
  104. package/dist/cli/commands/clusters.d.ts.map +1 -0
  105. package/dist/cli/commands/clusters.js +468 -0
  106. package/dist/cli/commands/clusters.js.map +1 -0
  107. package/dist/cli/commands/config.d.ts +12 -0
  108. package/dist/cli/commands/config.d.ts.map +1 -0
  109. package/dist/cli/commands/config.js +406 -0
  110. package/dist/cli/commands/config.js.map +1 -0
  111. package/dist/cli/commands/cron.d.ts +12 -0
  112. package/dist/cli/commands/cron.d.ts.map +1 -0
  113. package/dist/cli/commands/cron.js +215 -0
  114. package/dist/cli/commands/cron.js.map +1 -0
  115. package/dist/cli/commands/doctor.d.ts +13 -0
  116. package/dist/cli/commands/doctor.d.ts.map +1 -0
  117. package/dist/cli/commands/doctor.js +687 -0
  118. package/dist/cli/commands/doctor.js.map +1 -0
  119. package/dist/cli/commands/failover.d.ts +16 -0
  120. package/dist/cli/commands/failover.d.ts.map +1 -0
  121. package/dist/cli/commands/failover.js +333 -0
  122. package/dist/cli/commands/failover.js.map +1 -0
  123. package/dist/cli/commands/health.d.ts +12 -0
  124. package/dist/cli/commands/health.d.ts.map +1 -0
  125. package/dist/cli/commands/health.js +125 -0
  126. package/dist/cli/commands/health.js.map +1 -0
  127. package/dist/cli/commands/help.d.ts +12 -0
  128. package/dist/cli/commands/help.d.ts.map +1 -0
  129. package/dist/cli/commands/help.js +52 -0
  130. package/dist/cli/commands/help.js.map +1 -0
  131. package/dist/cli/commands/instances.d.ts +12 -0
  132. package/dist/cli/commands/instances.d.ts.map +1 -0
  133. package/dist/cli/commands/instances.js +801 -0
  134. package/dist/cli/commands/instances.js.map +1 -0
  135. package/dist/cli/commands/notify.d.ts +12 -0
  136. package/dist/cli/commands/notify.d.ts.map +1 -0
  137. package/dist/cli/commands/notify.js +43 -0
  138. package/dist/cli/commands/notify.js.map +1 -0
  139. package/dist/cli/commands/sql.d.ts +12 -0
  140. package/dist/cli/commands/sql.d.ts.map +1 -0
  141. package/dist/cli/commands/sql.js +90 -0
  142. package/dist/cli/commands/sql.js.map +1 -0
  143. package/dist/cli/commands/start.d.ts +12 -0
  144. package/dist/cli/commands/start.d.ts.map +1 -0
  145. package/dist/cli/commands/start.js +174 -0
  146. package/dist/cli/commands/start.js.map +1 -0
  147. package/dist/cli/commands/status.d.ts +12 -0
  148. package/dist/cli/commands/status.d.ts.map +1 -0
  149. package/dist/cli/commands/status.js +218 -0
  150. package/dist/cli/commands/status.js.map +1 -0
  151. package/dist/cli/commands/stop.d.ts +12 -0
  152. package/dist/cli/commands/stop.d.ts.map +1 -0
  153. package/dist/cli/commands/stop.js +128 -0
  154. package/dist/cli/commands/stop.js.map +1 -0
  155. package/dist/cli/commands/topology.d.ts +12 -0
  156. package/dist/cli/commands/topology.d.ts.map +1 -0
  157. package/dist/cli/commands/topology.js +106 -0
  158. package/dist/cli/commands/topology.js.map +1 -0
  159. package/dist/cli/completer.d.ts +47 -0
  160. package/dist/cli/completer.d.ts.map +1 -0
  161. package/dist/cli/completer.js +332 -0
  162. package/dist/cli/completer.js.map +1 -0
  163. package/dist/cli/formatter.d.ts +165 -0
  164. package/dist/cli/formatter.d.ts.map +1 -0
  165. package/dist/cli/formatter.js +408 -0
  166. package/dist/cli/formatter.js.map +1 -0
  167. package/dist/cli/index.d.ts +21 -0
  168. package/dist/cli/index.d.ts.map +1 -0
  169. package/dist/cli/index.js +79 -0
  170. package/dist/cli/index.js.map +1 -0
  171. package/dist/cli/raw-input.d.ts +97 -0
  172. package/dist/cli/raw-input.d.ts.map +1 -0
  173. package/dist/cli/raw-input.js +493 -0
  174. package/dist/cli/raw-input.js.map +1 -0
  175. package/dist/cli/registry.d.ts +103 -0
  176. package/dist/cli/registry.d.ts.map +1 -0
  177. package/dist/cli/registry.js +205 -0
  178. package/dist/cli/registry.js.map +1 -0
  179. package/dist/cli/repl.d.ts +83 -0
  180. package/dist/cli/repl.d.ts.map +1 -0
  181. package/dist/cli/repl.js +447 -0
  182. package/dist/cli/repl.js.map +1 -0
  183. package/dist/cli/ui/components.d.ts +144 -0
  184. package/dist/cli/ui/components.d.ts.map +1 -0
  185. package/dist/cli/ui/components.js +331 -0
  186. package/dist/cli/ui/components.js.map +1 -0
  187. package/dist/cli/ui/index.d.ts +7 -0
  188. package/dist/cli/ui/index.d.ts.map +1 -0
  189. package/dist/cli/ui/index.js +23 -0
  190. package/dist/cli/ui/index.js.map +1 -0
  191. package/dist/cli/utils/docker-files.d.ts +39 -0
  192. package/dist/cli/utils/docker-files.d.ts.map +1 -0
  193. package/dist/cli/utils/docker-files.js +223 -0
  194. package/dist/cli/utils/docker-files.js.map +1 -0
  195. package/dist/cli/utils/docker-prereq.d.ts +48 -0
  196. package/dist/cli/utils/docker-prereq.d.ts.map +1 -0
  197. package/dist/cli/utils/docker-prereq.js +203 -0
  198. package/dist/cli/utils/docker-prereq.js.map +1 -0
  199. package/dist/config/settings.d.ts +594 -0
  200. package/dist/config/settings.d.ts.map +1 -0
  201. package/dist/config/settings.js +250 -0
  202. package/dist/config/settings.js.map +1 -0
  203. package/dist/core/discovery/cluster-view.d.ts +50 -0
  204. package/dist/core/discovery/cluster-view.d.ts.map +1 -0
  205. package/dist/core/discovery/cluster-view.js +235 -0
  206. package/dist/core/discovery/cluster-view.js.map +1 -0
  207. package/dist/core/discovery/scanner.d.ts +70 -0
  208. package/dist/core/discovery/scanner.d.ts.map +1 -0
  209. package/dist/core/discovery/scanner.js +197 -0
  210. package/dist/core/discovery/scanner.js.map +1 -0
  211. package/dist/core/discovery/topology.d.ts +118 -0
  212. package/dist/core/discovery/topology.d.ts.map +1 -0
  213. package/dist/core/discovery/topology.js +550 -0
  214. package/dist/core/discovery/topology.js.map +1 -0
  215. package/dist/core/failover/candidate-selector.d.ts +46 -0
  216. package/dist/core/failover/candidate-selector.d.ts.map +1 -0
  217. package/dist/core/failover/candidate-selector.js +70 -0
  218. package/dist/core/failover/candidate-selector.js.map +1 -0
  219. package/dist/core/failover/executor.d.ts +104 -0
  220. package/dist/core/failover/executor.d.ts.map +1 -0
  221. package/dist/core/failover/executor.js +248 -0
  222. package/dist/core/failover/executor.js.map +1 -0
  223. package/dist/core/failover/operation-builder.d.ts +71 -0
  224. package/dist/core/failover/operation-builder.d.ts.map +1 -0
  225. package/dist/core/failover/operation-builder.js +157 -0
  226. package/dist/core/failover/operation-builder.js.map +1 -0
  227. package/dist/core/failover/operation-runner.d.ts +75 -0
  228. package/dist/core/failover/operation-runner.d.ts.map +1 -0
  229. package/dist/core/failover/operation-runner.js +191 -0
  230. package/dist/core/failover/operation-runner.js.map +1 -0
  231. package/dist/core/failover/promoter.d.ts +33 -0
  232. package/dist/core/failover/promoter.d.ts.map +1 -0
  233. package/dist/core/failover/promoter.js +97 -0
  234. package/dist/core/failover/promoter.js.map +1 -0
  235. package/dist/core/failover/recovery-manager.d.ts +47 -0
  236. package/dist/core/failover/recovery-manager.d.ts.map +1 -0
  237. package/dist/core/failover/recovery-manager.js +145 -0
  238. package/dist/core/failover/recovery-manager.js.map +1 -0
  239. package/dist/core/failover/types.d.ts +54 -0
  240. package/dist/core/failover/types.d.ts.map +1 -0
  241. package/dist/core/failover/types.js +8 -0
  242. package/dist/core/failover/types.js.map +1 -0
  243. package/dist/core/monitoring/collector.d.ts +25 -0
  244. package/dist/core/monitoring/collector.d.ts.map +1 -0
  245. package/dist/core/monitoring/collector.js +115 -0
  246. package/dist/core/monitoring/collector.js.map +1 -0
  247. package/dist/core/monitoring/exporters.d.ts +49 -0
  248. package/dist/core/monitoring/exporters.d.ts.map +1 -0
  249. package/dist/core/monitoring/exporters.js +126 -0
  250. package/dist/core/monitoring/exporters.js.map +1 -0
  251. package/dist/core/routing/proxysql-manager.d.ts +213 -0
  252. package/dist/core/routing/proxysql-manager.d.ts.map +1 -0
  253. package/dist/core/routing/proxysql-manager.js +632 -0
  254. package/dist/core/routing/proxysql-manager.js.map +1 -0
  255. package/dist/core/sync/replica-recovery.d.ts +40 -0
  256. package/dist/core/sync/replica-recovery.d.ts.map +1 -0
  257. package/dist/core/sync/replica-recovery.js +134 -0
  258. package/dist/core/sync/replica-recovery.js.map +1 -0
  259. package/dist/core/sync/sync-coordinator.d.ts +83 -0
  260. package/dist/core/sync/sync-coordinator.d.ts.map +1 -0
  261. package/dist/core/sync/sync-coordinator.js +254 -0
  262. package/dist/core/sync/sync-coordinator.js.map +1 -0
  263. package/dist/core/sync/topology-watcher.d.ts +76 -0
  264. package/dist/core/sync/topology-watcher.d.ts.map +1 -0
  265. package/dist/core/sync/topology-watcher.js +222 -0
  266. package/dist/core/sync/topology-watcher.js.map +1 -0
  267. package/dist/core/sync/types.d.ts +85 -0
  268. package/dist/core/sync/types.d.ts.map +1 -0
  269. package/dist/core/sync/types.js +8 -0
  270. package/dist/core/sync/types.js.map +1 -0
  271. package/dist/index.d.ts +5 -0
  272. package/dist/index.d.ts.map +1 -0
  273. package/dist/index.js +9 -0
  274. package/dist/index.js.map +1 -0
  275. package/dist/types/index.d.ts +212 -0
  276. package/dist/types/index.d.ts.map +1 -0
  277. package/dist/types/index.js +153 -0
  278. package/dist/types/index.js.map +1 -0
  279. package/dist/utils/database.d.ts +62 -0
  280. package/dist/utils/database.d.ts.map +1 -0
  281. package/dist/utils/database.js +257 -0
  282. package/dist/utils/database.js.map +1 -0
  283. package/dist/utils/exceptions.d.ts +69 -0
  284. package/dist/utils/exceptions.d.ts.map +1 -0
  285. package/dist/utils/exceptions.js +121 -0
  286. package/dist/utils/exceptions.js.map +1 -0
  287. package/dist/utils/logger.d.ts +20 -0
  288. package/dist/utils/logger.d.ts.map +1 -0
  289. package/dist/utils/logger.js +90 -0
  290. package/dist/utils/logger.js.map +1 -0
  291. package/dist/utils/mysql-client.d.ts +43 -0
  292. package/dist/utils/mysql-client.d.ts.map +1 -0
  293. package/dist/utils/mysql-client.js +125 -0
  294. package/dist/utils/mysql-client.js.map +1 -0
  295. package/docker/Dockerfile +61 -0
  296. package/docker/Dockerfile.node +41 -0
  297. package/docker/grafana/dashboards/clawsql.json +212 -0
  298. package/docker/grafana/provisioning/dashboards/dashboards.yml +13 -0
  299. package/docker/grafana/provisioning/datasources/datasources.yml +12 -0
  300. package/docker/init/primary.sql +26 -0
  301. package/docker/init/replica.sql +16 -0
  302. package/docker/orchestrator/orchestrator.conf.json +98 -0
  303. package/docker/prometheus/prometheus.yml +45 -0
  304. package/docker/proxysql/entrypoint.sh +8 -0
  305. package/docker/proxysql/init.sql.demo +30 -0
  306. package/docker/proxysql/proxysql.cnf +38 -0
  307. package/docker-compose.demo.yml +115 -0
  308. package/docker-compose.yml +217 -0
  309. package/init/primary.sql +19 -0
  310. package/init/replica.sql +13 -0
  311. package/package.json +84 -0
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /**
3
+ * Tests for ClawSQL custom exceptions
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const exceptions_1 = require("../../utils/exceptions");
7
+ describe('ClawSQLError', () => {
8
+ it('should create error with code and message', () => {
9
+ const error = new exceptions_1.ClawSQLError('TEST_ERROR', 'Test error message');
10
+ expect(error.name).toBe('ClawSQLError');
11
+ expect(error.code).toBe('TEST_ERROR');
12
+ expect(error.message).toBe('Test error message');
13
+ expect(error.details).toEqual({});
14
+ });
15
+ it('should create error with details', () => {
16
+ const details = { key: 'value', count: 42 };
17
+ const error = new exceptions_1.ClawSQLError('TEST_ERROR', 'Test message', details);
18
+ expect(error.details).toEqual(details);
19
+ });
20
+ it('should serialize to JSON correctly', () => {
21
+ const error = new exceptions_1.ClawSQLError('TEST_ERROR', 'Test message', { foo: 'bar' });
22
+ const json = error.toJSON();
23
+ expect(json).toEqual({
24
+ error: 'TEST_ERROR',
25
+ message: 'Test message',
26
+ details: { foo: 'bar' },
27
+ });
28
+ });
29
+ it('should have stack trace', () => {
30
+ const error = new exceptions_1.ClawSQLError('TEST_ERROR', 'Test message');
31
+ expect(error.stack).toBeDefined();
32
+ expect(error.stack).toContain('ClawSQLError');
33
+ });
34
+ });
35
+ describe('ValidationError', () => {
36
+ it('should create validation error', () => {
37
+ const error = new exceptions_1.ValidationError('Invalid input', { field: 'name' });
38
+ expect(error.name).toBe('ValidationError');
39
+ expect(error.code).toBe('VALIDATION_ERROR');
40
+ expect(error.message).toBe('Invalid input');
41
+ expect(error.details).toEqual({ field: 'name' });
42
+ });
43
+ });
44
+ describe('NotFoundError', () => {
45
+ it('should create not found error for resource', () => {
46
+ const error = new exceptions_1.NotFoundError('Cluster', 'cluster-123');
47
+ expect(error.name).toBe('NotFoundError');
48
+ expect(error.code).toBe('NOT_FOUND');
49
+ expect(error.message).toBe('Cluster not found: cluster-123');
50
+ expect(error.details).toEqual({ resource: 'Cluster', identifier: 'cluster-123' });
51
+ });
52
+ it('should create not found error for instance', () => {
53
+ const error = new exceptions_1.NotFoundError('Instance', 'localhost:3306');
54
+ expect(error.message).toBe('Instance not found: localhost:3306');
55
+ });
56
+ });
57
+ describe('AlreadyExistsError', () => {
58
+ it('should create already exists error', () => {
59
+ const error = new exceptions_1.AlreadyExistsError('Instance', 'localhost:3306');
60
+ expect(error.name).toBe('AlreadyExistsError');
61
+ expect(error.code).toBe('ALREADY_EXISTS');
62
+ expect(error.message).toBe('Instance already exists: localhost:3306');
63
+ expect(error.details).toEqual({ resource: 'Instance', identifier: 'localhost:3306' });
64
+ });
65
+ });
66
+ describe('ConnectionError', () => {
67
+ it('should create connection error', () => {
68
+ const error = new exceptions_1.ConnectionError('Failed to connect to database', { host: 'localhost' });
69
+ expect(error.name).toBe('ConnectionError');
70
+ expect(error.code).toBe('CONNECTION_ERROR');
71
+ expect(error.message).toBe('Failed to connect to database');
72
+ expect(error.details).toEqual({ host: 'localhost' });
73
+ });
74
+ });
75
+ describe('OrchestratorError', () => {
76
+ it('should create orchestrator error', () => {
77
+ const error = new exceptions_1.OrchestratorError('Orchestrator unreachable', { url: 'http://orchestrator:3000' });
78
+ expect(error.name).toBe('OrchestratorError');
79
+ expect(error.code).toBe('ORCHESTRATOR_ERROR');
80
+ expect(error.message).toBe('Orchestrator unreachable');
81
+ });
82
+ });
83
+ describe('ProxySQLError', () => {
84
+ it('should create proxysql error', () => {
85
+ const error = new exceptions_1.ProxySQLError('Failed to add server', { hostgroup: 10 });
86
+ expect(error.name).toBe('ProxySQLError');
87
+ expect(error.code).toBe('PROXYSQL_ERROR');
88
+ expect(error.message).toBe('Failed to add server');
89
+ });
90
+ });
91
+ describe('FailoverError', () => {
92
+ it('should create failover error', () => {
93
+ const error = new exceptions_1.FailoverError('Failover failed', { clusterId: 'cluster-1' });
94
+ expect(error.name).toBe('FailoverError');
95
+ expect(error.code).toBe('FAILOVER_ERROR');
96
+ expect(error.message).toBe('Failover failed');
97
+ });
98
+ });
99
+ describe('AuthenticationError', () => {
100
+ it('should create authentication error with default message', () => {
101
+ const error = new exceptions_1.AuthenticationError();
102
+ expect(error.name).toBe('AuthenticationError');
103
+ expect(error.code).toBe('AUTHENTICATION_ERROR');
104
+ expect(error.message).toBe('Authentication failed');
105
+ });
106
+ it('should create authentication error with custom message', () => {
107
+ const error = new exceptions_1.AuthenticationError('Invalid token');
108
+ expect(error.message).toBe('Invalid token');
109
+ });
110
+ });
111
+ describe('AuthorizationError', () => {
112
+ it('should create authorization error with default message', () => {
113
+ const error = new exceptions_1.AuthorizationError();
114
+ expect(error.name).toBe('AuthorizationError');
115
+ expect(error.code).toBe('AUTHORIZATION_ERROR');
116
+ expect(error.message).toBe('Access denied');
117
+ });
118
+ it('should create authorization error with custom message', () => {
119
+ const error = new exceptions_1.AuthorizationError('Insufficient permissions');
120
+ expect(error.message).toBe('Insufficient permissions');
121
+ });
122
+ });
123
+ describe('Error inheritance', () => {
124
+ it('all errors should be instance of ClawSQLError', () => {
125
+ const errors = [
126
+ new exceptions_1.ValidationError('test'),
127
+ new exceptions_1.NotFoundError('Resource', 'id'),
128
+ new exceptions_1.AlreadyExistsError('Resource', 'id'),
129
+ new exceptions_1.ConnectionError('test'),
130
+ new exceptions_1.OrchestratorError('test'),
131
+ new exceptions_1.ProxySQLError('test'),
132
+ new exceptions_1.FailoverError('test'),
133
+ new exceptions_1.AuthenticationError(),
134
+ new exceptions_1.AuthorizationError(),
135
+ ];
136
+ for (const error of errors) {
137
+ expect(error).toBeInstanceOf(exceptions_1.ClawSQLError);
138
+ expect(error).toBeInstanceOf(Error);
139
+ }
140
+ });
141
+ });
142
+ //# sourceMappingURL=exceptions.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.test.js","sourceRoot":"","sources":["../../../src/__tests__/utils/exceptions.test.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEH,uDAWgC;AAEhC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,IAAI,yBAAY,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;QAEnE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,IAAI,yBAAY,CAAC,YAAY,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;QAEtE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,IAAI,yBAAY,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CA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,CAAC,MAAM,CAAC;YAC7B,IAAI,0BAAa,CAAC,MAAM,CAAC;YACzB,IAAI,0BAAa,CAAC,MAAM,CAAC;YACzB,IAAI,gCAAmB,EAAE;YACzB,IAAI,+BAAkB,EAAE;SACzB,CAAC;QAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,yBAAY,CAAC,CAAC;YAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ClawSQL - Clusters API Routes
3
+ */
4
+ import { FastifyPluginAsync } from 'fastify';
5
+ declare const clustersRoutes: FastifyPluginAsync;
6
+ export default clustersRoutes;
7
+ //# sourceMappingURL=clusters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clusters.d.ts","sourceRoot":"","sources":["../../../src/api/routes/clusters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAyD7C,QAAA,MAAM,cAAc,EAAE,kBAwFrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ /**
3
+ * ClawSQL - Clusters API Routes
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const uuid_1 = require("uuid");
7
+ const index_js_1 = require("../../types/index.js");
8
+ const exceptions_js_1 = require("../../utils/exceptions.js");
9
+ const topology_js_1 = require("../../core/discovery/topology.js");
10
+ // In-memory cluster registry
11
+ const clusterRegistry = new Map();
12
+ /**
13
+ * Convert MySQLCluster to API response
14
+ */
15
+ function clusterToResponse(cluster) {
16
+ return {
17
+ cluster_id: cluster.clusterId,
18
+ name: cluster.name,
19
+ description: cluster.description ?? null,
20
+ primary: cluster.primary ? {
21
+ instance_id: `${cluster.primary.host}:${cluster.primary.port}`,
22
+ host: cluster.primary.host,
23
+ port: cluster.primary.port,
24
+ server_id: cluster.primary.serverId ?? null,
25
+ role: cluster.primary.role,
26
+ state: cluster.primary.state,
27
+ version: cluster.primary.version ?? null,
28
+ cluster_id: cluster.primary.clusterId ?? null,
29
+ replication_lag: cluster.primary.replicationLag ?? null,
30
+ labels: cluster.primary.labels,
31
+ last_seen: cluster.primary.lastSeen.toISOString(),
32
+ created_at: cluster.primary.lastSeen.toISOString(),
33
+ } : null,
34
+ replicas: cluster.replicas.map(r => ({
35
+ instance_id: `${r.host}:${r.port}`,
36
+ host: r.host,
37
+ port: r.port,
38
+ server_id: r.serverId ?? null,
39
+ role: r.role,
40
+ state: r.state,
41
+ version: r.version ?? null,
42
+ cluster_id: r.clusterId ?? null,
43
+ replication_lag: r.replicationLag ?? null,
44
+ labels: r.labels,
45
+ last_seen: r.lastSeen.toISOString(),
46
+ created_at: r.lastSeen.toISOString(),
47
+ })),
48
+ instance_count: (0, index_js_1.getInstanceCount)(cluster),
49
+ health_status: (0, index_js_1.getClusterHealthStatus)(cluster),
50
+ created_at: cluster.createdAt.toISOString(),
51
+ updated_at: cluster.updatedAt.toISOString(),
52
+ };
53
+ }
54
+ const clustersRoutes = async (fastify) => {
55
+ // List clusters
56
+ fastify.get('/', async (request) => {
57
+ const clusters = Array.from(clusterRegistry.values());
58
+ const page = request.query.page || 1;
59
+ const pageSize = request.query.page_size || 20;
60
+ const total = clusters.length;
61
+ const start = (page - 1) * pageSize;
62
+ const end = start + pageSize;
63
+ return {
64
+ items: clusters.slice(start, end).map(clusterToResponse),
65
+ total,
66
+ page,
67
+ page_size: pageSize,
68
+ };
69
+ });
70
+ // Get cluster
71
+ fastify.get('/:cluster_id', async (request) => {
72
+ // Try local registry first
73
+ let cluster = clusterRegistry.get(request.params.cluster_id);
74
+ // If not found, try Orchestrator
75
+ if (!cluster) {
76
+ try {
77
+ const orchestrator = (0, topology_js_1.getOrchestratorClient)();
78
+ const orchestratorCluster = await orchestrator.getTopology(request.params.cluster_id);
79
+ if (orchestratorCluster) {
80
+ cluster = orchestratorCluster;
81
+ clusterRegistry.set(request.params.cluster_id, cluster);
82
+ }
83
+ }
84
+ catch (error) {
85
+ fastify.log.debug({ error }, 'Failed to get topology from Orchestrator');
86
+ }
87
+ }
88
+ if (!cluster) {
89
+ throw new exceptions_js_1.NotFoundError('Cluster', request.params.cluster_id);
90
+ }
91
+ return clusterToResponse(cluster);
92
+ });
93
+ // Create cluster
94
+ fastify.post('/', async (request, reply) => {
95
+ const clusterId = (0, uuid_1.v4)();
96
+ const cluster = (0, index_js_1.createMySQLCluster)(clusterId, request.body.name, {
97
+ description: request.body.description,
98
+ });
99
+ clusterRegistry.set(clusterId, cluster);
100
+ reply.code(201);
101
+ return clusterToResponse(cluster);
102
+ });
103
+ // Delete cluster
104
+ fastify.delete('/:cluster_id', async (request, reply) => {
105
+ if (!clusterRegistry.has(request.params.cluster_id)) {
106
+ throw new exceptions_js_1.NotFoundError('Cluster', request.params.cluster_id);
107
+ }
108
+ clusterRegistry.delete(request.params.cluster_id);
109
+ reply.code(204);
110
+ });
111
+ // Sync cluster from Orchestrator
112
+ fastify.post('/:cluster_id/sync', async (request) => {
113
+ const orchestrator = (0, topology_js_1.getOrchestratorClient)();
114
+ const cluster = await orchestrator.getTopology(request.params.cluster_id);
115
+ if (!cluster) {
116
+ throw new exceptions_js_1.NotFoundError('Cluster', request.params.cluster_id);
117
+ }
118
+ clusterRegistry.set(request.params.cluster_id, cluster);
119
+ return clusterToResponse(cluster);
120
+ });
121
+ };
122
+ exports.default = clustersRoutes;
123
+ //# sourceMappingURL=clusters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clusters.js","sourceRoot":"","sources":["../../../src/api/routes/clusters.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,+BAAoC;AACpC,mDAK8B;AAC9B,6DAA0D;AAC1D,kEAAyE;AAEzE,6BAA6B;AAC7B,MA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CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ClawSQL - Configuration API Routes
3
+ */
4
+ import { FastifyPluginAsync } from 'fastify';
5
+ declare const configRoutes: FastifyPluginAsync;
6
+ export default configRoutes;
7
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/api/routes/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,QAAA,MAAM,YAAY,EAAE,kBA0DnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * ClawSQL - Configuration API Routes
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const settings_js_1 = require("../../config/settings.js");
7
+ const configRoutes = async (fastify) => {
8
+ // Get current configuration
9
+ fastify.get('/', async () => {
10
+ const settings = (0, settings_js_1.getSettings)();
11
+ // Return safe configuration (hide secrets)
12
+ return {
13
+ app: {
14
+ name: settings.appName,
15
+ version: settings.appVersion,
16
+ debug: settings.debug,
17
+ },
18
+ api: {
19
+ host: settings.api.host,
20
+ port: settings.api.port,
21
+ },
22
+ database: {
23
+ host: settings.metadataDb.host || 'metadata-mysql',
24
+ port: settings.metadataDb.port,
25
+ name: settings.metadataDb.name,
26
+ },
27
+ orchestrator: {
28
+ url: settings.orchestrator.url,
29
+ timeout: settings.orchestrator.timeout,
30
+ },
31
+ proxysql: {
32
+ host: settings.proxysql.host,
33
+ admin_port: settings.proxysql.adminPort,
34
+ mysql_port: settings.proxysql.mysqlPort,
35
+ },
36
+ prometheus: {
37
+ url: settings.prometheus.url,
38
+ },
39
+ failover: {
40
+ auto_failover_enabled: settings.failover.autoFailoverEnabled,
41
+ timeout_seconds: settings.failover.timeoutSeconds,
42
+ min_replicas_for_failover: settings.failover.minReplicasForFailover,
43
+ confirmation_checks: settings.failover.confirmationChecks,
44
+ },
45
+ monitoring: {
46
+ collection_interval: settings.monitoring.collectionInterval,
47
+ health_check_interval: settings.monitoring.healthCheckInterval,
48
+ },
49
+ logging: {
50
+ level: settings.logging.level,
51
+ format: settings.logging.format,
52
+ },
53
+ };
54
+ });
55
+ // Get version
56
+ fastify.get('/version', async () => {
57
+ const settings = (0, settings_js_1.getSettings)();
58
+ return {
59
+ version: settings.appVersion,
60
+ name: settings.appName,
61
+ };
62
+ });
63
+ };
64
+ exports.default = configRoutes;
65
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/api/routes/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,0DAAuD;AAEvD,MAAM,YAAY,GAAuB,KAAK,EAAE,OAAO,EAAE,EAAE;IACzD,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QAC1B,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;QAE/B,2CAA2C;QAC3C,OAAO;YACL,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ,CAAC,OAAO;gBACtB,OAAO,EAAE,QAAQ,CAAC,UAAU;gBAC5B,KAAK,EAAE,QAAQ,CAAC,KAAK;aACtB;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;gBACvB,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;aACxB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,gBAAgB;gBAClD,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI;gBAC9B,IAAI,EAAE,QAAQ,CAAC,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
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ClawSQL - Failover API Routes
3
+ */
4
+ import { FastifyPluginAsync } from 'fastify';
5
+ declare const failoverRoutes: FastifyPluginAsync;
6
+ export default failoverRoutes;
7
+ //# sourceMappingURL=failover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failover.d.ts","sourceRoot":"","sources":["../../../src/api/routes/failover.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK7C,QAAA,MAAM,cAAc,EAAE,kBAqHrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * ClawSQL - Failover API Routes
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const exceptions_js_1 = require("../../utils/exceptions.js");
7
+ const executor_js_1 = require("../../core/failover/executor.js");
8
+ const topology_js_1 = require("../../core/discovery/topology.js");
9
+ const failoverRoutes = async (fastify) => {
10
+ // List failover operations
11
+ fastify.get('/', async (request, _reply) => {
12
+ const executor = (0, executor_js_1.getFailoverExecutor)();
13
+ const operations = executor.getOperationHistory(request.query.cluster_id, request.query.limit || 100);
14
+ return {
15
+ items: operations.map(op => ({
16
+ operation_id: op.operationId,
17
+ cluster_id: op.clusterId,
18
+ old_primary_id: op.oldPrimaryId || null,
19
+ new_primary_id: op.newPrimaryId ?? null,
20
+ state: op.state,
21
+ started_at: op.startedAt?.toISOString() ?? null,
22
+ completed_at: op.completedAt?.toISOString() ?? null,
23
+ duration_seconds: op.startedAt && op.completedAt
24
+ ? (op.completedAt.getTime() - op.startedAt.getTime()) / 1000
25
+ : null,
26
+ steps: op.steps,
27
+ error: op.error ?? null,
28
+ manual: op.manual,
29
+ reason: op.reason || null,
30
+ triggered_by: op.triggeredBy ?? null,
31
+ })),
32
+ total: operations.length,
33
+ };
34
+ });
35
+ // Get failover operation
36
+ fastify.get('/:operation_id', async (request, _reply) => {
37
+ const executor = (0, executor_js_1.getFailoverExecutor)();
38
+ const operation = executor.getOperation(request.params.operation_id);
39
+ if (!operation) {
40
+ throw new exceptions_js_1.NotFoundError('Failover operation', request.params.operation_id);
41
+ }
42
+ return {
43
+ operation_id: operation.operationId,
44
+ cluster_id: operation.clusterId,
45
+ old_primary_id: operation.oldPrimaryId || null,
46
+ new_primary_id: operation.newPrimaryId ?? null,
47
+ state: operation.state,
48
+ started_at: operation.startedAt?.toISOString() ?? null,
49
+ completed_at: operation.completedAt?.toISOString() ?? null,
50
+ duration_seconds: operation.startedAt && operation.completedAt
51
+ ? (operation.completedAt.getTime() - operation.startedAt.getTime()) / 1000
52
+ : null,
53
+ steps: operation.steps,
54
+ error: operation.error ?? null,
55
+ manual: operation.manual,
56
+ reason: operation.reason || null,
57
+ triggered_by: operation.triggeredBy ?? null,
58
+ };
59
+ });
60
+ // Execute manual failover
61
+ fastify.post('/cluster/:cluster_id', async (request, _reply) => {
62
+ // Get cluster from Orchestrator
63
+ const orchestrator = (0, topology_js_1.getOrchestratorClient)();
64
+ const cluster = await orchestrator.getTopology(request.params.cluster_id);
65
+ if (!cluster) {
66
+ throw new exceptions_js_1.NotFoundError('Cluster', request.params.cluster_id);
67
+ }
68
+ const executor = (0, executor_js_1.getFailoverExecutor)();
69
+ const operation = await executor.executeManualFailover(cluster, request.body.target_instance_id, request.body.reason);
70
+ const durationSeconds = operation.startedAt && operation.completedAt
71
+ ? (operation.completedAt.getTime() - operation.startedAt.getTime()) / 1000
72
+ : null;
73
+ return {
74
+ operation_id: operation.operationId,
75
+ cluster_id: operation.clusterId,
76
+ old_primary_id: operation.oldPrimaryId || null,
77
+ new_primary_id: operation.newPrimaryId ?? null,
78
+ state: operation.state,
79
+ started_at: operation.startedAt?.toISOString() ?? null,
80
+ completed_at: operation.completedAt?.toISOString() ?? null,
81
+ duration_seconds: durationSeconds,
82
+ steps: operation.steps,
83
+ error: operation.error ?? null,
84
+ manual: operation.manual,
85
+ reason: operation.reason || null,
86
+ triggered_by: operation.triggeredBy ?? null,
87
+ };
88
+ });
89
+ // Cancel failover operation
90
+ fastify.post('/:operation_id/cancel', async (request, _reply) => {
91
+ const executor = (0, executor_js_1.getFailoverExecutor)();
92
+ const cancelled = await executor.cancelOperation(request.params.operation_id);
93
+ if (!cancelled) {
94
+ throw new exceptions_js_1.NotFoundError('Failover operation', request.params.operation_id);
95
+ }
96
+ return { message: `Failover operation ${request.params.operation_id} cancelled` };
97
+ });
98
+ };
99
+ exports.default = failoverRoutes;
100
+ //# sourceMappingURL=failover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failover.js","sourceRoot":"","sources":["../../../src/api/routes/failover.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,6DAA0D;AAC1D,iEAAsE;AACtE,kEAAyE;AAEzE,MAAM,cAAc,GAAuB,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3D,2BAA2B;IAC3B,OAAO,CAAC,GAAG,CAER,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,IAAA,iCAAmB,GAAE,CAAC;QACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,mBAAmB,CAC7C,OAAO,CAAC,KAAK,CAAC,UAAU,EACxB,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,CAC3B,CAAC;QAEF,OAAO;YACL,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC3B,YAAY,EAAE,EAAE,CAAC,WAAW;gBAC5B,UAAU,EAAE,EAAE,CAAC,SAAS;gBACxB,cAAc,EAAE,EAAE,CAAC,YAAY,IAAI,IAAI;gBACvC,cAAc,EAAE,EAAE,CAAC,YAAY,IAAI,IAAI;gBACvC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACf,UAAU,EAAE,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,IAAI;gBAC/C,YAAY,EAA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F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ClawSQL - Instances API Routes
3
+ *
4
+ * Instance management with persistence in shared metadata database.
5
+ * - Topology data (role, state, replication) comes from Orchestrator
6
+ * - User metadata (labels, extra) stored in instance_metadata table
7
+ */
8
+ import { FastifyPluginAsync } from 'fastify';
9
+ declare const instancesRoutes: FastifyPluginAsync;
10
+ export default instancesRoutes;
11
+ //# sourceMappingURL=instances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../../src/api/routes/instances.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA0I7C,QAAA,MAAM,eAAe,EAAE,kBA0RtB,CAAC;AAEF,eAAe,eAAe,CAAC"}