@hasna/microservices 0.0.2 → 0.0.4
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/bin/index.js +70 -0
- package/bin/mcp.js +71 -1
- package/dist/index.js +70 -0
- package/microservices/microservice-ads/package.json +27 -0
- package/microservices/microservice-ads/src/cli/index.ts +407 -0
- package/microservices/microservice-ads/src/db/campaigns.ts +493 -0
- package/microservices/microservice-ads/src/db/database.ts +93 -0
- package/microservices/microservice-ads/src/db/migrations.ts +60 -0
- package/microservices/microservice-ads/src/index.ts +39 -0
- package/microservices/microservice-ads/src/mcp/index.ts +320 -0
- package/microservices/microservice-contracts/package.json +27 -0
- package/microservices/microservice-contracts/src/cli/index.ts +383 -0
- package/microservices/microservice-contracts/src/db/contracts.ts +496 -0
- package/microservices/microservice-contracts/src/db/database.ts +93 -0
- package/microservices/microservice-contracts/src/db/migrations.ts +58 -0
- package/microservices/microservice-contracts/src/index.ts +43 -0
- package/microservices/microservice-contracts/src/mcp/index.ts +308 -0
- package/microservices/microservice-domains/package.json +27 -0
- package/microservices/microservice-domains/src/cli/index.ts +438 -0
- package/microservices/microservice-domains/src/db/database.ts +93 -0
- package/microservices/microservice-domains/src/db/domains.ts +551 -0
- package/microservices/microservice-domains/src/db/migrations.ts +60 -0
- package/microservices/microservice-domains/src/index.ts +44 -0
- package/microservices/microservice-domains/src/mcp/index.ts +368 -0
- package/microservices/microservice-hiring/package.json +27 -0
- package/microservices/microservice-hiring/src/cli/index.ts +431 -0
- package/microservices/microservice-hiring/src/db/database.ts +93 -0
- package/microservices/microservice-hiring/src/db/hiring.ts +582 -0
- package/microservices/microservice-hiring/src/db/migrations.ts +68 -0
- package/microservices/microservice-hiring/src/index.ts +51 -0
- package/microservices/microservice-hiring/src/mcp/index.ts +464 -0
- package/microservices/microservice-payments/package.json +27 -0
- package/microservices/microservice-payments/src/cli/index.ts +357 -0
- package/microservices/microservice-payments/src/db/database.ts +93 -0
- package/microservices/microservice-payments/src/db/migrations.ts +63 -0
- package/microservices/microservice-payments/src/db/payments.ts +652 -0
- package/microservices/microservice-payments/src/index.ts +51 -0
- package/microservices/microservice-payments/src/mcp/index.ts +460 -0
- package/microservices/microservice-payroll/package.json +27 -0
- package/microservices/microservice-payroll/src/cli/index.ts +374 -0
- package/microservices/microservice-payroll/src/db/database.ts +93 -0
- package/microservices/microservice-payroll/src/db/migrations.ts +69 -0
- package/microservices/microservice-payroll/src/db/payroll.ts +741 -0
- package/microservices/microservice-payroll/src/index.ts +48 -0
- package/microservices/microservice-payroll/src/mcp/index.ts +420 -0
- package/microservices/microservice-shipping/package.json +27 -0
- package/microservices/microservice-shipping/src/cli/index.ts +398 -0
- package/microservices/microservice-shipping/src/db/database.ts +93 -0
- package/microservices/microservice-shipping/src/db/migrations.ts +61 -0
- package/microservices/microservice-shipping/src/db/shipping.ts +643 -0
- package/microservices/microservice-shipping/src/index.ts +53 -0
- package/microservices/microservice-shipping/src/mcp/index.ts +385 -0
- package/microservices/microservice-social/package.json +27 -0
- package/microservices/microservice-social/src/cli/index.ts +447 -0
- package/microservices/microservice-social/src/db/database.ts +93 -0
- package/microservices/microservice-social/src/db/migrations.ts +55 -0
- package/microservices/microservice-social/src/db/social.ts +672 -0
- package/microservices/microservice-social/src/index.ts +46 -0
- package/microservices/microservice-social/src/mcp/index.ts +435 -0
- package/microservices/microservice-subscriptions/package.json +27 -0
- package/microservices/microservice-subscriptions/src/cli/index.ts +400 -0
- package/microservices/microservice-subscriptions/src/db/database.ts +93 -0
- package/microservices/microservice-subscriptions/src/db/migrations.ts +57 -0
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +692 -0
- package/microservices/microservice-subscriptions/src/index.ts +41 -0
- package/microservices/microservice-subscriptions/src/mcp/index.ts +365 -0
- package/microservices/microservice-transcriber/package.json +28 -0
- package/microservices/microservice-transcriber/src/cli/index.ts +1347 -0
- package/microservices/microservice-transcriber/src/db/annotations.ts +37 -0
- package/microservices/microservice-transcriber/src/db/database.ts +82 -0
- package/microservices/microservice-transcriber/src/db/migrations.ts +72 -0
- package/microservices/microservice-transcriber/src/db/transcripts.ts +395 -0
- package/microservices/microservice-transcriber/src/index.ts +43 -0
- package/microservices/microservice-transcriber/src/lib/config.ts +77 -0
- package/microservices/microservice-transcriber/src/lib/diff.ts +91 -0
- package/microservices/microservice-transcriber/src/lib/downloader.ts +570 -0
- package/microservices/microservice-transcriber/src/lib/feeds.ts +62 -0
- package/microservices/microservice-transcriber/src/lib/live.ts +94 -0
- package/microservices/microservice-transcriber/src/lib/notion.ts +129 -0
- package/microservices/microservice-transcriber/src/lib/providers.ts +713 -0
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +147 -0
- package/microservices/microservice-transcriber/src/lib/translator.ts +75 -0
- package/microservices/microservice-transcriber/src/lib/webhook.ts +37 -0
- package/microservices/microservice-transcriber/src/mcp/index.ts +1070 -0
- package/microservices/microservice-transcriber/src/server/index.ts +199 -0
- package/package.json +1 -1
- 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
|
@@ -0,0 +1,383 @@
|
|
|
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
|
+
} from "../db/contracts.js";
|
|
15
|
+
import {
|
|
16
|
+
createClause,
|
|
17
|
+
listClauses,
|
|
18
|
+
deleteClause,
|
|
19
|
+
} from "../db/contracts.js";
|
|
20
|
+
import {
|
|
21
|
+
createReminder,
|
|
22
|
+
listReminders,
|
|
23
|
+
deleteReminder,
|
|
24
|
+
} from "../db/contracts.js";
|
|
25
|
+
|
|
26
|
+
const program = new Command();
|
|
27
|
+
|
|
28
|
+
program
|
|
29
|
+
.name("microservice-contracts")
|
|
30
|
+
.description("Contract and agreement management microservice")
|
|
31
|
+
.version("0.0.1");
|
|
32
|
+
|
|
33
|
+
// --- Contracts ---
|
|
34
|
+
|
|
35
|
+
const contractCmd = program
|
|
36
|
+
.command("contract")
|
|
37
|
+
.description("Contract management");
|
|
38
|
+
|
|
39
|
+
contractCmd
|
|
40
|
+
.command("create")
|
|
41
|
+
.description("Create a new contract")
|
|
42
|
+
.requiredOption("--title <title>", "Contract title")
|
|
43
|
+
.option("--type <type>", "Contract type (nda/service/employment/license/other)", "other")
|
|
44
|
+
.option("--status <status>", "Status (draft/pending_signature/active/expired/terminated)", "draft")
|
|
45
|
+
.option("--counterparty <name>", "Counterparty name")
|
|
46
|
+
.option("--counterparty-email <email>", "Counterparty email")
|
|
47
|
+
.option("--start-date <date>", "Start date (YYYY-MM-DD)")
|
|
48
|
+
.option("--end-date <date>", "End date (YYYY-MM-DD)")
|
|
49
|
+
.option("--auto-renew", "Enable auto-renewal", false)
|
|
50
|
+
.option("--renewal-period <period>", "Renewal period (e.g. '1 year')")
|
|
51
|
+
.option("--value <amount>", "Contract value")
|
|
52
|
+
.option("--currency <code>", "Currency code", "USD")
|
|
53
|
+
.option("--file-path <path>", "Path to contract file")
|
|
54
|
+
.option("--json", "Output as JSON", false)
|
|
55
|
+
.action((opts) => {
|
|
56
|
+
const contract = createContract({
|
|
57
|
+
title: opts.title,
|
|
58
|
+
type: opts.type,
|
|
59
|
+
status: opts.status,
|
|
60
|
+
counterparty: opts.counterparty,
|
|
61
|
+
counterparty_email: opts.counterpartyEmail,
|
|
62
|
+
start_date: opts.startDate,
|
|
63
|
+
end_date: opts.endDate,
|
|
64
|
+
auto_renew: opts.autoRenew,
|
|
65
|
+
renewal_period: opts.renewalPeriod,
|
|
66
|
+
value: opts.value ? parseFloat(opts.value) : undefined,
|
|
67
|
+
currency: opts.currency,
|
|
68
|
+
file_path: opts.filePath,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (opts.json) {
|
|
72
|
+
console.log(JSON.stringify(contract, null, 2));
|
|
73
|
+
} else {
|
|
74
|
+
console.log(`Created contract: ${contract.title} (${contract.id})`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
contractCmd
|
|
79
|
+
.command("list")
|
|
80
|
+
.description("List contracts")
|
|
81
|
+
.option("--search <query>", "Search by title, counterparty, or email")
|
|
82
|
+
.option("--type <type>", "Filter by type")
|
|
83
|
+
.option("--status <status>", "Filter by status")
|
|
84
|
+
.option("--counterparty <name>", "Filter by counterparty")
|
|
85
|
+
.option("--limit <n>", "Limit results")
|
|
86
|
+
.option("--json", "Output as JSON", false)
|
|
87
|
+
.action((opts) => {
|
|
88
|
+
const contracts = listContracts({
|
|
89
|
+
search: opts.search,
|
|
90
|
+
type: opts.type,
|
|
91
|
+
status: opts.status,
|
|
92
|
+
counterparty: opts.counterparty,
|
|
93
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (opts.json) {
|
|
97
|
+
console.log(JSON.stringify(contracts, null, 2));
|
|
98
|
+
} else {
|
|
99
|
+
if (contracts.length === 0) {
|
|
100
|
+
console.log("No contracts found.");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const c of contracts) {
|
|
104
|
+
const cp = c.counterparty ? ` — ${c.counterparty}` : "";
|
|
105
|
+
const status = ` [${c.status}]`;
|
|
106
|
+
console.log(` ${c.title}${cp}${status} (${c.id})`);
|
|
107
|
+
}
|
|
108
|
+
console.log(`\n${contracts.length} contract(s)`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
contractCmd
|
|
113
|
+
.command("get")
|
|
114
|
+
.description("Get a contract by ID")
|
|
115
|
+
.argument("<id>", "Contract ID")
|
|
116
|
+
.option("--json", "Output as JSON", false)
|
|
117
|
+
.action((id, opts) => {
|
|
118
|
+
const contract = getContract(id);
|
|
119
|
+
if (!contract) {
|
|
120
|
+
console.error(`Contract '${id}' not found.`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (opts.json) {
|
|
125
|
+
console.log(JSON.stringify(contract, null, 2));
|
|
126
|
+
} else {
|
|
127
|
+
console.log(`${contract.title}`);
|
|
128
|
+
console.log(` Type: ${contract.type}`);
|
|
129
|
+
console.log(` Status: ${contract.status}`);
|
|
130
|
+
if (contract.counterparty) console.log(` Counterparty: ${contract.counterparty}`);
|
|
131
|
+
if (contract.counterparty_email) console.log(` Email: ${contract.counterparty_email}`);
|
|
132
|
+
if (contract.start_date) console.log(` Start: ${contract.start_date}`);
|
|
133
|
+
if (contract.end_date) console.log(` End: ${contract.end_date}`);
|
|
134
|
+
if (contract.value !== null) console.log(` Value: ${contract.value} ${contract.currency}`);
|
|
135
|
+
if (contract.auto_renew) console.log(` Auto-renew: ${contract.renewal_period || "1 year"}`);
|
|
136
|
+
if (contract.file_path) console.log(` File: ${contract.file_path}`);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
contractCmd
|
|
141
|
+
.command("update")
|
|
142
|
+
.description("Update a contract")
|
|
143
|
+
.argument("<id>", "Contract ID")
|
|
144
|
+
.option("--title <title>", "Title")
|
|
145
|
+
.option("--type <type>", "Type")
|
|
146
|
+
.option("--status <status>", "Status")
|
|
147
|
+
.option("--counterparty <name>", "Counterparty name")
|
|
148
|
+
.option("--counterparty-email <email>", "Counterparty email")
|
|
149
|
+
.option("--start-date <date>", "Start date")
|
|
150
|
+
.option("--end-date <date>", "End date")
|
|
151
|
+
.option("--auto-renew", "Enable auto-renewal")
|
|
152
|
+
.option("--no-auto-renew", "Disable auto-renewal")
|
|
153
|
+
.option("--renewal-period <period>", "Renewal period")
|
|
154
|
+
.option("--value <amount>", "Value")
|
|
155
|
+
.option("--currency <code>", "Currency")
|
|
156
|
+
.option("--file-path <path>", "File path")
|
|
157
|
+
.option("--json", "Output as JSON", false)
|
|
158
|
+
.action((id, opts) => {
|
|
159
|
+
const input: Record<string, unknown> = {};
|
|
160
|
+
if (opts.title !== undefined) input.title = opts.title;
|
|
161
|
+
if (opts.type !== undefined) input.type = opts.type;
|
|
162
|
+
if (opts.status !== undefined) input.status = opts.status;
|
|
163
|
+
if (opts.counterparty !== undefined) input.counterparty = opts.counterparty;
|
|
164
|
+
if (opts.counterpartyEmail !== undefined) input.counterparty_email = opts.counterpartyEmail;
|
|
165
|
+
if (opts.startDate !== undefined) input.start_date = opts.startDate;
|
|
166
|
+
if (opts.endDate !== undefined) input.end_date = opts.endDate;
|
|
167
|
+
if (opts.autoRenew !== undefined) input.auto_renew = opts.autoRenew;
|
|
168
|
+
if (opts.renewalPeriod !== undefined) input.renewal_period = opts.renewalPeriod;
|
|
169
|
+
if (opts.value !== undefined) input.value = parseFloat(opts.value);
|
|
170
|
+
if (opts.currency !== undefined) input.currency = opts.currency;
|
|
171
|
+
if (opts.filePath !== undefined) input.file_path = opts.filePath;
|
|
172
|
+
|
|
173
|
+
const contract = updateContract(id, input);
|
|
174
|
+
if (!contract) {
|
|
175
|
+
console.error(`Contract '${id}' not found.`);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (opts.json) {
|
|
180
|
+
console.log(JSON.stringify(contract, null, 2));
|
|
181
|
+
} else {
|
|
182
|
+
console.log(`Updated: ${contract.title}`);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
contractCmd
|
|
187
|
+
.command("delete")
|
|
188
|
+
.description("Delete a contract")
|
|
189
|
+
.argument("<id>", "Contract ID")
|
|
190
|
+
.action((id) => {
|
|
191
|
+
const deleted = deleteContract(id);
|
|
192
|
+
if (deleted) {
|
|
193
|
+
console.log(`Deleted contract ${id}`);
|
|
194
|
+
} else {
|
|
195
|
+
console.error(`Contract '${id}' not found.`);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// --- Expiring & Renew ---
|
|
201
|
+
|
|
202
|
+
program
|
|
203
|
+
.command("expiring")
|
|
204
|
+
.description("List contracts expiring within N days")
|
|
205
|
+
.option("--days <n>", "Number of days to look ahead", "30")
|
|
206
|
+
.option("--json", "Output as JSON", false)
|
|
207
|
+
.action((opts) => {
|
|
208
|
+
const days = parseInt(opts.days);
|
|
209
|
+
const contracts = listExpiring(days);
|
|
210
|
+
|
|
211
|
+
if (opts.json) {
|
|
212
|
+
console.log(JSON.stringify(contracts, null, 2));
|
|
213
|
+
} else {
|
|
214
|
+
if (contracts.length === 0) {
|
|
215
|
+
console.log(`No contracts expiring within ${days} days.`);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
for (const c of contracts) {
|
|
219
|
+
console.log(` ${c.title} — expires ${c.end_date} [${c.status}]`);
|
|
220
|
+
}
|
|
221
|
+
console.log(`\n${contracts.length} contract(s) expiring within ${days} days`);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
program
|
|
226
|
+
.command("renew")
|
|
227
|
+
.description("Renew a contract")
|
|
228
|
+
.argument("<id>", "Contract ID")
|
|
229
|
+
.option("--json", "Output as JSON", false)
|
|
230
|
+
.action((id, opts) => {
|
|
231
|
+
const contract = renewContract(id);
|
|
232
|
+
if (!contract) {
|
|
233
|
+
console.error(`Contract '${id}' not found.`);
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (opts.json) {
|
|
238
|
+
console.log(JSON.stringify(contract, null, 2));
|
|
239
|
+
} else {
|
|
240
|
+
console.log(`Renewed: ${contract.title} — new end date: ${contract.end_date}`);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// --- Clauses ---
|
|
245
|
+
|
|
246
|
+
const clauseCmd = program
|
|
247
|
+
.command("clause")
|
|
248
|
+
.description("Clause management");
|
|
249
|
+
|
|
250
|
+
clauseCmd
|
|
251
|
+
.command("add")
|
|
252
|
+
.description("Add a clause to a contract")
|
|
253
|
+
.requiredOption("--contract <id>", "Contract ID")
|
|
254
|
+
.requiredOption("--name <name>", "Clause name")
|
|
255
|
+
.requiredOption("--text <text>", "Clause text")
|
|
256
|
+
.option("--type <type>", "Clause type (standard/custom/negotiated)", "standard")
|
|
257
|
+
.option("--json", "Output as JSON", false)
|
|
258
|
+
.action((opts) => {
|
|
259
|
+
const clause = createClause({
|
|
260
|
+
contract_id: opts.contract,
|
|
261
|
+
name: opts.name,
|
|
262
|
+
text: opts.text,
|
|
263
|
+
type: opts.type,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
if (opts.json) {
|
|
267
|
+
console.log(JSON.stringify(clause, null, 2));
|
|
268
|
+
} else {
|
|
269
|
+
console.log(`Added clause: ${clause.name} (${clause.id})`);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
clauseCmd
|
|
274
|
+
.command("list")
|
|
275
|
+
.description("List clauses for a contract")
|
|
276
|
+
.argument("<contract-id>", "Contract ID")
|
|
277
|
+
.option("--json", "Output as JSON", false)
|
|
278
|
+
.action((contractId, opts) => {
|
|
279
|
+
const clauses = listClauses(contractId);
|
|
280
|
+
|
|
281
|
+
if (opts.json) {
|
|
282
|
+
console.log(JSON.stringify(clauses, null, 2));
|
|
283
|
+
} else {
|
|
284
|
+
if (clauses.length === 0) {
|
|
285
|
+
console.log("No clauses found.");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
for (const c of clauses) {
|
|
289
|
+
console.log(` ${c.name} [${c.type}]: ${c.text.substring(0, 80)}${c.text.length > 80 ? "..." : ""}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
clauseCmd
|
|
295
|
+
.command("remove")
|
|
296
|
+
.description("Remove a clause")
|
|
297
|
+
.argument("<id>", "Clause ID")
|
|
298
|
+
.action((id) => {
|
|
299
|
+
const deleted = deleteClause(id);
|
|
300
|
+
if (deleted) {
|
|
301
|
+
console.log(`Removed clause ${id}`);
|
|
302
|
+
} else {
|
|
303
|
+
console.error(`Clause '${id}' not found.`);
|
|
304
|
+
process.exit(1);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// --- Reminders ---
|
|
309
|
+
|
|
310
|
+
const remindCmd = program
|
|
311
|
+
.command("remind")
|
|
312
|
+
.description("Reminder management");
|
|
313
|
+
|
|
314
|
+
remindCmd
|
|
315
|
+
.command("set")
|
|
316
|
+
.description("Set a reminder for a contract")
|
|
317
|
+
.requiredOption("--contract <id>", "Contract ID")
|
|
318
|
+
.requiredOption("--at <datetime>", "Reminder datetime (ISO 8601)")
|
|
319
|
+
.requiredOption("--message <msg>", "Reminder message")
|
|
320
|
+
.option("--json", "Output as JSON", false)
|
|
321
|
+
.action((opts) => {
|
|
322
|
+
const reminder = createReminder({
|
|
323
|
+
contract_id: opts.contract,
|
|
324
|
+
remind_at: opts.at,
|
|
325
|
+
message: opts.message,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
if (opts.json) {
|
|
329
|
+
console.log(JSON.stringify(reminder, null, 2));
|
|
330
|
+
} else {
|
|
331
|
+
console.log(`Set reminder: ${reminder.message} at ${reminder.remind_at} (${reminder.id})`);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
remindCmd
|
|
336
|
+
.command("list")
|
|
337
|
+
.description("List reminders for a contract")
|
|
338
|
+
.argument("<contract-id>", "Contract ID")
|
|
339
|
+
.option("--json", "Output as JSON", false)
|
|
340
|
+
.action((contractId, opts) => {
|
|
341
|
+
const reminders = listReminders(contractId);
|
|
342
|
+
|
|
343
|
+
if (opts.json) {
|
|
344
|
+
console.log(JSON.stringify(reminders, null, 2));
|
|
345
|
+
} else {
|
|
346
|
+
if (reminders.length === 0) {
|
|
347
|
+
console.log("No reminders found.");
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
for (const r of reminders) {
|
|
351
|
+
const sent = r.sent ? " (sent)" : "";
|
|
352
|
+
console.log(` ${r.remind_at} — ${r.message}${sent}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// --- Stats ---
|
|
358
|
+
|
|
359
|
+
program
|
|
360
|
+
.command("stats")
|
|
361
|
+
.description("Show contract statistics")
|
|
362
|
+
.option("--json", "Output as JSON", false)
|
|
363
|
+
.action((opts) => {
|
|
364
|
+
const stats = getContractStats();
|
|
365
|
+
|
|
366
|
+
if (opts.json) {
|
|
367
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
368
|
+
} else {
|
|
369
|
+
console.log(`Total contracts: ${stats.total}`);
|
|
370
|
+
console.log("\nBy status:");
|
|
371
|
+
for (const [status, count] of Object.entries(stats.by_status)) {
|
|
372
|
+
console.log(` ${status}: ${count}`);
|
|
373
|
+
}
|
|
374
|
+
console.log("\nBy type:");
|
|
375
|
+
for (const [type, count] of Object.entries(stats.by_type)) {
|
|
376
|
+
console.log(` ${type}: ${count}`);
|
|
377
|
+
}
|
|
378
|
+
console.log(`\nTotal active value: ${stats.total_value} USD`);
|
|
379
|
+
console.log(`Expiring within 30 days: ${stats.expiring_30_days}`);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
program.parse(process.argv);
|