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