@ganakailabs/cloudeval-cli 0.29.3 → 0.30.0

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.
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-CS4NE336.js";
9
9
  import {
10
10
  Onboarding
11
- } from "./chunk-4OE4CRKD.js";
11
+ } from "./chunk-VRO5RWBC.js";
12
12
  import {
13
13
  checkUserStatus,
14
14
  completeActiveAssistantMessage,
@@ -35,13 +35,13 @@ import {
35
35
  reduceChunk,
36
36
  runReports,
37
37
  streamChat
38
- } from "./chunk-ERGQHMNT.js";
38
+ } from "./chunk-NXM4JEOB.js";
39
39
  import {
40
40
  Banner
41
- } from "./chunk-D2ROSW4U.js";
41
+ } from "./chunk-LWKMLKKE.js";
42
42
  import {
43
43
  CLI_VERSION
44
- } from "./chunk-PN4AUAH6.js";
44
+ } from "./chunk-C5GOTWYL.js";
45
45
  import {
46
46
  raisedButtonStyle,
47
47
  terminalTheme
@@ -5914,7 +5914,7 @@ var getUserIdentityFromToken = async (token) => {
5914
5914
  return { name: "You" };
5915
5915
  }
5916
5916
  try {
5917
- const { extractEmailFromToken } = await import("./dist-QYIPN7MD.js");
5917
+ const { extractEmailFromToken } = await import("./dist-6LEMVXIY.js");
5918
5918
  const email = extractEmailFromToken(token) ?? void 0;
5919
5919
  return {
5920
5920
  name: getFirstNameForDisplay({ email }),
@@ -7350,7 +7350,7 @@ var App = ({
7350
7350
  setIsLoggingIn(true);
7351
7351
  setLoaderStep(1);
7352
7352
  try {
7353
- const { login } = await import("./dist-QYIPN7MD.js");
7353
+ const { login } = await import("./dist-6LEMVXIY.js");
7354
7354
  const newToken = await login(baseUrl, {
7355
7355
  headless: Boolean(process.env.SSH_TTY || process.env.CI)
7356
7356
  });
@@ -3,8 +3,8 @@ import {
3
3
  bannerMetaColor,
4
4
  bannerSegmentColor,
5
5
  splitBannerLineSegments
6
- } from "./chunk-D2ROSW4U.js";
7
- import "./chunk-PN4AUAH6.js";
6
+ } from "./chunk-LWKMLKKE.js";
7
+ import "./chunk-C5GOTWYL.js";
8
8
  import "./chunk-ZDKRIOMB.js";
9
9
  export {
10
10
  Banner,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Onboarding
3
- } from "./chunk-4OE4CRKD.js";
4
- import "./chunk-ERGQHMNT.js";
3
+ } from "./chunk-VRO5RWBC.js";
4
+ import "./chunk-NXM4JEOB.js";
5
5
  import "./chunk-ZDKRIOMB.js";
6
6
  export {
7
7
  Onboarding
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var CLI_VERSION = "0.29.3";
2
+ var CLI_VERSION = "0.30.0";
3
3
 
4
4
  export {
5
5
  CLI_VERSION
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CLI_VERSION
3
- } from "./chunk-PN4AUAH6.js";
3
+ } from "./chunk-C5GOTWYL.js";
4
4
  import {
5
5
  shouldUseColor,
6
6
  terminalTheme
@@ -2737,7 +2737,10 @@ var normalizeCostParsed = (report, metrics = {}) => {
2737
2737
  ).map((item, index) => {
2738
2738
  const row = isObject22(item) ? item : {};
2739
2739
  return {
2740
- name: stringOr2(row.name ?? row.service ?? row.family, `Service ${index + 1}`),
2740
+ name: stringOr2(
2741
+ row.name ?? row.service ?? row.family,
2742
+ `Service ${index + 1}`
2743
+ ),
2741
2744
  amount: numberOr(row.amount ?? row.monthly_cost ?? row.cost, 0),
2742
2745
  currency: stringOr2(row.currency, currency),
2743
2746
  changePercent: numberOr(row.change_percent ?? row.changePercent, 0)
@@ -2749,8 +2752,14 @@ var normalizeCostParsed = (report, metrics = {}) => {
2749
2752
  const row = isObject22(item) ? item : {};
2750
2753
  return {
2751
2754
  id: stringOr2(row.id ?? row.resource_id, `recommendation-${index + 1}`),
2752
- title: stringOr2(row.title ?? row.recommendation ?? row.description, "Cost recommendation"),
2753
- monthlySavings: numberOr(row.monthlySavings ?? row.monthly_savings ?? row.savings, 0),
2755
+ title: stringOr2(
2756
+ row.title ?? row.recommendation ?? row.description,
2757
+ "Cost recommendation"
2758
+ ),
2759
+ monthlySavings: numberOr(
2760
+ row.monthlySavings ?? row.monthly_savings ?? row.savings,
2761
+ 0
2762
+ ),
2754
2763
  currency: stringOr2(row.currency, currency),
2755
2764
  risk: stringOr2(row.risk, "medium")
2756
2765
  };
@@ -2768,20 +2777,22 @@ var normalizeWafParsed = (report, metrics = {}) => {
2768
2777
  const processed = isObject22(report.processed) ? report.processed : {};
2769
2778
  const source = { ...metrics, ...processed };
2770
2779
  const pillarScores = isObject22(source.pillar_scores) ? source.pillar_scores : {};
2771
- const rules = arrayOrEmpty(report.all_rules ?? source.rules).map((item, index) => {
2772
- const row = isObject22(item) ? item : {};
2773
- const outcome = stringOr2(row.status ?? row.outcome, "pass").toLowerCase();
2774
- return {
2775
- id: stringOr2(row.id ?? row.rule_id ?? row.name, `rule-${index + 1}`),
2776
- pillar: stringOr2(row.pillar, "Uncategorized"),
2777
- title: stringOr2(row.title ?? row.description, "Architecture rule"),
2778
- status: outcome === "fail" || outcome === "error" ? "fail" : outcome === "warn" ? "warn" : "pass",
2779
- severity: stringOr2(row.severity, "medium").toLowerCase(),
2780
- resource: typeof row.resource === "string" ? row.resource : void 0,
2781
- evidence: typeof row.evidence === "string" ? row.evidence : void 0,
2782
- recommendation: typeof row.recommendation === "string" ? row.recommendation : void 0
2783
- };
2784
- });
2780
+ const rules = arrayOrEmpty(report.all_rules ?? source.rules).map(
2781
+ (item, index) => {
2782
+ const row = isObject22(item) ? item : {};
2783
+ const outcome = stringOr2(row.status ?? row.outcome, "pass").toLowerCase();
2784
+ return {
2785
+ id: stringOr2(row.id ?? row.rule_id ?? row.name, `rule-${index + 1}`),
2786
+ pillar: stringOr2(row.pillar, "Uncategorized"),
2787
+ title: stringOr2(row.title ?? row.description, "Architecture rule"),
2788
+ status: outcome === "fail" || outcome === "error" ? "fail" : outcome === "warn" ? "warn" : "pass",
2789
+ severity: stringOr2(row.severity, "medium").toLowerCase(),
2790
+ resource: typeof row.resource === "string" ? row.resource : void 0,
2791
+ evidence: typeof row.evidence === "string" ? row.evidence : void 0,
2792
+ recommendation: typeof row.recommendation === "string" ? row.recommendation : void 0
2793
+ };
2794
+ }
2795
+ );
2785
2796
  const failedRules = rules.filter((rule) => rule.status === "fail");
2786
2797
  const mediumRules = rules.filter((rule) => rule.severity === "medium");
2787
2798
  const highRules = rules.filter(
@@ -2815,7 +2826,10 @@ var normalizeBackendReportDetail = (input, fallback) => {
2815
2826
  const report = isObject22(input.report) ? input.report : input;
2816
2827
  const reportType = input.report_type ?? report.kind ?? fallback.reportType;
2817
2828
  const kind = reportTypeToKind(reportType);
2818
- const projectId = stringOr2(input.project_id ?? report.project_id, fallback.projectId);
2829
+ const projectId = stringOr2(
2830
+ input.project_id ?? report.project_id,
2831
+ fallback.projectId
2832
+ );
2819
2833
  const generatedAt = stringOr2(
2820
2834
  input.timestamp ?? report.generated_at ?? (isObject22(report.metadata) ? report.metadata.generated_at : void 0),
2821
2835
  (/* @__PURE__ */ new Date(0)).toISOString()
@@ -2877,6 +2891,45 @@ var fetchJson = async (options, path2, query = {}) => {
2877
2891
  }
2878
2892
  return response.json();
2879
2893
  };
2894
+ var parseContentDispositionFilename = (value) => {
2895
+ if (!value) return void 0;
2896
+ const match = value.match(/filename="?([^";]+)"?/i);
2897
+ return match?.[1];
2898
+ };
2899
+ var downloadReportPdf = async (options) => {
2900
+ const apiBase = normalizeApiBase(options.baseUrl);
2901
+ const url = appendQuery(
2902
+ new URL(
2903
+ `${apiBase}/reports/${encodeURIComponent(options.projectId)}/export/pdf`
2904
+ ),
2905
+ {
2906
+ user_id: options.userId,
2907
+ verbosity: options.verbosity || "detailed",
2908
+ report_type: options.reportType || "all",
2909
+ include_visuals: options.includeVisuals === false ? "false" : "true"
2910
+ }
2911
+ );
2912
+ const response = await fetch(url, {
2913
+ method: "GET",
2914
+ headers: getCLIHeaders(options.authToken)
2915
+ });
2916
+ if (!response.ok) {
2917
+ const body = await compactErrorBody2(response);
2918
+ throw new Error(
2919
+ `PDF report request failed with status ${response.status} ${response.statusText}${body ? `: ${body}` : ""}`
2920
+ );
2921
+ }
2922
+ const bytes = new Uint8Array(await response.arrayBuffer());
2923
+ return {
2924
+ bytes,
2925
+ filename: parseContentDispositionFilename(
2926
+ response.headers.get("content-disposition")
2927
+ ) || `cloudeval-${options.projectId}-${options.verbosity || "detailed"}.pdf`,
2928
+ contentType: response.headers.get("content-type") || "application/pdf",
2929
+ status: response.headers.get("x-cloudeval-report-status") || void 0,
2930
+ warningsCount: response.headers.get("x-cloudeval-report-warnings-count") ? Number(response.headers.get("x-cloudeval-report-warnings-count")) : void 0
2931
+ };
2932
+ };
2880
2933
  var postJson = async (options, path2, query = {}, body) => {
2881
2934
  const apiBase = normalizeApiBase(options.baseUrl);
2882
2935
  const url = appendQuery(new URL(`${apiBase}${path2}`), query);
@@ -2956,7 +3009,10 @@ var getWafReport = async (options) => {
2956
3009
  `/reports/detail/${encodeURIComponent(projectId)}/architecture`,
2957
3010
  { user_id: requireUserId(options.userId) }
2958
3011
  );
2959
- const report = normalizeBackendReportDetail(raw, { projectId, reportType: "architecture" });
3012
+ const report = normalizeBackendReportDetail(raw, {
3013
+ projectId,
3014
+ reportType: "architecture"
3015
+ });
2960
3016
  if (options.severity && isObject22(report.parsed) && Array.isArray(report.parsed.rules)) {
2961
3017
  return {
2962
3018
  ...report,
@@ -2980,9 +3036,13 @@ var getReportDetail = async (options) => fetchJson(
2980
3036
  timestamp: options.timestamp
2981
3037
  }
2982
3038
  );
2983
- var getCostReportFull = async (options) => fetchJson(options, `/cost-reports/${encodeURIComponent(options.projectId)}/full`, {
2984
- user_id: options.userId
2985
- });
3039
+ var getCostReportFull = async (options) => fetchJson(
3040
+ options,
3041
+ `/cost-reports/${encodeURIComponent(options.projectId)}/full`,
3042
+ {
3043
+ user_id: options.userId
3044
+ }
3045
+ );
2986
3046
  var getWafReportFull = async (options) => fetchJson(
2987
3047
  options,
2988
3048
  `/well-architected-reports/${encodeURIComponent(options.projectId)}/full`,
@@ -2996,9 +3056,13 @@ var getCostReportHistory = async (options) => options.timestamp ? fetchJson(
2996
3056
  options.timestamp
2997
3057
  )}`,
2998
3058
  { user_id: options.userId }
2999
- ) : fetchJson(options, `/cost-reports/${encodeURIComponent(options.projectId)}/historical`, {
3000
- user_id: options.userId
3001
- });
3059
+ ) : fetchJson(
3060
+ options,
3061
+ `/cost-reports/${encodeURIComponent(options.projectId)}/historical`,
3062
+ {
3063
+ user_id: options.userId
3064
+ }
3065
+ );
3002
3066
  var getWafReportHistory = async (options) => options.timestamp ? fetchJson(
3003
3067
  options,
3004
3068
  `/well-architected-reports/${encodeURIComponent(
@@ -3023,13 +3087,17 @@ var runReports = async (options) => {
3023
3087
  for (const type of reportRunTypes(options.type)) {
3024
3088
  if (type === "cost") {
3025
3089
  results.push(
3026
- await postJson(options, `/cost-reports/${encodeURIComponent(projectId)}/regenerate`, {
3027
- user_id: userId,
3028
- region: options.region,
3029
- currency: options.currency,
3030
- include_time_series: boolQuery(options.includeTimeSeries),
3031
- save_report: boolQuery(options.saveReport)
3032
- })
3090
+ await postJson(
3091
+ options,
3092
+ `/cost-reports/${encodeURIComponent(projectId)}/regenerate`,
3093
+ {
3094
+ user_id: userId,
3095
+ region: options.region,
3096
+ currency: options.currency,
3097
+ include_time_series: boolQuery(options.includeTimeSeries),
3098
+ save_report: boolQuery(options.saveReport)
3099
+ }
3100
+ )
3033
3101
  );
3034
3102
  continue;
3035
3103
  }
@@ -3047,9 +3115,13 @@ var runReports = async (options) => {
3047
3115
  continue;
3048
3116
  }
3049
3117
  results.push(
3050
- await postJson(options, `/reports/${encodeURIComponent(projectId)}/unit-tests/regenerate`, {
3051
- user_id: userId
3052
- })
3118
+ await postJson(
3119
+ options,
3120
+ `/reports/${encodeURIComponent(projectId)}/unit-tests/regenerate`,
3121
+ {
3122
+ user_id: userId
3123
+ }
3124
+ )
3053
3125
  );
3054
3126
  }
3055
3127
  return results;
@@ -3792,6 +3864,7 @@ export {
3792
3864
  initialChatState,
3793
3865
  completeActiveAssistantMessage,
3794
3866
  reduceChunk,
3867
+ downloadReportPdf,
3795
3868
  fetchReportResource,
3796
3869
  listReports,
3797
3870
  getReport,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  completeOnboarding
3
- } from "./chunk-ERGQHMNT.js";
3
+ } from "./chunk-NXM4JEOB.js";
4
4
  import {
5
5
  terminalTheme
6
6
  } from "./chunk-ZDKRIOMB.js";