@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,65 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatAmount,
4
+ formatDate
5
+ } from "./chunk-FFBG6RU4.js";
6
+ import {
7
+ HisaaboApiError,
8
+ HisaaboClient
9
+ } from "./chunk-FTOBDKMO.js";
10
+ import {
11
+ requireAuth
12
+ } from "./chunk-2P35S2C3.js";
13
+ import {
14
+ EXIT,
15
+ fatalError,
16
+ outputCSV,
17
+ outputJSON,
18
+ outputTSV,
19
+ outputTable
20
+ } from "./chunk-EYNDY7RB.js";
21
+
22
+ // src/commands/payment/unpaid-invoices.ts
23
+ async function paymentUnpaidInvoicesCommand(partyId, opts) {
24
+ const cfg = requireAuth();
25
+ const client = new HisaaboClient(cfg);
26
+ try {
27
+ const result = await client.payment.unpaidInvoices({ partyId });
28
+ if (opts.json) {
29
+ outputJSON(result);
30
+ return;
31
+ }
32
+ const invoices = Array.isArray(result) ? result : result?.data ?? [];
33
+ if (invoices.length === 0) {
34
+ console.log("\n No unpaid invoices for this party.\n");
35
+ return;
36
+ }
37
+ console.log(`
38
+ Unpaid Invoices (${invoices.length})
39
+ `);
40
+ const cols = [
41
+ { key: "invoiceNumber", header: "Invoice #", width: 14 },
42
+ { key: "invoiceDate", header: "Date", width: 13, format: (v) => formatDate(String(v ?? "")) },
43
+ { key: "totalAmount", header: "Total (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
44
+ { key: "paidAmount", header: "Paid (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
45
+ { key: "outstandingAmount", header: "Outstanding (\u20B9)", align: "right", width: 16, format: (v) => formatAmount(String(v ?? "0")) },
46
+ { key: "status", header: "Status", width: 10, format: (v) => String(v ?? "").toUpperCase() }
47
+ ];
48
+ if (opts.format === "tsv") outputTSV(invoices, cols);
49
+ else if (opts.format === "csv") outputCSV(invoices, cols);
50
+ else outputTable(invoices, cols);
51
+ console.log();
52
+ } catch (e) {
53
+ if (e instanceof HisaaboApiError) {
54
+ const err = e.hisaaboError;
55
+ if (err.code === "not_found") fatalError(`Party not found: ${partyId}`, EXIT.NOT_FOUND);
56
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
57
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
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
+ paymentUnpaidInvoicesCommand
65
+ };
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatAmount,
4
+ formatDate
5
+ } from "./chunk-FFBG6RU4.js";
6
+ import {
7
+ HisaaboApiError,
8
+ HisaaboClient
9
+ } from "./chunk-FTOBDKMO.js";
10
+ import {
11
+ requireAuth
12
+ } from "./chunk-2P35S2C3.js";
13
+ import {
14
+ EXIT,
15
+ fatalError,
16
+ outputCSV,
17
+ outputJSON,
18
+ outputTSV,
19
+ outputTable,
20
+ paginationFooter
21
+ } from "./chunk-EYNDY7RB.js";
22
+
23
+ // src/commands/payment/untracked.ts
24
+ async function paymentUntrackedCommand(opts) {
25
+ const cfg = requireAuth();
26
+ const client = new HisaaboClient(cfg);
27
+ const page = opts.page ?? 1;
28
+ const limit = opts.limit ?? 20;
29
+ try {
30
+ const result = await client.payment.untrackedPayments({ page, limit });
31
+ if (opts.json) {
32
+ outputJSON(result);
33
+ return;
34
+ }
35
+ const payments = Array.isArray(result) ? result : result?.data ?? [];
36
+ const total = result?.total ?? payments.length;
37
+ const resultPage = result?.page ?? page;
38
+ const resultLimit = result?.limit ?? limit;
39
+ console.log(`
40
+ Untracked Payments ${total} total
41
+ `);
42
+ const cols = [
43
+ { key: "paymentNumber", header: "#", width: 12 },
44
+ { key: "partyName", header: "Party", width: 22 },
45
+ { key: "paymentDate", header: "Date", width: 13, format: (v) => formatDate(String(v ?? "")) },
46
+ { key: "amount", header: "Amount (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
47
+ { key: "mode", header: "Mode", width: 8 },
48
+ { key: "referenceNumber", header: "Ref#", width: 14, format: (v) => String(v ?? "-") }
49
+ ];
50
+ if (opts.format === "tsv") outputTSV(payments, cols);
51
+ else if (opts.format === "csv") outputCSV(payments, cols);
52
+ else {
53
+ outputTable(payments, cols);
54
+ paginationFooter(resultPage, resultLimit, total);
55
+ }
56
+ } catch (e) {
57
+ if (e instanceof HisaaboApiError) {
58
+ const err = e.hisaaboError;
59
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
60
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
61
+ }
62
+ fatalError(String(e instanceof Error ? e.message : e));
63
+ }
64
+ }
65
+ export {
66
+ paymentUntrackedCommand
67
+ };
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatINR
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
+ outputJSON,
16
+ success
17
+ } from "./chunk-EYNDY7RB.js";
18
+
19
+ // src/commands/payment/update.ts
20
+ async function paymentUpdateCommand(id, opts) {
21
+ const cfg = requireAuth();
22
+ const client = new HisaaboClient(cfg);
23
+ const input = { id };
24
+ if (opts.amount !== void 0) input.amount = opts.amount;
25
+ if (opts.mode !== void 0) input.mode = opts.mode;
26
+ if (opts.date !== void 0) input.paymentDate = opts.date;
27
+ if (opts.reference !== void 0) input.referenceNumber = opts.reference || null;
28
+ if (opts.notes !== void 0) input.notes = opts.notes || null;
29
+ const hasUpdates = Object.keys(input).length > 1;
30
+ if (!hasUpdates) {
31
+ fatalError("No fields to update. Provide at least one option: --amount, --mode, --date, --reference, --notes", EXIT.USAGE);
32
+ }
33
+ try {
34
+ const payment = await client.payment.update(input);
35
+ if (opts.json) {
36
+ outputJSON(payment);
37
+ return;
38
+ }
39
+ success(`Updated: ${payment.paymentNumber} \u2014 ${formatINR(payment.amount)}`);
40
+ } catch (e) {
41
+ if (e instanceof HisaaboApiError) {
42
+ const err = e.hisaaboError;
43
+ if (err.code === "not_found") fatalError(`Payment not found: ${id}`, EXIT.NOT_FOUND);
44
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
45
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
46
+ if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
47
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
48
+ }
49
+ fatalError(String(e instanceof Error ? e.message : e));
50
+ }
51
+ }
52
+ export {
53
+ paymentUpdateCommand
54
+ };
@@ -0,0 +1,61 @@
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
+ success
14
+ } from "./chunk-EYNDY7RB.js";
15
+
16
+ // src/commands/business/update.ts
17
+ async function businessUpdateCommand(opts) {
18
+ const cfg = requireAuth();
19
+ const client = new HisaaboClient(cfg);
20
+ const payload = {};
21
+ if (opts.name !== void 0) payload["name"] = opts.name;
22
+ if (opts.gstin !== void 0) payload["gstin"] = opts.gstin;
23
+ if (opts.address !== void 0) payload["address"] = opts.address;
24
+ if (opts.state !== void 0) payload["state"] = opts.state;
25
+ if (opts.phone !== void 0) payload["phone"] = opts.phone;
26
+ if (opts.email !== void 0) payload["email"] = opts.email;
27
+ if (opts.financialYearStart !== void 0) {
28
+ const month = parseInt(opts.financialYearStart, 10);
29
+ if (isNaN(month) || month < 1 || month > 12) {
30
+ fatalError("--financial-year-start must be a month number (1\u201312).", EXIT.USAGE);
31
+ }
32
+ payload["financialYearStart"] = month;
33
+ }
34
+ if (Object.keys(payload).length === 0) {
35
+ fatalError("No fields to update. Pass at least one option (--name, --gstin, etc.).", EXIT.USAGE);
36
+ }
37
+ try {
38
+ const result = await client.business.update(payload);
39
+ if (opts.json) {
40
+ outputJSON(result);
41
+ return;
42
+ }
43
+ success("Business settings updated.");
44
+ } catch (e) {
45
+ if (e instanceof HisaaboApiError) {
46
+ const err = e.hisaaboError;
47
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
48
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
49
+ if (err.code === "validation_failed") {
50
+ const msgs = Object.entries(err.fields).map(([f, ms]) => ` ${f}: ${ms.join(", ")}`).join("\n");
51
+ fatalError(`Validation failed:
52
+ ${msgs}`, EXIT.VALIDATION);
53
+ }
54
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
55
+ }
56
+ fatalError(String(e instanceof Error ? e.message : e));
57
+ }
58
+ }
59
+ export {
60
+ businessUpdateCommand
61
+ };
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ formatINR
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
+ outputJSON,
16
+ success
17
+ } from "./chunk-EYNDY7RB.js";
18
+
19
+ // src/commands/expense/update.ts
20
+ async function expenseUpdateCommand(id, opts) {
21
+ const cfg = requireAuth();
22
+ const client = new HisaaboClient(cfg);
23
+ const data = {};
24
+ if (opts.amount !== void 0) data.amount = opts.amount;
25
+ if (opts.category !== void 0) data.category = opts.category;
26
+ if (opts.date !== void 0) data.expenseDate = opts.date;
27
+ if (opts.description !== void 0) data.description = opts.description;
28
+ if (opts.paymentMode !== void 0) data.mode = opts.paymentMode;
29
+ if (opts.reference !== void 0) data.referenceNumber = opts.reference;
30
+ if (Object.keys(data).length === 0) {
31
+ fatalError(
32
+ "No fields to update. Provide at least one option: --amount, --category, --date, --description, --payment-mode, --reference",
33
+ EXIT.USAGE
34
+ );
35
+ }
36
+ try {
37
+ const expense = await client.expense.update(id, data);
38
+ if (opts.json) {
39
+ outputJSON(expense);
40
+ return;
41
+ }
42
+ success(`Updated: ${expense.category} \u2014 ${formatINR(expense.amount)}`);
43
+ } catch (e) {
44
+ if (e instanceof HisaaboApiError) {
45
+ const err = e.hisaaboError;
46
+ if (err.code === "not_found") fatalError(`Expense not found: ${id}`, EXIT.NOT_FOUND);
47
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
48
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
49
+ if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
50
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
51
+ }
52
+ fatalError(String(e instanceof Error ? e.message : e));
53
+ }
54
+ }
55
+ export {
56
+ expenseUpdateCommand
57
+ };
@@ -0,0 +1,45 @@
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
+ success
14
+ } from "./chunk-EYNDY7RB.js";
15
+
16
+ // src/commands/tenant/update-role.ts
17
+ var VALID_ROLES = ["admin", "seller_manager", "seller", "accountant"];
18
+ async function tenantUpdateRoleCommand(userId, role, opts) {
19
+ const cfg = requireAuth();
20
+ const client = new HisaaboClient(cfg);
21
+ if (!VALID_ROLES.includes(role)) {
22
+ fatalError(`Invalid role "${role}". Must be one of: ${VALID_ROLES.join(", ")}`, EXIT.VALIDATION);
23
+ }
24
+ try {
25
+ const result = await client.tenant.updateMemberRole({ userId, role });
26
+ if (opts.json) {
27
+ outputJSON(result);
28
+ return;
29
+ }
30
+ success(`Updated role for member ${userId} to ${role}`);
31
+ } catch (e) {
32
+ if (e instanceof HisaaboApiError) {
33
+ const err = e.hisaaboError;
34
+ if (err.code === "not_found") fatalError(`Member not found: ${userId}`, EXIT.NOT_FOUND);
35
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
36
+ if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
37
+ if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
38
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
39
+ }
40
+ fatalError(String(e instanceof Error ? e.message : e));
41
+ }
42
+ }
43
+ export {
44
+ tenantUpdateRoleCommand
45
+ };
@@ -0,0 +1,56 @@
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
+ success
14
+ } from "./chunk-EYNDY7RB.js";
15
+
16
+ // src/commands/store/update-settings.ts
17
+ async function storeUpdateSettingsCommand(opts) {
18
+ const cfg = requireAuth();
19
+ const client = new HisaaboClient(cfg);
20
+ const data = {};
21
+ if (opts.slug !== void 0) data["storeSlug"] = opts.slug;
22
+ if (opts.tagline !== void 0) data["storeDescription"] = opts.tagline;
23
+ if (opts.enabled !== void 0) {
24
+ if (opts.enabled !== "true" && opts.enabled !== "false") {
25
+ fatalError("--enabled must be 'true' or 'false'", EXIT.USAGE);
26
+ }
27
+ data["storeEnabled"] = opts.enabled === "true";
28
+ }
29
+ if (Object.keys(data).length === 0) {
30
+ fatalError("At least one option is required (--slug, --tagline, --enabled)", EXIT.USAGE);
31
+ }
32
+ try {
33
+ const result = await client.store.updateSettings(data);
34
+ if (opts.json) {
35
+ outputJSON(result);
36
+ return;
37
+ }
38
+ success("Store settings updated");
39
+ console.log(` Enabled: ${result.storeEnabled ? "Yes" : "No"}`);
40
+ if (result.storeSlug) console.log(` Slug: ${result.storeSlug}`);
41
+ if (result.storeName) console.log(` Name: ${result.storeName}`);
42
+ if (result.storeDescription) console.log(` About: ${result.storeDescription}`);
43
+ console.log();
44
+ } catch (e) {
45
+ if (e instanceof HisaaboApiError) {
46
+ const err = e.hisaaboError;
47
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
48
+ if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
49
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
50
+ }
51
+ fatalError(String(e instanceof Error ? e.message : e));
52
+ }
53
+ }
54
+ export {
55
+ storeUpdateSettingsCommand
56
+ };
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@hisaabo/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/hisaabo/hisaabo.git",
9
+ "directory": "packages/cli"
10
+ },
6
11
  "bin": {
7
12
  "hisaabo": "./dist/bin/hisaabo.js"
8
13
  },