@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,328 +0,0 @@
1
- /**
2
- * Calendar CRUD operations
3
- */
4
-
5
- import { getDatabase } from "./database.js";
6
-
7
- export interface CalendarEvent {
8
- id: string;
9
- title: string;
10
- description: string | null;
11
- start_at: string;
12
- end_at: string | null;
13
- all_day: boolean;
14
- location: string | null;
15
- calendar: string;
16
- status: "confirmed" | "tentative" | "cancelled";
17
- recurrence_rule: string | null;
18
- reminder_minutes: number | null;
19
- tags: string[];
20
- metadata: Record<string, unknown>;
21
- created_at: string;
22
- updated_at: string;
23
- }
24
-
25
- interface EventRow {
26
- id: string;
27
- title: string;
28
- description: string | null;
29
- start_at: string;
30
- end_at: string | null;
31
- all_day: number;
32
- location: string | null;
33
- calendar: string;
34
- status: string;
35
- recurrence_rule: string | null;
36
- reminder_minutes: number | null;
37
- tags: string;
38
- metadata: string;
39
- created_at: string;
40
- updated_at: string;
41
- }
42
-
43
- function rowToEvent(row: EventRow): CalendarEvent {
44
- return {
45
- ...row,
46
- all_day: row.all_day === 1,
47
- status: row.status as CalendarEvent["status"],
48
- tags: JSON.parse(row.tags || "[]"),
49
- metadata: JSON.parse(row.metadata || "{}"),
50
- };
51
- }
52
-
53
- export interface Reminder {
54
- id: string;
55
- event_id: string;
56
- remind_at: string;
57
- sent: boolean;
58
- created_at: string;
59
- }
60
-
61
- interface ReminderRow {
62
- id: string;
63
- event_id: string;
64
- remind_at: string;
65
- sent: number;
66
- created_at: string;
67
- }
68
-
69
- function rowToReminder(row: ReminderRow): Reminder {
70
- return {
71
- ...row,
72
- sent: row.sent === 1,
73
- };
74
- }
75
-
76
- // --- Events ---
77
-
78
- export interface CreateEventInput {
79
- title: string;
80
- description?: string;
81
- start_at: string;
82
- end_at?: string;
83
- all_day?: boolean;
84
- location?: string;
85
- calendar?: string;
86
- status?: CalendarEvent["status"];
87
- recurrence_rule?: string;
88
- reminder_minutes?: number;
89
- tags?: string[];
90
- metadata?: Record<string, unknown>;
91
- }
92
-
93
- export function createEvent(input: CreateEventInput): CalendarEvent {
94
- const db = getDatabase();
95
- const id = crypto.randomUUID();
96
- const tags = JSON.stringify(input.tags || []);
97
- const metadata = JSON.stringify(input.metadata || {});
98
-
99
- db.prepare(
100
- `INSERT INTO events (id, title, description, start_at, end_at, all_day, location, calendar, status, recurrence_rule, reminder_minutes, tags, metadata)
101
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
102
- ).run(
103
- id,
104
- input.title,
105
- input.description || null,
106
- input.start_at,
107
- input.end_at || null,
108
- input.all_day ? 1 : 0,
109
- input.location || null,
110
- input.calendar || "default",
111
- input.status || "confirmed",
112
- input.recurrence_rule || null,
113
- input.reminder_minutes ?? null,
114
- tags,
115
- metadata
116
- );
117
-
118
- return getEvent(id)!;
119
- }
120
-
121
- export function getEvent(id: string): CalendarEvent | null {
122
- const db = getDatabase();
123
- const row = db.prepare("SELECT * FROM events WHERE id = ?").get(id) as EventRow | null;
124
- return row ? rowToEvent(row) : null;
125
- }
126
-
127
- export interface ListEventsOptions {
128
- from?: string;
129
- to?: string;
130
- calendar?: string;
131
- status?: string;
132
- limit?: number;
133
- offset?: number;
134
- }
135
-
136
- export function listEvents(options: ListEventsOptions = {}): CalendarEvent[] {
137
- const db = getDatabase();
138
- const conditions: string[] = [];
139
- const params: unknown[] = [];
140
-
141
- if (options.from) {
142
- conditions.push("start_at >= ?");
143
- params.push(options.from);
144
- }
145
-
146
- if (options.to) {
147
- conditions.push("start_at <= ?");
148
- params.push(options.to);
149
- }
150
-
151
- if (options.calendar) {
152
- conditions.push("calendar = ?");
153
- params.push(options.calendar);
154
- }
155
-
156
- if (options.status) {
157
- conditions.push("status = ?");
158
- params.push(options.status);
159
- }
160
-
161
- let sql = "SELECT * FROM events";
162
- if (conditions.length > 0) {
163
- sql += " WHERE " + conditions.join(" AND ");
164
- }
165
- sql += " ORDER BY start_at ASC";
166
-
167
- if (options.limit) {
168
- sql += " LIMIT ?";
169
- params.push(options.limit);
170
- }
171
- if (options.offset) {
172
- sql += " OFFSET ?";
173
- params.push(options.offset);
174
- }
175
-
176
- const rows = db.prepare(sql).all(...params) as EventRow[];
177
- return rows.map(rowToEvent);
178
- }
179
-
180
- export interface UpdateEventInput {
181
- title?: string;
182
- description?: string;
183
- start_at?: string;
184
- end_at?: string;
185
- all_day?: boolean;
186
- location?: string;
187
- calendar?: string;
188
- status?: CalendarEvent["status"];
189
- recurrence_rule?: string;
190
- reminder_minutes?: number | null;
191
- tags?: string[];
192
- metadata?: Record<string, unknown>;
193
- }
194
-
195
- export function updateEvent(
196
- id: string,
197
- input: UpdateEventInput
198
- ): CalendarEvent | null {
199
- const db = getDatabase();
200
- const existing = getEvent(id);
201
- if (!existing) return null;
202
-
203
- const sets: string[] = [];
204
- const params: unknown[] = [];
205
-
206
- if (input.title !== undefined) {
207
- sets.push("title = ?");
208
- params.push(input.title);
209
- }
210
- if (input.description !== undefined) {
211
- sets.push("description = ?");
212
- params.push(input.description);
213
- }
214
- if (input.start_at !== undefined) {
215
- sets.push("start_at = ?");
216
- params.push(input.start_at);
217
- }
218
- if (input.end_at !== undefined) {
219
- sets.push("end_at = ?");
220
- params.push(input.end_at);
221
- }
222
- if (input.all_day !== undefined) {
223
- sets.push("all_day = ?");
224
- params.push(input.all_day ? 1 : 0);
225
- }
226
- if (input.location !== undefined) {
227
- sets.push("location = ?");
228
- params.push(input.location);
229
- }
230
- if (input.calendar !== undefined) {
231
- sets.push("calendar = ?");
232
- params.push(input.calendar);
233
- }
234
- if (input.status !== undefined) {
235
- sets.push("status = ?");
236
- params.push(input.status);
237
- }
238
- if (input.recurrence_rule !== undefined) {
239
- sets.push("recurrence_rule = ?");
240
- params.push(input.recurrence_rule);
241
- }
242
- if (input.reminder_minutes !== undefined) {
243
- sets.push("reminder_minutes = ?");
244
- params.push(input.reminder_minutes);
245
- }
246
- if (input.tags !== undefined) {
247
- sets.push("tags = ?");
248
- params.push(JSON.stringify(input.tags));
249
- }
250
- if (input.metadata !== undefined) {
251
- sets.push("metadata = ?");
252
- params.push(JSON.stringify(input.metadata));
253
- }
254
-
255
- if (sets.length === 0) return existing;
256
-
257
- sets.push("updated_at = datetime('now')");
258
- params.push(id);
259
-
260
- db.prepare(
261
- `UPDATE events SET ${sets.join(", ")} WHERE id = ?`
262
- ).run(...params);
263
-
264
- return getEvent(id);
265
- }
266
-
267
- export function deleteEvent(id: string): boolean {
268
- const db = getDatabase();
269
- const result = db.prepare("DELETE FROM events WHERE id = ?").run(id);
270
- return result.changes > 0;
271
- }
272
-
273
- export function getUpcoming(limit: number = 10): CalendarEvent[] {
274
- const db = getDatabase();
275
- const rows = db
276
- .prepare(
277
- "SELECT * FROM events WHERE start_at >= datetime('now') AND status != 'cancelled' ORDER BY start_at ASC LIMIT ?"
278
- )
279
- .all(limit) as EventRow[];
280
- return rows.map(rowToEvent);
281
- }
282
-
283
- export function getToday(): CalendarEvent[] {
284
- const db = getDatabase();
285
- const rows = db
286
- .prepare(
287
- "SELECT * FROM events WHERE date(start_at) = date('now') AND status != 'cancelled' ORDER BY start_at ASC"
288
- )
289
- .all() as EventRow[];
290
- return rows.map(rowToEvent);
291
- }
292
-
293
- // --- Reminders ---
294
-
295
- export interface CreateReminderInput {
296
- event_id: string;
297
- remind_at: string;
298
- }
299
-
300
- export function createReminder(input: CreateReminderInput): Reminder {
301
- const db = getDatabase();
302
- const id = crypto.randomUUID();
303
-
304
- db.prepare(
305
- `INSERT INTO reminders (id, event_id, remind_at) VALUES (?, ?, ?)`
306
- ).run(id, input.event_id, input.remind_at);
307
-
308
- const row = db.prepare("SELECT * FROM reminders WHERE id = ?").get(id) as ReminderRow;
309
- return rowToReminder(row);
310
- }
311
-
312
- export function listPendingReminders(): Reminder[] {
313
- const db = getDatabase();
314
- const rows = db
315
- .prepare(
316
- "SELECT * FROM reminders WHERE sent = 0 AND remind_at <= datetime('now') ORDER BY remind_at ASC"
317
- )
318
- .all() as ReminderRow[];
319
- return rows.map(rowToReminder);
320
- }
321
-
322
- export function markReminderSent(id: string): boolean {
323
- const db = getDatabase();
324
- const result = db
325
- .prepare("UPDATE reminders SET sent = 1 WHERE id = ?")
326
- .run(id);
327
- return result.changes > 0;
328
- }
@@ -1,82 +0,0 @@
1
- /**
2
- * Database connection for microservice-calendar
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
- if (process.env["MICROSERVICES_DIR"]) {
14
- return join(process.env["MICROSERVICES_DIR"], "microservice-calendar", "data.db");
15
- }
16
-
17
- let dir = resolve(process.cwd());
18
- while (true) {
19
- const msDir = join(dir, ".microservices");
20
- if (existsSync(msDir)) return join(msDir, "microservice-calendar", "data.db");
21
- const parent = dirname(dir);
22
- if (parent === dir) break;
23
- dir = parent;
24
- }
25
-
26
- const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
27
- return join(home, ".microservices", "microservice-calendar", "data.db");
28
- }
29
-
30
- export function getDatabase(): Database {
31
- if (_db) return _db;
32
-
33
- const dbPath = getDbPath();
34
- const dataDir = dirname(dbPath);
35
- if (!existsSync(dataDir)) {
36
- mkdirSync(dataDir, { recursive: true });
37
- }
38
-
39
- _db = new Database(dbPath);
40
- _db.exec("PRAGMA journal_mode = WAL");
41
- _db.exec("PRAGMA foreign_keys = ON");
42
-
43
- _db.exec(`
44
- CREATE TABLE IF NOT EXISTS _migrations (
45
- id INTEGER PRIMARY KEY,
46
- name TEXT NOT NULL,
47
- applied_at TEXT NOT NULL DEFAULT (datetime('now'))
48
- )
49
- `);
50
-
51
- const applied = _db
52
- .query("SELECT id FROM _migrations ORDER BY id")
53
- .all() as { id: number }[];
54
- const appliedIds = new Set(applied.map((r) => r.id));
55
-
56
- for (const migration of MIGRATIONS) {
57
- if (appliedIds.has(migration.id)) continue;
58
- _db.exec("BEGIN");
59
- try {
60
- _db.exec(migration.sql);
61
- _db.prepare("INSERT INTO _migrations (id, name) VALUES (?, ?)").run(
62
- migration.id,
63
- migration.name
64
- );
65
- _db.exec("COMMIT");
66
- } catch (error) {
67
- _db.exec("ROLLBACK");
68
- throw new Error(
69
- `Migration ${migration.id} (${migration.name}) failed: ${error instanceof Error ? error.message : String(error)}`
70
- );
71
- }
72
- }
73
-
74
- return _db;
75
- }
76
-
77
- export function closeDatabase(): void {
78
- if (_db) {
79
- _db.close();
80
- _db = null;
81
- }
82
- }
@@ -1,47 +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 events (
13
- id TEXT PRIMARY KEY,
14
- title TEXT NOT NULL,
15
- description TEXT,
16
- start_at TEXT NOT NULL,
17
- end_at TEXT,
18
- all_day INTEGER NOT NULL DEFAULT 0,
19
- location TEXT,
20
- calendar TEXT NOT NULL DEFAULT 'default',
21
- status TEXT NOT NULL DEFAULT 'confirmed' CHECK(status IN ('confirmed', 'tentative', 'cancelled')),
22
- recurrence_rule TEXT,
23
- reminder_minutes INTEGER,
24
- tags TEXT NOT NULL DEFAULT '[]',
25
- metadata TEXT NOT NULL DEFAULT '{}',
26
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
27
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
28
- );
29
-
30
- CREATE TABLE IF NOT EXISTS reminders (
31
- id TEXT PRIMARY KEY,
32
- event_id TEXT NOT NULL REFERENCES events(id) ON DELETE CASCADE,
33
- remind_at TEXT NOT NULL,
34
- sent INTEGER NOT NULL DEFAULT 0,
35
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
36
- );
37
-
38
- CREATE INDEX IF NOT EXISTS idx_events_start ON events(start_at);
39
- CREATE INDEX IF NOT EXISTS idx_events_end ON events(end_at);
40
- CREATE INDEX IF NOT EXISTS idx_events_calendar ON events(calendar);
41
- CREATE INDEX IF NOT EXISTS idx_events_status ON events(status);
42
- CREATE INDEX IF NOT EXISTS idx_reminders_event ON reminders(event_id);
43
- CREATE INDEX IF NOT EXISTS idx_reminders_remind_at ON reminders(remind_at);
44
- CREATE INDEX IF NOT EXISTS idx_reminders_sent ON reminders(sent);
45
- `,
46
- },
47
- ];
@@ -1,24 +0,0 @@
1
- /**
2
- * microservice-calendar — Calendar management microservice
3
- */
4
-
5
- export {
6
- createEvent,
7
- getEvent,
8
- listEvents,
9
- updateEvent,
10
- deleteEvent,
11
- getUpcoming,
12
- getToday,
13
- createReminder,
14
- listPendingReminders,
15
- markReminderSent,
16
- type CalendarEvent,
17
- type Reminder,
18
- type CreateEventInput,
19
- type UpdateEventInput,
20
- type ListEventsOptions,
21
- type CreateReminderInput,
22
- } from "./db/calendar.js";
23
-
24
- export { getDatabase, closeDatabase } from "./db/database.js";
@@ -1,226 +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
- createEvent,
8
- getEvent,
9
- listEvents,
10
- updateEvent,
11
- deleteEvent,
12
- getUpcoming,
13
- getToday,
14
- createReminder,
15
- listPendingReminders,
16
- markReminderSent,
17
- } from "../db/calendar.js";
18
-
19
- const server = new McpServer({
20
- name: "microservice-calendar",
21
- version: "0.0.1",
22
- });
23
-
24
- // --- Events ---
25
-
26
- server.registerTool(
27
- "create_event",
28
- {
29
- title: "Create Event",
30
- description: "Create a new calendar event.",
31
- inputSchema: {
32
- title: z.string(),
33
- start_at: z.string(),
34
- end_at: z.string().optional(),
35
- all_day: z.boolean().optional(),
36
- description: z.string().optional(),
37
- location: z.string().optional(),
38
- calendar: z.string().optional(),
39
- status: z.enum(["confirmed", "tentative", "cancelled"]).optional(),
40
- recurrence_rule: z.string().optional(),
41
- reminder_minutes: z.number().optional(),
42
- tags: z.array(z.string()).optional(),
43
- },
44
- },
45
- async (params) => {
46
- const event = createEvent(params);
47
- return { content: [{ type: "text", text: JSON.stringify(event, null, 2) }] };
48
- }
49
- );
50
-
51
- server.registerTool(
52
- "get_event",
53
- {
54
- title: "Get Event",
55
- description: "Get a calendar event by ID.",
56
- inputSchema: { id: z.string() },
57
- },
58
- async ({ id }) => {
59
- const event = getEvent(id);
60
- if (!event) {
61
- return { content: [{ type: "text", text: `Event '${id}' not found.` }], isError: true };
62
- }
63
- return { content: [{ type: "text", text: JSON.stringify(event, null, 2) }] };
64
- }
65
- );
66
-
67
- server.registerTool(
68
- "list_events",
69
- {
70
- title: "List Events",
71
- description: "List calendar events with optional filters (date range, calendar, status).",
72
- inputSchema: {
73
- from: z.string().optional(),
74
- to: z.string().optional(),
75
- calendar: z.string().optional(),
76
- status: z.string().optional(),
77
- limit: z.number().optional(),
78
- },
79
- },
80
- async (params) => {
81
- const events = listEvents(params);
82
- return {
83
- content: [
84
- { type: "text", text: JSON.stringify({ events, count: events.length }, null, 2) },
85
- ],
86
- };
87
- }
88
- );
89
-
90
- server.registerTool(
91
- "update_event",
92
- {
93
- title: "Update Event",
94
- description: "Update an existing calendar event.",
95
- inputSchema: {
96
- id: z.string(),
97
- title: z.string().optional(),
98
- start_at: z.string().optional(),
99
- end_at: z.string().optional(),
100
- all_day: z.boolean().optional(),
101
- description: z.string().optional(),
102
- location: z.string().optional(),
103
- calendar: z.string().optional(),
104
- status: z.enum(["confirmed", "tentative", "cancelled"]).optional(),
105
- recurrence_rule: z.string().optional(),
106
- reminder_minutes: z.number().optional(),
107
- tags: z.array(z.string()).optional(),
108
- },
109
- },
110
- async ({ id, ...input }) => {
111
- const event = updateEvent(id, input);
112
- if (!event) {
113
- return { content: [{ type: "text", text: `Event '${id}' not found.` }], isError: true };
114
- }
115
- return { content: [{ type: "text", text: JSON.stringify(event, null, 2) }] };
116
- }
117
- );
118
-
119
- server.registerTool(
120
- "delete_event",
121
- {
122
- title: "Delete Event",
123
- description: "Delete a calendar event by ID.",
124
- inputSchema: { id: z.string() },
125
- },
126
- async ({ id }) => {
127
- const deleted = deleteEvent(id);
128
- return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
129
- }
130
- );
131
-
132
- server.registerTool(
133
- "get_upcoming",
134
- {
135
- title: "Get Upcoming Events",
136
- description: "Get the next N upcoming events.",
137
- inputSchema: {
138
- limit: z.number().optional(),
139
- },
140
- },
141
- async ({ limit }) => {
142
- const events = getUpcoming(limit || 10);
143
- return {
144
- content: [
145
- { type: "text", text: JSON.stringify({ events, count: events.length }, null, 2) },
146
- ],
147
- };
148
- }
149
- );
150
-
151
- server.registerTool(
152
- "get_today",
153
- {
154
- title: "Get Today's Events",
155
- description: "Get all events for today.",
156
- inputSchema: {},
157
- },
158
- async () => {
159
- const events = getToday();
160
- return {
161
- content: [
162
- { type: "text", text: JSON.stringify({ events, count: events.length }, null, 2) },
163
- ],
164
- };
165
- }
166
- );
167
-
168
- // --- Reminders ---
169
-
170
- server.registerTool(
171
- "create_reminder",
172
- {
173
- title: "Create Reminder",
174
- description: "Create a reminder for a calendar event.",
175
- inputSchema: {
176
- event_id: z.string(),
177
- remind_at: z.string(),
178
- },
179
- },
180
- async (params) => {
181
- const reminder = createReminder(params);
182
- return { content: [{ type: "text", text: JSON.stringify(reminder, null, 2) }] };
183
- }
184
- );
185
-
186
- server.registerTool(
187
- "list_pending_reminders",
188
- {
189
- title: "List Pending Reminders",
190
- description: "List all reminders that are due but not yet sent.",
191
- inputSchema: {},
192
- },
193
- async () => {
194
- const reminders = listPendingReminders();
195
- return {
196
- content: [
197
- { type: "text", text: JSON.stringify({ reminders, count: reminders.length }, null, 2) },
198
- ],
199
- };
200
- }
201
- );
202
-
203
- server.registerTool(
204
- "mark_reminder_sent",
205
- {
206
- title: "Mark Reminder Sent",
207
- description: "Mark a reminder as sent.",
208
- inputSchema: { id: z.string() },
209
- },
210
- async ({ id }) => {
211
- const marked = markReminderSent(id);
212
- return { content: [{ type: "text", text: JSON.stringify({ id, marked }) }] };
213
- }
214
- );
215
-
216
- // --- Start ---
217
- async function main() {
218
- const transport = new StdioServerTransport();
219
- await server.connect(transport);
220
- console.error("microservice-calendar MCP server running on stdio");
221
- }
222
-
223
- main().catch((error) => {
224
- console.error("Fatal error:", error);
225
- process.exit(1);
226
- });