@reporting-bi/cli 0.1.15 → 0.1.16
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/dist/index.js +37 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10421,20 +10421,44 @@ function parsePastedCode(input) {
|
|
|
10421
10421
|
}
|
|
10422
10422
|
return { code: text2 };
|
|
10423
10423
|
}
|
|
10424
|
+
async function resolveDomain(domain2) {
|
|
10425
|
+
let origin = new URL(domain2).origin;
|
|
10426
|
+
for (let i = 0; i < 5; i++) {
|
|
10427
|
+
let res;
|
|
10428
|
+
try {
|
|
10429
|
+
res = await fetch(`${origin}/auth/info`, { method: "HEAD", redirect: "manual" });
|
|
10430
|
+
} catch {
|
|
10431
|
+
return origin;
|
|
10432
|
+
}
|
|
10433
|
+
const location = res.headers.get("location");
|
|
10434
|
+
if (res.status < 300 || res.status >= 400 || !location) return origin;
|
|
10435
|
+
const next = new URL(location, origin).origin;
|
|
10436
|
+
if (next === origin) return origin;
|
|
10437
|
+
origin = next;
|
|
10438
|
+
}
|
|
10439
|
+
return origin;
|
|
10440
|
+
}
|
|
10424
10441
|
async function login(args) {
|
|
10425
10442
|
const { positional, flags } = parseArgs(args);
|
|
10426
|
-
const
|
|
10443
|
+
const requested = positional[0] || "https://bi.reporting.eu";
|
|
10444
|
+
const domain2 = await resolveDomain(requested);
|
|
10427
10445
|
const accounting2 = flags.accounting ? parseInt(flags.accounting) : void 0;
|
|
10428
10446
|
const port = flags.port ? parseInt(flags.port) : 0;
|
|
10429
10447
|
const browser = flags["no-browser"] !== "true" && canOpenBrowser();
|
|
10430
|
-
console.log(`Logging in to ${domain2}...`);
|
|
10448
|
+
console.log(`Logging in to ${domain2}${domain2 !== requested.replace(/\/+$/, "") ? ` (redirected from ${requested})` : ""}...`);
|
|
10431
10449
|
const code = await getAuthorizationCode(domain2, port, browser);
|
|
10432
10450
|
if (!code) {
|
|
10433
10451
|
console.error("Login cancelled or timed out.");
|
|
10434
10452
|
process.exit(1);
|
|
10435
10453
|
}
|
|
10436
10454
|
const client = createAuthClient(domain2);
|
|
10437
|
-
|
|
10455
|
+
try {
|
|
10456
|
+
await client.authorize(code);
|
|
10457
|
+
} catch (e) {
|
|
10458
|
+
const data = e.data;
|
|
10459
|
+
console.error(`Login failed: ${data?.error_description || data?.error || e.message}${data?.status ? ` (HTTP ${data.status})` : ""}`);
|
|
10460
|
+
process.exit(1);
|
|
10461
|
+
}
|
|
10438
10462
|
const credentials = await client.readCredentials();
|
|
10439
10463
|
if (!credentials?.access_token) {
|
|
10440
10464
|
console.error("Failed to obtain tokens.");
|
|
@@ -36654,7 +36678,7 @@ async function mcp() {
|
|
|
36654
36678
|
setMcpMode();
|
|
36655
36679
|
const server = new McpServer({
|
|
36656
36680
|
name: "reporting-bi",
|
|
36657
|
-
version: "0.1.
|
|
36681
|
+
version: "0.1.16"
|
|
36658
36682
|
});
|
|
36659
36683
|
server.tool(
|
|
36660
36684
|
"status",
|
|
@@ -37195,8 +37219,8 @@ async function checkForUpdate() {
|
|
|
37195
37219
|
saveUpdateCheck({ lastCheck: now });
|
|
37196
37220
|
const latest = await fetchLatestVersion();
|
|
37197
37221
|
if (!latest) return;
|
|
37198
|
-
if (!isNewer(latest, "0.1.
|
|
37199
|
-
console.error(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.
|
|
37222
|
+
if (!isNewer(latest, "0.1.16")) return;
|
|
37223
|
+
console.error(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.16"} \u2192 ${latest}...\x1B[0m`);
|
|
37200
37224
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: ["ignore", 2, 2] });
|
|
37201
37225
|
console.error(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
37202
37226
|
} catch {
|
|
@@ -37208,11 +37232,11 @@ async function forceUpdate() {
|
|
|
37208
37232
|
console.error("Could not fetch latest version from npm.");
|
|
37209
37233
|
process.exit(1);
|
|
37210
37234
|
}
|
|
37211
|
-
if (!isNewer(latest, "0.1.
|
|
37212
|
-
console.log(`Already up to date (${"0.1.
|
|
37235
|
+
if (!isNewer(latest, "0.1.16")) {
|
|
37236
|
+
console.log(`Already up to date (${"0.1.16"}).`);
|
|
37213
37237
|
return;
|
|
37214
37238
|
}
|
|
37215
|
-
console.log(`Updating ${PACKAGE_NAME} ${"0.1.
|
|
37239
|
+
console.log(`Updating ${PACKAGE_NAME} ${"0.1.16"} \u2192 ${latest}...`);
|
|
37216
37240
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
37217
37241
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
37218
37242
|
saveUpdateCheck({ lastCheck: Date.now() });
|
|
@@ -37353,12 +37377,12 @@ Global options:
|
|
|
37353
37377
|
--filter <expression> Filter results (server-side where clause)
|
|
37354
37378
|
--verbose Show API request URLs for debugging
|
|
37355
37379
|
|
|
37356
|
-
Default domain: https://reporting.
|
|
37380
|
+
Default domain: https://bi.reporting.eu
|
|
37357
37381
|
Default language: cs
|
|
37358
37382
|
|
|
37359
37383
|
Examples:
|
|
37360
|
-
rpbi login https://reporting.
|
|
37361
|
-
rpbi use https://reporting.
|
|
37384
|
+
rpbi login https://bi.reporting.eu --accounting 100000
|
|
37385
|
+
rpbi use https://bi.reporting.eu --accounting 100000
|
|
37362
37386
|
rpbi status
|
|
37363
37387
|
|
|
37364
37388
|
rpbi etl list
|
|
@@ -37406,7 +37430,7 @@ Examples:
|
|
|
37406
37430
|
(async () => {
|
|
37407
37431
|
const [command, ...args] = process.argv.slice(2);
|
|
37408
37432
|
if (command === "--version" || command === "-v") {
|
|
37409
|
-
console.log("0.1.
|
|
37433
|
+
console.log("0.1.16");
|
|
37410
37434
|
return;
|
|
37411
37435
|
}
|
|
37412
37436
|
await checkForUpdate();
|