@nsshunt/ststestrunner 1.0.63 → 1.0.65
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/ststestrunner.mjs +396 -510
- package/dist/ststestrunner.mjs.map +1 -1
- package/dist/ststestrunner.umd.js +396 -510
- package/dist/ststestrunner.umd.js.map +1 -1
- package/package.json +6 -6
- package/types/setupFhirTestResources.d.ts.map +1 -1
- package/types/startUpDelFhirResources.d.ts.map +1 -1
- package/types/testCaseFhir01.d.ts +5 -9
- package/types/testCaseFhir01.d.ts.map +1 -1
- package/types/testCaseFhir02.d.ts +5 -9
- package/types/testCaseFhir02.d.ts.map +1 -1
- package/types/testCaseFhir03.d.ts +5 -9
- package/types/testCaseFhir03.d.ts.map +1 -1
- package/types/testCaseFhir04.d.ts +5 -9
- package/types/testCaseFhir04.d.ts.map +1 -1
- package/types/testCaseFhir05.d.ts +5 -9
- package/types/testCaseFhir05.d.ts.map +1 -1
- package/types/testCaseFhir06.d.ts +2 -2
- package/types/testCaseFhir06.d.ts.map +1 -1
- package/types/testCaseFhir07.d.ts +2 -2
- package/types/testCaseFhir07.d.ts.map +1 -1
- package/types/testCaseFhir08.d.ts +2 -2
- package/types/testCaseFhir08.d.ts.map +1 -1
- package/types/testCaseFhir09.d.ts +5 -9
- package/types/testCaseFhir09.d.ts.map +1 -1
- package/types/testCaseFhirBase.d.ts +0 -2
- package/types/testCaseFhirBase.d.ts.map +1 -1
- package/types/testCaseFhirQueryBase.d.ts +3 -2
- package/types/testCaseFhirQueryBase.d.ts.map +1 -1
package/dist/ststestrunner.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
17
17
|
return __privateGet(obj, member, getter);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
var _runner, _workerInstance, _logMessageDataSet, _publishTelemetryTimeout, _publishTelemetryCount, _maxBufferSize, _publishTelemetryTimeoutVal, _color, _randomPastelColour, _TestCase01_instances, GetRandomHexColor_fn, _GetRandomPastelColor, _debug2, _GenLogMessage, _SetupTimeout, _PublishTelemetryData, _ForcePublishTelemetryData, _PublishTelemetry, _OutputLogMessage, _options4,
|
|
20
|
+
var _runner, _workerInstance, _logMessageDataSet, _publishTelemetryTimeout, _publishTelemetryCount, _maxBufferSize, _publishTelemetryTimeoutVal, _color, _randomPastelColour, _TestCase01_instances, GetRandomHexColor_fn, _GetRandomPastelColor, _debug2, _GenLogMessage, _SetupTimeout, _PublishTelemetryData, _ForcePublishTelemetryData, _PublishTelemetry, _OutputLogMessage, _options4, _randomDataRecordset, _runner2, _workerInstance2, _fhirClient, _accesssToken, _clientId, _clientSecret, _publishTelemetryCount2, _maxBufferSize2, _publishTelemetryTimeout2, _publishTelemetryTimeoutVal2, _originRegex, _LogMessage, _PublishTelemetryData2, _ForcePublishTelemetryData2, _SetupTimeout2, _OutputLogMessage2, _ResetAgent, _CheckResetAgent, _debug3, _debug4, _error2, _GetPersonRecord, _runner3, _workerInstance3, _logMessageDataSet2, _publishTelemetryTimeout3, _publishTelemetryCount3, _maxBufferSize3, _publishTelemetryTimeoutVal3, _color2, _randomPastelColour2, _TestStartUp_instances, GetRandomHexColor_fn2, _GetRandomPastelColor2, _debug5, _GenLogMessage2, _SetupTimeout3, _PublishTelemetryData3, _ForcePublishTelemetryData3, _PublishTelemetry2, _OutputLogMessage3, _runner4, _workerInstance4, _logMessageDataSet3, _publishTelemetryTimeout4, _publishTelemetryCount4, _maxBufferSize4, _publishTelemetryTimeoutVal4, _color3, _randomPastelColour3, _TestShutDown_instances, GetRandomHexColor_fn3, _GetRandomPastelColor3, _debug6, _GenLogMessage3, _SetupTimeout4, _PublishTelemetryData4, _ForcePublishTelemetryData4, _PublishTelemetry3, _OutputLogMessage4, _options5, _id2, _clientName2, _wm, _socketUtils2, _debug7, _error3, _info2, _GetKeyPayloadData, _LogPayloadEventRetVal, _EmitStateChange, _SetupRunnerEventHandlers, _HandleAddRunner, _SetupWSSClient2, _OnSocketConnected2, _RegisterSocketEvents, _EmitEvent, _GetSocketEventHandlers;
|
|
21
21
|
import { defaultLogger, Sleep, STSAxiosConfig, AgentManager } from "@nsshunt/stsutils";
|
|
22
22
|
import "@nsshunt/stsobservability";
|
|
23
23
|
import http from "node:http";
|
|
@@ -1642,15 +1642,17 @@ class WorkerInstance {
|
|
|
1642
1642
|
archived: false
|
|
1643
1643
|
};
|
|
1644
1644
|
__privateGet$2(this, _runners)[runner.id].runner.iteration = 0;
|
|
1645
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runner.id, IRunnerState.created);
|
|
1645
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#CreateRunnerEx2RunState", runner.id, IRunnerState.created);
|
|
1646
1646
|
} catch (error) {
|
|
1647
1647
|
__privateGet$2(this, _error$1).call(this, `#CreateRunnerEx2RunState(): [${error}]`);
|
|
1648
1648
|
}
|
|
1649
1649
|
});
|
|
1650
|
-
__privateAdd$2(this, _UpdateRunnerStateById, (id, state) => {
|
|
1650
|
+
__privateAdd$2(this, _UpdateRunnerStateById, (fromContext, id, state) => {
|
|
1651
1651
|
try {
|
|
1652
1652
|
if (__privateGet$2(this, _runners)[id]) {
|
|
1653
|
+
const previousState = __privateGet$2(this, _runners)[id].runner.state;
|
|
1653
1654
|
__privateGet$2(this, _runners)[id].runner.state = state;
|
|
1655
|
+
__privateGet$2(this, _debug$1).call(this, `#UpdateRunnerStateById(): Context: [${fromContext}] Previous State: [${previousState}] New State: [${state}]`);
|
|
1654
1656
|
__privateGet$2(this, _PostMessageToWorkerManagerById).call(this, eIWMessageCommands.RunnerStateChange, id, false);
|
|
1655
1657
|
} else {
|
|
1656
1658
|
__privateGet$2(this, _warn).call(this, `#UpdateRunnerStateById(): Runner ID: [${id}] not found`);
|
|
@@ -1844,7 +1846,7 @@ class WorkerInstance {
|
|
|
1844
1846
|
const { state } = __privateGet$2(this, _runners)[runnerId].runner;
|
|
1845
1847
|
if (state === IRunnerState.created) {
|
|
1846
1848
|
result = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _a2.StartRunner());
|
|
1847
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.running);
|
|
1849
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#StartRunner-1", runnerId, IRunnerState.running);
|
|
1848
1850
|
await Sleep(0);
|
|
1849
1851
|
const startLoop = /* @__PURE__ */ new Date();
|
|
1850
1852
|
const ExecuteLoop = async () => {
|
|
@@ -1885,11 +1887,11 @@ class WorkerInstance {
|
|
|
1885
1887
|
} else {
|
|
1886
1888
|
if (pauseOnComplete === true) {
|
|
1887
1889
|
await ((_b2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _b2.PauseRunner());
|
|
1888
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
|
|
1890
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#StartRunner-2", runnerId, IRunnerState.paused);
|
|
1889
1891
|
ExecuteLoop();
|
|
1890
1892
|
} else {
|
|
1891
1893
|
await ((_c = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _c.Completed());
|
|
1892
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.completed);
|
|
1894
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#StartRunner-3", runnerId, IRunnerState.completed);
|
|
1893
1895
|
}
|
|
1894
1896
|
}
|
|
1895
1897
|
} else {
|
|
@@ -1917,7 +1919,7 @@ class WorkerInstance {
|
|
|
1917
1919
|
const { state } = __privateGet$2(this, _runners)[id].runner;
|
|
1918
1920
|
if (state === IRunnerState.paused || state === IRunnerState.running) {
|
|
1919
1921
|
retVal = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, id)) == null ? void 0 : _a2.StopRunner());
|
|
1920
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, id, IRunnerState.stopped);
|
|
1922
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#StopRunnerByRunnerId", id, IRunnerState.stopped);
|
|
1921
1923
|
}
|
|
1922
1924
|
} else {
|
|
1923
1925
|
__privateGet$2(this, _warn).call(this, `#StopRunnerByRunnerId(): Runner: [${id}] not found`);
|
|
@@ -1945,7 +1947,7 @@ class WorkerInstance {
|
|
|
1945
1947
|
const { state } = __privateGet$2(this, _runners)[runnerId].runner;
|
|
1946
1948
|
if (state === IRunnerState.created || state === IRunnerState.paused || state === IRunnerState.running) {
|
|
1947
1949
|
result = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _a2.TerminateRunner());
|
|
1948
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.terminated);
|
|
1950
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#TerminateRunner", runnerId, IRunnerState.terminated);
|
|
1949
1951
|
}
|
|
1950
1952
|
} else {
|
|
1951
1953
|
__privateGet$2(this, _warn).call(this, `#TerminateRunner(): Runner: [${runnerId}] not found`);
|
|
@@ -1991,7 +1993,7 @@ class WorkerInstance {
|
|
|
1991
1993
|
const { state } = __privateGet$2(this, _runners)[runnerId].runner;
|
|
1992
1994
|
if (state === IRunnerState.running) {
|
|
1993
1995
|
result = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _a2.PauseRunner());
|
|
1994
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
|
|
1996
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#PauseRunner", runnerId, IRunnerState.paused);
|
|
1995
1997
|
}
|
|
1996
1998
|
} else {
|
|
1997
1999
|
__privateGet$2(this, _warn).call(this, `#PauseRunner(): Runner: [${runnerId}] not found`);
|
|
@@ -2010,7 +2012,7 @@ class WorkerInstance {
|
|
|
2010
2012
|
const { state } = __privateGet$2(this, _runners)[runnerId].runner;
|
|
2011
2013
|
if (state === IRunnerState.paused) {
|
|
2012
2014
|
result = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _a2.ResumeRunner());
|
|
2013
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.running);
|
|
2015
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#ResumeRunner", runnerId, IRunnerState.running);
|
|
2014
2016
|
}
|
|
2015
2017
|
} else {
|
|
2016
2018
|
__privateGet$2(this, _warn).call(this, `#ResumeRunner(): Runner: [${runnerId}] not found`);
|
|
@@ -2028,7 +2030,7 @@ class WorkerInstance {
|
|
|
2028
2030
|
if (__privateGet$2(this, _runners)[runnerId]) {
|
|
2029
2031
|
const { state } = __privateGet$2(this, _runners)[runnerId].runner;
|
|
2030
2032
|
if (state === IRunnerState.paused || state === IRunnerState.running) {
|
|
2031
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
|
|
2033
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#ResetRunner", runnerId, IRunnerState.paused);
|
|
2032
2034
|
__privateGet$2(this, _ResetRunnerIterationById).call(this, runnerId);
|
|
2033
2035
|
result = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _a2.ResetRunner());
|
|
2034
2036
|
}
|
|
@@ -2053,7 +2055,7 @@ class WorkerInstance {
|
|
|
2053
2055
|
result = await ((_a2 = __privateGet$2(this, _GetRunnerInstanceById).call(this, runnerId)) == null ? void 0 : _a2.ExecuteRunner());
|
|
2054
2056
|
const newIteration = __privateGet$2(this, _IncRunnerIterationById).call(this, runnerId);
|
|
2055
2057
|
__privateGet$2(this, _debug$1).call(this, `${chalk$2.magenta(` --> runner: [${runnerId}]`)} Next iteration number: [${newIteration}] for next Execute or Resume.`);
|
|
2056
|
-
__privateGet$2(this, _UpdateRunnerStateById).call(this, runnerId, IRunnerState.paused);
|
|
2058
|
+
__privateGet$2(this, _UpdateRunnerStateById).call(this, "#ExecuteRunner", runnerId, IRunnerState.paused);
|
|
2057
2059
|
}
|
|
2058
2060
|
} else {
|
|
2059
2061
|
__privateGet$2(this, _warn).call(this, `#ExecuteRunner(): Runner: [${runnerId}] not found`);
|
|
@@ -6929,41 +6931,7 @@ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Ca
|
|
|
6929
6931
|
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6930
6932
|
var __privateAdd$1 = (obj, member, value2) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value2);
|
|
6931
6933
|
var __privateSet$1 = (obj, member, value2, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value2), value2);
|
|
6932
|
-
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER,
|
|
6933
|
-
const byteToHex$1 = [];
|
|
6934
|
-
for (let i = 0; i < 256; ++i) {
|
|
6935
|
-
byteToHex$1.push((i + 256).toString(16).slice(1));
|
|
6936
|
-
}
|
|
6937
|
-
function unsafeStringify$1(arr, offset = 0) {
|
|
6938
|
-
return (byteToHex$1[arr[offset + 0]] + byteToHex$1[arr[offset + 1]] + byteToHex$1[arr[offset + 2]] + byteToHex$1[arr[offset + 3]] + "-" + byteToHex$1[arr[offset + 4]] + byteToHex$1[arr[offset + 5]] + "-" + byteToHex$1[arr[offset + 6]] + byteToHex$1[arr[offset + 7]] + "-" + byteToHex$1[arr[offset + 8]] + byteToHex$1[arr[offset + 9]] + "-" + byteToHex$1[arr[offset + 10]] + byteToHex$1[arr[offset + 11]] + byteToHex$1[arr[offset + 12]] + byteToHex$1[arr[offset + 13]] + byteToHex$1[arr[offset + 14]] + byteToHex$1[arr[offset + 15]]).toLowerCase();
|
|
6939
|
-
}
|
|
6940
|
-
let getRandomValues$1;
|
|
6941
|
-
const rnds8$1 = new Uint8Array(16);
|
|
6942
|
-
function rng$1() {
|
|
6943
|
-
if (!getRandomValues$1) {
|
|
6944
|
-
if (typeof crypto === "undefined" || !crypto.getRandomValues) {
|
|
6945
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
6946
|
-
}
|
|
6947
|
-
getRandomValues$1 = crypto.getRandomValues.bind(crypto);
|
|
6948
|
-
}
|
|
6949
|
-
return getRandomValues$1(rnds8$1);
|
|
6950
|
-
}
|
|
6951
|
-
const randomUUID$1 = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
6952
|
-
const native$1 = { randomUUID: randomUUID$1 };
|
|
6953
|
-
function v4$1(options, buf, offset) {
|
|
6954
|
-
var _a2;
|
|
6955
|
-
if (native$1.randomUUID && true && !options) {
|
|
6956
|
-
return native$1.randomUUID();
|
|
6957
|
-
}
|
|
6958
|
-
options = options || {};
|
|
6959
|
-
const rnds = options.random ?? ((_a2 = options.rng) == null ? void 0 : _a2.call(options)) ?? rng$1();
|
|
6960
|
-
if (rnds.length < 16) {
|
|
6961
|
-
throw new Error("Random bytes length must be >= 16");
|
|
6962
|
-
}
|
|
6963
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
6964
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
6965
|
-
return unsafeStringify$1(rnds);
|
|
6966
|
-
}
|
|
6934
|
+
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER, _stsfhirapiroot, _fhirSocketClient, _LogDebugMessage, _HandleError, _BuildQueryString, _InvokeResourceAPI;
|
|
6967
6935
|
const isNode$1 = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
6968
6936
|
function getDefaultExportFromCjs(x2) {
|
|
6969
6937
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -11938,6 +11906,40 @@ EstablishSocketConnect_fn$1 = function(name, socketIoCustomPath, onConnectCallBa
|
|
|
11938
11906
|
}
|
|
11939
11907
|
});
|
|
11940
11908
|
};
|
|
11909
|
+
const byteToHex$1 = [];
|
|
11910
|
+
for (let i = 0; i < 256; ++i) {
|
|
11911
|
+
byteToHex$1.push((i + 256).toString(16).slice(1));
|
|
11912
|
+
}
|
|
11913
|
+
function unsafeStringify$1(arr, offset = 0) {
|
|
11914
|
+
return (byteToHex$1[arr[offset + 0]] + byteToHex$1[arr[offset + 1]] + byteToHex$1[arr[offset + 2]] + byteToHex$1[arr[offset + 3]] + "-" + byteToHex$1[arr[offset + 4]] + byteToHex$1[arr[offset + 5]] + "-" + byteToHex$1[arr[offset + 6]] + byteToHex$1[arr[offset + 7]] + "-" + byteToHex$1[arr[offset + 8]] + byteToHex$1[arr[offset + 9]] + "-" + byteToHex$1[arr[offset + 10]] + byteToHex$1[arr[offset + 11]] + byteToHex$1[arr[offset + 12]] + byteToHex$1[arr[offset + 13]] + byteToHex$1[arr[offset + 14]] + byteToHex$1[arr[offset + 15]]).toLowerCase();
|
|
11915
|
+
}
|
|
11916
|
+
let getRandomValues$1;
|
|
11917
|
+
const rnds8$1 = new Uint8Array(16);
|
|
11918
|
+
function rng$1() {
|
|
11919
|
+
if (!getRandomValues$1) {
|
|
11920
|
+
if (typeof crypto === "undefined" || !crypto.getRandomValues) {
|
|
11921
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
11922
|
+
}
|
|
11923
|
+
getRandomValues$1 = crypto.getRandomValues.bind(crypto);
|
|
11924
|
+
}
|
|
11925
|
+
return getRandomValues$1(rnds8$1);
|
|
11926
|
+
}
|
|
11927
|
+
const randomUUID$1 = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
11928
|
+
const native$1 = { randomUUID: randomUUID$1 };
|
|
11929
|
+
function v4$1(options, buf, offset) {
|
|
11930
|
+
var _a2;
|
|
11931
|
+
if (native$1.randomUUID && true && !options) {
|
|
11932
|
+
return native$1.randomUUID();
|
|
11933
|
+
}
|
|
11934
|
+
options = options || {};
|
|
11935
|
+
const rnds = options.random ?? ((_a2 = options.rng) == null ? void 0 : _a2.call(options)) ?? rng$1();
|
|
11936
|
+
if (rnds.length < 16) {
|
|
11937
|
+
throw new Error("Random bytes length must be >= 16");
|
|
11938
|
+
}
|
|
11939
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
11940
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
11941
|
+
return unsafeStringify$1(rnds);
|
|
11942
|
+
}
|
|
11941
11943
|
class FhirSocketClient {
|
|
11942
11944
|
constructor(options) {
|
|
11943
11945
|
__privateAdd$1(this, _socketUtils);
|
|
@@ -12263,25 +12265,84 @@ _error = /* @__PURE__ */ new WeakMap();
|
|
|
12263
12265
|
_info = /* @__PURE__ */ new WeakMap();
|
|
12264
12266
|
_SetupWSSClient = /* @__PURE__ */ new WeakMap();
|
|
12265
12267
|
_OnSocketConnected = /* @__PURE__ */ new WeakMap();
|
|
12268
|
+
function sleep(ms) {
|
|
12269
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
12270
|
+
}
|
|
12271
|
+
function getJitteredDelay(base, jitter) {
|
|
12272
|
+
const random = Math.floor(Math.random() * jitter);
|
|
12273
|
+
return base + random;
|
|
12274
|
+
}
|
|
12275
|
+
function createRetryAxiosClient(retryConfig) {
|
|
12276
|
+
const {
|
|
12277
|
+
maxRetries = 3,
|
|
12278
|
+
retryDelayMs = 300,
|
|
12279
|
+
retryJitterMs = 100,
|
|
12280
|
+
retryMethods = ["get", "head", "put", "delete", "options"],
|
|
12281
|
+
// post, patch
|
|
12282
|
+
retryStatusCodes = [408, 429, 500, 502, 503, 504],
|
|
12283
|
+
retryErrorCodes = [
|
|
12284
|
+
"ECONNRESET",
|
|
12285
|
+
"ETIMEDOUT",
|
|
12286
|
+
"EAI_AGAIN",
|
|
12287
|
+
"ECONNREFUSED",
|
|
12288
|
+
"ENOTFOUND",
|
|
12289
|
+
"EHOSTUNREACH",
|
|
12290
|
+
"EPIPE"
|
|
12291
|
+
],
|
|
12292
|
+
maxRetryDurationMs = 1e4,
|
|
12293
|
+
onRetryAttempt,
|
|
12294
|
+
stsAxiosConfig
|
|
12295
|
+
} = retryConfig || {};
|
|
12296
|
+
const instance = axios.create();
|
|
12297
|
+
instance.interceptors.request.use((config) => {
|
|
12298
|
+
const now = Date.now();
|
|
12299
|
+
config.metadata = {
|
|
12300
|
+
startTime: now,
|
|
12301
|
+
__retryCount: 0
|
|
12302
|
+
};
|
|
12303
|
+
if (stsAxiosConfig) {
|
|
12304
|
+
Object.assign(config, stsAxiosConfig.config);
|
|
12305
|
+
}
|
|
12306
|
+
return config;
|
|
12307
|
+
});
|
|
12308
|
+
instance.interceptors.response.use(
|
|
12309
|
+
(response) => response,
|
|
12310
|
+
async (error) => {
|
|
12311
|
+
var _a2;
|
|
12312
|
+
const config = error.config;
|
|
12313
|
+
if (!config || !config.method || !config.metadata) {
|
|
12314
|
+
return Promise.reject(error);
|
|
12315
|
+
}
|
|
12316
|
+
const now = Date.now();
|
|
12317
|
+
const elapsed = now - config.metadata.startTime;
|
|
12318
|
+
const method = config.method.toLowerCase();
|
|
12319
|
+
const status = (_a2 = error.response) == null ? void 0 : _a2.status;
|
|
12320
|
+
const code = error.code;
|
|
12321
|
+
const isRetryable = retryMethods.includes(method) && (retryErrorCodes.includes(code || "") || retryStatusCodes.includes(status || 0));
|
|
12322
|
+
if (config.metadata.__retryCount < maxRetries && isRetryable && elapsed < maxRetryDurationMs) {
|
|
12323
|
+
config.metadata.__retryCount += 1;
|
|
12324
|
+
const delayBase = retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1);
|
|
12325
|
+
const jitteredDelay = getJitteredDelay(delayBase, retryJitterMs);
|
|
12326
|
+
if (onRetryAttempt) {
|
|
12327
|
+
onRetryAttempt(config.metadata.__retryCount, error, jitteredDelay);
|
|
12328
|
+
}
|
|
12329
|
+
await sleep(jitteredDelay);
|
|
12330
|
+
return instance(config);
|
|
12331
|
+
}
|
|
12332
|
+
return Promise.reject(error);
|
|
12333
|
+
}
|
|
12334
|
+
);
|
|
12335
|
+
return instance;
|
|
12336
|
+
}
|
|
12266
12337
|
class FhirClient {
|
|
12267
12338
|
constructor(options) {
|
|
12268
12339
|
__privateAdd$1(this, _options3);
|
|
12269
12340
|
__privateAdd$1(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
|
|
12270
|
-
__privateAdd$1(this, _invokeMethods, {});
|
|
12271
|
-
__privateAdd$1(this, _maxRetries, 5);
|
|
12272
|
-
__privateAdd$1(this, _sleepDuration, [50, 100, 200, 500, 1e3, 2e3, 5e3]);
|
|
12273
|
-
__privateAdd$1(this, _NoRetryStatusCodes, [
|
|
12274
|
-
StatusCodes.NOT_FOUND,
|
|
12275
|
-
StatusCodes.CONFLICT
|
|
12276
|
-
]);
|
|
12277
12341
|
__privateAdd$1(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
12278
12342
|
__privateAdd$1(this, _fhirSocketClient);
|
|
12279
12343
|
__privateAdd$1(this, _LogDebugMessage, (message) => {
|
|
12280
12344
|
__privateGet$1(this, _options3).logger.debug(message);
|
|
12281
12345
|
});
|
|
12282
|
-
__privateAdd$1(this, _LogErrorMessage, (message) => {
|
|
12283
|
-
__privateGet$1(this, _options3).logger.error(message);
|
|
12284
|
-
});
|
|
12285
12346
|
__privateAdd$1(this, _HandleError, (error) => {
|
|
12286
12347
|
__privateGet$1(this, _LogDebugMessage).call(this, chalk.red(`HandleError(): Error: [${error}]`));
|
|
12287
12348
|
let responseCode = 500;
|
|
@@ -12296,116 +12357,55 @@ class FhirClient {
|
|
|
12296
12357
|
}
|
|
12297
12358
|
return responseCode;
|
|
12298
12359
|
});
|
|
12299
|
-
__privateAdd$1(this,
|
|
12300
|
-
const
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
testFailIndexBefore: 1,
|
|
12305
|
-
url: url2,
|
|
12306
|
-
httpVerb,
|
|
12307
|
-
domainResource,
|
|
12308
|
-
filters,
|
|
12309
|
-
searchParams,
|
|
12310
|
-
errorCb
|
|
12311
|
-
};
|
|
12312
|
-
const InvokeAPI = async (id2) => {
|
|
12313
|
-
const metadataRecord = __privateGet$1(this, _invokeMethods)[id2];
|
|
12314
|
-
let performRetry = false;
|
|
12315
|
-
const returnData = await __privateGet$1(this, ___InvokeResourceAPI).call(this, metadataRecord, (statusCode, error) => {
|
|
12316
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Error: [${error}], Attempt: [${metadataRecord.retries + 1}]`));
|
|
12317
|
-
const noRetryIndex = __privateGet$1(this, _NoRetryStatusCodes).indexOf(statusCode);
|
|
12318
|
-
if (noRetryIndex === -1) {
|
|
12319
|
-
if (statusCode === StatusCodes.UNAUTHORIZED) {
|
|
12320
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
|
|
12321
|
-
__privateGet$1(this, _options3).ResetAccessToken();
|
|
12322
|
-
if (__privateGet$1(this, _options3).clientTelemetryEvents) {
|
|
12323
|
-
__privateGet$1(this, _options3).clientTelemetryEvents.AuthenticationErrorInc();
|
|
12324
|
-
}
|
|
12325
|
-
}
|
|
12326
|
-
if (isNode$1 && __privateGet$1(this, _options3).agentManager) {
|
|
12327
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
12328
|
-
__privateGet$1(this, _options3).agentManager.ResetAgent();
|
|
12329
|
-
}
|
|
12330
|
-
performRetry = true;
|
|
12331
|
-
}
|
|
12332
|
-
});
|
|
12333
|
-
return {
|
|
12334
|
-
response: returnData,
|
|
12335
|
-
retry: performRetry
|
|
12336
|
-
};
|
|
12337
|
-
};
|
|
12338
|
-
let retVal = null;
|
|
12339
|
-
while (__privateGet$1(this, _invokeMethods)[id].retries < __privateGet$1(this, _maxRetries)) {
|
|
12340
|
-
retVal = await InvokeAPI(id);
|
|
12341
|
-
if (retVal.retry === false) {
|
|
12342
|
-
delete __privateGet$1(this, _invokeMethods)[id];
|
|
12343
|
-
break;
|
|
12344
|
-
} else {
|
|
12345
|
-
console.log(`Going to retry. Current attempts: [${__privateGet$1(this, _invokeMethods)[id].retries + 1}]`);
|
|
12346
|
-
console.log(`Sleeping: [${__privateGet$1(this, _sleepDuration)[__privateGet$1(this, _invokeMethods)[id].retries]}]`);
|
|
12347
|
-
await Sleep(__privateGet$1(this, _sleepDuration)[__privateGet$1(this, _invokeMethods)[id].retries]);
|
|
12348
|
-
__privateGet$1(this, _invokeMethods)[id].retries++;
|
|
12349
|
-
if (__privateGet$1(this, _options3).clientTelemetryEvents) {
|
|
12350
|
-
__privateGet$1(this, _options3).clientTelemetryEvents.RetryInc();
|
|
12351
|
-
}
|
|
12352
|
-
}
|
|
12353
|
-
}
|
|
12354
|
-
if (retVal) {
|
|
12355
|
-
if (retVal.retry === true) {
|
|
12356
|
-
errorCb(new Error(`#InvokeResourceAPI(): Max retries exceeded. Max Retries: [${__privateGet$1(this, _invokeMethods)[id].retries}]`));
|
|
12357
|
-
delete __privateGet$1(this, _invokeMethods)[id];
|
|
12358
|
-
return null;
|
|
12359
|
-
} else {
|
|
12360
|
-
return retVal.response;
|
|
12361
|
-
}
|
|
12362
|
-
} else {
|
|
12363
|
-
return null;
|
|
12364
|
-
}
|
|
12365
|
-
});
|
|
12366
|
-
__privateAdd$1(this, _TestMode, (metaData, errorCb) => {
|
|
12367
|
-
const { id, url: url2, httpVerb, filters, retries } = metaData;
|
|
12368
|
-
if (retries < 1) {
|
|
12369
|
-
errorCb(401, new Error(`Testing Error Only. Error Code: [401], Message ID: [${id}, url: [${url2}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
12370
|
-
return true;
|
|
12371
|
-
}
|
|
12372
|
-
if (retries < 2) {
|
|
12373
|
-
errorCb(500, new Error(`Testing Error Only. Error Code: [500], Message ID: [${id}, url: [${url2}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
12374
|
-
return true;
|
|
12375
|
-
}
|
|
12376
|
-
return false;
|
|
12360
|
+
__privateAdd$1(this, _BuildQueryString, (baseUrl, queryParams) => {
|
|
12361
|
+
const url2 = new URL(baseUrl);
|
|
12362
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
12363
|
+
url2.search = searchParams.toString();
|
|
12364
|
+
return url2.toString();
|
|
12377
12365
|
});
|
|
12378
|
-
__privateAdd$1(this,
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
|
|
12384
|
-
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
|
|
12389
|
-
|
|
12366
|
+
__privateAdd$1(this, _InvokeResourceAPI, async (url2, httpVerb, domainResource, filters) => {
|
|
12367
|
+
const accessToken = await __privateGet$1(this, _options3).GetAccessToken();
|
|
12368
|
+
const requestConfig = new STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, __privateGet$1(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
12369
|
+
if (isNode$1 && __privateGet$1(this, _options3).agentManager) {
|
|
12370
|
+
requestConfig.withAgentManager(__privateGet$1(this, _options3).agentManager);
|
|
12371
|
+
}
|
|
12372
|
+
const api = createRetryAxiosClient({
|
|
12373
|
+
maxRetries: 4,
|
|
12374
|
+
retryDelayMs: 300,
|
|
12375
|
+
retryJitterMs: 150,
|
|
12376
|
+
maxRetryDurationMs: 5e3,
|
|
12377
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
12378
|
+
var _a2;
|
|
12379
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a2 = error.response) == null ? void 0 : _a2.status)}`);
|
|
12390
12380
|
}
|
|
12391
|
-
|
|
12392
|
-
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
return null;
|
|
12396
|
-
}
|
|
12381
|
+
// Below works also ...
|
|
12382
|
+
//stsAxiosConfig: requestConfig
|
|
12383
|
+
});
|
|
12384
|
+
return await api(url2, requestConfig.config);
|
|
12397
12385
|
});
|
|
12398
|
-
__publicField2(this, "GetResource", async (resource, id, filters
|
|
12386
|
+
__publicField2(this, "GetResource", async (resource, id, filters) => {
|
|
12399
12387
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12388
|
+
try {
|
|
12389
|
+
const retVal = await __privateGet$1(this, _fhirSocketClient).GetResource(resource, id);
|
|
12390
|
+
if (retVal.status === StatusCodes.OK) {
|
|
12391
|
+
return retVal.value;
|
|
12392
|
+
} else {
|
|
12393
|
+
const errorResponse = new Error(`GetResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.OK}]`);
|
|
12394
|
+
errorResponse.response = {
|
|
12395
|
+
status: retVal.status
|
|
12396
|
+
};
|
|
12397
|
+
throw errorResponse;
|
|
12398
|
+
}
|
|
12399
|
+
} catch (error) {
|
|
12400
|
+
const errorResponse = new Error(`GetResource(): Error: [${error}]`);
|
|
12401
|
+
errorResponse.response = {
|
|
12402
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12403
|
+
};
|
|
12404
|
+
throw errorResponse;
|
|
12405
12405
|
}
|
|
12406
12406
|
} else {
|
|
12407
12407
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
12408
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "get", null, filters
|
|
12408
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "get", null, filters);
|
|
12409
12409
|
if (response) {
|
|
12410
12410
|
return response.data;
|
|
12411
12411
|
} else {
|
|
@@ -12413,21 +12413,23 @@ class FhirClient {
|
|
|
12413
12413
|
}
|
|
12414
12414
|
}
|
|
12415
12415
|
});
|
|
12416
|
-
|
|
12417
|
-
const url2 = new URL(baseUrl);
|
|
12418
|
-
const searchParams = new URLSearchParams(queryParams);
|
|
12419
|
-
url2.search = searchParams.toString();
|
|
12420
|
-
return url2.toString();
|
|
12421
|
-
});
|
|
12422
|
-
__publicField2(this, "GetResources", async (resource, filters, searchParams, errorCb) => {
|
|
12416
|
+
__publicField2(this, "GetResources", async (resource, filters, searchParams) => {
|
|
12423
12417
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12424
|
-
|
|
12418
|
+
try {
|
|
12419
|
+
return __privateGet$1(this, _fhirSocketClient).GetResources(resource, searchParams);
|
|
12420
|
+
} catch (error) {
|
|
12421
|
+
const errorResponse = new Error(`GetResources(): Error: [${error}]`);
|
|
12422
|
+
errorResponse.response = {
|
|
12423
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12424
|
+
};
|
|
12425
|
+
throw errorResponse;
|
|
12426
|
+
}
|
|
12425
12427
|
} else {
|
|
12426
12428
|
let url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}`;
|
|
12427
12429
|
if (searchParams) {
|
|
12428
12430
|
url2 = __privateGet$1(this, _BuildQueryString).call(this, url2, searchParams);
|
|
12429
12431
|
}
|
|
12430
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "get", null, filters
|
|
12432
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "get", null, filters);
|
|
12431
12433
|
if (response) {
|
|
12432
12434
|
return response.data;
|
|
12433
12435
|
} else {
|
|
@@ -12435,36 +12437,54 @@ class FhirClient {
|
|
|
12435
12437
|
}
|
|
12436
12438
|
}
|
|
12437
12439
|
});
|
|
12438
|
-
__publicField2(this, "CreateResource", async (resource, domainResource
|
|
12440
|
+
__publicField2(this, "CreateResource", async (resource, domainResource) => {
|
|
12439
12441
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12442
|
+
try {
|
|
12443
|
+
const retVal = await __privateGet$1(this, _fhirSocketClient).CreateResource(resource, domainResource);
|
|
12444
|
+
if (retVal.status === StatusCodes.CREATED) {
|
|
12445
|
+
return retVal.value;
|
|
12446
|
+
} else {
|
|
12447
|
+
const errorResponse = new Error(`CreateResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.CREATED}]`);
|
|
12448
|
+
errorResponse.response = {
|
|
12449
|
+
status: retVal.status
|
|
12450
|
+
};
|
|
12451
|
+
throw errorResponse;
|
|
12452
|
+
}
|
|
12453
|
+
} catch (error) {
|
|
12454
|
+
const errorResponse = new Error(`CreateResource(): Error: [${error}]`);
|
|
12455
|
+
errorResponse.response = {
|
|
12456
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12457
|
+
};
|
|
12458
|
+
throw errorResponse;
|
|
12446
12459
|
}
|
|
12447
12460
|
} else {
|
|
12448
12461
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}`;
|
|
12449
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "post", domainResource, null
|
|
12462
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "post", domainResource, null);
|
|
12450
12463
|
if (response) {
|
|
12451
12464
|
if (response.status === StatusCodes.CREATED) {
|
|
12452
12465
|
return response.data;
|
|
12453
12466
|
} else {
|
|
12454
|
-
|
|
12455
|
-
return null;
|
|
12467
|
+
throw new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`);
|
|
12456
12468
|
}
|
|
12457
12469
|
} else {
|
|
12458
12470
|
return null;
|
|
12459
12471
|
}
|
|
12460
12472
|
}
|
|
12461
12473
|
});
|
|
12462
|
-
__publicField2(this, "UpdateResource", async (resource, domainResource
|
|
12474
|
+
__publicField2(this, "UpdateResource", async (resource, domainResource) => {
|
|
12463
12475
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12464
|
-
|
|
12476
|
+
try {
|
|
12477
|
+
return __privateGet$1(this, _fhirSocketClient).UpdateResource(resource, domainResource);
|
|
12478
|
+
} catch (error) {
|
|
12479
|
+
const errorResponse = new Error(`UpdateResource(): Error: [${error}]`);
|
|
12480
|
+
errorResponse.response = {
|
|
12481
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12482
|
+
};
|
|
12483
|
+
throw errorResponse;
|
|
12484
|
+
}
|
|
12465
12485
|
} else {
|
|
12466
12486
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
12467
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "put", domainResource, null
|
|
12487
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "put", domainResource, null);
|
|
12468
12488
|
if (response) {
|
|
12469
12489
|
return response.data;
|
|
12470
12490
|
} else {
|
|
@@ -12472,12 +12492,20 @@ class FhirClient {
|
|
|
12472
12492
|
}
|
|
12473
12493
|
}
|
|
12474
12494
|
});
|
|
12475
|
-
__publicField2(this, "UpdateResources", async (resource, domainResources
|
|
12495
|
+
__publicField2(this, "UpdateResources", async (resource, domainResources) => {
|
|
12476
12496
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12477
|
-
|
|
12497
|
+
try {
|
|
12498
|
+
return __privateGet$1(this, _fhirSocketClient).UpdateResources(resource, domainResources);
|
|
12499
|
+
} catch (error) {
|
|
12500
|
+
const errorResponse = new Error(`UpdateResources(): Error: [${error}]`);
|
|
12501
|
+
errorResponse.response = {
|
|
12502
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12503
|
+
};
|
|
12504
|
+
throw errorResponse;
|
|
12505
|
+
}
|
|
12478
12506
|
} else {
|
|
12479
12507
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}`;
|
|
12480
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null
|
|
12508
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null);
|
|
12481
12509
|
if (response) {
|
|
12482
12510
|
return response.data;
|
|
12483
12511
|
} else {
|
|
@@ -12485,12 +12513,20 @@ class FhirClient {
|
|
|
12485
12513
|
}
|
|
12486
12514
|
}
|
|
12487
12515
|
});
|
|
12488
|
-
__publicField2(this, "PatchResource", async (resource, domainResource
|
|
12516
|
+
__publicField2(this, "PatchResource", async (resource, domainResource) => {
|
|
12489
12517
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12490
|
-
|
|
12518
|
+
try {
|
|
12519
|
+
return __privateGet$1(this, _fhirSocketClient).PatchResource(resource, domainResource);
|
|
12520
|
+
} catch (error) {
|
|
12521
|
+
const errorResponse = new Error(`PatchResource(): Error: [${error}]`);
|
|
12522
|
+
errorResponse.response = {
|
|
12523
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12524
|
+
};
|
|
12525
|
+
throw errorResponse;
|
|
12526
|
+
}
|
|
12491
12527
|
} else {
|
|
12492
12528
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
12493
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null
|
|
12529
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null);
|
|
12494
12530
|
if (response) {
|
|
12495
12531
|
return response.data;
|
|
12496
12532
|
} else {
|
|
@@ -12498,12 +12534,20 @@ class FhirClient {
|
|
|
12498
12534
|
}
|
|
12499
12535
|
}
|
|
12500
12536
|
});
|
|
12501
|
-
__publicField2(this, "PatchResources", async (resource, domainResources
|
|
12537
|
+
__publicField2(this, "PatchResources", async (resource, domainResources) => {
|
|
12502
12538
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12503
|
-
|
|
12539
|
+
try {
|
|
12540
|
+
return __privateGet$1(this, _fhirSocketClient).PatchResources(resource, domainResources);
|
|
12541
|
+
} catch (error) {
|
|
12542
|
+
const errorResponse = new Error(`PatchResources(): Error: [${error}]`);
|
|
12543
|
+
errorResponse.response = {
|
|
12544
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12545
|
+
};
|
|
12546
|
+
throw errorResponse;
|
|
12547
|
+
}
|
|
12504
12548
|
} else {
|
|
12505
12549
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}`;
|
|
12506
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null
|
|
12550
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null);
|
|
12507
12551
|
if (response) {
|
|
12508
12552
|
return response.data;
|
|
12509
12553
|
} else {
|
|
@@ -12511,12 +12555,20 @@ class FhirClient {
|
|
|
12511
12555
|
}
|
|
12512
12556
|
}
|
|
12513
12557
|
});
|
|
12514
|
-
__publicField2(this, "DeleteResource", async (resource, id
|
|
12558
|
+
__publicField2(this, "DeleteResource", async (resource, id) => {
|
|
12515
12559
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12516
|
-
|
|
12560
|
+
try {
|
|
12561
|
+
return __privateGet$1(this, _fhirSocketClient).DeleteResource(resource, id);
|
|
12562
|
+
} catch (error) {
|
|
12563
|
+
const errorResponse = new Error(`DeleteResource(): Error: [${error}]`);
|
|
12564
|
+
errorResponse.response = {
|
|
12565
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12566
|
+
};
|
|
12567
|
+
throw errorResponse;
|
|
12568
|
+
}
|
|
12517
12569
|
} else {
|
|
12518
12570
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
12519
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "delete", null, null
|
|
12571
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "delete", null, null);
|
|
12520
12572
|
if (response) {
|
|
12521
12573
|
return response.data;
|
|
12522
12574
|
} else {
|
|
@@ -12524,12 +12576,20 @@ class FhirClient {
|
|
|
12524
12576
|
}
|
|
12525
12577
|
}
|
|
12526
12578
|
});
|
|
12527
|
-
__publicField2(this, "DeleteResources", async (resource, domainResources
|
|
12579
|
+
__publicField2(this, "DeleteResources", async (resource, domainResources) => {
|
|
12528
12580
|
if (__privateGet$1(this, _options3).useSocketClient === true && __privateGet$1(this, _fhirSocketClient)) {
|
|
12529
|
-
|
|
12581
|
+
try {
|
|
12582
|
+
return __privateGet$1(this, _fhirSocketClient).DeleteResources(resource, domainResources);
|
|
12583
|
+
} catch (error) {
|
|
12584
|
+
const errorResponse = new Error(`DeleteResources(): Error: [${error}]`);
|
|
12585
|
+
errorResponse.response = {
|
|
12586
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
12587
|
+
};
|
|
12588
|
+
throw errorResponse;
|
|
12589
|
+
}
|
|
12530
12590
|
} else {
|
|
12531
12591
|
const url2 = `${__privateGet$1(this, _options3).fhirEndpoint}${__privateGet$1(this, _stsfhirapiroot)}/${resource}`;
|
|
12532
|
-
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null
|
|
12592
|
+
const response = await __privateGet$1(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null);
|
|
12533
12593
|
if (response) {
|
|
12534
12594
|
return response.data;
|
|
12535
12595
|
} else {
|
|
@@ -12544,7 +12604,17 @@ class FhirClient {
|
|
|
12544
12604
|
if (isNode$1 && __privateGet$1(this, _options3).agentManager) {
|
|
12545
12605
|
requestConfig.withAgentManager(__privateGet$1(this, _options3).agentManager);
|
|
12546
12606
|
}
|
|
12547
|
-
|
|
12607
|
+
const api = createRetryAxiosClient({
|
|
12608
|
+
maxRetries: 4,
|
|
12609
|
+
retryDelayMs: 300,
|
|
12610
|
+
retryJitterMs: 150,
|
|
12611
|
+
maxRetryDurationMs: 5e3,
|
|
12612
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
12613
|
+
var _a2;
|
|
12614
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a2 = error.response) == null ? void 0 : _a2.status)}`);
|
|
12615
|
+
}
|
|
12616
|
+
});
|
|
12617
|
+
return await api(url2, requestConfig.config);
|
|
12548
12618
|
} catch (error) {
|
|
12549
12619
|
__privateGet$1(this, _HandleError).call(this, error);
|
|
12550
12620
|
}
|
|
@@ -12568,19 +12638,12 @@ class FhirClient {
|
|
|
12568
12638
|
}
|
|
12569
12639
|
_options3 = /* @__PURE__ */ new WeakMap();
|
|
12570
12640
|
_DUMMY_USER = /* @__PURE__ */ new WeakMap();
|
|
12571
|
-
_invokeMethods = /* @__PURE__ */ new WeakMap();
|
|
12572
|
-
_maxRetries = /* @__PURE__ */ new WeakMap();
|
|
12573
|
-
_sleepDuration = /* @__PURE__ */ new WeakMap();
|
|
12574
|
-
_NoRetryStatusCodes = /* @__PURE__ */ new WeakMap();
|
|
12575
12641
|
_stsfhirapiroot = /* @__PURE__ */ new WeakMap();
|
|
12576
12642
|
_fhirSocketClient = /* @__PURE__ */ new WeakMap();
|
|
12577
12643
|
_LogDebugMessage = /* @__PURE__ */ new WeakMap();
|
|
12578
|
-
_LogErrorMessage = /* @__PURE__ */ new WeakMap();
|
|
12579
12644
|
_HandleError = /* @__PURE__ */ new WeakMap();
|
|
12580
|
-
_InvokeResourceAPI = /* @__PURE__ */ new WeakMap();
|
|
12581
|
-
_TestMode = /* @__PURE__ */ new WeakMap();
|
|
12582
|
-
___InvokeResourceAPI = /* @__PURE__ */ new WeakMap();
|
|
12583
12645
|
_BuildQueryString = /* @__PURE__ */ new WeakMap();
|
|
12646
|
+
_InvokeResourceAPI = /* @__PURE__ */ new WeakMap();
|
|
12584
12647
|
class TestCaseFhirBase {
|
|
12585
12648
|
/*
|
|
12586
12649
|
#FHIR_SOCKET_CLIENT_USE = true;
|
|
@@ -12591,8 +12654,6 @@ class TestCaseFhirBase {
|
|
|
12591
12654
|
*/
|
|
12592
12655
|
constructor(workerInstance, runner) {
|
|
12593
12656
|
__privateAdd(this, _options4);
|
|
12594
|
-
//#authUtilsNode: AuthUtilsNode;
|
|
12595
|
-
__privateAdd(this, _agentManager);
|
|
12596
12657
|
__privateAdd(this, _randomDataRecordset, []);
|
|
12597
12658
|
__privateAdd(this, _runner2);
|
|
12598
12659
|
__privateAdd(this, _workerInstance2);
|
|
@@ -12749,6 +12810,9 @@ class TestCaseFhirBase {
|
|
|
12749
12810
|
return __privateGet(this, _accesssToken);
|
|
12750
12811
|
} catch (error) {
|
|
12751
12812
|
const errorTime = performance.now() - startTime;
|
|
12813
|
+
if (__privateGet(this, _fhirClient).options.agentManager) {
|
|
12814
|
+
__privateGet(this, _fhirClient).options.agentManager.ResetAgent();
|
|
12815
|
+
}
|
|
12752
12816
|
__privateGet(this, _runner2).instrumentData.authenticationErrorCount++;
|
|
12753
12817
|
__privateGet(this, _runner2).instrumentData.message.push(chalk$1.red(`GetAccessToken Fail Time: [${errorTime.toString()}]`));
|
|
12754
12818
|
__privateGet(this, _runner2).instrumentData.message.push(chalk$1.red(error.toString()));
|
|
@@ -12793,10 +12857,7 @@ class TestCaseFhirBase {
|
|
|
12793
12857
|
const blocksToLoad = 20;
|
|
12794
12858
|
for (let i = 0; i < blocksToLoad; i++) {
|
|
12795
12859
|
const recordId = `stsres_${blockNum + i}`;
|
|
12796
|
-
const retVal = await __privateGet(this, _fhirClient).GetResource("Person", recordId, null
|
|
12797
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
12798
|
-
console.error(chalk$1.red(`StartTestDataLoad(): Error: [${error}]`));
|
|
12799
|
-
});
|
|
12860
|
+
const retVal = await __privateGet(this, _fhirClient).GetResource("Person", recordId, null);
|
|
12800
12861
|
if (retVal) {
|
|
12801
12862
|
const recordsetData = retVal.address;
|
|
12802
12863
|
const zzz = recordsetData[0];
|
|
@@ -12968,9 +13029,6 @@ class TestCaseFhirBase {
|
|
|
12968
13029
|
*/
|
|
12969
13030
|
}));
|
|
12970
13031
|
}
|
|
12971
|
-
get agentManager() {
|
|
12972
|
-
return __privateGet(this, _agentManager);
|
|
12973
|
-
}
|
|
12974
13032
|
get accesssToken() {
|
|
12975
13033
|
return __privateGet(this, _accesssToken);
|
|
12976
13034
|
}
|
|
@@ -13218,7 +13276,6 @@ class TestCaseFhirBase {
|
|
|
13218
13276
|
*/
|
|
13219
13277
|
}
|
|
13220
13278
|
_options4 = new WeakMap();
|
|
13221
|
-
_agentManager = new WeakMap();
|
|
13222
13279
|
_randomDataRecordset = new WeakMap();
|
|
13223
13280
|
_runner2 = new WeakMap();
|
|
13224
13281
|
_workerInstance2 = new WeakMap();
|
|
@@ -13236,62 +13293,42 @@ _PublishTelemetryData2 = new WeakMap();
|
|
|
13236
13293
|
_ForcePublishTelemetryData2 = new WeakMap();
|
|
13237
13294
|
_SetupTimeout2 = new WeakMap();
|
|
13238
13295
|
_OutputLogMessage2 = new WeakMap();
|
|
13239
|
-
class
|
|
13296
|
+
class TestCaseFhirQueryBase extends TestCaseFhirBase {
|
|
13240
13297
|
constructor(workerInstance, runner) {
|
|
13241
13298
|
super(workerInstance, runner);
|
|
13242
|
-
__publicField(this, "
|
|
13243
|
-
|
|
13244
|
-
|
|
13299
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13300
|
+
return null;
|
|
13301
|
+
});
|
|
13302
|
+
__privateAdd(this, _ResetAgent, (reason) => {
|
|
13303
|
+
if (this.fhirClient.options.agentManager) {
|
|
13304
|
+
const resetMessage = chalk$1.rgb(50, 100, 50)`Iteration: [${this.runner.iteration} #authUtilsNode(): Agent Reset, reason: [${reason}]`;
|
|
13305
|
+
this.runner.instrumentData.message.push(resetMessage);
|
|
13306
|
+
console.log(resetMessage);
|
|
13307
|
+
this.fhirClient.options.agentManager.ResetAgent();
|
|
13245
13308
|
}
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
this.runner.instrumentData.
|
|
13249
|
-
|
|
13250
|
-
this.runner.instrumentData.message.push(chalk$1.green(`Iteration: [${this.runner.iteration} #authUtilsNode(): Agent Reset`));
|
|
13309
|
+
});
|
|
13310
|
+
__privateAdd(this, _CheckResetAgent, () => {
|
|
13311
|
+
if (this.runner.instrumentData.requestCount % this.runner.options.agentResetMod === 0) {
|
|
13312
|
+
__privateGet(this, _ResetAgent).call(this, "agentResetMod triggered");
|
|
13251
13313
|
}
|
|
13252
|
-
const retVal = await this.GetAccessToken();
|
|
13253
|
-
this.Debug(`ExecuteRunner(): RetVal: [${retVal}]`);
|
|
13254
|
-
this.accesssToken = null;
|
|
13255
|
-
this.runner.instrumentData.coreCount = 1;
|
|
13256
|
-
this.runner.instrumentData.requestCount++;
|
|
13257
|
-
this.runner.instrumentData.velocity++;
|
|
13258
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13259
|
-
const end = performance.now();
|
|
13260
|
-
const diff = end - start;
|
|
13261
|
-
this.runner.instrumentData.duration = diff;
|
|
13262
|
-
await this.PublishTelemetry();
|
|
13263
|
-
return true;
|
|
13264
13314
|
});
|
|
13265
|
-
if (this.agentManager) {
|
|
13266
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13267
|
-
}
|
|
13268
|
-
}
|
|
13269
|
-
}
|
|
13270
|
-
class TestCaseFhir02 extends TestCaseFhirBase {
|
|
13271
|
-
constructor(workerInstance, runner) {
|
|
13272
|
-
super(workerInstance, runner);
|
|
13273
13315
|
__publicField(this, "ExecuteRunner", async () => {
|
|
13274
13316
|
if (this.runner.iteration % 100 === 0) {
|
|
13275
|
-
this.Debug(
|
|
13317
|
+
this.Debug(`${this.runner.options.testType} -->> Iteration: ${this.runner.iteration}`);
|
|
13276
13318
|
}
|
|
13277
|
-
const iteration = this.runner.iteration;
|
|
13278
|
-
const start = performance.now();
|
|
13279
|
-
const options = this.runner.options;
|
|
13280
13319
|
if (this.runner.iteration === 0) {
|
|
13281
13320
|
await this.StartTestDataLoad();
|
|
13282
13321
|
}
|
|
13322
|
+
const start = performance.now();
|
|
13283
13323
|
this.runner.instrumentData.activeRequestCount++;
|
|
13284
|
-
|
|
13285
|
-
this.runner.instrumentData.message.push(chalk$1.green(`Iteration: [${iteration} #authUtilsNode(): Agent Reset`));
|
|
13286
|
-
}
|
|
13287
|
-
const personRecord = this.GetPersonRecord(`${options.personPrefix}`, iteration);
|
|
13324
|
+
__privateGet(this, _CheckResetAgent).call(this);
|
|
13288
13325
|
try {
|
|
13289
|
-
|
|
13290
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13291
|
-
this.runner.instrumentData.errorCount++;
|
|
13292
|
-
});
|
|
13326
|
+
await this.ExecuteQuery();
|
|
13293
13327
|
} catch (error) {
|
|
13294
13328
|
this.runner.instrumentData.errorCount++;
|
|
13329
|
+
const message = `TestCaseFhirQueryBase:ExecuteRunner(): TestType: [${this.runner.options.testType}], Error: [${error}]`;
|
|
13330
|
+
this.LogErrorMessage(message);
|
|
13331
|
+
__privateGet(this, _ResetAgent).call(this, message);
|
|
13295
13332
|
}
|
|
13296
13333
|
this.runner.instrumentData.coreCount = 1;
|
|
13297
13334
|
this.runner.instrumentData.requestCount++;
|
|
@@ -13303,76 +13340,49 @@ class TestCaseFhir02 extends TestCaseFhirBase {
|
|
|
13303
13340
|
await this.PublishTelemetry();
|
|
13304
13341
|
return true;
|
|
13305
13342
|
});
|
|
13306
|
-
if (this.agentManager) {
|
|
13307
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13308
|
-
}
|
|
13309
13343
|
}
|
|
13310
13344
|
}
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
}
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13345
|
+
_ResetAgent = new WeakMap();
|
|
13346
|
+
_CheckResetAgent = new WeakMap();
|
|
13347
|
+
class TestCaseFhir01 extends TestCaseFhirQueryBase {
|
|
13348
|
+
constructor() {
|
|
13349
|
+
super(...arguments);
|
|
13350
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13351
|
+
await this.GetAccessToken();
|
|
13352
|
+
this.accesssToken = null;
|
|
13353
|
+
return null;
|
|
13354
|
+
});
|
|
13355
|
+
}
|
|
13356
|
+
}
|
|
13357
|
+
class TestCaseFhir02 extends TestCaseFhirQueryBase {
|
|
13358
|
+
constructor() {
|
|
13359
|
+
super(...arguments);
|
|
13360
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13361
|
+
return await this.fhirClient.CreateResource("Person", this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration));
|
|
13362
|
+
});
|
|
13363
|
+
}
|
|
13364
|
+
}
|
|
13365
|
+
class TestCaseFhir03 extends TestCaseFhirQueryBase {
|
|
13366
|
+
constructor() {
|
|
13367
|
+
super(...arguments);
|
|
13368
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13369
|
+
const personRecord = this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration);
|
|
13370
|
+
const retVal = await this.fhirClient.GetResource("Person", personRecord.id, null);
|
|
13333
13371
|
const p1 = JSON.stringify(personRecord);
|
|
13334
13372
|
const p2 = JSON.stringify(retVal);
|
|
13335
|
-
|
|
13336
|
-
if (compareReocrds !== 0) {
|
|
13373
|
+
if (p1.localeCompare(p2) !== 0) {
|
|
13337
13374
|
this.runner.instrumentData.errorCount++;
|
|
13338
13375
|
}
|
|
13339
|
-
|
|
13340
|
-
this.runner.instrumentData.requestCount++;
|
|
13341
|
-
this.runner.instrumentData.velocity++;
|
|
13342
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13343
|
-
const end = performance.now();
|
|
13344
|
-
const diff = end - start;
|
|
13345
|
-
this.runner.instrumentData.duration = diff;
|
|
13346
|
-
await this.PublishTelemetry();
|
|
13347
|
-
return true;
|
|
13376
|
+
return retVal;
|
|
13348
13377
|
});
|
|
13349
|
-
if (this.agentManager) {
|
|
13350
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13351
|
-
}
|
|
13352
13378
|
}
|
|
13353
13379
|
}
|
|
13354
|
-
class TestCaseFhir04 extends
|
|
13355
|
-
constructor(
|
|
13356
|
-
super(
|
|
13357
|
-
__publicField(this, "
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
}
|
|
13361
|
-
const iteration = this.runner.iteration;
|
|
13362
|
-
const start = performance.now();
|
|
13363
|
-
const options = this.runner.options;
|
|
13364
|
-
if (this.runner.iteration === 0) {
|
|
13365
|
-
await this.StartTestDataLoad();
|
|
13366
|
-
}
|
|
13367
|
-
this.runner.instrumentData.activeRequestCount++;
|
|
13368
|
-
if (this.runner.instrumentData.requestCount % options.agentResetMod === 0) {
|
|
13369
|
-
this.runner.instrumentData.message.push(chalk$1.green(`Iteration: [${iteration} #authUtilsNode(): Agent Reset`));
|
|
13370
|
-
}
|
|
13371
|
-
const personRecord = this.GetPersonRecord(`${options.personPrefix}`, iteration);
|
|
13372
|
-
const originalPersonRecord = await this.fhirClient.GetResource("Person", personRecord.id, null, (error) => {
|
|
13373
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13374
|
-
this.runner.instrumentData.errorCount++;
|
|
13375
|
-
});
|
|
13380
|
+
class TestCaseFhir04 extends TestCaseFhirQueryBase {
|
|
13381
|
+
constructor() {
|
|
13382
|
+
super(...arguments);
|
|
13383
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13384
|
+
const personRecord = this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration);
|
|
13385
|
+
const originalPersonRecord = await this.fhirClient.GetResource("Person", personRecord.id, null);
|
|
13376
13386
|
const p1 = JSON.stringify(personRecord);
|
|
13377
13387
|
const p2 = JSON.stringify(originalPersonRecord);
|
|
13378
13388
|
const compareRecords = p1.localeCompare(p2);
|
|
@@ -13380,132 +13390,52 @@ class TestCaseFhir04 extends TestCaseFhirBase {
|
|
|
13380
13390
|
this.runner.instrumentData.errorCount++;
|
|
13381
13391
|
}
|
|
13382
13392
|
if (originalPersonRecord && originalPersonRecord.text) {
|
|
13383
|
-
originalPersonRecord.text.div = `Updated record ${iteration}`;
|
|
13384
|
-
const retVal = await this.fhirClient.UpdateResource("Person", originalPersonRecord
|
|
13385
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13386
|
-
this.runner.instrumentData.errorCount++;
|
|
13387
|
-
});
|
|
13393
|
+
originalPersonRecord.text.div = `Updated record ${this.runner.iteration}`;
|
|
13394
|
+
const retVal = await this.fhirClient.UpdateResource("Person", originalPersonRecord);
|
|
13388
13395
|
const p12 = JSON.stringify(retVal);
|
|
13389
13396
|
const p22 = JSON.stringify(originalPersonRecord);
|
|
13390
13397
|
const compareRecords2 = p12.localeCompare(p22);
|
|
13391
13398
|
if (compareRecords2 !== 0) {
|
|
13392
13399
|
this.runner.instrumentData.errorCount++;
|
|
13393
13400
|
}
|
|
13401
|
+
return retVal;
|
|
13394
13402
|
} else {
|
|
13395
13403
|
this.runner.instrumentData.errorCount++;
|
|
13404
|
+
return null;
|
|
13396
13405
|
}
|
|
13397
|
-
this.runner.instrumentData.coreCount = 1;
|
|
13398
|
-
this.runner.instrumentData.requestCount++;
|
|
13399
|
-
this.runner.instrumentData.velocity++;
|
|
13400
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13401
|
-
const end = performance.now();
|
|
13402
|
-
const diff = end - start;
|
|
13403
|
-
this.runner.instrumentData.duration = diff;
|
|
13404
|
-
await this.PublishTelemetry();
|
|
13405
|
-
return true;
|
|
13406
13406
|
});
|
|
13407
|
-
if (this.agentManager) {
|
|
13408
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13409
|
-
}
|
|
13410
13407
|
}
|
|
13411
13408
|
}
|
|
13412
|
-
class TestCaseFhir05 extends
|
|
13413
|
-
constructor(
|
|
13414
|
-
super(
|
|
13415
|
-
__publicField(this, "
|
|
13416
|
-
|
|
13417
|
-
this.Debug(`TestCaseFhir05(): -->> Iteration: ${this.runner.iteration}`);
|
|
13418
|
-
}
|
|
13419
|
-
const iteration = this.runner.iteration;
|
|
13420
|
-
const start = performance.now();
|
|
13421
|
-
const options = this.runner.options;
|
|
13422
|
-
if (this.runner.iteration === 0) {
|
|
13423
|
-
await this.StartTestDataLoad();
|
|
13424
|
-
}
|
|
13425
|
-
this.runner.instrumentData.activeRequestCount++;
|
|
13426
|
-
if (this.runner.instrumentData.requestCount % options.agentResetMod === 0) {
|
|
13427
|
-
this.runner.instrumentData.message.push(chalk$1.green(`Iteration: [${iteration} #authUtilsNode(): Agent Reset`));
|
|
13428
|
-
}
|
|
13429
|
-
const personRecord = this.GetPersonRecord(`${options.personPrefix}`, iteration);
|
|
13409
|
+
class TestCaseFhir05 extends TestCaseFhirQueryBase {
|
|
13410
|
+
constructor() {
|
|
13411
|
+
super(...arguments);
|
|
13412
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13413
|
+
const personRecord = this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration);
|
|
13430
13414
|
if (personRecord && personRecord.text) {
|
|
13431
|
-
personRecord.text.div = `Updated record ${iteration}`;
|
|
13432
|
-
const retVal = await this.fhirClient.UpdateResource("Person", personRecord
|
|
13433
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13434
|
-
this.runner.instrumentData.errorCount++;
|
|
13435
|
-
});
|
|
13415
|
+
personRecord.text.div = `Updated record ${this.runner.iteration}`;
|
|
13416
|
+
const retVal = await this.fhirClient.UpdateResource("Person", personRecord);
|
|
13436
13417
|
const p1 = JSON.stringify(retVal);
|
|
13437
13418
|
const p2 = JSON.stringify(personRecord);
|
|
13438
13419
|
const compareRecords = p1.localeCompare(p2);
|
|
13439
13420
|
if (compareRecords !== 0) {
|
|
13440
13421
|
this.runner.instrumentData.errorCount++;
|
|
13441
13422
|
}
|
|
13423
|
+
return retVal;
|
|
13442
13424
|
} else {
|
|
13443
13425
|
this.runner.instrumentData.errorCount++;
|
|
13426
|
+
return null;
|
|
13444
13427
|
}
|
|
13445
|
-
this.runner.instrumentData.coreCount = 1;
|
|
13446
|
-
this.runner.instrumentData.requestCount++;
|
|
13447
|
-
this.runner.instrumentData.velocity++;
|
|
13448
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13449
|
-
const end = performance.now();
|
|
13450
|
-
const diff = end - start;
|
|
13451
|
-
this.runner.instrumentData.duration = diff;
|
|
13452
|
-
await this.PublishTelemetry();
|
|
13453
|
-
return true;
|
|
13454
|
-
});
|
|
13455
|
-
if (this.agentManager) {
|
|
13456
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13457
|
-
}
|
|
13458
|
-
}
|
|
13459
|
-
}
|
|
13460
|
-
class TestCaseFhirQueryBase extends TestCaseFhirBase {
|
|
13461
|
-
constructor(workerInstance, runner) {
|
|
13462
|
-
super(workerInstance, runner);
|
|
13463
|
-
__publicField(this, "ExecuteQuery", async (iteration, fhirClient) => {
|
|
13464
|
-
return null;
|
|
13465
|
-
});
|
|
13466
|
-
__publicField(this, "ExecuteRunner", async () => {
|
|
13467
|
-
if (this.runner.iteration % 100 === 0) {
|
|
13468
|
-
this.Debug(`-->> Iteration: ${this.runner.iteration}`);
|
|
13469
|
-
}
|
|
13470
|
-
const start = performance.now();
|
|
13471
|
-
const options = this.runner.options;
|
|
13472
|
-
this.runner.instrumentData.activeRequestCount++;
|
|
13473
|
-
if (this.runner.instrumentData.requestCount % options.agentResetMod === 0) {
|
|
13474
|
-
this.runner.instrumentData.message.push(chalk$1.green(`Iteration: [${this.runner.iteration} #authUtilsNode(): Agent Reset`));
|
|
13475
|
-
}
|
|
13476
|
-
const retVal = await this.ExecuteQuery(this.runner.iteration, this.fhirClient);
|
|
13477
|
-
if ((retVal == null ? void 0 : retVal.length) === 0) {
|
|
13478
|
-
this.runner.instrumentData.errorCount++;
|
|
13479
|
-
}
|
|
13480
|
-
this.runner.instrumentData.coreCount = 1;
|
|
13481
|
-
this.runner.instrumentData.requestCount++;
|
|
13482
|
-
this.runner.instrumentData.velocity++;
|
|
13483
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13484
|
-
const end = performance.now();
|
|
13485
|
-
const diff = end - start;
|
|
13486
|
-
this.runner.instrumentData.duration = diff;
|
|
13487
|
-
await this.PublishTelemetry();
|
|
13488
|
-
return true;
|
|
13489
13428
|
});
|
|
13490
|
-
if (this.agentManager) {
|
|
13491
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13492
|
-
}
|
|
13493
13429
|
}
|
|
13494
13430
|
}
|
|
13495
13431
|
class TestCaseFhir06 extends TestCaseFhirQueryBase {
|
|
13496
13432
|
constructor() {
|
|
13497
13433
|
super(...arguments);
|
|
13498
|
-
__publicField(this, "ExecuteQuery", async (
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
}
|
|
13502
|
-
const searchLetter = String.fromCharCode(65 + iteration % 26);
|
|
13503
|
-
const retVal = await fhirClient.GetResources("Person", null, {
|
|
13434
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13435
|
+
const searchLetter = String.fromCharCode(65 + this.runner.iteration % 26);
|
|
13436
|
+
const retVal = await this.fhirClient.GetResources("Person", null, {
|
|
13504
13437
|
given: searchLetter,
|
|
13505
13438
|
family: searchLetter
|
|
13506
|
-
}, (error) => {
|
|
13507
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13508
|
-
this.runner.instrumentData.errorCount++;
|
|
13509
13439
|
});
|
|
13510
13440
|
return retVal;
|
|
13511
13441
|
});
|
|
@@ -13514,16 +13444,10 @@ class TestCaseFhir06 extends TestCaseFhirQueryBase {
|
|
|
13514
13444
|
class TestCaseFhir07 extends TestCaseFhirQueryBase {
|
|
13515
13445
|
constructor() {
|
|
13516
13446
|
super(...arguments);
|
|
13517
|
-
__publicField(this, "ExecuteQuery", async (
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
}
|
|
13521
|
-
const searchLetter = String.fromCharCode(65 + iteration % 26);
|
|
13522
|
-
const retVal = await fhirClient.GetResources("Person", null, {
|
|
13447
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13448
|
+
const searchLetter = String.fromCharCode(65 + this.runner.iteration % 26);
|
|
13449
|
+
const retVal = await this.fhirClient.GetResources("Person", null, {
|
|
13523
13450
|
given: searchLetter
|
|
13524
|
-
}, (error) => {
|
|
13525
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13526
|
-
this.runner.instrumentData.errorCount++;
|
|
13527
13451
|
});
|
|
13528
13452
|
return retVal;
|
|
13529
13453
|
});
|
|
@@ -13532,60 +13456,27 @@ class TestCaseFhir07 extends TestCaseFhirQueryBase {
|
|
|
13532
13456
|
class TestCaseFhir08 extends TestCaseFhirQueryBase {
|
|
13533
13457
|
constructor() {
|
|
13534
13458
|
super(...arguments);
|
|
13535
|
-
__publicField(this, "ExecuteQuery", async (
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
}
|
|
13539
|
-
const searchLetter = String.fromCharCode(65 + iteration % 26);
|
|
13540
|
-
const retVal = await fhirClient.GetResources("Person", null, {
|
|
13459
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13460
|
+
const searchLetter = String.fromCharCode(65 + this.runner.iteration % 26);
|
|
13461
|
+
const retVal = await this.fhirClient.GetResources("Person", null, {
|
|
13541
13462
|
family: searchLetter
|
|
13542
|
-
}, (error) => {
|
|
13543
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13544
|
-
this.runner.instrumentData.errorCount++;
|
|
13545
13463
|
});
|
|
13546
13464
|
return retVal;
|
|
13547
13465
|
});
|
|
13548
13466
|
}
|
|
13549
13467
|
}
|
|
13550
|
-
class TestCaseFhir09 extends
|
|
13551
|
-
constructor(
|
|
13552
|
-
super(
|
|
13553
|
-
__publicField(this, "
|
|
13554
|
-
|
|
13555
|
-
this.Debug(`TestCaseFhir09(): -->> Iteration: ${this.runner.iteration}`);
|
|
13556
|
-
}
|
|
13557
|
-
const iteration = this.runner.iteration;
|
|
13558
|
-
const start = performance.now();
|
|
13559
|
-
const options = this.runner.options;
|
|
13560
|
-
if (this.runner.iteration === 0) {
|
|
13561
|
-
await this.StartTestDataLoad();
|
|
13562
|
-
}
|
|
13563
|
-
this.runner.instrumentData.activeRequestCount++;
|
|
13564
|
-
if (this.runner.instrumentData.requestCount % options.agentResetMod === 0) {
|
|
13565
|
-
this.runner.instrumentData.message.push(chalk$1.green(`Iteration: [${iteration} #authUtilsNode(): Agent Reset`));
|
|
13566
|
-
}
|
|
13567
|
-
const personRecord = this.GetPersonRecord(`${options.personPrefix}`, iteration);
|
|
13468
|
+
class TestCaseFhir09 extends TestCaseFhirQueryBase {
|
|
13469
|
+
constructor() {
|
|
13470
|
+
super(...arguments);
|
|
13471
|
+
__publicField(this, "ExecuteQuery", async () => {
|
|
13472
|
+
const personRecord = this.GetPersonRecord(`${this.runner.options.personPrefix}`, this.runner.iteration);
|
|
13568
13473
|
if (personRecord.text) {
|
|
13569
|
-
await this.fhirClient.DeleteResource("Person", personRecord.id
|
|
13570
|
-
this.LogErrorMessage(`test(POST /stsresource and query using filter): ${error}`);
|
|
13571
|
-
this.runner.instrumentData.errorCount++;
|
|
13572
|
-
});
|
|
13474
|
+
return await this.fhirClient.DeleteResource("Person", personRecord.id);
|
|
13573
13475
|
} else {
|
|
13574
13476
|
this.runner.instrumentData.errorCount++;
|
|
13477
|
+
return null;
|
|
13575
13478
|
}
|
|
13576
|
-
this.runner.instrumentData.coreCount = 1;
|
|
13577
|
-
this.runner.instrumentData.requestCount++;
|
|
13578
|
-
this.runner.instrumentData.velocity++;
|
|
13579
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13580
|
-
const end = performance.now();
|
|
13581
|
-
const diff = end - start;
|
|
13582
|
-
this.runner.instrumentData.duration = diff;
|
|
13583
|
-
await this.PublishTelemetry();
|
|
13584
|
-
return true;
|
|
13585
13479
|
});
|
|
13586
|
-
if (this.agentManager) {
|
|
13587
|
-
this.agentManager.agentResetCount = runner.options.agentResetMod;
|
|
13588
|
-
}
|
|
13589
13480
|
}
|
|
13590
13481
|
}
|
|
13591
13482
|
class StartUpDelFhirResources extends TestCaseFhirBase {
|
|
@@ -13603,55 +13494,52 @@ class StartUpDelFhirResources extends TestCaseFhirBase {
|
|
|
13603
13494
|
this.runner.instrumentData.rx += 65e5;
|
|
13604
13495
|
let complete = false;
|
|
13605
13496
|
let totalRecordsDelete = 0;
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
this.LogErrorMessage(chalk$1.red(`ExecuteRunner():GetResources: Error: [${error}]`));
|
|
13614
|
-
const duration2 = (performance.now() - start2) / 1e3;
|
|
13615
|
-
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - post GetResources() - Total Duration (error): [${duration2}]`));
|
|
13616
|
-
});
|
|
13617
|
-
const duration = (performance.now() - start2) / 1e3;
|
|
13618
|
-
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - post GetResources() - Total Duration: [${duration}]`));
|
|
13619
|
-
__privateGet(this, _debug3).call(this, retVal);
|
|
13620
|
-
if (retVal) {
|
|
13621
|
-
__privateGet(this, _debug3).call(this, `Records already exist - going to delete ...`);
|
|
13622
|
-
__privateGet(this, _debug3).call(this, retVal.length);
|
|
13623
|
-
const start3 = performance.now();
|
|
13624
|
-
const delRetVal = await this.fhirClient.DeleteResources("Person", retVal, (error) => {
|
|
13625
|
-
this.LogErrorMessage(chalk$1.red(`test(POST /stsresource and query using filter): ${error}`));
|
|
13626
|
-
const duration3 = (performance.now() - start3) / 1e3;
|
|
13627
|
-
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - post DeleteResources() - Total Duration (error): [${duration3}]`));
|
|
13497
|
+
try {
|
|
13498
|
+
while (!complete) {
|
|
13499
|
+
const start2 = performance.now();
|
|
13500
|
+
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - pre GetResources()`));
|
|
13501
|
+
const retVal = await this.fhirClient.GetResources("Person", null, {
|
|
13502
|
+
limit: options.batchDeleteSize,
|
|
13503
|
+
prefix: options.personPrefix
|
|
13628
13504
|
});
|
|
13629
|
-
const
|
|
13630
|
-
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - post
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13505
|
+
const duration = (performance.now() - start2) / 1e3;
|
|
13506
|
+
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - post GetResources() - Total Duration: [${duration}]`));
|
|
13507
|
+
__privateGet(this, _debug3).call(this, retVal);
|
|
13508
|
+
if (retVal) {
|
|
13509
|
+
__privateGet(this, _debug3).call(this, `Records already exist - going to delete ...`);
|
|
13510
|
+
__privateGet(this, _debug3).call(this, retVal.length);
|
|
13511
|
+
const start3 = performance.now();
|
|
13512
|
+
const delRetVal = await this.fhirClient.DeleteResources("Person", retVal);
|
|
13513
|
+
const duration2 = (performance.now() - start3) / 1e3;
|
|
13514
|
+
__privateGet(this, _debug3).call(this, chalk$1.magenta(`ExecuteRunner() - post DeleteResources() - Total Duration: [${duration2}]`));
|
|
13515
|
+
if (delRetVal) {
|
|
13516
|
+
if (delRetVal.length === 0) {
|
|
13517
|
+
complete = true;
|
|
13518
|
+
} else {
|
|
13519
|
+
__privateGet(this, _debug3).call(this, `Records deleted ...`);
|
|
13520
|
+
__privateGet(this, _debug3).call(this, delRetVal.length);
|
|
13521
|
+
totalRecordsDelete += delRetVal.length;
|
|
13522
|
+
__privateGet(this, _debug3).call(this, chalk$1.red(`total records delete = ${totalRecordsDelete}`));
|
|
13523
|
+
}
|
|
13634
13524
|
} else {
|
|
13635
|
-
|
|
13636
|
-
__privateGet(this, _debug3).call(this, delRetVal.length);
|
|
13637
|
-
totalRecordsDelete += delRetVal.length;
|
|
13638
|
-
__privateGet(this, _debug3).call(this, chalk$1.red(`total records delete = ${totalRecordsDelete}`));
|
|
13525
|
+
complete = true;
|
|
13639
13526
|
}
|
|
13640
13527
|
} else {
|
|
13641
13528
|
complete = true;
|
|
13642
13529
|
}
|
|
13643
|
-
|
|
13644
|
-
complete = true;
|
|
13530
|
+
await Sleep(1);
|
|
13645
13531
|
}
|
|
13646
|
-
|
|
13532
|
+
__privateGet(this, _debug3).call(this, chalk$1.red(`total records delete = ${totalRecordsDelete}`));
|
|
13533
|
+
this.runner.instrumentData.activeRequestCount--;
|
|
13534
|
+
const end = performance.now();
|
|
13535
|
+
const diff = end - start;
|
|
13536
|
+
this.runner.instrumentData.duration = diff;
|
|
13537
|
+
await this.PublishTelemetry();
|
|
13538
|
+
return true;
|
|
13539
|
+
} catch (error) {
|
|
13540
|
+
console.error(`StartUpDelFhirResources:ExecuteRunner(): Error: [${error}]`);
|
|
13541
|
+
return false;
|
|
13647
13542
|
}
|
|
13648
|
-
__privateGet(this, _debug3).call(this, chalk$1.red(`total records delete = ${totalRecordsDelete}`));
|
|
13649
|
-
this.runner.instrumentData.activeRequestCount--;
|
|
13650
|
-
const end = performance.now();
|
|
13651
|
-
const diff = end - start;
|
|
13652
|
-
this.runner.instrumentData.duration = diff;
|
|
13653
|
-
await this.PublishTelemetry();
|
|
13654
|
-
return true;
|
|
13655
13543
|
});
|
|
13656
13544
|
}
|
|
13657
13545
|
}
|
|
@@ -15707,9 +15595,7 @@ class SetupFhirTestResources extends TestCaseFhirBase {
|
|
|
15707
15595
|
const personRecord = __privateGet(this, _GetPersonRecord).call(this, options.testBlocksPrefix, options.personPrefix, this.runner.iteration, options.blockSize);
|
|
15708
15596
|
__privateGet(this, _debug4).call(this, chalk$1.yellow(`ExecuteRunner(): Record Length: [${JSON.stringify(personRecord).length}]`));
|
|
15709
15597
|
try {
|
|
15710
|
-
const retVal = await this.fhirClient.CreateResource("Person", personRecord
|
|
15711
|
-
this.LogErrorMessage(`ExecuteRunner():CreateResource: Error: [${error}]`);
|
|
15712
|
-
});
|
|
15598
|
+
const retVal = await this.fhirClient.CreateResource("Person", personRecord);
|
|
15713
15599
|
__privateGet(this, _debug4).call(this, chalk$1.yellow(`ExecuteRunner():CreateResource: Return ID: [${retVal == null ? void 0 : retVal.id}]`));
|
|
15714
15600
|
} catch (error) {
|
|
15715
15601
|
__privateGet(this, _error2).call(this, chalk$1.red(`ExecuteRunner():CreateResource: Error: [${error}]`));
|