@gooddata/sdk-code-convertors 11.28.0-alpha.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.
Files changed (237) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +42 -0
  3. package/esm/configs/areaChart.d.ts +113 -0
  4. package/esm/configs/areaChart.d.ts.map +1 -0
  5. package/esm/configs/areaChart.js +232 -0
  6. package/esm/configs/areaChart.js.map +1 -0
  7. package/esm/configs/barChart.d.ts +101 -0
  8. package/esm/configs/barChart.d.ts.map +1 -0
  9. package/esm/configs/barChart.js +210 -0
  10. package/esm/configs/barChart.js.map +1 -0
  11. package/esm/configs/bubbleChart.d.ts +93 -0
  12. package/esm/configs/bubbleChart.d.ts.map +1 -0
  13. package/esm/configs/bubbleChart.js +186 -0
  14. package/esm/configs/bubbleChart.js.map +1 -0
  15. package/esm/configs/bulletChart.d.ts +87 -0
  16. package/esm/configs/bulletChart.d.ts.map +1 -0
  17. package/esm/configs/bulletChart.js +174 -0
  18. package/esm/configs/bulletChart.js.map +1 -0
  19. package/esm/configs/columnChart.d.ts +101 -0
  20. package/esm/configs/columnChart.d.ts.map +1 -0
  21. package/esm/configs/columnChart.js +210 -0
  22. package/esm/configs/columnChart.js.map +1 -0
  23. package/esm/configs/comboChart.d.ts +155 -0
  24. package/esm/configs/comboChart.d.ts.map +1 -0
  25. package/esm/configs/comboChart.js +355 -0
  26. package/esm/configs/comboChart.js.map +1 -0
  27. package/esm/configs/dependencyWheelChart.d.ts +37 -0
  28. package/esm/configs/dependencyWheelChart.d.ts.map +1 -0
  29. package/esm/configs/dependencyWheelChart.js +81 -0
  30. package/esm/configs/dependencyWheelChart.js.map +1 -0
  31. package/esm/configs/donutChart.d.ts +47 -0
  32. package/esm/configs/donutChart.d.ts.map +1 -0
  33. package/esm/configs/donutChart.js +96 -0
  34. package/esm/configs/donutChart.js.map +1 -0
  35. package/esm/configs/funnelChart.d.ts +47 -0
  36. package/esm/configs/funnelChart.d.ts.map +1 -0
  37. package/esm/configs/funnelChart.js +96 -0
  38. package/esm/configs/funnelChart.js.map +1 -0
  39. package/esm/configs/geoAreaChart.d.ts +62 -0
  40. package/esm/configs/geoAreaChart.d.ts.map +1 -0
  41. package/esm/configs/geoAreaChart.js +123 -0
  42. package/esm/configs/geoAreaChart.js.map +1 -0
  43. package/esm/configs/geoChart.d.ts +49 -0
  44. package/esm/configs/geoChart.d.ts.map +1 -0
  45. package/esm/configs/geoChart.js +157 -0
  46. package/esm/configs/geoChart.js.map +1 -0
  47. package/esm/configs/headlineChart.d.ts +89 -0
  48. package/esm/configs/headlineChart.d.ts.map +1 -0
  49. package/esm/configs/headlineChart.js +124 -0
  50. package/esm/configs/headlineChart.js.map +1 -0
  51. package/esm/configs/heatmapChart.d.ts +75 -0
  52. package/esm/configs/heatmapChart.d.ts.map +1 -0
  53. package/esm/configs/heatmapChart.js +158 -0
  54. package/esm/configs/heatmapChart.js.map +1 -0
  55. package/esm/configs/lineChart.d.ts +135 -0
  56. package/esm/configs/lineChart.d.ts.map +1 -0
  57. package/esm/configs/lineChart.js +294 -0
  58. package/esm/configs/lineChart.js.map +1 -0
  59. package/esm/configs/pieChart.d.ts +47 -0
  60. package/esm/configs/pieChart.d.ts.map +1 -0
  61. package/esm/configs/pieChart.js +96 -0
  62. package/esm/configs/pieChart.js.map +1 -0
  63. package/esm/configs/pyramidChart.d.ts +47 -0
  64. package/esm/configs/pyramidChart.d.ts.map +1 -0
  65. package/esm/configs/pyramidChart.js +96 -0
  66. package/esm/configs/pyramidChart.js.map +1 -0
  67. package/esm/configs/repeaterChart.d.ts +36 -0
  68. package/esm/configs/repeaterChart.d.ts.map +1 -0
  69. package/esm/configs/repeaterChart.js +104 -0
  70. package/esm/configs/repeaterChart.js.map +1 -0
  71. package/esm/configs/sankeyChart.d.ts +39 -0
  72. package/esm/configs/sankeyChart.d.ts.map +1 -0
  73. package/esm/configs/sankeyChart.js +84 -0
  74. package/esm/configs/sankeyChart.js.map +1 -0
  75. package/esm/configs/scatterChart.d.ts +95 -0
  76. package/esm/configs/scatterChart.d.ts.map +1 -0
  77. package/esm/configs/scatterChart.js +198 -0
  78. package/esm/configs/scatterChart.js.map +1 -0
  79. package/esm/configs/table.d.ts +61 -0
  80. package/esm/configs/table.d.ts.map +1 -0
  81. package/esm/configs/table.js +169 -0
  82. package/esm/configs/table.js.map +1 -0
  83. package/esm/configs/treemapChart.d.ts +47 -0
  84. package/esm/configs/treemapChart.d.ts.map +1 -0
  85. package/esm/configs/treemapChart.js +96 -0
  86. package/esm/configs/treemapChart.js.map +1 -0
  87. package/esm/configs/types.d.ts +93 -0
  88. package/esm/configs/types.d.ts.map +1 -0
  89. package/esm/configs/types.js +3 -0
  90. package/esm/configs/types.js.map +1 -0
  91. package/esm/configs/utils.d.ts +12 -0
  92. package/esm/configs/utils.d.ts.map +1 -0
  93. package/esm/configs/utils.js +76 -0
  94. package/esm/configs/utils.js.map +1 -0
  95. package/esm/configs/waterfallChart.d.ts +109 -0
  96. package/esm/configs/waterfallChart.d.ts.map +1 -0
  97. package/esm/configs/waterfallChart.js +214 -0
  98. package/esm/configs/waterfallChart.js.map +1 -0
  99. package/esm/conts.d.ts +9 -0
  100. package/esm/conts.d.ts.map +1 -0
  101. package/esm/conts.js +41 -0
  102. package/esm/conts.js.map +1 -0
  103. package/esm/execution/buildAfmExecution.d.ts +5 -0
  104. package/esm/execution/buildAfmExecution.d.ts.map +1 -0
  105. package/esm/execution/buildAfmExecution.js +374 -0
  106. package/esm/execution/buildAfmExecution.js.map +1 -0
  107. package/esm/from/declarativeAttributeHierarchyToYaml.d.ts +12 -0
  108. package/esm/from/declarativeAttributeHierarchyToYaml.d.ts.map +1 -0
  109. package/esm/from/declarativeAttributeHierarchyToYaml.js +26 -0
  110. package/esm/from/declarativeAttributeHierarchyToYaml.js.map +1 -0
  111. package/esm/from/declarativeDashboardToYaml.d.ts +59 -0
  112. package/esm/from/declarativeDashboardToYaml.d.ts.map +1 -0
  113. package/esm/from/declarativeDashboardToYaml.js +771 -0
  114. package/esm/from/declarativeDashboardToYaml.js.map +1 -0
  115. package/esm/from/declarativeDatasetToYaml.d.ts +9 -0
  116. package/esm/from/declarativeDatasetToYaml.d.ts.map +1 -0
  117. package/esm/from/declarativeDatasetToYaml.js +239 -0
  118. package/esm/from/declarativeDatasetToYaml.js.map +1 -0
  119. package/esm/from/declarativeDateInstanceToYaml.d.ts +8 -0
  120. package/esm/from/declarativeDateInstanceToYaml.d.ts.map +1 -0
  121. package/esm/from/declarativeDateInstanceToYaml.js +30 -0
  122. package/esm/from/declarativeDateInstanceToYaml.js.map +1 -0
  123. package/esm/from/declarativeMetricToYaml.d.ts +8 -0
  124. package/esm/from/declarativeMetricToYaml.d.ts.map +1 -0
  125. package/esm/from/declarativeMetricToYaml.js +34 -0
  126. package/esm/from/declarativeMetricToYaml.js.map +1 -0
  127. package/esm/from/declarativePluginToYaml.d.ts +10 -0
  128. package/esm/from/declarativePluginToYaml.d.ts.map +1 -0
  129. package/esm/from/declarativePluginToYaml.js +26 -0
  130. package/esm/from/declarativePluginToYaml.js.map +1 -0
  131. package/esm/from/declarativeVisualisationToYaml.d.ts +64 -0
  132. package/esm/from/declarativeVisualisationToYaml.d.ts.map +1 -0
  133. package/esm/from/declarativeVisualisationToYaml.js +1513 -0
  134. package/esm/from/declarativeVisualisationToYaml.js.map +1 -0
  135. package/esm/index.d.ts +18 -0
  136. package/esm/index.d.ts.map +1 -0
  137. package/esm/index.js +22 -0
  138. package/esm/index.js.map +1 -0
  139. package/esm/schemas/types.d.ts +32 -0
  140. package/esm/schemas/types.d.ts.map +1 -0
  141. package/esm/schemas/types.js +3 -0
  142. package/esm/schemas/types.js.map +1 -0
  143. package/esm/schemas/v1/metadata.d.ts +7277 -0
  144. package/esm/schemas/v1/metadata.d.ts.map +1 -0
  145. package/esm/schemas/v1/metadata.js +3 -0
  146. package/esm/schemas/v1/metadata.js.map +1 -0
  147. package/esm/sdk-code-convertors.d.ts +7861 -0
  148. package/esm/to/yamlAttributeHierarchyToDeclarative.d.ts +5 -0
  149. package/esm/to/yamlAttributeHierarchyToDeclarative.d.ts.map +1 -0
  150. package/esm/to/yamlAttributeHierarchyToDeclarative.js +16 -0
  151. package/esm/to/yamlAttributeHierarchyToDeclarative.js.map +1 -0
  152. package/esm/to/yamlDashboardToDeclarative.d.ts +29 -0
  153. package/esm/to/yamlDashboardToDeclarative.d.ts.map +1 -0
  154. package/esm/to/yamlDashboardToDeclarative.js +732 -0
  155. package/esm/to/yamlDashboardToDeclarative.js.map +1 -0
  156. package/esm/to/yamlDatasetToDeclarative.d.ts +41 -0
  157. package/esm/to/yamlDatasetToDeclarative.d.ts.map +1 -0
  158. package/esm/to/yamlDatasetToDeclarative.js +346 -0
  159. package/esm/to/yamlDatasetToDeclarative.js.map +1 -0
  160. package/esm/to/yamlDateDatasetToDeclarative.d.ts +5 -0
  161. package/esm/to/yamlDateDatasetToDeclarative.d.ts.map +1 -0
  162. package/esm/to/yamlDateDatasetToDeclarative.js +21 -0
  163. package/esm/to/yamlDateDatasetToDeclarative.js.map +1 -0
  164. package/esm/to/yamlMetricToDeclarative.d.ts +5 -0
  165. package/esm/to/yamlMetricToDeclarative.d.ts.map +1 -0
  166. package/esm/to/yamlMetricToDeclarative.js +24 -0
  167. package/esm/to/yamlMetricToDeclarative.js.map +1 -0
  168. package/esm/to/yamlPluginToDeclarative.d.ts +5 -0
  169. package/esm/to/yamlPluginToDeclarative.d.ts.map +1 -0
  170. package/esm/to/yamlPluginToDeclarative.js +17 -0
  171. package/esm/to/yamlPluginToDeclarative.js.map +1 -0
  172. package/esm/to/yamlVisualisationToDeclarative.d.ts +31 -0
  173. package/esm/to/yamlVisualisationToDeclarative.d.ts.map +1 -0
  174. package/esm/to/yamlVisualisationToDeclarative.js +1048 -0
  175. package/esm/to/yamlVisualisationToDeclarative.js.map +1 -0
  176. package/esm/tsdoc-metadata.json +11 -0
  177. package/esm/types.d.ts +66 -0
  178. package/esm/types.d.ts.map +1 -0
  179. package/esm/types.js +22 -0
  180. package/esm/types.js.map +1 -0
  181. package/esm/utils/configUtils.d.ts +20 -0
  182. package/esm/utils/configUtils.d.ts.map +1 -0
  183. package/esm/utils/configUtils.js +312 -0
  184. package/esm/utils/configUtils.js.map +1 -0
  185. package/esm/utils/convertBucketToTitle.d.ts +116 -0
  186. package/esm/utils/convertBucketToTitle.d.ts.map +1 -0
  187. package/esm/utils/convertBucketToTitle.js +370 -0
  188. package/esm/utils/convertBucketToTitle.js.map +1 -0
  189. package/esm/utils/customUrl.d.ts +4 -0
  190. package/esm/utils/customUrl.d.ts.map +1 -0
  191. package/esm/utils/customUrl.js +31 -0
  192. package/esm/utils/customUrl.js.map +1 -0
  193. package/esm/utils/dateUtils.d.ts +5 -0
  194. package/esm/utils/dateUtils.d.ts.map +1 -0
  195. package/esm/utils/dateUtils.js +43 -0
  196. package/esm/utils/dateUtils.js.map +1 -0
  197. package/esm/utils/errors.d.ts +35 -0
  198. package/esm/utils/errors.d.ts.map +1 -0
  199. package/esm/utils/errors.js +65 -0
  200. package/esm/utils/errors.js.map +1 -0
  201. package/esm/utils/filterUtils.d.ts +3 -0
  202. package/esm/utils/filterUtils.d.ts.map +1 -0
  203. package/esm/utils/filterUtils.js +26 -0
  204. package/esm/utils/filterUtils.js.map +1 -0
  205. package/esm/utils/granularityUtils.d.ts +17 -0
  206. package/esm/utils/granularityUtils.d.ts.map +1 -0
  207. package/esm/utils/granularityUtils.js +1434 -0
  208. package/esm/utils/granularityUtils.js.map +1 -0
  209. package/esm/utils/locationUtils.d.ts +11 -0
  210. package/esm/utils/locationUtils.d.ts.map +1 -0
  211. package/esm/utils/locationUtils.js +75 -0
  212. package/esm/utils/locationUtils.js.map +1 -0
  213. package/esm/utils/nameUtils.d.ts +7 -0
  214. package/esm/utils/nameUtils.d.ts.map +1 -0
  215. package/esm/utils/nameUtils.js +37 -0
  216. package/esm/utils/nameUtils.js.map +1 -0
  217. package/esm/utils/permissionUtils.d.ts +29 -0
  218. package/esm/utils/permissionUtils.d.ts.map +1 -0
  219. package/esm/utils/permissionUtils.js +82 -0
  220. package/esm/utils/permissionUtils.js.map +1 -0
  221. package/esm/utils/sharedUtils.d.ts +21 -0
  222. package/esm/utils/sharedUtils.d.ts.map +1 -0
  223. package/esm/utils/sharedUtils.js +63 -0
  224. package/esm/utils/sharedUtils.js.map +1 -0
  225. package/esm/utils/texts.d.ts +8 -0
  226. package/esm/utils/texts.d.ts.map +1 -0
  227. package/esm/utils/texts.js +47 -0
  228. package/esm/utils/texts.js.map +1 -0
  229. package/esm/utils/typeGuards.d.ts +51 -0
  230. package/esm/utils/typeGuards.d.ts.map +1 -0
  231. package/esm/utils/typeGuards.js +286 -0
  232. package/esm/utils/typeGuards.js.map +1 -0
  233. package/esm/utils/yamlUtils.d.ts +28 -0
  234. package/esm/utils/yamlUtils.d.ts.map +1 -0
  235. package/esm/utils/yamlUtils.js +163 -0
  236. package/esm/utils/yamlUtils.js.map +1 -0
  237. package/package.json +74 -0
@@ -0,0 +1,732 @@
1
+ // (C) 2023-2026 GoodData Corporation
2
+ import { randomUUID } from "crypto";
3
+ import { VisualisationsTypes } from "../conts.js";
4
+ import { parseUrlTarget } from "../utils/customUrl.js";
5
+ import { convertGranularity } from "../utils/granularityUtils.js";
6
+ import { toDeclarativePermissions } from "../utils/permissionUtils.js";
7
+ import { convertIdToTitle, getFullField } from "../utils/sharedUtils.js";
8
+ import { isAbsoluteDateFilter, isAttributeField, isAttributeFilter, isContainerWidget, isDashboardAbsoluteDateFilter, isDashboardAttributeFilter, isDashboardEmptyDateFilter, isDashboardNoopDateFilter, isDashboardRelativeDateFilter, isInsightWidget, isMetricValueFilter, isRankingFilter, isRelativeDateFilter, isRichTextWidget, isVisualizationSwitcherWidget, parseReferenceObject, } from "../utils/typeGuards.js";
9
+ import { createIdentifier, createLocalIdentifier } from "../utils/yamlUtils.js";
10
+ function extractDashboardEmptyValueHandling(filter) {
11
+ const value = filter.empty_values;
12
+ if (value === "include" || value === "exclude" || value === "only") {
13
+ return value;
14
+ }
15
+ return undefined;
16
+ }
17
+ function createFilterContextId(baseId) {
18
+ return `${baseId}_filterContext_${randomUUID()}`;
19
+ }
20
+ /**
21
+ * Convert YAML tabs to Dashboard tabs with their own layouts and filter contexts.
22
+ * Each tab maintains its own sections, filters, and filter configurations independently.
23
+ * Filter contexts are created as separate entities referenced by filterContextRef.
24
+ */
25
+ function yamlTabsToDeclarative(entities, tabs, enableSectionHeaders) {
26
+ const declarativeTabs = [];
27
+ const filterContexts = [];
28
+ tabs.forEach((tab) => {
29
+ // Convert tab sections to layout
30
+ const layout = yamlLayoutToDeclarative(entities, tab.sections, enableSectionHeaders);
31
+ // Process tab filters to get filter context and configs
32
+ const { filterContext, dateFilterConfig, dateFilterConfigs, attributeFilterConfigs, filterGroupsConfig, } = yamlFilterContextToDeclarative(tab.id, tab.filters);
33
+ // Store the filter context separately
34
+ filterContexts.push(filterContext);
35
+ // Create the tab structure with filterContextRef
36
+ declarativeTabs.push({
37
+ localIdentifier: tab.id,
38
+ title: tab.title,
39
+ layout,
40
+ filterContextRef: createIdentifier(filterContext.id, { forceType: "filterContext" }),
41
+ dateFilterConfig,
42
+ dateFilterConfigs,
43
+ attributeFilterConfigs,
44
+ ...(filterGroupsConfig ? { filterGroupsConfig } : {}),
45
+ });
46
+ });
47
+ return {
48
+ tabs: declarativeTabs,
49
+ filterContexts,
50
+ };
51
+ }
52
+ /**
53
+ * Process dashboard with tabs - uses active tab or first tab as main dashboard for backwards compatibility
54
+ */
55
+ function processDashboardWithTabs(entities, input) {
56
+ const tabsResult = yamlTabsToDeclarative(entities, input.tabs, input.enable_section_headers);
57
+ // Use first tab as default for backwards compatibility
58
+ const defaultTabIndex = 0;
59
+ const defaultTab = tabsResult.tabs[defaultTabIndex];
60
+ return {
61
+ layout: defaultTab.layout,
62
+ filterContext: tabsResult.filterContexts[defaultTabIndex],
63
+ dateFilterConfig: defaultTab.dateFilterConfig,
64
+ dateFilterConfigs: defaultTab.dateFilterConfigs,
65
+ attributeFilterConfigs: defaultTab.attributeFilterConfigs,
66
+ tabs: tabsResult.tabs,
67
+ tabFilterContexts: tabsResult.filterContexts,
68
+ };
69
+ }
70
+ /**
71
+ * Process traditional dashboard without tabs
72
+ */
73
+ function processDashboardWithoutTabs(entities, input) {
74
+ const { filterContext, tabFilterContexts: _tabFilterContexts, ...rest } = processDashboardWithTabs(entities, {
75
+ ...input,
76
+ tabs: [
77
+ {
78
+ id: "defaultTabId",
79
+ title: "",
80
+ filters: input.filters,
81
+ sections: input.sections ?? [],
82
+ },
83
+ ],
84
+ });
85
+ const dashboardFilterContextId = createFilterContextId(input.id);
86
+ const dashboardFilterContext = {
87
+ ...filterContext,
88
+ id: dashboardFilterContextId,
89
+ };
90
+ return {
91
+ ...rest,
92
+ tabs: rest.tabs.map((tab) => ({
93
+ ...tab,
94
+ filterContextRef: createIdentifier(dashboardFilterContextId, { forceType: "filterContext" }),
95
+ })),
96
+ filterContext: dashboardFilterContext,
97
+ tabFilterContexts: [dashboardFilterContext],
98
+ };
99
+ }
100
+ /** @public */
101
+ export function yamlDashboardToDeclarative(entities, input) {
102
+ // Process dashboard based on whether it has tabs
103
+ const { layout, filterContext, dateFilterConfig, dateFilterConfigs, attributeFilterConfigs, tabs, tabFilterContexts, } = input.tabs ? processDashboardWithTabs(entities, input) : processDashboardWithoutTabs(entities, input);
104
+ const plugins = yamlPluginsToDeclarative(input.plugins);
105
+ const [, permissions] = toDeclarativePermissions(input.permissions);
106
+ const content = {
107
+ version: "2",
108
+ layout,
109
+ plugins,
110
+ attributeFilterConfigs,
111
+ dateFilterConfig,
112
+ dateFilterConfigs,
113
+ ...(tabs ? { tabs } : {}),
114
+ ...(input.cross_filtering === false ? { disableCrossFiltering: true } : {}),
115
+ ...(input.user_filters_save === false ? { disableUserFilterSave: true } : {}),
116
+ ...(input.user_filters_reset === false ? { disableUserFilterReset: true } : {}),
117
+ ...(input.filter_views === false ? { disableFilterViews: true } : {}),
118
+ filterContextRef: createIdentifier(filterContext.id, { forceType: "filterContext" }),
119
+ };
120
+ const dashboard = {
121
+ id: input.id,
122
+ title: input.title ?? convertIdToTitle(input.id),
123
+ tags: input.tags ?? [],
124
+ description: input.description ?? "",
125
+ content,
126
+ permissions,
127
+ };
128
+ return {
129
+ dashboard,
130
+ filterContext,
131
+ ...(tabFilterContexts && tabFilterContexts.length > 0 ? { tabFilterContexts } : {}),
132
+ };
133
+ }
134
+ function yamlLayoutToDeclarative(entities, sections = [], enableSectionHeaders) {
135
+ return {
136
+ type: "IDashboardLayout",
137
+ sections: sections.map((yamlSection) => yamlSectionToDeclarative(entities, yamlSection, enableSectionHeaders)),
138
+ ...(enableSectionHeaders === undefined
139
+ ? {}
140
+ : {
141
+ configuration: {
142
+ sections: {
143
+ enableHeader: enableSectionHeaders,
144
+ },
145
+ },
146
+ }),
147
+ };
148
+ }
149
+ function yamlSectionToDeclarative(entities, yamlSection, enableSectionHeaders) {
150
+ return {
151
+ type: "IDashboardLayoutSection",
152
+ ...(yamlSection.title || yamlSection.description
153
+ ? {
154
+ header: {
155
+ title: yamlSection.title ?? "",
156
+ description: yamlSection.description ?? "",
157
+ },
158
+ }
159
+ : {}),
160
+ items: yamlSection.widgets
161
+ .map((widget) => yamlWidgetItemToDeclarative(entities, widget, enableSectionHeaders))
162
+ .filter(Boolean),
163
+ };
164
+ }
165
+ export function yamlWidgetItemToDeclarative(entities, input, enableSectionHeaders) {
166
+ const size = yamlSizeToDeclarative(input);
167
+ const widget = yamlWidgetToDeclarative(entities, input, enableSectionHeaders ?? true);
168
+ if (!widget) {
169
+ return null;
170
+ }
171
+ return {
172
+ type: "IDashboardLayoutItem",
173
+ size,
174
+ widget,
175
+ };
176
+ }
177
+ function yamlSizeToDeclarative(input) {
178
+ return {
179
+ xl: {
180
+ gridWidth: input.columns ?? 12,
181
+ gridHeight: input.rows ?? 22,
182
+ },
183
+ };
184
+ }
185
+ function yamlInsightWidgetToDeclarative(entities, input) {
186
+ return {
187
+ ...(input.id ? { localIdentifier: input.id } : {}),
188
+ type: "insight",
189
+ insight: createIdentifier(input.visualization, { forceType: "visualizationObject" }),
190
+ title: input.title || "",
191
+ description: useInherit(input.description),
192
+ configuration: {
193
+ hideTitle: input.title === false,
194
+ description: {
195
+ includeMetrics: false,
196
+ source: input.description === "inherit" || input.description === undefined ? "insight" : "widget",
197
+ visible: input.description !== false,
198
+ },
199
+ },
200
+ ignoreDashboardFilters: (input.ignored_filters ?? [])
201
+ .map((filterId) => yamlIgnoredFilterToDeclarative(filterId))
202
+ .filter(Boolean),
203
+ ...(input.date
204
+ ? {
205
+ dateDataSet: createIdentifier(input.date, { forceType: "dataset" }),
206
+ }
207
+ : {}),
208
+ properties: yamlWidgetPropertiesToDeclarative(input),
209
+ drills: (input.interactions ?? [])
210
+ .map((interaction) => yamlInteractionToDeclarative(entities, input.visualization, interaction))
211
+ .filter(Boolean),
212
+ ignoredDrillDownHierarchies: (input.ignored_drill_downs ?? [])
213
+ .map((hierarchy) => yamlIgnoredDrillDownToDeclarative(entities, input.visualization, hierarchy))
214
+ .filter(Boolean),
215
+ drillDownIntersectionIgnoredAttributes: (input.ignored_drill_downs_intersections ?? [])
216
+ .map((intersection) => yamlIgnoredDrillDownsIntersectionsToDeclarative(entities, input.visualization, intersection))
217
+ .filter(Boolean),
218
+ ...(input.ignored_cross_filtering ? { ignoreCrossFiltering: true } : {}),
219
+ };
220
+ }
221
+ export function yamlWidgetToDeclarative(entities, input, enableSectionHeaders) {
222
+ if (isContainerWidget(input)) {
223
+ return {
224
+ ...(input.container ? { localIdentifier: input.container } : {}),
225
+ type: "IDashboardLayout",
226
+ sections: input.sections.map((section) => ({
227
+ type: "IDashboardLayoutSection",
228
+ header: {
229
+ ...(enableSectionHeaders && section.title ? { title: section.title } : {}),
230
+ ...(enableSectionHeaders && section.description
231
+ ? { description: section.description }
232
+ : {}),
233
+ },
234
+ items: section.widgets
235
+ .map((widget) => yamlWidgetItemToDeclarative(entities, widget, enableSectionHeaders))
236
+ .filter(Boolean),
237
+ })),
238
+ configuration: {
239
+ sections: {
240
+ enableHeader: input.enable_section_headers === undefined
241
+ ? !!input.sections.some((s) => s.title || s.description)
242
+ : input.enable_section_headers,
243
+ },
244
+ ...(input.layout_direction ? { direction: input.layout_direction } : {}),
245
+ },
246
+ };
247
+ }
248
+ if (isVisualizationSwitcherWidget(input)) {
249
+ const visualizations = input.visualizations
250
+ .map((vis) => yamlInsightWidgetToDeclarative(entities, vis))
251
+ .filter((vis) => vis !== null && vis !== undefined);
252
+ return {
253
+ ...(input.id ? { localIdentifier: input.id } : {}),
254
+ type: "visualizationSwitcher",
255
+ visualizations,
256
+ description: "",
257
+ title: "",
258
+ drills: [],
259
+ ignoreDashboardFilters: [],
260
+ };
261
+ }
262
+ if (isRichTextWidget(input)) {
263
+ return {
264
+ ...(input.id ? { localIdentifier: input.id } : {}),
265
+ type: "richText",
266
+ content: input.content,
267
+ description: "",
268
+ title: "",
269
+ drills: [],
270
+ ignoreDashboardFilters: [],
271
+ };
272
+ }
273
+ if (isInsightWidget(input)) {
274
+ return yamlInsightWidgetToDeclarative(entities, input);
275
+ }
276
+ return undefined;
277
+ }
278
+ function yamlIgnoredDrillDownToDeclarative(entities, visualization, hierarchy) {
279
+ const target = entities
280
+ .filter((e) => VisualisationsTypes.includes(e.type))
281
+ .find((e) => e.id === visualization)?.data;
282
+ if (!target) {
283
+ return null;
284
+ }
285
+ if (hierarchy.hierarchy) {
286
+ return {
287
+ type: "attributeHierarchyReference",
288
+ attributeHierarchy: hierarchy.hierarchy,
289
+ attribute: createIdentifier(hierarchy.on),
290
+ };
291
+ }
292
+ if (hierarchy.template) {
293
+ return {
294
+ type: "dateHierarchyReference",
295
+ dateHierarchyTemplate: hierarchy.template,
296
+ dateDatasetAttribute: createIdentifier(hierarchy.on),
297
+ };
298
+ }
299
+ return null;
300
+ }
301
+ function yamlIgnoredDrillDownsIntersectionsToDeclarative(entities, visualization, intersection) {
302
+ if (!intersection.attributes || intersection.attributes.length === 0) {
303
+ return null;
304
+ }
305
+ const drillDownReference = yamlIgnoredDrillDownToDeclarative(entities, visualization, intersection.hierarchy);
306
+ if (!drillDownReference) {
307
+ return null;
308
+ }
309
+ return {
310
+ ignoredAttributes: intersection.attributes.map((attribute) => attribute),
311
+ drillDownReference,
312
+ };
313
+ }
314
+ function yamlWidgetPropertiesToDeclarative(input) {
315
+ const controls = {};
316
+ if (input.zoom_data) {
317
+ controls.zoomInsight = true;
318
+ }
319
+ if (Object.keys(controls).length > 0) {
320
+ return {
321
+ controls,
322
+ };
323
+ }
324
+ return {};
325
+ }
326
+ export function yamlInteractionToDeclarative(entities, visualisation, input) {
327
+ const target = entities
328
+ .filter((e) => VisualisationsTypes.includes(e.type))
329
+ .find((e) => e.id === visualisation)?.data;
330
+ if (!target) {
331
+ return null;
332
+ }
333
+ const field = target.query.fields[input.click_on] ?? null;
334
+ if (!field) {
335
+ return null;
336
+ }
337
+ const origin = isAttributeField(getFullField(field))
338
+ ? {
339
+ type: "drillFromAttribute",
340
+ attribute: createLocalIdentifier(input.click_on),
341
+ }
342
+ : {
343
+ type: "drillFromMeasure",
344
+ measure: createLocalIdentifier(input.click_on),
345
+ };
346
+ const interactionFilters = yamlInteractionFiltersToDeclarative(input, target.query?.filter_by);
347
+ const ignoredAttrs = input.ignored_intersection_attributes?.length
348
+ ? { drillIntersectionIgnoredAttributes: input.ignored_intersection_attributes }
349
+ : {};
350
+ if (input.open_visualization) {
351
+ const target = createIdentifier((input.open_visualization ?? ""), {
352
+ forceType: "visualizationObject",
353
+ });
354
+ return {
355
+ type: "drillToInsight",
356
+ transition: "pop-up",
357
+ target,
358
+ origin,
359
+ ...interactionFilters.ignoredAttrs,
360
+ ...interactionFilters.ignoredDashboardFilters,
361
+ ...interactionFilters.includedSourceInsight,
362
+ ...interactionFilters.includedSourceMeasure,
363
+ };
364
+ }
365
+ if (input.open_dashboard) {
366
+ const target = createIdentifier((input.open_dashboard ?? ""), {
367
+ forceType: "analyticalDashboard",
368
+ });
369
+ return {
370
+ type: "drillToDashboard",
371
+ transition: "in-place",
372
+ target,
373
+ origin,
374
+ ...(input.open_dashboard_tab ? { targetTabLocalIdentifier: input.open_dashboard_tab } : {}),
375
+ ...interactionFilters.ignoredAttrs,
376
+ ...interactionFilters.ignoredDashboardFilters,
377
+ ...interactionFilters.includedSourceInsight,
378
+ ...interactionFilters.includedSourceMeasure,
379
+ };
380
+ }
381
+ if (input.open_url && typeof input.open_url === "string") {
382
+ const url = parseUrlTarget(input.open_url);
383
+ return {
384
+ type: "drillToCustomUrl",
385
+ transition: "new-window",
386
+ target: {
387
+ url,
388
+ },
389
+ origin,
390
+ ...ignoredAttrs,
391
+ };
392
+ }
393
+ if (input.open_url && typeof input.open_url === "object") {
394
+ const url = input.open_url;
395
+ const displayForm = createIdentifier((url["label"] ?? ""));
396
+ const hyperlinkDisplayForm = createIdentifier((url["href"] ?? ""));
397
+ return {
398
+ type: "drillToAttributeUrl",
399
+ transition: "new-window",
400
+ target: {
401
+ displayForm,
402
+ hyperlinkDisplayForm,
403
+ },
404
+ origin,
405
+ ...ignoredAttrs,
406
+ };
407
+ }
408
+ return null;
409
+ }
410
+ function yamlInteractionFiltersToDeclarative(input, sourceVisualizationFilters) {
411
+ const interaction = input;
412
+ const excluded = interaction.filters?.exclude;
413
+ const included = interaction.filters?.include;
414
+ const ignoredAttrs = (excluded?.drilled_datapoint ?? interaction.ignored_intersection_attributes)?.length
415
+ ? {
416
+ drillIntersectionIgnoredAttributes: (excluded?.drilled_datapoint ??
417
+ interaction.ignored_intersection_attributes),
418
+ }
419
+ : {};
420
+ const ignoredDashboardFilters = (excluded?.dashboard_filters ?? interaction.ignored_dashboard_filters)
421
+ ?.length
422
+ ? {
423
+ ignoredDashboardFilters: (excluded?.dashboard_filters ??
424
+ interaction.ignored_dashboard_filters),
425
+ }
426
+ : {};
427
+ const includedSourceInsight = included?.visualization_filters ?? interaction.included_source_insight_filters;
428
+ const includedSourceMeasure = included?.metric_filters ?? interaction.included_source_measure_filters;
429
+ return {
430
+ ignoredAttrs,
431
+ ignoredDashboardFilters,
432
+ includedSourceInsight: includedSourceInsight
433
+ ? {
434
+ includedSourceInsightFiltersObjRefs: yamlSourceFiltersToDeclarative(includedSourceInsight, sourceVisualizationFilters),
435
+ }
436
+ : {},
437
+ includedSourceMeasure: includedSourceMeasure
438
+ ? {
439
+ includedSourceMeasureFiltersObjRefs: yamlSourceFiltersToDeclarative(includedSourceMeasure, sourceVisualizationFilters),
440
+ }
441
+ : {},
442
+ };
443
+ }
444
+ function yamlSourceFiltersToDeclarative(input, sourceVisualizationFilters) {
445
+ return input
446
+ .map((filterId) => sourceInsightFilterIdToDeclarative(filterId, sourceVisualizationFilters))
447
+ .filter(Boolean);
448
+ }
449
+ function sourceInsightFilterIdToDeclarative(filterId, sourceVisualizationFilters) {
450
+ const filter = sourceVisualizationFilters?.[filterId];
451
+ if (!filter) {
452
+ return null;
453
+ }
454
+ if (isAttributeFilter(filter)) {
455
+ return {
456
+ type: "attributeFilter",
457
+ label: createIdentifier(filter.using),
458
+ };
459
+ }
460
+ if (isAbsoluteDateFilter(filter) || isRelativeDateFilter(filter)) {
461
+ return {
462
+ type: "dateFilter",
463
+ dataSet: createIdentifier(filter.using, { forceType: "dataset" }),
464
+ };
465
+ }
466
+ if (isMetricValueFilter(filter)) {
467
+ return {
468
+ type: "measureValueFilter",
469
+ measure: createIdentifier(filter.using, { forceMetric: true }) ??
470
+ createLocalIdentifier(filter.using),
471
+ };
472
+ }
473
+ if (isRankingFilter(filter)) {
474
+ return {
475
+ type: "rankingFilter",
476
+ measure: createIdentifier(filter.using, { forceMetric: true }) ??
477
+ createLocalIdentifier(filter.using),
478
+ };
479
+ }
480
+ return null;
481
+ }
482
+ function yamlIgnoredFilterToDeclarative(input) {
483
+ const ref = parseReferenceObject(input);
484
+ if (ref?.type === "label") {
485
+ return {
486
+ type: "attributeFilterReference",
487
+ displayForm: createIdentifier(input),
488
+ };
489
+ }
490
+ if (ref?.type === "dataset") {
491
+ return {
492
+ type: "dateFilterReference",
493
+ dataSet: createIdentifier(input),
494
+ };
495
+ }
496
+ return null;
497
+ }
498
+ export function yamlPluginsToDeclarative(plugins) {
499
+ return plugins?.map((plugin) => yamlPluginToDeclarative(plugin));
500
+ }
501
+ function yamlPluginToDeclarative(input) {
502
+ if (typeof input === "string") {
503
+ return {
504
+ type: "IDashboardPluginLink",
505
+ plugin: createIdentifier(input, { forceType: "dashboardPlugin" }),
506
+ };
507
+ }
508
+ return {
509
+ type: "IDashboardPluginLink",
510
+ plugin: createIdentifier(input.id, { forceType: "dashboardPlugin" }),
511
+ parameters: serialiseParameters(input.parameters ?? ""),
512
+ };
513
+ }
514
+ function isFilterGroup(filter) {
515
+ return (typeof filter === "object" &&
516
+ filter !== null &&
517
+ "type" in filter &&
518
+ filter.type === "filter_group" &&
519
+ "filters" in filter);
520
+ }
521
+ function flattenFilters(yamlFilters) {
522
+ if (!yamlFilters) {
523
+ return {};
524
+ }
525
+ const result = {};
526
+ for (const [key, filter] of Object.entries(yamlFilters)) {
527
+ if (isFilterGroup(filter)) {
528
+ // Flatten nested filters from the group
529
+ const nestedFlat = flattenFilters(filter.filters);
530
+ Object.assign(result, nestedFlat);
531
+ }
532
+ else {
533
+ result[key] = filter;
534
+ }
535
+ }
536
+ return result;
537
+ }
538
+ export function yamlFilterContextToDeclarative(baseId, yamlFilters) {
539
+ const dateFilterConfig = {};
540
+ const dateFilterConfigs = [];
541
+ const attributeFilterConfigs = [];
542
+ // Extract filter groups configuration
543
+ const filterGroupsConfig = extractFilterGroupsConfig(yamlFilters);
544
+ // Flatten filter groups to get individual filters
545
+ const flatFilters = flattenFilters(yamlFilters);
546
+ const allFilters = Object.entries(flatFilters);
547
+ const attributeFilters = allFilters.filter(([, filter]) => isDashboardAttributeFilter(filter));
548
+ const dateFilters = allFilters.filter(([, filter]) => isDashboardAbsoluteDateFilter(filter) ||
549
+ isDashboardRelativeDateFilter(filter) ||
550
+ isDashboardEmptyDateFilter(filter));
551
+ const filters = Object.keys(flatFilters)
552
+ .map((key) => {
553
+ const filter = flatFilters[key];
554
+ const isAbsoluteDateFilter = isDashboardAbsoluteDateFilter(filter);
555
+ const isRelativeDateFilter = isDashboardRelativeDateFilter(filter);
556
+ if (isAbsoluteDateFilter || isRelativeDateFilter) {
557
+ const emptyValueHandling = extractDashboardEmptyValueHandling(filter);
558
+ //others date filters
559
+ if (filter["date"]) {
560
+ const dateFilterConf = {
561
+ dateDataSet: createIdentifier(filter["date"], {
562
+ forceType: "dataset",
563
+ }),
564
+ config: fillDateFilterConfig(filter),
565
+ };
566
+ dateFilterConfigs.push(dateFilterConf);
567
+ //common date filter
568
+ }
569
+ else {
570
+ fillDateFilterConfig(filter, dateFilterConfig);
571
+ //special case when common filter is empty, do not add it to filter context, but keep settings
572
+ if (isDashboardNoopDateFilter(filter)) {
573
+ return null;
574
+ }
575
+ }
576
+ return {
577
+ dateFilter: {
578
+ localIdentifier: key,
579
+ type: isAbsoluteDateFilter ? "absolute" : "relative",
580
+ granularity: convertGranularity(filter["granularity"] ?? "DAY"),
581
+ ...(filter["from"] === undefined ? {} : { from: filter["from"] }),
582
+ ...(filter["to"] === undefined ? {} : { to: filter["to"] }),
583
+ ...(filter["date"]
584
+ ? {
585
+ dataSet: createIdentifier(filter["date"], {
586
+ forceType: "dataset",
587
+ }),
588
+ }
589
+ : {}),
590
+ ...(emptyValueHandling ? { emptyValueHandling } : {}),
591
+ //attribute
592
+ },
593
+ };
594
+ }
595
+ if (isDashboardAttributeFilter(filter)) {
596
+ const state = filter.state;
597
+ const attributeFilterConfig = {};
598
+ if (filter.mode && filter.mode !== "active") {
599
+ attributeFilterConfig.mode = filter.mode;
600
+ }
601
+ if (filter.display_as) {
602
+ attributeFilterConfig.displayAsLabel = createIdentifier(filter.display_as, {
603
+ forceType: "label",
604
+ });
605
+ }
606
+ if ((filter.mode && filter.mode !== "active") || filter.display_as) {
607
+ attributeFilterConfig.localIdentifier = key;
608
+ attributeFilterConfigs.push(attributeFilterConfig);
609
+ }
610
+ const attributeParents = filter.parents?.filter((parent) => {
611
+ const item = normalizeLocalDateFilter(parent);
612
+ return attributeFilters.some(([key]) => key === item.using);
613
+ });
614
+ const dateParents = filter.parents?.filter((parent) => {
615
+ const item = normalizeLocalDateFilter(parent);
616
+ return dateFilters.some(([key]) => key === item.using);
617
+ });
618
+ return {
619
+ attributeFilter: {
620
+ displayForm: createIdentifier(filter.using ?? ""),
621
+ negativeSelection: !state?.include,
622
+ attributeElements: {
623
+ uris: (state && (state.exclude ?? state.include)) ?? [],
624
+ },
625
+ localIdentifier: key,
626
+ ...(attributeParents && attributeParents.length > 0
627
+ ? {
628
+ filterElementsBy: attributeParents.map((parent) => {
629
+ return {
630
+ filterLocalIdentifier: parent,
631
+ over: {
632
+ attributes: [],
633
+ },
634
+ };
635
+ }),
636
+ }
637
+ : {}),
638
+ ...(dateParents && dateParents.length > 0
639
+ ? {
640
+ filterElementsByDate: dateParents.map((parent) => {
641
+ const item = normalizeLocalDateFilter(parent);
642
+ return {
643
+ filterLocalIdentifier: item.using,
644
+ isCommonDate: item.common,
645
+ };
646
+ }),
647
+ }
648
+ : {}),
649
+ ...(filter.metric_filters
650
+ ? {
651
+ validateElementsBy: filter.metric_filters.map((metricFilter) => createIdentifier(metricFilter)),
652
+ }
653
+ : {}),
654
+ title: filter.title,
655
+ selectionMode: filter.multiselect === false ? "single" : "multi",
656
+ },
657
+ };
658
+ }
659
+ return null;
660
+ })
661
+ .filter(Boolean);
662
+ return {
663
+ dateFilterConfig: Object.keys(dateFilterConfig).length > 0
664
+ ? { filterName: "", ...dateFilterConfig }
665
+ : undefined,
666
+ attributeFilterConfigs: attributeFilterConfigs.length > 0 ? attributeFilterConfigs : undefined,
667
+ dateFilterConfigs: dateFilterConfigs.length > 0 ? dateFilterConfigs : undefined,
668
+ filterGroupsConfig,
669
+ filterContext: {
670
+ id: createFilterContextId(baseId),
671
+ title: "",
672
+ content: {
673
+ version: "2",
674
+ filters,
675
+ },
676
+ },
677
+ };
678
+ }
679
+ function extractFilterGroupsConfig(yamlFilters) {
680
+ if (!yamlFilters) {
681
+ return undefined;
682
+ }
683
+ const groups = [];
684
+ for (const [groupId, filter] of Object.entries(yamlFilters)) {
685
+ if (isFilterGroup(filter)) {
686
+ const nestedFilters = filter.filters;
687
+ const filterLocalIdentifiers = nestedFilters ? Object.keys(nestedFilters) : [];
688
+ groups.push({
689
+ title: filter.title,
690
+ localIdentifier: groupId,
691
+ filters: filterLocalIdentifiers.map((filterLocalIdentifier) => ({
692
+ filterLocalIdentifier,
693
+ })),
694
+ });
695
+ }
696
+ }
697
+ return groups.length > 0 ? { groups } : undefined;
698
+ }
699
+ function fillDateFilterConfig(filter, config) {
700
+ const current = config ?? {
701
+ mode: "active",
702
+ filterName: "",
703
+ };
704
+ if (filter.mode && filter.mode !== "active") {
705
+ current.mode = filter.mode;
706
+ }
707
+ if (filter.title) {
708
+ current.filterName = filter.title;
709
+ }
710
+ return current;
711
+ }
712
+ function useInherit(input) {
713
+ return input && input !== "inherit" ? input : "";
714
+ }
715
+ function serialiseParameters(params) {
716
+ try {
717
+ return JSON.stringify(params);
718
+ }
719
+ catch {
720
+ return params;
721
+ }
722
+ }
723
+ function normalizeLocalDateFilter(item) {
724
+ if (typeof item === "object") {
725
+ return item;
726
+ }
727
+ return {
728
+ using: item,
729
+ common: true,
730
+ };
731
+ }
732
+ //# sourceMappingURL=yamlDashboardToDeclarative.js.map