diff --git a/package.json b/package.json index dfbbfa0..bbd46b1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "node": ">=10" }, "description": "SDMX REST API client for JavaScript", - "version": "2.15.1", + "version": "2.15.2", "main": "./lib/index.js", "scripts": { "prebuild": "rm -rf lib && mkdir lib", @@ -57,18 +57,18 @@ "devDependencies": { "chai": "4.2.0", "chai-as-promised": "7.1.1", - "codecov": "3.6.1", + "codecov": "3.6.5", "coffee-coverage": "3.0.1", "coffeeify": "3.0.1", "coffeelint": "2.1.0", "coffeescript": "2.4.1", "commitizen": "4.0.3", - "cz-conventional-changelog": "3.0.2", - "husky": "3.1.0", + "cz-conventional-changelog": "3.1.0", + "husky": "4.2.3", "istanbul": "0.4.5", "mocha": "5.2.0", - "nock": "11.7.0", - "semantic-release": "15.13.31" + "nock": "12.0.1", + "semantic-release": "17.0.4" }, "config": { "commitizen": { diff --git a/src/data/data-query.coffee b/src/data/data-query.coffee index 7095fc0..0840e63 100644 --- a/src/data/data-query.coffee +++ b/src/data/data-query.coffee @@ -7,7 +7,6 @@ defaults = key: 'all' provider: 'all' - obsDimension: 'TIME_PERIOD' detail: DataDetail.FULL history: false @@ -20,7 +19,8 @@ ValidQuery = updatedAfter: (i, e) -> !i or isValidDate(i, 'updatedAfter', e) firstNObs: (i, e) -> !i or isValidNObs(i, 'firstNObs', e) lastNObs: (i, e) -> !i or isValidNObs(i, 'lastNObs', e) - obsDimension: (i, e) -> isValidPattern(i, NCNameIDType, 'obs dimension', e) + obsDimension: (i, e) -> + !i or isValidPattern(i, NCNameIDType, 'obs dimension', e) detail: (i, e) -> isValidEnum(i, DataDetail, 'details', e) history: (i, e) -> isValidHistory(i, e) @@ -66,7 +66,7 @@ query = class DataQuery updatedAfter: opts?.updatedAfter firstNObs: opts?.firstNObs lastNObs: opts?.lastNObs - obsDimension: opts?.obsDimension ? defaults.obsDimension + obsDimension: opts?.obsDimension detail: opts?.detail ? defaults.detail history: opts?.history ? defaults.history input = isValidQuery query diff --git a/src/utils/url-generator.coffee b/src/utils/url-generator.coffee index bf62df8..e5dbf62 100644 --- a/src/utils/url-generator.coffee +++ b/src/utils/url-generator.coffee @@ -22,9 +22,10 @@ createEntryPoint = (s) -> createDataQuery = (query, service) -> url = createEntryPoint service - url = url + "data/#{query.flow}/#{query.key}/#{query.provider}" - url = url + "?dimensionAtObservation=#{query.obsDimension}" - url = url + "&detail=#{query.detail}" + url = url + "data/#{query.flow}/#{query.key}/#{query.provider}?" + if query.obsDimension + url = url + "dimensionAtObservation=#{query.obsDimension}&" + url = url + "detail=#{query.detail}" if (service.api isnt ApiVersion.v1_0_0 and service.api isnt ApiVersion.v1_0_1 and service.api isnt ApiVersion.v1_0_2) @@ -50,8 +51,7 @@ hasHistory = (q, s) -> handleDataQueryParams = (q, s) -> p = [] - p.push "dimensionAtObservation=#{q.obsDimension}" unless \ - q.obsDimension is 'TIME_PERIOD' + p.push "dimensionAtObservation=#{q.obsDimension}" if q.obsDimension p.push "detail=#{q.detail}" unless q.detail is 'full' p.push "includeHistory=#{q.history}" if hasHistory(q, s) p.push "startPeriod=#{q.start}" if q.start diff --git a/test/data/data-query.test.coffee b/test/data/data-query.test.coffee index 02e3994..c41d062 100644 --- a/test/data/data-query.test.coffee +++ b/test/data/data-query.test.coffee @@ -31,7 +31,7 @@ describe 'Data queries', -> q.should.have.property('updatedAfter').that.is.undefined q.should.have.property('firstNObs').that.is.undefined q.should.have.property('lastNObs').that.is.undefined - q.should.have.property('obsDimension').that.equals 'TIME_PERIOD' + q.should.have.property('obsDimension').that.is.undefined q.should.have.property('detail').that.equals 'full' q.should.have.property('history').that.is.false diff --git a/test/index.test.coffee b/test/index.test.coffee index e8d9abc..a4518b1 100644 --- a/test/index.test.coffee +++ b/test/index.test.coffee @@ -108,7 +108,7 @@ describe 'API', -> query.should.have.property('updatedAfter').that.is.undefined query.should.have.property('firstNObs').that.is.undefined query.should.have.property('lastNObs').that.is.undefined - query.should.have.property('obsDimension').that.equals 'TIME_PERIOD' + query.should.have.property('obsDimension').that.is.undefined query.should.have.property('detail').that.equals 'full' query.should.have.property('history').that.is.false diff --git a/test/utils/url-generator.test.coffee b/test/utils/url-generator.test.coffee index 4411351..c71ca21 100644 --- a/test/utils/url-generator.test.coffee +++ b/test/utils/url-generator.test.coffee @@ -371,7 +371,7 @@ describe 'URL Generator', -> it 'generates a URL for a partial data query', -> expected = "http://test.com/data/EXR/A..EUR.SP00.A/all?\ - dimensionAtObservation=TIME_PERIOD&detail=full&includeHistory=false" + detail=full&includeHistory=false" query = DataQuery.from({flow: 'EXR', key: 'A..EUR.SP00.A'}) service = Service.from({url: 'http://test.com', api: ApiVersion.v1_1_0}) url = new UrlGenerator().getUrl(query, service)