@reporting-bi/cli 0.1.5 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/index.js +158 -82
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1741,9 +1741,9 @@ var require_side_channel = __commonJS({
1741
1741
  }
1742
1742
  });
1743
1743
 
1744
- // ../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/formats.js
1744
+ // ../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/formats.js
1745
1745
  var require_formats = __commonJS({
1746
- "../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/formats.js"(exports2, module2) {
1746
+ "../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/formats.js"(exports2, module2) {
1747
1747
  "use strict";
1748
1748
  var replace = String.prototype.replace;
1749
1749
  var percentTwenties = /%20/g;
@@ -1767,9 +1767,9 @@ var require_formats = __commonJS({
1767
1767
  }
1768
1768
  });
1769
1769
 
1770
- // ../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/utils.js
1770
+ // ../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/utils.js
1771
1771
  var require_utils = __commonJS({
1772
- "../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/utils.js"(exports2, module2) {
1772
+ "../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/utils.js"(exports2, module2) {
1773
1773
  "use strict";
1774
1774
  var formats = require_formats();
1775
1775
  var getSideChannel = require_side_channel();
@@ -1792,7 +1792,7 @@ var require_utils = __commonJS({
1792
1792
  var hexTable = function() {
1793
1793
  var array2 = [];
1794
1794
  for (var i = 0; i < 256; ++i) {
1795
- array2.push("%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase());
1795
+ array2[array2.length] = "%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase();
1796
1796
  }
1797
1797
  return array2;
1798
1798
  }();
@@ -1804,7 +1804,7 @@ var require_utils = __commonJS({
1804
1804
  var compacted = [];
1805
1805
  for (var j = 0; j < obj.length; ++j) {
1806
1806
  if (typeof obj[j] !== "undefined") {
1807
- compacted.push(obj[j]);
1807
+ compacted[compacted.length] = obj[j];
1808
1808
  }
1809
1809
  }
1810
1810
  item.obj[item.prop] = compacted;
@@ -1826,12 +1826,18 @@ var require_utils = __commonJS({
1826
1826
  }
1827
1827
  if (typeof source !== "object" && typeof source !== "function") {
1828
1828
  if (isArray(target)) {
1829
- target.push(source);
1829
+ var nextIndex = target.length;
1830
+ if (options && typeof options.arrayLimit === "number" && nextIndex > options.arrayLimit) {
1831
+ return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
1832
+ }
1833
+ target[nextIndex] = source;
1830
1834
  } else if (target && typeof target === "object") {
1831
1835
  if (isOverflow(target)) {
1832
1836
  var newIndex = getMaxIndex(target) + 1;
1833
1837
  target[newIndex] = source;
1834
1838
  setMaxIndex(target, newIndex);
1839
+ } else if (options && options.strictMerge) {
1840
+ return [target, source];
1835
1841
  } else if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
1836
1842
  target[source] = true;
1837
1843
  }
@@ -1850,7 +1856,11 @@ var require_utils = __commonJS({
1850
1856
  }
1851
1857
  return markOverflow(result, getMaxIndex(source) + 1);
1852
1858
  }
1853
- return [target].concat(source);
1859
+ var combined = [target].concat(source);
1860
+ if (options && typeof options.arrayLimit === "number" && combined.length > options.arrayLimit) {
1861
+ return markOverflow(arrayToObject(combined, options), combined.length - 1);
1862
+ }
1863
+ return combined;
1854
1864
  }
1855
1865
  var mergeTarget = target;
1856
1866
  if (isArray(target) && !isArray(source)) {
@@ -1863,7 +1873,7 @@ var require_utils = __commonJS({
1863
1873
  if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
1864
1874
  target[i] = merge3(targetItem, item, options);
1865
1875
  } else {
1866
- target.push(item);
1876
+ target[target.length] = item;
1867
1877
  }
1868
1878
  } else {
1869
1879
  target[i] = item;
@@ -1878,6 +1888,15 @@ var require_utils = __commonJS({
1878
1888
  } else {
1879
1889
  acc[key] = value;
1880
1890
  }
1891
+ if (isOverflow(source) && !isOverflow(acc)) {
1892
+ markOverflow(acc, getMaxIndex(source));
1893
+ }
1894
+ if (isOverflow(acc)) {
1895
+ var keyNum = parseInt(key, 10);
1896
+ if (String(keyNum) === key && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
1897
+ setMaxIndex(acc, keyNum);
1898
+ }
1899
+ }
1881
1900
  return acc;
1882
1901
  }, mergeTarget);
1883
1902
  };
@@ -1955,8 +1974,8 @@ var require_utils = __commonJS({
1955
1974
  var key = keys[j];
1956
1975
  var val = obj[key];
1957
1976
  if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) {
1958
- queue.push({ obj, prop: key });
1959
- refs.push(val);
1977
+ queue[queue.length] = { obj, prop: key };
1978
+ refs[refs.length] = val;
1960
1979
  }
1961
1980
  }
1962
1981
  }
@@ -1989,7 +2008,7 @@ var require_utils = __commonJS({
1989
2008
  if (isArray(val)) {
1990
2009
  var mapped = [];
1991
2010
  for (var i = 0; i < val.length; i += 1) {
1992
- mapped.push(fn(val[i]));
2011
+ mapped[mapped.length] = fn(val[i]);
1993
2012
  }
1994
2013
  return mapped;
1995
2014
  }
@@ -2005,15 +2024,16 @@ var require_utils = __commonJS({
2005
2024
  isBuffer,
2006
2025
  isOverflow,
2007
2026
  isRegExp,
2027
+ markOverflow,
2008
2028
  maybeMap,
2009
2029
  merge: merge2
2010
2030
  };
2011
2031
  }
2012
2032
  });
2013
2033
 
2014
- // ../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/stringify.js
2034
+ // ../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/stringify.js
2015
2035
  var require_stringify = __commonJS({
2016
- "../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/stringify.js"(exports2, module2) {
2036
+ "../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/stringify.js"(exports2, module2) {
2017
2037
  "use strict";
2018
2038
  var getSideChannel = require_side_channel();
2019
2039
  var utils = require_utils();
@@ -2294,9 +2314,9 @@ var require_stringify = __commonJS({
2294
2314
  }
2295
2315
  });
2296
2316
 
2297
- // ../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/parse.js
2317
+ // ../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/parse.js
2298
2318
  var require_parse = __commonJS({
2299
- "../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/parse.js"(exports2, module2) {
2319
+ "../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/parse.js"(exports2, module2) {
2300
2320
  "use strict";
2301
2321
  var utils = require_utils();
2302
2322
  var has = Object.prototype.hasOwnProperty;
@@ -2321,6 +2341,7 @@ var require_parse = __commonJS({
2321
2341
  parseArrays: true,
2322
2342
  plainObjects: false,
2323
2343
  strictDepth: false,
2344
+ strictMerge: true,
2324
2345
  strictNullHandling: false,
2325
2346
  throwOnLimitExceeded: false
2326
2347
  };
@@ -2401,9 +2422,15 @@ var require_parse = __commonJS({
2401
2422
  if (part.indexOf("[]=") > -1) {
2402
2423
  val = isArray(val) ? [val] : val;
2403
2424
  }
2425
+ if (options.comma && isArray(val) && val.length > options.arrayLimit) {
2426
+ if (options.throwOnLimitExceeded) {
2427
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
2428
+ }
2429
+ val = utils.combine([], val, options.arrayLimit, options.plainObjects);
2430
+ }
2404
2431
  if (key !== null) {
2405
2432
  var existing = has.call(obj, key);
2406
- if (existing && options.duplicates === "combine") {
2433
+ if (existing && (options.duplicates === "combine" || part.indexOf("[]=") > -1)) {
2407
2434
  obj[key] = utils.combine(
2408
2435
  obj[key],
2409
2436
  val,
@@ -2443,11 +2470,17 @@ var require_parse = __commonJS({
2443
2470
  var cleanRoot = root.charAt(0) === "[" && root.charAt(root.length - 1) === "]" ? root.slice(1, -1) : root;
2444
2471
  var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, ".") : cleanRoot;
2445
2472
  var index = parseInt(decodedRoot, 10);
2473
+ var isValidArrayIndex = !isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays;
2446
2474
  if (!options.parseArrays && decodedRoot === "") {
2447
2475
  obj = { 0: leaf };
2448
- } else if (!isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && (options.parseArrays && index <= options.arrayLimit)) {
2476
+ } else if (isValidArrayIndex && index < options.arrayLimit) {
2449
2477
  obj = [];
2450
2478
  obj[index] = leaf;
2479
+ } else if (isValidArrayIndex && options.throwOnLimitExceeded) {
2480
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
2481
+ } else if (isValidArrayIndex) {
2482
+ obj[index] = leaf;
2483
+ utils.markOverflow(obj, index);
2451
2484
  } else if (decodedRoot !== "__proto__") {
2452
2485
  obj[decodedRoot] = leaf;
2453
2486
  }
@@ -2477,7 +2510,7 @@ var require_parse = __commonJS({
2477
2510
  return;
2478
2511
  }
2479
2512
  }
2480
- keys.push(parent);
2513
+ keys[keys.length] = parent;
2481
2514
  }
2482
2515
  var i = 0;
2483
2516
  while ((segment = child.exec(key)) !== null && i < options.depth) {
@@ -2488,13 +2521,13 @@ var require_parse = __commonJS({
2488
2521
  return;
2489
2522
  }
2490
2523
  }
2491
- keys.push(segment[1]);
2524
+ keys[keys.length] = segment[1];
2492
2525
  }
2493
2526
  if (segment) {
2494
2527
  if (options.strictDepth === true) {
2495
2528
  throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true");
2496
2529
  }
2497
- keys.push("[" + key.slice(segment.index) + "]");
2530
+ keys[keys.length] = "[" + key.slice(segment.index) + "]";
2498
2531
  }
2499
2532
  return keys;
2500
2533
  };
@@ -2554,6 +2587,7 @@ var require_parse = __commonJS({
2554
2587
  parseArrays: opts.parseArrays !== false,
2555
2588
  plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects,
2556
2589
  strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults.strictDepth,
2590
+ strictMerge: typeof opts.strictMerge === "boolean" ? !!opts.strictMerge : defaults.strictMerge,
2557
2591
  strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling,
2558
2592
  throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === "boolean" ? opts.throwOnLimitExceeded : false
2559
2593
  };
@@ -2579,9 +2613,9 @@ var require_parse = __commonJS({
2579
2613
  }
2580
2614
  });
2581
2615
 
2582
- // ../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/index.js
2616
+ // ../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/index.js
2583
2617
  var require_lib = __commonJS({
2584
- "../../.yarn/cache/qs-npm-6.14.1-2af4c28250-0e3b22dc45.zip/node_modules/qs/lib/index.js"(exports2, module2) {
2618
+ "../../.yarn/cache/qs-npm-6.15.0-2165244317-ff341078a7.zip/node_modules/qs/lib/index.js"(exports2, module2) {
2585
2619
  "use strict";
2586
2620
  var stringify = require_stringify();
2587
2621
  var parse3 = require_parse();
@@ -9660,6 +9694,7 @@ var ReportingAuthClient = class {
9660
9694
  "name": options.name || "",
9661
9695
  "username": options.username || "",
9662
9696
  "expiration": options.expiration,
9697
+ "client_id": options.client_id || void 0,
9663
9698
  "scope": scope,
9664
9699
  "accounting": accounting2
9665
9700
  }))
@@ -9667,7 +9702,7 @@ var ReportingAuthClient = class {
9667
9702
  return await this.response.json();
9668
9703
  }
9669
9704
  async impersonate(username) {
9670
- await this.fetchWithAuth(`${this.options.serviceUrl}/impersonate`, {
9705
+ const response = await this.fetchWithAuth(`${this.options.serviceUrl}/impersonate`, {
9671
9706
  method: "POST",
9672
9707
  headers: {
9673
9708
  "Content-Type": "application/json"
@@ -9676,6 +9711,28 @@ var ReportingAuthClient = class {
9676
9711
  "username": username
9677
9712
  })
9678
9713
  });
9714
+ if (!response.ok) {
9715
+ const err = await response.json();
9716
+ throw new ReportingAuthClientException(err);
9717
+ }
9718
+ }
9719
+ async log(action, data = {}, accounting2) {
9720
+ await this.fetchWithAuth(`${this.options.serviceUrl}/log`, {
9721
+ method: "POST",
9722
+ headers: {
9723
+ "Content-Type": "application/json"
9724
+ },
9725
+ body: JSON.stringify({ action, accounting: accounting2 ?? this.options.accounting, ...data })
9726
+ });
9727
+ }
9728
+ async stopImpersonate() {
9729
+ const response = await this.fetchWithAuth(`${this.options.serviceUrl}/stopImpersonate`, {
9730
+ method: "POST"
9731
+ });
9732
+ if (!response.ok) {
9733
+ const err = await response.json();
9734
+ throw new ReportingAuthClientException(err);
9735
+ }
9679
9736
  }
9680
9737
  async authorize(authorizationCode) {
9681
9738
  this.response = await this.fetchWithAuth(`${this.options.serviceUrl}/token`, {
@@ -9707,6 +9764,9 @@ var ReportingAuthClient = class {
9707
9764
  if (authorizationCode) {
9708
9765
  queryParams.push("code=" + encodeURIComponent(authorizationCode));
9709
9766
  }
9767
+ if (this.options.state) {
9768
+ queryParams.push("state=" + encodeURIComponent(this.options.state));
9769
+ }
9710
9770
  queryParams.push("redirect_uri=" + encodeURIComponent(redirectUri));
9711
9771
  }
9712
9772
  url2 += (url2.includes("?") ? "&" : "?") + queryParams.join("&");
@@ -10632,8 +10692,8 @@ async function pull(flags) {
10632
10692
  const absPath = path4.join(dir, relPath);
10633
10693
  try {
10634
10694
  const content2 = await wikiService.get(
10635
- `pageContent/${lang}/${page.id_wiki_page}`,
10636
- void 0,
10695
+ `pages/${page.id_wiki_page}/content`,
10696
+ { lang },
10637
10697
  { parseResponse: false }
10638
10698
  ) || "";
10639
10699
  writeFileSync4(absPath, content2);
@@ -10724,9 +10784,9 @@ async function push(flags, files) {
10724
10784
  if (entry2) {
10725
10785
  try {
10726
10786
  if (entry2.type === "page") {
10727
- await wikiService.delete(`page/${entry2.lang}/${entry2.id}`);
10787
+ await wikiService.delete(`pages/${entry2.id}`, { lang: entry2.lang });
10728
10788
  } else {
10729
- await wikiService.delete(`file/${entry2.id}`);
10789
+ await wikiService.delete(`files/${entry2.id}`);
10730
10790
  }
10731
10791
  const idx = index.indexOf(entry2);
10732
10792
  if (idx !== -1) index.splice(idx, 1);
@@ -10749,8 +10809,8 @@ async function push(flags, files) {
10749
10809
  if (!force) {
10750
10810
  try {
10751
10811
  const serverContent = await wikiService.get(
10752
- `pageContent/${entry.lang}/${entry.id}`,
10753
- void 0,
10812
+ `pages/${entry.id}/content`,
10813
+ { lang: entry.lang },
10754
10814
  { parseResponse: false }
10755
10815
  ) || "";
10756
10816
  const serverHash = computeHash(serverContent);
@@ -10761,7 +10821,7 @@ async function push(flags, files) {
10761
10821
  } catch {
10762
10822
  }
10763
10823
  }
10764
- const updated = await wikiService.post("page", {
10824
+ const updated = await wikiService.post("pages", {
10765
10825
  id_wiki_page: entry.id,
10766
10826
  lang: entry.lang,
10767
10827
  name: pageName,
@@ -10771,7 +10831,7 @@ async function push(flags, files) {
10771
10831
  if (updated?.date_created) entry.serverDate = updated.date_created;
10772
10832
  console.log(` Updated: ${relPath}`);
10773
10833
  } else {
10774
- const result = await wikiService.post("page", {
10834
+ const result = await wikiService.post("pages", {
10775
10835
  lang,
10776
10836
  name: pageName,
10777
10837
  content: localContent
@@ -10794,7 +10854,7 @@ async function push(flags, files) {
10794
10854
  const buf = fs5.readFileSync(absPath);
10795
10855
  const b64Content = buf.toString("base64");
10796
10856
  if (entry) {
10797
- const updated = await wikiService.post("file", {
10857
+ const updated = await wikiService.post("files", {
10798
10858
  id_wiki_file: entry.id,
10799
10859
  filename: name,
10800
10860
  content: b64Content,
@@ -10804,7 +10864,7 @@ async function push(flags, files) {
10804
10864
  if (updated?.date_created) entry.serverDate = updated.date_created;
10805
10865
  console.log(` Updated: ${relPath}`);
10806
10866
  } else {
10807
- const result = await wikiService.post("file", {
10867
+ const result = await wikiService.post("files", {
10808
10868
  lang,
10809
10869
  filename: name,
10810
10870
  content: b64Content
@@ -10950,13 +11010,13 @@ async function list2(flags) {
10950
11010
  async function get(id, flags) {
10951
11011
  const lang = flags.lang || DEFAULT_LANG;
10952
11012
  const service = await createService("wiki");
10953
- const page = await service.get(`page/${lang}/${id}`);
11013
+ const page = await service.get(`pages/${id}`, { lang });
10954
11014
  output(page, flags);
10955
11015
  }
10956
11016
  async function read(id, flags) {
10957
11017
  const lang = flags.lang || DEFAULT_LANG;
10958
11018
  const service = await createService("wiki");
10959
- const content2 = await service.get(`pageContent/${lang}/${id}`, void 0, { parseResponse: false });
11019
+ const content2 = await service.get(`pageContent/${id}`, { lang }, { parseResponse: false });
10960
11020
  process.stdout.write(content2 || "");
10961
11021
  }
10962
11022
  async function search(query, flags) {
@@ -10992,13 +11052,13 @@ async function save(id, flags) {
10992
11052
  };
10993
11053
  if (id) page.id_wiki_page = parseInt(id);
10994
11054
  if (flags.name) page.name = flags.name;
10995
- const result = await service.post("page", page);
11055
+ const result = await service.post("pages", page);
10996
11056
  output(result, flags);
10997
11057
  }
10998
11058
  async function del(id, flags) {
10999
11059
  const lang = flags.lang || DEFAULT_LANG;
11000
11060
  const service = await createService("wiki");
11001
- await service.delete(`page/${lang}/${id}`);
11061
+ await service.delete(`pages/${id}`, { lang });
11002
11062
  console.log(`Page ${id} deleted.`);
11003
11063
  }
11004
11064
  async function wiki(args) {
@@ -11213,7 +11273,7 @@ async function pull2(flags) {
11213
11273
  const absPath = path5.join(dir, relPath);
11214
11274
  try {
11215
11275
  const content2 = await etlService.get(
11216
- `threadContent/${thread.id_thread}`,
11276
+ `threads/${thread.id_thread}/content`,
11217
11277
  void 0,
11218
11278
  { parseResponse: false }
11219
11279
  ) || "";
@@ -11319,7 +11379,7 @@ async function push2(flags, files) {
11319
11379
  if (!force) {
11320
11380
  try {
11321
11381
  const serverContent = await etlService.get(
11322
- `threadContent/${entry.id_thread}`,
11382
+ `threads/${entry.id_thread}/content`,
11323
11383
  void 0,
11324
11384
  { parseResponse: false }
11325
11385
  ) || "";
@@ -11331,7 +11391,7 @@ async function push2(flags, files) {
11331
11391
  } catch {
11332
11392
  }
11333
11393
  }
11334
- await etlService.post(`threadContent/${entry.id_thread}`, localContent);
11394
+ await etlService.patch(`threads/${entry.id_thread}/content`, localContent);
11335
11395
  entry.hash = computeHash(localContent);
11336
11396
  try {
11337
11397
  const meta3 = await etlService.get(`threads/${entry.id_thread}`, { fields: ["date_created"] });
@@ -11354,7 +11414,7 @@ async function push2(flags, files) {
11354
11414
  enabled: 1
11355
11415
  });
11356
11416
  if (newThread?.id_thread) {
11357
- await etlService.post(`threadContent/${newThread.id_thread}`, localContent);
11417
+ await etlService.patch(`threads/${newThread.id_thread}/content`, localContent);
11358
11418
  index.push({
11359
11419
  path: relPath,
11360
11420
  id_thread: newThread.id_thread,
@@ -11496,7 +11556,7 @@ async function get2(id, flags) {
11496
11556
  }
11497
11557
  async function content(id, flags) {
11498
11558
  const service = await createService("etl");
11499
- const text2 = await service.get(`threadContent/${id}`, void 0, { parseResponse: false });
11559
+ const text2 = await service.get(`threads/${id}/content`, void 0, { parseResponse: false });
11500
11560
  process.stdout.write(text2 || "");
11501
11561
  }
11502
11562
  async function exec2(id, flags) {
@@ -11507,8 +11567,24 @@ async function exec2(id, flags) {
11507
11567
  } else if (flags.sql) {
11508
11568
  body = flags.sql;
11509
11569
  }
11510
- const result = await service.post(`exec/${id}`, body, { parseResponse: false });
11511
- process.stdout.write(result || "");
11570
+ if (flags.output) {
11571
+ const response = await service.postRaw(`exec/${id}`, body, {
11572
+ csv_delimiter: " ",
11573
+ csv_header: "1",
11574
+ csv_header_json: "1",
11575
+ csv_null_value: "NULL"
11576
+ }, { headers: { accept: "text/csv" } });
11577
+ if (!response.ok) {
11578
+ const text3 = await response.text();
11579
+ console.error(text3);
11580
+ process.exit(1);
11581
+ }
11582
+ const text2 = await response.text();
11583
+ fs8.writeFileSync(flags.output, text2);
11584
+ } else {
11585
+ const result = await service.post(`exec/${id}`, body, void 0, { parseResponse: false });
11586
+ process.stdout.write(result || "");
11587
+ }
11512
11588
  }
11513
11589
  async function search2(query, flags) {
11514
11590
  const service = await createService("etl");
@@ -11571,17 +11647,17 @@ async function list4(flags) {
11571
11647
  }
11572
11648
  async function start(jobName, flags) {
11573
11649
  const service = await createService("jobs");
11574
- await service.get("start", { job_name: jobName });
11650
+ await service.post("start", { job_name: jobName });
11575
11651
  console.log(`Job "${jobName}" started.`);
11576
11652
  }
11577
11653
  async function stop(jobName, flags) {
11578
11654
  const service = await createService("jobs");
11579
- await service.get("stop", { job_name: jobName });
11655
+ await service.post("stop", { job_name: jobName });
11580
11656
  console.log(`Job "${jobName}" stopped.`);
11581
11657
  }
11582
11658
  async function statusCmd(flags) {
11583
11659
  const service = await createService("jobs");
11584
- const statuses = await service.get("jobStatuses", getListParams(flags, DEFAULT_STATUS_FIELDS));
11660
+ const statuses = await service.get("statuses", getListParams(flags, DEFAULT_STATUS_FIELDS));
11585
11661
  output(statuses || [], flags);
11586
11662
  }
11587
11663
  async function jobs(args) {
@@ -11723,7 +11799,7 @@ async function statements(flags) {
11723
11799
  }
11724
11800
  async function statement(id, flags) {
11725
11801
  const service = await createService("definition");
11726
- const result = await service.get(`statement/${id}`);
11802
+ const result = await service.get(`statements/${id}`);
11727
11803
  output(result, flags);
11728
11804
  }
11729
11805
  async function dimensions2(flags) {
@@ -11786,7 +11862,7 @@ async function tables(flags) {
11786
11862
  }
11787
11863
  async function table(id, flags) {
11788
11864
  const service = await createService("mdm");
11789
- const result = await service.get(`tableDefinition/${id}`);
11865
+ const result = await service.get(`tableDefinitions/${id}`);
11790
11866
  output(result, flags);
11791
11867
  }
11792
11868
  async function columns(id, flags) {
@@ -11801,8 +11877,8 @@ async function values(id, flags) {
11801
11877
  }
11802
11878
  async function exportCsv(id, flags) {
11803
11879
  const service = await createService("mdm");
11804
- const type = flags.type || "mdm";
11805
- const result = await service.get(`export/${id}/${type}`, void 0, { parseResponse: false });
11880
+ const format = flags.format || "csv";
11881
+ const result = await service.get(`export/${id}`, { format }, { parseResponse: false });
11806
11882
  process.stdout.write(result || "");
11807
11883
  }
11808
11884
  async function mdm(args) {
@@ -11831,7 +11907,7 @@ async function mdm(args) {
11831
11907
  return values(rest[0], flags);
11832
11908
  case "export":
11833
11909
  if (!rest[0]) {
11834
- console.error("Usage: rpbi mdm export <id> [--type mdm|sql]");
11910
+ console.error("Usage: rpbi mdm export <id> [--format csv]");
11835
11911
  process.exit(1);
11836
11912
  }
11837
11913
  return exportCsv(rest[0], flags);
@@ -11851,12 +11927,12 @@ async function list6(flags) {
11851
11927
  }
11852
11928
  async function get4(id, flags) {
11853
11929
  const service = await createService("helpdesk");
11854
- const ticket = await service.get(`ticket/${id}`);
11930
+ const ticket = await service.get(`tickets/${id}`);
11855
11931
  output(ticket, flags);
11856
11932
  }
11857
11933
  async function messages(id, flags) {
11858
11934
  const service = await createService("helpdesk");
11859
- const msgs = await service.get(`messages/${id}`, getListParams(flags, DEFAULT_MESSAGES_FIELDS));
11935
+ const msgs = await service.get(`ticketMessages/${id}`, getListParams(flags, DEFAULT_MESSAGES_FIELDS));
11860
11936
  output(msgs || [], flags);
11861
11937
  }
11862
11938
  async function create(flags) {
@@ -11869,9 +11945,9 @@ async function create(flags) {
11869
11945
  const service = await createService("helpdesk");
11870
11946
  const ticket = { subject };
11871
11947
  if (flags.priority) ticket.priority = parseInt(flags.priority);
11872
- const result = await service.post("ticket", ticket);
11948
+ const result = await service.post("tickets", ticket);
11873
11949
  if (text2 && result?.id_request) {
11874
- await service.post("message", { id_request: result.id_request, text: text2 });
11950
+ await service.post("messages", { id_request: result.id_request, text: text2 });
11875
11951
  }
11876
11952
  output(result, flags);
11877
11953
  }
@@ -35085,7 +35161,7 @@ function text(data) {
35085
35161
  async function mcp() {
35086
35162
  const server = new McpServer({
35087
35163
  name: "reporting-bi",
35088
- version: "0.1.5"
35164
+ version: "0.1.7"
35089
35165
  });
35090
35166
  server.tool(
35091
35167
  "status",
@@ -35187,7 +35263,7 @@ async function mcp() {
35187
35263
  { id: external_exports3.number().describe("Thread ID") },
35188
35264
  async ({ id }) => {
35189
35265
  const service = await createService("etl");
35190
- const result = await service.get(`threadContent/${id}`, void 0, { parseResponse: false });
35266
+ const result = await service.get(`threads/${id}/content`, void 0, { parseResponse: false });
35191
35267
  return text(result || "");
35192
35268
  }
35193
35269
  );
@@ -35227,7 +35303,7 @@ async function mcp() {
35227
35303
  { id: external_exports3.number().describe("Statement ID") },
35228
35304
  async ({ id }) => {
35229
35305
  const service = await createService("definition");
35230
- const result = await service.get(`statement/${id}`);
35306
+ const result = await service.get(`statements/${id}`);
35231
35307
  return json2(result);
35232
35308
  }
35233
35309
  );
@@ -35287,7 +35363,7 @@ async function mcp() {
35287
35363
  { id: external_exports3.number().describe("Table ID (id_md)") },
35288
35364
  async ({ id }) => {
35289
35365
  const service = await createService("mdm");
35290
- const result = await service.get(`tableDefinition/${id}`);
35366
+ const result = await service.get(`tableDefinitions/${id}`);
35291
35367
  return json2(result);
35292
35368
  }
35293
35369
  );
@@ -35313,11 +35389,11 @@ async function mcp() {
35313
35389
  );
35314
35390
  server.tool(
35315
35391
  "mdm_export",
35316
- "Export an MDM table as CSV",
35317
- { id: external_exports3.number().describe("Table ID (id_md)"), type: external_exports3.enum(["mdm", "sql"]).optional().describe("Export type (default: mdm)") },
35318
- async ({ id, type }) => {
35392
+ "Export an MDM table (csv; xlsx planned)",
35393
+ { id: external_exports3.number().describe("Table ID (id_md)"), format: external_exports3.enum(["csv"]).optional().describe("Output file format (default: csv)") },
35394
+ async ({ id, format }) => {
35319
35395
  const service = await createService("mdm");
35320
- const result = await service.get(`export/${id}/${type || "mdm"}`, void 0, { parseResponse: false });
35396
+ const result = await service.get(`export/${id}`, { format: format || "csv" }, { parseResponse: false });
35321
35397
  return text(result || "");
35322
35398
  }
35323
35399
  );
@@ -35337,7 +35413,7 @@ async function mcp() {
35337
35413
  { job_name: external_exports3.string().describe("Job name") },
35338
35414
  async ({ job_name }) => {
35339
35415
  const service = await createService("jobs");
35340
- await service.get("start", { job_name });
35416
+ await service.post("start", { job_name });
35341
35417
  return text(`Job "${job_name}" started.`);
35342
35418
  }
35343
35419
  );
@@ -35347,7 +35423,7 @@ async function mcp() {
35347
35423
  { job_name: external_exports3.string().describe("Job name") },
35348
35424
  async ({ job_name }) => {
35349
35425
  const service = await createService("jobs");
35350
- await service.get("stop", { job_name });
35426
+ await service.post("stop", { job_name });
35351
35427
  return text(`Job "${job_name}" stopped.`);
35352
35428
  }
35353
35429
  );
@@ -35357,7 +35433,7 @@ async function mcp() {
35357
35433
  ListParams,
35358
35434
  async (params) => {
35359
35435
  const service = await createService("jobs");
35360
- const result = await service.get("jobStatuses", toRequestParams(params, ["job_name", "running", "enabled", "last_run", "next_run"]));
35436
+ const result = await service.get("statuses", toRequestParams(params, ["job_name", "running", "enabled", "last_run", "next_run"]));
35361
35437
  return json2(result || []);
35362
35438
  }
35363
35439
  );
@@ -35417,7 +35493,7 @@ async function mcp() {
35417
35493
  { id: external_exports3.number().describe("Page ID"), lang: external_exports3.string().optional().describe("Language code (default: 'cs')") },
35418
35494
  async ({ id, lang }) => {
35419
35495
  const service = await createService("wiki");
35420
- const result = await service.get(`page/${lang || "cs"}/${id}`);
35496
+ const result = await service.get(`pages/${id}`, { lang: lang || "cs" });
35421
35497
  return json2(result);
35422
35498
  }
35423
35499
  );
@@ -35427,7 +35503,7 @@ async function mcp() {
35427
35503
  { id: external_exports3.number().describe("Page ID"), lang: external_exports3.string().optional().describe("Language code (default: 'cs')") },
35428
35504
  async ({ id, lang }) => {
35429
35505
  const service = await createService("wiki");
35430
- const result = await service.get(`pageContent/${lang || "cs"}/${id}`, void 0, { parseResponse: false });
35506
+ const result = await service.get(`pages/${id}/content`, { lang: lang || "cs" }, { parseResponse: false });
35431
35507
  return text(result || "");
35432
35508
  }
35433
35509
  );
@@ -35455,7 +35531,7 @@ async function mcp() {
35455
35531
  const page = { lang: lang || "cs", content: content2 };
35456
35532
  if (id) page.id_wiki_page = id;
35457
35533
  if (name) page.name = name;
35458
- const result = await service.post("page", page);
35534
+ const result = await service.post("pages", page);
35459
35535
  return json2(result);
35460
35536
  }
35461
35537
  );
@@ -35465,7 +35541,7 @@ async function mcp() {
35465
35541
  { id: external_exports3.number().describe("Page ID"), lang: external_exports3.string().optional().describe("Language code (default: 'cs')") },
35466
35542
  async ({ id, lang }) => {
35467
35543
  const service = await createService("wiki");
35468
- await service.delete(`page/${lang || "cs"}/${id}`);
35544
+ await service.delete(`pages/${id}`, { lang: lang || "cs" });
35469
35545
  return text(`Page ${id} deleted.`);
35470
35546
  }
35471
35547
  );
@@ -35485,7 +35561,7 @@ async function mcp() {
35485
35561
  { id: external_exports3.number().describe("Ticket ID") },
35486
35562
  async ({ id }) => {
35487
35563
  const service = await createService("helpdesk");
35488
- const result = await service.get(`ticket/${id}`);
35564
+ const result = await service.get(`tickets/${id}`);
35489
35565
  return json2(result);
35490
35566
  }
35491
35567
  );
@@ -35495,7 +35571,7 @@ async function mcp() {
35495
35571
  { id: external_exports3.number().describe("Ticket ID"), ...ListParams },
35496
35572
  async (params) => {
35497
35573
  const service = await createService("helpdesk");
35498
- const result = await service.get(`messages/${params.id}`, toRequestParams(params, ["id_message", "text", "who_created", "date_created"]));
35574
+ const result = await service.get(`ticketMessages/${params.id}`, toRequestParams(params, ["id_message", "text", "who_created", "date_created"]));
35499
35575
  return json2(result || []);
35500
35576
  }
35501
35577
  );
@@ -35511,9 +35587,9 @@ async function mcp() {
35511
35587
  const service = await createService("helpdesk");
35512
35588
  const ticket = { subject };
35513
35589
  if (priority) ticket.priority = priority;
35514
- const result = await service.post("ticket", ticket);
35590
+ const result = await service.post("tickets", ticket);
35515
35591
  if (msgText && result?.id_request) {
35516
- await service.post("message", { id_request: result.id_request, text: msgText });
35592
+ await service.post("messages", { id_request: result.id_request, text: msgText });
35517
35593
  }
35518
35594
  return json2(result);
35519
35595
  }
@@ -35631,8 +35707,8 @@ async function checkForUpdate() {
35631
35707
  saveUpdateCheck({ lastCheck: now });
35632
35708
  const latest = await fetchLatestVersion();
35633
35709
  if (!latest) return;
35634
- if (!isNewer(latest, "0.1.5")) return;
35635
- console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.5"} \u2192 ${latest}...\x1B[0m`);
35710
+ if (!isNewer(latest, "0.1.7")) return;
35711
+ console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.7"} \u2192 ${latest}...\x1B[0m`);
35636
35712
  (0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
35637
35713
  console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
35638
35714
  } catch {
@@ -35644,11 +35720,11 @@ async function forceUpdate() {
35644
35720
  console.error("Could not fetch latest version from npm.");
35645
35721
  process.exit(1);
35646
35722
  }
35647
- if (!isNewer(latest, "0.1.5")) {
35648
- console.log(`Already up to date (${"0.1.5"}).`);
35723
+ if (!isNewer(latest, "0.1.7")) {
35724
+ console.log(`Already up to date (${"0.1.7"}).`);
35649
35725
  return;
35650
35726
  }
35651
- console.log(`Updating ${PACKAGE_NAME} ${"0.1.5"} \u2192 ${latest}...`);
35727
+ console.log(`Updating ${PACKAGE_NAME} ${"0.1.7"} \u2192 ${latest}...`);
35652
35728
  (0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
35653
35729
  console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
35654
35730
  saveUpdateCheck({ lastCheck: Date.now() });
@@ -35798,7 +35874,7 @@ Examples:
35798
35874
  (async () => {
35799
35875
  const [command, ...args] = process.argv.slice(2);
35800
35876
  if (command === "--version" || command === "-v") {
35801
- console.log("0.1.5");
35877
+ console.log("0.1.7");
35802
35878
  return;
35803
35879
  }
35804
35880
  await checkForUpdate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reporting-bi/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Reporting.bi CLI — command-line interface for the Reporting.bi platform",
6
6
  "main": "./dist/index.js",