@dra2020/baseclient 1.0.146 → 1.0.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseclient.js +36 -12
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +2 -0
- package/lib/detail/detail.ts +10 -5
- package/lib/geo/geo.ts +26 -5
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -1245,8 +1245,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1245
1245
|
exports.FormatDetail = void 0;
|
|
1246
1246
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1247
1247
|
//import { Util } from '@dra2020/baseclient';
|
|
1248
|
-
const
|
|
1249
|
-
const
|
|
1248
|
+
const reIdentifierOrStringOrNumber = /([a-zA-Z0-9_$][a-zA-Z0-9_$]*)|(['"])(?:(?=(\\?))\3.)*?\2/g;
|
|
1249
|
+
const reNumber = /[0-9][0-9]*/;
|
|
1250
1250
|
const reParam = /^__\d+$/;
|
|
1251
1251
|
const reString = /^['"]/;
|
|
1252
1252
|
// Number format: (locale|general|integer|currency).precision
|
|
@@ -1284,9 +1284,11 @@ class Evaluator {
|
|
|
1284
1284
|
let safeexpr = this.expr;
|
|
1285
1285
|
let safenames = names.map(n => namemap[n]);
|
|
1286
1286
|
// Replace valid identifiers with safe version
|
|
1287
|
-
safeexpr = safeexpr.replace(
|
|
1287
|
+
safeexpr = safeexpr.replace(reIdentifierOrStringOrNumber, (match) => {
|
|
1288
1288
|
if (namemap[match])
|
|
1289
1289
|
return namemap[match];
|
|
1290
|
+
else if (reNumber.test(match))
|
|
1291
|
+
return match;
|
|
1290
1292
|
else if (match === '__format' || reString.test(match))
|
|
1291
1293
|
return match;
|
|
1292
1294
|
else {
|
|
@@ -1295,8 +1297,11 @@ class Evaluator {
|
|
|
1295
1297
|
}
|
|
1296
1298
|
});
|
|
1297
1299
|
// Remove any identifiers that aren't the simple parameters to prevent out-of-sandbox execution
|
|
1298
|
-
safeexpr = safeexpr.replace(
|
|
1299
|
-
let valid = reParam.test(match)
|
|
1300
|
+
safeexpr = safeexpr.replace(reIdentifierOrStringOrNumber, (match) => {
|
|
1301
|
+
let valid = reParam.test(match)
|
|
1302
|
+
|| match === '__format'
|
|
1303
|
+
|| reString.test(match)
|
|
1304
|
+
|| reNumber.test(match);
|
|
1300
1305
|
if (valid)
|
|
1301
1306
|
return match;
|
|
1302
1307
|
else {
|
|
@@ -2597,7 +2602,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
2597
2602
|
return result;
|
|
2598
2603
|
};
|
|
2599
2604
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2600
|
-
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollectionNonNull = exports.geoTopoToCollection = exports.geoCollectionToTopoNonNull = exports.geoCollectionToTopo = exports.geoMapToCollectionNonNull = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoNormalizeCollection = exports.geoNormalizeFeature = exports.geoEnsureID = exports.hidemapConcat = exports.dumpMetrics = void 0;
|
|
2605
|
+
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollectionNonNull = exports.geoTopoToCollection = exports.geoCollectionToTopoNonNull = exports.geoCollectionToTopo = exports.geoMapToCollectionNonNull = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoNormalizeCollection = exports.geoNormalizeFeature = exports.geoEnsureID = exports.isValidId = exports.applyCanonicalID = exports.hidemapConcat = exports.dumpMetrics = void 0;
|
|
2601
2606
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
2602
2607
|
const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
|
|
2603
2608
|
// Tracing/debugging aid
|
|
@@ -2623,6 +2628,26 @@ function hidemapConcat(...args) {
|
|
|
2623
2628
|
}
|
|
2624
2629
|
exports.hidemapConcat = hidemapConcat;
|
|
2625
2630
|
const NormalizeAll = { joinPolygons: true, checkRewind: true, ensureID: true };
|
|
2631
|
+
function applyCanonicalID(col) {
|
|
2632
|
+
if (col && Array.isArray(col.features))
|
|
2633
|
+
col.features.forEach((f, n) => { f.properties.id = String(n + 1); });
|
|
2634
|
+
}
|
|
2635
|
+
exports.applyCanonicalID = applyCanonicalID;
|
|
2636
|
+
function isValidId(col) {
|
|
2637
|
+
if (!col || !Array.isArray(col.features))
|
|
2638
|
+
return true;
|
|
2639
|
+
let set = new Set();
|
|
2640
|
+
for (let i = 0; i < col.features.length; i++) {
|
|
2641
|
+
let f = col.features[i];
|
|
2642
|
+
if (typeof f.properties.id !== 'string')
|
|
2643
|
+
return false; // id must be string
|
|
2644
|
+
if (set.has(f.properties.id))
|
|
2645
|
+
return false; // id must be unique
|
|
2646
|
+
set.add(f.properties.id);
|
|
2647
|
+
}
|
|
2648
|
+
return true;
|
|
2649
|
+
}
|
|
2650
|
+
exports.isValidId = isValidId;
|
|
2626
2651
|
// set the canonical 'id' property from the best property value.
|
|
2627
2652
|
// if joinPolygons is true, we do not enforce uniqueness.
|
|
2628
2653
|
//
|
|
@@ -2632,8 +2657,6 @@ function geoEnsureID(col, options) {
|
|
|
2632
2657
|
const props = ['id', 'GEOID', 'GEOID10', 'GEOID20', 'GEOID30', 'DISTRICT', 'DISTRICTNO', 'DISTRICTNAME'];
|
|
2633
2658
|
if (col && col.features && col.features.length > 0) {
|
|
2634
2659
|
let f = col.features[0];
|
|
2635
|
-
if (f.properties.id !== undefined)
|
|
2636
|
-
return; // short-cut - assume if 'id' is set, we're all good.
|
|
2637
2660
|
props.forEach(p => {
|
|
2638
2661
|
if (prop === undefined)
|
|
2639
2662
|
if (f.properties[p] !== undefined)
|
|
@@ -2644,12 +2667,13 @@ function geoEnsureID(col, options) {
|
|
|
2644
2667
|
prop = p;
|
|
2645
2668
|
}
|
|
2646
2669
|
});
|
|
2647
|
-
if (prop)
|
|
2670
|
+
if (prop) {
|
|
2648
2671
|
col.features.forEach(f => { f.properties.id = f.properties[prop]; });
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
col.features.forEach(f => { f.properties.id = String(n++); });
|
|
2672
|
+
if (!isValidId(col))
|
|
2673
|
+
applyCanonicalID(col);
|
|
2652
2674
|
}
|
|
2675
|
+
else
|
|
2676
|
+
applyCanonicalID(col);
|
|
2653
2677
|
}
|
|
2654
2678
|
}
|
|
2655
2679
|
exports.geoEnsureID = geoEnsureID;
|