@zeniai/client-epic-state 4.17.15 → 4.17.16

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.
@@ -3,6 +3,12 @@ export interface TableVisualizationPayload {
3
3
  values: Array<Record<string, string>>;
4
4
  columns: string[];
5
5
  }
6
+ export interface YFormatPayload {
7
+ type: string;
8
+ unit: string;
9
+ scale: string;
10
+ symbol?: string;
11
+ }
6
12
  export interface ChartVisualizationPayload {
7
13
  values: Array<Record<string, string | number>>;
8
14
  x: string;
@@ -11,6 +17,7 @@ export interface ChartVisualizationPayload {
11
17
  * We will normalize it to string[] in state.
12
18
  */
13
19
  y: string | string[];
20
+ y_format?: YFormatPayload;
14
21
  lines?: string[] | null;
15
22
  }
16
23
  export interface AiCfoVisualizationPayload {
@@ -139,15 +139,25 @@ const toAiCfoVisualization = (visualization) => {
139
139
  };
140
140
  exports.toAiCfoVisualization = toAiCfoVisualization;
141
141
  const toAiCfoVisualizationData = (data) => {
142
- var _a, _b;
142
+ var _a, _b, _c, _d, _e;
143
143
  if ('x' in data && 'y' in data) {
144
144
  // Normalize y to always be an array
145
145
  const yArray = Array.isArray(data.y) ? data.y : [data.y];
146
+ // Handle y_format (now required)
147
+ const yFormat = data.y_format != null
148
+ ? {
149
+ type: (_a = (0, aiCfoState_1.toYFormatTypeStrict)(data.y_format.type)) !== null && _a !== void 0 ? _a : 'number',
150
+ unit: (0, aiCfoState_1.toYFormatUnitStrict)(data.y_format.unit),
151
+ scale: (_b = (0, aiCfoState_1.toYFormatScaleStrict)(data.y_format.scale)) !== null && _b !== void 0 ? _b : 'raw',
152
+ symbol: (_c = data.y_format.symbol) !== null && _c !== void 0 ? _c : undefined,
153
+ }
154
+ : undefined;
146
155
  return {
147
156
  values: data.values,
148
157
  x: data.x,
149
158
  y: yArray,
150
- lines: (_a = data.lines) !== null && _a !== void 0 ? _a : [],
159
+ lines: (_d = data.lines) !== null && _d !== void 0 ? _d : [],
160
+ yFormat,
151
161
  };
152
162
  }
153
163
  // Table cleaning logic: only strip quotes from column names and cell values
@@ -160,7 +170,7 @@ const toAiCfoVisualizationData = (data) => {
160
170
  };
161
171
  const columns = (Array.isArray(data.columns)
162
172
  ? data.columns
163
- : Object.keys((_b = data.values[0]) !== null && _b !== void 0 ? _b : [])).map(stripQuotes);
173
+ : Object.keys((_e = data.values[0]) !== null && _e !== void 0 ? _e : [])).map(stripQuotes);
164
174
  const rows = data.values.map((row) => columns.map((col) => {
165
175
  const value = row[col];
166
176
  return value == null ? '' : stripQuotes(value);
@@ -18,6 +18,24 @@ export declare const toAiCfoChartTypeStrict: (v: string) => "bar_chart" | "pie_c
18
18
  export type AiCfoChartType = ReturnType<typeof toAiCfoChartType>;
19
19
  export declare const ALL_AI_CFO_ANSWER_STATE_TYPES: readonly ["complete", "partial"];
20
20
  export declare const ALL_AI_CFO_ANSWER_RESPONSE_TYPES: readonly ["analysis", "answer", "reasoning", "thought"];
21
+ export declare const ALL_Y_FORMAT_TYPES: readonly ["currency", "number"];
22
+ export declare const ALL_Y_FORMAT_NON_CURRENCY_UNITS: readonly ["percentage", "unit", "ratio"];
23
+ export declare const ALL_Y_FORMAT_SCALES: readonly ["raw", "K", "M", "B", "T"];
24
+ export declare const toYFormatType: (v: string) => "number" | "currency";
25
+ export declare const toYFormatUnit: (v: string) => string;
26
+ export declare const toYFormatScale: (v: string) => "M" | "raw" | "K" | "B" | "T";
27
+ export declare const toYFormatTypeStrict: (v: string) => "number" | "currency" | undefined;
28
+ export declare const toYFormatUnitStrict: (v: string) => string;
29
+ export declare const toYFormatScaleStrict: (v: string) => "M" | "raw" | "K" | "B" | "T" | undefined;
30
+ export type YFormatType = ReturnType<typeof toYFormatType>;
31
+ export type YFormatUnit = ReturnType<typeof toYFormatUnit>;
32
+ export type YFormatScale = ReturnType<typeof toYFormatScale>;
33
+ export interface YFormat {
34
+ type: YFormatType;
35
+ unit: YFormatUnit;
36
+ scale: YFormatScale;
37
+ symbol?: string;
38
+ }
21
39
  export declare const toAiCfoAnswerStateType: (v: string) => "complete" | "partial";
22
40
  export declare const toAiCfoAnswerResponseType: (v: string) => "analysis" | "answer" | "reasoning" | "thought";
23
41
  export declare const toAiCfoAnswerStateTypeStrict: (v: string) => "complete" | "partial" | undefined;
@@ -32,6 +50,7 @@ export interface ChartVisualization {
32
50
  values: Array<Record<string, string | number>>;
33
51
  x: string;
34
52
  y: string[];
53
+ yFormat?: YFormat;
35
54
  lines?: string[];
36
55
  }
37
56
  export interface AiCfoVisualization {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toMessageTypeStrict = exports.toMessageSenderStrict = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateType = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = void 0;
3
+ exports.toMessageTypeStrict = exports.toMessageSenderStrict = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateType = exports.toYFormatScaleStrict = exports.toYFormatUnitStrict = exports.toYFormatTypeStrict = exports.toYFormatScale = exports.toYFormatUnit = exports.toYFormatType = exports.ALL_Y_FORMAT_SCALES = exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS = exports.ALL_Y_FORMAT_TYPES = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = void 0;
4
4
  const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
5
  exports.ALL_AI_CFO_CHARTS_TYPES = [
6
6
  'bar_chart',
@@ -26,6 +26,41 @@ exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = [
26
26
  'reasoning',
27
27
  'thought',
28
28
  ];
29
+ exports.ALL_Y_FORMAT_TYPES = ['currency', 'number'];
30
+ exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS = [
31
+ 'percentage',
32
+ 'unit',
33
+ 'ratio',
34
+ ];
35
+ exports.ALL_Y_FORMAT_SCALES = ['raw', 'K', 'M', 'B', 'T'];
36
+ const toYFormatType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_Y_FORMAT_TYPES);
37
+ exports.toYFormatType = toYFormatType;
38
+ const toYFormatUnit = (v) => {
39
+ // Check if it's one of the non-currency units
40
+ const nonCurrencyUnit = (0, stringToUnion_1.stringToUnion)(v, exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS);
41
+ if (nonCurrencyUnit) {
42
+ return nonCurrencyUnit;
43
+ }
44
+ // If not a non-currency unit, assume it's a currency code and return it.
45
+ return v;
46
+ };
47
+ exports.toYFormatUnit = toYFormatUnit;
48
+ const toYFormatScale = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_Y_FORMAT_SCALES);
49
+ exports.toYFormatScale = toYFormatScale;
50
+ const toYFormatTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_Y_FORMAT_TYPES);
51
+ exports.toYFormatTypeStrict = toYFormatTypeStrict;
52
+ const toYFormatUnitStrict = (v) => {
53
+ // Check if it's one of the non-currency units
54
+ const nonCurrencyUnit = (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS);
55
+ if (nonCurrencyUnit) {
56
+ return nonCurrencyUnit;
57
+ }
58
+ // If not a non-currency unit, assume it's a currency code and return it.
59
+ return v;
60
+ };
61
+ exports.toYFormatUnitStrict = toYFormatUnitStrict;
62
+ const toYFormatScaleStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_Y_FORMAT_SCALES);
63
+ exports.toYFormatScaleStrict = toYFormatScaleStrict;
29
64
  const toAiCfoAnswerStateType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_ANSWER_STATE_TYPES);
30
65
  exports.toAiCfoAnswerStateType = toAiCfoAnswerStateType;
31
66
  const toAiCfoAnswerResponseType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.17.15",
3
+ "version": "4.17.16",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",