@hisaabo/cli 0.9.0 → 0.10.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.
- package/README.md +154 -4
- package/dist/bin/{audit-trail-IJ6SKACR.js → audit-trail-RTPTWZAL.js} +12 -15
- package/dist/bin/{categories-O6TODPAH.js → categories-JJDTOT5T.js} +3 -3
- package/dist/bin/{check-slug-P7RFU6OP.js → check-slug-5L2VDAEN.js} +16 -4
- package/dist/bin/chunk-2DDIXPNI.js +1512 -0
- package/dist/bin/chunk-ALOHN6GR.js +78 -0
- package/dist/bin/{chunk-QUITS2FE.js → chunk-ESX7V56A.js} +95 -20
- package/dist/bin/chunk-M7DVLVD5.js +245 -0
- package/dist/bin/{chunk-WDN7RIE3.js → chunk-VXEEFNIY.js} +133 -47
- package/dist/bin/client-NFYNYEDI.js +17 -0
- package/dist/bin/{collection-efficiency-DA5RWG3V.js → collection-efficiency-UF3AJPQB.js} +12 -56
- package/dist/bin/{config-4LLNT4SH.js → config-7HVBRHL3.js} +2 -2
- package/dist/bin/{create-C5INBPQO.js → create-2BZQLXQA.js} +18 -9
- package/dist/bin/{default-account-2GMQ7ZA4.js → default-account-MR6O5LPT.js} +7 -13
- package/dist/bin/{expenses-S2YVA5UT.js → expenses-CU6JGDVX.js} +12 -11
- package/dist/bin/{export-YOOODNVX.js → export-GFYQIQLT.js} +9 -24
- package/dist/bin/{export-6PMJ2YVL.js → export-WS24LYNH.js} +47 -11
- package/dist/bin/{factory-6MUCSXTL.js → factory-JSEQCPY3.js} +51 -57
- package/dist/bin/{get-GMQRROK2.js → get-HGMB7T6Y.js} +5 -4
- package/dist/bin/{get-ZV3SC2VY.js → get-KAOGGRJR.js} +4 -4
- package/dist/bin/hisaabo.js +2024 -837
- package/dist/bin/{import-UUHMLCKX.js → import-6CEMNCTM.js} +30 -33
- package/dist/bin/{invitations-OVORTTMF.js → invitations-LASABD2X.js} +11 -14
- package/dist/bin/{invite-GGHBZY4U.js → invite-VCBXS7VY.js} +13 -15
- package/dist/bin/{invoice-breakdown-32XXAZDP.js → invoice-breakdown-3XXSYA77.js} +12 -37
- package/dist/bin/{items-6NOIMH6B.js → items-PJPN6ZX3.js} +11 -10
- package/dist/bin/{items-toggle-L6W6QKQD.js → items-toggle-53C35MJU.js} +6 -5
- package/dist/bin/{list-RAR56EMQ.js → list-63EKE6DT.js} +13 -16
- package/dist/bin/{list-OXAVDXH7.js → list-7OSZX6C7.js} +5 -5
- package/dist/bin/{list-FC5JHKHD.js → list-OOROCQR2.js} +11 -12
- package/dist/bin/{members-Y6XJVHHR.js → members-SPHU5F4M.js} +7 -7
- package/dist/bin/monthly-comparison-3FFJT63K.js +79 -0
- package/dist/bin/{order-cancel-QRTCNART.js → order-cancel-RW4NYHKN.js} +8 -18
- package/dist/bin/{order-confirm-LGQOMC4O.js → order-confirm-NXFL2EIQ.js} +7 -15
- package/dist/bin/{order-get-4XAQCRYV.js → order-get-QPSOY2RT.js} +11 -11
- package/dist/bin/{order-update-KZY4H2UR.js → order-update-7DWKEROO.js} +4 -4
- package/dist/bin/{output-NUOL7KJW.js → output-XFDIL3A6.js} +5 -1
- package/dist/bin/{payment-modes-DY2ZEMK7.js → payment-modes-Z5WV3E3O.js} +12 -27
- package/dist/bin/{profit-loss-5GJBG3PL.js → profit-loss-AOISAJ56.js} +14 -13
- package/dist/bin/{receivables-aging-6A7XJKDT.js → receivables-aging-5JHFECGB.js} +13 -66
- package/dist/bin/{remove-ZBX34TIQ.js → remove-TC4UWMOL.js} +7 -15
- package/dist/bin/{revoke-ZTAMW2Q2.js → revoke-QHLNPGI5.js} +7 -3
- package/dist/bin/{revoke-XDNOA2GJ.js → revoke-SXVNALYQ.js} +7 -15
- package/dist/bin/{revoke-all-365NRBOA.js → revoke-all-CYW6A5UE.js} +8 -4
- package/dist/bin/{revoke-invitation-PQH7XNYA.js → revoke-invitation-Z33EUJTS.js} +7 -3
- package/dist/bin/safety-TPD2P7I5.js +18 -0
- package/dist/bin/{sales-trend-D6PQ7MHY.js → sales-trend-WCW6X5BI.js} +16 -16
- package/dist/bin/sequence-HOQ4PQRK.js +56 -0
- package/dist/bin/{store-SVRZBUFO.js → store-DDMHTNTO.js} +15 -8
- package/dist/bin/{summary-H6U7O5GJ.js → summary-TYAL2D3Q.js} +7 -5
- package/dist/bin/{top-customers-ATBN6RDI.js → top-customers-GMIS6GC3.js} +13 -11
- package/dist/bin/{top-items-XXU6KYTC.js → top-items-BK54JO3G.js} +16 -14
- package/dist/bin/{top-outstanding-JTQNGGW4.js → top-outstanding-L4NRJ6NE.js} +9 -11
- package/dist/bin/{unpaid-invoices-BTNQFWCH.js → unpaid-invoices-CEUFEYH7.js} +8 -8
- package/dist/bin/{untracked-PAMEDJ6Y.js → untracked-T6DIDMDQ.js} +9 -9
- package/dist/bin/{update-EK4NJWU4.js → update-EPNB2U74.js} +4 -4
- package/dist/bin/{update-EGHPFXLK.js → update-I2DZRVLR.js} +10 -17
- package/dist/bin/{update-6ZMX2OYX.js → update-MFNOVS6D.js} +4 -4
- package/dist/bin/{update-role-24PDTNFK.js → update-role-D2ETEL2Q.js} +7 -4
- package/dist/bin/{update-settings-AASI6WZX.js → update-settings-UGXLQRYI.js} +15 -9
- package/package.json +8 -7
- package/dist/bin/chunk-NO4FIFMS.js +0 -176
- package/dist/bin/chunk-ZPYC767N.js +0 -157
- package/dist/bin/client-36JX5MR3.js +0 -11
- package/dist/bin/monthly-comparison-IAUZ6SBJ.js +0 -176
- package/dist/bin/sequence-KZWADVD7.js +0 -66
|
@@ -48,6 +48,14 @@ function normalizeTrpcError(raw) {
|
|
|
48
48
|
}
|
|
49
49
|
return { code: "api_error", message };
|
|
50
50
|
}
|
|
51
|
+
function requestTimeoutMs() {
|
|
52
|
+
const n = Number(process.env["HISAABO_TIMEOUT_MS"]);
|
|
53
|
+
return Number.isFinite(n) && n > 0 ? n : 3e4;
|
|
54
|
+
}
|
|
55
|
+
function transferTimeoutMs() {
|
|
56
|
+
const n = Number(process.env["HISAABO_TRANSFER_TIMEOUT_MS"]);
|
|
57
|
+
return Number.isFinite(n) && n > 0 ? n : 30 * 6e4;
|
|
58
|
+
}
|
|
51
59
|
var HisaaboClient = class {
|
|
52
60
|
constructor(config) {
|
|
53
61
|
this.config = config;
|
|
@@ -56,10 +64,11 @@ var HisaaboClient = class {
|
|
|
56
64
|
apiUrl;
|
|
57
65
|
buildHeaders() {
|
|
58
66
|
const headers = {
|
|
59
|
-
"Authorization": `Bearer ${this.config.token}`,
|
|
60
67
|
"x-tenant-id": this.config.tenantId,
|
|
61
|
-
"x-client-type": "cli"
|
|
68
|
+
"x-client-type": "cli",
|
|
69
|
+
"X-Hisaabo-Client": "cli"
|
|
62
70
|
};
|
|
71
|
+
if (this.config.token) headers["Authorization"] = `Bearer ${this.config.token}`;
|
|
63
72
|
if (this.config.businessId) {
|
|
64
73
|
headers["x-business-id"] = this.config.businessId;
|
|
65
74
|
}
|
|
@@ -81,7 +90,15 @@ var HisaaboClient = class {
|
|
|
81
90
|
message: `Rate limited. Try again in ${Math.ceil(retryMs / 1e3)}s.`
|
|
82
91
|
});
|
|
83
92
|
}
|
|
84
|
-
|
|
93
|
+
let body;
|
|
94
|
+
try {
|
|
95
|
+
body = await res.json();
|
|
96
|
+
} catch {
|
|
97
|
+
throw new HisaaboApiError({
|
|
98
|
+
code: "api_error",
|
|
99
|
+
message: `Unexpected non-JSON response from API (HTTP ${res.status})`
|
|
100
|
+
});
|
|
101
|
+
}
|
|
85
102
|
if (typeof body !== "object" || body === null) {
|
|
86
103
|
throw new HisaaboApiError({ code: "api_error", message: "Unexpected response format from API" });
|
|
87
104
|
}
|
|
@@ -96,7 +113,8 @@ var HisaaboClient = class {
|
|
|
96
113
|
const data = result["data"];
|
|
97
114
|
return superjson.deserialize(data);
|
|
98
115
|
}
|
|
99
|
-
async query(path,
|
|
116
|
+
async query(path, ...args) {
|
|
117
|
+
const input = args[0];
|
|
100
118
|
const maxRetries = 2;
|
|
101
119
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
102
120
|
try {
|
|
@@ -104,7 +122,10 @@ var HisaaboClient = class {
|
|
|
104
122
|
if (input !== void 0) {
|
|
105
123
|
url.searchParams.set("input", JSON.stringify(superjson.serialize(input)));
|
|
106
124
|
}
|
|
107
|
-
const res = await fetch(url.toString(), {
|
|
125
|
+
const res = await fetch(url.toString(), {
|
|
126
|
+
headers: this.buildHeaders(),
|
|
127
|
+
signal: AbortSignal.timeout(requestTimeoutMs())
|
|
128
|
+
});
|
|
108
129
|
return await this.unwrap(res);
|
|
109
130
|
} catch (e) {
|
|
110
131
|
if (e instanceof HisaaboApiError && e.hisaaboError.code === "rate_limited" && attempt < maxRetries) {
|
|
@@ -118,14 +139,16 @@ var HisaaboClient = class {
|
|
|
118
139
|
}
|
|
119
140
|
throw new HisaaboApiError({ code: "api_error", message: "Max retries exceeded" });
|
|
120
141
|
}
|
|
121
|
-
async mutate(path,
|
|
142
|
+
async mutate(path, ...args) {
|
|
143
|
+
const input = args[0];
|
|
122
144
|
try {
|
|
123
145
|
const res = await fetch(`${this.config.apiUrl}/api/trpc/${path}`, {
|
|
124
146
|
method: "POST",
|
|
125
147
|
headers: { ...this.buildHeaders(), "Content-Type": "application/json" },
|
|
126
|
-
body: JSON.stringify(superjson.serialize(input))
|
|
148
|
+
body: JSON.stringify(superjson.serialize(input)),
|
|
149
|
+
signal: AbortSignal.timeout(requestTimeoutMs())
|
|
127
150
|
});
|
|
128
|
-
return this.unwrap(res);
|
|
151
|
+
return await this.unwrap(res);
|
|
129
152
|
} catch (e) {
|
|
130
153
|
if (e instanceof HisaaboApiError) throw e;
|
|
131
154
|
throw new HisaaboApiError({ code: "network_error", message: String(e instanceof Error ? e.message : e) });
|
|
@@ -135,23 +158,33 @@ var HisaaboClient = class {
|
|
|
135
158
|
get auth() {
|
|
136
159
|
const c = this;
|
|
137
160
|
return {
|
|
138
|
-
|
|
139
|
-
return c.mutate("auth.
|
|
161
|
+
nativeStart(input) {
|
|
162
|
+
return c.mutate("auth.nativeStart", {
|
|
163
|
+
client: "cli",
|
|
164
|
+
codeChallengeMethod: "S256",
|
|
165
|
+
...input
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
nativeExchange(input) {
|
|
169
|
+
return c.mutate("auth.nativeExchange", input).then((r) => {
|
|
170
|
+
if (!r.sessionToken) throw new HisaaboApiError({ code: "api_error", message: "Sign-in response did not include a session" });
|
|
171
|
+
return { sessionToken: r.sessionToken, user: r.user };
|
|
172
|
+
});
|
|
140
173
|
},
|
|
141
174
|
logout() {
|
|
142
|
-
return c.mutate("auth.logout"
|
|
175
|
+
return c.mutate("auth.logout");
|
|
143
176
|
},
|
|
144
177
|
me() {
|
|
145
|
-
return c.query("auth.me")
|
|
178
|
+
return c.query("auth.me").then((r) => {
|
|
179
|
+
if (!r.user) throw new HisaaboApiError({ code: "unauthorized", message: "Not authenticated" });
|
|
180
|
+
return { ...r.user, role: r.role ?? "", tenantId: r.tenantId, tenantName: r.tenantName };
|
|
181
|
+
});
|
|
146
182
|
},
|
|
147
183
|
completeProfile(input) {
|
|
148
184
|
return c.mutate("auth.completeProfile", input);
|
|
149
185
|
},
|
|
150
186
|
logoutAll() {
|
|
151
|
-
return c.mutate("auth.logoutAll"
|
|
152
|
-
},
|
|
153
|
-
register(input) {
|
|
154
|
-
return c.mutate("auth.register", input);
|
|
187
|
+
return c.mutate("auth.logoutAll");
|
|
155
188
|
},
|
|
156
189
|
updateName(input) {
|
|
157
190
|
return c.mutate("auth.updateName", input);
|
|
@@ -171,14 +204,14 @@ var HisaaboClient = class {
|
|
|
171
204
|
list() {
|
|
172
205
|
return c.query("business.list");
|
|
173
206
|
},
|
|
174
|
-
get() {
|
|
175
|
-
return c.query("business.getById");
|
|
207
|
+
get(id) {
|
|
208
|
+
return c.query("business.getById", { id });
|
|
176
209
|
},
|
|
177
210
|
create(input) {
|
|
178
211
|
return c.mutate("business.create", input);
|
|
179
212
|
},
|
|
180
|
-
update(
|
|
181
|
-
return c.mutate("business.update",
|
|
213
|
+
update(id, data) {
|
|
214
|
+
return c.mutate("business.update", { id, data });
|
|
182
215
|
},
|
|
183
216
|
updateSequenceNumber(input) {
|
|
184
217
|
return c.mutate("business.updateSequenceNumber", input);
|
|
@@ -187,7 +220,7 @@ var HisaaboClient = class {
|
|
|
187
220
|
return c.query("business.auditTrail", input);
|
|
188
221
|
},
|
|
189
222
|
exportData() {
|
|
190
|
-
return c.mutate("business.exportData"
|
|
223
|
+
return c.mutate("business.exportData");
|
|
191
224
|
}
|
|
192
225
|
};
|
|
193
226
|
}
|
|
@@ -273,9 +306,6 @@ var HisaaboClient = class {
|
|
|
273
306
|
adjustStock(input) {
|
|
274
307
|
return c.mutate("item.adjustStock", input);
|
|
275
308
|
},
|
|
276
|
-
categories() {
|
|
277
|
-
return c.query("item.categories");
|
|
278
|
-
},
|
|
279
309
|
createVariant(input) {
|
|
280
310
|
return c.mutate("item.createVariant", input);
|
|
281
311
|
},
|
|
@@ -309,8 +339,14 @@ var HisaaboClient = class {
|
|
|
309
339
|
salesStats(input) {
|
|
310
340
|
return c.query("item.salesStats", input);
|
|
311
341
|
},
|
|
342
|
+
priceSummary(input) {
|
|
343
|
+
return c.query("item.priceSummary", input);
|
|
344
|
+
},
|
|
312
345
|
stockMovements(input) {
|
|
313
346
|
return c.query("item.stockMovements", input);
|
|
347
|
+
},
|
|
348
|
+
stockSummary(input) {
|
|
349
|
+
return c.query("item.stockSummary", input);
|
|
314
350
|
}
|
|
315
351
|
};
|
|
316
352
|
}
|
|
@@ -529,31 +565,31 @@ var HisaaboClient = class {
|
|
|
529
565
|
return c.query("reports.collectionEfficiency", input);
|
|
530
566
|
},
|
|
531
567
|
trialBalance(input) {
|
|
532
|
-
return c.query("reports.trialBalance", input
|
|
568
|
+
return c.query("reports.trialBalance", input);
|
|
533
569
|
},
|
|
534
570
|
balanceSheet(input) {
|
|
535
|
-
return c.query("reports.balanceSheet", input
|
|
571
|
+
return c.query("reports.balanceSheet", input);
|
|
536
572
|
},
|
|
537
573
|
profitAndLoss(input) {
|
|
538
|
-
return c.query("reports.profitAndLoss", input
|
|
574
|
+
return c.query("reports.profitAndLoss", input);
|
|
539
575
|
},
|
|
540
576
|
cashFlowStatement(input) {
|
|
541
|
-
return c.query("reports.cashFlowStatement", input
|
|
577
|
+
return c.query("reports.cashFlowStatement", input);
|
|
542
578
|
},
|
|
543
579
|
generalLedger(input) {
|
|
544
580
|
return c.query("reports.generalLedger", input);
|
|
545
581
|
},
|
|
546
582
|
comparativeTrialBalance(input) {
|
|
547
|
-
return c.query("reports.comparativeTrialBalance", input
|
|
583
|
+
return c.query("reports.comparativeTrialBalance", input);
|
|
548
584
|
},
|
|
549
585
|
comparativeBalanceSheet(input) {
|
|
550
|
-
return c.query("reports.comparativeBalanceSheet", input
|
|
586
|
+
return c.query("reports.comparativeBalanceSheet", input);
|
|
551
587
|
},
|
|
552
588
|
comparativeProfitAndLoss(input) {
|
|
553
|
-
return c.query("reports.comparativeProfitAndLoss", input
|
|
589
|
+
return c.query("reports.comparativeProfitAndLoss", input);
|
|
554
590
|
},
|
|
555
591
|
tallyExport(input) {
|
|
556
|
-
return c.query("reports.tallyExport", input
|
|
592
|
+
return c.query("reports.tallyExport", input);
|
|
557
593
|
}
|
|
558
594
|
};
|
|
559
595
|
}
|
|
@@ -593,7 +629,39 @@ var HisaaboClient = class {
|
|
|
593
629
|
}
|
|
594
630
|
};
|
|
595
631
|
}
|
|
632
|
+
// ── TDS sections ──────────────────────────────────────────────
|
|
633
|
+
get tdsSection() {
|
|
634
|
+
const c = this;
|
|
635
|
+
return {
|
|
636
|
+
list(input) {
|
|
637
|
+
return c.query("tdsSection.list", input);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
596
641
|
// ── Target ────────────────────────────────────────────────────
|
|
642
|
+
get notification() {
|
|
643
|
+
const c = this;
|
|
644
|
+
return {
|
|
645
|
+
list(input) {
|
|
646
|
+
return c.query("notification.list", input);
|
|
647
|
+
},
|
|
648
|
+
unreadCounts() {
|
|
649
|
+
return c.query("notification.unreadCounts");
|
|
650
|
+
},
|
|
651
|
+
markRead(ids) {
|
|
652
|
+
return c.mutate("notification.markRead", { ids });
|
|
653
|
+
},
|
|
654
|
+
markAllRead() {
|
|
655
|
+
return c.mutate("notification.markAllRead");
|
|
656
|
+
},
|
|
657
|
+
getPreferences(businessId) {
|
|
658
|
+
return c.query("notification.getPreferences", { businessId });
|
|
659
|
+
},
|
|
660
|
+
updatePreference(input) {
|
|
661
|
+
return c.mutate("notification.updatePreference", input);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
}
|
|
597
665
|
get target() {
|
|
598
666
|
const c = this;
|
|
599
667
|
return {
|
|
@@ -880,7 +948,7 @@ var HisaaboClient = class {
|
|
|
880
948
|
const c = this;
|
|
881
949
|
return {
|
|
882
950
|
list(input) {
|
|
883
|
-
return c.query("journal.list", input
|
|
951
|
+
return c.query("journal.list", input);
|
|
884
952
|
},
|
|
885
953
|
getById(id) {
|
|
886
954
|
return c.query("journal.getById", { id });
|
|
@@ -919,7 +987,7 @@ var HisaaboClient = class {
|
|
|
919
987
|
return c.query("itc.dashboard", input ?? {});
|
|
920
988
|
},
|
|
921
989
|
ledger(input) {
|
|
922
|
-
return c.query("itc.ledger", input
|
|
990
|
+
return c.query("itc.ledger", input);
|
|
923
991
|
},
|
|
924
992
|
agingAlerts() {
|
|
925
993
|
return c.query("itc.agingAlerts");
|
|
@@ -934,7 +1002,7 @@ var HisaaboClient = class {
|
|
|
934
1002
|
return c.mutate("itc.recordUtilization", input);
|
|
935
1003
|
},
|
|
936
1004
|
gstr3bTable4(input) {
|
|
937
|
-
return c.query("itc.gstr3bTable4", input
|
|
1005
|
+
return c.query("itc.gstr3bTable4", input);
|
|
938
1006
|
}
|
|
939
1007
|
};
|
|
940
1008
|
}
|
|
@@ -943,13 +1011,13 @@ var HisaaboClient = class {
|
|
|
943
1011
|
const c = this;
|
|
944
1012
|
return {
|
|
945
1013
|
importList(input) {
|
|
946
|
-
return c.query("bankRecon.importList", input
|
|
1014
|
+
return c.query("bankRecon.importList", input);
|
|
947
1015
|
},
|
|
948
1016
|
importDetail(importId) {
|
|
949
1017
|
return c.query("bankRecon.importDetail", { importId });
|
|
950
1018
|
},
|
|
951
|
-
summary(
|
|
952
|
-
return c.query("bankRecon.summary",
|
|
1019
|
+
summary(input) {
|
|
1020
|
+
return c.query("bankRecon.summary", input);
|
|
953
1021
|
},
|
|
954
1022
|
lines(input) {
|
|
955
1023
|
return c.query("bankRecon.lines", input);
|
|
@@ -991,7 +1059,7 @@ var HisaaboClient = class {
|
|
|
991
1059
|
const c = this;
|
|
992
1060
|
return {
|
|
993
1061
|
dashboard(input) {
|
|
994
|
-
return c.query("eInvoice.dashboard", input
|
|
1062
|
+
return c.query("eInvoice.dashboard", input);
|
|
995
1063
|
},
|
|
996
1064
|
generate(input) {
|
|
997
1065
|
return c.mutate("eInvoice.generate", input);
|
|
@@ -1002,8 +1070,8 @@ var HisaaboClient = class {
|
|
|
1002
1070
|
retryFailed(input) {
|
|
1003
1071
|
return c.mutate("eInvoice.retryFailed", input);
|
|
1004
1072
|
},
|
|
1005
|
-
bulkRetry(
|
|
1006
|
-
return c.mutate("eInvoice.bulkRetry"
|
|
1073
|
+
bulkRetry() {
|
|
1074
|
+
return c.mutate("eInvoice.bulkRetry");
|
|
1007
1075
|
},
|
|
1008
1076
|
getStatus(invoiceId) {
|
|
1009
1077
|
return c.query("eInvoice.getStatus", { invoiceId });
|
|
@@ -1015,7 +1083,7 @@ var HisaaboClient = class {
|
|
|
1015
1083
|
const c = this;
|
|
1016
1084
|
return {
|
|
1017
1085
|
dashboard(input) {
|
|
1018
|
-
return c.query("ewayBill.dashboard", input
|
|
1086
|
+
return c.query("ewayBill.dashboard", input);
|
|
1019
1087
|
},
|
|
1020
1088
|
generate(input) {
|
|
1021
1089
|
return c.mutate("ewayBill.generate", input);
|
|
@@ -1032,8 +1100,8 @@ var HisaaboClient = class {
|
|
|
1032
1100
|
getByInvoice(invoiceId) {
|
|
1033
1101
|
return c.query("ewayBill.getByInvoice", { invoiceId });
|
|
1034
1102
|
},
|
|
1035
|
-
expiringList(
|
|
1036
|
-
return c.query("ewayBill.expiringList"
|
|
1103
|
+
expiringList() {
|
|
1104
|
+
return c.query("ewayBill.expiringList");
|
|
1037
1105
|
}
|
|
1038
1106
|
};
|
|
1039
1107
|
}
|
|
@@ -1062,8 +1130,8 @@ var HisaaboClient = class {
|
|
|
1062
1130
|
get account() {
|
|
1063
1131
|
const c = this;
|
|
1064
1132
|
return {
|
|
1065
|
-
list(
|
|
1066
|
-
return c.query("account.list"
|
|
1133
|
+
list() {
|
|
1134
|
+
return c.query("account.list");
|
|
1067
1135
|
},
|
|
1068
1136
|
create(input) {
|
|
1069
1137
|
return c.mutate("account.create", input);
|
|
@@ -1104,9 +1172,27 @@ var HisaaboClient = class {
|
|
|
1104
1172
|
};
|
|
1105
1173
|
}
|
|
1106
1174
|
};
|
|
1175
|
+
var NOTIFICATION_CHANNELS = [
|
|
1176
|
+
"money_in",
|
|
1177
|
+
"collections",
|
|
1178
|
+
"sales",
|
|
1179
|
+
"store",
|
|
1180
|
+
"payables",
|
|
1181
|
+
"banking",
|
|
1182
|
+
"compliance",
|
|
1183
|
+
"inventory",
|
|
1184
|
+
"targets",
|
|
1185
|
+
"security",
|
|
1186
|
+
"digest",
|
|
1187
|
+
"general",
|
|
1188
|
+
"promotions"
|
|
1189
|
+
];
|
|
1107
1190
|
|
|
1108
1191
|
export {
|
|
1109
1192
|
HisaaboApiError,
|
|
1110
1193
|
formatHisaaboError,
|
|
1111
|
-
|
|
1194
|
+
requestTimeoutMs,
|
|
1195
|
+
transferTimeoutMs,
|
|
1196
|
+
HisaaboClient,
|
|
1197
|
+
NOTIFICATION_CHANNELS
|
|
1112
1198
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
HisaaboApiError,
|
|
4
|
+
HisaaboClient,
|
|
5
|
+
NOTIFICATION_CHANNELS,
|
|
6
|
+
formatHisaaboError,
|
|
7
|
+
requestTimeoutMs,
|
|
8
|
+
transferTimeoutMs
|
|
9
|
+
} from "./chunk-VXEEFNIY.js";
|
|
10
|
+
export {
|
|
11
|
+
HisaaboApiError,
|
|
12
|
+
HisaaboClient,
|
|
13
|
+
NOTIFICATION_CHANNELS,
|
|
14
|
+
formatHisaaboError,
|
|
15
|
+
requestTimeoutMs,
|
|
16
|
+
transferTimeoutMs
|
|
17
|
+
};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
apiFrom,
|
|
4
|
+
apiTo,
|
|
3
5
|
formatAmount,
|
|
4
6
|
fyStart,
|
|
5
7
|
monthEnd,
|
|
6
8
|
monthStart,
|
|
7
9
|
todayISO
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M7DVLVD5.js";
|
|
9
11
|
import {
|
|
10
12
|
HisaaboApiError,
|
|
11
13
|
HisaaboClient
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VXEEFNIY.js";
|
|
13
15
|
import {
|
|
14
16
|
requireAuth
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ESX7V56A.js";
|
|
16
18
|
import {
|
|
17
19
|
EXIT,
|
|
18
20
|
fatalError,
|
|
@@ -20,9 +22,8 @@ import {
|
|
|
20
22
|
outputCSV,
|
|
21
23
|
outputJSON,
|
|
22
24
|
outputTSV,
|
|
23
|
-
outputTable,
|
|
24
25
|
termWidth
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2DDIXPNI.js";
|
|
26
27
|
|
|
27
28
|
// src/commands/dashboard/collection-efficiency.ts
|
|
28
29
|
import chalk from "chalk";
|
|
@@ -48,31 +49,22 @@ async function dashboardCollectionEfficiencyCommand(opts) {
|
|
|
48
49
|
toDate = todayISO();
|
|
49
50
|
}
|
|
50
51
|
try {
|
|
51
|
-
const data = await client.dashboard.collectionEfficiency({ fromDate, toDate });
|
|
52
|
+
const data = await client.dashboard.collectionEfficiency({ fromDate: apiFrom(fromDate), toDate: apiTo(toDate) });
|
|
52
53
|
if (opts.json) {
|
|
53
54
|
outputJSON(data);
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const collectionRate = parseFloat(String(d["collectionRate"] ?? d["rate"] ?? (totalInvoiced > 0 ? (totalCollected / totalInvoiced * 100).toFixed(2) : "0")));
|
|
61
|
-
const dso = parseFloat(String(d["dso"] ?? d["daysSalesOutstanding"] ?? "0"));
|
|
62
|
-
const aging = d["aging"] ?? d["agingBreakdown"] ?? d["breakdown"] ?? null;
|
|
57
|
+
const totalInvoiced = parseFloat(data.totalInvoiced);
|
|
58
|
+
const totalCollected = parseFloat(data.totalCollected);
|
|
59
|
+
const outstanding = totalInvoiced - totalCollected;
|
|
60
|
+
const collectionRate = data.efficiencyPct;
|
|
63
61
|
if (opts.format === "tsv" || opts.format === "csv") {
|
|
64
62
|
const rows = [
|
|
65
63
|
{ metric: "Total Invoiced", value: formatAmount(totalInvoiced) },
|
|
66
64
|
{ metric: "Total Collected", value: formatAmount(totalCollected) },
|
|
67
65
|
{ metric: "Outstanding", value: formatAmount(outstanding) },
|
|
68
|
-
{ metric: "Collection Rate", value: `${collectionRate.toFixed(1)}%` }
|
|
69
|
-
{ metric: "DSO (days)", value: dso > 0 ? String(Math.round(dso)) : "-" }
|
|
66
|
+
{ metric: "Collection Rate", value: `${collectionRate.toFixed(1)}%` }
|
|
70
67
|
];
|
|
71
|
-
if (aging) {
|
|
72
|
-
for (const [k, v] of Object.entries(aging)) {
|
|
73
|
-
rows.push({ metric: `Aging: ${k}`, value: formatAmount(String(v)) });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
68
|
const columns = [
|
|
77
69
|
{ key: "metric", header: "Metric", align: "left" },
|
|
78
70
|
{ key: "value", header: "Value", align: "right" }
|
|
@@ -114,43 +106,7 @@ async function dashboardCollectionEfficiencyCommand(opts) {
|
|
|
114
106
|
const rateLabel = "Collection Rate".padEnd(20).slice(0, 20);
|
|
115
107
|
process.stdout.write(` \u2502 ${hasColor() ? chalk.bold(rateLabel) : rateLabel} ${bar} ${rateStr.padStart(6)} \u2502
|
|
116
108
|
`);
|
|
117
|
-
if (dso > 0) {
|
|
118
|
-
const dsoStr = `${Math.round(dso)} days`;
|
|
119
|
-
const dsoLabel = "DSO".padEnd(20).slice(0, 20);
|
|
120
|
-
const dsoColor = dso <= 30 ? chalk.green : dso <= 60 ? chalk.yellow : chalk.red;
|
|
121
|
-
const dsoVal = hasColor() ? dsoColor(dsoStr) : dsoStr;
|
|
122
|
-
process.stdout.write(` \u2502 ${dsoLabel} ${dsoVal.padStart(innerW - 22)} \u2502
|
|
123
|
-
`);
|
|
124
|
-
}
|
|
125
|
-
if (aging && Object.keys(aging).length > 0) {
|
|
126
|
-
sep();
|
|
127
|
-
process.stdout.write(` \u2502 ${hasColor() ? chalk.bold("Aging Breakdown") : "Aging Breakdown"}${" ".repeat(innerW - 16)} \u2502
|
|
128
|
-
`);
|
|
129
|
-
const agingEntries = Object.entries(aging);
|
|
130
|
-
for (const [bucket, val] of agingEntries) {
|
|
131
|
-
const amt = parseFloat(String(val));
|
|
132
|
-
const amtStr = `\u20B9${formatAmount(amt)}`;
|
|
133
|
-
const bucketLabel = bucket.padEnd(20).slice(0, 20);
|
|
134
|
-
const isOld = /90\+|90_plus/i.test(bucket);
|
|
135
|
-
const color = isOld ? chalk.red : /31|61/.test(bucket) ? chalk.yellow : void 0;
|
|
136
|
-
const valStr = color && hasColor() ? color(amtStr) : amtStr;
|
|
137
|
-
process.stdout.write(` \u2502 ${bucketLabel.slice(0, 18)} ${valStr.padStart(innerW - 22)} \u2502
|
|
138
|
-
`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
109
|
process.stdout.write(" \u2514" + "\u2500".repeat(innerW) + "\u2518\n\n");
|
|
142
|
-
if (aging && Object.keys(aging).length > 0) {
|
|
143
|
-
const agingRows = Object.entries(aging).map(([bucket, val]) => ({
|
|
144
|
-
bucket,
|
|
145
|
-
amount: formatAmount(String(val))
|
|
146
|
-
}));
|
|
147
|
-
const agingColumns = [
|
|
148
|
-
{ key: "bucket", header: "Aging Bucket", align: "left" },
|
|
149
|
-
{ key: "amount", header: "Amount \u20B9", align: "right" }
|
|
150
|
-
];
|
|
151
|
-
outputTable(agingRows, agingColumns);
|
|
152
|
-
process.stdout.write("\n");
|
|
153
|
-
}
|
|
154
110
|
} catch (e) {
|
|
155
111
|
if (e instanceof HisaaboApiError) {
|
|
156
112
|
const err = e.hisaaboError;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HisaaboApiError,
|
|
4
4
|
HisaaboClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
6
|
import {
|
|
7
7
|
requireAuth
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
9
|
import {
|
|
10
10
|
EXIT,
|
|
11
11
|
fatalError,
|
|
12
12
|
hasColor,
|
|
13
13
|
outputJSON
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/api-key/create.ts
|
|
17
17
|
import chalk from "chalk";
|
|
@@ -21,14 +21,19 @@ async function apiKeyCreateCommand(opts) {
|
|
|
21
21
|
if (!opts.name || opts.name.trim().length === 0) {
|
|
22
22
|
fatalError("--name is required.", EXIT.USAGE);
|
|
23
23
|
}
|
|
24
|
+
const days = opts.expiresInDays === void 0 ? 90 : Number(opts.expiresInDays);
|
|
25
|
+
if (!Number.isInteger(days) || days < 1) {
|
|
26
|
+
fatalError("--expires-in-days must be a positive integer.", EXIT.USAGE);
|
|
27
|
+
}
|
|
28
|
+
const expiresAt = new Date(Date.now() + days * 24 * 60 * 60 * 1e3).toISOString();
|
|
24
29
|
try {
|
|
25
|
-
const result = await client.apiKey.create({ name: opts.name.trim() });
|
|
30
|
+
const result = await client.apiKey.create({ name: opts.name.trim(), expiresAt });
|
|
26
31
|
if (opts.json) {
|
|
27
32
|
outputJSON(result);
|
|
28
33
|
return;
|
|
29
34
|
}
|
|
30
|
-
const key = String(result
|
|
31
|
-
const id = String(result
|
|
35
|
+
const key = String(result.key);
|
|
36
|
+
const id = String(result.id);
|
|
32
37
|
if (hasColor()) {
|
|
33
38
|
process.stdout.write("\n");
|
|
34
39
|
process.stdout.write(chalk.bold.green(" \u2713 API key created successfully!\n"));
|
|
@@ -41,8 +46,10 @@ async function apiKeyCreateCommand(opts) {
|
|
|
41
46
|
process.stdout.write(" " + chalk.cyan.bold(key) + "\n");
|
|
42
47
|
process.stdout.write("\n");
|
|
43
48
|
}
|
|
44
|
-
process.stdout.write(chalk.dim(" Use it
|
|
45
|
-
process.stdout.write(chalk.dim(" Or
|
|
49
|
+
process.stdout.write(chalk.dim(" Use it by piping it to: hisaabo login --token-stdin\n"));
|
|
50
|
+
process.stdout.write(chalk.dim(" Or export it as HISAABO_TOKEN (together with HISAABO_API_URL).\n"));
|
|
51
|
+
process.stdout.write(chalk.dim(` Expires: ${expiresAt.slice(0, 10)}
|
|
52
|
+
`));
|
|
46
53
|
if (id) process.stdout.write(chalk.dim(`
|
|
47
54
|
Key ID: ${id}
|
|
48
55
|
`));
|
|
@@ -56,7 +63,9 @@ async function apiKeyCreateCommand(opts) {
|
|
|
56
63
|
${key}
|
|
57
64
|
|
|
58
65
|
`);
|
|
59
|
-
process.stdout.write(
|
|
66
|
+
process.stdout.write("Use it by piping it to: hisaabo login --token-stdin\n");
|
|
67
|
+
process.stdout.write("Or export it as HISAABO_TOKEN (together with HISAABO_API_URL).\n");
|
|
68
|
+
process.stdout.write(`Expires: ${expiresAt.slice(0, 10)}
|
|
60
69
|
`);
|
|
61
70
|
}
|
|
62
71
|
if (id) process.stdout.write(`Key ID: ${id}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HisaaboApiError,
|
|
4
4
|
HisaaboClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
6
|
import {
|
|
7
7
|
requireAuth
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
9
|
import {
|
|
10
10
|
EXIT,
|
|
11
11
|
fatalError,
|
|
12
12
|
outputJSON
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2DDIXPNI.js";
|
|
14
14
|
|
|
15
15
|
// src/commands/payment/default-account.ts
|
|
16
16
|
async function paymentDefaultAccountCommand(opts) {
|
|
@@ -31,16 +31,10 @@ async function paymentDefaultAccountCommand(opts) {
|
|
|
31
31
|
console.log(`
|
|
32
32
|
Recommended Bank Account`);
|
|
33
33
|
console.log(` ${sep}`);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (acct["bankName"]) console.log(` Bank : ${acct["bankName"]}`);
|
|
39
|
-
if (acct["accountNumber"]) console.log(` Number : ${acct["accountNumber"]}`);
|
|
40
|
-
if (acct["ifsc"]) console.log(` IFSC : ${acct["ifsc"]}`);
|
|
41
|
-
} else {
|
|
42
|
-
console.log(` ${String(result)}`);
|
|
43
|
-
}
|
|
34
|
+
console.log(` ID : ${result.id}`);
|
|
35
|
+
console.log(` Account : ${result.accountName}`);
|
|
36
|
+
console.log(` Type : ${result.accountType}`);
|
|
37
|
+
console.log(` Balance : ${result.currentBalance}`);
|
|
44
38
|
console.log();
|
|
45
39
|
} catch (e) {
|
|
46
40
|
if (e instanceof HisaaboApiError) {
|