@pagelines/sdk 1.0.711 → 1.0.713

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/contract.js CHANGED
@@ -5666,6 +5666,49 @@ function normalizeSimpleChartJson(e) {
5666
5666
  ].join("\n")
5667
5667
  };
5668
5668
  }
5669
+ function normalizeAliasedChartJson(e) {
5670
+ if (!isRecord(e) || (readSimpleString(e.visualType) ?? readSimpleString(e.kind)) !== "chart") return null;
5671
+ let t = readSimpleString(e.chartType);
5672
+ if (t !== "bar" && t !== "line" && t !== "scatter") return null;
5673
+ let n = isRecord(e.xAxis) ? e.xAxis : void 0, r = readSimpleString(e.xKey) ?? (n ? readSimpleString(n.key) ?? readSimpleString(n.dataKey) : void 0);
5674
+ if (!r) return null;
5675
+ let i = readSimpleString(e.xAxisLabel) ?? (n ? readSimpleString(n.label) : void 0);
5676
+ if (!Array.isArray(e.series)) return null;
5677
+ let a = [];
5678
+ for (let t of e.series) {
5679
+ if (!isRecord(t)) return null;
5680
+ let e = readSimpleString(t.dataKey) ?? readSimpleString(t.key);
5681
+ if (!e) return null;
5682
+ let n = readSimpleString(t.label) ?? readSimpleString(t.name);
5683
+ a.push({
5684
+ dataKey: e,
5685
+ ...n ? { label: n } : {}
5686
+ });
5687
+ }
5688
+ if (a.length === 0 || !Array.isArray(e.data)) return null;
5689
+ let o = e.data.filter(isRecord), s = isRecord(e.meta) ? e.meta : e, c = readSimpleString(s.title);
5690
+ if (!c) return null;
5691
+ let l = readSimpleString(s.description) ?? readSimpleString(s.subtitle), u = readSimpleString(s.footer) ?? readSimpleString(s.source), d = readSimpleString(e.fallbackMarkdown) ?? [
5692
+ `| ${markdownCell(i ?? r)} | ${a.map((e) => markdownCell(e.label ?? e.dataKey)).join(" | ")} |`,
5693
+ `|---|${a.map(() => "---:").join("|")}|`,
5694
+ ...o.map((e) => `| ${markdownCell(e[r])} | ${a.map((t) => markdownCell(e[t.dataKey])).join(" | ")} |`)
5695
+ ].join("\n");
5696
+ return {
5697
+ version: 1,
5698
+ visualType: "chart",
5699
+ chartType: t,
5700
+ meta: {
5701
+ title: c,
5702
+ ...l ? { description: l } : {},
5703
+ ...u ? { footer: u } : {}
5704
+ },
5705
+ xKey: r,
5706
+ ...i ? { xAxisLabel: i } : {},
5707
+ series: a,
5708
+ data: o,
5709
+ fallbackMarkdown: d
5710
+ };
5711
+ }
5669
5712
  function parseChatVisualFencePayload(e) {
5670
5713
  let t;
5671
5714
  try {
@@ -5684,7 +5727,7 @@ function parseChatVisualFencePayload(e) {
5684
5727
  }
5685
5728
  let n = Sa.safeParse(t);
5686
5729
  if (!n.success) {
5687
- let e = normalizeSimpleChartJson(t);
5730
+ let e = normalizeSimpleChartJson(t) ?? normalizeAliasedChartJson(t);
5688
5731
  if (e) {
5689
5732
  let t = Sa.safeParse(e);
5690
5733
  if (t.success) return {