@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.
- package/README.md +120 -138
- package/bin/index.js +703 -12728
- package/bin/mcp.js +250 -9726
- package/dist/index.js +170 -9407
- package/package.json +25 -25
- package/microservices/microservice-ads/package.json +0 -27
- 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 -93
- 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 -27
- 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 -93
- 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 -27
- 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 -93
- 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 -27
- 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 -93
- 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 -27
- 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 -82
- 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 -27
- 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 -93
- 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 -27
- 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 -93
- 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 -27
- 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 -93
- 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 -27
- 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 -93
- 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 -27
- package/microservices/microservice-crm/src/cli/index.ts +0 -396
- package/microservices/microservice-crm/src/db/database.ts +0 -82
- 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 -27
- package/microservices/microservice-documents/src/cli/index.ts +0 -246
- package/microservices/microservice-documents/src/db/database.ts +0 -82
- 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 -27
- package/microservices/microservice-domains/src/cli/index.ts +0 -1111
- package/microservices/microservice-domains/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-expenses/src/cli/index.ts +0 -267
- package/microservices/microservice-expenses/src/db/database.ts +0 -82
- 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 -27
- package/microservices/microservice-habits/src/cli/index.ts +0 -315
- package/microservices/microservice-habits/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-health/src/cli/index.ts +0 -484
- package/microservices/microservice-health/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-hiring/src/cli/index.ts +0 -741
- package/microservices/microservice-hiring/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-inventory/src/cli/index.ts +0 -365
- package/microservices/microservice-inventory/src/db/database.ts +0 -82
- 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/dist/assets/index-Bngq7FNM.css +0 -1
- package/microservices/microservice-invoices/dashboard/dist/assets/index-aHW4ARZR.js +0 -124
- package/microservices/microservice-invoices/dashboard/dist/index.html +0 -13
- 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 -30
- 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 -82
- 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 -27
- package/microservices/microservice-leads/src/cli/index.ts +0 -596
- package/microservices/microservice-leads/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-notes/src/cli/index.ts +0 -63
- package/microservices/microservice-notes/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-notifications/src/cli/index.ts +0 -349
- package/microservices/microservice-notifications/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-payments/src/cli/index.ts +0 -609
- package/microservices/microservice-payments/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-payroll/src/cli/index.ts +0 -643
- package/microservices/microservice-payroll/src/db/database.ts +0 -93
- 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 -27
- 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 -93
- 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 -27
- package/microservices/microservice-projects/src/cli/index.ts +0 -480
- package/microservices/microservice-projects/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-proposals/src/cli/index.ts +0 -400
- package/microservices/microservice-proposals/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-reading/src/cli/index.ts +0 -464
- package/microservices/microservice-reading/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-shipping/src/cli/index.ts +0 -606
- package/microservices/microservice-shipping/src/db/database.ts +0 -93
- 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 -28
- package/microservices/microservice-social/src/cli/index.ts +0 -1583
- package/microservices/microservice-social/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
- package/microservices/microservice-subscriptions/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
- package/microservices/microservice-timesheets/src/db/database.ts +0 -82
- 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 -28
- 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 -82
- 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 -27
- package/microservices/microservice-travel/src/cli/index.ts +0 -505
- package/microservices/microservice-travel/src/db/database.ts +0 -93
- 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 -27
- package/microservices/microservice-wiki/src/cli/index.ts +0 -345
- package/microservices/microservice-wiki/src/db/database.ts +0 -93
- 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,52 +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 accounts (
|
|
13
|
-
id TEXT PRIMARY KEY,
|
|
14
|
-
name TEXT NOT NULL,
|
|
15
|
-
type TEXT NOT NULL CHECK(type IN ('asset', 'liability', 'equity', 'revenue', 'expense')),
|
|
16
|
-
code TEXT UNIQUE,
|
|
17
|
-
description TEXT,
|
|
18
|
-
parent_id TEXT REFERENCES accounts(id) ON DELETE SET NULL,
|
|
19
|
-
balance REAL NOT NULL DEFAULT 0,
|
|
20
|
-
currency TEXT NOT NULL DEFAULT 'USD',
|
|
21
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
22
|
-
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
CREATE TABLE IF NOT EXISTS transactions (
|
|
26
|
-
id TEXT PRIMARY KEY,
|
|
27
|
-
date TEXT NOT NULL DEFAULT (date('now')),
|
|
28
|
-
description TEXT NOT NULL,
|
|
29
|
-
reference TEXT,
|
|
30
|
-
metadata TEXT NOT NULL DEFAULT '{}',
|
|
31
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
CREATE TABLE IF NOT EXISTS transaction_entries (
|
|
35
|
-
id TEXT PRIMARY KEY,
|
|
36
|
-
transaction_id TEXT NOT NULL REFERENCES transactions(id) ON DELETE CASCADE,
|
|
37
|
-
account_id TEXT NOT NULL REFERENCES accounts(id) ON DELETE RESTRICT,
|
|
38
|
-
debit REAL NOT NULL DEFAULT 0,
|
|
39
|
-
credit REAL NOT NULL DEFAULT 0,
|
|
40
|
-
description TEXT
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
CREATE INDEX IF NOT EXISTS idx_accounts_type ON accounts(type);
|
|
44
|
-
CREATE INDEX IF NOT EXISTS idx_accounts_code ON accounts(code);
|
|
45
|
-
CREATE INDEX IF NOT EXISTS idx_accounts_parent ON accounts(parent_id);
|
|
46
|
-
CREATE INDEX IF NOT EXISTS idx_transactions_date ON transactions(date);
|
|
47
|
-
CREATE INDEX IF NOT EXISTS idx_transactions_reference ON transactions(reference);
|
|
48
|
-
CREATE INDEX IF NOT EXISTS idx_transaction_entries_transaction ON transaction_entries(transaction_id);
|
|
49
|
-
CREATE INDEX IF NOT EXISTS idx_transaction_entries_account ON transaction_entries(account_id);
|
|
50
|
-
`,
|
|
51
|
-
},
|
|
52
|
-
];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* microservice-bookkeeping — Double-entry bookkeeping microservice
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
createAccount,
|
|
7
|
-
getAccount,
|
|
8
|
-
listAccounts,
|
|
9
|
-
updateAccount,
|
|
10
|
-
deleteAccount,
|
|
11
|
-
createTransaction,
|
|
12
|
-
getTransaction,
|
|
13
|
-
listTransactions,
|
|
14
|
-
deleteTransaction,
|
|
15
|
-
getTrialBalance,
|
|
16
|
-
getAccountBalance,
|
|
17
|
-
getIncomeStatement,
|
|
18
|
-
type Account,
|
|
19
|
-
type AccountType,
|
|
20
|
-
type CreateAccountInput,
|
|
21
|
-
type UpdateAccountInput,
|
|
22
|
-
type ListAccountsOptions,
|
|
23
|
-
type Transaction,
|
|
24
|
-
type TransactionEntry,
|
|
25
|
-
type TransactionWithEntries,
|
|
26
|
-
type TransactionEntryInput,
|
|
27
|
-
type CreateTransactionInput,
|
|
28
|
-
type ListTransactionsOptions,
|
|
29
|
-
type TrialBalanceEntry,
|
|
30
|
-
} from "./db/bookkeeping.js";
|
|
31
|
-
|
|
32
|
-
export { getDatabase, closeDatabase } from "./db/database.js";
|
|
@@ -1,284 +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
|
-
createAccount,
|
|
8
|
-
getAccount,
|
|
9
|
-
listAccounts,
|
|
10
|
-
updateAccount,
|
|
11
|
-
deleteAccount,
|
|
12
|
-
createTransaction,
|
|
13
|
-
getTransaction,
|
|
14
|
-
listTransactions,
|
|
15
|
-
deleteTransaction,
|
|
16
|
-
getTrialBalance,
|
|
17
|
-
getAccountBalance,
|
|
18
|
-
getIncomeStatement,
|
|
19
|
-
} from "../db/bookkeeping.js";
|
|
20
|
-
|
|
21
|
-
const server = new McpServer({
|
|
22
|
-
name: "microservice-bookkeeping",
|
|
23
|
-
version: "0.0.1",
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// --- Accounts ---
|
|
27
|
-
|
|
28
|
-
server.registerTool(
|
|
29
|
-
"create_account",
|
|
30
|
-
{
|
|
31
|
-
title: "Create Account",
|
|
32
|
-
description: "Create a new chart-of-accounts entry.",
|
|
33
|
-
inputSchema: {
|
|
34
|
-
name: z.string(),
|
|
35
|
-
type: z.enum(["asset", "liability", "equity", "revenue", "expense"]),
|
|
36
|
-
code: z.string().optional(),
|
|
37
|
-
description: z.string().optional(),
|
|
38
|
-
parent_id: z.string().optional(),
|
|
39
|
-
currency: z.string().optional(),
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
async (params) => {
|
|
43
|
-
const account = createAccount(params);
|
|
44
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
server.registerTool(
|
|
49
|
-
"get_account",
|
|
50
|
-
{
|
|
51
|
-
title: "Get Account",
|
|
52
|
-
description: "Get an account by ID or code.",
|
|
53
|
-
inputSchema: { id: z.string() },
|
|
54
|
-
},
|
|
55
|
-
async ({ id }) => {
|
|
56
|
-
const account = getAccount(id);
|
|
57
|
-
if (!account) {
|
|
58
|
-
return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
|
|
59
|
-
}
|
|
60
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
server.registerTool(
|
|
65
|
-
"list_accounts",
|
|
66
|
-
{
|
|
67
|
-
title: "List Accounts",
|
|
68
|
-
description: "List accounts with optional filters.",
|
|
69
|
-
inputSchema: {
|
|
70
|
-
type: z.enum(["asset", "liability", "equity", "revenue", "expense"]).optional(),
|
|
71
|
-
search: z.string().optional(),
|
|
72
|
-
parent_id: z.string().optional(),
|
|
73
|
-
currency: z.string().optional(),
|
|
74
|
-
limit: z.number().optional(),
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
async (params) => {
|
|
78
|
-
const accounts = listAccounts(params);
|
|
79
|
-
return {
|
|
80
|
-
content: [
|
|
81
|
-
{ type: "text", text: JSON.stringify({ accounts, count: accounts.length }, null, 2) },
|
|
82
|
-
],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
server.registerTool(
|
|
88
|
-
"update_account",
|
|
89
|
-
{
|
|
90
|
-
title: "Update Account",
|
|
91
|
-
description: "Update an existing account.",
|
|
92
|
-
inputSchema: {
|
|
93
|
-
id: z.string(),
|
|
94
|
-
name: z.string().optional(),
|
|
95
|
-
type: z.enum(["asset", "liability", "equity", "revenue", "expense"]).optional(),
|
|
96
|
-
code: z.string().optional(),
|
|
97
|
-
description: z.string().optional(),
|
|
98
|
-
parent_id: z.string().optional(),
|
|
99
|
-
currency: z.string().optional(),
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
async ({ id, ...input }) => {
|
|
103
|
-
const account = updateAccount(id, input);
|
|
104
|
-
if (!account) {
|
|
105
|
-
return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
|
|
106
|
-
}
|
|
107
|
-
return { content: [{ type: "text", text: JSON.stringify(account, null, 2) }] };
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
server.registerTool(
|
|
112
|
-
"delete_account",
|
|
113
|
-
{
|
|
114
|
-
title: "Delete Account",
|
|
115
|
-
description: "Delete an account. Fails if account has transaction entries.",
|
|
116
|
-
inputSchema: { id: z.string() },
|
|
117
|
-
},
|
|
118
|
-
async ({ id }) => {
|
|
119
|
-
try {
|
|
120
|
-
const deleted = deleteAccount(id);
|
|
121
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
122
|
-
} catch (error) {
|
|
123
|
-
return {
|
|
124
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
125
|
-
isError: true,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
// --- Transactions ---
|
|
132
|
-
|
|
133
|
-
const entrySchema = z.object({
|
|
134
|
-
account_id: z.string(),
|
|
135
|
-
debit: z.number().optional(),
|
|
136
|
-
credit: z.number().optional(),
|
|
137
|
-
description: z.string().optional(),
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
server.registerTool(
|
|
141
|
-
"create_transaction",
|
|
142
|
-
{
|
|
143
|
-
title: "Create Transaction",
|
|
144
|
-
description:
|
|
145
|
-
"Record a double-entry transaction. Entries must balance (total debits = total credits). Requires at least two entries.",
|
|
146
|
-
inputSchema: {
|
|
147
|
-
description: z.string(),
|
|
148
|
-
date: z.string().optional(),
|
|
149
|
-
reference: z.string().optional(),
|
|
150
|
-
metadata: z.record(z.unknown()).optional(),
|
|
151
|
-
entries: z.array(entrySchema),
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
async (params) => {
|
|
155
|
-
try {
|
|
156
|
-
const txn = createTransaction(params);
|
|
157
|
-
return { content: [{ type: "text", text: JSON.stringify(txn, null, 2) }] };
|
|
158
|
-
} catch (error) {
|
|
159
|
-
return {
|
|
160
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
161
|
-
isError: true,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
server.registerTool(
|
|
168
|
-
"get_transaction",
|
|
169
|
-
{
|
|
170
|
-
title: "Get Transaction",
|
|
171
|
-
description: "Get a transaction with its entries by ID or reference.",
|
|
172
|
-
inputSchema: { id: z.string() },
|
|
173
|
-
},
|
|
174
|
-
async ({ id }) => {
|
|
175
|
-
const txn = getTransaction(id);
|
|
176
|
-
if (!txn) {
|
|
177
|
-
return { content: [{ type: "text", text: `Transaction '${id}' not found.` }], isError: true };
|
|
178
|
-
}
|
|
179
|
-
return { content: [{ type: "text", text: JSON.stringify(txn, null, 2) }] };
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
server.registerTool(
|
|
184
|
-
"list_transactions",
|
|
185
|
-
{
|
|
186
|
-
title: "List Transactions",
|
|
187
|
-
description: "List transactions with optional filters.",
|
|
188
|
-
inputSchema: {
|
|
189
|
-
from_date: z.string().optional(),
|
|
190
|
-
to_date: z.string().optional(),
|
|
191
|
-
account_id: z.string().optional(),
|
|
192
|
-
reference: z.string().optional(),
|
|
193
|
-
search: z.string().optional(),
|
|
194
|
-
limit: z.number().optional(),
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
async (params) => {
|
|
198
|
-
const transactions = listTransactions(params);
|
|
199
|
-
return {
|
|
200
|
-
content: [
|
|
201
|
-
{ type: "text", text: JSON.stringify({ transactions, count: transactions.length }, null, 2) },
|
|
202
|
-
],
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
server.registerTool(
|
|
208
|
-
"delete_transaction",
|
|
209
|
-
{
|
|
210
|
-
title: "Delete Transaction",
|
|
211
|
-
description: "Delete a transaction and reverse all account balance changes.",
|
|
212
|
-
inputSchema: { id: z.string() },
|
|
213
|
-
},
|
|
214
|
-
async ({ id }) => {
|
|
215
|
-
try {
|
|
216
|
-
const deleted = deleteTransaction(id);
|
|
217
|
-
return { content: [{ type: "text", text: JSON.stringify({ id, deleted }) }] };
|
|
218
|
-
} catch (error) {
|
|
219
|
-
return {
|
|
220
|
-
content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
|
|
221
|
-
isError: true,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
// --- Reports ---
|
|
228
|
-
|
|
229
|
-
server.registerTool(
|
|
230
|
-
"trial_balance",
|
|
231
|
-
{
|
|
232
|
-
title: "Trial Balance",
|
|
233
|
-
description: "Get the trial balance report. Shows all accounts with their total debits and credits.",
|
|
234
|
-
inputSchema: {},
|
|
235
|
-
},
|
|
236
|
-
async () => {
|
|
237
|
-
const tb = getTrialBalance();
|
|
238
|
-
return { content: [{ type: "text", text: JSON.stringify(tb, null, 2) }] };
|
|
239
|
-
}
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
server.registerTool(
|
|
243
|
-
"account_balance",
|
|
244
|
-
{
|
|
245
|
-
title: "Account Balance",
|
|
246
|
-
description: "Get detailed balance information for a specific account.",
|
|
247
|
-
inputSchema: { id: z.string() },
|
|
248
|
-
},
|
|
249
|
-
async ({ id }) => {
|
|
250
|
-
const result = getAccountBalance(id);
|
|
251
|
-
if (!result) {
|
|
252
|
-
return { content: [{ type: "text", text: `Account '${id}' not found.` }], isError: true };
|
|
253
|
-
}
|
|
254
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
255
|
-
}
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
server.registerTool(
|
|
259
|
-
"income_statement",
|
|
260
|
-
{
|
|
261
|
-
title: "Income Statement",
|
|
262
|
-
description: "Get the income statement (revenue minus expenses). Optionally filter by date range.",
|
|
263
|
-
inputSchema: {
|
|
264
|
-
from_date: z.string().optional(),
|
|
265
|
-
to_date: z.string().optional(),
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
async (params) => {
|
|
269
|
-
const result = getIncomeStatement(params);
|
|
270
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
271
|
-
}
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
// --- Start ---
|
|
275
|
-
async function main() {
|
|
276
|
-
const transport = new StdioServerTransport();
|
|
277
|
-
await server.connect(transport);
|
|
278
|
-
console.error("microservice-bookkeeping MCP server running on stdio");
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
main().catch((error) => {
|
|
282
|
-
console.error("Fatal error:", error);
|
|
283
|
-
process.exit(1);
|
|
284
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hasna/microservice-calendar",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"description": "Calendar management microservice with SQLite — manage events, reminders, and schedules",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"microservice-calendar": "./src/cli/index.ts",
|
|
8
|
-
"microservice-calendar-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
|
-
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import {
|
|
5
|
-
createEvent,
|
|
6
|
-
getEvent,
|
|
7
|
-
listEvents,
|
|
8
|
-
updateEvent,
|
|
9
|
-
deleteEvent,
|
|
10
|
-
getUpcoming,
|
|
11
|
-
getToday,
|
|
12
|
-
createReminder,
|
|
13
|
-
listPendingReminders,
|
|
14
|
-
markReminderSent,
|
|
15
|
-
} from "../db/calendar.js";
|
|
16
|
-
|
|
17
|
-
const program = new Command();
|
|
18
|
-
|
|
19
|
-
program
|
|
20
|
-
.name("microservice-calendar")
|
|
21
|
-
.description("Calendar management microservice")
|
|
22
|
-
.version("0.0.1");
|
|
23
|
-
|
|
24
|
-
// --- Events ---
|
|
25
|
-
|
|
26
|
-
program
|
|
27
|
-
.command("add")
|
|
28
|
-
.description("Add a new event")
|
|
29
|
-
.requiredOption("--title <title>", "Event title")
|
|
30
|
-
.requiredOption("--start <datetime>", "Start date/time (ISO 8601)")
|
|
31
|
-
.option("--end <datetime>", "End date/time (ISO 8601)")
|
|
32
|
-
.option("--all-day", "Mark as all-day event")
|
|
33
|
-
.option("--location <location>", "Location")
|
|
34
|
-
.option("--calendar <name>", "Calendar name", "default")
|
|
35
|
-
.option("--status <status>", "Status: confirmed|tentative|cancelled", "confirmed")
|
|
36
|
-
.option("--recurrence <rule>", "Recurrence rule (e.g. RRULE:FREQ=WEEKLY)")
|
|
37
|
-
.option("--reminder <minutes>", "Reminder minutes before event")
|
|
38
|
-
.option("--description <text>", "Event description")
|
|
39
|
-
.option("--tags <tags>", "Comma-separated tags")
|
|
40
|
-
.option("--json", "Output as JSON", false)
|
|
41
|
-
.action((opts) => {
|
|
42
|
-
const event = createEvent({
|
|
43
|
-
title: opts.title,
|
|
44
|
-
start_at: opts.start,
|
|
45
|
-
end_at: opts.end,
|
|
46
|
-
all_day: opts.allDay || false,
|
|
47
|
-
location: opts.location,
|
|
48
|
-
calendar: opts.calendar,
|
|
49
|
-
status: opts.status,
|
|
50
|
-
recurrence_rule: opts.recurrence,
|
|
51
|
-
reminder_minutes: opts.reminder ? parseInt(opts.reminder) : undefined,
|
|
52
|
-
description: opts.description,
|
|
53
|
-
tags: opts.tags ? opts.tags.split(",").map((t: string) => t.trim()) : undefined,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (opts.json) {
|
|
57
|
-
console.log(JSON.stringify(event, null, 2));
|
|
58
|
-
} else {
|
|
59
|
-
console.log(`Created event: ${event.title} (${event.id})`);
|
|
60
|
-
console.log(` Start: ${event.start_at}`);
|
|
61
|
-
if (event.end_at) console.log(` End: ${event.end_at}`);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
program
|
|
66
|
-
.command("get")
|
|
67
|
-
.description("Get an event by ID")
|
|
68
|
-
.argument("<id>", "Event ID")
|
|
69
|
-
.option("--json", "Output as JSON", false)
|
|
70
|
-
.action((id, opts) => {
|
|
71
|
-
const event = getEvent(id);
|
|
72
|
-
if (!event) {
|
|
73
|
-
console.error(`Event '${id}' not found.`);
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (opts.json) {
|
|
78
|
-
console.log(JSON.stringify(event, null, 2));
|
|
79
|
-
} else {
|
|
80
|
-
console.log(`${event.title}`);
|
|
81
|
-
console.log(` Start: ${event.start_at}`);
|
|
82
|
-
if (event.end_at) console.log(` End: ${event.end_at}`);
|
|
83
|
-
console.log(` Calendar: ${event.calendar}`);
|
|
84
|
-
console.log(` Status: ${event.status}`);
|
|
85
|
-
if (event.all_day) console.log(` All day: yes`);
|
|
86
|
-
if (event.location) console.log(` Location: ${event.location}`);
|
|
87
|
-
if (event.description) console.log(` Description: ${event.description}`);
|
|
88
|
-
if (event.tags.length) console.log(` Tags: ${event.tags.join(", ")}`);
|
|
89
|
-
if (event.recurrence_rule) console.log(` Recurrence: ${event.recurrence_rule}`);
|
|
90
|
-
if (event.reminder_minutes != null) console.log(` Reminder: ${event.reminder_minutes} min before`);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
program
|
|
95
|
-
.command("list")
|
|
96
|
-
.description("List events")
|
|
97
|
-
.option("--from <date>", "From date/time")
|
|
98
|
-
.option("--to <date>", "To date/time")
|
|
99
|
-
.option("--calendar <name>", "Filter by calendar")
|
|
100
|
-
.option("--status <status>", "Filter by status")
|
|
101
|
-
.option("--limit <n>", "Limit results")
|
|
102
|
-
.option("--json", "Output as JSON", false)
|
|
103
|
-
.action((opts) => {
|
|
104
|
-
const events = listEvents({
|
|
105
|
-
from: opts.from,
|
|
106
|
-
to: opts.to,
|
|
107
|
-
calendar: opts.calendar,
|
|
108
|
-
status: opts.status,
|
|
109
|
-
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
if (opts.json) {
|
|
113
|
-
console.log(JSON.stringify(events, null, 2));
|
|
114
|
-
} else {
|
|
115
|
-
if (events.length === 0) {
|
|
116
|
-
console.log("No events found.");
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
for (const e of events) {
|
|
120
|
-
const loc = e.location ? ` @ ${e.location}` : "";
|
|
121
|
-
const tags = e.tags.length ? ` [${e.tags.join(", ")}]` : "";
|
|
122
|
-
console.log(` ${e.start_at} ${e.title}${loc}${tags} (${e.status})`);
|
|
123
|
-
}
|
|
124
|
-
console.log(`\n${events.length} event(s)`);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
program
|
|
129
|
-
.command("update")
|
|
130
|
-
.description("Update an event")
|
|
131
|
-
.argument("<id>", "Event ID")
|
|
132
|
-
.option("--title <title>", "Title")
|
|
133
|
-
.option("--start <datetime>", "Start date/time")
|
|
134
|
-
.option("--end <datetime>", "End date/time")
|
|
135
|
-
.option("--all-day", "Mark as all-day")
|
|
136
|
-
.option("--location <location>", "Location")
|
|
137
|
-
.option("--calendar <name>", "Calendar name")
|
|
138
|
-
.option("--status <status>", "Status")
|
|
139
|
-
.option("--recurrence <rule>", "Recurrence rule")
|
|
140
|
-
.option("--reminder <minutes>", "Reminder minutes")
|
|
141
|
-
.option("--description <text>", "Description")
|
|
142
|
-
.option("--tags <tags>", "Comma-separated tags")
|
|
143
|
-
.option("--json", "Output as JSON", false)
|
|
144
|
-
.action((id, opts) => {
|
|
145
|
-
const input: Record<string, unknown> = {};
|
|
146
|
-
if (opts.title !== undefined) input.title = opts.title;
|
|
147
|
-
if (opts.start !== undefined) input.start_at = opts.start;
|
|
148
|
-
if (opts.end !== undefined) input.end_at = opts.end;
|
|
149
|
-
if (opts.allDay !== undefined) input.all_day = opts.allDay;
|
|
150
|
-
if (opts.location !== undefined) input.location = opts.location;
|
|
151
|
-
if (opts.calendar !== undefined) input.calendar = opts.calendar;
|
|
152
|
-
if (opts.status !== undefined) input.status = opts.status;
|
|
153
|
-
if (opts.recurrence !== undefined) input.recurrence_rule = opts.recurrence;
|
|
154
|
-
if (opts.reminder !== undefined) input.reminder_minutes = parseInt(opts.reminder);
|
|
155
|
-
if (opts.description !== undefined) input.description = opts.description;
|
|
156
|
-
if (opts.tags !== undefined) input.tags = opts.tags.split(",").map((t: string) => t.trim());
|
|
157
|
-
|
|
158
|
-
const event = updateEvent(id, input);
|
|
159
|
-
if (!event) {
|
|
160
|
-
console.error(`Event '${id}' not found.`);
|
|
161
|
-
process.exit(1);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (opts.json) {
|
|
165
|
-
console.log(JSON.stringify(event, null, 2));
|
|
166
|
-
} else {
|
|
167
|
-
console.log(`Updated: ${event.title}`);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
program
|
|
172
|
-
.command("delete")
|
|
173
|
-
.description("Delete an event")
|
|
174
|
-
.argument("<id>", "Event ID")
|
|
175
|
-
.action((id) => {
|
|
176
|
-
const deleted = deleteEvent(id);
|
|
177
|
-
if (deleted) {
|
|
178
|
-
console.log(`Deleted event ${id}`);
|
|
179
|
-
} else {
|
|
180
|
-
console.error(`Event '${id}' not found.`);
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
program
|
|
186
|
-
.command("upcoming")
|
|
187
|
-
.description("Show upcoming events")
|
|
188
|
-
.option("--limit <n>", "Number of events", "10")
|
|
189
|
-
.option("--json", "Output as JSON", false)
|
|
190
|
-
.action((opts) => {
|
|
191
|
-
const events = getUpcoming(parseInt(opts.limit));
|
|
192
|
-
|
|
193
|
-
if (opts.json) {
|
|
194
|
-
console.log(JSON.stringify(events, null, 2));
|
|
195
|
-
} else {
|
|
196
|
-
if (events.length === 0) {
|
|
197
|
-
console.log("No upcoming events.");
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
for (const e of events) {
|
|
201
|
-
const loc = e.location ? ` @ ${e.location}` : "";
|
|
202
|
-
console.log(` ${e.start_at} ${e.title}${loc}`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
program
|
|
208
|
-
.command("today")
|
|
209
|
-
.description("Show today's events")
|
|
210
|
-
.option("--json", "Output as JSON", false)
|
|
211
|
-
.action((opts) => {
|
|
212
|
-
const events = getToday();
|
|
213
|
-
|
|
214
|
-
if (opts.json) {
|
|
215
|
-
console.log(JSON.stringify(events, null, 2));
|
|
216
|
-
} else {
|
|
217
|
-
if (events.length === 0) {
|
|
218
|
-
console.log("No events today.");
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
for (const e of events) {
|
|
222
|
-
const loc = e.location ? ` @ ${e.location}` : "";
|
|
223
|
-
console.log(` ${e.start_at} ${e.title}${loc}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// --- Reminders ---
|
|
229
|
-
|
|
230
|
-
const reminderCmd = program
|
|
231
|
-
.command("reminder")
|
|
232
|
-
.description("Reminder management");
|
|
233
|
-
|
|
234
|
-
reminderCmd
|
|
235
|
-
.command("add")
|
|
236
|
-
.description("Add a reminder for an event")
|
|
237
|
-
.requiredOption("--event <id>", "Event ID")
|
|
238
|
-
.requiredOption("--at <datetime>", "Remind at date/time (ISO 8601)")
|
|
239
|
-
.option("--json", "Output as JSON", false)
|
|
240
|
-
.action((opts) => {
|
|
241
|
-
const reminder = createReminder({
|
|
242
|
-
event_id: opts.event,
|
|
243
|
-
remind_at: opts.at,
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
if (opts.json) {
|
|
247
|
-
console.log(JSON.stringify(reminder, null, 2));
|
|
248
|
-
} else {
|
|
249
|
-
console.log(`Created reminder: ${reminder.id} for event ${reminder.event_id} at ${reminder.remind_at}`);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
reminderCmd
|
|
254
|
-
.command("pending")
|
|
255
|
-
.description("List pending reminders")
|
|
256
|
-
.option("--json", "Output as JSON", false)
|
|
257
|
-
.action((opts) => {
|
|
258
|
-
const reminders = listPendingReminders();
|
|
259
|
-
|
|
260
|
-
if (opts.json) {
|
|
261
|
-
console.log(JSON.stringify(reminders, null, 2));
|
|
262
|
-
} else {
|
|
263
|
-
if (reminders.length === 0) {
|
|
264
|
-
console.log("No pending reminders.");
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
for (const r of reminders) {
|
|
268
|
-
console.log(` ${r.remind_at} event:${r.event_id} (${r.id})`);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
reminderCmd
|
|
274
|
-
.command("sent")
|
|
275
|
-
.description("Mark a reminder as sent")
|
|
276
|
-
.argument("<id>", "Reminder ID")
|
|
277
|
-
.action((id) => {
|
|
278
|
-
const marked = markReminderSent(id);
|
|
279
|
-
if (marked) {
|
|
280
|
-
console.log(`Marked reminder ${id} as sent.`);
|
|
281
|
-
} else {
|
|
282
|
-
console.error(`Reminder '${id}' not found.`);
|
|
283
|
-
process.exit(1);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
program.parse(process.argv);
|