@reporting-bi/cli 0.1.12 → 0.1.13

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 +45 -37
  2. package/package.json +32 -32
package/dist/index.js CHANGED
@@ -10270,6 +10270,14 @@ function output(data, flags) {
10270
10270
  console.log(data);
10271
10271
  }
10272
10272
  }
10273
+ function errorMessage(err) {
10274
+ const data = err?.data;
10275
+ return data?.message || data?.error || (err instanceof Error ? err.message : String(err));
10276
+ }
10277
+ function fail(err, context3) {
10278
+ console.error(context3 ? `${context3}: ${errorMessage(err)}` : errorMessage(err));
10279
+ process.exit(1);
10280
+ }
10273
10281
 
10274
10282
  // src/commands/accounting.ts
10275
10283
  async function fetchAccountingName(accountingId) {
@@ -11874,11 +11882,11 @@ async function params(id, flags) {
11874
11882
  if (flags.save) {
11875
11883
  const data = JSON.parse(fs8.readFileSync(flags.save, "utf-8"));
11876
11884
  data.id_thread ??= parseInt(id);
11877
- const result = await service.post(`threads/${id}/parameters`, data);
11885
+ const result = await service.post(`threads/${id}/parameters`, data).catch((err) => fail(err, "Parameter not saved"));
11878
11886
  await refreshYaml();
11879
11887
  output(result, flags);
11880
11888
  } else if (flags.delete) {
11881
- await service.delete(`threads/${id}/parameters/${flags.delete}`);
11889
+ await service.delete(`threads/${id}/parameters/${flags.delete}`).catch((err) => fail(err, "Parameter not deleted"));
11882
11890
  await refreshYaml();
11883
11891
  console.log(`Parameter ${flags.delete} deleted.`);
11884
11892
  } else {
@@ -12852,11 +12860,11 @@ async function params2(id, flags) {
12852
12860
  if (flags.save) {
12853
12861
  const data = JSON.parse(fs12.readFileSync(flags.save, "utf-8"));
12854
12862
  data.id_thread ??= parseInt(id);
12855
- const result = await service.post("parameters", data);
12863
+ const result = await service.post("parameters", data).catch((err) => fail(err, "Parameter not saved"));
12856
12864
  await refreshMeta();
12857
12865
  output(result, flags);
12858
12866
  } else if (flags.delete) {
12859
- await service.delete(`parameters/${flags.delete}`);
12867
+ await service.delete(`parameters/${flags.delete}`).catch((err) => fail(err, "Parameter not deleted"));
12860
12868
  await refreshMeta();
12861
12869
  console.log(`Parameter ${flags.delete} deleted.`);
12862
12870
  } else {
@@ -13711,15 +13719,15 @@ var makeIssue = (params3) => {
13711
13719
  message: issueData.message
13712
13720
  };
13713
13721
  }
13714
- let errorMessage = "";
13722
+ let errorMessage2 = "";
13715
13723
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
13716
13724
  for (const map2 of maps) {
13717
- errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
13725
+ errorMessage2 = map2(fullIssue, { data, defaultError: errorMessage2 }).message;
13718
13726
  }
13719
13727
  return {
13720
13728
  ...issueData,
13721
13729
  path: fullPath,
13722
- message: errorMessage
13730
+ message: errorMessage2
13723
13731
  };
13724
13732
  };
13725
13733
  function addIssueToContext(ctx, issueData) {
@@ -32751,19 +32759,19 @@ var getRefs = (options) => {
32751
32759
  };
32752
32760
 
32753
32761
  // ../../.yarn/__virtual__/zod-to-json-schema-virtual-00ec010bf6/0/cache/zod-to-json-schema-npm-3.25.1-850d9216b4-711b30e34d.zip/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
32754
- function addErrorMessage(res, key, errorMessage, refs) {
32762
+ function addErrorMessage(res, key, errorMessage2, refs) {
32755
32763
  if (!refs?.errorMessages)
32756
32764
  return;
32757
- if (errorMessage) {
32765
+ if (errorMessage2) {
32758
32766
  res.errorMessage = {
32759
32767
  ...res.errorMessage,
32760
- [key]: errorMessage
32768
+ [key]: errorMessage2
32761
32769
  };
32762
32770
  }
32763
32771
  }
32764
- function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
32772
+ function setResponseValueAndErrors(res, key, value, errorMessage2, refs) {
32765
32773
  res[key] = value;
32766
- addErrorMessage(res, key, errorMessage, refs);
32774
+ addErrorMessage(res, key, errorMessage2, refs);
32767
32775
  }
32768
32776
 
32769
32777
  // ../../.yarn/__virtual__/zod-to-json-schema-virtual-00ec010bf6/0/cache/zod-to-json-schema-npm-3.25.1-850d9216b4-711b30e34d.zip/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
@@ -34074,8 +34082,8 @@ var Protocol = class {
34074
34082
  if (queuedMessage.type === "response") {
34075
34083
  resolver(message);
34076
34084
  } else {
34077
- const errorMessage = message;
34078
- const error48 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
34085
+ const errorMessage2 = message;
34086
+ const error48 = new McpError(errorMessage2.error.code, errorMessage2.error.message, errorMessage2.error.data);
34079
34087
  resolver(error48);
34080
34088
  }
34081
34089
  } else {
@@ -35228,23 +35236,23 @@ var Server = class extends Protocol {
35228
35236
  const wrappedHandler = async (request, extra) => {
35229
35237
  const validatedRequest = safeParse2(CallToolRequestSchema, request);
35230
35238
  if (!validatedRequest.success) {
35231
- const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
35232
- throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
35239
+ const errorMessage2 = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
35240
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage2}`);
35233
35241
  }
35234
35242
  const { params: params3 } = validatedRequest.data;
35235
35243
  const result = await Promise.resolve(handler(request, extra));
35236
35244
  if (params3.task) {
35237
35245
  const taskValidationResult = safeParse2(CreateTaskResultSchema, result);
35238
35246
  if (!taskValidationResult.success) {
35239
- const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
35240
- throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
35247
+ const errorMessage2 = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
35248
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage2}`);
35241
35249
  }
35242
35250
  return taskValidationResult.data;
35243
35251
  }
35244
35252
  const validationResult = safeParse2(CallToolResultSchema, result);
35245
35253
  if (!validationResult.success) {
35246
- const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
35247
- throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
35254
+ const errorMessage2 = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
35255
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage2}`);
35248
35256
  }
35249
35257
  return validationResult.data;
35250
35258
  };
@@ -35738,12 +35746,12 @@ var McpServer = class {
35738
35746
  * @param errorMessage - The error message.
35739
35747
  * @returns The tool error result.
35740
35748
  */
35741
- createToolError(errorMessage) {
35749
+ createToolError(errorMessage2) {
35742
35750
  return {
35743
35751
  content: [
35744
35752
  {
35745
35753
  type: "text",
35746
- text: errorMessage
35754
+ text: errorMessage2
35747
35755
  }
35748
35756
  ],
35749
35757
  isError: true
@@ -35761,8 +35769,8 @@ var McpServer = class {
35761
35769
  const parseResult = await safeParseAsync2(schemaToParse, args);
35762
35770
  if (!parseResult.success) {
35763
35771
  const error48 = "error" in parseResult ? parseResult.error : "Unknown error";
35764
- const errorMessage = getParseErrorMessage(error48);
35765
- throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage}`);
35772
+ const errorMessage2 = getParseErrorMessage(error48);
35773
+ throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage2}`);
35766
35774
  }
35767
35775
  return parseResult.data;
35768
35776
  }
@@ -35786,8 +35794,8 @@ var McpServer = class {
35786
35794
  const parseResult = await safeParseAsync2(outputObj, result.structuredContent);
35787
35795
  if (!parseResult.success) {
35788
35796
  const error48 = "error" in parseResult ? parseResult.error : "Unknown error";
35789
- const errorMessage = getParseErrorMessage(error48);
35790
- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`);
35797
+ const errorMessage2 = getParseErrorMessage(error48);
35798
+ throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage2}`);
35791
35799
  }
35792
35800
  }
35793
35801
  /**
@@ -35999,8 +36007,8 @@ var McpServer = class {
35999
36007
  const parseResult = await safeParseAsync2(argsObj, request.params.arguments);
36000
36008
  if (!parseResult.success) {
36001
36009
  const error48 = "error" in parseResult ? parseResult.error : "Unknown error";
36002
- const errorMessage = getParseErrorMessage(error48);
36003
- throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${errorMessage}`);
36010
+ const errorMessage2 = getParseErrorMessage(error48);
36011
+ throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${errorMessage2}`);
36004
36012
  }
36005
36013
  const args = parseResult.data;
36006
36014
  const cb = prompt.callback;
@@ -36524,7 +36532,7 @@ async function mcp() {
36524
36532
  setMcpMode();
36525
36533
  const server = new McpServer({
36526
36534
  name: "reporting-bi",
36527
- version: "0.1.12"
36535
+ version: "0.1.13"
36528
36536
  });
36529
36537
  server.tool(
36530
36538
  "status",
@@ -37057,8 +37065,8 @@ async function checkForUpdate() {
37057
37065
  saveUpdateCheck({ lastCheck: now });
37058
37066
  const latest = await fetchLatestVersion();
37059
37067
  if (!latest) return;
37060
- if (!isNewer(latest, "0.1.12")) return;
37061
- console.error(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.12"} \u2192 ${latest}...\x1B[0m`);
37068
+ if (!isNewer(latest, "0.1.13")) return;
37069
+ console.error(`\x1B[33mUpdating ${PACKAGE_NAME} ${"0.1.13"} \u2192 ${latest}...\x1B[0m`);
37062
37070
  (0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: ["ignore", 2, 2] });
37063
37071
  console.error(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
37064
37072
  } catch {
@@ -37070,11 +37078,11 @@ async function forceUpdate() {
37070
37078
  console.error("Could not fetch latest version from npm.");
37071
37079
  process.exit(1);
37072
37080
  }
37073
- if (!isNewer(latest, "0.1.12")) {
37074
- console.log(`Already up to date (${"0.1.12"}).`);
37081
+ if (!isNewer(latest, "0.1.13")) {
37082
+ console.log(`Already up to date (${"0.1.13"}).`);
37075
37083
  return;
37076
37084
  }
37077
- console.log(`Updating ${PACKAGE_NAME} ${"0.1.12"} \u2192 ${latest}...`);
37085
+ console.log(`Updating ${PACKAGE_NAME} ${"0.1.13"} \u2192 ${latest}...`);
37078
37086
  (0, import_node_child_process3.execSync)(npmInstallCmd(latest), { stdio: "inherit" });
37079
37087
  console.log(`\x1B[32mUpdated to ${latest}.\x1B[0m`);
37080
37088
  saveUpdateCheck({ lastCheck: Date.now() });
@@ -37113,7 +37121,7 @@ ETL:
37113
37121
  etl exec <id> [--sql "..."|--file f] Execute thread (optionally with custom SQL)
37114
37122
  etl abort <spid> Abort a running exec (exec reports "rpbi: spid <n>" on stderr)
37115
37123
  etl search <query> Search threads
37116
- etl params <id> [--save <json>|--delete <idz>] List, save or delete thread parameters
37124
+ etl params <id> [--save <json>|--delete <idz>] List, save or delete thread parameters (save creates, or updates when the JSON carries "idz"; a name already declared alongside is refused)
37117
37125
  etl pull [--dir <path>] [--no-context] Pull all ETL threads, parameters, metadata & schema to local files
37118
37126
  etl push [files...] [--dir <path>] [--force] Push modified/new .sql files back to server
37119
37127
  etl status [--dir <path>] [--remote] [--json] Show local changes (--remote compares with server)
@@ -37138,7 +37146,7 @@ Extensions (requires the "custom.define" right):
37138
37146
  ext content <id> [--query] Get resource content (--query for query SQL)
37139
37147
  ext exec <query_id> [--sql "..."|--file f] Execute query (optionally with custom SQL)
37140
37148
  ext abort <spid> Abort a running exec (exec reports "rpbi: spid <n>" on stderr)
37141
- ext params <query_id> [--save <json>|--delete <idz>] List, save or delete query parameters
37149
+ ext params <query_id> [--save <json>|--delete <idz>] List, save or delete query parameters (save creates, or updates when the JSON carries "idz"; a name already declared alongside is refused)
37142
37150
  ext deps --project <id>|--query <id>|--resource <id> List SQL dependencies (resource \u2194 query links)
37143
37151
  ext deps --query <id> --add <resource_id> Link a query to a resource (or --resource <id> --add <query_id>)
37144
37152
  ext deps --remove <idz> Unlink a dependency
@@ -37262,7 +37270,7 @@ Examples:
37262
37270
  (async () => {
37263
37271
  const [command, ...args] = process.argv.slice(2);
37264
37272
  if (command === "--version" || command === "-v") {
37265
- console.log("0.1.12");
37273
+ console.log("0.1.13");
37266
37274
  return;
37267
37275
  }
37268
37276
  await checkForUpdate();
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
1
  {
2
- "name": "@reporting-bi/cli",
3
- "version": "0.1.12",
4
- "license": "UNLICENSED",
5
- "description": "Reporting.bi CLI — command-line interface for the Reporting.bi platform",
6
- "main": "./dist/index.js",
7
- "bin": {
8
- "rpbi": "./dist/index.js"
9
- },
10
- "files": [
11
- "dist/index.js"
12
- ],
13
- "scripts": {
14
- "build": "yarn node build.mjs",
15
- "watch": "yarn build --watch",
16
- "rpbi": "yarn node dist/index.js",
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
- "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
- },
20
- "devDependencies": {
21
- "@modelcontextprotocol/sdk": "1.26.0",
22
- "@reporting/rp-auth-client-v2": "workspace:^",
23
- "@reporting/rp-client": "workspace:^",
24
- "@reporting/rp-types": "workspace:^",
25
- "@types/node": "^18.11.18",
26
- "esbuild": "^0.25.1",
27
- "typescript": "^5.9.3",
28
- "zod": "^4.3.6"
29
- },
30
- "publishConfig": {
31
- "access": "public"
32
- }
33
- }
2
+ "name": "@reporting-bi/cli",
3
+ "version": "0.1.13",
4
+ "license": "UNLICENSED",
5
+ "description": "Reporting.bi CLI — command-line interface for the Reporting.bi platform",
6
+ "main": "./dist/index.js",
7
+ "bin": {
8
+ "rpbi": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist/index.js"
12
+ ],
13
+ "scripts": {
14
+ "build": "yarn node build.mjs",
15
+ "watch": "yarn build --watch",
16
+ "rpbi": "yarn node dist/index.js",
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
+ "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
+ },
20
+ "devDependencies": {
21
+ "@modelcontextprotocol/sdk": "1.26.0",
22
+ "@reporting/rp-auth-client-v2": "^0.0.1",
23
+ "@reporting/rp-client": "^0.0.1",
24
+ "@reporting/rp-types": "^0.0.3",
25
+ "@types/node": "^18.11.18",
26
+ "esbuild": "^0.25.1",
27
+ "typescript": "^5.9.3",
28
+ "zod": "^4.3.6"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ }
33
+ }