@nsshunt/stsfhirclient 1.0.19 → 1.0.21
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.
|
@@ -12,7 +12,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
12
12
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
13
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
14
14
|
|
|
15
|
-
var _options2, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot,
|
|
15
|
+
var _options2, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _agentManager2, _LogDebugMessage, _LogErrorMessage, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
|
|
16
16
|
var byteToHex = [];
|
|
17
17
|
for (var i = 0; i < 256; ++i) {
|
|
18
18
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -1921,7 +1921,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
1921
1921
|
return __privateGet2(obj, member, getter);
|
|
1922
1922
|
}
|
|
1923
1923
|
});
|
|
1924
|
-
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions;
|
|
1924
|
+
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
|
|
1925
1925
|
var ansiStyles$1 = { exports: {} };
|
|
1926
1926
|
var colorName;
|
|
1927
1927
|
var hasRequiredColorName;
|
|
@@ -3562,10 +3562,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3562
3562
|
__privateAdd2(this, _agentResetInterval, null);
|
|
3563
3563
|
__privateAdd2(this, _requestCount, 0);
|
|
3564
3564
|
__privateAdd2(this, _SetupResetInterval, () => {
|
|
3565
|
-
|
|
3566
|
-
this
|
|
3567
|
-
|
|
3568
|
-
|
|
3565
|
+
if (__privateGet2(this, _options).agentResetInterval && __privateGet2(this, _options).agentResetInterval > 0) {
|
|
3566
|
+
__privateSet2(this, _agentResetInterval, setTimeout(() => {
|
|
3567
|
+
this.ResetAgent();
|
|
3568
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3569
|
+
}, __privateGet2(this, _options).agentResetInterval).unref());
|
|
3570
|
+
}
|
|
3569
3571
|
});
|
|
3570
3572
|
__privateAdd2(this, _GetAgentOptions, (https2) => {
|
|
3571
3573
|
let options;
|
|
@@ -3601,6 +3603,22 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3601
3603
|
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3602
3604
|
}
|
|
3603
3605
|
}
|
|
3606
|
+
get agentResetInterval() {
|
|
3607
|
+
return __privateGet2(this, _options).agentResetInterval;
|
|
3608
|
+
}
|
|
3609
|
+
set agentResetInterval(val) {
|
|
3610
|
+
if (__privateGet2(this, _agentResetInterval)) {
|
|
3611
|
+
clearTimeout(__privateGet2(this, _agentResetInterval));
|
|
3612
|
+
}
|
|
3613
|
+
__privateGet2(this, _options).agentResetInterval = val;
|
|
3614
|
+
__privateGet2(this, _SetupResetInterval).call(this);
|
|
3615
|
+
}
|
|
3616
|
+
get agentResetCount() {
|
|
3617
|
+
return __privateGet2(this, _options).agentResetCount;
|
|
3618
|
+
}
|
|
3619
|
+
set agentResetCount(val) {
|
|
3620
|
+
__privateGet2(this, _options).agentResetCount = val;
|
|
3621
|
+
}
|
|
3604
3622
|
IncRequestCount() {
|
|
3605
3623
|
__privateWrapper(this, _requestCount)._++;
|
|
3606
3624
|
if (__privateGet2(this, _options).agentResetCount) {
|
|
@@ -3673,6 +3691,103 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3673
3691
|
_requestCount = /* @__PURE__ */ new WeakMap();
|
|
3674
3692
|
_SetupResetInterval = /* @__PURE__ */ new WeakMap();
|
|
3675
3693
|
_GetAgentOptions = /* @__PURE__ */ new WeakMap();
|
|
3694
|
+
class STSAxiosConfig {
|
|
3695
|
+
/*
|
|
3696
|
+
headers = {
|
|
3697
|
+
'Content-Type': 'application/json',
|
|
3698
|
+
'Authorization': 'Bearer ' + accesss_token,
|
|
3699
|
+
'x-sts_user_id': DUMMY_USER
|
|
3700
|
+
}
|
|
3701
|
+
*/
|
|
3702
|
+
constructor(url, method, headers, timeout) {
|
|
3703
|
+
__privateAdd2(this, _url);
|
|
3704
|
+
__privateAdd2(this, _method);
|
|
3705
|
+
__privateAdd2(this, _headers);
|
|
3706
|
+
__privateAdd2(this, _data);
|
|
3707
|
+
__privateAdd2(this, _agentManager);
|
|
3708
|
+
__privateAdd2(this, _timeout);
|
|
3709
|
+
__privateAdd2(this, _withCredentials);
|
|
3710
|
+
__privateSet2(this, _url, url);
|
|
3711
|
+
__privateSet2(this, _method, method);
|
|
3712
|
+
if (headers !== void 0) {
|
|
3713
|
+
__privateSet2(this, _headers, headers);
|
|
3714
|
+
}
|
|
3715
|
+
if (timeout !== void 0) {
|
|
3716
|
+
__privateSet2(this, _timeout, timeout);
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3720
|
+
withData(data) {
|
|
3721
|
+
__privateSet2(this, _data, data);
|
|
3722
|
+
return this;
|
|
3723
|
+
}
|
|
3724
|
+
// 'Content-Type': 'application/json'
|
|
3725
|
+
withAuthHeaders(accesssToken, stsUserId) {
|
|
3726
|
+
__privateSet2(this, _headers, {
|
|
3727
|
+
"Content-Type": "application/json",
|
|
3728
|
+
"Authorization": "Bearer " + accesssToken
|
|
3729
|
+
});
|
|
3730
|
+
if (stsUserId) {
|
|
3731
|
+
__privateGet2(this, _headers)["x-sts_user_id"] = stsUserId;
|
|
3732
|
+
}
|
|
3733
|
+
return this;
|
|
3734
|
+
}
|
|
3735
|
+
withHeaders(headers) {
|
|
3736
|
+
__privateSet2(this, _headers, headers);
|
|
3737
|
+
return this;
|
|
3738
|
+
}
|
|
3739
|
+
withDefaultHeaders() {
|
|
3740
|
+
__privateSet2(this, _headers, {
|
|
3741
|
+
"Content-Type": "application/json"
|
|
3742
|
+
});
|
|
3743
|
+
return this;
|
|
3744
|
+
}
|
|
3745
|
+
withCredentials() {
|
|
3746
|
+
__privateSet2(this, _withCredentials, true);
|
|
3747
|
+
return this;
|
|
3748
|
+
}
|
|
3749
|
+
withTimeout(timeout) {
|
|
3750
|
+
__privateSet2(this, _timeout, timeout);
|
|
3751
|
+
return this;
|
|
3752
|
+
}
|
|
3753
|
+
withAgentManager(agentManager) {
|
|
3754
|
+
__privateSet2(this, _agentManager, agentManager);
|
|
3755
|
+
return this;
|
|
3756
|
+
}
|
|
3757
|
+
get config() {
|
|
3758
|
+
const retVal = {
|
|
3759
|
+
url: __privateGet2(this, _url),
|
|
3760
|
+
method: __privateGet2(this, _method)
|
|
3761
|
+
};
|
|
3762
|
+
if (__privateGet2(this, _headers)) {
|
|
3763
|
+
retVal.headers = __privateGet2(this, _headers);
|
|
3764
|
+
}
|
|
3765
|
+
if (__privateGet2(this, _agentManager) !== void 0) {
|
|
3766
|
+
if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
|
|
3767
|
+
retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
3768
|
+
} else {
|
|
3769
|
+
retVal.httpAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
if (__privateGet2(this, _data) !== void 0) {
|
|
3773
|
+
retVal.data = __privateGet2(this, _data);
|
|
3774
|
+
}
|
|
3775
|
+
if (__privateGet2(this, _timeout) !== void 0) {
|
|
3776
|
+
retVal.timeout = __privateGet2(this, _timeout);
|
|
3777
|
+
}
|
|
3778
|
+
if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
|
|
3779
|
+
retVal.withCredentials = true;
|
|
3780
|
+
}
|
|
3781
|
+
return retVal;
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
3785
|
+
_method = /* @__PURE__ */ new WeakMap();
|
|
3786
|
+
_headers = /* @__PURE__ */ new WeakMap();
|
|
3787
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
3788
|
+
_agentManager = /* @__PURE__ */ new WeakMap();
|
|
3789
|
+
_timeout = /* @__PURE__ */ new WeakMap();
|
|
3790
|
+
_withCredentials = /* @__PURE__ */ new WeakMap();
|
|
3676
3791
|
class FhirClient {
|
|
3677
3792
|
constructor(options) {
|
|
3678
3793
|
__privateAdd(this, _options2);
|
|
@@ -3687,7 +3802,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3687
3802
|
]);
|
|
3688
3803
|
__privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
3689
3804
|
// Default value
|
|
3690
|
-
__privateAdd(this,
|
|
3805
|
+
__privateAdd(this, _agentManager2, null);
|
|
3691
3806
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3692
3807
|
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
3693
3808
|
__privateGet(this, _options2).logger.debug(message);
|
|
@@ -3750,9 +3865,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3750
3865
|
__privateGet(this, _options2).clientTelemetryEvents.AuthenticationErrorInc();
|
|
3751
3866
|
}
|
|
3752
3867
|
}
|
|
3753
|
-
if (isNode && __privateGet(this,
|
|
3868
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
3754
3869
|
console.error(chalk$2.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
3755
|
-
__privateGet(this,
|
|
3870
|
+
__privateGet(this, _agentManager2).ResetAgent();
|
|
3756
3871
|
}
|
|
3757
3872
|
performRetry = true;
|
|
3758
3873
|
}
|
|
@@ -3811,30 +3926,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3811
3926
|
}
|
|
3812
3927
|
}
|
|
3813
3928
|
const accessToken = await __privateGet(this, _options2).GetAccessToken();
|
|
3814
|
-
const
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
"x-sts_user_id": __privateGet(this, _DUMMY_USER)
|
|
3818
|
-
};
|
|
3819
|
-
const requestConfig = {
|
|
3820
|
-
url,
|
|
3821
|
-
method: httpVerb,
|
|
3822
|
-
headers
|
|
3823
|
-
};
|
|
3824
|
-
if (isNode && __privateGet(this, _agentManager)) {
|
|
3825
|
-
if (__privateGet(this, _agentManager).IsHttps(url)) {
|
|
3826
|
-
requestConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3827
|
-
} else {
|
|
3828
|
-
requestConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3829
|
-
}
|
|
3929
|
+
const requestConfig = new STSAxiosConfig(url, httpVerb).withAuthHeaders(accessToken, __privateGet(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
3930
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
3931
|
+
requestConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
3830
3932
|
}
|
|
3831
|
-
|
|
3832
|
-
requestConfig.data = filters;
|
|
3833
|
-
} else if (domainResource) {
|
|
3834
|
-
requestConfig.data = domainResource;
|
|
3835
|
-
}
|
|
3836
|
-
const retVal = await axios(requestConfig);
|
|
3837
|
-
return retVal;
|
|
3933
|
+
return await axios(requestConfig.config);
|
|
3838
3934
|
} catch (error) {
|
|
3839
3935
|
const responseCode = __privateGet(this, _HandleError).call(this, error);
|
|
3840
3936
|
errorCb(responseCode, error);
|
|
@@ -3930,23 +4026,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3930
4026
|
__publicField(this, "GetLatency", async () => {
|
|
3931
4027
|
const url = `${__privateGet(this, _options2).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/latency`;
|
|
3932
4028
|
try {
|
|
3933
|
-
const
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
const requestConfig = {
|
|
3937
|
-
url,
|
|
3938
|
-
method: "get",
|
|
3939
|
-
headers
|
|
3940
|
-
};
|
|
3941
|
-
if (isNode && __privateGet(this, _agentManager)) {
|
|
3942
|
-
if (__privateGet(this, _agentManager).IsHttps(url)) {
|
|
3943
|
-
requestConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3944
|
-
} else {
|
|
3945
|
-
requestConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
3946
|
-
}
|
|
4029
|
+
const requestConfig = new STSAxiosConfig(url, "get").withDefaultHeaders();
|
|
4030
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
4031
|
+
requestConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
3947
4032
|
}
|
|
3948
|
-
|
|
3949
|
-
return retVal;
|
|
4033
|
+
return await axios(requestConfig.config);
|
|
3950
4034
|
} catch (error) {
|
|
3951
4035
|
__privateGet(this, _HandleError).call(this, error);
|
|
3952
4036
|
}
|
|
@@ -3957,11 +4041,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3957
4041
|
}
|
|
3958
4042
|
if (isNode) {
|
|
3959
4043
|
if (__privateGet(this, _options2).agentOptions) {
|
|
3960
|
-
__privateSet(this,
|
|
4044
|
+
__privateSet(this, _agentManager2, new AgentManager({
|
|
3961
4045
|
agentOptions: __privateGet(this, _options2).agentOptions
|
|
3962
4046
|
}));
|
|
3963
4047
|
} else {
|
|
3964
|
-
__privateSet(this,
|
|
4048
|
+
__privateSet(this, _agentManager2, new AgentManager({}));
|
|
3965
4049
|
}
|
|
3966
4050
|
}
|
|
3967
4051
|
}
|
|
@@ -3976,7 +4060,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
3976
4060
|
_sleepDuration = new WeakMap();
|
|
3977
4061
|
_NoRetryStatusCodes = new WeakMap();
|
|
3978
4062
|
_stsfhirapiroot = new WeakMap();
|
|
3979
|
-
|
|
4063
|
+
_agentManager2 = new WeakMap();
|
|
3980
4064
|
_LogDebugMessage = new WeakMap();
|
|
3981
4065
|
_LogErrorMessage = new WeakMap();
|
|
3982
4066
|
_HandleError = new WeakMap();
|