@hasna/microservices 0.0.10 → 0.0.11

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 (90) hide show
  1. package/bin/index.js +86 -1
  2. package/bin/mcp.js +86 -1
  3. package/dist/index.js +86 -1
  4. package/microservices/microservice-analytics/package.json +27 -0
  5. package/microservices/microservice-analytics/src/cli/index.ts +373 -0
  6. package/microservices/microservice-analytics/src/db/analytics.ts +564 -0
  7. package/microservices/microservice-analytics/src/db/database.ts +93 -0
  8. package/microservices/microservice-analytics/src/db/migrations.ts +50 -0
  9. package/microservices/microservice-analytics/src/index.ts +37 -0
  10. package/microservices/microservice-analytics/src/mcp/index.ts +334 -0
  11. package/microservices/microservice-assets/package.json +27 -0
  12. package/microservices/microservice-assets/src/cli/index.ts +375 -0
  13. package/microservices/microservice-assets/src/db/assets.ts +370 -0
  14. package/microservices/microservice-assets/src/db/database.ts +93 -0
  15. package/microservices/microservice-assets/src/db/migrations.ts +51 -0
  16. package/microservices/microservice-assets/src/index.ts +32 -0
  17. package/microservices/microservice-assets/src/mcp/index.ts +346 -0
  18. package/microservices/microservice-compliance/package.json +27 -0
  19. package/microservices/microservice-compliance/src/cli/index.ts +467 -0
  20. package/microservices/microservice-compliance/src/db/compliance.ts +633 -0
  21. package/microservices/microservice-compliance/src/db/database.ts +93 -0
  22. package/microservices/microservice-compliance/src/db/migrations.ts +63 -0
  23. package/microservices/microservice-compliance/src/index.ts +46 -0
  24. package/microservices/microservice-compliance/src/mcp/index.ts +438 -0
  25. package/microservices/microservice-habits/package.json +27 -0
  26. package/microservices/microservice-habits/src/cli/index.ts +315 -0
  27. package/microservices/microservice-habits/src/db/database.ts +93 -0
  28. package/microservices/microservice-habits/src/db/habits.ts +451 -0
  29. package/microservices/microservice-habits/src/db/migrations.ts +46 -0
  30. package/microservices/microservice-habits/src/index.ts +31 -0
  31. package/microservices/microservice-habits/src/mcp/index.ts +313 -0
  32. package/microservices/microservice-health/package.json +27 -0
  33. package/microservices/microservice-health/src/cli/index.ts +484 -0
  34. package/microservices/microservice-health/src/db/database.ts +93 -0
  35. package/microservices/microservice-health/src/db/health.ts +708 -0
  36. package/microservices/microservice-health/src/db/migrations.ts +70 -0
  37. package/microservices/microservice-health/src/index.ts +63 -0
  38. package/microservices/microservice-health/src/mcp/index.ts +437 -0
  39. package/microservices/microservice-notifications/package.json +27 -0
  40. package/microservices/microservice-notifications/src/cli/index.ts +349 -0
  41. package/microservices/microservice-notifications/src/db/database.ts +93 -0
  42. package/microservices/microservice-notifications/src/db/migrations.ts +62 -0
  43. package/microservices/microservice-notifications/src/db/notifications.ts +509 -0
  44. package/microservices/microservice-notifications/src/index.ts +41 -0
  45. package/microservices/microservice-notifications/src/mcp/index.ts +422 -0
  46. package/microservices/microservice-products/package.json +27 -0
  47. package/microservices/microservice-products/src/cli/index.ts +416 -0
  48. package/microservices/microservice-products/src/db/categories.ts +154 -0
  49. package/microservices/microservice-products/src/db/database.ts +93 -0
  50. package/microservices/microservice-products/src/db/migrations.ts +58 -0
  51. package/microservices/microservice-products/src/db/pricing-tiers.ts +66 -0
  52. package/microservices/microservice-products/src/db/products.ts +452 -0
  53. package/microservices/microservice-products/src/index.ts +53 -0
  54. package/microservices/microservice-products/src/mcp/index.ts +453 -0
  55. package/microservices/microservice-projects/package.json +27 -0
  56. package/microservices/microservice-projects/src/cli/index.ts +480 -0
  57. package/microservices/microservice-projects/src/db/database.ts +93 -0
  58. package/microservices/microservice-projects/src/db/migrations.ts +65 -0
  59. package/microservices/microservice-projects/src/db/projects.ts +715 -0
  60. package/microservices/microservice-projects/src/index.ts +57 -0
  61. package/microservices/microservice-projects/src/mcp/index.ts +501 -0
  62. package/microservices/microservice-proposals/package.json +27 -0
  63. package/microservices/microservice-proposals/src/cli/index.ts +400 -0
  64. package/microservices/microservice-proposals/src/db/database.ts +93 -0
  65. package/microservices/microservice-proposals/src/db/migrations.ts +52 -0
  66. package/microservices/microservice-proposals/src/db/proposals.ts +532 -0
  67. package/microservices/microservice-proposals/src/index.ts +37 -0
  68. package/microservices/microservice-proposals/src/mcp/index.ts +375 -0
  69. package/microservices/microservice-reading/package.json +27 -0
  70. package/microservices/microservice-reading/src/cli/index.ts +464 -0
  71. package/microservices/microservice-reading/src/db/database.ts +93 -0
  72. package/microservices/microservice-reading/src/db/migrations.ts +59 -0
  73. package/microservices/microservice-reading/src/db/reading.ts +524 -0
  74. package/microservices/microservice-reading/src/index.ts +51 -0
  75. package/microservices/microservice-reading/src/mcp/index.ts +368 -0
  76. package/microservices/microservice-travel/package.json +27 -0
  77. package/microservices/microservice-travel/src/cli/index.ts +505 -0
  78. package/microservices/microservice-travel/src/db/database.ts +93 -0
  79. package/microservices/microservice-travel/src/db/migrations.ts +77 -0
  80. package/microservices/microservice-travel/src/db/travel.ts +802 -0
  81. package/microservices/microservice-travel/src/index.ts +60 -0
  82. package/microservices/microservice-travel/src/mcp/index.ts +495 -0
  83. package/microservices/microservice-wiki/package.json +27 -0
  84. package/microservices/microservice-wiki/src/cli/index.ts +345 -0
  85. package/microservices/microservice-wiki/src/db/database.ts +93 -0
  86. package/microservices/microservice-wiki/src/db/migrations.ts +55 -0
  87. package/microservices/microservice-wiki/src/db/wiki.ts +395 -0
  88. package/microservices/microservice-wiki/src/index.ts +32 -0
  89. package/microservices/microservice-wiki/src/mcp/index.ts +344 -0
  90. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ /**
2
+ * microservice-analytics — Business analytics microservice
3
+ */
4
+
5
+ export {
6
+ recordKpi,
7
+ getKpiById,
8
+ getKpi,
9
+ getKpiTrend,
10
+ listKpis,
11
+ getLatestKpis,
12
+ deleteKpi,
13
+ createDashboard,
14
+ getDashboard,
15
+ listDashboards,
16
+ updateDashboard,
17
+ deleteDashboard,
18
+ generateReport,
19
+ getReport,
20
+ listReports,
21
+ deleteReport,
22
+ getBusinessHealth,
23
+ generateExecutiveSummary,
24
+ type Kpi,
25
+ type RecordKpiInput,
26
+ type ListKpisOptions,
27
+ type Dashboard,
28
+ type CreateDashboardInput,
29
+ type UpdateDashboardInput,
30
+ type Report,
31
+ type ReportType,
32
+ type GenerateReportInput,
33
+ type ListReportsOptions,
34
+ type BusinessHealth,
35
+ } from "./db/analytics.js";
36
+
37
+ export { getDatabase, closeDatabase } from "./db/database.js";
@@ -0,0 +1,334 @@
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
+ recordKpi,
8
+ getKpi,
9
+ getKpiTrend,
10
+ listKpis,
11
+ getLatestKpis,
12
+ deleteKpi,
13
+ createDashboard,
14
+ getDashboard,
15
+ listDashboards,
16
+ updateDashboard,
17
+ deleteDashboard,
18
+ generateReport,
19
+ getReport,
20
+ listReports,
21
+ deleteReport,
22
+ getBusinessHealth,
23
+ generateExecutiveSummary,
24
+ } from "../db/analytics.js";
25
+
26
+ const server = new McpServer({
27
+ name: "microservice-analytics",
28
+ version: "0.0.1",
29
+ });
30
+
31
+ // --- KPIs ---
32
+
33
+ server.registerTool(
34
+ "record_kpi",
35
+ {
36
+ title: "Record KPI",
37
+ description: "Record a KPI value.",
38
+ inputSchema: {
39
+ name: z.string(),
40
+ value: z.number(),
41
+ category: z.string().optional(),
42
+ source_service: z.string().optional(),
43
+ period: z.string().optional(),
44
+ },
45
+ },
46
+ async (params) => {
47
+ const kpi = recordKpi(params);
48
+ return { content: [{ type: "text", text: JSON.stringify(kpi, null, 2) }] };
49
+ }
50
+ );
51
+
52
+ server.registerTool(
53
+ "get_kpi",
54
+ {
55
+ title: "Get KPI",
56
+ description: "Get the latest value for a KPI by name.",
57
+ inputSchema: {
58
+ name: z.string(),
59
+ period: z.string().optional(),
60
+ },
61
+ },
62
+ async ({ name, period }) => {
63
+ const kpi = getKpi(name, period);
64
+ if (!kpi) {
65
+ return { content: [{ type: "text", text: `KPI '${name}' not found.` }], isError: true };
66
+ }
67
+ return { content: [{ type: "text", text: JSON.stringify(kpi, null, 2) }] };
68
+ }
69
+ );
70
+
71
+ server.registerTool(
72
+ "get_kpi_trend",
73
+ {
74
+ title: "Get KPI Trend",
75
+ description: "Get the trend for a KPI over a number of days.",
76
+ inputSchema: {
77
+ name: z.string(),
78
+ days: z.number().optional(),
79
+ },
80
+ },
81
+ async ({ name, days }) => {
82
+ const trend = getKpiTrend(name, days);
83
+ return {
84
+ content: [
85
+ { type: "text", text: JSON.stringify({ trend, count: trend.length }, null, 2) },
86
+ ],
87
+ };
88
+ }
89
+ );
90
+
91
+ server.registerTool(
92
+ "list_kpis",
93
+ {
94
+ title: "List KPIs",
95
+ description: "List KPIs with optional filters.",
96
+ inputSchema: {
97
+ category: z.string().optional(),
98
+ source_service: z.string().optional(),
99
+ limit: z.number().optional(),
100
+ },
101
+ },
102
+ async (params) => {
103
+ const kpis = listKpis(params);
104
+ return {
105
+ content: [
106
+ { type: "text", text: JSON.stringify({ kpis, count: kpis.length }, null, 2) },
107
+ ],
108
+ };
109
+ }
110
+ );
111
+
112
+ server.registerTool(
113
+ "get_latest_kpis",
114
+ {
115
+ title: "Get Latest KPIs",
116
+ description: "Get the most recent value for each unique KPI.",
117
+ inputSchema: {},
118
+ },
119
+ async () => {
120
+ const kpis = getLatestKpis();
121
+ return {
122
+ content: [
123
+ { type: "text", text: JSON.stringify({ kpis, count: kpis.length }, null, 2) },
124
+ ],
125
+ };
126
+ }
127
+ );
128
+
129
+ server.registerTool(
130
+ "delete_kpi",
131
+ {
132
+ title: "Delete KPI",
133
+ description: "Delete a KPI entry by ID.",
134
+ inputSchema: { id: z.string() },
135
+ },
136
+ async ({ id }) => {
137
+ const deleted = deleteKpi(id);
138
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
139
+ }
140
+ );
141
+
142
+ // --- Dashboards ---
143
+
144
+ server.registerTool(
145
+ "create_dashboard",
146
+ {
147
+ title: "Create Dashboard",
148
+ description: "Create a new dashboard.",
149
+ inputSchema: {
150
+ name: z.string(),
151
+ description: z.string().optional(),
152
+ widgets: z.array(z.unknown()).optional(),
153
+ },
154
+ },
155
+ async (params) => {
156
+ const dashboard = createDashboard(params);
157
+ return { content: [{ type: "text", text: JSON.stringify(dashboard, null, 2) }] };
158
+ }
159
+ );
160
+
161
+ server.registerTool(
162
+ "get_dashboard",
163
+ {
164
+ title: "Get Dashboard",
165
+ description: "Get a dashboard by ID.",
166
+ inputSchema: { id: z.string() },
167
+ },
168
+ async ({ id }) => {
169
+ const dashboard = getDashboard(id);
170
+ if (!dashboard) {
171
+ return { content: [{ type: "text", text: `Dashboard '${id}' not found.` }], isError: true };
172
+ }
173
+ return { content: [{ type: "text", text: JSON.stringify(dashboard, null, 2) }] };
174
+ }
175
+ );
176
+
177
+ server.registerTool(
178
+ "list_dashboards",
179
+ {
180
+ title: "List Dashboards",
181
+ description: "List all dashboards.",
182
+ inputSchema: {},
183
+ },
184
+ async () => {
185
+ const dashboards = listDashboards();
186
+ return {
187
+ content: [
188
+ { type: "text", text: JSON.stringify({ dashboards, count: dashboards.length }, null, 2) },
189
+ ],
190
+ };
191
+ }
192
+ );
193
+
194
+ server.registerTool(
195
+ "update_dashboard",
196
+ {
197
+ title: "Update Dashboard",
198
+ description: "Update a dashboard.",
199
+ inputSchema: {
200
+ id: z.string(),
201
+ name: z.string().optional(),
202
+ description: z.string().optional(),
203
+ widgets: z.array(z.unknown()).optional(),
204
+ },
205
+ },
206
+ async ({ id, ...input }) => {
207
+ const dashboard = updateDashboard(id, input);
208
+ if (!dashboard) {
209
+ return { content: [{ type: "text", text: `Dashboard '${id}' not found.` }], isError: true };
210
+ }
211
+ return { content: [{ type: "text", text: JSON.stringify(dashboard, null, 2) }] };
212
+ }
213
+ );
214
+
215
+ server.registerTool(
216
+ "delete_dashboard",
217
+ {
218
+ title: "Delete Dashboard",
219
+ description: "Delete a dashboard by ID.",
220
+ inputSchema: { id: z.string() },
221
+ },
222
+ async ({ id }) => {
223
+ const deleted = deleteDashboard(id);
224
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
225
+ }
226
+ );
227
+
228
+ // --- Reports ---
229
+
230
+ server.registerTool(
231
+ "generate_report",
232
+ {
233
+ title: "Generate Report",
234
+ description: "Generate a business report.",
235
+ inputSchema: {
236
+ name: z.string(),
237
+ type: z.enum(["daily", "weekly", "monthly", "quarterly", "annual", "custom"]),
238
+ period: z.string().optional(),
239
+ },
240
+ },
241
+ async (params) => {
242
+ const report = generateReport(params);
243
+ return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
244
+ }
245
+ );
246
+
247
+ server.registerTool(
248
+ "get_report",
249
+ {
250
+ title: "Get Report",
251
+ description: "Get a report by ID.",
252
+ inputSchema: { id: z.string() },
253
+ },
254
+ async ({ id }) => {
255
+ const report = getReport(id);
256
+ if (!report) {
257
+ return { content: [{ type: "text", text: `Report '${id}' not found.` }], isError: true };
258
+ }
259
+ return { content: [{ type: "text", text: JSON.stringify(report, null, 2) }] };
260
+ }
261
+ );
262
+
263
+ server.registerTool(
264
+ "list_reports",
265
+ {
266
+ title: "List Reports",
267
+ description: "List reports with optional filters.",
268
+ inputSchema: {
269
+ type: z.enum(["daily", "weekly", "monthly", "quarterly", "annual", "custom"]).optional(),
270
+ limit: z.number().optional(),
271
+ },
272
+ },
273
+ async (params) => {
274
+ const reports = listReports(params);
275
+ return {
276
+ content: [
277
+ { type: "text", text: JSON.stringify({ reports, count: reports.length }, null, 2) },
278
+ ],
279
+ };
280
+ }
281
+ );
282
+
283
+ server.registerTool(
284
+ "delete_report",
285
+ {
286
+ title: "Delete Report",
287
+ description: "Delete a report by ID.",
288
+ inputSchema: { id: z.string() },
289
+ },
290
+ async ({ id }) => {
291
+ const deleted = deleteReport(id);
292
+ return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
293
+ }
294
+ );
295
+
296
+ // --- Health & Summary ---
297
+
298
+ server.registerTool(
299
+ "get_business_health",
300
+ {
301
+ title: "Get Business Health",
302
+ description: "Get overall business health summary across all KPI categories.",
303
+ inputSchema: {},
304
+ },
305
+ async () => {
306
+ const health = getBusinessHealth();
307
+ return { content: [{ type: "text", text: JSON.stringify(health, null, 2) }] };
308
+ }
309
+ );
310
+
311
+ server.registerTool(
312
+ "generate_executive_summary",
313
+ {
314
+ title: "Generate Executive Summary",
315
+ description: "Generate an AI-powered executive summary of KPI trends.",
316
+ inputSchema: {},
317
+ },
318
+ async () => {
319
+ const summary = await generateExecutiveSummary();
320
+ return { content: [{ type: "text", text: summary }] };
321
+ }
322
+ );
323
+
324
+ // --- Start ---
325
+ async function main() {
326
+ const transport = new StdioServerTransport();
327
+ await server.connect(transport);
328
+ console.error("microservice-analytics MCP server running on stdio");
329
+ }
330
+
331
+ main().catch((error) => {
332
+ console.error("Fatal error:", error);
333
+ process.exit(1);
334
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@hasna/microservice-assets",
3
+ "version": "0.0.1",
4
+ "description": "Digital asset management microservice with SQLite — manage assets, collections, and metadata",
5
+ "type": "module",
6
+ "bin": {
7
+ "microservice-assets": "./src/cli/index.ts",
8
+ "microservice-assets-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
+ }