@reporting-bi/cli 0.1.13 → 0.1.15
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 +204 -68
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2533,11 +2533,11 @@ var require_lib = __commonJS({
|
|
|
2533
2533
|
"../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/index.js"(exports2, module2) {
|
|
2534
2534
|
"use strict";
|
|
2535
2535
|
var stringify = require_stringify();
|
|
2536
|
-
var
|
|
2536
|
+
var parse6 = require_parse();
|
|
2537
2537
|
var formats = require_formats();
|
|
2538
2538
|
module2.exports = {
|
|
2539
2539
|
formats,
|
|
2540
|
-
parse:
|
|
2540
|
+
parse: parse6,
|
|
2541
2541
|
stringify
|
|
2542
2542
|
};
|
|
2543
2543
|
}
|
|
@@ -6089,24 +6089,24 @@ var require_fast_uri = __commonJS({
|
|
|
6089
6089
|
function normalize(uri, options) {
|
|
6090
6090
|
if (typeof uri === "string") {
|
|
6091
6091
|
uri = /** @type {T} */
|
|
6092
|
-
serialize(
|
|
6092
|
+
serialize(parse6(uri, options), options);
|
|
6093
6093
|
} else if (typeof uri === "object") {
|
|
6094
6094
|
uri = /** @type {T} */
|
|
6095
|
-
|
|
6095
|
+
parse6(serialize(uri, options), options);
|
|
6096
6096
|
}
|
|
6097
6097
|
return uri;
|
|
6098
6098
|
}
|
|
6099
6099
|
function resolve8(baseURI, relativeURI, options) {
|
|
6100
6100
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
6101
|
-
const resolved = resolveComponent(
|
|
6101
|
+
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
6102
6102
|
schemelessOptions.skipEscape = true;
|
|
6103
6103
|
return serialize(resolved, schemelessOptions);
|
|
6104
6104
|
}
|
|
6105
6105
|
function resolveComponent(base, relative6, options, skipNormalization) {
|
|
6106
6106
|
const target = {};
|
|
6107
6107
|
if (!skipNormalization) {
|
|
6108
|
-
base =
|
|
6109
|
-
relative6 =
|
|
6108
|
+
base = parse6(serialize(base, options), options);
|
|
6109
|
+
relative6 = parse6(serialize(relative6, options), options);
|
|
6110
6110
|
}
|
|
6111
6111
|
options = options || {};
|
|
6112
6112
|
if (!options.tolerant && relative6.scheme) {
|
|
@@ -6158,13 +6158,13 @@ var require_fast_uri = __commonJS({
|
|
|
6158
6158
|
function equal(uriA, uriB, options) {
|
|
6159
6159
|
if (typeof uriA === "string") {
|
|
6160
6160
|
uriA = unescape(uriA);
|
|
6161
|
-
uriA = serialize(normalizeComponentEncoding(
|
|
6161
|
+
uriA = serialize(normalizeComponentEncoding(parse6(uriA, options), true), { ...options, skipEscape: true });
|
|
6162
6162
|
} else if (typeof uriA === "object") {
|
|
6163
6163
|
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
|
|
6164
6164
|
}
|
|
6165
6165
|
if (typeof uriB === "string") {
|
|
6166
6166
|
uriB = unescape(uriB);
|
|
6167
|
-
uriB = serialize(normalizeComponentEncoding(
|
|
6167
|
+
uriB = serialize(normalizeComponentEncoding(parse6(uriB, options), true), { ...options, skipEscape: true });
|
|
6168
6168
|
} else if (typeof uriB === "object") {
|
|
6169
6169
|
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
|
|
6170
6170
|
}
|
|
@@ -6233,7 +6233,7 @@ var require_fast_uri = __commonJS({
|
|
|
6233
6233
|
return uriTokens.join("");
|
|
6234
6234
|
}
|
|
6235
6235
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
6236
|
-
function
|
|
6236
|
+
function parse6(uri, opts) {
|
|
6237
6237
|
const options = Object.assign({}, opts);
|
|
6238
6238
|
const parsed = {
|
|
6239
6239
|
scheme: void 0,
|
|
@@ -6327,7 +6327,7 @@ var require_fast_uri = __commonJS({
|
|
|
6327
6327
|
resolveComponent,
|
|
6328
6328
|
equal,
|
|
6329
6329
|
serialize,
|
|
6330
|
-
parse:
|
|
6330
|
+
parse: parse6
|
|
6331
6331
|
};
|
|
6332
6332
|
module2.exports = fastUri;
|
|
6333
6333
|
module2.exports.default = fastUri;
|
|
@@ -9315,6 +9315,7 @@ var require_dist = __commonJS({
|
|
|
9315
9315
|
// src/commands/login.ts
|
|
9316
9316
|
var http = __toESM(require("node:http"));
|
|
9317
9317
|
var import_node_child_process2 = require("node:child_process");
|
|
9318
|
+
var readline = __toESM(require("node:readline"));
|
|
9318
9319
|
|
|
9319
9320
|
// src/config.ts
|
|
9320
9321
|
var fs2 = __toESM(require("node:fs"));
|
|
@@ -9536,13 +9537,23 @@ var ReportingAuthClient = class {
|
|
|
9536
9537
|
}
|
|
9537
9538
|
return tokenInfo;
|
|
9538
9539
|
}
|
|
9540
|
+
/**
|
|
9541
|
+
* Revokes the session. A SAML2 session answers with `logout_url` - the caller navigates there so
|
|
9542
|
+
* the identity provider session ends too; every other session answers with an empty body.
|
|
9543
|
+
*/
|
|
9539
9544
|
async logout() {
|
|
9540
|
-
await this.fetchWithAuth(`${this.options.serviceUrl}/revoke`, {
|
|
9545
|
+
const response = await this.fetchWithAuth(`${this.options.serviceUrl}/revoke`, {
|
|
9541
9546
|
method: "GET",
|
|
9542
9547
|
headers: {
|
|
9543
9548
|
"Content-Type": "application/json"
|
|
9544
9549
|
}
|
|
9545
9550
|
});
|
|
9551
|
+
const text2 = response.ok ? await response.text() : "";
|
|
9552
|
+
try {
|
|
9553
|
+
return text2 ? JSON.parse(text2) : {};
|
|
9554
|
+
} catch {
|
|
9555
|
+
return {};
|
|
9556
|
+
}
|
|
9546
9557
|
}
|
|
9547
9558
|
redirectToLogin() {
|
|
9548
9559
|
if (typeof window === "undefined") throw new Error("Not in browser environment");
|
|
@@ -9757,13 +9768,13 @@ var Service = class extends EventTarget {
|
|
|
9757
9768
|
throw new ServiceException({ data: error48, url: response.url });
|
|
9758
9769
|
}
|
|
9759
9770
|
}
|
|
9760
|
-
async handleResponse(response,
|
|
9771
|
+
async handleResponse(response, parse6) {
|
|
9761
9772
|
if (!response.ok) {
|
|
9762
9773
|
await this.handleError(response);
|
|
9763
9774
|
return null;
|
|
9764
9775
|
}
|
|
9765
9776
|
const contentType = response.headers.get("Content-Type");
|
|
9766
|
-
if (contentType?.includes("application/json") &&
|
|
9777
|
+
if (contentType?.includes("application/json") && parse6 !== false) {
|
|
9767
9778
|
return await response.json();
|
|
9768
9779
|
} else {
|
|
9769
9780
|
return await response.text();
|
|
@@ -9921,6 +9932,12 @@ var CLIENT_SECRET = "48481427819bb41798bd74fa109c90b184ca4d64d20e60dfbe8430299f0
|
|
|
9921
9932
|
var EXIT_LOGIN_REQUIRED = 2;
|
|
9922
9933
|
var LOGIN_REQUIRED_MARKER = "rpbi: login_required";
|
|
9923
9934
|
var SPID_MARKER = "rpbi: spid";
|
|
9935
|
+
function readSqlInput(flags) {
|
|
9936
|
+
if (flags.stdin) return fs2.readFileSync(0, "utf-8");
|
|
9937
|
+
if (flags.file) return fs2.readFileSync(flags.file, "utf-8");
|
|
9938
|
+
if (flags.sql) return flags.sql;
|
|
9939
|
+
return void 0;
|
|
9940
|
+
}
|
|
9924
9941
|
var LoginRequiredError = class extends Error {
|
|
9925
9942
|
constructor(domain2, detail) {
|
|
9926
9943
|
super(`Session expired. Run "rpbi login ${domain2}" again.`);
|
|
@@ -10270,6 +10287,21 @@ function output(data, flags) {
|
|
|
10270
10287
|
console.log(data);
|
|
10271
10288
|
}
|
|
10272
10289
|
}
|
|
10290
|
+
function outputParseResult(result, flags) {
|
|
10291
|
+
const errors = result?.errors ?? [];
|
|
10292
|
+
if (flags.json) {
|
|
10293
|
+
output({ errors }, flags);
|
|
10294
|
+
return;
|
|
10295
|
+
}
|
|
10296
|
+
if (errors.length === 0) {
|
|
10297
|
+
console.log("No syntax errors.");
|
|
10298
|
+
return;
|
|
10299
|
+
}
|
|
10300
|
+
for (const error48 of errors) {
|
|
10301
|
+
console.log(error48.line ? `Line ${error48.line}: ${error48.error}` : `${error48.error}`);
|
|
10302
|
+
}
|
|
10303
|
+
process.exitCode = 1;
|
|
10304
|
+
}
|
|
10273
10305
|
function errorMessage(err) {
|
|
10274
10306
|
const data = err?.data;
|
|
10275
10307
|
return data?.message || data?.error || (err instanceof Error ? err.message : String(err));
|
|
@@ -10366,17 +10398,37 @@ var callback_default = `<!DOCTYPE html>
|
|
|
10366
10398
|
function renderCallback(status6, title, message) {
|
|
10367
10399
|
return callback_default.replace("{{status}}", status6).replace("{{title}}", title).replace("{{message}}", message);
|
|
10368
10400
|
}
|
|
10369
|
-
function
|
|
10401
|
+
function canOpenBrowser() {
|
|
10402
|
+
const env = process.env;
|
|
10403
|
+
if (process.platform === "linux" || process.platform === "freebsd" || process.platform === "openbsd") {
|
|
10404
|
+
return !!(env.DISPLAY || env.WAYLAND_DISPLAY);
|
|
10405
|
+
}
|
|
10406
|
+
return !(env.SSH_CONNECTION || env.SSH_TTY);
|
|
10407
|
+
}
|
|
10408
|
+
function openBrowser(url2, onError) {
|
|
10370
10409
|
const platform = process.platform;
|
|
10371
10410
|
const cmd = platform === "darwin" ? "open" : platform === "win32" ? 'start ""' : "xdg-open";
|
|
10372
|
-
(0, import_node_child_process2.exec)(`${cmd} ${JSON.stringify(url2)}
|
|
10411
|
+
(0, import_node_child_process2.exec)(`${cmd} ${JSON.stringify(url2)}`, (err) => {
|
|
10412
|
+
if (err) onError();
|
|
10413
|
+
});
|
|
10414
|
+
}
|
|
10415
|
+
function parsePastedCode(input) {
|
|
10416
|
+
const text2 = input.trim();
|
|
10417
|
+
if (!text2) return {};
|
|
10418
|
+
if (/[?&](code|error)=/.test(text2)) {
|
|
10419
|
+
const params3 = new URL(text2, "http://localhost").searchParams;
|
|
10420
|
+
return { code: params3.get("code") || void 0, error: params3.get("error") || void 0 };
|
|
10421
|
+
}
|
|
10422
|
+
return { code: text2 };
|
|
10373
10423
|
}
|
|
10374
10424
|
async function login(args) {
|
|
10375
10425
|
const { positional, flags } = parseArgs(args);
|
|
10376
10426
|
const domain2 = positional[0] || "https://reporting.bi";
|
|
10377
10427
|
const accounting2 = flags.accounting ? parseInt(flags.accounting) : void 0;
|
|
10428
|
+
const port = flags.port ? parseInt(flags.port) : 0;
|
|
10429
|
+
const browser = flags["no-browser"] !== "true" && canOpenBrowser();
|
|
10378
10430
|
console.log(`Logging in to ${domain2}...`);
|
|
10379
|
-
const code = await getAuthorizationCode(domain2);
|
|
10431
|
+
const code = await getAuthorizationCode(domain2, port, browser);
|
|
10380
10432
|
if (!code) {
|
|
10381
10433
|
console.error("Login cancelled or timed out.");
|
|
10382
10434
|
process.exit(1);
|
|
@@ -10409,12 +10461,17 @@ async function login(args) {
|
|
|
10409
10461
|
console.log('No accounting set. Use "rpbi use <domain> --accounting <id>" to set one.');
|
|
10410
10462
|
}
|
|
10411
10463
|
}
|
|
10412
|
-
function getAuthorizationCode(domain2) {
|
|
10464
|
+
function getAuthorizationCode(domain2, port, browser) {
|
|
10413
10465
|
return new Promise((resolve8) => {
|
|
10414
10466
|
let timeout;
|
|
10467
|
+
let rl;
|
|
10468
|
+
let finished = false;
|
|
10415
10469
|
const done = (result) => {
|
|
10470
|
+
if (finished) return;
|
|
10471
|
+
finished = true;
|
|
10416
10472
|
clearTimeout(timeout);
|
|
10417
10473
|
server.close();
|
|
10474
|
+
rl?.close();
|
|
10418
10475
|
resolve8(result);
|
|
10419
10476
|
};
|
|
10420
10477
|
const server = http.createServer((req, res) => {
|
|
@@ -10432,17 +10489,57 @@ function getAuthorizationCode(domain2) {
|
|
|
10432
10489
|
res.end("Waiting for authentication...");
|
|
10433
10490
|
}
|
|
10434
10491
|
});
|
|
10435
|
-
server.
|
|
10492
|
+
server.on("error", (err) => {
|
|
10493
|
+
console.error(`Cannot listen for the login callback: ${err.message}`);
|
|
10494
|
+
done(null);
|
|
10495
|
+
});
|
|
10496
|
+
server.listen(port, "localhost", () => {
|
|
10436
10497
|
const address = server.address();
|
|
10437
10498
|
if (!address || typeof address === "string") {
|
|
10438
10499
|
done(null);
|
|
10439
10500
|
return;
|
|
10440
10501
|
}
|
|
10441
|
-
const
|
|
10442
|
-
const redirectUri = `http://localhost:${port}`;
|
|
10502
|
+
const redirectUri = `http://localhost:${address.port}`;
|
|
10443
10503
|
const authUrl = `${domain2}/auth?client_id=${CLIENT_ID}&redirect_uri=${encodeURIComponent(redirectUri)}`;
|
|
10444
|
-
|
|
10445
|
-
|
|
10504
|
+
const printManual = () => {
|
|
10505
|
+
console.log("Open this URL in a browser and sign in:");
|
|
10506
|
+
console.log("");
|
|
10507
|
+
console.log(` ${authUrl}`);
|
|
10508
|
+
console.log("");
|
|
10509
|
+
if (process.stdin.isTTY) {
|
|
10510
|
+
console.log(`The browser then goes to ${redirectUri}/?code=... - if that page does not load`);
|
|
10511
|
+
console.log("(the browser runs on another machine), copy its whole address from the address bar");
|
|
10512
|
+
console.log("and paste it here.");
|
|
10513
|
+
}
|
|
10514
|
+
};
|
|
10515
|
+
if (browser) {
|
|
10516
|
+
console.log("Opening browser for authentication...");
|
|
10517
|
+
console.log(`If it does not open, visit: ${authUrl}`);
|
|
10518
|
+
openBrowser(authUrl, () => {
|
|
10519
|
+
console.log("Could not open a browser.");
|
|
10520
|
+
printManual();
|
|
10521
|
+
});
|
|
10522
|
+
} else {
|
|
10523
|
+
printManual();
|
|
10524
|
+
}
|
|
10525
|
+
if (process.stdin.isTTY) {
|
|
10526
|
+
rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false });
|
|
10527
|
+
rl.on("line", (line) => {
|
|
10528
|
+
let pasted;
|
|
10529
|
+
try {
|
|
10530
|
+
pasted = parsePastedCode(line);
|
|
10531
|
+
} catch {
|
|
10532
|
+
console.error("Not a valid address, paste the whole URL from the address bar.");
|
|
10533
|
+
return;
|
|
10534
|
+
}
|
|
10535
|
+
if (pasted.error) {
|
|
10536
|
+
console.error(`Login failed: ${pasted.error}`);
|
|
10537
|
+
done(null);
|
|
10538
|
+
} else if (pasted.code) {
|
|
10539
|
+
done(pasted.code);
|
|
10540
|
+
}
|
|
10541
|
+
});
|
|
10542
|
+
}
|
|
10446
10543
|
});
|
|
10447
10544
|
timeout = setTimeout(() => done(null), 5 * 60 * 1e3);
|
|
10448
10545
|
});
|
|
@@ -11829,12 +11926,7 @@ async function content(id, flags) {
|
|
|
11829
11926
|
}
|
|
11830
11927
|
async function exec2(id, flags) {
|
|
11831
11928
|
const service = await createService("etl", { cwd: flags.dir || "." });
|
|
11832
|
-
|
|
11833
|
-
if (flags.file) {
|
|
11834
|
-
body = fs8.readFileSync(flags.file, "utf-8");
|
|
11835
|
-
} else if (flags.sql) {
|
|
11836
|
-
body = flags.sql;
|
|
11837
|
-
}
|
|
11929
|
+
const body = readSqlInput(flags);
|
|
11838
11930
|
if (flags.output) {
|
|
11839
11931
|
const response = await service.postRaw(`exec/${id}`, body, {
|
|
11840
11932
|
csv_delimiter: " ",
|
|
@@ -11860,6 +11952,12 @@ async function exec2(id, flags) {
|
|
|
11860
11952
|
process.stdout.write(result || "");
|
|
11861
11953
|
}
|
|
11862
11954
|
}
|
|
11955
|
+
async function parse(id, flags) {
|
|
11956
|
+
const service = await createService("etl", { cwd: flags.dir || "." });
|
|
11957
|
+
const body = readSqlInput(flags) ?? await service.get(`threads/${id}/content`, void 0, { parseResponse: false }) ?? "";
|
|
11958
|
+
const result = await service.post(`parse/${id}`, body).catch((err) => fail(err, "Parse failed"));
|
|
11959
|
+
outputParseResult(result, flags);
|
|
11960
|
+
}
|
|
11863
11961
|
async function abort2(spid, flags) {
|
|
11864
11962
|
const service = await createService("etl", { cwd: flags.dir || "." });
|
|
11865
11963
|
const result = await service.get(`abort/${spid}`);
|
|
@@ -11914,10 +12012,16 @@ async function etl(args) {
|
|
|
11914
12012
|
return content(rest[0], flags);
|
|
11915
12013
|
case "exec":
|
|
11916
12014
|
if (!rest[0]) {
|
|
11917
|
-
console.error('Usage: rpbi etl exec <id> [--file path] [--sql "..."]');
|
|
12015
|
+
console.error('Usage: rpbi etl exec <id> [--file path] [--sql "..."] [--stdin]');
|
|
11918
12016
|
process.exit(1);
|
|
11919
12017
|
}
|
|
11920
12018
|
return exec2(rest[0], flags);
|
|
12019
|
+
case "parse":
|
|
12020
|
+
if (!rest[0]) {
|
|
12021
|
+
console.error('Usage: rpbi etl parse <id> [--file path] [--sql "..."] [--stdin]');
|
|
12022
|
+
process.exit(1);
|
|
12023
|
+
}
|
|
12024
|
+
return parse(rest[0], flags);
|
|
11921
12025
|
case "abort":
|
|
11922
12026
|
if (!rest[0]) {
|
|
11923
12027
|
console.error("Usage: rpbi etl abort <spid>");
|
|
@@ -11947,7 +12051,7 @@ async function etl(args) {
|
|
|
11947
12051
|
case "watch":
|
|
11948
12052
|
return watch4(flags);
|
|
11949
12053
|
default:
|
|
11950
|
-
console.log("Usage: rpbi etl <list|get|content|exec|abort|search|params|pull|push|context|status|watch> [options]");
|
|
12054
|
+
console.log("Usage: rpbi etl <list|get|content|exec|parse|abort|search|params|pull|push|context|status|watch> [options]");
|
|
11951
12055
|
break;
|
|
11952
12056
|
}
|
|
11953
12057
|
}
|
|
@@ -12329,12 +12433,7 @@ async function doc(id, flags) {
|
|
|
12329
12433
|
}
|
|
12330
12434
|
async function exec3(id, flags) {
|
|
12331
12435
|
const service = await createService("deployment", { cwd: flags.dir || "." });
|
|
12332
|
-
|
|
12333
|
-
if (flags.file) {
|
|
12334
|
-
body = fs10.readFileSync(flags.file, "utf-8");
|
|
12335
|
-
} else if (flags.sql) {
|
|
12336
|
-
body = flags.sql;
|
|
12337
|
-
}
|
|
12436
|
+
const body = readSqlInput(flags);
|
|
12338
12437
|
const params3 = {};
|
|
12339
12438
|
if (flags.database) params3.database = flags.database;
|
|
12340
12439
|
if (flags.output) {
|
|
@@ -12357,6 +12456,20 @@ async function exec3(id, flags) {
|
|
|
12357
12456
|
process.stdout.write(result || "");
|
|
12358
12457
|
}
|
|
12359
12458
|
}
|
|
12459
|
+
async function parse2(id, flags) {
|
|
12460
|
+
let body = readSqlInput(flags);
|
|
12461
|
+
if (body === void 0) {
|
|
12462
|
+
if (!id) {
|
|
12463
|
+
console.error('Usage: rpbi deployment parse [<id>] [--file path] [--sql "..."] [--stdin]');
|
|
12464
|
+
process.exit(1);
|
|
12465
|
+
}
|
|
12466
|
+
const deploymentService = await createService("deployment", { cwd: flags.dir || "." });
|
|
12467
|
+
body = await deploymentService.get(`threads/${id}/content`, void 0, { parseResponse: false }) ?? "";
|
|
12468
|
+
}
|
|
12469
|
+
const service = await createService("server", { cwd: flags.dir || "." });
|
|
12470
|
+
const result = await service.post("parse", body).catch((err) => fail(err, "Parse failed"));
|
|
12471
|
+
outputParseResult(result, flags);
|
|
12472
|
+
}
|
|
12360
12473
|
async function deployment(args) {
|
|
12361
12474
|
const { positional, flags } = parseArgs(args);
|
|
12362
12475
|
const [subcommand, ...rest] = positional;
|
|
@@ -12383,10 +12496,12 @@ async function deployment(args) {
|
|
|
12383
12496
|
return doc(rest[0], flags);
|
|
12384
12497
|
case "exec":
|
|
12385
12498
|
if (!rest[0]) {
|
|
12386
|
-
console.error('Usage: rpbi deployment exec <id> [--file path] [--sql "..."] [--database all]');
|
|
12499
|
+
console.error('Usage: rpbi deployment exec <id> [--file path] [--sql "..."] [--stdin] [--database all]');
|
|
12387
12500
|
process.exit(1);
|
|
12388
12501
|
}
|
|
12389
12502
|
return exec3(rest[0], flags);
|
|
12503
|
+
case "parse":
|
|
12504
|
+
return parse2(rest[0], flags);
|
|
12390
12505
|
case "pull":
|
|
12391
12506
|
return pull3(flags);
|
|
12392
12507
|
case "push":
|
|
@@ -12396,7 +12511,7 @@ async function deployment(args) {
|
|
|
12396
12511
|
case "watch":
|
|
12397
12512
|
return watch5(flags);
|
|
12398
12513
|
default:
|
|
12399
|
-
console.log("Usage: rpbi deployment <list|get|content|doc|exec|pull|push|status|watch> [options]");
|
|
12514
|
+
console.log("Usage: rpbi deployment <list|get|content|doc|exec|parse|pull|push|status|watch> [options]");
|
|
12400
12515
|
break;
|
|
12401
12516
|
}
|
|
12402
12517
|
}
|
|
@@ -12921,12 +13036,7 @@ async function deps(flags) {
|
|
|
12921
13036
|
}
|
|
12922
13037
|
async function exec4(id, flags) {
|
|
12923
13038
|
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
12924
|
-
|
|
12925
|
-
if (flags.file) {
|
|
12926
|
-
body = fs12.readFileSync(flags.file, "utf-8");
|
|
12927
|
-
} else if (flags.sql) {
|
|
12928
|
-
body = flags.sql;
|
|
12929
|
-
}
|
|
13039
|
+
const body = readSqlInput(flags);
|
|
12930
13040
|
if (flags.output) {
|
|
12931
13041
|
const response = await service.postRaw(`exec/${id}`, body, {
|
|
12932
13042
|
csv_delimiter: " ",
|
|
@@ -12952,6 +13062,12 @@ async function exec4(id, flags) {
|
|
|
12952
13062
|
process.stdout.write(result || "");
|
|
12953
13063
|
}
|
|
12954
13064
|
}
|
|
13065
|
+
async function parse3(id, flags) {
|
|
13066
|
+
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
13067
|
+
const body = readSqlInput(flags) ?? await service.get(`queryContent/${id}`, void 0, { parseResponse: false }) ?? "";
|
|
13068
|
+
const result = await service.post(`parse/${id}`, body).catch((err) => fail(err, "Parse failed"));
|
|
13069
|
+
outputParseResult(result, flags);
|
|
13070
|
+
}
|
|
12955
13071
|
async function abort3(spid, flags) {
|
|
12956
13072
|
const service = await createService("extensions", { cwd: flags.dir || "." });
|
|
12957
13073
|
const result = await service.get(`abort/${spid}`);
|
|
@@ -12975,10 +13091,16 @@ async function ext(args) {
|
|
|
12975
13091
|
return content3(rest[0], flags);
|
|
12976
13092
|
case "exec":
|
|
12977
13093
|
if (!rest[0]) {
|
|
12978
|
-
console.error('Usage: rpbi ext exec <query_id> [--file path] [--sql "..."]');
|
|
13094
|
+
console.error('Usage: rpbi ext exec <query_id> [--file path] [--sql "..."] [--stdin]');
|
|
12979
13095
|
process.exit(1);
|
|
12980
13096
|
}
|
|
12981
13097
|
return exec4(rest[0], flags);
|
|
13098
|
+
case "parse":
|
|
13099
|
+
if (!rest[0]) {
|
|
13100
|
+
console.error('Usage: rpbi ext parse <query_id> [--file path] [--sql "..."] [--stdin]');
|
|
13101
|
+
process.exit(1);
|
|
13102
|
+
}
|
|
13103
|
+
return parse3(rest[0], flags);
|
|
12982
13104
|
case "abort":
|
|
12983
13105
|
if (!rest[0]) {
|
|
12984
13106
|
console.error("Usage: rpbi ext abort <spid>");
|
|
@@ -13002,7 +13124,7 @@ async function ext(args) {
|
|
|
13002
13124
|
case "watch":
|
|
13003
13125
|
return watch6(flags);
|
|
13004
13126
|
default:
|
|
13005
|
-
console.log("Usage: rpbi ext <projects|resources|queries|content|exec|abort|params|deps|pull|push|status|watch> [options]");
|
|
13127
|
+
console.log("Usage: rpbi ext <projects|resources|queries|content|exec|parse|abort|params|deps|pull|push|status|watch> [options]");
|
|
13006
13128
|
break;
|
|
13007
13129
|
}
|
|
13008
13130
|
}
|
|
@@ -17483,7 +17605,7 @@ __export(core_exports2, {
|
|
|
17483
17605
|
isValidJWT: () => isValidJWT2,
|
|
17484
17606
|
locales: () => locales_exports,
|
|
17485
17607
|
meta: () => meta,
|
|
17486
|
-
parse: () =>
|
|
17608
|
+
parse: () => parse4,
|
|
17487
17609
|
parseAsync: () => parseAsync,
|
|
17488
17610
|
prettifyError: () => prettifyError,
|
|
17489
17611
|
process: () => process2,
|
|
@@ -18406,7 +18528,7 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
18406
18528
|
}
|
|
18407
18529
|
return result.value;
|
|
18408
18530
|
};
|
|
18409
|
-
var
|
|
18531
|
+
var parse4 = /* @__PURE__ */ _parse($ZodRealError);
|
|
18410
18532
|
var _parseAsync = (_Err) => async (schema, value, _ctx, params3) => {
|
|
18411
18533
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
18412
18534
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -21079,10 +21201,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def2) =>
|
|
|
21079
21201
|
throw new Error("implement() must be called with a function");
|
|
21080
21202
|
}
|
|
21081
21203
|
return function(...args) {
|
|
21082
|
-
const parsedArgs = inst._def.input ?
|
|
21204
|
+
const parsedArgs = inst._def.input ? parse4(inst._def.input, args) : args;
|
|
21083
21205
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
21084
21206
|
if (inst._def.output) {
|
|
21085
|
-
return
|
|
21207
|
+
return parse4(inst._def.output, result);
|
|
21086
21208
|
}
|
|
21087
21209
|
return result;
|
|
21088
21210
|
};
|
|
@@ -28853,7 +28975,7 @@ var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def2) => {
|
|
|
28853
28975
|
$ZodType.init(inst, def2);
|
|
28854
28976
|
inst.def = def2;
|
|
28855
28977
|
inst.type = def2.type;
|
|
28856
|
-
inst.parse = (data, params3) =>
|
|
28978
|
+
inst.parse = (data, params3) => parse4(inst, data, params3, { callee: inst.parse });
|
|
28857
28979
|
inst.safeParse = (data, params3) => safeParse(inst, data, params3);
|
|
28858
28980
|
inst.parseAsync = async (data, params3) => parseAsync(inst, data, params3, { callee: inst.parseAsync });
|
|
28859
28981
|
inst.safeParseAsync = async (data, params3) => safeParseAsync(inst, data, params3);
|
|
@@ -29215,7 +29337,7 @@ __export(external_exports3, {
|
|
|
29215
29337
|
object: () => object2,
|
|
29216
29338
|
optional: () => optional,
|
|
29217
29339
|
overwrite: () => _overwrite,
|
|
29218
|
-
parse: () =>
|
|
29340
|
+
parse: () => parse5,
|
|
29219
29341
|
parseAsync: () => parseAsync2,
|
|
29220
29342
|
partialRecord: () => partialRecord,
|
|
29221
29343
|
pipe: () => pipe,
|
|
@@ -29560,7 +29682,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
|
|
|
29560
29682
|
});
|
|
29561
29683
|
|
|
29562
29684
|
// ../../.yarn/cache/zod-npm-4.3.6-a096e305e6-860d25a81a.zip/node_modules/zod/v4/classic/parse.js
|
|
29563
|
-
var
|
|
29685
|
+
var parse5 = /* @__PURE__ */ _parse(ZodRealError);
|
|
29564
29686
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
29565
29687
|
var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
29566
29688
|
var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -29603,7 +29725,7 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def2) => {
|
|
|
29603
29725
|
reg.add(inst, meta3);
|
|
29604
29726
|
return inst;
|
|
29605
29727
|
};
|
|
29606
|
-
inst.parse = (data, params3) =>
|
|
29728
|
+
inst.parse = (data, params3) => parse5(inst, data, params3, { callee: inst.parse });
|
|
29607
29729
|
inst.safeParse = (data, params3) => safeParse3(inst, data, params3);
|
|
29608
29730
|
inst.parseAsync = async (data, params3) => parseAsync2(inst, data, params3, { callee: inst.parseAsync });
|
|
29609
29731
|
inst.safeParseAsync = async (data, params3) => safeParseAsync3(inst, data, params3);
|
|
@@ -36532,7 +36654,7 @@ async function mcp() {
|
|
|
36532
36654
|
setMcpMode();
|
|
36533
36655
|
const server = new McpServer({
|
|
36534
36656
|
name: "reporting-bi",
|
|
36535
|
-
version: "0.1.
|
|
36657
|
+
version: "0.1.15"
|
|
36536
36658
|
});
|
|
36537
36659
|
server.tool(
|
|
36538
36660
|
"status",
|
|
@@ -36868,10 +36990,18 @@ async function mcp() {
|
|
|
36868
36990
|
server.tool(
|
|
36869
36991
|
"wiki_search",
|
|
36870
36992
|
"Search wiki pages",
|
|
36871
|
-
{
|
|
36993
|
+
{
|
|
36994
|
+
query: external_exports3.string().describe("Search query"),
|
|
36995
|
+
semantic: external_exports3.boolean().optional().describe("Also return pages semantically close to the query (needs a vector model configured on the server; results then carry a similarity score)"),
|
|
36996
|
+
...ListParams
|
|
36997
|
+
},
|
|
36872
36998
|
async (params3) => {
|
|
36873
36999
|
const service = await createService("wiki");
|
|
36874
|
-
const result = await service.get("search", {
|
|
37000
|
+
const result = await service.get("search", {
|
|
37001
|
+
...toRequestParams(params3),
|
|
37002
|
+
q: params3.query,
|
|
37003
|
+
...params3.semantic ? { mode: "semantic" } : {}
|
|
37004
|
+
});
|
|
36875
37005
|
return json2(result || []);
|
|
36876
37006
|
}
|
|
36877
37007
|
);
|
|
@@ -37065,8 +37195,8 @@ async function checkForUpdate() {
|
|
|
37065
37195
|
saveUpdateCheck({ lastCheck: now });
|
|
37066
37196
|
const latest = await fetchLatestVersion();
|
|
37067
37197
|
if (!latest) return;
|
|
37068
|
-
if (!isNewer(latest, "0.1.
|
|
37069
|
-
console.error(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.
|
|
37198
|
+
if (!isNewer(latest, "0.1.15")) return;
|
|
37199
|
+
console.error(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.15"} \u2192 ${latest}...\x1B[0m`);
|
|
37070
37200
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: ["ignore", 2, 2] });
|
|
37071
37201
|
console.error(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
37072
37202
|
} catch {
|
|
@@ -37078,11 +37208,11 @@ async function forceUpdate() {
|
|
|
37078
37208
|
console.error("Could not fetch latest version from npm.");
|
|
37079
37209
|
process.exit(1);
|
|
37080
37210
|
}
|
|
37081
|
-
if (!isNewer(latest, "0.1.
|
|
37082
|
-
console.log(`Already up to date (${"0.1.
|
|
37211
|
+
if (!isNewer(latest, "0.1.15")) {
|
|
37212
|
+
console.log(`Already up to date (${"0.1.15"}).`);
|
|
37083
37213
|
return;
|
|
37084
37214
|
}
|
|
37085
|
-
console.log(`Updating ${PACKAGE_NAME} ${"0.1.
|
|
37215
|
+
console.log(`Updating ${PACKAGE_NAME} ${"0.1.15"} \u2192 ${latest}...`);
|
|
37086
37216
|
(0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
|
|
37087
37217
|
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
37088
37218
|
saveUpdateCheck({ lastCheck: Date.now() });
|
|
@@ -37103,7 +37233,10 @@ pull removes local files deleted on the server (a locally modified file is kept)
|
|
|
37103
37233
|
deletes on the server what was deleted locally \u2014 single files or whole folders.
|
|
37104
37234
|
|
|
37105
37235
|
Commands:
|
|
37106
|
-
login [domain] [--accounting <id>]
|
|
37236
|
+
login [domain] [--accounting <id>] [--no-browser] [--port <n>]
|
|
37237
|
+
Login to a Reporting.bi instance (opens browser; without a
|
|
37238
|
+
display prints the URL - paste back the address the browser
|
|
37239
|
+
ends at, or forward --port over SSH)
|
|
37107
37240
|
logout [domain] Logout and revoke tokens (default: active connection)
|
|
37108
37241
|
use <domain> [--accounting <id>] Switch active connection and/or set accounting
|
|
37109
37242
|
status [--json] Show all connections, token and session expiry
|
|
@@ -37118,7 +37251,8 @@ ETL:
|
|
|
37118
37251
|
etl list List all threads
|
|
37119
37252
|
etl get <id> Get thread metadata
|
|
37120
37253
|
etl content <id> Get thread SQL content (plain text)
|
|
37121
|
-
etl exec <id> [--sql "..."|--file f] Execute thread (optionally with custom SQL)
|
|
37254
|
+
etl exec <id> [--sql "..."|--file f|--stdin] Execute thread (optionally with custom SQL)
|
|
37255
|
+
etl parse <id> [--sql "..."|--file f|--stdin] Syntax check (set parseonly) of the thread or the given SQL; exit 1 on errors (--json: {errors}, exit 0)
|
|
37122
37256
|
etl abort <spid> Abort a running exec (exec reports "rpbi: spid <n>" on stderr)
|
|
37123
37257
|
etl search <query> Search threads
|
|
37124
37258
|
etl params <id> [--save <json>|--delete <idz>] List, save or delete thread parameters (save creates, or updates when the JSON carries "idz"; a name already declared alongside is refused)
|
|
@@ -37133,7 +37267,8 @@ Deployment (requires the "deployment" right):
|
|
|
37133
37267
|
deployment get <id> Get thread metadata
|
|
37134
37268
|
deployment content <id> Get thread SQL content (plain text)
|
|
37135
37269
|
deployment doc <id> Get thread documentation (markdown)
|
|
37136
|
-
deployment exec <id> [--sql "..."|--file f] [--database all] Execute thread (optionally with custom SQL)
|
|
37270
|
+
deployment exec <id> [--sql "..."|--file f|--stdin] [--database all] Execute thread (optionally with custom SQL)
|
|
37271
|
+
deployment parse [<id>] [--sql "..."|--file f|--stdin] Syntax check (set parseonly, no placeholder replacement) of the thread or the given SQL
|
|
37137
37272
|
deployment pull [--dir <path>] Pull all deployment threads (.sql) & docs (.md) to local files
|
|
37138
37273
|
deployment push [files...] [--dir <path>] [--force] Push modified/new files back to server
|
|
37139
37274
|
deployment status [--dir <path>] [--remote] [--json] Show local changes (--remote compares with server)
|
|
@@ -37144,7 +37279,8 @@ Extensions (requires the "custom.define" right):
|
|
|
37144
37279
|
ext resources List resources
|
|
37145
37280
|
ext queries List queries
|
|
37146
37281
|
ext content <id> [--query] Get resource content (--query for query SQL)
|
|
37147
|
-
ext exec <query_id> [--sql "..."|--file f] Execute query (optionally with custom SQL)
|
|
37282
|
+
ext exec <query_id> [--sql "..."|--file f|--stdin] Execute query (optionally with custom SQL)
|
|
37283
|
+
ext parse <query_id> [--sql "..."|--file f|--stdin] Syntax check (set parseonly) of the query or the given SQL; exit 1 on errors (--json: {errors}, exit 0)
|
|
37148
37284
|
ext abort <spid> Abort a running exec (exec reports "rpbi: spid <n>" on stderr)
|
|
37149
37285
|
ext params <query_id> [--save <json>|--delete <idz>] List, save or delete query parameters (save creates, or updates when the JSON carries "idz"; a name already declared alongside is refused)
|
|
37150
37286
|
ext deps --project <id>|--query <id>|--resource <id> List SQL dependencies (resource \u2194 query links)
|
|
@@ -37270,7 +37406,7 @@ Examples:
|
|
|
37270
37406
|
(async () => {
|
|
37271
37407
|
const [command, ...args] = process.argv.slice(2);
|
|
37272
37408
|
if (command === "--version" || command === "-v") {
|
|
37273
|
-
console.log("0.1.
|
|
37409
|
+
console.log("0.1.15");
|
|
37274
37410
|
return;
|
|
37275
37411
|
}
|
|
37276
37412
|
await checkForUpdate();
|