@hisaabo/cli 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +154 -4
  2. package/dist/bin/{audit-trail-IJ6SKACR.js → audit-trail-RTPTWZAL.js} +12 -15
  3. package/dist/bin/{categories-O6TODPAH.js → categories-JJDTOT5T.js} +3 -3
  4. package/dist/bin/{check-slug-P7RFU6OP.js → check-slug-5L2VDAEN.js} +16 -4
  5. package/dist/bin/chunk-2DDIXPNI.js +1512 -0
  6. package/dist/bin/chunk-ALOHN6GR.js +78 -0
  7. package/dist/bin/{chunk-QUITS2FE.js → chunk-ESX7V56A.js} +95 -20
  8. package/dist/bin/chunk-M7DVLVD5.js +245 -0
  9. package/dist/bin/{chunk-WDN7RIE3.js → chunk-VXEEFNIY.js} +133 -47
  10. package/dist/bin/client-NFYNYEDI.js +17 -0
  11. package/dist/bin/{collection-efficiency-DA5RWG3V.js → collection-efficiency-UF3AJPQB.js} +12 -56
  12. package/dist/bin/{config-4LLNT4SH.js → config-7HVBRHL3.js} +2 -2
  13. package/dist/bin/{create-C5INBPQO.js → create-2BZQLXQA.js} +18 -9
  14. package/dist/bin/{default-account-2GMQ7ZA4.js → default-account-MR6O5LPT.js} +7 -13
  15. package/dist/bin/{expenses-S2YVA5UT.js → expenses-CU6JGDVX.js} +12 -11
  16. package/dist/bin/{export-YOOODNVX.js → export-GFYQIQLT.js} +9 -24
  17. package/dist/bin/{export-6PMJ2YVL.js → export-WS24LYNH.js} +47 -11
  18. package/dist/bin/{factory-6MUCSXTL.js → factory-JSEQCPY3.js} +51 -57
  19. package/dist/bin/{get-GMQRROK2.js → get-HGMB7T6Y.js} +5 -4
  20. package/dist/bin/{get-ZV3SC2VY.js → get-KAOGGRJR.js} +4 -4
  21. package/dist/bin/hisaabo.js +2024 -837
  22. package/dist/bin/{import-UUHMLCKX.js → import-6CEMNCTM.js} +30 -33
  23. package/dist/bin/{invitations-OVORTTMF.js → invitations-LASABD2X.js} +11 -14
  24. package/dist/bin/{invite-GGHBZY4U.js → invite-VCBXS7VY.js} +13 -15
  25. package/dist/bin/{invoice-breakdown-32XXAZDP.js → invoice-breakdown-3XXSYA77.js} +12 -37
  26. package/dist/bin/{items-6NOIMH6B.js → items-PJPN6ZX3.js} +11 -10
  27. package/dist/bin/{items-toggle-L6W6QKQD.js → items-toggle-53C35MJU.js} +6 -5
  28. package/dist/bin/{list-RAR56EMQ.js → list-63EKE6DT.js} +13 -16
  29. package/dist/bin/{list-OXAVDXH7.js → list-7OSZX6C7.js} +5 -5
  30. package/dist/bin/{list-FC5JHKHD.js → list-OOROCQR2.js} +11 -12
  31. package/dist/bin/{members-Y6XJVHHR.js → members-SPHU5F4M.js} +7 -7
  32. package/dist/bin/monthly-comparison-3FFJT63K.js +79 -0
  33. package/dist/bin/{order-cancel-QRTCNART.js → order-cancel-RW4NYHKN.js} +8 -18
  34. package/dist/bin/{order-confirm-LGQOMC4O.js → order-confirm-NXFL2EIQ.js} +7 -15
  35. package/dist/bin/{order-get-4XAQCRYV.js → order-get-QPSOY2RT.js} +11 -11
  36. package/dist/bin/{order-update-KZY4H2UR.js → order-update-7DWKEROO.js} +4 -4
  37. package/dist/bin/{output-NUOL7KJW.js → output-XFDIL3A6.js} +5 -1
  38. package/dist/bin/{payment-modes-DY2ZEMK7.js → payment-modes-Z5WV3E3O.js} +12 -27
  39. package/dist/bin/{profit-loss-5GJBG3PL.js → profit-loss-AOISAJ56.js} +14 -13
  40. package/dist/bin/{receivables-aging-6A7XJKDT.js → receivables-aging-5JHFECGB.js} +13 -66
  41. package/dist/bin/{remove-ZBX34TIQ.js → remove-TC4UWMOL.js} +7 -15
  42. package/dist/bin/{revoke-ZTAMW2Q2.js → revoke-QHLNPGI5.js} +7 -3
  43. package/dist/bin/{revoke-XDNOA2GJ.js → revoke-SXVNALYQ.js} +7 -15
  44. package/dist/bin/{revoke-all-365NRBOA.js → revoke-all-CYW6A5UE.js} +8 -4
  45. package/dist/bin/{revoke-invitation-PQH7XNYA.js → revoke-invitation-Z33EUJTS.js} +7 -3
  46. package/dist/bin/safety-TPD2P7I5.js +18 -0
  47. package/dist/bin/{sales-trend-D6PQ7MHY.js → sales-trend-WCW6X5BI.js} +16 -16
  48. package/dist/bin/sequence-HOQ4PQRK.js +56 -0
  49. package/dist/bin/{store-SVRZBUFO.js → store-DDMHTNTO.js} +15 -8
  50. package/dist/bin/{summary-H6U7O5GJ.js → summary-TYAL2D3Q.js} +7 -5
  51. package/dist/bin/{top-customers-ATBN6RDI.js → top-customers-GMIS6GC3.js} +13 -11
  52. package/dist/bin/{top-items-XXU6KYTC.js → top-items-BK54JO3G.js} +16 -14
  53. package/dist/bin/{top-outstanding-JTQNGGW4.js → top-outstanding-L4NRJ6NE.js} +9 -11
  54. package/dist/bin/{unpaid-invoices-BTNQFWCH.js → unpaid-invoices-CEUFEYH7.js} +8 -8
  55. package/dist/bin/{untracked-PAMEDJ6Y.js → untracked-T6DIDMDQ.js} +9 -9
  56. package/dist/bin/{update-EK4NJWU4.js → update-EPNB2U74.js} +4 -4
  57. package/dist/bin/{update-EGHPFXLK.js → update-I2DZRVLR.js} +10 -17
  58. package/dist/bin/{update-6ZMX2OYX.js → update-MFNOVS6D.js} +4 -4
  59. package/dist/bin/{update-role-24PDTNFK.js → update-role-D2ETEL2Q.js} +7 -4
  60. package/dist/bin/{update-settings-AASI6WZX.js → update-settings-UGXLQRYI.js} +15 -9
  61. package/package.json +8 -7
  62. package/dist/bin/chunk-NO4FIFMS.js +0 -176
  63. package/dist/bin/chunk-ZPYC767N.js +0 -157
  64. package/dist/bin/client-36JX5MR3.js +0 -11
  65. package/dist/bin/monthly-comparison-IAUZ6SBJ.js +0 -176
  66. package/dist/bin/sequence-KZWADVD7.js +0 -66
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatAmount
4
+ } from "./chunk-M7DVLVD5.js";
5
+ import {
6
+ HisaaboApiError,
7
+ HisaaboClient
8
+ } from "./chunk-VXEEFNIY.js";
9
+ import {
10
+ requireAuth
11
+ } from "./chunk-ESX7V56A.js";
12
+ import {
13
+ EXIT,
14
+ fatalError,
15
+ hasColor,
16
+ outputCSV,
17
+ outputJSON,
18
+ outputTSV,
19
+ outputTable
20
+ } from "./chunk-2DDIXPNI.js";
21
+
22
+ // src/commands/dashboard/monthly-comparison.ts
23
+ import chalk from "chalk";
24
+ function changeArrow(pct) {
25
+ if (!hasColor()) return pct >= 0 ? `+${pct.toFixed(1)}%` : `${pct.toFixed(1)}%`;
26
+ if (pct > 0) return chalk.green(`\u25B2 +${pct.toFixed(1)}%`);
27
+ if (pct < 0) return chalk.red(`\u25BC ${pct.toFixed(1)}%`);
28
+ return chalk.dim("\u2500 0.0%");
29
+ }
30
+ async function dashboardMonthlyComparisonCommand(opts) {
31
+ const cfg = requireAuth();
32
+ const client = new HisaaboClient(cfg);
33
+ try {
34
+ const data = await client.dashboard.monthlyComparison();
35
+ if (opts.json) {
36
+ outputJSON(data);
37
+ return;
38
+ }
39
+ const metric = (label, m) => ({
40
+ metric: label,
41
+ previous: formatAmount(m.prev),
42
+ current: formatAmount(m.curr),
43
+ change: m.pctChange === null ? "-" : changeArrow(m.pctChange)
44
+ });
45
+ const rows = [
46
+ metric("Sales", data.sales),
47
+ metric("Purchases", data.purchases),
48
+ metric("Expenses", data.expenses)
49
+ ];
50
+ const columns = [
51
+ { key: "metric", header: "Metric", align: "left" },
52
+ { key: "previous", header: `${data.prevMonth} \u20B9`, align: "right" },
53
+ { key: "current", header: `${data.currMonth} \u20B9`, align: "right" },
54
+ { key: "change", header: "Change", align: "right" }
55
+ ];
56
+ if (opts.format === "tsv") {
57
+ outputTSV(rows, columns);
58
+ return;
59
+ }
60
+ if (opts.format === "csv") {
61
+ outputCSV(rows, columns);
62
+ return;
63
+ }
64
+ if (hasColor()) process.stdout.write("\n" + chalk.bold(" Monthly Comparison\n") + "\n");
65
+ else process.stdout.write("\n Monthly Comparison\n\n");
66
+ outputTable(rows, columns);
67
+ process.stdout.write("\n");
68
+ } catch (e) {
69
+ if (e instanceof HisaaboApiError) {
70
+ const err = e.hisaaboError;
71
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
72
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
73
+ }
74
+ fatalError(String(e instanceof Error ? e.message : e));
75
+ }
76
+ }
77
+ export {
78
+ dashboardMonthlyComparisonCommand
79
+ };
@@ -1,38 +1,28 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ confirmOrExit
4
+ } from "./chunk-ALOHN6GR.js";
2
5
  import {
3
6
  HisaaboApiError,
4
7
  HisaaboClient
5
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
6
9
  import {
7
10
  requireAuth
8
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
9
12
  import {
10
13
  EXIT,
11
14
  fatalError,
12
15
  outputJSON,
13
16
  success
14
- } from "./chunk-NO4FIFMS.js";
17
+ } from "./chunk-2DDIXPNI.js";
15
18
 
16
19
  // src/commands/store/order-cancel.ts
17
- import * as readline from "readline";
18
20
  async function storeOrderCancelCommand(id, opts) {
19
21
  const cfg = requireAuth();
20
22
  const client = new HisaaboClient(cfg);
21
- if (!opts.yes && process.stdin.isTTY) {
22
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
23
- const answer = await new Promise((resolve) => {
24
- rl.question(` Cancel order ${id}? This cannot be undone. (y/n): `, resolve);
25
- });
26
- rl.close();
27
- if (answer.trim().toLowerCase() !== "y") {
28
- console.log(" Cancelled.");
29
- process.exit(0);
30
- }
31
- }
23
+ await confirmOrExit(` Cancel order ${id}? This cannot be undone.`, opts);
32
24
  try {
33
- const input = { orderId: id };
34
- if (opts.reason) input["reason"] = opts.reason;
35
- const result = await client.store.cancelOrder(input);
25
+ const result = await client.store.cancelOrder({ orderId: id, reason: opts.reason || void 0 });
36
26
  if (opts.json) {
37
27
  outputJSON(result);
38
28
  return;
@@ -1,34 +1,26 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ confirmOrExit
4
+ } from "./chunk-ALOHN6GR.js";
2
5
  import {
3
6
  HisaaboApiError,
4
7
  HisaaboClient
5
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
6
9
  import {
7
10
  requireAuth
8
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
9
12
  import {
10
13
  EXIT,
11
14
  fatalError,
12
15
  outputJSON,
13
16
  success
14
- } from "./chunk-NO4FIFMS.js";
17
+ } from "./chunk-2DDIXPNI.js";
15
18
 
16
19
  // src/commands/store/order-confirm.ts
17
- import * as readline from "readline";
18
20
  async function storeOrderConfirmCommand(id, opts) {
19
21
  const cfg = requireAuth();
20
22
  const client = new HisaaboClient(cfg);
21
- if (!opts.yes && process.stdin.isTTY) {
22
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
23
- const answer = await new Promise((resolve) => {
24
- rl.question(` Confirm order ${id}? (y/n): `, resolve);
25
- });
26
- rl.close();
27
- if (answer.trim().toLowerCase() !== "y") {
28
- console.log(" Cancelled.");
29
- process.exit(0);
30
- }
31
- }
23
+ await confirmOrExit(` Confirm order ${id}?`, opts);
32
24
  try {
33
25
  const result = await client.store.confirmOrder({ orderId: id });
34
26
  if (opts.json) {
@@ -3,20 +3,20 @@ import {
3
3
  formatAmount,
4
4
  formatDate,
5
5
  formatStatus
6
- } from "./chunk-ZPYC767N.js";
6
+ } from "./chunk-M7DVLVD5.js";
7
7
  import {
8
8
  HisaaboApiError,
9
9
  HisaaboClient
10
- } from "./chunk-WDN7RIE3.js";
10
+ } from "./chunk-VXEEFNIY.js";
11
11
  import {
12
12
  requireAuth
13
- } from "./chunk-QUITS2FE.js";
13
+ } from "./chunk-ESX7V56A.js";
14
14
  import {
15
15
  EXIT,
16
16
  fatalError,
17
17
  hasColor,
18
18
  outputJSON
19
- } from "./chunk-NO4FIFMS.js";
19
+ } from "./chunk-2DDIXPNI.js";
20
20
 
21
21
  // src/commands/store/order-get.ts
22
22
  import chalk from "chalk";
@@ -53,21 +53,21 @@ async function storeOrderGetCommand(id, opts) {
53
53
  `);
54
54
  process.stdout.write(` Total: \u20B9${formatAmount(order.totalAmount)}
55
55
  `);
56
- if (order.shippingAddress) {
57
- process.stdout.write(` Address: ${order.shippingAddress}
56
+ if (order.deliveryAddress) {
57
+ process.stdout.write(` Address: ${order.deliveryAddress}
58
58
  `);
59
59
  }
60
- if (order.notes) {
61
- process.stdout.write(` Notes: ${order.notes}
60
+ if (order.deliveryNotes) {
61
+ process.stdout.write(` Notes: ${order.deliveryNotes}
62
62
  `);
63
63
  }
64
- if (order.items && order.items.length > 0) {
64
+ if (order.lineItems.length > 0) {
65
65
  process.stdout.write(`
66
66
  Items:
67
67
  `);
68
- for (const item of order.items) {
68
+ for (const item of order.lineItems) {
69
69
  process.stdout.write(
70
- ` \u2022 ${item.name} qty: ${item.quantity} \u20B9${formatAmount(item.price)}
70
+ ` \u2022 ${item.itemName} qty: ${item.quantity} \u20B9${formatAmount(item.unitPrice)}
71
71
  `
72
72
  );
73
73
  }
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  formatStatus
4
- } from "./chunk-ZPYC767N.js";
4
+ } from "./chunk-M7DVLVD5.js";
5
5
  import {
6
6
  HisaaboApiError,
7
7
  HisaaboClient
8
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
9
9
  import {
10
10
  requireAuth
11
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
12
12
  import {
13
13
  EXIT,
14
14
  fatalError,
15
15
  outputJSON,
16
16
  success
17
- } from "./chunk-NO4FIFMS.js";
17
+ } from "./chunk-2DDIXPNI.js";
18
18
 
19
19
  // src/commands/store/order-update.ts
20
20
  var VALID_STATUSES = ["preparing", "ready", "delivered"];
@@ -4,6 +4,7 @@ import {
4
4
  fatalError,
5
5
  getWidthTier,
6
6
  hasColor,
7
+ installTerminalSanitizer,
7
8
  isInteractive,
8
9
  outputCSV,
9
10
  outputIds,
@@ -11,16 +12,18 @@ import {
11
12
  outputTSV,
12
13
  outputTable,
13
14
  paginationFooter,
15
+ sanitizeTerminal,
14
16
  stripAnsi,
15
17
  success,
16
18
  termWidth,
17
19
  warn
18
- } from "./chunk-NO4FIFMS.js";
20
+ } from "./chunk-2DDIXPNI.js";
19
21
  export {
20
22
  EXIT,
21
23
  fatalError,
22
24
  getWidthTier,
23
25
  hasColor,
26
+ installTerminalSanitizer,
24
27
  isInteractive,
25
28
  outputCSV,
26
29
  outputIds,
@@ -28,6 +31,7 @@ export {
28
31
  outputTSV,
29
32
  outputTable,
30
33
  paginationFooter,
34
+ sanitizeTerminal,
31
35
  stripAnsi,
32
36
  success,
33
37
  termWidth,
@@ -1,18 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ apiFrom,
4
+ apiTo,
3
5
  formatAmount,
4
6
  fyStart,
5
7
  monthEnd,
6
8
  monthStart,
7
9
  todayISO
8
- } from "./chunk-ZPYC767N.js";
10
+ } from "./chunk-M7DVLVD5.js";
9
11
  import {
10
12
  HisaaboApiError,
11
13
  HisaaboClient
12
- } from "./chunk-WDN7RIE3.js";
14
+ } from "./chunk-VXEEFNIY.js";
13
15
  import {
14
16
  requireAuth
15
- } from "./chunk-QUITS2FE.js";
17
+ } from "./chunk-ESX7V56A.js";
16
18
  import {
17
19
  EXIT,
18
20
  fatalError,
@@ -21,7 +23,7 @@ import {
21
23
  outputJSON,
22
24
  outputTSV,
23
25
  outputTable
24
- } from "./chunk-NO4FIFMS.js";
26
+ } from "./chunk-2DDIXPNI.js";
25
27
 
26
28
  // src/commands/dashboard/payment-modes.ts
27
29
  import chalk from "chalk";
@@ -54,33 +56,16 @@ async function dashboardPaymentModesCommand(opts) {
54
56
  toDate = todayISO();
55
57
  }
56
58
  try {
57
- const data = await client.dashboard.paymentModeBreakdown({ fromDate, toDate });
59
+ const data = await client.dashboard.paymentModeBreakdown({ fromDate: apiFrom(fromDate), toDate: apiTo(toDate) });
58
60
  if (opts.json) {
59
61
  outputJSON(data);
60
62
  return;
61
63
  }
62
- let modes = [];
63
- if (Array.isArray(data)) {
64
- modes = data.map((r) => ({
65
- mode: String(r["mode"] ?? r["paymentMode"] ?? r["method"] ?? "-"),
66
- amount: parseFloat(String(r["amount"] ?? r["totalAmount"] ?? "0")),
67
- count: parseInt(String(r["count"] ?? r["paymentCount"] ?? "0"), 10)
68
- }));
69
- } else if (data && typeof data === "object") {
70
- const obj = data;
71
- for (const [key, val] of Object.entries(obj)) {
72
- if (typeof val === "object" && val !== null) {
73
- const entry = val;
74
- modes.push({
75
- mode: key,
76
- amount: parseFloat(String(entry["amount"] ?? entry["totalAmount"] ?? "0")),
77
- count: parseInt(String(entry["count"] ?? "0"), 10)
78
- });
79
- } else if (typeof val === "string" || typeof val === "number") {
80
- modes.push({ mode: key, amount: parseFloat(String(val)), count: 0 });
81
- }
82
- }
83
- }
64
+ const modes = data.map((r) => ({
65
+ mode: r.mode,
66
+ amount: parseFloat(r.total),
67
+ count: r.count
68
+ }));
84
69
  modes.sort((a, b) => b.amount - a.amount);
85
70
  const total = modes.reduce((s, r) => s + r.amount, 0);
86
71
  const rows = modes.map((r) => {
@@ -1,26 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ apiFrom,
4
+ apiTo,
3
5
  formatDate,
4
6
  formatINR,
5
7
  fyStart,
6
8
  monthEnd,
7
9
  monthStart,
8
10
  todayISO
9
- } from "./chunk-ZPYC767N.js";
11
+ } from "./chunk-M7DVLVD5.js";
10
12
  import {
11
13
  HisaaboApiError,
12
14
  HisaaboClient
13
- } from "./chunk-WDN7RIE3.js";
15
+ } from "./chunk-VXEEFNIY.js";
14
16
  import {
15
17
  requireAuth
16
- } from "./chunk-QUITS2FE.js";
18
+ } from "./chunk-ESX7V56A.js";
17
19
  import {
18
20
  EXIT,
19
21
  fatalError,
20
22
  hasColor,
21
23
  outputJSON,
22
24
  termWidth
23
- } from "./chunk-NO4FIFMS.js";
25
+ } from "./chunk-2DDIXPNI.js";
24
26
 
25
27
  // src/commands/dashboard/profit-loss.ts
26
28
  import chalk from "chalk";
@@ -81,19 +83,18 @@ async function dashboardProfitLossCommand(opts) {
81
83
  toDate = todayISO();
82
84
  }
83
85
  try {
84
- const data = await client.dashboard.profitAndLoss({ fromDate, toDate });
86
+ const data = await client.dashboard.profitAndLoss({ fromDate: apiFrom(fromDate), toDate: apiTo(toDate) });
85
87
  if (opts.json) {
86
88
  outputJSON(data);
87
89
  return;
88
90
  }
89
- const pl = data;
90
- const revenue = parseFloat(String(pl["revenue"] ?? pl["totalRevenue"] ?? pl["sales"] ?? "0"));
91
- const cogs = parseFloat(String(pl["cogs"] ?? pl["costOfGoodsSold"] ?? pl["purchases"] ?? "0"));
92
- const grossProfit = parseFloat(String(pl["grossProfit"] ?? String(revenue - cogs)));
93
- const opex = parseFloat(String(pl["operatingExpenses"] ?? pl["expenses"] ?? pl["totalExpenses"] ?? "0"));
94
- const netProfit = parseFloat(String(pl["netProfit"] ?? pl["profit"] ?? String(grossProfit - opex)));
95
- const grossMargin = revenue > 0 ? (grossProfit / revenue * 100).toFixed(1) + "%" : "-";
96
- const netMargin = revenue > 0 ? (netProfit / revenue * 100).toFixed(1) + "%" : "-";
91
+ const revenue = parseFloat(data.revenue);
92
+ const cogs = parseFloat(data.cogs);
93
+ const grossProfit = parseFloat(data.grossProfit);
94
+ const opex = parseFloat(data.totalExpenses);
95
+ const netProfit = parseFloat(data.netProfit);
96
+ const grossMargin = revenue > 0 ? `${data.grossMarginPercent}%` : "-";
97
+ const netMargin = revenue > 0 ? `${data.netMarginPercent}%` : "-";
97
98
  const width = Math.min(termWidth() - 2, 52);
98
99
  const innerW = width - 2;
99
100
  const lines = [];
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  formatAmount
4
- } from "./chunk-ZPYC767N.js";
4
+ } from "./chunk-M7DVLVD5.js";
5
5
  import {
6
6
  HisaaboApiError,
7
7
  HisaaboClient
8
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
9
9
  import {
10
10
  requireAuth
11
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
12
12
  import {
13
13
  EXIT,
14
14
  fatalError,
@@ -16,9 +16,8 @@ import {
16
16
  outputCSV,
17
17
  outputJSON,
18
18
  outputTSV,
19
- outputTable,
20
19
  termWidth
21
- } from "./chunk-NO4FIFMS.js";
20
+ } from "./chunk-2DDIXPNI.js";
22
21
 
23
22
  // src/commands/dashboard/receivables-aging.ts
24
23
  import chalk from "chalk";
@@ -36,55 +35,20 @@ async function dashboardReceivablesAgingCommand(opts) {
36
35
  outputJSON(data);
37
36
  return;
38
37
  }
39
- const BUCKETS = [
40
- { key: "current", label: "Current (not due)" },
41
- { key: "1_30", label: "1\u201330 days" },
42
- { key: "31_60", label: "31\u201360 days" },
43
- { key: "61_90", label: "61\u201390 days" },
44
- { key: "90_plus", label: "90+ days" }
38
+ const bucketData = [
39
+ { bucket: "Current (not due)", amount: parseFloat(data.summary.current) },
40
+ { bucket: "31\u201360 days", amount: parseFloat(data.summary.days31_60) },
41
+ { bucket: "61\u201390 days", amount: parseFloat(data.summary.days61_90) },
42
+ { bucket: "90+ days", amount: parseFloat(data.summary.days90Plus) }
45
43
  ];
46
- let bucketData = [];
47
- if (Array.isArray(data)) {
48
- bucketData = data.map((r) => ({
49
- bucket: String(r["bucket"] ?? r["range"] ?? r["label"] ?? "-"),
50
- amount: parseFloat(String(r["amount"] ?? r["totalAmount"] ?? "0")),
51
- count: parseInt(String(r["count"] ?? r["invoiceCount"] ?? "0"), 10)
52
- }));
53
- } else if (data && typeof data === "object") {
54
- const obj = data;
55
- for (const { key, label } of BUCKETS) {
56
- const entry = obj[key] ?? obj[label];
57
- if (entry != null) {
58
- bucketData.push({
59
- bucket: label,
60
- amount: parseFloat(String(entry["amount"] ?? entry["totalAmount"] ?? "0")),
61
- count: parseInt(String(entry["count"] ?? entry["invoiceCount"] ?? "0"), 10)
62
- });
63
- }
64
- }
65
- if (bucketData.length === 0) {
66
- for (const { key, label } of BUCKETS) {
67
- const val = obj[key];
68
- if (val != null) {
69
- bucketData.push({
70
- bucket: label,
71
- amount: parseFloat(String(val)),
72
- count: 0
73
- });
74
- }
75
- }
76
- }
77
- }
78
44
  if (opts.format === "tsv" || opts.format === "csv") {
79
45
  const rows = bucketData.map((r) => ({
80
46
  bucket: r.bucket,
81
- amount: formatAmount(r.amount),
82
- count: String(r.count || "-")
47
+ amount: formatAmount(r.amount)
83
48
  }));
84
49
  const columns = [
85
50
  { key: "bucket", header: "Aging Bucket", align: "left" },
86
- { key: "amount", header: "Amount \u20B9", align: "right" },
87
- { key: "count", header: "Invoices", align: "right" }
51
+ { key: "amount", header: "Amount \u20B9", align: "right" }
88
52
  ];
89
53
  if (opts.format === "tsv") outputTSV(rows, columns);
90
54
  else outputCSV(rows, columns);
@@ -113,8 +77,8 @@ async function dashboardReceivablesAgingCommand(opts) {
113
77
  let coloredLabel = label;
114
78
  if (hasColor()) {
115
79
  const idx = bucketData.indexOf(row);
116
- const colors = [chalk.green, chalk.yellow, chalk.yellow, chalk.red, chalk.red];
117
- const labelColors = [chalk.green, chalk.yellow, chalk.yellow, chalk.red, (s) => chalk.bold(chalk.red(s))];
80
+ const colors = [chalk.green, chalk.yellow, chalk.red, chalk.red];
81
+ const labelColors = [chalk.green, chalk.yellow, chalk.red, (s) => chalk.bold(chalk.red(s))];
118
82
  const colorFn = colors[idx] ?? chalk.white;
119
83
  const labelFn = labelColors[idx] ?? chalk.white;
120
84
  coloredBar = colorFn(bar);
@@ -130,23 +94,6 @@ async function dashboardReceivablesAgingCommand(opts) {
130
94
  const totalLine = ` \u2502 ${hasColor() ? chalk.bold(totalLabel) : totalLabel} ${" ".repeat(barW)} ${hasColor() ? chalk.bold(totalAmt) : totalAmt} \u2502`;
131
95
  process.stdout.write(totalLine + "\n");
132
96
  process.stdout.write(" \u2514" + "\u2500".repeat(innerW) + "\u2518\n\n");
133
- if (bucketData.length === 0) {
134
- process.stdout.write(" No receivables data available.\n\n");
135
- }
136
- if (bucketData.some((r) => r.count > 0)) {
137
- const rows = bucketData.map((r) => ({
138
- bucket: r.bucket,
139
- amount: formatAmount(r.amount),
140
- count: String(r.count)
141
- }));
142
- const columns = [
143
- { key: "bucket", header: "Aging Bucket", align: "left" },
144
- { key: "amount", header: "Amount \u20B9", align: "right" },
145
- { key: "count", header: "Invoices", align: "right" }
146
- ];
147
- outputTable(rows, columns);
148
- process.stdout.write("\n");
149
- }
150
97
  } catch (e) {
151
98
  if (e instanceof HisaaboApiError) {
152
99
  const err = e.hisaaboError;
@@ -1,35 +1,27 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ confirmOrExit
4
+ } from "./chunk-ALOHN6GR.js";
2
5
  import {
3
6
  HisaaboApiError,
4
7
  HisaaboClient
5
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
6
9
  import {
7
10
  requireAuth
8
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
9
12
  import {
10
13
  EXIT,
11
14
  fatalError,
12
15
  outputJSON,
13
16
  success
14
- } from "./chunk-NO4FIFMS.js";
17
+ } from "./chunk-2DDIXPNI.js";
15
18
 
16
19
  // src/commands/tenant/remove.ts
17
- import * as readline from "readline";
18
20
  async function tenantRemoveCommand(userId, opts) {
19
21
  const cfg = requireAuth();
20
22
  const client = new HisaaboClient(cfg);
21
23
  try {
22
- if (!opts.yes && process.stdin.isTTY) {
23
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
24
- const answer = await new Promise((resolve) => {
25
- rl.question(` Remove member ${userId} from the organization? (y/N): `, resolve);
26
- });
27
- rl.close();
28
- if (answer.trim().toLowerCase() !== "y") {
29
- console.log(" Cancelled.");
30
- process.exit(0);
31
- }
32
- }
24
+ await confirmOrExit(` Remove member ${userId} from the organization?`, opts);
33
25
  const result = await client.tenant.removeMember({ userId });
34
26
  if (opts.json) {
35
27
  outputJSON(result);
@@ -1,22 +1,26 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ confirmOrExit
4
+ } from "./chunk-ALOHN6GR.js";
2
5
  import {
3
6
  HisaaboApiError,
4
7
  HisaaboClient
5
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
6
9
  import {
7
10
  requireAuth
8
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
9
12
  import {
10
13
  EXIT,
11
14
  fatalError,
12
15
  outputJSON,
13
16
  success
14
- } from "./chunk-NO4FIFMS.js";
17
+ } from "./chunk-2DDIXPNI.js";
15
18
 
16
19
  // src/commands/session/revoke.ts
17
20
  async function revokeSessionCommand(sessionId, opts) {
18
21
  const cfg = requireAuth();
19
22
  const client = new HisaaboClient(cfg);
23
+ await confirmOrExit(`Revoke session ${sessionId}?`, opts);
20
24
  try {
21
25
  const result = await client.auth.revokeSession({ sessionId });
22
26
  if (opts.json) {
@@ -1,34 +1,26 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ confirmOrExit
4
+ } from "./chunk-ALOHN6GR.js";
2
5
  import {
3
6
  HisaaboApiError,
4
7
  HisaaboClient
5
- } from "./chunk-WDN7RIE3.js";
8
+ } from "./chunk-VXEEFNIY.js";
6
9
  import {
7
10
  requireAuth
8
- } from "./chunk-QUITS2FE.js";
11
+ } from "./chunk-ESX7V56A.js";
9
12
  import {
10
13
  EXIT,
11
14
  fatalError,
12
15
  outputJSON,
13
16
  success
14
- } from "./chunk-NO4FIFMS.js";
17
+ } from "./chunk-2DDIXPNI.js";
15
18
 
16
19
  // src/commands/api-key/revoke.ts
17
- import * as readline from "readline";
18
20
  async function apiKeyRevokeCommand(id, opts) {
19
21
  const cfg = requireAuth();
20
22
  const client = new HisaaboClient(cfg);
21
- if (!opts.yes && process.stdin.isTTY) {
22
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
23
- const answer = await new Promise((resolve) => {
24
- rl.question(` Revoke API key ${id}? This cannot be undone. (y/N): `, resolve);
25
- });
26
- rl.close();
27
- if (answer.trim().toLowerCase() !== "y") {
28
- console.log(" Cancelled.");
29
- process.exit(0);
30
- }
31
- }
23
+ await confirmOrExit(` Revoke API key ${id}? This cannot be undone.`, opts);
32
24
  try {
33
25
  const result = await client.apiKey.revoke({ id });
34
26
  if (opts.json) {