@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.
- package/.turbo/turbo-typecheck.log +1 -1
- package/README.md +332 -0
- package/dist/bin/audit-trail-5LOCJ7XZ.js +78 -0
- package/dist/bin/categories-64WWZTND.js +47 -0
- package/dist/bin/check-slug-FLHHUDYS.js +65 -0
- package/dist/bin/chunk-4MEL44QX.js +848 -0
- package/dist/bin/chunk-FIMJZAS4.js +84 -0
- package/dist/bin/chunk-NO4FIFMS.js +176 -0
- package/dist/bin/chunk-T63VQXNM.js +156 -0
- package/dist/bin/client-5NZ23GML.js +11 -0
- package/dist/bin/collection-efficiency-U56XNVEE.js +165 -0
- package/dist/bin/config-335MN4I7.js +18 -0
- package/dist/bin/create-RPDEORDD.js +83 -0
- package/dist/bin/default-account-AE6EXZZR.js +58 -0
- package/dist/bin/expenses-5N2QSG54.js +89 -0
- package/dist/bin/export-QICOQK34.js +59 -0
- package/dist/bin/factory-KOCW2AQM.js +483 -0
- package/dist/bin/get-A43QCI2S.js +66 -0
- package/dist/bin/get-GWH6S5SJ.js +71 -0
- package/dist/bin/hisaabo.js +2302 -1510
- package/dist/bin/invitations-P3EEN5WI.js +66 -0
- package/dist/bin/invite-T3CKX53E.js +53 -0
- package/dist/bin/invoice-breakdown-FN5BEFJD.js +97 -0
- package/dist/bin/items-2OOCQKVF.js +62 -0
- package/dist/bin/items-toggle-SKZWCGJH.js +46 -0
- package/dist/bin/list-A2RKI3ZG.js +79 -0
- package/dist/bin/list-NRMBMKMI.js +90 -0
- package/dist/bin/list-T74SN6IR.js +46 -0
- package/dist/bin/members-W2GW3ODT.js +55 -0
- package/dist/bin/monthly-comparison-T34ZFOHL.js +176 -0
- package/dist/bin/order-cancel-TI27JYYD.js +55 -0
- package/dist/bin/order-confirm-VMRAMNTD.js +53 -0
- package/dist/bin/order-get-C2RBUR4O.js +88 -0
- package/dist/bin/order-update-RE3HATNF.js +60 -0
- package/dist/bin/output-NUOL7KJW.js +35 -0
- package/dist/bin/payment-modes-WOOT22I7.js +126 -0
- package/dist/bin/profit-loss-T4RESJ32.js +135 -0
- package/dist/bin/receivables-aging-6XMENEWS.js +161 -0
- package/dist/bin/remove-6QZI4JCY.js +52 -0
- package/dist/bin/revoke-AVEMPAC7.js +40 -0
- package/dist/bin/revoke-YUCFZFNR.js +52 -0
- package/dist/bin/revoke-all-LFW5WBHO.js +33 -0
- package/dist/bin/revoke-invitation-DTGQRJR4.js +40 -0
- package/dist/bin/sales-trend-ZYBRUDUU.js +71 -0
- package/dist/bin/sequence-FPOJTI2P.js +66 -0
- package/dist/bin/store-IOB4Y67C.js +82 -0
- package/dist/bin/summary-5KYBA4ZO.js +113 -0
- package/dist/bin/top-customers-WSQ2UEJL.js +81 -0
- package/dist/bin/top-items-RWQPDGLN.js +84 -0
- package/dist/bin/top-outstanding-QAMO2E7Y.js +64 -0
- package/dist/bin/unpaid-invoices-WB3TK5B4.js +65 -0
- package/dist/bin/untracked-H733MYJL.js +67 -0
- package/dist/bin/update-H6LPO2Z4.js +61 -0
- package/dist/bin/update-JU2X3XU5.js +54 -0
- package/dist/bin/update-TLBUIC5J.js +57 -0
- package/dist/bin/update-role-QST7BVFX.js +45 -0
- package/dist/bin/update-settings-Q2EGRLKZ.js +56 -0
- package/package.json +7 -6
- package/src/auth.ts +12 -3
- package/src/bin/hisaabo.ts +49 -935
- package/src/bin/registrars/api-key.ts +44 -0
- package/src/bin/registrars/auth.ts +222 -0
- package/src/bin/registrars/automated-invoice.ts +167 -0
- package/src/bin/registrars/bank.ts +124 -0
- package/src/bin/registrars/business.ts +120 -0
- package/src/bin/registrars/dashboard.ts +225 -0
- package/src/bin/registrars/document.ts +184 -0
- package/src/bin/registrars/expense.ts +87 -0
- package/src/bin/registrars/gst.ts +41 -0
- package/src/bin/registrars/import.ts +49 -0
- package/src/bin/registrars/invoice.ts +117 -0
- package/src/bin/registrars/item.ts +112 -0
- package/src/bin/registrars/party.ts +81 -0
- package/src/bin/registrars/payment.ts +128 -0
- package/src/bin/registrars/report.ts +142 -0
- package/src/bin/registrars/session.ts +32 -0
- package/src/bin/registrars/shipment.ts +74 -0
- package/src/bin/registrars/store.ts +128 -0
- package/src/bin/registrars/target.ts +46 -0
- package/src/bin/registrars/tenant.ts +73 -0
- package/src/client.ts +589 -15
- package/src/commands/api-key/create.ts +72 -0
- package/src/commands/api-key/list.ts +71 -0
- package/src/commands/api-key/revoke.ts +46 -0
- package/src/commands/automated-invoice/create.ts +85 -0
- package/src/commands/automated-invoice/delete.ts +42 -0
- package/src/commands/automated-invoice/get.ts +113 -0
- package/src/commands/automated-invoice/history.ts +65 -0
- package/src/commands/automated-invoice/index.ts +11 -0
- package/src/commands/automated-invoice/list.ts +91 -0
- package/src/commands/automated-invoice/pause.ts +29 -0
- package/src/commands/automated-invoice/resume.ts +29 -0
- package/src/commands/automated-invoice/run-now.ts +29 -0
- package/src/commands/automated-invoice/suggestions.ts +68 -0
- package/src/commands/automated-invoice/update.ts +54 -0
- package/src/commands/automated-invoice/usage.ts +68 -0
- package/src/commands/bank/gateway-config.ts +61 -0
- package/src/commands/bank/update-gateway.ts +84 -0
- package/src/commands/business/audit-trail.ts +79 -0
- package/src/commands/business/export.ts +52 -0
- package/src/commands/business/get.ts +55 -0
- package/src/commands/business/sequence.ts +65 -0
- package/src/commands/business/update.ts +64 -0
- package/src/commands/dashboard/collection-efficiency.ts +164 -0
- package/src/commands/dashboard/expenses.ts +76 -0
- package/src/commands/dashboard/invoice-breakdown.ts +89 -0
- package/src/commands/dashboard/monthly-comparison.ts +193 -0
- package/src/commands/dashboard/payment-modes.ts +121 -0
- package/src/commands/dashboard/profit-loss.ts +146 -0
- package/src/commands/dashboard/receivables-aging.ts +169 -0
- package/src/commands/dashboard/sales-trend.ts +68 -0
- package/src/commands/dashboard/summary.ts +105 -0
- package/src/commands/dashboard/top-customers.ts +70 -0
- package/src/commands/dashboard/top-items.ts +74 -0
- package/src/commands/dashboard/top-outstanding.ts +61 -0
- package/src/commands/document/factory.ts +590 -0
- package/src/commands/expense/categories.ts +40 -0
- package/src/commands/expense/update.ts +58 -0
- package/src/commands/import/index.ts +68 -0
- package/src/commands/item/categories.ts +40 -0
- package/src/commands/item/low-stock-count.ts +32 -0
- package/src/commands/item/merge.ts +53 -0
- package/src/commands/item/price-history.ts +59 -0
- package/src/commands/item/rename-unit.ts +39 -0
- package/src/commands/item/sales-stats.ts +44 -0
- package/src/commands/item/stock-history.ts +70 -0
- package/src/commands/item/switch-base-unit.ts +42 -0
- package/src/commands/item/update.ts +59 -0
- package/src/commands/item/variants-create.ts +58 -0
- package/src/commands/item/variants-delete.ts +47 -0
- package/src/commands/item/variants-list.ts +63 -0
- package/src/commands/item/variants-update.ts +61 -0
- package/src/commands/party/ledger-report.ts +81 -0
- package/src/commands/party/merge.ts +50 -0
- package/src/commands/party/stats.ts +40 -0
- package/src/commands/party/top-items.ts +57 -0
- package/src/commands/party/update.ts +65 -0
- package/src/commands/payment/default-account.ts +56 -0
- package/src/commands/payment/get.ts +59 -0
- package/src/commands/payment/unpaid-invoices.ts +69 -0
- package/src/commands/payment/untracked.ts +70 -0
- package/src/commands/payment/update.ts +54 -0
- package/src/commands/report/index.ts +348 -1
- package/src/commands/session/list.ts +91 -0
- package/src/commands/session/revoke-all.ts +20 -0
- package/src/commands/session/revoke.ts +32 -0
- package/src/commands/store/check-slug.ts +48 -0
- package/src/commands/store/items-toggle.ts +41 -0
- package/src/commands/store/items.ts +61 -0
- package/src/commands/store/order-cancel.ts +48 -0
- package/src/commands/store/order-confirm.ts +45 -0
- package/src/commands/store/order-get.ts +66 -0
- package/src/commands/store/order-update.ts +52 -0
- package/src/commands/store/update-settings.ts +52 -0
- package/src/commands/tenant/invitations.ts +62 -0
- package/src/commands/tenant/invite.ts +57 -0
- package/src/commands/tenant/list.ts +46 -0
- package/src/commands/tenant/members.ts +55 -0
- package/src/commands/tenant/remove.ts +47 -0
- package/src/commands/tenant/revoke-invitation.ts +32 -0
- package/src/commands/tenant/update-role.ts +41 -0
- package/src/config.ts +51 -2
- package/src/error-handler.ts +53 -0
- package/src/output.ts +1 -0
- package/src/spinner.ts +39 -0
- package/tsup.config.ts +6 -1
- package/src/components/ErrorDisplay.tsx +0 -16
- package/src/components/Header.tsx +0 -26
- package/src/components/MoneyCell.tsx +0 -16
- package/src/components/Spinner.tsx +0 -12
- package/src/components/StatusBadge.tsx +0 -39
- package/src/components/Table.tsx +0 -63
package/src/client.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type HisaaboError =
|
|
|
20
20
|
| { code: "not_found"; resource: string }
|
|
21
21
|
| { code: "validation_failed"; fields: Record<string, string[]> }
|
|
22
22
|
| { code: "network_error"; message: string }
|
|
23
|
+
| { code: "rate_limited"; retryAfterMs: number; message: string }
|
|
23
24
|
| { code: "api_error"; message: string };
|
|
24
25
|
|
|
25
26
|
export class HisaaboApiError extends Error {
|
|
@@ -44,6 +45,8 @@ export function formatHisaaboError(err: HisaaboError): string {
|
|
|
44
45
|
.map(([field, msgs]) => ` ${field}: ${msgs.join(", ")}`)
|
|
45
46
|
.join("\n")
|
|
46
47
|
);
|
|
48
|
+
case "rate_limited":
|
|
49
|
+
return `Rate limited: ${err.message}`;
|
|
47
50
|
case "network_error":
|
|
48
51
|
return `Network error: ${err.message}`;
|
|
49
52
|
case "api_error":
|
|
@@ -94,6 +97,23 @@ export class HisaaboClient {
|
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
private async unwrap<T>(res: Response): Promise<T> {
|
|
100
|
+
// Detect rate limiting before tRPC error parsing
|
|
101
|
+
if (res.status === 429) {
|
|
102
|
+
const retryAfter = res.headers.get("retry-after");
|
|
103
|
+
let retryMs = 60_000;
|
|
104
|
+
if (retryAfter) {
|
|
105
|
+
const parsed = Number(retryAfter);
|
|
106
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
107
|
+
retryMs = Math.min(parsed * 1000, 120_000); // cap at 2 minutes
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
throw new HisaaboApiError({
|
|
111
|
+
code: "rate_limited",
|
|
112
|
+
retryAfterMs: retryMs,
|
|
113
|
+
message: `Rate limited. Try again in ${Math.ceil(retryMs / 1000)}s.`,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
97
117
|
const body = await res.json() as unknown;
|
|
98
118
|
|
|
99
119
|
if (typeof body !== "object" || body === null) {
|
|
@@ -116,17 +136,27 @@ export class HisaaboClient {
|
|
|
116
136
|
}
|
|
117
137
|
|
|
118
138
|
async query<T>(path: string, input?: unknown): Promise<T> {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
const maxRetries = 2;
|
|
140
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
141
|
+
try {
|
|
142
|
+
const url = new URL(`${this.config.apiUrl}/api/trpc/${path}`);
|
|
143
|
+
if (input !== undefined) {
|
|
144
|
+
url.searchParams.set("input", JSON.stringify(superjson.serialize(input)));
|
|
145
|
+
}
|
|
146
|
+
const res = await fetch(url.toString(), { headers: this.buildHeaders() });
|
|
147
|
+
return await this.unwrap<T>(res);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
// Auto-retry on rate limit for idempotent reads
|
|
150
|
+
if (e instanceof HisaaboApiError && e.hisaaboError.code === "rate_limited" && attempt < maxRetries) {
|
|
151
|
+
const waitMs = Math.min((e.hisaaboError as { retryAfterMs: number }).retryAfterMs, 10_000);
|
|
152
|
+
await new Promise((r) => setTimeout(r, waitMs));
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (e instanceof HisaaboApiError) throw e;
|
|
156
|
+
throw new HisaaboApiError({ code: "network_error", message: String(e instanceof Error ? e.message : e) });
|
|
157
|
+
}
|
|
129
158
|
}
|
|
159
|
+
throw new HisaaboApiError({ code: "api_error", message: "Max retries exceeded" });
|
|
130
160
|
}
|
|
131
161
|
|
|
132
162
|
async mutate<T>(path: string, input: unknown): Promise<T> {
|
|
@@ -157,6 +187,24 @@ export class HisaaboClient {
|
|
|
157
187
|
me() {
|
|
158
188
|
return c.query<AuthUser>("auth.me");
|
|
159
189
|
},
|
|
190
|
+
completeProfile(input: { name: string }) {
|
|
191
|
+
return c.mutate<any>("auth.completeProfile", input);
|
|
192
|
+
},
|
|
193
|
+
logoutAll() {
|
|
194
|
+
return c.mutate<any>("auth.logoutAll", {});
|
|
195
|
+
},
|
|
196
|
+
register(input: any) {
|
|
197
|
+
return c.mutate<any>("auth.register", input);
|
|
198
|
+
},
|
|
199
|
+
updateName(input: { name: string }) {
|
|
200
|
+
return c.mutate<any>("auth.updateName", input);
|
|
201
|
+
},
|
|
202
|
+
listSessions(input: { expired: boolean }) {
|
|
203
|
+
return c.query<any>("auth.listSessions", input);
|
|
204
|
+
},
|
|
205
|
+
revokeSession(input: { sessionId: string }) {
|
|
206
|
+
return c.mutate<any>("auth.revokeSession", input);
|
|
207
|
+
},
|
|
160
208
|
};
|
|
161
209
|
}
|
|
162
210
|
|
|
@@ -169,7 +217,22 @@ export class HisaaboClient {
|
|
|
169
217
|
return c.query<BusinessSummary[]>("business.list");
|
|
170
218
|
},
|
|
171
219
|
get() {
|
|
172
|
-
return c.query<BusinessDetail>("business.
|
|
220
|
+
return c.query<BusinessDetail>("business.getById");
|
|
221
|
+
},
|
|
222
|
+
create(input: any) {
|
|
223
|
+
return c.mutate<any>("business.create", input);
|
|
224
|
+
},
|
|
225
|
+
update(input: any) {
|
|
226
|
+
return c.mutate<any>("business.update", input);
|
|
227
|
+
},
|
|
228
|
+
updateSequenceNumber(input: any) {
|
|
229
|
+
return c.mutate<any>("business.updateSequenceNumber", input);
|
|
230
|
+
},
|
|
231
|
+
auditTrail(input?: { page?: number; limit?: number }) {
|
|
232
|
+
return c.query<any>("business.auditTrail", input);
|
|
233
|
+
},
|
|
234
|
+
exportData() {
|
|
235
|
+
return c.mutate<any>("business.exportData", {});
|
|
173
236
|
},
|
|
174
237
|
};
|
|
175
238
|
}
|
|
@@ -183,11 +246,14 @@ export class HisaaboClient {
|
|
|
183
246
|
return c.query<PaginatedResult<InvoiceSummary>>("invoice.list", input);
|
|
184
247
|
},
|
|
185
248
|
get(id: string) {
|
|
186
|
-
return c.query<InvoiceDetail>("invoice.
|
|
249
|
+
return c.query<InvoiceDetail>("invoice.getById", { id });
|
|
187
250
|
},
|
|
188
251
|
create(input: InvoiceCreateInput) {
|
|
189
252
|
return c.mutate<InvoiceDetail>("invoice.create", input);
|
|
190
253
|
},
|
|
254
|
+
update(input: any) {
|
|
255
|
+
return c.mutate<any>("invoice.update", input);
|
|
256
|
+
},
|
|
191
257
|
updateStatus(id: string, status: InvoiceStatus) {
|
|
192
258
|
return c.mutate<InvoiceSummary>("invoice.updateStatus", { id, status });
|
|
193
259
|
},
|
|
@@ -206,7 +272,7 @@ export class HisaaboClient {
|
|
|
206
272
|
return c.query<PaginatedResult<PartySummary>>("party.list", input);
|
|
207
273
|
},
|
|
208
274
|
get(id: string) {
|
|
209
|
-
return c.query<PartyDetail>("party.
|
|
275
|
+
return c.query<PartyDetail>("party.getById", { id });
|
|
210
276
|
},
|
|
211
277
|
create(input: PartyCreateInput) {
|
|
212
278
|
return c.mutate<PartySummary>("party.create", input);
|
|
@@ -220,6 +286,18 @@ export class HisaaboClient {
|
|
|
220
286
|
ledger(partyId: string, input?: LedgerInput) {
|
|
221
287
|
return c.query<LedgerResult>("party.ledger", { partyId, ...input });
|
|
222
288
|
},
|
|
289
|
+
ledgerReport(input: any) {
|
|
290
|
+
return c.query<any>("party.ledgerReport", input);
|
|
291
|
+
},
|
|
292
|
+
getStats(input: any) {
|
|
293
|
+
return c.query<any>("party.getStats", input);
|
|
294
|
+
},
|
|
295
|
+
topItems(input: any) {
|
|
296
|
+
return c.query<any>("party.topItems", input);
|
|
297
|
+
},
|
|
298
|
+
merge(input: any) {
|
|
299
|
+
return c.mutate<any>("party.merge", input);
|
|
300
|
+
},
|
|
223
301
|
};
|
|
224
302
|
}
|
|
225
303
|
|
|
@@ -232,7 +310,7 @@ export class HisaaboClient {
|
|
|
232
310
|
return c.query<PaginatedResult<ItemSummary>>("item.list", input);
|
|
233
311
|
},
|
|
234
312
|
get(id: string) {
|
|
235
|
-
return c.query<ItemDetail>("item.
|
|
313
|
+
return c.query<ItemDetail>("item.getById", { id });
|
|
236
314
|
},
|
|
237
315
|
create(input: ItemCreateInput) {
|
|
238
316
|
return c.mutate<ItemSummary>("item.create", input);
|
|
@@ -249,6 +327,42 @@ export class HisaaboClient {
|
|
|
249
327
|
categories() {
|
|
250
328
|
return c.query<string[]>("item.categories");
|
|
251
329
|
},
|
|
330
|
+
createVariant(input: any) {
|
|
331
|
+
return c.mutate<any>("item.createVariant", input);
|
|
332
|
+
},
|
|
333
|
+
updateVariant(input: any) {
|
|
334
|
+
return c.mutate<any>("item.updateVariant", input);
|
|
335
|
+
},
|
|
336
|
+
deleteVariant(input: any) {
|
|
337
|
+
return c.mutate<any>("item.deleteVariant", input);
|
|
338
|
+
},
|
|
339
|
+
listVariants(input: any) {
|
|
340
|
+
return c.query<any>("item.listVariants", input);
|
|
341
|
+
},
|
|
342
|
+
merge(input: any) {
|
|
343
|
+
return c.mutate<any>("item.merge", input);
|
|
344
|
+
},
|
|
345
|
+
switchBaseUnit(input: any) {
|
|
346
|
+
return c.mutate<any>("item.switchBaseUnit", input);
|
|
347
|
+
},
|
|
348
|
+
renameUnit(input: any) {
|
|
349
|
+
return c.mutate<any>("item.renameUnit", input);
|
|
350
|
+
},
|
|
351
|
+
stockAdjustmentHistory(input: any) {
|
|
352
|
+
return c.query<any>("item.stockAdjustmentHistory", input);
|
|
353
|
+
},
|
|
354
|
+
lowStockCount() {
|
|
355
|
+
return c.query<any>("item.lowStockCount");
|
|
356
|
+
},
|
|
357
|
+
priceHistory(input: any) {
|
|
358
|
+
return c.query<any>("item.priceHistory", input);
|
|
359
|
+
},
|
|
360
|
+
salesStats(input: any) {
|
|
361
|
+
return c.query<any>("item.salesStats", input);
|
|
362
|
+
},
|
|
363
|
+
stockMovements(input: any) {
|
|
364
|
+
return c.query<any>("item.stockMovements", input);
|
|
365
|
+
},
|
|
252
366
|
};
|
|
253
367
|
}
|
|
254
368
|
|
|
@@ -272,6 +386,18 @@ export class HisaaboClient {
|
|
|
272
386
|
delete(id: string) {
|
|
273
387
|
return c.mutate<{ success: boolean }>("payment.delete", { id });
|
|
274
388
|
},
|
|
389
|
+
unpaidInvoices(input: any) {
|
|
390
|
+
return c.query<any>("payment.unpaidInvoices", input);
|
|
391
|
+
},
|
|
392
|
+
untrackedPayments(input: any) {
|
|
393
|
+
return c.query<any>("payment.untrackedPayments", input);
|
|
394
|
+
},
|
|
395
|
+
defaultAccount(input?: any) {
|
|
396
|
+
return c.query<any>("payment.defaultAccount", input);
|
|
397
|
+
},
|
|
398
|
+
assignAccount(input: any) {
|
|
399
|
+
return c.mutate<any>("payment.assignAccount", input);
|
|
400
|
+
},
|
|
275
401
|
};
|
|
276
402
|
}
|
|
277
403
|
|
|
@@ -306,6 +432,42 @@ export class HisaaboClient {
|
|
|
306
432
|
summary(input?: DashboardInput) {
|
|
307
433
|
return c.query<DashboardSummary>("dashboard.summary", input);
|
|
308
434
|
},
|
|
435
|
+
salesTrend(input: { months?: number; fromDate?: string; toDate?: string; granularity?: string }) {
|
|
436
|
+
return c.query<any>("dashboard.salesTrend", input);
|
|
437
|
+
},
|
|
438
|
+
topOutstanding(input?: { limit?: number }) {
|
|
439
|
+
return c.query<any>("dashboard.topOutstanding", input);
|
|
440
|
+
},
|
|
441
|
+
topCustomers(input?: { limit?: number; fromDate?: string; toDate?: string }) {
|
|
442
|
+
return c.query<any>("dashboard.topCustomers", input);
|
|
443
|
+
},
|
|
444
|
+
topSellingItems(input?: { limit?: number; itemType?: string; fromDate?: string; toDate?: string }) {
|
|
445
|
+
return c.query<any>("dashboard.topSellingItems", input);
|
|
446
|
+
},
|
|
447
|
+
expensesByCategory(input?: { fromDate?: string; toDate?: string }) {
|
|
448
|
+
return c.query<any>("dashboard.expensesByCategory", input);
|
|
449
|
+
},
|
|
450
|
+
invoiceStatusBreakdown(input?: { fromDate?: string; toDate?: string }) {
|
|
451
|
+
return c.query<any>("dashboard.invoiceStatusBreakdown", input);
|
|
452
|
+
},
|
|
453
|
+
profitAndLoss(input?: { fromDate?: string; toDate?: string }) {
|
|
454
|
+
return c.query<any>("dashboard.profitAndLoss", input);
|
|
455
|
+
},
|
|
456
|
+
receivablesAging() {
|
|
457
|
+
return c.query<any>("dashboard.receivablesAging");
|
|
458
|
+
},
|
|
459
|
+
paymentModeBreakdown(input?: { fromDate?: string; toDate?: string }) {
|
|
460
|
+
return c.query<any>("dashboard.paymentModeBreakdown", input);
|
|
461
|
+
},
|
|
462
|
+
collectionEfficiency(input?: { fromDate?: string; toDate?: string }) {
|
|
463
|
+
return c.query<any>("dashboard.collectionEfficiency", input);
|
|
464
|
+
},
|
|
465
|
+
monthlyComparison() {
|
|
466
|
+
return c.query<any>("dashboard.monthlyComparison");
|
|
467
|
+
},
|
|
468
|
+
shippingSummary(input?: { fromDate?: string; toDate?: string }) {
|
|
469
|
+
return c.query<any>("dashboard.shippingSummary", input);
|
|
470
|
+
},
|
|
309
471
|
};
|
|
310
472
|
}
|
|
311
473
|
|
|
@@ -378,6 +540,12 @@ export class HisaaboClient {
|
|
|
378
540
|
summary() {
|
|
379
541
|
return c.query<BankSummary>("bankAccount.summary");
|
|
380
542
|
},
|
|
543
|
+
getGatewayConfig(bankAccountId: string) {
|
|
544
|
+
return c.query<GatewayConfig | null>("bankAccount.getGatewayConfig", { bankAccountId });
|
|
545
|
+
},
|
|
546
|
+
upsertGatewayConfig(input: UpsertGatewayConfigInput) {
|
|
547
|
+
return c.mutate<GatewayConfig>("bankAccount.upsertGatewayConfig", input);
|
|
548
|
+
},
|
|
381
549
|
};
|
|
382
550
|
}
|
|
383
551
|
|
|
@@ -407,6 +575,18 @@ export class HisaaboClient {
|
|
|
407
575
|
paymentSummary(input: PaymentSummaryInput) {
|
|
408
576
|
return c.query<PaymentSummaryResult>("reports.paymentSummary", input);
|
|
409
577
|
},
|
|
578
|
+
salesRegister(input: { fromDate: string; toDate: string; partyId?: string }) {
|
|
579
|
+
return c.query<any>("reports.salesRegister", input);
|
|
580
|
+
},
|
|
581
|
+
purchaseRegister(input: { fromDate: string; toDate: string; partyId?: string }) {
|
|
582
|
+
return c.query<any>("reports.purchaseRegister", input);
|
|
583
|
+
},
|
|
584
|
+
cashFlowForecast(input?: Record<string, unknown>) {
|
|
585
|
+
return c.query<any>("reports.cashFlowForecast", input ?? {});
|
|
586
|
+
},
|
|
587
|
+
collectionEfficiency(input: { fromDate: string; toDate: string }) {
|
|
588
|
+
return c.query<any>("reports.collectionEfficiency", input);
|
|
589
|
+
},
|
|
410
590
|
};
|
|
411
591
|
}
|
|
412
592
|
|
|
@@ -430,6 +610,21 @@ export class HisaaboClient {
|
|
|
430
610
|
updateOrder(input: { orderId: string; status: "preparing" | "ready" | "delivered" }) {
|
|
431
611
|
return c.mutate<{ success: boolean; status: string }>("store.updateOrderStatus", input);
|
|
432
612
|
},
|
|
613
|
+
confirmOrder(input: any) {
|
|
614
|
+
return c.mutate<any>("store.confirmOrder", input);
|
|
615
|
+
},
|
|
616
|
+
cancelOrder(input: any) {
|
|
617
|
+
return c.mutate<any>("store.cancelOrder", input);
|
|
618
|
+
},
|
|
619
|
+
checkSlug(input: any) {
|
|
620
|
+
return c.query<any>("store.checkSlug", input);
|
|
621
|
+
},
|
|
622
|
+
listStoreItems(input: any) {
|
|
623
|
+
return c.query<any>("store.listStoreItems", input);
|
|
624
|
+
},
|
|
625
|
+
bulkToggleItems(input: any) {
|
|
626
|
+
return c.mutate<any>("store.bulkToggleItems", input);
|
|
627
|
+
},
|
|
433
628
|
};
|
|
434
629
|
}
|
|
435
630
|
|
|
@@ -459,6 +654,268 @@ export class HisaaboClient {
|
|
|
459
654
|
};
|
|
460
655
|
}
|
|
461
656
|
|
|
657
|
+
// ── Tenant ───────────────────────────────────────────────────
|
|
658
|
+
|
|
659
|
+
get tenant() {
|
|
660
|
+
const c = this;
|
|
661
|
+
return {
|
|
662
|
+
list() {
|
|
663
|
+
return c.query<any>("tenant.list");
|
|
664
|
+
},
|
|
665
|
+
select(input: any) {
|
|
666
|
+
return c.mutate<any>("tenant.select", input);
|
|
667
|
+
},
|
|
668
|
+
members() {
|
|
669
|
+
return c.query<any>("tenant.members");
|
|
670
|
+
},
|
|
671
|
+
inviteMember(input: any) {
|
|
672
|
+
return c.mutate<any>("tenant.inviteMember", input);
|
|
673
|
+
},
|
|
674
|
+
removeMember(input: any) {
|
|
675
|
+
return c.mutate<any>("tenant.removeMember", input);
|
|
676
|
+
},
|
|
677
|
+
updateMemberRole(input: any) {
|
|
678
|
+
return c.mutate<any>("tenant.updateMemberRole", input);
|
|
679
|
+
},
|
|
680
|
+
pendingInvitations() {
|
|
681
|
+
return c.query<any>("tenant.pendingInvitations");
|
|
682
|
+
},
|
|
683
|
+
revokeInvitation(input: { invitationId: string }) {
|
|
684
|
+
return c.mutate<any>("tenant.revokeInvitation", input);
|
|
685
|
+
},
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// ── Document ──────────────────────────────────────────────────
|
|
690
|
+
|
|
691
|
+
get document() {
|
|
692
|
+
const c = this;
|
|
693
|
+
return {
|
|
694
|
+
convert(input: any) {
|
|
695
|
+
return c.mutate<any>("document.convert", input);
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// ── Quotation ─────────────────────────────────────────────────
|
|
701
|
+
|
|
702
|
+
get quotation() {
|
|
703
|
+
const c = this;
|
|
704
|
+
return {
|
|
705
|
+
list(input: any) {
|
|
706
|
+
return c.query<any>("quotation.list", input);
|
|
707
|
+
},
|
|
708
|
+
getById(input: any) {
|
|
709
|
+
return c.query<any>("quotation.getById", input);
|
|
710
|
+
},
|
|
711
|
+
create(input: any) {
|
|
712
|
+
return c.mutate<any>("quotation.create", input);
|
|
713
|
+
},
|
|
714
|
+
updateStatus(input: any) {
|
|
715
|
+
return c.mutate<any>("quotation.updateStatus", input);
|
|
716
|
+
},
|
|
717
|
+
delete(input: any) {
|
|
718
|
+
return c.mutate<any>("quotation.delete", input);
|
|
719
|
+
},
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// ── Credit Note ───────────────────────────────────────────────
|
|
724
|
+
|
|
725
|
+
get creditNote() {
|
|
726
|
+
const c = this;
|
|
727
|
+
return {
|
|
728
|
+
list(input: any) {
|
|
729
|
+
return c.query<any>("creditNote.list", input);
|
|
730
|
+
},
|
|
731
|
+
getById(input: any) {
|
|
732
|
+
return c.query<any>("creditNote.getById", input);
|
|
733
|
+
},
|
|
734
|
+
create(input: any) {
|
|
735
|
+
return c.mutate<any>("creditNote.create", input);
|
|
736
|
+
},
|
|
737
|
+
updateStatus(input: any) {
|
|
738
|
+
return c.mutate<any>("creditNote.updateStatus", input);
|
|
739
|
+
},
|
|
740
|
+
delete(input: any) {
|
|
741
|
+
return c.mutate<any>("creditNote.delete", input);
|
|
742
|
+
},
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// ── Debit Note ────────────────────────────────────────────────
|
|
747
|
+
|
|
748
|
+
get debitNote() {
|
|
749
|
+
const c = this;
|
|
750
|
+
return {
|
|
751
|
+
list(input: any) {
|
|
752
|
+
return c.query<any>("debitNote.list", input);
|
|
753
|
+
},
|
|
754
|
+
getById(input: any) {
|
|
755
|
+
return c.query<any>("debitNote.getById", input);
|
|
756
|
+
},
|
|
757
|
+
create(input: any) {
|
|
758
|
+
return c.mutate<any>("debitNote.create", input);
|
|
759
|
+
},
|
|
760
|
+
updateStatus(input: any) {
|
|
761
|
+
return c.mutate<any>("debitNote.updateStatus", input);
|
|
762
|
+
},
|
|
763
|
+
delete(input: any) {
|
|
764
|
+
return c.mutate<any>("debitNote.delete", input);
|
|
765
|
+
},
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// ── Delivery Challan ──────────────────────────────────────────
|
|
770
|
+
|
|
771
|
+
get deliveryChallan() {
|
|
772
|
+
const c = this;
|
|
773
|
+
return {
|
|
774
|
+
list(input: any) {
|
|
775
|
+
return c.query<any>("deliveryChallan.list", input);
|
|
776
|
+
},
|
|
777
|
+
getById(input: any) {
|
|
778
|
+
return c.query<any>("deliveryChallan.getById", input);
|
|
779
|
+
},
|
|
780
|
+
create(input: any) {
|
|
781
|
+
return c.mutate<any>("deliveryChallan.create", input);
|
|
782
|
+
},
|
|
783
|
+
updateStatus(input: any) {
|
|
784
|
+
return c.mutate<any>("deliveryChallan.updateStatus", input);
|
|
785
|
+
},
|
|
786
|
+
delete(input: any) {
|
|
787
|
+
return c.mutate<any>("deliveryChallan.delete", input);
|
|
788
|
+
},
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// ── Proforma ──────────────────────────────────────────────────
|
|
793
|
+
|
|
794
|
+
get proforma() {
|
|
795
|
+
const c = this;
|
|
796
|
+
return {
|
|
797
|
+
list(input: any) {
|
|
798
|
+
return c.query<any>("proforma.list", input);
|
|
799
|
+
},
|
|
800
|
+
getById(input: any) {
|
|
801
|
+
return c.query<any>("proforma.getById", input);
|
|
802
|
+
},
|
|
803
|
+
create(input: any) {
|
|
804
|
+
return c.mutate<any>("proforma.create", input);
|
|
805
|
+
},
|
|
806
|
+
updateStatus(input: any) {
|
|
807
|
+
return c.mutate<any>("proforma.updateStatus", input);
|
|
808
|
+
},
|
|
809
|
+
delete(input: any) {
|
|
810
|
+
return c.mutate<any>("proforma.delete", input);
|
|
811
|
+
},
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// ── Sales Return ──────────────────────────────────────────────
|
|
816
|
+
|
|
817
|
+
get salesReturn() {
|
|
818
|
+
const c = this;
|
|
819
|
+
return {
|
|
820
|
+
list(input: any) {
|
|
821
|
+
return c.query<any>("salesReturn.list", input);
|
|
822
|
+
},
|
|
823
|
+
getById(input: any) {
|
|
824
|
+
return c.query<any>("salesReturn.getById", input);
|
|
825
|
+
},
|
|
826
|
+
create(input: any) {
|
|
827
|
+
return c.mutate<any>("salesReturn.create", input);
|
|
828
|
+
},
|
|
829
|
+
updateStatus(input: any) {
|
|
830
|
+
return c.mutate<any>("salesReturn.updateStatus", input);
|
|
831
|
+
},
|
|
832
|
+
delete(input: any) {
|
|
833
|
+
return c.mutate<any>("salesReturn.delete", input);
|
|
834
|
+
},
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// ── Purchase Return ───────────────────────────────────────────
|
|
839
|
+
|
|
840
|
+
get purchaseReturn() {
|
|
841
|
+
const c = this;
|
|
842
|
+
return {
|
|
843
|
+
list(input: any) {
|
|
844
|
+
return c.query<any>("purchaseReturn.list", input);
|
|
845
|
+
},
|
|
846
|
+
getById(input: any) {
|
|
847
|
+
return c.query<any>("purchaseReturn.getById", input);
|
|
848
|
+
},
|
|
849
|
+
create(input: any) {
|
|
850
|
+
return c.mutate<any>("purchaseReturn.create", input);
|
|
851
|
+
},
|
|
852
|
+
updateStatus(input: any) {
|
|
853
|
+
return c.mutate<any>("purchaseReturn.updateStatus", input);
|
|
854
|
+
},
|
|
855
|
+
delete(input: any) {
|
|
856
|
+
return c.mutate<any>("purchaseReturn.delete", input);
|
|
857
|
+
},
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// ── Recurring Invoice ─────────────────────────────────────────
|
|
862
|
+
|
|
863
|
+
get recurringInvoice() {
|
|
864
|
+
const c = this;
|
|
865
|
+
return {
|
|
866
|
+
list(input: RecurringInvoiceListInput) {
|
|
867
|
+
return c.query<PaginatedResult<RecurringInvoiceSummary>>("recurringInvoice.list", input);
|
|
868
|
+
},
|
|
869
|
+
getById(id: string) {
|
|
870
|
+
return c.query<RecurringInvoiceDetail>("recurringInvoice.getById", { id });
|
|
871
|
+
},
|
|
872
|
+
create(input: RecurringInvoiceCreateInput) {
|
|
873
|
+
return c.mutate<RecurringInvoiceDetail>("recurringInvoice.create", input);
|
|
874
|
+
},
|
|
875
|
+
update(id: string, data: Partial<RecurringInvoiceCreateInput>) {
|
|
876
|
+
return c.mutate<RecurringInvoiceDetail>("recurringInvoice.update", { id, data });
|
|
877
|
+
},
|
|
878
|
+
delete(id: string) {
|
|
879
|
+
return c.mutate<{ success: boolean }>("recurringInvoice.delete", { id });
|
|
880
|
+
},
|
|
881
|
+
pause(id: string) {
|
|
882
|
+
return c.mutate<{ success: boolean }>("recurringInvoice.pause", { id });
|
|
883
|
+
},
|
|
884
|
+
resume(id: string) {
|
|
885
|
+
return c.mutate<{ success: boolean }>("recurringInvoice.resume", { id });
|
|
886
|
+
},
|
|
887
|
+
runNow(id: string) {
|
|
888
|
+
return c.mutate<{ success: boolean; invoiceId?: string }>("recurringInvoice.runNow", { id });
|
|
889
|
+
},
|
|
890
|
+
executionHistory(templateId: string, page?: number, limit?: number) {
|
|
891
|
+
return c.query<PaginatedResult<RecurringInvoiceExecution>>("recurringInvoice.executionHistory", { templateId, page, limit });
|
|
892
|
+
},
|
|
893
|
+
planUsage() {
|
|
894
|
+
return c.query<RecurringInvoicePlanUsage>("recurringInvoice.planUsage");
|
|
895
|
+
},
|
|
896
|
+
suggestions() {
|
|
897
|
+
return c.query<RecurringInvoiceSuggestion[]>("recurringInvoice.suggestions");
|
|
898
|
+
},
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// ── API Key ───────────────────────────────────────────────────
|
|
903
|
+
|
|
904
|
+
get apiKey() {
|
|
905
|
+
const c = this;
|
|
906
|
+
return {
|
|
907
|
+
list() {
|
|
908
|
+
return c.query<any>("apiKey.list");
|
|
909
|
+
},
|
|
910
|
+
create(input: any) {
|
|
911
|
+
return c.mutate<any>("apiKey.create", input);
|
|
912
|
+
},
|
|
913
|
+
revoke(input: any) {
|
|
914
|
+
return c.mutate<any>("apiKey.revoke", input);
|
|
915
|
+
},
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
|
|
462
919
|
// ── Import ────────────────────────────────────────────────────
|
|
463
920
|
|
|
464
921
|
get import() {
|
|
@@ -949,7 +1406,42 @@ export interface ShipmentUpdateInput {
|
|
|
949
1406
|
notes?: string;
|
|
950
1407
|
}
|
|
951
1408
|
|
|
952
|
-
export type BankAccountType = "savings" | "current" | "cash" | "credit" | "other";
|
|
1409
|
+
export type BankAccountType = "savings" | "current" | "cash" | "credit" | "other" | "payment_gateway";
|
|
1410
|
+
|
|
1411
|
+
export interface GatewayChargeRate {
|
|
1412
|
+
type: "percentage" | "flat";
|
|
1413
|
+
value: string;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
export interface GatewayChargeConfig {
|
|
1417
|
+
credit_card?: GatewayChargeRate;
|
|
1418
|
+
debit_card?: GatewayChargeRate;
|
|
1419
|
+
upi?: GatewayChargeRate;
|
|
1420
|
+
net_banking?: GatewayChargeRate;
|
|
1421
|
+
wallet?: GatewayChargeRate;
|
|
1422
|
+
default?: GatewayChargeRate;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
export interface GatewayConfig {
|
|
1426
|
+
id: string;
|
|
1427
|
+
businessId: string;
|
|
1428
|
+
bankAccountId: string;
|
|
1429
|
+
settlementAccountId: string;
|
|
1430
|
+
chargeConfig: GatewayChargeConfig;
|
|
1431
|
+
expenseCategory: string;
|
|
1432
|
+
autoSettle: boolean;
|
|
1433
|
+
isActive: boolean;
|
|
1434
|
+
createdAt: string;
|
|
1435
|
+
updatedAt: string;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
export interface UpsertGatewayConfigInput {
|
|
1439
|
+
bankAccountId: string;
|
|
1440
|
+
settlementAccountId: string;
|
|
1441
|
+
chargeConfig: GatewayChargeConfig;
|
|
1442
|
+
expenseCategory?: string;
|
|
1443
|
+
autoSettle?: boolean;
|
|
1444
|
+
}
|
|
953
1445
|
|
|
954
1446
|
export interface BankAccountSummary {
|
|
955
1447
|
id: string;
|
|
@@ -1227,3 +1719,85 @@ export interface ImportResult {
|
|
|
1227
1719
|
export interface ImportItemsResult extends ImportResult {
|
|
1228
1720
|
created: number;
|
|
1229
1721
|
}
|
|
1722
|
+
|
|
1723
|
+
// ── Recurring Invoice types ───────────────────────────────────────────────
|
|
1724
|
+
|
|
1725
|
+
export type RecurringInvoiceStatus = "active" | "paused" | "completed" | "expired";
|
|
1726
|
+
export type RecurringInvoiceFrequency = "weekly" | "biweekly" | "monthly" | "quarterly" | "half_yearly" | "yearly" | "custom";
|
|
1727
|
+
|
|
1728
|
+
export interface RecurringInvoiceSummary {
|
|
1729
|
+
id: string;
|
|
1730
|
+
name: string;
|
|
1731
|
+
partyName: string;
|
|
1732
|
+
type: "sale" | "purchase";
|
|
1733
|
+
frequency: RecurringInvoiceFrequency;
|
|
1734
|
+
status: RecurringInvoiceStatus;
|
|
1735
|
+
nextRunDate: string | null;
|
|
1736
|
+
lastRunDate: string | null;
|
|
1737
|
+
totalRuns: number;
|
|
1738
|
+
maxRuns: number | null;
|
|
1739
|
+
startDate: string;
|
|
1740
|
+
endDate: string | null;
|
|
1741
|
+
createdAt: string;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
export interface RecurringInvoiceLineItem {
|
|
1745
|
+
description: string;
|
|
1746
|
+
quantity: string;
|
|
1747
|
+
unitPrice: string;
|
|
1748
|
+
taxPercent?: string;
|
|
1749
|
+
discountPercent?: string;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
export interface RecurringInvoiceDetail extends RecurringInvoiceSummary {
|
|
1753
|
+
partyId: string;
|
|
1754
|
+
customIntervalDays: number | null;
|
|
1755
|
+
lineItems: RecurringInvoiceLineItem[];
|
|
1756
|
+
notes: string | null;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
export interface RecurringInvoiceListInput {
|
|
1760
|
+
status?: RecurringInvoiceStatus;
|
|
1761
|
+
page?: number;
|
|
1762
|
+
limit?: number;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
export interface RecurringInvoiceCreateInput {
|
|
1766
|
+
partyId: string;
|
|
1767
|
+
name: string;
|
|
1768
|
+
type: "sale" | "purchase";
|
|
1769
|
+
frequency: RecurringInvoiceFrequency;
|
|
1770
|
+
customIntervalDays?: number;
|
|
1771
|
+
lineItems: Array<{
|
|
1772
|
+
description: string;
|
|
1773
|
+
quantity: string;
|
|
1774
|
+
unitPrice: string;
|
|
1775
|
+
taxPercent?: string;
|
|
1776
|
+
discountPercent?: string;
|
|
1777
|
+
}>;
|
|
1778
|
+
startDate: string;
|
|
1779
|
+
endDate?: string;
|
|
1780
|
+
maxRuns?: number;
|
|
1781
|
+
notes?: string;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
export interface RecurringInvoiceExecution {
|
|
1785
|
+
id: string;
|
|
1786
|
+
invoiceNumber: string;
|
|
1787
|
+
status: string;
|
|
1788
|
+
errorMessage: string | null;
|
|
1789
|
+
executedAt: string;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
export interface RecurringInvoicePlanUsage {
|
|
1793
|
+
runsThisMonth: number;
|
|
1794
|
+
totalTemplates: number;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
export interface RecurringInvoiceSuggestion {
|
|
1798
|
+
partyId: string;
|
|
1799
|
+
partyName: string;
|
|
1800
|
+
frequency: string;
|
|
1801
|
+
confidence: number;
|
|
1802
|
+
reason: string;
|
|
1803
|
+
}
|