@reporting-bi/cli 0.0.8 → 0.0.9
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 +104 -72
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -3111,8 +3111,30 @@ 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
3139
|
function parseArgs(args2) {
|
|
3118
3140
|
const positional = [];
|
|
@@ -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
|
|
|
@@ -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) {
|
|
@@ -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,7 +3594,7 @@ 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
3600
|
async function etl(args2) {
|
|
@@ -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,7 +3653,7 @@ 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
3659
|
async function jobs(args2) {
|
|
@@ -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(args2) {
|
|
3688
|
+
const { positional, flags } = parseArgs(args2);
|
|
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(args2) {
|
|
3714
|
+
const { positional, flags } = parseArgs(args2);
|
|
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(args2) {
|
|
3726
|
+
const { positional, flags } = parseArgs(args2);
|
|
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(args2) {
|
|
3737
|
+
const { positional, flags } = parseArgs(args2);
|
|
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,12 +3756,12 @@ 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
3767
|
async function users(args2) {
|
|
@@ -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,22 +3805,22 @@ 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
3826
|
async function def(args2) {
|
|
@@ -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) {
|
|
@@ -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) {
|
|
@@ -3982,11 +4001,11 @@ Jobs:
|
|
|
3982
4001
|
jobs status Show status of all jobs
|
|
3983
4002
|
|
|
3984
4003
|
Analytics:
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4004
|
+
context list [--all] List saved report contexts (--all for all contexts)
|
|
4005
|
+
context get <context_id> Get report context details
|
|
4006
|
+
report <context_id> Execute report and get results
|
|
4007
|
+
dimensions --module <m> List dimensions for a module
|
|
4008
|
+
years --module <m> List available years
|
|
3990
4009
|
|
|
3991
4010
|
Users:
|
|
3992
4011
|
users list List all users
|
|
@@ -4027,6 +4046,10 @@ Wiki:
|
|
|
4027
4046
|
Global options:
|
|
4028
4047
|
--json Output raw JSON instead of table format
|
|
4029
4048
|
--columns col1,col2,... Select specific columns to display
|
|
4049
|
+
--offset <n> Skip first N results
|
|
4050
|
+
--limit <n> Limit to N results
|
|
4051
|
+
--sort <col>[,col2,...] Sort by columns (prefix with - for desc)
|
|
4052
|
+
--filter <expression> Filter results (server-side where clause)
|
|
4030
4053
|
|
|
4031
4054
|
Default domain: https://reporting.bi
|
|
4032
4055
|
Default language: cs
|
|
@@ -4044,8 +4067,8 @@ Examples:
|
|
|
4044
4067
|
rpbi jobs start "My Job"
|
|
4045
4068
|
rpbi jobs status
|
|
4046
4069
|
|
|
4047
|
-
rpbi
|
|
4048
|
-
rpbi
|
|
4070
|
+
rpbi context list
|
|
4071
|
+
rpbi report 123
|
|
4049
4072
|
|
|
4050
4073
|
rpbi users me
|
|
4051
4074
|
rpbi users list --json
|
|
@@ -4091,8 +4114,17 @@ switch (command) {
|
|
|
4091
4114
|
case "jobs":
|
|
4092
4115
|
jobs(args);
|
|
4093
4116
|
break;
|
|
4094
|
-
case "
|
|
4095
|
-
|
|
4117
|
+
case "context":
|
|
4118
|
+
context(args);
|
|
4119
|
+
break;
|
|
4120
|
+
case "report":
|
|
4121
|
+
report(args);
|
|
4122
|
+
break;
|
|
4123
|
+
case "dimensions":
|
|
4124
|
+
dimensions(args);
|
|
4125
|
+
break;
|
|
4126
|
+
case "years":
|
|
4127
|
+
years(args);
|
|
4096
4128
|
break;
|
|
4097
4129
|
case "users":
|
|
4098
4130
|
users(args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reporting-bi/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
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",
|