@nsshunt/stsfhirclient 1.0.67 → 1.0.68
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 +151 -148
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +151 -148
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/FhirClient.d.ts +9 -9
- package/types/FhirClient.d.ts.map +1 -1
- package/types/retryAxiosClient.d.ts +15 -0
- package/types/retryAxiosClient.d.ts.map +1 -0
- package/types/srv_dev/stsfhircontrollertestcasesclient.d.ts.map +1 -1
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -8,43 +8,9 @@ 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,
|
|
11
|
+
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _fhirSocketClient, _LogDebugMessage, _LogErrorMessage, _HandleError, _TestMode, _InvokeResourceAPI, _BuildQueryString;
|
|
12
12
|
import axios from "axios";
|
|
13
13
|
import { defaultLogger, Sleep, STSAxiosConfig } from "@nsshunt/stsutils";
|
|
14
|
-
const byteToHex = [];
|
|
15
|
-
for (let i = 0; i < 256; ++i) {
|
|
16
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
17
|
-
}
|
|
18
|
-
function unsafeStringify(arr, offset = 0) {
|
|
19
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
20
|
-
}
|
|
21
|
-
let getRandomValues;
|
|
22
|
-
const rnds8 = new Uint8Array(16);
|
|
23
|
-
function rng() {
|
|
24
|
-
if (!getRandomValues) {
|
|
25
|
-
if (typeof crypto === "undefined" || !crypto.getRandomValues) {
|
|
26
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
27
|
-
}
|
|
28
|
-
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
29
|
-
}
|
|
30
|
-
return getRandomValues(rnds8);
|
|
31
|
-
}
|
|
32
|
-
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
33
|
-
const native = { randomUUID };
|
|
34
|
-
function v4(options, buf, offset) {
|
|
35
|
-
var _a;
|
|
36
|
-
if (native.randomUUID && true && !options) {
|
|
37
|
-
return native.randomUUID();
|
|
38
|
-
}
|
|
39
|
-
options = options || {};
|
|
40
|
-
const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
|
|
41
|
-
if (rnds.length < 16) {
|
|
42
|
-
throw new Error("Random bytes length must be >= 16");
|
|
43
|
-
}
|
|
44
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
45
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
46
|
-
return unsafeStringify(rnds);
|
|
47
|
-
}
|
|
48
14
|
const isNode$1 = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
49
15
|
function getDefaultExportFromCjs(x) {
|
|
50
16
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -5019,6 +4985,40 @@ EstablishSocketConnect_fn = function(name, socketIoCustomPath, onConnectCallBack
|
|
|
5019
4985
|
}
|
|
5020
4986
|
});
|
|
5021
4987
|
};
|
|
4988
|
+
const byteToHex = [];
|
|
4989
|
+
for (let i = 0; i < 256; ++i) {
|
|
4990
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
4991
|
+
}
|
|
4992
|
+
function unsafeStringify(arr, offset = 0) {
|
|
4993
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
4994
|
+
}
|
|
4995
|
+
let getRandomValues;
|
|
4996
|
+
const rnds8 = new Uint8Array(16);
|
|
4997
|
+
function rng() {
|
|
4998
|
+
if (!getRandomValues) {
|
|
4999
|
+
if (typeof crypto === "undefined" || !crypto.getRandomValues) {
|
|
5000
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
5001
|
+
}
|
|
5002
|
+
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
5003
|
+
}
|
|
5004
|
+
return getRandomValues(rnds8);
|
|
5005
|
+
}
|
|
5006
|
+
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
5007
|
+
const native = { randomUUID };
|
|
5008
|
+
function v4(options, buf, offset) {
|
|
5009
|
+
var _a;
|
|
5010
|
+
if (native.randomUUID && true && !options) {
|
|
5011
|
+
return native.randomUUID();
|
|
5012
|
+
}
|
|
5013
|
+
options = options || {};
|
|
5014
|
+
const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
|
|
5015
|
+
if (rnds.length < 16) {
|
|
5016
|
+
throw new Error("Random bytes length must be >= 16");
|
|
5017
|
+
}
|
|
5018
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
5019
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
5020
|
+
return unsafeStringify(rnds);
|
|
5021
|
+
}
|
|
5022
5022
|
class FhirSocketClient {
|
|
5023
5023
|
constructor(options) {
|
|
5024
5024
|
__privateAdd(this, _socketUtils);
|
|
@@ -5345,6 +5345,75 @@ _error = new WeakMap();
|
|
|
5345
5345
|
_info = new WeakMap();
|
|
5346
5346
|
_SetupWSSClient = new WeakMap();
|
|
5347
5347
|
_OnSocketConnected = new WeakMap();
|
|
5348
|
+
function sleep(ms) {
|
|
5349
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5350
|
+
}
|
|
5351
|
+
function getJitteredDelay(base, jitter) {
|
|
5352
|
+
const random = Math.floor(Math.random() * jitter);
|
|
5353
|
+
return base + random;
|
|
5354
|
+
}
|
|
5355
|
+
function createRetryAxiosClient(retryConfig) {
|
|
5356
|
+
const {
|
|
5357
|
+
maxRetries = 3,
|
|
5358
|
+
retryDelayMs = 300,
|
|
5359
|
+
retryJitterMs = 100,
|
|
5360
|
+
retryMethods = ["get", "head", "put", "delete", "options"],
|
|
5361
|
+
// post, patch
|
|
5362
|
+
retryStatusCodes = [408, 429, 500, 502, 503, 504],
|
|
5363
|
+
retryErrorCodes = [
|
|
5364
|
+
"ECONNRESET",
|
|
5365
|
+
"ETIMEDOUT",
|
|
5366
|
+
"EAI_AGAIN",
|
|
5367
|
+
"ECONNREFUSED",
|
|
5368
|
+
"ENOTFOUND",
|
|
5369
|
+
"EHOSTUNREACH",
|
|
5370
|
+
"EPIPE"
|
|
5371
|
+
],
|
|
5372
|
+
maxRetryDurationMs = 1e4,
|
|
5373
|
+
onRetryAttempt,
|
|
5374
|
+
stsAxiosConfig
|
|
5375
|
+
} = retryConfig || {};
|
|
5376
|
+
const instance = axios.create();
|
|
5377
|
+
instance.interceptors.request.use((config) => {
|
|
5378
|
+
const now = Date.now();
|
|
5379
|
+
config.metadata = {
|
|
5380
|
+
startTime: now,
|
|
5381
|
+
__retryCount: 0
|
|
5382
|
+
};
|
|
5383
|
+
if (stsAxiosConfig) {
|
|
5384
|
+
Object.assign(config, stsAxiosConfig.config);
|
|
5385
|
+
}
|
|
5386
|
+
return config;
|
|
5387
|
+
});
|
|
5388
|
+
instance.interceptors.response.use(
|
|
5389
|
+
(response) => response,
|
|
5390
|
+
async (error) => {
|
|
5391
|
+
var _a;
|
|
5392
|
+
const config = error.config;
|
|
5393
|
+
if (!config || !config.method || !config.metadata) {
|
|
5394
|
+
return Promise.reject(error);
|
|
5395
|
+
}
|
|
5396
|
+
const now = Date.now();
|
|
5397
|
+
const elapsed = now - config.metadata.startTime;
|
|
5398
|
+
const method = config.method.toLowerCase();
|
|
5399
|
+
const status = (_a = error.response) == null ? void 0 : _a.status;
|
|
5400
|
+
const code = error.code;
|
|
5401
|
+
const isRetryable = retryMethods.includes(method) && (retryErrorCodes.includes(code || "") || retryStatusCodes.includes(status || 0));
|
|
5402
|
+
if (config.metadata.__retryCount < maxRetries && isRetryable && elapsed < maxRetryDurationMs) {
|
|
5403
|
+
config.metadata.__retryCount += 1;
|
|
5404
|
+
const delayBase = retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1);
|
|
5405
|
+
const jitteredDelay = getJitteredDelay(delayBase, retryJitterMs);
|
|
5406
|
+
if (onRetryAttempt) {
|
|
5407
|
+
onRetryAttempt(config.metadata.__retryCount, error, jitteredDelay);
|
|
5408
|
+
}
|
|
5409
|
+
await sleep(jitteredDelay);
|
|
5410
|
+
return instance(config);
|
|
5411
|
+
}
|
|
5412
|
+
return Promise.reject(error);
|
|
5413
|
+
}
|
|
5414
|
+
);
|
|
5415
|
+
return instance;
|
|
5416
|
+
}
|
|
5348
5417
|
class FhirClient {
|
|
5349
5418
|
constructor(options) {
|
|
5350
5419
|
__privateAdd(this, _options3);
|
|
@@ -5360,15 +5429,12 @@ class FhirClient {
|
|
|
5360
5429
|
__privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
5361
5430
|
// Default value
|
|
5362
5431
|
__privateAdd(this, _fhirSocketClient);
|
|
5363
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5364
5432
|
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
5365
5433
|
__privateGet(this, _options3).logger.debug(message);
|
|
5366
5434
|
});
|
|
5367
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5368
5435
|
__privateAdd(this, _LogErrorMessage, (message) => {
|
|
5369
5436
|
__privateGet(this, _options3).logger.error(message);
|
|
5370
5437
|
});
|
|
5371
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5372
5438
|
__privateAdd(this, _HandleError, (error) => {
|
|
5373
5439
|
__privateGet(this, _LogDebugMessage).call(this, chalk.red(`HandleError(): Error: [${error}]`));
|
|
5374
5440
|
let responseCode = 500;
|
|
@@ -5383,73 +5449,6 @@ class FhirClient {
|
|
|
5383
5449
|
}
|
|
5384
5450
|
return responseCode;
|
|
5385
5451
|
});
|
|
5386
|
-
__privateAdd(this, _InvokeResourceAPI, async (url2, httpVerb, domainResource, filters, searchParams, errorCb) => {
|
|
5387
|
-
const id = v4();
|
|
5388
|
-
__privateGet(this, _invokeMethods)[id] = {
|
|
5389
|
-
id,
|
|
5390
|
-
retries: 0,
|
|
5391
|
-
testFailIndexBefore: 1,
|
|
5392
|
-
url: url2,
|
|
5393
|
-
httpVerb,
|
|
5394
|
-
domainResource,
|
|
5395
|
-
filters,
|
|
5396
|
-
searchParams,
|
|
5397
|
-
errorCb
|
|
5398
|
-
};
|
|
5399
|
-
const InvokeAPI = async (id2) => {
|
|
5400
|
-
const metadataRecord = __privateGet(this, _invokeMethods)[id2];
|
|
5401
|
-
let performRetry = false;
|
|
5402
|
-
const returnData = await __privateGet(this, ___InvokeResourceAPI).call(this, metadataRecord, (statusCode, error) => {
|
|
5403
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Error: [${error}], Attempt: [${metadataRecord.retries + 1}]`));
|
|
5404
|
-
const noRetryIndex = __privateGet(this, _NoRetryStatusCodes).indexOf(statusCode);
|
|
5405
|
-
if (noRetryIndex === -1) {
|
|
5406
|
-
if (statusCode === StatusCodes.UNAUTHORIZED) {
|
|
5407
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
|
|
5408
|
-
__privateGet(this, _options3).ResetAccessToken();
|
|
5409
|
-
if (__privateGet(this, _options3).clientTelemetryEvents) {
|
|
5410
|
-
__privateGet(this, _options3).clientTelemetryEvents.AuthenticationErrorInc();
|
|
5411
|
-
}
|
|
5412
|
-
}
|
|
5413
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5414
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
5415
|
-
__privateGet(this, _options3).agentManager.ResetAgent();
|
|
5416
|
-
}
|
|
5417
|
-
performRetry = true;
|
|
5418
|
-
}
|
|
5419
|
-
});
|
|
5420
|
-
return {
|
|
5421
|
-
response: returnData,
|
|
5422
|
-
retry: performRetry
|
|
5423
|
-
};
|
|
5424
|
-
};
|
|
5425
|
-
let retVal = null;
|
|
5426
|
-
while (__privateGet(this, _invokeMethods)[id].retries < __privateGet(this, _maxRetries)) {
|
|
5427
|
-
retVal = await InvokeAPI(id);
|
|
5428
|
-
if (retVal.retry === false) {
|
|
5429
|
-
delete __privateGet(this, _invokeMethods)[id];
|
|
5430
|
-
break;
|
|
5431
|
-
} else {
|
|
5432
|
-
console.log(`Going to retry. Current attempts: [${__privateGet(this, _invokeMethods)[id].retries + 1}]`);
|
|
5433
|
-
console.log(`Sleeping: [${__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]}]`);
|
|
5434
|
-
await Sleep(__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]);
|
|
5435
|
-
__privateGet(this, _invokeMethods)[id].retries++;
|
|
5436
|
-
if (__privateGet(this, _options3).clientTelemetryEvents) {
|
|
5437
|
-
__privateGet(this, _options3).clientTelemetryEvents.RetryInc();
|
|
5438
|
-
}
|
|
5439
|
-
}
|
|
5440
|
-
}
|
|
5441
|
-
if (retVal) {
|
|
5442
|
-
if (retVal.retry === true) {
|
|
5443
|
-
errorCb(new Error(`#InvokeResourceAPI(): Max retries exceeded. Max Retries: [${__privateGet(this, _invokeMethods)[id].retries}]`));
|
|
5444
|
-
delete __privateGet(this, _invokeMethods)[id];
|
|
5445
|
-
return null;
|
|
5446
|
-
} else {
|
|
5447
|
-
return retVal.response;
|
|
5448
|
-
}
|
|
5449
|
-
} else {
|
|
5450
|
-
return null;
|
|
5451
|
-
}
|
|
5452
|
-
});
|
|
5453
5452
|
__privateAdd(this, _TestMode, (metaData, errorCb) => {
|
|
5454
5453
|
const { id, url: url2, httpVerb, filters, retries } = metaData;
|
|
5455
5454
|
if (retries < 1) {
|
|
@@ -5462,37 +5461,40 @@ class FhirClient {
|
|
|
5462
5461
|
}
|
|
5463
5462
|
return false;
|
|
5464
5463
|
});
|
|
5465
|
-
__privateAdd(this,
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
return null;
|
|
5471
|
-
}
|
|
5472
|
-
}
|
|
5473
|
-
const accessToken = await __privateGet(this, _options3).GetAccessToken();
|
|
5474
|
-
const requestConfig = new STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, __privateGet(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
5475
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5476
|
-
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5477
|
-
}
|
|
5478
|
-
return await axios(requestConfig.config);
|
|
5479
|
-
} catch (error) {
|
|
5480
|
-
const responseCode = __privateGet(this, _HandleError).call(this, error);
|
|
5481
|
-
errorCb(responseCode, error);
|
|
5482
|
-
return null;
|
|
5464
|
+
__privateAdd(this, _InvokeResourceAPI, async (url2, httpVerb, domainResource, filters) => {
|
|
5465
|
+
const accessToken = await __privateGet(this, _options3).GetAccessToken();
|
|
5466
|
+
const requestConfig = new STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, __privateGet(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
5467
|
+
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5468
|
+
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5483
5469
|
}
|
|
5470
|
+
const api = createRetryAxiosClient({
|
|
5471
|
+
maxRetries: 4,
|
|
5472
|
+
retryDelayMs: 300,
|
|
5473
|
+
retryJitterMs: 150,
|
|
5474
|
+
maxRetryDurationMs: 5e3,
|
|
5475
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5476
|
+
var _a;
|
|
5477
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a = error.response) == null ? void 0 : _a.status)}`);
|
|
5478
|
+
}
|
|
5479
|
+
//stsAxiosConfig: requestConfig
|
|
5480
|
+
});
|
|
5481
|
+
return await api(url2, requestConfig.config);
|
|
5484
5482
|
});
|
|
5485
|
-
__publicField(this, "GetResource", async (resource, id, filters
|
|
5483
|
+
__publicField(this, "GetResource", async (resource, id, filters) => {
|
|
5486
5484
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5487
5485
|
const retVal = await __privateGet(this, _fhirSocketClient).GetResource(resource, id);
|
|
5488
5486
|
if (retVal.status === StatusCodes.OK) {
|
|
5489
5487
|
return retVal.value;
|
|
5490
5488
|
} else {
|
|
5491
|
-
|
|
5489
|
+
const errorResponse = new Error(`CreateResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.OK}]`);
|
|
5490
|
+
errorResponse.response = {
|
|
5491
|
+
status: retVal.status
|
|
5492
|
+
};
|
|
5493
|
+
throw errorResponse;
|
|
5492
5494
|
}
|
|
5493
5495
|
} else {
|
|
5494
5496
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5495
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "get", null, filters
|
|
5497
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "get", null, filters);
|
|
5496
5498
|
if (response) {
|
|
5497
5499
|
return response.data;
|
|
5498
5500
|
} else {
|
|
@@ -5506,7 +5508,7 @@ class FhirClient {
|
|
|
5506
5508
|
url2.search = searchParams.toString();
|
|
5507
5509
|
return url2.toString();
|
|
5508
5510
|
});
|
|
5509
|
-
__publicField(this, "GetResources", async (resource, filters, searchParams
|
|
5511
|
+
__publicField(this, "GetResources", async (resource, filters, searchParams) => {
|
|
5510
5512
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5511
5513
|
return __privateGet(this, _fhirSocketClient).GetResources(resource, searchParams);
|
|
5512
5514
|
} else {
|
|
@@ -5514,7 +5516,7 @@ class FhirClient {
|
|
|
5514
5516
|
if (searchParams) {
|
|
5515
5517
|
url2 = __privateGet(this, _BuildQueryString).call(this, url2, searchParams);
|
|
5516
5518
|
}
|
|
5517
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "get", null, filters
|
|
5519
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "get", null, filters);
|
|
5518
5520
|
if (response) {
|
|
5519
5521
|
return response.data;
|
|
5520
5522
|
} else {
|
|
@@ -5522,36 +5524,38 @@ class FhirClient {
|
|
|
5522
5524
|
}
|
|
5523
5525
|
}
|
|
5524
5526
|
});
|
|
5525
|
-
__publicField(this, "CreateResource", async (resource, domainResource
|
|
5527
|
+
__publicField(this, "CreateResource", async (resource, domainResource) => {
|
|
5526
5528
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5527
5529
|
const retVal = await __privateGet(this, _fhirSocketClient).CreateResource(resource, domainResource);
|
|
5528
5530
|
if (retVal.status === StatusCodes.CREATED) {
|
|
5529
5531
|
return retVal.value;
|
|
5530
5532
|
} else {
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
+
const errorResponse = new Error(`CreateResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5534
|
+
errorResponse.response = {
|
|
5535
|
+
status: retVal.status
|
|
5536
|
+
};
|
|
5537
|
+
throw errorResponse;
|
|
5533
5538
|
}
|
|
5534
5539
|
} else {
|
|
5535
5540
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5536
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "post", domainResource, null
|
|
5541
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "post", domainResource, null);
|
|
5537
5542
|
if (response) {
|
|
5538
5543
|
if (response.status === StatusCodes.CREATED) {
|
|
5539
5544
|
return response.data;
|
|
5540
5545
|
} else {
|
|
5541
|
-
|
|
5542
|
-
return null;
|
|
5546
|
+
throw new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5543
5547
|
}
|
|
5544
5548
|
} else {
|
|
5545
5549
|
return null;
|
|
5546
5550
|
}
|
|
5547
5551
|
}
|
|
5548
5552
|
});
|
|
5549
|
-
__publicField(this, "UpdateResource", async (resource, domainResource
|
|
5553
|
+
__publicField(this, "UpdateResource", async (resource, domainResource) => {
|
|
5550
5554
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5551
5555
|
return __privateGet(this, _fhirSocketClient).UpdateResource(resource, domainResource);
|
|
5552
5556
|
} else {
|
|
5553
5557
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5554
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResource, null
|
|
5558
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResource, null);
|
|
5555
5559
|
if (response) {
|
|
5556
5560
|
return response.data;
|
|
5557
5561
|
} else {
|
|
@@ -5559,12 +5563,12 @@ class FhirClient {
|
|
|
5559
5563
|
}
|
|
5560
5564
|
}
|
|
5561
5565
|
});
|
|
5562
|
-
__publicField(this, "UpdateResources", async (resource, domainResources
|
|
5566
|
+
__publicField(this, "UpdateResources", async (resource, domainResources) => {
|
|
5563
5567
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5564
5568
|
return __privateGet(this, _fhirSocketClient).UpdateResources(resource, domainResources);
|
|
5565
5569
|
} else {
|
|
5566
5570
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5567
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null
|
|
5571
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null);
|
|
5568
5572
|
if (response) {
|
|
5569
5573
|
return response.data;
|
|
5570
5574
|
} else {
|
|
@@ -5572,12 +5576,12 @@ class FhirClient {
|
|
|
5572
5576
|
}
|
|
5573
5577
|
}
|
|
5574
5578
|
});
|
|
5575
|
-
__publicField(this, "PatchResource", async (resource, domainResource
|
|
5579
|
+
__publicField(this, "PatchResource", async (resource, domainResource) => {
|
|
5576
5580
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5577
5581
|
return __privateGet(this, _fhirSocketClient).PatchResource(resource, domainResource);
|
|
5578
5582
|
} else {
|
|
5579
5583
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5580
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null
|
|
5584
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null);
|
|
5581
5585
|
if (response) {
|
|
5582
5586
|
return response.data;
|
|
5583
5587
|
} else {
|
|
@@ -5585,12 +5589,12 @@ class FhirClient {
|
|
|
5585
5589
|
}
|
|
5586
5590
|
}
|
|
5587
5591
|
});
|
|
5588
|
-
__publicField(this, "PatchResources", async (resource, domainResources
|
|
5592
|
+
__publicField(this, "PatchResources", async (resource, domainResources) => {
|
|
5589
5593
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5590
5594
|
return __privateGet(this, _fhirSocketClient).PatchResources(resource, domainResources);
|
|
5591
5595
|
} else {
|
|
5592
5596
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5593
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null
|
|
5597
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null);
|
|
5594
5598
|
if (response) {
|
|
5595
5599
|
return response.data;
|
|
5596
5600
|
} else {
|
|
@@ -5598,12 +5602,12 @@ class FhirClient {
|
|
|
5598
5602
|
}
|
|
5599
5603
|
}
|
|
5600
5604
|
});
|
|
5601
|
-
__publicField(this, "DeleteResource", async (resource, id
|
|
5605
|
+
__publicField(this, "DeleteResource", async (resource, id) => {
|
|
5602
5606
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5603
5607
|
return __privateGet(this, _fhirSocketClient).DeleteResource(resource, id);
|
|
5604
5608
|
} else {
|
|
5605
5609
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5606
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", null, null
|
|
5610
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", null, null);
|
|
5607
5611
|
if (response) {
|
|
5608
5612
|
return response.data;
|
|
5609
5613
|
} else {
|
|
@@ -5611,12 +5615,12 @@ class FhirClient {
|
|
|
5611
5615
|
}
|
|
5612
5616
|
}
|
|
5613
5617
|
});
|
|
5614
|
-
__publicField(this, "DeleteResources", async (resource, domainResources
|
|
5618
|
+
__publicField(this, "DeleteResources", async (resource, domainResources) => {
|
|
5615
5619
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5616
5620
|
return __privateGet(this, _fhirSocketClient).DeleteResources(resource, domainResources);
|
|
5617
5621
|
} else {
|
|
5618
5622
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5619
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null
|
|
5623
|
+
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null);
|
|
5620
5624
|
if (response) {
|
|
5621
5625
|
return response.data;
|
|
5622
5626
|
} else {
|
|
@@ -5664,9 +5668,8 @@ _fhirSocketClient = new WeakMap();
|
|
|
5664
5668
|
_LogDebugMessage = new WeakMap();
|
|
5665
5669
|
_LogErrorMessage = new WeakMap();
|
|
5666
5670
|
_HandleError = new WeakMap();
|
|
5667
|
-
_InvokeResourceAPI = new WeakMap();
|
|
5668
5671
|
_TestMode = new WeakMap();
|
|
5669
|
-
|
|
5672
|
+
_InvokeResourceAPI = new WeakMap();
|
|
5670
5673
|
_BuildQueryString = new WeakMap();
|
|
5671
5674
|
export {
|
|
5672
5675
|
FhirClient
|