From dc37c7145208cb7036e8c2e929b2f1a7ef186eff Mon Sep 17 00:00:00 2001 From: "Elias W. BA" Date: Wed, 26 Jan 2022 16:23:12 +0000 Subject: [PATCH 1/3] Check if result.headers.location exist and display it otherwise avoid it, #55 --- lib/Adaptor.js | 2 +- src/Adaptor.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Adaptor.js b/lib/Adaptor.js index 4b14ef5..9ce11e9 100644 --- a/lib/Adaptor.js +++ b/lib/Adaptor.js @@ -322,7 +322,7 @@ function create(resourceType, data, options = {}, callback = false) { data: (0, _Utils.nestArray)(data, resourceType), ...requestConfig }).then(result => { - _Utils.Log.success(`Created ${resourceType}: ${result.headers.location}`); + _Utils.Log.success(`Created ${resourceType}` + (result.headers.location ? `: ${result.headers.location}` : ``)); return (0, _Utils.handleResponse)(result, state, callback); }); diff --git a/src/Adaptor.js b/src/Adaptor.js index a91c583..9cd1e22 100644 --- a/src/Adaptor.js +++ b/src/Adaptor.js @@ -235,7 +235,10 @@ export function create(resourceType, data, options = {}, callback = false) { data: nestArray(data, resourceType), ...requestConfig, }).then(result => { - Log.success(`Created ${resourceType}: ${result.headers.location}`); + Log.success( + `Created ${resourceType}` + + (result.headers.location ? `: ${result.headers.location}` : ``) + ); return handleResponse(result, state, callback); }); }; From fa8913812164f937647845bca6b170d6ee5e9e8f Mon Sep 17 00:00:00 2001 From: Taylor Downs Date: Thu, 27 Jan 2022 09:50:54 +0000 Subject: [PATCH 2/3] details for create --- lib/Adaptor.js | 7 ++++++- src/Adaptor.js | 11 +++++++---- test/integration.js | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Adaptor.js b/lib/Adaptor.js index 9ce11e9..c9e6f19 100644 --- a/lib/Adaptor.js +++ b/lib/Adaptor.js @@ -322,7 +322,12 @@ function create(resourceType, data, options = {}, callback = false) { data: (0, _Utils.nestArray)(data, resourceType), ...requestConfig }).then(result => { - _Utils.Log.success(`Created ${resourceType}` + (result.headers.location ? `: ${result.headers.location}` : ``)); + const { + location + } = result.headers; + const details = location ? `@ ${location}` : `with response ${JSON.stringify(result.data, null, 2)}`; + + _Utils.Log.success(`Created ${resourceType} ${details}`); return (0, _Utils.handleResponse)(result, state, callback); }); diff --git a/src/Adaptor.js b/src/Adaptor.js index 9cd1e22..7dc6c20 100644 --- a/src/Adaptor.js +++ b/src/Adaptor.js @@ -235,10 +235,13 @@ export function create(resourceType, data, options = {}, callback = false) { data: nestArray(data, resourceType), ...requestConfig, }).then(result => { - Log.success( - `Created ${resourceType}` + - (result.headers.location ? `: ${result.headers.location}` : ``) - ); + const { location } = result.headers; + + const details = location + ? `@ ${location}` + : `with response ${JSON.stringify(result.data, null, 2)}`; + + Log.success(`Created ${resourceType} ${details}`); return handleResponse(result, state, callback); }); }; diff --git a/test/integration.js b/test/integration.js index 833204d..f9a267f 100644 --- a/test/integration.js +++ b/test/integration.js @@ -247,7 +247,7 @@ describe('Integration tests', () => { configuration: { username: 'admin', password: 'district', - hostUrl: 'https://play.dhis2.org/2.36.4', + hostUrl: 'https://play.dhis2.org/2.37.2', }, data: {}, }; From 65cefeac3874ebe2c669c5c9923aaf580562724b Mon Sep 17 00:00:00 2001 From: "Elias W. BA" Date: Fri, 28 Jan 2022 10:10:37 +0000 Subject: [PATCH 3/3] Always log the content of data which has all the import summaries --- lib/Adaptor.js | 6 +++--- src/Adaptor.js | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/Adaptor.js b/lib/Adaptor.js index c9e6f19..6241fe4 100644 --- a/lib/Adaptor.js +++ b/lib/Adaptor.js @@ -323,9 +323,9 @@ function create(resourceType, data, options = {}, callback = false) { ...requestConfig }).then(result => { const { - location - } = result.headers; - const details = location ? `@ ${location}` : `with response ${JSON.stringify(result.data, null, 2)}`; + data + } = result; + const details = `with response ${JSON.stringify(data, null, 2)}`; _Utils.Log.success(`Created ${resourceType} ${details}`); diff --git a/src/Adaptor.js b/src/Adaptor.js index 7dc6c20..d3849da 100644 --- a/src/Adaptor.js +++ b/src/Adaptor.js @@ -235,11 +235,8 @@ export function create(resourceType, data, options = {}, callback = false) { data: nestArray(data, resourceType), ...requestConfig, }).then(result => { - const { location } = result.headers; - - const details = location - ? `@ ${location}` - : `with response ${JSON.stringify(result.data, null, 2)}`; + const { data } = result; + const details = `with response ${JSON.stringify(data, null, 2)}`; Log.success(`Created ${resourceType} ${details}`); return handleResponse(result, state, callback);