@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,375 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import { Command } from "commander";
4
+ import {
5
+ createAsset,
6
+ getAsset,
7
+ listAssets,
8
+ updateAsset,
9
+ deleteAsset,
10
+ searchAssets,
11
+ listByType,
12
+ listByTag,
13
+ getAssetStats,
14
+ } from "../db/assets.js";
15
+ import {
16
+ createCollection,
17
+ listCollections,
18
+ addToCollection,
19
+ removeFromCollection,
20
+ getCollectionAssets,
21
+ } from "../db/assets.js";
22
+
23
+ const program = new Command();
24
+
25
+ program
26
+ .name("microservice-assets")
27
+ .description("Digital asset management microservice")
28
+ .version("0.0.1");
29
+
30
+ // --- Assets ---
31
+
32
+ program
33
+ .command("create")
34
+ .description("Create a new asset")
35
+ .requiredOption("--name <name>", "Asset name")
36
+ .option("--description <desc>", "Description")
37
+ .option("--type <type>", "Asset type (image, video, document, audio, template, logo, font, other)")
38
+ .option("--file-path <path>", "File path")
39
+ .option("--file-size <size>", "File size in bytes")
40
+ .option("--mime-type <mime>", "MIME type")
41
+ .option("--dimensions <dims>", "Dimensions (e.g. 1920x1080)")
42
+ .option("--tags <tags>", "Comma-separated tags")
43
+ .option("--category <cat>", "Category")
44
+ .option("--uploaded-by <user>", "Uploaded by")
45
+ .option("--json", "Output as JSON", false)
46
+ .action((opts) => {
47
+ const asset = createAsset({
48
+ name: opts.name,
49
+ description: opts.description,
50
+ type: opts.type,
51
+ file_path: opts.filePath,
52
+ file_size: opts.fileSize ? parseInt(opts.fileSize) : undefined,
53
+ mime_type: opts.mimeType,
54
+ dimensions: opts.dimensions,
55
+ tags: opts.tags ? opts.tags.split(",").map((t: string) => t.trim()) : undefined,
56
+ category: opts.category,
57
+ uploaded_by: opts.uploadedBy,
58
+ });
59
+
60
+ if (opts.json) {
61
+ console.log(JSON.stringify(asset, null, 2));
62
+ } else {
63
+ console.log(`Created asset: ${asset.name} (${asset.id})`);
64
+ }
65
+ });
66
+
67
+ program
68
+ .command("get")
69
+ .description("Get an asset by ID")
70
+ .argument("<id>", "Asset ID")
71
+ .option("--json", "Output as JSON", false)
72
+ .action((id, opts) => {
73
+ const asset = getAsset(id);
74
+ if (!asset) {
75
+ console.error(`Asset '${id}' not found.`);
76
+ process.exit(1);
77
+ }
78
+
79
+ if (opts.json) {
80
+ console.log(JSON.stringify(asset, null, 2));
81
+ } else {
82
+ console.log(`${asset.name}`);
83
+ if (asset.type) console.log(` Type: ${asset.type}`);
84
+ if (asset.file_path) console.log(` Path: ${asset.file_path}`);
85
+ if (asset.file_size) console.log(` Size: ${asset.file_size} bytes`);
86
+ if (asset.mime_type) console.log(` MIME: ${asset.mime_type}`);
87
+ if (asset.dimensions) console.log(` Dimensions: ${asset.dimensions}`);
88
+ if (asset.category) console.log(` Category: ${asset.category}`);
89
+ if (asset.tags.length) console.log(` Tags: ${asset.tags.join(", ")}`);
90
+ if (asset.uploaded_by) console.log(` Uploaded by: ${asset.uploaded_by}`);
91
+ }
92
+ });
93
+
94
+ program
95
+ .command("list")
96
+ .description("List assets")
97
+ .option("--search <query>", "Search by name, description, or tags")
98
+ .option("--type <type>", "Filter by type")
99
+ .option("--category <cat>", "Filter by category")
100
+ .option("--tag <tag>", "Filter by tag")
101
+ .option("--limit <n>", "Limit results")
102
+ .option("--json", "Output as JSON", false)
103
+ .action((opts) => {
104
+ const assets = listAssets({
105
+ search: opts.search,
106
+ type: opts.type,
107
+ category: opts.category,
108
+ tag: opts.tag,
109
+ limit: opts.limit ? parseInt(opts.limit) : undefined,
110
+ });
111
+
112
+ if (opts.json) {
113
+ console.log(JSON.stringify(assets, null, 2));
114
+ } else {
115
+ if (assets.length === 0) {
116
+ console.log("No assets found.");
117
+ return;
118
+ }
119
+ for (const a of assets) {
120
+ const type = a.type ? ` [${a.type}]` : "";
121
+ const tags = a.tags.length ? ` (${a.tags.join(", ")})` : "";
122
+ console.log(` ${a.name}${type}${tags}`);
123
+ }
124
+ console.log(`\n${assets.length} asset(s)`);
125
+ }
126
+ });
127
+
128
+ program
129
+ .command("update")
130
+ .description("Update an asset")
131
+ .argument("<id>", "Asset ID")
132
+ .option("--name <name>", "Name")
133
+ .option("--description <desc>", "Description")
134
+ .option("--type <type>", "Type")
135
+ .option("--file-path <path>", "File path")
136
+ .option("--file-size <size>", "File size")
137
+ .option("--mime-type <mime>", "MIME type")
138
+ .option("--dimensions <dims>", "Dimensions")
139
+ .option("--tags <tags>", "Comma-separated tags")
140
+ .option("--category <cat>", "Category")
141
+ .option("--uploaded-by <user>", "Uploaded by")
142
+ .option("--json", "Output as JSON", false)
143
+ .action((id, opts) => {
144
+ const input: Record<string, unknown> = {};
145
+ if (opts.name !== undefined) input.name = opts.name;
146
+ if (opts.description !== undefined) input.description = opts.description;
147
+ if (opts.type !== undefined) input.type = opts.type;
148
+ if (opts.filePath !== undefined) input.file_path = opts.filePath;
149
+ if (opts.fileSize !== undefined) input.file_size = parseInt(opts.fileSize);
150
+ if (opts.mimeType !== undefined) input.mime_type = opts.mimeType;
151
+ if (opts.dimensions !== undefined) input.dimensions = opts.dimensions;
152
+ if (opts.tags !== undefined) input.tags = opts.tags.split(",").map((t: string) => t.trim());
153
+ if (opts.category !== undefined) input.category = opts.category;
154
+ if (opts.uploadedBy !== undefined) input.uploaded_by = opts.uploadedBy;
155
+
156
+ const asset = updateAsset(id, input);
157
+ if (!asset) {
158
+ console.error(`Asset '${id}' not found.`);
159
+ process.exit(1);
160
+ }
161
+
162
+ if (opts.json) {
163
+ console.log(JSON.stringify(asset, null, 2));
164
+ } else {
165
+ console.log(`Updated: ${asset.name}`);
166
+ }
167
+ });
168
+
169
+ program
170
+ .command("delete")
171
+ .description("Delete an asset")
172
+ .argument("<id>", "Asset ID")
173
+ .action((id) => {
174
+ const deleted = deleteAsset(id);
175
+ if (deleted) {
176
+ console.log(`Deleted asset ${id}`);
177
+ } else {
178
+ console.error(`Asset '${id}' not found.`);
179
+ process.exit(1);
180
+ }
181
+ });
182
+
183
+ program
184
+ .command("search")
185
+ .description("Search assets")
186
+ .argument("<query>", "Search term")
187
+ .option("--json", "Output as JSON", false)
188
+ .action((query, opts) => {
189
+ const results = searchAssets(query);
190
+
191
+ if (opts.json) {
192
+ console.log(JSON.stringify(results, null, 2));
193
+ } else {
194
+ if (results.length === 0) {
195
+ console.log(`No assets matching "${query}".`);
196
+ return;
197
+ }
198
+ for (const a of results) {
199
+ const type = a.type ? ` [${a.type}]` : "";
200
+ console.log(` ${a.name}${type}`);
201
+ }
202
+ }
203
+ });
204
+
205
+ program
206
+ .command("by-type")
207
+ .description("List assets by type")
208
+ .argument("<type>", "Asset type")
209
+ .option("--json", "Output as JSON", false)
210
+ .action((type, opts) => {
211
+ const assets = listByType(type);
212
+
213
+ if (opts.json) {
214
+ console.log(JSON.stringify(assets, null, 2));
215
+ } else {
216
+ if (assets.length === 0) {
217
+ console.log(`No assets of type "${type}".`);
218
+ return;
219
+ }
220
+ for (const a of assets) {
221
+ console.log(` ${a.name}`);
222
+ }
223
+ console.log(`\n${assets.length} asset(s)`);
224
+ }
225
+ });
226
+
227
+ program
228
+ .command("by-tag")
229
+ .description("List assets by tag")
230
+ .argument("<tag>", "Tag")
231
+ .option("--json", "Output as JSON", false)
232
+ .action((tag, opts) => {
233
+ const assets = listByTag(tag);
234
+
235
+ if (opts.json) {
236
+ console.log(JSON.stringify(assets, null, 2));
237
+ } else {
238
+ if (assets.length === 0) {
239
+ console.log(`No assets with tag "${tag}".`);
240
+ return;
241
+ }
242
+ for (const a of assets) {
243
+ console.log(` ${a.name} (${a.tags.join(", ")})`);
244
+ }
245
+ console.log(`\n${assets.length} asset(s)`);
246
+ }
247
+ });
248
+
249
+ program
250
+ .command("stats")
251
+ .description("Get asset statistics")
252
+ .option("--json", "Output as JSON", false)
253
+ .action((opts) => {
254
+ const stats = getAssetStats();
255
+
256
+ if (opts.json) {
257
+ console.log(JSON.stringify(stats, null, 2));
258
+ } else {
259
+ console.log(`Total assets: ${stats.total_assets}`);
260
+ console.log(`Total size: ${stats.total_size} bytes`);
261
+ if (Object.keys(stats.by_type).length) {
262
+ console.log("By type:");
263
+ for (const [type, count] of Object.entries(stats.by_type)) {
264
+ console.log(` ${type}: ${count}`);
265
+ }
266
+ }
267
+ if (Object.keys(stats.by_category).length) {
268
+ console.log("By category:");
269
+ for (const [cat, count] of Object.entries(stats.by_category)) {
270
+ console.log(` ${cat}: ${count}`);
271
+ }
272
+ }
273
+ }
274
+ });
275
+
276
+ // --- Collections ---
277
+
278
+ const collectionCmd = program
279
+ .command("collection")
280
+ .description("Collection management");
281
+
282
+ collectionCmd
283
+ .command("create")
284
+ .description("Create a collection")
285
+ .requiredOption("--name <name>", "Collection name")
286
+ .option("--description <desc>", "Description")
287
+ .option("--json", "Output as JSON", false)
288
+ .action((opts) => {
289
+ const collection = createCollection({
290
+ name: opts.name,
291
+ description: opts.description,
292
+ });
293
+
294
+ if (opts.json) {
295
+ console.log(JSON.stringify(collection, null, 2));
296
+ } else {
297
+ console.log(`Created collection: ${collection.name} (${collection.id})`);
298
+ }
299
+ });
300
+
301
+ collectionCmd
302
+ .command("list")
303
+ .description("List collections")
304
+ .option("--json", "Output as JSON", false)
305
+ .action((opts) => {
306
+ const collections = listCollections();
307
+
308
+ if (opts.json) {
309
+ console.log(JSON.stringify(collections, null, 2));
310
+ } else {
311
+ if (collections.length === 0) {
312
+ console.log("No collections found.");
313
+ return;
314
+ }
315
+ for (const c of collections) {
316
+ const desc = c.description ? ` — ${c.description}` : "";
317
+ console.log(` ${c.name}${desc}`);
318
+ }
319
+ }
320
+ });
321
+
322
+ collectionCmd
323
+ .command("add")
324
+ .description("Add an asset to a collection")
325
+ .requiredOption("--collection <id>", "Collection ID")
326
+ .requiredOption("--asset <id>", "Asset ID")
327
+ .action((opts) => {
328
+ const added = addToCollection(opts.collection, opts.asset);
329
+ if (added) {
330
+ console.log(`Added asset ${opts.asset} to collection ${opts.collection}`);
331
+ } else {
332
+ console.error("Failed to add asset to collection.");
333
+ process.exit(1);
334
+ }
335
+ });
336
+
337
+ collectionCmd
338
+ .command("remove")
339
+ .description("Remove an asset from a collection")
340
+ .requiredOption("--collection <id>", "Collection ID")
341
+ .requiredOption("--asset <id>", "Asset ID")
342
+ .action((opts) => {
343
+ const removed = removeFromCollection(opts.collection, opts.asset);
344
+ if (removed) {
345
+ console.log(`Removed asset ${opts.asset} from collection ${opts.collection}`);
346
+ } else {
347
+ console.error("Asset not in collection or collection not found.");
348
+ process.exit(1);
349
+ }
350
+ });
351
+
352
+ collectionCmd
353
+ .command("assets")
354
+ .description("List assets in a collection")
355
+ .argument("<collection-id>", "Collection ID")
356
+ .option("--json", "Output as JSON", false)
357
+ .action((collectionId, opts) => {
358
+ const assets = getCollectionAssets(collectionId);
359
+
360
+ if (opts.json) {
361
+ console.log(JSON.stringify(assets, null, 2));
362
+ } else {
363
+ if (assets.length === 0) {
364
+ console.log("No assets in collection.");
365
+ return;
366
+ }
367
+ for (const a of assets) {
368
+ const type = a.type ? ` [${a.type}]` : "";
369
+ console.log(` ${a.name}${type}`);
370
+ }
371
+ console.log(`\n${assets.length} asset(s)`);
372
+ }
373
+ });
374
+
375
+ program.parse(process.argv);