@hisaabo/cli 0.1.0 → 0.4.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 (172) hide show
  1. package/.turbo/turbo-typecheck.log +1 -1
  2. package/README.md +332 -0
  3. package/dist/bin/audit-trail-5LOCJ7XZ.js +78 -0
  4. package/dist/bin/categories-64WWZTND.js +47 -0
  5. package/dist/bin/check-slug-FLHHUDYS.js +65 -0
  6. package/dist/bin/chunk-4MEL44QX.js +848 -0
  7. package/dist/bin/chunk-FIMJZAS4.js +84 -0
  8. package/dist/bin/chunk-NO4FIFMS.js +176 -0
  9. package/dist/bin/chunk-T63VQXNM.js +156 -0
  10. package/dist/bin/client-5NZ23GML.js +11 -0
  11. package/dist/bin/collection-efficiency-U56XNVEE.js +165 -0
  12. package/dist/bin/config-335MN4I7.js +18 -0
  13. package/dist/bin/create-RPDEORDD.js +83 -0
  14. package/dist/bin/default-account-AE6EXZZR.js +58 -0
  15. package/dist/bin/expenses-5N2QSG54.js +89 -0
  16. package/dist/bin/export-QICOQK34.js +59 -0
  17. package/dist/bin/factory-KOCW2AQM.js +483 -0
  18. package/dist/bin/get-A43QCI2S.js +66 -0
  19. package/dist/bin/get-GWH6S5SJ.js +71 -0
  20. package/dist/bin/hisaabo.js +2302 -1510
  21. package/dist/bin/invitations-P3EEN5WI.js +66 -0
  22. package/dist/bin/invite-T3CKX53E.js +53 -0
  23. package/dist/bin/invoice-breakdown-FN5BEFJD.js +97 -0
  24. package/dist/bin/items-2OOCQKVF.js +62 -0
  25. package/dist/bin/items-toggle-SKZWCGJH.js +46 -0
  26. package/dist/bin/list-A2RKI3ZG.js +79 -0
  27. package/dist/bin/list-NRMBMKMI.js +90 -0
  28. package/dist/bin/list-T74SN6IR.js +46 -0
  29. package/dist/bin/members-W2GW3ODT.js +55 -0
  30. package/dist/bin/monthly-comparison-T34ZFOHL.js +176 -0
  31. package/dist/bin/order-cancel-TI27JYYD.js +55 -0
  32. package/dist/bin/order-confirm-VMRAMNTD.js +53 -0
  33. package/dist/bin/order-get-C2RBUR4O.js +88 -0
  34. package/dist/bin/order-update-RE3HATNF.js +60 -0
  35. package/dist/bin/output-NUOL7KJW.js +35 -0
  36. package/dist/bin/payment-modes-WOOT22I7.js +126 -0
  37. package/dist/bin/profit-loss-T4RESJ32.js +135 -0
  38. package/dist/bin/receivables-aging-6XMENEWS.js +161 -0
  39. package/dist/bin/remove-6QZI4JCY.js +52 -0
  40. package/dist/bin/revoke-AVEMPAC7.js +40 -0
  41. package/dist/bin/revoke-YUCFZFNR.js +52 -0
  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-ZYBRUDUU.js +71 -0
  45. package/dist/bin/sequence-FPOJTI2P.js +66 -0
  46. package/dist/bin/store-IOB4Y67C.js +82 -0
  47. package/dist/bin/summary-5KYBA4ZO.js +113 -0
  48. package/dist/bin/top-customers-WSQ2UEJL.js +81 -0
  49. package/dist/bin/top-items-RWQPDGLN.js +84 -0
  50. package/dist/bin/top-outstanding-QAMO2E7Y.js +64 -0
  51. package/dist/bin/unpaid-invoices-WB3TK5B4.js +65 -0
  52. package/dist/bin/untracked-H733MYJL.js +67 -0
  53. package/dist/bin/update-H6LPO2Z4.js +61 -0
  54. package/dist/bin/update-JU2X3XU5.js +54 -0
  55. package/dist/bin/update-TLBUIC5J.js +57 -0
  56. package/dist/bin/update-role-QST7BVFX.js +45 -0
  57. package/dist/bin/update-settings-Q2EGRLKZ.js +56 -0
  58. package/package.json +7 -6
  59. package/src/auth.ts +12 -3
  60. package/src/bin/hisaabo.ts +49 -935
  61. package/src/bin/registrars/api-key.ts +44 -0
  62. package/src/bin/registrars/auth.ts +222 -0
  63. package/src/bin/registrars/automated-invoice.ts +167 -0
  64. package/src/bin/registrars/bank.ts +124 -0
  65. package/src/bin/registrars/business.ts +120 -0
  66. package/src/bin/registrars/dashboard.ts +225 -0
  67. package/src/bin/registrars/document.ts +184 -0
  68. package/src/bin/registrars/expense.ts +87 -0
  69. package/src/bin/registrars/gst.ts +41 -0
  70. package/src/bin/registrars/import.ts +49 -0
  71. package/src/bin/registrars/invoice.ts +117 -0
  72. package/src/bin/registrars/item.ts +112 -0
  73. package/src/bin/registrars/party.ts +81 -0
  74. package/src/bin/registrars/payment.ts +128 -0
  75. package/src/bin/registrars/report.ts +142 -0
  76. package/src/bin/registrars/session.ts +32 -0
  77. package/src/bin/registrars/shipment.ts +74 -0
  78. package/src/bin/registrars/store.ts +128 -0
  79. package/src/bin/registrars/target.ts +46 -0
  80. package/src/bin/registrars/tenant.ts +73 -0
  81. package/src/client.ts +589 -15
  82. package/src/commands/api-key/create.ts +72 -0
  83. package/src/commands/api-key/list.ts +71 -0
  84. package/src/commands/api-key/revoke.ts +46 -0
  85. package/src/commands/automated-invoice/create.ts +85 -0
  86. package/src/commands/automated-invoice/delete.ts +42 -0
  87. package/src/commands/automated-invoice/get.ts +113 -0
  88. package/src/commands/automated-invoice/history.ts +65 -0
  89. package/src/commands/automated-invoice/index.ts +11 -0
  90. package/src/commands/automated-invoice/list.ts +91 -0
  91. package/src/commands/automated-invoice/pause.ts +29 -0
  92. package/src/commands/automated-invoice/resume.ts +29 -0
  93. package/src/commands/automated-invoice/run-now.ts +29 -0
  94. package/src/commands/automated-invoice/suggestions.ts +68 -0
  95. package/src/commands/automated-invoice/update.ts +54 -0
  96. package/src/commands/automated-invoice/usage.ts +68 -0
  97. package/src/commands/bank/gateway-config.ts +61 -0
  98. package/src/commands/bank/update-gateway.ts +84 -0
  99. package/src/commands/business/audit-trail.ts +79 -0
  100. package/src/commands/business/export.ts +52 -0
  101. package/src/commands/business/get.ts +55 -0
  102. package/src/commands/business/sequence.ts +65 -0
  103. package/src/commands/business/update.ts +64 -0
  104. package/src/commands/dashboard/collection-efficiency.ts +164 -0
  105. package/src/commands/dashboard/expenses.ts +76 -0
  106. package/src/commands/dashboard/invoice-breakdown.ts +89 -0
  107. package/src/commands/dashboard/monthly-comparison.ts +193 -0
  108. package/src/commands/dashboard/payment-modes.ts +121 -0
  109. package/src/commands/dashboard/profit-loss.ts +146 -0
  110. package/src/commands/dashboard/receivables-aging.ts +169 -0
  111. package/src/commands/dashboard/sales-trend.ts +68 -0
  112. package/src/commands/dashboard/summary.ts +105 -0
  113. package/src/commands/dashboard/top-customers.ts +70 -0
  114. package/src/commands/dashboard/top-items.ts +74 -0
  115. package/src/commands/dashboard/top-outstanding.ts +61 -0
  116. package/src/commands/document/factory.ts +590 -0
  117. package/src/commands/expense/categories.ts +40 -0
  118. package/src/commands/expense/update.ts +58 -0
  119. package/src/commands/import/index.ts +68 -0
  120. package/src/commands/item/categories.ts +40 -0
  121. package/src/commands/item/low-stock-count.ts +32 -0
  122. package/src/commands/item/merge.ts +53 -0
  123. package/src/commands/item/price-history.ts +59 -0
  124. package/src/commands/item/rename-unit.ts +39 -0
  125. package/src/commands/item/sales-stats.ts +44 -0
  126. package/src/commands/item/stock-history.ts +70 -0
  127. package/src/commands/item/switch-base-unit.ts +42 -0
  128. package/src/commands/item/update.ts +59 -0
  129. package/src/commands/item/variants-create.ts +58 -0
  130. package/src/commands/item/variants-delete.ts +47 -0
  131. package/src/commands/item/variants-list.ts +63 -0
  132. package/src/commands/item/variants-update.ts +61 -0
  133. package/src/commands/party/ledger-report.ts +81 -0
  134. package/src/commands/party/merge.ts +50 -0
  135. package/src/commands/party/stats.ts +40 -0
  136. package/src/commands/party/top-items.ts +57 -0
  137. package/src/commands/party/update.ts +65 -0
  138. package/src/commands/payment/default-account.ts +56 -0
  139. package/src/commands/payment/get.ts +59 -0
  140. package/src/commands/payment/unpaid-invoices.ts +69 -0
  141. package/src/commands/payment/untracked.ts +70 -0
  142. package/src/commands/payment/update.ts +54 -0
  143. package/src/commands/report/index.ts +348 -1
  144. package/src/commands/session/list.ts +91 -0
  145. package/src/commands/session/revoke-all.ts +20 -0
  146. package/src/commands/session/revoke.ts +32 -0
  147. package/src/commands/store/check-slug.ts +48 -0
  148. package/src/commands/store/items-toggle.ts +41 -0
  149. package/src/commands/store/items.ts +61 -0
  150. package/src/commands/store/order-cancel.ts +48 -0
  151. package/src/commands/store/order-confirm.ts +45 -0
  152. package/src/commands/store/order-get.ts +66 -0
  153. package/src/commands/store/order-update.ts +52 -0
  154. package/src/commands/store/update-settings.ts +52 -0
  155. package/src/commands/tenant/invitations.ts +62 -0
  156. package/src/commands/tenant/invite.ts +57 -0
  157. package/src/commands/tenant/list.ts +46 -0
  158. package/src/commands/tenant/members.ts +55 -0
  159. package/src/commands/tenant/remove.ts +47 -0
  160. package/src/commands/tenant/revoke-invitation.ts +32 -0
  161. package/src/commands/tenant/update-role.ts +41 -0
  162. package/src/config.ts +51 -2
  163. package/src/error-handler.ts +53 -0
  164. package/src/output.ts +1 -0
  165. package/src/spinner.ts +39 -0
  166. package/tsup.config.ts +6 -1
  167. package/src/components/ErrorDisplay.tsx +0 -16
  168. package/src/components/Header.tsx +0 -26
  169. package/src/components/MoneyCell.tsx +0 -16
  170. package/src/components/Spinner.tsx +0 -12
  171. package/src/components/StatusBadge.tsx +0 -39
  172. package/src/components/Table.tsx +0 -63
@@ -0,0 +1,848 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/client.ts
4
+ import superjson from "superjson";
5
+ var HisaaboApiError = class extends Error {
6
+ constructor(hisaaboError) {
7
+ super(formatHisaaboError(hisaaboError));
8
+ this.hisaaboError = hisaaboError;
9
+ this.name = "HisaaboApiError";
10
+ }
11
+ };
12
+ function formatHisaaboError(err) {
13
+ switch (err.code) {
14
+ case "unauthorized":
15
+ return `Authentication required: ${err.message}`;
16
+ case "forbidden":
17
+ return `Permission denied: ${err.message}`;
18
+ case "not_found":
19
+ return `Not found: ${err.resource}`;
20
+ case "validation_failed":
21
+ return `Validation failed:
22
+ ` + Object.entries(err.fields).map(([field, msgs]) => ` ${field}: ${msgs.join(", ")}`).join("\n");
23
+ case "rate_limited":
24
+ return `Rate limited: ${err.message}`;
25
+ case "network_error":
26
+ return `Network error: ${err.message}`;
27
+ case "api_error":
28
+ return `API error: ${err.message}`;
29
+ }
30
+ }
31
+ function normalizeTrpcError(raw) {
32
+ if (!raw || typeof raw !== "object") {
33
+ return { code: "api_error", message: "Unknown error from API" };
34
+ }
35
+ const err = raw;
36
+ const code = err["code"];
37
+ const message = err["message"] ?? "Unknown error";
38
+ if (code === "UNAUTHORIZED") return { code: "unauthorized", message };
39
+ if (code === "FORBIDDEN") return { code: "forbidden", message };
40
+ if (code === "NOT_FOUND") return { code: "not_found", resource: message };
41
+ if (code === "BAD_REQUEST") {
42
+ const data = err["data"];
43
+ const zodError = data?.["zodError"];
44
+ if (zodError?.fieldErrors) {
45
+ return { code: "validation_failed", fields: zodError.fieldErrors };
46
+ }
47
+ return { code: "validation_failed", fields: { _: [message] } };
48
+ }
49
+ return { code: "api_error", message };
50
+ }
51
+ var HisaaboClient = class {
52
+ constructor(config) {
53
+ this.config = config;
54
+ this.apiUrl = config.apiUrl;
55
+ }
56
+ apiUrl;
57
+ buildHeaders() {
58
+ return {
59
+ "Authorization": `Bearer ${this.config.token}`,
60
+ "x-business-id": this.config.businessId,
61
+ "x-tenant-id": this.config.tenantId,
62
+ "x-client-type": "cli"
63
+ };
64
+ }
65
+ async unwrap(res) {
66
+ if (res.status === 429) {
67
+ const retryAfter = res.headers.get("retry-after");
68
+ let retryMs = 6e4;
69
+ if (retryAfter) {
70
+ const parsed = Number(retryAfter);
71
+ if (Number.isFinite(parsed) && parsed > 0) {
72
+ retryMs = Math.min(parsed * 1e3, 12e4);
73
+ }
74
+ }
75
+ throw new HisaaboApiError({
76
+ code: "rate_limited",
77
+ retryAfterMs: retryMs,
78
+ message: `Rate limited. Try again in ${Math.ceil(retryMs / 1e3)}s.`
79
+ });
80
+ }
81
+ const body = await res.json();
82
+ if (typeof body !== "object" || body === null) {
83
+ throw new HisaaboApiError({ code: "api_error", message: "Unexpected response format from API" });
84
+ }
85
+ const envelope = body;
86
+ if (!res.ok || "error" in envelope) {
87
+ throw new HisaaboApiError(normalizeTrpcError(envelope["error"] ?? { code: "api_error", message: `HTTP ${res.status}` }));
88
+ }
89
+ const result = envelope["result"];
90
+ if (!result) {
91
+ throw new HisaaboApiError({ code: "api_error", message: "Missing result in API response" });
92
+ }
93
+ const data = result["data"];
94
+ return superjson.deserialize(data);
95
+ }
96
+ async query(path, input) {
97
+ const maxRetries = 2;
98
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
99
+ try {
100
+ const url = new URL(`${this.config.apiUrl}/api/trpc/${path}`);
101
+ if (input !== void 0) {
102
+ url.searchParams.set("input", JSON.stringify(superjson.serialize(input)));
103
+ }
104
+ const res = await fetch(url.toString(), { headers: this.buildHeaders() });
105
+ return await this.unwrap(res);
106
+ } catch (e) {
107
+ if (e instanceof HisaaboApiError && e.hisaaboError.code === "rate_limited" && attempt < maxRetries) {
108
+ const waitMs = Math.min(e.hisaaboError.retryAfterMs, 1e4);
109
+ await new Promise((r) => setTimeout(r, waitMs));
110
+ continue;
111
+ }
112
+ if (e instanceof HisaaboApiError) throw e;
113
+ throw new HisaaboApiError({ code: "network_error", message: String(e instanceof Error ? e.message : e) });
114
+ }
115
+ }
116
+ throw new HisaaboApiError({ code: "api_error", message: "Max retries exceeded" });
117
+ }
118
+ async mutate(path, input) {
119
+ try {
120
+ const res = await fetch(`${this.config.apiUrl}/api/trpc/${path}`, {
121
+ method: "POST",
122
+ headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
123
+ body: JSON.stringify(superjson.serialize(input))
124
+ });
125
+ return this.unwrap(res);
126
+ } catch (e) {
127
+ if (e instanceof HisaaboApiError) throw e;
128
+ throw new HisaaboApiError({ code: "network_error", message: String(e instanceof Error ? e.message : e) });
129
+ }
130
+ }
131
+ // ── Auth ──────────────────────────────────────────────────────
132
+ get auth() {
133
+ const c = this;
134
+ return {
135
+ login(input) {
136
+ return c.mutate("auth.login", input);
137
+ },
138
+ logout() {
139
+ return c.mutate("auth.logout", {});
140
+ },
141
+ me() {
142
+ return c.query("auth.me");
143
+ },
144
+ completeProfile(input) {
145
+ return c.mutate("auth.completeProfile", input);
146
+ },
147
+ logoutAll() {
148
+ return c.mutate("auth.logoutAll", {});
149
+ },
150
+ register(input) {
151
+ return c.mutate("auth.register", input);
152
+ },
153
+ updateName(input) {
154
+ return c.mutate("auth.updateName", input);
155
+ },
156
+ listSessions(input) {
157
+ return c.query("auth.listSessions", input);
158
+ },
159
+ revokeSession(input) {
160
+ return c.mutate("auth.revokeSession", input);
161
+ }
162
+ };
163
+ }
164
+ // ── Business ──────────────────────────────────────────────────
165
+ get business() {
166
+ const c = this;
167
+ return {
168
+ list() {
169
+ return c.query("business.list");
170
+ },
171
+ get() {
172
+ return c.query("business.getById");
173
+ },
174
+ create(input) {
175
+ return c.mutate("business.create", input);
176
+ },
177
+ update(input) {
178
+ return c.mutate("business.update", input);
179
+ },
180
+ updateSequenceNumber(input) {
181
+ return c.mutate("business.updateSequenceNumber", input);
182
+ },
183
+ auditTrail(input) {
184
+ return c.query("business.auditTrail", input);
185
+ },
186
+ exportData() {
187
+ return c.mutate("business.exportData", {});
188
+ }
189
+ };
190
+ }
191
+ // ── Invoice ───────────────────────────────────────────────────
192
+ get invoice() {
193
+ const c = this;
194
+ return {
195
+ list(input) {
196
+ return c.query("invoice.list", input);
197
+ },
198
+ get(id) {
199
+ return c.query("invoice.getById", { id });
200
+ },
201
+ create(input) {
202
+ return c.mutate("invoice.create", input);
203
+ },
204
+ update(input) {
205
+ return c.mutate("invoice.update", input);
206
+ },
207
+ updateStatus(id, status) {
208
+ return c.mutate("invoice.updateStatus", { id, status });
209
+ },
210
+ delete(id) {
211
+ return c.mutate("invoice.delete", { id });
212
+ }
213
+ };
214
+ }
215
+ // ── Party ─────────────────────────────────────────────────────
216
+ get party() {
217
+ const c = this;
218
+ return {
219
+ list(input) {
220
+ return c.query("party.list", input);
221
+ },
222
+ get(id) {
223
+ return c.query("party.getById", { id });
224
+ },
225
+ create(input) {
226
+ return c.mutate("party.create", input);
227
+ },
228
+ update(id, data) {
229
+ return c.mutate("party.update", { id, data });
230
+ },
231
+ delete(id) {
232
+ return c.mutate("party.delete", { id });
233
+ },
234
+ ledger(partyId, input) {
235
+ return c.query("party.ledger", { partyId, ...input });
236
+ },
237
+ ledgerReport(input) {
238
+ return c.query("party.ledgerReport", input);
239
+ },
240
+ getStats(input) {
241
+ return c.query("party.getStats", input);
242
+ },
243
+ topItems(input) {
244
+ return c.query("party.topItems", input);
245
+ },
246
+ merge(input) {
247
+ return c.mutate("party.merge", input);
248
+ }
249
+ };
250
+ }
251
+ // ── Item ──────────────────────────────────────────────────────
252
+ get item() {
253
+ const c = this;
254
+ return {
255
+ list(input) {
256
+ return c.query("item.list", input);
257
+ },
258
+ get(id) {
259
+ return c.query("item.getById", { id });
260
+ },
261
+ create(input) {
262
+ return c.mutate("item.create", input);
263
+ },
264
+ update(id, data) {
265
+ return c.mutate("item.update", { id, data });
266
+ },
267
+ delete(id) {
268
+ return c.mutate("item.delete", { id });
269
+ },
270
+ adjustStock(input) {
271
+ return c.mutate("item.adjustStock", input);
272
+ },
273
+ categories() {
274
+ return c.query("item.categories");
275
+ },
276
+ createVariant(input) {
277
+ return c.mutate("item.createVariant", input);
278
+ },
279
+ updateVariant(input) {
280
+ return c.mutate("item.updateVariant", input);
281
+ },
282
+ deleteVariant(input) {
283
+ return c.mutate("item.deleteVariant", input);
284
+ },
285
+ listVariants(input) {
286
+ return c.query("item.listVariants", input);
287
+ },
288
+ merge(input) {
289
+ return c.mutate("item.merge", input);
290
+ },
291
+ switchBaseUnit(input) {
292
+ return c.mutate("item.switchBaseUnit", input);
293
+ },
294
+ renameUnit(input) {
295
+ return c.mutate("item.renameUnit", input);
296
+ },
297
+ stockAdjustmentHistory(input) {
298
+ return c.query("item.stockAdjustmentHistory", input);
299
+ },
300
+ lowStockCount() {
301
+ return c.query("item.lowStockCount");
302
+ },
303
+ priceHistory(input) {
304
+ return c.query("item.priceHistory", input);
305
+ },
306
+ salesStats(input) {
307
+ return c.query("item.salesStats", input);
308
+ },
309
+ stockMovements(input) {
310
+ return c.query("item.stockMovements", input);
311
+ }
312
+ };
313
+ }
314
+ // ── Payment ───────────────────────────────────────────────────
315
+ get payment() {
316
+ const c = this;
317
+ return {
318
+ list(input) {
319
+ return c.query("payment.list", input);
320
+ },
321
+ getById(id) {
322
+ return c.query("payment.getById", { id });
323
+ },
324
+ create(input) {
325
+ return c.mutate("payment.create", input);
326
+ },
327
+ update(input) {
328
+ return c.mutate("payment.update", input);
329
+ },
330
+ delete(id) {
331
+ return c.mutate("payment.delete", { id });
332
+ },
333
+ unpaidInvoices(input) {
334
+ return c.query("payment.unpaidInvoices", input);
335
+ },
336
+ untrackedPayments(input) {
337
+ return c.query("payment.untrackedPayments", input);
338
+ },
339
+ defaultAccount(input) {
340
+ return c.query("payment.defaultAccount", input);
341
+ },
342
+ assignAccount(input) {
343
+ return c.mutate("payment.assignAccount", input);
344
+ }
345
+ };
346
+ }
347
+ // ── Expense ───────────────────────────────────────────────────
348
+ get expense() {
349
+ const c = this;
350
+ return {
351
+ list(input) {
352
+ return c.query("expense.list", input);
353
+ },
354
+ create(input) {
355
+ return c.mutate("expense.create", input);
356
+ },
357
+ update(id, data) {
358
+ return c.mutate("expense.update", { id, data });
359
+ },
360
+ delete(id) {
361
+ return c.mutate("expense.delete", { id });
362
+ },
363
+ categories() {
364
+ return c.query("expense.categories");
365
+ }
366
+ };
367
+ }
368
+ // ── Dashboard ─────────────────────────────────────────────────
369
+ get dashboard() {
370
+ const c = this;
371
+ return {
372
+ summary(input) {
373
+ return c.query("dashboard.summary", input);
374
+ },
375
+ salesTrend(input) {
376
+ return c.query("dashboard.salesTrend", input);
377
+ },
378
+ topOutstanding(input) {
379
+ return c.query("dashboard.topOutstanding", input);
380
+ },
381
+ topCustomers(input) {
382
+ return c.query("dashboard.topCustomers", input);
383
+ },
384
+ topSellingItems(input) {
385
+ return c.query("dashboard.topSellingItems", input);
386
+ },
387
+ expensesByCategory(input) {
388
+ return c.query("dashboard.expensesByCategory", input);
389
+ },
390
+ invoiceStatusBreakdown(input) {
391
+ return c.query("dashboard.invoiceStatusBreakdown", input);
392
+ },
393
+ profitAndLoss(input) {
394
+ return c.query("dashboard.profitAndLoss", input);
395
+ },
396
+ receivablesAging() {
397
+ return c.query("dashboard.receivablesAging");
398
+ },
399
+ paymentModeBreakdown(input) {
400
+ return c.query("dashboard.paymentModeBreakdown", input);
401
+ },
402
+ collectionEfficiency(input) {
403
+ return c.query("dashboard.collectionEfficiency", input);
404
+ },
405
+ monthlyComparison() {
406
+ return c.query("dashboard.monthlyComparison");
407
+ },
408
+ shippingSummary(input) {
409
+ return c.query("dashboard.shippingSummary", input);
410
+ }
411
+ };
412
+ }
413
+ // ── GST ───────────────────────────────────────────────────────
414
+ get gst() {
415
+ const c = this;
416
+ return {
417
+ gstr1(input) {
418
+ return c.query("gst.gstr1", input);
419
+ },
420
+ gstr3b(input) {
421
+ return c.query("gst.gstr3b", input);
422
+ },
423
+ gstr1CSV(input) {
424
+ return c.query("gst.gstr1CSV", input);
425
+ }
426
+ };
427
+ }
428
+ // ── Shipment ──────────────────────────────────────────────────
429
+ get shipment() {
430
+ const c = this;
431
+ return {
432
+ list(input) {
433
+ return c.query("shipment.list", input);
434
+ },
435
+ get(id) {
436
+ return c.query("shipment.getById", { id });
437
+ },
438
+ create(input) {
439
+ return c.mutate("shipment.create", input);
440
+ },
441
+ update(input) {
442
+ return c.mutate("shipment.update", input);
443
+ },
444
+ delete(id) {
445
+ return c.mutate("shipment.delete", { id });
446
+ }
447
+ };
448
+ }
449
+ // ── Bank Account ──────────────────────────────────────────────
450
+ get bankAccount() {
451
+ const c = this;
452
+ return {
453
+ list() {
454
+ return c.query("bankAccount.list");
455
+ },
456
+ get(id) {
457
+ return c.query("bankAccount.getById", { id });
458
+ },
459
+ create(input) {
460
+ return c.mutate("bankAccount.create", input);
461
+ },
462
+ update(id, data) {
463
+ return c.mutate("bankAccount.update", { id, data });
464
+ },
465
+ delete(id) {
466
+ return c.mutate("bankAccount.delete", { id });
467
+ },
468
+ transfer(input) {
469
+ return c.mutate("bankAccount.transfer", input);
470
+ },
471
+ listTransactions(input) {
472
+ return c.query("bankAccount.listTransactions", input);
473
+ },
474
+ summary() {
475
+ return c.query("bankAccount.summary");
476
+ },
477
+ getGatewayConfig(bankAccountId) {
478
+ return c.query("bankAccount.getGatewayConfig", { bankAccountId });
479
+ },
480
+ upsertGatewayConfig(input) {
481
+ return c.mutate("bankAccount.upsertGatewayConfig", input);
482
+ }
483
+ };
484
+ }
485
+ // ── Reports ───────────────────────────────────────────────────
486
+ get reports() {
487
+ const c = this;
488
+ return {
489
+ daybook(input) {
490
+ return c.query("reports.daybook", input);
491
+ },
492
+ outstanding(input) {
493
+ return c.query("reports.outstanding", input);
494
+ },
495
+ taxSummary(input) {
496
+ return c.query("reports.taxSummary", input);
497
+ },
498
+ itemSales(input) {
499
+ return c.query("reports.itemSales", input);
500
+ },
501
+ stockSummary(input) {
502
+ return c.query("reports.stockSummary", input);
503
+ },
504
+ partyStatement(input) {
505
+ return c.query("reports.partyStatement", input);
506
+ },
507
+ paymentSummary(input) {
508
+ return c.query("reports.paymentSummary", input);
509
+ },
510
+ salesRegister(input) {
511
+ return c.query("reports.salesRegister", input);
512
+ },
513
+ purchaseRegister(input) {
514
+ return c.query("reports.purchaseRegister", input);
515
+ },
516
+ cashFlowForecast(input) {
517
+ return c.query("reports.cashFlowForecast", input ?? {});
518
+ },
519
+ collectionEfficiency(input) {
520
+ return c.query("reports.collectionEfficiency", input);
521
+ }
522
+ };
523
+ }
524
+ // ── Store ─────────────────────────────────────────────────────
525
+ get store() {
526
+ const c = this;
527
+ return {
528
+ getSettings() {
529
+ return c.query("store.getSettings");
530
+ },
531
+ updateSettings(input) {
532
+ return c.mutate("store.updateSettings", input);
533
+ },
534
+ listOrders(input) {
535
+ return c.query("store.listOrders", input);
536
+ },
537
+ getOrder(id) {
538
+ return c.query("store.getOrder", { id });
539
+ },
540
+ updateOrder(input) {
541
+ return c.mutate("store.updateOrderStatus", input);
542
+ },
543
+ confirmOrder(input) {
544
+ return c.mutate("store.confirmOrder", input);
545
+ },
546
+ cancelOrder(input) {
547
+ return c.mutate("store.cancelOrder", input);
548
+ },
549
+ checkSlug(input) {
550
+ return c.query("store.checkSlug", input);
551
+ },
552
+ listStoreItems(input) {
553
+ return c.query("store.listStoreItems", input);
554
+ },
555
+ bulkToggleItems(input) {
556
+ return c.mutate("store.bulkToggleItems", input);
557
+ }
558
+ };
559
+ }
560
+ // ── Target ────────────────────────────────────────────────────
561
+ get target() {
562
+ const c = this;
563
+ return {
564
+ list(input) {
565
+ return c.query("target.list", input);
566
+ },
567
+ create(input) {
568
+ return c.mutate("target.create", input);
569
+ },
570
+ getProgress(id) {
571
+ return c.query("target.getProgress", { id });
572
+ },
573
+ update(input) {
574
+ return c.mutate("target.update", input);
575
+ },
576
+ delete(id) {
577
+ return c.mutate("target.delete", { id });
578
+ },
579
+ myTargets() {
580
+ return c.query("target.myTargets");
581
+ }
582
+ };
583
+ }
584
+ // ── Tenant ───────────────────────────────────────────────────
585
+ get tenant() {
586
+ const c = this;
587
+ return {
588
+ list() {
589
+ return c.query("tenant.list");
590
+ },
591
+ select(input) {
592
+ return c.mutate("tenant.select", input);
593
+ },
594
+ members() {
595
+ return c.query("tenant.members");
596
+ },
597
+ inviteMember(input) {
598
+ return c.mutate("tenant.inviteMember", input);
599
+ },
600
+ removeMember(input) {
601
+ return c.mutate("tenant.removeMember", input);
602
+ },
603
+ updateMemberRole(input) {
604
+ return c.mutate("tenant.updateMemberRole", input);
605
+ },
606
+ pendingInvitations() {
607
+ return c.query("tenant.pendingInvitations");
608
+ },
609
+ revokeInvitation(input) {
610
+ return c.mutate("tenant.revokeInvitation", input);
611
+ }
612
+ };
613
+ }
614
+ // ── Document ──────────────────────────────────────────────────
615
+ get document() {
616
+ const c = this;
617
+ return {
618
+ convert(input) {
619
+ return c.mutate("document.convert", input);
620
+ }
621
+ };
622
+ }
623
+ // ── Quotation ─────────────────────────────────────────────────
624
+ get quotation() {
625
+ const c = this;
626
+ return {
627
+ list(input) {
628
+ return c.query("quotation.list", input);
629
+ },
630
+ getById(input) {
631
+ return c.query("quotation.getById", input);
632
+ },
633
+ create(input) {
634
+ return c.mutate("quotation.create", input);
635
+ },
636
+ updateStatus(input) {
637
+ return c.mutate("quotation.updateStatus", input);
638
+ },
639
+ delete(input) {
640
+ return c.mutate("quotation.delete", input);
641
+ }
642
+ };
643
+ }
644
+ // ── Credit Note ───────────────────────────────────────────────
645
+ get creditNote() {
646
+ const c = this;
647
+ return {
648
+ list(input) {
649
+ return c.query("creditNote.list", input);
650
+ },
651
+ getById(input) {
652
+ return c.query("creditNote.getById", input);
653
+ },
654
+ create(input) {
655
+ return c.mutate("creditNote.create", input);
656
+ },
657
+ updateStatus(input) {
658
+ return c.mutate("creditNote.updateStatus", input);
659
+ },
660
+ delete(input) {
661
+ return c.mutate("creditNote.delete", input);
662
+ }
663
+ };
664
+ }
665
+ // ── Debit Note ────────────────────────────────────────────────
666
+ get debitNote() {
667
+ const c = this;
668
+ return {
669
+ list(input) {
670
+ return c.query("debitNote.list", input);
671
+ },
672
+ getById(input) {
673
+ return c.query("debitNote.getById", input);
674
+ },
675
+ create(input) {
676
+ return c.mutate("debitNote.create", input);
677
+ },
678
+ updateStatus(input) {
679
+ return c.mutate("debitNote.updateStatus", input);
680
+ },
681
+ delete(input) {
682
+ return c.mutate("debitNote.delete", input);
683
+ }
684
+ };
685
+ }
686
+ // ── Delivery Challan ──────────────────────────────────────────
687
+ get deliveryChallan() {
688
+ const c = this;
689
+ return {
690
+ list(input) {
691
+ return c.query("deliveryChallan.list", input);
692
+ },
693
+ getById(input) {
694
+ return c.query("deliveryChallan.getById", input);
695
+ },
696
+ create(input) {
697
+ return c.mutate("deliveryChallan.create", input);
698
+ },
699
+ updateStatus(input) {
700
+ return c.mutate("deliveryChallan.updateStatus", input);
701
+ },
702
+ delete(input) {
703
+ return c.mutate("deliveryChallan.delete", input);
704
+ }
705
+ };
706
+ }
707
+ // ── Proforma ──────────────────────────────────────────────────
708
+ get proforma() {
709
+ const c = this;
710
+ return {
711
+ list(input) {
712
+ return c.query("proforma.list", input);
713
+ },
714
+ getById(input) {
715
+ return c.query("proforma.getById", input);
716
+ },
717
+ create(input) {
718
+ return c.mutate("proforma.create", input);
719
+ },
720
+ updateStatus(input) {
721
+ return c.mutate("proforma.updateStatus", input);
722
+ },
723
+ delete(input) {
724
+ return c.mutate("proforma.delete", input);
725
+ }
726
+ };
727
+ }
728
+ // ── Sales Return ──────────────────────────────────────────────
729
+ get salesReturn() {
730
+ const c = this;
731
+ return {
732
+ list(input) {
733
+ return c.query("salesReturn.list", input);
734
+ },
735
+ getById(input) {
736
+ return c.query("salesReturn.getById", input);
737
+ },
738
+ create(input) {
739
+ return c.mutate("salesReturn.create", input);
740
+ },
741
+ updateStatus(input) {
742
+ return c.mutate("salesReturn.updateStatus", input);
743
+ },
744
+ delete(input) {
745
+ return c.mutate("salesReturn.delete", input);
746
+ }
747
+ };
748
+ }
749
+ // ── Purchase Return ───────────────────────────────────────────
750
+ get purchaseReturn() {
751
+ const c = this;
752
+ return {
753
+ list(input) {
754
+ return c.query("purchaseReturn.list", input);
755
+ },
756
+ getById(input) {
757
+ return c.query("purchaseReturn.getById", input);
758
+ },
759
+ create(input) {
760
+ return c.mutate("purchaseReturn.create", input);
761
+ },
762
+ updateStatus(input) {
763
+ return c.mutate("purchaseReturn.updateStatus", input);
764
+ },
765
+ delete(input) {
766
+ return c.mutate("purchaseReturn.delete", input);
767
+ }
768
+ };
769
+ }
770
+ // ── Recurring Invoice ─────────────────────────────────────────
771
+ get recurringInvoice() {
772
+ const c = this;
773
+ return {
774
+ list(input) {
775
+ return c.query("recurringInvoice.list", input);
776
+ },
777
+ getById(id) {
778
+ return c.query("recurringInvoice.getById", { id });
779
+ },
780
+ create(input) {
781
+ return c.mutate("recurringInvoice.create", input);
782
+ },
783
+ update(id, data) {
784
+ return c.mutate("recurringInvoice.update", { id, data });
785
+ },
786
+ delete(id) {
787
+ return c.mutate("recurringInvoice.delete", { id });
788
+ },
789
+ pause(id) {
790
+ return c.mutate("recurringInvoice.pause", { id });
791
+ },
792
+ resume(id) {
793
+ return c.mutate("recurringInvoice.resume", { id });
794
+ },
795
+ runNow(id) {
796
+ return c.mutate("recurringInvoice.runNow", { id });
797
+ },
798
+ executionHistory(templateId, page, limit) {
799
+ return c.query("recurringInvoice.executionHistory", { templateId, page, limit });
800
+ },
801
+ planUsage() {
802
+ return c.query("recurringInvoice.planUsage");
803
+ },
804
+ suggestions() {
805
+ return c.query("recurringInvoice.suggestions");
806
+ }
807
+ };
808
+ }
809
+ // ── API Key ───────────────────────────────────────────────────
810
+ get apiKey() {
811
+ const c = this;
812
+ return {
813
+ list() {
814
+ return c.query("apiKey.list");
815
+ },
816
+ create(input) {
817
+ return c.mutate("apiKey.create", input);
818
+ },
819
+ revoke(input) {
820
+ return c.mutate("apiKey.revoke", input);
821
+ }
822
+ };
823
+ }
824
+ // ── Import ────────────────────────────────────────────────────
825
+ get import() {
826
+ const c = this;
827
+ return {
828
+ importParties(input) {
829
+ return c.mutate("import.importParties", input);
830
+ },
831
+ importItems(input) {
832
+ return c.mutate("import.importItems", input);
833
+ },
834
+ importInvoices(input) {
835
+ return c.mutate("import.importInvoices", input);
836
+ },
837
+ importPayments(input) {
838
+ return c.mutate("import.importPayments", input);
839
+ }
840
+ };
841
+ }
842
+ };
843
+
844
+ export {
845
+ HisaaboApiError,
846
+ formatHisaaboError,
847
+ HisaaboClient
848
+ };