From ca878e48dde520a52cc0e577444a2a36501093dc Mon Sep 17 00:00:00 2001 From: Kevin Schmidt Date: Wed, 14 Sep 2022 12:25:08 -0600 Subject: [PATCH] Fix inconsistent args with FeatureLayerMetadata.create and QueryFields.create (#241) * Fix ids in layers metadata. (#240) * Fix params passed to QueryFields.create. --- CHANGELOG.md | 2 ++ lib/helpers/table-layer-metadata.js | 4 +++- lib/query/render-features.js | 2 +- lib/queryRelatedRecords.js | 2 +- test/unit/query/render-features.spec.js | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ff054..313cd45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased ### Fixed - geojson validation security vulnerablity +- fix ids in layers metadata +- fix params passed to QueryFields.create ## [4.0.1] - 08-05-2022 ### Changed diff --git a/lib/helpers/table-layer-metadata.js b/lib/helpers/table-layer-metadata.js index 56fe7fd..3fdf5f9 100644 --- a/lib/helpers/table-layer-metadata.js +++ b/lib/helpers/table-layer-metadata.js @@ -26,11 +26,13 @@ class TableLayerMetadata { const { params: { - layer: layerId + layer: reqLayer } = {}, query = {} } = req + const layerId = reqLayer != null ? reqLayer : req.layerId + const { currentVersion, fullVersion, diff --git a/lib/query/render-features.js b/lib/query/render-features.js index 0067ac1..0d2c2ec 100644 --- a/lib/query/render-features.js +++ b/lib/query/render-features.js @@ -33,7 +33,7 @@ function renderFeaturesResponse (data = {}, params = {}) { const computedProperties = { geometryType: params.geometryType, spatialReference: getOutputSpatialReference(data, params), - fields: QueryFields.create({ data, ...params }), + fields: QueryFields.create({ ...data, ...params }), features: data.features || [], exceededTransferLimit: !!limitExceeded, objectIdFieldName: idField || objectIdFieldNameDefault, diff --git a/lib/queryRelatedRecords.js b/lib/queryRelatedRecords.js index 562514c..553423c 100644 --- a/lib/queryRelatedRecords.js +++ b/lib/queryRelatedRecords.js @@ -11,7 +11,7 @@ function queryRelatedRecords (data, params = {}) { relatedRecordGroups: [] } - if (!params.returnCountOnly) response.fields = QueryFields.create(data, params) + if (!params.returnCountOnly) response.fields = QueryFields.create({ ...data, ...params }) const geomType = getGeometryTypeFromGeojson(data) if (geomType) { diff --git a/test/unit/query/render-features.spec.js b/test/unit/query/render-features.spec.js index 5b8c32f..02ccf0a 100644 --- a/test/unit/query/render-features.spec.js +++ b/test/unit/query/render-features.spec.js @@ -79,7 +79,7 @@ describe('renderFeaturesResponse', () => { exceededTransferLimit: false }) createQueryFieldsSpy.callCount.should.equal(1) - createQueryFieldsSpy.firstCall.args.should.deepEqual([{ data: json, geometryType: 'esriGeometryPoint' }]) + createQueryFieldsSpy.firstCall.args.should.deepEqual([{ ...json, geometryType: 'esriGeometryPoint' }]) getCollectionCrsSpy.callCount.should.equal(1) getCollectionCrsSpy.firstCall.args.should.deepEqual([json]) normalizeSpatialReferenceSpy.callCount.should.equal(1) @@ -134,7 +134,7 @@ describe('renderFeaturesResponse', () => { transform: 'transform' }) createQueryFieldsSpy.callCount.should.equal(1) - createQueryFieldsSpy.firstCall.args.should.deepEqual([{ data: json, geometryType: 'esriGeometryPoint' }]) + createQueryFieldsSpy.firstCall.args.should.deepEqual([{ ...json, geometryType: 'esriGeometryPoint' }]) getCollectionCrsSpy.callCount.should.equal(1) getCollectionCrsSpy.firstCall.args.should.deepEqual([json]) normalizeSpatialReferenceSpy.callCount.should.equal(1)