Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sosna committed Mar 1, 2020
2 parents 467a0e0 + 9058a8d commit 0466727
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions src/data/data-query.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
defaults =
key: 'all'
provider: 'all'
obsDimension: 'TIME_PERIOD'
detail: DataDetail.FULL
history: false

Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/utils/url-generator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/data/data-query.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/index.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/utils/url-generator.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0466727

Please sign in to comment.