@hpcc-js/ddl-shim 2.24.0 → 2.25.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 ADDED
@@ -0,0 +1,2656 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ var fs = require('fs');
6
+
7
+ function _interopNamespaceDefault(e) {
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
25
+
26
+ var $ref = "#/definitions/Schema";
27
+ var $schema = "http://json-schema.org/draft-07/schema#";
28
+ var definitions = {
29
+ ActivityType: {
30
+ anyOf: [
31
+ {
32
+ $ref: "#/definitions/IFilter"
33
+ },
34
+ {
35
+ $ref: "#/definitions/IProject"
36
+ },
37
+ {
38
+ $ref: "#/definitions/IGroupBy"
39
+ },
40
+ {
41
+ $ref: "#/definitions/ISort"
42
+ },
43
+ {
44
+ $ref: "#/definitions/ILimit"
45
+ },
46
+ {
47
+ $ref: "#/definitions/IMappings"
48
+ }
49
+ ]
50
+ },
51
+ AggregateType: {
52
+ anyOf: [
53
+ {
54
+ $ref: "#/definitions/IAggregate"
55
+ },
56
+ {
57
+ $ref: "#/definitions/ICount"
58
+ }
59
+ ]
60
+ },
61
+ Dataset: {
62
+ items: {
63
+ },
64
+ type: "array"
65
+ },
66
+ DatasourceType: {
67
+ anyOf: [
68
+ {
69
+ $ref: "#/definitions/IWUResult"
70
+ },
71
+ {
72
+ $ref: "#/definitions/ILogicalFile"
73
+ },
74
+ {
75
+ $ref: "#/definitions/IRoxieService"
76
+ },
77
+ {
78
+ $ref: "#/definitions/IHipieService"
79
+ },
80
+ {
81
+ $ref: "#/definitions/IRestService"
82
+ },
83
+ {
84
+ $ref: "#/definitions/IForm"
85
+ },
86
+ {
87
+ $ref: "#/definitions/IDatabomb"
88
+ }
89
+ ]
90
+ },
91
+ FilterCondition: {
92
+ anyOf: [
93
+ {
94
+ $ref: "#/definitions/IFilterCondition"
95
+ },
96
+ {
97
+ $ref: "#/definitions/IFilterStaticCondition"
98
+ }
99
+ ]
100
+ },
101
+ IAggregate: {
102
+ additionalProperties: false,
103
+ properties: {
104
+ baseCountFieldID: {
105
+ type: "string"
106
+ },
107
+ fieldID: {
108
+ type: "string"
109
+ },
110
+ inFieldID: {
111
+ type: "string"
112
+ },
113
+ type: {
114
+ $ref: "#/definitions/IAggregateType"
115
+ }
116
+ },
117
+ required: [
118
+ "fieldID",
119
+ "type",
120
+ "inFieldID"
121
+ ],
122
+ type: "object"
123
+ },
124
+ IAggregateType: {
125
+ "enum": [
126
+ "min",
127
+ "max",
128
+ "sum",
129
+ "mean",
130
+ "variance",
131
+ "deviation"
132
+ ],
133
+ type: "string"
134
+ },
135
+ ICalculated: {
136
+ additionalProperties: false,
137
+ properties: {
138
+ fieldID: {
139
+ type: "string"
140
+ },
141
+ sourceFieldID1: {
142
+ type: "string"
143
+ },
144
+ sourceFieldID2: {
145
+ type: "string"
146
+ },
147
+ type: {
148
+ $ref: "#/definitions/ICalculatedType"
149
+ }
150
+ },
151
+ required: [
152
+ "fieldID",
153
+ "type",
154
+ "sourceFieldID1",
155
+ "sourceFieldID2"
156
+ ],
157
+ type: "object"
158
+ },
159
+ ICalculatedType: {
160
+ "enum": [
161
+ "+",
162
+ "-",
163
+ "*",
164
+ "/"
165
+ ],
166
+ type: "string"
167
+ },
168
+ ICount: {
169
+ additionalProperties: false,
170
+ properties: {
171
+ fieldID: {
172
+ type: "string"
173
+ },
174
+ type: {
175
+ "const": "count",
176
+ type: "string"
177
+ }
178
+ },
179
+ required: [
180
+ "fieldID",
181
+ "type"
182
+ ],
183
+ type: "object"
184
+ },
185
+ IDatabomb: {
186
+ additionalProperties: false,
187
+ properties: {
188
+ fields: {
189
+ items: {
190
+ $ref: "#/definitions/IField"
191
+ },
192
+ type: "array"
193
+ },
194
+ format: {
195
+ $ref: "#/definitions/IDatabombFormat"
196
+ },
197
+ id: {
198
+ type: "string"
199
+ },
200
+ payload: {
201
+ type: "string"
202
+ },
203
+ type: {
204
+ "const": "databomb",
205
+ type: "string"
206
+ }
207
+ },
208
+ required: [
209
+ "fields",
210
+ "format",
211
+ "id",
212
+ "type"
213
+ ],
214
+ type: "object"
215
+ },
216
+ IDatabombFormat: {
217
+ "enum": [
218
+ "csv",
219
+ "tsv",
220
+ "json"
221
+ ],
222
+ type: "string"
223
+ },
224
+ IDatabombRef: {
225
+ additionalProperties: false,
226
+ properties: {
227
+ id: {
228
+ type: "string"
229
+ }
230
+ },
231
+ required: [
232
+ "id"
233
+ ],
234
+ type: "object"
235
+ },
236
+ IDatasource: {
237
+ additionalProperties: false,
238
+ properties: {
239
+ id: {
240
+ type: "string"
241
+ },
242
+ type: {
243
+ $ref: "#/definitions/IDatasourceType"
244
+ }
245
+ },
246
+ required: [
247
+ "type",
248
+ "id"
249
+ ],
250
+ type: "object"
251
+ },
252
+ IDatasourceRef: {
253
+ anyOf: [
254
+ {
255
+ $ref: "#/definitions/IDatabombRef"
256
+ },
257
+ {
258
+ $ref: "#/definitions/IWUResultRef"
259
+ },
260
+ {
261
+ $ref: "#/definitions/IRoxieServiceRef"
262
+ },
263
+ {
264
+ $ref: "#/definitions/IHipieSqlRef"
265
+ }
266
+ ]
267
+ },
268
+ IDatasourceType: {
269
+ "enum": [
270
+ "wuresult",
271
+ "logicalfile",
272
+ "roxie",
273
+ "hipie",
274
+ "rest",
275
+ "form",
276
+ "databomb"
277
+ ],
278
+ type: "string"
279
+ },
280
+ IEquals: {
281
+ additionalProperties: false,
282
+ properties: {
283
+ fieldID: {
284
+ type: "string"
285
+ },
286
+ sourceFieldID: {
287
+ type: "string"
288
+ },
289
+ transformations: {
290
+ items: {
291
+ $ref: "#/definitions/MultiTransformationType"
292
+ },
293
+ type: "array"
294
+ },
295
+ type: {
296
+ "const": "=",
297
+ type: "string"
298
+ }
299
+ },
300
+ required: [
301
+ "fieldID",
302
+ "type",
303
+ "sourceFieldID"
304
+ ],
305
+ type: "object"
306
+ },
307
+ IField: {
308
+ anyOf: [
309
+ {
310
+ $ref: "#/definitions/IFieldBoolean"
311
+ },
312
+ {
313
+ $ref: "#/definitions/IFieldNumber"
314
+ },
315
+ {
316
+ $ref: "#/definitions/IFieldNumber64"
317
+ },
318
+ {
319
+ $ref: "#/definitions/IFieldString"
320
+ },
321
+ {
322
+ $ref: "#/definitions/IFieldRange"
323
+ },
324
+ {
325
+ $ref: "#/definitions/IFieldDataset"
326
+ },
327
+ {
328
+ $ref: "#/definitions/IFieldSet"
329
+ },
330
+ {
331
+ $ref: "#/definitions/IFieldObject"
332
+ }
333
+ ]
334
+ },
335
+ IFieldBoolean: {
336
+ additionalProperties: false,
337
+ properties: {
338
+ "default": {
339
+ type: "boolean"
340
+ },
341
+ id: {
342
+ type: "string"
343
+ },
344
+ type: {
345
+ "const": "boolean",
346
+ type: "string"
347
+ }
348
+ },
349
+ required: [
350
+ "type",
351
+ "id"
352
+ ],
353
+ type: "object"
354
+ },
355
+ IFieldDataset: {
356
+ additionalProperties: false,
357
+ properties: {
358
+ children: {
359
+ items: {
360
+ $ref: "#/definitions/IField"
361
+ },
362
+ type: "array"
363
+ },
364
+ "default": {
365
+ $ref: "#/definitions/Dataset"
366
+ },
367
+ id: {
368
+ type: "string"
369
+ },
370
+ type: {
371
+ "const": "dataset",
372
+ type: "string"
373
+ }
374
+ },
375
+ required: [
376
+ "type",
377
+ "id",
378
+ "children"
379
+ ],
380
+ type: "object"
381
+ },
382
+ IFieldNumber: {
383
+ additionalProperties: false,
384
+ properties: {
385
+ "default": {
386
+ type: "number"
387
+ },
388
+ id: {
389
+ type: "string"
390
+ },
391
+ type: {
392
+ "const": "number",
393
+ type: "string"
394
+ }
395
+ },
396
+ required: [
397
+ "type",
398
+ "id"
399
+ ],
400
+ type: "object"
401
+ },
402
+ IFieldNumber64: {
403
+ additionalProperties: false,
404
+ properties: {
405
+ "default": {
406
+ $ref: "#/definitions/Number64"
407
+ },
408
+ id: {
409
+ type: "string"
410
+ },
411
+ type: {
412
+ "const": "number64",
413
+ type: "string"
414
+ }
415
+ },
416
+ required: [
417
+ "type",
418
+ "id"
419
+ ],
420
+ type: "object"
421
+ },
422
+ IFieldObject: {
423
+ additionalProperties: false,
424
+ properties: {
425
+ "default": {
426
+ type: "object"
427
+ },
428
+ fields: {
429
+ additionalProperties: {
430
+ $ref: "#/definitions/IField"
431
+ },
432
+ type: "object"
433
+ },
434
+ id: {
435
+ type: "string"
436
+ },
437
+ type: {
438
+ "const": "object",
439
+ type: "string"
440
+ }
441
+ },
442
+ required: [
443
+ "type",
444
+ "id",
445
+ "fields"
446
+ ],
447
+ type: "object"
448
+ },
449
+ IFieldRange: {
450
+ additionalProperties: false,
451
+ properties: {
452
+ "default": {
453
+ $ref: "#/definitions/Range"
454
+ },
455
+ id: {
456
+ type: "string"
457
+ },
458
+ type: {
459
+ "const": "range",
460
+ type: "string"
461
+ }
462
+ },
463
+ required: [
464
+ "type",
465
+ "id"
466
+ ],
467
+ type: "object"
468
+ },
469
+ IFieldSet: {
470
+ additionalProperties: false,
471
+ properties: {
472
+ "default": {
473
+ items: {
474
+ type: [
475
+ "string",
476
+ "number"
477
+ ]
478
+ },
479
+ type: "array"
480
+ },
481
+ fieldType: {
482
+ "enum": [
483
+ "string",
484
+ "number"
485
+ ],
486
+ type: "string"
487
+ },
488
+ id: {
489
+ type: "string"
490
+ },
491
+ type: {
492
+ "const": "set",
493
+ type: "string"
494
+ }
495
+ },
496
+ required: [
497
+ "type",
498
+ "id",
499
+ "fieldType"
500
+ ],
501
+ type: "object"
502
+ },
503
+ IFieldString: {
504
+ additionalProperties: false,
505
+ properties: {
506
+ "default": {
507
+ type: "string"
508
+ },
509
+ id: {
510
+ type: "string"
511
+ },
512
+ type: {
513
+ "const": "string",
514
+ type: "string"
515
+ }
516
+ },
517
+ required: [
518
+ "type",
519
+ "id"
520
+ ],
521
+ type: "object"
522
+ },
523
+ IFieldType: {
524
+ "enum": [
525
+ "boolean",
526
+ "number",
527
+ "number64",
528
+ "string",
529
+ "range",
530
+ "dataset",
531
+ "set",
532
+ "object"
533
+ ],
534
+ type: "string"
535
+ },
536
+ IFilter: {
537
+ additionalProperties: false,
538
+ properties: {
539
+ conditions: {
540
+ items: {
541
+ $ref: "#/definitions/FilterCondition"
542
+ },
543
+ type: "array"
544
+ },
545
+ type: {
546
+ "const": "filter",
547
+ type: "string"
548
+ }
549
+ },
550
+ required: [
551
+ "conditions",
552
+ "type"
553
+ ],
554
+ type: "object"
555
+ },
556
+ IFilterCondition: {
557
+ additionalProperties: false,
558
+ properties: {
559
+ mappings: {
560
+ items: {
561
+ $ref: "#/definitions/IMapping"
562
+ },
563
+ type: "array"
564
+ },
565
+ viewID: {
566
+ type: "string"
567
+ }
568
+ },
569
+ required: [
570
+ "viewID",
571
+ "mappings"
572
+ ],
573
+ type: "object"
574
+ },
575
+ IFilterStaticCondition: {
576
+ additionalProperties: false,
577
+ properties: {
578
+ condition: {
579
+ $ref: "#/definitions/IMappingConditionType"
580
+ },
581
+ localFieldID: {
582
+ type: "string"
583
+ },
584
+ value: {
585
+ type: [
586
+ "string",
587
+ "number"
588
+ ]
589
+ }
590
+ },
591
+ required: [
592
+ "localFieldID",
593
+ "condition",
594
+ "value"
595
+ ],
596
+ type: "object"
597
+ },
598
+ IForm: {
599
+ additionalProperties: false,
600
+ properties: {
601
+ fields: {
602
+ items: {
603
+ $ref: "#/definitions/IField"
604
+ },
605
+ type: "array"
606
+ },
607
+ id: {
608
+ type: "string"
609
+ },
610
+ type: {
611
+ "const": "form",
612
+ type: "string"
613
+ }
614
+ },
615
+ required: [
616
+ "fields",
617
+ "id",
618
+ "type"
619
+ ],
620
+ type: "object"
621
+ },
622
+ IGroupBy: {
623
+ additionalProperties: false,
624
+ properties: {
625
+ aggregates: {
626
+ items: {
627
+ $ref: "#/definitions/AggregateType"
628
+ },
629
+ type: "array"
630
+ },
631
+ groupByIDs: {
632
+ items: {
633
+ type: "string"
634
+ },
635
+ type: "array"
636
+ },
637
+ type: {
638
+ "const": "groupby",
639
+ type: "string"
640
+ }
641
+ },
642
+ required: [
643
+ "aggregates",
644
+ "groupByIDs",
645
+ "type"
646
+ ],
647
+ type: "object"
648
+ },
649
+ IHipieService: {
650
+ additionalProperties: false,
651
+ properties: {
652
+ id: {
653
+ type: "string"
654
+ },
655
+ inputs: {
656
+ items: {
657
+ $ref: "#/definitions/IField"
658
+ },
659
+ type: "array"
660
+ },
661
+ outputs: {
662
+ $ref: "#/definitions/OutputDict"
663
+ },
664
+ queryID: {
665
+ type: "string"
666
+ },
667
+ querySet: {
668
+ type: "string"
669
+ },
670
+ type: {
671
+ "const": "hipie",
672
+ type: "string"
673
+ },
674
+ url: {
675
+ type: "string"
676
+ }
677
+ },
678
+ required: [
679
+ "id",
680
+ "inputs",
681
+ "outputs",
682
+ "queryID",
683
+ "querySet",
684
+ "type",
685
+ "url"
686
+ ],
687
+ type: "object"
688
+ },
689
+ IHipieSqlRef: {
690
+ additionalProperties: false,
691
+ properties: {
692
+ id: {
693
+ type: "string"
694
+ }
695
+ },
696
+ required: [
697
+ "id"
698
+ ],
699
+ type: "object"
700
+ },
701
+ ILimit: {
702
+ additionalProperties: false,
703
+ properties: {
704
+ limit: {
705
+ type: "number"
706
+ },
707
+ type: {
708
+ "const": "limit",
709
+ type: "string"
710
+ }
711
+ },
712
+ required: [
713
+ "limit",
714
+ "type"
715
+ ],
716
+ type: "object"
717
+ },
718
+ ILogicalFile: {
719
+ additionalProperties: false,
720
+ properties: {
721
+ fields: {
722
+ items: {
723
+ $ref: "#/definitions/IField"
724
+ },
725
+ type: "array"
726
+ },
727
+ id: {
728
+ type: "string"
729
+ },
730
+ logicalFile: {
731
+ type: "string"
732
+ },
733
+ type: {
734
+ "const": "logicalfile",
735
+ type: "string"
736
+ },
737
+ url: {
738
+ type: "string"
739
+ }
740
+ },
741
+ required: [
742
+ "fields",
743
+ "id",
744
+ "logicalFile",
745
+ "type",
746
+ "url"
747
+ ],
748
+ type: "object"
749
+ },
750
+ IMap: {
751
+ additionalProperties: false,
752
+ properties: {
753
+ "default": {
754
+ },
755
+ fieldID: {
756
+ type: "string"
757
+ },
758
+ mappings: {
759
+ items: {
760
+ $ref: "#/definitions/IMapMapping"
761
+ },
762
+ type: "array"
763
+ },
764
+ sourceFieldID: {
765
+ type: "string"
766
+ },
767
+ type: {
768
+ "const": "map",
769
+ type: "string"
770
+ }
771
+ },
772
+ required: [
773
+ "fieldID",
774
+ "type",
775
+ "sourceFieldID",
776
+ "default",
777
+ "mappings"
778
+ ],
779
+ type: "object"
780
+ },
781
+ IMapMapping: {
782
+ additionalProperties: false,
783
+ properties: {
784
+ newValue: {
785
+ },
786
+ value: {
787
+ }
788
+ },
789
+ required: [
790
+ "value",
791
+ "newValue"
792
+ ],
793
+ type: "object"
794
+ },
795
+ IMapping: {
796
+ additionalProperties: false,
797
+ properties: {
798
+ condition: {
799
+ $ref: "#/definitions/IMappingConditionType"
800
+ },
801
+ localFieldID: {
802
+ type: "string"
803
+ },
804
+ nullable: {
805
+ type: "boolean"
806
+ },
807
+ remoteFieldID: {
808
+ type: "string"
809
+ }
810
+ },
811
+ required: [
812
+ "remoteFieldID",
813
+ "localFieldID",
814
+ "condition",
815
+ "nullable"
816
+ ],
817
+ type: "object"
818
+ },
819
+ IMappingConditionType: {
820
+ "enum": [
821
+ "==",
822
+ "!=",
823
+ ">",
824
+ ">=",
825
+ "<",
826
+ "<=",
827
+ "range",
828
+ "in"
829
+ ],
830
+ type: "string"
831
+ },
832
+ IMappings: {
833
+ additionalProperties: false,
834
+ properties: {
835
+ transformations: {
836
+ items: {
837
+ $ref: "#/definitions/ProjectTransformationType"
838
+ },
839
+ type: "array"
840
+ },
841
+ type: {
842
+ "const": "mappings",
843
+ type: "string"
844
+ }
845
+ },
846
+ required: [
847
+ "transformations",
848
+ "type"
849
+ ],
850
+ type: "object"
851
+ },
852
+ IMulti: {
853
+ additionalProperties: false,
854
+ properties: {
855
+ fieldID: {
856
+ type: "string"
857
+ },
858
+ transformations: {
859
+ items: {
860
+ $ref: "#/definitions/MultiTransformationType"
861
+ },
862
+ type: "array"
863
+ },
864
+ type: {
865
+ "const": "multi",
866
+ type: "string"
867
+ }
868
+ },
869
+ required: [
870
+ "fieldID",
871
+ "type",
872
+ "transformations"
873
+ ],
874
+ type: "object"
875
+ },
876
+ IOutput: {
877
+ additionalProperties: false,
878
+ properties: {
879
+ fields: {
880
+ items: {
881
+ $ref: "#/definitions/IField"
882
+ },
883
+ type: "array"
884
+ }
885
+ },
886
+ required: [
887
+ "fields"
888
+ ],
889
+ type: "object"
890
+ },
891
+ IProject: {
892
+ additionalProperties: false,
893
+ properties: {
894
+ transformations: {
895
+ items: {
896
+ $ref: "#/definitions/ProjectTransformationType"
897
+ },
898
+ type: "array"
899
+ },
900
+ type: {
901
+ "const": "project",
902
+ type: "string"
903
+ }
904
+ },
905
+ required: [
906
+ "transformations",
907
+ "type"
908
+ ],
909
+ type: "object"
910
+ },
911
+ IProperties: {
912
+ type: "object"
913
+ },
914
+ IRequestField: {
915
+ additionalProperties: false,
916
+ properties: {
917
+ localFieldID: {
918
+ type: "string"
919
+ },
920
+ remoteFieldID: {
921
+ type: "string"
922
+ },
923
+ source: {
924
+ type: "string"
925
+ },
926
+ value: {
927
+ type: "string"
928
+ }
929
+ },
930
+ required: [
931
+ "localFieldID",
932
+ "source",
933
+ "remoteFieldID",
934
+ "value"
935
+ ],
936
+ type: "object"
937
+ },
938
+ IRestService: {
939
+ additionalProperties: false,
940
+ properties: {
941
+ action: {
942
+ type: "string"
943
+ },
944
+ id: {
945
+ type: "string"
946
+ },
947
+ inputs: {
948
+ items: {
949
+ $ref: "#/definitions/IField"
950
+ },
951
+ type: "array"
952
+ },
953
+ mode: {
954
+ "enum": [
955
+ "get",
956
+ "post"
957
+ ],
958
+ type: "string"
959
+ },
960
+ outputs: {
961
+ $ref: "#/definitions/OutputDict"
962
+ },
963
+ type: {
964
+ "const": "rest",
965
+ type: "string"
966
+ },
967
+ url: {
968
+ type: "string"
969
+ }
970
+ },
971
+ required: [
972
+ "action",
973
+ "id",
974
+ "inputs",
975
+ "outputs",
976
+ "type",
977
+ "url"
978
+ ],
979
+ type: "object"
980
+ },
981
+ IRoxieService: {
982
+ additionalProperties: false,
983
+ properties: {
984
+ id: {
985
+ type: "string"
986
+ },
987
+ inputs: {
988
+ items: {
989
+ $ref: "#/definitions/IField"
990
+ },
991
+ type: "array"
992
+ },
993
+ outputs: {
994
+ $ref: "#/definitions/OutputDict"
995
+ },
996
+ queryID: {
997
+ type: "string"
998
+ },
999
+ querySet: {
1000
+ type: "string"
1001
+ },
1002
+ type: {
1003
+ "const": "roxie",
1004
+ type: "string"
1005
+ },
1006
+ url: {
1007
+ type: "string"
1008
+ }
1009
+ },
1010
+ required: [
1011
+ "id",
1012
+ "inputs",
1013
+ "outputs",
1014
+ "queryID",
1015
+ "querySet",
1016
+ "type",
1017
+ "url"
1018
+ ],
1019
+ type: "object"
1020
+ },
1021
+ IRoxieServiceRef: {
1022
+ additionalProperties: false,
1023
+ properties: {
1024
+ id: {
1025
+ type: "string"
1026
+ },
1027
+ output: {
1028
+ type: "string"
1029
+ },
1030
+ request: {
1031
+ items: {
1032
+ $ref: "#/definitions/IRequestField"
1033
+ },
1034
+ type: "array"
1035
+ }
1036
+ },
1037
+ required: [
1038
+ "id",
1039
+ "output",
1040
+ "request"
1041
+ ],
1042
+ type: "object"
1043
+ },
1044
+ IScale: {
1045
+ additionalProperties: false,
1046
+ properties: {
1047
+ factor: {
1048
+ type: "number"
1049
+ },
1050
+ fieldID: {
1051
+ type: "string"
1052
+ },
1053
+ sourceFieldID: {
1054
+ type: "string"
1055
+ },
1056
+ type: {
1057
+ "const": "scale",
1058
+ type: "string"
1059
+ }
1060
+ },
1061
+ required: [
1062
+ "fieldID",
1063
+ "type",
1064
+ "sourceFieldID",
1065
+ "factor"
1066
+ ],
1067
+ type: "object"
1068
+ },
1069
+ ISort: {
1070
+ additionalProperties: false,
1071
+ properties: {
1072
+ conditions: {
1073
+ items: {
1074
+ $ref: "#/definitions/ISortCondition"
1075
+ },
1076
+ type: "array"
1077
+ },
1078
+ type: {
1079
+ "const": "sort",
1080
+ type: "string"
1081
+ }
1082
+ },
1083
+ required: [
1084
+ "conditions",
1085
+ "type"
1086
+ ],
1087
+ type: "object"
1088
+ },
1089
+ ISortCondition: {
1090
+ additionalProperties: false,
1091
+ properties: {
1092
+ descending: {
1093
+ type: "boolean"
1094
+ },
1095
+ fieldID: {
1096
+ type: "string"
1097
+ }
1098
+ },
1099
+ required: [
1100
+ "fieldID",
1101
+ "descending"
1102
+ ],
1103
+ type: "object"
1104
+ },
1105
+ ITemplate: {
1106
+ additionalProperties: false,
1107
+ properties: {
1108
+ fieldID: {
1109
+ type: "string"
1110
+ },
1111
+ template: {
1112
+ type: "string"
1113
+ },
1114
+ type: {
1115
+ "const": "template",
1116
+ type: "string"
1117
+ }
1118
+ },
1119
+ required: [
1120
+ "fieldID",
1121
+ "type",
1122
+ "template"
1123
+ ],
1124
+ type: "object"
1125
+ },
1126
+ IView: {
1127
+ additionalProperties: false,
1128
+ properties: {
1129
+ activities: {
1130
+ items: {
1131
+ $ref: "#/definitions/ActivityType"
1132
+ },
1133
+ type: "array"
1134
+ },
1135
+ datasource: {
1136
+ $ref: "#/definitions/IDatasourceRef"
1137
+ },
1138
+ id: {
1139
+ type: "string"
1140
+ },
1141
+ visualization: {
1142
+ $ref: "#/definitions/IVisualization"
1143
+ }
1144
+ },
1145
+ required: [
1146
+ "id",
1147
+ "datasource",
1148
+ "activities",
1149
+ "visualization"
1150
+ ],
1151
+ type: "object"
1152
+ },
1153
+ IVisualization: {
1154
+ additionalProperties: false,
1155
+ properties: {
1156
+ __class: {
1157
+ type: "string"
1158
+ },
1159
+ chartType: {
1160
+ type: "string"
1161
+ },
1162
+ description: {
1163
+ type: "string"
1164
+ },
1165
+ id: {
1166
+ type: "string"
1167
+ },
1168
+ mappings: {
1169
+ $ref: "#/definitions/IMappings"
1170
+ },
1171
+ properties: {
1172
+ $ref: "#/definitions/IWidgetProperties"
1173
+ },
1174
+ secondaryDataviewID: {
1175
+ type: "string"
1176
+ },
1177
+ title: {
1178
+ type: "string"
1179
+ },
1180
+ visibility: {
1181
+ $ref: "#/definitions/VisibilityType"
1182
+ }
1183
+ },
1184
+ required: [
1185
+ "__class",
1186
+ "chartType",
1187
+ "id",
1188
+ "mappings",
1189
+ "properties",
1190
+ "title",
1191
+ "visibility"
1192
+ ],
1193
+ type: "object"
1194
+ },
1195
+ IWUResult: {
1196
+ additionalProperties: false,
1197
+ properties: {
1198
+ id: {
1199
+ type: "string"
1200
+ },
1201
+ outputs: {
1202
+ $ref: "#/definitions/OutputDict"
1203
+ },
1204
+ type: {
1205
+ "const": "wuresult",
1206
+ type: "string"
1207
+ },
1208
+ url: {
1209
+ type: "string"
1210
+ },
1211
+ wuid: {
1212
+ type: "string"
1213
+ }
1214
+ },
1215
+ required: [
1216
+ "id",
1217
+ "outputs",
1218
+ "type",
1219
+ "url",
1220
+ "wuid"
1221
+ ],
1222
+ type: "object"
1223
+ },
1224
+ IWUResultRef: {
1225
+ additionalProperties: false,
1226
+ properties: {
1227
+ id: {
1228
+ type: "string"
1229
+ },
1230
+ output: {
1231
+ type: "string"
1232
+ }
1233
+ },
1234
+ required: [
1235
+ "id",
1236
+ "output"
1237
+ ],
1238
+ type: "object"
1239
+ },
1240
+ IWidgetProperties: {
1241
+ additionalProperties: {
1242
+ anyOf: [
1243
+ {
1244
+ type: "string"
1245
+ },
1246
+ {
1247
+ items: {
1248
+ type: "string"
1249
+ },
1250
+ type: "array"
1251
+ },
1252
+ {
1253
+ type: "number"
1254
+ },
1255
+ {
1256
+ type: "boolean"
1257
+ },
1258
+ {
1259
+ not: {
1260
+ }
1261
+ },
1262
+ {
1263
+ $ref: "#/definitions/IWidgetProperties"
1264
+ },
1265
+ {
1266
+ items: {
1267
+ $ref: "#/definitions/IWidgetProperties"
1268
+ },
1269
+ type: "array"
1270
+ }
1271
+ ]
1272
+ },
1273
+ properties: {
1274
+ __class: {
1275
+ type: "string"
1276
+ }
1277
+ },
1278
+ required: [
1279
+ "__class"
1280
+ ],
1281
+ type: "object"
1282
+ },
1283
+ MultiTransformationType: {
1284
+ anyOf: [
1285
+ {
1286
+ $ref: "#/definitions/IEquals"
1287
+ },
1288
+ {
1289
+ $ref: "#/definitions/ICalculated"
1290
+ },
1291
+ {
1292
+ $ref: "#/definitions/IScale"
1293
+ },
1294
+ {
1295
+ $ref: "#/definitions/ITemplate"
1296
+ },
1297
+ {
1298
+ $ref: "#/definitions/IMap"
1299
+ }
1300
+ ]
1301
+ },
1302
+ Number64: {
1303
+ type: "string"
1304
+ },
1305
+ OutputDict: {
1306
+ additionalProperties: {
1307
+ $ref: "#/definitions/IOutput"
1308
+ },
1309
+ type: "object"
1310
+ },
1311
+ ProjectTransformationType: {
1312
+ anyOf: [
1313
+ {
1314
+ $ref: "#/definitions/MultiTransformationType"
1315
+ },
1316
+ {
1317
+ $ref: "#/definitions/IMulti"
1318
+ }
1319
+ ]
1320
+ },
1321
+ Range: {
1322
+ items: {
1323
+ type: [
1324
+ "number",
1325
+ "string"
1326
+ ]
1327
+ },
1328
+ maxItems: 2,
1329
+ minItems: 2,
1330
+ type: "array"
1331
+ },
1332
+ Schema: {
1333
+ additionalProperties: false,
1334
+ properties: {
1335
+ createdBy: {
1336
+ additionalProperties: false,
1337
+ properties: {
1338
+ name: {
1339
+ type: "string"
1340
+ },
1341
+ version: {
1342
+ type: "string"
1343
+ }
1344
+ },
1345
+ required: [
1346
+ "name",
1347
+ "version"
1348
+ ],
1349
+ type: "object"
1350
+ },
1351
+ datasources: {
1352
+ items: {
1353
+ $ref: "#/definitions/DatasourceType"
1354
+ },
1355
+ type: "array"
1356
+ },
1357
+ dataviews: {
1358
+ items: {
1359
+ $ref: "#/definitions/IView"
1360
+ },
1361
+ type: "array"
1362
+ },
1363
+ defs: {
1364
+ additionalProperties: false,
1365
+ properties: {
1366
+ activityTypes: {
1367
+ additionalProperties: false,
1368
+ properties: {
1369
+ filter: {
1370
+ $ref: "#/definitions/IFilter"
1371
+ },
1372
+ groupby: {
1373
+ $ref: "#/definitions/IGroupBy"
1374
+ },
1375
+ limit: {
1376
+ $ref: "#/definitions/ILimit"
1377
+ },
1378
+ mappings: {
1379
+ $ref: "#/definitions/IMappings"
1380
+ },
1381
+ project: {
1382
+ $ref: "#/definitions/IProject"
1383
+ },
1384
+ sort: {
1385
+ $ref: "#/definitions/ISort"
1386
+ }
1387
+ },
1388
+ required: [
1389
+ "filter",
1390
+ "project",
1391
+ "groupby",
1392
+ "sort",
1393
+ "limit",
1394
+ "mappings"
1395
+ ],
1396
+ type: "object"
1397
+ },
1398
+ aggregateTypes: {
1399
+ additionalProperties: false,
1400
+ properties: {
1401
+ aggregate: {
1402
+ $ref: "#/definitions/IAggregate"
1403
+ },
1404
+ count: {
1405
+ $ref: "#/definitions/ICount"
1406
+ }
1407
+ },
1408
+ required: [
1409
+ "aggregate",
1410
+ "count"
1411
+ ],
1412
+ type: "object"
1413
+ },
1414
+ datasourceRefTypes: {
1415
+ additionalProperties: false,
1416
+ properties: {
1417
+ roxieServiceRef: {
1418
+ $ref: "#/definitions/IRoxieServiceRef"
1419
+ },
1420
+ wuResultRef: {
1421
+ $ref: "#/definitions/IWUResultRef"
1422
+ }
1423
+ },
1424
+ required: [
1425
+ "wuResultRef",
1426
+ "roxieServiceRef"
1427
+ ],
1428
+ type: "object"
1429
+ },
1430
+ datasourceTypes: {
1431
+ additionalProperties: false,
1432
+ properties: {
1433
+ databomb: {
1434
+ $ref: "#/definitions/IDatabomb"
1435
+ },
1436
+ datasource: {
1437
+ $ref: "#/definitions/IDatasource"
1438
+ },
1439
+ form: {
1440
+ $ref: "#/definitions/IForm"
1441
+ },
1442
+ hipieService: {
1443
+ $ref: "#/definitions/IHipieService"
1444
+ },
1445
+ logicalFile: {
1446
+ $ref: "#/definitions/ILogicalFile"
1447
+ },
1448
+ roxieService: {
1449
+ $ref: "#/definitions/IRoxieService"
1450
+ },
1451
+ wuresult: {
1452
+ $ref: "#/definitions/IWUResult"
1453
+ }
1454
+ },
1455
+ required: [
1456
+ "datasource",
1457
+ "logicalFile",
1458
+ "form",
1459
+ "databomb",
1460
+ "wuresult",
1461
+ "hipieService",
1462
+ "roxieService"
1463
+ ],
1464
+ type: "object"
1465
+ },
1466
+ fieldTypes: {
1467
+ additionalProperties: false,
1468
+ properties: {
1469
+ dataset: {
1470
+ $ref: "#/definitions/Dataset"
1471
+ },
1472
+ field: {
1473
+ $ref: "#/definitions/IField"
1474
+ },
1475
+ fieldBoolean: {
1476
+ $ref: "#/definitions/IFieldBoolean"
1477
+ },
1478
+ fieldDataset: {
1479
+ $ref: "#/definitions/IFieldDataset"
1480
+ },
1481
+ fieldNumber: {
1482
+ $ref: "#/definitions/IFieldNumber"
1483
+ },
1484
+ fieldNumber64: {
1485
+ $ref: "#/definitions/IFieldNumber64"
1486
+ },
1487
+ fieldObject: {
1488
+ $ref: "#/definitions/IFieldObject"
1489
+ },
1490
+ fieldRange: {
1491
+ $ref: "#/definitions/IFieldRange"
1492
+ },
1493
+ fieldSet: {
1494
+ $ref: "#/definitions/IFieldSet"
1495
+ },
1496
+ fieldString: {
1497
+ $ref: "#/definitions/IFieldString"
1498
+ },
1499
+ fieldType: {
1500
+ $ref: "#/definitions/IFieldType"
1501
+ },
1502
+ number64: {
1503
+ $ref: "#/definitions/Number64"
1504
+ },
1505
+ range: {
1506
+ $ref: "#/definitions/Range"
1507
+ }
1508
+ },
1509
+ required: [
1510
+ "number64",
1511
+ "range",
1512
+ "dataset",
1513
+ "fieldType",
1514
+ "fieldBoolean",
1515
+ "fieldNumber",
1516
+ "fieldNumber64",
1517
+ "fieldString",
1518
+ "fieldRange",
1519
+ "fieldDataset",
1520
+ "fieldSet",
1521
+ "fieldObject",
1522
+ "field"
1523
+ ],
1524
+ type: "object"
1525
+ },
1526
+ transformationTypes: {
1527
+ additionalProperties: false,
1528
+ properties: {
1529
+ calculated: {
1530
+ $ref: "#/definitions/ICalculated"
1531
+ },
1532
+ equals: {
1533
+ $ref: "#/definitions/IEquals"
1534
+ },
1535
+ map: {
1536
+ $ref: "#/definitions/IMap"
1537
+ },
1538
+ multi: {
1539
+ $ref: "#/definitions/IMulti"
1540
+ },
1541
+ scale: {
1542
+ $ref: "#/definitions/IScale"
1543
+ },
1544
+ template: {
1545
+ $ref: "#/definitions/ITemplate"
1546
+ }
1547
+ },
1548
+ required: [
1549
+ "equals",
1550
+ "calculated",
1551
+ "scale",
1552
+ "template",
1553
+ "map",
1554
+ "multi"
1555
+ ],
1556
+ type: "object"
1557
+ }
1558
+ },
1559
+ required: [
1560
+ "fieldTypes",
1561
+ "datasourceTypes",
1562
+ "datasourceRefTypes",
1563
+ "activityTypes",
1564
+ "aggregateTypes",
1565
+ "transformationTypes"
1566
+ ],
1567
+ type: "object"
1568
+ },
1569
+ hipieProperties: {
1570
+ $ref: "#/definitions/IProperties"
1571
+ },
1572
+ properties: {
1573
+ $ref: "#/definitions/IProperties"
1574
+ },
1575
+ version: {
1576
+ "const": "2.2.1",
1577
+ type: "string"
1578
+ }
1579
+ },
1580
+ required: [
1581
+ "version",
1582
+ "createdBy",
1583
+ "datasources",
1584
+ "dataviews"
1585
+ ],
1586
+ type: "object"
1587
+ },
1588
+ VisibilityType: {
1589
+ "enum": [
1590
+ "normal",
1591
+ "flyout"
1592
+ ],
1593
+ type: "string"
1594
+ }
1595
+ };
1596
+ var v2 = {
1597
+ $ref: $ref,
1598
+ $schema: $schema,
1599
+ definitions: definitions
1600
+ };
1601
+
1602
+ var ddl2Schema = /*#__PURE__*/Object.freeze({
1603
+ __proto__: null,
1604
+ $ref: $ref,
1605
+ $schema: $schema,
1606
+ default: v2,
1607
+ definitions: definitions
1608
+ });
1609
+
1610
+ /******************************************************************************
1611
+ Copyright (c) Microsoft Corporation.
1612
+
1613
+ Permission to use, copy, modify, and/or distribute this software for any
1614
+ purpose with or without fee is hereby granted.
1615
+
1616
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1617
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1618
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1619
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1620
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1621
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1622
+ PERFORMANCE OF THIS SOFTWARE.
1623
+ ***************************************************************************** */
1624
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1625
+
1626
+
1627
+ var __assign = function() {
1628
+ __assign = Object.assign || function __assign(t) {
1629
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1630
+ s = arguments[i];
1631
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1632
+ }
1633
+ return t;
1634
+ };
1635
+ return __assign.apply(this, arguments);
1636
+ };
1637
+
1638
+ function __spreadArray(to, from, pack) {
1639
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1640
+ if (ar || !(i in from)) {
1641
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1642
+ ar[i] = from[i];
1643
+ }
1644
+ }
1645
+ return to.concat(ar || Array.prototype.slice.call(from));
1646
+ }
1647
+
1648
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1649
+ var e = new Error(message);
1650
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1651
+ };
1652
+
1653
+ var PKG_NAME = "@hpcc-js/ddl-shim";
1654
+ var PKG_VERSION = "2.25.0";
1655
+
1656
+ function isWorkunitDatasource(ref) {
1657
+ return ref.WUID !== undefined;
1658
+ }
1659
+ function isDatabombDatasource(ref) {
1660
+ return ref.databomb === true;
1661
+ }
1662
+ function isHipieDatasource(ref) {
1663
+ return ref.URL !== undefined;
1664
+ }
1665
+ function isPieVisualization(viz) {
1666
+ return viz.type === "PIE" || viz.type === "BAR";
1667
+ }
1668
+ function isLineVisualization(viz) {
1669
+ return viz.type === "LINE";
1670
+ }
1671
+ function isChoroVisualization(viz) {
1672
+ return viz.type === "CHORO";
1673
+ }
1674
+ function isTableVisualization(viz) {
1675
+ return viz.type === "TABLE";
1676
+ }
1677
+ function isSliderVisualization(viz) {
1678
+ return viz.type === "SLIDER";
1679
+ }
1680
+ function isGraphVisualization(viz) {
1681
+ return viz.type === "GRAPH";
1682
+ }
1683
+ function isFormVisualization(viz) {
1684
+ return viz.type === "FORM";
1685
+ }
1686
+
1687
+ function isRoxieServiceRef(ref) {
1688
+ return ref.request !== undefined;
1689
+ }
1690
+
1691
+ var classMappings = {
1692
+ c3chart_Bar: "chart_Bar",
1693
+ c3chart_Column: "chart_Column",
1694
+ c3chart_Pie: "chart_Pie",
1695
+ c3chart_Area: "chart_Area",
1696
+ c3chart_Line: "chart_Line",
1697
+ amchart_Bar: "chart_Bar",
1698
+ amchart_Column: "chart_Column",
1699
+ amchart_Pie: "chart_Pie",
1700
+ amchart_Area: "chart_Area",
1701
+ amchart_Line: "chart_Line",
1702
+ google_Bar: "chart_Bar",
1703
+ google_Column: "chart_Column",
1704
+ google_Pie: "chart_Pie",
1705
+ google_Area: "chart_Area",
1706
+ google_Line: "chart_Line",
1707
+ other_Table: "dgrid_Table"
1708
+ };
1709
+ var propertyMappings = {
1710
+ xAxisLabelRotation: [
1711
+ { name: "xAxisOverlapMode", transform: function (n) { return "rotate"; } },
1712
+ { name: "xAxisLabelRotation", transform: function (n) { return n; } }
1713
+ ],
1714
+ tooltipLabelColor: {
1715
+ name: "tooltipLabelColor"
1716
+ },
1717
+ tooltipSeriesColor: {
1718
+ name: "tooltipSeriesColor"
1719
+ },
1720
+ tooltipValueColor: {
1721
+ name: "tooltipValueColor"
1722
+ },
1723
+ tooltipValueFormat: {
1724
+ name: "tooltipValueFormat"
1725
+ },
1726
+ timePattern: {
1727
+ name: "xAxisTypeTimePattern"
1728
+ },
1729
+ smoothLines: {
1730
+ name: "interpolate",
1731
+ transform: function (n) {
1732
+ if (n === false)
1733
+ return "linear";
1734
+ return "catmullRom";
1735
+ }
1736
+ },
1737
+ holePercent: {
1738
+ name: "innerRadius"
1739
+ },
1740
+ flip: {
1741
+ name: "orientation",
1742
+ transform: function (n) { return n ? "vertical" : "horizontal"; }
1743
+ },
1744
+ bottomText: {
1745
+ name: "xAxisTitle"
1746
+ },
1747
+ xAxisTypeTimePattern: {
1748
+ name: "xAxisTypeTimePattern"
1749
+ },
1750
+ yAxisTypeTimePattern: {
1751
+ name: "yAxisTypeTimePattern"
1752
+ },
1753
+ valueFormat: {
1754
+ name: "tooltipValueFormat"
1755
+ },
1756
+ stacked: {
1757
+ name: "yAxisStacked"
1758
+ },
1759
+ showYGrid: {
1760
+ name: "yAxisGuideLines"
1761
+ },
1762
+ showXGrid: {
1763
+ name: "xAxisGuideLines"
1764
+ },
1765
+ showValueLabel: {
1766
+ name: "showValue"
1767
+ },
1768
+ low: {
1769
+ name: "yAxisDomainLow"
1770
+ },
1771
+ high: {
1772
+ name: "yAxisDomainHigh"
1773
+ },
1774
+ fillOpacity: {
1775
+ name: "interpolateFillOpacity"
1776
+ },
1777
+ areaFillOpacity: {
1778
+ name: "interpolateFillOpacity"
1779
+ },
1780
+ showToolbar: {
1781
+ name: "titleVisible"
1782
+ },
1783
+ showCSV: {
1784
+ name: "downloadButtonVisible"
1785
+ }
1786
+ };
1787
+ function findKeyVal(object, key, val) {
1788
+ var value;
1789
+ for (var k in object) {
1790
+ if (k === key && object[k] === val) {
1791
+ value = object;
1792
+ break;
1793
+ }
1794
+ if (object[k] && typeof object[k] === "object") {
1795
+ value = findKeyVal(object[k], key, val);
1796
+ if (value !== undefined) {
1797
+ break;
1798
+ }
1799
+ }
1800
+ }
1801
+ return value;
1802
+ }
1803
+ function apply_to_dataviews(ddl2, dermObj) {
1804
+ ddl2.dataviews.forEach(apply_to_dataview);
1805
+ function apply_to_dataview(dv) {
1806
+ var widgetId = dv.id;
1807
+ var dermPanelObj = findKeyVal(dermObj, "__id", widgetId);
1808
+ if (dermPanelObj) {
1809
+ var dermPanelProps = dermPanelObj.__properties;
1810
+ var dermWidgetObj = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
1811
+ var dermWidgetProps = dermWidgetObj.__properties;
1812
+ apply_class_mapping(dermWidgetObj);
1813
+ apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
1814
+ apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
1815
+ if (dv.visualization.properties.chartType) {
1816
+ dv.visualization.properties.charttype = dv.visualization.properties.chartType;
1817
+ }
1818
+ }
1819
+ else {
1820
+ console.warn(widgetId + " not found in dermObj");
1821
+ }
1822
+ function apply_class_mapping(dermWidgetObj) {
1823
+ dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
1824
+ dv.visualization.properties.__class = "marshaller_VizChartPanel";
1825
+ if (!dv.visualization.properties.widget)
1826
+ dv.visualization.properties.widget = {};
1827
+ dv.visualization.properties.widget.__class = dv.visualization.__class;
1828
+ function swap_with_supported_class(_class) {
1829
+ return classMappings[_class] ? classMappings[_class] : _class;
1830
+ }
1831
+ }
1832
+ function apply_panel_property_mapping(dermPanelProps, dermWidgetProps) {
1833
+ dv.visualization.title = dermPanelProps.title || "";
1834
+ dv.visualization.description = "";
1835
+ dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
1836
+ dv.visualization.chartType = dv.visualization.__class.split("_")[1];
1837
+ for (var propName in dermPanelProps) {
1838
+ if (typeof propertyMappings[propName] !== "undefined") {
1839
+ var newPropName = propertyMappings[propName].name;
1840
+ if (typeof propertyMappings[propName].transform === "function") {
1841
+ dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
1842
+ }
1843
+ else {
1844
+ dv.visualization.properties[newPropName] = dermPanelProps[propName];
1845
+ }
1846
+ }
1847
+ }
1848
+ if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
1849
+ dv.visualization.properties.legendVisible = true;
1850
+ }
1851
+ }
1852
+ function apply_widget_property_mapping(dermPanelProps, dermWidgetProps) {
1853
+ dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
1854
+ dv.visualization.description = ""; // TODO - should this map to anything?
1855
+ dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
1856
+ dv.visualization.chartType = dv.visualization.__class.split("_")[1];
1857
+ var _loop_1 = function (propName) {
1858
+ if (typeof propertyMappings[propName] !== "undefined") {
1859
+ if (propertyMappings[propName] instanceof Array) {
1860
+ propertyMappings[propName].forEach(function (p) {
1861
+ var newPropName = p.name;
1862
+ dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
1863
+ if (typeof propertyMappings[propName].transform === "function") {
1864
+ dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
1865
+ }
1866
+ else {
1867
+ dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
1868
+ }
1869
+ });
1870
+ }
1871
+ else {
1872
+ var newPropName = propertyMappings[propName].name;
1873
+ dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
1874
+ }
1875
+ }
1876
+ };
1877
+ for (var propName in dermWidgetProps) {
1878
+ _loop_1(propName);
1879
+ }
1880
+ }
1881
+ }
1882
+ }
1883
+ function apply_to_properties_layout(ddl2, dermObj) {
1884
+ var retVal = {
1885
+ layout: []
1886
+ };
1887
+ if (!dermObj || !dermObj.__properties)
1888
+ return;
1889
+ dermObj.__properties.content.forEach(function (cell) {
1890
+ var cellPosition = {
1891
+ // TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
1892
+ id: cell.__properties.widget.__id,
1893
+ position: [
1894
+ cell.__properties.gridCol,
1895
+ cell.__properties.gridRow,
1896
+ cell.__properties.gridColSpan,
1897
+ cell.__properties.gridRowSpan
1898
+ ]
1899
+ };
1900
+ retVal.layout.push(cellPosition);
1901
+ });
1902
+ return retVal;
1903
+ }
1904
+ function upgrade$1(ddl2, dermObj) {
1905
+ apply_to_dataviews(ddl2, dermObj);
1906
+ return apply_to_properties_layout(ddl2, dermObj);
1907
+ }
1908
+
1909
+ function faCharFix(faChar) {
1910
+ return faChar;
1911
+ }
1912
+ var DDLUpgrade = /** @class */ (function () {
1913
+ function DDLUpgrade(ddl, baseUrl, wuid, toLowerCase) {
1914
+ if (baseUrl === void 0) { baseUrl = "http://localhost:8010"; }
1915
+ if (wuid === void 0) { wuid = "WUID"; }
1916
+ if (toLowerCase === void 0) { toLowerCase = true; }
1917
+ this._datasources = {};
1918
+ this._datasourceUpdates = {};
1919
+ this._visualizations = {};
1920
+ this._ddl2Datasources = {};
1921
+ this._ddl2DatasourceFields = {};
1922
+ this._ddl2Dataviews = {};
1923
+ this._ddl2DataviewActivities = {};
1924
+ this._ddl = ddl;
1925
+ this._baseUrl = baseUrl;
1926
+ this._wuid = wuid;
1927
+ this._toLowerCase = toLowerCase;
1928
+ this.indexDDL();
1929
+ this.readDDL();
1930
+ }
1931
+ DDLUpgrade.prototype.toLowerCase = function (s) {
1932
+ return this._toLowerCase ? s.toLowerCase() : s;
1933
+ };
1934
+ DDLUpgrade.prototype.isVizDatasourceRoxie = function (viz) {
1935
+ if (viz.source) {
1936
+ var ds = this._datasources[viz.source.id];
1937
+ if (isHipieDatasource(ds)) {
1938
+ return true;
1939
+ }
1940
+ }
1941
+ return false;
1942
+ };
1943
+ DDLUpgrade.prototype.getDatasourceOutputs = function (dsID, vizID) {
1944
+ var retVal = [];
1945
+ var datasource = this._datasources[dsID];
1946
+ for (var _i = 0, _a = datasource.outputs; _i < _a.length; _i++) {
1947
+ var output = _a[_i];
1948
+ if (output.notify) {
1949
+ for (var _b = 0, _c = output.notify; _b < _c.length; _b++) {
1950
+ var notify = _c[_b];
1951
+ if (notify === vizID) {
1952
+ retVal.push({
1953
+ datasource: datasource,
1954
+ output: output
1955
+ });
1956
+ }
1957
+ }
1958
+ }
1959
+ }
1960
+ return retVal;
1961
+ };
1962
+ DDLUpgrade.prototype.getDatasourceFilters = function (dsID, vizID) {
1963
+ var retVal = {};
1964
+ for (var _i = 0, _a = this.getDatasourceOutputs(dsID, vizID); _i < _a.length; _i++) {
1965
+ var dsOut = _a[_i];
1966
+ if (dsOut.output.filter) {
1967
+ for (var _b = 0, _c = dsOut.output.filter; _b < _c.length; _b++) {
1968
+ var filter = _c[_b];
1969
+ retVal[filter.fieldid] = {
1970
+ datasource: dsOut.datasource,
1971
+ output: dsOut.output,
1972
+ filter: filter
1973
+ };
1974
+ }
1975
+ }
1976
+ }
1977
+ return retVal;
1978
+ };
1979
+ DDLUpgrade.prototype.indexDDL = function () {
1980
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
1981
+ var dash = _a[_i];
1982
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
1983
+ var viz = _c[_b];
1984
+ this._visualizations[viz.id] = viz;
1985
+ }
1986
+ }
1987
+ for (var _d = 0, _e = this._ddl.datasources; _d < _e.length; _d++) {
1988
+ var ds = _e[_d];
1989
+ this._datasources[ds.id] = ds;
1990
+ for (var _f = 0, _g = ds.outputs; _f < _g.length; _f++) {
1991
+ var output = _g[_f];
1992
+ if (output.notify) {
1993
+ for (var _h = 0, _j = output.notify; _h < _j.length; _h++) {
1994
+ var notify = _j[_h];
1995
+ this._datasourceUpdates[notify] = {
1996
+ id: ds.id,
1997
+ output: output.from || output.id
1998
+ };
1999
+ }
2000
+ }
2001
+ }
2002
+ }
2003
+ };
2004
+ DDLUpgrade.prototype.readDDL = function () {
2005
+ for (var _i = 0, _a = this._ddl.datasources; _i < _a.length; _i++) {
2006
+ var ds = _a[_i];
2007
+ if (isWorkunitDatasource(ds)) {
2008
+ var ddl2DS = {
2009
+ type: "wuresult",
2010
+ id: ds.id,
2011
+ url: this._baseUrl,
2012
+ wuid: this._wuid,
2013
+ outputs: {}
2014
+ };
2015
+ for (var _b = 0, _c = ds.outputs; _b < _c.length; _b++) {
2016
+ var output = _c[_b];
2017
+ this.output2output(output, ddl2DS.outputs);
2018
+ }
2019
+ this._ddl2Datasources[ds.id] = ddl2DS;
2020
+ }
2021
+ else if (isDatabombDatasource(ds)) ;
2022
+ else {
2023
+ var urlParts = ds.URL.split("/WsEcl/submit/query/");
2024
+ var hostParts = urlParts[0];
2025
+ var roxieParts = urlParts[1].split("/");
2026
+ var ddl2DS = {
2027
+ type: "hipie",
2028
+ id: ds.id,
2029
+ url: hostParts,
2030
+ querySet: roxieParts[0],
2031
+ queryID: roxieParts[1],
2032
+ inputs: [],
2033
+ outputs: {}
2034
+ };
2035
+ for (var _d = 0, _e = ds.outputs; _d < _e.length; _d++) {
2036
+ var output = _e[_d];
2037
+ this.output2output(output, ddl2DS.outputs);
2038
+ }
2039
+ this._ddl2Datasources[ds.id] = ddl2DS;
2040
+ }
2041
+ }
2042
+ for (var _f = 0, _g = this._ddl.dashboards; _f < _g.length; _f++) {
2043
+ var dash = _g[_f];
2044
+ for (var _h = 0, _j = dash.visualizations; _h < _j.length; _h++) {
2045
+ var viz = _j[_h];
2046
+ if (viz.type === "FORM") {
2047
+ this._ddl2Datasources[viz.id] = {
2048
+ type: "form",
2049
+ id: viz.id,
2050
+ fields: this.formFields2field(viz.fields)
2051
+ };
2052
+ this._datasourceUpdates[viz.id] = { id: viz.id };
2053
+ }
2054
+ else if (viz.type === "SLIDER") {
2055
+ this._ddl2Datasources[viz.id] = {
2056
+ type: "form",
2057
+ id: viz.id,
2058
+ fields: this.formFields2field(viz.fields, true)
2059
+ };
2060
+ this._datasourceUpdates[viz.id] = { id: viz.id };
2061
+ }
2062
+ this._ddl2Dataviews[viz.id] = this.anyViz2view(viz);
2063
+ }
2064
+ }
2065
+ this.readGroupBy();
2066
+ this.readFilters();
2067
+ this.readSort();
2068
+ this.readMappings();
2069
+ };
2070
+ DDLUpgrade.prototype.readGroupBy = function () {
2071
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2072
+ var dash = _a[_i];
2073
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2074
+ var viz = _c[_b];
2075
+ if (viz.fields) {
2076
+ var projectTransformations = [];
2077
+ var groupByColumns = [];
2078
+ var aggrFields = [];
2079
+ for (var _d = 0, _e = viz.fields; _d < _e.length; _d++) {
2080
+ var field = _e[_d];
2081
+ if (field.properties && field.properties.function) {
2082
+ switch (field.properties.function) {
2083
+ case "SUM":
2084
+ case "MIN":
2085
+ case "MAX":
2086
+ aggrFields.push({
2087
+ type: this.func2aggr(field.properties.function),
2088
+ inFieldID: this.toLowerCase(field.properties.params.param1),
2089
+ fieldID: this.toLowerCase(field.id)
2090
+ });
2091
+ break;
2092
+ case "AVE":
2093
+ aggrFields.push({
2094
+ type: this.func2aggr(field.properties.function),
2095
+ inFieldID: this.toLowerCase(field.properties.params.param1),
2096
+ baseCountFieldID: field.properties.params.param2 ? this.toLowerCase(field.properties.params.param2) : undefined,
2097
+ fieldID: this.toLowerCase(field.id)
2098
+ });
2099
+ break;
2100
+ case "SCALE":
2101
+ if (typeof field.properties.params.param1 === "object") {
2102
+ var props = field.properties.params.param1;
2103
+ switch (props.function) {
2104
+ case "SUM":
2105
+ case "MIN":
2106
+ case "MAX":
2107
+ aggrFields.push({
2108
+ type: this.func2aggr(props.function),
2109
+ inFieldID: this.toLowerCase(props.params.param1),
2110
+ fieldID: this.toLowerCase(field.id)
2111
+ });
2112
+ break;
2113
+ }
2114
+ }
2115
+ projectTransformations.push({
2116
+ type: "scale",
2117
+ sourceFieldID: this.toLowerCase(field.id),
2118
+ fieldID: this.toLowerCase(field.id),
2119
+ factor: +field.properties.params.param2
2120
+ });
2121
+ break;
2122
+ default:
2123
+ groupByColumns.push(this.toLowerCase(field.id));
2124
+ throw new Error("Unhandled field function: ".concat(field.properties.function));
2125
+ }
2126
+ }
2127
+ else {
2128
+ groupByColumns.push(this.toLowerCase(field.id));
2129
+ }
2130
+ }
2131
+ if (projectTransformations.length) {
2132
+ this._ddl2DataviewActivities[viz.id].project.transformations = projectTransformations;
2133
+ }
2134
+ if (aggrFields.length) {
2135
+ this._ddl2DataviewActivities[viz.id].groupBy.groupByIDs = __spreadArray([], groupByColumns, true);
2136
+ this._ddl2DataviewActivities[viz.id].groupBy.aggregates = aggrFields;
2137
+ }
2138
+ }
2139
+ }
2140
+ }
2141
+ };
2142
+ DDLUpgrade.prototype.func2aggr = function (func) {
2143
+ switch (func) {
2144
+ case "SUM":
2145
+ return "sum";
2146
+ case "AVE":
2147
+ return "mean";
2148
+ case "MIN":
2149
+ return "min";
2150
+ case "MAX":
2151
+ return "max";
2152
+ }
2153
+ throw new Error("Unknown DDL1 Function Type: ".concat(func));
2154
+ };
2155
+ DDLUpgrade.prototype.readMappings = function () {
2156
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2157
+ var dash = _a[_i];
2158
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2159
+ var viz = _c[_b];
2160
+ if (isFormVisualization(viz)) ;
2161
+ else if (isPieVisualization(viz)) {
2162
+ this.readPieMappings(viz);
2163
+ }
2164
+ else if (isChoroVisualization(viz)) {
2165
+ this.readChoroMappings(viz);
2166
+ }
2167
+ else if (isLineVisualization(viz)) {
2168
+ this.readLineMappings(viz);
2169
+ }
2170
+ else if (isTableVisualization(viz)) {
2171
+ this.readTableMappings(viz);
2172
+ }
2173
+ else if (isGraphVisualization(viz)) {
2174
+ this.readGraphMappings(viz);
2175
+ }
2176
+ else if (isSliderVisualization(viz)) {
2177
+ this.readSliderMappings(viz);
2178
+ }
2179
+ else {
2180
+ throw new Error("Unkown DDL1 mapping type: ".concat(viz.type));
2181
+ }
2182
+ }
2183
+ }
2184
+ };
2185
+ DDLUpgrade.prototype.readPieMappings = function (viz) {
2186
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2187
+ mappings.transformations.push({
2188
+ fieldID: "label",
2189
+ type: "=",
2190
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2191
+ });
2192
+ mappings.transformations.push({
2193
+ fieldID: "weight",
2194
+ type: "=",
2195
+ sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
2196
+ });
2197
+ };
2198
+ DDLUpgrade.prototype.readChoroMappings = function (viz) {
2199
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2200
+ mappings.transformations.push({
2201
+ fieldID: "label",
2202
+ type: "=",
2203
+ sourceFieldID: this.toLowerCase(this.anyChoroMapping2label(viz.source.mappings))
2204
+ });
2205
+ mappings.transformations.push({
2206
+ fieldID: "weight",
2207
+ type: "=",
2208
+ sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
2209
+ });
2210
+ };
2211
+ DDLUpgrade.prototype.anyChoroMapping2label = function (mapping) {
2212
+ return mapping.state || mapping.county || mapping.geohash;
2213
+ };
2214
+ DDLUpgrade.prototype.readLineMappings = function (viz) {
2215
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2216
+ mappings.transformations.push({
2217
+ fieldID: viz.source.mappings.x[0],
2218
+ type: "=",
2219
+ sourceFieldID: this.toLowerCase(viz.source.mappings.x[0])
2220
+ });
2221
+ for (var i = 0; i < viz.source.mappings.y.length; ++i) {
2222
+ mappings.transformations.push({
2223
+ fieldID: viz.source.mappings.y[i],
2224
+ type: "=",
2225
+ sourceFieldID: this.toLowerCase(viz.source.mappings.y[i])
2226
+ });
2227
+ }
2228
+ };
2229
+ DDLUpgrade.prototype.readTableMappings = function (viz) {
2230
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2231
+ for (var i = 0; i < viz.label.length; ++i) {
2232
+ mappings.transformations.push({
2233
+ fieldID: viz.label[i],
2234
+ type: "=",
2235
+ sourceFieldID: this.toLowerCase(viz.source.mappings.value[i])
2236
+ });
2237
+ }
2238
+ };
2239
+ DDLUpgrade.prototype.readGraphEnums = function (valueMappings, annotation) {
2240
+ if (annotation === void 0) { annotation = false; }
2241
+ var retVal = [];
2242
+ if (valueMappings) {
2243
+ for (var value in valueMappings) {
2244
+ var newValue = {};
2245
+ for (var key in valueMappings[value]) {
2246
+ if (key === "faChar") {
2247
+ newValue[key] = faCharFix(valueMappings[value][key]);
2248
+ }
2249
+ else if (annotation && key.indexOf("icon_") === 0) {
2250
+ console.warn("Deprecated flag property: " + key);
2251
+ newValue[key.split("icon_")[1]] = valueMappings[value][key];
2252
+ }
2253
+ else {
2254
+ newValue[key] = valueMappings[value][key];
2255
+ }
2256
+ }
2257
+ // remove v1.x "0" annotations as they equated to "nothing" ---
2258
+ if (!annotation || value !== "0") {
2259
+ retVal.push({
2260
+ value: value,
2261
+ newValue: newValue
2262
+ });
2263
+ }
2264
+ }
2265
+ }
2266
+ return retVal;
2267
+ };
2268
+ DDLUpgrade.prototype.readGraphMappings = function (viz) {
2269
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2270
+ mappings.transformations.push({
2271
+ fieldID: "uid",
2272
+ type: "=",
2273
+ sourceFieldID: this.toLowerCase(viz.source.mappings.uid)
2274
+ });
2275
+ mappings.transformations.push({
2276
+ fieldID: "label",
2277
+ type: "=",
2278
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2279
+ });
2280
+ if (viz.icon.fieldid) {
2281
+ mappings.transformations.push({
2282
+ fieldID: "icon",
2283
+ type: "map",
2284
+ sourceFieldID: this.toLowerCase(viz.icon.fieldid),
2285
+ default: { fachar: faCharFix(viz.icon.faChar) },
2286
+ mappings: this.readGraphEnums(viz.icon.valuemappings)
2287
+ });
2288
+ }
2289
+ var idx = 0;
2290
+ if (viz.flag) {
2291
+ for (var _i = 0, _a = viz.flag; _i < _a.length; _i++) {
2292
+ var flag = _a[_i];
2293
+ if (flag.fieldid) {
2294
+ mappings.transformations.push({
2295
+ fieldID: "annotation_".concat(idx++),
2296
+ type: "map",
2297
+ sourceFieldID: this.toLowerCase(flag.fieldid),
2298
+ default: {},
2299
+ mappings: this.readGraphEnums(flag.valuemappings, true)
2300
+ });
2301
+ }
2302
+ }
2303
+ }
2304
+ mappings.transformations.push({
2305
+ fieldID: "links",
2306
+ type: "=",
2307
+ sourceFieldID: this.toLowerCase(viz.source.link.childfile),
2308
+ transformations: [{
2309
+ fieldID: "uid",
2310
+ type: "=",
2311
+ sourceFieldID: this.toLowerCase(viz.source.link.mappings.uid)
2312
+ }]
2313
+ });
2314
+ };
2315
+ DDLUpgrade.prototype.readSliderMappings = function (viz) {
2316
+ var mappings = this._ddl2DataviewActivities[viz.id].mappings;
2317
+ mappings.transformations.push({
2318
+ fieldID: "label",
2319
+ type: "=",
2320
+ sourceFieldID: this.toLowerCase(viz.source.mappings.label)
2321
+ });
2322
+ };
2323
+ DDLUpgrade.prototype.readFilters = function () {
2324
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2325
+ var dash = _a[_i];
2326
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2327
+ var viz = _c[_b];
2328
+ if (viz.events) {
2329
+ for (var eventID in viz.events) {
2330
+ var event_1 = viz.events[eventID];
2331
+ for (var _d = 0, _e = event_1.updates; _d < _e.length; _d++) {
2332
+ var update = _e[_d];
2333
+ var otherViz = this._ddl2Dataviews[update.visualization];
2334
+ var dsFilters = this.getDatasourceFilters(update.datasource, otherViz.id);
2335
+ if (update.mappings) {
2336
+ if (isRoxieServiceRef(otherViz.datasource)) {
2337
+ for (var key in update.mappings) {
2338
+ otherViz.datasource.request.push({
2339
+ source: viz.id,
2340
+ remoteFieldID: this.toLowerCase(key),
2341
+ localFieldID: this.toLowerCase(update.mappings[key])
2342
+ });
2343
+ }
2344
+ }
2345
+ else {
2346
+ var condition = {
2347
+ viewID: viz.id,
2348
+ mappings: []
2349
+ };
2350
+ for (var key in update.mappings) {
2351
+ var mapping = update.mappings[key];
2352
+ var dsFilter = (mapping && dsFilters[mapping]) ? dsFilters[mapping].filter : undefined;
2353
+ if (!dsFilter) {
2354
+ console.warn("Select Mapping \"".concat(mapping, "\" in viz \"").concat(viz.id, "\" not found in filters for \"").concat(otherViz.id, "\""));
2355
+ }
2356
+ else {
2357
+ condition.mappings.push({
2358
+ remoteFieldID: this.toLowerCase(key),
2359
+ localFieldID: this.toLowerCase(update.mappings[key]),
2360
+ condition: this.rule2condition(dsFilter.rule),
2361
+ nullable: dsFilter.nullable
2362
+ });
2363
+ }
2364
+ }
2365
+ this._ddl2DataviewActivities[otherViz.id].filters.conditions.push(condition);
2366
+ }
2367
+ }
2368
+ }
2369
+ }
2370
+ }
2371
+ }
2372
+ }
2373
+ };
2374
+ DDLUpgrade.prototype.rule2condition = function (_) {
2375
+ switch (_) {
2376
+ case "set":
2377
+ return "in";
2378
+ case "notequals":
2379
+ return "!=";
2380
+ }
2381
+ return _;
2382
+ };
2383
+ DDLUpgrade.prototype.readSort = function () {
2384
+ var _this = this;
2385
+ for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
2386
+ var dash = _a[_i];
2387
+ for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
2388
+ var viz = _c[_b];
2389
+ if (viz.source) {
2390
+ if (viz.source.sort) {
2391
+ var vizSort = this._ddl2DataviewActivities[viz.id].sort;
2392
+ vizSort.conditions = viz.source.sort.map(function (s) {
2393
+ if (s.indexOf("-") === 0) {
2394
+ return {
2395
+ fieldID: _this.toLowerCase(s.substr(1)),
2396
+ descending: true
2397
+ };
2398
+ }
2399
+ return {
2400
+ fieldID: _this.toLowerCase(s),
2401
+ descending: false
2402
+ };
2403
+ });
2404
+ }
2405
+ if (viz.source.first) {
2406
+ var vizLimit = this._ddl2DataviewActivities[viz.id].limit;
2407
+ vizLimit.limit = +viz.source.first;
2408
+ }
2409
+ }
2410
+ }
2411
+ }
2412
+ };
2413
+ DDLUpgrade.prototype.anyViz2view = function (viz) {
2414
+ var project = {
2415
+ type: "project",
2416
+ transformations: []
2417
+ };
2418
+ var filters = {
2419
+ type: "filter",
2420
+ conditions: []
2421
+ };
2422
+ var groupBy = {
2423
+ type: "groupby",
2424
+ groupByIDs: [],
2425
+ aggregates: []
2426
+ };
2427
+ var sort = {
2428
+ type: "sort",
2429
+ conditions: []
2430
+ };
2431
+ var limit = {
2432
+ type: "limit",
2433
+ limit: 0
2434
+ };
2435
+ var mappings = {
2436
+ type: "mappings",
2437
+ transformations: []
2438
+ };
2439
+ this._ddl2DataviewActivities[viz.id] = {
2440
+ project: project,
2441
+ filters: filters,
2442
+ sort: sort,
2443
+ groupBy: groupBy,
2444
+ limit: limit,
2445
+ mappings: mappings
2446
+ };
2447
+ var datasourceRef = this.isVizDatasourceRoxie(viz) ? {
2448
+ id: this._datasourceUpdates[viz.id].id,
2449
+ request: [],
2450
+ output: this._datasourceUpdates[viz.id].output
2451
+ } : {
2452
+ id: this._datasourceUpdates[viz.id].id,
2453
+ output: this._datasourceUpdates[viz.id].output
2454
+ };
2455
+ return {
2456
+ id: viz.id,
2457
+ datasource: datasourceRef,
2458
+ activities: [
2459
+ project,
2460
+ filters,
2461
+ sort,
2462
+ groupBy,
2463
+ limit
2464
+ ],
2465
+ 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 || {}) })
2466
+ };
2467
+ };
2468
+ DDLUpgrade.prototype.type2chartType = function (chartType) {
2469
+ switch (chartType) {
2470
+ case "LINE":
2471
+ return { chartType: "Line", __class: "chart_Line" };
2472
+ case "BUBBLE":
2473
+ return { chartType: "Bubble", __class: "chart_Bubble" };
2474
+ case "PIE":
2475
+ return { chartType: "Pie", __class: "chart_Pie" };
2476
+ case "BAR":
2477
+ return { chartType: "Column", __class: "chart_Column" };
2478
+ case "FORM":
2479
+ return { chartType: "FieldForm", __class: "form_FieldForm" };
2480
+ case "WORD_CLOUD":
2481
+ return { chartType: "WordCloud", __class: "chart_WordCloud" };
2482
+ case "CHORO":
2483
+ return { chartType: "ChoroplethStates", __class: "map_ChoroplethStates" };
2484
+ case "SUMMARY":
2485
+ return { chartType: "Summary", __class: "chart_Summary" };
2486
+ case "SLIDER":
2487
+ return { chartType: "FieldForm", __class: "form_FieldForm" };
2488
+ case "HEAT_MAP":
2489
+ return { chartType: "HeatMap", __class: "other_HeatMap" };
2490
+ case "2DCHART":
2491
+ return { chartType: "Column", __class: "chart_Column" };
2492
+ case "GRAPH":
2493
+ return { chartType: "AdjacencyGraph", __class: "graph_AdjacencyGraph" };
2494
+ case "TABLE":
2495
+ default:
2496
+ return { chartType: "Table", __class: "dgrid_Table" };
2497
+ }
2498
+ };
2499
+ DDLUpgrade.prototype.formFields2field = function (fields, slider) {
2500
+ var _this = this;
2501
+ if (slider === void 0) { slider = false; }
2502
+ if (!fields)
2503
+ return [];
2504
+ return fields.map(function (field) {
2505
+ switch (field.properties.type) {
2506
+ case "range":
2507
+ return {
2508
+ type: "range",
2509
+ id: field.id,
2510
+ default: (field.properties.default ? field.properties.default : undefined)
2511
+ };
2512
+ case "dataset":
2513
+ return {
2514
+ type: "dataset",
2515
+ id: field.id,
2516
+ default: [],
2517
+ children: []
2518
+ };
2519
+ default:
2520
+ return {
2521
+ type: _this.formFieldType2fieldType(field.properties.datatype, slider),
2522
+ id: field.id,
2523
+ default: field.properties.default ? field.properties.default[0] : undefined
2524
+ };
2525
+ }
2526
+ });
2527
+ };
2528
+ DDLUpgrade.prototype.formFieldType2fieldType = function (fieldType, slider) {
2529
+ switch (fieldType) {
2530
+ case "bool":
2531
+ case "boolean":
2532
+ return "boolean";
2533
+ case "integer":
2534
+ case "unsigned":
2535
+ case "float":
2536
+ case "double":
2537
+ case "real":
2538
+ return "number";
2539
+ case "string":
2540
+ return "string";
2541
+ default:
2542
+ return slider ? "number" : "string";
2543
+ }
2544
+ };
2545
+ DDLUpgrade.prototype.output2output = function (output, target) {
2546
+ target[output.from || output.id] = {
2547
+ fields: this.filters2fields(output.filter)
2548
+ };
2549
+ };
2550
+ DDLUpgrade.prototype.filters2fields = function (filters) {
2551
+ if (!filters)
2552
+ return [];
2553
+ return filters.filter(function (filter) {
2554
+ var idParts = filter.fieldid.split("-");
2555
+ return idParts.length === 1 || idParts[1] === "range";
2556
+ }).map(function (filter) {
2557
+ var idParts = filter.fieldid.split("-");
2558
+ var retVal = {
2559
+ type: "string",
2560
+ id: idParts[0]
2561
+ };
2562
+ return retVal;
2563
+ });
2564
+ };
2565
+ DDLUpgrade.prototype.getVizField = function (vizID, fieldID) {
2566
+ return {
2567
+ type: "string",
2568
+ id: "",
2569
+ default: ""
2570
+ };
2571
+ };
2572
+ DDLUpgrade.prototype.writeDatasources = function () {
2573
+ var retVal = [];
2574
+ for (var id in this._ddl2Datasources) {
2575
+ retVal.push(this._ddl2Datasources[id]);
2576
+ }
2577
+ return retVal;
2578
+ };
2579
+ DDLUpgrade.prototype.writeDataviews = function () {
2580
+ var retVal = [];
2581
+ for (var id in this._ddl2Dataviews) {
2582
+ retVal.push(this._ddl2Dataviews[id]);
2583
+ }
2584
+ return retVal;
2585
+ };
2586
+ DDLUpgrade.prototype.writeProperties = function () {
2587
+ return {
2588
+ // TODO
2589
+ };
2590
+ };
2591
+ DDLUpgrade.prototype.write = function () {
2592
+ return {
2593
+ version: "2.2.1",
2594
+ createdBy: {
2595
+ name: PKG_NAME,
2596
+ version: PKG_VERSION
2597
+ },
2598
+ datasources: this.writeDatasources(),
2599
+ dataviews: this.writeDataviews(),
2600
+ properties: this.writeProperties()
2601
+ };
2602
+ };
2603
+ return DDLUpgrade;
2604
+ }());
2605
+ function upgrade(ddl, baseUrl, wuid, toLowerCase, dermatologyJson) {
2606
+ if (toLowerCase === void 0) { toLowerCase = true; }
2607
+ if (dermatologyJson === void 0) { dermatologyJson = {}; }
2608
+ var ddlUp = new DDLUpgrade(ddl, baseUrl, wuid, toLowerCase);
2609
+ var retVal = ddlUp.write();
2610
+ retVal.properties = upgrade$1(retVal, dermatologyJson);
2611
+ return retVal;
2612
+ }
2613
+
2614
+ var args = process.argv.slice(2);
2615
+ switch (args[0]) {
2616
+ case "--echo":
2617
+ process.stdout.write(args[1]);
2618
+ break;
2619
+ case "--schema":
2620
+ process.stdout.write(JSON.stringify(ddl2Schema));
2621
+ break;
2622
+ case "--upgrade":
2623
+ case "--upgradeNoLower":
2624
+ var srcPath = args[1];
2625
+ var destPath_1 = args[2];
2626
+ var baseUrl_1 = args[3];
2627
+ var wuid_1 = args[4];
2628
+ var layoutPath = args[5];
2629
+ if (srcPath && destPath_1 && srcPath !== destPath_1) {
2630
+ var layoutJson_1 = {};
2631
+ if (layoutPath) {
2632
+ try {
2633
+ layoutJson_1 = JSON.parse(fs__namespace.readFileSync(layoutPath).toString());
2634
+ }
2635
+ catch (e) {
2636
+ console.error(e);
2637
+ }
2638
+ }
2639
+ fs__namespace.readFile(srcPath, "utf8", function (err, data) {
2640
+ if (err)
2641
+ throw err;
2642
+ var ddl2 = upgrade(JSON.parse(data), baseUrl_1 || "http://localhost:8010", wuid_1 || "WUID", args[0] === "--upgrade", layoutJson_1);
2643
+ fs__namespace.writeFile(destPath_1, JSON.stringify(ddl2), function (err) {
2644
+ if (err)
2645
+ throw err;
2646
+ console.info("complete");
2647
+ });
2648
+ });
2649
+ }
2650
+ break;
2651
+ case "--help":
2652
+ break;
2653
+ default:
2654
+ 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");
2655
+ }
2656
+ //# sourceMappingURL=cli.js.map