@hasna/microservices 0.0.15 → 0.0.17

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 (296) hide show
  1. package/README.md +120 -138
  2. package/bin/index.js +703 -12728
  3. package/bin/mcp.js +250 -9726
  4. package/dist/index.js +170 -9407
  5. package/package.json +25 -25
  6. package/microservices/microservice-ads/package.json +0 -27
  7. package/microservices/microservice-ads/src/cli/index.ts +0 -605
  8. package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
  9. package/microservices/microservice-ads/src/db/database.ts +0 -93
  10. package/microservices/microservice-ads/src/db/migrations.ts +0 -60
  11. package/microservices/microservice-ads/src/index.ts +0 -39
  12. package/microservices/microservice-ads/src/mcp/index.ts +0 -480
  13. package/microservices/microservice-analytics/package.json +0 -27
  14. package/microservices/microservice-analytics/src/cli/index.ts +0 -373
  15. package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
  16. package/microservices/microservice-analytics/src/db/database.ts +0 -93
  17. package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
  18. package/microservices/microservice-analytics/src/index.ts +0 -37
  19. package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
  20. package/microservices/microservice-assets/package.json +0 -27
  21. package/microservices/microservice-assets/src/cli/index.ts +0 -375
  22. package/microservices/microservice-assets/src/db/assets.ts +0 -370
  23. package/microservices/microservice-assets/src/db/database.ts +0 -93
  24. package/microservices/microservice-assets/src/db/migrations.ts +0 -51
  25. package/microservices/microservice-assets/src/index.ts +0 -32
  26. package/microservices/microservice-assets/src/mcp/index.ts +0 -346
  27. package/microservices/microservice-bookkeeping/package.json +0 -27
  28. package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
  29. package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
  30. package/microservices/microservice-bookkeeping/src/db/database.ts +0 -93
  31. package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
  32. package/microservices/microservice-bookkeeping/src/index.ts +0 -32
  33. package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
  34. package/microservices/microservice-calendar/package.json +0 -27
  35. package/microservices/microservice-calendar/src/cli/index.ts +0 -287
  36. package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
  37. package/microservices/microservice-calendar/src/db/database.ts +0 -82
  38. package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
  39. package/microservices/microservice-calendar/src/index.ts +0 -24
  40. package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
  41. package/microservices/microservice-company/package.json +0 -27
  42. package/microservices/microservice-company/src/cli/index.ts +0 -1126
  43. package/microservices/microservice-company/src/db/company.ts +0 -854
  44. package/microservices/microservice-company/src/db/database.ts +0 -93
  45. package/microservices/microservice-company/src/db/migrations.ts +0 -214
  46. package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
  47. package/microservices/microservice-company/src/index.ts +0 -60
  48. package/microservices/microservice-company/src/lib/audit.ts +0 -168
  49. package/microservices/microservice-company/src/lib/finance.ts +0 -299
  50. package/microservices/microservice-company/src/lib/settings.ts +0 -85
  51. package/microservices/microservice-company/src/lib/workflows.ts +0 -698
  52. package/microservices/microservice-company/src/mcp/index.ts +0 -991
  53. package/microservices/microservice-compliance/package.json +0 -27
  54. package/microservices/microservice-compliance/src/cli/index.ts +0 -467
  55. package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
  56. package/microservices/microservice-compliance/src/db/database.ts +0 -93
  57. package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
  58. package/microservices/microservice-compliance/src/index.ts +0 -46
  59. package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
  60. package/microservices/microservice-contacts/package.json +0 -27
  61. package/microservices/microservice-contacts/src/cli/index.ts +0 -393
  62. package/microservices/microservice-contacts/src/db/companies.ts +0 -167
  63. package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
  64. package/microservices/microservice-contacts/src/db/database.ts +0 -93
  65. package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
  66. package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
  67. package/microservices/microservice-contacts/src/index.ts +0 -42
  68. package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
  69. package/microservices/microservice-contracts/package.json +0 -27
  70. package/microservices/microservice-contracts/src/cli/index.ts +0 -770
  71. package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
  72. package/microservices/microservice-contracts/src/db/database.ts +0 -93
  73. package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
  74. package/microservices/microservice-contracts/src/index.ts +0 -43
  75. package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
  76. package/microservices/microservice-crm/package.json +0 -27
  77. package/microservices/microservice-crm/src/cli/index.ts +0 -396
  78. package/microservices/microservice-crm/src/db/database.ts +0 -82
  79. package/microservices/microservice-crm/src/db/migrations.ts +0 -66
  80. package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
  81. package/microservices/microservice-crm/src/index.ts +0 -34
  82. package/microservices/microservice-crm/src/mcp/index.ts +0 -294
  83. package/microservices/microservice-documents/package.json +0 -27
  84. package/microservices/microservice-documents/src/cli/index.ts +0 -246
  85. package/microservices/microservice-documents/src/db/database.ts +0 -82
  86. package/microservices/microservice-documents/src/db/documents.ts +0 -316
  87. package/microservices/microservice-documents/src/db/migrations.ts +0 -49
  88. package/microservices/microservice-documents/src/index.ts +0 -24
  89. package/microservices/microservice-documents/src/mcp/index.ts +0 -202
  90. package/microservices/microservice-domains/package.json +0 -27
  91. package/microservices/microservice-domains/src/cli/index.ts +0 -1111
  92. package/microservices/microservice-domains/src/db/database.ts +0 -93
  93. package/microservices/microservice-domains/src/db/domains.ts +0 -1164
  94. package/microservices/microservice-domains/src/db/migrations.ts +0 -60
  95. package/microservices/microservice-domains/src/index.ts +0 -65
  96. package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
  97. package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
  98. package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
  99. package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
  100. package/microservices/microservice-domains/src/mcp/index.ts +0 -781
  101. package/microservices/microservice-expenses/package.json +0 -27
  102. package/microservices/microservice-expenses/src/cli/index.ts +0 -267
  103. package/microservices/microservice-expenses/src/db/database.ts +0 -82
  104. package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
  105. package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
  106. package/microservices/microservice-expenses/src/index.ts +0 -25
  107. package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
  108. package/microservices/microservice-habits/package.json +0 -27
  109. package/microservices/microservice-habits/src/cli/index.ts +0 -315
  110. package/microservices/microservice-habits/src/db/database.ts +0 -93
  111. package/microservices/microservice-habits/src/db/habits.ts +0 -451
  112. package/microservices/microservice-habits/src/db/migrations.ts +0 -46
  113. package/microservices/microservice-habits/src/index.ts +0 -31
  114. package/microservices/microservice-habits/src/mcp/index.ts +0 -313
  115. package/microservices/microservice-health/package.json +0 -27
  116. package/microservices/microservice-health/src/cli/index.ts +0 -484
  117. package/microservices/microservice-health/src/db/database.ts +0 -93
  118. package/microservices/microservice-health/src/db/health.ts +0 -708
  119. package/microservices/microservice-health/src/db/migrations.ts +0 -70
  120. package/microservices/microservice-health/src/index.ts +0 -63
  121. package/microservices/microservice-health/src/mcp/index.ts +0 -437
  122. package/microservices/microservice-hiring/package.json +0 -27
  123. package/microservices/microservice-hiring/src/cli/index.ts +0 -741
  124. package/microservices/microservice-hiring/src/db/database.ts +0 -93
  125. package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
  126. package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
  127. package/microservices/microservice-hiring/src/index.ts +0 -80
  128. package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
  129. package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
  130. package/microservices/microservice-inventory/package.json +0 -27
  131. package/microservices/microservice-inventory/src/cli/index.ts +0 -365
  132. package/microservices/microservice-inventory/src/db/database.ts +0 -82
  133. package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
  134. package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
  135. package/microservices/microservice-inventory/src/index.ts +0 -28
  136. package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
  137. package/microservices/microservice-invoices/dashboard/dist/assets/index-Bngq7FNM.css +0 -1
  138. package/microservices/microservice-invoices/dashboard/dist/assets/index-aHW4ARZR.js +0 -124
  139. package/microservices/microservice-invoices/dashboard/dist/index.html +0 -13
  140. package/microservices/microservice-invoices/dashboard/index.html +0 -12
  141. package/microservices/microservice-invoices/dashboard/package.json +0 -29
  142. package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
  143. package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
  144. package/microservices/microservice-invoices/package.json +0 -30
  145. package/microservices/microservice-invoices/src/cli/index.ts +0 -308
  146. package/microservices/microservice-invoices/src/db/business.ts +0 -241
  147. package/microservices/microservice-invoices/src/db/clients.ts +0 -127
  148. package/microservices/microservice-invoices/src/db/database.ts +0 -82
  149. package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
  150. package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
  151. package/microservices/microservice-invoices/src/index.ts +0 -56
  152. package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
  153. package/microservices/microservice-invoices/src/server/index.ts +0 -162
  154. package/microservices/microservice-leads/package.json +0 -27
  155. package/microservices/microservice-leads/src/cli/index.ts +0 -596
  156. package/microservices/microservice-leads/src/db/database.ts +0 -93
  157. package/microservices/microservice-leads/src/db/leads.ts +0 -520
  158. package/microservices/microservice-leads/src/db/lists.ts +0 -151
  159. package/microservices/microservice-leads/src/db/migrations.ts +0 -93
  160. package/microservices/microservice-leads/src/index.ts +0 -65
  161. package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
  162. package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
  163. package/microservices/microservice-leads/src/mcp/index.ts +0 -533
  164. package/microservices/microservice-notes/package.json +0 -27
  165. package/microservices/microservice-notes/src/cli/index.ts +0 -63
  166. package/microservices/microservice-notes/src/db/database.ts +0 -93
  167. package/microservices/microservice-notes/src/db/migrations.ts +0 -40
  168. package/microservices/microservice-notes/src/db/notes.ts +0 -114
  169. package/microservices/microservice-notes/src/index.ts +0 -2
  170. package/microservices/microservice-notes/src/mcp/index.ts +0 -37
  171. package/microservices/microservice-notifications/package.json +0 -27
  172. package/microservices/microservice-notifications/src/cli/index.ts +0 -349
  173. package/microservices/microservice-notifications/src/db/database.ts +0 -93
  174. package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
  175. package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
  176. package/microservices/microservice-notifications/src/index.ts +0 -41
  177. package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
  178. package/microservices/microservice-payments/package.json +0 -27
  179. package/microservices/microservice-payments/src/cli/index.ts +0 -609
  180. package/microservices/microservice-payments/src/db/database.ts +0 -93
  181. package/microservices/microservice-payments/src/db/migrations.ts +0 -81
  182. package/microservices/microservice-payments/src/db/payments.ts +0 -1204
  183. package/microservices/microservice-payments/src/index.ts +0 -51
  184. package/microservices/microservice-payments/src/mcp/index.ts +0 -683
  185. package/microservices/microservice-payroll/package.json +0 -27
  186. package/microservices/microservice-payroll/src/cli/index.ts +0 -643
  187. package/microservices/microservice-payroll/src/db/database.ts +0 -93
  188. package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
  189. package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
  190. package/microservices/microservice-payroll/src/index.ts +0 -48
  191. package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
  192. package/microservices/microservice-products/package.json +0 -27
  193. package/microservices/microservice-products/src/cli/index.ts +0 -416
  194. package/microservices/microservice-products/src/db/categories.ts +0 -154
  195. package/microservices/microservice-products/src/db/database.ts +0 -93
  196. package/microservices/microservice-products/src/db/migrations.ts +0 -58
  197. package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
  198. package/microservices/microservice-products/src/db/products.ts +0 -452
  199. package/microservices/microservice-products/src/index.ts +0 -53
  200. package/microservices/microservice-products/src/mcp/index.ts +0 -453
  201. package/microservices/microservice-projects/package.json +0 -27
  202. package/microservices/microservice-projects/src/cli/index.ts +0 -480
  203. package/microservices/microservice-projects/src/db/database.ts +0 -93
  204. package/microservices/microservice-projects/src/db/migrations.ts +0 -65
  205. package/microservices/microservice-projects/src/db/projects.ts +0 -715
  206. package/microservices/microservice-projects/src/index.ts +0 -57
  207. package/microservices/microservice-projects/src/mcp/index.ts +0 -501
  208. package/microservices/microservice-proposals/package.json +0 -27
  209. package/microservices/microservice-proposals/src/cli/index.ts +0 -400
  210. package/microservices/microservice-proposals/src/db/database.ts +0 -93
  211. package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
  212. package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
  213. package/microservices/microservice-proposals/src/index.ts +0 -37
  214. package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
  215. package/microservices/microservice-reading/package.json +0 -27
  216. package/microservices/microservice-reading/src/cli/index.ts +0 -464
  217. package/microservices/microservice-reading/src/db/database.ts +0 -93
  218. package/microservices/microservice-reading/src/db/migrations.ts +0 -59
  219. package/microservices/microservice-reading/src/db/reading.ts +0 -524
  220. package/microservices/microservice-reading/src/index.ts +0 -51
  221. package/microservices/microservice-reading/src/mcp/index.ts +0 -368
  222. package/microservices/microservice-shipping/package.json +0 -27
  223. package/microservices/microservice-shipping/src/cli/index.ts +0 -606
  224. package/microservices/microservice-shipping/src/db/database.ts +0 -93
  225. package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
  226. package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
  227. package/microservices/microservice-shipping/src/index.ts +0 -53
  228. package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
  229. package/microservices/microservice-social/package.json +0 -28
  230. package/microservices/microservice-social/src/cli/index.ts +0 -1583
  231. package/microservices/microservice-social/src/db/database.ts +0 -93
  232. package/microservices/microservice-social/src/db/migrations.ts +0 -160
  233. package/microservices/microservice-social/src/db/social.ts +0 -1076
  234. package/microservices/microservice-social/src/index.ts +0 -46
  235. package/microservices/microservice-social/src/lib/audience.ts +0 -353
  236. package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
  237. package/microservices/microservice-social/src/lib/media.ts +0 -311
  238. package/microservices/microservice-social/src/lib/mentions.ts +0 -434
  239. package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
  240. package/microservices/microservice-social/src/lib/publisher.ts +0 -377
  241. package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
  242. package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
  243. package/microservices/microservice-social/src/lib/threads.ts +0 -291
  244. package/microservices/microservice-social/src/mcp/index.ts +0 -1425
  245. package/microservices/microservice-social/src/server/index.ts +0 -441
  246. package/microservices/microservice-subscriptions/package.json +0 -27
  247. package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
  248. package/microservices/microservice-subscriptions/src/db/database.ts +0 -93
  249. package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
  250. package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
  251. package/microservices/microservice-subscriptions/src/index.ts +0 -41
  252. package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
  253. package/microservices/microservice-timesheets/package.json +0 -27
  254. package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
  255. package/microservices/microservice-timesheets/src/db/database.ts +0 -82
  256. package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
  257. package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
  258. package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
  259. package/microservices/microservice-timesheets/src/index.ts +0 -44
  260. package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
  261. package/microservices/microservice-transcriber/package.json +0 -28
  262. package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
  263. package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
  264. package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
  265. package/microservices/microservice-transcriber/src/db/database.ts +0 -82
  266. package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
  267. package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
  268. package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
  269. package/microservices/microservice-transcriber/src/index.ts +0 -43
  270. package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
  271. package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
  272. package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
  273. package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
  274. package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
  275. package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
  276. package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
  277. package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
  278. package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
  279. package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
  280. package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
  281. package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
  282. package/microservices/microservice-transcriber/src/server/index.ts +0 -199
  283. package/microservices/microservice-travel/package.json +0 -27
  284. package/microservices/microservice-travel/src/cli/index.ts +0 -505
  285. package/microservices/microservice-travel/src/db/database.ts +0 -93
  286. package/microservices/microservice-travel/src/db/migrations.ts +0 -77
  287. package/microservices/microservice-travel/src/db/travel.ts +0 -802
  288. package/microservices/microservice-travel/src/index.ts +0 -60
  289. package/microservices/microservice-travel/src/mcp/index.ts +0 -495
  290. package/microservices/microservice-wiki/package.json +0 -27
  291. package/microservices/microservice-wiki/src/cli/index.ts +0 -345
  292. package/microservices/microservice-wiki/src/db/database.ts +0 -93
  293. package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
  294. package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
  295. package/microservices/microservice-wiki/src/index.ts +0 -32
  296. package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
@@ -1,93 +0,0 @@
1
- /**
2
- * Database connection for microservice-compliance
3
- */
4
-
5
- import { Database } from "bun:sqlite";
6
- import { existsSync, mkdirSync } from "node:fs";
7
- import { dirname, join, resolve } from "node:path";
8
- import { MIGRATIONS } from "./migrations.js";
9
-
10
- let _db: Database | null = null;
11
-
12
- function getDbPath(): string {
13
- // Environment variable override
14
- if (process.env["MICROSERVICES_DIR"]) {
15
- return join(process.env["MICROSERVICES_DIR"], "microservice-compliance", "data.db");
16
- }
17
-
18
- // Check for .microservices in current or parent directories
19
- let dir = resolve(process.cwd());
20
- while (true) {
21
- const candidate = join(dir, ".microservices", "microservice-compliance", "data.db");
22
- const msDir = join(dir, ".microservices");
23
- if (existsSync(msDir)) return candidate;
24
- const parent = dirname(dir);
25
- if (parent === dir) break;
26
- dir = parent;
27
- }
28
-
29
- // Global fallback
30
- const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
31
- return join(home, ".microservices", "microservice-compliance", "data.db");
32
- }
33
-
34
- function ensureDir(filePath: string): void {
35
- const dir = dirname(resolve(filePath));
36
- if (!existsSync(dir)) {
37
- mkdirSync(dir, { recursive: true });
38
- }
39
- }
40
-
41
- export function getDatabase(): Database {
42
- if (_db) return _db;
43
-
44
- const dbPath = getDbPath();
45
- ensureDir(dbPath);
46
-
47
- _db = new Database(dbPath);
48
- _db.exec("PRAGMA journal_mode = WAL");
49
- _db.exec("PRAGMA foreign_keys = ON");
50
-
51
- // Create migrations table
52
- _db.exec(`
53
- CREATE TABLE IF NOT EXISTS _migrations (
54
- id INTEGER PRIMARY KEY,
55
- name TEXT NOT NULL,
56
- applied_at TEXT NOT NULL DEFAULT (datetime('now'))
57
- )
58
- `);
59
-
60
- // Apply pending migrations
61
- const applied = _db
62
- .query("SELECT id FROM _migrations ORDER BY id")
63
- .all() as { id: number }[];
64
- const appliedIds = new Set(applied.map((r) => r.id));
65
-
66
- for (const migration of MIGRATIONS) {
67
- if (appliedIds.has(migration.id)) continue;
68
-
69
- _db.exec("BEGIN");
70
- try {
71
- _db.exec(migration.sql);
72
- _db.prepare("INSERT INTO _migrations (id, name) VALUES (?, ?)").run(
73
- migration.id,
74
- migration.name
75
- );
76
- _db.exec("COMMIT");
77
- } catch (error) {
78
- _db.exec("ROLLBACK");
79
- throw new Error(
80
- `Migration ${migration.id} (${migration.name}) failed: ${error instanceof Error ? error.message : String(error)}`
81
- );
82
- }
83
- }
84
-
85
- return _db;
86
- }
87
-
88
- export function closeDatabase(): void {
89
- if (_db) {
90
- _db.close();
91
- _db = null;
92
- }
93
- }
@@ -1,63 +0,0 @@
1
- export interface MigrationEntry {
2
- id: number;
3
- name: string;
4
- sql: string;
5
- }
6
-
7
- export const MIGRATIONS: MigrationEntry[] = [
8
- {
9
- id: 1,
10
- name: "initial_schema",
11
- sql: `
12
- CREATE TABLE IF NOT EXISTS requirements (
13
- id TEXT PRIMARY KEY,
14
- name TEXT NOT NULL,
15
- framework TEXT CHECK(framework IN ('gdpr','soc2','hipaa','pci','tax','iso27001','custom')),
16
- status TEXT NOT NULL DEFAULT 'in_progress' CHECK(status IN ('compliant','non_compliant','in_progress','not_applicable')),
17
- description TEXT,
18
- evidence TEXT,
19
- due_date TEXT,
20
- reviewed_at TEXT,
21
- reviewer TEXT,
22
- metadata TEXT NOT NULL DEFAULT '{}',
23
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
24
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
25
- );
26
-
27
- CREATE TABLE IF NOT EXISTS licenses (
28
- id TEXT PRIMARY KEY,
29
- name TEXT NOT NULL,
30
- type TEXT CHECK(type IN ('software','business','professional','patent','trademark')),
31
- issuer TEXT,
32
- license_number TEXT,
33
- status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active','expired','pending_renewal')),
34
- issued_at TEXT,
35
- expires_at TEXT,
36
- auto_renew INTEGER NOT NULL DEFAULT 0,
37
- cost REAL,
38
- metadata TEXT NOT NULL DEFAULT '{}',
39
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
40
- );
41
-
42
- CREATE TABLE IF NOT EXISTS audits (
43
- id TEXT PRIMARY KEY,
44
- name TEXT NOT NULL,
45
- framework TEXT,
46
- status TEXT NOT NULL DEFAULT 'scheduled' CHECK(status IN ('scheduled','in_progress','completed','failed')),
47
- findings TEXT NOT NULL DEFAULT '[]',
48
- auditor TEXT,
49
- scheduled_at TEXT,
50
- completed_at TEXT,
51
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
52
- );
53
-
54
- CREATE INDEX IF NOT EXISTS idx_requirements_framework ON requirements(framework);
55
- CREATE INDEX IF NOT EXISTS idx_requirements_status ON requirements(status);
56
- CREATE INDEX IF NOT EXISTS idx_requirements_due_date ON requirements(due_date);
57
- CREATE INDEX IF NOT EXISTS idx_licenses_status ON licenses(status);
58
- CREATE INDEX IF NOT EXISTS idx_licenses_expires_at ON licenses(expires_at);
59
- CREATE INDEX IF NOT EXISTS idx_audits_framework ON audits(framework);
60
- CREATE INDEX IF NOT EXISTS idx_audits_status ON audits(status);
61
- `,
62
- },
63
- ];
@@ -1,46 +0,0 @@
1
- /**
2
- * microservice-compliance — Compliance management microservice
3
- */
4
-
5
- export {
6
- createRequirement,
7
- getRequirement,
8
- listRequirements,
9
- updateRequirement,
10
- deleteRequirement,
11
- searchRequirements,
12
- createLicense,
13
- getLicense,
14
- listLicenses,
15
- updateLicense,
16
- deleteLicense,
17
- renewLicense,
18
- listExpiringLicenses,
19
- getLicenseStats,
20
- scheduleAudit,
21
- getAudit,
22
- listAudits,
23
- completeAudit,
24
- getAuditReport,
25
- deleteAudit,
26
- getComplianceScore,
27
- getFrameworkStatus,
28
- type Requirement,
29
- type License,
30
- type Audit,
31
- type Framework,
32
- type RequirementStatus,
33
- type LicenseType,
34
- type LicenseStatus,
35
- type AuditStatus,
36
- type CreateRequirementInput,
37
- type UpdateRequirementInput,
38
- type ListRequirementsOptions,
39
- type CreateLicenseInput,
40
- type UpdateLicenseInput,
41
- type ListLicensesOptions,
42
- type CreateAuditInput,
43
- type ListAuditsOptions,
44
- } from "./db/compliance.js";
45
-
46
- export { getDatabase, closeDatabase } from "./db/database.js";
@@ -1,438 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
- import { z } from "zod";
6
- import {
7
- createRequirement,
8
- getRequirement,
9
- listRequirements,
10
- updateRequirement,
11
- deleteRequirement,
12
- searchRequirements,
13
- createLicense,
14
- getLicense,
15
- listLicenses,
16
- updateLicense,
17
- deleteLicense,
18
- renewLicense,
19
- listExpiringLicenses,
20
- getLicenseStats,
21
- scheduleAudit,
22
- getAudit,
23
- listAudits,
24
- completeAudit,
25
- getAuditReport,
26
- deleteAudit,
27
- getComplianceScore,
28
- getFrameworkStatus,
29
- } from "../db/compliance.js";
30
-
31
- const server = new McpServer({
32
- name: "microservice-compliance",
33
- version: "0.0.1",
34
- });
35
-
36
- // --- Requirements ---
37
-
38
- server.registerTool(
39
- "create_requirement",
40
- {
41
- title: "Create Requirement",
42
- description: "Create a new compliance requirement.",
43
- inputSchema: {
44
- name: z.string(),
45
- framework: z.enum(["gdpr", "soc2", "hipaa", "pci", "tax", "iso27001", "custom"]).optional(),
46
- status: z.enum(["compliant", "non_compliant", "in_progress", "not_applicable"]).optional(),
47
- description: z.string().optional(),
48
- evidence: z.string().optional(),
49
- due_date: z.string().optional(),
50
- reviewer: z.string().optional(),
51
- },
52
- },
53
- async (params) => {
54
- const req = createRequirement(params);
55
- return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
56
- }
57
- );
58
-
59
- server.registerTool(
60
- "get_requirement",
61
- {
62
- title: "Get Requirement",
63
- description: "Get a compliance requirement by ID.",
64
- inputSchema: { id: z.string() },
65
- },
66
- async ({ id }) => {
67
- const req = getRequirement(id);
68
- if (!req) {
69
- return { content: [{ type: "text", text: `Requirement '${id}' not found.` }], isError: true };
70
- }
71
- return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
72
- }
73
- );
74
-
75
- server.registerTool(
76
- "list_requirements",
77
- {
78
- title: "List Requirements",
79
- description: "List compliance requirements with optional filters.",
80
- inputSchema: {
81
- framework: z.string().optional(),
82
- status: z.string().optional(),
83
- search: z.string().optional(),
84
- limit: z.number().optional(),
85
- },
86
- },
87
- async (params) => {
88
- const reqs = listRequirements(params);
89
- return {
90
- content: [{ type: "text", text: JSON.stringify({ requirements: reqs, count: reqs.length }, null, 2) }],
91
- };
92
- }
93
- );
94
-
95
- server.registerTool(
96
- "update_requirement",
97
- {
98
- title: "Update Requirement",
99
- description: "Update an existing compliance requirement.",
100
- inputSchema: {
101
- id: z.string(),
102
- name: z.string().optional(),
103
- framework: z.enum(["gdpr", "soc2", "hipaa", "pci", "tax", "iso27001", "custom"]).optional(),
104
- status: z.enum(["compliant", "non_compliant", "in_progress", "not_applicable"]).optional(),
105
- description: z.string().optional(),
106
- evidence: z.string().optional(),
107
- due_date: z.string().optional(),
108
- reviewed_at: z.string().optional(),
109
- reviewer: z.string().optional(),
110
- },
111
- },
112
- async ({ id, ...input }) => {
113
- const req = updateRequirement(id, input);
114
- if (!req) {
115
- return { content: [{ type: "text", text: `Requirement '${id}' not found.` }], isError: true };
116
- }
117
- return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
118
- }
119
- );
120
-
121
- server.registerTool(
122
- "delete_requirement",
123
- {
124
- title: "Delete Requirement",
125
- description: "Delete a compliance requirement by ID.",
126
- inputSchema: { id: z.string() },
127
- },
128
- async ({ id }) => {
129
- const deleted = deleteRequirement(id);
130
- return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
131
- }
132
- );
133
-
134
- server.registerTool(
135
- "search_requirements",
136
- {
137
- title: "Search Requirements",
138
- description: "Search requirements by name or description.",
139
- inputSchema: { query: z.string() },
140
- },
141
- async ({ query }) => {
142
- const results = searchRequirements(query);
143
- return {
144
- content: [{ type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) }],
145
- };
146
- }
147
- );
148
-
149
- // --- Licenses ---
150
-
151
- server.registerTool(
152
- "create_license",
153
- {
154
- title: "Create License",
155
- description: "Create a new license.",
156
- inputSchema: {
157
- name: z.string(),
158
- type: z.enum(["software", "business", "professional", "patent", "trademark"]).optional(),
159
- issuer: z.string().optional(),
160
- license_number: z.string().optional(),
161
- status: z.enum(["active", "expired", "pending_renewal"]).optional(),
162
- issued_at: z.string().optional(),
163
- expires_at: z.string().optional(),
164
- auto_renew: z.boolean().optional(),
165
- cost: z.number().optional(),
166
- },
167
- },
168
- async (params) => {
169
- const lic = createLicense(params);
170
- return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
171
- }
172
- );
173
-
174
- server.registerTool(
175
- "get_license",
176
- {
177
- title: "Get License",
178
- description: "Get a license by ID.",
179
- inputSchema: { id: z.string() },
180
- },
181
- async ({ id }) => {
182
- const lic = getLicense(id);
183
- if (!lic) {
184
- return { content: [{ type: "text", text: `License '${id}' not found.` }], isError: true };
185
- }
186
- return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
187
- }
188
- );
189
-
190
- server.registerTool(
191
- "list_licenses",
192
- {
193
- title: "List Licenses",
194
- description: "List licenses with optional filters.",
195
- inputSchema: {
196
- type: z.string().optional(),
197
- status: z.string().optional(),
198
- search: z.string().optional(),
199
- limit: z.number().optional(),
200
- },
201
- },
202
- async (params) => {
203
- const lics = listLicenses(params);
204
- return {
205
- content: [{ type: "text", text: JSON.stringify({ licenses: lics, count: lics.length }, null, 2) }],
206
- };
207
- }
208
- );
209
-
210
- server.registerTool(
211
- "update_license",
212
- {
213
- title: "Update License",
214
- description: "Update an existing license.",
215
- inputSchema: {
216
- id: z.string(),
217
- name: z.string().optional(),
218
- type: z.enum(["software", "business", "professional", "patent", "trademark"]).optional(),
219
- issuer: z.string().optional(),
220
- license_number: z.string().optional(),
221
- status: z.enum(["active", "expired", "pending_renewal"]).optional(),
222
- issued_at: z.string().optional(),
223
- expires_at: z.string().optional(),
224
- auto_renew: z.boolean().optional(),
225
- cost: z.number().optional(),
226
- },
227
- },
228
- async ({ id, ...input }) => {
229
- const lic = updateLicense(id, input);
230
- if (!lic) {
231
- return { content: [{ type: "text", text: `License '${id}' not found.` }], isError: true };
232
- }
233
- return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
234
- }
235
- );
236
-
237
- server.registerTool(
238
- "delete_license",
239
- {
240
- title: "Delete License",
241
- description: "Delete a license by ID.",
242
- inputSchema: { id: z.string() },
243
- },
244
- async ({ id }) => {
245
- const deleted = deleteLicense(id);
246
- return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
247
- }
248
- );
249
-
250
- server.registerTool(
251
- "renew_license",
252
- {
253
- title: "Renew License",
254
- description: "Renew a license with a new expiry date.",
255
- inputSchema: {
256
- id: z.string(),
257
- expires_at: z.string(),
258
- },
259
- },
260
- async ({ id, expires_at }) => {
261
- const lic = renewLicense(id, expires_at);
262
- if (!lic) {
263
- return { content: [{ type: "text", text: `License '${id}' not found.` }], isError: true };
264
- }
265
- return { content: [{ type: "text", text: JSON.stringify(lic, null, 2) }] };
266
- }
267
- );
268
-
269
- server.registerTool(
270
- "list_expiring_licenses",
271
- {
272
- title: "List Expiring Licenses",
273
- description: "List licenses expiring within N days.",
274
- inputSchema: { days: z.number().default(30) },
275
- },
276
- async ({ days }) => {
277
- const lics = listExpiringLicenses(days);
278
- return {
279
- content: [{ type: "text", text: JSON.stringify({ licenses: lics, count: lics.length }, null, 2) }],
280
- };
281
- }
282
- );
283
-
284
- server.registerTool(
285
- "get_license_stats",
286
- {
287
- title: "Get License Stats",
288
- description: "Get license statistics — totals by status and type.",
289
- inputSchema: {},
290
- },
291
- async () => {
292
- const stats = getLicenseStats();
293
- return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
294
- }
295
- );
296
-
297
- // --- Audits ---
298
-
299
- server.registerTool(
300
- "schedule_audit",
301
- {
302
- title: "Schedule Audit",
303
- description: "Schedule a new compliance audit.",
304
- inputSchema: {
305
- name: z.string(),
306
- framework: z.string().optional(),
307
- auditor: z.string().optional(),
308
- scheduled_at: z.string().optional(),
309
- },
310
- },
311
- async (params) => {
312
- const audit = scheduleAudit(params);
313
- return { content: [{ type: "text", text: JSON.stringify(audit, null, 2) }] };
314
- }
315
- );
316
-
317
- server.registerTool(
318
- "get_audit",
319
- {
320
- title: "Get Audit",
321
- description: "Get an audit by ID.",
322
- inputSchema: { id: z.string() },
323
- },
324
- async ({ id }) => {
325
- const audit = getAudit(id);
326
- if (!audit) {
327
- return { content: [{ type: "text", text: `Audit '${id}' not found.` }], isError: true };
328
- }
329
- return { content: [{ type: "text", text: JSON.stringify(audit, null, 2) }] };
330
- }
331
- );
332
-
333
- server.registerTool(
334
- "list_audits",
335
- {
336
- title: "List Audits",
337
- description: "List audits with optional filters.",
338
- inputSchema: {
339
- framework: z.string().optional(),
340
- status: z.string().optional(),
341
- limit: z.number().optional(),
342
- },
343
- },
344
- async (params) => {
345
- const audits = listAudits(params);
346
- return {
347
- content: [{ type: "text", text: JSON.stringify({ audits, count: audits.length }, null, 2) }],
348
- };
349
- }
350
- );
351
-
352
- server.registerTool(
353
- "complete_audit",
354
- {
355
- title: "Complete Audit",
356
- description: "Complete an audit with findings. Audits with critical-severity findings are marked as failed.",
357
- inputSchema: {
358
- id: z.string(),
359
- findings: z.array(z.any()),
360
- },
361
- },
362
- async ({ id, findings }) => {
363
- const audit = completeAudit(id, findings);
364
- if (!audit) {
365
- return { content: [{ type: "text", text: `Audit '${id}' not found.` }], isError: true };
366
- }
367
- return { content: [{ type: "text", text: JSON.stringify(audit, null, 2) }] };
368
- }
369
- );
370
-
371
- server.registerTool(
372
- "get_audit_report",
373
- {
374
- title: "Get Audit Report",
375
- description: "Get a detailed audit report with findings summary.",
376
- inputSchema: { id: z.string() },
377
- },
378
- async ({ id }) => {
379
- const report = getAuditReport(id);
380
- if (!report) {
381
- return { content: [{ type: "text", text: `Audit '${id}' not found.` }], isError: true };
382
- }
383
- return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
384
- }
385
- );
386
-
387
- server.registerTool(
388
- "delete_audit",
389
- {
390
- title: "Delete Audit",
391
- description: "Delete an audit by ID.",
392
- inputSchema: { id: z.string() },
393
- },
394
- async ({ id }) => {
395
- const deleted = deleteAudit(id);
396
- return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
397
- }
398
- );
399
-
400
- // --- Analytics ---
401
-
402
- server.registerTool(
403
- "get_compliance_score",
404
- {
405
- title: "Get Compliance Score",
406
- description: "Get the overall compliance score — percentage of applicable requirements that are compliant.",
407
- inputSchema: {},
408
- },
409
- async () => {
410
- const score = getComplianceScore();
411
- return { content: [{ type: "text", text: JSON.stringify(score, null, 2) }] };
412
- }
413
- );
414
-
415
- server.registerTool(
416
- "get_framework_status",
417
- {
418
- title: "Get Framework Status",
419
- description: "Get compliance status for a specific framework.",
420
- inputSchema: { framework: z.string() },
421
- },
422
- async ({ framework }) => {
423
- const status = getFrameworkStatus(framework);
424
- return { content: [{ type: "text", text: JSON.stringify(status, null, 2) }] };
425
- }
426
- );
427
-
428
- // --- Start ---
429
- async function main() {
430
- const transport = new StdioServerTransport();
431
- await server.connect(transport);
432
- console.error("microservice-compliance MCP server running on stdio");
433
- }
434
-
435
- main().catch((error) => {
436
- console.error("Fatal error:", error);
437
- process.exit(1);
438
- });
@@ -1,27 +0,0 @@
1
- {
2
- "name": "@hasna/microservice-contacts",
3
- "version": "0.0.1",
4
- "description": "Contact management microservice with SQLite — manage contacts, companies, and relationships",
5
- "type": "module",
6
- "bin": {
7
- "microservice-contacts": "./src/cli/index.ts",
8
- "microservice-contacts-mcp": "./src/mcp/index.ts"
9
- },
10
- "exports": {
11
- ".": "./src/index.ts"
12
- },
13
- "scripts": {
14
- "dev": "bun run ./src/cli/index.ts",
15
- "test": "bun test"
16
- },
17
- "dependencies": {
18
- "@modelcontextprotocol/sdk": "^1.26.0",
19
- "commander": "^12.1.0",
20
- "zod": "^3.24.0"
21
- },
22
- "license": "Apache-2.0",
23
- "publishConfig": {
24
- "registry": "https://registry.npmjs.org",
25
- "access": "public"
26
- }
27
- }