@nsshunt/stsfhirclient 1.0.68 → 1.0.70
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/stsfhirclient.mjs +110 -55
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +110 -55
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/FhirClient.d.ts.map +1 -1
- package/types/srv_dev/stsfhircontrollertestcasesclient.d.ts +1 -0
- package/types/srv_dev/stsfhircontrollertestcasesclient.d.ts.map +1 -1
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value2) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value2);
|
|
10
10
|
var __privateSet = (obj, member, value2, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value2) : member.set(obj, value2), value2);
|
|
11
|
-
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER,
|
|
11
|
+
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER, _stsfhirapiroot, _fhirSocketClient, _LogDebugMessage, _HandleError, _BuildQueryString, _InvokeResourceAPI;
|
|
12
12
|
import axios from "axios";
|
|
13
13
|
import { defaultLogger, Sleep, STSAxiosConfig } from "@nsshunt/stsutils";
|
|
14
14
|
const isNode$1 = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
@@ -5419,22 +5419,12 @@ class FhirClient {
|
|
|
5419
5419
|
__privateAdd(this, _options3);
|
|
5420
5420
|
__privateAdd(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
|
|
5421
5421
|
//@@ needs to come from headers ??
|
|
5422
|
-
__privateAdd(this, _invokeMethods, {});
|
|
5423
|
-
__privateAdd(this, _maxRetries, 5);
|
|
5424
|
-
__privateAdd(this, _sleepDuration, [50, 100, 200, 500, 1e3, 2e3, 5e3]);
|
|
5425
|
-
__privateAdd(this, _NoRetryStatusCodes, [
|
|
5426
|
-
StatusCodes.NOT_FOUND,
|
|
5427
|
-
StatusCodes.CONFLICT
|
|
5428
|
-
]);
|
|
5429
5422
|
__privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
5430
5423
|
// Default value
|
|
5431
5424
|
__privateAdd(this, _fhirSocketClient);
|
|
5432
5425
|
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
5433
5426
|
__privateGet(this, _options3).logger.debug(message);
|
|
5434
5427
|
});
|
|
5435
|
-
__privateAdd(this, _LogErrorMessage, (message) => {
|
|
5436
|
-
__privateGet(this, _options3).logger.error(message);
|
|
5437
|
-
});
|
|
5438
5428
|
__privateAdd(this, _HandleError, (error) => {
|
|
5439
5429
|
__privateGet(this, _LogDebugMessage).call(this, chalk.red(`HandleError(): Error: [${error}]`));
|
|
5440
5430
|
let responseCode = 500;
|
|
@@ -5449,17 +5439,11 @@ class FhirClient {
|
|
|
5449
5439
|
}
|
|
5450
5440
|
return responseCode;
|
|
5451
5441
|
});
|
|
5452
|
-
__privateAdd(this,
|
|
5453
|
-
const
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
}
|
|
5458
|
-
if (retries < 2) {
|
|
5459
|
-
errorCb(500, new Error(`Testing Error Only. Error Code: [500], Message ID: [${id}, url: [${url2}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
5460
|
-
return true;
|
|
5461
|
-
}
|
|
5462
|
-
return false;
|
|
5442
|
+
__privateAdd(this, _BuildQueryString, (baseUrl, queryParams) => {
|
|
5443
|
+
const url2 = new URL(baseUrl);
|
|
5444
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
5445
|
+
url2.search = searchParams.toString();
|
|
5446
|
+
return url2.toString();
|
|
5463
5447
|
});
|
|
5464
5448
|
__privateAdd(this, _InvokeResourceAPI, async (url2, httpVerb, domainResource, filters) => {
|
|
5465
5449
|
const accessToken = await __privateGet(this, _options3).GetAccessToken();
|
|
@@ -5476,19 +5460,28 @@ class FhirClient {
|
|
|
5476
5460
|
var _a;
|
|
5477
5461
|
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a = error.response) == null ? void 0 : _a.status)}`);
|
|
5478
5462
|
}
|
|
5463
|
+
// Below works also ...
|
|
5479
5464
|
//stsAxiosConfig: requestConfig
|
|
5480
5465
|
});
|
|
5481
5466
|
return await api(url2, requestConfig.config);
|
|
5482
5467
|
});
|
|
5483
5468
|
__publicField(this, "GetResource", async (resource, id, filters) => {
|
|
5484
5469
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5470
|
+
try {
|
|
5471
|
+
const retVal = await __privateGet(this, _fhirSocketClient).GetResource(resource, id);
|
|
5472
|
+
if (retVal.status === StatusCodes.OK) {
|
|
5473
|
+
return retVal.value;
|
|
5474
|
+
} else {
|
|
5475
|
+
const errorResponse = new Error(`GetResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.OK}]`);
|
|
5476
|
+
errorResponse.response = {
|
|
5477
|
+
status: retVal.status
|
|
5478
|
+
};
|
|
5479
|
+
throw errorResponse;
|
|
5480
|
+
}
|
|
5481
|
+
} catch (error) {
|
|
5482
|
+
const errorResponse = new Error(`GetResource(): Error: [${error}]`);
|
|
5490
5483
|
errorResponse.response = {
|
|
5491
|
-
status:
|
|
5484
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5492
5485
|
};
|
|
5493
5486
|
throw errorResponse;
|
|
5494
5487
|
}
|
|
@@ -5502,15 +5495,17 @@ class FhirClient {
|
|
|
5502
5495
|
}
|
|
5503
5496
|
}
|
|
5504
5497
|
});
|
|
5505
|
-
__privateAdd(this, _BuildQueryString, (baseUrl, queryParams) => {
|
|
5506
|
-
const url2 = new URL(baseUrl);
|
|
5507
|
-
const searchParams = new URLSearchParams(queryParams);
|
|
5508
|
-
url2.search = searchParams.toString();
|
|
5509
|
-
return url2.toString();
|
|
5510
|
-
});
|
|
5511
5498
|
__publicField(this, "GetResources", async (resource, filters, searchParams) => {
|
|
5512
5499
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5513
|
-
|
|
5500
|
+
try {
|
|
5501
|
+
return __privateGet(this, _fhirSocketClient).GetResources(resource, searchParams);
|
|
5502
|
+
} catch (error) {
|
|
5503
|
+
const errorResponse = new Error(`GetResources(): Error: [${error}]`);
|
|
5504
|
+
errorResponse.response = {
|
|
5505
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5506
|
+
};
|
|
5507
|
+
throw errorResponse;
|
|
5508
|
+
}
|
|
5514
5509
|
} else {
|
|
5515
5510
|
let url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5516
5511
|
if (searchParams) {
|
|
@@ -5526,13 +5521,21 @@ class FhirClient {
|
|
|
5526
5521
|
});
|
|
5527
5522
|
__publicField(this, "CreateResource", async (resource, domainResource) => {
|
|
5528
5523
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5524
|
+
try {
|
|
5525
|
+
const retVal = await __privateGet(this, _fhirSocketClient).CreateResource(resource, domainResource);
|
|
5526
|
+
if (retVal.status === StatusCodes.CREATED) {
|
|
5527
|
+
return retVal.value;
|
|
5528
|
+
} else {
|
|
5529
|
+
const errorResponse = new Error(`CreateResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5530
|
+
errorResponse.response = {
|
|
5531
|
+
status: retVal.status
|
|
5532
|
+
};
|
|
5533
|
+
throw errorResponse;
|
|
5534
|
+
}
|
|
5535
|
+
} catch (error) {
|
|
5536
|
+
const errorResponse = new Error(`CreateResource(): Error: [${error}]`);
|
|
5534
5537
|
errorResponse.response = {
|
|
5535
|
-
status:
|
|
5538
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5536
5539
|
};
|
|
5537
5540
|
throw errorResponse;
|
|
5538
5541
|
}
|
|
@@ -5552,7 +5555,15 @@ class FhirClient {
|
|
|
5552
5555
|
});
|
|
5553
5556
|
__publicField(this, "UpdateResource", async (resource, domainResource) => {
|
|
5554
5557
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5555
|
-
|
|
5558
|
+
try {
|
|
5559
|
+
return __privateGet(this, _fhirSocketClient).UpdateResource(resource, domainResource);
|
|
5560
|
+
} catch (error) {
|
|
5561
|
+
const errorResponse = new Error(`UpdateResource(): Error: [${error}]`);
|
|
5562
|
+
errorResponse.response = {
|
|
5563
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5564
|
+
};
|
|
5565
|
+
throw errorResponse;
|
|
5566
|
+
}
|
|
5556
5567
|
} else {
|
|
5557
5568
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5558
5569
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResource, null);
|
|
@@ -5565,7 +5576,15 @@ class FhirClient {
|
|
|
5565
5576
|
});
|
|
5566
5577
|
__publicField(this, "UpdateResources", async (resource, domainResources) => {
|
|
5567
5578
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5568
|
-
|
|
5579
|
+
try {
|
|
5580
|
+
return __privateGet(this, _fhirSocketClient).UpdateResources(resource, domainResources);
|
|
5581
|
+
} catch (error) {
|
|
5582
|
+
const errorResponse = new Error(`UpdateResources(): Error: [${error}]`);
|
|
5583
|
+
errorResponse.response = {
|
|
5584
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5585
|
+
};
|
|
5586
|
+
throw errorResponse;
|
|
5587
|
+
}
|
|
5569
5588
|
} else {
|
|
5570
5589
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5571
5590
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null);
|
|
@@ -5578,7 +5597,15 @@ class FhirClient {
|
|
|
5578
5597
|
});
|
|
5579
5598
|
__publicField(this, "PatchResource", async (resource, domainResource) => {
|
|
5580
5599
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5581
|
-
|
|
5600
|
+
try {
|
|
5601
|
+
return __privateGet(this, _fhirSocketClient).PatchResource(resource, domainResource);
|
|
5602
|
+
} catch (error) {
|
|
5603
|
+
const errorResponse = new Error(`PatchResource(): Error: [${error}]`);
|
|
5604
|
+
errorResponse.response = {
|
|
5605
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5606
|
+
};
|
|
5607
|
+
throw errorResponse;
|
|
5608
|
+
}
|
|
5582
5609
|
} else {
|
|
5583
5610
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5584
5611
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null);
|
|
@@ -5591,7 +5618,15 @@ class FhirClient {
|
|
|
5591
5618
|
});
|
|
5592
5619
|
__publicField(this, "PatchResources", async (resource, domainResources) => {
|
|
5593
5620
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5594
|
-
|
|
5621
|
+
try {
|
|
5622
|
+
return __privateGet(this, _fhirSocketClient).PatchResources(resource, domainResources);
|
|
5623
|
+
} catch (error) {
|
|
5624
|
+
const errorResponse = new Error(`PatchResources(): Error: [${error}]`);
|
|
5625
|
+
errorResponse.response = {
|
|
5626
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5627
|
+
};
|
|
5628
|
+
throw errorResponse;
|
|
5629
|
+
}
|
|
5595
5630
|
} else {
|
|
5596
5631
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5597
5632
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null);
|
|
@@ -5604,7 +5639,15 @@ class FhirClient {
|
|
|
5604
5639
|
});
|
|
5605
5640
|
__publicField(this, "DeleteResource", async (resource, id) => {
|
|
5606
5641
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5607
|
-
|
|
5642
|
+
try {
|
|
5643
|
+
return __privateGet(this, _fhirSocketClient).DeleteResource(resource, id);
|
|
5644
|
+
} catch (error) {
|
|
5645
|
+
const errorResponse = new Error(`DeleteResource(): Error: [${error}]`);
|
|
5646
|
+
errorResponse.response = {
|
|
5647
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5648
|
+
};
|
|
5649
|
+
throw errorResponse;
|
|
5650
|
+
}
|
|
5608
5651
|
} else {
|
|
5609
5652
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5610
5653
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", null, null);
|
|
@@ -5617,7 +5660,15 @@ class FhirClient {
|
|
|
5617
5660
|
});
|
|
5618
5661
|
__publicField(this, "DeleteResources", async (resource, domainResources) => {
|
|
5619
5662
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5620
|
-
|
|
5663
|
+
try {
|
|
5664
|
+
return __privateGet(this, _fhirSocketClient).DeleteResources(resource, domainResources);
|
|
5665
|
+
} catch (error) {
|
|
5666
|
+
const errorResponse = new Error(`DeleteResources(): Error: [${error}]`);
|
|
5667
|
+
errorResponse.response = {
|
|
5668
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5669
|
+
};
|
|
5670
|
+
throw errorResponse;
|
|
5671
|
+
}
|
|
5621
5672
|
} else {
|
|
5622
5673
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5623
5674
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null);
|
|
@@ -5635,7 +5686,17 @@ class FhirClient {
|
|
|
5635
5686
|
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5636
5687
|
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5637
5688
|
}
|
|
5638
|
-
|
|
5689
|
+
const api = createRetryAxiosClient({
|
|
5690
|
+
maxRetries: 4,
|
|
5691
|
+
retryDelayMs: 300,
|
|
5692
|
+
retryJitterMs: 150,
|
|
5693
|
+
maxRetryDurationMs: 5e3,
|
|
5694
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5695
|
+
var _a;
|
|
5696
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a = error.response) == null ? void 0 : _a.status)}`);
|
|
5697
|
+
}
|
|
5698
|
+
});
|
|
5699
|
+
return await api(url2, requestConfig.config);
|
|
5639
5700
|
} catch (error) {
|
|
5640
5701
|
__privateGet(this, _HandleError).call(this, error);
|
|
5641
5702
|
}
|
|
@@ -5659,18 +5720,12 @@ class FhirClient {
|
|
|
5659
5720
|
}
|
|
5660
5721
|
_options3 = new WeakMap();
|
|
5661
5722
|
_DUMMY_USER = new WeakMap();
|
|
5662
|
-
_invokeMethods = new WeakMap();
|
|
5663
|
-
_maxRetries = new WeakMap();
|
|
5664
|
-
_sleepDuration = new WeakMap();
|
|
5665
|
-
_NoRetryStatusCodes = new WeakMap();
|
|
5666
5723
|
_stsfhirapiroot = new WeakMap();
|
|
5667
5724
|
_fhirSocketClient = new WeakMap();
|
|
5668
5725
|
_LogDebugMessage = new WeakMap();
|
|
5669
|
-
_LogErrorMessage = new WeakMap();
|
|
5670
5726
|
_HandleError = new WeakMap();
|
|
5671
|
-
_TestMode = new WeakMap();
|
|
5672
|
-
_InvokeResourceAPI = new WeakMap();
|
|
5673
5727
|
_BuildQueryString = new WeakMap();
|
|
5728
|
+
_InvokeResourceAPI = new WeakMap();
|
|
5674
5729
|
export {
|
|
5675
5730
|
FhirClient
|
|
5676
5731
|
};
|