@hpcc-js/ddl-shim 2.19.0 → 2.19.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.
package/dist/index.es6.js CHANGED
@@ -13,51 +13,51 @@ function _mergeNamespaces(n, m) {
13
13
  return Object.freeze(n);
14
14
  }
15
15
 
16
- var PKG_NAME = "@hpcc-js/ddl-shim";
17
- var PKG_VERSION = "2.19.0";
18
- var BUILD_VERSION = "2.102.2";
19
-
20
- function isWorkunitDatasource(ref) {
21
- return ref.WUID !== undefined;
22
- }
23
- function isDatabombDatasource(ref) {
24
- return ref.databomb === true;
25
- }
26
- function isHipieDatasource(ref) {
27
- return ref.URL !== undefined;
28
- }
29
- function isPieVisualization(viz) {
30
- return viz.type === "PIE" || viz.type === "BAR";
31
- }
32
- function isLineVisualization(viz) {
33
- return viz.type === "LINE";
34
- }
35
- function isChoroVisualization(viz) {
36
- return viz.type === "CHORO";
37
- }
38
- function isTableVisualization(viz) {
39
- return viz.type === "TABLE";
40
- }
41
- function isSliderVisualization(viz) {
42
- return viz.type === "SLIDER";
43
- }
44
- function isGraphVisualization(viz) {
45
- return viz.type === "GRAPH";
46
- }
47
- function isHeatMapVisualization(viz) {
48
- return viz.type === "HEAT_MAP";
49
- }
50
- function isFormVisualization(viz) {
51
- return viz.type === "FORM";
52
- }
53
- function isUSStateMapping(mappings) {
54
- return mappings.state !== undefined;
55
- }
56
- function isUSCountyMapping(mappings) {
57
- return mappings.county !== undefined;
58
- }
59
- function isGeohashMapping(mappings) {
60
- return mappings.geohash !== undefined;
16
+ var PKG_NAME = "@hpcc-js/ddl-shim";
17
+ var PKG_VERSION = "2.19.1";
18
+ var BUILD_VERSION = "2.102.11";
19
+
20
+ function isWorkunitDatasource(ref) {
21
+ return ref.WUID !== undefined;
22
+ }
23
+ function isDatabombDatasource(ref) {
24
+ return ref.databomb === true;
25
+ }
26
+ function isHipieDatasource(ref) {
27
+ return ref.URL !== undefined;
28
+ }
29
+ function isPieVisualization(viz) {
30
+ return viz.type === "PIE" || viz.type === "BAR";
31
+ }
32
+ function isLineVisualization(viz) {
33
+ return viz.type === "LINE";
34
+ }
35
+ function isChoroVisualization(viz) {
36
+ return viz.type === "CHORO";
37
+ }
38
+ function isTableVisualization(viz) {
39
+ return viz.type === "TABLE";
40
+ }
41
+ function isSliderVisualization(viz) {
42
+ return viz.type === "SLIDER";
43
+ }
44
+ function isGraphVisualization(viz) {
45
+ return viz.type === "GRAPH";
46
+ }
47
+ function isHeatMapVisualization(viz) {
48
+ return viz.type === "HEAT_MAP";
49
+ }
50
+ function isFormVisualization(viz) {
51
+ return viz.type === "FORM";
52
+ }
53
+ function isUSStateMapping(mappings) {
54
+ return mappings.state !== undefined;
55
+ }
56
+ function isUSCountyMapping(mappings) {
57
+ return mappings.county !== undefined;
58
+ }
59
+ function isGeohashMapping(mappings) {
60
+ return mappings.geohash !== undefined;
61
61
  }
62
62
 
63
63
  var v1 = /*#__PURE__*/Object.freeze({
@@ -78,36 +78,36 @@ var v1 = /*#__PURE__*/Object.freeze({
78
78
  isGeohashMapping: isGeohashMapping
79
79
  });
80
80
 
81
- function isDatabombRef(ref) {
82
- return !isWUResultRef(ref) && !isRoxieServiceRef(ref);
83
- }
84
- function isWUResultRef(ref) {
85
- return ref.output !== undefined && !isRoxieServiceRef(ref);
86
- }
87
- function isRoxieServiceRef(ref) {
88
- return ref.request !== undefined;
89
- }
90
- function isIFilterCondition(fc) {
91
- return !!fc.viewID;
92
- }
93
- function isFilterActivity(activity) {
94
- return activity.type === "filter";
95
- }
96
- function isProjectActivity(activity) {
97
- return activity.type === "project";
98
- }
99
- function isMappingsActivity(activity) {
100
- return activity.type === "mappings";
101
- }
102
- function isGroupByActivity(activity) {
103
- return activity.type === "groupby";
104
- }
105
- function isSortActivity(activity) {
106
- return activity.type === "sort";
107
- }
108
- function isLimitActivity(activity) {
109
- return activity.type === "limit";
110
- }
81
+ function isDatabombRef(ref) {
82
+ return !isWUResultRef(ref) && !isRoxieServiceRef(ref);
83
+ }
84
+ function isWUResultRef(ref) {
85
+ return ref.output !== undefined && !isRoxieServiceRef(ref);
86
+ }
87
+ function isRoxieServiceRef(ref) {
88
+ return ref.request !== undefined;
89
+ }
90
+ function isIFilterCondition(fc) {
91
+ return !!fc.viewID;
92
+ }
93
+ function isFilterActivity(activity) {
94
+ return activity.type === "filter";
95
+ }
96
+ function isProjectActivity(activity) {
97
+ return activity.type === "project";
98
+ }
99
+ function isMappingsActivity(activity) {
100
+ return activity.type === "mappings";
101
+ }
102
+ function isGroupByActivity(activity) {
103
+ return activity.type === "groupby";
104
+ }
105
+ function isSortActivity(activity) {
106
+ return activity.type === "sort";
107
+ }
108
+ function isLimitActivity(activity) {
109
+ return activity.type === "limit";
110
+ }
111
111
  var VisibilitySet = ["normal", "flyout"];
112
112
 
113
113
  var v2$1 = /*#__PURE__*/Object.freeze({
@@ -161,927 +161,927 @@ function __spreadArray(to, from, pack) {
161
161
  return to.concat(ar || Array.prototype.slice.call(from));
162
162
  }
163
163
 
164
- var classMappings = {
165
- c3chart_Bar: "chart_Bar",
166
- c3chart_Column: "chart_Column",
167
- c3chart_Pie: "chart_Pie",
168
- c3chart_Area: "chart_Area",
169
- c3chart_Line: "chart_Line",
170
- amchart_Bar: "chart_Bar",
171
- amchart_Column: "chart_Column",
172
- amchart_Pie: "chart_Pie",
173
- amchart_Area: "chart_Area",
174
- amchart_Line: "chart_Line",
175
- google_Bar: "chart_Bar",
176
- google_Column: "chart_Column",
177
- google_Pie: "chart_Pie",
178
- google_Area: "chart_Area",
179
- google_Line: "chart_Line",
180
- other_Table: "dgrid_Table"
181
- };
182
- var propertyMappings = {
183
- xAxisLabelRotation: [
184
- { name: "xAxisOverlapMode", transform: function (n) { return "rotate"; } },
185
- { name: "xAxisLabelRotation", transform: function (n) { return n; } }
186
- ],
187
- tooltipLabelColor: {
188
- name: "tooltipLabelColor"
189
- },
190
- tooltipSeriesColor: {
191
- name: "tooltipSeriesColor"
192
- },
193
- tooltipValueColor: {
194
- name: "tooltipValueColor"
195
- },
196
- tooltipValueFormat: {
197
- name: "tooltipValueFormat"
198
- },
199
- timePattern: {
200
- name: "xAxisTypeTimePattern"
201
- },
202
- smoothLines: {
203
- name: "interpolate",
204
- transform: function (n) {
205
- if (n === false)
206
- return "linear";
207
- return "catmullRom";
208
- }
209
- },
210
- holePercent: {
211
- name: "innerRadius"
212
- },
213
- flip: {
214
- name: "orientation",
215
- transform: function (n) { return n ? "vertical" : "horizontal"; }
216
- },
217
- bottomText: {
218
- name: "xAxisTitle"
219
- },
220
- xAxisTypeTimePattern: {
221
- name: "xAxisTypeTimePattern"
222
- },
223
- yAxisTypeTimePattern: {
224
- name: "yAxisTypeTimePattern"
225
- },
226
- valueFormat: {
227
- name: "tooltipValueFormat"
228
- },
229
- stacked: {
230
- name: "yAxisStacked"
231
- },
232
- showYGrid: {
233
- name: "yAxisGuideLines"
234
- },
235
- showXGrid: {
236
- name: "xAxisGuideLines"
237
- },
238
- showValueLabel: {
239
- name: "showValue"
240
- },
241
- low: {
242
- name: "yAxisDomainLow"
243
- },
244
- high: {
245
- name: "yAxisDomainHigh"
246
- },
247
- fillOpacity: {
248
- name: "interpolateFillOpacity"
249
- },
250
- areaFillOpacity: {
251
- name: "interpolateFillOpacity"
252
- },
253
- showToolbar: {
254
- name: "titleVisible"
255
- },
256
- showCSV: {
257
- name: "downloadButtonVisible"
258
- }
259
- };
260
- function findKeyVal(object, key, val) {
261
- var value;
262
- for (var k in object) {
263
- if (k === key && object[k] === val) {
264
- value = object;
265
- break;
266
- }
267
- if (object[k] && typeof object[k] === "object") {
268
- value = findKeyVal(object[k], key, val);
269
- if (value !== undefined) {
270
- break;
271
- }
272
- }
273
- }
274
- return value;
275
- }
276
- function apply_to_dataviews(ddl2, dermObj) {
277
- ddl2.dataviews.forEach(apply_to_dataview);
278
- function apply_to_dataview(dv) {
279
- var widgetId = dv.id;
280
- var dermPanelObj = findKeyVal(dermObj, "__id", widgetId);
281
- if (dermPanelObj) {
282
- var dermPanelProps = dermPanelObj.__properties;
283
- var dermWidgetObj = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
284
- var dermWidgetProps = dermWidgetObj.__properties;
285
- apply_class_mapping(dermWidgetObj);
286
- apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
287
- apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
288
- if (dv.visualization.properties.chartType) {
289
- dv.visualization.properties.charttype = dv.visualization.properties.chartType;
290
- }
291
- }
292
- else {
293
- console.warn(widgetId + " not found in dermObj");
294
- }
295
- function apply_class_mapping(dermWidgetObj) {
296
- dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
297
- dv.visualization.properties.__class = "marshaller_VizChartPanel";
298
- if (!dv.visualization.properties.widget)
299
- dv.visualization.properties.widget = {};
300
- dv.visualization.properties.widget.__class = dv.visualization.__class;
301
- function swap_with_supported_class(_class) {
302
- return classMappings[_class] ? classMappings[_class] : _class;
303
- }
304
- }
305
- function apply_panel_property_mapping(dermPanelProps, dermWidgetProps) {
306
- dv.visualization.title = dermPanelProps.title || "";
307
- dv.visualization.description = "";
308
- dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
309
- dv.visualization.chartType = dv.visualization.__class.split("_")[1];
310
- for (var propName in dermPanelProps) {
311
- if (typeof propertyMappings[propName] !== "undefined") {
312
- var newPropName = propertyMappings[propName].name;
313
- if (typeof propertyMappings[propName].transform === "function") {
314
- dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
315
- }
316
- else {
317
- dv.visualization.properties[newPropName] = dermPanelProps[propName];
318
- }
319
- }
320
- }
321
- if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
322
- dv.visualization.properties.legendVisible = true;
323
- }
324
- }
325
- function apply_widget_property_mapping(dermPanelProps, dermWidgetProps) {
326
- dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
327
- dv.visualization.description = ""; // TODO - should this map to anything?
328
- dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
329
- dv.visualization.chartType = dv.visualization.__class.split("_")[1];
330
- var _loop_1 = function (propName) {
331
- if (typeof propertyMappings[propName] !== "undefined") {
332
- if (propertyMappings[propName] instanceof Array) {
333
- propertyMappings[propName].forEach(function (p) {
334
- var newPropName = p.name;
335
- dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
336
- if (typeof propertyMappings[propName].transform === "function") {
337
- dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
338
- }
339
- else {
340
- dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
341
- }
342
- });
343
- }
344
- else {
345
- var newPropName = propertyMappings[propName].name;
346
- dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
347
- }
348
- }
349
- };
350
- for (var propName in dermWidgetProps) {
351
- _loop_1(propName);
352
- }
353
- }
354
- }
355
- }
356
- function apply_to_properties_layout(ddl2, dermObj) {
357
- var retVal = {
358
- layout: []
359
- };
360
- if (!dermObj || !dermObj.__properties)
361
- return;
362
- dermObj.__properties.content.forEach(function (cell) {
363
- var cellPosition = {
364
- // TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
365
- id: cell.__properties.widget.__id,
366
- position: [
367
- cell.__properties.gridCol,
368
- cell.__properties.gridRow,
369
- cell.__properties.gridColSpan,
370
- cell.__properties.gridRowSpan
371
- ]
372
- };
373
- retVal.layout.push(cellPosition);
374
- });
375
- return retVal;
376
- }
377
- function upgrade$1(ddl2, dermObj) {
378
- apply_to_dataviews(ddl2, dermObj);
379
- return apply_to_properties_layout(ddl2, dermObj);
380
- }
381
-
382
- function faCharFix(faChar) {
383
- return faChar;
384
- }
385
- var DDLUpgrade = /** @class */ (function () {
386
- function DDLUpgrade(ddl, baseUrl, wuid, toLowerCase) {
387
- if (baseUrl === void 0) { baseUrl = "http://localhost:8010"; }
388
- if (wuid === void 0) { wuid = "WUID"; }
389
- if (toLowerCase === void 0) { toLowerCase = true; }
390
- this._datasources = {};
391
- this._datasourceUpdates = {};
392
- this._visualizations = {};
393
- this._ddl2Datasources = {};
394
- this._ddl2DatasourceFields = {};
395
- this._ddl2Dataviews = {};
396
- this._ddl2DataviewActivities = {};
397
- this._ddl = ddl;
398
- this._baseUrl = baseUrl;
399
- this._wuid = wuid;
400
- this._toLowerCase = toLowerCase;
401
- this.indexDDL();
402
- this.readDDL();
403
- }
404
- DDLUpgrade.prototype.toLowerCase = function (s) {
405
- return this._toLowerCase ? s.toLowerCase() : s;
406
- };
407
- DDLUpgrade.prototype.isVizDatasourceRoxie = function (viz) {
408
- if (viz.source) {
409
- var ds = this._datasources[viz.source.id];
410
- if (isHipieDatasource(ds)) {
411
- return true;
412
- }
413
- }
414
- return false;
415
- };
416
- DDLUpgrade.prototype.getDatasourceOutputs = function (dsID, vizID) {
417
- var retVal = [];
418
- var datasource = this._datasources[dsID];
419
- for (var _i = 0, _a = datasource.outputs; _i < _a.length; _i++) {
420
- var output = _a[_i];
421
- if (output.notify) {
422
- for (var _b = 0, _c = output.notify; _b < _c.length; _b++) {
423
- var notify = _c[_b];
424
- if (notify === vizID) {
425
- retVal.push({
426
- datasource: datasource,
427
- output: output
428
- });
429
- }
430
- }
431
- }
432
- }
433
- return retVal;
434
- };
435
- DDLUpgrade.prototype.getDatasourceFilters = function (dsID, vizID) {
436
- var retVal = {};
437
- for (var _i = 0, _a = this.getDatasourceOutputs(dsID, vizID); _i < _a.length; _i++) {
438
- var dsOut = _a[_i];
439
- if (dsOut.output.filter) {
440
- for (var _b = 0, _c = dsOut.output.filter; _b < _c.length; _b++) {
441
- var filter = _c[_b];
442
- retVal[filter.fieldid] = {
443
- datasource: dsOut.datasource,
444
- output: dsOut.output,
445
- filter: filter
446
- };
447
- }
448
- }
449
- }
450
- return retVal;
451
- };
452
- DDLUpgrade.prototype.indexDDL = function () {
453
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
454
- var dash = _a[_i];
455
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
456
- var viz = _c[_b];
457
- this._visualizations[viz.id] = viz;
458
- }
459
- }
460
- for (var _d = 0, _e = this._ddl.datasources; _d < _e.length; _d++) {
461
- var ds = _e[_d];
462
- this._datasources[ds.id] = ds;
463
- for (var _f = 0, _g = ds.outputs; _f < _g.length; _f++) {
464
- var output = _g[_f];
465
- if (output.notify) {
466
- for (var _h = 0, _j = output.notify; _h < _j.length; _h++) {
467
- var notify = _j[_h];
468
- this._datasourceUpdates[notify] = {
469
- id: ds.id,
470
- output: output.from || output.id
471
- };
472
- }
473
- }
474
- }
475
- }
476
- };
477
- DDLUpgrade.prototype.readDDL = function () {
478
- for (var _i = 0, _a = this._ddl.datasources; _i < _a.length; _i++) {
479
- var ds = _a[_i];
480
- if (isWorkunitDatasource(ds)) {
481
- var ddl2DS = {
482
- type: "wuresult",
483
- id: ds.id,
484
- url: this._baseUrl,
485
- wuid: this._wuid,
486
- outputs: {}
487
- };
488
- for (var _b = 0, _c = ds.outputs; _b < _c.length; _b++) {
489
- var output = _c[_b];
490
- this.output2output(output, ddl2DS.outputs);
491
- }
492
- this._ddl2Datasources[ds.id] = ddl2DS;
493
- }
494
- else if (isDatabombDatasource(ds)) ;
495
- else {
496
- var urlParts = ds.URL.split("/WsEcl/submit/query/");
497
- var hostParts = urlParts[0];
498
- var roxieParts = urlParts[1].split("/");
499
- var ddl2DS = {
500
- type: "hipie",
501
- id: ds.id,
502
- url: hostParts,
503
- querySet: roxieParts[0],
504
- queryID: roxieParts[1],
505
- inputs: [],
506
- outputs: {}
507
- };
508
- for (var _d = 0, _e = ds.outputs; _d < _e.length; _d++) {
509
- var output = _e[_d];
510
- this.output2output(output, ddl2DS.outputs);
511
- }
512
- this._ddl2Datasources[ds.id] = ddl2DS;
513
- }
514
- }
515
- for (var _f = 0, _g = this._ddl.dashboards; _f < _g.length; _f++) {
516
- var dash = _g[_f];
517
- for (var _h = 0, _j = dash.visualizations; _h < _j.length; _h++) {
518
- var viz = _j[_h];
519
- if (viz.type === "FORM") {
520
- this._ddl2Datasources[viz.id] = {
521
- type: "form",
522
- id: viz.id,
523
- fields: this.formFields2field(viz.fields)
524
- };
525
- this._datasourceUpdates[viz.id] = { id: viz.id };
526
- }
527
- else if (viz.type === "SLIDER") {
528
- this._ddl2Datasources[viz.id] = {
529
- type: "form",
530
- id: viz.id,
531
- fields: this.formFields2field(viz.fields, true)
532
- };
533
- this._datasourceUpdates[viz.id] = { id: viz.id };
534
- }
535
- this._ddl2Dataviews[viz.id] = this.anyViz2view(viz);
536
- }
537
- }
538
- this.readGroupBy();
539
- this.readFilters();
540
- this.readSort();
541
- this.readMappings();
542
- };
543
- DDLUpgrade.prototype.readGroupBy = function () {
544
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
545
- var dash = _a[_i];
546
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
547
- var viz = _c[_b];
548
- if (viz.fields) {
549
- var projectTransformations = [];
550
- var groupByColumns = [];
551
- var aggrFields = [];
552
- for (var _d = 0, _e = viz.fields; _d < _e.length; _d++) {
553
- var field = _e[_d];
554
- if (field.properties && field.properties.function) {
555
- switch (field.properties.function) {
556
- case "SUM":
557
- case "MIN":
558
- case "MAX":
559
- aggrFields.push({
560
- type: this.func2aggr(field.properties.function),
561
- inFieldID: this.toLowerCase(field.properties.params.param1),
562
- fieldID: this.toLowerCase(field.id)
563
- });
564
- break;
565
- case "AVE":
566
- aggrFields.push({
567
- type: this.func2aggr(field.properties.function),
568
- inFieldID: this.toLowerCase(field.properties.params.param1),
569
- baseCountFieldID: field.properties.params.param2 ? this.toLowerCase(field.properties.params.param2) : undefined,
570
- fieldID: this.toLowerCase(field.id)
571
- });
572
- break;
573
- case "SCALE":
574
- if (typeof field.properties.params.param1 === "object") {
575
- var props = field.properties.params.param1;
576
- switch (props.function) {
577
- case "SUM":
578
- case "MIN":
579
- case "MAX":
580
- aggrFields.push({
581
- type: this.func2aggr(props.function),
582
- inFieldID: this.toLowerCase(props.params.param1),
583
- fieldID: this.toLowerCase(field.id)
584
- });
585
- break;
586
- }
587
- }
588
- projectTransformations.push({
589
- type: "scale",
590
- sourceFieldID: this.toLowerCase(field.id),
591
- fieldID: this.toLowerCase(field.id),
592
- factor: +field.properties.params.param2
593
- });
594
- break;
595
- default:
596
- groupByColumns.push(this.toLowerCase(field.id));
597
- throw new Error("Unhandled field function: ".concat(field.properties.function));
598
- }
599
- }
600
- else {
601
- groupByColumns.push(this.toLowerCase(field.id));
602
- }
603
- }
604
- if (projectTransformations.length) {
605
- this._ddl2DataviewActivities[viz.id].project.transformations = projectTransformations;
606
- }
607
- if (aggrFields.length) {
608
- this._ddl2DataviewActivities[viz.id].groupBy.groupByIDs = __spreadArray([], groupByColumns, true);
609
- this._ddl2DataviewActivities[viz.id].groupBy.aggregates = aggrFields;
610
- }
611
- }
612
- }
613
- }
614
- };
615
- DDLUpgrade.prototype.func2aggr = function (func) {
616
- switch (func) {
617
- case "SUM":
618
- return "sum";
619
- case "AVE":
620
- return "mean";
621
- case "MIN":
622
- return "min";
623
- case "MAX":
624
- return "max";
625
- }
626
- throw new Error("Unknown DDL1 Function Type: ".concat(func));
627
- };
628
- DDLUpgrade.prototype.readMappings = function () {
629
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
630
- var dash = _a[_i];
631
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
632
- var viz = _c[_b];
633
- if (isFormVisualization(viz)) ;
634
- else if (isPieVisualization(viz)) {
635
- this.readPieMappings(viz);
636
- }
637
- else if (isChoroVisualization(viz)) {
638
- this.readChoroMappings(viz);
639
- }
640
- else if (isLineVisualization(viz)) {
641
- this.readLineMappings(viz);
642
- }
643
- else if (isTableVisualization(viz)) {
644
- this.readTableMappings(viz);
645
- }
646
- else if (isGraphVisualization(viz)) {
647
- this.readGraphMappings(viz);
648
- }
649
- else if (isSliderVisualization(viz)) {
650
- this.readSliderMappings(viz);
651
- }
652
- else {
653
- throw new Error("Unkown DDL1 mapping type: ".concat(viz.type));
654
- }
655
- }
656
- }
657
- };
658
- DDLUpgrade.prototype.readPieMappings = function (viz) {
659
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
660
- mappings.transformations.push({
661
- fieldID: "label",
662
- type: "=",
663
- sourceFieldID: this.toLowerCase(viz.source.mappings.label)
664
- });
665
- mappings.transformations.push({
666
- fieldID: "weight",
667
- type: "=",
668
- sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
669
- });
670
- };
671
- DDLUpgrade.prototype.readChoroMappings = function (viz) {
672
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
673
- mappings.transformations.push({
674
- fieldID: "label",
675
- type: "=",
676
- sourceFieldID: this.toLowerCase(this.anyChoroMapping2label(viz.source.mappings))
677
- });
678
- mappings.transformations.push({
679
- fieldID: "weight",
680
- type: "=",
681
- sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
682
- });
683
- };
684
- DDLUpgrade.prototype.anyChoroMapping2label = function (mapping) {
685
- return mapping.state || mapping.county || mapping.geohash;
686
- };
687
- DDLUpgrade.prototype.readLineMappings = function (viz) {
688
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
689
- mappings.transformations.push({
690
- fieldID: viz.source.mappings.x[0],
691
- type: "=",
692
- sourceFieldID: this.toLowerCase(viz.source.mappings.x[0])
693
- });
694
- for (var i = 0; i < viz.source.mappings.y.length; ++i) {
695
- mappings.transformations.push({
696
- fieldID: viz.source.mappings.y[i],
697
- type: "=",
698
- sourceFieldID: this.toLowerCase(viz.source.mappings.y[i])
699
- });
700
- }
701
- };
702
- DDLUpgrade.prototype.readTableMappings = function (viz) {
703
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
704
- for (var i = 0; i < viz.label.length; ++i) {
705
- mappings.transformations.push({
706
- fieldID: viz.label[i],
707
- type: "=",
708
- sourceFieldID: this.toLowerCase(viz.source.mappings.value[i])
709
- });
710
- }
711
- };
712
- DDLUpgrade.prototype.readGraphEnums = function (valueMappings, annotation) {
713
- if (annotation === void 0) { annotation = false; }
714
- var retVal = [];
715
- if (valueMappings) {
716
- for (var value in valueMappings) {
717
- var newValue = {};
718
- for (var key in valueMappings[value]) {
719
- if (key === "faChar") {
720
- newValue[key] = faCharFix(valueMappings[value][key]);
721
- }
722
- else if (annotation && key.indexOf("icon_") === 0) {
723
- console.log("Deprecated flag property: " + key);
724
- newValue[key.split("icon_")[1]] = valueMappings[value][key];
725
- }
726
- else {
727
- newValue[key] = valueMappings[value][key];
728
- }
729
- }
730
- // remove v1.x "0" annotations as they equated to "nothing" ---
731
- if (!annotation || value !== "0") {
732
- retVal.push({
733
- value: value,
734
- newValue: newValue
735
- });
736
- }
737
- }
738
- }
739
- return retVal;
740
- };
741
- DDLUpgrade.prototype.readGraphMappings = function (viz) {
742
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
743
- mappings.transformations.push({
744
- fieldID: "uid",
745
- type: "=",
746
- sourceFieldID: this.toLowerCase(viz.source.mappings.uid)
747
- });
748
- mappings.transformations.push({
749
- fieldID: "label",
750
- type: "=",
751
- sourceFieldID: this.toLowerCase(viz.source.mappings.label)
752
- });
753
- if (viz.icon.fieldid) {
754
- mappings.transformations.push({
755
- fieldID: "icon",
756
- type: "map",
757
- sourceFieldID: this.toLowerCase(viz.icon.fieldid),
758
- default: { fachar: faCharFix(viz.icon.faChar) },
759
- mappings: this.readGraphEnums(viz.icon.valuemappings)
760
- });
761
- }
762
- var idx = 0;
763
- if (viz.flag) {
764
- for (var _i = 0, _a = viz.flag; _i < _a.length; _i++) {
765
- var flag = _a[_i];
766
- if (flag.fieldid) {
767
- mappings.transformations.push({
768
- fieldID: "annotation_".concat(idx++),
769
- type: "map",
770
- sourceFieldID: this.toLowerCase(flag.fieldid),
771
- default: {},
772
- mappings: this.readGraphEnums(flag.valuemappings, true)
773
- });
774
- }
775
- }
776
- }
777
- mappings.transformations.push({
778
- fieldID: "links",
779
- type: "=",
780
- sourceFieldID: this.toLowerCase(viz.source.link.childfile),
781
- transformations: [{
782
- fieldID: "uid",
783
- type: "=",
784
- sourceFieldID: this.toLowerCase(viz.source.link.mappings.uid)
785
- }]
786
- });
787
- };
788
- DDLUpgrade.prototype.readSliderMappings = function (viz) {
789
- var mappings = this._ddl2DataviewActivities[viz.id].mappings;
790
- mappings.transformations.push({
791
- fieldID: "label",
792
- type: "=",
793
- sourceFieldID: this.toLowerCase(viz.source.mappings.label)
794
- });
795
- };
796
- DDLUpgrade.prototype.readFilters = function () {
797
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
798
- var dash = _a[_i];
799
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
800
- var viz = _c[_b];
801
- if (viz.events) {
802
- for (var eventID in viz.events) {
803
- var event_1 = viz.events[eventID];
804
- for (var _d = 0, _e = event_1.updates; _d < _e.length; _d++) {
805
- var update = _e[_d];
806
- var otherViz = this._ddl2Dataviews[update.visualization];
807
- var dsFilters = this.getDatasourceFilters(update.datasource, otherViz.id);
808
- if (update.mappings) {
809
- if (isRoxieServiceRef(otherViz.datasource)) {
810
- for (var key in update.mappings) {
811
- otherViz.datasource.request.push({
812
- source: viz.id,
813
- remoteFieldID: this.toLowerCase(key),
814
- localFieldID: this.toLowerCase(update.mappings[key])
815
- });
816
- }
817
- }
818
- else {
819
- var condition = {
820
- viewID: viz.id,
821
- mappings: []
822
- };
823
- for (var key in update.mappings) {
824
- var mapping = update.mappings[key];
825
- var dsFilter = (mapping && dsFilters[mapping]) ? dsFilters[mapping].filter : undefined;
826
- if (!dsFilter) {
827
- console.warn("Select Mapping \"".concat(mapping, "\" in viz \"").concat(viz.id, "\" not found in filters for \"").concat(otherViz.id, "\""));
828
- }
829
- else {
830
- condition.mappings.push({
831
- remoteFieldID: this.toLowerCase(key),
832
- localFieldID: this.toLowerCase(update.mappings[key]),
833
- condition: this.rule2condition(dsFilter.rule),
834
- nullable: dsFilter.nullable
835
- });
836
- }
837
- }
838
- this._ddl2DataviewActivities[otherViz.id].filters.conditions.push(condition);
839
- }
840
- }
841
- }
842
- }
843
- }
844
- }
845
- }
846
- };
847
- DDLUpgrade.prototype.rule2condition = function (_) {
848
- switch (_) {
849
- case "set":
850
- return "in";
851
- case "notequals":
852
- return "!=";
853
- }
854
- return _;
855
- };
856
- DDLUpgrade.prototype.readSort = function () {
857
- var _this = this;
858
- for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
859
- var dash = _a[_i];
860
- for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
861
- var viz = _c[_b];
862
- if (viz.source) {
863
- if (viz.source.sort) {
864
- var vizSort = this._ddl2DataviewActivities[viz.id].sort;
865
- vizSort.conditions = viz.source.sort.map(function (s) {
866
- if (s.indexOf("-") === 0) {
867
- return {
868
- fieldID: _this.toLowerCase(s.substr(1)),
869
- descending: true
870
- };
871
- }
872
- return {
873
- fieldID: _this.toLowerCase(s),
874
- descending: false
875
- };
876
- });
877
- }
878
- if (viz.source.first) {
879
- var vizLimit = this._ddl2DataviewActivities[viz.id].limit;
880
- vizLimit.limit = +viz.source.first;
881
- }
882
- }
883
- }
884
- }
885
- };
886
- DDLUpgrade.prototype.anyViz2view = function (viz) {
887
- var project = {
888
- type: "project",
889
- transformations: []
890
- };
891
- var filters = {
892
- type: "filter",
893
- conditions: []
894
- };
895
- var groupBy = {
896
- type: "groupby",
897
- groupByIDs: [],
898
- aggregates: []
899
- };
900
- var sort = {
901
- type: "sort",
902
- conditions: []
903
- };
904
- var limit = {
905
- type: "limit",
906
- limit: 0
907
- };
908
- var mappings = {
909
- type: "mappings",
910
- transformations: []
911
- };
912
- this._ddl2DataviewActivities[viz.id] = {
913
- project: project,
914
- filters: filters,
915
- sort: sort,
916
- groupBy: groupBy,
917
- limit: limit,
918
- mappings: mappings
919
- };
920
- var datasourceRef = this.isVizDatasourceRoxie(viz) ? {
921
- id: this._datasourceUpdates[viz.id].id,
922
- request: [],
923
- output: this._datasourceUpdates[viz.id].output
924
- } : {
925
- id: this._datasourceUpdates[viz.id].id,
926
- output: this._datasourceUpdates[viz.id].output
927
- };
928
- return {
929
- id: viz.id,
930
- datasource: datasourceRef,
931
- activities: [
932
- project,
933
- filters,
934
- sort,
935
- groupBy,
936
- limit
937
- ],
938
- 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 || {}) })
939
- };
940
- };
941
- DDLUpgrade.prototype.type2chartType = function (chartType) {
942
- switch (chartType) {
943
- case "LINE":
944
- return { chartType: "Line", __class: "chart_Line" };
945
- case "BUBBLE":
946
- return { chartType: "Bubble", __class: "chart_Bubble" };
947
- case "PIE":
948
- return { chartType: "Pie", __class: "chart_Pie" };
949
- case "BAR":
950
- return { chartType: "Column", __class: "chart_Column" };
951
- case "FORM":
952
- return { chartType: "FieldForm", __class: "form_FieldForm" };
953
- case "WORD_CLOUD":
954
- return { chartType: "WordCloud", __class: "chart_WordCloud" };
955
- case "CHORO":
956
- return { chartType: "ChoroplethStates", __class: "map_ChoroplethStates" };
957
- case "SUMMARY":
958
- return { chartType: "Summary", __class: "chart_Summary" };
959
- case "SLIDER":
960
- return { chartType: "FieldForm", __class: "form_FieldForm" };
961
- case "HEAT_MAP":
962
- return { chartType: "HeatMap", __class: "other_HeatMap" };
963
- case "2DCHART":
964
- return { chartType: "Column", __class: "chart_Column" };
965
- case "GRAPH":
966
- return { chartType: "AdjacencyGraph", __class: "graph_AdjacencyGraph" };
967
- case "TABLE":
968
- default:
969
- return { chartType: "Table", __class: "dgrid_Table" };
970
- }
971
- };
972
- DDLUpgrade.prototype.formFields2field = function (fields, slider) {
973
- var _this = this;
974
- if (slider === void 0) { slider = false; }
975
- if (!fields)
976
- return [];
977
- return fields.map(function (field) {
978
- switch (field.properties.type) {
979
- case "range":
980
- return {
981
- type: "range",
982
- id: field.id,
983
- default: (field.properties.default ? field.properties.default : undefined)
984
- };
985
- case "dataset":
986
- return {
987
- type: "dataset",
988
- id: field.id,
989
- default: [],
990
- children: []
991
- };
992
- default:
993
- return {
994
- type: _this.formFieldType2fieldType(field.properties.datatype, slider),
995
- id: field.id,
996
- default: field.properties.default ? field.properties.default[0] : undefined
997
- };
998
- }
999
- });
1000
- };
1001
- DDLUpgrade.prototype.formFieldType2fieldType = function (fieldType, slider) {
1002
- switch (fieldType) {
1003
- case "bool":
1004
- case "boolean":
1005
- return "boolean";
1006
- case "integer":
1007
- case "unsigned":
1008
- case "float":
1009
- case "double":
1010
- case "real":
1011
- return "number";
1012
- case "string":
1013
- return "string";
1014
- default:
1015
- return slider ? "number" : "string";
1016
- }
1017
- };
1018
- DDLUpgrade.prototype.output2output = function (output, target) {
1019
- target[output.from || output.id] = {
1020
- fields: this.filters2fields(output.filter)
1021
- };
1022
- };
1023
- DDLUpgrade.prototype.filters2fields = function (filters) {
1024
- if (!filters)
1025
- return [];
1026
- return filters.filter(function (filter) {
1027
- var idParts = filter.fieldid.split("-");
1028
- return idParts.length === 1 || idParts[1] === "range";
1029
- }).map(function (filter) {
1030
- var idParts = filter.fieldid.split("-");
1031
- var retVal = {
1032
- type: "string",
1033
- id: idParts[0]
1034
- };
1035
- return retVal;
1036
- });
1037
- };
1038
- DDLUpgrade.prototype.getVizField = function (vizID, fieldID) {
1039
- return {
1040
- type: "string",
1041
- id: "",
1042
- default: ""
1043
- };
1044
- };
1045
- DDLUpgrade.prototype.writeDatasources = function () {
1046
- var retVal = [];
1047
- for (var id in this._ddl2Datasources) {
1048
- retVal.push(this._ddl2Datasources[id]);
1049
- }
1050
- return retVal;
1051
- };
1052
- DDLUpgrade.prototype.writeDataviews = function () {
1053
- var retVal = [];
1054
- for (var id in this._ddl2Dataviews) {
1055
- retVal.push(this._ddl2Dataviews[id]);
1056
- }
1057
- return retVal;
1058
- };
1059
- DDLUpgrade.prototype.writeProperties = function () {
1060
- return {
1061
- // TODO
1062
- };
1063
- };
1064
- DDLUpgrade.prototype.write = function () {
1065
- return {
1066
- version: "2.2.1",
1067
- createdBy: {
1068
- name: PKG_NAME,
1069
- version: PKG_VERSION
1070
- },
1071
- datasources: this.writeDatasources(),
1072
- dataviews: this.writeDataviews(),
1073
- properties: this.writeProperties()
1074
- };
1075
- };
1076
- return DDLUpgrade;
1077
- }());
1078
- function upgrade(ddl, baseUrl, wuid, toLowerCase, dermatologyJson) {
1079
- if (toLowerCase === void 0) { toLowerCase = true; }
1080
- if (dermatologyJson === void 0) { dermatologyJson = {}; }
1081
- var ddlUp = new DDLUpgrade(ddl, baseUrl, wuid, toLowerCase);
1082
- var retVal = ddlUp.write();
1083
- retVal.properties = upgrade$1(retVal, dermatologyJson);
1084
- return retVal;
164
+ var classMappings = {
165
+ c3chart_Bar: "chart_Bar",
166
+ c3chart_Column: "chart_Column",
167
+ c3chart_Pie: "chart_Pie",
168
+ c3chart_Area: "chart_Area",
169
+ c3chart_Line: "chart_Line",
170
+ amchart_Bar: "chart_Bar",
171
+ amchart_Column: "chart_Column",
172
+ amchart_Pie: "chart_Pie",
173
+ amchart_Area: "chart_Area",
174
+ amchart_Line: "chart_Line",
175
+ google_Bar: "chart_Bar",
176
+ google_Column: "chart_Column",
177
+ google_Pie: "chart_Pie",
178
+ google_Area: "chart_Area",
179
+ google_Line: "chart_Line",
180
+ other_Table: "dgrid_Table"
181
+ };
182
+ var propertyMappings = {
183
+ xAxisLabelRotation: [
184
+ { name: "xAxisOverlapMode", transform: function (n) { return "rotate"; } },
185
+ { name: "xAxisLabelRotation", transform: function (n) { return n; } }
186
+ ],
187
+ tooltipLabelColor: {
188
+ name: "tooltipLabelColor"
189
+ },
190
+ tooltipSeriesColor: {
191
+ name: "tooltipSeriesColor"
192
+ },
193
+ tooltipValueColor: {
194
+ name: "tooltipValueColor"
195
+ },
196
+ tooltipValueFormat: {
197
+ name: "tooltipValueFormat"
198
+ },
199
+ timePattern: {
200
+ name: "xAxisTypeTimePattern"
201
+ },
202
+ smoothLines: {
203
+ name: "interpolate",
204
+ transform: function (n) {
205
+ if (n === false)
206
+ return "linear";
207
+ return "catmullRom";
208
+ }
209
+ },
210
+ holePercent: {
211
+ name: "innerRadius"
212
+ },
213
+ flip: {
214
+ name: "orientation",
215
+ transform: function (n) { return n ? "vertical" : "horizontal"; }
216
+ },
217
+ bottomText: {
218
+ name: "xAxisTitle"
219
+ },
220
+ xAxisTypeTimePattern: {
221
+ name: "xAxisTypeTimePattern"
222
+ },
223
+ yAxisTypeTimePattern: {
224
+ name: "yAxisTypeTimePattern"
225
+ },
226
+ valueFormat: {
227
+ name: "tooltipValueFormat"
228
+ },
229
+ stacked: {
230
+ name: "yAxisStacked"
231
+ },
232
+ showYGrid: {
233
+ name: "yAxisGuideLines"
234
+ },
235
+ showXGrid: {
236
+ name: "xAxisGuideLines"
237
+ },
238
+ showValueLabel: {
239
+ name: "showValue"
240
+ },
241
+ low: {
242
+ name: "yAxisDomainLow"
243
+ },
244
+ high: {
245
+ name: "yAxisDomainHigh"
246
+ },
247
+ fillOpacity: {
248
+ name: "interpolateFillOpacity"
249
+ },
250
+ areaFillOpacity: {
251
+ name: "interpolateFillOpacity"
252
+ },
253
+ showToolbar: {
254
+ name: "titleVisible"
255
+ },
256
+ showCSV: {
257
+ name: "downloadButtonVisible"
258
+ }
259
+ };
260
+ function findKeyVal(object, key, val) {
261
+ var value;
262
+ for (var k in object) {
263
+ if (k === key && object[k] === val) {
264
+ value = object;
265
+ break;
266
+ }
267
+ if (object[k] && typeof object[k] === "object") {
268
+ value = findKeyVal(object[k], key, val);
269
+ if (value !== undefined) {
270
+ break;
271
+ }
272
+ }
273
+ }
274
+ return value;
275
+ }
276
+ function apply_to_dataviews(ddl2, dermObj) {
277
+ ddl2.dataviews.forEach(apply_to_dataview);
278
+ function apply_to_dataview(dv) {
279
+ var widgetId = dv.id;
280
+ var dermPanelObj = findKeyVal(dermObj, "__id", widgetId);
281
+ if (dermPanelObj) {
282
+ var dermPanelProps = dermPanelObj.__properties;
283
+ var dermWidgetObj = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
284
+ var dermWidgetProps = dermWidgetObj.__properties;
285
+ apply_class_mapping(dermWidgetObj);
286
+ apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
287
+ apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
288
+ if (dv.visualization.properties.chartType) {
289
+ dv.visualization.properties.charttype = dv.visualization.properties.chartType;
290
+ }
291
+ }
292
+ else {
293
+ console.warn(widgetId + " not found in dermObj");
294
+ }
295
+ function apply_class_mapping(dermWidgetObj) {
296
+ dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
297
+ dv.visualization.properties.__class = "marshaller_VizChartPanel";
298
+ if (!dv.visualization.properties.widget)
299
+ dv.visualization.properties.widget = {};
300
+ dv.visualization.properties.widget.__class = dv.visualization.__class;
301
+ function swap_with_supported_class(_class) {
302
+ return classMappings[_class] ? classMappings[_class] : _class;
303
+ }
304
+ }
305
+ function apply_panel_property_mapping(dermPanelProps, dermWidgetProps) {
306
+ dv.visualization.title = dermPanelProps.title || "";
307
+ dv.visualization.description = "";
308
+ dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
309
+ dv.visualization.chartType = dv.visualization.__class.split("_")[1];
310
+ for (var propName in dermPanelProps) {
311
+ if (typeof propertyMappings[propName] !== "undefined") {
312
+ var newPropName = propertyMappings[propName].name;
313
+ if (typeof propertyMappings[propName].transform === "function") {
314
+ dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
315
+ }
316
+ else {
317
+ dv.visualization.properties[newPropName] = dermPanelProps[propName];
318
+ }
319
+ }
320
+ }
321
+ if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
322
+ dv.visualization.properties.legendVisible = true;
323
+ }
324
+ }
325
+ function apply_widget_property_mapping(dermPanelProps, dermWidgetProps) {
326
+ dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
327
+ dv.visualization.description = ""; // TODO - should this map to anything?
328
+ dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
329
+ dv.visualization.chartType = dv.visualization.__class.split("_")[1];
330
+ var _loop_1 = function (propName) {
331
+ if (typeof propertyMappings[propName] !== "undefined") {
332
+ if (propertyMappings[propName] instanceof Array) {
333
+ propertyMappings[propName].forEach(function (p) {
334
+ var newPropName = p.name;
335
+ dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
336
+ if (typeof propertyMappings[propName].transform === "function") {
337
+ dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
338
+ }
339
+ else {
340
+ dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
341
+ }
342
+ });
343
+ }
344
+ else {
345
+ var newPropName = propertyMappings[propName].name;
346
+ dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
347
+ }
348
+ }
349
+ };
350
+ for (var propName in dermWidgetProps) {
351
+ _loop_1(propName);
352
+ }
353
+ }
354
+ }
355
+ }
356
+ function apply_to_properties_layout(ddl2, dermObj) {
357
+ var retVal = {
358
+ layout: []
359
+ };
360
+ if (!dermObj || !dermObj.__properties)
361
+ return;
362
+ dermObj.__properties.content.forEach(function (cell) {
363
+ var cellPosition = {
364
+ // TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
365
+ id: cell.__properties.widget.__id,
366
+ position: [
367
+ cell.__properties.gridCol,
368
+ cell.__properties.gridRow,
369
+ cell.__properties.gridColSpan,
370
+ cell.__properties.gridRowSpan
371
+ ]
372
+ };
373
+ retVal.layout.push(cellPosition);
374
+ });
375
+ return retVal;
376
+ }
377
+ function upgrade$1(ddl2, dermObj) {
378
+ apply_to_dataviews(ddl2, dermObj);
379
+ return apply_to_properties_layout(ddl2, dermObj);
380
+ }
381
+
382
+ function faCharFix(faChar) {
383
+ return faChar;
384
+ }
385
+ var DDLUpgrade = /** @class */ (function () {
386
+ function DDLUpgrade(ddl, baseUrl, wuid, toLowerCase) {
387
+ if (baseUrl === void 0) { baseUrl = "http://localhost:8010"; }
388
+ if (wuid === void 0) { wuid = "WUID"; }
389
+ if (toLowerCase === void 0) { toLowerCase = true; }
390
+ this._datasources = {};
391
+ this._datasourceUpdates = {};
392
+ this._visualizations = {};
393
+ this._ddl2Datasources = {};
394
+ this._ddl2DatasourceFields = {};
395
+ this._ddl2Dataviews = {};
396
+ this._ddl2DataviewActivities = {};
397
+ this._ddl = ddl;
398
+ this._baseUrl = baseUrl;
399
+ this._wuid = wuid;
400
+ this._toLowerCase = toLowerCase;
401
+ this.indexDDL();
402
+ this.readDDL();
403
+ }
404
+ DDLUpgrade.prototype.toLowerCase = function (s) {
405
+ return this._toLowerCase ? s.toLowerCase() : s;
406
+ };
407
+ DDLUpgrade.prototype.isVizDatasourceRoxie = function (viz) {
408
+ if (viz.source) {
409
+ var ds = this._datasources[viz.source.id];
410
+ if (isHipieDatasource(ds)) {
411
+ return true;
412
+ }
413
+ }
414
+ return false;
415
+ };
416
+ DDLUpgrade.prototype.getDatasourceOutputs = function (dsID, vizID) {
417
+ var retVal = [];
418
+ var datasource = this._datasources[dsID];
419
+ for (var _i = 0, _a = datasource.outputs; _i < _a.length; _i++) {
420
+ var output = _a[_i];
421
+ if (output.notify) {
422
+ for (var _b = 0, _c = output.notify; _b < _c.length; _b++) {
423
+ var notify = _c[_b];
424
+ if (notify === vizID) {
425
+ retVal.push({
426
+ datasource: datasource,
427
+ output: output
428
+ });
429
+ }
430
+ }
431
+ }
432
+ }
433
+ return retVal;
434
+ };
435
+ DDLUpgrade.prototype.getDatasourceFilters = function (dsID, vizID) {
436
+ var retVal = {};
437
+ for (var _i = 0, _a = this.getDatasourceOutputs(dsID, vizID); _i < _a.length; _i++) {
438
+ var dsOut = _a[_i];
439
+ if (dsOut.output.filter) {
440
+ for (var _b = 0, _c = dsOut.output.filter; _b < _c.length; _b++) {
441
+ var filter = _c[_b];
442
+ retVal[filter.fieldid] = {
443
+ datasource: dsOut.datasource,
444
+ output: dsOut.output,
445
+ filter: filter
446
+ };
447
+ }
448
+ }
449
+ }
450
+ return retVal;
451
+ };
452
+ DDLUpgrade.prototype.indexDDL = function () {
453
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
454
+ var dash = _a[_i];
455
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
456
+ var viz = _c[_b];
457
+ this._visualizations[viz.id] = viz;
458
+ }
459
+ }
460
+ for (var _d = 0, _e = this._ddl.datasources; _d < _e.length; _d++) {
461
+ var ds = _e[_d];
462
+ this._datasources[ds.id] = ds;
463
+ for (var _f = 0, _g = ds.outputs; _f < _g.length; _f++) {
464
+ var output = _g[_f];
465
+ if (output.notify) {
466
+ for (var _h = 0, _j = output.notify; _h < _j.length; _h++) {
467
+ var notify = _j[_h];
468
+ this._datasourceUpdates[notify] = {
469
+ id: ds.id,
470
+ output: output.from || output.id
471
+ };
472
+ }
473
+ }
474
+ }
475
+ }
476
+ };
477
+ DDLUpgrade.prototype.readDDL = function () {
478
+ for (var _i = 0, _a = this._ddl.datasources; _i < _a.length; _i++) {
479
+ var ds = _a[_i];
480
+ if (isWorkunitDatasource(ds)) {
481
+ var ddl2DS = {
482
+ type: "wuresult",
483
+ id: ds.id,
484
+ url: this._baseUrl,
485
+ wuid: this._wuid,
486
+ outputs: {}
487
+ };
488
+ for (var _b = 0, _c = ds.outputs; _b < _c.length; _b++) {
489
+ var output = _c[_b];
490
+ this.output2output(output, ddl2DS.outputs);
491
+ }
492
+ this._ddl2Datasources[ds.id] = ddl2DS;
493
+ }
494
+ else if (isDatabombDatasource(ds)) ;
495
+ else {
496
+ var urlParts = ds.URL.split("/WsEcl/submit/query/");
497
+ var hostParts = urlParts[0];
498
+ var roxieParts = urlParts[1].split("/");
499
+ var ddl2DS = {
500
+ type: "hipie",
501
+ id: ds.id,
502
+ url: hostParts,
503
+ querySet: roxieParts[0],
504
+ queryID: roxieParts[1],
505
+ inputs: [],
506
+ outputs: {}
507
+ };
508
+ for (var _d = 0, _e = ds.outputs; _d < _e.length; _d++) {
509
+ var output = _e[_d];
510
+ this.output2output(output, ddl2DS.outputs);
511
+ }
512
+ this._ddl2Datasources[ds.id] = ddl2DS;
513
+ }
514
+ }
515
+ for (var _f = 0, _g = this._ddl.dashboards; _f < _g.length; _f++) {
516
+ var dash = _g[_f];
517
+ for (var _h = 0, _j = dash.visualizations; _h < _j.length; _h++) {
518
+ var viz = _j[_h];
519
+ if (viz.type === "FORM") {
520
+ this._ddl2Datasources[viz.id] = {
521
+ type: "form",
522
+ id: viz.id,
523
+ fields: this.formFields2field(viz.fields)
524
+ };
525
+ this._datasourceUpdates[viz.id] = { id: viz.id };
526
+ }
527
+ else if (viz.type === "SLIDER") {
528
+ this._ddl2Datasources[viz.id] = {
529
+ type: "form",
530
+ id: viz.id,
531
+ fields: this.formFields2field(viz.fields, true)
532
+ };
533
+ this._datasourceUpdates[viz.id] = { id: viz.id };
534
+ }
535
+ this._ddl2Dataviews[viz.id] = this.anyViz2view(viz);
536
+ }
537
+ }
538
+ this.readGroupBy();
539
+ this.readFilters();
540
+ this.readSort();
541
+ this.readMappings();
542
+ };
543
+ DDLUpgrade.prototype.readGroupBy = function () {
544
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
545
+ var dash = _a[_i];
546
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
547
+ var viz = _c[_b];
548
+ if (viz.fields) {
549
+ var projectTransformations = [];
550
+ var groupByColumns = [];
551
+ var aggrFields = [];
552
+ for (var _d = 0, _e = viz.fields; _d < _e.length; _d++) {
553
+ var field = _e[_d];
554
+ if (field.properties && field.properties.function) {
555
+ switch (field.properties.function) {
556
+ case "SUM":
557
+ case "MIN":
558
+ case "MAX":
559
+ aggrFields.push({
560
+ type: this.func2aggr(field.properties.function),
561
+ inFieldID: this.toLowerCase(field.properties.params.param1),
562
+ fieldID: this.toLowerCase(field.id)
563
+ });
564
+ break;
565
+ case "AVE":
566
+ aggrFields.push({
567
+ type: this.func2aggr(field.properties.function),
568
+ inFieldID: this.toLowerCase(field.properties.params.param1),
569
+ baseCountFieldID: field.properties.params.param2 ? this.toLowerCase(field.properties.params.param2) : undefined,
570
+ fieldID: this.toLowerCase(field.id)
571
+ });
572
+ break;
573
+ case "SCALE":
574
+ if (typeof field.properties.params.param1 === "object") {
575
+ var props = field.properties.params.param1;
576
+ switch (props.function) {
577
+ case "SUM":
578
+ case "MIN":
579
+ case "MAX":
580
+ aggrFields.push({
581
+ type: this.func2aggr(props.function),
582
+ inFieldID: this.toLowerCase(props.params.param1),
583
+ fieldID: this.toLowerCase(field.id)
584
+ });
585
+ break;
586
+ }
587
+ }
588
+ projectTransformations.push({
589
+ type: "scale",
590
+ sourceFieldID: this.toLowerCase(field.id),
591
+ fieldID: this.toLowerCase(field.id),
592
+ factor: +field.properties.params.param2
593
+ });
594
+ break;
595
+ default:
596
+ groupByColumns.push(this.toLowerCase(field.id));
597
+ throw new Error("Unhandled field function: ".concat(field.properties.function));
598
+ }
599
+ }
600
+ else {
601
+ groupByColumns.push(this.toLowerCase(field.id));
602
+ }
603
+ }
604
+ if (projectTransformations.length) {
605
+ this._ddl2DataviewActivities[viz.id].project.transformations = projectTransformations;
606
+ }
607
+ if (aggrFields.length) {
608
+ this._ddl2DataviewActivities[viz.id].groupBy.groupByIDs = __spreadArray([], groupByColumns, true);
609
+ this._ddl2DataviewActivities[viz.id].groupBy.aggregates = aggrFields;
610
+ }
611
+ }
612
+ }
613
+ }
614
+ };
615
+ DDLUpgrade.prototype.func2aggr = function (func) {
616
+ switch (func) {
617
+ case "SUM":
618
+ return "sum";
619
+ case "AVE":
620
+ return "mean";
621
+ case "MIN":
622
+ return "min";
623
+ case "MAX":
624
+ return "max";
625
+ }
626
+ throw new Error("Unknown DDL1 Function Type: ".concat(func));
627
+ };
628
+ DDLUpgrade.prototype.readMappings = function () {
629
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
630
+ var dash = _a[_i];
631
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
632
+ var viz = _c[_b];
633
+ if (isFormVisualization(viz)) ;
634
+ else if (isPieVisualization(viz)) {
635
+ this.readPieMappings(viz);
636
+ }
637
+ else if (isChoroVisualization(viz)) {
638
+ this.readChoroMappings(viz);
639
+ }
640
+ else if (isLineVisualization(viz)) {
641
+ this.readLineMappings(viz);
642
+ }
643
+ else if (isTableVisualization(viz)) {
644
+ this.readTableMappings(viz);
645
+ }
646
+ else if (isGraphVisualization(viz)) {
647
+ this.readGraphMappings(viz);
648
+ }
649
+ else if (isSliderVisualization(viz)) {
650
+ this.readSliderMappings(viz);
651
+ }
652
+ else {
653
+ throw new Error("Unkown DDL1 mapping type: ".concat(viz.type));
654
+ }
655
+ }
656
+ }
657
+ };
658
+ DDLUpgrade.prototype.readPieMappings = function (viz) {
659
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
660
+ mappings.transformations.push({
661
+ fieldID: "label",
662
+ type: "=",
663
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
664
+ });
665
+ mappings.transformations.push({
666
+ fieldID: "weight",
667
+ type: "=",
668
+ sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
669
+ });
670
+ };
671
+ DDLUpgrade.prototype.readChoroMappings = function (viz) {
672
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
673
+ mappings.transformations.push({
674
+ fieldID: "label",
675
+ type: "=",
676
+ sourceFieldID: this.toLowerCase(this.anyChoroMapping2label(viz.source.mappings))
677
+ });
678
+ mappings.transformations.push({
679
+ fieldID: "weight",
680
+ type: "=",
681
+ sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
682
+ });
683
+ };
684
+ DDLUpgrade.prototype.anyChoroMapping2label = function (mapping) {
685
+ return mapping.state || mapping.county || mapping.geohash;
686
+ };
687
+ DDLUpgrade.prototype.readLineMappings = function (viz) {
688
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
689
+ mappings.transformations.push({
690
+ fieldID: viz.source.mappings.x[0],
691
+ type: "=",
692
+ sourceFieldID: this.toLowerCase(viz.source.mappings.x[0])
693
+ });
694
+ for (var i = 0; i < viz.source.mappings.y.length; ++i) {
695
+ mappings.transformations.push({
696
+ fieldID: viz.source.mappings.y[i],
697
+ type: "=",
698
+ sourceFieldID: this.toLowerCase(viz.source.mappings.y[i])
699
+ });
700
+ }
701
+ };
702
+ DDLUpgrade.prototype.readTableMappings = function (viz) {
703
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
704
+ for (var i = 0; i < viz.label.length; ++i) {
705
+ mappings.transformations.push({
706
+ fieldID: viz.label[i],
707
+ type: "=",
708
+ sourceFieldID: this.toLowerCase(viz.source.mappings.value[i])
709
+ });
710
+ }
711
+ };
712
+ DDLUpgrade.prototype.readGraphEnums = function (valueMappings, annotation) {
713
+ if (annotation === void 0) { annotation = false; }
714
+ var retVal = [];
715
+ if (valueMappings) {
716
+ for (var value in valueMappings) {
717
+ var newValue = {};
718
+ for (var key in valueMappings[value]) {
719
+ if (key === "faChar") {
720
+ newValue[key] = faCharFix(valueMappings[value][key]);
721
+ }
722
+ else if (annotation && key.indexOf("icon_") === 0) {
723
+ console.warn("Deprecated flag property: " + key);
724
+ newValue[key.split("icon_")[1]] = valueMappings[value][key];
725
+ }
726
+ else {
727
+ newValue[key] = valueMappings[value][key];
728
+ }
729
+ }
730
+ // remove v1.x "0" annotations as they equated to "nothing" ---
731
+ if (!annotation || value !== "0") {
732
+ retVal.push({
733
+ value: value,
734
+ newValue: newValue
735
+ });
736
+ }
737
+ }
738
+ }
739
+ return retVal;
740
+ };
741
+ DDLUpgrade.prototype.readGraphMappings = function (viz) {
742
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
743
+ mappings.transformations.push({
744
+ fieldID: "uid",
745
+ type: "=",
746
+ sourceFieldID: this.toLowerCase(viz.source.mappings.uid)
747
+ });
748
+ mappings.transformations.push({
749
+ fieldID: "label",
750
+ type: "=",
751
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
752
+ });
753
+ if (viz.icon.fieldid) {
754
+ mappings.transformations.push({
755
+ fieldID: "icon",
756
+ type: "map",
757
+ sourceFieldID: this.toLowerCase(viz.icon.fieldid),
758
+ default: { fachar: faCharFix(viz.icon.faChar) },
759
+ mappings: this.readGraphEnums(viz.icon.valuemappings)
760
+ });
761
+ }
762
+ var idx = 0;
763
+ if (viz.flag) {
764
+ for (var _i = 0, _a = viz.flag; _i < _a.length; _i++) {
765
+ var flag = _a[_i];
766
+ if (flag.fieldid) {
767
+ mappings.transformations.push({
768
+ fieldID: "annotation_".concat(idx++),
769
+ type: "map",
770
+ sourceFieldID: this.toLowerCase(flag.fieldid),
771
+ default: {},
772
+ mappings: this.readGraphEnums(flag.valuemappings, true)
773
+ });
774
+ }
775
+ }
776
+ }
777
+ mappings.transformations.push({
778
+ fieldID: "links",
779
+ type: "=",
780
+ sourceFieldID: this.toLowerCase(viz.source.link.childfile),
781
+ transformations: [{
782
+ fieldID: "uid",
783
+ type: "=",
784
+ sourceFieldID: this.toLowerCase(viz.source.link.mappings.uid)
785
+ }]
786
+ });
787
+ };
788
+ DDLUpgrade.prototype.readSliderMappings = function (viz) {
789
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
790
+ mappings.transformations.push({
791
+ fieldID: "label",
792
+ type: "=",
793
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
794
+ });
795
+ };
796
+ DDLUpgrade.prototype.readFilters = function () {
797
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
798
+ var dash = _a[_i];
799
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
800
+ var viz = _c[_b];
801
+ if (viz.events) {
802
+ for (var eventID in viz.events) {
803
+ var event_1 = viz.events[eventID];
804
+ for (var _d = 0, _e = event_1.updates; _d < _e.length; _d++) {
805
+ var update = _e[_d];
806
+ var otherViz = this._ddl2Dataviews[update.visualization];
807
+ var dsFilters = this.getDatasourceFilters(update.datasource, otherViz.id);
808
+ if (update.mappings) {
809
+ if (isRoxieServiceRef(otherViz.datasource)) {
810
+ for (var key in update.mappings) {
811
+ otherViz.datasource.request.push({
812
+ source: viz.id,
813
+ remoteFieldID: this.toLowerCase(key),
814
+ localFieldID: this.toLowerCase(update.mappings[key])
815
+ });
816
+ }
817
+ }
818
+ else {
819
+ var condition = {
820
+ viewID: viz.id,
821
+ mappings: []
822
+ };
823
+ for (var key in update.mappings) {
824
+ var mapping = update.mappings[key];
825
+ var dsFilter = (mapping && dsFilters[mapping]) ? dsFilters[mapping].filter : undefined;
826
+ if (!dsFilter) {
827
+ console.warn("Select Mapping \"".concat(mapping, "\" in viz \"").concat(viz.id, "\" not found in filters for \"").concat(otherViz.id, "\""));
828
+ }
829
+ else {
830
+ condition.mappings.push({
831
+ remoteFieldID: this.toLowerCase(key),
832
+ localFieldID: this.toLowerCase(update.mappings[key]),
833
+ condition: this.rule2condition(dsFilter.rule),
834
+ nullable: dsFilter.nullable
835
+ });
836
+ }
837
+ }
838
+ this._ddl2DataviewActivities[otherViz.id].filters.conditions.push(condition);
839
+ }
840
+ }
841
+ }
842
+ }
843
+ }
844
+ }
845
+ }
846
+ };
847
+ DDLUpgrade.prototype.rule2condition = function (_) {
848
+ switch (_) {
849
+ case "set":
850
+ return "in";
851
+ case "notequals":
852
+ return "!=";
853
+ }
854
+ return _;
855
+ };
856
+ DDLUpgrade.prototype.readSort = function () {
857
+ var _this = this;
858
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
859
+ var dash = _a[_i];
860
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
861
+ var viz = _c[_b];
862
+ if (viz.source) {
863
+ if (viz.source.sort) {
864
+ var vizSort = this._ddl2DataviewActivities[viz.id].sort;
865
+ vizSort.conditions = viz.source.sort.map(function (s) {
866
+ if (s.indexOf("-") === 0) {
867
+ return {
868
+ fieldID: _this.toLowerCase(s.substr(1)),
869
+ descending: true
870
+ };
871
+ }
872
+ return {
873
+ fieldID: _this.toLowerCase(s),
874
+ descending: false
875
+ };
876
+ });
877
+ }
878
+ if (viz.source.first) {
879
+ var vizLimit = this._ddl2DataviewActivities[viz.id].limit;
880
+ vizLimit.limit = +viz.source.first;
881
+ }
882
+ }
883
+ }
884
+ }
885
+ };
886
+ DDLUpgrade.prototype.anyViz2view = function (viz) {
887
+ var project = {
888
+ type: "project",
889
+ transformations: []
890
+ };
891
+ var filters = {
892
+ type: "filter",
893
+ conditions: []
894
+ };
895
+ var groupBy = {
896
+ type: "groupby",
897
+ groupByIDs: [],
898
+ aggregates: []
899
+ };
900
+ var sort = {
901
+ type: "sort",
902
+ conditions: []
903
+ };
904
+ var limit = {
905
+ type: "limit",
906
+ limit: 0
907
+ };
908
+ var mappings = {
909
+ type: "mappings",
910
+ transformations: []
911
+ };
912
+ this._ddl2DataviewActivities[viz.id] = {
913
+ project: project,
914
+ filters: filters,
915
+ sort: sort,
916
+ groupBy: groupBy,
917
+ limit: limit,
918
+ mappings: mappings
919
+ };
920
+ var datasourceRef = this.isVizDatasourceRoxie(viz) ? {
921
+ id: this._datasourceUpdates[viz.id].id,
922
+ request: [],
923
+ output: this._datasourceUpdates[viz.id].output
924
+ } : {
925
+ id: this._datasourceUpdates[viz.id].id,
926
+ output: this._datasourceUpdates[viz.id].output
927
+ };
928
+ return {
929
+ id: viz.id,
930
+ datasource: datasourceRef,
931
+ activities: [
932
+ project,
933
+ filters,
934
+ sort,
935
+ groupBy,
936
+ limit
937
+ ],
938
+ 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 || {}) })
939
+ };
940
+ };
941
+ DDLUpgrade.prototype.type2chartType = function (chartType) {
942
+ switch (chartType) {
943
+ case "LINE":
944
+ return { chartType: "Line", __class: "chart_Line" };
945
+ case "BUBBLE":
946
+ return { chartType: "Bubble", __class: "chart_Bubble" };
947
+ case "PIE":
948
+ return { chartType: "Pie", __class: "chart_Pie" };
949
+ case "BAR":
950
+ return { chartType: "Column", __class: "chart_Column" };
951
+ case "FORM":
952
+ return { chartType: "FieldForm", __class: "form_FieldForm" };
953
+ case "WORD_CLOUD":
954
+ return { chartType: "WordCloud", __class: "chart_WordCloud" };
955
+ case "CHORO":
956
+ return { chartType: "ChoroplethStates", __class: "map_ChoroplethStates" };
957
+ case "SUMMARY":
958
+ return { chartType: "Summary", __class: "chart_Summary" };
959
+ case "SLIDER":
960
+ return { chartType: "FieldForm", __class: "form_FieldForm" };
961
+ case "HEAT_MAP":
962
+ return { chartType: "HeatMap", __class: "other_HeatMap" };
963
+ case "2DCHART":
964
+ return { chartType: "Column", __class: "chart_Column" };
965
+ case "GRAPH":
966
+ return { chartType: "AdjacencyGraph", __class: "graph_AdjacencyGraph" };
967
+ case "TABLE":
968
+ default:
969
+ return { chartType: "Table", __class: "dgrid_Table" };
970
+ }
971
+ };
972
+ DDLUpgrade.prototype.formFields2field = function (fields, slider) {
973
+ var _this = this;
974
+ if (slider === void 0) { slider = false; }
975
+ if (!fields)
976
+ return [];
977
+ return fields.map(function (field) {
978
+ switch (field.properties.type) {
979
+ case "range":
980
+ return {
981
+ type: "range",
982
+ id: field.id,
983
+ default: (field.properties.default ? field.properties.default : undefined)
984
+ };
985
+ case "dataset":
986
+ return {
987
+ type: "dataset",
988
+ id: field.id,
989
+ default: [],
990
+ children: []
991
+ };
992
+ default:
993
+ return {
994
+ type: _this.formFieldType2fieldType(field.properties.datatype, slider),
995
+ id: field.id,
996
+ default: field.properties.default ? field.properties.default[0] : undefined
997
+ };
998
+ }
999
+ });
1000
+ };
1001
+ DDLUpgrade.prototype.formFieldType2fieldType = function (fieldType, slider) {
1002
+ switch (fieldType) {
1003
+ case "bool":
1004
+ case "boolean":
1005
+ return "boolean";
1006
+ case "integer":
1007
+ case "unsigned":
1008
+ case "float":
1009
+ case "double":
1010
+ case "real":
1011
+ return "number";
1012
+ case "string":
1013
+ return "string";
1014
+ default:
1015
+ return slider ? "number" : "string";
1016
+ }
1017
+ };
1018
+ DDLUpgrade.prototype.output2output = function (output, target) {
1019
+ target[output.from || output.id] = {
1020
+ fields: this.filters2fields(output.filter)
1021
+ };
1022
+ };
1023
+ DDLUpgrade.prototype.filters2fields = function (filters) {
1024
+ if (!filters)
1025
+ return [];
1026
+ return filters.filter(function (filter) {
1027
+ var idParts = filter.fieldid.split("-");
1028
+ return idParts.length === 1 || idParts[1] === "range";
1029
+ }).map(function (filter) {
1030
+ var idParts = filter.fieldid.split("-");
1031
+ var retVal = {
1032
+ type: "string",
1033
+ id: idParts[0]
1034
+ };
1035
+ return retVal;
1036
+ });
1037
+ };
1038
+ DDLUpgrade.prototype.getVizField = function (vizID, fieldID) {
1039
+ return {
1040
+ type: "string",
1041
+ id: "",
1042
+ default: ""
1043
+ };
1044
+ };
1045
+ DDLUpgrade.prototype.writeDatasources = function () {
1046
+ var retVal = [];
1047
+ for (var id in this._ddl2Datasources) {
1048
+ retVal.push(this._ddl2Datasources[id]);
1049
+ }
1050
+ return retVal;
1051
+ };
1052
+ DDLUpgrade.prototype.writeDataviews = function () {
1053
+ var retVal = [];
1054
+ for (var id in this._ddl2Dataviews) {
1055
+ retVal.push(this._ddl2Dataviews[id]);
1056
+ }
1057
+ return retVal;
1058
+ };
1059
+ DDLUpgrade.prototype.writeProperties = function () {
1060
+ return {
1061
+ // TODO
1062
+ };
1063
+ };
1064
+ DDLUpgrade.prototype.write = function () {
1065
+ return {
1066
+ version: "2.2.1",
1067
+ createdBy: {
1068
+ name: PKG_NAME,
1069
+ version: PKG_VERSION
1070
+ },
1071
+ datasources: this.writeDatasources(),
1072
+ dataviews: this.writeDataviews(),
1073
+ properties: this.writeProperties()
1074
+ };
1075
+ };
1076
+ return DDLUpgrade;
1077
+ }());
1078
+ function upgrade(ddl, baseUrl, wuid, toLowerCase, dermatologyJson) {
1079
+ if (toLowerCase === void 0) { toLowerCase = true; }
1080
+ if (dermatologyJson === void 0) { dermatologyJson = {}; }
1081
+ var ddlUp = new DDLUpgrade(ddl, baseUrl, wuid, toLowerCase);
1082
+ var retVal = ddlUp.write();
1083
+ retVal.properties = upgrade$1(retVal, dermatologyJson);
1084
+ return retVal;
1085
1085
  }
1086
1086
 
1087
1087
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -9805,28 +9805,28 @@ var _ddl2Schema = /*#__PURE__*/Object.freeze({
9805
9805
  'default': v2
9806
9806
  });
9807
9807
 
9808
- var Ajv = ajv || _Ajv;
9809
- var ddl2Schema = _ddl2Schema;
9810
- var options = {
9811
- allErrors: false,
9812
- verbose: true,
9813
- jsonPointers: false
9814
- };
9815
- function doValidate(ddl, schema) {
9816
- var ajv = new Ajv(options);
9817
- var validate = ajv.compile(schema);
9818
- var success = validate(ddl);
9819
- return {
9820
- success: success,
9821
- errors: validate.errors
9822
- };
9823
- }
9824
- function validate2(ddl) {
9825
- return doValidate(ddl, _ddl2Schema);
9808
+ var Ajv = ajv || _Ajv;
9809
+ var ddl2Schema = _ddl2Schema;
9810
+ var options = {
9811
+ allErrors: false,
9812
+ verbose: true,
9813
+ jsonPointers: false
9814
+ };
9815
+ function doValidate(ddl, schema) {
9816
+ var ajv = new Ajv(options);
9817
+ var validate = ajv.compile(schema);
9818
+ var success = validate(ddl);
9819
+ return {
9820
+ success: success,
9821
+ errors: validate.errors
9822
+ };
9823
+ }
9824
+ function validate2(ddl) {
9825
+ return doValidate(ddl, _ddl2Schema);
9826
9826
  }
9827
9827
 
9828
- function isDDL2Schema(ref) {
9829
- return ref.version !== undefined && ref.datasources !== undefined && ref.dataviews !== undefined;
9828
+ function isDDL2Schema(ref) {
9829
+ return ref.version !== undefined && ref.datasources !== undefined && ref.dataviews !== undefined;
9830
9830
  }
9831
9831
 
9832
9832
  export { BUILD_VERSION, v1 as DDL1, v2$1 as DDL2, PKG_NAME, PKG_VERSION, ddl2Schema, isDDL2Schema, upgrade, validate2 };