@anuma/sdk 10.10.0 → 11.0.1
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.
- package/dist/expo/index.cjs +1024 -552
- package/dist/expo/index.d.mts +9 -5
- package/dist/expo/index.d.ts +9 -5
- package/dist/expo/index.mjs +1020 -552
- package/dist/react/index.cjs +1204 -661
- package/dist/react/index.d.mts +9 -5
- package/dist/react/index.d.ts +9 -5
- package/dist/react/index.mjs +1200 -661
- package/dist/tools/index.cjs +36 -2
- package/dist/tools/index.mjs +36 -2
- package/package.json +1 -1
package/dist/tools/index.cjs
CHANGED
|
@@ -2529,10 +2529,23 @@ function createDisplayTool(options, config) {
|
|
|
2529
2529
|
}
|
|
2530
2530
|
|
|
2531
2531
|
// src/tools/chart.ts
|
|
2532
|
+
var NUMERIC_STRING = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;
|
|
2533
|
+
var THOUSANDS_GROUPED = /^[-+]?\d{1,3}(?:,\d{3})+(?:\.\d*)?$/;
|
|
2534
|
+
function toNumber(value) {
|
|
2535
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
2536
|
+
if (typeof value !== "string") return void 0;
|
|
2537
|
+
let cleaned = value.replace(/[\s$€£¥%]/g, "");
|
|
2538
|
+
if (cleaned.includes(",")) {
|
|
2539
|
+
if (!THOUSANDS_GROUPED.test(cleaned)) return void 0;
|
|
2540
|
+
cleaned = cleaned.replace(/,/g, "");
|
|
2541
|
+
}
|
|
2542
|
+
const number = NUMERIC_STRING.test(cleaned) ? Number(cleaned) : void 0;
|
|
2543
|
+
return number !== void 0 && Number.isFinite(number) ? number : void 0;
|
|
2544
|
+
}
|
|
2532
2545
|
function createChartTool(options) {
|
|
2533
2546
|
return createDisplayTool(options, {
|
|
2534
2547
|
name: "display_chart",
|
|
2535
|
-
description: 'Render a bar, line, area, or pie chart inline \u2014 visualize data, plot a trend over time, or graph a comparison. Use whenever the user asks to chart, plot, graph, or visualize numbers (sales, prices, temperatures, metrics). You MUST pass the actual numeric values in the "data" array \u2014 they are never inferred.',
|
|
2548
|
+
description: 'Render a bar, line, area, or pie chart inline \u2014 visualize data, plot a trend over time, or graph a comparison. Use whenever the user asks to chart, plot, graph, or visualize numbers (sales, prices, temperatures, metrics). You MUST pass the actual numeric values in the "data" array \u2014 they are never inferred. Do not chart price or market history (crypto, stocks, market caps) unless those values came from a tool result or a cited source earlier in this conversation; never fill a price series from memory.',
|
|
2536
2549
|
parameters: {
|
|
2537
2550
|
type: "object",
|
|
2538
2551
|
properties: {
|
|
@@ -2590,10 +2603,31 @@ function createChartTool(options) {
|
|
|
2590
2603
|
error: 'The "dataKeys" array is required and must list the numeric keys to chart, e.g. ["revenue"].'
|
|
2591
2604
|
};
|
|
2592
2605
|
}
|
|
2606
|
+
const points = data.map((point) => ({ ...point }));
|
|
2607
|
+
for (const key of dataKeys) {
|
|
2608
|
+
let numericCount = 0;
|
|
2609
|
+
for (const [index, point] of points.entries()) {
|
|
2610
|
+
const raw = point[key];
|
|
2611
|
+
if (raw === void 0 || raw === null) continue;
|
|
2612
|
+
const value = toNumber(raw);
|
|
2613
|
+
if (value === void 0) {
|
|
2614
|
+
return {
|
|
2615
|
+
error: `Series "${key}" has a non-numeric value at data[${index}]: ${JSON.stringify(raw)}. Values for dataKeys must be plain numbers, e.g. 65000 rather than "$65,000 USD".`
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
point[key] = value;
|
|
2619
|
+
numericCount++;
|
|
2620
|
+
}
|
|
2621
|
+
if (numericCount === 0) {
|
|
2622
|
+
return {
|
|
2623
|
+
error: `Series "${key}" has no numeric values. Every entry in "dataKeys" must name a numeric key present in the "data" objects.`
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2593
2627
|
return {
|
|
2594
2628
|
chartType,
|
|
2595
2629
|
title: args.title,
|
|
2596
|
-
data,
|
|
2630
|
+
data: points,
|
|
2597
2631
|
dataKeys,
|
|
2598
2632
|
xAxisKey: args.xAxisKey,
|
|
2599
2633
|
colors: args.colors
|
package/dist/tools/index.mjs
CHANGED
|
@@ -2368,10 +2368,23 @@ function createDisplayTool(options, config) {
|
|
|
2368
2368
|
}
|
|
2369
2369
|
|
|
2370
2370
|
// src/tools/chart.ts
|
|
2371
|
+
var NUMERIC_STRING = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;
|
|
2372
|
+
var THOUSANDS_GROUPED = /^[-+]?\d{1,3}(?:,\d{3})+(?:\.\d*)?$/;
|
|
2373
|
+
function toNumber(value) {
|
|
2374
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
2375
|
+
if (typeof value !== "string") return void 0;
|
|
2376
|
+
let cleaned = value.replace(/[\s$€£¥%]/g, "");
|
|
2377
|
+
if (cleaned.includes(",")) {
|
|
2378
|
+
if (!THOUSANDS_GROUPED.test(cleaned)) return void 0;
|
|
2379
|
+
cleaned = cleaned.replace(/,/g, "");
|
|
2380
|
+
}
|
|
2381
|
+
const number = NUMERIC_STRING.test(cleaned) ? Number(cleaned) : void 0;
|
|
2382
|
+
return number !== void 0 && Number.isFinite(number) ? number : void 0;
|
|
2383
|
+
}
|
|
2371
2384
|
function createChartTool(options) {
|
|
2372
2385
|
return createDisplayTool(options, {
|
|
2373
2386
|
name: "display_chart",
|
|
2374
|
-
description: 'Render a bar, line, area, or pie chart inline \u2014 visualize data, plot a trend over time, or graph a comparison. Use whenever the user asks to chart, plot, graph, or visualize numbers (sales, prices, temperatures, metrics). You MUST pass the actual numeric values in the "data" array \u2014 they are never inferred.',
|
|
2387
|
+
description: 'Render a bar, line, area, or pie chart inline \u2014 visualize data, plot a trend over time, or graph a comparison. Use whenever the user asks to chart, plot, graph, or visualize numbers (sales, prices, temperatures, metrics). You MUST pass the actual numeric values in the "data" array \u2014 they are never inferred. Do not chart price or market history (crypto, stocks, market caps) unless those values came from a tool result or a cited source earlier in this conversation; never fill a price series from memory.',
|
|
2375
2388
|
parameters: {
|
|
2376
2389
|
type: "object",
|
|
2377
2390
|
properties: {
|
|
@@ -2429,10 +2442,31 @@ function createChartTool(options) {
|
|
|
2429
2442
|
error: 'The "dataKeys" array is required and must list the numeric keys to chart, e.g. ["revenue"].'
|
|
2430
2443
|
};
|
|
2431
2444
|
}
|
|
2445
|
+
const points = data.map((point) => ({ ...point }));
|
|
2446
|
+
for (const key of dataKeys) {
|
|
2447
|
+
let numericCount = 0;
|
|
2448
|
+
for (const [index, point] of points.entries()) {
|
|
2449
|
+
const raw = point[key];
|
|
2450
|
+
if (raw === void 0 || raw === null) continue;
|
|
2451
|
+
const value = toNumber(raw);
|
|
2452
|
+
if (value === void 0) {
|
|
2453
|
+
return {
|
|
2454
|
+
error: `Series "${key}" has a non-numeric value at data[${index}]: ${JSON.stringify(raw)}. Values for dataKeys must be plain numbers, e.g. 65000 rather than "$65,000 USD".`
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
point[key] = value;
|
|
2458
|
+
numericCount++;
|
|
2459
|
+
}
|
|
2460
|
+
if (numericCount === 0) {
|
|
2461
|
+
return {
|
|
2462
|
+
error: `Series "${key}" has no numeric values. Every entry in "dataKeys" must name a numeric key present in the "data" objects.`
|
|
2463
|
+
};
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2432
2466
|
return {
|
|
2433
2467
|
chartType,
|
|
2434
2468
|
title: args.title,
|
|
2435
|
-
data,
|
|
2469
|
+
data: points,
|
|
2436
2470
|
dataKeys,
|
|
2437
2471
|
xAxisKey: args.xAxisKey,
|
|
2438
2472
|
colors: args.colors
|