@hasna/microservices 0.0.16 → 0.0.18
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.
- package/README.md +143 -23
- package/bin/index.js +784 -13987
- package/bin/mcp.js +298 -10973
- package/dist/index.js +251 -10056
- package/package.json +36 -26
- package/microservices/microservice-ads/package.json +0 -28
- package/microservices/microservice-ads/src/cli/index.ts +0 -605
- package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
- package/microservices/microservice-ads/src/db/database.ts +0 -91
- package/microservices/microservice-ads/src/db/migrations.ts +0 -60
- package/microservices/microservice-ads/src/index.ts +0 -39
- package/microservices/microservice-ads/src/mcp/index.ts +0 -480
- package/microservices/microservice-analytics/package.json +0 -28
- package/microservices/microservice-analytics/src/cli/index.ts +0 -373
- package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
- package/microservices/microservice-analytics/src/db/database.ts +0 -91
- package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
- package/microservices/microservice-analytics/src/index.ts +0 -37
- package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
- package/microservices/microservice-assets/package.json +0 -28
- package/microservices/microservice-assets/src/cli/index.ts +0 -375
- package/microservices/microservice-assets/src/db/assets.ts +0 -370
- package/microservices/microservice-assets/src/db/database.ts +0 -91
- package/microservices/microservice-assets/src/db/migrations.ts +0 -51
- package/microservices/microservice-assets/src/index.ts +0 -32
- package/microservices/microservice-assets/src/mcp/index.ts +0 -346
- package/microservices/microservice-bookkeeping/package.json +0 -28
- package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
- package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
- package/microservices/microservice-bookkeeping/src/db/database.ts +0 -91
- package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
- package/microservices/microservice-bookkeeping/src/index.ts +0 -32
- package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
- package/microservices/microservice-calendar/package.json +0 -28
- package/microservices/microservice-calendar/src/cli/index.ts +0 -287
- package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
- package/microservices/microservice-calendar/src/db/database.ts +0 -91
- package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
- package/microservices/microservice-calendar/src/index.ts +0 -24
- package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
- package/microservices/microservice-company/package.json +0 -28
- package/microservices/microservice-company/src/cli/index.ts +0 -1126
- package/microservices/microservice-company/src/db/company.ts +0 -854
- package/microservices/microservice-company/src/db/database.ts +0 -91
- package/microservices/microservice-company/src/db/migrations.ts +0 -214
- package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
- package/microservices/microservice-company/src/index.ts +0 -60
- package/microservices/microservice-company/src/lib/audit.ts +0 -168
- package/microservices/microservice-company/src/lib/finance.ts +0 -299
- package/microservices/microservice-company/src/lib/settings.ts +0 -85
- package/microservices/microservice-company/src/lib/workflows.ts +0 -698
- package/microservices/microservice-company/src/mcp/index.ts +0 -991
- package/microservices/microservice-compliance/package.json +0 -28
- package/microservices/microservice-compliance/src/cli/index.ts +0 -467
- package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
- package/microservices/microservice-compliance/src/db/database.ts +0 -91
- package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
- package/microservices/microservice-compliance/src/index.ts +0 -46
- package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
- package/microservices/microservice-contacts/package.json +0 -28
- package/microservices/microservice-contacts/src/cli/index.ts +0 -393
- package/microservices/microservice-contacts/src/db/companies.ts +0 -167
- package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
- package/microservices/microservice-contacts/src/db/database.ts +0 -91
- package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
- package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
- package/microservices/microservice-contacts/src/index.ts +0 -42
- package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
- package/microservices/microservice-contracts/package.json +0 -28
- package/microservices/microservice-contracts/src/cli/index.ts +0 -770
- package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
- package/microservices/microservice-contracts/src/db/database.ts +0 -91
- package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
- package/microservices/microservice-contracts/src/index.ts +0 -43
- package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
- package/microservices/microservice-crm/package.json +0 -28
- package/microservices/microservice-crm/src/cli/index.ts +0 -396
- package/microservices/microservice-crm/src/db/database.ts +0 -91
- package/microservices/microservice-crm/src/db/migrations.ts +0 -66
- package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
- package/microservices/microservice-crm/src/index.ts +0 -34
- package/microservices/microservice-crm/src/mcp/index.ts +0 -294
- package/microservices/microservice-documents/package.json +0 -28
- package/microservices/microservice-documents/src/cli/index.ts +0 -246
- package/microservices/microservice-documents/src/db/database.ts +0 -91
- package/microservices/microservice-documents/src/db/documents.ts +0 -316
- package/microservices/microservice-documents/src/db/migrations.ts +0 -49
- package/microservices/microservice-documents/src/index.ts +0 -24
- package/microservices/microservice-documents/src/mcp/index.ts +0 -202
- package/microservices/microservice-domains/package.json +0 -28
- package/microservices/microservice-domains/src/cli/index.ts +0 -1111
- package/microservices/microservice-domains/src/db/database.ts +0 -91
- package/microservices/microservice-domains/src/db/domains.ts +0 -1164
- package/microservices/microservice-domains/src/db/migrations.ts +0 -60
- package/microservices/microservice-domains/src/index.ts +0 -65
- package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
- package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
- package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
- package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
- package/microservices/microservice-domains/src/mcp/index.ts +0 -781
- package/microservices/microservice-expenses/package.json +0 -28
- package/microservices/microservice-expenses/src/cli/index.ts +0 -267
- package/microservices/microservice-expenses/src/db/database.ts +0 -91
- package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
- package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
- package/microservices/microservice-expenses/src/index.ts +0 -25
- package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
- package/microservices/microservice-habits/package.json +0 -28
- package/microservices/microservice-habits/src/cli/index.ts +0 -315
- package/microservices/microservice-habits/src/db/database.ts +0 -91
- package/microservices/microservice-habits/src/db/habits.ts +0 -451
- package/microservices/microservice-habits/src/db/migrations.ts +0 -46
- package/microservices/microservice-habits/src/index.ts +0 -31
- package/microservices/microservice-habits/src/mcp/index.ts +0 -313
- package/microservices/microservice-health/package.json +0 -28
- package/microservices/microservice-health/src/cli/index.ts +0 -484
- package/microservices/microservice-health/src/db/database.ts +0 -91
- package/microservices/microservice-health/src/db/health.ts +0 -708
- package/microservices/microservice-health/src/db/migrations.ts +0 -70
- package/microservices/microservice-health/src/index.ts +0 -63
- package/microservices/microservice-health/src/mcp/index.ts +0 -437
- package/microservices/microservice-hiring/package.json +0 -28
- package/microservices/microservice-hiring/src/cli/index.ts +0 -741
- package/microservices/microservice-hiring/src/db/database.ts +0 -91
- package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
- package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
- package/microservices/microservice-hiring/src/index.ts +0 -80
- package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
- package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
- package/microservices/microservice-inventory/package.json +0 -28
- package/microservices/microservice-inventory/src/cli/index.ts +0 -365
- package/microservices/microservice-inventory/src/db/database.ts +0 -91
- package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
- package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
- package/microservices/microservice-inventory/src/index.ts +0 -28
- package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
- package/microservices/microservice-invoices/dashboard/index.html +0 -12
- package/microservices/microservice-invoices/dashboard/package.json +0 -29
- package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
- package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
- package/microservices/microservice-invoices/package.json +0 -31
- package/microservices/microservice-invoices/src/cli/index.ts +0 -308
- package/microservices/microservice-invoices/src/db/business.ts +0 -241
- package/microservices/microservice-invoices/src/db/clients.ts +0 -127
- package/microservices/microservice-invoices/src/db/database.ts +0 -91
- package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
- package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
- package/microservices/microservice-invoices/src/index.ts +0 -56
- package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
- package/microservices/microservice-invoices/src/server/index.ts +0 -162
- package/microservices/microservice-leads/package.json +0 -28
- package/microservices/microservice-leads/src/cli/index.ts +0 -596
- package/microservices/microservice-leads/src/db/database.ts +0 -91
- package/microservices/microservice-leads/src/db/leads.ts +0 -520
- package/microservices/microservice-leads/src/db/lists.ts +0 -151
- package/microservices/microservice-leads/src/db/migrations.ts +0 -93
- package/microservices/microservice-leads/src/index.ts +0 -65
- package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
- package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
- package/microservices/microservice-leads/src/mcp/index.ts +0 -533
- package/microservices/microservice-notes/package.json +0 -28
- package/microservices/microservice-notes/src/cli/index.ts +0 -63
- package/microservices/microservice-notes/src/db/database.ts +0 -91
- package/microservices/microservice-notes/src/db/migrations.ts +0 -40
- package/microservices/microservice-notes/src/db/notes.ts +0 -114
- package/microservices/microservice-notes/src/index.ts +0 -2
- package/microservices/microservice-notes/src/mcp/index.ts +0 -37
- package/microservices/microservice-notifications/package.json +0 -28
- package/microservices/microservice-notifications/src/cli/index.ts +0 -349
- package/microservices/microservice-notifications/src/db/database.ts +0 -91
- package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
- package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
- package/microservices/microservice-notifications/src/index.ts +0 -41
- package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
- package/microservices/microservice-payments/package.json +0 -28
- package/microservices/microservice-payments/src/cli/index.ts +0 -609
- package/microservices/microservice-payments/src/db/database.ts +0 -91
- package/microservices/microservice-payments/src/db/migrations.ts +0 -81
- package/microservices/microservice-payments/src/db/payments.ts +0 -1204
- package/microservices/microservice-payments/src/index.ts +0 -51
- package/microservices/microservice-payments/src/mcp/index.ts +0 -683
- package/microservices/microservice-payroll/package.json +0 -28
- package/microservices/microservice-payroll/src/cli/index.ts +0 -643
- package/microservices/microservice-payroll/src/db/database.ts +0 -91
- package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
- package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
- package/microservices/microservice-payroll/src/index.ts +0 -48
- package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
- package/microservices/microservice-products/package.json +0 -28
- package/microservices/microservice-products/src/cli/index.ts +0 -416
- package/microservices/microservice-products/src/db/categories.ts +0 -154
- package/microservices/microservice-products/src/db/database.ts +0 -91
- package/microservices/microservice-products/src/db/migrations.ts +0 -58
- package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
- package/microservices/microservice-products/src/db/products.ts +0 -452
- package/microservices/microservice-products/src/index.ts +0 -53
- package/microservices/microservice-products/src/mcp/index.ts +0 -453
- package/microservices/microservice-projects/package.json +0 -28
- package/microservices/microservice-projects/src/cli/index.ts +0 -480
- package/microservices/microservice-projects/src/db/database.ts +0 -91
- package/microservices/microservice-projects/src/db/migrations.ts +0 -65
- package/microservices/microservice-projects/src/db/projects.ts +0 -715
- package/microservices/microservice-projects/src/index.ts +0 -57
- package/microservices/microservice-projects/src/mcp/index.ts +0 -501
- package/microservices/microservice-proposals/package.json +0 -28
- package/microservices/microservice-proposals/src/cli/index.ts +0 -400
- package/microservices/microservice-proposals/src/db/database.ts +0 -91
- package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
- package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
- package/microservices/microservice-proposals/src/index.ts +0 -37
- package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
- package/microservices/microservice-reading/package.json +0 -28
- package/microservices/microservice-reading/src/cli/index.ts +0 -464
- package/microservices/microservice-reading/src/db/database.ts +0 -91
- package/microservices/microservice-reading/src/db/migrations.ts +0 -59
- package/microservices/microservice-reading/src/db/reading.ts +0 -524
- package/microservices/microservice-reading/src/index.ts +0 -51
- package/microservices/microservice-reading/src/mcp/index.ts +0 -368
- package/microservices/microservice-shipping/package.json +0 -28
- package/microservices/microservice-shipping/src/cli/index.ts +0 -606
- package/microservices/microservice-shipping/src/db/database.ts +0 -91
- package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
- package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
- package/microservices/microservice-shipping/src/index.ts +0 -53
- package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
- package/microservices/microservice-social/package.json +0 -29
- package/microservices/microservice-social/src/cli/index.ts +0 -1583
- package/microservices/microservice-social/src/db/database.ts +0 -91
- package/microservices/microservice-social/src/db/migrations.ts +0 -160
- package/microservices/microservice-social/src/db/social.ts +0 -1076
- package/microservices/microservice-social/src/index.ts +0 -46
- package/microservices/microservice-social/src/lib/audience.ts +0 -353
- package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
- package/microservices/microservice-social/src/lib/media.ts +0 -311
- package/microservices/microservice-social/src/lib/mentions.ts +0 -434
- package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
- package/microservices/microservice-social/src/lib/publisher.ts +0 -377
- package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
- package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
- package/microservices/microservice-social/src/lib/threads.ts +0 -291
- package/microservices/microservice-social/src/mcp/index.ts +0 -1425
- package/microservices/microservice-social/src/server/index.ts +0 -441
- package/microservices/microservice-subscriptions/package.json +0 -28
- package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
- package/microservices/microservice-subscriptions/src/db/database.ts +0 -91
- package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
- package/microservices/microservice-subscriptions/src/index.ts +0 -41
- package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
- package/microservices/microservice-timesheets/package.json +0 -28
- package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
- package/microservices/microservice-timesheets/src/db/database.ts +0 -91
- package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
- package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
- package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
- package/microservices/microservice-timesheets/src/index.ts +0 -44
- package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
- package/microservices/microservice-transcriber/package.json +0 -29
- package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
- package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
- package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
- package/microservices/microservice-transcriber/src/db/database.ts +0 -91
- package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
- package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
- package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
- package/microservices/microservice-transcriber/src/index.ts +0 -43
- package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
- package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
- package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
- package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
- package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
- package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
- package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
- package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
- package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
- package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
- package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
- package/microservices/microservice-transcriber/src/server/index.ts +0 -199
- package/microservices/microservice-travel/package.json +0 -28
- package/microservices/microservice-travel/src/cli/index.ts +0 -505
- package/microservices/microservice-travel/src/db/database.ts +0 -91
- package/microservices/microservice-travel/src/db/migrations.ts +0 -77
- package/microservices/microservice-travel/src/db/travel.ts +0 -802
- package/microservices/microservice-travel/src/index.ts +0 -60
- package/microservices/microservice-travel/src/mcp/index.ts +0 -495
- package/microservices/microservice-wiki/package.json +0 -28
- package/microservices/microservice-wiki/src/cli/index.ts +0 -345
- package/microservices/microservice-wiki/src/db/database.ts +0 -91
- package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
- package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
- package/microservices/microservice-wiki/src/index.ts +0 -32
- package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
|
@@ -1,533 +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
|
-
createLead,
|
|
8
|
-
getLead,
|
|
9
|
-
listLeads,
|
|
10
|
-
updateLead,
|
|
11
|
-
deleteLead,
|
|
12
|
-
searchLeads,
|
|
13
|
-
bulkImportLeads,
|
|
14
|
-
exportLeads,
|
|
15
|
-
addActivity,
|
|
16
|
-
getActivities,
|
|
17
|
-
getLeadTimeline,
|
|
18
|
-
getLeadStats,
|
|
19
|
-
getPipeline,
|
|
20
|
-
deduplicateLeads,
|
|
21
|
-
mergeLeads,
|
|
22
|
-
} from "../db/leads.js";
|
|
23
|
-
import {
|
|
24
|
-
createList,
|
|
25
|
-
listLists,
|
|
26
|
-
getListMembers,
|
|
27
|
-
getSmartListMembers,
|
|
28
|
-
addToList,
|
|
29
|
-
removeFromList,
|
|
30
|
-
deleteList,
|
|
31
|
-
} from "../db/lists.js";
|
|
32
|
-
import { enrichLead, bulkEnrich } from "../lib/enrichment.js";
|
|
33
|
-
import { scoreLead, autoScoreAll, getScoreDistribution } from "../lib/scoring.js";
|
|
34
|
-
|
|
35
|
-
const server = new McpServer({
|
|
36
|
-
name: "microservice-leads",
|
|
37
|
-
version: "0.0.1",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// --- Lead CRUD ---
|
|
41
|
-
|
|
42
|
-
server.registerTool(
|
|
43
|
-
"create_lead",
|
|
44
|
-
{
|
|
45
|
-
title: "Create Lead",
|
|
46
|
-
description: "Create a new lead.",
|
|
47
|
-
inputSchema: {
|
|
48
|
-
name: z.string().optional(),
|
|
49
|
-
email: z.string().optional(),
|
|
50
|
-
phone: z.string().optional(),
|
|
51
|
-
company: z.string().optional(),
|
|
52
|
-
title: z.string().optional(),
|
|
53
|
-
website: z.string().optional(),
|
|
54
|
-
linkedin_url: z.string().optional(),
|
|
55
|
-
source: z.string().optional(),
|
|
56
|
-
tags: z.array(z.string()).optional(),
|
|
57
|
-
notes: z.string().optional(),
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
async (params) => {
|
|
61
|
-
const lead = createLead(params);
|
|
62
|
-
return { content: [{ type: "text", text: JSON.stringify(lead, null, 2) }] };
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
server.registerTool(
|
|
67
|
-
"get_lead",
|
|
68
|
-
{
|
|
69
|
-
title: "Get Lead",
|
|
70
|
-
description: "Get a lead by ID.",
|
|
71
|
-
inputSchema: { id: z.string() },
|
|
72
|
-
},
|
|
73
|
-
async ({ id }) => {
|
|
74
|
-
const lead = getLead(id);
|
|
75
|
-
if (!lead) {
|
|
76
|
-
return { content: [{ type: "text", text: `Lead '${id}' not found.` }], isError: true };
|
|
77
|
-
}
|
|
78
|
-
return { content: [{ type: "text", text: JSON.stringify(lead, null, 2) }] };
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
server.registerTool(
|
|
83
|
-
"list_leads",
|
|
84
|
-
{
|
|
85
|
-
title: "List Leads",
|
|
86
|
-
description: "List leads with optional filters.",
|
|
87
|
-
inputSchema: {
|
|
88
|
-
status: z.string().optional(),
|
|
89
|
-
source: z.string().optional(),
|
|
90
|
-
score_min: z.number().optional(),
|
|
91
|
-
score_max: z.number().optional(),
|
|
92
|
-
enriched: z.boolean().optional(),
|
|
93
|
-
limit: z.number().optional(),
|
|
94
|
-
offset: z.number().optional(),
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
async (params) => {
|
|
98
|
-
const leads = listLeads(params);
|
|
99
|
-
return {
|
|
100
|
-
content: [
|
|
101
|
-
{ type: "text", text: JSON.stringify({ leads, count: leads.length }, null, 2) },
|
|
102
|
-
],
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
server.registerTool(
|
|
108
|
-
"update_lead",
|
|
109
|
-
{
|
|
110
|
-
title: "Update Lead",
|
|
111
|
-
description: "Update an existing lead.",
|
|
112
|
-
inputSchema: {
|
|
113
|
-
id: z.string(),
|
|
114
|
-
name: z.string().optional(),
|
|
115
|
-
email: z.string().optional(),
|
|
116
|
-
phone: z.string().optional(),
|
|
117
|
-
company: z.string().optional(),
|
|
118
|
-
title: z.string().optional(),
|
|
119
|
-
website: z.string().optional(),
|
|
120
|
-
linkedin_url: z.string().optional(),
|
|
121
|
-
source: z.string().optional(),
|
|
122
|
-
status: z.string().optional(),
|
|
123
|
-
tags: z.array(z.string()).optional(),
|
|
124
|
-
notes: z.string().optional(),
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
async ({ id, ...input }) => {
|
|
128
|
-
const lead = updateLead(id, input);
|
|
129
|
-
if (!lead) {
|
|
130
|
-
return { content: [{ type: "text", text: `Lead '${id}' not found.` }], isError: true };
|
|
131
|
-
}
|
|
132
|
-
return { content: [{ type: "text", text: JSON.stringify(lead, null, 2) }] };
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
server.registerTool(
|
|
137
|
-
"delete_lead",
|
|
138
|
-
{
|
|
139
|
-
title: "Delete Lead",
|
|
140
|
-
description: "Delete a lead by ID.",
|
|
141
|
-
inputSchema: { id: z.string() },
|
|
142
|
-
},
|
|
143
|
-
async ({ id }) => {
|
|
144
|
-
const deleted = deleteLead(id);
|
|
145
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
server.registerTool(
|
|
150
|
-
"search_leads",
|
|
151
|
-
{
|
|
152
|
-
title: "Search Leads",
|
|
153
|
-
description: "Search leads by name, email, or company.",
|
|
154
|
-
inputSchema: { query: z.string() },
|
|
155
|
-
},
|
|
156
|
-
async ({ query }) => {
|
|
157
|
-
const results = searchLeads(query);
|
|
158
|
-
return {
|
|
159
|
-
content: [
|
|
160
|
-
{ type: "text", text: JSON.stringify({ results, count: results.length }, null, 2) },
|
|
161
|
-
],
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
// --- Import/Export ---
|
|
167
|
-
|
|
168
|
-
server.registerTool(
|
|
169
|
-
"bulk_import_leads",
|
|
170
|
-
{
|
|
171
|
-
title: "Bulk Import Leads",
|
|
172
|
-
description: "Import multiple leads at once with deduplication by email.",
|
|
173
|
-
inputSchema: {
|
|
174
|
-
leads: z.array(
|
|
175
|
-
z.object({
|
|
176
|
-
name: z.string().optional(),
|
|
177
|
-
email: z.string().optional(),
|
|
178
|
-
phone: z.string().optional(),
|
|
179
|
-
company: z.string().optional(),
|
|
180
|
-
title: z.string().optional(),
|
|
181
|
-
website: z.string().optional(),
|
|
182
|
-
linkedin_url: z.string().optional(),
|
|
183
|
-
source: z.string().optional(),
|
|
184
|
-
})
|
|
185
|
-
),
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
async ({ leads }) => {
|
|
189
|
-
const result = bulkImportLeads(leads);
|
|
190
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
191
|
-
}
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
server.registerTool(
|
|
195
|
-
"export_leads",
|
|
196
|
-
{
|
|
197
|
-
title: "Export Leads",
|
|
198
|
-
description: "Export leads in CSV or JSON format.",
|
|
199
|
-
inputSchema: {
|
|
200
|
-
format: z.enum(["csv", "json"]).optional(),
|
|
201
|
-
status: z.string().optional(),
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
async ({ format, status }) => {
|
|
205
|
-
const output = exportLeads(format || "json", status ? { status } : undefined);
|
|
206
|
-
return { content: [{ type: "text", text: output }] };
|
|
207
|
-
}
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
// --- Enrichment ---
|
|
211
|
-
|
|
212
|
-
server.registerTool(
|
|
213
|
-
"enrich_lead",
|
|
214
|
-
{
|
|
215
|
-
title: "Enrich Lead",
|
|
216
|
-
description: "Enrich a lead with data from email/domain research.",
|
|
217
|
-
inputSchema: { id: z.string() },
|
|
218
|
-
},
|
|
219
|
-
async ({ id }) => {
|
|
220
|
-
const lead = enrichLead(id);
|
|
221
|
-
if (!lead) {
|
|
222
|
-
return { content: [{ type: "text", text: `Lead '${id}' not found.` }], isError: true };
|
|
223
|
-
}
|
|
224
|
-
return { content: [{ type: "text", text: JSON.stringify(lead, null, 2) }] };
|
|
225
|
-
}
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
server.registerTool(
|
|
229
|
-
"bulk_enrich_leads",
|
|
230
|
-
{
|
|
231
|
-
title: "Bulk Enrich Leads",
|
|
232
|
-
description: "Enrich multiple leads by their IDs.",
|
|
233
|
-
inputSchema: { lead_ids: z.array(z.string()) },
|
|
234
|
-
},
|
|
235
|
-
async ({ lead_ids }) => {
|
|
236
|
-
const result = bulkEnrich(lead_ids);
|
|
237
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
// --- Scoring ---
|
|
242
|
-
|
|
243
|
-
server.registerTool(
|
|
244
|
-
"score_lead",
|
|
245
|
-
{
|
|
246
|
-
title: "Score Lead",
|
|
247
|
-
description: "Score a lead (0-100) based on data completeness and engagement.",
|
|
248
|
-
inputSchema: { id: z.string() },
|
|
249
|
-
},
|
|
250
|
-
async ({ id }) => {
|
|
251
|
-
const result = scoreLead(id);
|
|
252
|
-
if (!result) {
|
|
253
|
-
return { content: [{ type: "text", text: `Lead '${id}' not found.` }], isError: true };
|
|
254
|
-
}
|
|
255
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
server.registerTool(
|
|
260
|
-
"auto_score_all",
|
|
261
|
-
{
|
|
262
|
-
title: "Auto Score All",
|
|
263
|
-
description: "Auto-score all leads with score=0.",
|
|
264
|
-
inputSchema: {},
|
|
265
|
-
},
|
|
266
|
-
async () => {
|
|
267
|
-
const result = autoScoreAll();
|
|
268
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
server.registerTool(
|
|
273
|
-
"get_score_distribution",
|
|
274
|
-
{
|
|
275
|
-
title: "Score Distribution",
|
|
276
|
-
description: "Get the distribution of lead scores across ranges.",
|
|
277
|
-
inputSchema: {},
|
|
278
|
-
},
|
|
279
|
-
async () => {
|
|
280
|
-
const distribution = getScoreDistribution();
|
|
281
|
-
return { content: [{ type: "text", text: JSON.stringify(distribution, null, 2) }] };
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
// --- Pipeline & Stats ---
|
|
286
|
-
|
|
287
|
-
server.registerTool(
|
|
288
|
-
"get_lead_stats",
|
|
289
|
-
{
|
|
290
|
-
title: "Lead Stats",
|
|
291
|
-
description: "Get lead statistics including totals, by status, by source, avg score, and conversion rate.",
|
|
292
|
-
inputSchema: {},
|
|
293
|
-
},
|
|
294
|
-
async () => {
|
|
295
|
-
const stats = getLeadStats();
|
|
296
|
-
return { content: [{ type: "text", text: JSON.stringify(stats, null, 2) }] };
|
|
297
|
-
}
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
server.registerTool(
|
|
301
|
-
"get_pipeline",
|
|
302
|
-
{
|
|
303
|
-
title: "Lead Pipeline",
|
|
304
|
-
description: "Get the lead pipeline funnel view.",
|
|
305
|
-
inputSchema: {},
|
|
306
|
-
},
|
|
307
|
-
async () => {
|
|
308
|
-
const pipeline = getPipeline();
|
|
309
|
-
return { content: [{ type: "text", text: JSON.stringify(pipeline, null, 2) }] };
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
|
|
313
|
-
// --- Activities ---
|
|
314
|
-
|
|
315
|
-
server.registerTool(
|
|
316
|
-
"add_activity",
|
|
317
|
-
{
|
|
318
|
-
title: "Add Activity",
|
|
319
|
-
description: "Add an activity to a lead.",
|
|
320
|
-
inputSchema: {
|
|
321
|
-
lead_id: z.string(),
|
|
322
|
-
type: z.enum(["email_sent", "email_opened", "call", "meeting", "note", "status_change", "score_change", "enriched"]),
|
|
323
|
-
description: z.string().optional(),
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
async ({ lead_id, type, description }) => {
|
|
327
|
-
const activity = addActivity(lead_id, type, description);
|
|
328
|
-
return { content: [{ type: "text", text: JSON.stringify(activity, null, 2) }] };
|
|
329
|
-
}
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
server.registerTool(
|
|
333
|
-
"get_activities",
|
|
334
|
-
{
|
|
335
|
-
title: "Get Activities",
|
|
336
|
-
description: "Get activities for a lead.",
|
|
337
|
-
inputSchema: {
|
|
338
|
-
lead_id: z.string(),
|
|
339
|
-
limit: z.number().optional(),
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
async ({ lead_id, limit }) => {
|
|
343
|
-
const activities = limit ? getActivities(lead_id, limit) : getActivities(lead_id);
|
|
344
|
-
return {
|
|
345
|
-
content: [
|
|
346
|
-
{ type: "text", text: JSON.stringify({ activities, count: activities.length }, null, 2) },
|
|
347
|
-
],
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
);
|
|
351
|
-
|
|
352
|
-
server.registerTool(
|
|
353
|
-
"get_lead_timeline",
|
|
354
|
-
{
|
|
355
|
-
title: "Lead Timeline",
|
|
356
|
-
description: "Get full activity timeline for a lead.",
|
|
357
|
-
inputSchema: { lead_id: z.string() },
|
|
358
|
-
},
|
|
359
|
-
async ({ lead_id }) => {
|
|
360
|
-
const timeline = getLeadTimeline(lead_id);
|
|
361
|
-
return {
|
|
362
|
-
content: [
|
|
363
|
-
{ type: "text", text: JSON.stringify({ timeline, count: timeline.length }, null, 2) },
|
|
364
|
-
],
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
// --- Dedup & Merge ---
|
|
370
|
-
|
|
371
|
-
server.registerTool(
|
|
372
|
-
"deduplicate_leads",
|
|
373
|
-
{
|
|
374
|
-
title: "Deduplicate Leads",
|
|
375
|
-
description: "Find duplicate leads by email.",
|
|
376
|
-
inputSchema: {},
|
|
377
|
-
},
|
|
378
|
-
async () => {
|
|
379
|
-
const pairs = deduplicateLeads();
|
|
380
|
-
return { content: [{ type: "text", text: JSON.stringify({ pairs, count: pairs.length }, null, 2) }] };
|
|
381
|
-
}
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
server.registerTool(
|
|
385
|
-
"merge_leads",
|
|
386
|
-
{
|
|
387
|
-
title: "Merge Leads",
|
|
388
|
-
description: "Merge two leads — keep the first, merge data from the second, delete the second.",
|
|
389
|
-
inputSchema: {
|
|
390
|
-
keep_id: z.string(),
|
|
391
|
-
merge_id: z.string(),
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
async ({ keep_id, merge_id }) => {
|
|
395
|
-
const result = mergeLeads(keep_id, merge_id);
|
|
396
|
-
if (!result) {
|
|
397
|
-
return { content: [{ type: "text", text: "One or both leads not found." }], isError: true };
|
|
398
|
-
}
|
|
399
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
// --- Convert ---
|
|
404
|
-
|
|
405
|
-
server.registerTool(
|
|
406
|
-
"convert_lead",
|
|
407
|
-
{
|
|
408
|
-
title: "Convert Lead",
|
|
409
|
-
description: "Mark a lead as converted.",
|
|
410
|
-
inputSchema: { id: z.string() },
|
|
411
|
-
},
|
|
412
|
-
async ({ id }) => {
|
|
413
|
-
const lead = updateLead(id, { status: "converted" });
|
|
414
|
-
if (!lead) {
|
|
415
|
-
return { content: [{ type: "text", text: `Lead '${id}' not found.` }], isError: true };
|
|
416
|
-
}
|
|
417
|
-
addActivity(id, "status_change", "Lead converted");
|
|
418
|
-
return { content: [{ type: "text", text: JSON.stringify(lead, null, 2) }] };
|
|
419
|
-
}
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
// --- Lists ---
|
|
423
|
-
|
|
424
|
-
server.registerTool(
|
|
425
|
-
"create_lead_list",
|
|
426
|
-
{
|
|
427
|
-
title: "Create Lead List",
|
|
428
|
-
description: "Create a lead list.",
|
|
429
|
-
inputSchema: {
|
|
430
|
-
name: z.string(),
|
|
431
|
-
description: z.string().optional(),
|
|
432
|
-
filter_query: z.string().optional(),
|
|
433
|
-
},
|
|
434
|
-
},
|
|
435
|
-
async (params) => {
|
|
436
|
-
const list = createList(params);
|
|
437
|
-
return { content: [{ type: "text", text: JSON.stringify(list, null, 2) }] };
|
|
438
|
-
}
|
|
439
|
-
);
|
|
440
|
-
|
|
441
|
-
server.registerTool(
|
|
442
|
-
"list_lead_lists",
|
|
443
|
-
{
|
|
444
|
-
title: "List Lead Lists",
|
|
445
|
-
description: "List all lead lists.",
|
|
446
|
-
inputSchema: {},
|
|
447
|
-
},
|
|
448
|
-
async () => {
|
|
449
|
-
const lists = listLists();
|
|
450
|
-
return {
|
|
451
|
-
content: [
|
|
452
|
-
{ type: "text", text: JSON.stringify({ lists, count: lists.length }, null, 2) },
|
|
453
|
-
],
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
server.registerTool(
|
|
459
|
-
"get_list_members",
|
|
460
|
-
{
|
|
461
|
-
title: "Get List Members",
|
|
462
|
-
description: "Get members of a lead list. For smart lists with filter_query, returns dynamically matched leads.",
|
|
463
|
-
inputSchema: {
|
|
464
|
-
list_id: z.string(),
|
|
465
|
-
smart: z.boolean().optional(),
|
|
466
|
-
},
|
|
467
|
-
},
|
|
468
|
-
async ({ list_id, smart }) => {
|
|
469
|
-
const members = smart ? getSmartListMembers(list_id) : getListMembers(list_id);
|
|
470
|
-
return {
|
|
471
|
-
content: [
|
|
472
|
-
{ type: "text", text: JSON.stringify({ members, count: members.length }, null, 2) },
|
|
473
|
-
],
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
);
|
|
477
|
-
|
|
478
|
-
server.registerTool(
|
|
479
|
-
"add_to_list",
|
|
480
|
-
{
|
|
481
|
-
title: "Add to List",
|
|
482
|
-
description: "Add a lead to a list.",
|
|
483
|
-
inputSchema: {
|
|
484
|
-
list_id: z.string(),
|
|
485
|
-
lead_id: z.string(),
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
async ({ list_id, lead_id }) => {
|
|
489
|
-
const added = addToList(list_id, lead_id);
|
|
490
|
-
return { content: [{ type: "text", text: JSON.stringify({ list_id, lead_id, added }) }] };
|
|
491
|
-
}
|
|
492
|
-
);
|
|
493
|
-
|
|
494
|
-
server.registerTool(
|
|
495
|
-
"remove_from_list",
|
|
496
|
-
{
|
|
497
|
-
title: "Remove from List",
|
|
498
|
-
description: "Remove a lead from a list.",
|
|
499
|
-
inputSchema: {
|
|
500
|
-
list_id: z.string(),
|
|
501
|
-
lead_id: z.string(),
|
|
502
|
-
},
|
|
503
|
-
},
|
|
504
|
-
async ({ list_id, lead_id }) => {
|
|
505
|
-
const removed = removeFromList(list_id, lead_id);
|
|
506
|
-
return { content: [{ type: "text", text: JSON.stringify({ list_id, lead_id, removed }) }] };
|
|
507
|
-
}
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
server.registerTool(
|
|
511
|
-
"delete_lead_list",
|
|
512
|
-
{
|
|
513
|
-
title: "Delete Lead List",
|
|
514
|
-
description: "Delete a lead list.",
|
|
515
|
-
inputSchema: { id: z.string() },
|
|
516
|
-
},
|
|
517
|
-
async ({ id }) => {
|
|
518
|
-
const deleted = deleteList(id);
|
|
519
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
520
|
-
}
|
|
521
|
-
);
|
|
522
|
-
|
|
523
|
-
// --- Start ---
|
|
524
|
-
async function main() {
|
|
525
|
-
const transport = new StdioServerTransport();
|
|
526
|
-
await server.connect(transport);
|
|
527
|
-
console.error("microservice-leads MCP server running on stdio");
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
main().catch((error) => {
|
|
531
|
-
console.error("Fatal error:", error);
|
|
532
|
-
process.exit(1);
|
|
533
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hasna/microservice-notes",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"description": "Notes microservice with SQLite — structured notes with tags, folders, and full-text search",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"microservice-notes": "./src/cli/index.ts",
|
|
8
|
-
"microservice-notes-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
|
-
"@hasna/cloud": "^0.1.24",
|
|
19
|
-
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
20
|
-
"commander": "^12.1.0",
|
|
21
|
-
"zod": "^3.24.0"
|
|
22
|
-
},
|
|
23
|
-
"license": "Apache-2.0",
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"registry": "https://registry.npmjs.org",
|
|
26
|
-
"access": "public"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import { createNote, getNote, listNotes, updateNote, deleteNote, countNotes, createFolder, listFolders, deleteFolder } from "../db/notes.js";
|
|
4
|
-
|
|
5
|
-
const program = new Command();
|
|
6
|
-
program.name("microservice-notes").description("Notes microservice").version("0.0.1");
|
|
7
|
-
|
|
8
|
-
program.command("add").description("Create a note")
|
|
9
|
-
.requiredOption("--title <title>", "Title")
|
|
10
|
-
.option("--content <text>", "Content")
|
|
11
|
-
.option("--folder <id>", "Folder ID")
|
|
12
|
-
.option("--tags <tags>", "Comma-separated tags")
|
|
13
|
-
.option("--pinned", "Pin the note", false)
|
|
14
|
-
.option("--json", "JSON output", false)
|
|
15
|
-
.action((opts) => {
|
|
16
|
-
const note = createNote({ title: opts.title, content: opts.content, folder_id: opts.folder, pinned: opts.pinned, tags: opts.tags?.split(",").map((t: string) => t.trim()) });
|
|
17
|
-
opts.json ? console.log(JSON.stringify(note, null, 2)) : console.log(`Created note: ${note.title} (${note.id})`);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
program.command("get").argument("<id>").option("--json", "", false).description("Get a note")
|
|
21
|
-
.action((id, opts) => {
|
|
22
|
-
const note = getNote(id);
|
|
23
|
-
if (!note) { console.error(`Note '${id}' not found.`); process.exit(1); }
|
|
24
|
-
opts.json ? console.log(JSON.stringify(note, null, 2)) : console.log(`${note.title}\n${note.content}`);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
program.command("list").option("--search <q>").option("--tag <tag>").option("--folder <id>").option("--pinned", "", false).option("--limit <n>").option("--json", "", false).description("List notes")
|
|
28
|
-
.action((opts) => {
|
|
29
|
-
const notes = listNotes({ search: opts.search, tag: opts.tag, folder_id: opts.folder, pinned: opts.pinned || undefined, limit: opts.limit ? parseInt(opts.limit) : undefined });
|
|
30
|
-
if (opts.json) { console.log(JSON.stringify(notes, null, 2)); return; }
|
|
31
|
-
if (!notes.length) { console.log("No notes."); return; }
|
|
32
|
-
for (const n of notes) { const pin = n.pinned ? " [pinned]" : ""; const tags = n.tags.length ? ` [${n.tags.join(", ")}]` : ""; console.log(` ${n.title}${pin}${tags}`); }
|
|
33
|
-
console.log(`\n${notes.length} note(s)`);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
program.command("update").argument("<id>").option("--title <t>").option("--content <t>").option("--folder <id>").option("--tags <tags>").option("--pinned").option("--json", "", false).description("Update a note")
|
|
37
|
-
.action((id, opts) => {
|
|
38
|
-
const input: Record<string, unknown> = {};
|
|
39
|
-
if (opts.title !== undefined) input.title = opts.title;
|
|
40
|
-
if (opts.content !== undefined) input.content = opts.content;
|
|
41
|
-
if (opts.folder !== undefined) input.folder_id = opts.folder;
|
|
42
|
-
if (opts.tags !== undefined) input.tags = opts.tags.split(",").map((t: string) => t.trim());
|
|
43
|
-
if (opts.pinned !== undefined) input.pinned = true;
|
|
44
|
-
const note = updateNote(id, input);
|
|
45
|
-
if (!note) { console.error(`Note '${id}' not found.`); process.exit(1); }
|
|
46
|
-
opts.json ? console.log(JSON.stringify(note, null, 2)) : console.log(`Updated: ${note.title}`);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
program.command("delete").argument("<id>").description("Delete a note")
|
|
50
|
-
.action((id) => { deleteNote(id) ? console.log(`Deleted ${id}`) : (console.error(`Not found.`), process.exit(1)); });
|
|
51
|
-
|
|
52
|
-
program.command("count").option("--json", "", false).description("Count notes")
|
|
53
|
-
.action((opts) => { const c = countNotes(); opts.json ? console.log(JSON.stringify({ count: c })) : console.log(`${c} note(s)`); });
|
|
54
|
-
|
|
55
|
-
const folderCmd = program.command("folder").description("Folder management");
|
|
56
|
-
folderCmd.command("add").requiredOption("--name <name>").option("--parent <id>").option("--json", "", false).description("Create a folder")
|
|
57
|
-
.action((opts) => { const f = createFolder(opts.name, opts.parent); opts.json ? console.log(JSON.stringify(f, null, 2)) : console.log(`Created folder: ${f.name} (${f.id})`); });
|
|
58
|
-
folderCmd.command("list").option("--parent <id>").option("--json", "", false).description("List folders")
|
|
59
|
-
.action((opts) => { const folders = listFolders(opts.parent); opts.json ? console.log(JSON.stringify(folders, null, 2)) : folders.forEach(f => console.log(` ${f.name}`)); });
|
|
60
|
-
folderCmd.command("delete").argument("<id>").description("Delete a folder")
|
|
61
|
-
.action((id) => { deleteFolder(id) ? console.log(`Deleted ${id}`) : (console.error(`Not found.`), process.exit(1)); });
|
|
62
|
-
|
|
63
|
-
program.parse(process.argv);
|