@reporting-bi/cli 0.0.8 → 0.0.10
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 +280 -173
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1055,13 +1055,13 @@ var require_implementation = __commonJS({
|
|
|
1055
1055
|
if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
|
|
1056
1056
|
throw new TypeError(ERROR_MESSAGE + target);
|
|
1057
1057
|
}
|
|
1058
|
-
var
|
|
1058
|
+
var args = slicy(arguments, 1);
|
|
1059
1059
|
var bound;
|
|
1060
1060
|
var binder = function() {
|
|
1061
1061
|
if (this instanceof bound) {
|
|
1062
1062
|
var result = target.apply(
|
|
1063
1063
|
this,
|
|
1064
|
-
concatty(
|
|
1064
|
+
concatty(args, arguments)
|
|
1065
1065
|
);
|
|
1066
1066
|
if (Object(result) === result) {
|
|
1067
1067
|
return result;
|
|
@@ -1070,10 +1070,10 @@ var require_implementation = __commonJS({
|
|
|
1070
1070
|
}
|
|
1071
1071
|
return target.apply(
|
|
1072
1072
|
that,
|
|
1073
|
-
concatty(
|
|
1073
|
+
concatty(args, arguments)
|
|
1074
1074
|
);
|
|
1075
1075
|
};
|
|
1076
|
-
var boundLength = max(0, target.length -
|
|
1076
|
+
var boundLength = max(0, target.length - args.length);
|
|
1077
1077
|
var boundArgs = [];
|
|
1078
1078
|
for (var i = 0; i < boundLength; i++) {
|
|
1079
1079
|
boundArgs[i] = "$" + i;
|
|
@@ -1144,11 +1144,11 @@ var require_call_bind_apply_helpers = __commonJS({
|
|
|
1144
1144
|
var $TypeError = require_type();
|
|
1145
1145
|
var $call = require_functionCall();
|
|
1146
1146
|
var $actualApply = require_actualApply();
|
|
1147
|
-
module2.exports = function callBindBasic(
|
|
1148
|
-
if (
|
|
1147
|
+
module2.exports = function callBindBasic(args) {
|
|
1148
|
+
if (args.length < 1 || typeof args[0] !== "function") {
|
|
1149
1149
|
throw new $TypeError("a function is required");
|
|
1150
1150
|
}
|
|
1151
|
-
return $actualApply(bind, $call,
|
|
1151
|
+
return $actualApply(bind, $call, args);
|
|
1152
1152
|
};
|
|
1153
1153
|
}
|
|
1154
1154
|
});
|
|
@@ -2650,7 +2650,7 @@ var require_service = __commonJS({
|
|
|
2650
2650
|
this.options.baseUrl = `https://${this.options.baseUrl}`;
|
|
2651
2651
|
}
|
|
2652
2652
|
}
|
|
2653
|
-
createUrl(
|
|
2653
|
+
createUrl(path3 = "", params) {
|
|
2654
2654
|
if (this.options.xdebugSession) {
|
|
2655
2655
|
params = params || {};
|
|
2656
2656
|
params.XDEBUG_SESSION = this.options.xdebugSession === true ? "1" : this.options.xdebugSession.toString();
|
|
@@ -2660,8 +2660,8 @@ var require_service = __commonJS({
|
|
|
2660
2660
|
}
|
|
2661
2661
|
const queryString = params ? "?" + serializeRequestParams(params) : "";
|
|
2662
2662
|
const a = params && params.accounting ? params.accounting.toString() : this.a ? this.a.toString() : null;
|
|
2663
|
-
|
|
2664
|
-
const parts = [this.options.baseUrl, a, this.options.name,
|
|
2663
|
+
path3 = path3.replace(/^\//, "");
|
|
2664
|
+
const parts = [this.options.baseUrl, a, this.options.name, path3];
|
|
2665
2665
|
return parts.filter((p) => p != null && p !== "").join("/") + queryString;
|
|
2666
2666
|
}
|
|
2667
2667
|
async createHeaders(headers) {
|
|
@@ -2702,28 +2702,28 @@ var require_service = __commonJS({
|
|
|
2702
2702
|
return await response.text();
|
|
2703
2703
|
}
|
|
2704
2704
|
}
|
|
2705
|
-
async getRaw(
|
|
2706
|
-
return fetch(this.createUrl(
|
|
2705
|
+
async getRaw(path3, params, options) {
|
|
2706
|
+
return fetch(this.createUrl(path3, params), {
|
|
2707
2707
|
headers: await this.createHeaders(options?.headers),
|
|
2708
2708
|
credentials: this.credentials
|
|
2709
2709
|
});
|
|
2710
2710
|
}
|
|
2711
|
-
async get(
|
|
2711
|
+
async get(path3, params, options) {
|
|
2712
2712
|
if (options?.cache) {
|
|
2713
|
-
const cachedData = this.cache.get({ path:
|
|
2713
|
+
const cachedData = this.cache.get({ path: path3, params });
|
|
2714
2714
|
if (cachedData)
|
|
2715
2715
|
return cachedData;
|
|
2716
2716
|
}
|
|
2717
|
-
const response = await this.getRaw(
|
|
2717
|
+
const response = await this.getRaw(path3, params, options);
|
|
2718
2718
|
const responseData = await this.handleResponse(response, options?.parseResponse);
|
|
2719
2719
|
if (options?.cache && responseData) {
|
|
2720
|
-
this.cache.set({ path:
|
|
2720
|
+
this.cache.set({ path: path3, params }, responseData);
|
|
2721
2721
|
}
|
|
2722
2722
|
return responseData;
|
|
2723
2723
|
}
|
|
2724
|
-
async postRaw(
|
|
2724
|
+
async postRaw(path3, data, params, options) {
|
|
2725
2725
|
const json = isObject(data) || Array.isArray(data);
|
|
2726
|
-
return fetch(this.createUrl(
|
|
2726
|
+
return fetch(this.createUrl(path3, params), {
|
|
2727
2727
|
method: "POST",
|
|
2728
2728
|
body: json ? JSON.stringify(data) : data,
|
|
2729
2729
|
headers: await this.createHeaders({
|
|
@@ -2733,24 +2733,24 @@ var require_service = __commonJS({
|
|
|
2733
2733
|
credentials: this.credentials
|
|
2734
2734
|
});
|
|
2735
2735
|
}
|
|
2736
|
-
async post(
|
|
2737
|
-
const response = await this.postRaw(
|
|
2736
|
+
async post(path3, data, params, options) {
|
|
2737
|
+
const response = await this.postRaw(path3, data, params, options);
|
|
2738
2738
|
return this.handleResponse(response);
|
|
2739
2739
|
}
|
|
2740
|
-
async deleteRaw(
|
|
2741
|
-
return fetch(this.createUrl(
|
|
2740
|
+
async deleteRaw(path3, params, options) {
|
|
2741
|
+
return fetch(this.createUrl(path3, params), {
|
|
2742
2742
|
method: "DELETE",
|
|
2743
2743
|
headers: await this.createHeaders(options?.headers),
|
|
2744
2744
|
credentials: this.credentials
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
|
-
async delete(
|
|
2748
|
-
const response = await this.deleteRaw(
|
|
2747
|
+
async delete(path3, params, options) {
|
|
2748
|
+
const response = await this.deleteRaw(path3, params, options);
|
|
2749
2749
|
return this.handleResponse(response);
|
|
2750
2750
|
}
|
|
2751
|
-
async putRaw(
|
|
2751
|
+
async putRaw(path3, data, params, options) {
|
|
2752
2752
|
const json = isObject(data) || Array.isArray(data);
|
|
2753
|
-
return fetch(this.createUrl(
|
|
2753
|
+
return fetch(this.createUrl(path3, params), {
|
|
2754
2754
|
method: "PUT",
|
|
2755
2755
|
body: json ? JSON.stringify(data) : data,
|
|
2756
2756
|
headers: await this.createHeaders({
|
|
@@ -2760,8 +2760,8 @@ var require_service = __commonJS({
|
|
|
2760
2760
|
credentials: this.credentials
|
|
2761
2761
|
});
|
|
2762
2762
|
}
|
|
2763
|
-
async put(
|
|
2764
|
-
const response = await this.putRaw(
|
|
2763
|
+
async put(path3, data, params, options) {
|
|
2764
|
+
const response = await this.putRaw(path3, data, params, options);
|
|
2765
2765
|
return this.handleResponse(response);
|
|
2766
2766
|
}
|
|
2767
2767
|
};
|
|
@@ -3111,24 +3111,46 @@ function getFields(flags, defaults) {
|
|
|
3111
3111
|
if (flags.columns) return flags.columns.split(",").map((s) => s.trim());
|
|
3112
3112
|
return defaults;
|
|
3113
3113
|
}
|
|
3114
|
+
function getListParams(flags, defaultFields) {
|
|
3115
|
+
const params = {};
|
|
3116
|
+
const fields = getFields(flags, defaultFields);
|
|
3117
|
+
if (fields) params.fields = fields;
|
|
3118
|
+
if (flags.offset) params.offset = parseInt(flags.offset);
|
|
3119
|
+
if (flags.limit) params.count = parseInt(flags.limit);
|
|
3120
|
+
if (flags.sort) {
|
|
3121
|
+
params.order = flags.sort.split(",").map((s) => {
|
|
3122
|
+
s = s.trim();
|
|
3123
|
+
if (s.startsWith("-")) return [s.slice(1), "desc"];
|
|
3124
|
+
if (s.startsWith("+")) return [s.slice(1), "asc"];
|
|
3125
|
+
return [s, "asc"];
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
if (flags.filter) params.where = flags.filter;
|
|
3129
|
+
return params;
|
|
3130
|
+
}
|
|
3114
3131
|
var FLAG_ALIASES = {
|
|
3115
|
-
a: "accounting"
|
|
3132
|
+
a: "accounting",
|
|
3133
|
+
c: "columns",
|
|
3134
|
+
o: "offset",
|
|
3135
|
+
l: "limit",
|
|
3136
|
+
s: "sort",
|
|
3137
|
+
f: "filter"
|
|
3116
3138
|
};
|
|
3117
|
-
function parseArgs(
|
|
3139
|
+
function parseArgs(args) {
|
|
3118
3140
|
const positional = [];
|
|
3119
3141
|
const flags = {};
|
|
3120
|
-
for (let i = 0; i <
|
|
3121
|
-
if (
|
|
3122
|
-
flags[
|
|
3123
|
-
} else if (
|
|
3124
|
-
flags[
|
|
3142
|
+
for (let i = 0; i < args.length; i++) {
|
|
3143
|
+
if (args[i].startsWith("--") && (i + 1 >= args.length || args[i + 1].startsWith("-"))) {
|
|
3144
|
+
flags[args[i].slice(2)] = "true";
|
|
3145
|
+
} else if (args[i].startsWith("--") && i + 1 < args.length) {
|
|
3146
|
+
flags[args[i].slice(2)] = args[i + 1];
|
|
3125
3147
|
i++;
|
|
3126
|
-
} else if (
|
|
3127
|
-
const key = FLAG_ALIASES[
|
|
3128
|
-
flags[key] =
|
|
3148
|
+
} else if (args[i].startsWith("-") && !args[i].startsWith("--") && i + 1 < args.length) {
|
|
3149
|
+
const key = FLAG_ALIASES[args[i].slice(1)] || args[i].slice(1);
|
|
3150
|
+
flags[key] = args[i + 1];
|
|
3129
3151
|
i++;
|
|
3130
3152
|
} else {
|
|
3131
|
-
positional.push(
|
|
3153
|
+
positional.push(args[i]);
|
|
3132
3154
|
}
|
|
3133
3155
|
}
|
|
3134
3156
|
return { positional, flags };
|
|
@@ -3187,8 +3209,8 @@ async function fetchAccountingName(accountingId) {
|
|
|
3187
3209
|
const match = accountings?.find((a) => a.accounting === accountingId);
|
|
3188
3210
|
return match?.company ?? null;
|
|
3189
3211
|
}
|
|
3190
|
-
async function accounting(
|
|
3191
|
-
const { positional, flags } = parseArgs(
|
|
3212
|
+
async function accounting(args) {
|
|
3213
|
+
const { positional, flags } = parseArgs(args);
|
|
3192
3214
|
const [subcommand] = positional;
|
|
3193
3215
|
switch (subcommand) {
|
|
3194
3216
|
case "list":
|
|
@@ -3200,7 +3222,7 @@ async function accounting(args2) {
|
|
|
3200
3222
|
}
|
|
3201
3223
|
async function list(flags) {
|
|
3202
3224
|
const service = await createService("accounting");
|
|
3203
|
-
const accountings = await service.get("accountings",
|
|
3225
|
+
const accountings = await service.get("accountings", getListParams(flags, ["accounting", "company"]));
|
|
3204
3226
|
output(accountings || [], flags);
|
|
3205
3227
|
}
|
|
3206
3228
|
|
|
@@ -3272,8 +3294,8 @@ function openBrowser(url) {
|
|
|
3272
3294
|
const cmd = platform === "darwin" ? "open" : platform === "win32" ? 'start ""' : "xdg-open";
|
|
3273
3295
|
(0, import_node_child_process.exec)(`${cmd} ${JSON.stringify(url)}`);
|
|
3274
3296
|
}
|
|
3275
|
-
async function login(
|
|
3276
|
-
const { positional, flags } = parseArgs(
|
|
3297
|
+
async function login(args) {
|
|
3298
|
+
const { positional, flags } = parseArgs(args);
|
|
3277
3299
|
const domain = positional[0] || "https://reporting.bi";
|
|
3278
3300
|
const accounting2 = flags.accounting ? parseInt(flags.accounting) : void 0;
|
|
3279
3301
|
console.log(`Logging in to ${domain}...`);
|
|
@@ -3404,8 +3426,8 @@ function status() {
|
|
|
3404
3426
|
}
|
|
3405
3427
|
|
|
3406
3428
|
// src/commands/use.ts
|
|
3407
|
-
async function use(
|
|
3408
|
-
const { positional, flags } = parseArgs(
|
|
3429
|
+
async function use(args) {
|
|
3430
|
+
const { positional, flags } = parseArgs(args);
|
|
3409
3431
|
const accounting2 = flags.accounting ? parseInt(flags.accounting) : void 0;
|
|
3410
3432
|
let domain = positional[0];
|
|
3411
3433
|
if (!domain && !accounting2) {
|
|
@@ -3446,7 +3468,7 @@ var fs2 = __toESM(require("node:fs"));
|
|
|
3446
3468
|
var DEFAULT_LANG = "cs";
|
|
3447
3469
|
async function list2(flags) {
|
|
3448
3470
|
const service = await createService("wiki");
|
|
3449
|
-
const pages = await service.get("pages");
|
|
3471
|
+
const pages = await service.get("pages", getListParams(flags));
|
|
3450
3472
|
output(pages || [], flags);
|
|
3451
3473
|
}
|
|
3452
3474
|
async function get(id, flags) {
|
|
@@ -3463,7 +3485,7 @@ async function read(id, flags) {
|
|
|
3463
3485
|
}
|
|
3464
3486
|
async function search(query, flags) {
|
|
3465
3487
|
const service = await createService("wiki");
|
|
3466
|
-
const results = await service.get("search", { q: query });
|
|
3488
|
+
const results = await service.get("search", { ...getListParams(flags), q: query });
|
|
3467
3489
|
output(results || [], flags);
|
|
3468
3490
|
}
|
|
3469
3491
|
async function readContent(flags) {
|
|
@@ -3503,8 +3525,8 @@ async function del(id, flags) {
|
|
|
3503
3525
|
await service.delete(`page/${lang}/${id}`);
|
|
3504
3526
|
console.log(`Page ${id} deleted.`);
|
|
3505
3527
|
}
|
|
3506
|
-
async function wiki(
|
|
3507
|
-
const { positional, flags } = parseArgs(
|
|
3528
|
+
async function wiki(args) {
|
|
3529
|
+
const { positional, flags } = parseArgs(args);
|
|
3508
3530
|
const [subcommand, ...rest] = positional;
|
|
3509
3531
|
switch (subcommand) {
|
|
3510
3532
|
case "list":
|
|
@@ -3546,7 +3568,7 @@ var fs3 = __toESM(require("node:fs"));
|
|
|
3546
3568
|
var DEFAULT_FIELDS = ["id_thread", "description", "module", "type", "enabled", "ord_num"];
|
|
3547
3569
|
async function list3(flags) {
|
|
3548
3570
|
const service = await createService("etl");
|
|
3549
|
-
const threads = await service.get("threads",
|
|
3571
|
+
const threads = await service.get("threads", getListParams(flags, DEFAULT_FIELDS));
|
|
3550
3572
|
output(threads || [], flags);
|
|
3551
3573
|
}
|
|
3552
3574
|
async function get2(id, flags) {
|
|
@@ -3572,11 +3594,11 @@ async function exec2(id, flags) {
|
|
|
3572
3594
|
}
|
|
3573
3595
|
async function search2(query, flags) {
|
|
3574
3596
|
const service = await createService("etl");
|
|
3575
|
-
const results = await service.get("search", {
|
|
3597
|
+
const results = await service.get("search", { ...getListParams(flags, DEFAULT_FIELDS), q: query });
|
|
3576
3598
|
output(results || [], flags);
|
|
3577
3599
|
}
|
|
3578
|
-
async function etl(
|
|
3579
|
-
const { positional, flags } = parseArgs(
|
|
3600
|
+
async function etl(args) {
|
|
3601
|
+
const { positional, flags } = parseArgs(args);
|
|
3580
3602
|
const [subcommand, ...rest] = positional;
|
|
3581
3603
|
switch (subcommand) {
|
|
3582
3604
|
case "list":
|
|
@@ -3616,7 +3638,7 @@ var DEFAULT_LIST_FIELDS = ["job_name", "description", "enabled", "last_run", "ne
|
|
|
3616
3638
|
var DEFAULT_STATUS_FIELDS = ["job_name", "running", "enabled", "last_run", "next_run"];
|
|
3617
3639
|
async function list4(flags) {
|
|
3618
3640
|
const service = await createService("jobs");
|
|
3619
|
-
const jobs2 = await service.get("userJobs",
|
|
3641
|
+
const jobs2 = await service.get("userJobs", getListParams(flags, DEFAULT_LIST_FIELDS));
|
|
3620
3642
|
output(jobs2 || [], flags);
|
|
3621
3643
|
}
|
|
3622
3644
|
async function start(jobName, flags) {
|
|
@@ -3631,11 +3653,11 @@ async function stop(jobName, flags) {
|
|
|
3631
3653
|
}
|
|
3632
3654
|
async function statusCmd(flags) {
|
|
3633
3655
|
const service = await createService("jobs");
|
|
3634
|
-
const statuses = await service.get("jobStatuses",
|
|
3656
|
+
const statuses = await service.get("jobStatuses", getListParams(flags, DEFAULT_STATUS_FIELDS));
|
|
3635
3657
|
output(statuses || [], flags);
|
|
3636
3658
|
}
|
|
3637
|
-
async function jobs(
|
|
3638
|
-
const { positional, flags } = parseArgs(
|
|
3659
|
+
async function jobs(args) {
|
|
3660
|
+
const { positional, flags } = parseArgs(args);
|
|
3639
3661
|
const [subcommand, ...rest] = positional;
|
|
3640
3662
|
switch (subcommand) {
|
|
3641
3663
|
case "list":
|
|
@@ -3662,64 +3684,61 @@ async function jobs(args2) {
|
|
|
3662
3684
|
|
|
3663
3685
|
// src/commands/analytics.ts
|
|
3664
3686
|
var DEFAULT_CONTEXT_FIELDS = ["id_context", "name", "module", "user_name"];
|
|
3665
|
-
async function
|
|
3666
|
-
const
|
|
3667
|
-
const
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3687
|
+
async function context(args) {
|
|
3688
|
+
const { positional, flags } = parseArgs(args);
|
|
3689
|
+
const [subcommand, ...rest] = positional;
|
|
3690
|
+
switch (subcommand) {
|
|
3691
|
+
case "list":
|
|
3692
|
+
case void 0: {
|
|
3693
|
+
const endpoint = flags.all ? "context" : "namedContext";
|
|
3694
|
+
const service2 = await createService("analytics");
|
|
3695
|
+
const ctxs = await service2.get(endpoint, getListParams(flags, DEFAULT_CONTEXT_FIELDS));
|
|
3696
|
+
output(ctxs || [], flags);
|
|
3697
|
+
break;
|
|
3698
|
+
}
|
|
3699
|
+
case "get":
|
|
3700
|
+
if (!rest[0]) {
|
|
3701
|
+
console.error("Usage: rpbi context get <id>");
|
|
3702
|
+
process.exit(1);
|
|
3703
|
+
}
|
|
3704
|
+
const service = await createService("analytics");
|
|
3705
|
+
const ctx = await service.get(`context/${rest[0]}`);
|
|
3706
|
+
output(ctx, flags);
|
|
3707
|
+
break;
|
|
3708
|
+
default:
|
|
3709
|
+
console.log("Usage: rpbi context <list|get> [options]");
|
|
3710
|
+
break;
|
|
3711
|
+
}
|
|
3674
3712
|
}
|
|
3675
|
-
async function report(
|
|
3713
|
+
async function report(args) {
|
|
3714
|
+
const { positional, flags } = parseArgs(args);
|
|
3715
|
+
const id = positional[0];
|
|
3716
|
+
if (!id) {
|
|
3717
|
+
console.error("Usage: rpbi report <context_id> [--index N]");
|
|
3718
|
+
process.exit(1);
|
|
3719
|
+
}
|
|
3676
3720
|
const service = await createService("analytics");
|
|
3677
3721
|
const index = flags.index || "0";
|
|
3678
3722
|
const result = await service.get(`report/${id}/${index}`, void 0, { parseResponse: false });
|
|
3679
3723
|
process.stdout.write(result || "");
|
|
3680
3724
|
}
|
|
3681
|
-
async function dimensions(
|
|
3725
|
+
async function dimensions(args) {
|
|
3726
|
+
const { positional, flags } = parseArgs(args);
|
|
3682
3727
|
const module2 = flags.module || flags.m;
|
|
3683
3728
|
if (!module2) {
|
|
3684
|
-
console.error("Usage: rpbi
|
|
3729
|
+
console.error("Usage: rpbi dimensions --module <module>");
|
|
3685
3730
|
process.exit(1);
|
|
3686
3731
|
}
|
|
3687
3732
|
const service = await createService("definition");
|
|
3688
|
-
const dims = await service.get(`visibleDimensions/${module2}`,
|
|
3733
|
+
const dims = await service.get(`visibleDimensions/${module2}`, getListParams(flags));
|
|
3689
3734
|
output(dims || [], flags);
|
|
3690
3735
|
}
|
|
3691
|
-
async function
|
|
3736
|
+
async function years(args) {
|
|
3737
|
+
const { positional, flags } = parseArgs(args);
|
|
3692
3738
|
const service = await createService("analytics");
|
|
3693
3739
|
const tree = await service.get("years");
|
|
3694
3740
|
output(tree || [], flags);
|
|
3695
3741
|
}
|
|
3696
|
-
async function analytics(args2) {
|
|
3697
|
-
const { positional, flags } = parseArgs(args2);
|
|
3698
|
-
const [subcommand, ...rest] = positional;
|
|
3699
|
-
switch (subcommand) {
|
|
3700
|
-
case "contexts":
|
|
3701
|
-
return contexts(flags);
|
|
3702
|
-
case "context":
|
|
3703
|
-
if (!rest[0]) {
|
|
3704
|
-
console.error("Usage: rpbi analytics context <id>");
|
|
3705
|
-
process.exit(1);
|
|
3706
|
-
}
|
|
3707
|
-
return getContext(rest[0], flags);
|
|
3708
|
-
case "report":
|
|
3709
|
-
if (!rest[0]) {
|
|
3710
|
-
console.error("Usage: rpbi analytics report <context_id> [--index N]");
|
|
3711
|
-
process.exit(1);
|
|
3712
|
-
}
|
|
3713
|
-
return report(rest[0], flags);
|
|
3714
|
-
case "dimensions":
|
|
3715
|
-
return dimensions(flags);
|
|
3716
|
-
case "years":
|
|
3717
|
-
return periods(flags);
|
|
3718
|
-
default:
|
|
3719
|
-
console.log("Usage: rpbi analytics <contexts|context|report|dimensions|years> [options]");
|
|
3720
|
-
break;
|
|
3721
|
-
}
|
|
3722
|
-
}
|
|
3723
3742
|
|
|
3724
3743
|
// src/commands/users.ts
|
|
3725
3744
|
var DEFAULT_LIST_FIELDS2 = ["user_name", "login_name", "company"];
|
|
@@ -3727,7 +3746,7 @@ var DEFAULT_RIGHTS_FIELDS = ["right", "accounting", "role", "source"];
|
|
|
3727
3746
|
var DEFAULT_ROLES_FIELDS = ["id_access_role", "role", "description"];
|
|
3728
3747
|
async function list5(flags) {
|
|
3729
3748
|
const service = await createService("users");
|
|
3730
|
-
const users2 = await service.get("allUsers",
|
|
3749
|
+
const users2 = await service.get("allUsers", getListParams(flags, DEFAULT_LIST_FIELDS2));
|
|
3731
3750
|
output(users2 || [], flags);
|
|
3732
3751
|
}
|
|
3733
3752
|
async function get3(user, flags) {
|
|
@@ -3737,16 +3756,16 @@ async function get3(user, flags) {
|
|
|
3737
3756
|
}
|
|
3738
3757
|
async function rights(flags) {
|
|
3739
3758
|
const service = await createService("users");
|
|
3740
|
-
const result = await service.get("userRights",
|
|
3759
|
+
const result = await service.get("userRights", getListParams(flags, DEFAULT_RIGHTS_FIELDS));
|
|
3741
3760
|
output(result || [], flags);
|
|
3742
3761
|
}
|
|
3743
3762
|
async function roles(flags) {
|
|
3744
3763
|
const service = await createService("users");
|
|
3745
|
-
const result = await service.get("accessRoles",
|
|
3764
|
+
const result = await service.get("accessRoles", getListParams(flags, DEFAULT_ROLES_FIELDS));
|
|
3746
3765
|
output(result || [], flags);
|
|
3747
3766
|
}
|
|
3748
|
-
async function users(
|
|
3749
|
-
const { positional, flags } = parseArgs(
|
|
3767
|
+
async function users(args) {
|
|
3768
|
+
const { positional, flags } = parseArgs(args);
|
|
3750
3769
|
const [subcommand, ...rest] = positional;
|
|
3751
3770
|
switch (subcommand) {
|
|
3752
3771
|
case "list":
|
|
@@ -3771,12 +3790,12 @@ var DEFAULT_DIMENSIONS_FIELDS = ["dim_num", "description", "enabled", "ord_num"]
|
|
|
3771
3790
|
var DEFAULT_MODULES_FIELDS = ["module", "name", "type"];
|
|
3772
3791
|
async function statements(flags) {
|
|
3773
3792
|
const service = await createService("definition");
|
|
3774
|
-
const result = await service.get("
|
|
3793
|
+
const result = await service.get("statements", getListParams(flags, DEFAULT_STATEMENTS_FIELDS));
|
|
3775
3794
|
output(result || [], flags);
|
|
3776
3795
|
}
|
|
3777
3796
|
async function statement(id, flags) {
|
|
3778
3797
|
const service = await createService("definition");
|
|
3779
|
-
const result = await service.get(`
|
|
3798
|
+
const result = await service.get(`statement/${id}`);
|
|
3780
3799
|
output(result, flags);
|
|
3781
3800
|
}
|
|
3782
3801
|
async function dimensions2(flags) {
|
|
@@ -3786,26 +3805,26 @@ async function dimensions2(flags) {
|
|
|
3786
3805
|
process.exit(1);
|
|
3787
3806
|
}
|
|
3788
3807
|
const service = await createService("definition");
|
|
3789
|
-
const result = await service.get(`dimensions/${module2}`,
|
|
3808
|
+
const result = await service.get(`dimensions/${module2}`, getListParams(flags, DEFAULT_DIMENSIONS_FIELDS));
|
|
3790
3809
|
output(result || [], flags);
|
|
3791
3810
|
}
|
|
3792
3811
|
async function modules(flags) {
|
|
3793
3812
|
const service = await createService("definition");
|
|
3794
|
-
const result = await service.get("modules",
|
|
3813
|
+
const result = await service.get("modules", getListParams(flags, DEFAULT_MODULES_FIELDS));
|
|
3795
3814
|
output(result || [], flags);
|
|
3796
3815
|
}
|
|
3797
3816
|
async function scenarios(flags) {
|
|
3798
3817
|
const service = await createService("definition");
|
|
3799
|
-
const result = await service.get("scenarios",
|
|
3818
|
+
const result = await service.get("scenarios", getListParams(flags));
|
|
3800
3819
|
output(result || [], flags);
|
|
3801
3820
|
}
|
|
3802
3821
|
async function fiscalYears(flags) {
|
|
3803
3822
|
const service = await createService("definition");
|
|
3804
|
-
const result = await service.get("fiscalYears",
|
|
3823
|
+
const result = await service.get("fiscalYears", getListParams(flags));
|
|
3805
3824
|
output(result || [], flags);
|
|
3806
3825
|
}
|
|
3807
|
-
async function def(
|
|
3808
|
-
const { positional, flags } = parseArgs(
|
|
3826
|
+
async function def(args) {
|
|
3827
|
+
const { positional, flags } = parseArgs(args);
|
|
3809
3828
|
const [subcommand, ...rest] = positional;
|
|
3810
3829
|
switch (subcommand) {
|
|
3811
3830
|
case "statements":
|
|
@@ -3834,7 +3853,7 @@ async function def(args2) {
|
|
|
3834
3853
|
var DEFAULT_TABLES_FIELDS = ["id_md", "md_name", "type"];
|
|
3835
3854
|
async function tables(flags) {
|
|
3836
3855
|
const service = await createService("mdm");
|
|
3837
|
-
const result = await service.get("tableDefinitions",
|
|
3856
|
+
const result = await service.get("tableDefinitions", getListParams(flags, DEFAULT_TABLES_FIELDS));
|
|
3838
3857
|
output(result || [], flags);
|
|
3839
3858
|
}
|
|
3840
3859
|
async function table(id, flags) {
|
|
@@ -3844,12 +3863,12 @@ async function table(id, flags) {
|
|
|
3844
3863
|
}
|
|
3845
3864
|
async function columns(id, flags) {
|
|
3846
3865
|
const service = await createService("mdm");
|
|
3847
|
-
const result = await service.get(`columnDefinitions/${id}`,
|
|
3866
|
+
const result = await service.get(`columnDefinitions/${id}`, getListParams(flags));
|
|
3848
3867
|
output(result || [], flags);
|
|
3849
3868
|
}
|
|
3850
3869
|
async function values(id, flags) {
|
|
3851
3870
|
const service = await createService("mdm");
|
|
3852
|
-
const result = await service.get(`values/${id}`,
|
|
3871
|
+
const result = await service.get(`values/${id}`, getListParams(flags));
|
|
3853
3872
|
output(result || [], flags);
|
|
3854
3873
|
}
|
|
3855
3874
|
async function exportCsv(id, flags) {
|
|
@@ -3858,8 +3877,8 @@ async function exportCsv(id, flags) {
|
|
|
3858
3877
|
const result = await service.get(`export/${id}/${type}`, void 0, { parseResponse: false });
|
|
3859
3878
|
process.stdout.write(result || "");
|
|
3860
3879
|
}
|
|
3861
|
-
async function mdm(
|
|
3862
|
-
const { positional, flags } = parseArgs(
|
|
3880
|
+
async function mdm(args) {
|
|
3881
|
+
const { positional, flags } = parseArgs(args);
|
|
3863
3882
|
const [subcommand, ...rest] = positional;
|
|
3864
3883
|
switch (subcommand) {
|
|
3865
3884
|
case "tables":
|
|
@@ -3899,7 +3918,7 @@ var DEFAULT_LIST_FIELDS3 = ["id_request", "subject", "status", "priority", "who_
|
|
|
3899
3918
|
var DEFAULT_MESSAGES_FIELDS = ["id_message", "text", "who_created", "date_created"];
|
|
3900
3919
|
async function list6(flags) {
|
|
3901
3920
|
const service = await createService("helpdesk");
|
|
3902
|
-
const tickets = await service.get("tickets",
|
|
3921
|
+
const tickets = await service.get("tickets", getListParams(flags, DEFAULT_LIST_FIELDS3));
|
|
3903
3922
|
output(tickets || [], flags);
|
|
3904
3923
|
}
|
|
3905
3924
|
async function get4(id, flags) {
|
|
@@ -3909,7 +3928,7 @@ async function get4(id, flags) {
|
|
|
3909
3928
|
}
|
|
3910
3929
|
async function messages(id, flags) {
|
|
3911
3930
|
const service = await createService("helpdesk");
|
|
3912
|
-
const msgs = await service.get(`messages/${id}`,
|
|
3931
|
+
const msgs = await service.get(`messages/${id}`, getListParams(flags, DEFAULT_MESSAGES_FIELDS));
|
|
3913
3932
|
output(msgs || [], flags);
|
|
3914
3933
|
}
|
|
3915
3934
|
async function create(flags) {
|
|
@@ -3928,8 +3947,8 @@ async function create(flags) {
|
|
|
3928
3947
|
}
|
|
3929
3948
|
output(result, flags);
|
|
3930
3949
|
}
|
|
3931
|
-
async function helpdesk(
|
|
3932
|
-
const { positional, flags } = parseArgs(
|
|
3950
|
+
async function helpdesk(args) {
|
|
3951
|
+
const { positional, flags } = parseArgs(args);
|
|
3933
3952
|
const [subcommand, ...rest] = positional;
|
|
3934
3953
|
switch (subcommand) {
|
|
3935
3954
|
case "list":
|
|
@@ -3954,6 +3973,78 @@ async function helpdesk(args2) {
|
|
|
3954
3973
|
}
|
|
3955
3974
|
}
|
|
3956
3975
|
|
|
3976
|
+
// src/autoupdate.ts
|
|
3977
|
+
var fs4 = __toESM(require("node:fs"));
|
|
3978
|
+
var path2 = __toESM(require("node:path"));
|
|
3979
|
+
var os2 = __toESM(require("node:os"));
|
|
3980
|
+
var https = __toESM(require("node:https"));
|
|
3981
|
+
var import_node_child_process2 = require("node:child_process");
|
|
3982
|
+
var CONFIG_DIR2 = path2.join(os2.homedir(), ".config", "reporting-bi");
|
|
3983
|
+
var UPDATE_CHECK_FILE = path2.join(CONFIG_DIR2, "update-check.json");
|
|
3984
|
+
var CHECK_INTERVAL = 60 * 60 * 1e3;
|
|
3985
|
+
var PACKAGE_NAME = "@reporting-bi/cli";
|
|
3986
|
+
function loadUpdateCheck() {
|
|
3987
|
+
try {
|
|
3988
|
+
return JSON.parse(fs4.readFileSync(UPDATE_CHECK_FILE, "utf-8"));
|
|
3989
|
+
} catch {
|
|
3990
|
+
return { lastCheck: 0 };
|
|
3991
|
+
}
|
|
3992
|
+
}
|
|
3993
|
+
function saveUpdateCheck(data) {
|
|
3994
|
+
fs4.mkdirSync(CONFIG_DIR2, { recursive: true });
|
|
3995
|
+
fs4.writeFileSync(UPDATE_CHECK_FILE, JSON.stringify(data, null, 2));
|
|
3996
|
+
}
|
|
3997
|
+
function fetchLatestVersion() {
|
|
3998
|
+
return new Promise((resolve) => {
|
|
3999
|
+
const req = https.get(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, { timeout: 5e3 }, (res) => {
|
|
4000
|
+
if (res.statusCode !== 200) {
|
|
4001
|
+
res.resume();
|
|
4002
|
+
return resolve(null);
|
|
4003
|
+
}
|
|
4004
|
+
let body = "";
|
|
4005
|
+
res.on("data", (chunk) => body += chunk);
|
|
4006
|
+
res.on("end", () => {
|
|
4007
|
+
try {
|
|
4008
|
+
resolve(JSON.parse(body).version ?? null);
|
|
4009
|
+
} catch {
|
|
4010
|
+
resolve(null);
|
|
4011
|
+
}
|
|
4012
|
+
});
|
|
4013
|
+
});
|
|
4014
|
+
req.on("error", () => resolve(null));
|
|
4015
|
+
req.on("timeout", () => {
|
|
4016
|
+
req.destroy();
|
|
4017
|
+
resolve(null);
|
|
4018
|
+
});
|
|
4019
|
+
});
|
|
4020
|
+
}
|
|
4021
|
+
function isNewer(remote, local) {
|
|
4022
|
+
const r = remote.split(".").map(Number);
|
|
4023
|
+
const l = local.split(".").map(Number);
|
|
4024
|
+
for (let i = 0; i < Math.max(r.length, l.length); i++) {
|
|
4025
|
+
const rv = r[i] ?? 0;
|
|
4026
|
+
const lv = l[i] ?? 0;
|
|
4027
|
+
if (rv > lv) return true;
|
|
4028
|
+
if (rv < lv) return false;
|
|
4029
|
+
}
|
|
4030
|
+
return false;
|
|
4031
|
+
}
|
|
4032
|
+
async function checkForUpdate() {
|
|
4033
|
+
try {
|
|
4034
|
+
const data = loadUpdateCheck();
|
|
4035
|
+
const now = Date.now();
|
|
4036
|
+
if (now - data.lastCheck < CHECK_INTERVAL) return;
|
|
4037
|
+
saveUpdateCheck({ lastCheck: now });
|
|
4038
|
+
const latest = await fetchLatestVersion();
|
|
4039
|
+
if (!latest) return;
|
|
4040
|
+
if (!isNewer(latest, "0.0.10")) return;
|
|
4041
|
+
console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.0.10"} \u2192 ${latest}...\x1B[0m`);
|
|
4042
|
+
(0, import_node_child_process2.execSync)(`npm install -g ${PACKAGE_NAME}@${latest}`, { stdio: "inherit" });
|
|
4043
|
+
console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
|
|
4044
|
+
} catch {
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
|
|
3957
4048
|
// USAGE.md
|
|
3958
4049
|
var USAGE_default = `Reporting.bi CLI
|
|
3959
4050
|
|
|
@@ -3982,11 +4073,11 @@ Jobs:
|
|
|
3982
4073
|
jobs status Show status of all jobs
|
|
3983
4074
|
|
|
3984
4075
|
Analytics:
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4076
|
+
context list [--all] List saved report contexts (--all for all contexts)
|
|
4077
|
+
context get <context_id> Get report context details
|
|
4078
|
+
report <context_id> Execute report and get results
|
|
4079
|
+
dimensions --module <m> List dimensions for a module
|
|
4080
|
+
years --module <m> List available years
|
|
3990
4081
|
|
|
3991
4082
|
Users:
|
|
3992
4083
|
users list List all users
|
|
@@ -4027,6 +4118,10 @@ Wiki:
|
|
|
4027
4118
|
Global options:
|
|
4028
4119
|
--json Output raw JSON instead of table format
|
|
4029
4120
|
--columns col1,col2,... Select specific columns to display
|
|
4121
|
+
--offset <n> Skip first N results
|
|
4122
|
+
--limit <n> Limit to N results
|
|
4123
|
+
--sort <col>[,col2,...] Sort by columns (prefix with - for desc)
|
|
4124
|
+
--filter <expression> Filter results (server-side where clause)
|
|
4030
4125
|
|
|
4031
4126
|
Default domain: https://reporting.bi
|
|
4032
4127
|
Default language: cs
|
|
@@ -4044,8 +4139,8 @@ Examples:
|
|
|
4044
4139
|
rpbi jobs start "My Job"
|
|
4045
4140
|
rpbi jobs status
|
|
4046
4141
|
|
|
4047
|
-
rpbi
|
|
4048
|
-
rpbi
|
|
4142
|
+
rpbi context list
|
|
4143
|
+
rpbi report 123
|
|
4049
4144
|
|
|
4050
4145
|
rpbi users me
|
|
4051
4146
|
rpbi users list --json
|
|
@@ -4068,48 +4163,60 @@ Examples:
|
|
|
4068
4163
|
`;
|
|
4069
4164
|
|
|
4070
4165
|
// src/index.ts
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4166
|
+
(async () => {
|
|
4167
|
+
await checkForUpdate();
|
|
4168
|
+
const [command, ...args] = process.argv.slice(2);
|
|
4169
|
+
switch (command) {
|
|
4170
|
+
case "login":
|
|
4171
|
+
login(args);
|
|
4172
|
+
break;
|
|
4173
|
+
case "logout":
|
|
4174
|
+
logout(args[0]);
|
|
4175
|
+
break;
|
|
4176
|
+
case "use":
|
|
4177
|
+
use(args);
|
|
4178
|
+
break;
|
|
4179
|
+
case "wiki":
|
|
4180
|
+
wiki(args);
|
|
4181
|
+
break;
|
|
4182
|
+
case "accounting":
|
|
4183
|
+
accounting(args);
|
|
4184
|
+
break;
|
|
4185
|
+
case "etl":
|
|
4186
|
+
etl(args);
|
|
4187
|
+
break;
|
|
4188
|
+
case "jobs":
|
|
4189
|
+
jobs(args);
|
|
4190
|
+
break;
|
|
4191
|
+
case "context":
|
|
4192
|
+
context(args);
|
|
4193
|
+
break;
|
|
4194
|
+
case "report":
|
|
4195
|
+
report(args);
|
|
4196
|
+
break;
|
|
4197
|
+
case "dimensions":
|
|
4198
|
+
dimensions(args);
|
|
4199
|
+
break;
|
|
4200
|
+
case "years":
|
|
4201
|
+
years(args);
|
|
4202
|
+
break;
|
|
4203
|
+
case "users":
|
|
4204
|
+
users(args);
|
|
4205
|
+
break;
|
|
4206
|
+
case "def":
|
|
4207
|
+
def(args);
|
|
4208
|
+
break;
|
|
4209
|
+
case "mdm":
|
|
4210
|
+
mdm(args);
|
|
4211
|
+
break;
|
|
4212
|
+
case "helpdesk":
|
|
4213
|
+
helpdesk(args);
|
|
4214
|
+
break;
|
|
4215
|
+
case "status":
|
|
4216
|
+
status();
|
|
4217
|
+
break;
|
|
4218
|
+
default:
|
|
4219
|
+
console.log(USAGE_default);
|
|
4220
|
+
break;
|
|
4221
|
+
}
|
|
4222
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reporting-bi/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Reporting.bi CLI — command-line interface for the Reporting.bi platform",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"deploy-installers": "cp install.sh ../rp-static/install-cli.sh && cp install.ps1 ../rp-static/install-cli.ps1",
|
|
18
18
|
"release": "yarn node -e \"const p=require('./package.json');const v=p.version.split('.');v[2]++;p.version=v.join('.');require('fs').writeFileSync('package.json',JSON.stringify(p,null,'\\t')+'\\n')\" && yarn build && git add package.json && git commit -m \"rp-cli v$(yarn node -p \"require('./package.json').version\")\" && git push && yarn npm publish --access public"
|
|
19
19
|
},
|
|
20
|
-
"dependencies": {},
|
|
21
20
|
"devDependencies": {
|
|
22
21
|
"@reporting/rp-auth-client-v2": "^0.0.1",
|
|
23
22
|
"@reporting/rp-client": "^0.0.1",
|