@openfn/language-dhis2 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -24
- package/dist/index.js +10 -24
- package/package.json +1 -1
- package/types/Utils.d.ts +0 -5
package/dist/index.cjs
CHANGED
|
@@ -68,20 +68,6 @@ var CONTENT_TYPES = {
|
|
|
68
68
|
csv: "application/csv",
|
|
69
69
|
xls: "application/vnd.ms-excel"
|
|
70
70
|
};
|
|
71
|
-
var Log = class {
|
|
72
|
-
static success(message) {
|
|
73
|
-
return console.info(`\u2713 Success at ${new Date()}:
|
|
74
|
-
\u221F`, message);
|
|
75
|
-
}
|
|
76
|
-
static warn(message) {
|
|
77
|
-
return console.warn(`\u26A0 Warning at ${new Date()}:
|
|
78
|
-
\u221F`, message);
|
|
79
|
-
}
|
|
80
|
-
static error(message) {
|
|
81
|
-
return console.error(`\u2717 Error at ${new Date()}:
|
|
82
|
-
\u221F`, message);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
71
|
function buildUrl(urlString, hostUrl, apiVersion) {
|
|
86
72
|
const pathSuffix = apiVersion ? `/${apiVersion}${urlString}` : `${urlString}`;
|
|
87
73
|
return hostUrl + "/api" + pathSuffix;
|
|
@@ -280,7 +266,7 @@ function execute(...operations) {
|
|
|
280
266
|
function configMigrationHelper(state) {
|
|
281
267
|
const { hostUrl, apiUrl } = state.configuration;
|
|
282
268
|
if (!hostUrl) {
|
|
283
|
-
|
|
269
|
+
console.warn(
|
|
284
270
|
"DEPRECATION WARNING: Please migrate instance address from `apiUrl` to `hostUrl`."
|
|
285
271
|
);
|
|
286
272
|
state.configuration.hostUrl = apiUrl;
|
|
@@ -300,7 +286,7 @@ import_axios3.default.interceptors.response.use(
|
|
|
300
286
|
message: "Unexpected content returned",
|
|
301
287
|
responseData: response.data
|
|
302
288
|
};
|
|
303
|
-
|
|
289
|
+
console.error(newError.message);
|
|
304
290
|
return Promise.reject(newError);
|
|
305
291
|
}
|
|
306
292
|
}
|
|
@@ -308,7 +294,7 @@ import_axios3.default.interceptors.response.use(
|
|
|
308
294
|
try {
|
|
309
295
|
response = { ...response, data: JSON.parse(response.data) };
|
|
310
296
|
} catch (error) {
|
|
311
|
-
|
|
297
|
+
console.warn("Non-JSON response detected, unable to parse.");
|
|
312
298
|
}
|
|
313
299
|
}
|
|
314
300
|
return response;
|
|
@@ -320,7 +306,7 @@ import_axios3.default.interceptors.response.use(
|
|
|
320
306
|
if ((_b = error.config) == null ? void 0 : _b.data)
|
|
321
307
|
error.config.data = "--REDACTED--";
|
|
322
308
|
const details = (_c = error.response) == null ? void 0 : _c.data;
|
|
323
|
-
|
|
309
|
+
console.error(error.message || "That didn't work.");
|
|
324
310
|
if (details)
|
|
325
311
|
console.log(JSON.stringify(details, null, 2));
|
|
326
312
|
return Promise.reject({
|
|
@@ -346,7 +332,7 @@ function create(resourceType, data, options = {}, callback = false) {
|
|
|
346
332
|
...requestConfig
|
|
347
333
|
}).then((result) => {
|
|
348
334
|
const details = `with response ${JSON.stringify(result.data, null, 2)}`;
|
|
349
|
-
|
|
335
|
+
console.log(`Created ${resolvedResourceType} ${details}`);
|
|
350
336
|
const { location } = result.headers;
|
|
351
337
|
if (location)
|
|
352
338
|
console.log(`Record available @ ${location}`);
|
|
@@ -375,7 +361,7 @@ function update(resourceType, path, data, options = {}, callback = false) {
|
|
|
375
361
|
data: resolvedData,
|
|
376
362
|
...requestConfig
|
|
377
363
|
}).then((result) => {
|
|
378
|
-
|
|
364
|
+
console.log(`Updated ${resolvedResourceType} at ${resolvedPath}`);
|
|
379
365
|
return handleResponse(result, state, callback);
|
|
380
366
|
});
|
|
381
367
|
};
|
|
@@ -395,7 +381,7 @@ function get(resourceType, query, options = {}, callback = false) {
|
|
|
395
381
|
responseType: "json",
|
|
396
382
|
...requestConfig
|
|
397
383
|
}).then((result) => {
|
|
398
|
-
|
|
384
|
+
console.log(`Retrieved ${resolvedResourceType}`);
|
|
399
385
|
return handleResponse(result, state, callback);
|
|
400
386
|
});
|
|
401
387
|
};
|
|
@@ -420,7 +406,7 @@ function upsert(resourceType, query, data, options = {}, callback = false) {
|
|
|
420
406
|
return update(resourceType, path, data, options)(state);
|
|
421
407
|
}
|
|
422
408
|
}).then((result) => {
|
|
423
|
-
|
|
409
|
+
console.log(`Performed a "composed upsert" on ${resourceType}`);
|
|
424
410
|
return handleResponse(result, state, callback);
|
|
425
411
|
});
|
|
426
412
|
};
|
|
@@ -512,7 +498,7 @@ function patch(resourceType, path, data, options = {}, callback = false) {
|
|
|
512
498
|
data: resolvedData,
|
|
513
499
|
...requestConfig
|
|
514
500
|
}).then((result) => {
|
|
515
|
-
|
|
501
|
+
console.log(`Patched ${resolvedResourceType} at ${resolvedPath}`);
|
|
516
502
|
return handleResponse(result, state, callback);
|
|
517
503
|
});
|
|
518
504
|
};
|
|
@@ -538,7 +524,7 @@ function destroy(resourceType, path, data = null, options = {}, callback = false
|
|
|
538
524
|
resolvedData,
|
|
539
525
|
...requestConfig
|
|
540
526
|
}).then((result) => {
|
|
541
|
-
|
|
527
|
+
console.log(`Deleted ${resolvedResourceType} at ${resolvedPath}`);
|
|
542
528
|
return handleResponse(result, state, callback);
|
|
543
529
|
});
|
|
544
530
|
};
|
package/dist/index.js
CHANGED
|
@@ -19,20 +19,6 @@ var CONTENT_TYPES = {
|
|
|
19
19
|
csv: "application/csv",
|
|
20
20
|
xls: "application/vnd.ms-excel"
|
|
21
21
|
};
|
|
22
|
-
var Log = class {
|
|
23
|
-
static success(message) {
|
|
24
|
-
return console.info(`\u2713 Success at ${new Date()}:
|
|
25
|
-
\u221F`, message);
|
|
26
|
-
}
|
|
27
|
-
static warn(message) {
|
|
28
|
-
return console.warn(`\u26A0 Warning at ${new Date()}:
|
|
29
|
-
\u221F`, message);
|
|
30
|
-
}
|
|
31
|
-
static error(message) {
|
|
32
|
-
return console.error(`\u2717 Error at ${new Date()}:
|
|
33
|
-
\u221F`, message);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
22
|
function buildUrl(urlString, hostUrl, apiVersion) {
|
|
37
23
|
const pathSuffix = apiVersion ? `/${apiVersion}${urlString}` : `${urlString}`;
|
|
38
24
|
return hostUrl + "/api" + pathSuffix;
|
|
@@ -247,7 +233,7 @@ function execute(...operations) {
|
|
|
247
233
|
function configMigrationHelper(state) {
|
|
248
234
|
const { hostUrl, apiUrl } = state.configuration;
|
|
249
235
|
if (!hostUrl) {
|
|
250
|
-
|
|
236
|
+
console.warn(
|
|
251
237
|
"DEPRECATION WARNING: Please migrate instance address from `apiUrl` to `hostUrl`."
|
|
252
238
|
);
|
|
253
239
|
state.configuration.hostUrl = apiUrl;
|
|
@@ -267,7 +253,7 @@ axios3.interceptors.response.use(
|
|
|
267
253
|
message: "Unexpected content returned",
|
|
268
254
|
responseData: response.data
|
|
269
255
|
};
|
|
270
|
-
|
|
256
|
+
console.error(newError.message);
|
|
271
257
|
return Promise.reject(newError);
|
|
272
258
|
}
|
|
273
259
|
}
|
|
@@ -275,7 +261,7 @@ axios3.interceptors.response.use(
|
|
|
275
261
|
try {
|
|
276
262
|
response = { ...response, data: JSON.parse(response.data) };
|
|
277
263
|
} catch (error) {
|
|
278
|
-
|
|
264
|
+
console.warn("Non-JSON response detected, unable to parse.");
|
|
279
265
|
}
|
|
280
266
|
}
|
|
281
267
|
return response;
|
|
@@ -287,7 +273,7 @@ axios3.interceptors.response.use(
|
|
|
287
273
|
if ((_b = error.config) == null ? void 0 : _b.data)
|
|
288
274
|
error.config.data = "--REDACTED--";
|
|
289
275
|
const details = (_c = error.response) == null ? void 0 : _c.data;
|
|
290
|
-
|
|
276
|
+
console.error(error.message || "That didn't work.");
|
|
291
277
|
if (details)
|
|
292
278
|
console.log(JSON.stringify(details, null, 2));
|
|
293
279
|
return Promise.reject({
|
|
@@ -313,7 +299,7 @@ function create(resourceType, data, options = {}, callback = false) {
|
|
|
313
299
|
...requestConfig
|
|
314
300
|
}).then((result) => {
|
|
315
301
|
const details = `with response ${JSON.stringify(result.data, null, 2)}`;
|
|
316
|
-
|
|
302
|
+
console.log(`Created ${resolvedResourceType} ${details}`);
|
|
317
303
|
const { location } = result.headers;
|
|
318
304
|
if (location)
|
|
319
305
|
console.log(`Record available @ ${location}`);
|
|
@@ -342,7 +328,7 @@ function update(resourceType, path, data, options = {}, callback = false) {
|
|
|
342
328
|
data: resolvedData,
|
|
343
329
|
...requestConfig
|
|
344
330
|
}).then((result) => {
|
|
345
|
-
|
|
331
|
+
console.log(`Updated ${resolvedResourceType} at ${resolvedPath}`);
|
|
346
332
|
return handleResponse(result, state, callback);
|
|
347
333
|
});
|
|
348
334
|
};
|
|
@@ -362,7 +348,7 @@ function get(resourceType, query, options = {}, callback = false) {
|
|
|
362
348
|
responseType: "json",
|
|
363
349
|
...requestConfig
|
|
364
350
|
}).then((result) => {
|
|
365
|
-
|
|
351
|
+
console.log(`Retrieved ${resolvedResourceType}`);
|
|
366
352
|
return handleResponse(result, state, callback);
|
|
367
353
|
});
|
|
368
354
|
};
|
|
@@ -387,7 +373,7 @@ function upsert(resourceType, query, data, options = {}, callback = false) {
|
|
|
387
373
|
return update(resourceType, path, data, options)(state);
|
|
388
374
|
}
|
|
389
375
|
}).then((result) => {
|
|
390
|
-
|
|
376
|
+
console.log(`Performed a "composed upsert" on ${resourceType}`);
|
|
391
377
|
return handleResponse(result, state, callback);
|
|
392
378
|
});
|
|
393
379
|
};
|
|
@@ -479,7 +465,7 @@ function patch(resourceType, path, data, options = {}, callback = false) {
|
|
|
479
465
|
data: resolvedData,
|
|
480
466
|
...requestConfig
|
|
481
467
|
}).then((result) => {
|
|
482
|
-
|
|
468
|
+
console.log(`Patched ${resolvedResourceType} at ${resolvedPath}`);
|
|
483
469
|
return handleResponse(result, state, callback);
|
|
484
470
|
});
|
|
485
471
|
};
|
|
@@ -505,7 +491,7 @@ function destroy(resourceType, path, data = null, options = {}, callback = false
|
|
|
505
491
|
resolvedData,
|
|
506
492
|
...requestConfig
|
|
507
493
|
}).then((result) => {
|
|
508
|
-
|
|
494
|
+
console.log(`Deleted ${resolvedResourceType} at ${resolvedPath}`);
|
|
509
495
|
return handleResponse(result, state, callback);
|
|
510
496
|
});
|
|
511
497
|
};
|
package/package.json
CHANGED