@hpcc-js/ddl-shim 2.17.23 → 2.18.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/LICENSE +43 -43
- package/dist/cli.js +1048 -1103
- package/dist/cli.js.map +1 -1
- package/dist/index.es6.js +1436 -1550
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +1441 -1555
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +10 -25
- package/schema/v1.json +26 -78
- package/schema/v2.json +40 -120
- package/src/__package__.ts +2 -2
- package/src/cli.ts +60 -60
- package/src/ddl/v0_0_22.ts +344 -344
- package/src/ddl/v1.ts +313 -313
- package/src/ddl/v2.ts +426 -426
- package/src/ddl/v2_0_23.ts +395 -395
- package/src/ddl/v2_1_0.ts +406 -406
- package/src/dermatology.ts +229 -229
- package/src/index.ts +11 -11
- package/src/upgrade.ts +734 -734
- package/src/validate.ts +39 -39
- package/types/__package__.d.ts +3 -3
- package/types/__package__.d.ts.map +1 -1
- package/types/cli.d.ts +1 -1
- package/types/ddl/v0_0_22.d.ts +270 -270
- package/types/ddl/v1.d.ts +234 -234
- package/types/ddl/v2.d.ts +338 -338
- package/types/ddl/v2_0_23.d.ts +314 -314
- package/types/ddl/v2_1_0.d.ts +321 -321
- package/types/dermatology.d.ts +10 -10
- package/types/index.d.ts +7 -7
- package/types/upgrade.d.ts +3 -3
- package/types/validate.d.ts +7 -7
package/dist/index.es6.js
CHANGED
|
@@ -1,48 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
function
|
|
30
|
-
return viz.type === "
|
|
31
|
-
}
|
|
32
|
-
function
|
|
33
|
-
return viz.type === "
|
|
34
|
-
}
|
|
35
|
-
function
|
|
36
|
-
return viz.type === "
|
|
37
|
-
}
|
|
38
|
-
function
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
1
|
+
function _mergeNamespaces(n, m) {
|
|
2
|
+
m.forEach(function (e) {
|
|
3
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !(k in n)) {
|
|
5
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
6
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () { return e[k]; }
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
return Object.freeze(n);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var PKG_NAME = "@hpcc-js/ddl-shim";
|
|
17
|
+
var PKG_VERSION = "2.18.1";
|
|
18
|
+
var BUILD_VERSION = "2.102.1";
|
|
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;
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
var v1 = /*#__PURE__*/Object.freeze({
|
|
@@ -63,39 +78,39 @@ var v1 = /*#__PURE__*/Object.freeze({
|
|
|
63
78
|
isGeohashMapping: isGeohashMapping
|
|
64
79
|
});
|
|
65
80
|
|
|
66
|
-
function isDatabombRef(ref) {
|
|
67
|
-
return !isWUResultRef(ref) && !isRoxieServiceRef(ref);
|
|
68
|
-
}
|
|
69
|
-
function isWUResultRef(ref) {
|
|
70
|
-
return ref.output !== undefined && !isRoxieServiceRef(ref);
|
|
71
|
-
}
|
|
72
|
-
function isRoxieServiceRef(ref) {
|
|
73
|
-
return ref.request !== undefined;
|
|
74
|
-
}
|
|
75
|
-
function isIFilterCondition(fc) {
|
|
76
|
-
return !!fc.viewID;
|
|
77
|
-
}
|
|
78
|
-
function isFilterActivity(activity) {
|
|
79
|
-
return activity.type === "filter";
|
|
80
|
-
}
|
|
81
|
-
function isProjectActivity(activity) {
|
|
82
|
-
return activity.type === "project";
|
|
83
|
-
}
|
|
84
|
-
function isMappingsActivity(activity) {
|
|
85
|
-
return activity.type === "mappings";
|
|
86
|
-
}
|
|
87
|
-
function isGroupByActivity(activity) {
|
|
88
|
-
return activity.type === "groupby";
|
|
89
|
-
}
|
|
90
|
-
function isSortActivity(activity) {
|
|
91
|
-
return activity.type === "sort";
|
|
92
|
-
}
|
|
93
|
-
function isLimitActivity(activity) {
|
|
94
|
-
return activity.type === "limit";
|
|
95
|
-
}
|
|
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
|
+
}
|
|
96
111
|
var VisibilitySet = ["normal", "flyout"];
|
|
97
112
|
|
|
98
|
-
var v2 = /*#__PURE__*/Object.freeze({
|
|
113
|
+
var v2$1 = /*#__PURE__*/Object.freeze({
|
|
99
114
|
__proto__: null,
|
|
100
115
|
isDatabombRef: isDatabombRef,
|
|
101
116
|
isWUResultRef: isWUResultRef,
|
|
@@ -143,960 +158,941 @@ function __spreadArray(to, from, pack) {
|
|
|
143
158
|
ar[i] = from[i];
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
|
-
return to.concat(ar || from);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
var classMappings = {
|
|
150
|
-
c3chart_Bar: "chart_Bar",
|
|
151
|
-
c3chart_Column: "chart_Column",
|
|
152
|
-
c3chart_Pie: "chart_Pie",
|
|
153
|
-
c3chart_Area: "chart_Area",
|
|
154
|
-
c3chart_Line: "chart_Line",
|
|
155
|
-
amchart_Bar: "chart_Bar",
|
|
156
|
-
amchart_Column: "chart_Column",
|
|
157
|
-
amchart_Pie: "chart_Pie",
|
|
158
|
-
amchart_Area: "chart_Area",
|
|
159
|
-
amchart_Line: "chart_Line",
|
|
160
|
-
google_Bar: "chart_Bar",
|
|
161
|
-
google_Column: "chart_Column",
|
|
162
|
-
google_Pie: "chart_Pie",
|
|
163
|
-
google_Area: "chart_Area",
|
|
164
|
-
google_Line: "chart_Line",
|
|
165
|
-
other_Table: "dgrid_Table"
|
|
166
|
-
};
|
|
167
|
-
var propertyMappings = {
|
|
168
|
-
xAxisLabelRotation: [
|
|
169
|
-
{ name: "xAxisOverlapMode", transform: function (n) { return "rotate"; } },
|
|
170
|
-
{ name: "xAxisLabelRotation", transform: function (n) { return n; } }
|
|
171
|
-
],
|
|
172
|
-
tooltipLabelColor: {
|
|
173
|
-
name: "tooltipLabelColor"
|
|
174
|
-
},
|
|
175
|
-
tooltipSeriesColor: {
|
|
176
|
-
name: "tooltipSeriesColor"
|
|
177
|
-
},
|
|
178
|
-
tooltipValueColor: {
|
|
179
|
-
name: "tooltipValueColor"
|
|
180
|
-
},
|
|
181
|
-
tooltipValueFormat: {
|
|
182
|
-
name: "tooltipValueFormat"
|
|
183
|
-
},
|
|
184
|
-
timePattern: {
|
|
185
|
-
name: "xAxisTypeTimePattern"
|
|
186
|
-
},
|
|
187
|
-
smoothLines: {
|
|
188
|
-
name: "interpolate",
|
|
189
|
-
transform: function (n) {
|
|
190
|
-
if (n === false)
|
|
191
|
-
return "linear";
|
|
192
|
-
return "catmullRom";
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
holePercent: {
|
|
196
|
-
name: "innerRadius"
|
|
197
|
-
},
|
|
198
|
-
flip: {
|
|
199
|
-
name: "orientation",
|
|
200
|
-
transform: function (n) { return n ? "vertical" : "horizontal"; }
|
|
201
|
-
},
|
|
202
|
-
bottomText: {
|
|
203
|
-
name: "xAxisTitle"
|
|
204
|
-
},
|
|
205
|
-
xAxisTypeTimePattern: {
|
|
206
|
-
name: "xAxisTypeTimePattern"
|
|
207
|
-
},
|
|
208
|
-
yAxisTypeTimePattern: {
|
|
209
|
-
name: "yAxisTypeTimePattern"
|
|
210
|
-
},
|
|
211
|
-
valueFormat: {
|
|
212
|
-
name: "tooltipValueFormat"
|
|
213
|
-
},
|
|
214
|
-
stacked: {
|
|
215
|
-
name: "yAxisStacked"
|
|
216
|
-
},
|
|
217
|
-
showYGrid: {
|
|
218
|
-
name: "yAxisGuideLines"
|
|
219
|
-
},
|
|
220
|
-
showXGrid: {
|
|
221
|
-
name: "xAxisGuideLines"
|
|
222
|
-
},
|
|
223
|
-
showValueLabel: {
|
|
224
|
-
name: "showValue"
|
|
225
|
-
},
|
|
226
|
-
low: {
|
|
227
|
-
name: "yAxisDomainLow"
|
|
228
|
-
},
|
|
229
|
-
high: {
|
|
230
|
-
name: "yAxisDomainHigh"
|
|
231
|
-
},
|
|
232
|
-
fillOpacity: {
|
|
233
|
-
name: "interpolateFillOpacity"
|
|
234
|
-
},
|
|
235
|
-
areaFillOpacity: {
|
|
236
|
-
name: "interpolateFillOpacity"
|
|
237
|
-
},
|
|
238
|
-
showToolbar: {
|
|
239
|
-
name: "titleVisible"
|
|
240
|
-
},
|
|
241
|
-
showCSV: {
|
|
242
|
-
name: "downloadButtonVisible"
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
function findKeyVal(object, key, val) {
|
|
246
|
-
var value;
|
|
247
|
-
for (var k in object) {
|
|
248
|
-
if (k === key && object[k] === val) {
|
|
249
|
-
value = object;
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
if (object[k] && typeof object[k] === "object") {
|
|
253
|
-
value = findKeyVal(object[k], key, val);
|
|
254
|
-
if (value !== undefined) {
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return value;
|
|
260
|
-
}
|
|
261
|
-
function apply_to_dataviews(ddl2, dermObj) {
|
|
262
|
-
ddl2.dataviews.forEach(apply_to_dataview);
|
|
263
|
-
function apply_to_dataview(dv) {
|
|
264
|
-
var widgetId = dv.id;
|
|
265
|
-
var dermPanelObj = findKeyVal(dermObj, "__id", widgetId);
|
|
266
|
-
if (dermPanelObj) {
|
|
267
|
-
var dermPanelProps = dermPanelObj.__properties;
|
|
268
|
-
var dermWidgetObj = dermPanelObj.__properties.chart ? dermPanelObj.__properties.chart : dermPanelObj.__properties.widget;
|
|
269
|
-
var dermWidgetProps = dermWidgetObj.__properties;
|
|
270
|
-
apply_class_mapping(dermWidgetObj);
|
|
271
|
-
apply_panel_property_mapping(dermPanelProps, dermWidgetProps);
|
|
272
|
-
apply_widget_property_mapping(dermPanelProps, dermWidgetProps);
|
|
273
|
-
if (dv.visualization.properties.chartType) {
|
|
274
|
-
dv.visualization.properties.charttype = dv.visualization.properties.chartType;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
console.warn(widgetId + " not found in dermObj");
|
|
279
|
-
}
|
|
280
|
-
function apply_class_mapping(dermWidgetObj) {
|
|
281
|
-
dv.visualization.__class = swap_with_supported_class(dermWidgetObj.__class);
|
|
282
|
-
dv.visualization.properties.__class = "marshaller_VizChartPanel";
|
|
283
|
-
if (!dv.visualization.properties.widget)
|
|
284
|
-
dv.visualization.properties.widget = {};
|
|
285
|
-
dv.visualization.properties.widget.__class = dv.visualization.__class;
|
|
286
|
-
function swap_with_supported_class(_class) {
|
|
287
|
-
return classMappings[_class] ? classMappings[_class] : _class;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function apply_panel_property_mapping(dermPanelProps, dermWidgetProps) {
|
|
291
|
-
dv.visualization.title = dermPanelProps.title || "";
|
|
292
|
-
dv.visualization.description = "";
|
|
293
|
-
dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
|
|
294
|
-
dv.visualization.chartType = dv.visualization.__class.split("_")[1];
|
|
295
|
-
for (var propName in dermPanelProps) {
|
|
296
|
-
if (typeof propertyMappings[propName] !== "undefined") {
|
|
297
|
-
var newPropName = propertyMappings[propName].name;
|
|
298
|
-
if (typeof propertyMappings[propName].transform === "function") {
|
|
299
|
-
dv.visualization.properties[newPropName] = propertyMappings[propName].transform(dermPanelProps[propName]);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
dv.visualization.properties[newPropName] = dermPanelProps[propName];
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (dermWidgetProps && dermWidgetProps.showLegend && dv.visualization.properties) {
|
|
307
|
-
dv.visualization.properties.legendVisible = true;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
function apply_widget_property_mapping(dermPanelProps, dermWidgetProps) {
|
|
311
|
-
dv.visualization.title = dv.visualization.title || dermWidgetProps.title || "";
|
|
312
|
-
dv.visualization.description = ""; // TODO - should this map to anything?
|
|
313
|
-
dv.visualization.visibility = dv.visualization.visibility === "flyout" ? "flyout" : "normal";
|
|
314
|
-
dv.visualization.chartType = dv.visualization.__class.split("_")[1];
|
|
315
|
-
var _loop_1 = function (propName) {
|
|
316
|
-
if (typeof propertyMappings[propName] !== "undefined") {
|
|
317
|
-
if (propertyMappings[propName] instanceof Array) {
|
|
318
|
-
propertyMappings[propName].forEach(function (p) {
|
|
319
|
-
var newPropName = p.name;
|
|
320
|
-
dv.visualization.properties.widget[newPropName] = p.transform(dermWidgetProps[propName]);
|
|
321
|
-
if (typeof propertyMappings[propName].transform === "function") {
|
|
322
|
-
dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
dv.visualization.properties.widget[newPropName] = dermWidgetProps[propName];
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
var newPropName = propertyMappings[propName].name;
|
|
331
|
-
dv.visualization.properties.widget[newPropName] = propertyMappings[propName].transform(dermWidgetProps[propName]);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
for (var propName in dermWidgetProps) {
|
|
336
|
-
_loop_1(propName);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
function apply_to_properties_layout(ddl2, dermObj) {
|
|
342
|
-
var retVal = {
|
|
343
|
-
layout: []
|
|
344
|
-
};
|
|
345
|
-
if (!dermObj || !dermObj.__properties)
|
|
346
|
-
return;
|
|
347
|
-
dermObj.__properties.content.forEach(function (cell) {
|
|
348
|
-
var cellPosition = {
|
|
349
|
-
// TODO - if "id" could be avoided then layouts could apply to any dashboard with the same number of widgets
|
|
350
|
-
id: cell.__properties.widget.__id,
|
|
351
|
-
position: [
|
|
352
|
-
cell.__properties.gridCol,
|
|
353
|
-
cell.__properties.gridRow,
|
|
354
|
-
cell.__properties.gridColSpan,
|
|
355
|
-
cell.__properties.gridRowSpan
|
|
356
|
-
]
|
|
357
|
-
};
|
|
358
|
-
retVal.layout.push(cellPosition);
|
|
359
|
-
});
|
|
360
|
-
return retVal;
|
|
361
|
-
}
|
|
362
|
-
function upgrade(ddl2, dermObj) {
|
|
363
|
-
apply_to_dataviews(ddl2, dermObj);
|
|
364
|
-
return apply_to_properties_layout(ddl2, dermObj);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function faCharFix(faChar) {
|
|
368
|
-
return faChar;
|
|
369
|
-
}
|
|
370
|
-
var DDLUpgrade = /** @class */ (function () {
|
|
371
|
-
function DDLUpgrade(ddl, baseUrl, wuid, toLowerCase) {
|
|
372
|
-
if (baseUrl === void 0) { baseUrl = "http://localhost:8010"; }
|
|
373
|
-
if (wuid === void 0) { wuid = "WUID"; }
|
|
374
|
-
if (toLowerCase === void 0) { toLowerCase = true; }
|
|
375
|
-
this._datasources = {};
|
|
376
|
-
this._datasourceUpdates = {};
|
|
377
|
-
this._visualizations = {};
|
|
378
|
-
this._ddl2Datasources = {};
|
|
379
|
-
this._ddl2DatasourceFields = {};
|
|
380
|
-
this._ddl2Dataviews = {};
|
|
381
|
-
this._ddl2DataviewActivities = {};
|
|
382
|
-
this._ddl = ddl;
|
|
383
|
-
this._baseUrl = baseUrl;
|
|
384
|
-
this._wuid = wuid;
|
|
385
|
-
this._toLowerCase = toLowerCase;
|
|
386
|
-
this.indexDDL();
|
|
387
|
-
this.readDDL();
|
|
388
|
-
}
|
|
389
|
-
DDLUpgrade.prototype.toLowerCase = function (s) {
|
|
390
|
-
return this._toLowerCase ? s.toLowerCase() : s;
|
|
391
|
-
};
|
|
392
|
-
DDLUpgrade.prototype.isVizDatasourceRoxie = function (viz) {
|
|
393
|
-
if (viz.source) {
|
|
394
|
-
var ds = this._datasources[viz.source.id];
|
|
395
|
-
if (isHipieDatasource(ds)) {
|
|
396
|
-
return true;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return false;
|
|
400
|
-
};
|
|
401
|
-
DDLUpgrade.prototype.getDatasourceOutputs = function (dsID, vizID) {
|
|
402
|
-
var retVal = [];
|
|
403
|
-
var datasource = this._datasources[dsID];
|
|
404
|
-
for (var _i = 0, _a = datasource.outputs; _i < _a.length; _i++) {
|
|
405
|
-
var output = _a[_i];
|
|
406
|
-
if (output.notify) {
|
|
407
|
-
for (var _b = 0, _c = output.notify; _b < _c.length; _b++) {
|
|
408
|
-
var notify = _c[_b];
|
|
409
|
-
if (notify === vizID) {
|
|
410
|
-
retVal.push({
|
|
411
|
-
datasource: datasource,
|
|
412
|
-
output: output
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return retVal;
|
|
419
|
-
};
|
|
420
|
-
DDLUpgrade.prototype.getDatasourceFilters = function (dsID, vizID) {
|
|
421
|
-
var retVal = {};
|
|
422
|
-
for (var _i = 0, _a = this.getDatasourceOutputs(dsID, vizID); _i < _a.length; _i++) {
|
|
423
|
-
var dsOut = _a[_i];
|
|
424
|
-
if (dsOut.output.filter) {
|
|
425
|
-
for (var _b = 0, _c = dsOut.output.filter; _b < _c.length; _b++) {
|
|
426
|
-
var filter = _c[_b];
|
|
427
|
-
retVal[filter.fieldid] = {
|
|
428
|
-
datasource: dsOut.datasource,
|
|
429
|
-
output: dsOut.output,
|
|
430
|
-
filter: filter
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
return retVal;
|
|
436
|
-
};
|
|
437
|
-
DDLUpgrade.prototype.indexDDL = function () {
|
|
438
|
-
for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
|
|
439
|
-
var dash = _a[_i];
|
|
440
|
-
for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
|
|
441
|
-
var viz = _c[_b];
|
|
442
|
-
this._visualizations[viz.id] = viz;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
for (var _d = 0, _e = this._ddl.datasources; _d < _e.length; _d++) {
|
|
446
|
-
var ds = _e[_d];
|
|
447
|
-
this._datasources[ds.id] = ds;
|
|
448
|
-
for (var _f = 0, _g = ds.outputs; _f < _g.length; _f++) {
|
|
449
|
-
var output = _g[_f];
|
|
450
|
-
if (output.notify) {
|
|
451
|
-
for (var _h = 0, _j = output.notify; _h < _j.length; _h++) {
|
|
452
|
-
var notify = _j[_h];
|
|
453
|
-
this._datasourceUpdates[notify] = {
|
|
454
|
-
id: ds.id,
|
|
455
|
-
output: output.from || output.id
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
DDLUpgrade.prototype.readDDL = function () {
|
|
463
|
-
for (var _i = 0, _a = this._ddl.datasources; _i < _a.length; _i++) {
|
|
464
|
-
var ds = _a[_i];
|
|
465
|
-
if (isWorkunitDatasource(ds)) {
|
|
466
|
-
var ddl2DS = {
|
|
467
|
-
type: "wuresult",
|
|
468
|
-
id: ds.id,
|
|
469
|
-
url: this._baseUrl,
|
|
470
|
-
wuid: this._wuid,
|
|
471
|
-
outputs: {}
|
|
472
|
-
};
|
|
473
|
-
for (var _b = 0, _c = ds.outputs; _b < _c.length; _b++) {
|
|
474
|
-
var output = _c[_b];
|
|
475
|
-
this.output2output(output, ddl2DS.outputs);
|
|
476
|
-
}
|
|
477
|
-
this._ddl2Datasources[ds.id] = ddl2DS;
|
|
478
|
-
}
|
|
479
|
-
else if (isDatabombDatasource(ds)) ;
|
|
480
|
-
else {
|
|
481
|
-
var urlParts = ds.URL.split("/WsEcl/submit/query/");
|
|
482
|
-
var hostParts = urlParts[0];
|
|
483
|
-
var roxieParts = urlParts[1].split("/");
|
|
484
|
-
var ddl2DS = {
|
|
485
|
-
type: "hipie",
|
|
486
|
-
id: ds.id,
|
|
487
|
-
url: hostParts,
|
|
488
|
-
querySet: roxieParts[0],
|
|
489
|
-
queryID: roxieParts[1],
|
|
490
|
-
inputs: [],
|
|
491
|
-
outputs: {}
|
|
492
|
-
};
|
|
493
|
-
for (var _d = 0, _e = ds.outputs; _d < _e.length; _d++) {
|
|
494
|
-
var output = _e[_d];
|
|
495
|
-
this.output2output(output, ddl2DS.outputs);
|
|
496
|
-
}
|
|
497
|
-
this._ddl2Datasources[ds.id] = ddl2DS;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
for (var _f = 0, _g = this._ddl.dashboards; _f < _g.length; _f++) {
|
|
501
|
-
var dash = _g[_f];
|
|
502
|
-
for (var _h = 0, _j = dash.visualizations; _h < _j.length; _h++) {
|
|
503
|
-
var viz = _j[_h];
|
|
504
|
-
if (viz.type === "FORM") {
|
|
505
|
-
this._ddl2Datasources[viz.id] = {
|
|
506
|
-
type: "form",
|
|
507
|
-
id: viz.id,
|
|
508
|
-
fields: this.formFields2field(viz.fields)
|
|
509
|
-
};
|
|
510
|
-
this._datasourceUpdates[viz.id] = { id: viz.id };
|
|
511
|
-
}
|
|
512
|
-
else if (viz.type === "SLIDER") {
|
|
513
|
-
this._ddl2Datasources[viz.id] = {
|
|
514
|
-
type: "form",
|
|
515
|
-
id: viz.id,
|
|
516
|
-
fields: this.formFields2field(viz.fields, true)
|
|
517
|
-
};
|
|
518
|
-
this._datasourceUpdates[viz.id] = { id: viz.id };
|
|
519
|
-
}
|
|
520
|
-
this._ddl2Dataviews[viz.id] = this.anyViz2view(viz);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
this.readGroupBy();
|
|
524
|
-
this.readFilters();
|
|
525
|
-
this.readSort();
|
|
526
|
-
this.readMappings();
|
|
527
|
-
};
|
|
528
|
-
DDLUpgrade.prototype.readGroupBy = function () {
|
|
529
|
-
for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
|
|
530
|
-
var dash = _a[_i];
|
|
531
|
-
for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
|
|
532
|
-
var viz = _c[_b];
|
|
533
|
-
if (viz.fields) {
|
|
534
|
-
var projectTransformations = [];
|
|
535
|
-
var groupByColumns = [];
|
|
536
|
-
var aggrFields = [];
|
|
537
|
-
for (var _d = 0, _e = viz.fields; _d < _e.length; _d++) {
|
|
538
|
-
var field = _e[_d];
|
|
539
|
-
if (field.properties && field.properties.function) {
|
|
540
|
-
switch (field.properties.function) {
|
|
541
|
-
case "SUM":
|
|
542
|
-
case "MIN":
|
|
543
|
-
case "MAX":
|
|
544
|
-
aggrFields.push({
|
|
545
|
-
type: this.func2aggr(field.properties.function),
|
|
546
|
-
inFieldID: this.toLowerCase(field.properties.params.param1),
|
|
547
|
-
fieldID: this.toLowerCase(field.id)
|
|
548
|
-
});
|
|
549
|
-
break;
|
|
550
|
-
case "AVE":
|
|
551
|
-
aggrFields.push({
|
|
552
|
-
type: this.func2aggr(field.properties.function),
|
|
553
|
-
inFieldID: this.toLowerCase(field.properties.params.param1),
|
|
554
|
-
baseCountFieldID: field.properties.params.param2 ? this.toLowerCase(field.properties.params.param2) : undefined,
|
|
555
|
-
fieldID: this.toLowerCase(field.id)
|
|
556
|
-
});
|
|
557
|
-
break;
|
|
558
|
-
case "SCALE":
|
|
559
|
-
if (typeof field.properties.params.param1 === "object") {
|
|
560
|
-
var props = field.properties.params.param1;
|
|
561
|
-
switch (props.function) {
|
|
562
|
-
case "SUM":
|
|
563
|
-
case "MIN":
|
|
564
|
-
case "MAX":
|
|
565
|
-
aggrFields.push({
|
|
566
|
-
type: this.func2aggr(props.function),
|
|
567
|
-
inFieldID: this.toLowerCase(props.params.param1),
|
|
568
|
-
fieldID: this.toLowerCase(field.id)
|
|
569
|
-
});
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
projectTransformations.push({
|
|
574
|
-
type: "scale",
|
|
575
|
-
sourceFieldID: this.toLowerCase(field.id),
|
|
576
|
-
fieldID: this.toLowerCase(field.id),
|
|
577
|
-
factor: +field.properties.params.param2
|
|
578
|
-
});
|
|
579
|
-
break;
|
|
580
|
-
default:
|
|
581
|
-
groupByColumns.push(this.toLowerCase(field.id));
|
|
582
|
-
throw new Error("Unhandled field function: "
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
groupByColumns.push(this.toLowerCase(field.id));
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
if (projectTransformations.length) {
|
|
590
|
-
this._ddl2DataviewActivities[viz.id].project.transformations = projectTransformations;
|
|
591
|
-
}
|
|
592
|
-
if (aggrFields.length) {
|
|
593
|
-
this._ddl2DataviewActivities[viz.id].groupBy.groupByIDs = __spreadArray([], groupByColumns);
|
|
594
|
-
this._ddl2DataviewActivities[viz.id].groupBy.aggregates = aggrFields;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
DDLUpgrade.prototype.func2aggr = function (func) {
|
|
601
|
-
switch (func) {
|
|
602
|
-
case "SUM":
|
|
603
|
-
return "sum";
|
|
604
|
-
case "AVE":
|
|
605
|
-
return "mean";
|
|
606
|
-
case "MIN":
|
|
607
|
-
return "min";
|
|
608
|
-
case "MAX":
|
|
609
|
-
return "max";
|
|
610
|
-
}
|
|
611
|
-
throw new Error("Unknown DDL1 Function Type: "
|
|
612
|
-
};
|
|
613
|
-
DDLUpgrade.prototype.readMappings = function () {
|
|
614
|
-
for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
|
|
615
|
-
var dash = _a[_i];
|
|
616
|
-
for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
|
|
617
|
-
var viz = _c[_b];
|
|
618
|
-
if (isFormVisualization(viz)) ;
|
|
619
|
-
else if (isPieVisualization(viz)) {
|
|
620
|
-
this.readPieMappings(viz);
|
|
621
|
-
}
|
|
622
|
-
else if (isChoroVisualization(viz)) {
|
|
623
|
-
this.readChoroMappings(viz);
|
|
624
|
-
}
|
|
625
|
-
else if (isLineVisualization(viz)) {
|
|
626
|
-
this.readLineMappings(viz);
|
|
627
|
-
}
|
|
628
|
-
else if (isTableVisualization(viz)) {
|
|
629
|
-
this.readTableMappings(viz);
|
|
630
|
-
}
|
|
631
|
-
else if (isGraphVisualization(viz)) {
|
|
632
|
-
this.readGraphMappings(viz);
|
|
633
|
-
}
|
|
634
|
-
else if (isSliderVisualization(viz)) {
|
|
635
|
-
this.readSliderMappings(viz);
|
|
636
|
-
}
|
|
637
|
-
else {
|
|
638
|
-
throw new Error("Unkown DDL1 mapping type: "
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
DDLUpgrade.prototype.readPieMappings = function (viz) {
|
|
644
|
-
var mappings = this._ddl2DataviewActivities[viz.id].mappings;
|
|
645
|
-
mappings.transformations.push({
|
|
646
|
-
fieldID: "label",
|
|
647
|
-
type: "=",
|
|
648
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.label)
|
|
649
|
-
});
|
|
650
|
-
mappings.transformations.push({
|
|
651
|
-
fieldID: "weight",
|
|
652
|
-
type: "=",
|
|
653
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
|
|
654
|
-
});
|
|
655
|
-
};
|
|
656
|
-
DDLUpgrade.prototype.readChoroMappings = function (viz) {
|
|
657
|
-
var mappings = this._ddl2DataviewActivities[viz.id].mappings;
|
|
658
|
-
mappings.transformations.push({
|
|
659
|
-
fieldID: "label",
|
|
660
|
-
type: "=",
|
|
661
|
-
sourceFieldID: this.toLowerCase(this.anyChoroMapping2label(viz.source.mappings))
|
|
662
|
-
});
|
|
663
|
-
mappings.transformations.push({
|
|
664
|
-
fieldID: "weight",
|
|
665
|
-
type: "=",
|
|
666
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.weight[0])
|
|
667
|
-
});
|
|
668
|
-
};
|
|
669
|
-
DDLUpgrade.prototype.anyChoroMapping2label = function (mapping) {
|
|
670
|
-
return mapping.state || mapping.county || mapping.geohash;
|
|
671
|
-
};
|
|
672
|
-
DDLUpgrade.prototype.readLineMappings = function (viz) {
|
|
673
|
-
var mappings = this._ddl2DataviewActivities[viz.id].mappings;
|
|
674
|
-
mappings.transformations.push({
|
|
675
|
-
fieldID: viz.source.mappings.x[0],
|
|
676
|
-
type: "=",
|
|
677
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.x[0])
|
|
678
|
-
});
|
|
679
|
-
for (var i = 0; i < viz.source.mappings.y.length; ++i) {
|
|
680
|
-
mappings.transformations.push({
|
|
681
|
-
fieldID: viz.source.mappings.y[i],
|
|
682
|
-
type: "=",
|
|
683
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.y[i])
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
DDLUpgrade.prototype.readTableMappings = function (viz) {
|
|
688
|
-
var mappings = this._ddl2DataviewActivities[viz.id].mappings;
|
|
689
|
-
for (var i = 0; i < viz.label.length; ++i) {
|
|
690
|
-
mappings.transformations.push({
|
|
691
|
-
fieldID: viz.label[i],
|
|
692
|
-
type: "=",
|
|
693
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.value[i])
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
};
|
|
697
|
-
DDLUpgrade.prototype.readGraphEnums = function (valueMappings, annotation) {
|
|
698
|
-
if (annotation === void 0) { annotation = false; }
|
|
699
|
-
var retVal = [];
|
|
700
|
-
if (valueMappings) {
|
|
701
|
-
for (var value in valueMappings) {
|
|
702
|
-
var newValue = {};
|
|
703
|
-
for (var key in valueMappings[value]) {
|
|
704
|
-
if (key === "faChar") {
|
|
705
|
-
newValue[key] = faCharFix(valueMappings[value][key]);
|
|
706
|
-
}
|
|
707
|
-
else if (annotation && key.indexOf("icon_") === 0) {
|
|
708
|
-
console.log("Deprecated flag property: " + key);
|
|
709
|
-
newValue[key.split("icon_")[1]] = valueMappings[value][key];
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
newValue[key] = valueMappings[value][key];
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
// remove v1.x "0" annotations as they equated to "nothing" ---
|
|
716
|
-
if (!annotation || value !== "0") {
|
|
717
|
-
retVal.push({
|
|
718
|
-
value: value,
|
|
719
|
-
newValue: newValue
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
return retVal;
|
|
725
|
-
};
|
|
726
|
-
DDLUpgrade.prototype.readGraphMappings = function (viz) {
|
|
727
|
-
var mappings = this._ddl2DataviewActivities[viz.id].mappings;
|
|
728
|
-
mappings.transformations.push({
|
|
729
|
-
fieldID: "uid",
|
|
730
|
-
type: "=",
|
|
731
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.uid)
|
|
732
|
-
});
|
|
733
|
-
mappings.transformations.push({
|
|
734
|
-
fieldID: "label",
|
|
735
|
-
type: "=",
|
|
736
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.label)
|
|
737
|
-
});
|
|
738
|
-
if (viz.icon.fieldid) {
|
|
739
|
-
mappings.transformations.push({
|
|
740
|
-
fieldID: "icon",
|
|
741
|
-
type: "map",
|
|
742
|
-
sourceFieldID: this.toLowerCase(viz.icon.fieldid),
|
|
743
|
-
default: { fachar: faCharFix(viz.icon.faChar) },
|
|
744
|
-
mappings: this.readGraphEnums(viz.icon.valuemappings)
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
var idx = 0;
|
|
748
|
-
if (viz.flag) {
|
|
749
|
-
for (var _i = 0, _a = viz.flag; _i < _a.length; _i++) {
|
|
750
|
-
var flag = _a[_i];
|
|
751
|
-
if (flag.fieldid) {
|
|
752
|
-
mappings.transformations.push({
|
|
753
|
-
fieldID: "annotation_"
|
|
754
|
-
type: "map",
|
|
755
|
-
sourceFieldID: this.toLowerCase(flag.fieldid),
|
|
756
|
-
default: {},
|
|
757
|
-
mappings: this.readGraphEnums(flag.valuemappings, true)
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
mappings.transformations.push({
|
|
763
|
-
fieldID: "links",
|
|
764
|
-
type: "=",
|
|
765
|
-
sourceFieldID: this.toLowerCase(viz.source.link.childfile),
|
|
766
|
-
transformations: [{
|
|
767
|
-
fieldID: "uid",
|
|
768
|
-
type: "=",
|
|
769
|
-
sourceFieldID: this.toLowerCase(viz.source.link.mappings.uid)
|
|
770
|
-
}]
|
|
771
|
-
});
|
|
772
|
-
};
|
|
773
|
-
DDLUpgrade.prototype.readSliderMappings = function (viz) {
|
|
774
|
-
var mappings = this._ddl2DataviewActivities[viz.id].mappings;
|
|
775
|
-
mappings.transformations.push({
|
|
776
|
-
fieldID: "label",
|
|
777
|
-
type: "=",
|
|
778
|
-
sourceFieldID: this.toLowerCase(viz.source.mappings.label)
|
|
779
|
-
});
|
|
780
|
-
};
|
|
781
|
-
DDLUpgrade.prototype.readFilters = function () {
|
|
782
|
-
for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
|
|
783
|
-
var dash = _a[_i];
|
|
784
|
-
for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
|
|
785
|
-
var viz = _c[_b];
|
|
786
|
-
if (viz.events) {
|
|
787
|
-
for (var eventID in viz.events) {
|
|
788
|
-
var event_1 = viz.events[eventID];
|
|
789
|
-
for (var _d = 0, _e = event_1.updates; _d < _e.length; _d++) {
|
|
790
|
-
var update = _e[_d];
|
|
791
|
-
var otherViz = this._ddl2Dataviews[update.visualization];
|
|
792
|
-
var dsFilters = this.getDatasourceFilters(update.datasource, otherViz.id);
|
|
793
|
-
if (update.mappings) {
|
|
794
|
-
if (isRoxieServiceRef(otherViz.datasource)) {
|
|
795
|
-
for (var key in update.mappings) {
|
|
796
|
-
otherViz.datasource.request.push({
|
|
797
|
-
source: viz.id,
|
|
798
|
-
remoteFieldID: this.toLowerCase(key),
|
|
799
|
-
localFieldID: this.toLowerCase(update.mappings[key])
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
else {
|
|
804
|
-
var condition = {
|
|
805
|
-
viewID: viz.id,
|
|
806
|
-
mappings: []
|
|
807
|
-
};
|
|
808
|
-
for (var key in update.mappings) {
|
|
809
|
-
var mapping = update.mappings[key];
|
|
810
|
-
var dsFilter = (mapping && dsFilters[mapping]) ? dsFilters[mapping].filter : undefined;
|
|
811
|
-
if (!dsFilter) {
|
|
812
|
-
console.warn("Select Mapping \""
|
|
813
|
-
}
|
|
814
|
-
else {
|
|
815
|
-
condition.mappings.push({
|
|
816
|
-
remoteFieldID: this.toLowerCase(key),
|
|
817
|
-
localFieldID: this.toLowerCase(update.mappings[key]),
|
|
818
|
-
condition: this.rule2condition(dsFilter.rule),
|
|
819
|
-
nullable: dsFilter.nullable
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
this._ddl2DataviewActivities[otherViz.id].filters.conditions.push(condition);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
DDLUpgrade.prototype.rule2condition = function (_) {
|
|
833
|
-
switch (_) {
|
|
834
|
-
case "set":
|
|
835
|
-
return "in";
|
|
836
|
-
case "notequals":
|
|
837
|
-
return "!=";
|
|
838
|
-
}
|
|
839
|
-
return _;
|
|
840
|
-
};
|
|
841
|
-
DDLUpgrade.prototype.readSort = function () {
|
|
842
|
-
var _this = this;
|
|
843
|
-
for (var _i = 0, _a = this._ddl.dashboards; _i < _a.length; _i++) {
|
|
844
|
-
var dash = _a[_i];
|
|
845
|
-
for (var _b = 0, _c = dash.visualizations; _b < _c.length; _b++) {
|
|
846
|
-
var viz = _c[_b];
|
|
847
|
-
if (viz.source) {
|
|
848
|
-
if (viz.source.sort) {
|
|
849
|
-
var vizSort = this._ddl2DataviewActivities[viz.id].sort;
|
|
850
|
-
vizSort.conditions = viz.source.sort.map(function (s) {
|
|
851
|
-
if (s.indexOf("-") === 0) {
|
|
852
|
-
return {
|
|
853
|
-
fieldID: _this.toLowerCase(s.substr(1)),
|
|
854
|
-
descending: true
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
return {
|
|
858
|
-
fieldID: _this.toLowerCase(s),
|
|
859
|
-
descending: false
|
|
860
|
-
};
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
if (viz.source.first) {
|
|
864
|
-
var vizLimit = this._ddl2DataviewActivities[viz.id].limit;
|
|
865
|
-
vizLimit.limit = +viz.source.first;
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
DDLUpgrade.prototype.anyViz2view = function (viz) {
|
|
872
|
-
var project = {
|
|
873
|
-
type: "project",
|
|
874
|
-
transformations: []
|
|
875
|
-
};
|
|
876
|
-
var filters = {
|
|
877
|
-
type: "filter",
|
|
878
|
-
conditions: []
|
|
879
|
-
};
|
|
880
|
-
var groupBy = {
|
|
881
|
-
type: "groupby",
|
|
882
|
-
groupByIDs: [],
|
|
883
|
-
aggregates: []
|
|
884
|
-
};
|
|
885
|
-
var sort = {
|
|
886
|
-
type: "sort",
|
|
887
|
-
conditions: []
|
|
888
|
-
};
|
|
889
|
-
var limit = {
|
|
890
|
-
type: "limit",
|
|
891
|
-
limit: 0
|
|
892
|
-
};
|
|
893
|
-
var mappings = {
|
|
894
|
-
type: "mappings",
|
|
895
|
-
transformations: []
|
|
896
|
-
};
|
|
897
|
-
this._ddl2DataviewActivities[viz.id] = {
|
|
898
|
-
project: project,
|
|
899
|
-
filters: filters,
|
|
900
|
-
sort: sort,
|
|
901
|
-
groupBy: groupBy,
|
|
902
|
-
limit: limit,
|
|
903
|
-
mappings: mappings
|
|
904
|
-
};
|
|
905
|
-
var datasourceRef = this.isVizDatasourceRoxie(viz) ? {
|
|
906
|
-
id: this._datasourceUpdates[viz.id].id,
|
|
907
|
-
request: [],
|
|
908
|
-
output: this._datasourceUpdates[viz.id].output
|
|
909
|
-
} : {
|
|
910
|
-
id: this._datasourceUpdates[viz.id].id,
|
|
911
|
-
output: this._datasourceUpdates[viz.id].output
|
|
912
|
-
};
|
|
913
|
-
return {
|
|
914
|
-
id: viz.id,
|
|
915
|
-
datasource: datasourceRef,
|
|
916
|
-
activities: [
|
|
917
|
-
project,
|
|
918
|
-
filters,
|
|
919
|
-
sort,
|
|
920
|
-
groupBy,
|
|
921
|
-
limit
|
|
922
|
-
],
|
|
923
|
-
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 || {}) })
|
|
924
|
-
};
|
|
925
|
-
};
|
|
926
|
-
DDLUpgrade.prototype.type2chartType = function (chartType) {
|
|
927
|
-
switch (chartType) {
|
|
928
|
-
case "LINE":
|
|
929
|
-
return { chartType: "Line", __class: "chart_Line" };
|
|
930
|
-
case "BUBBLE":
|
|
931
|
-
return { chartType: "Bubble", __class: "chart_Bubble" };
|
|
932
|
-
case "PIE":
|
|
933
|
-
return { chartType: "Pie", __class: "chart_Pie" };
|
|
934
|
-
case "BAR":
|
|
935
|
-
return { chartType: "Column", __class: "chart_Column" };
|
|
936
|
-
case "FORM":
|
|
937
|
-
return { chartType: "FieldForm", __class: "form_FieldForm" };
|
|
938
|
-
case "WORD_CLOUD":
|
|
939
|
-
return { chartType: "WordCloud", __class: "chart_WordCloud" };
|
|
940
|
-
case "CHORO":
|
|
941
|
-
return { chartType: "ChoroplethStates", __class: "map_ChoroplethStates" };
|
|
942
|
-
case "SUMMARY":
|
|
943
|
-
return { chartType: "Summary", __class: "chart_Summary" };
|
|
944
|
-
case "SLIDER":
|
|
945
|
-
return { chartType: "FieldForm", __class: "form_FieldForm" };
|
|
946
|
-
case "HEAT_MAP":
|
|
947
|
-
return { chartType: "HeatMap", __class: "other_HeatMap" };
|
|
948
|
-
case "2DCHART":
|
|
949
|
-
return { chartType: "Column", __class: "chart_Column" };
|
|
950
|
-
case "GRAPH":
|
|
951
|
-
return { chartType: "AdjacencyGraph", __class: "graph_AdjacencyGraph" };
|
|
952
|
-
case "TABLE":
|
|
953
|
-
default:
|
|
954
|
-
return { chartType: "Table", __class: "dgrid_Table" };
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
DDLUpgrade.prototype.formFields2field = function (fields, slider) {
|
|
958
|
-
var _this = this;
|
|
959
|
-
if (slider === void 0) { slider = false; }
|
|
960
|
-
if (!fields)
|
|
961
|
-
return [];
|
|
962
|
-
return fields.map(function (field) {
|
|
963
|
-
switch (field.properties.type) {
|
|
964
|
-
case "range":
|
|
965
|
-
return {
|
|
966
|
-
type: "range",
|
|
967
|
-
id: field.id,
|
|
968
|
-
default: (field.properties.default ? field.properties.default : undefined)
|
|
969
|
-
};
|
|
970
|
-
case "dataset":
|
|
971
|
-
return {
|
|
972
|
-
type: "dataset",
|
|
973
|
-
id: field.id,
|
|
974
|
-
default: [],
|
|
975
|
-
children: []
|
|
976
|
-
};
|
|
977
|
-
default:
|
|
978
|
-
return {
|
|
979
|
-
type: _this.formFieldType2fieldType(field.properties.datatype, slider),
|
|
980
|
-
id: field.id,
|
|
981
|
-
default: field.properties.default ? field.properties.default[0] : undefined
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
|
-
};
|
|
986
|
-
DDLUpgrade.prototype.formFieldType2fieldType = function (fieldType, slider) {
|
|
987
|
-
switch (fieldType) {
|
|
988
|
-
case "bool":
|
|
989
|
-
case "boolean":
|
|
990
|
-
return "boolean";
|
|
991
|
-
case "integer":
|
|
992
|
-
case "unsigned":
|
|
993
|
-
case "float":
|
|
994
|
-
case "double":
|
|
995
|
-
case "real":
|
|
996
|
-
return "number";
|
|
997
|
-
case "string":
|
|
998
|
-
return "string";
|
|
999
|
-
default:
|
|
1000
|
-
return slider ? "number" : "string";
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
DDLUpgrade.prototype.output2output = function (output, target) {
|
|
1004
|
-
target[output.from || output.id] = {
|
|
1005
|
-
fields: this.filters2fields(output.filter)
|
|
1006
|
-
};
|
|
1007
|
-
};
|
|
1008
|
-
DDLUpgrade.prototype.filters2fields = function (filters) {
|
|
1009
|
-
if (!filters)
|
|
1010
|
-
return [];
|
|
1011
|
-
return filters.filter(function (filter) {
|
|
1012
|
-
var idParts = filter.fieldid.split("-");
|
|
1013
|
-
return idParts.length === 1 || idParts[1] === "range";
|
|
1014
|
-
}).map(function (filter) {
|
|
1015
|
-
var idParts = filter.fieldid.split("-");
|
|
1016
|
-
var retVal = {
|
|
1017
|
-
type: "string",
|
|
1018
|
-
id: idParts[0]
|
|
1019
|
-
};
|
|
1020
|
-
return retVal;
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
1023
|
-
DDLUpgrade.prototype.getVizField = function (vizID, fieldID) {
|
|
1024
|
-
return {
|
|
1025
|
-
type: "string",
|
|
1026
|
-
id: "",
|
|
1027
|
-
default: ""
|
|
1028
|
-
};
|
|
1029
|
-
};
|
|
1030
|
-
DDLUpgrade.prototype.writeDatasources = function () {
|
|
1031
|
-
var retVal = [];
|
|
1032
|
-
for (var id in this._ddl2Datasources) {
|
|
1033
|
-
retVal.push(this._ddl2Datasources[id]);
|
|
1034
|
-
}
|
|
1035
|
-
return retVal;
|
|
1036
|
-
};
|
|
1037
|
-
DDLUpgrade.prototype.writeDataviews = function () {
|
|
1038
|
-
var retVal = [];
|
|
1039
|
-
for (var id in this._ddl2Dataviews) {
|
|
1040
|
-
retVal.push(this._ddl2Dataviews[id]);
|
|
1041
|
-
}
|
|
1042
|
-
return retVal;
|
|
1043
|
-
};
|
|
1044
|
-
DDLUpgrade.prototype.writeProperties = function () {
|
|
1045
|
-
return {
|
|
1046
|
-
// TODO
|
|
1047
|
-
};
|
|
1048
|
-
};
|
|
1049
|
-
DDLUpgrade.prototype.write = function () {
|
|
1050
|
-
return {
|
|
1051
|
-
version: "2.2.1",
|
|
1052
|
-
createdBy: {
|
|
1053
|
-
name: PKG_NAME,
|
|
1054
|
-
version: PKG_VERSION
|
|
1055
|
-
},
|
|
1056
|
-
datasources: this.writeDatasources(),
|
|
1057
|
-
dataviews: this.writeDataviews(),
|
|
1058
|
-
properties: this.writeProperties()
|
|
1059
|
-
};
|
|
1060
|
-
};
|
|
1061
|
-
return DDLUpgrade;
|
|
1062
|
-
}());
|
|
1063
|
-
function upgrade
|
|
1064
|
-
if (toLowerCase === void 0) { toLowerCase = true; }
|
|
1065
|
-
if (dermatologyJson === void 0) { dermatologyJson = {}; }
|
|
1066
|
-
var ddlUp = new DDLUpgrade(ddl, baseUrl, wuid, toLowerCase);
|
|
1067
|
-
var retVal = ddlUp.write();
|
|
1068
|
-
retVal.properties = upgrade(retVal, dermatologyJson);
|
|
1069
|
-
return retVal;
|
|
161
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
162
|
+
}
|
|
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;
|
|
1070
1085
|
}
|
|
1071
1086
|
|
|
1072
1087
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1073
1088
|
|
|
1074
|
-
|
|
1075
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
function createCommonjsModule(fn, basedir, module) {
|
|
1079
|
-
return module = {
|
|
1080
|
-
path: basedir,
|
|
1081
|
-
exports: {},
|
|
1082
|
-
require: function (path, base) {
|
|
1083
|
-
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
1084
|
-
}
|
|
1085
|
-
}, fn(module, module.exports), module.exports;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
function getCjsExportFromNamespace (n) {
|
|
1089
|
-
return n && n['default'] || n;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
function commonjsRequire () {
|
|
1093
|
-
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
1094
|
-
}
|
|
1089
|
+
var uri_all = {exports: {}};
|
|
1095
1090
|
|
|
1096
|
-
var uri_all = createCommonjsModule(function (module, exports) {
|
|
1097
1091
|
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
|
|
1092
|
+
|
|
1093
|
+
(function (module, exports) {
|
|
1098
1094
|
(function (global, factory) {
|
|
1099
|
-
|
|
1095
|
+
factory(exports) ;
|
|
1100
1096
|
}(commonjsGlobal, (function (exports) {
|
|
1101
1097
|
function merge() {
|
|
1102
1098
|
for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1150,10 +1146,10 @@ function buildExps(isIRI) {
|
|
|
1150
1146
|
//subset, excludes bidi control characters
|
|
1151
1147
|
IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
|
|
1152
1148
|
//subset
|
|
1153
|
-
UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$)
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
|
|
1149
|
+
UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$);
|
|
1150
|
+
subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*");
|
|
1151
|
+
subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*");
|
|
1152
|
+
var DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
|
|
1157
1153
|
//relaxed parsing rules
|
|
1158
1154
|
IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
|
|
1159
1155
|
H16$ = subexp(HEXDIG$$ + "{1,4}"),
|
|
@@ -1177,14 +1173,14 @@ function buildExps(isIRI) {
|
|
|
1177
1173
|
IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
|
|
1178
1174
|
//[ *6( h16 ":" ) h16 ] "::"
|
|
1179
1175
|
IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
|
|
1180
|
-
ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+")
|
|
1176
|
+
ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+");
|
|
1181
1177
|
//RFC 6874, with relaxed parsing rules
|
|
1182
|
-
|
|
1178
|
+
subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+");
|
|
1183
1179
|
//RFC 6874
|
|
1184
|
-
|
|
1185
|
-
PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]"))
|
|
1186
|
-
|
|
1187
|
-
|
|
1180
|
+
subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*");
|
|
1181
|
+
var PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]"));
|
|
1182
|
+
subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+");
|
|
1183
|
+
subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*");
|
|
1188
1184
|
return {
|
|
1189
1185
|
NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
|
|
1190
1186
|
NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
|
|
@@ -2298,7 +2294,7 @@ var handler$3 = {
|
|
|
2298
2294
|
|
|
2299
2295
|
var O = {};
|
|
2300
2296
|
//RFC 3986
|
|
2301
|
-
var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (
|
|
2297
|
+
var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + ("\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" ) + "]";
|
|
2302
2298
|
var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
|
|
2303
2299
|
var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
|
|
2304
2300
|
//RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
|
|
@@ -2496,25 +2492,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2496
2492
|
|
|
2497
2493
|
})));
|
|
2498
2494
|
|
|
2499
|
-
});
|
|
2495
|
+
}(uri_all, uri_all.exports));
|
|
2496
|
+
|
|
2497
|
+
// do not edit .js files directly - edit src/index.jst
|
|
2500
2498
|
|
|
2501
|
-
unwrapExports(uri_all);
|
|
2502
2499
|
|
|
2503
|
-
var isArray = Array.isArray;
|
|
2504
|
-
var keyList = Object.keys;
|
|
2505
|
-
var hasProp = Object.prototype.hasOwnProperty;
|
|
2506
2500
|
|
|
2507
2501
|
var fastDeepEqual = function equal(a, b) {
|
|
2508
2502
|
if (a === b) return true;
|
|
2509
2503
|
|
|
2510
2504
|
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
2511
|
-
|
|
2512
|
-
, arrB = isArray(b)
|
|
2513
|
-
, i
|
|
2514
|
-
, length
|
|
2515
|
-
, key;
|
|
2505
|
+
if (a.constructor !== b.constructor) return false;
|
|
2516
2506
|
|
|
2517
|
-
|
|
2507
|
+
var length, i, keys;
|
|
2508
|
+
if (Array.isArray(a)) {
|
|
2518
2509
|
length = a.length;
|
|
2519
2510
|
if (length != b.length) return false;
|
|
2520
2511
|
for (i = length; i-- !== 0;)
|
|
@@ -2522,41 +2513,35 @@ var fastDeepEqual = function equal(a, b) {
|
|
|
2522
2513
|
return true;
|
|
2523
2514
|
}
|
|
2524
2515
|
|
|
2525
|
-
if (arrA != arrB) return false;
|
|
2526
2516
|
|
|
2527
|
-
var dateA = a instanceof Date
|
|
2528
|
-
, dateB = b instanceof Date;
|
|
2529
|
-
if (dateA != dateB) return false;
|
|
2530
|
-
if (dateA && dateB) return a.getTime() == b.getTime();
|
|
2531
2517
|
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
if (
|
|
2535
|
-
if (regexpA && regexpB) return a.toString() == b.toString();
|
|
2518
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
2519
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
2520
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
2536
2521
|
|
|
2537
|
-
|
|
2522
|
+
keys = Object.keys(a);
|
|
2538
2523
|
length = keys.length;
|
|
2539
|
-
|
|
2540
|
-
if (length !== keyList(b).length)
|
|
2541
|
-
return false;
|
|
2524
|
+
if (length !== Object.keys(b).length) return false;
|
|
2542
2525
|
|
|
2543
2526
|
for (i = length; i-- !== 0;)
|
|
2544
|
-
if (!
|
|
2527
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
2545
2528
|
|
|
2546
2529
|
for (i = length; i-- !== 0;) {
|
|
2547
|
-
key = keys[i];
|
|
2530
|
+
var key = keys[i];
|
|
2531
|
+
|
|
2548
2532
|
if (!equal(a[key], b[key])) return false;
|
|
2549
2533
|
}
|
|
2550
2534
|
|
|
2551
2535
|
return true;
|
|
2552
2536
|
}
|
|
2553
2537
|
|
|
2538
|
+
// true if both NaN, false otherwise
|
|
2554
2539
|
return a!==a && b!==b;
|
|
2555
2540
|
};
|
|
2556
2541
|
|
|
2557
2542
|
// https://mathiasbynens.be/notes/javascript-encoding
|
|
2558
2543
|
// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
|
|
2559
|
-
var ucs2length = function ucs2length(str) {
|
|
2544
|
+
var ucs2length$1 = function ucs2length(str) {
|
|
2560
2545
|
var length = 0
|
|
2561
2546
|
, len = str.length
|
|
2562
2547
|
, pos = 0
|
|
@@ -2573,20 +2558,18 @@ var ucs2length = function ucs2length(str) {
|
|
|
2573
2558
|
return length;
|
|
2574
2559
|
};
|
|
2575
2560
|
|
|
2576
|
-
var util = {
|
|
2561
|
+
var util$5 = {
|
|
2577
2562
|
copy: copy,
|
|
2578
2563
|
checkDataType: checkDataType,
|
|
2579
2564
|
checkDataTypes: checkDataTypes,
|
|
2580
2565
|
coerceToTypes: coerceToTypes,
|
|
2581
|
-
toHash: toHash,
|
|
2566
|
+
toHash: toHash$1,
|
|
2582
2567
|
getProperty: getProperty,
|
|
2583
2568
|
escapeQuotes: escapeQuotes,
|
|
2584
2569
|
equal: fastDeepEqual,
|
|
2585
|
-
ucs2length: ucs2length,
|
|
2570
|
+
ucs2length: ucs2length$1,
|
|
2586
2571
|
varOccurences: varOccurences,
|
|
2587
2572
|
varReplace: varReplace,
|
|
2588
|
-
cleanUpCode: cleanUpCode,
|
|
2589
|
-
finalCleanUpCode: finalCleanUpCode,
|
|
2590
2573
|
schemaHasRules: schemaHasRules,
|
|
2591
2574
|
schemaHasRulesExcept: schemaHasRulesExcept,
|
|
2592
2575
|
schemaUnknownRules: schemaUnknownRules,
|
|
@@ -2608,7 +2591,7 @@ function copy(o, to) {
|
|
|
2608
2591
|
}
|
|
2609
2592
|
|
|
2610
2593
|
|
|
2611
|
-
function checkDataType(dataType, data, negate) {
|
|
2594
|
+
function checkDataType(dataType, data, strictNumbers, negate) {
|
|
2612
2595
|
var EQUAL = negate ? ' !== ' : ' === '
|
|
2613
2596
|
, AND = negate ? ' || ' : ' && '
|
|
2614
2597
|
, OK = negate ? '!' : ''
|
|
@@ -2621,18 +2604,21 @@ function checkDataType(dataType, data, negate) {
|
|
|
2621
2604
|
NOT + 'Array.isArray(' + data + '))';
|
|
2622
2605
|
case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
|
|
2623
2606
|
NOT + '(' + data + ' % 1)' +
|
|
2624
|
-
AND + data + EQUAL + data +
|
|
2607
|
+
AND + data + EQUAL + data +
|
|
2608
|
+
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
|
|
2609
|
+
case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
|
|
2610
|
+
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
|
|
2625
2611
|
default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
|
|
2626
2612
|
}
|
|
2627
2613
|
}
|
|
2628
2614
|
|
|
2629
2615
|
|
|
2630
|
-
function checkDataTypes(dataTypes, data) {
|
|
2616
|
+
function checkDataTypes(dataTypes, data, strictNumbers) {
|
|
2631
2617
|
switch (dataTypes.length) {
|
|
2632
|
-
case 1: return checkDataType(dataTypes[0], data, true);
|
|
2618
|
+
case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
|
|
2633
2619
|
default:
|
|
2634
2620
|
var code = '';
|
|
2635
|
-
var types = toHash(dataTypes);
|
|
2621
|
+
var types = toHash$1(dataTypes);
|
|
2636
2622
|
if (types.array && types.object) {
|
|
2637
2623
|
code = types.null ? '(': '(!' + data + ' || ';
|
|
2638
2624
|
code += 'typeof ' + data + ' !== "object")';
|
|
@@ -2642,14 +2628,14 @@ function checkDataTypes(dataTypes, data) {
|
|
|
2642
2628
|
}
|
|
2643
2629
|
if (types.number) delete types.integer;
|
|
2644
2630
|
for (var t in types)
|
|
2645
|
-
code += (code ? ' && ' : '' ) + checkDataType(t, data, true);
|
|
2631
|
+
code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
|
|
2646
2632
|
|
|
2647
2633
|
return code;
|
|
2648
2634
|
}
|
|
2649
2635
|
}
|
|
2650
2636
|
|
|
2651
2637
|
|
|
2652
|
-
var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
|
|
2638
|
+
var COERCE_TO_TYPES = toHash$1([ 'string', 'number', 'integer', 'boolean', 'null' ]);
|
|
2653
2639
|
function coerceToTypes(optionCoerceTypes, dataTypes) {
|
|
2654
2640
|
if (Array.isArray(dataTypes)) {
|
|
2655
2641
|
var types = [];
|
|
@@ -2667,19 +2653,19 @@ function coerceToTypes(optionCoerceTypes, dataTypes) {
|
|
|
2667
2653
|
}
|
|
2668
2654
|
|
|
2669
2655
|
|
|
2670
|
-
function toHash(arr) {
|
|
2656
|
+
function toHash$1(arr) {
|
|
2671
2657
|
var hash = {};
|
|
2672
2658
|
for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
|
|
2673
2659
|
return hash;
|
|
2674
2660
|
}
|
|
2675
2661
|
|
|
2676
2662
|
|
|
2677
|
-
var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
|
2663
|
+
var IDENTIFIER$1 = /^[a-z$_][a-z$_0-9]*$/i;
|
|
2678
2664
|
var SINGLE_QUOTE = /'|\\/g;
|
|
2679
2665
|
function getProperty(key) {
|
|
2680
2666
|
return typeof key == 'number'
|
|
2681
2667
|
? '[' + key + ']'
|
|
2682
|
-
: IDENTIFIER.test(key)
|
|
2668
|
+
: IDENTIFIER$1.test(key)
|
|
2683
2669
|
? '.' + key
|
|
2684
2670
|
: "['" + escapeQuotes(key) + "']";
|
|
2685
2671
|
}
|
|
@@ -2708,42 +2694,6 @@ function varReplace(str, dataVar, expr) {
|
|
|
2708
2694
|
}
|
|
2709
2695
|
|
|
2710
2696
|
|
|
2711
|
-
var EMPTY_ELSE = /else\s*{\s*}/g
|
|
2712
|
-
, EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
|
|
2713
|
-
, EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
|
|
2714
|
-
function cleanUpCode(out) {
|
|
2715
|
-
return out.replace(EMPTY_ELSE, '')
|
|
2716
|
-
.replace(EMPTY_IF_NO_ELSE, '')
|
|
2717
|
-
.replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
|
|
2718
|
-
}
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
var ERRORS_REGEXP = /[^v.]errors/g
|
|
2722
|
-
, REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
|
|
2723
|
-
, REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
|
|
2724
|
-
, RETURN_VALID = 'return errors === 0;'
|
|
2725
|
-
, RETURN_TRUE = 'validate.errors = null; return true;'
|
|
2726
|
-
, RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
|
|
2727
|
-
, RETURN_DATA_ASYNC = 'return data;'
|
|
2728
|
-
, ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
|
|
2729
|
-
, REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
|
|
2730
|
-
|
|
2731
|
-
function finalCleanUpCode(out, async) {
|
|
2732
|
-
var matches = out.match(ERRORS_REGEXP);
|
|
2733
|
-
if (matches && matches.length == 2) {
|
|
2734
|
-
out = async
|
|
2735
|
-
? out.replace(REMOVE_ERRORS_ASYNC, '')
|
|
2736
|
-
.replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
|
|
2737
|
-
: out.replace(REMOVE_ERRORS, '')
|
|
2738
|
-
.replace(RETURN_VALID, RETURN_TRUE);
|
|
2739
|
-
}
|
|
2740
|
-
|
|
2741
|
-
matches = out.match(ROOTDATA_REGEXP);
|
|
2742
|
-
if (!matches || matches.length !== 3) return out;
|
|
2743
|
-
return out.replace(REMOVE_ROOTDATA, '');
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
2697
|
function schemaHasRules(schema, rules) {
|
|
2748
2698
|
if (typeof schema == 'boolean') return !schema;
|
|
2749
2699
|
for (var key in schema) if (rules[key]) return true;
|
|
@@ -2783,17 +2733,17 @@ function getPath(currentPath, prop, jsonPointers) {
|
|
|
2783
2733
|
}
|
|
2784
2734
|
|
|
2785
2735
|
|
|
2786
|
-
var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
2787
|
-
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2736
|
+
var JSON_POINTER$1 = /^\/(?:[^~]|~0|~1)*$/;
|
|
2737
|
+
var RELATIVE_JSON_POINTER$1 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2788
2738
|
function getData($data, lvl, paths) {
|
|
2789
2739
|
var up, jsonPointer, data, matches;
|
|
2790
2740
|
if ($data === '') return 'rootData';
|
|
2791
2741
|
if ($data[0] == '/') {
|
|
2792
|
-
if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
|
|
2742
|
+
if (!JSON_POINTER$1.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
|
|
2793
2743
|
jsonPointer = $data;
|
|
2794
2744
|
data = 'rootData';
|
|
2795
2745
|
} else {
|
|
2796
|
-
matches = $data.match(RELATIVE_JSON_POINTER);
|
|
2746
|
+
matches = $data.match(RELATIVE_JSON_POINTER$1);
|
|
2797
2747
|
if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
|
|
2798
2748
|
up = +matches[1];
|
|
2799
2749
|
jsonPointer = matches[2];
|
|
@@ -2822,7 +2772,7 @@ function getData($data, lvl, paths) {
|
|
|
2822
2772
|
|
|
2823
2773
|
function joinPaths (a, b) {
|
|
2824
2774
|
if (a == '""') return b;
|
|
2825
|
-
return (a + ' + ' + b).replace(/' \+ '/g, '');
|
|
2775
|
+
return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
|
|
2826
2776
|
}
|
|
2827
2777
|
|
|
2828
2778
|
|
|
@@ -2845,15 +2795,17 @@ function unescapeJsonPointer(str) {
|
|
|
2845
2795
|
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
2846
2796
|
}
|
|
2847
2797
|
|
|
2848
|
-
var
|
|
2798
|
+
var util$4 = util$5;
|
|
2799
|
+
|
|
2800
|
+
var schema_obj = SchemaObject$2;
|
|
2849
2801
|
|
|
2850
|
-
function SchemaObject(obj) {
|
|
2851
|
-
util.copy(obj, this);
|
|
2802
|
+
function SchemaObject$2(obj) {
|
|
2803
|
+
util$4.copy(obj, this);
|
|
2852
2804
|
}
|
|
2853
2805
|
|
|
2854
|
-
var jsonSchemaTraverse =
|
|
2806
|
+
var jsonSchemaTraverse = {exports: {}};
|
|
2855
2807
|
|
|
2856
|
-
var traverse =
|
|
2808
|
+
var traverse$1 = jsonSchemaTraverse.exports = function (schema, opts, cb) {
|
|
2857
2809
|
// Legacy support for v0.3.1 and earlier.
|
|
2858
2810
|
if (typeof opts == 'function') {
|
|
2859
2811
|
cb = opts;
|
|
@@ -2868,7 +2820,7 @@ var traverse = module.exports = function (schema, opts, cb) {
|
|
|
2868
2820
|
};
|
|
2869
2821
|
|
|
2870
2822
|
|
|
2871
|
-
traverse.keywords = {
|
|
2823
|
+
traverse$1.keywords = {
|
|
2872
2824
|
additionalItems: true,
|
|
2873
2825
|
items: true,
|
|
2874
2826
|
contains: true,
|
|
@@ -2877,21 +2829,21 @@ traverse.keywords = {
|
|
|
2877
2829
|
not: true
|
|
2878
2830
|
};
|
|
2879
2831
|
|
|
2880
|
-
traverse.arrayKeywords = {
|
|
2832
|
+
traverse$1.arrayKeywords = {
|
|
2881
2833
|
items: true,
|
|
2882
2834
|
allOf: true,
|
|
2883
2835
|
anyOf: true,
|
|
2884
2836
|
oneOf: true
|
|
2885
2837
|
};
|
|
2886
2838
|
|
|
2887
|
-
traverse.propsKeywords = {
|
|
2839
|
+
traverse$1.propsKeywords = {
|
|
2888
2840
|
definitions: true,
|
|
2889
2841
|
properties: true,
|
|
2890
2842
|
patternProperties: true,
|
|
2891
2843
|
dependencies: true
|
|
2892
2844
|
};
|
|
2893
2845
|
|
|
2894
|
-
traverse.skipKeywords = {
|
|
2846
|
+
traverse$1.skipKeywords = {
|
|
2895
2847
|
default: true,
|
|
2896
2848
|
enum: true,
|
|
2897
2849
|
const: true,
|
|
@@ -2919,16 +2871,16 @@ function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr,
|
|
|
2919
2871
|
for (var key in schema) {
|
|
2920
2872
|
var sch = schema[key];
|
|
2921
2873
|
if (Array.isArray(sch)) {
|
|
2922
|
-
if (key in traverse.arrayKeywords) {
|
|
2874
|
+
if (key in traverse$1.arrayKeywords) {
|
|
2923
2875
|
for (var i=0; i<sch.length; i++)
|
|
2924
2876
|
_traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
|
|
2925
2877
|
}
|
|
2926
|
-
} else if (key in traverse.propsKeywords) {
|
|
2878
|
+
} else if (key in traverse$1.propsKeywords) {
|
|
2927
2879
|
if (sch && typeof sch == 'object') {
|
|
2928
2880
|
for (var prop in sch)
|
|
2929
2881
|
_traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
|
|
2930
2882
|
}
|
|
2931
|
-
} else if (key in traverse.keywords || (opts.allKeys && !(key in traverse.skipKeywords))) {
|
|
2883
|
+
} else if (key in traverse$1.keywords || (opts.allKeys && !(key in traverse$1.skipKeywords))) {
|
|
2932
2884
|
_traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
|
|
2933
2885
|
}
|
|
2934
2886
|
}
|
|
@@ -2940,16 +2892,21 @@ function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr,
|
|
|
2940
2892
|
function escapeJsonPtr(str) {
|
|
2941
2893
|
return str.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
2942
2894
|
}
|
|
2943
|
-
});
|
|
2944
2895
|
|
|
2945
|
-
var
|
|
2896
|
+
var URI$1 = uri_all.exports
|
|
2897
|
+
, equal$1 = fastDeepEqual
|
|
2898
|
+
, util$3 = util$5
|
|
2899
|
+
, SchemaObject$1 = schema_obj
|
|
2900
|
+
, traverse = jsonSchemaTraverse.exports;
|
|
2901
|
+
|
|
2902
|
+
var resolve_1 = resolve$3;
|
|
2946
2903
|
|
|
2947
|
-
resolve.normalizeId = normalizeId;
|
|
2948
|
-
resolve.fullPath = getFullPath;
|
|
2949
|
-
resolve.url = resolveUrl;
|
|
2950
|
-
resolve.ids = resolveIds;
|
|
2951
|
-
resolve.inlineRef = inlineRef;
|
|
2952
|
-
resolve.schema = resolveSchema;
|
|
2904
|
+
resolve$3.normalizeId = normalizeId;
|
|
2905
|
+
resolve$3.fullPath = getFullPath;
|
|
2906
|
+
resolve$3.url = resolveUrl;
|
|
2907
|
+
resolve$3.ids = resolveIds;
|
|
2908
|
+
resolve$3.inlineRef = inlineRef;
|
|
2909
|
+
resolve$3.schema = resolveSchema;
|
|
2953
2910
|
|
|
2954
2911
|
/**
|
|
2955
2912
|
* [resolve and compile the references ($ref)]
|
|
@@ -2959,16 +2916,16 @@ resolve.schema = resolveSchema;
|
|
|
2959
2916
|
* @param {String} ref reference to resolve
|
|
2960
2917
|
* @return {Object|Function} schema object (if the schema can be inlined) or validation function
|
|
2961
2918
|
*/
|
|
2962
|
-
function resolve(compile, root, ref) {
|
|
2919
|
+
function resolve$3(compile, root, ref) {
|
|
2963
2920
|
/* jshint validthis: true */
|
|
2964
2921
|
var refVal = this._refs[ref];
|
|
2965
2922
|
if (typeof refVal == 'string') {
|
|
2966
2923
|
if (this._refs[refVal]) refVal = this._refs[refVal];
|
|
2967
|
-
else return resolve.call(this, compile, root, refVal);
|
|
2924
|
+
else return resolve$3.call(this, compile, root, refVal);
|
|
2968
2925
|
}
|
|
2969
2926
|
|
|
2970
2927
|
refVal = refVal || this._schemas[ref];
|
|
2971
|
-
if (refVal instanceof
|
|
2928
|
+
if (refVal instanceof SchemaObject$1) {
|
|
2972
2929
|
return inlineRef(refVal.schema, this._opts.inlineRefs)
|
|
2973
2930
|
? refVal.schema
|
|
2974
2931
|
: refVal.validate || this._compile(refVal);
|
|
@@ -2982,7 +2939,7 @@ function resolve(compile, root, ref) {
|
|
|
2982
2939
|
baseId = res.baseId;
|
|
2983
2940
|
}
|
|
2984
2941
|
|
|
2985
|
-
if (schema instanceof
|
|
2942
|
+
if (schema instanceof SchemaObject$1) {
|
|
2986
2943
|
v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
|
|
2987
2944
|
} else if (schema !== undefined) {
|
|
2988
2945
|
v = inlineRef(schema, this._opts.inlineRefs)
|
|
@@ -3003,7 +2960,7 @@ function resolve(compile, root, ref) {
|
|
|
3003
2960
|
*/
|
|
3004
2961
|
function resolveSchema(root, ref) {
|
|
3005
2962
|
/* jshint validthis: true */
|
|
3006
|
-
var p =
|
|
2963
|
+
var p = URI$1.parse(ref)
|
|
3007
2964
|
, refPath = _getFullPath(p)
|
|
3008
2965
|
, baseId = getFullPath(this._getId(root.schema));
|
|
3009
2966
|
if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
|
|
@@ -3011,12 +2968,12 @@ function resolveSchema(root, ref) {
|
|
|
3011
2968
|
var refVal = this._refs[id];
|
|
3012
2969
|
if (typeof refVal == 'string') {
|
|
3013
2970
|
return resolveRecursive.call(this, root, refVal, p);
|
|
3014
|
-
} else if (refVal instanceof
|
|
2971
|
+
} else if (refVal instanceof SchemaObject$1) {
|
|
3015
2972
|
if (!refVal.validate) this._compile(refVal);
|
|
3016
2973
|
root = refVal;
|
|
3017
2974
|
} else {
|
|
3018
2975
|
refVal = this._schemas[id];
|
|
3019
|
-
if (refVal instanceof
|
|
2976
|
+
if (refVal instanceof SchemaObject$1) {
|
|
3020
2977
|
if (!refVal.validate) this._compile(refVal);
|
|
3021
2978
|
if (id == normalizeId(ref))
|
|
3022
2979
|
return { schema: refVal, root: root, baseId: baseId };
|
|
@@ -3047,7 +3004,7 @@ function resolveRecursive(root, ref, parsedRef) {
|
|
|
3047
3004
|
}
|
|
3048
3005
|
|
|
3049
3006
|
|
|
3050
|
-
var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
|
|
3007
|
+
var PREVENT_SCOPE_CHANGE = util$3.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
|
|
3051
3008
|
/* @this Ajv */
|
|
3052
3009
|
function getJsonPointer(parsedRef, baseId, schema, root) {
|
|
3053
3010
|
/* jshint validthis: true */
|
|
@@ -3058,7 +3015,7 @@ function getJsonPointer(parsedRef, baseId, schema, root) {
|
|
|
3058
3015
|
for (var i = 1; i < parts.length; i++) {
|
|
3059
3016
|
var part = parts[i];
|
|
3060
3017
|
if (part) {
|
|
3061
|
-
part = util.unescapeFragment(part);
|
|
3018
|
+
part = util$3.unescapeFragment(part);
|
|
3062
3019
|
schema = schema[part];
|
|
3063
3020
|
if (schema === undefined) break;
|
|
3064
3021
|
var id;
|
|
@@ -3082,7 +3039,7 @@ function getJsonPointer(parsedRef, baseId, schema, root) {
|
|
|
3082
3039
|
}
|
|
3083
3040
|
|
|
3084
3041
|
|
|
3085
|
-
var SIMPLE_INLINED = util.toHash([
|
|
3042
|
+
var SIMPLE_INLINED = util$3.toHash([
|
|
3086
3043
|
'type', 'format', 'pattern',
|
|
3087
3044
|
'maxLength', 'minLength',
|
|
3088
3045
|
'maxProperties', 'minProperties',
|
|
@@ -3142,13 +3099,13 @@ function countKeys(schema) {
|
|
|
3142
3099
|
|
|
3143
3100
|
function getFullPath(id, normalize) {
|
|
3144
3101
|
if (normalize !== false) id = normalizeId(id);
|
|
3145
|
-
var p =
|
|
3102
|
+
var p = URI$1.parse(id);
|
|
3146
3103
|
return _getFullPath(p);
|
|
3147
3104
|
}
|
|
3148
3105
|
|
|
3149
3106
|
|
|
3150
3107
|
function _getFullPath(p) {
|
|
3151
|
-
return
|
|
3108
|
+
return URI$1.serialize(p).split('#')[0] + '#';
|
|
3152
3109
|
}
|
|
3153
3110
|
|
|
3154
3111
|
|
|
@@ -3160,7 +3117,7 @@ function normalizeId(id) {
|
|
|
3160
3117
|
|
|
3161
3118
|
function resolveUrl(baseId, id) {
|
|
3162
3119
|
id = normalizeId(id);
|
|
3163
|
-
return
|
|
3120
|
+
return URI$1.resolve(baseId, id);
|
|
3164
3121
|
}
|
|
3165
3122
|
|
|
3166
3123
|
|
|
@@ -3172,25 +3129,25 @@ function resolveIds(schema) {
|
|
|
3172
3129
|
var localRefs = {};
|
|
3173
3130
|
var self = this;
|
|
3174
3131
|
|
|
3175
|
-
|
|
3132
|
+
traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
3176
3133
|
if (jsonPtr === '') return;
|
|
3177
3134
|
var id = self._getId(sch);
|
|
3178
3135
|
var baseId = baseIds[parentJsonPtr];
|
|
3179
3136
|
var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
|
|
3180
3137
|
if (keyIndex !== undefined)
|
|
3181
|
-
fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
|
|
3138
|
+
fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util$3.escapeFragment(keyIndex));
|
|
3182
3139
|
|
|
3183
3140
|
if (typeof id == 'string') {
|
|
3184
|
-
id = baseId = normalizeId(baseId ?
|
|
3141
|
+
id = baseId = normalizeId(baseId ? URI$1.resolve(baseId, id) : id);
|
|
3185
3142
|
|
|
3186
3143
|
var refVal = self._refs[id];
|
|
3187
3144
|
if (typeof refVal == 'string') refVal = self._refs[refVal];
|
|
3188
3145
|
if (refVal && refVal.schema) {
|
|
3189
|
-
if (!
|
|
3146
|
+
if (!equal$1(sch, refVal.schema))
|
|
3190
3147
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
|
3191
3148
|
} else if (id != normalizeId(fullPath)) {
|
|
3192
3149
|
if (id[0] == '#') {
|
|
3193
|
-
if (localRefs[id] && !
|
|
3150
|
+
if (localRefs[id] && !equal$1(sch, localRefs[id]))
|
|
3194
3151
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
|
3195
3152
|
localRefs[id] = sch;
|
|
3196
3153
|
} else {
|
|
@@ -3205,28 +3162,30 @@ function resolveIds(schema) {
|
|
|
3205
3162
|
return localRefs;
|
|
3206
3163
|
}
|
|
3207
3164
|
|
|
3165
|
+
var resolve$2 = resolve_1;
|
|
3166
|
+
|
|
3208
3167
|
var error_classes = {
|
|
3209
|
-
Validation: errorSubclass(ValidationError),
|
|
3210
|
-
MissingRef: errorSubclass(MissingRefError)
|
|
3168
|
+
Validation: errorSubclass(ValidationError$1),
|
|
3169
|
+
MissingRef: errorSubclass(MissingRefError$1)
|
|
3211
3170
|
};
|
|
3212
3171
|
|
|
3213
3172
|
|
|
3214
|
-
function ValidationError(errors) {
|
|
3173
|
+
function ValidationError$1(errors) {
|
|
3215
3174
|
this.message = 'validation failed';
|
|
3216
3175
|
this.errors = errors;
|
|
3217
3176
|
this.ajv = this.validation = true;
|
|
3218
3177
|
}
|
|
3219
3178
|
|
|
3220
3179
|
|
|
3221
|
-
MissingRefError.message = function (baseId, ref) {
|
|
3180
|
+
MissingRefError$1.message = function (baseId, ref) {
|
|
3222
3181
|
return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
|
|
3223
3182
|
};
|
|
3224
3183
|
|
|
3225
3184
|
|
|
3226
|
-
function MissingRefError(baseId, ref, message) {
|
|
3227
|
-
this.message = message || MissingRefError.message(baseId, ref);
|
|
3228
|
-
this.missingRef =
|
|
3229
|
-
this.missingSchema =
|
|
3185
|
+
function MissingRefError$1(baseId, ref, message) {
|
|
3186
|
+
this.message = message || MissingRefError$1.message(baseId, ref);
|
|
3187
|
+
this.missingRef = resolve$2.url(baseId, ref);
|
|
3188
|
+
this.missingSchema = resolve$2.normalizeId(resolve$2.fullPath(this.missingRef));
|
|
3230
3189
|
}
|
|
3231
3190
|
|
|
3232
3191
|
|
|
@@ -3294,7 +3253,7 @@ var fastJsonStableStringify = function (data, opts) {
|
|
|
3294
3253
|
})(data);
|
|
3295
3254
|
};
|
|
3296
3255
|
|
|
3297
|
-
var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
3256
|
+
var validate$1 = function generate_validate(it, $keyword, $ruleType) {
|
|
3298
3257
|
var out = '';
|
|
3299
3258
|
var $async = it.schema.$async === true,
|
|
3300
3259
|
$refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
|
|
@@ -3386,7 +3345,7 @@ var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
|
3386
3345
|
it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
|
|
3387
3346
|
it.baseId = it.baseId || it.rootId;
|
|
3388
3347
|
delete it.isTop;
|
|
3389
|
-
it.dataPathArr = [
|
|
3348
|
+
it.dataPathArr = [""];
|
|
3390
3349
|
if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
|
|
3391
3350
|
var $defaultMsg = 'default is ignored in the schema root';
|
|
3392
3351
|
if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
|
|
@@ -3444,47 +3403,39 @@ var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
|
3444
3403
|
var $schemaPath = it.schemaPath + '.type',
|
|
3445
3404
|
$errSchemaPath = it.errSchemaPath + '/type',
|
|
3446
3405
|
$method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
|
|
3447
|
-
out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
|
|
3406
|
+
out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
|
|
3448
3407
|
if ($coerceToTypes) {
|
|
3449
3408
|
var $dataType = 'dataType' + $lvl,
|
|
3450
3409
|
$coerced = 'coerced' + $lvl;
|
|
3451
|
-
out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; ';
|
|
3410
|
+
out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; var ' + ($coerced) + ' = undefined; ';
|
|
3452
3411
|
if (it.opts.coerceTypes == 'array') {
|
|
3453
|
-
out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ')) ' + ($dataType) + ' =
|
|
3412
|
+
out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ') && ' + ($data) + '.length == 1) { ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; if (' + (it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)) + ') ' + ($coerced) + ' = ' + ($data) + '; } ';
|
|
3454
3413
|
}
|
|
3455
|
-
out += '
|
|
3456
|
-
var $bracesCoercion = '';
|
|
3414
|
+
out += ' if (' + ($coerced) + ' !== undefined) ; ';
|
|
3457
3415
|
var arr1 = $coerceToTypes;
|
|
3458
3416
|
if (arr1) {
|
|
3459
3417
|
var $type, $i = -1,
|
|
3460
3418
|
l1 = arr1.length - 1;
|
|
3461
3419
|
while ($i < l1) {
|
|
3462
3420
|
$type = arr1[$i += 1];
|
|
3463
|
-
if ($i) {
|
|
3464
|
-
out += ' if (' + ($coerced) + ' === undefined) { ';
|
|
3465
|
-
$bracesCoercion += '}';
|
|
3466
|
-
}
|
|
3467
|
-
if (it.opts.coerceTypes == 'array' && $type != 'array') {
|
|
3468
|
-
out += ' if (' + ($dataType) + ' == \'array\' && ' + ($data) + '.length == 1) { ' + ($coerced) + ' = ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; } ';
|
|
3469
|
-
}
|
|
3470
3421
|
if ($type == 'string') {
|
|
3471
|
-
out += ' if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
|
|
3422
|
+
out += ' else if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
|
|
3472
3423
|
} else if ($type == 'number' || $type == 'integer') {
|
|
3473
|
-
out += ' if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
|
|
3424
|
+
out += ' else if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
|
|
3474
3425
|
if ($type == 'integer') {
|
|
3475
3426
|
out += ' && !(' + ($data) + ' % 1)';
|
|
3476
3427
|
}
|
|
3477
3428
|
out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
|
|
3478
3429
|
} else if ($type == 'boolean') {
|
|
3479
|
-
out += ' if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
|
|
3430
|
+
out += ' else if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
|
|
3480
3431
|
} else if ($type == 'null') {
|
|
3481
|
-
out += ' if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
|
|
3432
|
+
out += ' else if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
|
|
3482
3433
|
} else if (it.opts.coerceTypes == 'array' && $type == 'array') {
|
|
3483
|
-
out += ' if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
|
|
3434
|
+
out += ' else if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
|
|
3484
3435
|
}
|
|
3485
3436
|
}
|
|
3486
3437
|
}
|
|
3487
|
-
out += '
|
|
3438
|
+
out += ' else { ';
|
|
3488
3439
|
var $$outStack = $$outStack || [];
|
|
3489
3440
|
$$outStack.push(out);
|
|
3490
3441
|
out = ''; /* istanbul ignore else */
|
|
@@ -3524,7 +3475,7 @@ var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
|
3524
3475
|
} else {
|
|
3525
3476
|
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
|
3526
3477
|
}
|
|
3527
|
-
out += ' }
|
|
3478
|
+
out += ' } if (' + ($coerced) + ' !== undefined) { ';
|
|
3528
3479
|
var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
|
|
3529
3480
|
$parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
|
|
3530
3481
|
out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
|
|
@@ -3597,7 +3548,7 @@ var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
|
3597
3548
|
$rulesGroup = arr2[i2 += 1];
|
|
3598
3549
|
if ($shouldUseGroup($rulesGroup)) {
|
|
3599
3550
|
if ($rulesGroup.type) {
|
|
3600
|
-
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { ';
|
|
3551
|
+
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
|
|
3601
3552
|
}
|
|
3602
3553
|
if (it.opts.useDefaults) {
|
|
3603
3554
|
if ($rulesGroup.type == 'object' && it.schema.properties) {
|
|
@@ -3765,10 +3716,6 @@ var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
|
3765
3716
|
} else {
|
|
3766
3717
|
out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
|
|
3767
3718
|
}
|
|
3768
|
-
out = it.util.cleanUpCode(out);
|
|
3769
|
-
if ($top) {
|
|
3770
|
-
out = it.util.finalCleanUpCode(out, $async);
|
|
3771
|
-
}
|
|
3772
3719
|
|
|
3773
3720
|
function $shouldUseGroup($rulesGroup) {
|
|
3774
3721
|
var rules = $rulesGroup.rules;
|
|
@@ -3788,17 +3735,24 @@ var validate = function generate_validate(it, $keyword, $ruleType) {
|
|
|
3788
3735
|
return out;
|
|
3789
3736
|
};
|
|
3790
3737
|
|
|
3738
|
+
var resolve$1 = resolve_1
|
|
3739
|
+
, util$2 = util$5
|
|
3740
|
+
, errorClasses$1 = error_classes
|
|
3741
|
+
, stableStringify$1 = fastJsonStableStringify;
|
|
3742
|
+
|
|
3743
|
+
var validateGenerator = validate$1;
|
|
3744
|
+
|
|
3791
3745
|
/**
|
|
3792
3746
|
* Functions below are used inside compiled validations function
|
|
3793
3747
|
*/
|
|
3794
3748
|
|
|
3795
|
-
var ucs2length
|
|
3796
|
-
|
|
3749
|
+
var ucs2length = util$2.ucs2length;
|
|
3750
|
+
var equal = fastDeepEqual;
|
|
3797
3751
|
|
|
3798
3752
|
// this error is thrown by async schemas to return validation errors via exception
|
|
3799
|
-
var ValidationError
|
|
3753
|
+
var ValidationError = errorClasses$1.Validation;
|
|
3800
3754
|
|
|
3801
|
-
var compile_1 = compile;
|
|
3755
|
+
var compile_1 = compile$1;
|
|
3802
3756
|
|
|
3803
3757
|
|
|
3804
3758
|
/**
|
|
@@ -3810,7 +3764,7 @@ var compile_1 = compile;
|
|
|
3810
3764
|
* @param {String} baseId base ID for IDs in the schema
|
|
3811
3765
|
* @return {Function} validation function
|
|
3812
3766
|
*/
|
|
3813
|
-
function compile(schema, root, localRefs, baseId) {
|
|
3767
|
+
function compile$1(schema, root, localRefs, baseId) {
|
|
3814
3768
|
/* jshint validthis: true, evil: true */
|
|
3815
3769
|
/* eslint no-shadow: 0 */
|
|
3816
3770
|
var self = this
|
|
@@ -3862,11 +3816,11 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
3862
3816
|
function localCompile(_schema, _root, localRefs, baseId) {
|
|
3863
3817
|
var isRoot = !_root || (_root && _root.schema == _schema);
|
|
3864
3818
|
if (_root.schema != root.schema)
|
|
3865
|
-
return compile.call(self, _schema, _root, localRefs, baseId);
|
|
3819
|
+
return compile$1.call(self, _schema, _root, localRefs, baseId);
|
|
3866
3820
|
|
|
3867
3821
|
var $async = _schema.$async === true;
|
|
3868
3822
|
|
|
3869
|
-
var sourceCode =
|
|
3823
|
+
var sourceCode = validateGenerator({
|
|
3870
3824
|
isTop: true,
|
|
3871
3825
|
schema: _schema,
|
|
3872
3826
|
isRoot: isRoot,
|
|
@@ -3875,11 +3829,11 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
3875
3829
|
schemaPath: '',
|
|
3876
3830
|
errSchemaPath: '#',
|
|
3877
3831
|
errorPath: '""',
|
|
3878
|
-
MissingRefError:
|
|
3832
|
+
MissingRefError: errorClasses$1.MissingRef,
|
|
3879
3833
|
RULES: RULES,
|
|
3880
|
-
validate:
|
|
3881
|
-
util: util,
|
|
3882
|
-
resolve:
|
|
3834
|
+
validate: validateGenerator,
|
|
3835
|
+
util: util$2,
|
|
3836
|
+
resolve: resolve$1,
|
|
3883
3837
|
resolveRef: resolveRef,
|
|
3884
3838
|
usePattern: usePattern,
|
|
3885
3839
|
useDefault: useDefault,
|
|
@@ -3891,12 +3845,12 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
3891
3845
|
});
|
|
3892
3846
|
|
|
3893
3847
|
sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
|
|
3894
|
-
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode)
|
|
3848
|
+
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode$1)
|
|
3895
3849
|
+ sourceCode;
|
|
3896
3850
|
|
|
3897
|
-
if (opts.processCode) sourceCode = opts.processCode(sourceCode);
|
|
3851
|
+
if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
|
|
3898
3852
|
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
|
|
3899
|
-
var validate
|
|
3853
|
+
var validate;
|
|
3900
3854
|
try {
|
|
3901
3855
|
var makeValidate = new Function(
|
|
3902
3856
|
'self',
|
|
@@ -3912,7 +3866,7 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
3912
3866
|
sourceCode
|
|
3913
3867
|
);
|
|
3914
3868
|
|
|
3915
|
-
validate
|
|
3869
|
+
validate = makeValidate(
|
|
3916
3870
|
self,
|
|
3917
3871
|
RULES,
|
|
3918
3872
|
formats,
|
|
@@ -3920,36 +3874,36 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
3920
3874
|
refVal,
|
|
3921
3875
|
defaults,
|
|
3922
3876
|
customRules,
|
|
3923
|
-
|
|
3924
|
-
ucs2length
|
|
3925
|
-
ValidationError
|
|
3877
|
+
equal,
|
|
3878
|
+
ucs2length,
|
|
3879
|
+
ValidationError
|
|
3926
3880
|
);
|
|
3927
3881
|
|
|
3928
|
-
refVal[0] = validate
|
|
3882
|
+
refVal[0] = validate;
|
|
3929
3883
|
} catch(e) {
|
|
3930
3884
|
self.logger.error('Error compiling schema, function code:', sourceCode);
|
|
3931
3885
|
throw e;
|
|
3932
3886
|
}
|
|
3933
3887
|
|
|
3934
|
-
validate
|
|
3935
|
-
validate
|
|
3936
|
-
validate
|
|
3937
|
-
validate
|
|
3938
|
-
validate
|
|
3939
|
-
if ($async) validate
|
|
3888
|
+
validate.schema = _schema;
|
|
3889
|
+
validate.errors = null;
|
|
3890
|
+
validate.refs = refs;
|
|
3891
|
+
validate.refVal = refVal;
|
|
3892
|
+
validate.root = isRoot ? validate : _root;
|
|
3893
|
+
if ($async) validate.$async = true;
|
|
3940
3894
|
if (opts.sourceCode === true) {
|
|
3941
|
-
validate
|
|
3895
|
+
validate.source = {
|
|
3942
3896
|
code: sourceCode,
|
|
3943
3897
|
patterns: patterns,
|
|
3944
3898
|
defaults: defaults
|
|
3945
3899
|
};
|
|
3946
3900
|
}
|
|
3947
3901
|
|
|
3948
|
-
return validate
|
|
3902
|
+
return validate;
|
|
3949
3903
|
}
|
|
3950
3904
|
|
|
3951
3905
|
function resolveRef(baseId, ref, isRoot) {
|
|
3952
|
-
ref =
|
|
3906
|
+
ref = resolve$1.url(baseId, ref);
|
|
3953
3907
|
var refIndex = refs[ref];
|
|
3954
3908
|
var _refVal, refCode;
|
|
3955
3909
|
if (refIndex !== undefined) {
|
|
@@ -3967,13 +3921,13 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
3967
3921
|
}
|
|
3968
3922
|
|
|
3969
3923
|
refCode = addLocalRef(ref);
|
|
3970
|
-
var v =
|
|
3924
|
+
var v = resolve$1.call(self, localCompile, root, ref);
|
|
3971
3925
|
if (v === undefined) {
|
|
3972
3926
|
var localSchema = localRefs && localRefs[ref];
|
|
3973
3927
|
if (localSchema) {
|
|
3974
|
-
v =
|
|
3928
|
+
v = resolve$1.inlineRef(localSchema, opts.inlineRefs)
|
|
3975
3929
|
? localSchema
|
|
3976
|
-
: compile.call(self, localSchema, root, localRefs, baseId);
|
|
3930
|
+
: compile$1.call(self, localSchema, root, localRefs, baseId);
|
|
3977
3931
|
}
|
|
3978
3932
|
}
|
|
3979
3933
|
|
|
@@ -4022,10 +3976,10 @@ function compile(schema, root, localRefs, baseId) {
|
|
|
4022
3976
|
case 'number':
|
|
4023
3977
|
return '' + value;
|
|
4024
3978
|
case 'string':
|
|
4025
|
-
return util.toQuotedString(value);
|
|
3979
|
+
return util$2.toQuotedString(value);
|
|
4026
3980
|
case 'object':
|
|
4027
3981
|
if (value === null) return 'null';
|
|
4028
|
-
var valueStr =
|
|
3982
|
+
var valueStr = stableStringify$1(value);
|
|
4029
3983
|
var index = defaultsHash[valueStr];
|
|
4030
3984
|
if (index === undefined) {
|
|
4031
3985
|
index = defaultsHash[valueStr] = defaults.length;
|
|
@@ -4140,7 +4094,7 @@ function compIndex(schema, root, baseId) {
|
|
|
4140
4094
|
|
|
4141
4095
|
|
|
4142
4096
|
function patternCode(i, patterns) {
|
|
4143
|
-
return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
|
|
4097
|
+
return 'var pattern' + i + ' = new RegExp(' + util$2.toQuotedString(patterns[i]) + ');';
|
|
4144
4098
|
}
|
|
4145
4099
|
|
|
4146
4100
|
|
|
@@ -4154,7 +4108,7 @@ function refValCode(i, refVal) {
|
|
|
4154
4108
|
}
|
|
4155
4109
|
|
|
4156
4110
|
|
|
4157
|
-
function customRuleCode(i) {
|
|
4111
|
+
function customRuleCode$1(i) {
|
|
4158
4112
|
return 'var customRule' + i + ' = customRules[' + i + '];';
|
|
4159
4113
|
}
|
|
4160
4114
|
|
|
@@ -4167,38 +4121,38 @@ function vars(arr, statement) {
|
|
|
4167
4121
|
return code;
|
|
4168
4122
|
}
|
|
4169
4123
|
|
|
4170
|
-
var cache =
|
|
4171
|
-
|
|
4124
|
+
var cache = {exports: {}};
|
|
4172
4125
|
|
|
4173
|
-
var Cache =
|
|
4126
|
+
var Cache$1 = cache.exports = function Cache() {
|
|
4174
4127
|
this._cache = {};
|
|
4175
4128
|
};
|
|
4176
4129
|
|
|
4177
4130
|
|
|
4178
|
-
Cache.prototype.put = function Cache_put(key, value) {
|
|
4131
|
+
Cache$1.prototype.put = function Cache_put(key, value) {
|
|
4179
4132
|
this._cache[key] = value;
|
|
4180
4133
|
};
|
|
4181
4134
|
|
|
4182
4135
|
|
|
4183
|
-
Cache.prototype.get = function Cache_get(key) {
|
|
4136
|
+
Cache$1.prototype.get = function Cache_get(key) {
|
|
4184
4137
|
return this._cache[key];
|
|
4185
4138
|
};
|
|
4186
4139
|
|
|
4187
4140
|
|
|
4188
|
-
Cache.prototype.del = function Cache_del(key) {
|
|
4141
|
+
Cache$1.prototype.del = function Cache_del(key) {
|
|
4189
4142
|
delete this._cache[key];
|
|
4190
4143
|
};
|
|
4191
4144
|
|
|
4192
4145
|
|
|
4193
|
-
Cache.prototype.clear = function Cache_clear() {
|
|
4146
|
+
Cache$1.prototype.clear = function Cache_clear() {
|
|
4194
4147
|
this._cache = {};
|
|
4195
4148
|
};
|
|
4196
|
-
|
|
4149
|
+
|
|
4150
|
+
var util$1 = util$5;
|
|
4197
4151
|
|
|
4198
4152
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
4199
4153
|
var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
|
|
4200
|
-
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d
|
|
4201
|
-
var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)
|
|
4154
|
+
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
4155
|
+
var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
|
4202
4156
|
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
4203
4157
|
var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
4204
4158
|
// uri-template: https://tools.ietf.org/html/rfc6570
|
|
@@ -4206,31 +4160,31 @@ var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|
|
|
|
4206
4160
|
// For the source: https://gist.github.com/dperini/729294
|
|
4207
4161
|
// For test cases: https://mathiasbynens.be/demo/url-regex
|
|
4208
4162
|
// @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
|
|
4209
|
-
// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]
|
|
4210
|
-
var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-
|
|
4163
|
+
// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
|
4164
|
+
var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
|
|
4211
4165
|
var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
4212
|
-
var JSON_POINTER
|
|
4166
|
+
var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
4213
4167
|
var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
4214
|
-
var RELATIVE_JSON_POINTER
|
|
4168
|
+
var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
4215
4169
|
|
|
4216
4170
|
|
|
4217
|
-
var formats_1 = formats;
|
|
4171
|
+
var formats_1 = formats$1;
|
|
4218
4172
|
|
|
4219
|
-
function formats(mode) {
|
|
4173
|
+
function formats$1(mode) {
|
|
4220
4174
|
mode = mode == 'full' ? 'full' : 'fast';
|
|
4221
|
-
return util.copy(formats[mode]);
|
|
4175
|
+
return util$1.copy(formats$1[mode]);
|
|
4222
4176
|
}
|
|
4223
4177
|
|
|
4224
4178
|
|
|
4225
|
-
formats.fast = {
|
|
4179
|
+
formats$1.fast = {
|
|
4226
4180
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
4227
4181
|
date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
|
|
4228
4182
|
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
4229
|
-
time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d
|
|
4230
|
-
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d
|
|
4183
|
+
time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
|
|
4184
|
+
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
|
|
4231
4185
|
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
|
4232
|
-
uri: /^(?:[a-z][a-z0-9
|
|
4233
|
-
'uri-reference': /^(?:(?:[a-z][a-z0-9
|
|
4186
|
+
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
|
|
4187
|
+
'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
|
|
4234
4188
|
'uri-template': URITEMPLATE,
|
|
4235
4189
|
url: URL,
|
|
4236
4190
|
// email (sources from jsen validator):
|
|
@@ -4247,14 +4201,14 @@ formats.fast = {
|
|
|
4247
4201
|
uuid: UUID,
|
|
4248
4202
|
// JSON-pointer: https://tools.ietf.org/html/rfc6901
|
|
4249
4203
|
// uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
|
|
4250
|
-
'json-pointer': JSON_POINTER
|
|
4204
|
+
'json-pointer': JSON_POINTER,
|
|
4251
4205
|
'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
|
|
4252
4206
|
// relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
|
|
4253
|
-
'relative-json-pointer': RELATIVE_JSON_POINTER
|
|
4207
|
+
'relative-json-pointer': RELATIVE_JSON_POINTER
|
|
4254
4208
|
};
|
|
4255
4209
|
|
|
4256
4210
|
|
|
4257
|
-
formats.full = {
|
|
4211
|
+
formats$1.full = {
|
|
4258
4212
|
date: date,
|
|
4259
4213
|
time: time,
|
|
4260
4214
|
'date-time': date_time,
|
|
@@ -4263,14 +4217,14 @@ formats.full = {
|
|
|
4263
4217
|
'uri-template': URITEMPLATE,
|
|
4264
4218
|
url: URL,
|
|
4265
4219
|
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
|
4266
|
-
hostname:
|
|
4220
|
+
hostname: HOSTNAME,
|
|
4267
4221
|
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
|
4268
4222
|
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
|
4269
4223
|
regex: regex,
|
|
4270
4224
|
uuid: UUID,
|
|
4271
|
-
'json-pointer': JSON_POINTER
|
|
4225
|
+
'json-pointer': JSON_POINTER,
|
|
4272
4226
|
'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
|
|
4273
|
-
'relative-json-pointer': RELATIVE_JSON_POINTER
|
|
4227
|
+
'relative-json-pointer': RELATIVE_JSON_POINTER
|
|
4274
4228
|
};
|
|
4275
4229
|
|
|
4276
4230
|
|
|
@@ -4316,13 +4270,6 @@ function date_time(str) {
|
|
|
4316
4270
|
}
|
|
4317
4271
|
|
|
4318
4272
|
|
|
4319
|
-
function hostname(str) {
|
|
4320
|
-
// https://tools.ietf.org/html/rfc1034#section-3.5
|
|
4321
|
-
// https://tools.ietf.org/html/rfc1123#section-2
|
|
4322
|
-
return str.length <= 255 && HOSTNAME.test(str);
|
|
4323
|
-
}
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
4273
|
var NOT_URI_FRAGMENT = /\/|:/;
|
|
4327
4274
|
function uri(str) {
|
|
4328
4275
|
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
|
|
@@ -4483,7 +4430,7 @@ var allOf = function generate_allOf(it, $keyword, $ruleType) {
|
|
|
4483
4430
|
l1 = arr1.length - 1;
|
|
4484
4431
|
while ($i < l1) {
|
|
4485
4432
|
$sch = arr1[$i += 1];
|
|
4486
|
-
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
4433
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
4487
4434
|
$allSchemasEmpty = false;
|
|
4488
4435
|
$it.schema = $sch;
|
|
4489
4436
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
|
@@ -4504,7 +4451,6 @@ var allOf = function generate_allOf(it, $keyword, $ruleType) {
|
|
|
4504
4451
|
out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
|
|
4505
4452
|
}
|
|
4506
4453
|
}
|
|
4507
|
-
out = it.util.cleanUpCode(out);
|
|
4508
4454
|
return out;
|
|
4509
4455
|
};
|
|
4510
4456
|
|
|
@@ -4524,7 +4470,7 @@ var anyOf = function generate_anyOf(it, $keyword, $ruleType) {
|
|
|
4524
4470
|
$it.level++;
|
|
4525
4471
|
var $nextValid = 'valid' + $it.level;
|
|
4526
4472
|
var $noEmptySchema = $schema.every(function($sch) {
|
|
4527
|
-
return it.util.schemaHasRules($sch, it.RULES.all);
|
|
4473
|
+
return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all));
|
|
4528
4474
|
});
|
|
4529
4475
|
if ($noEmptySchema) {
|
|
4530
4476
|
var $currentBaseId = $it.baseId;
|
|
@@ -4573,7 +4519,6 @@ var anyOf = function generate_anyOf(it, $keyword, $ruleType) {
|
|
|
4573
4519
|
if (it.opts.allErrors) {
|
|
4574
4520
|
out += ' } ';
|
|
4575
4521
|
}
|
|
4576
|
-
out = it.util.cleanUpCode(out);
|
|
4577
4522
|
} else {
|
|
4578
4523
|
if ($breakOnError) {
|
|
4579
4524
|
out += ' if (true) { ';
|
|
@@ -4586,7 +4531,7 @@ var comment = function generate_comment(it, $keyword, $ruleType) {
|
|
|
4586
4531
|
var out = ' ';
|
|
4587
4532
|
var $schema = it.schema[$keyword];
|
|
4588
4533
|
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
|
4589
|
-
|
|
4534
|
+
!it.opts.allErrors;
|
|
4590
4535
|
var $comment = it.util.toQuotedString($schema);
|
|
4591
4536
|
if (it.opts.$comment === true) {
|
|
4592
4537
|
out += ' console.log(' + ($comment) + ');';
|
|
@@ -4667,7 +4612,7 @@ var contains = function generate_contains(it, $keyword, $ruleType) {
|
|
|
4667
4612
|
$dataNxt = $it.dataLevel = it.dataLevel + 1,
|
|
4668
4613
|
$nextData = 'data' + $dataNxt,
|
|
4669
4614
|
$currentBaseId = it.baseId,
|
|
4670
|
-
$nonEmptySchema = it.util.schemaHasRules($schema, it.RULES.all);
|
|
4615
|
+
$nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all));
|
|
4671
4616
|
out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
|
|
4672
4617
|
if ($nonEmptySchema) {
|
|
4673
4618
|
var $wasComposite = it.compositeRule;
|
|
@@ -4726,7 +4671,6 @@ var contains = function generate_contains(it, $keyword, $ruleType) {
|
|
|
4726
4671
|
if (it.opts.allErrors) {
|
|
4727
4672
|
out += ' } ';
|
|
4728
4673
|
}
|
|
4729
|
-
out = it.util.cleanUpCode(out);
|
|
4730
4674
|
return out;
|
|
4731
4675
|
};
|
|
4732
4676
|
|
|
@@ -4748,6 +4692,7 @@ var dependencies = function generate_dependencies(it, $keyword, $ruleType) {
|
|
|
4748
4692
|
$propertyDeps = {},
|
|
4749
4693
|
$ownProperties = it.opts.ownProperties;
|
|
4750
4694
|
for ($property in $schema) {
|
|
4695
|
+
if ($property == '__proto__') continue;
|
|
4751
4696
|
var $sch = $schema[$property];
|
|
4752
4697
|
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
|
|
4753
4698
|
$deps[$property] = $sch;
|
|
@@ -4873,7 +4818,7 @@ var dependencies = function generate_dependencies(it, $keyword, $ruleType) {
|
|
|
4873
4818
|
var $currentBaseId = $it.baseId;
|
|
4874
4819
|
for (var $property in $schemaDeps) {
|
|
4875
4820
|
var $sch = $schemaDeps[$property];
|
|
4876
|
-
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
4821
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
4877
4822
|
out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
|
|
4878
4823
|
if ($ownProperties) {
|
|
4879
4824
|
out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
|
|
@@ -4894,7 +4839,6 @@ var dependencies = function generate_dependencies(it, $keyword, $ruleType) {
|
|
|
4894
4839
|
if ($breakOnError) {
|
|
4895
4840
|
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
|
|
4896
4841
|
}
|
|
4897
|
-
out = it.util.cleanUpCode(out);
|
|
4898
4842
|
return out;
|
|
4899
4843
|
};
|
|
4900
4844
|
|
|
@@ -5126,8 +5070,8 @@ var _if = function generate_if(it, $keyword, $ruleType) {
|
|
|
5126
5070
|
var $nextValid = 'valid' + $it.level;
|
|
5127
5071
|
var $thenSch = it.schema['then'],
|
|
5128
5072
|
$elseSch = it.schema['else'],
|
|
5129
|
-
$thenPresent = $thenSch !== undefined && it.util.schemaHasRules($thenSch, it.RULES.all),
|
|
5130
|
-
$elsePresent = $elseSch !== undefined && it.util.schemaHasRules($elseSch, it.RULES.all),
|
|
5073
|
+
$thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)),
|
|
5074
|
+
$elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)),
|
|
5131
5075
|
$currentBaseId = $it.baseId;
|
|
5132
5076
|
if ($thenPresent || $elsePresent) {
|
|
5133
5077
|
var $ifClause;
|
|
@@ -5205,7 +5149,6 @@ var _if = function generate_if(it, $keyword, $ruleType) {
|
|
|
5205
5149
|
if ($breakOnError) {
|
|
5206
5150
|
out += ' else { ';
|
|
5207
5151
|
}
|
|
5208
|
-
out = it.util.cleanUpCode(out);
|
|
5209
5152
|
} else {
|
|
5210
5153
|
if ($breakOnError) {
|
|
5211
5154
|
out += ' if (true) { ';
|
|
@@ -5281,7 +5224,7 @@ var items = function generate_items(it, $keyword, $ruleType) {
|
|
|
5281
5224
|
l1 = arr1.length - 1;
|
|
5282
5225
|
while ($i < l1) {
|
|
5283
5226
|
$sch = arr1[$i += 1];
|
|
5284
|
-
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
5227
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
5285
5228
|
out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { ';
|
|
5286
5229
|
var $passData = $data + '[' + $i + ']';
|
|
5287
5230
|
$it.schema = $sch;
|
|
@@ -5304,7 +5247,7 @@ var items = function generate_items(it, $keyword, $ruleType) {
|
|
|
5304
5247
|
}
|
|
5305
5248
|
}
|
|
5306
5249
|
}
|
|
5307
|
-
if (typeof $additionalItems == 'object' && it.util.schemaHasRules($additionalItems, it.RULES.all)) {
|
|
5250
|
+
if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
|
|
5308
5251
|
$it.schema = $additionalItems;
|
|
5309
5252
|
$it.schemaPath = it.schemaPath + '.additionalItems';
|
|
5310
5253
|
$it.errSchemaPath = it.errSchemaPath + '/additionalItems';
|
|
@@ -5328,7 +5271,7 @@ var items = function generate_items(it, $keyword, $ruleType) {
|
|
|
5328
5271
|
$closingBraces += '}';
|
|
5329
5272
|
}
|
|
5330
5273
|
}
|
|
5331
|
-
} else if (it.util.schemaHasRules($schema, it.RULES.all)) {
|
|
5274
|
+
} else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
|
|
5332
5275
|
$it.schema = $schema;
|
|
5333
5276
|
$it.schemaPath = $schemaPath;
|
|
5334
5277
|
$it.errSchemaPath = $errSchemaPath;
|
|
@@ -5351,7 +5294,6 @@ var items = function generate_items(it, $keyword, $ruleType) {
|
|
|
5351
5294
|
if ($breakOnError) {
|
|
5352
5295
|
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
|
|
5353
5296
|
}
|
|
5354
|
-
out = it.util.cleanUpCode(out);
|
|
5355
5297
|
return out;
|
|
5356
5298
|
};
|
|
5357
5299
|
|
|
@@ -5380,6 +5322,12 @@ var _limit = function generate__limit(it, $keyword, $ruleType) {
|
|
|
5380
5322
|
$op = $isMax ? '<' : '>',
|
|
5381
5323
|
$notOp = $isMax ? '>' : '<',
|
|
5382
5324
|
$errorKeyword = undefined;
|
|
5325
|
+
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
|
|
5326
|
+
throw new Error($keyword + ' must be number');
|
|
5327
|
+
}
|
|
5328
|
+
if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
|
|
5329
|
+
throw new Error($exclusiveKeyword + ' must be number or boolean');
|
|
5330
|
+
}
|
|
5383
5331
|
if ($isDataExcl) {
|
|
5384
5332
|
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
|
|
5385
5333
|
$exclusive = 'exclusive' + $lvl,
|
|
@@ -5530,6 +5478,9 @@ var _limitItems = function generate__limitItems(it, $keyword, $ruleType) {
|
|
|
5530
5478
|
} else {
|
|
5531
5479
|
$schemaValue = $schema;
|
|
5532
5480
|
}
|
|
5481
|
+
if (!($isData || typeof $schema == 'number')) {
|
|
5482
|
+
throw new Error($keyword + ' must be number');
|
|
5483
|
+
}
|
|
5533
5484
|
var $op = $keyword == 'maxItems' ? '>' : '<';
|
|
5534
5485
|
out += 'if ( ';
|
|
5535
5486
|
if ($isData) {
|
|
@@ -5607,6 +5558,9 @@ var _limitLength = function generate__limitLength(it, $keyword, $ruleType) {
|
|
|
5607
5558
|
} else {
|
|
5608
5559
|
$schemaValue = $schema;
|
|
5609
5560
|
}
|
|
5561
|
+
if (!($isData || typeof $schema == 'number')) {
|
|
5562
|
+
throw new Error($keyword + ' must be number');
|
|
5563
|
+
}
|
|
5610
5564
|
var $op = $keyword == 'maxLength' ? '>' : '<';
|
|
5611
5565
|
out += 'if ( ';
|
|
5612
5566
|
if ($isData) {
|
|
@@ -5689,6 +5643,9 @@ var _limitProperties = function generate__limitProperties(it, $keyword, $ruleTyp
|
|
|
5689
5643
|
} else {
|
|
5690
5644
|
$schemaValue = $schema;
|
|
5691
5645
|
}
|
|
5646
|
+
if (!($isData || typeof $schema == 'number')) {
|
|
5647
|
+
throw new Error($keyword + ' must be number');
|
|
5648
|
+
}
|
|
5692
5649
|
var $op = $keyword == 'maxProperties' ? '>' : '<';
|
|
5693
5650
|
out += 'if ( ';
|
|
5694
5651
|
if ($isData) {
|
|
@@ -5765,6 +5722,9 @@ var multipleOf = function generate_multipleOf(it, $keyword, $ruleType) {
|
|
|
5765
5722
|
} else {
|
|
5766
5723
|
$schemaValue = $schema;
|
|
5767
5724
|
}
|
|
5725
|
+
if (!($isData || typeof $schema == 'number')) {
|
|
5726
|
+
throw new Error($keyword + ' must be number');
|
|
5727
|
+
}
|
|
5768
5728
|
out += 'var division' + ($lvl) + ';if (';
|
|
5769
5729
|
if ($isData) {
|
|
5770
5730
|
out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
|
|
@@ -5838,7 +5798,7 @@ var not = function generate_not(it, $keyword, $ruleType) {
|
|
|
5838
5798
|
var $it = it.util.copy(it);
|
|
5839
5799
|
$it.level++;
|
|
5840
5800
|
var $nextValid = 'valid' + $it.level;
|
|
5841
|
-
if (it.util.schemaHasRules($schema, it.RULES.all)) {
|
|
5801
|
+
if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
|
|
5842
5802
|
$it.schema = $schema;
|
|
5843
5803
|
$it.schemaPath = $schemaPath;
|
|
5844
5804
|
$it.errSchemaPath = $errSchemaPath;
|
|
@@ -5936,7 +5896,7 @@ var oneOf = function generate_oneOf(it, $keyword, $ruleType) {
|
|
|
5936
5896
|
l1 = arr1.length - 1;
|
|
5937
5897
|
while ($i < l1) {
|
|
5938
5898
|
$sch = arr1[$i += 1];
|
|
5939
|
-
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
5899
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
5940
5900
|
$it.schema = $sch;
|
|
5941
5901
|
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
|
5942
5902
|
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
|
@@ -6057,7 +6017,7 @@ var pattern = function generate_pattern(it, $keyword, $ruleType) {
|
|
|
6057
6017
|
return out;
|
|
6058
6018
|
};
|
|
6059
6019
|
|
|
6060
|
-
var properties = function generate_properties(it, $keyword, $ruleType) {
|
|
6020
|
+
var properties$2 = function generate_properties(it, $keyword, $ruleType) {
|
|
6061
6021
|
var out = ' ';
|
|
6062
6022
|
var $lvl = it.level;
|
|
6063
6023
|
var $dataLvl = it.dataLevel;
|
|
@@ -6076,9 +6036,9 @@ var properties = function generate_properties(it, $keyword, $ruleType) {
|
|
|
6076
6036
|
$dataNxt = $it.dataLevel = it.dataLevel + 1,
|
|
6077
6037
|
$nextData = 'data' + $dataNxt,
|
|
6078
6038
|
$dataProperties = 'dataProperties' + $lvl;
|
|
6079
|
-
var $schemaKeys = Object.keys($schema || {}),
|
|
6039
|
+
var $schemaKeys = Object.keys($schema || {}).filter(notProto),
|
|
6080
6040
|
$pProperties = it.schema.patternProperties || {},
|
|
6081
|
-
$pPropertyKeys = Object.keys($pProperties),
|
|
6041
|
+
$pPropertyKeys = Object.keys($pProperties).filter(notProto),
|
|
6082
6042
|
$aProperties = it.schema.additionalProperties,
|
|
6083
6043
|
$someProperties = $schemaKeys.length || $pPropertyKeys.length,
|
|
6084
6044
|
$noAdditional = $aProperties === false,
|
|
@@ -6088,7 +6048,13 @@ var properties = function generate_properties(it, $keyword, $ruleType) {
|
|
|
6088
6048
|
$ownProperties = it.opts.ownProperties,
|
|
6089
6049
|
$currentBaseId = it.baseId;
|
|
6090
6050
|
var $required = it.schema.required;
|
|
6091
|
-
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired)
|
|
6051
|
+
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
|
|
6052
|
+
var $requiredHash = it.util.toHash($required);
|
|
6053
|
+
}
|
|
6054
|
+
|
|
6055
|
+
function notProto(p) {
|
|
6056
|
+
return p !== '__proto__';
|
|
6057
|
+
}
|
|
6092
6058
|
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
|
|
6093
6059
|
if ($ownProperties) {
|
|
6094
6060
|
out += ' var ' + ($dataProperties) + ' = undefined;';
|
|
@@ -6241,7 +6207,7 @@ var properties = function generate_properties(it, $keyword, $ruleType) {
|
|
|
6241
6207
|
while (i3 < l3) {
|
|
6242
6208
|
$propertyKey = arr3[i3 += 1];
|
|
6243
6209
|
var $sch = $schema[$propertyKey];
|
|
6244
|
-
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
6210
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
6245
6211
|
var $prop = it.util.getProperty($propertyKey),
|
|
6246
6212
|
$passData = $data + $prop,
|
|
6247
6213
|
$hasDefault = $useDefaults && $sch.default !== undefined;
|
|
@@ -6344,7 +6310,7 @@ var properties = function generate_properties(it, $keyword, $ruleType) {
|
|
|
6344
6310
|
while (i4 < l4) {
|
|
6345
6311
|
$pProperty = arr4[i4 += 1];
|
|
6346
6312
|
var $sch = $pProperties[$pProperty];
|
|
6347
|
-
if (it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
6313
|
+
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
|
6348
6314
|
$it.schema = $sch;
|
|
6349
6315
|
$it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
|
|
6350
6316
|
$it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
|
|
@@ -6383,7 +6349,6 @@ var properties = function generate_properties(it, $keyword, $ruleType) {
|
|
|
6383
6349
|
if ($breakOnError) {
|
|
6384
6350
|
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
|
|
6385
6351
|
}
|
|
6386
|
-
out = it.util.cleanUpCode(out);
|
|
6387
6352
|
return out;
|
|
6388
6353
|
};
|
|
6389
6354
|
|
|
@@ -6402,7 +6367,7 @@ var propertyNames = function generate_propertyNames(it, $keyword, $ruleType) {
|
|
|
6402
6367
|
$it.level++;
|
|
6403
6368
|
var $nextValid = 'valid' + $it.level;
|
|
6404
6369
|
out += 'var ' + ($errs) + ' = errors;';
|
|
6405
|
-
if (it.util.schemaHasRules($schema, it.RULES.all)) {
|
|
6370
|
+
if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
|
|
6406
6371
|
$it.schema = $schema;
|
|
6407
6372
|
$it.schemaPath = $schemaPath;
|
|
6408
6373
|
$it.errSchemaPath = $errSchemaPath;
|
|
@@ -6465,11 +6430,10 @@ var propertyNames = function generate_propertyNames(it, $keyword, $ruleType) {
|
|
|
6465
6430
|
if ($breakOnError) {
|
|
6466
6431
|
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
|
|
6467
6432
|
}
|
|
6468
|
-
out = it.util.cleanUpCode(out);
|
|
6469
6433
|
return out;
|
|
6470
6434
|
};
|
|
6471
6435
|
|
|
6472
|
-
var required = function generate_required(it, $keyword, $ruleType) {
|
|
6436
|
+
var required$1 = function generate_required(it, $keyword, $ruleType) {
|
|
6473
6437
|
var out = ' ';
|
|
6474
6438
|
var $lvl = it.level;
|
|
6475
6439
|
var $dataLvl = it.dataLevel;
|
|
@@ -6494,7 +6458,7 @@ var required = function generate_required(it, $keyword, $ruleType) {
|
|
|
6494
6458
|
while (i1 < l1) {
|
|
6495
6459
|
$property = arr1[i1 += 1];
|
|
6496
6460
|
var $propertySch = it.schema.properties[$property];
|
|
6497
|
-
if (!($propertySch && it.util.schemaHasRules($propertySch, it.RULES.all))) {
|
|
6461
|
+
if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
|
|
6498
6462
|
$required[$required.length] = $property;
|
|
6499
6463
|
}
|
|
6500
6464
|
}
|
|
@@ -6765,7 +6729,7 @@ var uniqueItems = function generate_uniqueItems(it, $keyword, $ruleType) {
|
|
|
6765
6729
|
} else {
|
|
6766
6730
|
out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
|
|
6767
6731
|
var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
|
|
6768
|
-
out += ' if (' + (it.util[$method]($itemType, 'item', true)) + ') continue; ';
|
|
6732
|
+
out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
|
|
6769
6733
|
if ($typeIsArray) {
|
|
6770
6734
|
out += ' if (typeof item == \'string\') item = \'"\' + item; ';
|
|
6771
6735
|
}
|
|
@@ -6846,16 +6810,17 @@ var dotjs = {
|
|
|
6846
6810
|
not: not,
|
|
6847
6811
|
oneOf: oneOf,
|
|
6848
6812
|
pattern: pattern,
|
|
6849
|
-
properties: properties,
|
|
6813
|
+
properties: properties$2,
|
|
6850
6814
|
propertyNames: propertyNames,
|
|
6851
|
-
required: required,
|
|
6815
|
+
required: required$1,
|
|
6852
6816
|
uniqueItems: uniqueItems,
|
|
6853
|
-
validate: validate
|
|
6817
|
+
validate: validate$1
|
|
6854
6818
|
};
|
|
6855
6819
|
|
|
6856
|
-
var
|
|
6820
|
+
var ruleModules = dotjs
|
|
6821
|
+
, toHash = util$5.toHash;
|
|
6857
6822
|
|
|
6858
|
-
var rules = function rules() {
|
|
6823
|
+
var rules$1 = function rules() {
|
|
6859
6824
|
var RULES = [
|
|
6860
6825
|
{ type: 'number',
|
|
6861
6826
|
rules: [ { 'maximum': ['exclusiveMaximum'] },
|
|
@@ -6879,8 +6844,8 @@ var rules = function rules() {
|
|
|
6879
6844
|
'additionalItems', 'then', 'else'
|
|
6880
6845
|
];
|
|
6881
6846
|
var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
|
|
6882
|
-
RULES.all = toHash
|
|
6883
|
-
RULES.types = toHash
|
|
6847
|
+
RULES.all = toHash(ALL);
|
|
6848
|
+
RULES.types = toHash(TYPES);
|
|
6884
6849
|
|
|
6885
6850
|
RULES.forEach(function (group) {
|
|
6886
6851
|
group.rules = group.rules.map(function (keyword) {
|
|
@@ -6897,7 +6862,7 @@ var rules = function rules() {
|
|
|
6897
6862
|
ALL.push(keyword);
|
|
6898
6863
|
var rule = RULES.all[keyword] = {
|
|
6899
6864
|
keyword: keyword,
|
|
6900
|
-
code:
|
|
6865
|
+
code: ruleModules[keyword],
|
|
6901
6866
|
implements: implKeywords
|
|
6902
6867
|
};
|
|
6903
6868
|
return rule;
|
|
@@ -6905,13 +6870,13 @@ var rules = function rules() {
|
|
|
6905
6870
|
|
|
6906
6871
|
RULES.all.$comment = {
|
|
6907
6872
|
keyword: '$comment',
|
|
6908
|
-
code:
|
|
6873
|
+
code: ruleModules.$comment
|
|
6909
6874
|
};
|
|
6910
6875
|
|
|
6911
6876
|
if (group.type) RULES.types[group.type] = group;
|
|
6912
6877
|
});
|
|
6913
6878
|
|
|
6914
|
-
RULES.keywords = toHash
|
|
6879
|
+
RULES.keywords = toHash(ALL.concat(KEYWORDS));
|
|
6915
6880
|
RULES.custom = {};
|
|
6916
6881
|
|
|
6917
6882
|
return RULES;
|
|
@@ -6955,7 +6920,7 @@ var data = function (metaSchema, keywordsJsonPointers) {
|
|
|
6955
6920
|
keywords[key] = {
|
|
6956
6921
|
anyOf: [
|
|
6957
6922
|
schema,
|
|
6958
|
-
{ $ref: 'https://raw.githubusercontent.com/
|
|
6923
|
+
{ $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
|
|
6959
6924
|
]
|
|
6960
6925
|
};
|
|
6961
6926
|
}
|
|
@@ -6965,7 +6930,7 @@ var data = function (metaSchema, keywordsJsonPointers) {
|
|
|
6965
6930
|
return metaSchema;
|
|
6966
6931
|
};
|
|
6967
6932
|
|
|
6968
|
-
var MissingRefError
|
|
6933
|
+
var MissingRefError = error_classes.MissingRef;
|
|
6969
6934
|
|
|
6970
6935
|
var async = compileAsync;
|
|
6971
6936
|
|
|
@@ -7018,7 +6983,7 @@ function compileAsync(schema, meta, callback) {
|
|
|
7018
6983
|
function _compileAsync(schemaObj) {
|
|
7019
6984
|
try { return self._compile(schemaObj); }
|
|
7020
6985
|
catch(e) {
|
|
7021
|
-
if (e instanceof MissingRefError
|
|
6986
|
+
if (e instanceof MissingRefError) return loadMissingSchema(e);
|
|
7022
6987
|
throw e;
|
|
7023
6988
|
}
|
|
7024
6989
|
|
|
@@ -7282,10 +7247,10 @@ var custom = function generate_custom(it, $keyword, $ruleType) {
|
|
|
7282
7247
|
return out;
|
|
7283
7248
|
};
|
|
7284
7249
|
|
|
7285
|
-
var $schema = "http://json-schema.org/draft-07/schema#";
|
|
7286
|
-
var $id = "http://json-schema.org/draft-07/schema#";
|
|
7250
|
+
var $schema$2 = "http://json-schema.org/draft-07/schema#";
|
|
7251
|
+
var $id$1 = "http://json-schema.org/draft-07/schema#";
|
|
7287
7252
|
var title = "Core schema meta-schema";
|
|
7288
|
-
var definitions = {
|
|
7253
|
+
var definitions$1 = {
|
|
7289
7254
|
schemaArray: {
|
|
7290
7255
|
type: "array",
|
|
7291
7256
|
minItems: 1,
|
|
@@ -7328,7 +7293,7 @@ var definitions = {
|
|
|
7328
7293
|
]
|
|
7329
7294
|
}
|
|
7330
7295
|
};
|
|
7331
|
-
var type = [
|
|
7296
|
+
var type$1 = [
|
|
7332
7297
|
"object",
|
|
7333
7298
|
"boolean"
|
|
7334
7299
|
];
|
|
@@ -7524,41 +7489,20 @@ var properties$1 = {
|
|
|
7524
7489
|
$ref: "#"
|
|
7525
7490
|
}
|
|
7526
7491
|
};
|
|
7527
|
-
var
|
|
7528
|
-
$schema: $schema,
|
|
7529
|
-
$id: $id,
|
|
7492
|
+
var require$$13 = {
|
|
7493
|
+
$schema: $schema$2,
|
|
7494
|
+
$id: $id$1,
|
|
7530
7495
|
title: title,
|
|
7531
|
-
definitions: definitions,
|
|
7532
|
-
type: type,
|
|
7496
|
+
definitions: definitions$1,
|
|
7497
|
+
type: type$1,
|
|
7533
7498
|
properties: properties$1,
|
|
7534
7499
|
"default": true
|
|
7535
7500
|
};
|
|
7536
7501
|
|
|
7537
|
-
var
|
|
7538
|
-
__proto__: null,
|
|
7539
|
-
$schema: $schema,
|
|
7540
|
-
$id: $id,
|
|
7541
|
-
title: title,
|
|
7542
|
-
definitions: definitions,
|
|
7543
|
-
type: type,
|
|
7544
|
-
properties: properties$1,
|
|
7545
|
-
'default': jsonSchemaDraft07
|
|
7546
|
-
});
|
|
7547
|
-
|
|
7548
|
-
var require$$2 = getCjsExportFromNamespace(jsonSchemaDraft07$1);
|
|
7549
|
-
|
|
7550
|
-
var IDENTIFIER$1 = /^[a-z_$][a-z0-9_$-]*$/i;
|
|
7551
|
-
|
|
7552
|
-
var metaSchema = require$$2;
|
|
7553
|
-
|
|
7554
|
-
var keyword = {
|
|
7555
|
-
add: addKeyword,
|
|
7556
|
-
get: getKeyword,
|
|
7557
|
-
remove: removeKeyword,
|
|
7558
|
-
validate: validateKeyword
|
|
7559
|
-
};
|
|
7502
|
+
var metaSchema = require$$13;
|
|
7560
7503
|
|
|
7561
|
-
var
|
|
7504
|
+
var definition_schema = {
|
|
7505
|
+
$id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
|
|
7562
7506
|
definitions: {
|
|
7563
7507
|
simpleTypes: metaSchema.definitions.simpleTypes
|
|
7564
7508
|
},
|
|
@@ -7591,6 +7535,18 @@ var definitionSchema = {
|
|
|
7591
7535
|
}
|
|
7592
7536
|
};
|
|
7593
7537
|
|
|
7538
|
+
var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
|
|
7539
|
+
var customRuleCode = custom;
|
|
7540
|
+
var definitionSchema = definition_schema;
|
|
7541
|
+
|
|
7542
|
+
var keyword = {
|
|
7543
|
+
add: addKeyword,
|
|
7544
|
+
get: getKeyword,
|
|
7545
|
+
remove: removeKeyword,
|
|
7546
|
+
validate: validateKeyword
|
|
7547
|
+
};
|
|
7548
|
+
|
|
7549
|
+
|
|
7594
7550
|
/**
|
|
7595
7551
|
* Define custom keyword
|
|
7596
7552
|
* @this Ajv
|
|
@@ -7605,7 +7561,7 @@ function addKeyword(keyword, definition) {
|
|
|
7605
7561
|
if (RULES.keywords[keyword])
|
|
7606
7562
|
throw new Error('Keyword ' + keyword + ' is already defined');
|
|
7607
7563
|
|
|
7608
|
-
if (!IDENTIFIER
|
|
7564
|
+
if (!IDENTIFIER.test(keyword))
|
|
7609
7565
|
throw new Error('Keyword ' + keyword + ' is not a valid identifier');
|
|
7610
7566
|
|
|
7611
7567
|
if (definition) {
|
|
@@ -7625,7 +7581,7 @@ function addKeyword(keyword, definition) {
|
|
|
7625
7581
|
metaSchema = {
|
|
7626
7582
|
anyOf: [
|
|
7627
7583
|
metaSchema,
|
|
7628
|
-
{ '$ref': 'https://raw.githubusercontent.com/
|
|
7584
|
+
{ '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
|
|
7629
7585
|
]
|
|
7630
7586
|
};
|
|
7631
7587
|
}
|
|
@@ -7655,7 +7611,7 @@ function addKeyword(keyword, definition) {
|
|
|
7655
7611
|
keyword: keyword,
|
|
7656
7612
|
definition: definition,
|
|
7657
7613
|
custom: true,
|
|
7658
|
-
code:
|
|
7614
|
+
code: customRuleCode,
|
|
7659
7615
|
implements: definition.implements
|
|
7660
7616
|
};
|
|
7661
7617
|
ruleGroup.rules.push(rule);
|
|
@@ -7725,13 +7681,13 @@ function validateKeyword(definition, throwError) {
|
|
|
7725
7681
|
}
|
|
7726
7682
|
|
|
7727
7683
|
var $schema$1 = "http://json-schema.org/draft-07/schema#";
|
|
7728
|
-
var $id
|
|
7684
|
+
var $id = "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#";
|
|
7729
7685
|
var description = "Meta-schema for $data reference (JSON Schema extension proposal)";
|
|
7730
|
-
var type
|
|
7731
|
-
var required
|
|
7686
|
+
var type = "object";
|
|
7687
|
+
var required = [
|
|
7732
7688
|
"$data"
|
|
7733
7689
|
];
|
|
7734
|
-
var properties
|
|
7690
|
+
var properties = {
|
|
7735
7691
|
$data: {
|
|
7736
7692
|
type: "string",
|
|
7737
7693
|
anyOf: [
|
|
@@ -7745,56 +7701,52 @@ var properties$2 = {
|
|
|
7745
7701
|
}
|
|
7746
7702
|
};
|
|
7747
7703
|
var additionalProperties = false;
|
|
7748
|
-
var
|
|
7704
|
+
var require$$12 = {
|
|
7749
7705
|
$schema: $schema$1,
|
|
7750
|
-
$id: $id
|
|
7706
|
+
$id: $id,
|
|
7751
7707
|
description: description,
|
|
7752
|
-
type: type
|
|
7753
|
-
required: required
|
|
7754
|
-
properties: properties
|
|
7708
|
+
type: type,
|
|
7709
|
+
required: required,
|
|
7710
|
+
properties: properties,
|
|
7755
7711
|
additionalProperties: additionalProperties
|
|
7756
7712
|
};
|
|
7757
7713
|
|
|
7758
|
-
var
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
Ajv.prototype.
|
|
7775
|
-
Ajv.prototype.
|
|
7776
|
-
Ajv.prototype.
|
|
7777
|
-
Ajv.prototype.
|
|
7778
|
-
Ajv.prototype.
|
|
7779
|
-
|
|
7780
|
-
Ajv.prototype.
|
|
7781
|
-
Ajv.prototype.
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
Ajv.prototype.
|
|
7786
|
-
|
|
7787
|
-
Ajv.prototype.
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
Ajv.
|
|
7792
|
-
Ajv.
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
Ajv.ValidationError = error_classes.Validation;
|
|
7796
|
-
Ajv.MissingRefError = error_classes.MissingRef;
|
|
7797
|
-
Ajv.$dataMetaSchema = data;
|
|
7714
|
+
var compileSchema = compile_1
|
|
7715
|
+
, resolve = resolve_1
|
|
7716
|
+
, Cache = cache.exports
|
|
7717
|
+
, SchemaObject = schema_obj
|
|
7718
|
+
, stableStringify = fastJsonStableStringify
|
|
7719
|
+
, formats = formats_1
|
|
7720
|
+
, rules = rules$1
|
|
7721
|
+
, $dataMetaSchema = data
|
|
7722
|
+
, util = util$5;
|
|
7723
|
+
|
|
7724
|
+
var ajv = Ajv$1;
|
|
7725
|
+
|
|
7726
|
+
Ajv$1.prototype.validate = validate;
|
|
7727
|
+
Ajv$1.prototype.compile = compile;
|
|
7728
|
+
Ajv$1.prototype.addSchema = addSchema;
|
|
7729
|
+
Ajv$1.prototype.addMetaSchema = addMetaSchema;
|
|
7730
|
+
Ajv$1.prototype.validateSchema = validateSchema;
|
|
7731
|
+
Ajv$1.prototype.getSchema = getSchema;
|
|
7732
|
+
Ajv$1.prototype.removeSchema = removeSchema;
|
|
7733
|
+
Ajv$1.prototype.addFormat = addFormat;
|
|
7734
|
+
Ajv$1.prototype.errorsText = errorsText;
|
|
7735
|
+
|
|
7736
|
+
Ajv$1.prototype._addSchema = _addSchema;
|
|
7737
|
+
Ajv$1.prototype._compile = _compile;
|
|
7738
|
+
|
|
7739
|
+
Ajv$1.prototype.compileAsync = async;
|
|
7740
|
+
var customKeyword = keyword;
|
|
7741
|
+
Ajv$1.prototype.addKeyword = customKeyword.add;
|
|
7742
|
+
Ajv$1.prototype.getKeyword = customKeyword.get;
|
|
7743
|
+
Ajv$1.prototype.removeKeyword = customKeyword.remove;
|
|
7744
|
+
Ajv$1.prototype.validateKeyword = customKeyword.validate;
|
|
7745
|
+
|
|
7746
|
+
var errorClasses = error_classes;
|
|
7747
|
+
Ajv$1.ValidationError = errorClasses.Validation;
|
|
7748
|
+
Ajv$1.MissingRefError = errorClasses.MissingRef;
|
|
7749
|
+
Ajv$1.$dataMetaSchema = $dataMetaSchema;
|
|
7798
7750
|
|
|
7799
7751
|
var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
|
|
7800
7752
|
|
|
@@ -7807,16 +7759,16 @@ var META_SUPPORT_DATA = ['/properties'];
|
|
|
7807
7759
|
* @param {Object} opts optional options
|
|
7808
7760
|
* @return {Object} ajv instance
|
|
7809
7761
|
*/
|
|
7810
|
-
function Ajv(opts) {
|
|
7811
|
-
if (!(this instanceof Ajv)) return new Ajv(opts);
|
|
7762
|
+
function Ajv$1(opts) {
|
|
7763
|
+
if (!(this instanceof Ajv$1)) return new Ajv$1(opts);
|
|
7812
7764
|
opts = this._opts = util.copy(opts) || {};
|
|
7813
7765
|
setLogger(this);
|
|
7814
7766
|
this._schemas = {};
|
|
7815
7767
|
this._refs = {};
|
|
7816
7768
|
this._fragments = {};
|
|
7817
|
-
this._formats =
|
|
7769
|
+
this._formats = formats(opts.format);
|
|
7818
7770
|
|
|
7819
|
-
this._cache = opts.cache || new
|
|
7771
|
+
this._cache = opts.cache || new Cache;
|
|
7820
7772
|
this._loadingSchemas = {};
|
|
7821
7773
|
this._compilations = [];
|
|
7822
7774
|
this.RULES = rules();
|
|
@@ -7824,10 +7776,11 @@ function Ajv(opts) {
|
|
|
7824
7776
|
|
|
7825
7777
|
opts.loopRequired = opts.loopRequired || Infinity;
|
|
7826
7778
|
if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
|
|
7827
|
-
if (opts.serialize === undefined) opts.serialize =
|
|
7779
|
+
if (opts.serialize === undefined) opts.serialize = stableStringify;
|
|
7828
7780
|
this._metaOpts = getMetaSchemaOptions(this);
|
|
7829
7781
|
|
|
7830
7782
|
if (opts.formats) addInitialFormats(this);
|
|
7783
|
+
if (opts.keywords) addInitialKeywords(this);
|
|
7831
7784
|
addDefaultMetaSchema(this);
|
|
7832
7785
|
if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
|
|
7833
7786
|
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
|
|
@@ -7844,7 +7797,7 @@ function Ajv(opts) {
|
|
|
7844
7797
|
* @param {Any} data to be validated
|
|
7845
7798
|
* @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
|
|
7846
7799
|
*/
|
|
7847
|
-
function validate
|
|
7800
|
+
function validate(schemaKeyRef, data) {
|
|
7848
7801
|
var v;
|
|
7849
7802
|
if (typeof schemaKeyRef == 'string') {
|
|
7850
7803
|
v = this.getSchema(schemaKeyRef);
|
|
@@ -7867,7 +7820,7 @@ function validate$1(schemaKeyRef, data) {
|
|
|
7867
7820
|
* @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
|
|
7868
7821
|
* @return {Function} validating function
|
|
7869
7822
|
*/
|
|
7870
|
-
function compile
|
|
7823
|
+
function compile(schema, _meta) {
|
|
7871
7824
|
var schemaObj = this._addSchema(schema, undefined, _meta);
|
|
7872
7825
|
return schemaObj.validate || this._compile(schemaObj);
|
|
7873
7826
|
}
|
|
@@ -7890,7 +7843,7 @@ function addSchema(schema, key, _skipValidation, _meta) {
|
|
|
7890
7843
|
var id = this._getId(schema);
|
|
7891
7844
|
if (id !== undefined && typeof id != 'string')
|
|
7892
7845
|
throw new Error('schema id must be string');
|
|
7893
|
-
key =
|
|
7846
|
+
key = resolve.normalizeId(key || id);
|
|
7894
7847
|
checkUnique(this, key);
|
|
7895
7848
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
7896
7849
|
return this;
|
|
@@ -7967,13 +7920,13 @@ function getSchema(keyRef) {
|
|
|
7967
7920
|
|
|
7968
7921
|
|
|
7969
7922
|
function _getSchemaFragment(self, ref) {
|
|
7970
|
-
var res =
|
|
7923
|
+
var res = resolve.schema.call(self, { schema: {} }, ref);
|
|
7971
7924
|
if (res) {
|
|
7972
7925
|
var schema = res.schema
|
|
7973
7926
|
, root = res.root
|
|
7974
7927
|
, baseId = res.baseId;
|
|
7975
|
-
var v =
|
|
7976
|
-
self._fragments[ref] = new
|
|
7928
|
+
var v = compileSchema.call(self, schema, root, undefined, baseId);
|
|
7929
|
+
self._fragments[ref] = new SchemaObject({
|
|
7977
7930
|
ref: ref,
|
|
7978
7931
|
fragment: true,
|
|
7979
7932
|
schema: schema,
|
|
@@ -7987,7 +7940,7 @@ function _getSchemaFragment(self, ref) {
|
|
|
7987
7940
|
|
|
7988
7941
|
|
|
7989
7942
|
function _getSchemaObj(self, keyRef) {
|
|
7990
|
-
keyRef =
|
|
7943
|
+
keyRef = resolve.normalizeId(keyRef);
|
|
7991
7944
|
return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
|
|
7992
7945
|
}
|
|
7993
7946
|
|
|
@@ -8025,7 +7978,7 @@ function removeSchema(schemaKeyRef) {
|
|
|
8025
7978
|
this._cache.del(cacheKey);
|
|
8026
7979
|
var id = this._getId(schemaKeyRef);
|
|
8027
7980
|
if (id) {
|
|
8028
|
-
id =
|
|
7981
|
+
id = resolve.normalizeId(id);
|
|
8029
7982
|
delete this._schemas[id];
|
|
8030
7983
|
delete this._refs[id];
|
|
8031
7984
|
}
|
|
@@ -8056,17 +8009,17 @@ function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
|
|
|
8056
8009
|
|
|
8057
8010
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
8058
8011
|
|
|
8059
|
-
var id =
|
|
8012
|
+
var id = resolve.normalizeId(this._getId(schema));
|
|
8060
8013
|
if (id && shouldAddSchema) checkUnique(this, id);
|
|
8061
8014
|
|
|
8062
8015
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
8063
8016
|
var recursiveMeta;
|
|
8064
|
-
if (willValidate && !(recursiveMeta = id && id ==
|
|
8017
|
+
if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
|
|
8065
8018
|
this.validateSchema(schema, true);
|
|
8066
8019
|
|
|
8067
|
-
var localRefs =
|
|
8020
|
+
var localRefs = resolve.ids.call(this, schema);
|
|
8068
8021
|
|
|
8069
|
-
var schemaObj = new
|
|
8022
|
+
var schemaObj = new SchemaObject({
|
|
8070
8023
|
id: id,
|
|
8071
8024
|
schema: schema,
|
|
8072
8025
|
localRefs: localRefs,
|
|
@@ -8103,7 +8056,7 @@ function _compile(schemaObj, root) {
|
|
|
8103
8056
|
}
|
|
8104
8057
|
|
|
8105
8058
|
var v;
|
|
8106
|
-
try { v =
|
|
8059
|
+
try { v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs); }
|
|
8107
8060
|
catch(e) {
|
|
8108
8061
|
delete schemaObj.validate;
|
|
8109
8062
|
throw e;
|
|
@@ -8199,12 +8152,12 @@ function addFormat(name, format) {
|
|
|
8199
8152
|
function addDefaultMetaSchema(self) {
|
|
8200
8153
|
var $dataSchema;
|
|
8201
8154
|
if (self._opts.$data) {
|
|
8202
|
-
$dataSchema = require$$
|
|
8155
|
+
$dataSchema = require$$12;
|
|
8203
8156
|
self.addMetaSchema($dataSchema, $dataSchema.$id, true);
|
|
8204
8157
|
}
|
|
8205
8158
|
if (self._opts.meta === false) return;
|
|
8206
|
-
var metaSchema = require$$
|
|
8207
|
-
if (self._opts.$data) metaSchema =
|
|
8159
|
+
var metaSchema = require$$13;
|
|
8160
|
+
if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
|
|
8208
8161
|
self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
|
|
8209
8162
|
self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
|
|
8210
8163
|
}
|
|
@@ -8226,6 +8179,14 @@ function addInitialFormats(self) {
|
|
|
8226
8179
|
}
|
|
8227
8180
|
|
|
8228
8181
|
|
|
8182
|
+
function addInitialKeywords(self) {
|
|
8183
|
+
for (var name in self._opts.keywords) {
|
|
8184
|
+
var keyword = self._opts.keywords[name];
|
|
8185
|
+
self.addKeyword(name, keyword);
|
|
8186
|
+
}
|
|
8187
|
+
}
|
|
8188
|
+
|
|
8189
|
+
|
|
8229
8190
|
function checkUnique(self, id) {
|
|
8230
8191
|
if (self._schemas[id] || self._refs[id])
|
|
8231
8192
|
throw new Error('schema with key or id "' + id + '" already exists');
|
|
@@ -8255,14 +8216,14 @@ function setLogger(self) {
|
|
|
8255
8216
|
|
|
8256
8217
|
function noop() {}
|
|
8257
8218
|
|
|
8258
|
-
var _Ajv = /*#__PURE__*/
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
})
|
|
8219
|
+
var _Ajv = /*#__PURE__*/_mergeNamespaces({
|
|
8220
|
+
__proto__: null,
|
|
8221
|
+
'default': ajv
|
|
8222
|
+
}, [ajv]);
|
|
8262
8223
|
|
|
8263
8224
|
var $ref = "#/definitions/Schema";
|
|
8264
|
-
var $schema
|
|
8265
|
-
var definitions
|
|
8225
|
+
var $schema = "http://json-schema.org/draft-07/schema#";
|
|
8226
|
+
var definitions = {
|
|
8266
8227
|
ActivityType: {
|
|
8267
8228
|
anyOf: [
|
|
8268
8229
|
{
|
|
@@ -8335,17 +8296,6 @@ var definitions$1 = {
|
|
|
8335
8296
|
}
|
|
8336
8297
|
]
|
|
8337
8298
|
},
|
|
8338
|
-
IActivityType: {
|
|
8339
|
-
"enum": [
|
|
8340
|
-
"filter",
|
|
8341
|
-
"project",
|
|
8342
|
-
"groupby",
|
|
8343
|
-
"sort",
|
|
8344
|
-
"limit",
|
|
8345
|
-
"mappings"
|
|
8346
|
-
],
|
|
8347
|
-
type: "string"
|
|
8348
|
-
},
|
|
8349
8299
|
IAggregate: {
|
|
8350
8300
|
additionalProperties: false,
|
|
8351
8301
|
properties: {
|
|
@@ -8420,9 +8370,7 @@ var definitions$1 = {
|
|
|
8420
8370
|
type: "string"
|
|
8421
8371
|
},
|
|
8422
8372
|
type: {
|
|
8423
|
-
"
|
|
8424
|
-
"count"
|
|
8425
|
-
],
|
|
8373
|
+
"const": "count",
|
|
8426
8374
|
type: "string"
|
|
8427
8375
|
}
|
|
8428
8376
|
},
|
|
@@ -8451,9 +8399,7 @@ var definitions$1 = {
|
|
|
8451
8399
|
type: "string"
|
|
8452
8400
|
},
|
|
8453
8401
|
type: {
|
|
8454
|
-
"
|
|
8455
|
-
"databomb"
|
|
8456
|
-
],
|
|
8402
|
+
"const": "databomb",
|
|
8457
8403
|
type: "string"
|
|
8458
8404
|
}
|
|
8459
8405
|
},
|
|
@@ -8545,9 +8491,7 @@ var definitions$1 = {
|
|
|
8545
8491
|
type: "array"
|
|
8546
8492
|
},
|
|
8547
8493
|
type: {
|
|
8548
|
-
"
|
|
8549
|
-
"="
|
|
8550
|
-
],
|
|
8494
|
+
"const": "=",
|
|
8551
8495
|
type: "string"
|
|
8552
8496
|
}
|
|
8553
8497
|
},
|
|
@@ -8596,9 +8540,7 @@ var definitions$1 = {
|
|
|
8596
8540
|
type: "string"
|
|
8597
8541
|
},
|
|
8598
8542
|
type: {
|
|
8599
|
-
"
|
|
8600
|
-
"boolean"
|
|
8601
|
-
],
|
|
8543
|
+
"const": "boolean",
|
|
8602
8544
|
type: "string"
|
|
8603
8545
|
}
|
|
8604
8546
|
},
|
|
@@ -8624,9 +8566,7 @@ var definitions$1 = {
|
|
|
8624
8566
|
type: "string"
|
|
8625
8567
|
},
|
|
8626
8568
|
type: {
|
|
8627
|
-
"
|
|
8628
|
-
"dataset"
|
|
8629
|
-
],
|
|
8569
|
+
"const": "dataset",
|
|
8630
8570
|
type: "string"
|
|
8631
8571
|
}
|
|
8632
8572
|
},
|
|
@@ -8647,9 +8587,7 @@ var definitions$1 = {
|
|
|
8647
8587
|
type: "string"
|
|
8648
8588
|
},
|
|
8649
8589
|
type: {
|
|
8650
|
-
"
|
|
8651
|
-
"number"
|
|
8652
|
-
],
|
|
8590
|
+
"const": "number",
|
|
8653
8591
|
type: "string"
|
|
8654
8592
|
}
|
|
8655
8593
|
},
|
|
@@ -8669,9 +8607,7 @@ var definitions$1 = {
|
|
|
8669
8607
|
type: "string"
|
|
8670
8608
|
},
|
|
8671
8609
|
type: {
|
|
8672
|
-
"
|
|
8673
|
-
"number64"
|
|
8674
|
-
],
|
|
8610
|
+
"const": "number64",
|
|
8675
8611
|
type: "string"
|
|
8676
8612
|
}
|
|
8677
8613
|
},
|
|
@@ -8697,9 +8633,7 @@ var definitions$1 = {
|
|
|
8697
8633
|
type: "string"
|
|
8698
8634
|
},
|
|
8699
8635
|
type: {
|
|
8700
|
-
"
|
|
8701
|
-
"object"
|
|
8702
|
-
],
|
|
8636
|
+
"const": "object",
|
|
8703
8637
|
type: "string"
|
|
8704
8638
|
}
|
|
8705
8639
|
},
|
|
@@ -8720,9 +8654,7 @@ var definitions$1 = {
|
|
|
8720
8654
|
type: "string"
|
|
8721
8655
|
},
|
|
8722
8656
|
type: {
|
|
8723
|
-
"
|
|
8724
|
-
"range"
|
|
8725
|
-
],
|
|
8657
|
+
"const": "range",
|
|
8726
8658
|
type: "string"
|
|
8727
8659
|
}
|
|
8728
8660
|
},
|
|
@@ -8755,9 +8687,7 @@ var definitions$1 = {
|
|
|
8755
8687
|
type: "string"
|
|
8756
8688
|
},
|
|
8757
8689
|
type: {
|
|
8758
|
-
"
|
|
8759
|
-
"set"
|
|
8760
|
-
],
|
|
8690
|
+
"const": "set",
|
|
8761
8691
|
type: "string"
|
|
8762
8692
|
}
|
|
8763
8693
|
},
|
|
@@ -8778,9 +8708,7 @@ var definitions$1 = {
|
|
|
8778
8708
|
type: "string"
|
|
8779
8709
|
},
|
|
8780
8710
|
type: {
|
|
8781
|
-
"
|
|
8782
|
-
"string"
|
|
8783
|
-
],
|
|
8711
|
+
"const": "string",
|
|
8784
8712
|
type: "string"
|
|
8785
8713
|
}
|
|
8786
8714
|
},
|
|
@@ -8813,9 +8741,7 @@ var definitions$1 = {
|
|
|
8813
8741
|
type: "array"
|
|
8814
8742
|
},
|
|
8815
8743
|
type: {
|
|
8816
|
-
"
|
|
8817
|
-
"filter"
|
|
8818
|
-
],
|
|
8744
|
+
"const": "filter",
|
|
8819
8745
|
type: "string"
|
|
8820
8746
|
}
|
|
8821
8747
|
},
|
|
@@ -8880,9 +8806,7 @@ var definitions$1 = {
|
|
|
8880
8806
|
type: "string"
|
|
8881
8807
|
},
|
|
8882
8808
|
type: {
|
|
8883
|
-
"
|
|
8884
|
-
"form"
|
|
8885
|
-
],
|
|
8809
|
+
"const": "form",
|
|
8886
8810
|
type: "string"
|
|
8887
8811
|
}
|
|
8888
8812
|
},
|
|
@@ -8909,9 +8833,7 @@ var definitions$1 = {
|
|
|
8909
8833
|
type: "array"
|
|
8910
8834
|
},
|
|
8911
8835
|
type: {
|
|
8912
|
-
"
|
|
8913
|
-
"groupby"
|
|
8914
|
-
],
|
|
8836
|
+
"const": "groupby",
|
|
8915
8837
|
type: "string"
|
|
8916
8838
|
}
|
|
8917
8839
|
},
|
|
@@ -8944,9 +8866,7 @@ var definitions$1 = {
|
|
|
8944
8866
|
type: "string"
|
|
8945
8867
|
},
|
|
8946
8868
|
type: {
|
|
8947
|
-
"
|
|
8948
|
-
"hipie"
|
|
8949
|
-
],
|
|
8869
|
+
"const": "hipie",
|
|
8950
8870
|
type: "string"
|
|
8951
8871
|
},
|
|
8952
8872
|
url: {
|
|
@@ -8983,9 +8903,7 @@ var definitions$1 = {
|
|
|
8983
8903
|
type: "number"
|
|
8984
8904
|
},
|
|
8985
8905
|
type: {
|
|
8986
|
-
"
|
|
8987
|
-
"limit"
|
|
8988
|
-
],
|
|
8906
|
+
"const": "limit",
|
|
8989
8907
|
type: "string"
|
|
8990
8908
|
}
|
|
8991
8909
|
},
|
|
@@ -9011,9 +8929,7 @@ var definitions$1 = {
|
|
|
9011
8929
|
type: "string"
|
|
9012
8930
|
},
|
|
9013
8931
|
type: {
|
|
9014
|
-
"
|
|
9015
|
-
"logicalfile"
|
|
9016
|
-
],
|
|
8932
|
+
"const": "logicalfile",
|
|
9017
8933
|
type: "string"
|
|
9018
8934
|
},
|
|
9019
8935
|
url: {
|
|
@@ -9047,9 +8963,7 @@ var definitions$1 = {
|
|
|
9047
8963
|
type: "string"
|
|
9048
8964
|
},
|
|
9049
8965
|
type: {
|
|
9050
|
-
"
|
|
9051
|
-
"map"
|
|
9052
|
-
],
|
|
8966
|
+
"const": "map",
|
|
9053
8967
|
type: "string"
|
|
9054
8968
|
}
|
|
9055
8969
|
},
|
|
@@ -9123,9 +9037,7 @@ var definitions$1 = {
|
|
|
9123
9037
|
type: "array"
|
|
9124
9038
|
},
|
|
9125
9039
|
type: {
|
|
9126
|
-
"
|
|
9127
|
-
"mappings"
|
|
9128
|
-
],
|
|
9040
|
+
"const": "mappings",
|
|
9129
9041
|
type: "string"
|
|
9130
9042
|
}
|
|
9131
9043
|
},
|
|
@@ -9148,9 +9060,7 @@ var definitions$1 = {
|
|
|
9148
9060
|
type: "array"
|
|
9149
9061
|
},
|
|
9150
9062
|
type: {
|
|
9151
|
-
"
|
|
9152
|
-
"multi"
|
|
9153
|
-
],
|
|
9063
|
+
"const": "multi",
|
|
9154
9064
|
type: "string"
|
|
9155
9065
|
}
|
|
9156
9066
|
},
|
|
@@ -9186,9 +9096,7 @@ var definitions$1 = {
|
|
|
9186
9096
|
type: "array"
|
|
9187
9097
|
},
|
|
9188
9098
|
type: {
|
|
9189
|
-
"
|
|
9190
|
-
"project"
|
|
9191
|
-
],
|
|
9099
|
+
"const": "project",
|
|
9192
9100
|
type: "string"
|
|
9193
9101
|
}
|
|
9194
9102
|
},
|
|
@@ -9251,9 +9159,7 @@ var definitions$1 = {
|
|
|
9251
9159
|
$ref: "#/definitions/OutputDict"
|
|
9252
9160
|
},
|
|
9253
9161
|
type: {
|
|
9254
|
-
"
|
|
9255
|
-
"rest"
|
|
9256
|
-
],
|
|
9162
|
+
"const": "rest",
|
|
9257
9163
|
type: "string"
|
|
9258
9164
|
},
|
|
9259
9165
|
url: {
|
|
@@ -9292,9 +9198,7 @@ var definitions$1 = {
|
|
|
9292
9198
|
type: "string"
|
|
9293
9199
|
},
|
|
9294
9200
|
type: {
|
|
9295
|
-
"
|
|
9296
|
-
"roxie"
|
|
9297
|
-
],
|
|
9201
|
+
"const": "roxie",
|
|
9298
9202
|
type: "string"
|
|
9299
9203
|
},
|
|
9300
9204
|
url: {
|
|
@@ -9348,9 +9252,7 @@ var definitions$1 = {
|
|
|
9348
9252
|
type: "string"
|
|
9349
9253
|
},
|
|
9350
9254
|
type: {
|
|
9351
|
-
"
|
|
9352
|
-
"scale"
|
|
9353
|
-
],
|
|
9255
|
+
"const": "scale",
|
|
9354
9256
|
type: "string"
|
|
9355
9257
|
}
|
|
9356
9258
|
},
|
|
@@ -9372,9 +9274,7 @@ var definitions$1 = {
|
|
|
9372
9274
|
type: "array"
|
|
9373
9275
|
},
|
|
9374
9276
|
type: {
|
|
9375
|
-
"
|
|
9376
|
-
"sort"
|
|
9377
|
-
],
|
|
9277
|
+
"const": "sort",
|
|
9378
9278
|
type: "string"
|
|
9379
9279
|
}
|
|
9380
9280
|
},
|
|
@@ -9410,9 +9310,7 @@ var definitions$1 = {
|
|
|
9410
9310
|
type: "string"
|
|
9411
9311
|
},
|
|
9412
9312
|
type: {
|
|
9413
|
-
"
|
|
9414
|
-
"template"
|
|
9415
|
-
],
|
|
9313
|
+
"const": "template",
|
|
9416
9314
|
type: "string"
|
|
9417
9315
|
}
|
|
9418
9316
|
},
|
|
@@ -9502,9 +9400,7 @@ var definitions$1 = {
|
|
|
9502
9400
|
$ref: "#/definitions/OutputDict"
|
|
9503
9401
|
},
|
|
9504
9402
|
type: {
|
|
9505
|
-
"
|
|
9506
|
-
"wuresult"
|
|
9507
|
-
],
|
|
9403
|
+
"const": "wuresult",
|
|
9508
9404
|
type: "string"
|
|
9509
9405
|
},
|
|
9510
9406
|
url: {
|
|
@@ -9621,20 +9517,12 @@ var definitions$1 = {
|
|
|
9621
9517
|
]
|
|
9622
9518
|
},
|
|
9623
9519
|
Range: {
|
|
9624
|
-
items:
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
},
|
|
9631
|
-
{
|
|
9632
|
-
type: [
|
|
9633
|
-
"number",
|
|
9634
|
-
"string"
|
|
9635
|
-
]
|
|
9636
|
-
}
|
|
9637
|
-
],
|
|
9520
|
+
items: {
|
|
9521
|
+
type: [
|
|
9522
|
+
"number",
|
|
9523
|
+
"string"
|
|
9524
|
+
]
|
|
9525
|
+
},
|
|
9638
9526
|
maxItems: 2,
|
|
9639
9527
|
minItems: 2,
|
|
9640
9528
|
type: "array"
|
|
@@ -9883,9 +9771,7 @@ var definitions$1 = {
|
|
|
9883
9771
|
$ref: "#/definitions/IProperties"
|
|
9884
9772
|
},
|
|
9885
9773
|
version: {
|
|
9886
|
-
"
|
|
9887
|
-
"2.2.1"
|
|
9888
|
-
],
|
|
9774
|
+
"const": "2.2.1",
|
|
9889
9775
|
type: "string"
|
|
9890
9776
|
}
|
|
9891
9777
|
},
|
|
@@ -9905,43 +9791,43 @@ var definitions$1 = {
|
|
|
9905
9791
|
type: "string"
|
|
9906
9792
|
}
|
|
9907
9793
|
};
|
|
9908
|
-
var v2
|
|
9794
|
+
var v2 = {
|
|
9909
9795
|
$ref: $ref,
|
|
9910
|
-
$schema: $schema
|
|
9911
|
-
definitions: definitions
|
|
9796
|
+
$schema: $schema,
|
|
9797
|
+
definitions: definitions
|
|
9912
9798
|
};
|
|
9913
9799
|
|
|
9914
9800
|
var _ddl2Schema = /*#__PURE__*/Object.freeze({
|
|
9915
9801
|
__proto__: null,
|
|
9916
9802
|
$ref: $ref,
|
|
9917
|
-
$schema: $schema
|
|
9918
|
-
definitions: definitions
|
|
9919
|
-
'default': v2
|
|
9803
|
+
$schema: $schema,
|
|
9804
|
+
definitions: definitions,
|
|
9805
|
+
'default': v2
|
|
9920
9806
|
});
|
|
9921
9807
|
|
|
9922
|
-
var Ajv
|
|
9923
|
-
var ddl2Schema = _ddl2Schema;
|
|
9924
|
-
var options = {
|
|
9925
|
-
allErrors: false,
|
|
9926
|
-
verbose: true,
|
|
9927
|
-
jsonPointers: false
|
|
9928
|
-
};
|
|
9929
|
-
function doValidate(ddl, schema) {
|
|
9930
|
-
var ajv = new Ajv
|
|
9931
|
-
var validate = ajv.compile(schema);
|
|
9932
|
-
var success = validate(ddl);
|
|
9933
|
-
return {
|
|
9934
|
-
success: success,
|
|
9935
|
-
errors: validate.errors
|
|
9936
|
-
};
|
|
9937
|
-
}
|
|
9938
|
-
function validate2(ddl) {
|
|
9939
|
-
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);
|
|
9940
9826
|
}
|
|
9941
9827
|
|
|
9942
|
-
function isDDL2Schema(ref) {
|
|
9943
|
-
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;
|
|
9944
9830
|
}
|
|
9945
9831
|
|
|
9946
|
-
export { BUILD_VERSION, v1 as DDL1, v2 as DDL2, PKG_NAME, PKG_VERSION, ddl2Schema, isDDL2Schema, upgrade
|
|
9832
|
+
export { BUILD_VERSION, v1 as DDL1, v2$1 as DDL2, PKG_NAME, PKG_VERSION, ddl2Schema, isDDL2Schema, upgrade, validate2 };
|
|
9947
9833
|
//# sourceMappingURL=index.es6.js.map
|