@astrato-io/visualizations 0.6.4 → 0.7.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.
Files changed (220) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +32 -2
  3. package/THIRD_PARTY_NOTICES.md +68 -205
  4. package/VISUALIZATION_DEFINITIONS.md +68 -114
  5. package/chunks/Button-BrGKp9Nm.js +110 -0
  6. package/chunks/DefaultPropsProvider-BsfB7QTn.js +257 -0
  7. package/chunks/FieldTypeIcon-Drs6hSJF.js +22 -0
  8. package/chunks/{LinearProgress-CUZ0D8_t.js → LinearProgress-VtfFx2vJ.js} +51 -51
  9. package/chunks/MenuOption-ByRqhRdX.js +3934 -0
  10. package/chunks/Title-CO5dP1ma.js +1691 -0
  11. package/chunks/ToggleButton-KOBAimC1.js +112 -0
  12. package/chunks/app-filter-bar.compiler-TwVTeoj5.js +64 -0
  13. package/chunks/bar.compiler-DuQg8EUb.js +374 -0
  14. package/chunks/builder-DEDvNq1k.js +201 -0
  15. package/chunks/{color-settings-ZIvgNTq1.js → color-rules-CN7TcGrC.js} +2 -6
  16. package/chunks/color-settings-3VRlf_Vw.js +6 -0
  17. package/chunks/colorManipulator-D8Pjy1pf.js +45 -0
  18. package/chunks/coloring-CncX_JRX.js +278 -0
  19. package/chunks/{src-BC7cGcJ-.js → definitions-BPJQTx16.js} +650 -464
  20. package/chunks/{escobar-BGqT1EsE.js → escobar-DRhRMYRE.js} +6282 -4931
  21. package/chunks/event-bus-CrLB-Y8z.js +3 -0
  22. package/chunks/extend-preset-CUFNpmPe.js +4398 -0
  23. package/chunks/filter.compiler-w27dlv0C.js +70 -0
  24. package/chunks/filtering-cc7WqWpg.js +1153 -0
  25. package/chunks/handlers-TOT-7INo.js +12871 -0
  26. package/chunks/icon-picker-styles-CoJmwTRi.js +2246 -0
  27. package/chunks/isEqual-B8loyPsC.js +12 -0
  28. package/chunks/label-format-type-weq1XfcX.js +8 -0
  29. package/chunks/line.compiler-Ct1WhN2p.js +198 -0
  30. package/chunks/logger-DpQtYQnX.js +1163 -0
  31. package/chunks/lookup-BWllin0q.js +36 -0
  32. package/chunks/{metadata-CPXdYoln.js → metadata-WABZrt7Y.js} +1 -1
  33. package/chunks/number.compiler-D8TPly-4.js +53 -0
  34. package/chunks/{src-C0LgoUWY.js → operations-Dh4v1Ovt.js} +7716 -7541
  35. package/chunks/{range-DrzdfBX4.js → range-Bi-7zT0k.js} +2 -2
  36. package/chunks/registry-KervaxqJ.js +31 -0
  37. package/chunks/render-wrappers-OEmtaM8g.js +2 -0
  38. package/chunks/{registry-CExpGJ1N.js → requirements-PAoRaJyb.js} +294 -326
  39. package/chunks/responsive.styles-DSiOGD7u.js +82 -0
  40. package/chunks/shared-Bn4N5QcZ.js +1218 -0
  41. package/chunks/src-77e3mC7i.js +391 -0
  42. package/chunks/standalone-B55oyW6c.js +689 -0
  43. package/chunks/{standalone-CY57qwZ-.js → standalone-BDhPQtzQ.js} +386 -352
  44. package/chunks/{standalone-BDCwI6Hn.js → standalone-BGkmozIb.js} +1108 -953
  45. package/chunks/standalone-BMTCb10X.js +179 -0
  46. package/chunks/standalone-BXKRE_Se.js +468 -0
  47. package/chunks/standalone-Bes8srx1.js +354 -0
  48. package/chunks/standalone-BjZp0QMe.js +2 -0
  49. package/chunks/{standalone-BH5NqDwp.js → standalone-BlMIwpEe.js} +687 -573
  50. package/chunks/{standalone-CCNtaJ7s.js → standalone-C8ZAEutO.js} +44 -43
  51. package/chunks/standalone-C8qAelL4.js +2 -0
  52. package/chunks/standalone-CJvIXsQE.js +743 -0
  53. package/chunks/standalone-CLmGb7nn2.js +355 -0
  54. package/chunks/{ui-D1HQNIBy.js → standalone-CM5XcAN5.js} +15946 -17658
  55. package/chunks/standalone-CXNP6-xD.js +420 -0
  56. package/chunks/{standalone-BYm1UjLr.js → standalone-D5Q5ngsD.js} +59 -57
  57. package/chunks/standalone-DLlyRIE6.js +287 -0
  58. package/chunks/standalone-DMcI1afI.js +396 -0
  59. package/chunks/{standalone-jiz0L2Dg.js → standalone-DN4S1MjT.js} +1113 -1094
  60. package/chunks/{standalone-QJ1kKMnO.js → standalone-DT0wKji7.js} +2 -2
  61. package/chunks/{standalone-D5vnf-9y.js → standalone-DVTJwsTY.js} +1110 -1035
  62. package/chunks/standalone-DW6NT205.js +518 -0
  63. package/chunks/standalone-DYQIQH4c.js +2095 -0
  64. package/chunks/standalone-D__XCp-h.js +1003 -0
  65. package/chunks/standalone-XTgSsTAa.js +354 -0
  66. package/chunks/standalone-XuGksArp.js +68 -0
  67. package/chunks/{standalone-CNyNHKVx.js → standalone-we5D5MIn.js} +176 -172
  68. package/chunks/table.compiler-DMeeHxb6.js +222 -0
  69. package/chunks/useFieldName-Cjn9KCVp.js +7 -0
  70. package/chunks/useSlotProps-DLbQp4lc.js +166 -0
  71. package/chunks/{utils-Ba9T0TqC.js → utils-vdmi_2PK.js} +6266 -6517
  72. package/chunks/{src-DvX5LU9T.js → view-BuwQugKb.js} +2893 -5956
  73. package/chunks/visualization-filters-Cc4KU-l-.js +7455 -0
  74. package/chunks/web-components-DqClFkgO.js +1185 -0
  75. package/chunks/with-html-element-D0uY2zjI.js +7328 -0
  76. package/definitions.js +3 -3
  77. package/docs/operations/astrato-app-filter-bar.md +17 -17
  78. package/docs/operations/bar.md +1006 -1071
  79. package/docs/operations/combo.md +717 -738
  80. package/docs/operations/date-picker.md +27 -27
  81. package/docs/operations/distribution-gauge.md +471 -607
  82. package/docs/operations/dot.md +787 -879
  83. package/docs/operations/filter.md +139 -163
  84. package/docs/operations/gauge.md +491 -627
  85. package/docs/operations/heatMap.md +834 -916
  86. package/docs/operations/histogram.md +166 -180
  87. package/docs/operations/iframe.md +5 -5
  88. package/docs/operations/image.md +16 -16
  89. package/docs/operations/index.md +12 -12
  90. package/docs/operations/line.md +811 -888
  91. package/docs/operations/number.md +470 -536
  92. package/docs/operations/pie.md +825 -958
  93. package/docs/operations/radar.md +599 -679
  94. package/docs/operations/sankey.md +462 -584
  95. package/docs/operations/scatter.md +823 -929
  96. package/docs/operations/shape.md +34 -34
  97. package/docs/operations/simpleTextObject.md +18 -25
  98. package/docs/operations/slider.md +33 -43
  99. package/docs/operations/table.md +1177 -1150
  100. package/docs/operations/tree.md +404 -397
  101. package/docs/operations/treemap.md +595 -673
  102. package/docs/operations/waterfall.md +369 -379
  103. package/docs/operations/word-cloud.md +512 -583
  104. package/getters.js +7 -7
  105. package/index.js +3 -1183
  106. package/metadata.js +18 -18
  107. package/operations.js +13 -13
  108. package/package.json +133 -88
  109. package/render.js +10 -0
  110. package/src/charts/bar.d.ts +1 -0
  111. package/src/charts/combo.d.ts +1 -0
  112. package/src/charts/dot.d.ts +1 -0
  113. package/src/charts/gauge-distribution.d.ts +1 -0
  114. package/src/charts/gauge.d.ts +1 -0
  115. package/src/charts/heat-map.d.ts +1 -0
  116. package/src/charts/histogram.d.ts +1 -0
  117. package/src/charts/line.d.ts +1 -0
  118. package/src/charts/pie.d.ts +1 -0
  119. package/src/charts/radar.d.ts +1 -0
  120. package/src/charts/sankey.d.ts +1 -0
  121. package/src/charts/scatter.d.ts +1 -0
  122. package/src/charts/table.d.ts +1 -0
  123. package/src/charts/tree.d.ts +1 -0
  124. package/src/charts/treemap.d.ts +1 -0
  125. package/src/charts/waterfall.d.ts +1 -0
  126. package/src/charts/word-cloud.d.ts +1 -0
  127. package/src/definitions/index.d.ts +2 -2
  128. package/src/definitions/{shared/lib → model/definitions}/available-fields.d.ts +0 -1
  129. package/src/definitions/{shared/lib/compilers/index.d.ts → model/definitions/compilers/compile.d.ts} +1 -1
  130. package/src/definitions/model/definitions/data-item-resolution.d.ts +19 -0
  131. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +1364 -0
  132. package/src/definitions/model/definitions/descriptors/json-schema.d.ts +2 -0
  133. package/src/definitions/model/definitions/diagnostics.d.ts +5 -0
  134. package/src/definitions/model/definitions/field-suggestions.d.ts +2 -0
  135. package/src/definitions/model/definitions/index.d.ts +23 -0
  136. package/src/definitions/{shared/lib → model/definitions}/registry/compile.d.ts +1 -1
  137. package/src/definitions/model/definitions/registry/descriptor-registry.d.ts +3 -0
  138. package/src/definitions/model/definitions/schema-registry.d.ts +660 -0
  139. package/src/definitions/{shared/lib → model/definitions}/schemas/broad-chart.schema.d.ts +1 -1
  140. package/src/definitions/{shared/lib → model/definitions}/schemas/common.schema.d.ts +0 -1
  141. package/src/definitions/model/definitions/schemas/index.d.ts +9 -0
  142. package/src/definitions/{shared/lib → model/definitions}/schemas/object.schema.d.ts +8 -8
  143. package/src/definitions/{shared/lib → model/definitions}/types/compilation.types.d.ts +10 -0
  144. package/src/definitions/{shared/lib → model/definitions}/types/definition.types.d.ts +1 -1
  145. package/src/definitions/model/definitions/types/index.d.ts +3 -0
  146. package/src/definitions/{shared/lib/registry → model/definitions}/validation.d.ts +1 -1
  147. package/src/getters/index.d.ts +3 -3
  148. package/src/index.d.ts +1 -1
  149. package/src/objects/app-filter-bar.d.ts +1 -0
  150. package/src/objects/date-picker.d.ts +1 -0
  151. package/src/objects/filter.d.ts +1 -0
  152. package/src/objects/iframe.d.ts +1 -0
  153. package/src/objects/image.d.ts +1 -0
  154. package/src/objects/number.d.ts +1 -0
  155. package/src/objects/shape.d.ts +1 -0
  156. package/src/objects/slider.d.ts +1 -0
  157. package/src/objects/text.d.ts +1 -0
  158. package/src/operations/index.d.ts +3 -3
  159. package/src/registry/create-visualization-registry.d.ts +5 -0
  160. package/src/render/index.d.ts +34 -0
  161. package/src/runtime/index.d.ts +2 -2
  162. package/src/types.d.ts +9 -4
  163. package/src/web-components/index.d.ts +3 -3
  164. package/chunks/Radio-Ciu-F4CU.js +0 -957
  165. package/chunks/ToggleButton-BCJc3Jlc.js +0 -153
  166. package/chunks/_baseFlatten-DPXPOrea.js +0 -7076
  167. package/chunks/app-filter-bar.compiler-j_CVoWTa.js +0 -55
  168. package/chunks/bar.compiler-oqaPzIut.js +0 -370
  169. package/chunks/coloring-C16AUZEi.js +0 -663
  170. package/chunks/data-item-resolution-1lvYB5ln.js +0 -53
  171. package/chunks/event-bus-KiSiCJrC.js +0 -2683
  172. package/chunks/events-WZut5Ow6.js +0 -4
  173. package/chunks/filter.compiler-CuLtc_02.js +0 -60
  174. package/chunks/filtering-Yq4DEa0t.js +0 -953
  175. package/chunks/gauge-target-type-BkKXAqkX.js +0 -4
  176. package/chunks/grouping-type-BX_9Ix5q.js +0 -3
  177. package/chunks/interfaces-VUY4_yVO.js +0 -8742
  178. package/chunks/line-settings-DfYTUyPz.js +0 -4
  179. package/chunks/line.compiler-BpA_6Tc7.js +0 -188
  180. package/chunks/number.compiler-DbkWcG4S.js +0 -44
  181. package/chunks/pie-uv42Eqal.js +0 -10
  182. package/chunks/requirements-DNhuShLS.js +0 -6
  183. package/chunks/shared-CKDL4hx9.js +0 -1171
  184. package/chunks/src-Cum_2NLV.js +0 -12145
  185. package/chunks/src-Dun_jXtz.js +0 -10295
  186. package/chunks/standalone-87YV_m9n.js +0 -687
  187. package/chunks/standalone-BLVAWLNJ.js +0 -385
  188. package/chunks/standalone-BPomtAVs.js +0 -2
  189. package/chunks/standalone-BXyBcUOQ.js +0 -2
  190. package/chunks/standalone-BllF4rDp.js +0 -383
  191. package/chunks/standalone-BmfMt74U.js +0 -726
  192. package/chunks/standalone-BqWyrnZI.js +0 -281
  193. package/chunks/standalone-C85u7U6I.js +0 -340
  194. package/chunks/standalone-CDQnr6qT.js +0 -345
  195. package/chunks/standalone-CZynjFG7.js +0 -12979
  196. package/chunks/standalone-DFPva_ku.js +0 -299
  197. package/chunks/standalone-DQxxNwF8.js +0 -675
  198. package/chunks/standalone-DS9T0FZ-.js +0 -830
  199. package/chunks/standalone-Dx3MLlrO.js +0 -512
  200. package/chunks/standalone-DzixzZAL.js +0 -411
  201. package/chunks/standalone-lBm9hQ-q.js +0 -179
  202. package/chunks/standalone-rJ45Zfl1.js +0 -68
  203. package/chunks/table.compiler-BrXkm4Fz.js +0 -213
  204. package/chunks/toInteger-DVZr-D1j.js +0 -11
  205. package/chunks/treemap-x_zmJoG7.js +0 -23
  206. package/chunks/types-dVVCsDWD.js +0 -4
  207. package/chunks/useFieldName-oqQ3bvnO.js +0 -7
  208. package/chunks/view-CLqWMV7Z.js +0 -156
  209. package/src/definitions/shared/index.d.ts +0 -5
  210. package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +0 -587
  211. package/src/definitions/shared/lib/registry/index.d.ts +0 -3
  212. package/src/definitions/shared/lib/schemas/index.d.ts +0 -9
  213. package/src/definitions/shared/lib/types/index.d.ts +0 -3
  214. package/src/definitions/{shared/lib → model/definitions}/schemas/app-filter-bar.schema.d.ts +0 -0
  215. package/src/definitions/{shared/lib → model/definitions}/schemas/bar.schema.d.ts +0 -0
  216. package/src/definitions/{shared/lib → model/definitions}/schemas/filter.schema.d.ts +0 -0
  217. package/src/definitions/{shared/lib → model/definitions}/schemas/line.schema.d.ts +0 -0
  218. package/src/definitions/{shared/lib → model/definitions}/schemas/number.schema.d.ts +0 -0
  219. package/src/definitions/{shared/lib → model/definitions}/schemas/table.schema.d.ts +4 -4
  220. /package/src/definitions/{shared/lib → model/definitions}/types/descriptor.types.d.ts +0 -0
@@ -1,55 +0,0 @@
1
- import { Xd as e } from "./src-Dun_jXtz.js";
2
- import { m as t } from "./src-C0LgoUWY.js";
3
- import { B as n, d as r, g as i, h as a, u as o, v as s, w as c } from "./shared-CKDL4hx9.js";
4
- var l = async (l) => {
5
- let u = n.safeParse(l.definition);
6
- if (!u.success) return {
7
- issues: c(u.error, l.definition),
8
- success: !1
9
- };
10
- let d = e.safeParse(l.baseVSpec);
11
- if (!d.success) return {
12
- issues: [r("invalid_structure", ["baseVSpec"], "Base app filter bar vSpec is invalid.")],
13
- success: !1
14
- };
15
- let f = d.data;
16
- if (!s(f, [])) return {
17
- issues: [r("non_fresh_base_vspec", ["baseVSpec"], "App filter bar definitions require a fresh base vSpec.")],
18
- success: !1
19
- };
20
- let p = u.data.settings ?? {}, m = [
21
- ...p.orientation === void 0 ? [] : [{
22
- name: t.SET_ORIENTATION,
23
- payload: p.orientation
24
- }],
25
- ...p.selectionMode === void 0 ? [] : [{
26
- name: t.SET_SELECTION_MODE,
27
- payload: p.selectionMode
28
- }],
29
- ...p.enableAddingNewFilters === void 0 ? [] : [{
30
- name: t.SET_ADDING_FILTERS_ENABLED,
31
- payload: p.enableAddingNewFilters
32
- }],
33
- ...p.enableAssociativeFilter === void 0 ? [] : [{
34
- name: t.SET_ASSOCIATIVE_FILTER_ENABLED,
35
- payload: p.enableAssociativeFilter
36
- }],
37
- ...p.showClearAll === void 0 ? [] : [{
38
- name: t.SET_CLEAR_ALL_ENABLED,
39
- payload: p.showClearAll
40
- }],
41
- ...p.showChartBreakdown === void 0 ? [] : [{
42
- name: t.SET_CHART_BREAKDOWN_ENABLED,
43
- payload: p.showChartBreakdown
44
- }],
45
- ...p.selectableFieldKeys === void 0 ? [] : [{
46
- name: t.SET_SELECTABLE_FIELD_KEYS,
47
- payload: p.selectableFieldKeys
48
- }]
49
- ], h = await a(o(l, f), m, ["settings"]);
50
- return "issue" in h ? {
51
- issues: [h.issue],
52
- success: !1
53
- } : i(h.state, e);
54
- };
55
- export { l as compileAppFilterBarVisualizationDefinition };
@@ -1,370 +0,0 @@
1
- import { Eo as e } from "./interfaces-VUY4_yVO.js";
2
- import { Id as t } from "./src-Dun_jXtz.js";
3
- import { _ as n, b as r, t as i, u as a, v as o, w as s } from "./src-C0LgoUWY.js";
4
- import { S as c, _ as l, b as u, c as d, f, h as p, k as m, l as h, m as g, n as _, nt as v, w as y } from "./shared-CKDL4hx9.js";
5
- import { a as b, i as x, n as S, t as C } from "./data-item-resolution-1lvYB5ln.js";
6
- var w = {
7
- formatString: "setDimensionFormatString",
8
- formatType: "setDimensionFormatType"
9
- }, T = {
10
- currency: "setMeasureCurrency",
11
- currencyIsPrefix: "setMeasureCurrencyIsPrefix",
12
- formatString: "setMeasureFormatString",
13
- formatType: "setMeasureFormatType",
14
- negativeType: "setMeasureNegativeType"
15
- }, E = (e, t, n, r = {}) => ({
16
- code: e,
17
- message: n,
18
- path: t,
19
- ...r
20
- }), D = (e) => {
21
- let t = [...e.data.dimensions.map((e, t) => ({
22
- item: e,
23
- path: [
24
- "data",
25
- "dimensions",
26
- t,
27
- "ref"
28
- ]
29
- })), ...e.data.measures.map((e, t) => ({
30
- item: e,
31
- path: [
32
- "data",
33
- "measures",
34
- t,
35
- "ref"
36
- ]
37
- }))], n = t.map(({ item: e }) => e.ref), r = new Set(n), i = /* @__PURE__ */ new Set(), a = [];
38
- t.forEach(({ item: e, path: t }) => {
39
- i.has(e.ref) && a.push(E("duplicate_alias", t, `Reference "${e.ref}" is duplicated.`)), i.add(e.ref);
40
- }), e.sorting?.forEach((e, t) => {
41
- r.has(e.by) || a.push(E("unknown_alias", [
42
- "sorting",
43
- t,
44
- "by"
45
- ], `Reference "${e.by}" does not exist.`, { allowedValues: n }));
46
- }), a.push(...c(e.presentation?.coloring, e.data.dimensions.map((e) => e.ref), e.data.measures.map((e) => e.ref)));
47
- let o = e.limiting?.topN?.by;
48
- return o && !e.data.measures.some((e) => e.ref === o) && a.push(E("unknown_alias", [
49
- "limiting",
50
- "topN",
51
- "by"
52
- ], `Measure reference "${o}" does not exist.`, { allowedValues: e.data.measures.map((e) => e.ref) })), a;
53
- }, O = (e) => {
54
- if (e.type !== "bar") return E("unsupported_visualization", ["baseVSpec", "type"], `Definition type "bar" cannot compile against base vSpec type "${e.type}".`);
55
- let t = e;
56
- return t.dimensions.length > 0 || t.measures.length > 0 || (t.supportingMeasures?.length ?? 0) > 0 || Object.keys(t.referencedData).length > 0 ? E("non_fresh_base_vspec", ["baseVSpec"], "Bar visualization definitions can only compile against a fresh base vSpec.") : void 0;
57
- }, k = (e) => {
58
- let t = Object.entries(e).find(([, e]) => e.success === !1);
59
- return t ? {
60
- id: t[0],
61
- result: t[1]
62
- } : void 0;
63
- }, A = (e, t) => {
64
- if (!e || typeof e.data != "object" || e.data === null || !("dataItem" in e.data)) return;
65
- let n = e.data.dataItem;
66
- if (!(typeof n != "object" || !n || !("internalKey" in n) || typeof n.internalKey != "string" || !("uniqueSignature" in n) || typeof n.uniqueSignature != "string")) return {
67
- dataItemInternalKey: n.internalKey,
68
- dataItemUniqueSignature: n.uniqueSignature,
69
- kind: t
70
- };
71
- }, j = async (e, t) => {
72
- let n = e;
73
- for (let [e, r] of t.data.dimensions.entries()) {
74
- let t = `dimension:${r.ref}`, o = await i(n.vSpec, n.availableFields, [{
75
- id: t,
76
- name: a.ADD_DIMENSION,
77
- payload: { key: r.fieldKey }
78
- }], n.input.variables ?? [], [], n.input.theme), s = k(o.results), c = A(o.results[t], "dimension");
79
- if (s || !c) return {
80
- issue: E("operation_failed", [
81
- "data",
82
- "dimensions",
83
- e
84
- ], s?.result.error ?? "Dimension operation did not return the created data-item identity."),
85
- success: !1
86
- };
87
- n = {
88
- ...n,
89
- resolvedRefs: {
90
- ...n.resolvedRefs,
91
- [r.ref]: c
92
- },
93
- vSpec: o.vSpec
94
- };
95
- }
96
- for (let [r, o] of t.data.measures.entries()) {
97
- let t = S(o, e.input.availableFields), s = `measure:${o.ref}`, c = await i(n.vSpec, n.availableFields, [{
98
- id: s,
99
- name: a.ADD_MEASURE,
100
- payload: C(o, e.input.availableFields)
101
- }], n.input.variables ?? [], [], n.input.theme), l = k(c.results), u = A(c.results[s], "measure");
102
- if (l || !u) return {
103
- issue: E("operation_failed", [
104
- "data",
105
- "measures",
106
- r
107
- ], l?.result.error ?? "Measure operation did not return the created data-item identity."),
108
- success: !1
109
- };
110
- n = {
111
- ...n,
112
- measureAggregations: {
113
- ...n.measureAggregations,
114
- [o.ref]: t
115
- },
116
- resolvedRefs: {
117
- ...n.resolvedRefs,
118
- [o.ref]: u
119
- },
120
- vSpec: c.vSpec
121
- };
122
- }
123
- return {
124
- state: n,
125
- success: !0
126
- };
127
- }, M = (e) => ({
128
- dataItemInternalKey: e.dataItemInternalKey,
129
- dataItemUniqueSignature: e.dataItemUniqueSignature
130
- }), N = async (e, t) => {
131
- let r = [];
132
- return t.data.dimensions.forEach((t, n) => {
133
- let i = e.resolvedRefs[t.ref];
134
- t.showNullValues !== void 0 && r.push({
135
- name: a.UPDATE_DIMENSION,
136
- payload: {
137
- ...M(i),
138
- changes: { showNullValues: t.showNullValues }
139
- }
140
- }), t.temporalGrouping && r.push(g("setDimensionTemporalGrouping", i, t.ref, [
141
- "data",
142
- "dimensions",
143
- n
144
- ], t.temporalGrouping)), t.format?.formatType !== void 0 && r.push(h(w.formatType, i, t.ref, [
145
- "data",
146
- "dimensions",
147
- n
148
- ], "formatType", t.format.formatType)), t.format?.formatString !== void 0 && r.push(h(w.formatString, i, t.ref, [
149
- "data",
150
- "dimensions",
151
- n
152
- ], "formatString", t.format.formatString));
153
- }), t.data.measures.forEach((t, i) => {
154
- let a = e.resolvedRefs[t.ref];
155
- [
156
- "formatType",
157
- "formatString",
158
- "currency",
159
- "currencyIsPrefix",
160
- "negativeType"
161
- ].forEach((e) => {
162
- let n = t.format?.[e];
163
- n !== void 0 && r.push(h(T[e], a, t.ref, [
164
- "data",
165
- "measures",
166
- i
167
- ], e, n));
168
- }), t.dataLabels && r.push({
169
- name: s.SET_MEASURE_DATA_LABELS_SHOW,
170
- payload: {
171
- ...M(a),
172
- show: t.dataLabels.visible
173
- }
174
- }), t.dataLabels?.placements && r.push({
175
- name: s.SET_MEASURE_DATA_LABEL_BAR_PLACEMENTS,
176
- payload: {
177
- ...M(a),
178
- placements: t.dataLabels.placements.map((e) => ({ position: e }))
179
- }
180
- }), t.axis && r.push({
181
- name: n.CHANGE_MEASURE_AXIS,
182
- payload: {
183
- ...M(a),
184
- secondaryAxis: t.axis === "secondary"
185
- }
186
- });
187
- }), p(e, r, ["data"]);
188
- }, P = (e, t) => p(e, t.filterGroup ? [{
189
- id: "filterGroup",
190
- name: "setStaticFilterGroup",
191
- payload: u(t.filterGroup)
192
- }] : [], ["filterGroup"]), F = async (t, n) => {
193
- if (!n.sorting?.length) return {
194
- state: t,
195
- success: !0
196
- };
197
- let r = t.vSpec, i = new Map(n.sorting.map((e) => [e.by, e])), o = new Map(Object.entries(t.resolvedRefs).map(([e, t]) => [`${t.dataItemInternalKey}:${t.dataItemUniqueSignature}`, e])), s = r.querySettings?.sortingOrder ?? [], c = n.sorting.map((e) => t.resolvedRefs[e.by]), l = new Set(c.map((e) => `${e.dataItemInternalKey}:${e.dataItemUniqueSignature}`)), u = [...c, ...s.filter((e) => !l.has(`${e.dataItem.internalKey}:${e.dataItem.uniqueSignature}`)).map((e) => ({
198
- dataItemInternalKey: e.dataItem.internalKey,
199
- dataItemUniqueSignature: e.dataItem.uniqueSignature,
200
- kind: e.fieldType === "dimension" ? "dimension" : "measure"
201
- }))].map((t, n) => {
202
- let r = o.get(`${t.dataItemInternalKey}:${t.dataItemUniqueSignature}`), a = s.find((e) => e.dataItem.internalKey === t.dataItemInternalKey && e.dataItem.uniqueSignature === t.dataItemUniqueSignature);
203
- return {
204
- ...M(t),
205
- newIndex: n,
206
- sortDirection: (r ? i.get(r)?.direction : void 0) ?? a?.sortDirection ?? e.Asc
207
- };
208
- }), d = await p(t, [{
209
- name: a.CHANGE_SORT_ORDER_AND_DIRECTION,
210
- payload: { changeRequests: u }
211
- }], ["sorting"]);
212
- if (!d.success) return d;
213
- let f = n.sorting.map((e) => ({
214
- name: a.TOGGLE_SORTING_ITEM,
215
- payload: {
216
- ...M(t.resolvedRefs[e.by]),
217
- enabled: e.enabled ?? !0
218
- }
219
- }));
220
- return d = await p(d.state, f, ["sorting"]), d;
221
- }, I = (e, t) => {
222
- let n = [], { limiting: r } = t;
223
- if (r?.queryLimit !== void 0 && n.push({
224
- name: a.SET_QUERY_LIMIT,
225
- payload: r.queryLimit
226
- }), r?.topN) {
227
- let t = e.resolvedRefs[r.topN.by];
228
- n.push({
229
- name: a.ENABLE_TOP_N,
230
- payload: !0
231
- }, {
232
- name: a.SET_TOP_N_NUMBER_OF_VALUES,
233
- payload: r.topN.count
234
- }, {
235
- name: a.SET_TOP_N_SORT_ORDER,
236
- payload: r.topN.direction
237
- }, {
238
- name: a.SET_TOP_N_SHOW_OTHERS,
239
- payload: r.topN.showOthers ?? !1
240
- }, {
241
- name: a.SET_TOP_N_RANK_MEASURE,
242
- payload: {
243
- ...M(t),
244
- ...e.measureAggregations[r.topN.by] ? { aggregation: e.measureAggregations[r.topN.by] } : {}
245
- }
246
- });
247
- }
248
- return p(e, n, ["limiting"]);
249
- }, L = (e, t) => {
250
- let n = [], { presentation: i } = t, s = l(i?.axes);
251
- if (s) return Promise.resolve({
252
- issue: s,
253
- success: !1
254
- });
255
- i?.orientation !== void 0 && n.push({
256
- name: a.SET_BAR_CHART_ORIENTATION,
257
- payload: i.orientation
258
- });
259
- let c = i?.legend;
260
- c && n.push(...f(e.vSpec, c)), Object.entries(i?.axes ?? {}).forEach(([e, t]) => {
261
- t.titleVisible !== void 0 && n.push({
262
- name: a.SET_SHOW_AXIS_TITLE,
263
- payload: {
264
- axisName: e,
265
- showAxisName: t.titleVisible
266
- }
267
- }), t.title !== void 0 && n.push({
268
- name: a.SET_AXIS_TITLE,
269
- payload: {
270
- axisName: e,
271
- axisTitle: t.title
272
- }
273
- }), t.labelsVisible !== void 0 && n.push({
274
- name: a.SET_SHOW_AXIS_LABELS,
275
- payload: {
276
- axisName: e,
277
- showLabels: t.labelsVisible
278
- }
279
- }), t.ticksVisible !== void 0 && n.push({
280
- name: a.SET_SHOW_AXIS_TICKS,
281
- payload: {
282
- axisName: e,
283
- showAxisTicks: t.ticksVisible
284
- }
285
- }), t.lineVisible !== void 0 && n.push({
286
- name: a.SET_SHOW_AXIS_LINE,
287
- payload: {
288
- axisName: e,
289
- showAxisLine: t.lineVisible
290
- }
291
- }), n.push(...d(e, t)), "scale" in t && t.scale !== void 0 && n.push({
292
- name: o.SET_AXIS_SCALE,
293
- payload: {
294
- axisName: e,
295
- scale: t.scale
296
- }
297
- });
298
- });
299
- let u = i?.axes?.primaryMeasure?.bands;
300
- return u && n.push({
301
- name: r.SET_MEASURE_AXIS_BANDS,
302
- payload: { bands: u }
303
- }), p(e, n, ["presentation"]);
304
- }, R = async (e) => {
305
- let n = v.safeParse(e.definition);
306
- if (!n.success) return {
307
- issues: y(n.error, e.definition),
308
- success: !1
309
- };
310
- let r = t.safeParse(e.baseVSpec);
311
- if (!r.success) return {
312
- issues: [E("invalid_structure", ["baseVSpec"], "Base bar vSpec is invalid.", { details: { issues: r.error.issues } })],
313
- success: !1
314
- };
315
- let i = r.data, a = O(i);
316
- if (a) return {
317
- issues: [a],
318
- success: !1
319
- };
320
- let o = n.data.data.measures.find((e) => e.ref === n.data.limiting?.topN?.by), s = (o ? e.availableFields.find((e) => e.fieldKey === o.fieldKey) : void 0)?.kind === "measure" ? [E("unsupported_feature", [
321
- "limiting",
322
- "topN",
323
- "by"
324
- ], "Top N ranking by a predefined measure is not supported by the current query builder. Use a raw field or calculation.")] : [], c = [
325
- ...D(n.data),
326
- ...x(n.data.data.dimensions, e.availableFields, ["data", "dimensions"], "dimension"),
327
- ...x(n.data.data.measures, e.availableFields, ["data", "measures"], "measure"),
328
- ...b(n.data.filterGroup, e.availableFields),
329
- ...s
330
- ];
331
- if (c.length > 0) return {
332
- issues: c,
333
- success: !1
334
- };
335
- let l = await j({
336
- availableFields: m(e.availableFields),
337
- input: e,
338
- measureAggregations: {},
339
- resolvedRefs: {},
340
- vSpec: i
341
- }, n.data), u = [
342
- N,
343
- P,
344
- F,
345
- I,
346
- L,
347
- (e, t) => _(e, t.presentation?.coloring)
348
- ];
349
- for (let e of u) {
350
- if ("issue" in l) return {
351
- issues: [l.issue],
352
- success: !1
353
- };
354
- l = await e(l.state, n.data);
355
- }
356
- if ("issue" in l) return {
357
- issues: [l.issue],
358
- success: !1
359
- };
360
- let d = t.safeParse(l.state.vSpec);
361
- return d.success ? {
362
- resolvedRefs: l.state.resolvedRefs,
363
- success: !0,
364
- vSpec: d.data
365
- } : {
366
- issues: [E("invalid_compiled_vspec", [], "Compiled bar vSpec failed final validation.", { details: { issues: d.error.issues } })],
367
- success: !1
368
- };
369
- };
370
- export { R as compileBarVisualizationDefinition };