@hisaabo/cli 0.3.2 → 0.5.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 (85) hide show
  1. package/.turbo/turbo-typecheck.log +1 -1
  2. package/README.md +1 -1
  3. package/dist/bin/{audit-trail-2YGXGUXW.js → audit-trail-5LOCJ7XZ.js} +4 -4
  4. package/dist/bin/{categories-P5VFWD5F.js → categories-64WWZTND.js} +3 -3
  5. package/dist/bin/{check-slug-4TMOTWUJ.js → check-slug-FLHHUDYS.js} +3 -3
  6. package/dist/bin/{chunk-FTOBDKMO.js → chunk-4MEL44QX.js} +54 -10
  7. package/dist/bin/chunk-FIMJZAS4.js +84 -0
  8. package/dist/bin/{chunk-EYNDY7RB.js → chunk-NO4FIFMS.js} +2 -1
  9. package/dist/bin/{chunk-FFBG6RU4.js → chunk-T63VQXNM.js} +1 -1
  10. package/dist/bin/{client-QNJ2H5CW.js → client-5NZ23GML.js} +1 -1
  11. package/dist/bin/{collection-efficiency-WMKEGS6U.js → collection-efficiency-U56XNVEE.js} +4 -4
  12. package/dist/bin/{config-UKVQYPPR.js → config-335MN4I7.js} +2 -2
  13. package/dist/bin/{create-Y22FAVOW.js → create-RPDEORDD.js} +3 -3
  14. package/dist/bin/{default-account-SA56M66A.js → default-account-AE6EXZZR.js} +3 -3
  15. package/dist/bin/{expenses-VZAOLYUW.js → expenses-5N2QSG54.js} +4 -4
  16. package/dist/bin/{export-QZ6WT6PJ.js → export-QICOQK34.js} +3 -3
  17. package/dist/bin/{factory-2DCU3B5T.js → factory-KOCW2AQM.js} +4 -4
  18. package/dist/bin/{get-EXL44I2X.js → get-A43QCI2S.js} +3 -3
  19. package/dist/bin/{get-6UYP6UVD.js → get-GWH6S5SJ.js} +4 -4
  20. package/dist/bin/hisaabo.js +281 -70
  21. package/dist/bin/invitations-P3EEN5WI.js +66 -0
  22. package/dist/bin/{invite-O26SAL72.js → invite-T3CKX53E.js} +3 -3
  23. package/dist/bin/{invoice-breakdown-XEATXVMR.js → invoice-breakdown-FN5BEFJD.js} +4 -4
  24. package/dist/bin/{items-3U5USBVG.js → items-2OOCQKVF.js} +4 -4
  25. package/dist/bin/{items-toggle-YEKMI2CM.js → items-toggle-SKZWCGJH.js} +3 -3
  26. package/dist/bin/{list-VBAHY72W.js → list-A2RKI3ZG.js} +4 -4
  27. package/dist/bin/list-NRMBMKMI.js +90 -0
  28. package/dist/bin/{list-FX2C3NCL.js → list-T74SN6IR.js} +3 -3
  29. package/dist/bin/{members-5FPRUAB6.js → members-W2GW3ODT.js} +4 -4
  30. package/dist/bin/{monthly-comparison-JEJ3TTY2.js → monthly-comparison-T34ZFOHL.js} +4 -4
  31. package/dist/bin/{order-cancel-XI2LKYXV.js → order-cancel-TI27JYYD.js} +3 -3
  32. package/dist/bin/{order-confirm-HUFCU6MO.js → order-confirm-VMRAMNTD.js} +3 -3
  33. package/dist/bin/{order-get-NSDMPUZR.js → order-get-C2RBUR4O.js} +4 -4
  34. package/dist/bin/{order-update-C7QYSD5R.js → order-update-RE3HATNF.js} +4 -4
  35. package/dist/bin/{output-QFLEKG5W.js → output-NUOL7KJW.js} +1 -1
  36. package/dist/bin/{payment-modes-WI3AWSES.js → payment-modes-WOOT22I7.js} +4 -4
  37. package/dist/bin/{profit-loss-5RIEOBKP.js → profit-loss-T4RESJ32.js} +4 -4
  38. package/dist/bin/{receivables-aging-L6DIQCNE.js → receivables-aging-6XMENEWS.js} +4 -4
  39. package/dist/bin/{remove-M2B4TZ37.js → remove-6QZI4JCY.js} +3 -3
  40. package/dist/bin/revoke-AVEMPAC7.js +40 -0
  41. package/dist/bin/{revoke-H3V2GNCD.js → revoke-YUCFZFNR.js} +3 -3
  42. package/dist/bin/revoke-all-LFW5WBHO.js +33 -0
  43. package/dist/bin/revoke-invitation-DTGQRJR4.js +40 -0
  44. package/dist/bin/{sales-trend-TICB3KGF.js → sales-trend-ZYBRUDUU.js} +4 -4
  45. package/dist/bin/{sequence-XUD6FAKY.js → sequence-FPOJTI2P.js} +3 -3
  46. package/dist/bin/{store-UQ2DDQ5I.js → store-IOB4Y67C.js} +4 -4
  47. package/dist/bin/{summary-BPNFC7I2.js → summary-5KYBA4ZO.js} +4 -4
  48. package/dist/bin/{top-customers-WGGJWKCN.js → top-customers-WSQ2UEJL.js} +4 -4
  49. package/dist/bin/{top-items-C7ZDDJMR.js → top-items-RWQPDGLN.js} +4 -4
  50. package/dist/bin/{top-outstanding-MOGWJIQS.js → top-outstanding-QAMO2E7Y.js} +4 -4
  51. package/dist/bin/{unpaid-invoices-ZUPNMQJP.js → unpaid-invoices-WB3TK5B4.js} +4 -4
  52. package/dist/bin/{untracked-BCJEVDW4.js → untracked-H733MYJL.js} +4 -4
  53. package/dist/bin/{update-IG565YIN.js → update-H6LPO2Z4.js} +3 -3
  54. package/dist/bin/{update-HIU4PANX.js → update-JU2X3XU5.js} +4 -4
  55. package/dist/bin/{update-PVLAX7T3.js → update-TLBUIC5J.js} +4 -4
  56. package/dist/bin/{update-role-Q4ZYJRYT.js → update-role-QST7BVFX.js} +3 -3
  57. package/dist/bin/{update-settings-XPC6L5WM.js → update-settings-Q2EGRLKZ.js} +3 -3
  58. package/package.json +1 -5
  59. package/src/auth.ts +12 -3
  60. package/src/bin/hisaabo.ts +6 -1
  61. package/src/bin/registrars/auth.ts +79 -10
  62. package/src/bin/registrars/bank.ts +34 -0
  63. package/src/bin/registrars/session.ts +32 -0
  64. package/src/bin/registrars/tenant.ts +18 -0
  65. package/src/client.ts +95 -12
  66. package/src/commands/bank/gateway-config.ts +61 -0
  67. package/src/commands/bank/update-gateway.ts +84 -0
  68. package/src/commands/payment/create.ts +1 -3
  69. package/src/commands/session/list.ts +91 -0
  70. package/src/commands/session/revoke-all.ts +20 -0
  71. package/src/commands/session/revoke.ts +32 -0
  72. package/src/commands/tenant/invitations.ts +62 -0
  73. package/src/commands/tenant/revoke-invitation.ts +32 -0
  74. package/src/config.ts +51 -2
  75. package/src/error-handler.ts +53 -0
  76. package/src/output.ts +1 -0
  77. package/src/spinner.ts +39 -0
  78. package/tsup.config.ts +6 -1
  79. package/dist/bin/chunk-2P35S2C3.js +0 -46
  80. package/src/components/ErrorDisplay.tsx +0 -16
  81. package/src/components/Header.tsx +0 -26
  82. package/src/components/MoneyCell.tsx +0 -16
  83. package/src/components/Spinner.tsx +0 -12
  84. package/src/components/StatusBadge.tsx +0 -39
  85. package/src/components/Table.tsx +0 -63
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ HisaaboApiError,
4
+ HisaaboClient
5
+ } from "./chunk-4MEL44QX.js";
6
+ import {
7
+ requireAuth
8
+ } from "./chunk-FIMJZAS4.js";
9
+ import {
10
+ EXIT,
11
+ fatalError,
12
+ outputJSON,
13
+ success
14
+ } from "./chunk-NO4FIFMS.js";
15
+
16
+ // src/commands/tenant/revoke-invitation.ts
17
+ async function revokeInvitationCommand(invitationId, opts) {
18
+ const cfg = requireAuth();
19
+ const client = new HisaaboClient(cfg);
20
+ try {
21
+ const result = await client.tenant.revokeInvitation({ invitationId });
22
+ if (opts.json) {
23
+ outputJSON(result);
24
+ return;
25
+ }
26
+ success("Invitation revoked successfully.");
27
+ } catch (e) {
28
+ if (e instanceof HisaaboApiError) {
29
+ const err = e.hisaaboError;
30
+ if (err.code === "not_found") fatalError(`Invitation not found: ${invitationId}`, EXIT.NOT_FOUND);
31
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
32
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
33
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
34
+ }
35
+ fatalError(String(e instanceof Error ? e.message : e));
36
+ }
37
+ }
38
+ export {
39
+ revokeInvitationCommand
40
+ };
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  formatAmount
4
- } from "./chunk-FFBG6RU4.js";
4
+ } from "./chunk-T63VQXNM.js";
5
5
  import {
6
6
  HisaaboApiError,
7
7
  HisaaboClient
8
- } from "./chunk-FTOBDKMO.js";
8
+ } from "./chunk-4MEL44QX.js";
9
9
  import {
10
10
  requireAuth
11
- } from "./chunk-2P35S2C3.js";
11
+ } from "./chunk-FIMJZAS4.js";
12
12
  import {
13
13
  EXIT,
14
14
  fatalError,
@@ -17,7 +17,7 @@ import {
17
17
  outputJSON,
18
18
  outputTSV,
19
19
  outputTable
20
- } from "./chunk-EYNDY7RB.js";
20
+ } from "./chunk-NO4FIFMS.js";
21
21
 
22
22
  // src/commands/dashboard/sales-trend.ts
23
23
  import chalk from "chalk";
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  HisaaboApiError,
4
4
  HisaaboClient
5
- } from "./chunk-FTOBDKMO.js";
5
+ } from "./chunk-4MEL44QX.js";
6
6
  import {
7
7
  requireAuth
8
- } from "./chunk-2P35S2C3.js";
8
+ } from "./chunk-FIMJZAS4.js";
9
9
  import {
10
10
  EXIT,
11
11
  fatalError,
12
12
  outputJSON,
13
13
  success
14
- } from "./chunk-EYNDY7RB.js";
14
+ } from "./chunk-NO4FIFMS.js";
15
15
 
16
16
  // src/commands/business/sequence.ts
17
17
  async function businessSequenceCommand(opts) {
@@ -3,21 +3,21 @@ import {
3
3
  formatAmount,
4
4
  formatDate,
5
5
  formatStatus
6
- } from "./chunk-FFBG6RU4.js";
6
+ } from "./chunk-T63VQXNM.js";
7
7
  import {
8
8
  HisaaboApiError,
9
9
  HisaaboClient
10
- } from "./chunk-FTOBDKMO.js";
10
+ } from "./chunk-4MEL44QX.js";
11
11
  import {
12
12
  requireAuth
13
- } from "./chunk-2P35S2C3.js";
13
+ } from "./chunk-FIMJZAS4.js";
14
14
  import {
15
15
  EXIT,
16
16
  fatalError,
17
17
  outputJSON,
18
18
  outputTable,
19
19
  paginationFooter
20
- } from "./chunk-EYNDY7RB.js";
20
+ } from "./chunk-NO4FIFMS.js";
21
21
 
22
22
  // src/commands/store/index.ts
23
23
  async function storeSettingsCommand(opts) {
@@ -6,21 +6,21 @@ import {
6
6
  formatStatus,
7
7
  fyStart,
8
8
  todayISO
9
- } from "./chunk-FFBG6RU4.js";
9
+ } from "./chunk-T63VQXNM.js";
10
10
  import {
11
11
  HisaaboApiError,
12
12
  HisaaboClient
13
- } from "./chunk-FTOBDKMO.js";
13
+ } from "./chunk-4MEL44QX.js";
14
14
  import {
15
15
  requireAuth
16
- } from "./chunk-2P35S2C3.js";
16
+ } from "./chunk-FIMJZAS4.js";
17
17
  import {
18
18
  EXIT,
19
19
  fatalError,
20
20
  hasColor,
21
21
  outputJSON,
22
22
  termWidth
23
- } from "./chunk-EYNDY7RB.js";
23
+ } from "./chunk-NO4FIFMS.js";
24
24
 
25
25
  // src/commands/dashboard/summary.ts
26
26
  import chalk from "chalk";
@@ -5,14 +5,14 @@ import {
5
5
  monthEnd,
6
6
  monthStart,
7
7
  todayISO
8
- } from "./chunk-FFBG6RU4.js";
8
+ } from "./chunk-T63VQXNM.js";
9
9
  import {
10
10
  HisaaboApiError,
11
11
  HisaaboClient
12
- } from "./chunk-FTOBDKMO.js";
12
+ } from "./chunk-4MEL44QX.js";
13
13
  import {
14
14
  requireAuth
15
- } from "./chunk-2P35S2C3.js";
15
+ } from "./chunk-FIMJZAS4.js";
16
16
  import {
17
17
  EXIT,
18
18
  fatalError,
@@ -21,7 +21,7 @@ import {
21
21
  outputJSON,
22
22
  outputTSV,
23
23
  outputTable
24
- } from "./chunk-EYNDY7RB.js";
24
+ } from "./chunk-NO4FIFMS.js";
25
25
 
26
26
  // src/commands/dashboard/top-customers.ts
27
27
  import chalk from "chalk";
@@ -5,14 +5,14 @@ import {
5
5
  monthEnd,
6
6
  monthStart,
7
7
  todayISO
8
- } from "./chunk-FFBG6RU4.js";
8
+ } from "./chunk-T63VQXNM.js";
9
9
  import {
10
10
  HisaaboApiError,
11
11
  HisaaboClient
12
- } from "./chunk-FTOBDKMO.js";
12
+ } from "./chunk-4MEL44QX.js";
13
13
  import {
14
14
  requireAuth
15
- } from "./chunk-2P35S2C3.js";
15
+ } from "./chunk-FIMJZAS4.js";
16
16
  import {
17
17
  EXIT,
18
18
  fatalError,
@@ -21,7 +21,7 @@ import {
21
21
  outputJSON,
22
22
  outputTSV,
23
23
  outputTable
24
- } from "./chunk-EYNDY7RB.js";
24
+ } from "./chunk-NO4FIFMS.js";
25
25
 
26
26
  // src/commands/dashboard/top-items.ts
27
27
  import chalk from "chalk";
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  formatAmount
4
- } from "./chunk-FFBG6RU4.js";
4
+ } from "./chunk-T63VQXNM.js";
5
5
  import {
6
6
  HisaaboApiError,
7
7
  HisaaboClient
8
- } from "./chunk-FTOBDKMO.js";
8
+ } from "./chunk-4MEL44QX.js";
9
9
  import {
10
10
  requireAuth
11
- } from "./chunk-2P35S2C3.js";
11
+ } from "./chunk-FIMJZAS4.js";
12
12
  import {
13
13
  EXIT,
14
14
  fatalError,
@@ -17,7 +17,7 @@ import {
17
17
  outputJSON,
18
18
  outputTSV,
19
19
  outputTable
20
- } from "./chunk-EYNDY7RB.js";
20
+ } from "./chunk-NO4FIFMS.js";
21
21
 
22
22
  // src/commands/dashboard/top-outstanding.ts
23
23
  import chalk from "chalk";
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  formatAmount,
4
4
  formatDate
5
- } from "./chunk-FFBG6RU4.js";
5
+ } from "./chunk-T63VQXNM.js";
6
6
  import {
7
7
  HisaaboApiError,
8
8
  HisaaboClient
9
- } from "./chunk-FTOBDKMO.js";
9
+ } from "./chunk-4MEL44QX.js";
10
10
  import {
11
11
  requireAuth
12
- } from "./chunk-2P35S2C3.js";
12
+ } from "./chunk-FIMJZAS4.js";
13
13
  import {
14
14
  EXIT,
15
15
  fatalError,
@@ -17,7 +17,7 @@ import {
17
17
  outputJSON,
18
18
  outputTSV,
19
19
  outputTable
20
- } from "./chunk-EYNDY7RB.js";
20
+ } from "./chunk-NO4FIFMS.js";
21
21
 
22
22
  // src/commands/payment/unpaid-invoices.ts
23
23
  async function paymentUnpaidInvoicesCommand(partyId, opts) {
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  formatAmount,
4
4
  formatDate
5
- } from "./chunk-FFBG6RU4.js";
5
+ } from "./chunk-T63VQXNM.js";
6
6
  import {
7
7
  HisaaboApiError,
8
8
  HisaaboClient
9
- } from "./chunk-FTOBDKMO.js";
9
+ } from "./chunk-4MEL44QX.js";
10
10
  import {
11
11
  requireAuth
12
- } from "./chunk-2P35S2C3.js";
12
+ } from "./chunk-FIMJZAS4.js";
13
13
  import {
14
14
  EXIT,
15
15
  fatalError,
@@ -18,7 +18,7 @@ import {
18
18
  outputTSV,
19
19
  outputTable,
20
20
  paginationFooter
21
- } from "./chunk-EYNDY7RB.js";
21
+ } from "./chunk-NO4FIFMS.js";
22
22
 
23
23
  // src/commands/payment/untracked.ts
24
24
  async function paymentUntrackedCommand(opts) {
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  HisaaboApiError,
4
4
  HisaaboClient
5
- } from "./chunk-FTOBDKMO.js";
5
+ } from "./chunk-4MEL44QX.js";
6
6
  import {
7
7
  requireAuth
8
- } from "./chunk-2P35S2C3.js";
8
+ } from "./chunk-FIMJZAS4.js";
9
9
  import {
10
10
  EXIT,
11
11
  fatalError,
12
12
  outputJSON,
13
13
  success
14
- } from "./chunk-EYNDY7RB.js";
14
+ } from "./chunk-NO4FIFMS.js";
15
15
 
16
16
  // src/commands/business/update.ts
17
17
  async function businessUpdateCommand(opts) {
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  formatINR
4
- } from "./chunk-FFBG6RU4.js";
4
+ } from "./chunk-T63VQXNM.js";
5
5
  import {
6
6
  HisaaboApiError,
7
7
  HisaaboClient
8
- } from "./chunk-FTOBDKMO.js";
8
+ } from "./chunk-4MEL44QX.js";
9
9
  import {
10
10
  requireAuth
11
- } from "./chunk-2P35S2C3.js";
11
+ } from "./chunk-FIMJZAS4.js";
12
12
  import {
13
13
  EXIT,
14
14
  fatalError,
15
15
  outputJSON,
16
16
  success
17
- } from "./chunk-EYNDY7RB.js";
17
+ } from "./chunk-NO4FIFMS.js";
18
18
 
19
19
  // src/commands/payment/update.ts
20
20
  async function paymentUpdateCommand(id, opts) {
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  formatINR
4
- } from "./chunk-FFBG6RU4.js";
4
+ } from "./chunk-T63VQXNM.js";
5
5
  import {
6
6
  HisaaboApiError,
7
7
  HisaaboClient
8
- } from "./chunk-FTOBDKMO.js";
8
+ } from "./chunk-4MEL44QX.js";
9
9
  import {
10
10
  requireAuth
11
- } from "./chunk-2P35S2C3.js";
11
+ } from "./chunk-FIMJZAS4.js";
12
12
  import {
13
13
  EXIT,
14
14
  fatalError,
15
15
  outputJSON,
16
16
  success
17
- } from "./chunk-EYNDY7RB.js";
17
+ } from "./chunk-NO4FIFMS.js";
18
18
 
19
19
  // src/commands/expense/update.ts
20
20
  async function expenseUpdateCommand(id, opts) {
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  HisaaboApiError,
4
4
  HisaaboClient
5
- } from "./chunk-FTOBDKMO.js";
5
+ } from "./chunk-4MEL44QX.js";
6
6
  import {
7
7
  requireAuth
8
- } from "./chunk-2P35S2C3.js";
8
+ } from "./chunk-FIMJZAS4.js";
9
9
  import {
10
10
  EXIT,
11
11
  fatalError,
12
12
  outputJSON,
13
13
  success
14
- } from "./chunk-EYNDY7RB.js";
14
+ } from "./chunk-NO4FIFMS.js";
15
15
 
16
16
  // src/commands/tenant/update-role.ts
17
17
  var VALID_ROLES = ["admin", "seller_manager", "seller", "accountant"];
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  HisaaboApiError,
4
4
  HisaaboClient
5
- } from "./chunk-FTOBDKMO.js";
5
+ } from "./chunk-4MEL44QX.js";
6
6
  import {
7
7
  requireAuth
8
- } from "./chunk-2P35S2C3.js";
8
+ } from "./chunk-FIMJZAS4.js";
9
9
  import {
10
10
  EXIT,
11
11
  fatalError,
12
12
  outputJSON,
13
13
  success
14
- } from "./chunk-EYNDY7RB.js";
14
+ } from "./chunk-NO4FIFMS.js";
15
15
 
16
16
  // src/commands/store/update-settings.ts
17
17
  async function storeUpdateSettingsCommand(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hisaabo/cli",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -18,20 +18,16 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@hisaabo/shared": "workspace:*",
21
- "@inkjs/ui": "^2.0.0",
22
21
  "chalk": "^5.4.0",
23
22
  "commander": "^13.0.0",
24
23
  "conf": "^13.0.0",
25
- "ink": "^5.2.0",
26
24
  "open": "^10.1.0",
27
- "react": "^18.3.1",
28
25
  "superjson": "^2.2.0",
29
26
  "zod": "^3.24.0"
30
27
  },
31
28
  "devDependencies": {
32
29
  "@hisaabo/api": "workspace:*",
33
30
  "@types/node": "^22.0.0",
34
- "@types/react": "^18.3.0",
35
31
  "tsup": "^8.3.0",
36
32
  "tsx": "^4.19.0",
37
33
  "typescript": "^5.7.0"
package/src/auth.ts CHANGED
@@ -2,12 +2,20 @@ import { HisaaboClient, HisaaboApiError } from "./client.js";
2
2
  import { getConfig, setConfig, clearConfig, requireAuth, getConfigPath } from "./config.js";
3
3
  import { fatalError, EXIT, outputJSON, success } from "./output.js";
4
4
 
5
+ function validateApiUrl(url: string): string {
6
+ const parsed = new URL(url);
7
+ if (!["http:", "https:"].includes(parsed.protocol)) {
8
+ fatalError("API URL must use http:// or https://", EXIT.USAGE);
9
+ }
10
+ return parsed.origin + parsed.pathname.replace(/\/$/, "");
11
+ }
12
+
5
13
  /**
6
14
  * Authenticate using a long-lived API key (hisaabo_key_...).
7
15
  * Validates the token by calling auth.me, then stores it in config.
8
16
  */
9
17
  export async function loginWithToken(apiUrl: string, token: string): Promise<void> {
10
- const base = apiUrl.replace(/\/$/, "");
18
+ const base = validateApiUrl(apiUrl);
11
19
 
12
20
  // Use a temporary client with the token but no business/tenant yet
13
21
  const client = new HisaaboClient({
@@ -81,6 +89,7 @@ export async function loginWithToken(apiUrl: string, token: string): Promise<voi
81
89
  businessId: selected.id,
82
90
  businessName: selected.name,
83
91
  tenantId: selected.id,
92
+ tokenCreatedAt: Date.now(),
84
93
  });
85
94
 
86
95
  success(`Authenticated as ${user.name ?? user.email} (${user.email}) via API key`);
@@ -93,8 +102,7 @@ type AuthUser = { id: string; email: string; name: string | null; role: string }
93
102
  type BusinessSummary = { id: string; name: string; gstin?: string | null; gstRegistrationType?: string | null };
94
103
 
95
104
  export async function login(apiUrl: string, email: string, password: string): Promise<void> {
96
- // Normalize URL
97
- const base = apiUrl.replace(/\/$/, "");
105
+ const base = validateApiUrl(apiUrl);
98
106
 
99
107
  // Use a temporary client without auth for login
100
108
  const client = new HisaaboClient({
@@ -156,6 +164,7 @@ export async function login(apiUrl: string, email: string, password: string): Pr
156
164
  businessId: selected.id,
157
165
  businessName: selected.name,
158
166
  tenantId: selected.id, // fallback; real tenantId may differ
167
+ tokenCreatedAt: Date.now(),
159
168
  });
160
169
 
161
170
  success(`Active business: ${selected.name}`);
@@ -20,15 +20,19 @@ import { registerBusinessCommands } from "./registrars/business.js";
20
20
  import { registerDocumentCommands } from "./registrars/document.js";
21
21
  import { registerTenantCommands } from "./registrars/tenant.js";
22
22
  import { registerApiKeyCommands } from "./registrars/api-key.js";
23
+ import { registerSessionCommands } from "./registrars/session.js";
23
24
 
24
25
  // ── Program ───────────────────────────────────────────────────────────────
25
26
 
26
27
  const program = new Command();
27
28
 
29
+ declare const __CLI_VERSION__: string | undefined;
30
+ const cliVersion = typeof __CLI_VERSION__ !== "undefined" ? __CLI_VERSION__ : "dev";
31
+
28
32
  program
29
33
  .name("hisaabo")
30
34
  .description("Hisaabo CLI — Invoicing and business management")
31
- .version("0.1.0");
35
+ .version(cliVersion);
32
36
 
33
37
  // ── Register all command groups ───────────────────────────────────────────
34
38
 
@@ -51,6 +55,7 @@ registerBusinessCommands(program);
51
55
  registerDocumentCommands(program);
52
56
  registerTenantCommands(program);
53
57
  registerApiKeyCommands(program);
58
+ registerSessionCommands(program);
54
59
 
55
60
  // ── Run ────────────────────────────────────────────────────────────────────
56
61
 
@@ -5,6 +5,78 @@ import { setConfig, requireAuth } from "../../config.js";
5
5
  import { HisaaboClient, HisaaboApiError } from "../../client.js";
6
6
  import { fatalError, success, EXIT, outputJSON } from "../../output.js";
7
7
 
8
+ // ── Helpers ──────────────────────────────────────────────────────────────────
9
+
10
+ function ask(rl: readline.Interface, q: string): Promise<string> {
11
+ return new Promise<string>((res) => rl.question(q, res));
12
+ }
13
+
14
+ /**
15
+ * Prompt for a secret value (password, API token) with input hidden.
16
+ * Characters are replaced with '*' as the user types.
17
+ */
18
+ function askSecret(prompt: string): Promise<string> {
19
+ return new Promise((resolve) => {
20
+ const rl = readline.createInterface({ input: process.stdin, terminal: true });
21
+ process.stdout.write(prompt);
22
+
23
+ const chars: string[] = [];
24
+
25
+ const cleanup = () => {
26
+ process.stdin.removeListener("data", onData);
27
+ process.stdin.setRawMode?.(false);
28
+ process.stdin.pause();
29
+ };
30
+
31
+ // Restore terminal on unexpected signals
32
+ const onSignal = () => { cleanup(); process.exit(130); };
33
+ process.once("SIGTERM", onSignal);
34
+ process.once("SIGHUP", onSignal);
35
+
36
+ const onData = (key: Buffer) => {
37
+ const ch = key.toString();
38
+ if (ch === "\n" || ch === "\r") {
39
+ process.removeListener("SIGTERM", onSignal);
40
+ process.removeListener("SIGHUP", onSignal);
41
+ cleanup();
42
+ process.stdout.write("\n");
43
+ rl.close();
44
+ const result = chars.join("");
45
+ chars.length = 0; // clear password from array
46
+ resolve(result);
47
+ } else if (ch === "\x7f" || ch === "\b") {
48
+ // Backspace
49
+ if (chars.length > 0) {
50
+ chars.pop();
51
+ process.stdout.write("\b \b");
52
+ }
53
+ } else if (ch === "\x03") {
54
+ // Ctrl+C
55
+ cleanup();
56
+ process.stdout.write("\n");
57
+ process.exit(130);
58
+ } else if (ch.charCodeAt(0) >= 32) {
59
+ chars.push(ch);
60
+ process.stdout.write("*");
61
+ }
62
+ };
63
+
64
+ if (process.stdin.isTTY) {
65
+ process.stdin.setRawMode?.(true);
66
+ process.stdin.resume();
67
+ process.stdin.on("data", onData);
68
+ } else {
69
+ // Non-interactive: read line normally (piped input)
70
+ rl.question("", (answer) => {
71
+ rl.close();
72
+ resolve(answer.trim());
73
+ });
74
+ }
75
+ });
76
+ }
77
+
78
+ // ── Commands ─────────────────────────────────────────────────────────────────
79
+
8
80
  export function registerAuthCommands(program: Command): void {
9
81
  // ── login ─────────────────────────────────────────────────────────────────
10
82
 
@@ -13,8 +85,8 @@ export function registerAuthCommands(program: Command): void {
13
85
  .description("Authenticate and configure your Hisaabo server")
14
86
  .option("--api-url <url>", "Server URL")
15
87
  .option("--email <email>", "Email address")
16
- .option("--password <password>", "Password")
17
- .option("--token <token>", "API key (hisaabo_key_...) for passwordless auth")
88
+ .option("--password <password>", "Password (visible in shell history — prefer interactive prompt)")
89
+ .option("--token <token>", "API key (visible in shell history — prefer HISAABO_TOKEN env var)")
18
90
  .action(async (opts) => {
19
91
  let apiUrl = opts.apiUrl;
20
92
 
@@ -22,9 +94,8 @@ export function registerAuthCommands(program: Command): void {
22
94
  if (opts.token) {
23
95
  if (!apiUrl) {
24
96
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
25
- const ask = (q: string) => new Promise<string>((res) => rl.question(q, res));
26
97
  console.log("\n Hisaabo CLI\n " + "─".repeat(11) + "\n");
27
- const u = await ask(" Server URL [http://localhost:3000]: ");
98
+ const u = await ask(rl, " Server URL [http://localhost:3000]: ");
28
99
  rl.close();
29
100
  apiUrl = u.trim() || "http://localhost:3000";
30
101
  }
@@ -38,18 +109,16 @@ export function registerAuthCommands(program: Command): void {
38
109
 
39
110
  if (!apiUrl || !email || !password) {
40
111
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
41
- const ask = (q: string) => new Promise<string>((res) => rl.question(q, res));
42
112
  console.log("\n Hisaabo CLI\n " + "─".repeat(11) + "\n");
43
113
  if (!apiUrl) {
44
- const u = await ask(" Server URL [http://localhost:3000]: ");
114
+ const u = await ask(rl, " Server URL [http://localhost:3000]: ");
45
115
  apiUrl = u.trim() || "http://localhost:3000";
46
116
  }
47
- if (!email) email = (await ask(" Email: ")).trim();
117
+ if (!email) email = (await ask(rl, " Email: ")).trim();
118
+ rl.close();
48
119
  if (!password) {
49
- // Hide password input if possible
50
- password = (await ask(" Password: ")).trim();
120
+ password = await askSecret(" Password: ");
51
121
  }
52
- rl.close();
53
122
  console.log("\n Tip: Generate an API key at Settings → API Keys for passwordless CLI access.\n");
54
123
  }
55
124
 
@@ -2,6 +2,8 @@ import { Command } from "commander";
2
2
  import {
3
3
  bankListCommand, bankGetCommand, bankCreateCommand, bankTransferCommand, bankTransactionsCommand,
4
4
  } from "../../commands/bank/index.js";
5
+ import { bankGatewayConfigCommand } from "../../commands/bank/gateway-config.js";
6
+ import { bankUpdateGatewayCommand } from "../../commands/bank/update-gateway.js";
5
7
 
6
8
  export function registerBankCommands(program: Command): void {
7
9
  // ── bank ─────────────────────────────────────────────────────────────────
@@ -87,4 +89,36 @@ export function registerBankCommands(program: Command): void {
87
89
  limit: opts.limit,
88
90
  });
89
91
  });
92
+
93
+ bank
94
+ .command("gateway-config <accountId>")
95
+ .description("Display gateway configuration (charge rates, settlement account)")
96
+ .option("--json", "JSON output")
97
+ .action(async (accountId, opts) => {
98
+ await bankGatewayConfigCommand(accountId, { json: opts.json });
99
+ });
100
+
101
+ bank
102
+ .command("update-gateway <accountId>")
103
+ .description("Update gateway charge configuration")
104
+ .option("--json", "JSON output")
105
+ .option("--charge-credit-card <rate>", "Credit card charge rate (e.g. 2 for 2%, flat:20 for flat)")
106
+ .option("--charge-debit-card <rate>", "Debit card charge rate")
107
+ .option("--charge-upi <rate>", "UPI charge rate")
108
+ .option("--charge-net-banking <rate>", "Net banking charge rate")
109
+ .option("--charge-wallet <rate>", "Wallet charge rate")
110
+ .option("--charge-default <rate>", "Default charge rate for unlisted modes")
111
+ .option("--settlement-account <id>", "Settlement bank account ID")
112
+ .action(async (accountId, opts) => {
113
+ await bankUpdateGatewayCommand(accountId, {
114
+ json: opts.json,
115
+ chargeCreditCard: opts.chargeCreditCard,
116
+ chargeDebitCard: opts.chargeDebitCard,
117
+ chargeUpi: opts.chargeUpi,
118
+ chargeNetBanking: opts.chargeNetBanking,
119
+ chargeWallet: opts.chargeWallet,
120
+ chargeDefault: opts.chargeDefault,
121
+ settlementAccount: opts.settlementAccount,
122
+ });
123
+ });
90
124
  }