@reporting-bi/cli 0.1.6 → 0.1.8

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 +160 -82
  2. package/package.json +2 -2
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();
@@ -2604,7 +2638,7 @@ var require_service = __commonJS({
2604
2638
  Object.defineProperty(exports2, "__esModule", { value: true });
2605
2639
  exports2.Service = exports2.ServiceAuthException = exports2.ServiceEvent = exports2.ServiceException = exports2.serializeRequestParams = void 0;
2606
2640
  var qs_1 = __importDefault(require_lib());
2607
- var cache_1 = require_cache();
2641
+ var cache_js_1 = require_cache();
2608
2642
  function isObject2(value) {
2609
2643
  return value !== null && typeof value === "object" && !Array.isArray(value);
2610
2644
  }
@@ -2649,7 +2683,7 @@ var require_service = __commonJS({
2649
2683
  }
2650
2684
  get cache() {
2651
2685
  if (!this._cache)
2652
- this._cache = new cache_1.ServiceCache();
2686
+ this._cache = new cache_js_1.ServiceCache();
2653
2687
  return this._cache;
2654
2688
  }
2655
2689
  constructor(options) {
@@ -2786,6 +2820,24 @@ var require_service = __commonJS({
2786
2820
  const response = await this.putRaw(path7, data, params, options);
2787
2821
  return this.handleResponse(response);
2788
2822
  }
2823
+ async patchRaw(path7, data, params, options) {
2824
+ const url2 = this.createUrl(path7, params);
2825
+ this.dispatchEvent(new ServiceEvent2("beforeRequest", { url: url2, params, options, method: "PATCH" }));
2826
+ const json3 = isObject2(data) || Array.isArray(data);
2827
+ return fetch(url2, {
2828
+ method: "PATCH",
2829
+ body: json3 ? JSON.stringify(data) : data,
2830
+ headers: await this.createHeaders({
2831
+ ...options?.headers ?? {},
2832
+ "Content-Type": `${json3 ? "application/json" : "text/plain"}; charset=UTF-8`
2833
+ }),
2834
+ credentials: this.credentials
2835
+ });
2836
+ }
2837
+ async patch(path7, data, params, options) {
2838
+ const response = await this.patchRaw(path7, data, params, options);
2839
+ return this.handleResponse(response);
2840
+ }
2789
2841
  };
2790
2842
  exports2.Service = Service2;
2791
2843
  }
@@ -9660,6 +9712,7 @@ var ReportingAuthClient = class {
9660
9712
  "name": options.name || "",
9661
9713
  "username": options.username || "",
9662
9714
  "expiration": options.expiration,
9715
+ "client_id": options.client_id || void 0,
9663
9716
  "scope": scope,
9664
9717
  "accounting": accounting2
9665
9718
  }))
@@ -9667,7 +9720,7 @@ var ReportingAuthClient = class {
9667
9720
  return await this.response.json();
9668
9721
  }
9669
9722
  async impersonate(username) {
9670
- await this.fetchWithAuth(`${this.options.serviceUrl}/impersonate`, {
9723
+ const response = await this.fetchWithAuth(`${this.options.serviceUrl}/impersonate`, {
9671
9724
  method: "POST",
9672
9725
  headers: {
9673
9726
  "Content-Type": "application/json"
@@ -9676,6 +9729,28 @@ var ReportingAuthClient = class {
9676
9729
  "username": username
9677
9730
  })
9678
9731
  });
9732
+ if (!response.ok) {
9733
+ const err = await response.json();
9734
+ throw new ReportingAuthClientException(err);
9735
+ }
9736
+ }
9737
+ async log(action, data = {}, accounting2) {
9738
+ await this.fetchWithAuth(`${this.options.serviceUrl}/log`, {
9739
+ method: "POST",
9740
+ headers: {
9741
+ "Content-Type": "application/json"
9742
+ },
9743
+ body: JSON.stringify({ action, accounting: accounting2 ?? this.options.accounting, ...data })
9744
+ });
9745
+ }
9746
+ async stopImpersonate() {
9747
+ const response = await this.fetchWithAuth(`${this.options.serviceUrl}/stopImpersonate`, {
9748
+ method: "POST"
9749
+ });
9750
+ if (!response.ok) {
9751
+ const err = await response.json();
9752
+ throw new ReportingAuthClientException(err);
9753
+ }
9679
9754
  }
9680
9755
  async authorize(authorizationCode) {
9681
9756
  this.response = await this.fetchWithAuth(`${this.options.serviceUrl}/token`, {
@@ -9707,6 +9782,9 @@ var ReportingAuthClient = class {
9707
9782
  if (authorizationCode) {
9708
9783
  queryParams.push("code=" + encodeURIComponent(authorizationCode));
9709
9784
  }
9785
+ if (this.options.state) {
9786
+ queryParams.push("state=" + encodeURIComponent(this.options.state));
9787
+ }
9710
9788
  queryParams.push("redirect_uri=" + encodeURIComponent(redirectUri));
9711
9789
  }
9712
9790
  url2 += (url2.includes("?") ? "&" : "?") + queryParams.join("&");
@@ -10632,8 +10710,8 @@ async function pull(flags) {
10632
10710
  const absPath = path4.join(dir, relPath);
10633
10711
  try {
10634
10712
  const content2 = await wikiService.get(
10635
- `pageContent/${lang}/${page.id_wiki_page}`,
10636
- void 0,
10713
+ `pages/${page.id_wiki_page}/content`,
10714
+ { lang },
10637
10715
  { parseResponse: false }
10638
10716
  ) || "";
10639
10717
  writeFileSync4(absPath, content2);
@@ -10724,9 +10802,9 @@ async function push(flags, files) {
10724
10802
  if (entry2) {
10725
10803
  try {
10726
10804
  if (entry2.type === "page") {
10727
- await wikiService.delete(`page/${entry2.lang}/${entry2.id}`);
10805
+ await wikiService.delete(`pages/${entry2.id}`, { lang: entry2.lang });
10728
10806
  } else {
10729
- await wikiService.delete(`file/${entry2.id}`);
10807
+ await wikiService.delete(`files/${entry2.id}`);
10730
10808
  }
10731
10809
  const idx = index.indexOf(entry2);
10732
10810
  if (idx !== -1) index.splice(idx, 1);
@@ -10749,8 +10827,8 @@ async function push(flags, files) {
10749
10827
  if (!force) {
10750
10828
  try {
10751
10829
  const serverContent = await wikiService.get(
10752
- `pageContent/${entry.lang}/${entry.id}`,
10753
- void 0,
10830
+ `pages/${entry.id}/content`,
10831
+ { lang: entry.lang },
10754
10832
  { parseResponse: false }
10755
10833
  ) || "";
10756
10834
  const serverHash = computeHash(serverContent);
@@ -10761,7 +10839,7 @@ async function push(flags, files) {
10761
10839
  } catch {
10762
10840
  }
10763
10841
  }
10764
- const updated = await wikiService.post("page", {
10842
+ const updated = await wikiService.post("pages", {
10765
10843
  id_wiki_page: entry.id,
10766
10844
  lang: entry.lang,
10767
10845
  name: pageName,
@@ -10771,7 +10849,7 @@ async function push(flags, files) {
10771
10849
  if (updated?.date_created) entry.serverDate = updated.date_created;
10772
10850
  console.log(` Updated: ${relPath}`);
10773
10851
  } else {
10774
- const result = await wikiService.post("page", {
10852
+ const result = await wikiService.post("pages", {
10775
10853
  lang,
10776
10854
  name: pageName,
10777
10855
  content: localContent
@@ -10794,7 +10872,7 @@ async function push(flags, files) {
10794
10872
  const buf = fs5.readFileSync(absPath);
10795
10873
  const b64Content = buf.toString("base64");
10796
10874
  if (entry) {
10797
- const updated = await wikiService.post("file", {
10875
+ const updated = await wikiService.post("files", {
10798
10876
  id_wiki_file: entry.id,
10799
10877
  filename: name,
10800
10878
  content: b64Content,
@@ -10804,7 +10882,7 @@ async function push(flags, files) {
10804
10882
  if (updated?.date_created) entry.serverDate = updated.date_created;
10805
10883
  console.log(` Updated: ${relPath}`);
10806
10884
  } else {
10807
- const result = await wikiService.post("file", {
10885
+ const result = await wikiService.post("files", {
10808
10886
  lang,
10809
10887
  filename: name,
10810
10888
  content: b64Content
@@ -10950,13 +11028,13 @@ async function list2(flags) {
10950
11028
  async function get(id, flags) {
10951
11029
  const lang = flags.lang || DEFAULT_LANG;
10952
11030
  const service = await createService("wiki");
10953
- const page = await service.get(`page/${lang}/${id}`);
11031
+ const page = await service.get(`pages/${id}`, { lang });
10954
11032
  output(page, flags);
10955
11033
  }
10956
11034
  async function read(id, flags) {
10957
11035
  const lang = flags.lang || DEFAULT_LANG;
10958
11036
  const service = await createService("wiki");
10959
- const content2 = await service.get(`pageContent/${lang}/${id}`, void 0, { parseResponse: false });
11037
+ const content2 = await service.get(`pageContent/${id}`, { lang }, { parseResponse: false });
10960
11038
  process.stdout.write(content2 || "");
10961
11039
  }
10962
11040
  async function search(query, flags) {
@@ -10992,13 +11070,13 @@ async function save(id, flags) {
10992
11070
  };
10993
11071
  if (id) page.id_wiki_page = parseInt(id);
10994
11072
  if (flags.name) page.name = flags.name;
10995
- const result = await service.post("page", page);
11073
+ const result = await service.post("pages", page);
10996
11074
  output(result, flags);
10997
11075
  }
10998
11076
  async function del(id, flags) {
10999
11077
  const lang = flags.lang || DEFAULT_LANG;
11000
11078
  const service = await createService("wiki");
11001
- await service.delete(`page/${lang}/${id}`);
11079
+ await service.delete(`pages/${id}`, { lang });
11002
11080
  console.log(`Page ${id} deleted.`);
11003
11081
  }
11004
11082
  async function wiki(args) {
@@ -11213,7 +11291,7 @@ async function pull2(flags) {
11213
11291
  const absPath = path5.join(dir, relPath);
11214
11292
  try {
11215
11293
  const content2 = await etlService.get(
11216
- `threadContent/${thread.id_thread}`,
11294
+ `threads/${thread.id_thread}/content`,
11217
11295
  void 0,
11218
11296
  { parseResponse: false }
11219
11297
  ) || "";
@@ -11319,7 +11397,7 @@ async function push2(flags, files) {
11319
11397
  if (!force) {
11320
11398
  try {
11321
11399
  const serverContent = await etlService.get(
11322
- `threadContent/${entry.id_thread}`,
11400
+ `threads/${entry.id_thread}/content`,
11323
11401
  void 0,
11324
11402
  { parseResponse: false }
11325
11403
  ) || "";
@@ -11331,7 +11409,7 @@ async function push2(flags, files) {
11331
11409
  } catch {
11332
11410
  }
11333
11411
  }
11334
- await etlService.post(`threadContent/${entry.id_thread}`, localContent);
11412
+ await etlService.patch(`threads/${entry.id_thread}/content`, localContent);
11335
11413
  entry.hash = computeHash(localContent);
11336
11414
  try {
11337
11415
  const meta3 = await etlService.get(`threads/${entry.id_thread}`, { fields: ["date_created"] });
@@ -11354,7 +11432,7 @@ async function push2(flags, files) {
11354
11432
  enabled: 1
11355
11433
  });
11356
11434
  if (newThread?.id_thread) {
11357
- await etlService.post(`threadContent/${newThread.id_thread}`, localContent);
11435
+ await etlService.patch(`threads/${newThread.id_thread}/content`, localContent);
11358
11436
  index.push({
11359
11437
  path: relPath,
11360
11438
  id_thread: newThread.id_thread,
@@ -11496,7 +11574,7 @@ async function get2(id, flags) {
11496
11574
  }
11497
11575
  async function content(id, flags) {
11498
11576
  const service = await createService("etl");
11499
- const text2 = await service.get(`threadContent/${id}`, void 0, { parseResponse: false });
11577
+ const text2 = await service.get(`threads/${id}/content`, void 0, { parseResponse: false });
11500
11578
  process.stdout.write(text2 || "");
11501
11579
  }
11502
11580
  async function exec2(id, flags) {
@@ -11587,17 +11665,17 @@ async function list4(flags) {
11587
11665
  }
11588
11666
  async function start(jobName, flags) {
11589
11667
  const service = await createService("jobs");
11590
- await service.get("start", { job_name: jobName });
11668
+ await service.post("start", { job_name: jobName });
11591
11669
  console.log(`Job "${jobName}" started.`);
11592
11670
  }
11593
11671
  async function stop(jobName, flags) {
11594
11672
  const service = await createService("jobs");
11595
- await service.get("stop", { job_name: jobName });
11673
+ await service.post("stop", { job_name: jobName });
11596
11674
  console.log(`Job "${jobName}" stopped.`);
11597
11675
  }
11598
11676
  async function statusCmd(flags) {
11599
11677
  const service = await createService("jobs");
11600
- const statuses = await service.get("jobStatuses", getListParams(flags, DEFAULT_STATUS_FIELDS));
11678
+ const statuses = await service.get("statuses", getListParams(flags, DEFAULT_STATUS_FIELDS));
11601
11679
  output(statuses || [], flags);
11602
11680
  }
11603
11681
  async function jobs(args) {
@@ -11739,7 +11817,7 @@ async function statements(flags) {
11739
11817
  }
11740
11818
  async function statement(id, flags) {
11741
11819
  const service = await createService("definition");
11742
- const result = await service.get(`statement/${id}`);
11820
+ const result = await service.get(`statements/${id}`);
11743
11821
  output(result, flags);
11744
11822
  }
11745
11823
  async function dimensions2(flags) {
@@ -11802,7 +11880,7 @@ async function tables(flags) {
11802
11880
  }
11803
11881
  async function table(id, flags) {
11804
11882
  const service = await createService("mdm");
11805
- const result = await service.get(`tableDefinition/${id}`);
11883
+ const result = await service.get(`tableDefinitions/${id}`);
11806
11884
  output(result, flags);
11807
11885
  }
11808
11886
  async function columns(id, flags) {
@@ -11817,8 +11895,8 @@ async function values(id, flags) {
11817
11895
  }
11818
11896
  async function exportCsv(id, flags) {
11819
11897
  const service = await createService("mdm");
11820
- const type = flags.type || "mdm";
11821
- const result = await service.get(`export/${id}/${type}`, void 0, { parseResponse: false });
11898
+ const format = flags.format || "csv";
11899
+ const result = await service.get(`export/${id}`, { format }, { parseResponse: false });
11822
11900
  process.stdout.write(result || "");
11823
11901
  }
11824
11902
  async function mdm(args) {
@@ -11847,7 +11925,7 @@ async function mdm(args) {
11847
11925
  return values(rest[0], flags);
11848
11926
  case "export":
11849
11927
  if (!rest[0]) {
11850
- console.error("Usage: rpbi mdm export <id> [--type mdm|sql]");
11928
+ console.error("Usage: rpbi mdm export <id> [--format csv]");
11851
11929
  process.exit(1);
11852
11930
  }
11853
11931
  return exportCsv(rest[0], flags);
@@ -11867,12 +11945,12 @@ async function list6(flags) {
11867
11945
  }
11868
11946
  async function get4(id, flags) {
11869
11947
  const service = await createService("helpdesk");
11870
- const ticket = await service.get(`ticket/${id}`);
11948
+ const ticket = await service.get(`tickets/${id}`);
11871
11949
  output(ticket, flags);
11872
11950
  }
11873
11951
  async function messages(id, flags) {
11874
11952
  const service = await createService("helpdesk");
11875
- const msgs = await service.get(`messages/${id}`, getListParams(flags, DEFAULT_MESSAGES_FIELDS));
11953
+ const msgs = await service.get(`ticketMessages/${id}`, getListParams(flags, DEFAULT_MESSAGES_FIELDS));
11876
11954
  output(msgs || [], flags);
11877
11955
  }
11878
11956
  async function create(flags) {
@@ -11885,9 +11963,9 @@ async function create(flags) {
11885
11963
  const service = await createService("helpdesk");
11886
11964
  const ticket = { subject };
11887
11965
  if (flags.priority) ticket.priority = parseInt(flags.priority);
11888
- const result = await service.post("ticket", ticket);
11966
+ const result = await service.post("tickets", ticket);
11889
11967
  if (text2 && result?.id_request) {
11890
- await service.post("message", { id_request: result.id_request, text: text2 });
11968
+ await service.post("messages", { id_request: result.id_request, text: text2 });
11891
11969
  }
11892
11970
  output(result, flags);
11893
11971
  }
@@ -35101,7 +35179,7 @@ function text(data) {
35101
35179
  async function mcp() {
35102
35180
  const server = new McpServer({
35103
35181
  name: "reporting-bi",
35104
- version: "0.1.6"
35182
+ version: "0.1.8"
35105
35183
  });
35106
35184
  server.tool(
35107
35185
  "status",
@@ -35203,7 +35281,7 @@ async function mcp() {
35203
35281
  { id: external_exports3.number().describe("Thread ID") },
35204
35282
  async ({ id }) => {
35205
35283
  const service = await createService("etl");
35206
- const result = await service.get(`threadContent/${id}`, void 0, { parseResponse: false });
35284
+ const result = await service.get(`threads/${id}/content`, void 0, { parseResponse: false });
35207
35285
  return text(result || "");
35208
35286
  }
35209
35287
  );
@@ -35243,7 +35321,7 @@ async function mcp() {
35243
35321
  { id: external_exports3.number().describe("Statement ID") },
35244
35322
  async ({ id }) => {
35245
35323
  const service = await createService("definition");
35246
- const result = await service.get(`statement/${id}`);
35324
+ const result = await service.get(`statements/${id}`);
35247
35325
  return json2(result);
35248
35326
  }
35249
35327
  );
@@ -35303,7 +35381,7 @@ async function mcp() {
35303
35381
  { id: external_exports3.number().describe("Table ID (id_md)") },
35304
35382
  async ({ id }) => {
35305
35383
  const service = await createService("mdm");
35306
- const result = await service.get(`tableDefinition/${id}`);
35384
+ const result = await service.get(`tableDefinitions/${id}`);
35307
35385
  return json2(result);
35308
35386
  }
35309
35387
  );
@@ -35329,11 +35407,11 @@ async function mcp() {
35329
35407
  );
35330
35408
  server.tool(
35331
35409
  "mdm_export",
35332
- "Export an MDM table as CSV",
35333
- { id: external_exports3.number().describe("Table ID (id_md)"), type: external_exports3.enum(["mdm", "sql"]).optional().describe("Export type (default: mdm)") },
35334
- async ({ id, type }) => {
35410
+ "Export an MDM table (csv; xlsx planned)",
35411
+ { id: external_exports3.number().describe("Table ID (id_md)"), format: external_exports3.enum(["csv"]).optional().describe("Output file format (default: csv)") },
35412
+ async ({ id, format }) => {
35335
35413
  const service = await createService("mdm");
35336
- const result = await service.get(`export/${id}/${type || "mdm"}`, void 0, { parseResponse: false });
35414
+ const result = await service.get(`export/${id}`, { format: format || "csv" }, { parseResponse: false });
35337
35415
  return text(result || "");
35338
35416
  }
35339
35417
  );
@@ -35353,7 +35431,7 @@ async function mcp() {
35353
35431
  { job_name: external_exports3.string().describe("Job name") },
35354
35432
  async ({ job_name }) => {
35355
35433
  const service = await createService("jobs");
35356
- await service.get("start", { job_name });
35434
+ await service.post("start", { job_name });
35357
35435
  return text(`Job "${job_name}" started.`);
35358
35436
  }
35359
35437
  );
@@ -35363,7 +35441,7 @@ async function mcp() {
35363
35441
  { job_name: external_exports3.string().describe("Job name") },
35364
35442
  async ({ job_name }) => {
35365
35443
  const service = await createService("jobs");
35366
- await service.get("stop", { job_name });
35444
+ await service.post("stop", { job_name });
35367
35445
  return text(`Job "${job_name}" stopped.`);
35368
35446
  }
35369
35447
  );
@@ -35373,7 +35451,7 @@ async function mcp() {
35373
35451
  ListParams,
35374
35452
  async (params) => {
35375
35453
  const service = await createService("jobs");
35376
- const result = await service.get("jobStatuses", toRequestParams(params, ["job_name", "running", "enabled", "last_run", "next_run"]));
35454
+ const result = await service.get("statuses", toRequestParams(params, ["job_name", "running", "enabled", "last_run", "next_run"]));
35377
35455
  return json2(result || []);
35378
35456
  }
35379
35457
  );
@@ -35433,7 +35511,7 @@ async function mcp() {
35433
35511
  { id: external_exports3.number().describe("Page ID"), lang: external_exports3.string().optional().describe("Language code (default: 'cs')") },
35434
35512
  async ({ id, lang }) => {
35435
35513
  const service = await createService("wiki");
35436
- const result = await service.get(`page/${lang || "cs"}/${id}`);
35514
+ const result = await service.get(`pages/${id}`, { lang: lang || "cs" });
35437
35515
  return json2(result);
35438
35516
  }
35439
35517
  );
@@ -35443,7 +35521,7 @@ async function mcp() {
35443
35521
  { id: external_exports3.number().describe("Page ID"), lang: external_exports3.string().optional().describe("Language code (default: 'cs')") },
35444
35522
  async ({ id, lang }) => {
35445
35523
  const service = await createService("wiki");
35446
- const result = await service.get(`pageContent/${lang || "cs"}/${id}`, void 0, { parseResponse: false });
35524
+ const result = await service.get(`pages/${id}/content`, { lang: lang || "cs" }, { parseResponse: false });
35447
35525
  return text(result || "");
35448
35526
  }
35449
35527
  );
@@ -35471,7 +35549,7 @@ async function mcp() {
35471
35549
  const page = { lang: lang || "cs", content: content2 };
35472
35550
  if (id) page.id_wiki_page = id;
35473
35551
  if (name) page.name = name;
35474
- const result = await service.post("page", page);
35552
+ const result = await service.post("pages", page);
35475
35553
  return json2(result);
35476
35554
  }
35477
35555
  );
@@ -35481,7 +35559,7 @@ async function mcp() {
35481
35559
  { id: external_exports3.number().describe("Page ID"), lang: external_exports3.string().optional().describe("Language code (default: 'cs')") },
35482
35560
  async ({ id, lang }) => {
35483
35561
  const service = await createService("wiki");
35484
- await service.delete(`page/${lang || "cs"}/${id}`);
35562
+ await service.delete(`pages/${id}`, { lang: lang || "cs" });
35485
35563
  return text(`Page ${id} deleted.`);
35486
35564
  }
35487
35565
  );
@@ -35501,7 +35579,7 @@ async function mcp() {
35501
35579
  { id: external_exports3.number().describe("Ticket ID") },
35502
35580
  async ({ id }) => {
35503
35581
  const service = await createService("helpdesk");
35504
- const result = await service.get(`ticket/${id}`);
35582
+ const result = await service.get(`tickets/${id}`);
35505
35583
  return json2(result);
35506
35584
  }
35507
35585
  );
@@ -35511,7 +35589,7 @@ async function mcp() {
35511
35589
  { id: external_exports3.number().describe("Ticket ID"), ...ListParams },
35512
35590
  async (params) => {
35513
35591
  const service = await createService("helpdesk");
35514
- const result = await service.get(`messages/${params.id}`, toRequestParams(params, ["id_message", "text", "who_created", "date_created"]));
35592
+ const result = await service.get(`ticketMessages/${params.id}`, toRequestParams(params, ["id_message", "text", "who_created", "date_created"]));
35515
35593
  return json2(result || []);
35516
35594
  }
35517
35595
  );
@@ -35527,9 +35605,9 @@ async function mcp() {
35527
35605
  const service = await createService("helpdesk");
35528
35606
  const ticket = { subject };
35529
35607
  if (priority) ticket.priority = priority;
35530
- const result = await service.post("ticket", ticket);
35608
+ const result = await service.post("tickets", ticket);
35531
35609
  if (msgText && result?.id_request) {
35532
- await service.post("message", { id_request: result.id_request, text: msgText });
35610
+ await service.post("messages", { id_request: result.id_request, text: msgText });
35533
35611
  }
35534
35612
  return json2(result);
35535
35613
  }
@@ -35647,8 +35725,8 @@ async function checkForUpdate() {
35647
35725
  saveUpdateCheck({ lastCheck: now });
35648
35726
  const latest = await fetchLatestVersion();
35649
35727
  if (!latest) return;
35650
- if (!isNewer(latest, "0.1.6")) return;
35651
- console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.6"} \u2192 ${latest}...\x1B[0m`);
35728
+ if (!isNewer(latest, "0.1.8")) return;
35729
+ console.log(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.8"} \u2192 ${latest}...\x1B[0m`);
35652
35730
  (0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
35653
35731
  console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
35654
35732
  } catch {
@@ -35660,11 +35738,11 @@ async function forceUpdate() {
35660
35738
  console.error("Could not fetch latest version from npm.");
35661
35739
  process.exit(1);
35662
35740
  }
35663
- if (!isNewer(latest, "0.1.6")) {
35664
- console.log(`Already up to date (${"0.1.6"}).`);
35741
+ if (!isNewer(latest, "0.1.8")) {
35742
+ console.log(`Already up to date (${"0.1.8"}).`);
35665
35743
  return;
35666
35744
  }
35667
- console.log(`Updating ${PACKAGE_NAME} ${"0.1.6"} \u2192 ${latest}...`);
35745
+ console.log(`Updating ${PACKAGE_NAME} ${"0.1.8"} \u2192 ${latest}...`);
35668
35746
  (0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
35669
35747
  console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
35670
35748
  saveUpdateCheck({ lastCheck: Date.now() });
@@ -35814,7 +35892,7 @@ Examples:
35814
35892
  (async () => {
35815
35893
  const [command, ...args] = process.argv.slice(2);
35816
35894
  if (command === "--version" || command === "-v") {
35817
- console.log("0.1.6");
35895
+ console.log("0.1.8");
35818
35896
  return;
35819
35897
  }
35820
35898
  await checkForUpdate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reporting-bi/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Reporting.bi CLI — command-line interface for the Reporting.bi platform",
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "build": "yarn node build.mjs",
15
15
  "watch": "yarn build --watch",
16
16
  "rpbi": "yarn node dist/index.js",
17
- "deploy-installers": "cp install.sh ../rp-static/install-cli.sh && cp install.ps1 ../rp-static/install-cli.ps1",
17
+ "deploy-installers": "node -e \"const fs=require('fs');fs.cpSync('install.sh','../rp-static/install-cli.sh');fs.cpSync('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
20
  "devDependencies": {