@hpcc-js/ddl-shim 2.18.1 → 2.20.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.
package/dist/cli.js CHANGED
@@ -1608,7 +1608,7 @@ var ddl2Schema = /*#__PURE__*/Object.freeze({
1608
1608
  'default': v2
1609
1609
  });
1610
1610
 
1611
- /*! *****************************************************************************
1611
+ /******************************************************************************
1612
1612
  Copyright (c) Microsoft Corporation.
1613
1613
 
1614
1614
  Permission to use, copy, modify, and/or distribute this software for any
@@ -1644,1007 +1644,1007 @@ function __spreadArray(to, from, pack) {
1644
1644
  return to.concat(ar || Array.prototype.slice.call(from));
1645
1645
  }
1646
1646
 
1647
- var PKG_NAME = "@hpcc-js/ddl-shim";
1648
- var PKG_VERSION = "2.18.1";
1647
+ var PKG_NAME = "@hpcc-js/ddl-shim";
1648
+ var PKG_VERSION = "2.20.0";
1649
1649
 
1650
- function isWorkunitDatasource(ref) {
1651
- return ref.WUID !== undefined;
1652
- }
1653
- function isDatabombDatasource(ref) {
1654
- return ref.databomb === true;
1655
- }
1656
- function isHipieDatasource(ref) {
1657
- return ref.URL !== undefined;
1658
- }
1659
- function isPieVisualization(viz) {
1660
- return viz.type === "PIE" || viz.type === "BAR";
1661
- }
1662
- function isLineVisualization(viz) {
1663
- return viz.type === "LINE";
1664
- }
1665
- function isChoroVisualization(viz) {
1666
- return viz.type === "CHORO";
1667
- }
1668
- function isTableVisualization(viz) {
1669
- return viz.type === "TABLE";
1670
- }
1671
- function isSliderVisualization(viz) {
1672
- return viz.type === "SLIDER";
1673
- }
1674
- function isGraphVisualization(viz) {
1675
- return viz.type === "GRAPH";
1676
- }
1677
- function isFormVisualization(viz) {
1678
- return viz.type === "FORM";
1650
+ function isWorkunitDatasource(ref) {
1651
+ return ref.WUID !== undefined;
1652
+ }
1653
+ function isDatabombDatasource(ref) {
1654
+ return ref.databomb === true;
1655
+ }
1656
+ function isHipieDatasource(ref) {
1657
+ return ref.URL !== undefined;
1658
+ }
1659
+ function isPieVisualization(viz) {
1660
+ return viz.type === "PIE" || viz.type === "BAR";
1661
+ }
1662
+ function isLineVisualization(viz) {
1663
+ return viz.type === "LINE";
1664
+ }
1665
+ function isChoroVisualization(viz) {
1666
+ return viz.type === "CHORO";
1667
+ }
1668
+ function isTableVisualization(viz) {
1669
+ return viz.type === "TABLE";
1670
+ }
1671
+ function isSliderVisualization(viz) {
1672
+ return viz.type === "SLIDER";
1673
+ }
1674
+ function isGraphVisualization(viz) {
1675
+ return viz.type === "GRAPH";
1676
+ }
1677
+ function isFormVisualization(viz) {
1678
+ return viz.type === "FORM";
1679
1679
  }
1680
1680
 
1681
- function isRoxieServiceRef(ref) {
1682
- return ref.request !== undefined;
1681
+ function isRoxieServiceRef(ref) {
1682
+ return ref.request !== undefined;
1683
1683
  }
1684
1684
 
1685
- var classMappings = {
1686
- c3chart_Bar: "chart_Bar",
1687
- c3chart_Column: "chart_Column",
1688
- c3chart_Pie: "chart_Pie",
1689
- c3chart_Area: "chart_Area",
1690
- c3chart_Line: "chart_Line",
1691
- amchart_Bar: "chart_Bar",
1692
- amchart_Column: "chart_Column",
1693
- amchart_Pie: "chart_Pie",
1694
- amchart_Area: "chart_Area",
1695
- amchart_Line: "chart_Line",
1696
- google_Bar: "chart_Bar",
1697
- google_Column: "chart_Column",
1698
- google_Pie: "chart_Pie",
1699
- google_Area: "chart_Area",
1700
- google_Line: "chart_Line",
1701
- other_Table: "dgrid_Table"
1702
- };
1703
- var propertyMappings = {
1704
- xAxisLabelRotation: [
1705
- { name: "xAxisOverlapMode", transform: function (n) { return "rotate"; } },
1706
- { name: "xAxisLabelRotation", transform: function (n) { return n; } }
1707
- ],
1708
- tooltipLabelColor: {
1709
- name: "tooltipLabelColor"
1710
- },
1711
- tooltipSeriesColor: {
1712
- name: "tooltipSeriesColor"
1713
- },
1714
- tooltipValueColor: {
1715
- name: "tooltipValueColor"
1716
- },
1717
- tooltipValueFormat: {
1718
- name: "tooltipValueFormat"
1719
- },
1720
- timePattern: {
1721
- name: "xAxisTypeTimePattern"
1722
- },
1723
- smoothLines: {
1724
- name: "interpolate",
1725
- transform: function (n) {
1726
- if (n === false)
1727
- return "linear";
1728
- return "catmullRom";
1729
- }
1730
- },
1731
- holePercent: {
1732
- name: "innerRadius"
1733
- },
1734
- flip: {
1735
- name: "orientation",
1736
- transform: function (n) { return n ? "vertical" : "horizontal"; }
1737
- },
1738
- bottomText: {
1739
- name: "xAxisTitle"
1740
- },
1741
- xAxisTypeTimePattern: {
1742
- name: "xAxisTypeTimePattern"
1743
- },
1744
- yAxisTypeTimePattern: {
1745
- name: "yAxisTypeTimePattern"
1746
- },
1747
- valueFormat: {
1748
- name: "tooltipValueFormat"
1749
- },
1750
- stacked: {
1751
- name: "yAxisStacked"
1752
- },
1753
- showYGrid: {
1754
- name: "yAxisGuideLines"
1755
- },
1756
- showXGrid: {
1757
- name: "xAxisGuideLines"
1758
- },
1759
- showValueLabel: {
1760
- name: "showValue"
1761
- },
1762
- low: {
1763
- name: "yAxisDomainLow"
1764
- },
1765
- high: {
1766
- name: "yAxisDomainHigh"
1767
- },
1768
- fillOpacity: {
1769
- name: "interpolateFillOpacity"
1770
- },
1771
- areaFillOpacity: {
1772
- name: "interpolateFillOpacity"
1773
- },
1774
- showToolbar: {
1775
- name: "titleVisible"
1776
- },
1777
- showCSV: {
1778
- name: "downloadButtonVisible"
1779
- }
1780
- };
1781
- function findKeyVal(object, key, val) {
1782
- var value;
1783
- for (var k in object) {
1784
- if (k === key && object[k] === val) {
1785
- value = object;
1786
- break;
1787
- }
1788
- if (object[k] && typeof object[k] === "object") {
1789
- value = findKeyVal(object[k], key, val);
1790
- if (value !== undefined) {
1791
- break;
1792
- }
1793
- }
1794
- }
1795
- return value;
1796
- }
1797
- function apply_to_dataviews(ddl2, dermObj) {
1798
- ddl2.dataviews.forEach(apply_to_dataview);
1799
- function apply_to_dataview(dv) {
1800
- var widgetId = dv.id;
1801
- var dermPanelObj = findKeyVal(dermObj, "__id", widgetId);
1802
- if (dermPanelObj) {
1803
- var dermPanelProps = dermPanelObj.__properties;
1804
- var dermWidgetObj = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
1805
- var dermWidgetProps = dermWidgetObj.__properties;
1806
- apply_class_mapping(dermWidgetObj);
1807
- apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
1808
- apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
1809
- if (dv.visualization.properties.chartType) {
1810
- dv.visualization.properties.charttype = dv.visualization.properties.chartType;
1811
- }
1812
- }
1813
- else {
1814
- console.warn(widgetId + " not found in dermObj");
1815
- }
1816
- function apply_class_mapping(dermWidgetObj) {
1817
- dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
1818
- dv.visualization.properties.__class = "marshaller_VizChartPanel";
1819
- if (!dv.visualization.properties.widget)
1820
- dv.visualization.properties.widget = {};
1821
- dv.visualization.properties.widget.__class = dv.visualization.__class;
1822
- function swap_with_supported_class(_class) {
1823
- return classMappings[_class] ? classMappings[_class] : _class;
1824
- }
1825
- }
1826
- function apply_panel_property_mapping(dermPanelProps, dermWidgetProps) {
1827
- dv.visualization.title = dermPanelProps.title || "";
1828
- dv.visualization.description = "";
1829
- dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
1830
- dv.visualization.chartType = dv.visualization.__class.split("_")[1];
1831
- for (var propName in dermPanelProps) {
1832
- if (typeof propertyMappings[propName] !== "undefined") {
1833
- var newPropName = propertyMappings[propName].name;
1834
- if (typeof propertyMappings[propName].transform === "function") {
1835
- dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
1836
- }
1837
- else {
1838
- dv.visualization.properties[newPropName] = dermPanelProps[propName];
1839
- }
1840
- }
1841
- }
1842
- if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
1843
- dv.visualization.properties.legendVisible = true;
1844
- }
1845
- }
1846
- function apply_widget_property_mapping(dermPanelProps, dermWidgetProps) {
1847
- dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
1848
- dv.visualization.description = ""; // TODO - should this map to anything?
1849
- dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
1850
- dv.visualization.chartType = dv.visualization.__class.split("_")[1];
1851
- var _loop_1 = function (propName) {
1852
- if (typeof propertyMappings[propName] !== "undefined") {
1853
- if (propertyMappings[propName] instanceof Array) {
1854
- propertyMappings[propName].forEach(function (p) {
1855
- var newPropName = p.name;
1856
- dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
1857
- if (typeof propertyMappings[propName].transform === "function") {
1858
- dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
1859
- }
1860
- else {
1861
- dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
1862
- }
1863
- });
1864
- }
1865
- else {
1866
- var newPropName = propertyMappings[propName].name;
1867
- dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
1868
- }
1869
- }
1870
- };
1871
- for (var propName in dermWidgetProps) {
1872
- _loop_1(propName);
1873
- }
1874
- }
1875
- }
1876
- }
1877
- function apply_to_properties_layout(ddl2, dermObj) {
1878
- var retVal = {
1879
- layout: []
1880
- };
1881
- if (!dermObj || !dermObj.__properties)
1882
- return;
1883
- dermObj.__properties.content.forEach(function (cell) {
1884
- var cellPosition = {
1885
- // TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
1886
- id: cell.__properties.widget.__id,
1887
- position: [
1888
- cell.__properties.gridCol,
1889
- cell.__properties.gridRow,
1890
- cell.__properties.gridColSpan,
1891
- cell.__properties.gridRowSpan
1892
- ]
1893
- };
1894
- retVal.layout.push(cellPosition);
1895
- });
1896
- return retVal;
1897
- }
1898
- function upgrade$1(ddl2, dermObj) {
1899
- apply_to_dataviews(ddl2, dermObj);
1900
- return apply_to_properties_layout(ddl2, dermObj);
1685
+ var classMappings = {
1686
+ c3chart_Bar: "chart_Bar",
1687
+ c3chart_Column: "chart_Column",
1688
+ c3chart_Pie: "chart_Pie",
1689
+ c3chart_Area: "chart_Area",
1690
+ c3chart_Line: "chart_Line",
1691
+ amchart_Bar: "chart_Bar",
1692
+ amchart_Column: "chart_Column",
1693
+ amchart_Pie: "chart_Pie",
1694
+ amchart_Area: "chart_Area",
1695
+ amchart_Line: "chart_Line",
1696
+ google_Bar: "chart_Bar",
1697
+ google_Column: "chart_Column",
1698
+ google_Pie: "chart_Pie",
1699
+ google_Area: "chart_Area",
1700
+ google_Line: "chart_Line",
1701
+ other_Table: "dgrid_Table"
1702
+ };
1703
+ var propertyMappings = {
1704
+ xAxisLabelRotation: [
1705
+ { name: "xAxisOverlapMode", transform: function (n) { return "rotate"; } },
1706
+ { name: "xAxisLabelRotation", transform: function (n) { return n; } }
1707
+ ],
1708
+ tooltipLabelColor: {
1709
+ name: "tooltipLabelColor"
1710
+ },
1711
+ tooltipSeriesColor: {
1712
+ name: "tooltipSeriesColor"
1713
+ },
1714
+ tooltipValueColor: {
1715
+ name: "tooltipValueColor"
1716
+ },
1717
+ tooltipValueFormat: {
1718
+ name: "tooltipValueFormat"
1719
+ },
1720
+ timePattern: {
1721
+ name: "xAxisTypeTimePattern"
1722
+ },
1723
+ smoothLines: {
1724
+ name: "interpolate",
1725
+ transform: function (n) {
1726
+ if (n === false)
1727
+ return "linear";
1728
+ return "catmullRom";
1729
+ }
1730
+ },
1731
+ holePercent: {
1732
+ name: "innerRadius"
1733
+ },
1734
+ flip: {
1735
+ name: "orientation",
1736
+ transform: function (n) { return n ? "vertical" : "horizontal"; }
1737
+ },
1738
+ bottomText: {
1739
+ name: "xAxisTitle"
1740
+ },
1741
+ xAxisTypeTimePattern: {
1742
+ name: "xAxisTypeTimePattern"
1743
+ },
1744
+ yAxisTypeTimePattern: {
1745
+ name: "yAxisTypeTimePattern"
1746
+ },
1747
+ valueFormat: {
1748
+ name: "tooltipValueFormat"
1749
+ },
1750
+ stacked: {
1751
+ name: "yAxisStacked"
1752
+ },
1753
+ showYGrid: {
1754
+ name: "yAxisGuideLines"
1755
+ },
1756
+ showXGrid: {
1757
+ name: "xAxisGuideLines"
1758
+ },
1759
+ showValueLabel: {
1760
+ name: "showValue"
1761
+ },
1762
+ low: {
1763
+ name: "yAxisDomainLow"
1764
+ },
1765
+ high: {
1766
+ name: "yAxisDomainHigh"
1767
+ },
1768
+ fillOpacity: {
1769
+ name: "interpolateFillOpacity"
1770
+ },
1771
+ areaFillOpacity: {
1772
+ name: "interpolateFillOpacity"
1773
+ },
1774
+ showToolbar: {
1775
+ name: "titleVisible"
1776
+ },
1777
+ showCSV: {
1778
+ name: "downloadButtonVisible"
1779
+ }
1780
+ };
1781
+ function findKeyVal(object, key, val) {
1782
+ var value;
1783
+ for (var k in object) {
1784
+ if (k === key && object[k] === val) {
1785
+ value = object;
1786
+ break;
1787
+ }
1788
+ if (object[k] && typeof object[k] === "object") {
1789
+ value = findKeyVal(object[k], key, val);
1790
+ if (value !== undefined) {
1791
+ break;
1792
+ }
1793
+ }
1794
+ }
1795
+ return value;
1796
+ }
1797
+ function apply_to_dataviews(ddl2, dermObj) {
1798
+ ddl2.dataviews.forEach(apply_to_dataview);
1799
+ function apply_to_dataview(dv) {
1800
+ var widgetId = dv.id;
1801
+ var dermPanelObj = findKeyVal(dermObj, "__id", widgetId);
1802
+ if (dermPanelObj) {
1803
+ var dermPanelProps = dermPanelObj.__properties;
1804
+ var dermWidgetObj = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
1805
+ var dermWidgetProps = dermWidgetObj.__properties;
1806
+ apply_class_mapping(dermWidgetObj);
1807
+ apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
1808
+ apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
1809
+ if (dv.visualization.properties.chartType) {
1810
+ dv.visualization.properties.charttype = dv.visualization.properties.chartType;
1811
+ }
1812
+ }
1813
+ else {
1814
+ console.warn(widgetId + " not found in dermObj");
1815
+ }
1816
+ function apply_class_mapping(dermWidgetObj) {
1817
+ dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
1818
+ dv.visualization.properties.__class = "marshaller_VizChartPanel";
1819
+ if (!dv.visualization.properties.widget)
1820
+ dv.visualization.properties.widget = {};
1821
+ dv.visualization.properties.widget.__class = dv.visualization.__class;
1822
+ function swap_with_supported_class(_class) {
1823
+ return classMappings[_class] ? classMappings[_class] : _class;
1824
+ }
1825
+ }
1826
+ function apply_panel_property_mapping(dermPanelProps, dermWidgetProps) {
1827
+ dv.visualization.title = dermPanelProps.title || "";
1828
+ dv.visualization.description = "";
1829
+ dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
1830
+ dv.visualization.chartType = dv.visualization.__class.split("_")[1];
1831
+ for (var propName in dermPanelProps) {
1832
+ if (typeof propertyMappings[propName] !== "undefined") {
1833
+ var newPropName = propertyMappings[propName].name;
1834
+ if (typeof propertyMappings[propName].transform === "function") {
1835
+ dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
1836
+ }
1837
+ else {
1838
+ dv.visualization.properties[newPropName] = dermPanelProps[propName];
1839
+ }
1840
+ }
1841
+ }
1842
+ if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
1843
+ dv.visualization.properties.legendVisible = true;
1844
+ }
1845
+ }
1846
+ function apply_widget_property_mapping(dermPanelProps, dermWidgetProps) {
1847
+ dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
1848
+ dv.visualization.description = ""; // TODO - should this map to anything?
1849
+ dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
1850
+ dv.visualization.chartType = dv.visualization.__class.split("_")[1];
1851
+ var _loop_1 = function (propName) {
1852
+ if (typeof propertyMappings[propName] !== "undefined") {
1853
+ if (propertyMappings[propName] instanceof Array) {
1854
+ propertyMappings[propName].forEach(function (p) {
1855
+ var newPropName = p.name;
1856
+ dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
1857
+ if (typeof propertyMappings[propName].transform === "function") {
1858
+ dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
1859
+ }
1860
+ else {
1861
+ dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
1862
+ }
1863
+ });
1864
+ }
1865
+ else {
1866
+ var newPropName = propertyMappings[propName].name;
1867
+ dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
1868
+ }
1869
+ }
1870
+ };
1871
+ for (var propName in dermWidgetProps) {
1872
+ _loop_1(propName);
1873
+ }
1874
+ }
1875
+ }
1876
+ }
1877
+ function apply_to_properties_layout(ddl2, dermObj) {
1878
+ var retVal = {
1879
+ layout: []
1880
+ };
1881
+ if (!dermObj || !dermObj.__properties)
1882
+ return;
1883
+ dermObj.__properties.content.forEach(function (cell) {
1884
+ var cellPosition = {
1885
+ // TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
1886
+ id: cell.__properties.widget.__id,
1887
+ position: [
1888
+ cell.__properties.gridCol,
1889
+ cell.__properties.gridRow,
1890
+ cell.__properties.gridColSpan,
1891
+ cell.__properties.gridRowSpan
1892
+ ]
1893
+ };
1894
+ retVal.layout.push(cellPosition);
1895
+ });
1896
+ return retVal;
1897
+ }
1898
+ function upgrade$1(ddl2, dermObj) {
1899
+ apply_to_dataviews(ddl2, dermObj);
1900
+ return apply_to_properties_layout(ddl2, dermObj);
1901
1901
  }
1902
1902
 
1903
- function faCharFix(faChar) {
1904
- return faChar;
1905
- }
1906
- var DDLUpgrade = /** @class */ (function () {
1907
- function DDLUpgrade(ddl, baseUrl, wuid, toLowerCase) {
1908
- if (baseUrl === void 0) { baseUrl = "http://localhost:8010"; }
1909
- if (wuid === void 0) { wuid = "WUID"; }
1910
- if (toLowerCase === void 0) { toLowerCase = true; }
1911
- this._datasources = {};
1912
- this._datasourceUpdates = {};
1913
- this._visualizations = {};
1914
- this._ddl2Datasources = {};
1915
- this._ddl2DatasourceFields = {};
1916
- this._ddl2Dataviews = {};
1917
- this._ddl2DataviewActivities = {};
1918
- this._ddl = ddl;
1919
- this._baseUrl = baseUrl;
1920
- this._wuid = wuid;
1921
- this._toLowerCase = toLowerCase;
1922
- this.indexDDL();
1923
- this.readDDL();
1924
- }
1925
- DDLUpgrade.prototype.toLowerCase = function (s) {
1926
- return this._toLowerCase ? s.toLowerCase() : s;
1927
- };
1928
- DDLUpgrade.prototype.isVizDatasourceRoxie = function (viz) {
1929
- if (viz.source) {
1930
- var ds = this._datasources[viz.source.id];
1931
- if (isHipieDatasource(ds)) {
1932
- return true;
1933
- }
1934
- }
1935
- return false;
1936
- };
1937
- DDLUpgrade.prototype.getDatasourceOutputs = function (dsID, vizID) {
1938
- var retVal = [];
1939
- var datasource = this._datasources[dsID];
1940
- for (var _i = 0, _a = datasource.outputs; _i < _a.length; _i++) {
1941
- var output = _a[_i];
1942
- if (output.notify) {
1943
- for (var _b = 0, _c = output.notify; _b < _c.length; _b++) {
1944
- var notify = _c[_b];
1945
- if (notify === vizID) {
1946
- retVal.push({
1947
- datasource: datasource,
1948
- output: output
1949
- });
1950
- }
1951
- }
1952
- }
1953
- }
1954
- return retVal;
1955
- };
1956
- DDLUpgrade.prototype.getDatasourceFilters = function (dsID, vizID) {
1957
- var retVal = {};
1958
- for (var _i = 0, _a = this.getDatasourceOutputs(dsID, vizID); _i < _a.length; _i++) {
1959
- var dsOut = _a[_i];
1960
- if (dsOut.output.filter) {
1961
- for (var _b = 0, _c = dsOut.output.filter; _b < _c.length; _b++) {
1962
- var filter = _c[_b];
1963
- retVal[filter.fieldid] = {
1964
- datasource: dsOut.datasource,
1965
- output: dsOut.output,
1966
- filter: filter
1967
- };
1968
- }
1969
- }
1970
- }
1971
- return retVal;
1972
- };
1973
- DDLUpgrade.prototype.indexDDL = function () {
1974
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
1975
- var dash = _a[_i];
1976
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
1977
- var viz = _c[_b];
1978
- this._visualizations[viz.id] = viz;
1979
- }
1980
- }
1981
- for (var _d = 0, _e = this._ddl.datasources; _d < _e.length; _d++) {
1982
- var ds = _e[_d];
1983
- this._datasources[ds.id] = ds;
1984
- for (var _f = 0, _g = ds.outputs; _f < _g.length; _f++) {
1985
- var output = _g[_f];
1986
- if (output.notify) {
1987
- for (var _h = 0, _j = output.notify; _h < _j.length; _h++) {
1988
- var notify = _j[_h];
1989
- this._datasourceUpdates[notify] = {
1990
- id: ds.id,
1991
- output: output.from || output.id
1992
- };
1993
- }
1994
- }
1995
- }
1996
- }
1997
- };
1998
- DDLUpgrade.prototype.readDDL = function () {
1999
- for (var _i = 0, _a = this._ddl.datasources; _i < _a.length; _i++) {
2000
- var ds = _a[_i];
2001
- if (isWorkunitDatasource(ds)) {
2002
- var ddl2DS = {
2003
- type: "wuresult",
2004
- id: ds.id,
2005
- url: this._baseUrl,
2006
- wuid: this._wuid,
2007
- outputs: {}
2008
- };
2009
- for (var _b = 0, _c = ds.outputs; _b < _c.length; _b++) {
2010
- var output = _c[_b];
2011
- this.output2output(output, ddl2DS.outputs);
2012
- }
2013
- this._ddl2Datasources[ds.id] = ddl2DS;
2014
- }
2015
- else if (isDatabombDatasource(ds)) ;
2016
- else {
2017
- var urlParts = ds.URL.split("/WsEcl/submit/query/");
2018
- var hostParts = urlParts[0];
2019
- var roxieParts = urlParts[1].split("/");
2020
- var ddl2DS = {
2021
- type: "hipie",
2022
- id: ds.id,
2023
- url: hostParts,
2024
- querySet: roxieParts[0],
2025
- queryID: roxieParts[1],
2026
- inputs: [],
2027
- outputs: {}
2028
- };
2029
- for (var _d = 0, _e = ds.outputs; _d < _e.length; _d++) {
2030
- var output = _e[_d];
2031
- this.output2output(output, ddl2DS.outputs);
2032
- }
2033
- this._ddl2Datasources[ds.id] = ddl2DS;
2034
- }
2035
- }
2036
- for (var _f = 0, _g = this._ddl.dashboards; _f < _g.length; _f++) {
2037
- var dash = _g[_f];
2038
- for (var _h = 0, _j = dash.visualizations; _h < _j.length; _h++) {
2039
- var viz = _j[_h];
2040
- if (viz.type === "FORM") {
2041
- this._ddl2Datasources[viz.id] = {
2042
- type: "form",
2043
- id: viz.id,
2044
- fields: this.formFields2field(viz.fields)
2045
- };
2046
- this._datasourceUpdates[viz.id] = { id: viz.id };
2047
- }
2048
- else if (viz.type === "SLIDER") {
2049
- this._ddl2Datasources[viz.id] = {
2050
- type: "form",
2051
- id: viz.id,
2052
- fields: this.formFields2field(viz.fields, true)
2053
- };
2054
- this._datasourceUpdates[viz.id] = { id: viz.id };
2055
- }
2056
- this._ddl2Dataviews[viz.id] = this.anyViz2view(viz);
2057
- }
2058
- }
2059
- this.readGroupBy();
2060
- this.readFilters();
2061
- this.readSort();
2062
- this.readMappings();
2063
- };
2064
- DDLUpgrade.prototype.readGroupBy = function () {
2065
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2066
- var dash = _a[_i];
2067
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2068
- var viz = _c[_b];
2069
- if (viz.fields) {
2070
- var projectTransformations = [];
2071
- var groupByColumns = [];
2072
- var aggrFields = [];
2073
- for (var _d = 0, _e = viz.fields; _d < _e.length; _d++) {
2074
- var field = _e[_d];
2075
- if (field.properties && field.properties.function) {
2076
- switch (field.properties.function) {
2077
- case "SUM":
2078
- case "MIN":
2079
- case "MAX":
2080
- aggrFields.push({
2081
- type: this.func2aggr(field.properties.function),
2082
- inFieldID: this.toLowerCase(field.properties.params.param1),
2083
- fieldID: this.toLowerCase(field.id)
2084
- });
2085
- break;
2086
- case "AVE":
2087
- aggrFields.push({
2088
- type: this.func2aggr(field.properties.function),
2089
- inFieldID: this.toLowerCase(field.properties.params.param1),
2090
- baseCountFieldID: field.properties.params.param2 ? this.toLowerCase(field.properties.params.param2) : undefined,
2091
- fieldID: this.toLowerCase(field.id)
2092
- });
2093
- break;
2094
- case "SCALE":
2095
- if (typeof field.properties.params.param1 === "object") {
2096
- var props = field.properties.params.param1;
2097
- switch (props.function) {
2098
- case "SUM":
2099
- case "MIN":
2100
- case "MAX":
2101
- aggrFields.push({
2102
- type: this.func2aggr(props.function),
2103
- inFieldID: this.toLowerCase(props.params.param1),
2104
- fieldID: this.toLowerCase(field.id)
2105
- });
2106
- break;
2107
- }
2108
- }
2109
- projectTransformations.push({
2110
- type: "scale",
2111
- sourceFieldID: this.toLowerCase(field.id),
2112
- fieldID: this.toLowerCase(field.id),
2113
- factor: +field.properties.params.param2
2114
- });
2115
- break;
2116
- default:
2117
- groupByColumns.push(this.toLowerCase(field.id));
2118
- throw new Error("Unhandled field function: ".concat(field.properties.function));
2119
- }
2120
- }
2121
- else {
2122
- groupByColumns.push(this.toLowerCase(field.id));
2123
- }
2124
- }
2125
- if (projectTransformations.length) {
2126
- this._ddl2DataviewActivities[viz.id].project.transformations = projectTransformations;
2127
- }
2128
- if (aggrFields.length) {
2129
- this._ddl2DataviewActivities[viz.id].groupBy.groupByIDs = __spreadArray([], groupByColumns, true);
2130
- this._ddl2DataviewActivities[viz.id].groupBy.aggregates = aggrFields;
2131
- }
2132
- }
2133
- }
2134
- }
2135
- };
2136
- DDLUpgrade.prototype.func2aggr = function (func) {
2137
- switch (func) {
2138
- case "SUM":
2139
- return "sum";
2140
- case "AVE":
2141
- return "mean";
2142
- case "MIN":
2143
- return "min";
2144
- case "MAX":
2145
- return "max";
2146
- }
2147
- throw new Error("Unknown DDL1 Function Type: ".concat(func));
2148
- };
2149
- DDLUpgrade.prototype.readMappings = function () {
2150
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2151
- var dash = _a[_i];
2152
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2153
- var viz = _c[_b];
2154
- if (isFormVisualization(viz)) ;
2155
- else if (isPieVisualization(viz)) {
2156
- this.readPieMappings(viz);
2157
- }
2158
- else if (isChoroVisualization(viz)) {
2159
- this.readChoroMappings(viz);
2160
- }
2161
- else if (isLineVisualization(viz)) {
2162
- this.readLineMappings(viz);
2163
- }
2164
- else if (isTableVisualization(viz)) {
2165
- this.readTableMappings(viz);
2166
- }
2167
- else if (isGraphVisualization(viz)) {
2168
- this.readGraphMappings(viz);
2169
- }
2170
- else if (isSliderVisualization(viz)) {
2171
- this.readSliderMappings(viz);
2172
- }
2173
- else {
2174
- throw new Error("Unkown DDL1 mapping type: ".concat(viz.type));
2175
- }
2176
- }
2177
- }
2178
- };
2179
- DDLUpgrade.prototype.readPieMappings = function (viz) {
2180
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2181
- mappings.transformations.push({
2182
- fieldID: "label",
2183
- type: "=",
2184
- sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2185
- });
2186
- mappings.transformations.push({
2187
- fieldID: "weight",
2188
- type: "=",
2189
- sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
2190
- });
2191
- };
2192
- DDLUpgrade.prototype.readChoroMappings = function (viz) {
2193
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2194
- mappings.transformations.push({
2195
- fieldID: "label",
2196
- type: "=",
2197
- sourceFieldID: this.toLowerCase(this.anyChoroMapping2label(viz.source.mappings))
2198
- });
2199
- mappings.transformations.push({
2200
- fieldID: "weight",
2201
- type: "=",
2202
- sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
2203
- });
2204
- };
2205
- DDLUpgrade.prototype.anyChoroMapping2label = function (mapping) {
2206
- return mapping.state || mapping.county || mapping.geohash;
2207
- };
2208
- DDLUpgrade.prototype.readLineMappings = function (viz) {
2209
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2210
- mappings.transformations.push({
2211
- fieldID: viz.source.mappings.x[0],
2212
- type: "=",
2213
- sourceFieldID: this.toLowerCase(viz.source.mappings.x[0])
2214
- });
2215
- for (var i = 0; i < viz.source.mappings.y.length; ++i) {
2216
- mappings.transformations.push({
2217
- fieldID: viz.source.mappings.y[i],
2218
- type: "=",
2219
- sourceFieldID: this.toLowerCase(viz.source.mappings.y[i])
2220
- });
2221
- }
2222
- };
2223
- DDLUpgrade.prototype.readTableMappings = function (viz) {
2224
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2225
- for (var i = 0; i < viz.label.length; ++i) {
2226
- mappings.transformations.push({
2227
- fieldID: viz.label[i],
2228
- type: "=",
2229
- sourceFieldID: this.toLowerCase(viz.source.mappings.value[i])
2230
- });
2231
- }
2232
- };
2233
- DDLUpgrade.prototype.readGraphEnums = function (valueMappings, annotation) {
2234
- if (annotation === void 0) { annotation = false; }
2235
- var retVal = [];
2236
- if (valueMappings) {
2237
- for (var value in valueMappings) {
2238
- var newValue = {};
2239
- for (var key in valueMappings[value]) {
2240
- if (key === "faChar") {
2241
- newValue[key] = faCharFix(valueMappings[value][key]);
2242
- }
2243
- else if (annotation && key.indexOf("icon_") === 0) {
2244
- console.log("Deprecated flag property: " + key);
2245
- newValue[key.split("icon_")[1]] = valueMappings[value][key];
2246
- }
2247
- else {
2248
- newValue[key] = valueMappings[value][key];
2249
- }
2250
- }
2251
- // remove v1.x "0" annotations as they equated to "nothing" ---
2252
- if (!annotation || value !== "0") {
2253
- retVal.push({
2254
- value: value,
2255
- newValue: newValue
2256
- });
2257
- }
2258
- }
2259
- }
2260
- return retVal;
2261
- };
2262
- DDLUpgrade.prototype.readGraphMappings = function (viz) {
2263
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2264
- mappings.transformations.push({
2265
- fieldID: "uid",
2266
- type: "=",
2267
- sourceFieldID: this.toLowerCase(viz.source.mappings.uid)
2268
- });
2269
- mappings.transformations.push({
2270
- fieldID: "label",
2271
- type: "=",
2272
- sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2273
- });
2274
- if (viz.icon.fieldid) {
2275
- mappings.transformations.push({
2276
- fieldID: "icon",
2277
- type: "map",
2278
- sourceFieldID: this.toLowerCase(viz.icon.fieldid),
2279
- default: { fachar: faCharFix(viz.icon.faChar) },
2280
- mappings: this.readGraphEnums(viz.icon.valuemappings)
2281
- });
2282
- }
2283
- var idx = 0;
2284
- if (viz.flag) {
2285
- for (var _i = 0, _a = viz.flag; _i < _a.length; _i++) {
2286
- var flag = _a[_i];
2287
- if (flag.fieldid) {
2288
- mappings.transformations.push({
2289
- fieldID: "annotation_".concat(idx++),
2290
- type: "map",
2291
- sourceFieldID: this.toLowerCase(flag.fieldid),
2292
- default: {},
2293
- mappings: this.readGraphEnums(flag.valuemappings, true)
2294
- });
2295
- }
2296
- }
2297
- }
2298
- mappings.transformations.push({
2299
- fieldID: "links",
2300
- type: "=",
2301
- sourceFieldID: this.toLowerCase(viz.source.link.childfile),
2302
- transformations: [{
2303
- fieldID: "uid",
2304
- type: "=",
2305
- sourceFieldID: this.toLowerCase(viz.source.link.mappings.uid)
2306
- }]
2307
- });
2308
- };
2309
- DDLUpgrade.prototype.readSliderMappings = function (viz) {
2310
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2311
- mappings.transformations.push({
2312
- fieldID: "label",
2313
- type: "=",
2314
- sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2315
- });
2316
- };
2317
- DDLUpgrade.prototype.readFilters = function () {
2318
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2319
- var dash = _a[_i];
2320
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2321
- var viz = _c[_b];
2322
- if (viz.events) {
2323
- for (var eventID in viz.events) {
2324
- var event_1 = viz.events[eventID];
2325
- for (var _d = 0, _e = event_1.updates; _d < _e.length; _d++) {
2326
- var update = _e[_d];
2327
- var otherViz = this._ddl2Dataviews[update.visualization];
2328
- var dsFilters = this.getDatasourceFilters(update.datasource, otherViz.id);
2329
- if (update.mappings) {
2330
- if (isRoxieServiceRef(otherViz.datasource)) {
2331
- for (var key in update.mappings) {
2332
- otherViz.datasource.request.push({
2333
- source: viz.id,
2334
- remoteFieldID: this.toLowerCase(key),
2335
- localFieldID: this.toLowerCase(update.mappings[key])
2336
- });
2337
- }
2338
- }
2339
- else {
2340
- var condition = {
2341
- viewID: viz.id,
2342
- mappings: []
2343
- };
2344
- for (var key in update.mappings) {
2345
- var mapping = update.mappings[key];
2346
- var dsFilter = (mapping && dsFilters[mapping]) ? dsFilters[mapping].filter : undefined;
2347
- if (!dsFilter) {
2348
- console.warn("Select Mapping \"".concat(mapping, "\" in viz \"").concat(viz.id, "\" not found in filters for \"").concat(otherViz.id, "\""));
2349
- }
2350
- else {
2351
- condition.mappings.push({
2352
- remoteFieldID: this.toLowerCase(key),
2353
- localFieldID: this.toLowerCase(update.mappings[key]),
2354
- condition: this.rule2condition(dsFilter.rule),
2355
- nullable: dsFilter.nullable
2356
- });
2357
- }
2358
- }
2359
- this._ddl2DataviewActivities[otherViz.id].filters.conditions.push(condition);
2360
- }
2361
- }
2362
- }
2363
- }
2364
- }
2365
- }
2366
- }
2367
- };
2368
- DDLUpgrade.prototype.rule2condition = function (_) {
2369
- switch (_) {
2370
- case "set":
2371
- return "in";
2372
- case "notequals":
2373
- return "!=";
2374
- }
2375
- return _;
2376
- };
2377
- DDLUpgrade.prototype.readSort = function () {
2378
- var _this = this;
2379
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2380
- var dash = _a[_i];
2381
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2382
- var viz = _c[_b];
2383
- if (viz.source) {
2384
- if (viz.source.sort) {
2385
- var vizSort = this._ddl2DataviewActivities[viz.id].sort;
2386
- vizSort.conditions = viz.source.sort.map(function (s) {
2387
- if (s.indexOf("-") === 0) {
2388
- return {
2389
- fieldID: _this.toLowerCase(s.substr(1)),
2390
- descending: true
2391
- };
2392
- }
2393
- return {
2394
- fieldID: _this.toLowerCase(s),
2395
- descending: false
2396
- };
2397
- });
2398
- }
2399
- if (viz.source.first) {
2400
- var vizLimit = this._ddl2DataviewActivities[viz.id].limit;
2401
- vizLimit.limit = +viz.source.first;
2402
- }
2403
- }
2404
- }
2405
- }
2406
- };
2407
- DDLUpgrade.prototype.anyViz2view = function (viz) {
2408
- var project = {
2409
- type: "project",
2410
- transformations: []
2411
- };
2412
- var filters = {
2413
- type: "filter",
2414
- conditions: []
2415
- };
2416
- var groupBy = {
2417
- type: "groupby",
2418
- groupByIDs: [],
2419
- aggregates: []
2420
- };
2421
- var sort = {
2422
- type: "sort",
2423
- conditions: []
2424
- };
2425
- var limit = {
2426
- type: "limit",
2427
- limit: 0
2428
- };
2429
- var mappings = {
2430
- type: "mappings",
2431
- transformations: []
2432
- };
2433
- this._ddl2DataviewActivities[viz.id] = {
2434
- project: project,
2435
- filters: filters,
2436
- sort: sort,
2437
- groupBy: groupBy,
2438
- limit: limit,
2439
- mappings: mappings
2440
- };
2441
- var datasourceRef = this.isVizDatasourceRoxie(viz) ? {
2442
- id: this._datasourceUpdates[viz.id].id,
2443
- request: [],
2444
- output: this._datasourceUpdates[viz.id].output
2445
- } : {
2446
- id: this._datasourceUpdates[viz.id].id,
2447
- output: this._datasourceUpdates[viz.id].output
2448
- };
2449
- return {
2450
- id: viz.id,
2451
- datasource: datasourceRef,
2452
- activities: [
2453
- project,
2454
- filters,
2455
- sort,
2456
- groupBy,
2457
- limit
2458
- ],
2459
- visualization: __assign(__assign({ id: viz.id, title: viz.title || "", description: "", visibility: viz.properties && viz.properties.flyout === true ? "flyout" : "normal" }, this.type2chartType(viz.type)), { mappings: mappings, properties: (viz.properties || {}) })
2460
- };
2461
- };
2462
- DDLUpgrade.prototype.type2chartType = function (chartType) {
2463
- switch (chartType) {
2464
- case "LINE":
2465
- return { chartType: "Line", __class: "chart_Line" };
2466
- case "BUBBLE":
2467
- return { chartType: "Bubble", __class: "chart_Bubble" };
2468
- case "PIE":
2469
- return { chartType: "Pie", __class: "chart_Pie" };
2470
- case "BAR":
2471
- return { chartType: "Column", __class: "chart_Column" };
2472
- case "FORM":
2473
- return { chartType: "FieldForm", __class: "form_FieldForm" };
2474
- case "WORD_CLOUD":
2475
- return { chartType: "WordCloud", __class: "chart_WordCloud" };
2476
- case "CHORO":
2477
- return { chartType: "ChoroplethStates", __class: "map_ChoroplethStates" };
2478
- case "SUMMARY":
2479
- return { chartType: "Summary", __class: "chart_Summary" };
2480
- case "SLIDER":
2481
- return { chartType: "FieldForm", __class: "form_FieldForm" };
2482
- case "HEAT_MAP":
2483
- return { chartType: "HeatMap", __class: "other_HeatMap" };
2484
- case "2DCHART":
2485
- return { chartType: "Column", __class: "chart_Column" };
2486
- case "GRAPH":
2487
- return { chartType: "AdjacencyGraph", __class: "graph_AdjacencyGraph" };
2488
- case "TABLE":
2489
- default:
2490
- return { chartType: "Table", __class: "dgrid_Table" };
2491
- }
2492
- };
2493
- DDLUpgrade.prototype.formFields2field = function (fields, slider) {
2494
- var _this = this;
2495
- if (slider === void 0) { slider = false; }
2496
- if (!fields)
2497
- return [];
2498
- return fields.map(function (field) {
2499
- switch (field.properties.type) {
2500
- case "range":
2501
- return {
2502
- type: "range",
2503
- id: field.id,
2504
- default: (field.properties.default ? field.properties.default : undefined)
2505
- };
2506
- case "dataset":
2507
- return {
2508
- type: "dataset",
2509
- id: field.id,
2510
- default: [],
2511
- children: []
2512
- };
2513
- default:
2514
- return {
2515
- type: _this.formFieldType2fieldType(field.properties.datatype, slider),
2516
- id: field.id,
2517
- default: field.properties.default ? field.properties.default[0] : undefined
2518
- };
2519
- }
2520
- });
2521
- };
2522
- DDLUpgrade.prototype.formFieldType2fieldType = function (fieldType, slider) {
2523
- switch (fieldType) {
2524
- case "bool":
2525
- case "boolean":
2526
- return "boolean";
2527
- case "integer":
2528
- case "unsigned":
2529
- case "float":
2530
- case "double":
2531
- case "real":
2532
- return "number";
2533
- case "string":
2534
- return "string";
2535
- default:
2536
- return slider ? "number" : "string";
2537
- }
2538
- };
2539
- DDLUpgrade.prototype.output2output = function (output, target) {
2540
- target[output.from || output.id] = {
2541
- fields: this.filters2fields(output.filter)
2542
- };
2543
- };
2544
- DDLUpgrade.prototype.filters2fields = function (filters) {
2545
- if (!filters)
2546
- return [];
2547
- return filters.filter(function (filter) {
2548
- var idParts = filter.fieldid.split("-");
2549
- return idParts.length === 1 || idParts[1] === "range";
2550
- }).map(function (filter) {
2551
- var idParts = filter.fieldid.split("-");
2552
- var retVal = {
2553
- type: "string",
2554
- id: idParts[0]
2555
- };
2556
- return retVal;
2557
- });
2558
- };
2559
- DDLUpgrade.prototype.getVizField = function (vizID, fieldID) {
2560
- return {
2561
- type: "string",
2562
- id: "",
2563
- default: ""
2564
- };
2565
- };
2566
- DDLUpgrade.prototype.writeDatasources = function () {
2567
- var retVal = [];
2568
- for (var id in this._ddl2Datasources) {
2569
- retVal.push(this._ddl2Datasources[id]);
2570
- }
2571
- return retVal;
2572
- };
2573
- DDLUpgrade.prototype.writeDataviews = function () {
2574
- var retVal = [];
2575
- for (var id in this._ddl2Dataviews) {
2576
- retVal.push(this._ddl2Dataviews[id]);
2577
- }
2578
- return retVal;
2579
- };
2580
- DDLUpgrade.prototype.writeProperties = function () {
2581
- return {
2582
- // TODO
2583
- };
2584
- };
2585
- DDLUpgrade.prototype.write = function () {
2586
- return {
2587
- version: "2.2.1",
2588
- createdBy: {
2589
- name: PKG_NAME,
2590
- version: PKG_VERSION
2591
- },
2592
- datasources: this.writeDatasources(),
2593
- dataviews: this.writeDataviews(),
2594
- properties: this.writeProperties()
2595
- };
2596
- };
2597
- return DDLUpgrade;
2598
- }());
2599
- function upgrade(ddl, baseUrl, wuid, toLowerCase, dermatologyJson) {
2600
- if (toLowerCase === void 0) { toLowerCase = true; }
2601
- if (dermatologyJson === void 0) { dermatologyJson = {}; }
2602
- var ddlUp = new DDLUpgrade(ddl, baseUrl, wuid, toLowerCase);
2603
- var retVal = ddlUp.write();
2604
- retVal.properties = upgrade$1(retVal, dermatologyJson);
2605
- return retVal;
1903
+ function faCharFix(faChar) {
1904
+ return faChar;
1905
+ }
1906
+ var DDLUpgrade = /** @class */ (function () {
1907
+ function DDLUpgrade(ddl, baseUrl, wuid, toLowerCase) {
1908
+ if (baseUrl === void 0) { baseUrl = "http://localhost:8010"; }
1909
+ if (wuid === void 0) { wuid = "WUID"; }
1910
+ if (toLowerCase === void 0) { toLowerCase = true; }
1911
+ this._datasources = {};
1912
+ this._datasourceUpdates = {};
1913
+ this._visualizations = {};
1914
+ this._ddl2Datasources = {};
1915
+ this._ddl2DatasourceFields = {};
1916
+ this._ddl2Dataviews = {};
1917
+ this._ddl2DataviewActivities = {};
1918
+ this._ddl = ddl;
1919
+ this._baseUrl = baseUrl;
1920
+ this._wuid = wuid;
1921
+ this._toLowerCase = toLowerCase;
1922
+ this.indexDDL();
1923
+ this.readDDL();
1924
+ }
1925
+ DDLUpgrade.prototype.toLowerCase = function (s) {
1926
+ return this._toLowerCase ? s.toLowerCase() : s;
1927
+ };
1928
+ DDLUpgrade.prototype.isVizDatasourceRoxie = function (viz) {
1929
+ if (viz.source) {
1930
+ var ds = this._datasources[viz.source.id];
1931
+ if (isHipieDatasource(ds)) {
1932
+ return true;
1933
+ }
1934
+ }
1935
+ return false;
1936
+ };
1937
+ DDLUpgrade.prototype.getDatasourceOutputs = function (dsID, vizID) {
1938
+ var retVal = [];
1939
+ var datasource = this._datasources[dsID];
1940
+ for (var _i = 0, _a = datasource.outputs; _i < _a.length; _i++) {
1941
+ var output = _a[_i];
1942
+ if (output.notify) {
1943
+ for (var _b = 0, _c = output.notify; _b < _c.length; _b++) {
1944
+ var notify = _c[_b];
1945
+ if (notify === vizID) {
1946
+ retVal.push({
1947
+ datasource: datasource,
1948
+ output: output
1949
+ });
1950
+ }
1951
+ }
1952
+ }
1953
+ }
1954
+ return retVal;
1955
+ };
1956
+ DDLUpgrade.prototype.getDatasourceFilters = function (dsID, vizID) {
1957
+ var retVal = {};
1958
+ for (var _i = 0, _a = this.getDatasourceOutputs(dsID, vizID); _i < _a.length; _i++) {
1959
+ var dsOut = _a[_i];
1960
+ if (dsOut.output.filter) {
1961
+ for (var _b = 0, _c = dsOut.output.filter; _b < _c.length; _b++) {
1962
+ var filter = _c[_b];
1963
+ retVal[filter.fieldid] = {
1964
+ datasource: dsOut.datasource,
1965
+ output: dsOut.output,
1966
+ filter: filter
1967
+ };
1968
+ }
1969
+ }
1970
+ }
1971
+ return retVal;
1972
+ };
1973
+ DDLUpgrade.prototype.indexDDL = function () {
1974
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
1975
+ var dash = _a[_i];
1976
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
1977
+ var viz = _c[_b];
1978
+ this._visualizations[viz.id] = viz;
1979
+ }
1980
+ }
1981
+ for (var _d = 0, _e = this._ddl.datasources; _d < _e.length; _d++) {
1982
+ var ds = _e[_d];
1983
+ this._datasources[ds.id] = ds;
1984
+ for (var _f = 0, _g = ds.outputs; _f < _g.length; _f++) {
1985
+ var output = _g[_f];
1986
+ if (output.notify) {
1987
+ for (var _h = 0, _j = output.notify; _h < _j.length; _h++) {
1988
+ var notify = _j[_h];
1989
+ this._datasourceUpdates[notify] = {
1990
+ id: ds.id,
1991
+ output: output.from || output.id
1992
+ };
1993
+ }
1994
+ }
1995
+ }
1996
+ }
1997
+ };
1998
+ DDLUpgrade.prototype.readDDL = function () {
1999
+ for (var _i = 0, _a = this._ddl.datasources; _i < _a.length; _i++) {
2000
+ var ds = _a[_i];
2001
+ if (isWorkunitDatasource(ds)) {
2002
+ var ddl2DS = {
2003
+ type: "wuresult",
2004
+ id: ds.id,
2005
+ url: this._baseUrl,
2006
+ wuid: this._wuid,
2007
+ outputs: {}
2008
+ };
2009
+ for (var _b = 0, _c = ds.outputs; _b < _c.length; _b++) {
2010
+ var output = _c[_b];
2011
+ this.output2output(output, ddl2DS.outputs);
2012
+ }
2013
+ this._ddl2Datasources[ds.id] = ddl2DS;
2014
+ }
2015
+ else if (isDatabombDatasource(ds)) ;
2016
+ else {
2017
+ var urlParts = ds.URL.split("/WsEcl/submit/query/");
2018
+ var hostParts = urlParts[0];
2019
+ var roxieParts = urlParts[1].split("/");
2020
+ var ddl2DS = {
2021
+ type: "hipie",
2022
+ id: ds.id,
2023
+ url: hostParts,
2024
+ querySet: roxieParts[0],
2025
+ queryID: roxieParts[1],
2026
+ inputs: [],
2027
+ outputs: {}
2028
+ };
2029
+ for (var _d = 0, _e = ds.outputs; _d < _e.length; _d++) {
2030
+ var output = _e[_d];
2031
+ this.output2output(output, ddl2DS.outputs);
2032
+ }
2033
+ this._ddl2Datasources[ds.id] = ddl2DS;
2034
+ }
2035
+ }
2036
+ for (var _f = 0, _g = this._ddl.dashboards; _f < _g.length; _f++) {
2037
+ var dash = _g[_f];
2038
+ for (var _h = 0, _j = dash.visualizations; _h < _j.length; _h++) {
2039
+ var viz = _j[_h];
2040
+ if (viz.type === "FORM") {
2041
+ this._ddl2Datasources[viz.id] = {
2042
+ type: "form",
2043
+ id: viz.id,
2044
+ fields: this.formFields2field(viz.fields)
2045
+ };
2046
+ this._datasourceUpdates[viz.id] = { id: viz.id };
2047
+ }
2048
+ else if (viz.type === "SLIDER") {
2049
+ this._ddl2Datasources[viz.id] = {
2050
+ type: "form",
2051
+ id: viz.id,
2052
+ fields: this.formFields2field(viz.fields, true)
2053
+ };
2054
+ this._datasourceUpdates[viz.id] = { id: viz.id };
2055
+ }
2056
+ this._ddl2Dataviews[viz.id] = this.anyViz2view(viz);
2057
+ }
2058
+ }
2059
+ this.readGroupBy();
2060
+ this.readFilters();
2061
+ this.readSort();
2062
+ this.readMappings();
2063
+ };
2064
+ DDLUpgrade.prototype.readGroupBy = function () {
2065
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2066
+ var dash = _a[_i];
2067
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2068
+ var viz = _c[_b];
2069
+ if (viz.fields) {
2070
+ var projectTransformations = [];
2071
+ var groupByColumns = [];
2072
+ var aggrFields = [];
2073
+ for (var _d = 0, _e = viz.fields; _d < _e.length; _d++) {
2074
+ var field = _e[_d];
2075
+ if (field.properties && field.properties.function) {
2076
+ switch (field.properties.function) {
2077
+ case "SUM":
2078
+ case "MIN":
2079
+ case "MAX":
2080
+ aggrFields.push({
2081
+ type: this.func2aggr(field.properties.function),
2082
+ inFieldID: this.toLowerCase(field.properties.params.param1),
2083
+ fieldID: this.toLowerCase(field.id)
2084
+ });
2085
+ break;
2086
+ case "AVE":
2087
+ aggrFields.push({
2088
+ type: this.func2aggr(field.properties.function),
2089
+ inFieldID: this.toLowerCase(field.properties.params.param1),
2090
+ baseCountFieldID: field.properties.params.param2 ? this.toLowerCase(field.properties.params.param2) : undefined,
2091
+ fieldID: this.toLowerCase(field.id)
2092
+ });
2093
+ break;
2094
+ case "SCALE":
2095
+ if (typeof field.properties.params.param1 === "object") {
2096
+ var props = field.properties.params.param1;
2097
+ switch (props.function) {
2098
+ case "SUM":
2099
+ case "MIN":
2100
+ case "MAX":
2101
+ aggrFields.push({
2102
+ type: this.func2aggr(props.function),
2103
+ inFieldID: this.toLowerCase(props.params.param1),
2104
+ fieldID: this.toLowerCase(field.id)
2105
+ });
2106
+ break;
2107
+ }
2108
+ }
2109
+ projectTransformations.push({
2110
+ type: "scale",
2111
+ sourceFieldID: this.toLowerCase(field.id),
2112
+ fieldID: this.toLowerCase(field.id),
2113
+ factor: +field.properties.params.param2
2114
+ });
2115
+ break;
2116
+ default:
2117
+ groupByColumns.push(this.toLowerCase(field.id));
2118
+ throw new Error("Unhandled field function: ".concat(field.properties.function));
2119
+ }
2120
+ }
2121
+ else {
2122
+ groupByColumns.push(this.toLowerCase(field.id));
2123
+ }
2124
+ }
2125
+ if (projectTransformations.length) {
2126
+ this._ddl2DataviewActivities[viz.id].project.transformations = projectTransformations;
2127
+ }
2128
+ if (aggrFields.length) {
2129
+ this._ddl2DataviewActivities[viz.id].groupBy.groupByIDs = __spreadArray([], groupByColumns, true);
2130
+ this._ddl2DataviewActivities[viz.id].groupBy.aggregates = aggrFields;
2131
+ }
2132
+ }
2133
+ }
2134
+ }
2135
+ };
2136
+ DDLUpgrade.prototype.func2aggr = function (func) {
2137
+ switch (func) {
2138
+ case "SUM":
2139
+ return "sum";
2140
+ case "AVE":
2141
+ return "mean";
2142
+ case "MIN":
2143
+ return "min";
2144
+ case "MAX":
2145
+ return "max";
2146
+ }
2147
+ throw new Error("Unknown DDL1 Function Type: ".concat(func));
2148
+ };
2149
+ DDLUpgrade.prototype.readMappings = function () {
2150
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2151
+ var dash = _a[_i];
2152
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2153
+ var viz = _c[_b];
2154
+ if (isFormVisualization(viz)) ;
2155
+ else if (isPieVisualization(viz)) {
2156
+ this.readPieMappings(viz);
2157
+ }
2158
+ else if (isChoroVisualization(viz)) {
2159
+ this.readChoroMappings(viz);
2160
+ }
2161
+ else if (isLineVisualization(viz)) {
2162
+ this.readLineMappings(viz);
2163
+ }
2164
+ else if (isTableVisualization(viz)) {
2165
+ this.readTableMappings(viz);
2166
+ }
2167
+ else if (isGraphVisualization(viz)) {
2168
+ this.readGraphMappings(viz);
2169
+ }
2170
+ else if (isSliderVisualization(viz)) {
2171
+ this.readSliderMappings(viz);
2172
+ }
2173
+ else {
2174
+ throw new Error("Unkown DDL1 mapping type: ".concat(viz.type));
2175
+ }
2176
+ }
2177
+ }
2178
+ };
2179
+ DDLUpgrade.prototype.readPieMappings = function (viz) {
2180
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2181
+ mappings.transformations.push({
2182
+ fieldID: "label",
2183
+ type: "=",
2184
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2185
+ });
2186
+ mappings.transformations.push({
2187
+ fieldID: "weight",
2188
+ type: "=",
2189
+ sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
2190
+ });
2191
+ };
2192
+ DDLUpgrade.prototype.readChoroMappings = function (viz) {
2193
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2194
+ mappings.transformations.push({
2195
+ fieldID: "label",
2196
+ type: "=",
2197
+ sourceFieldID: this.toLowerCase(this.anyChoroMapping2label(viz.source.mappings))
2198
+ });
2199
+ mappings.transformations.push({
2200
+ fieldID: "weight",
2201
+ type: "=",
2202
+ sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
2203
+ });
2204
+ };
2205
+ DDLUpgrade.prototype.anyChoroMapping2label = function (mapping) {
2206
+ return mapping.state || mapping.county || mapping.geohash;
2207
+ };
2208
+ DDLUpgrade.prototype.readLineMappings = function (viz) {
2209
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2210
+ mappings.transformations.push({
2211
+ fieldID: viz.source.mappings.x[0],
2212
+ type: "=",
2213
+ sourceFieldID: this.toLowerCase(viz.source.mappings.x[0])
2214
+ });
2215
+ for (var i = 0; i < viz.source.mappings.y.length; ++i) {
2216
+ mappings.transformations.push({
2217
+ fieldID: viz.source.mappings.y[i],
2218
+ type: "=",
2219
+ sourceFieldID: this.toLowerCase(viz.source.mappings.y[i])
2220
+ });
2221
+ }
2222
+ };
2223
+ DDLUpgrade.prototype.readTableMappings = function (viz) {
2224
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2225
+ for (var i = 0; i < viz.label.length; ++i) {
2226
+ mappings.transformations.push({
2227
+ fieldID: viz.label[i],
2228
+ type: "=",
2229
+ sourceFieldID: this.toLowerCase(viz.source.mappings.value[i])
2230
+ });
2231
+ }
2232
+ };
2233
+ DDLUpgrade.prototype.readGraphEnums = function (valueMappings, annotation) {
2234
+ if (annotation === void 0) { annotation = false; }
2235
+ var retVal = [];
2236
+ if (valueMappings) {
2237
+ for (var value in valueMappings) {
2238
+ var newValue = {};
2239
+ for (var key in valueMappings[value]) {
2240
+ if (key === "faChar") {
2241
+ newValue[key] = faCharFix(valueMappings[value][key]);
2242
+ }
2243
+ else if (annotation && key.indexOf("icon_") === 0) {
2244
+ console.warn("Deprecated flag property: " + key);
2245
+ newValue[key.split("icon_")[1]] = valueMappings[value][key];
2246
+ }
2247
+ else {
2248
+ newValue[key] = valueMappings[value][key];
2249
+ }
2250
+ }
2251
+ // remove v1.x "0" annotations as they equated to "nothing" ---
2252
+ if (!annotation || value !== "0") {
2253
+ retVal.push({
2254
+ value: value,
2255
+ newValue: newValue
2256
+ });
2257
+ }
2258
+ }
2259
+ }
2260
+ return retVal;
2261
+ };
2262
+ DDLUpgrade.prototype.readGraphMappings = function (viz) {
2263
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2264
+ mappings.transformations.push({
2265
+ fieldID: "uid",
2266
+ type: "=",
2267
+ sourceFieldID: this.toLowerCase(viz.source.mappings.uid)
2268
+ });
2269
+ mappings.transformations.push({
2270
+ fieldID: "label",
2271
+ type: "=",
2272
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2273
+ });
2274
+ if (viz.icon.fieldid) {
2275
+ mappings.transformations.push({
2276
+ fieldID: "icon",
2277
+ type: "map",
2278
+ sourceFieldID: this.toLowerCase(viz.icon.fieldid),
2279
+ default: { fachar: faCharFix(viz.icon.faChar) },
2280
+ mappings: this.readGraphEnums(viz.icon.valuemappings)
2281
+ });
2282
+ }
2283
+ var idx = 0;
2284
+ if (viz.flag) {
2285
+ for (var _i = 0, _a = viz.flag; _i < _a.length; _i++) {
2286
+ var flag = _a[_i];
2287
+ if (flag.fieldid) {
2288
+ mappings.transformations.push({
2289
+ fieldID: "annotation_".concat(idx++),
2290
+ type: "map",
2291
+ sourceFieldID: this.toLowerCase(flag.fieldid),
2292
+ default: {},
2293
+ mappings: this.readGraphEnums(flag.valuemappings, true)
2294
+ });
2295
+ }
2296
+ }
2297
+ }
2298
+ mappings.transformations.push({
2299
+ fieldID: "links",
2300
+ type: "=",
2301
+ sourceFieldID: this.toLowerCase(viz.source.link.childfile),
2302
+ transformations: [{
2303
+ fieldID: "uid",
2304
+ type: "=",
2305
+ sourceFieldID: this.toLowerCase(viz.source.link.mappings.uid)
2306
+ }]
2307
+ });
2308
+ };
2309
+ DDLUpgrade.prototype.readSliderMappings = function (viz) {
2310
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2311
+ mappings.transformations.push({
2312
+ fieldID: "label",
2313
+ type: "=",
2314
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2315
+ });
2316
+ };
2317
+ DDLUpgrade.prototype.readFilters = function () {
2318
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2319
+ var dash = _a[_i];
2320
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2321
+ var viz = _c[_b];
2322
+ if (viz.events) {
2323
+ for (var eventID in viz.events) {
2324
+ var event_1 = viz.events[eventID];
2325
+ for (var _d = 0, _e = event_1.updates; _d < _e.length; _d++) {
2326
+ var update = _e[_d];
2327
+ var otherViz = this._ddl2Dataviews[update.visualization];
2328
+ var dsFilters = this.getDatasourceFilters(update.datasource, otherViz.id);
2329
+ if (update.mappings) {
2330
+ if (isRoxieServiceRef(otherViz.datasource)) {
2331
+ for (var key in update.mappings) {
2332
+ otherViz.datasource.request.push({
2333
+ source: viz.id,
2334
+ remoteFieldID: this.toLowerCase(key),
2335
+ localFieldID: this.toLowerCase(update.mappings[key])
2336
+ });
2337
+ }
2338
+ }
2339
+ else {
2340
+ var condition = {
2341
+ viewID: viz.id,
2342
+ mappings: []
2343
+ };
2344
+ for (var key in update.mappings) {
2345
+ var mapping = update.mappings[key];
2346
+ var dsFilter = (mapping && dsFilters[mapping]) ? dsFilters[mapping].filter : undefined;
2347
+ if (!dsFilter) {
2348
+ console.warn("Select Mapping \"".concat(mapping, "\" in viz \"").concat(viz.id, "\" not found in filters for \"").concat(otherViz.id, "\""));
2349
+ }
2350
+ else {
2351
+ condition.mappings.push({
2352
+ remoteFieldID: this.toLowerCase(key),
2353
+ localFieldID: this.toLowerCase(update.mappings[key]),
2354
+ condition: this.rule2condition(dsFilter.rule),
2355
+ nullable: dsFilter.nullable
2356
+ });
2357
+ }
2358
+ }
2359
+ this._ddl2DataviewActivities[otherViz.id].filters.conditions.push(condition);
2360
+ }
2361
+ }
2362
+ }
2363
+ }
2364
+ }
2365
+ }
2366
+ }
2367
+ };
2368
+ DDLUpgrade.prototype.rule2condition = function (_) {
2369
+ switch (_) {
2370
+ case "set":
2371
+ return "in";
2372
+ case "notequals":
2373
+ return "!=";
2374
+ }
2375
+ return _;
2376
+ };
2377
+ DDLUpgrade.prototype.readSort = function () {
2378
+ var _this = this;
2379
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2380
+ var dash = _a[_i];
2381
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2382
+ var viz = _c[_b];
2383
+ if (viz.source) {
2384
+ if (viz.source.sort) {
2385
+ var vizSort = this._ddl2DataviewActivities[viz.id].sort;
2386
+ vizSort.conditions = viz.source.sort.map(function (s) {
2387
+ if (s.indexOf("-") === 0) {
2388
+ return {
2389
+ fieldID: _this.toLowerCase(s.substr(1)),
2390
+ descending: true
2391
+ };
2392
+ }
2393
+ return {
2394
+ fieldID: _this.toLowerCase(s),
2395
+ descending: false
2396
+ };
2397
+ });
2398
+ }
2399
+ if (viz.source.first) {
2400
+ var vizLimit = this._ddl2DataviewActivities[viz.id].limit;
2401
+ vizLimit.limit = +viz.source.first;
2402
+ }
2403
+ }
2404
+ }
2405
+ }
2406
+ };
2407
+ DDLUpgrade.prototype.anyViz2view = function (viz) {
2408
+ var project = {
2409
+ type: "project",
2410
+ transformations: []
2411
+ };
2412
+ var filters = {
2413
+ type: "filter",
2414
+ conditions: []
2415
+ };
2416
+ var groupBy = {
2417
+ type: "groupby",
2418
+ groupByIDs: [],
2419
+ aggregates: []
2420
+ };
2421
+ var sort = {
2422
+ type: "sort",
2423
+ conditions: []
2424
+ };
2425
+ var limit = {
2426
+ type: "limit",
2427
+ limit: 0
2428
+ };
2429
+ var mappings = {
2430
+ type: "mappings",
2431
+ transformations: []
2432
+ };
2433
+ this._ddl2DataviewActivities[viz.id] = {
2434
+ project: project,
2435
+ filters: filters,
2436
+ sort: sort,
2437
+ groupBy: groupBy,
2438
+ limit: limit,
2439
+ mappings: mappings
2440
+ };
2441
+ var datasourceRef = this.isVizDatasourceRoxie(viz) ? {
2442
+ id: this._datasourceUpdates[viz.id].id,
2443
+ request: [],
2444
+ output: this._datasourceUpdates[viz.id].output
2445
+ } : {
2446
+ id: this._datasourceUpdates[viz.id].id,
2447
+ output: this._datasourceUpdates[viz.id].output
2448
+ };
2449
+ return {
2450
+ id: viz.id,
2451
+ datasource: datasourceRef,
2452
+ activities: [
2453
+ project,
2454
+ filters,
2455
+ sort,
2456
+ groupBy,
2457
+ limit
2458
+ ],
2459
+ visualization: __assign(__assign({ id: viz.id, title: viz.title || "", description: "", visibility: viz.properties && viz.properties.flyout === true ? "flyout" : "normal" }, this.type2chartType(viz.type)), { mappings: mappings, properties: (viz.properties || {}) })
2460
+ };
2461
+ };
2462
+ DDLUpgrade.prototype.type2chartType = function (chartType) {
2463
+ switch (chartType) {
2464
+ case "LINE":
2465
+ return { chartType: "Line", __class: "chart_Line" };
2466
+ case "BUBBLE":
2467
+ return { chartType: "Bubble", __class: "chart_Bubble" };
2468
+ case "PIE":
2469
+ return { chartType: "Pie", __class: "chart_Pie" };
2470
+ case "BAR":
2471
+ return { chartType: "Column", __class: "chart_Column" };
2472
+ case "FORM":
2473
+ return { chartType: "FieldForm", __class: "form_FieldForm" };
2474
+ case "WORD_CLOUD":
2475
+ return { chartType: "WordCloud", __class: "chart_WordCloud" };
2476
+ case "CHORO":
2477
+ return { chartType: "ChoroplethStates", __class: "map_ChoroplethStates" };
2478
+ case "SUMMARY":
2479
+ return { chartType: "Summary", __class: "chart_Summary" };
2480
+ case "SLIDER":
2481
+ return { chartType: "FieldForm", __class: "form_FieldForm" };
2482
+ case "HEAT_MAP":
2483
+ return { chartType: "HeatMap", __class: "other_HeatMap" };
2484
+ case "2DCHART":
2485
+ return { chartType: "Column", __class: "chart_Column" };
2486
+ case "GRAPH":
2487
+ return { chartType: "AdjacencyGraph", __class: "graph_AdjacencyGraph" };
2488
+ case "TABLE":
2489
+ default:
2490
+ return { chartType: "Table", __class: "dgrid_Table" };
2491
+ }
2492
+ };
2493
+ DDLUpgrade.prototype.formFields2field = function (fields, slider) {
2494
+ var _this = this;
2495
+ if (slider === void 0) { slider = false; }
2496
+ if (!fields)
2497
+ return [];
2498
+ return fields.map(function (field) {
2499
+ switch (field.properties.type) {
2500
+ case "range":
2501
+ return {
2502
+ type: "range",
2503
+ id: field.id,
2504
+ default: (field.properties.default ? field.properties.default : undefined)
2505
+ };
2506
+ case "dataset":
2507
+ return {
2508
+ type: "dataset",
2509
+ id: field.id,
2510
+ default: [],
2511
+ children: []
2512
+ };
2513
+ default:
2514
+ return {
2515
+ type: _this.formFieldType2fieldType(field.properties.datatype, slider),
2516
+ id: field.id,
2517
+ default: field.properties.default ? field.properties.default[0] : undefined
2518
+ };
2519
+ }
2520
+ });
2521
+ };
2522
+ DDLUpgrade.prototype.formFieldType2fieldType = function (fieldType, slider) {
2523
+ switch (fieldType) {
2524
+ case "bool":
2525
+ case "boolean":
2526
+ return "boolean";
2527
+ case "integer":
2528
+ case "unsigned":
2529
+ case "float":
2530
+ case "double":
2531
+ case "real":
2532
+ return "number";
2533
+ case "string":
2534
+ return "string";
2535
+ default:
2536
+ return slider ? "number" : "string";
2537
+ }
2538
+ };
2539
+ DDLUpgrade.prototype.output2output = function (output, target) {
2540
+ target[output.from || output.id] = {
2541
+ fields: this.filters2fields(output.filter)
2542
+ };
2543
+ };
2544
+ DDLUpgrade.prototype.filters2fields = function (filters) {
2545
+ if (!filters)
2546
+ return [];
2547
+ return filters.filter(function (filter) {
2548
+ var idParts = filter.fieldid.split("-");
2549
+ return idParts.length === 1 || idParts[1] === "range";
2550
+ }).map(function (filter) {
2551
+ var idParts = filter.fieldid.split("-");
2552
+ var retVal = {
2553
+ type: "string",
2554
+ id: idParts[0]
2555
+ };
2556
+ return retVal;
2557
+ });
2558
+ };
2559
+ DDLUpgrade.prototype.getVizField = function (vizID, fieldID) {
2560
+ return {
2561
+ type: "string",
2562
+ id: "",
2563
+ default: ""
2564
+ };
2565
+ };
2566
+ DDLUpgrade.prototype.writeDatasources = function () {
2567
+ var retVal = [];
2568
+ for (var id in this._ddl2Datasources) {
2569
+ retVal.push(this._ddl2Datasources[id]);
2570
+ }
2571
+ return retVal;
2572
+ };
2573
+ DDLUpgrade.prototype.writeDataviews = function () {
2574
+ var retVal = [];
2575
+ for (var id in this._ddl2Dataviews) {
2576
+ retVal.push(this._ddl2Dataviews[id]);
2577
+ }
2578
+ return retVal;
2579
+ };
2580
+ DDLUpgrade.prototype.writeProperties = function () {
2581
+ return {
2582
+ // TODO
2583
+ };
2584
+ };
2585
+ DDLUpgrade.prototype.write = function () {
2586
+ return {
2587
+ version: "2.2.1",
2588
+ createdBy: {
2589
+ name: PKG_NAME,
2590
+ version: PKG_VERSION
2591
+ },
2592
+ datasources: this.writeDatasources(),
2593
+ dataviews: this.writeDataviews(),
2594
+ properties: this.writeProperties()
2595
+ };
2596
+ };
2597
+ return DDLUpgrade;
2598
+ }());
2599
+ function upgrade(ddl, baseUrl, wuid, toLowerCase, dermatologyJson) {
2600
+ if (toLowerCase === void 0) { toLowerCase = true; }
2601
+ if (dermatologyJson === void 0) { dermatologyJson = {}; }
2602
+ var ddlUp = new DDLUpgrade(ddl, baseUrl, wuid, toLowerCase);
2603
+ var retVal = ddlUp.write();
2604
+ retVal.properties = upgrade$1(retVal, dermatologyJson);
2605
+ return retVal;
2606
2606
  }
2607
2607
 
2608
- var args = process.argv.slice(2);
2609
- switch (args[0]) {
2610
- case "--echo":
2611
- process.stdout.write(args[1]);
2612
- break;
2613
- case "--schema":
2614
- process.stdout.write(JSON.stringify(ddl2Schema));
2615
- break;
2616
- case "--upgrade":
2617
- case "--upgradeNoLower":
2618
- var srcPath = args[1];
2619
- var destPath_1 = args[2];
2620
- var baseUrl_1 = args[3];
2621
- var wuid_1 = args[4];
2622
- var layoutPath = args[5];
2623
- if (srcPath && destPath_1 && srcPath !== destPath_1) {
2624
- var layoutJson_1 = {};
2625
- if (layoutPath) {
2626
- try {
2627
- layoutJson_1 = JSON.parse(fs__namespace.readFileSync(layoutPath).toString());
2628
- }
2629
- catch (e) {
2630
- console.error(e);
2631
- }
2632
- }
2633
- fs__namespace.readFile(srcPath, "utf8", function (err, data) {
2634
- if (err)
2635
- throw err;
2636
- var ddl2 = upgrade(JSON.parse(data), baseUrl_1 || "http://localhost:8010", wuid_1 || "WUID", args[0] === "--upgrade", layoutJson_1);
2637
- fs__namespace.writeFile(destPath_1, JSON.stringify(ddl2), function (err) {
2638
- if (err)
2639
- throw err;
2640
- console.log("complete");
2641
- });
2642
- });
2643
- }
2644
- break;
2645
- case "--help":
2646
- break;
2647
- default:
2648
- process.stdout.write("\nUsage: <command>\n\nwhere <command> is one of:\n --schema: output DDL2 schmea.\n --upgrade ddl1 [baseUrl wuid [layout]]: updgrade ddl and layout version 1 to ddl version 2.\n --upgradeNoLower ddl1 [baseUrl wuid [layout]]: updgrade ddl and layout version 1 to ddl version 2 without changing field IDs upper/lower casing.\n --help: this message.\n");
2608
+ var args = process.argv.slice(2);
2609
+ switch (args[0]) {
2610
+ case "--echo":
2611
+ process.stdout.write(args[1]);
2612
+ break;
2613
+ case "--schema":
2614
+ process.stdout.write(JSON.stringify(ddl2Schema));
2615
+ break;
2616
+ case "--upgrade":
2617
+ case "--upgradeNoLower":
2618
+ var srcPath = args[1];
2619
+ var destPath_1 = args[2];
2620
+ var baseUrl_1 = args[3];
2621
+ var wuid_1 = args[4];
2622
+ var layoutPath = args[5];
2623
+ if (srcPath && destPath_1 && srcPath !== destPath_1) {
2624
+ var layoutJson_1 = {};
2625
+ if (layoutPath) {
2626
+ try {
2627
+ layoutJson_1 = JSON.parse(fs__namespace.readFileSync(layoutPath).toString());
2628
+ }
2629
+ catch (e) {
2630
+ console.error(e);
2631
+ }
2632
+ }
2633
+ fs__namespace.readFile(srcPath, "utf8", function (err, data) {
2634
+ if (err)
2635
+ throw err;
2636
+ var ddl2 = upgrade(JSON.parse(data), baseUrl_1 || "http://localhost:8010", wuid_1 || "WUID", args[0] === "--upgrade", layoutJson_1);
2637
+ fs__namespace.writeFile(destPath_1, JSON.stringify(ddl2), function (err) {
2638
+ if (err)
2639
+ throw err;
2640
+ console.info("complete");
2641
+ });
2642
+ });
2643
+ }
2644
+ break;
2645
+ case "--help":
2646
+ break;
2647
+ default:
2648
+ process.stdout.write("\nUsage: <command>\n\nwhere <command> is one of:\n --schema: output DDL2 schmea.\n --upgrade ddl1 [baseUrl wuid [layout]]: updgrade ddl and layout version 1 to ddl version 2.\n --upgradeNoLower ddl1 [baseUrl wuid [layout]]: updgrade ddl and layout version 1 to ddl version 2 without changing field IDs upper/lower casing.\n --help: this message.\n");
2649
2649
  }
2650
2650
  //# sourceMappingURL=cli.js.map