@hisaabo/cli 0.8.6 → 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-ZA43MLWO.js → export-WS24LYNH.js} +47 -14
- 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
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
confirmOrExit
|
|
4
|
+
} from "./chunk-ALOHN6GR.js";
|
|
2
5
|
import {
|
|
3
6
|
HisaaboApiError,
|
|
4
|
-
HisaaboClient
|
|
5
|
-
|
|
7
|
+
HisaaboClient,
|
|
8
|
+
transferTimeoutMs
|
|
9
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
10
|
import {
|
|
7
|
-
requireTenantAuth
|
|
8
|
-
|
|
11
|
+
requireTenantAuth,
|
|
12
|
+
resolveSameOriginUrl
|
|
13
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
14
|
import {
|
|
10
15
|
EXIT,
|
|
11
16
|
fatalError,
|
|
@@ -13,12 +18,11 @@ import {
|
|
|
13
18
|
isInteractive,
|
|
14
19
|
success,
|
|
15
20
|
warn
|
|
16
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2DDIXPNI.js";
|
|
17
22
|
|
|
18
23
|
// src/commands/backup/import.ts
|
|
19
24
|
import { createReadStream } from "fs";
|
|
20
25
|
import { stat } from "fs/promises";
|
|
21
|
-
import * as readline from "readline";
|
|
22
26
|
import chalk from "chalk";
|
|
23
27
|
var EXIT_AUTH = 1;
|
|
24
28
|
var EXIT_TARGET_NOT_EMPTY = 3;
|
|
@@ -33,11 +37,11 @@ async function resolveTenant(client, slugOrId) {
|
|
|
33
37
|
return { id: slugOrId, slug: slugOrId };
|
|
34
38
|
}
|
|
35
39
|
const tenants = await client.tenant.list();
|
|
36
|
-
const match = tenants.find((t) => t.
|
|
40
|
+
const match = tenants.find((t) => t.tenantSlug === slugOrId);
|
|
37
41
|
if (!match) {
|
|
38
42
|
fatalError(`Tenant "${slugOrId}" not found. Run: hisaabo tenant list`, EXIT.NOT_FOUND);
|
|
39
43
|
}
|
|
40
|
-
return { id: match.
|
|
44
|
+
return { id: match.tenantId, slug: match.tenantSlug };
|
|
41
45
|
}
|
|
42
46
|
function formatBytes(bytes) {
|
|
43
47
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -59,15 +63,6 @@ function clearProgress() {
|
|
|
59
63
|
if (!isInteractive()) return;
|
|
60
64
|
process.stdout.write("\r" + " ".repeat(80) + "\r");
|
|
61
65
|
}
|
|
62
|
-
async function confirm(question) {
|
|
63
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
64
|
-
return new Promise((resolve) => {
|
|
65
|
-
rl.question(question, (answer) => {
|
|
66
|
-
rl.close();
|
|
67
|
-
resolve(answer.trim().toLowerCase() === "y");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
66
|
function printCompatibility(compat) {
|
|
72
67
|
if (!compat) return;
|
|
73
68
|
if (compat.appVersionMatch && compat.schemaChecksumMatch) return;
|
|
@@ -115,25 +110,15 @@ async function restoreCommand(opts) {
|
|
|
115
110
|
}
|
|
116
111
|
throw e;
|
|
117
112
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
if (!proceed) {
|
|
125
|
-
console.log(" Cancelled.");
|
|
126
|
-
process.exit(0);
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
warn("Non-interactive mode: pass --yes to skip confirmation.");
|
|
130
|
-
process.exit(0);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
113
|
+
await confirmOrExit(
|
|
114
|
+
`This will import all data from \`${opts.input}\` into tenant \`${tenantSlug}\`.
|
|
115
|
+
Target tenant must be empty. Proceed?`,
|
|
116
|
+
opts
|
|
117
|
+
);
|
|
133
118
|
let uploadUrl;
|
|
134
119
|
try {
|
|
135
120
|
const result = await client.selfImport.request({ tenantId });
|
|
136
|
-
uploadUrl = result.url
|
|
121
|
+
uploadUrl = resolveSameOriginUrl(result.url, cfg.apiUrl);
|
|
137
122
|
} catch (e) {
|
|
138
123
|
if (e instanceof HisaaboApiError) {
|
|
139
124
|
const err = e.hisaaboError;
|
|
@@ -170,12 +155,20 @@ async function restoreCommand(opts) {
|
|
|
170
155
|
printUploadProgress(uploaded, fileStats.size, Date.now() - startTime);
|
|
171
156
|
}, 250);
|
|
172
157
|
let responseBody;
|
|
158
|
+
const abort = new AbortController();
|
|
159
|
+
let idleTimer;
|
|
160
|
+
const bumpIdle = () => {
|
|
161
|
+
if (idleTimer) clearTimeout(idleTimer);
|
|
162
|
+
idleTimer = setTimeout(() => abort.abort(), transferTimeoutMs());
|
|
163
|
+
};
|
|
164
|
+
bumpIdle();
|
|
173
165
|
try {
|
|
174
166
|
const nodeReadStream = createReadStream(opts.input);
|
|
175
167
|
const webReadable = new ReadableStream({
|
|
176
168
|
start(controller) {
|
|
177
169
|
nodeReadStream.on("data", (chunk) => {
|
|
178
170
|
const buf = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
171
|
+
bumpIdle();
|
|
179
172
|
uploaded += buf.length;
|
|
180
173
|
controller.enqueue(new Uint8Array(buf));
|
|
181
174
|
});
|
|
@@ -195,9 +188,12 @@ async function restoreCommand(opts) {
|
|
|
195
188
|
"Content-Length": String(fileStats.size)
|
|
196
189
|
},
|
|
197
190
|
body: webReadable,
|
|
191
|
+
redirect: "error",
|
|
192
|
+
signal: abort.signal,
|
|
198
193
|
// @ts-expect-error -- Node 18+ fetch needs duplex for request body streaming
|
|
199
194
|
duplex: "half"
|
|
200
195
|
});
|
|
196
|
+
if (idleTimer) clearTimeout(idleTimer);
|
|
201
197
|
clearInterval(progressInterval);
|
|
202
198
|
progressInterval = void 0;
|
|
203
199
|
clearProgress();
|
|
@@ -218,6 +214,7 @@ async function restoreCommand(opts) {
|
|
|
218
214
|
}
|
|
219
215
|
responseBody = raw;
|
|
220
216
|
} catch (e) {
|
|
217
|
+
if (idleTimer) clearTimeout(idleTimer);
|
|
221
218
|
if (progressInterval !== void 0) {
|
|
222
219
|
clearInterval(progressInterval);
|
|
223
220
|
}
|
|
@@ -2,17 +2,17 @@
|
|
|
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
14
|
outputTable
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2DDIXPNI.js";
|
|
16
16
|
|
|
17
17
|
// src/commands/tenant/invitations.ts
|
|
18
18
|
import chalk from "chalk";
|
|
@@ -25,21 +25,18 @@ async function listInvitationsCommand(opts) {
|
|
|
25
25
|
outputJSON(invitations);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const items =
|
|
28
|
+
const items = invitations;
|
|
29
29
|
if (items.length === 0) {
|
|
30
30
|
console.log("No pending invitations.");
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const rows = items.map((
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
expires: inv["expiresAt"] ? new Date(String(inv["expiresAt"])).toLocaleDateString() : "\u2014"
|
|
41
|
-
};
|
|
42
|
-
});
|
|
33
|
+
const rows = items.map((inv) => ({
|
|
34
|
+
id: inv.id.slice(0, 8) + "...",
|
|
35
|
+
email: inv.email,
|
|
36
|
+
role: inv.role,
|
|
37
|
+
invitedBy: inv.invitedByName ?? "\u2014",
|
|
38
|
+
expires: inv.expiresAt.toLocaleDateString()
|
|
39
|
+
}));
|
|
43
40
|
const columns = [
|
|
44
41
|
{ key: "id", header: "ID", align: "left" },
|
|
45
42
|
{ key: "email", header: "Email", align: "left" },
|
|
@@ -2,41 +2,39 @@
|
|
|
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
13
|
success
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/tenant/invite.ts
|
|
17
17
|
var VALID_ROLES = ["admin", "seller_manager", "seller", "accountant"];
|
|
18
|
+
function isTenantRole(v) {
|
|
19
|
+
return VALID_ROLES.includes(v);
|
|
20
|
+
}
|
|
18
21
|
async function tenantInviteCommand(email, opts) {
|
|
19
22
|
const cfg = requireAuth();
|
|
20
23
|
const client = new HisaaboClient(cfg);
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
fatalError(`Invalid role "${
|
|
24
|
+
const requested = opts.role ?? "seller";
|
|
25
|
+
if (!isTenantRole(requested)) {
|
|
26
|
+
fatalError(`Invalid role "${requested}". Must be one of: ${VALID_ROLES.join(", ")}`, EXIT.VALIDATION);
|
|
24
27
|
}
|
|
28
|
+
const role = requested;
|
|
25
29
|
try {
|
|
26
30
|
const result = await client.tenant.inviteMember({ email, role });
|
|
27
31
|
if (opts.json) {
|
|
28
32
|
outputJSON(result);
|
|
29
33
|
return;
|
|
30
34
|
}
|
|
31
|
-
success(`Invited ${email} as ${role}`);
|
|
32
|
-
if (result.
|
|
33
|
-
|
|
34
|
-
} else if (result.inviteToken) {
|
|
35
|
-
console.log(` Invite token: ${result.inviteToken}`);
|
|
36
|
-
}
|
|
37
|
-
if (result.message) {
|
|
38
|
-
console.log(` ${result.message}`);
|
|
39
|
-
}
|
|
35
|
+
success(`Invited ${email} as ${role} (invitation emailed)`);
|
|
36
|
+
if (result.inviteUrl) console.log(` Invite link: ${result.inviteUrl}`);
|
|
37
|
+
console.log(` Expires: ${result.expiresAt.toISOString()}`);
|
|
40
38
|
} catch (e) {
|
|
41
39
|
if (e instanceof HisaaboApiError) {
|
|
42
40
|
const err = e.hisaaboError;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
apiFrom,
|
|
4
|
+
apiTo,
|
|
3
5
|
formatAmount,
|
|
4
6
|
formatStatus,
|
|
5
7
|
fyStart,
|
|
6
8
|
monthEnd,
|
|
7
9
|
monthStart,
|
|
8
10
|
todayISO
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-M7DVLVD5.js";
|
|
10
12
|
import {
|
|
11
13
|
HisaaboApiError,
|
|
12
14
|
HisaaboClient
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VXEEFNIY.js";
|
|
14
16
|
import {
|
|
15
17
|
requireAuth
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ESX7V56A.js";
|
|
17
19
|
import {
|
|
18
20
|
EXIT,
|
|
19
21
|
fatalError,
|
|
20
22
|
hasColor,
|
|
21
23
|
outputJSON,
|
|
22
24
|
outputTable
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-2DDIXPNI.js";
|
|
24
26
|
|
|
25
27
|
// src/commands/dashboard/invoice-breakdown.ts
|
|
26
28
|
import chalk from "chalk";
|
|
@@ -37,43 +39,16 @@ async function dashboardInvoiceBreakdownCommand(opts) {
|
|
|
37
39
|
toDate = todayISO();
|
|
38
40
|
}
|
|
39
41
|
try {
|
|
40
|
-
const data = await client.dashboard.invoiceStatusBreakdown({ fromDate, toDate });
|
|
42
|
+
const data = await client.dashboard.invoiceStatusBreakdown({ fromDate: apiFrom(fromDate), toDate: apiTo(toDate) });
|
|
41
43
|
if (opts.json) {
|
|
42
44
|
outputJSON(data);
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
count: String(r["count"] ?? "-"),
|
|
51
|
-
amount: formatAmount(String(r["totalAmount"] ?? r["amount"] ?? "0"))
|
|
52
|
-
}));
|
|
53
|
-
} else if (data && typeof data === "object") {
|
|
54
|
-
const obj = data;
|
|
55
|
-
rows = ORDER.flatMap((status) => {
|
|
56
|
-
const entry = obj[status];
|
|
57
|
-
if (!entry) return [];
|
|
58
|
-
return [{
|
|
59
|
-
status: formatStatus(status),
|
|
60
|
-
count: String(entry["count"] ?? "-"),
|
|
61
|
-
amount: formatAmount(String(entry["totalAmount"] ?? entry["amount"] ?? "0"))
|
|
62
|
-
}];
|
|
63
|
-
});
|
|
64
|
-
for (const key of Object.keys(obj)) {
|
|
65
|
-
if (!ORDER.includes(key)) {
|
|
66
|
-
const entry = obj[key];
|
|
67
|
-
rows.push({
|
|
68
|
-
status: formatStatus(key),
|
|
69
|
-
count: String(entry["count"] ?? "-"),
|
|
70
|
-
amount: formatAmount(String(entry["totalAmount"] ?? entry["amount"] ?? "0"))
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
rows = [];
|
|
76
|
-
}
|
|
47
|
+
const rows = data.map((r) => ({
|
|
48
|
+
status: formatStatus(r.status),
|
|
49
|
+
count: String(r.count),
|
|
50
|
+
amount: formatAmount(r.total)
|
|
51
|
+
}));
|
|
77
52
|
const columns = [
|
|
78
53
|
{ key: "status", header: "Status", align: "left" },
|
|
79
54
|
{ key: "count", header: "Count", align: "right" },
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
formatAmount
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M7DVLVD5.js";
|
|
5
5
|
import {
|
|
6
6
|
HisaaboApiError,
|
|
7
7
|
HisaaboClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VXEEFNIY.js";
|
|
9
9
|
import {
|
|
10
10
|
requireAuth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ESX7V56A.js";
|
|
12
12
|
import {
|
|
13
13
|
EXIT,
|
|
14
14
|
fatalError,
|
|
@@ -16,24 +16,25 @@ import {
|
|
|
16
16
|
outputJSON,
|
|
17
17
|
outputTSV,
|
|
18
18
|
outputTable
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2DDIXPNI.js";
|
|
20
20
|
|
|
21
21
|
// src/commands/store/items.ts
|
|
22
22
|
async function storeItemsCommand(opts) {
|
|
23
23
|
const cfg = requireAuth();
|
|
24
24
|
const client = new HisaaboClient(cfg);
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
26
|
+
const result = await client.store.listStoreItems({});
|
|
27
|
+
const items = result.data;
|
|
27
28
|
if (opts.json) {
|
|
28
|
-
outputJSON(
|
|
29
|
+
outputJSON(result);
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
const cols = [
|
|
32
33
|
{ key: "id", header: "ID", width: 36 },
|
|
33
34
|
{ key: "name", header: "Name", width: 30 },
|
|
34
|
-
{ key: "
|
|
35
|
-
{ key: "
|
|
36
|
-
{ key: "
|
|
35
|
+
{ key: "salePrice", header: "Price (\u20B9)", align: "right", width: 12, format: (v) => formatAmount(String(v ?? "0")) },
|
|
36
|
+
{ key: "storeEnabled", header: "Status", width: 10, format: (v) => v ? "Enabled" : "Disabled" },
|
|
37
|
+
{ key: "stockQuantity", header: "Stock", align: "right", width: 8, format: (v) => v == null ? "-" : String(v) }
|
|
37
38
|
];
|
|
38
39
|
if (opts.format === "tsv") {
|
|
39
40
|
outputTSV(items, cols);
|
|
@@ -44,7 +45,7 @@ async function storeItemsCommand(opts) {
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
console.log(`
|
|
47
|
-
Store Items (${
|
|
48
|
+
Store Items (${result.total} total)
|
|
48
49
|
`);
|
|
49
50
|
outputTable(items, cols);
|
|
50
51
|
console.log();
|
|
@@ -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
|
outputJSON,
|
|
13
13
|
success
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/store/items-toggle.ts
|
|
17
17
|
async function storeItemsToggleCommand(opts) {
|
|
@@ -23,9 +23,10 @@ async function storeItemsToggleCommand(opts) {
|
|
|
23
23
|
const enableIds = opts.enable ? opts.enable.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
24
24
|
const disableIds = opts.disable ? opts.disable.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
26
|
+
const enabled = enableIds.length > 0 ? await client.store.bulkToggleItems({ itemIds: enableIds, storeEnabled: true }) : null;
|
|
27
|
+
const disabled = disableIds.length > 0 ? await client.store.bulkToggleItems({ itemIds: disableIds, storeEnabled: false }) : null;
|
|
27
28
|
if (opts.json) {
|
|
28
|
-
outputJSON(
|
|
29
|
+
outputJSON({ enabled, disabled });
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
if (enableIds.length > 0) success(`Enabled ${enableIds.length} item(s)`);
|
|
@@ -2,17 +2,17 @@
|
|
|
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
14
|
outputTable
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2DDIXPNI.js";
|
|
16
16
|
|
|
17
17
|
// src/commands/session/list.ts
|
|
18
18
|
import chalk from "chalk";
|
|
@@ -25,22 +25,19 @@ async function listSessionsCommand(opts) {
|
|
|
25
25
|
outputJSON(sessions);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const items =
|
|
28
|
+
const items = sessions;
|
|
29
29
|
if (items.length === 0) {
|
|
30
30
|
console.log(opts.expired ? "No expired sessions." : "No active sessions.");
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const rows = items.map((
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
current: s["isCurrent"] ? "\u2713" : ""
|
|
42
|
-
};
|
|
43
|
-
});
|
|
33
|
+
const rows = items.map((s) => ({
|
|
34
|
+
id: s.id.slice(0, 12) + "...",
|
|
35
|
+
device: s.userAgent ? parseUA(s.userAgent) : "Unknown",
|
|
36
|
+
ip: s.ipAddress ?? "\u2014",
|
|
37
|
+
lastUsed: s.lastUsedAt ? timeAgo(s.lastUsedAt) : "\u2014",
|
|
38
|
+
created: s.createdAt.toLocaleDateString(),
|
|
39
|
+
current: s.isCurrent ? "\u2713" : ""
|
|
40
|
+
}));
|
|
44
41
|
const columns = [
|
|
45
42
|
{ key: "id", header: "ID", align: "left" },
|
|
46
43
|
{ key: "device", header: "Device", align: "left" },
|
|
@@ -77,7 +74,7 @@ function parseUA(ua) {
|
|
|
77
74
|
return os ? `${browser} / ${os}` : browser;
|
|
78
75
|
}
|
|
79
76
|
function timeAgo(date) {
|
|
80
|
-
const diff = Date.now() -
|
|
77
|
+
const diff = Date.now() - date.getTime();
|
|
81
78
|
const mins = Math.floor(diff / 6e4);
|
|
82
79
|
if (mins < 1) return "now";
|
|
83
80
|
if (mins < 60) return `${mins}m ago`;
|
|
@@ -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
|
outputJSON,
|
|
13
13
|
outputTable
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/tenant/list.ts
|
|
17
17
|
async function tenantListCommand(opts) {
|
|
@@ -27,8 +27,8 @@ async function tenantListCommand(opts) {
|
|
|
27
27
|
Organizations ${result.length} total
|
|
28
28
|
`);
|
|
29
29
|
const cols = [
|
|
30
|
-
{ key: "
|
|
31
|
-
{ key: "
|
|
30
|
+
{ key: "tenantName", header: "Name", width: 30 },
|
|
31
|
+
{ key: "tenantSlug", header: "Slug", width: 24 },
|
|
32
32
|
{ key: "role", header: "Role", width: 16 }
|
|
33
33
|
];
|
|
34
34
|
outputTable(result, cols);
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
formatDate,
|
|
4
4
|
formatRelativeDate
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-M7DVLVD5.js";
|
|
6
6
|
import {
|
|
7
7
|
HisaaboApiError,
|
|
8
8
|
HisaaboClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VXEEFNIY.js";
|
|
10
10
|
import {
|
|
11
11
|
requireAuth
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ESX7V56A.js";
|
|
13
13
|
import {
|
|
14
14
|
EXIT,
|
|
15
15
|
fatalError,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
outputJSON,
|
|
19
19
|
outputTSV,
|
|
20
20
|
outputTable
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2DDIXPNI.js";
|
|
22
22
|
|
|
23
23
|
// src/commands/api-key/list.ts
|
|
24
24
|
import chalk from "chalk";
|
|
@@ -31,21 +31,20 @@ async function apiKeyListCommand(opts) {
|
|
|
31
31
|
outputJSON(keys);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const items =
|
|
34
|
+
const items = keys;
|
|
35
35
|
if (items.length === 0) {
|
|
36
36
|
process.stdout.write("\n No API keys found.\n Use: hisaabo api-key create --name <name>\n\n");
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
const rows = items.map((
|
|
40
|
-
const
|
|
41
|
-
const rawKey = String(k["keyPrefix"] ?? k["prefix"] ?? k["key"] ?? "");
|
|
39
|
+
const rows = items.map((k) => {
|
|
40
|
+
const rawKey = k.keyPrefix;
|
|
42
41
|
const displayKey = rawKey.length > 20 ? rawKey.slice(0, 20) + "..." : rawKey || "-";
|
|
43
42
|
return {
|
|
44
|
-
name:
|
|
43
|
+
name: k.name,
|
|
45
44
|
prefix: displayKey,
|
|
46
|
-
created: formatDate(
|
|
47
|
-
lastUsed: k
|
|
48
|
-
id:
|
|
45
|
+
created: formatDate(k.createdAt),
|
|
46
|
+
lastUsed: k.lastUsedAt ? formatRelativeDate(k.lastUsedAt) : "Never",
|
|
47
|
+
id: k.id
|
|
49
48
|
};
|
|
50
49
|
});
|
|
51
50
|
const columns = [
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
formatDate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M7DVLVD5.js";
|
|
5
5
|
import {
|
|
6
6
|
HisaaboApiError,
|
|
7
7
|
HisaaboClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VXEEFNIY.js";
|
|
9
9
|
import {
|
|
10
10
|
requireAuth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ESX7V56A.js";
|
|
12
12
|
import {
|
|
13
13
|
EXIT,
|
|
14
14
|
fatalError,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
outputJSON,
|
|
17
17
|
outputTSV,
|
|
18
18
|
outputTable
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2DDIXPNI.js";
|
|
20
20
|
|
|
21
21
|
// src/commands/tenant/members.ts
|
|
22
22
|
async function tenantMembersCommand(opts) {
|
|
@@ -32,10 +32,10 @@ async function tenantMembersCommand(opts) {
|
|
|
32
32
|
Team Members ${result.length} total
|
|
33
33
|
`);
|
|
34
34
|
const cols = [
|
|
35
|
-
{ key: "
|
|
36
|
-
{ key: "
|
|
35
|
+
{ key: "userName", header: "Name", width: 24 },
|
|
36
|
+
{ key: "userEmail", header: "Email", width: 30 },
|
|
37
37
|
{ key: "role", header: "Role", width: 18 },
|
|
38
|
-
{ key: "
|
|
38
|
+
{ key: "acceptedAt", header: "Joined", width: 13, format: (v) => formatDate(v) }
|
|
39
39
|
];
|
|
40
40
|
if (opts.format === "tsv") outputTSV(result, cols);
|
|
41
41
|
else if (opts.format === "csv") outputCSV(result, cols);
|