Comparing version 31.9.1 to 31.9.2
@@ -10,4 +10,2 @@ "use strict"; | ||
var _utils = require("../lib/utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -88,3 +86,3 @@ | ||
var encodedDimensions = dimensions.map(function (_ref2) { | ||
var formattedDimensions = dimensions.map(function (_ref2) { | ||
var dimension = _ref2.dimension, | ||
@@ -94,9 +92,7 @@ items = _ref2.items; | ||
if (Array.isArray(items) && items.length) { | ||
var encodedItems = items.map(_utils.customEncodeURIComponent); | ||
if (options && options.sorted) { | ||
encodedItems.sort(); | ||
items = (0, _sortBy.default)(items); | ||
} | ||
return "".concat(dimension, ":").concat(encodedItems.join(';')); | ||
return "".concat(dimension, ":").concat(items.join(';')); | ||
} | ||
@@ -109,3 +105,3 @@ | ||
}).join('/'); | ||
return "".concat(endPoint, ".").concat(this.format, "?dimension=").concat(encodedDimensions.join('&dimension=')); | ||
return "".concat(endPoint, ".").concat(this.format, "?dimension=").concat(formattedDimensions.join('&dimension=')); | ||
} | ||
@@ -135,3 +131,3 @@ /** | ||
var encodedFilters = filters.map(function (_ref3) { | ||
var formattedFilters = filters.map(function (_ref3) { | ||
var dimension = _ref3.dimension, | ||
@@ -141,9 +137,7 @@ items = _ref3.items; | ||
if (Array.isArray(items) && items.length) { | ||
var encodedItems = items.map(_utils.customEncodeURIComponent); | ||
if (options && options.sorted) { | ||
encodedItems.sort(); | ||
items = (0, _sortBy.default)(items); | ||
} | ||
return "".concat(dimension, ":").concat(encodedItems.join(';')); | ||
return "".concat(dimension, ":").concat(items.join(';')); | ||
} | ||
@@ -155,3 +149,3 @@ | ||
if (filters.length) { | ||
this.parameters.filter = encodedFilters; | ||
this.parameters.filter = formattedFilters; | ||
} | ||
@@ -158,0 +152,0 @@ |
@@ -0,1 +1,9 @@ | ||
## [31.9.2](https://github.com/dhis2/d2/compare/v31.9.1...v31.9.2) (2021-03-22) | ||
### Bug Fixes | ||
* remove encoding of query string for analytics requests DHIS2-10722 ([#284](https://github.com/dhis2/d2/issues/284)) ([c810235](https://github.com/dhis2/d2/commit/c81023554f9a0a0b564f08b8afea35fcce5ca043)) | ||
* remove unused import ([#285](https://github.com/dhis2/d2/issues/285)) ([6e1a408](https://github.com/dhis2/d2/commit/6e1a408da69cb251142af29895dee312d633b386)) | ||
## [31.9.1](https://github.com/dhis2/d2/compare/v31.9.0...v31.9.1) (2021-03-09) | ||
@@ -2,0 +10,0 @@ |
{ | ||
"name": "d2", | ||
"version": "31.9.1", | ||
"version": "31.9.2", | ||
"description": "Javascript library for DHIS2", | ||
@@ -5,0 +5,0 @@ "main": "d2.js", |
import AnalyticsRequestBase from '../AnalyticsRequestBase' | ||
import { customEncodeURIComponent } from '../../lib/utils' | ||
jest.mock('../../lib/utils', () => ({ | ||
customEncodeURIComponent: jest.fn(x => `<${x}>`), | ||
})) | ||
const endPoint = 'foo' | ||
@@ -19,2 +14,3 @@ const path = 'bar' | ||
{ dimension: 'answer', items: ['42'] }, | ||
{ dimension: 'space', items: ['in between'] }, | ||
] | ||
@@ -35,12 +31,7 @@ const buildRequest = overrides => { | ||
describe('AnalyticsRequestBase', () => { | ||
beforeEach(() => { | ||
customEncodeURIComponent.mockClear() | ||
}) | ||
it('Should build a URL of encoded dimension parameters', () => { | ||
it('Should build a URL of dimension parameters', () => { | ||
const request = buildRequest({ dimensions }) | ||
const url = request.buildUrl() | ||
expect(customEncodeURIComponent).toHaveBeenCalledTimes(4) | ||
expect(url).toBe( | ||
`${basePath}?dimension=ou:<mars>;<earth>&dimension=dx:<population>&dimension=question&dimension=answer:<42>` | ||
`${basePath}?dimension=ou:mars;earth&dimension=dx:population&dimension=question&dimension=answer:42&dimension=space:in between` | ||
) | ||
@@ -52,5 +43,4 @@ }) | ||
const url = request.buildUrl({ sorted: true }) | ||
expect(customEncodeURIComponent).toHaveBeenCalledTimes(4) | ||
expect(url).toBe( | ||
`${basePath}?dimension=answer:<42>&dimension=dx:<population>&dimension=ou:<earth>;<mars>&dimension=question` | ||
`${basePath}?dimension=answer:42&dimension=dx:population&dimension=ou:earth;mars&dimension=question&dimension=space:in between` | ||
) | ||
@@ -62,3 +52,2 @@ }) | ||
const query = request.buildQuery() | ||
expect(customEncodeURIComponent).toHaveBeenCalledTimes(0) | ||
expect(query).toMatchObject({ | ||
@@ -70,3 +59,2 @@ foo: 'bar', | ||
const query2 = request2.buildQuery() | ||
expect(customEncodeURIComponent).toHaveBeenCalledTimes(0) | ||
expect(query2).toMatchObject({ | ||
@@ -77,13 +65,13 @@ foo: 'bar', | ||
it('Should build a query with encoded filter parameters', () => { | ||
it('Should build a query with filter parameters', () => { | ||
const request = buildRequest({ filters: dimensions }) | ||
const query = request.buildQuery() | ||
expect(customEncodeURIComponent).toHaveBeenCalledTimes(4) | ||
expect(query).toMatchObject({ | ||
foo: 'bar', | ||
filter: [ | ||
'ou:<mars>;<earth>', | ||
'dx:<population>', | ||
'ou:mars;earth', | ||
'dx:population', | ||
'question', | ||
'answer:<42>', | ||
'answer:42', | ||
'space:in between', | ||
], | ||
@@ -96,10 +84,10 @@ }) | ||
const query = request.buildQuery({ sorted: true }) | ||
expect(customEncodeURIComponent).toHaveBeenCalledTimes(4) | ||
expect(query).toMatchObject({ | ||
foo: 'bar', | ||
filter: [ | ||
'answer:<42>', | ||
'dx:<population>', | ||
'ou:<earth>;<mars>', | ||
'answer:42', | ||
'dx:population', | ||
'ou:earth;mars', | ||
'question', | ||
'space:in between', | ||
], | ||
@@ -106,0 +94,0 @@ }) |
import sortBy from 'lodash/sortBy' | ||
import { customEncodeURIComponent } from '../lib/utils' | ||
@@ -54,11 +53,9 @@ /** | ||
} | ||
const encodedDimensions = dimensions.map(({ dimension, items }) => { | ||
const formattedDimensions = dimensions.map(({ dimension, items }) => { | ||
if (Array.isArray(items) && items.length) { | ||
const encodedItems = items.map(customEncodeURIComponent) | ||
if (options && options.sorted) { | ||
encodedItems.sort() | ||
items = sortBy(items) | ||
} | ||
return `${dimension}:${encodedItems.join(';')}` | ||
return `${dimension}:${items.join(';')}` | ||
} | ||
@@ -73,3 +70,3 @@ | ||
return `${endPoint}.${this.format}?dimension=${encodedDimensions.join( | ||
return `${endPoint}.${this.format}?dimension=${formattedDimensions.join( | ||
'&dimension=' | ||
@@ -99,10 +96,9 @@ )}` | ||
const encodedFilters = filters.map(({ dimension, items }) => { | ||
const formattedFilters = filters.map(({ dimension, items }) => { | ||
if (Array.isArray(items) && items.length) { | ||
const encodedItems = items.map(customEncodeURIComponent) | ||
if (options && options.sorted) { | ||
encodedItems.sort() | ||
items = sortBy(items) | ||
} | ||
return `${dimension}:${encodedItems.join(';')}` | ||
return `${dimension}:${items.join(';')}` | ||
} | ||
@@ -114,3 +110,3 @@ | ||
if (filters.length) { | ||
this.parameters.filter = encodedFilters | ||
this.parameters.filter = formattedFilters | ||
} | ||
@@ -117,0 +113,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6429044
44470