@nsshunt/stsfhirclient 1.0.66 → 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 -173
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +151 -173
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +1 -1
- 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;
|
|
@@ -5380,134 +5446,39 @@ class FhirClient {
|
|
|
5380
5446
|
} else {
|
|
5381
5447
|
__privateGet(this, _LogDebugMessage).call(this, chalk.red(`AXIOS Error = [${axiosError}]`));
|
|
5382
5448
|
}
|
|
5383
|
-
return responseCode;
|
|
5384
|
-
} else if (error.responseCode) {
|
|
5385
|
-
return error.responseCode;
|
|
5386
|
-
} else {
|
|
5387
|
-
return responseCode;
|
|
5388
|
-
}
|
|
5389
|
-
});
|
|
5390
|
-
__privateAdd(this, ___InvokeResourceAPI, async (metaData) => {
|
|
5391
|
-
try {
|
|
5392
|
-
const { url: url2, httpVerb, domainResource, filters } = metaData;
|
|
5393
|
-
if (__privateGet(this, _options3).testingMode) {
|
|
5394
|
-
await __privateGet(this, _TestMode).call(this, metaData);
|
|
5395
|
-
}
|
|
5396
|
-
const accessToken = await __privateGet(this, _options3).GetAccessToken();
|
|
5397
|
-
const requestConfig = new STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, __privateGet(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
5398
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5399
|
-
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5400
|
-
}
|
|
5401
|
-
return await axios(requestConfig.config);
|
|
5402
|
-
} catch (error) {
|
|
5403
|
-
throw {
|
|
5404
|
-
responseCode: __privateGet(this, _HandleError).call(this, error),
|
|
5405
|
-
error
|
|
5406
|
-
};
|
|
5407
5449
|
}
|
|
5450
|
+
return responseCode;
|
|
5408
5451
|
});
|
|
5409
|
-
__privateAdd(this,
|
|
5410
|
-
const id =
|
|
5411
|
-
|
|
5412
|
-
id,
|
|
5413
|
-
|
|
5414
|
-
testFailIndexBefore: 1,
|
|
5415
|
-
url: url2,
|
|
5416
|
-
httpVerb,
|
|
5417
|
-
domainResource,
|
|
5418
|
-
filters,
|
|
5419
|
-
searchParams
|
|
5420
|
-
};
|
|
5421
|
-
const InvokeAPI = async (id2) => {
|
|
5422
|
-
const metadataRecord = __privateGet(this, _invokeMethods)[id2];
|
|
5423
|
-
let performRetry = false;
|
|
5424
|
-
let returnData = null;
|
|
5425
|
-
let responseCode = null;
|
|
5426
|
-
let originalError;
|
|
5427
|
-
try {
|
|
5428
|
-
returnData = await __privateGet(this, ___InvokeResourceAPI).call(this, metadataRecord);
|
|
5429
|
-
} catch (error) {
|
|
5430
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Error: [${error}], Attempt: [${metadataRecord.retries + 1}]`));
|
|
5431
|
-
if (error) {
|
|
5432
|
-
originalError = error;
|
|
5433
|
-
if (error.responseCode) {
|
|
5434
|
-
responseCode = error.responseCode;
|
|
5435
|
-
const noRetryIndex = __privateGet(this, _NoRetryStatusCodes).indexOf(error.responseCode);
|
|
5436
|
-
if (noRetryIndex === -1) {
|
|
5437
|
-
if (error.responseCode === StatusCodes.UNAUTHORIZED) {
|
|
5438
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
|
|
5439
|
-
__privateGet(this, _options3).ResetAccessToken();
|
|
5440
|
-
if (__privateGet(this, _options3).clientTelemetryEvents) {
|
|
5441
|
-
__privateGet(this, _options3).clientTelemetryEvents.AuthenticationErrorInc();
|
|
5442
|
-
}
|
|
5443
|
-
}
|
|
5444
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5445
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
5446
|
-
__privateGet(this, _options3).agentManager.ResetAgent();
|
|
5447
|
-
}
|
|
5448
|
-
performRetry = true;
|
|
5449
|
-
}
|
|
5450
|
-
}
|
|
5451
|
-
}
|
|
5452
|
-
}
|
|
5453
|
-
return {
|
|
5454
|
-
response: returnData,
|
|
5455
|
-
retry: performRetry,
|
|
5456
|
-
responseCode,
|
|
5457
|
-
originalError
|
|
5458
|
-
};
|
|
5459
|
-
};
|
|
5460
|
-
let retVal = null;
|
|
5461
|
-
while (__privateGet(this, _invokeMethods)[id].retries < __privateGet(this, _maxRetries)) {
|
|
5462
|
-
retVal = await InvokeAPI(id);
|
|
5463
|
-
if (retVal.retry === false) {
|
|
5464
|
-
delete __privateGet(this, _invokeMethods)[id];
|
|
5465
|
-
break;
|
|
5466
|
-
} else {
|
|
5467
|
-
console.log(`Going to retry. Current attempts: [${__privateGet(this, _invokeMethods)[id].retries + 1}]`);
|
|
5468
|
-
console.log(`Sleeping: [${__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]}]`);
|
|
5469
|
-
await Sleep(__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]);
|
|
5470
|
-
__privateGet(this, _invokeMethods)[id].retries++;
|
|
5471
|
-
if (__privateGet(this, _options3).clientTelemetryEvents) {
|
|
5472
|
-
__privateGet(this, _options3).clientTelemetryEvents.RetryInc();
|
|
5473
|
-
}
|
|
5474
|
-
}
|
|
5452
|
+
__privateAdd(this, _TestMode, (metaData, errorCb) => {
|
|
5453
|
+
const { id, url: url2, httpVerb, filters, retries } = metaData;
|
|
5454
|
+
if (retries < 1) {
|
|
5455
|
+
errorCb(401, new Error(`Testing Error Only. Error Code: [401], Message ID: [${id}, url: [${url2}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
5456
|
+
return true;
|
|
5475
5457
|
}
|
|
5476
|
-
if (
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
delete __privateGet(this, _invokeMethods)[id];
|
|
5480
|
-
throw {
|
|
5481
|
-
responseCode: retVal.responseCode,
|
|
5482
|
-
error: new Error(`#InvokeResourceAPI(): Max retries exceeded. Max Retries: [${retries}], Original Error: [${retVal.originalError}]`)
|
|
5483
|
-
};
|
|
5484
|
-
} else {
|
|
5485
|
-
return retVal.response;
|
|
5486
|
-
}
|
|
5487
|
-
} else {
|
|
5488
|
-
throw {
|
|
5489
|
-
responseCode: 500,
|
|
5490
|
-
error: new Error(`#InvokeResourceAPI(): Null returned from API call.`)
|
|
5491
|
-
};
|
|
5458
|
+
if (retries < 2) {
|
|
5459
|
+
errorCb(500, new Error(`Testing Error Only. Error Code: [500], Message ID: [${id}, url: [${url2}], httpVerb: [${httpVerb}], filters: [${filters}], Retries: [${retries}]`));
|
|
5460
|
+
return true;
|
|
5492
5461
|
}
|
|
5462
|
+
return false;
|
|
5493
5463
|
});
|
|
5494
|
-
__privateAdd(this,
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
});
|
|
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);
|
|
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)}`);
|
|
5508
5478
|
}
|
|
5509
|
-
|
|
5479
|
+
//stsAxiosConfig: requestConfig
|
|
5510
5480
|
});
|
|
5481
|
+
return await api(url2, requestConfig.config);
|
|
5511
5482
|
});
|
|
5512
5483
|
__publicField(this, "GetResource", async (resource, id, filters) => {
|
|
5513
5484
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
@@ -5515,11 +5486,15 @@ class FhirClient {
|
|
|
5515
5486
|
if (retVal.status === StatusCodes.OK) {
|
|
5516
5487
|
return retVal.value;
|
|
5517
5488
|
} else {
|
|
5518
|
-
|
|
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;
|
|
5519
5494
|
}
|
|
5520
5495
|
} else {
|
|
5521
5496
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5522
|
-
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);
|
|
5523
5498
|
if (response) {
|
|
5524
5499
|
return response.data;
|
|
5525
5500
|
} else {
|
|
@@ -5541,7 +5516,7 @@ class FhirClient {
|
|
|
5541
5516
|
if (searchParams) {
|
|
5542
5517
|
url2 = __privateGet(this, _BuildQueryString).call(this, url2, searchParams);
|
|
5543
5518
|
}
|
|
5544
|
-
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);
|
|
5545
5520
|
if (response) {
|
|
5546
5521
|
return response.data;
|
|
5547
5522
|
} else {
|
|
@@ -5555,16 +5530,20 @@ class FhirClient {
|
|
|
5555
5530
|
if (retVal.status === StatusCodes.CREATED) {
|
|
5556
5531
|
return retVal.value;
|
|
5557
5532
|
} else {
|
|
5558
|
-
|
|
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;
|
|
5559
5538
|
}
|
|
5560
5539
|
} else {
|
|
5561
5540
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5562
|
-
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);
|
|
5563
5542
|
if (response) {
|
|
5564
5543
|
if (response.status === StatusCodes.CREATED) {
|
|
5565
5544
|
return response.data;
|
|
5566
5545
|
} else {
|
|
5567
|
-
|
|
5546
|
+
throw new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5568
5547
|
}
|
|
5569
5548
|
} else {
|
|
5570
5549
|
return null;
|
|
@@ -5576,7 +5555,7 @@ class FhirClient {
|
|
|
5576
5555
|
return __privateGet(this, _fhirSocketClient).UpdateResource(resource, domainResource);
|
|
5577
5556
|
} else {
|
|
5578
5557
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5579
|
-
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);
|
|
5580
5559
|
if (response) {
|
|
5581
5560
|
return response.data;
|
|
5582
5561
|
} else {
|
|
@@ -5589,7 +5568,7 @@ class FhirClient {
|
|
|
5589
5568
|
return __privateGet(this, _fhirSocketClient).UpdateResources(resource, domainResources);
|
|
5590
5569
|
} else {
|
|
5591
5570
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5592
|
-
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);
|
|
5593
5572
|
if (response) {
|
|
5594
5573
|
return response.data;
|
|
5595
5574
|
} else {
|
|
@@ -5602,7 +5581,7 @@ class FhirClient {
|
|
|
5602
5581
|
return __privateGet(this, _fhirSocketClient).PatchResource(resource, domainResource);
|
|
5603
5582
|
} else {
|
|
5604
5583
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5605
|
-
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);
|
|
5606
5585
|
if (response) {
|
|
5607
5586
|
return response.data;
|
|
5608
5587
|
} else {
|
|
@@ -5615,7 +5594,7 @@ class FhirClient {
|
|
|
5615
5594
|
return __privateGet(this, _fhirSocketClient).PatchResources(resource, domainResources);
|
|
5616
5595
|
} else {
|
|
5617
5596
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5618
|
-
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);
|
|
5619
5598
|
if (response) {
|
|
5620
5599
|
return response.data;
|
|
5621
5600
|
} else {
|
|
@@ -5628,7 +5607,7 @@ class FhirClient {
|
|
|
5628
5607
|
return __privateGet(this, _fhirSocketClient).DeleteResource(resource, id);
|
|
5629
5608
|
} else {
|
|
5630
5609
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5631
|
-
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);
|
|
5632
5611
|
if (response) {
|
|
5633
5612
|
return response.data;
|
|
5634
5613
|
} else {
|
|
@@ -5641,7 +5620,7 @@ class FhirClient {
|
|
|
5641
5620
|
return __privateGet(this, _fhirSocketClient).DeleteResources(resource, domainResources);
|
|
5642
5621
|
} else {
|
|
5643
5622
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5644
|
-
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);
|
|
5645
5624
|
if (response) {
|
|
5646
5625
|
return response.data;
|
|
5647
5626
|
} else {
|
|
@@ -5689,9 +5668,8 @@ _fhirSocketClient = new WeakMap();
|
|
|
5689
5668
|
_LogDebugMessage = new WeakMap();
|
|
5690
5669
|
_LogErrorMessage = new WeakMap();
|
|
5691
5670
|
_HandleError = new WeakMap();
|
|
5692
|
-
___InvokeResourceAPI = new WeakMap();
|
|
5693
|
-
_InvokeResourceAPI = new WeakMap();
|
|
5694
5671
|
_TestMode = new WeakMap();
|
|
5672
|
+
_InvokeResourceAPI = new WeakMap();
|
|
5695
5673
|
_BuildQueryString = new WeakMap();
|
|
5696
5674
|
export {
|
|
5697
5675
|
FhirClient
|