@data360/chart-payload-normalize 0.0.1 → 0.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAyCF,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAUlF;AAMD;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,GACZ,sBAAsB,CAyDxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAsDF,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAgBlF;AAMD;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,GACZ,sBAAsB,CAyDxB"}
package/dist/index.js CHANGED
@@ -33,8 +33,23 @@ function titleFromSpec(spec) {
33
33
  if (typeof raw === "string") {
34
34
  return raw;
35
35
  }
36
- if (isRecord(raw) && typeof raw.text === "string") {
37
- return raw.text;
36
+ if (Array.isArray(raw)) {
37
+ const joined = raw.filter((s) => typeof s === "string").join("\n").trim();
38
+ if (joined)
39
+ return joined;
40
+ }
41
+ if (isRecord(raw)) {
42
+ if (typeof raw.text === "string") {
43
+ return raw.text;
44
+ }
45
+ if (Array.isArray(raw.text)) {
46
+ const joined = raw.text
47
+ .filter((s) => typeof s === "string")
48
+ .join("\n")
49
+ .trim();
50
+ if (joined)
51
+ return joined;
52
+ }
38
53
  }
39
54
  return "Chart";
40
55
  }
@@ -48,6 +63,12 @@ export function subtitleFromSpec(spec) {
48
63
  if (typeof sub === "string" && sub.trim()) {
49
64
  return sub.trim();
50
65
  }
66
+ if (Array.isArray(sub)) {
67
+ const lines = sub.filter(s => typeof s === "string" && s.trim()).map(s => s.trim());
68
+ if (lines.length > 0) {
69
+ return lines.join(" · ");
70
+ }
71
+ }
51
72
  return undefined;
52
73
  }
53
74
  function isLikelyChartsApiEnvelope(data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data360/chart-payload-normalize",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Normalize Charts API envelopes and raw Vega-Lite JSON into spec + title for Data360 charts.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",