@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
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/output.ts
4
+ import chalk from "chalk";
5
+ function isInteractive() {
6
+ return process.stdout.isTTY === true;
7
+ }
8
+ function hasColor() {
9
+ if (process.env["NO_COLOR"] !== void 0) return false;
10
+ if (process.env["FORCE_COLOR"] === "0") return false;
11
+ return process.stdout.hasColors?.() ?? isInteractive();
12
+ }
13
+ function stripAnsi(str) {
14
+ return str.replace(/\x1b\[[0-9;]*m/g, "");
15
+ }
16
+ function getWidthTier() {
17
+ const w = process.stdout.columns ?? 80;
18
+ if (w < 80) return "narrow";
19
+ if (w <= 120) return "standard";
20
+ return "wide";
21
+ }
22
+ function termWidth() {
23
+ return process.stdout.columns ?? 80;
24
+ }
25
+ var EXIT = {
26
+ SUCCESS: 0,
27
+ GENERAL: 1,
28
+ USAGE: 2,
29
+ AUTH: 3,
30
+ FORBIDDEN: 4,
31
+ NOT_FOUND: 5,
32
+ VALIDATION: 6,
33
+ NETWORK: 7,
34
+ CONFLICT: 8
35
+ };
36
+ function fatalError(message, code = 1) {
37
+ if (hasColor()) {
38
+ process.stderr.write(chalk.red("Error: ") + message + "\n");
39
+ } else {
40
+ process.stderr.write("Error: " + message + "\n");
41
+ }
42
+ process.exit(code);
43
+ }
44
+ function success(message) {
45
+ if (hasColor()) {
46
+ process.stdout.write(chalk.green("\u2713 ") + message + "\n");
47
+ } else {
48
+ process.stdout.write("OK: " + message + "\n");
49
+ }
50
+ }
51
+ function warn(message) {
52
+ if (hasColor()) {
53
+ process.stderr.write(chalk.yellow("Warning: ") + message + "\n");
54
+ } else {
55
+ process.stderr.write("Warning: " + message + "\n");
56
+ }
57
+ }
58
+ function outputJSON(data) {
59
+ process.stdout.write(JSON.stringify(data, null, 2) + "\n");
60
+ }
61
+ function getNestedValue(obj, key) {
62
+ const parts = key.split(".");
63
+ let cur = obj;
64
+ for (const part of parts) {
65
+ if (cur == null || typeof cur !== "object") return void 0;
66
+ cur = cur[part];
67
+ }
68
+ return cur;
69
+ }
70
+ function padEnd(str, len) {
71
+ const visual = stripAnsi(str).length;
72
+ const pad = Math.max(0, len - visual);
73
+ return str + " ".repeat(pad);
74
+ }
75
+ function padStart(str, len) {
76
+ const visual = stripAnsi(str).length;
77
+ const pad = Math.max(0, len - visual);
78
+ return " ".repeat(pad) + str;
79
+ }
80
+ function outputTable(rows, columns) {
81
+ if (rows.length === 0) {
82
+ process.stdout.write(" (no results)\n");
83
+ return;
84
+ }
85
+ const widths = columns.map((col) => {
86
+ let max = stripAnsi(col.header).length;
87
+ for (const row of rows) {
88
+ const val = col.format ? col.format(getNestedValue(row, col.key), row) : String(getNestedValue(row, col.key) ?? "");
89
+ const vis = stripAnsi(val).length;
90
+ if (vis > max) max = vis;
91
+ }
92
+ if (col.width) max = Math.min(max, col.width);
93
+ return max;
94
+ });
95
+ const sep = "\u2500".repeat(widths.reduce((s, w) => s + w + 2, 1));
96
+ let header = " ";
97
+ for (let i = 0; i < columns.length; i++) {
98
+ const col = columns[i];
99
+ const h = col.align === "right" ? padStart(col.header, widths[i]) : padEnd(col.header, widths[i]);
100
+ header += (hasColor() ? chalk.dim(h) : h) + " ";
101
+ }
102
+ process.stdout.write(" " + (hasColor() ? chalk.dim(sep) : sep) + "\n");
103
+ process.stdout.write(header.trimEnd() + "\n");
104
+ process.stdout.write(" " + (hasColor() ? chalk.dim(sep) : sep) + "\n");
105
+ for (const row of rows) {
106
+ let line = " ";
107
+ for (let i = 0; i < columns.length; i++) {
108
+ const col = columns[i];
109
+ let val = col.format ? col.format(getNestedValue(row, col.key), row) : String(getNestedValue(row, col.key) ?? "");
110
+ const vis = stripAnsi(val).length;
111
+ if (col.width && vis > col.width) {
112
+ val = val.slice(0, col.width - 1) + "\u2026";
113
+ }
114
+ const cell = col.align === "right" ? padStart(val, widths[i]) : padEnd(val, widths[i]);
115
+ line += cell + " ";
116
+ }
117
+ process.stdout.write(line.trimEnd() + "\n");
118
+ }
119
+ process.stdout.write(" " + (hasColor() ? chalk.dim(sep) : sep) + "\n");
120
+ }
121
+ function outputTSV(rows, columns) {
122
+ process.stdout.write(columns.map((c) => c.header).join(" ") + "\n");
123
+ for (const row of rows) {
124
+ const line = columns.map((col) => {
125
+ const val = col.format ? col.format(getNestedValue(row, col.key), row) : String(getNestedValue(row, col.key) ?? "");
126
+ return stripAnsi(val).replace(/\t/g, " ");
127
+ });
128
+ process.stdout.write(line.join(" ") + "\n");
129
+ }
130
+ }
131
+ function csvEscape(val) {
132
+ if (val.includes(",") || val.includes('"') || val.includes("\n")) {
133
+ return `"${val.replace(/"/g, '""')}"`;
134
+ }
135
+ return val;
136
+ }
137
+ function outputCSV(rows, columns) {
138
+ process.stdout.write(columns.map((c) => csvEscape(c.header)).join(",") + "\n");
139
+ for (const row of rows) {
140
+ const line = columns.map((col) => {
141
+ const val = col.format ? col.format(getNestedValue(row, col.key), row) : String(getNestedValue(row, col.key) ?? "");
142
+ return csvEscape(stripAnsi(val));
143
+ });
144
+ process.stdout.write(line.join(",") + "\n");
145
+ }
146
+ }
147
+ function outputIds(ids) {
148
+ for (const id of ids) {
149
+ process.stdout.write(id + "\n");
150
+ }
151
+ }
152
+ function paginationFooter(page, limit, total) {
153
+ const from = (page - 1) * limit + 1;
154
+ const to = Math.min(page * limit, total);
155
+ const msg = ` Showing ${from}-${to} of ${total}`;
156
+ process.stdout.write("\n" + (hasColor() ? chalk.dim(msg) : msg) + "\n");
157
+ }
158
+
159
+ export {
160
+ isInteractive,
161
+ hasColor,
162
+ stripAnsi,
163
+ getWidthTier,
164
+ termWidth,
165
+ EXIT,
166
+ fatalError,
167
+ success,
168
+ warn,
169
+ outputJSON,
170
+ outputTable,
171
+ outputTSV,
172
+ outputCSV,
173
+ outputIds,
174
+ paginationFooter
175
+ };
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ hasColor
4
+ } from "./chunk-EYNDY7RB.js";
5
+
6
+ // src/format.ts
7
+ import chalk from "chalk";
8
+ function formatINR(amount) {
9
+ const num = typeof amount === "string" ? parseFloat(amount) : amount;
10
+ if (isNaN(num)) return "0.00";
11
+ const abs = Math.abs(num);
12
+ const formatted = new Intl.NumberFormat("en-IN", {
13
+ minimumFractionDigits: 2,
14
+ maximumFractionDigits: 2
15
+ }).format(abs);
16
+ return (num < 0 ? "-" : "") + "\u20B9" + formatted;
17
+ }
18
+ function formatAmount(amount) {
19
+ const num = typeof amount === "string" ? parseFloat(amount) : amount;
20
+ if (isNaN(num)) return "0.00";
21
+ const abs = Math.abs(num);
22
+ const formatted = new Intl.NumberFormat("en-IN", {
23
+ minimumFractionDigits: 2,
24
+ maximumFractionDigits: 2
25
+ }).format(abs);
26
+ return (num < 0 ? "-" : "") + formatted;
27
+ }
28
+ var MONTHS = [
29
+ "Jan",
30
+ "Feb",
31
+ "Mar",
32
+ "Apr",
33
+ "May",
34
+ "Jun",
35
+ "Jul",
36
+ "Aug",
37
+ "Sep",
38
+ "Oct",
39
+ "Nov",
40
+ "Dec"
41
+ ];
42
+ function formatDate(date) {
43
+ if (!date) return "-";
44
+ try {
45
+ const d = new Date(date);
46
+ if (isNaN(d.getTime())) return date;
47
+ const day = String(d.getDate()).padStart(2, "0");
48
+ const month = MONTHS[d.getMonth()];
49
+ const year = d.getFullYear();
50
+ return `${day} ${month} ${year}`;
51
+ } catch {
52
+ return date;
53
+ }
54
+ }
55
+ function formatRelativeDate(date) {
56
+ if (!date) return "-";
57
+ try {
58
+ const d = new Date(date);
59
+ const now = /* @__PURE__ */ new Date();
60
+ const diff = Math.floor((now.getTime() - d.getTime()) / (1e3 * 60 * 60 * 24));
61
+ if (diff === 0) return "Today";
62
+ if (diff === 1) return "Yesterday";
63
+ if (diff < 30) return `${diff}d ago`;
64
+ if (diff < 365) return `${Math.floor(diff / 30)}mo ago`;
65
+ return `${Math.floor(diff / 365)}y ago`;
66
+ } catch {
67
+ return date ?? "-";
68
+ }
69
+ }
70
+ var STATUS_CONFIG = {
71
+ paid: { label: "PAID", color: (s) => chalk.green(s) },
72
+ sent: { label: "SENT", color: (s) => chalk.blue(s) },
73
+ draft: { label: "DRAFT", color: (s) => chalk.dim(s) },
74
+ partial: { label: "PARTIAL", color: (s) => chalk.yellow(s) },
75
+ overdue: { label: "OVERDUE", color: (s) => chalk.red(s) },
76
+ cancelled: { label: "CANCEL", color: (s) => chalk.dim(chalk.strikethrough(s)) },
77
+ unfulfilled: { label: "UNFUL", color: (s) => chalk.blue(s) },
78
+ pending: { label: "PEND", color: (s) => chalk.yellow(s) },
79
+ confirmed: { label: "CONF", color: (s) => chalk.blue(s) },
80
+ delivered: { label: "DELIV", color: (s) => chalk.green(s) },
81
+ shipped: { label: "SHIPPED", color: (s) => chalk.blue(s) },
82
+ in_transit: { label: "TRANSIT", color: (s) => chalk.cyan(s) },
83
+ returned: { label: "RETURN", color: (s) => chalk.red(s) },
84
+ preparing: { label: "PREP", color: (s) => chalk.yellow(s) },
85
+ ready: { label: "READY", color: (s) => chalk.cyan(s) }
86
+ };
87
+ function formatStatus(status) {
88
+ const cfg = STATUS_CONFIG[status.toLowerCase()];
89
+ const label = cfg ? `[${cfg.label}]` : `[${status.toUpperCase()}]`;
90
+ if (!hasColor() || !cfg) return label;
91
+ return cfg.color(label);
92
+ }
93
+ function currentFY() {
94
+ const now = /* @__PURE__ */ new Date();
95
+ const year = now.getFullYear();
96
+ const month = now.getMonth() + 1;
97
+ if (month >= 4) {
98
+ return `${year}-${String(year + 1).slice(2)}`;
99
+ }
100
+ return `${year - 1}-${String(year).slice(2)}`;
101
+ }
102
+ function fyStart() {
103
+ const now = /* @__PURE__ */ new Date();
104
+ const year = now.getMonth() + 1 >= 4 ? now.getFullYear() : now.getFullYear() - 1;
105
+ return `${year}-04-01`;
106
+ }
107
+ function todayISO() {
108
+ return (/* @__PURE__ */ new Date()).toISOString().split("T")[0] ?? "";
109
+ }
110
+ function monthStart() {
111
+ const now = /* @__PURE__ */ new Date();
112
+ return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-01`;
113
+ }
114
+ function monthEnd() {
115
+ const now = /* @__PURE__ */ new Date();
116
+ const last = new Date(now.getFullYear(), now.getMonth() + 1, 0);
117
+ return `${last.getFullYear()}-${String(last.getMonth() + 1).padStart(2, "0")}-${String(last.getDate()).padStart(2, "0")}`;
118
+ }
119
+ function quarterRange(q) {
120
+ const now = /* @__PURE__ */ new Date();
121
+ const fyYear = now.getMonth() + 1 >= 4 ? now.getFullYear() : now.getFullYear() - 1;
122
+ const ranges = {
123
+ Q1: { from: `${fyYear}-04-01`, to: `${fyYear}-06-30`, month: 4, year: fyYear },
124
+ Q2: { from: `${fyYear}-07-01`, to: `${fyYear}-09-30`, month: 7, year: fyYear },
125
+ Q3: { from: `${fyYear}-10-01`, to: `${fyYear}-12-31`, month: 10, year: fyYear },
126
+ Q4: { from: `${fyYear + 1}-01-01`, to: `${fyYear + 1}-03-31`, month: 1, year: fyYear + 1 }
127
+ };
128
+ const upper = q.toUpperCase();
129
+ return ranges[upper] ?? ranges["Q1"];
130
+ }
131
+ function deliveryMethodLabel(method) {
132
+ const map = {
133
+ self_pickup: "Self Pickup",
134
+ hand_delivery: "Hand Delivery",
135
+ courier: "Courier",
136
+ bus: "Bus",
137
+ transport: "Transport",
138
+ post: "Post"
139
+ };
140
+ return map[method] ?? method;
141
+ }
142
+
143
+ export {
144
+ formatINR,
145
+ formatAmount,
146
+ formatDate,
147
+ formatRelativeDate,
148
+ formatStatus,
149
+ currentFY,
150
+ fyStart,
151
+ todayISO,
152
+ monthStart,
153
+ monthEnd,
154
+ quarterRange,
155
+ deliveryMethodLabel
156
+ };