@nsshunt/stsfhirclient 1.0.68 → 1.0.69
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 -28
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +110 -28
- 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, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _fhirSocketClient, _LogDebugMessage, _LogErrorMessage, _HandleError, _TestMode,
|
|
11
|
+
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _fhirSocketClient, _LogDebugMessage, _LogErrorMessage, _HandleError, _TestMode, _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]";
|
|
@@ -5461,6 +5461,12 @@ class FhirClient {
|
|
|
5461
5461
|
}
|
|
5462
5462
|
return false;
|
|
5463
5463
|
});
|
|
5464
|
+
__privateAdd(this, _BuildQueryString, (baseUrl, queryParams) => {
|
|
5465
|
+
const url2 = new URL(baseUrl);
|
|
5466
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
5467
|
+
url2.search = searchParams.toString();
|
|
5468
|
+
return url2.toString();
|
|
5469
|
+
});
|
|
5464
5470
|
__privateAdd(this, _InvokeResourceAPI, async (url2, httpVerb, domainResource, filters) => {
|
|
5465
5471
|
const accessToken = await __privateGet(this, _options3).GetAccessToken();
|
|
5466
5472
|
const requestConfig = new STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, __privateGet(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
@@ -5482,13 +5488,21 @@ class FhirClient {
|
|
|
5482
5488
|
});
|
|
5483
5489
|
__publicField(this, "GetResource", async (resource, id, filters) => {
|
|
5484
5490
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5491
|
+
try {
|
|
5492
|
+
const retVal = await __privateGet(this, _fhirSocketClient).GetResource(resource, id);
|
|
5493
|
+
if (retVal.status === StatusCodes.OK) {
|
|
5494
|
+
return retVal.value;
|
|
5495
|
+
} else {
|
|
5496
|
+
const errorResponse = new Error(`GetResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.OK}]`);
|
|
5497
|
+
errorResponse.response = {
|
|
5498
|
+
status: retVal.status
|
|
5499
|
+
};
|
|
5500
|
+
throw errorResponse;
|
|
5501
|
+
}
|
|
5502
|
+
} catch (error) {
|
|
5503
|
+
const errorResponse = new Error(`GetResource(): Error: [${error}]`);
|
|
5490
5504
|
errorResponse.response = {
|
|
5491
|
-
status:
|
|
5505
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5492
5506
|
};
|
|
5493
5507
|
throw errorResponse;
|
|
5494
5508
|
}
|
|
@@ -5502,15 +5516,17 @@ class FhirClient {
|
|
|
5502
5516
|
}
|
|
5503
5517
|
}
|
|
5504
5518
|
});
|
|
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
5519
|
__publicField(this, "GetResources", async (resource, filters, searchParams) => {
|
|
5512
5520
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5513
|
-
|
|
5521
|
+
try {
|
|
5522
|
+
return __privateGet(this, _fhirSocketClient).GetResources(resource, searchParams);
|
|
5523
|
+
} catch (error) {
|
|
5524
|
+
const errorResponse = new Error(`GetResources(): Error: [${error}]`);
|
|
5525
|
+
errorResponse.response = {
|
|
5526
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5527
|
+
};
|
|
5528
|
+
throw errorResponse;
|
|
5529
|
+
}
|
|
5514
5530
|
} else {
|
|
5515
5531
|
let url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5516
5532
|
if (searchParams) {
|
|
@@ -5526,13 +5542,21 @@ class FhirClient {
|
|
|
5526
5542
|
});
|
|
5527
5543
|
__publicField(this, "CreateResource", async (resource, domainResource) => {
|
|
5528
5544
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5545
|
+
try {
|
|
5546
|
+
const retVal = await __privateGet(this, _fhirSocketClient).CreateResource(resource, domainResource);
|
|
5547
|
+
if (retVal.status === StatusCodes.CREATED) {
|
|
5548
|
+
return retVal.value;
|
|
5549
|
+
} else {
|
|
5550
|
+
const errorResponse = new Error(`CreateResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5551
|
+
errorResponse.response = {
|
|
5552
|
+
status: retVal.status
|
|
5553
|
+
};
|
|
5554
|
+
throw errorResponse;
|
|
5555
|
+
}
|
|
5556
|
+
} catch (error) {
|
|
5557
|
+
const errorResponse = new Error(`CreateResource(): Error: [${error}]`);
|
|
5534
5558
|
errorResponse.response = {
|
|
5535
|
-
status:
|
|
5559
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5536
5560
|
};
|
|
5537
5561
|
throw errorResponse;
|
|
5538
5562
|
}
|
|
@@ -5552,7 +5576,15 @@ class FhirClient {
|
|
|
5552
5576
|
});
|
|
5553
5577
|
__publicField(this, "UpdateResource", async (resource, domainResource) => {
|
|
5554
5578
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5555
|
-
|
|
5579
|
+
try {
|
|
5580
|
+
return __privateGet(this, _fhirSocketClient).UpdateResource(resource, domainResource);
|
|
5581
|
+
} catch (error) {
|
|
5582
|
+
const errorResponse = new Error(`UpdateResource(): Error: [${error}]`);
|
|
5583
|
+
errorResponse.response = {
|
|
5584
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5585
|
+
};
|
|
5586
|
+
throw errorResponse;
|
|
5587
|
+
}
|
|
5556
5588
|
} else {
|
|
5557
5589
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5558
5590
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResource, null);
|
|
@@ -5565,7 +5597,15 @@ class FhirClient {
|
|
|
5565
5597
|
});
|
|
5566
5598
|
__publicField(this, "UpdateResources", async (resource, domainResources) => {
|
|
5567
5599
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5568
|
-
|
|
5600
|
+
try {
|
|
5601
|
+
return __privateGet(this, _fhirSocketClient).UpdateResources(resource, domainResources);
|
|
5602
|
+
} catch (error) {
|
|
5603
|
+
const errorResponse = new Error(`UpdateResources(): Error: [${error}]`);
|
|
5604
|
+
errorResponse.response = {
|
|
5605
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5606
|
+
};
|
|
5607
|
+
throw errorResponse;
|
|
5608
|
+
}
|
|
5569
5609
|
} else {
|
|
5570
5610
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5571
5611
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null);
|
|
@@ -5578,7 +5618,15 @@ class FhirClient {
|
|
|
5578
5618
|
});
|
|
5579
5619
|
__publicField(this, "PatchResource", async (resource, domainResource) => {
|
|
5580
5620
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5581
|
-
|
|
5621
|
+
try {
|
|
5622
|
+
return __privateGet(this, _fhirSocketClient).PatchResource(resource, domainResource);
|
|
5623
|
+
} catch (error) {
|
|
5624
|
+
const errorResponse = new Error(`PatchResource(): Error: [${error}]`);
|
|
5625
|
+
errorResponse.response = {
|
|
5626
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5627
|
+
};
|
|
5628
|
+
throw errorResponse;
|
|
5629
|
+
}
|
|
5582
5630
|
} else {
|
|
5583
5631
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5584
5632
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null);
|
|
@@ -5591,7 +5639,15 @@ class FhirClient {
|
|
|
5591
5639
|
});
|
|
5592
5640
|
__publicField(this, "PatchResources", async (resource, domainResources) => {
|
|
5593
5641
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5594
|
-
|
|
5642
|
+
try {
|
|
5643
|
+
return __privateGet(this, _fhirSocketClient).PatchResources(resource, domainResources);
|
|
5644
|
+
} catch (error) {
|
|
5645
|
+
const errorResponse = new Error(`PatchResources(): Error: [${error}]`);
|
|
5646
|
+
errorResponse.response = {
|
|
5647
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5648
|
+
};
|
|
5649
|
+
throw errorResponse;
|
|
5650
|
+
}
|
|
5595
5651
|
} else {
|
|
5596
5652
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5597
5653
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null);
|
|
@@ -5604,7 +5660,15 @@ class FhirClient {
|
|
|
5604
5660
|
});
|
|
5605
5661
|
__publicField(this, "DeleteResource", async (resource, id) => {
|
|
5606
5662
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5607
|
-
|
|
5663
|
+
try {
|
|
5664
|
+
return __privateGet(this, _fhirSocketClient).DeleteResource(resource, id);
|
|
5665
|
+
} catch (error) {
|
|
5666
|
+
const errorResponse = new Error(`DeleteResource(): Error: [${error}]`);
|
|
5667
|
+
errorResponse.response = {
|
|
5668
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5669
|
+
};
|
|
5670
|
+
throw errorResponse;
|
|
5671
|
+
}
|
|
5608
5672
|
} else {
|
|
5609
5673
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5610
5674
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", null, null);
|
|
@@ -5617,7 +5681,15 @@ class FhirClient {
|
|
|
5617
5681
|
});
|
|
5618
5682
|
__publicField(this, "DeleteResources", async (resource, domainResources) => {
|
|
5619
5683
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5620
|
-
|
|
5684
|
+
try {
|
|
5685
|
+
return __privateGet(this, _fhirSocketClient).DeleteResources(resource, domainResources);
|
|
5686
|
+
} catch (error) {
|
|
5687
|
+
const errorResponse = new Error(`DeleteResources(): Error: [${error}]`);
|
|
5688
|
+
errorResponse.response = {
|
|
5689
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5690
|
+
};
|
|
5691
|
+
throw errorResponse;
|
|
5692
|
+
}
|
|
5621
5693
|
} else {
|
|
5622
5694
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5623
5695
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null);
|
|
@@ -5635,7 +5707,17 @@ class FhirClient {
|
|
|
5635
5707
|
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5636
5708
|
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5637
5709
|
}
|
|
5638
|
-
|
|
5710
|
+
const api = createRetryAxiosClient({
|
|
5711
|
+
maxRetries: 4,
|
|
5712
|
+
retryDelayMs: 300,
|
|
5713
|
+
retryJitterMs: 150,
|
|
5714
|
+
maxRetryDurationMs: 5e3,
|
|
5715
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5716
|
+
var _a;
|
|
5717
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a = error.response) == null ? void 0 : _a.status)}`);
|
|
5718
|
+
}
|
|
5719
|
+
});
|
|
5720
|
+
return await api(url2, requestConfig.config);
|
|
5639
5721
|
} catch (error) {
|
|
5640
5722
|
__privateGet(this, _HandleError).call(this, error);
|
|
5641
5723
|
}
|
|
@@ -5669,8 +5751,8 @@ _LogDebugMessage = new WeakMap();
|
|
|
5669
5751
|
_LogErrorMessage = new WeakMap();
|
|
5670
5752
|
_HandleError = new WeakMap();
|
|
5671
5753
|
_TestMode = new WeakMap();
|
|
5672
|
-
_InvokeResourceAPI = new WeakMap();
|
|
5673
5754
|
_BuildQueryString = new WeakMap();
|
|
5755
|
+
_InvokeResourceAPI = new WeakMap();
|
|
5674
5756
|
export {
|
|
5675
5757
|
FhirClient
|
|
5676
5758
|
};
|