@hisaabo/cli 0.1.0 → 0.3.2

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 (146) hide show
  1. package/README.md +332 -0
  2. package/dist/bin/audit-trail-2YGXGUXW.js +78 -0
  3. package/dist/bin/categories-P5VFWD5F.js +47 -0
  4. package/dist/bin/check-slug-4TMOTWUJ.js +65 -0
  5. package/dist/bin/chunk-2P35S2C3.js +46 -0
  6. package/dist/bin/chunk-EYNDY7RB.js +175 -0
  7. package/dist/bin/chunk-FFBG6RU4.js +156 -0
  8. package/dist/bin/chunk-FTOBDKMO.js +804 -0
  9. package/dist/bin/client-QNJ2H5CW.js +11 -0
  10. package/dist/bin/collection-efficiency-WMKEGS6U.js +165 -0
  11. package/dist/bin/config-UKVQYPPR.js +18 -0
  12. package/dist/bin/create-Y22FAVOW.js +83 -0
  13. package/dist/bin/default-account-SA56M66A.js +58 -0
  14. package/dist/bin/expenses-VZAOLYUW.js +89 -0
  15. package/dist/bin/export-QZ6WT6PJ.js +59 -0
  16. package/dist/bin/factory-2DCU3B5T.js +483 -0
  17. package/dist/bin/get-6UYP6UVD.js +71 -0
  18. package/dist/bin/get-EXL44I2X.js +66 -0
  19. package/dist/bin/hisaabo.js +2029 -1450
  20. package/dist/bin/invite-O26SAL72.js +53 -0
  21. package/dist/bin/invoice-breakdown-XEATXVMR.js +97 -0
  22. package/dist/bin/items-3U5USBVG.js +62 -0
  23. package/dist/bin/items-toggle-YEKMI2CM.js +46 -0
  24. package/dist/bin/list-FX2C3NCL.js +46 -0
  25. package/dist/bin/list-VBAHY72W.js +79 -0
  26. package/dist/bin/members-5FPRUAB6.js +55 -0
  27. package/dist/bin/monthly-comparison-JEJ3TTY2.js +176 -0
  28. package/dist/bin/order-cancel-XI2LKYXV.js +55 -0
  29. package/dist/bin/order-confirm-HUFCU6MO.js +53 -0
  30. package/dist/bin/order-get-NSDMPUZR.js +88 -0
  31. package/dist/bin/order-update-C7QYSD5R.js +60 -0
  32. package/dist/bin/output-QFLEKG5W.js +35 -0
  33. package/dist/bin/payment-modes-WI3AWSES.js +126 -0
  34. package/dist/bin/profit-loss-5RIEOBKP.js +135 -0
  35. package/dist/bin/receivables-aging-L6DIQCNE.js +161 -0
  36. package/dist/bin/remove-M2B4TZ37.js +52 -0
  37. package/dist/bin/revoke-H3V2GNCD.js +52 -0
  38. package/dist/bin/sales-trend-TICB3KGF.js +71 -0
  39. package/dist/bin/sequence-XUD6FAKY.js +66 -0
  40. package/dist/bin/store-UQ2DDQ5I.js +82 -0
  41. package/dist/bin/summary-BPNFC7I2.js +113 -0
  42. package/dist/bin/top-customers-WGGJWKCN.js +81 -0
  43. package/dist/bin/top-items-C7ZDDJMR.js +84 -0
  44. package/dist/bin/top-outstanding-MOGWJIQS.js +64 -0
  45. package/dist/bin/unpaid-invoices-ZUPNMQJP.js +65 -0
  46. package/dist/bin/untracked-BCJEVDW4.js +67 -0
  47. package/dist/bin/update-HIU4PANX.js +54 -0
  48. package/dist/bin/update-IG565YIN.js +61 -0
  49. package/dist/bin/update-PVLAX7T3.js +57 -0
  50. package/dist/bin/update-role-Q4ZYJRYT.js +45 -0
  51. package/dist/bin/update-settings-XPC6L5WM.js +56 -0
  52. package/package.json +6 -1
  53. package/src/bin/hisaabo.ts +42 -933
  54. package/src/bin/registrars/api-key.ts +44 -0
  55. package/src/bin/registrars/auth.ts +153 -0
  56. package/src/bin/registrars/automated-invoice.ts +167 -0
  57. package/src/bin/registrars/bank.ts +90 -0
  58. package/src/bin/registrars/business.ts +120 -0
  59. package/src/bin/registrars/dashboard.ts +225 -0
  60. package/src/bin/registrars/document.ts +184 -0
  61. package/src/bin/registrars/expense.ts +87 -0
  62. package/src/bin/registrars/gst.ts +41 -0
  63. package/src/bin/registrars/import.ts +49 -0
  64. package/src/bin/registrars/invoice.ts +117 -0
  65. package/src/bin/registrars/item.ts +112 -0
  66. package/src/bin/registrars/party.ts +81 -0
  67. package/src/bin/registrars/payment.ts +128 -0
  68. package/src/bin/registrars/report.ts +142 -0
  69. package/src/bin/registrars/shipment.ts +74 -0
  70. package/src/bin/registrars/store.ts +128 -0
  71. package/src/bin/registrars/target.ts +46 -0
  72. package/src/bin/registrars/tenant.ts +55 -0
  73. package/src/client.ts +495 -4
  74. package/src/commands/api-key/create.ts +72 -0
  75. package/src/commands/api-key/list.ts +71 -0
  76. package/src/commands/api-key/revoke.ts +46 -0
  77. package/src/commands/automated-invoice/create.ts +85 -0
  78. package/src/commands/automated-invoice/delete.ts +42 -0
  79. package/src/commands/automated-invoice/get.ts +113 -0
  80. package/src/commands/automated-invoice/history.ts +65 -0
  81. package/src/commands/automated-invoice/index.ts +11 -0
  82. package/src/commands/automated-invoice/list.ts +91 -0
  83. package/src/commands/automated-invoice/pause.ts +29 -0
  84. package/src/commands/automated-invoice/resume.ts +29 -0
  85. package/src/commands/automated-invoice/run-now.ts +29 -0
  86. package/src/commands/automated-invoice/suggestions.ts +68 -0
  87. package/src/commands/automated-invoice/update.ts +54 -0
  88. package/src/commands/automated-invoice/usage.ts +68 -0
  89. package/src/commands/business/audit-trail.ts +79 -0
  90. package/src/commands/business/export.ts +52 -0
  91. package/src/commands/business/get.ts +55 -0
  92. package/src/commands/business/sequence.ts +65 -0
  93. package/src/commands/business/update.ts +64 -0
  94. package/src/commands/dashboard/collection-efficiency.ts +164 -0
  95. package/src/commands/dashboard/expenses.ts +76 -0
  96. package/src/commands/dashboard/invoice-breakdown.ts +89 -0
  97. package/src/commands/dashboard/monthly-comparison.ts +193 -0
  98. package/src/commands/dashboard/payment-modes.ts +121 -0
  99. package/src/commands/dashboard/profit-loss.ts +146 -0
  100. package/src/commands/dashboard/receivables-aging.ts +169 -0
  101. package/src/commands/dashboard/sales-trend.ts +68 -0
  102. package/src/commands/dashboard/summary.ts +105 -0
  103. package/src/commands/dashboard/top-customers.ts +70 -0
  104. package/src/commands/dashboard/top-items.ts +74 -0
  105. package/src/commands/dashboard/top-outstanding.ts +61 -0
  106. package/src/commands/document/factory.ts +590 -0
  107. package/src/commands/expense/categories.ts +40 -0
  108. package/src/commands/expense/update.ts +58 -0
  109. package/src/commands/import/index.ts +68 -0
  110. package/src/commands/item/categories.ts +40 -0
  111. package/src/commands/item/low-stock-count.ts +32 -0
  112. package/src/commands/item/merge.ts +53 -0
  113. package/src/commands/item/price-history.ts +59 -0
  114. package/src/commands/item/rename-unit.ts +39 -0
  115. package/src/commands/item/sales-stats.ts +44 -0
  116. package/src/commands/item/stock-history.ts +70 -0
  117. package/src/commands/item/switch-base-unit.ts +42 -0
  118. package/src/commands/item/update.ts +59 -0
  119. package/src/commands/item/variants-create.ts +58 -0
  120. package/src/commands/item/variants-delete.ts +47 -0
  121. package/src/commands/item/variants-list.ts +63 -0
  122. package/src/commands/item/variants-update.ts +61 -0
  123. package/src/commands/party/ledger-report.ts +81 -0
  124. package/src/commands/party/merge.ts +50 -0
  125. package/src/commands/party/stats.ts +40 -0
  126. package/src/commands/party/top-items.ts +57 -0
  127. package/src/commands/party/update.ts +65 -0
  128. package/src/commands/payment/default-account.ts +56 -0
  129. package/src/commands/payment/get.ts +59 -0
  130. package/src/commands/payment/unpaid-invoices.ts +69 -0
  131. package/src/commands/payment/untracked.ts +70 -0
  132. package/src/commands/payment/update.ts +54 -0
  133. package/src/commands/report/index.ts +348 -1
  134. package/src/commands/store/check-slug.ts +48 -0
  135. package/src/commands/store/items-toggle.ts +41 -0
  136. package/src/commands/store/items.ts +61 -0
  137. package/src/commands/store/order-cancel.ts +48 -0
  138. package/src/commands/store/order-confirm.ts +45 -0
  139. package/src/commands/store/order-get.ts +66 -0
  140. package/src/commands/store/order-update.ts +52 -0
  141. package/src/commands/store/update-settings.ts +52 -0
  142. package/src/commands/tenant/invite.ts +57 -0
  143. package/src/commands/tenant/list.ts +46 -0
  144. package/src/commands/tenant/members.ts +55 -0
  145. package/src/commands/tenant/remove.ts +47 -0
  146. package/src/commands/tenant/update-role.ts +41 -0
package/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # @hisaabo/cli
2
+
3
+ Terminal-first invoicing and business management for Indian businesses. Manage invoices, parties, items, payments, expenses, GST reports, and more -- all from the command line.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@hisaabo/cli?logo=npm&logoColor=white&label=@hisaabo/cli)](https://www.npmjs.com/package/@hisaabo/cli)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-20+-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/)
7
+ [![License: O'Saasy](https://img.shields.io/badge/license-O'Saasy-blue)](https://github.com/hisaabo/hisaabo/blob/main/LICENSE)
8
+
9
+ **What this does:** Run `hisaabo invoice list --this-month` and get a formatted table of every invoice your business issued this month. Run `hisaabo gst r3b --quarter Q4` and get your GSTR-3B numbers ready for filing. Pipe any command to `jq` or a spreadsheet with `--json`, `--format csv`, or `--format tsv`.
10
+
11
+ ---
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ npm install -g @hisaabo/cli
17
+ ```
18
+
19
+ **Log in interactively:**
20
+
21
+ ```bash
22
+ hisaabo login --api-url https://your-hisaabo-instance.com
23
+ ```
24
+
25
+ You'll be prompted for email and password, then asked to pick a business if you have more than one.
26
+
27
+ **Log in with an API key (for scripts and CI):**
28
+
29
+ ```bash
30
+ hisaabo login --api-url https://your-hisaabo-instance.com --token hisaabo_key_abc123...
31
+ ```
32
+
33
+ Generate API keys at Settings > API Keys in the Hisaabo web app.
34
+
35
+ **Verify your session:**
36
+
37
+ ```bash
38
+ hisaabo whoami
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Command Reference
44
+
45
+ ### Auth and Session
46
+
47
+ | Command | Description |
48
+ |---|---|
49
+ | `hisaabo login` | Authenticate with email/password or API key |
50
+ | `hisaabo logout` | Clear saved credentials |
51
+ | `hisaabo whoami` | Show current user and active business |
52
+ | `hisaabo switch` | Switch active business |
53
+
54
+ ### Business
55
+
56
+ | Command | Description |
57
+ |---|---|
58
+ | `hisaabo business list` | List all businesses under your account |
59
+ | `hisaabo business switch` | Switch active business |
60
+
61
+ ### Dashboard
62
+
63
+ | Command | Description |
64
+ |---|---|
65
+ | `hisaabo dashboard` | Financial summary with box-drawing UI (alias: `dash`) |
66
+
67
+ ### Invoices
68
+
69
+ | Command | Description |
70
+ |---|---|
71
+ | `invoice list` | List invoices (filterable by status, party, date range, type) |
72
+ | `invoice get <id>` | Get full invoice details with line items |
73
+ | `invoice create` | Create a new invoice (interactive or with flags) |
74
+ | `invoice status <id> <status>` | Update status (draft, sent, paid, cancelled) |
75
+ | `invoice pdf <id>` | Download invoice as PDF |
76
+ | `invoice delete <id>` | Delete an invoice |
77
+
78
+ ### Parties (Customers and Suppliers)
79
+
80
+ | Command | Description |
81
+ |---|---|
82
+ | `party list` | List parties (filterable by type, category, search) |
83
+ | `party get <id>` | Get party profile with balance |
84
+ | `party create` | Add a new customer or supplier |
85
+ | `party ledger <id>` | Debit/credit history for a party |
86
+ | `party delete <id>` | Delete a party |
87
+
88
+ ### Items
89
+
90
+ | Command | Description |
91
+ |---|---|
92
+ | `item list` | List items (filter by category, type, low stock) |
93
+ | `item get <id>` | Get item details with stock and pricing |
94
+ | `item create` | Add a new product or service |
95
+ | `item stock <id> <adjustment>` | Adjust stock (+10, -5, or set to 100) |
96
+ | `item delete <id>` | Delete an item |
97
+
98
+ ### Payments
99
+
100
+ | Command | Description |
101
+ |---|---|
102
+ | `payment list` | List payments (filterable by party, date range) |
103
+ | `payment create` | Record a payment (cash, bank, UPI, cheque) |
104
+ | `payment delete <id>` | Delete a payment |
105
+
106
+ ### Expenses
107
+
108
+ | Command | Description |
109
+ |---|---|
110
+ | `expense list` | List expenses (filterable by category, date range) |
111
+ | `expense create` | Record a business expense |
112
+ | `expense delete <id>` | Delete an expense |
113
+
114
+ ### Bank Accounts
115
+
116
+ | Command | Description |
117
+ |---|---|
118
+ | `bank list` | List accounts with balances |
119
+ | `bank get <id>` | Get account details |
120
+ | `bank create` | Add a new bank account |
121
+ | `bank transfer` | Transfer between accounts |
122
+ | `bank transactions <id>` | List transactions for an account |
123
+
124
+ ### GST
125
+
126
+ | Command | Description |
127
+ |---|---|
128
+ | `gst r1` | GSTR-1 report (by quarter or month) |
129
+ | `gst r3b` | GSTR-3B report (by quarter or month) |
130
+ | `gst r1-csv` | Download GSTR-1 as GSTN-compatible CSV for filing |
131
+
132
+ ### Reports
133
+
134
+ | Command | Description |
135
+ |---|---|
136
+ | `report daybook` | Day book -- all transactions for a period |
137
+ | `report outstanding` | Outstanding receivables and payables |
138
+ | `report tax-summary` | Tax collected and paid, grouped by rate |
139
+ | `report item-sales` | Item-wise sales breakdown |
140
+ | `report stock` | Current stock summary |
141
+
142
+ ### Shipments
143
+
144
+ | Command | Description |
145
+ |---|---|
146
+ | `shipment list` | List shipments (filterable by status, invoice) |
147
+ | `shipment get <id>` | Get shipment details |
148
+ | `shipment create` | Create a shipment linked to an invoice |
149
+ | `shipment update <id>` | Update status or tracking info |
150
+
151
+ ### Targets
152
+
153
+ | Command | Description |
154
+ |---|---|
155
+ | `target list` | List sales targets |
156
+ | `target my` | Show your target progress |
157
+ | `target create` | Set a new sales target (daily, weekly, monthly, quarterly) |
158
+
159
+ ### Recurring Invoices
160
+
161
+ | Command | Description |
162
+ |---|---|
163
+ | `automated-invoice list` | List recurring invoice templates |
164
+ | `automated-invoice get <id>` | Get template details |
165
+ | `automated-invoice create` | Create a new recurring template |
166
+ | `automated-invoice pause <id>` | Pause an active template |
167
+ | `automated-invoice resume <id>` | Resume a paused template |
168
+ | `automated-invoice run-now <id>` | Manually trigger invoice generation |
169
+ | `automated-invoice delete <id>` | Delete a template |
170
+
171
+ ### Store
172
+
173
+ | Command | Description |
174
+ |---|---|
175
+ | `store settings` | Show online store settings |
176
+ | `store orders` | List store orders |
177
+
178
+ ### Import
179
+
180
+ | Command | Description |
181
+ |---|---|
182
+ | `import parties <file>` | Bulk import parties from JSON or CSV |
183
+ | `import items <file>` | Bulk import items from JSON or CSV |
184
+
185
+ ---
186
+
187
+ ## Terminal Examples
188
+
189
+ **List this month's sale invoices:**
190
+
191
+ ```
192
+ $ hisaabo invoice list --type sale --this-month
193
+
194
+ ──────────────────────────────────────────────────────────────────────
195
+ # Party Amount Status Date
196
+ ──────────────────────────────────────────────────────────────────────
197
+ BB-15042 Sharma Fabrics 9,450.00 [PAID] Today
198
+ BB-15041 Gupta Enterprises 1,24,800.00 [SENT] Yesterday
199
+ BB-15040 Mehta Traders 47,200.00 [DRAFT] 3d ago
200
+ BB-15039 Vinod & Sons 18,000.00 [OVERDUE] 12d ago
201
+ ──────────────────────────────────────────────────────────────────────
202
+
203
+ Showing 1-4 of 4
204
+ ```
205
+
206
+ **Check a party's outstanding balance:**
207
+
208
+ ```
209
+ $ hisaabo party get f3a1...
210
+
211
+ Gupta Enterprises (customer)
212
+ ────────────────────────────────────────
213
+ Phone: +91 98765 43210
214
+ GSTIN: 27AABCG1234A1Z5
215
+ City: Mumbai
216
+ Balance: 1,24,800.00 receivable
217
+ Invoices: 14 (3 unpaid)
218
+ ```
219
+
220
+ **Pull GSTR-3B numbers for Q4 and pipe to a file:**
221
+
222
+ ```
223
+ $ hisaabo gst r3b --quarter Q4 --json | jq '.taxPayable'
224
+ {
225
+ "igst": "0.00",
226
+ "cgst": "18420.00",
227
+ "sgst": "18420.00",
228
+ "cess": "0.00"
229
+ }
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Output Formats and Scripting
235
+
236
+ Every `list` command supports multiple output formats:
237
+
238
+ | Flag | Format | Use case |
239
+ |---|---|---|
240
+ | *(default)* | Colored table | Human reading in a terminal |
241
+ | `--json` | Pretty-printed JSON | Piping to `jq`, scripts, CI |
242
+ | `--format tsv` | Tab-separated values | Pasting into spreadsheets |
243
+ | `--format csv` | Comma-separated values | Import into Excel, Google Sheets |
244
+ | `--format ids` | One ID per line | Piping into `xargs` |
245
+
246
+ **Pipe invoice IDs into a loop:**
247
+
248
+ ```bash
249
+ hisaabo invoice list --status draft --format ids | xargs -I{} hisaabo invoice status {} sent
250
+ ```
251
+
252
+ **Export all parties to CSV:**
253
+
254
+ ```bash
255
+ hisaabo party list --format csv > parties.csv
256
+ ```
257
+
258
+ **Environment variables:**
259
+
260
+ - `NO_COLOR=1` -- disable colored output (also respects `FORCE_COLOR=0`)
261
+ - Terminal width is detected automatically. Tables adapt to narrow (<80), standard (80-120), and wide (>120) terminals.
262
+
263
+ ---
264
+
265
+ ## Common Flags
266
+
267
+ Most commands accept these flags:
268
+
269
+ | Flag | Description |
270
+ |---|---|
271
+ | `--json` | Output as JSON instead of a table |
272
+ | `--format <fmt>` | Output format: `table`, `tsv`, `csv`, `ids` |
273
+ | `--page <n>` | Page number for paginated results |
274
+ | `--limit <n>` | Items per page |
275
+ | `--from <date>` | Start date filter (YYYY-MM-DD) |
276
+ | `--to <date>` | End date filter (YYYY-MM-DD) |
277
+ | `--this-month` | Filter to current calendar month |
278
+ | `--this-fy` | Filter to current financial year (April-March) |
279
+ | `-y, --yes` | Skip confirmation prompts |
280
+
281
+ ---
282
+
283
+ ## Multi-Business Support
284
+
285
+ If you manage multiple businesses under one account, list and switch between them from the CLI:
286
+
287
+ ```bash
288
+ # List all businesses on your account
289
+ hisaabo business list
290
+
291
+ # Switch the active business (interactive picker)
292
+ hisaabo switch
293
+
294
+ # Or switch via the business subcommand
295
+ hisaabo business switch
296
+ ```
297
+
298
+ All subsequent commands operate on the active business. The `dashboard`, `invoice`, `party`, and every other command scopes data to whichever business is currently selected. Switching resets all cached data so you always see numbers for the correct business.
299
+
300
+ **Web and mobile UI:** Business switching is also available without the CLI. In the web app, tap the business name in the sidebar to open a popover listing all your businesses plus a "Create New Business" option. On mobile, tap the business name on the home dashboard to open a bottom sheet with the same options.
301
+
302
+ ---
303
+
304
+ ## Development
305
+
306
+ ```bash
307
+ # From the monorepo root
308
+ pnpm install
309
+
310
+ # Run the CLI in dev mode (no build step needed)
311
+ pnpm --filter @hisaabo/cli dev -- invoice list
312
+
313
+ # Build
314
+ pnpm --filter @hisaabo/cli build
315
+
316
+ # Type-check
317
+ pnpm --filter @hisaabo/cli typecheck
318
+ ```
319
+
320
+ For local development, point at your local API:
321
+
322
+ ```bash
323
+ hisaabo login --api-url http://localhost:3000
324
+ ```
325
+
326
+ The CLI stores credentials in the OS config directory (`~/.config/hisaabo-cli` on Linux, `~/Library/Preferences/hisaabo-cli` on macOS).
327
+
328
+ ---
329
+
330
+ ## Full Documentation
331
+
332
+ [docs.hisaabo.in/cli](https://docs.hisaabo.in/cli) -- Setup guide, full command reference with all flags, scripting recipes, and CI/CD integration examples.
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatDate
4
+ } from "./chunk-FFBG6RU4.js";
5
+ import {
6
+ HisaaboApiError,
7
+ HisaaboClient
8
+ } from "./chunk-FTOBDKMO.js";
9
+ import {
10
+ requireAuth
11
+ } from "./chunk-2P35S2C3.js";
12
+ import {
13
+ EXIT,
14
+ fatalError,
15
+ hasColor,
16
+ outputCSV,
17
+ outputJSON,
18
+ outputTSV,
19
+ outputTable,
20
+ paginationFooter
21
+ } from "./chunk-EYNDY7RB.js";
22
+
23
+ // src/commands/business/audit-trail.ts
24
+ import chalk from "chalk";
25
+ async function businessAuditTrailCommand(opts) {
26
+ const cfg = requireAuth();
27
+ const client = new HisaaboClient(cfg);
28
+ const page = opts.page ? parseInt(opts.page, 10) : 1;
29
+ const limit = opts.limit ? parseInt(opts.limit, 10) : 25;
30
+ if (isNaN(page) || page < 1) fatalError("--page must be a positive integer.", EXIT.USAGE);
31
+ if (isNaN(limit) || limit < 1 || limit > 100) fatalError("--limit must be between 1 and 100.", EXIT.USAGE);
32
+ try {
33
+ const data = await client.business.auditTrail({ page, limit });
34
+ if (opts.json) {
35
+ outputJSON(data);
36
+ return;
37
+ }
38
+ const items = Array.isArray(data) ? data : Array.isArray(data?.items) ? data.items : Array.isArray(data?.data) ? data.data : [];
39
+ const total = typeof data?.total === "number" ? data.total : items.length;
40
+ const rows = items.map((item) => {
41
+ const r = item;
42
+ return {
43
+ timestamp: formatDate(String(r["createdAt"] ?? r["timestamp"] ?? "")),
44
+ user: String(r["userName"] ?? r["user"] ?? r["userEmail"] ?? "-"),
45
+ action: String(r["action"] ?? r["event"] ?? "-"),
46
+ details: String(r["details"] ?? r["description"] ?? r["meta"] ?? "-")
47
+ };
48
+ });
49
+ const columns = [
50
+ { key: "timestamp", header: "Date", align: "left" },
51
+ { key: "user", header: "User", align: "left", width: 28 },
52
+ { key: "action", header: "Action", align: "left", width: 24 },
53
+ { key: "details", header: "Details", align: "left", width: 40 }
54
+ ];
55
+ if (opts.format === "tsv") {
56
+ outputTSV(rows, columns);
57
+ } else if (opts.format === "csv") {
58
+ outputCSV(rows, columns);
59
+ } else {
60
+ if (hasColor()) process.stdout.write("\n" + chalk.bold(" Audit Trail\n") + "\n");
61
+ else process.stdout.write("\n Audit Trail\n\n");
62
+ outputTable(rows, columns);
63
+ if (total > limit) paginationFooter(page, limit, total);
64
+ process.stdout.write("\n");
65
+ }
66
+ } catch (e) {
67
+ if (e instanceof HisaaboApiError) {
68
+ const err = e.hisaaboError;
69
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
70
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
71
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
72
+ }
73
+ fatalError(String(e instanceof Error ? e.message : e));
74
+ }
75
+ }
76
+ export {
77
+ businessAuditTrailCommand
78
+ };
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ HisaaboApiError,
4
+ HisaaboClient
5
+ } from "./chunk-FTOBDKMO.js";
6
+ import {
7
+ requireAuth
8
+ } from "./chunk-2P35S2C3.js";
9
+ import {
10
+ EXIT,
11
+ fatalError,
12
+ outputJSON
13
+ } from "./chunk-EYNDY7RB.js";
14
+
15
+ // src/commands/expense/categories.ts
16
+ async function expenseCategoriesCommand(opts) {
17
+ const cfg = requireAuth();
18
+ const client = new HisaaboClient(cfg);
19
+ try {
20
+ const categories = await client.expense.categories();
21
+ if (opts.json) {
22
+ outputJSON(categories);
23
+ return;
24
+ }
25
+ if (!categories || categories.length === 0) {
26
+ console.log("\n No expense categories found.\n");
27
+ return;
28
+ }
29
+ console.log(`
30
+ Expense Categories (${categories.length})
31
+ `);
32
+ for (const cat of categories) {
33
+ console.log(` ${cat}`);
34
+ }
35
+ console.log();
36
+ } catch (e) {
37
+ if (e instanceof HisaaboApiError) {
38
+ const err = e.hisaaboError;
39
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
40
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
41
+ }
42
+ fatalError(String(e instanceof Error ? e.message : e));
43
+ }
44
+ }
45
+ export {
46
+ expenseCategoriesCommand
47
+ };
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ HisaaboApiError,
4
+ HisaaboClient
5
+ } from "./chunk-FTOBDKMO.js";
6
+ import {
7
+ requireAuth
8
+ } from "./chunk-2P35S2C3.js";
9
+ import {
10
+ EXIT,
11
+ fatalError,
12
+ hasColor,
13
+ outputJSON
14
+ } from "./chunk-EYNDY7RB.js";
15
+
16
+ // src/commands/store/check-slug.ts
17
+ import chalk from "chalk";
18
+ async function storeCheckSlugCommand(slug, opts) {
19
+ const cfg = requireAuth();
20
+ const client = new HisaaboClient(cfg);
21
+ try {
22
+ const result = await client.store.checkSlug({ slug });
23
+ if (opts.json) {
24
+ outputJSON(result);
25
+ return;
26
+ }
27
+ const available = typeof result === "object" && result !== null ? result["available"] : result;
28
+ if (available) {
29
+ if (hasColor()) {
30
+ process.stdout.write(chalk.green(`
31
+ \u2713 "${slug}" is available
32
+
33
+ `));
34
+ } else {
35
+ process.stdout.write(`
36
+ OK: "${slug}" is available
37
+
38
+ `);
39
+ }
40
+ } else {
41
+ if (hasColor()) {
42
+ process.stdout.write(chalk.red(`
43
+ \u2717 "${slug}" is already taken
44
+
45
+ `));
46
+ } else {
47
+ process.stdout.write(`
48
+ TAKEN: "${slug}" is already taken
49
+
50
+ `);
51
+ }
52
+ }
53
+ } catch (e) {
54
+ if (e instanceof HisaaboApiError) {
55
+ const err = e.hisaaboError;
56
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
57
+ if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
58
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
59
+ }
60
+ fatalError(String(e instanceof Error ? e.message : e));
61
+ }
62
+ }
63
+ export {
64
+ storeCheckSlugCommand
65
+ };
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fatalError
4
+ } from "./chunk-EYNDY7RB.js";
5
+
6
+ // src/config.ts
7
+ import Conf from "conf";
8
+ var conf = new Conf({
9
+ projectName: "hisaabo",
10
+ projectSuffix: "",
11
+ configName: "config"
12
+ });
13
+ function getConfig() {
14
+ return conf.store;
15
+ }
16
+ function setConfig(values) {
17
+ for (const [k, v] of Object.entries(values)) {
18
+ conf.set(k, v);
19
+ }
20
+ }
21
+ function clearConfig() {
22
+ conf.clear();
23
+ }
24
+ function isAuthenticated() {
25
+ const cfg = getConfig();
26
+ return !!(cfg.token && cfg.apiUrl && cfg.businessId);
27
+ }
28
+ function requireAuth() {
29
+ const cfg = getConfig();
30
+ if (!cfg.token || !cfg.apiUrl || !cfg.businessId || !cfg.tenantId) {
31
+ fatalError("Not authenticated. Run: hisaabo login", 3);
32
+ }
33
+ return cfg;
34
+ }
35
+ function getConfigPath() {
36
+ return conf.path;
37
+ }
38
+
39
+ export {
40
+ getConfig,
41
+ setConfig,
42
+ clearConfig,
43
+ isAuthenticated,
44
+ requireAuth,
45
+ getConfigPath
46
+ };