@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,770 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import {
|
|
5
|
-
createContract,
|
|
6
|
-
getContract,
|
|
7
|
-
listContracts,
|
|
8
|
-
updateContract,
|
|
9
|
-
deleteContract,
|
|
10
|
-
searchContracts,
|
|
11
|
-
listExpiring,
|
|
12
|
-
renewContract,
|
|
13
|
-
getContractStats,
|
|
14
|
-
submitForReview,
|
|
15
|
-
approveContract,
|
|
16
|
-
getContractHistory,
|
|
17
|
-
recordSignature,
|
|
18
|
-
listSignatures,
|
|
19
|
-
compareContracts,
|
|
20
|
-
exportContract,
|
|
21
|
-
} from "../db/contracts.js";
|
|
22
|
-
import {
|
|
23
|
-
createClause,
|
|
24
|
-
listClauses,
|
|
25
|
-
deleteClause,
|
|
26
|
-
addClauseFromTemplate,
|
|
27
|
-
saveClauseTemplate,
|
|
28
|
-
listClauseTemplates,
|
|
29
|
-
} from "../db/contracts.js";
|
|
30
|
-
import {
|
|
31
|
-
createReminder,
|
|
32
|
-
listReminders,
|
|
33
|
-
deleteReminder,
|
|
34
|
-
setMultiReminders,
|
|
35
|
-
} from "../db/contracts.js";
|
|
36
|
-
import {
|
|
37
|
-
createObligation,
|
|
38
|
-
listObligations,
|
|
39
|
-
completeObligation,
|
|
40
|
-
listOverdueObligations,
|
|
41
|
-
} from "../db/contracts.js";
|
|
42
|
-
|
|
43
|
-
const program = new Command();
|
|
44
|
-
|
|
45
|
-
program
|
|
46
|
-
.name("microservice-contracts")
|
|
47
|
-
.description("Contract and agreement management microservice")
|
|
48
|
-
.version("0.0.1");
|
|
49
|
-
|
|
50
|
-
// --- Contracts ---
|
|
51
|
-
|
|
52
|
-
const contractCmd = program
|
|
53
|
-
.command("contract")
|
|
54
|
-
.description("Contract management");
|
|
55
|
-
|
|
56
|
-
contractCmd
|
|
57
|
-
.command("create")
|
|
58
|
-
.description("Create a new contract")
|
|
59
|
-
.requiredOption("--title <title>", "Contract title")
|
|
60
|
-
.option("--type <type>", "Contract type (nda/service/employment/license/other)", "other")
|
|
61
|
-
.option("--status <status>", "Status (draft/pending_review/pending_signature/active/expired/terminated)", "draft")
|
|
62
|
-
.option("--counterparty <name>", "Counterparty name")
|
|
63
|
-
.option("--counterparty-email <email>", "Counterparty email")
|
|
64
|
-
.option("--start-date <date>", "Start date (YYYY-MM-DD)")
|
|
65
|
-
.option("--end-date <date>", "End date (YYYY-MM-DD)")
|
|
66
|
-
.option("--auto-renew", "Enable auto-renewal", false)
|
|
67
|
-
.option("--renewal-period <period>", "Renewal period (e.g. '1 year')")
|
|
68
|
-
.option("--value <amount>", "Contract value")
|
|
69
|
-
.option("--currency <code>", "Currency code", "USD")
|
|
70
|
-
.option("--file-path <path>", "Path to contract file")
|
|
71
|
-
.option("--json", "Output as JSON", false)
|
|
72
|
-
.action((opts) => {
|
|
73
|
-
const contract = createContract({
|
|
74
|
-
title: opts.title,
|
|
75
|
-
type: opts.type,
|
|
76
|
-
status: opts.status,
|
|
77
|
-
counterparty: opts.counterparty,
|
|
78
|
-
counterparty_email: opts.counterpartyEmail,
|
|
79
|
-
start_date: opts.startDate,
|
|
80
|
-
end_date: opts.endDate,
|
|
81
|
-
auto_renew: opts.autoRenew,
|
|
82
|
-
renewal_period: opts.renewalPeriod,
|
|
83
|
-
value: opts.value ? parseFloat(opts.value) : undefined,
|
|
84
|
-
currency: opts.currency,
|
|
85
|
-
file_path: opts.filePath,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (opts.json) {
|
|
89
|
-
console.log(JSON.stringify(contract, null, 2));
|
|
90
|
-
} else {
|
|
91
|
-
console.log(`Created contract: ${contract.title} (${contract.id})`);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
contractCmd
|
|
96
|
-
.command("list")
|
|
97
|
-
.description("List contracts")
|
|
98
|
-
.option("--search <query>", "Search by title, counterparty, or email")
|
|
99
|
-
.option("--type <type>", "Filter by type")
|
|
100
|
-
.option("--status <status>", "Filter by status")
|
|
101
|
-
.option("--counterparty <name>", "Filter by counterparty")
|
|
102
|
-
.option("--limit <n>", "Limit results")
|
|
103
|
-
.option("--json", "Output as JSON", false)
|
|
104
|
-
.action((opts) => {
|
|
105
|
-
const contracts = listContracts({
|
|
106
|
-
search: opts.search,
|
|
107
|
-
type: opts.type,
|
|
108
|
-
status: opts.status,
|
|
109
|
-
counterparty: opts.counterparty,
|
|
110
|
-
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (opts.json) {
|
|
114
|
-
console.log(JSON.stringify(contracts, null, 2));
|
|
115
|
-
} else {
|
|
116
|
-
if (contracts.length === 0) {
|
|
117
|
-
console.log("No contracts found.");
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
for (const c of contracts) {
|
|
121
|
-
const cp = c.counterparty ? ` — ${c.counterparty}` : "";
|
|
122
|
-
const status = ` [${c.status}]`;
|
|
123
|
-
console.log(` ${c.title}${cp}${status} (${c.id})`);
|
|
124
|
-
}
|
|
125
|
-
console.log(`\n${contracts.length} contract(s)`);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
contractCmd
|
|
130
|
-
.command("get")
|
|
131
|
-
.description("Get a contract by ID")
|
|
132
|
-
.argument("<id>", "Contract ID")
|
|
133
|
-
.option("--json", "Output as JSON", false)
|
|
134
|
-
.action((id, opts) => {
|
|
135
|
-
const contract = getContract(id);
|
|
136
|
-
if (!contract) {
|
|
137
|
-
console.error(`Contract '${id}' not found.`);
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (opts.json) {
|
|
142
|
-
console.log(JSON.stringify(contract, null, 2));
|
|
143
|
-
} else {
|
|
144
|
-
console.log(`${contract.title}`);
|
|
145
|
-
console.log(` Type: ${contract.type}`);
|
|
146
|
-
console.log(` Status: ${contract.status}`);
|
|
147
|
-
if (contract.counterparty) console.log(` Counterparty: ${contract.counterparty}`);
|
|
148
|
-
if (contract.counterparty_email) console.log(` Email: ${contract.counterparty_email}`);
|
|
149
|
-
if (contract.start_date) console.log(` Start: ${contract.start_date}`);
|
|
150
|
-
if (contract.end_date) console.log(` End: ${contract.end_date}`);
|
|
151
|
-
if (contract.value !== null) console.log(` Value: ${contract.value} ${contract.currency}`);
|
|
152
|
-
if (contract.auto_renew) console.log(` Auto-renew: ${contract.renewal_period || "1 year"}`);
|
|
153
|
-
if (contract.file_path) console.log(` File: ${contract.file_path}`);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
contractCmd
|
|
158
|
-
.command("update")
|
|
159
|
-
.description("Update a contract")
|
|
160
|
-
.argument("<id>", "Contract ID")
|
|
161
|
-
.option("--title <title>", "Title")
|
|
162
|
-
.option("--type <type>", "Type")
|
|
163
|
-
.option("--status <status>", "Status")
|
|
164
|
-
.option("--counterparty <name>", "Counterparty name")
|
|
165
|
-
.option("--counterparty-email <email>", "Counterparty email")
|
|
166
|
-
.option("--start-date <date>", "Start date")
|
|
167
|
-
.option("--end-date <date>", "End date")
|
|
168
|
-
.option("--auto-renew", "Enable auto-renewal")
|
|
169
|
-
.option("--no-auto-renew", "Disable auto-renewal")
|
|
170
|
-
.option("--renewal-period <period>", "Renewal period")
|
|
171
|
-
.option("--value <amount>", "Value")
|
|
172
|
-
.option("--currency <code>", "Currency")
|
|
173
|
-
.option("--file-path <path>", "File path")
|
|
174
|
-
.option("--json", "Output as JSON", false)
|
|
175
|
-
.action((id, opts) => {
|
|
176
|
-
const input: Record<string, unknown> = {};
|
|
177
|
-
if (opts.title !== undefined) input.title = opts.title;
|
|
178
|
-
if (opts.type !== undefined) input.type = opts.type;
|
|
179
|
-
if (opts.status !== undefined) input.status = opts.status;
|
|
180
|
-
if (opts.counterparty !== undefined) input.counterparty = opts.counterparty;
|
|
181
|
-
if (opts.counterpartyEmail !== undefined) input.counterparty_email = opts.counterpartyEmail;
|
|
182
|
-
if (opts.startDate !== undefined) input.start_date = opts.startDate;
|
|
183
|
-
if (opts.endDate !== undefined) input.end_date = opts.endDate;
|
|
184
|
-
if (opts.autoRenew !== undefined) input.auto_renew = opts.autoRenew;
|
|
185
|
-
if (opts.renewalPeriod !== undefined) input.renewal_period = opts.renewalPeriod;
|
|
186
|
-
if (opts.value !== undefined) input.value = parseFloat(opts.value);
|
|
187
|
-
if (opts.currency !== undefined) input.currency = opts.currency;
|
|
188
|
-
if (opts.filePath !== undefined) input.file_path = opts.filePath;
|
|
189
|
-
|
|
190
|
-
const contract = updateContract(id, input);
|
|
191
|
-
if (!contract) {
|
|
192
|
-
console.error(`Contract '${id}' not found.`);
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (opts.json) {
|
|
197
|
-
console.log(JSON.stringify(contract, null, 2));
|
|
198
|
-
} else {
|
|
199
|
-
console.log(`Updated: ${contract.title}`);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
contractCmd
|
|
204
|
-
.command("delete")
|
|
205
|
-
.description("Delete a contract")
|
|
206
|
-
.argument("<id>", "Contract ID")
|
|
207
|
-
.action((id) => {
|
|
208
|
-
const deleted = deleteContract(id);
|
|
209
|
-
if (deleted) {
|
|
210
|
-
console.log(`Deleted contract ${id}`);
|
|
211
|
-
} else {
|
|
212
|
-
console.error(`Contract '${id}' not found.`);
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// --- Approval workflow ---
|
|
218
|
-
|
|
219
|
-
contractCmd
|
|
220
|
-
.command("submit")
|
|
221
|
-
.description("Submit a draft contract for review (draft -> pending_review)")
|
|
222
|
-
.argument("<id>", "Contract ID")
|
|
223
|
-
.option("--json", "Output as JSON", false)
|
|
224
|
-
.action((id, opts) => {
|
|
225
|
-
try {
|
|
226
|
-
const contract = submitForReview(id);
|
|
227
|
-
if (!contract) {
|
|
228
|
-
console.error(`Contract '${id}' not found.`);
|
|
229
|
-
process.exit(1);
|
|
230
|
-
}
|
|
231
|
-
if (opts.json) {
|
|
232
|
-
console.log(JSON.stringify(contract, null, 2));
|
|
233
|
-
} else {
|
|
234
|
-
console.log(`Submitted for review: ${contract.title} [${contract.status}]`);
|
|
235
|
-
}
|
|
236
|
-
} catch (err) {
|
|
237
|
-
console.error((err as Error).message);
|
|
238
|
-
process.exit(1);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
contractCmd
|
|
243
|
-
.command("approve")
|
|
244
|
-
.description("Approve a contract (advances through approval workflow)")
|
|
245
|
-
.argument("<id>", "Contract ID")
|
|
246
|
-
.option("--json", "Output as JSON", false)
|
|
247
|
-
.action((id, opts) => {
|
|
248
|
-
try {
|
|
249
|
-
const contract = approveContract(id);
|
|
250
|
-
if (!contract) {
|
|
251
|
-
console.error(`Contract '${id}' not found.`);
|
|
252
|
-
process.exit(1);
|
|
253
|
-
}
|
|
254
|
-
if (opts.json) {
|
|
255
|
-
console.log(JSON.stringify(contract, null, 2));
|
|
256
|
-
} else {
|
|
257
|
-
console.log(`Approved: ${contract.title} [${contract.status}]`);
|
|
258
|
-
}
|
|
259
|
-
} catch (err) {
|
|
260
|
-
console.error((err as Error).message);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
// --- Version history ---
|
|
266
|
-
|
|
267
|
-
contractCmd
|
|
268
|
-
.command("history")
|
|
269
|
-
.description("Show version history for a contract")
|
|
270
|
-
.argument("<id>", "Contract ID")
|
|
271
|
-
.option("--json", "Output as JSON", false)
|
|
272
|
-
.action((id, opts) => {
|
|
273
|
-
const history = getContractHistory(id);
|
|
274
|
-
if (opts.json) {
|
|
275
|
-
console.log(JSON.stringify(history, null, 2));
|
|
276
|
-
} else {
|
|
277
|
-
if (history.length === 0) {
|
|
278
|
-
console.log("No version history.");
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
for (const v of history) {
|
|
282
|
-
console.log(` ${v.changed_at} — "${v.title}" [${v.status}] value=${v.value ?? "N/A"}`);
|
|
283
|
-
}
|
|
284
|
-
console.log(`\n${history.length} version(s)`);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
// --- Signature logging ---
|
|
289
|
-
|
|
290
|
-
contractCmd
|
|
291
|
-
.command("sign")
|
|
292
|
-
.description("Record a signature for a contract")
|
|
293
|
-
.argument("<id>", "Contract ID")
|
|
294
|
-
.requiredOption("--signer <name>", "Signer name")
|
|
295
|
-
.option("--email <email>", "Signer email")
|
|
296
|
-
.option("--method <method>", "Signature method (digital/wet/docusign)", "digital")
|
|
297
|
-
.option("--json", "Output as JSON", false)
|
|
298
|
-
.action((id, opts) => {
|
|
299
|
-
const sig = recordSignature({
|
|
300
|
-
contract_id: id,
|
|
301
|
-
signer_name: opts.signer,
|
|
302
|
-
signer_email: opts.email,
|
|
303
|
-
method: opts.method,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
if (opts.json) {
|
|
307
|
-
console.log(JSON.stringify(sig, null, 2));
|
|
308
|
-
} else {
|
|
309
|
-
const email = sig.signer_email ? ` (${sig.signer_email})` : "";
|
|
310
|
-
console.log(`Recorded signature: ${sig.signer_name}${email} via ${sig.method} (${sig.id})`);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
contractCmd
|
|
315
|
-
.command("signatures")
|
|
316
|
-
.description("List signatures for a contract")
|
|
317
|
-
.argument("<id>", "Contract ID")
|
|
318
|
-
.option("--json", "Output as JSON", false)
|
|
319
|
-
.action((id, opts) => {
|
|
320
|
-
const sigs = listSignatures(id);
|
|
321
|
-
if (opts.json) {
|
|
322
|
-
console.log(JSON.stringify(sigs, null, 2));
|
|
323
|
-
} else {
|
|
324
|
-
if (sigs.length === 0) {
|
|
325
|
-
console.log("No signatures found.");
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
for (const s of sigs) {
|
|
329
|
-
const email = s.signer_email ? ` (${s.signer_email})` : "";
|
|
330
|
-
console.log(` ${s.signer_name}${email} — ${s.method} — ${s.signed_at}`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// --- Contract comparison ---
|
|
336
|
-
|
|
337
|
-
contractCmd
|
|
338
|
-
.command("compare")
|
|
339
|
-
.description("Compare two contracts showing clause differences")
|
|
340
|
-
.argument("<id1>", "First contract ID")
|
|
341
|
-
.argument("<id2>", "Second contract ID")
|
|
342
|
-
.option("--json", "Output as JSON", false)
|
|
343
|
-
.action((id1, id2, opts) => {
|
|
344
|
-
try {
|
|
345
|
-
const diff = compareContracts(id1, id2);
|
|
346
|
-
if (opts.json) {
|
|
347
|
-
console.log(JSON.stringify(diff, null, 2));
|
|
348
|
-
} else {
|
|
349
|
-
console.log(`Comparing: "${diff.contract1.title}" vs "${diff.contract2.title}"\n`);
|
|
350
|
-
|
|
351
|
-
if (diff.field_differences.length > 0) {
|
|
352
|
-
console.log("Field differences:");
|
|
353
|
-
for (const d of diff.field_differences) {
|
|
354
|
-
console.log(` ${d.field}: ${JSON.stringify(d.contract1_value)} vs ${JSON.stringify(d.contract2_value)}`);
|
|
355
|
-
}
|
|
356
|
-
console.log("");
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (diff.clause_only_in_1.length > 0) {
|
|
360
|
-
console.log(`Clauses only in "${diff.contract1.title}":`);
|
|
361
|
-
for (const c of diff.clause_only_in_1) {
|
|
362
|
-
console.log(` - ${c.name}`);
|
|
363
|
-
}
|
|
364
|
-
console.log("");
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (diff.clause_only_in_2.length > 0) {
|
|
368
|
-
console.log(`Clauses only in "${diff.contract2.title}":`);
|
|
369
|
-
for (const c of diff.clause_only_in_2) {
|
|
370
|
-
console.log(` - ${c.name}`);
|
|
371
|
-
}
|
|
372
|
-
console.log("");
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (diff.clause_differences.length > 0) {
|
|
376
|
-
console.log("Clause text differences:");
|
|
377
|
-
for (const d of diff.clause_differences) {
|
|
378
|
-
console.log(` ${d.name}:`);
|
|
379
|
-
console.log(` Contract 1: ${d.contract1_text.substring(0, 80)}${d.contract1_text.length > 80 ? "..." : ""}`);
|
|
380
|
-
console.log(` Contract 2: ${d.contract2_text.substring(0, 80)}${d.contract2_text.length > 80 ? "..." : ""}`);
|
|
381
|
-
}
|
|
382
|
-
console.log("");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (diff.field_differences.length === 0 && diff.clause_only_in_1.length === 0 && diff.clause_only_in_2.length === 0 && diff.clause_differences.length === 0) {
|
|
386
|
-
console.log("No differences found.");
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
} catch (err) {
|
|
390
|
-
console.error((err as Error).message);
|
|
391
|
-
process.exit(1);
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// --- Markdown export ---
|
|
396
|
-
|
|
397
|
-
contractCmd
|
|
398
|
-
.command("export")
|
|
399
|
-
.description("Export a contract in markdown or JSON format")
|
|
400
|
-
.argument("<id>", "Contract ID")
|
|
401
|
-
.option("--format <format>", "Export format (md/json)", "md")
|
|
402
|
-
.action((id, opts) => {
|
|
403
|
-
try {
|
|
404
|
-
const output = exportContract(id, opts.format);
|
|
405
|
-
console.log(output);
|
|
406
|
-
} catch (err) {
|
|
407
|
-
console.error((err as Error).message);
|
|
408
|
-
process.exit(1);
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
// --- Expiring & Renew ---
|
|
413
|
-
|
|
414
|
-
program
|
|
415
|
-
.command("expiring")
|
|
416
|
-
.description("List contracts expiring within N days")
|
|
417
|
-
.option("--days <n>", "Number of days to look ahead", "30")
|
|
418
|
-
.option("--json", "Output as JSON", false)
|
|
419
|
-
.action((opts) => {
|
|
420
|
-
const days = parseInt(opts.days);
|
|
421
|
-
const contracts = listExpiring(days);
|
|
422
|
-
|
|
423
|
-
if (opts.json) {
|
|
424
|
-
console.log(JSON.stringify(contracts, null, 2));
|
|
425
|
-
} else {
|
|
426
|
-
if (contracts.length === 0) {
|
|
427
|
-
console.log(`No contracts expiring within ${days} days.`);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
for (const c of contracts) {
|
|
431
|
-
console.log(` ${c.title} — expires ${c.end_date} [${c.status}]`);
|
|
432
|
-
}
|
|
433
|
-
console.log(`\n${contracts.length} contract(s) expiring within ${days} days`);
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
program
|
|
438
|
-
.command("renew")
|
|
439
|
-
.description("Renew a contract")
|
|
440
|
-
.argument("<id>", "Contract ID")
|
|
441
|
-
.option("--json", "Output as JSON", false)
|
|
442
|
-
.action((id, opts) => {
|
|
443
|
-
const contract = renewContract(id);
|
|
444
|
-
if (!contract) {
|
|
445
|
-
console.error(`Contract '${id}' not found.`);
|
|
446
|
-
process.exit(1);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if (opts.json) {
|
|
450
|
-
console.log(JSON.stringify(contract, null, 2));
|
|
451
|
-
} else {
|
|
452
|
-
console.log(`Renewed: ${contract.title} — new end date: ${contract.end_date}`);
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
// --- Clauses ---
|
|
457
|
-
|
|
458
|
-
const clauseCmd = program
|
|
459
|
-
.command("clause")
|
|
460
|
-
.description("Clause management");
|
|
461
|
-
|
|
462
|
-
clauseCmd
|
|
463
|
-
.command("add")
|
|
464
|
-
.description("Add a clause to a contract")
|
|
465
|
-
.requiredOption("--contract <id>", "Contract ID")
|
|
466
|
-
.requiredOption("--name <name>", "Clause name")
|
|
467
|
-
.option("--text <text>", "Clause text")
|
|
468
|
-
.option("--from-template <templateName>", "Add clause from a template by name")
|
|
469
|
-
.option("--type <type>", "Clause type (standard/custom/negotiated)", "standard")
|
|
470
|
-
.option("--json", "Output as JSON", false)
|
|
471
|
-
.action((opts) => {
|
|
472
|
-
try {
|
|
473
|
-
let clause;
|
|
474
|
-
if (opts.fromTemplate) {
|
|
475
|
-
clause = addClauseFromTemplate(opts.contract, opts.fromTemplate);
|
|
476
|
-
} else {
|
|
477
|
-
if (!opts.text) {
|
|
478
|
-
console.error("Either --text or --from-template is required.");
|
|
479
|
-
process.exit(1);
|
|
480
|
-
}
|
|
481
|
-
clause = createClause({
|
|
482
|
-
contract_id: opts.contract,
|
|
483
|
-
name: opts.name,
|
|
484
|
-
text: opts.text,
|
|
485
|
-
type: opts.type,
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (opts.json) {
|
|
490
|
-
console.log(JSON.stringify(clause, null, 2));
|
|
491
|
-
} else {
|
|
492
|
-
console.log(`Added clause: ${clause.name} (${clause.id})`);
|
|
493
|
-
}
|
|
494
|
-
} catch (err) {
|
|
495
|
-
console.error((err as Error).message);
|
|
496
|
-
process.exit(1);
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
clauseCmd
|
|
501
|
-
.command("list")
|
|
502
|
-
.description("List clauses for a contract")
|
|
503
|
-
.argument("<contract-id>", "Contract ID")
|
|
504
|
-
.option("--json", "Output as JSON", false)
|
|
505
|
-
.action((contractId, opts) => {
|
|
506
|
-
const clauses = listClauses(contractId);
|
|
507
|
-
|
|
508
|
-
if (opts.json) {
|
|
509
|
-
console.log(JSON.stringify(clauses, null, 2));
|
|
510
|
-
} else {
|
|
511
|
-
if (clauses.length === 0) {
|
|
512
|
-
console.log("No clauses found.");
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
for (const c of clauses) {
|
|
516
|
-
console.log(` ${c.name} [${c.type}]: ${c.text.substring(0, 80)}${c.text.length > 80 ? "..." : ""}`);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
clauseCmd
|
|
522
|
-
.command("remove")
|
|
523
|
-
.description("Remove a clause")
|
|
524
|
-
.argument("<id>", "Clause ID")
|
|
525
|
-
.action((id) => {
|
|
526
|
-
const deleted = deleteClause(id);
|
|
527
|
-
if (deleted) {
|
|
528
|
-
console.log(`Removed clause ${id}`);
|
|
529
|
-
} else {
|
|
530
|
-
console.error(`Clause '${id}' not found.`);
|
|
531
|
-
process.exit(1);
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
// --- Clause templates ---
|
|
536
|
-
|
|
537
|
-
clauseCmd
|
|
538
|
-
.command("save-template")
|
|
539
|
-
.description("Save a clause as a reusable template")
|
|
540
|
-
.requiredOption("--name <name>", "Template name")
|
|
541
|
-
.requiredOption("--text <text>", "Template text")
|
|
542
|
-
.option("--type <type>", "Clause type (standard/custom/negotiated)", "standard")
|
|
543
|
-
.option("--json", "Output as JSON", false)
|
|
544
|
-
.action((opts) => {
|
|
545
|
-
const template = saveClauseTemplate({
|
|
546
|
-
name: opts.name,
|
|
547
|
-
text: opts.text,
|
|
548
|
-
type: opts.type,
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
if (opts.json) {
|
|
552
|
-
console.log(JSON.stringify(template, null, 2));
|
|
553
|
-
} else {
|
|
554
|
-
console.log(`Saved template: ${template.name} (${template.id})`);
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
clauseCmd
|
|
559
|
-
.command("list-templates")
|
|
560
|
-
.description("List all clause templates")
|
|
561
|
-
.option("--json", "Output as JSON", false)
|
|
562
|
-
.action((opts) => {
|
|
563
|
-
const templates = listClauseTemplates();
|
|
564
|
-
|
|
565
|
-
if (opts.json) {
|
|
566
|
-
console.log(JSON.stringify(templates, null, 2));
|
|
567
|
-
} else {
|
|
568
|
-
if (templates.length === 0) {
|
|
569
|
-
console.log("No clause templates found.");
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
for (const t of templates) {
|
|
573
|
-
console.log(` ${t.name} [${t.type}]: ${t.text.substring(0, 80)}${t.text.length > 80 ? "..." : ""}`);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
// --- Obligations ---
|
|
579
|
-
|
|
580
|
-
const obligationCmd = program
|
|
581
|
-
.command("obligation")
|
|
582
|
-
.description("Obligation tracking");
|
|
583
|
-
|
|
584
|
-
obligationCmd
|
|
585
|
-
.command("add")
|
|
586
|
-
.description("Add an obligation to a clause")
|
|
587
|
-
.requiredOption("--clause <id>", "Clause ID")
|
|
588
|
-
.requiredOption("--description <desc>", "Obligation description")
|
|
589
|
-
.option("--due-date <date>", "Due date (YYYY-MM-DD)")
|
|
590
|
-
.option("--assigned-to <name>", "Person assigned to this obligation")
|
|
591
|
-
.option("--json", "Output as JSON", false)
|
|
592
|
-
.action((opts) => {
|
|
593
|
-
const obligation = createObligation({
|
|
594
|
-
clause_id: opts.clause,
|
|
595
|
-
description: opts.description,
|
|
596
|
-
due_date: opts.dueDate,
|
|
597
|
-
assigned_to: opts.assignedTo,
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
if (opts.json) {
|
|
601
|
-
console.log(JSON.stringify(obligation, null, 2));
|
|
602
|
-
} else {
|
|
603
|
-
console.log(`Added obligation: ${obligation.description} (${obligation.id})`);
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
obligationCmd
|
|
608
|
-
.command("list")
|
|
609
|
-
.description("List obligations for a clause")
|
|
610
|
-
.argument("<clause-id>", "Clause ID")
|
|
611
|
-
.option("--json", "Output as JSON", false)
|
|
612
|
-
.action((clauseId, opts) => {
|
|
613
|
-
const obligations = listObligations(clauseId);
|
|
614
|
-
|
|
615
|
-
if (opts.json) {
|
|
616
|
-
console.log(JSON.stringify(obligations, null, 2));
|
|
617
|
-
} else {
|
|
618
|
-
if (obligations.length === 0) {
|
|
619
|
-
console.log("No obligations found.");
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
for (const o of obligations) {
|
|
623
|
-
const due = o.due_date ? ` due ${o.due_date}` : "";
|
|
624
|
-
const assigned = o.assigned_to ? ` (${o.assigned_to})` : "";
|
|
625
|
-
console.log(` [${o.status}] ${o.description}${due}${assigned}`);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
obligationCmd
|
|
631
|
-
.command("complete")
|
|
632
|
-
.description("Mark an obligation as completed")
|
|
633
|
-
.argument("<id>", "Obligation ID")
|
|
634
|
-
.option("--json", "Output as JSON", false)
|
|
635
|
-
.action((id, opts) => {
|
|
636
|
-
const obligation = completeObligation(id);
|
|
637
|
-
if (!obligation) {
|
|
638
|
-
console.error(`Obligation '${id}' not found.`);
|
|
639
|
-
process.exit(1);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
if (opts.json) {
|
|
643
|
-
console.log(JSON.stringify(obligation, null, 2));
|
|
644
|
-
} else {
|
|
645
|
-
console.log(`Completed: ${obligation.description}`);
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
obligationCmd
|
|
650
|
-
.command("overdue")
|
|
651
|
-
.description("List all overdue obligations")
|
|
652
|
-
.option("--json", "Output as JSON", false)
|
|
653
|
-
.action((opts) => {
|
|
654
|
-
const obligations = listOverdueObligations();
|
|
655
|
-
|
|
656
|
-
if (opts.json) {
|
|
657
|
-
console.log(JSON.stringify(obligations, null, 2));
|
|
658
|
-
} else {
|
|
659
|
-
if (obligations.length === 0) {
|
|
660
|
-
console.log("No overdue obligations.");
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
for (const o of obligations) {
|
|
664
|
-
const due = o.due_date ? ` due ${o.due_date}` : "";
|
|
665
|
-
const assigned = o.assigned_to ? ` (${o.assigned_to})` : "";
|
|
666
|
-
console.log(` [${o.status}] ${o.description}${due}${assigned}`);
|
|
667
|
-
}
|
|
668
|
-
console.log(`\n${obligations.length} overdue obligation(s)`);
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
|
|
672
|
-
// --- Reminders ---
|
|
673
|
-
|
|
674
|
-
const remindCmd = program
|
|
675
|
-
.command("remind")
|
|
676
|
-
.description("Reminder management");
|
|
677
|
-
|
|
678
|
-
remindCmd
|
|
679
|
-
.command("set")
|
|
680
|
-
.description("Set a reminder for a contract")
|
|
681
|
-
.requiredOption("--contract <id>", "Contract ID")
|
|
682
|
-
.option("--at <datetime>", "Reminder datetime (ISO 8601)")
|
|
683
|
-
.option("--message <msg>", "Reminder message")
|
|
684
|
-
.option("--days-before <days>", "Set multi-stage reminders (comma-separated, e.g. 60,30,7)")
|
|
685
|
-
.option("--json", "Output as JSON", false)
|
|
686
|
-
.action((opts) => {
|
|
687
|
-
if (opts.daysBefore) {
|
|
688
|
-
try {
|
|
689
|
-
const days = opts.daysBefore.split(",").map((d: string) => parseInt(d.trim()));
|
|
690
|
-
const reminders = setMultiReminders(opts.contract, days);
|
|
691
|
-
if (opts.json) {
|
|
692
|
-
console.log(JSON.stringify(reminders, null, 2));
|
|
693
|
-
} else {
|
|
694
|
-
for (const r of reminders) {
|
|
695
|
-
console.log(`Set reminder: ${r.message} at ${r.remind_at} (${r.id})`);
|
|
696
|
-
}
|
|
697
|
-
console.log(`\n${reminders.length} reminder(s) created`);
|
|
698
|
-
}
|
|
699
|
-
} catch (err) {
|
|
700
|
-
console.error((err as Error).message);
|
|
701
|
-
process.exit(1);
|
|
702
|
-
}
|
|
703
|
-
} else {
|
|
704
|
-
if (!opts.at || !opts.message) {
|
|
705
|
-
console.error("Either --at and --message are required, or use --days-before for multi-stage reminders.");
|
|
706
|
-
process.exit(1);
|
|
707
|
-
}
|
|
708
|
-
const reminder = createReminder({
|
|
709
|
-
contract_id: opts.contract,
|
|
710
|
-
remind_at: opts.at,
|
|
711
|
-
message: opts.message,
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
if (opts.json) {
|
|
715
|
-
console.log(JSON.stringify(reminder, null, 2));
|
|
716
|
-
} else {
|
|
717
|
-
console.log(`Set reminder: ${reminder.message} at ${reminder.remind_at} (${reminder.id})`);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
|
|
722
|
-
remindCmd
|
|
723
|
-
.command("list")
|
|
724
|
-
.description("List reminders for a contract")
|
|
725
|
-
.argument("<contract-id>", "Contract ID")
|
|
726
|
-
.option("--json", "Output as JSON", false)
|
|
727
|
-
.action((contractId, opts) => {
|
|
728
|
-
const reminders = listReminders(contractId);
|
|
729
|
-
|
|
730
|
-
if (opts.json) {
|
|
731
|
-
console.log(JSON.stringify(reminders, null, 2));
|
|
732
|
-
} else {
|
|
733
|
-
if (reminders.length === 0) {
|
|
734
|
-
console.log("No reminders found.");
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
for (const r of reminders) {
|
|
738
|
-
const sent = r.sent ? " (sent)" : "";
|
|
739
|
-
console.log(` ${r.remind_at} — ${r.message}${sent}`);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
// --- Stats ---
|
|
745
|
-
|
|
746
|
-
program
|
|
747
|
-
.command("stats")
|
|
748
|
-
.description("Show contract statistics")
|
|
749
|
-
.option("--json", "Output as JSON", false)
|
|
750
|
-
.action((opts) => {
|
|
751
|
-
const stats = getContractStats();
|
|
752
|
-
|
|
753
|
-
if (opts.json) {
|
|
754
|
-
console.log(JSON.stringify(stats, null, 2));
|
|
755
|
-
} else {
|
|
756
|
-
console.log(`Total contracts: ${stats.total}`);
|
|
757
|
-
console.log("\nBy status:");
|
|
758
|
-
for (const [status, count] of Object.entries(stats.by_status)) {
|
|
759
|
-
console.log(` ${status}: ${count}`);
|
|
760
|
-
}
|
|
761
|
-
console.log("\nBy type:");
|
|
762
|
-
for (const [type, count] of Object.entries(stats.by_type)) {
|
|
763
|
-
console.log(` ${type}: ${count}`);
|
|
764
|
-
}
|
|
765
|
-
console.log(`\nTotal active value: ${stats.total_value} USD`);
|
|
766
|
-
console.log(`Expiring within 30 days: ${stats.expiring_30_days}`);
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
program.parse(process.argv);
|