@astrato-io/visualizations 0.6.4 → 0.6.5

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 (149) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/THIRD_PARTY_NOTICES.md +94 -4
  3. package/chunks/ClickAwayListener-BbeNMAvj.js +52 -0
  4. package/chunks/{LinearProgress-CUZ0D8_t.js → LinearProgress-B1FeWaen.js} +54 -54
  5. package/chunks/app-filter-bar.compiler-BGJ7HAbr.js +64 -0
  6. package/chunks/bar.compiler-CT0ZbQKc.js +374 -0
  7. package/chunks/{src-Cum_2NLV.js → builder-B6dWSIdD.js} +5779 -5635
  8. package/chunks/{coloring-C16AUZEi.js → coloring-B1XAfg6b.js} +234 -233
  9. package/chunks/{src-BC7cGcJ-.js → definitions-D3OVqmXl.js} +438 -360
  10. package/chunks/{escobar-BGqT1EsE.js → escobar-eDjtGpkC.js} +4645 -4619
  11. package/chunks/filter.compiler-DBsyRBJt.js +70 -0
  12. package/chunks/{filtering-Yq4DEa0t.js → filtering-tqjAyJH5.js} +432 -313
  13. package/chunks/{grouping-type-BX_9Ix5q.js → grouping-type-On4s9Thj.js} +1 -1
  14. package/chunks/handlers-VTBfIZYZ.js +13072 -0
  15. package/chunks/isEqual-BDxAhUo8.js +7514 -0
  16. package/chunks/line.compiler-CzdM5Ld0.js +198 -0
  17. package/chunks/{metadata-CPXdYoln.js → metadata-BGElBy5Z.js} +1 -1
  18. package/chunks/number.compiler-G-R7y16P.js +53 -0
  19. package/chunks/{src-C0LgoUWY.js → operations-CTNUX6Sy.js} +9576 -9432
  20. package/chunks/{range-DrzdfBX4.js → range-CiwTbMig.js} +2 -2
  21. package/chunks/{registry-CExpGJ1N.js → registry-CsQQzukD.js} +153 -153
  22. package/chunks/{requirements-DNhuShLS.js → requirements-DYjZCFyf.js} +1 -1
  23. package/chunks/{shared-CKDL4hx9.js → shared-CBvcC5YV.js} +460 -413
  24. package/chunks/{standalone-D5vnf-9y.js → standalone-0M4HlmDW2.js} +823 -822
  25. package/chunks/standalone-0ashe9w1.js +411 -0
  26. package/chunks/{standalone-C85u7U6I.js → standalone-B7jax8wa.js} +93 -94
  27. package/chunks/standalone-BK0VYU-l.js +463 -0
  28. package/chunks/{standalone-BDCwI6Hn.js → standalone-BMIbT1b2.js} +815 -815
  29. package/chunks/standalone-BZV5vOwA.js +6 -0
  30. package/chunks/standalone-BhDrWj4p.js +1980 -0
  31. package/chunks/{standalone-CNyNHKVx.js → standalone-BtSHCp2U2.js} +97 -98
  32. package/chunks/{standalone-CDQnr6qT.js → standalone-BvaKdky9.js} +95 -96
  33. package/chunks/standalone-BwtM31-f.js +2 -0
  34. package/chunks/{standalone-CY57qwZ-.js → standalone-C3gg736V.js} +153 -153
  35. package/chunks/{standalone-DFPva_ku.js → standalone-CC1VUjO32.js} +60 -60
  36. package/chunks/{standalone-CCNtaJ7s.js → standalone-C_rYnZ0N.js} +41 -41
  37. package/chunks/{standalone-CZynjFG7.js → standalone-CoLrAxRV.js} +3701 -3482
  38. package/chunks/{standalone-jiz0L2Dg.js → standalone-DC-aUgXC.js} +104 -104
  39. package/chunks/standalone-DCtRoTWg.js +675 -0
  40. package/chunks/standalone-DUDFTBqL.js +833 -0
  41. package/chunks/standalone-DhZkX9Td.js +2 -0
  42. package/chunks/{standalone-Dx3MLlrO.js → standalone-DtLElfuM.js} +141 -141
  43. package/chunks/{standalone-BmfMt74U.js → standalone-G9Q4Uczu.js} +192 -192
  44. package/chunks/{standalone-BH5NqDwp.js → standalone-JuLF-OoH.js} +390 -391
  45. package/chunks/standalone-_DeX21JJ.js +383 -0
  46. package/chunks/{standalone-lBm9hQ-q.js → standalone-gFhKZh8m.js} +34 -34
  47. package/chunks/standalone-tDNy-SFH.js +281 -0
  48. package/chunks/{standalone-rJ45Zfl1.js → standalone-v1oxfU20.js} +10 -10
  49. package/chunks/{standalone-BYm1UjLr.js → standalone-vzBY6q0I2.js} +18 -18
  50. package/chunks/table.compiler-tb914oj3.js +222 -0
  51. package/chunks/{ui-D1HQNIBy.js → ui-DQWtv2iM.js} +13485 -3973
  52. package/chunks/{useFieldName-oqQ3bvnO.js → useFieldName-BvdcoJRl.js} +1 -1
  53. package/chunks/{utils-Ba9T0TqC.js → utils-Bg7K-t6K.js} +7306 -6024
  54. package/chunks/{src-DvX5LU9T.js → view-Bn83C8d9.js} +2555 -4831
  55. package/definitions.js +3 -3
  56. package/docs/operations/astrato-app-filter-bar.md +17 -17
  57. package/docs/operations/bar.md +989 -1071
  58. package/docs/operations/combo.md +717 -738
  59. package/docs/operations/date-picker.md +25 -25
  60. package/docs/operations/distribution-gauge.md +471 -607
  61. package/docs/operations/dot.md +787 -879
  62. package/docs/operations/filter.md +139 -163
  63. package/docs/operations/gauge.md +491 -627
  64. package/docs/operations/heatMap.md +834 -916
  65. package/docs/operations/histogram.md +166 -180
  66. package/docs/operations/iframe.md +5 -5
  67. package/docs/operations/image.md +16 -16
  68. package/docs/operations/index.md +12 -12
  69. package/docs/operations/line.md +811 -888
  70. package/docs/operations/number.md +470 -536
  71. package/docs/operations/pie.md +825 -958
  72. package/docs/operations/radar.md +599 -679
  73. package/docs/operations/sankey.md +462 -584
  74. package/docs/operations/scatter.md +823 -929
  75. package/docs/operations/shape.md +34 -34
  76. package/docs/operations/simpleTextObject.md +18 -25
  77. package/docs/operations/slider.md +33 -43
  78. package/docs/operations/table.md +1160 -1150
  79. package/docs/operations/tree.md +354 -361
  80. package/docs/operations/treemap.md +545 -637
  81. package/docs/operations/waterfall.md +369 -379
  82. package/docs/operations/word-cloud.md +512 -583
  83. package/getters.js +3 -3
  84. package/index.js +51 -51
  85. package/metadata.js +3 -3
  86. package/operations.js +7 -7
  87. package/package.json +80 -86
  88. package/src/definitions/index.d.ts +2 -2
  89. package/src/definitions/{shared/lib → model/definitions}/available-fields.d.ts +0 -1
  90. package/src/definitions/{shared/lib/compilers/index.d.ts → model/definitions/compilers/compile.d.ts} +1 -1
  91. package/src/definitions/model/definitions/data-item-resolution.d.ts +19 -0
  92. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +1341 -0
  93. package/src/definitions/model/definitions/descriptors/json-schema.d.ts +2 -0
  94. package/src/definitions/model/definitions/diagnostics.d.ts +5 -0
  95. package/src/definitions/model/definitions/field-suggestions.d.ts +2 -0
  96. package/src/definitions/model/definitions/index.d.ts +23 -0
  97. package/src/definitions/{shared/lib → model/definitions}/registry/compile.d.ts +1 -1
  98. package/src/definitions/model/definitions/registry/descriptor-registry.d.ts +3 -0
  99. package/src/definitions/model/definitions/schema-registry.d.ts +660 -0
  100. package/src/definitions/{shared/lib → model/definitions}/schemas/broad-chart.schema.d.ts +1 -1
  101. package/src/definitions/{shared/lib → model/definitions}/schemas/common.schema.d.ts +0 -1
  102. package/src/definitions/model/definitions/schemas/index.d.ts +9 -0
  103. package/src/definitions/{shared/lib → model/definitions}/schemas/object.schema.d.ts +6 -6
  104. package/src/definitions/{shared/lib → model/definitions}/types/definition.types.d.ts +1 -1
  105. package/src/definitions/model/definitions/types/index.d.ts +3 -0
  106. package/src/definitions/{shared/lib/registry → model/definitions}/validation.d.ts +1 -1
  107. package/chunks/Radio-Ciu-F4CU.js +0 -957
  108. package/chunks/ToggleButton-BCJc3Jlc.js +0 -153
  109. package/chunks/_baseFlatten-DPXPOrea.js +0 -7076
  110. package/chunks/app-filter-bar.compiler-j_CVoWTa.js +0 -55
  111. package/chunks/bar.compiler-oqaPzIut.js +0 -370
  112. package/chunks/data-item-resolution-1lvYB5ln.js +0 -53
  113. package/chunks/event-bus-KiSiCJrC.js +0 -2683
  114. package/chunks/filter.compiler-CuLtc_02.js +0 -60
  115. package/chunks/gauge-target-type-BkKXAqkX.js +0 -4
  116. package/chunks/interfaces-VUY4_yVO.js +0 -8742
  117. package/chunks/line-settings-DfYTUyPz.js +0 -4
  118. package/chunks/line.compiler-BpA_6Tc7.js +0 -188
  119. package/chunks/number.compiler-DbkWcG4S.js +0 -44
  120. package/chunks/pie-uv42Eqal.js +0 -10
  121. package/chunks/src-Dun_jXtz.js +0 -10295
  122. package/chunks/standalone-87YV_m9n.js +0 -687
  123. package/chunks/standalone-BLVAWLNJ.js +0 -385
  124. package/chunks/standalone-BPomtAVs.js +0 -2
  125. package/chunks/standalone-BXyBcUOQ.js +0 -2
  126. package/chunks/standalone-BllF4rDp.js +0 -383
  127. package/chunks/standalone-BqWyrnZI.js +0 -281
  128. package/chunks/standalone-DQxxNwF8.js +0 -675
  129. package/chunks/standalone-DS9T0FZ-.js +0 -830
  130. package/chunks/standalone-DzixzZAL.js +0 -411
  131. package/chunks/standalone-QJ1kKMnO.js +0 -6
  132. package/chunks/table.compiler-BrXkm4Fz.js +0 -213
  133. package/chunks/toInteger-DVZr-D1j.js +0 -11
  134. package/chunks/treemap-x_zmJoG7.js +0 -23
  135. package/chunks/types-dVVCsDWD.js +0 -4
  136. package/chunks/view-CLqWMV7Z.js +0 -156
  137. package/src/definitions/shared/index.d.ts +0 -5
  138. package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +0 -587
  139. package/src/definitions/shared/lib/registry/index.d.ts +0 -3
  140. package/src/definitions/shared/lib/schemas/index.d.ts +0 -9
  141. package/src/definitions/shared/lib/types/index.d.ts +0 -3
  142. package/src/definitions/{shared/lib → model/definitions}/schemas/app-filter-bar.schema.d.ts +0 -0
  143. package/src/definitions/{shared/lib → model/definitions}/schemas/bar.schema.d.ts +0 -0
  144. package/src/definitions/{shared/lib → model/definitions}/schemas/filter.schema.d.ts +0 -0
  145. package/src/definitions/{shared/lib → model/definitions}/schemas/line.schema.d.ts +0 -0
  146. package/src/definitions/{shared/lib → model/definitions}/schemas/number.schema.d.ts +0 -0
  147. package/src/definitions/{shared/lib → model/definitions}/schemas/table.schema.d.ts +4 -4
  148. /package/src/definitions/{shared/lib → model/definitions}/types/compilation.types.d.ts +0 -0
  149. /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 };
@@ -1,53 +0,0 @@
1
- import { Cs as e, ds as t } from "./interfaces-VUY4_yVO.js";
2
- import { D as n, E as r, O as i } from "./shared-CKDL4hx9.js";
3
- var a = t(), o = (e, t) => {
4
- let n = Math.min(e.length, t.length), r = 0;
5
- for (; r < n && e[r].toLocaleLowerCase() === t[r].toLocaleLowerCase();) r += 1;
6
- return r;
7
- }, s = (e, t) => [...t].sort((t, n) => o(e, n.fieldKey) - o(e, t.fieldKey) || t.fieldKey.localeCompare(n.fieldKey)).slice(0, 5).map((e) => e.fieldKey), c = [
8
- a.FieldType.DATE,
9
- a.FieldType.TIME,
10
- a.FieldType.TIMESTAMP,
11
- a.FieldType.TIMESTAMP_TZ
12
- ], l = (e, t, n, r) => ({
13
- ...r ? { allowedValues: r } : {},
14
- code: e,
15
- message: n,
16
- path: t
17
- }), u = (t) => r(t).filter((t) => !!e(t)), d = (e, t) => {
18
- let n = t.find((t) => t.fieldKey === e.fieldKey);
19
- return n?.kind === "field" ? u(n).find((t) => t.toLocaleUpperCase() === e.aggregation?.toLocaleUpperCase()) : void 0;
20
- }, f = (e, t) => {
21
- let n = t.find((t) => t.fieldKey === e.fieldKey);
22
- return n?.kind === "measure" ? n.item.measure.aggregation : d(e, t);
23
- }, p = (e, t, r = {}) => {
24
- let i = t.find((t) => t.fieldKey === e.fieldKey), a = i ? n(i) : void 0, o = d(e, t);
25
- return {
26
- ...r,
27
- key: e.fieldKey,
28
- ...a ? { sourceKind: a } : {},
29
- ...o ? { aggregation: o } : {}
30
- };
31
- }, m = (e, t, n, r) => {
32
- let a = t.find((t) => t.fieldKey === e.fieldKey);
33
- if (!a) return [l("unknown_field_key", [...n, "fieldKey"], `Field key "${e.fieldKey}" is not available.`, s(e.fieldKey, t))];
34
- if (!i(a, r)) return [l("invalid_field_role", [...n, "fieldKey"], `Available item "${e.fieldKey}" of kind "${a.kind}" cannot be used as a ${r}.`)];
35
- if (r !== "measure") return e.temporalGrouping ? g(e, t, n, c, "a temporally grouped dimension") : [];
36
- if (a.kind !== "field") return e.aggregation === void 0 ? [] : [l("invalid_aggregation", [...n, "aggregation"], `Aggregation must be omitted for semantic ${a.kind} "${e.fieldKey}".`)];
37
- let o = u(a);
38
- return e.aggregation ? o.some((t) => t.toLocaleUpperCase() === e.aggregation?.toLocaleUpperCase()) ? [] : [l("invalid_aggregation", [...n, "aggregation"], `Aggregation "${e.aggregation}" is not available for field key "${e.fieldKey}".`, o)] : [l("invalid_aggregation", [...n, "aggregation"], `Aggregation is required for raw field "${e.fieldKey}" when it is used as a measure.`, o)];
39
- }, h = (e, t, n, r) => e.flatMap((e, i) => m(e, t, [...n, i], r)), g = (e, t, n, r, i) => {
40
- let a = t.find((t) => t.fieldKey === e.fieldKey);
41
- return a?.kind !== "field" || r.includes(a.dataType) ? [] : [l("invalid_field_role", [...n, "fieldKey"], `Raw field "${e.fieldKey}" has data type "${a.dataType}" and cannot be used as ${i}.`, [...r])];
42
- }, _ = (e, t, n = ["filterGroup"]) => e ? e.filters.flatMap((e, r) => {
43
- let i = [
44
- ...n,
45
- "filters",
46
- r
47
- ];
48
- return "filters" in e ? _(e, t, i) : m({
49
- fieldKey: e.fieldKey,
50
- ref: `filter:${r}`
51
- }, t, i, "dimension");
52
- }) : [];
53
- export { _ as a, h as i, f as n, g as o, m as r, p as t };