@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
|
@@ -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;
|
|
@@ -5385,73 +5451,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5385
5451
|
}
|
|
5386
5452
|
return responseCode;
|
|
5387
5453
|
});
|
|
5388
|
-
__privateAdd(this, _InvokeResourceAPI, async (url2, httpVerb, domainResource, filters, searchParams, errorCb) => {
|
|
5389
|
-
const id = v4();
|
|
5390
|
-
__privateGet(this, _invokeMethods)[id] = {
|
|
5391
|
-
id,
|
|
5392
|
-
retries: 0,
|
|
5393
|
-
testFailIndexBefore: 1,
|
|
5394
|
-
url: url2,
|
|
5395
|
-
httpVerb,
|
|
5396
|
-
domainResource,
|
|
5397
|
-
filters,
|
|
5398
|
-
searchParams,
|
|
5399
|
-
errorCb
|
|
5400
|
-
};
|
|
5401
|
-
const InvokeAPI = async (id2) => {
|
|
5402
|
-
const metadataRecord = __privateGet(this, _invokeMethods)[id2];
|
|
5403
|
-
let performRetry = false;
|
|
5404
|
-
const returnData = await __privateGet(this, ___InvokeResourceAPI).call(this, metadataRecord, (statusCode, error) => {
|
|
5405
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Error: [${error}], Attempt: [${metadataRecord.retries + 1}]`));
|
|
5406
|
-
const noRetryIndex = __privateGet(this, _NoRetryStatusCodes).indexOf(statusCode);
|
|
5407
|
-
if (noRetryIndex === -1) {
|
|
5408
|
-
if (statusCode === StatusCodes.UNAUTHORIZED) {
|
|
5409
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Authentication error, resetting access_token (to null).`));
|
|
5410
|
-
__privateGet(this, _options3).ResetAccessToken();
|
|
5411
|
-
if (__privateGet(this, _options3).clientTelemetryEvents) {
|
|
5412
|
-
__privateGet(this, _options3).clientTelemetryEvents.AuthenticationErrorInc();
|
|
5413
|
-
}
|
|
5414
|
-
}
|
|
5415
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5416
|
-
console.error(chalk.red(`#InvokeResourceAPI(): Resetting https agent (to null).`));
|
|
5417
|
-
__privateGet(this, _options3).agentManager.ResetAgent();
|
|
5418
|
-
}
|
|
5419
|
-
performRetry = true;
|
|
5420
|
-
}
|
|
5421
|
-
});
|
|
5422
|
-
return {
|
|
5423
|
-
response: returnData,
|
|
5424
|
-
retry: performRetry
|
|
5425
|
-
};
|
|
5426
|
-
};
|
|
5427
|
-
let retVal = null;
|
|
5428
|
-
while (__privateGet(this, _invokeMethods)[id].retries < __privateGet(this, _maxRetries)) {
|
|
5429
|
-
retVal = await InvokeAPI(id);
|
|
5430
|
-
if (retVal.retry === false) {
|
|
5431
|
-
delete __privateGet(this, _invokeMethods)[id];
|
|
5432
|
-
break;
|
|
5433
|
-
} else {
|
|
5434
|
-
console.log(`Going to retry. Current attempts: [${__privateGet(this, _invokeMethods)[id].retries + 1}]`);
|
|
5435
|
-
console.log(`Sleeping: [${__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]}]`);
|
|
5436
|
-
await stsutils.Sleep(__privateGet(this, _sleepDuration)[__privateGet(this, _invokeMethods)[id].retries]);
|
|
5437
|
-
__privateGet(this, _invokeMethods)[id].retries++;
|
|
5438
|
-
if (__privateGet(this, _options3).clientTelemetryEvents) {
|
|
5439
|
-
__privateGet(this, _options3).clientTelemetryEvents.RetryInc();
|
|
5440
|
-
}
|
|
5441
|
-
}
|
|
5442
|
-
}
|
|
5443
|
-
if (retVal) {
|
|
5444
|
-
if (retVal.retry === true) {
|
|
5445
|
-
errorCb(new Error(`#InvokeResourceAPI(): Max retries exceeded. Max Retries: [${__privateGet(this, _invokeMethods)[id].retries}]`));
|
|
5446
|
-
delete __privateGet(this, _invokeMethods)[id];
|
|
5447
|
-
return null;
|
|
5448
|
-
} else {
|
|
5449
|
-
return retVal.response;
|
|
5450
|
-
}
|
|
5451
|
-
} else {
|
|
5452
|
-
return null;
|
|
5453
|
-
}
|
|
5454
|
-
});
|
|
5455
5454
|
__privateAdd(this, _TestMode, (metaData, errorCb) => {
|
|
5456
5455
|
const { id, url: url2, httpVerb, filters, retries } = metaData;
|
|
5457
5456
|
if (retries < 1) {
|
|
@@ -5464,37 +5463,40 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5464
5463
|
}
|
|
5465
5464
|
return false;
|
|
5466
5465
|
});
|
|
5467
|
-
__privateAdd(this,
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
return null;
|
|
5473
|
-
}
|
|
5474
|
-
}
|
|
5475
|
-
const accessToken = await __privateGet(this, _options3).GetAccessToken();
|
|
5476
|
-
const requestConfig = new stsutils.STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, __privateGet(this, _DUMMY_USER)).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
5477
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5478
|
-
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5479
|
-
}
|
|
5480
|
-
return await axios(requestConfig.config);
|
|
5481
|
-
} catch (error) {
|
|
5482
|
-
const responseCode = __privateGet(this, _HandleError).call(this, error);
|
|
5483
|
-
errorCb(responseCode, error);
|
|
5484
|
-
return null;
|
|
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);
|
|
5485
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)}`);
|
|
5480
|
+
}
|
|
5481
|
+
//stsAxiosConfig: requestConfig
|
|
5482
|
+
});
|
|
5483
|
+
return await api(url2, requestConfig.config);
|
|
5486
5484
|
});
|
|
5487
|
-
__publicField(this, "GetResource", async (resource, id, filters
|
|
5485
|
+
__publicField(this, "GetResource", async (resource, id, filters) => {
|
|
5488
5486
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5489
5487
|
const retVal = await __privateGet(this, _fhirSocketClient).GetResource(resource, id);
|
|
5490
5488
|
if (retVal.status === StatusCodes.OK) {
|
|
5491
5489
|
return retVal.value;
|
|
5492
5490
|
} else {
|
|
5493
|
-
|
|
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;
|
|
5494
5496
|
}
|
|
5495
5497
|
} else {
|
|
5496
5498
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5497
|
-
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);
|
|
5498
5500
|
if (response) {
|
|
5499
5501
|
return response.data;
|
|
5500
5502
|
} else {
|
|
@@ -5508,7 +5510,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5508
5510
|
url2.search = searchParams.toString();
|
|
5509
5511
|
return url2.toString();
|
|
5510
5512
|
});
|
|
5511
|
-
__publicField(this, "GetResources", async (resource, filters, searchParams
|
|
5513
|
+
__publicField(this, "GetResources", async (resource, filters, searchParams) => {
|
|
5512
5514
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5513
5515
|
return __privateGet(this, _fhirSocketClient).GetResources(resource, searchParams);
|
|
5514
5516
|
} else {
|
|
@@ -5516,7 +5518,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5516
5518
|
if (searchParams) {
|
|
5517
5519
|
url2 = __privateGet(this, _BuildQueryString).call(this, url2, searchParams);
|
|
5518
5520
|
}
|
|
5519
|
-
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);
|
|
5520
5522
|
if (response) {
|
|
5521
5523
|
return response.data;
|
|
5522
5524
|
} else {
|
|
@@ -5524,36 +5526,38 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5524
5526
|
}
|
|
5525
5527
|
}
|
|
5526
5528
|
});
|
|
5527
|
-
__publicField(this, "CreateResource", async (resource, domainResource
|
|
5529
|
+
__publicField(this, "CreateResource", async (resource, domainResource) => {
|
|
5528
5530
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5529
5531
|
const retVal = await __privateGet(this, _fhirSocketClient).CreateResource(resource, domainResource);
|
|
5530
5532
|
if (retVal.status === StatusCodes.CREATED) {
|
|
5531
5533
|
return retVal.value;
|
|
5532
5534
|
} else {
|
|
5533
|
-
|
|
5534
|
-
|
|
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;
|
|
5535
5540
|
}
|
|
5536
5541
|
} else {
|
|
5537
5542
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5538
|
-
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);
|
|
5539
5544
|
if (response) {
|
|
5540
5545
|
if (response.status === StatusCodes.CREATED) {
|
|
5541
5546
|
return response.data;
|
|
5542
5547
|
} else {
|
|
5543
|
-
|
|
5544
|
-
return null;
|
|
5548
|
+
throw new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5545
5549
|
}
|
|
5546
5550
|
} else {
|
|
5547
5551
|
return null;
|
|
5548
5552
|
}
|
|
5549
5553
|
}
|
|
5550
5554
|
});
|
|
5551
|
-
__publicField(this, "UpdateResource", async (resource, domainResource
|
|
5555
|
+
__publicField(this, "UpdateResource", async (resource, domainResource) => {
|
|
5552
5556
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5553
5557
|
return __privateGet(this, _fhirSocketClient).UpdateResource(resource, domainResource);
|
|
5554
5558
|
} else {
|
|
5555
5559
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5556
|
-
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);
|
|
5557
5561
|
if (response) {
|
|
5558
5562
|
return response.data;
|
|
5559
5563
|
} else {
|
|
@@ -5561,12 +5565,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5561
5565
|
}
|
|
5562
5566
|
}
|
|
5563
5567
|
});
|
|
5564
|
-
__publicField(this, "UpdateResources", async (resource, domainResources
|
|
5568
|
+
__publicField(this, "UpdateResources", async (resource, domainResources) => {
|
|
5565
5569
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5566
5570
|
return __privateGet(this, _fhirSocketClient).UpdateResources(resource, domainResources);
|
|
5567
5571
|
} else {
|
|
5568
5572
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5569
|
-
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);
|
|
5570
5574
|
if (response) {
|
|
5571
5575
|
return response.data;
|
|
5572
5576
|
} else {
|
|
@@ -5574,12 +5578,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5574
5578
|
}
|
|
5575
5579
|
}
|
|
5576
5580
|
});
|
|
5577
|
-
__publicField(this, "PatchResource", async (resource, domainResource
|
|
5581
|
+
__publicField(this, "PatchResource", async (resource, domainResource) => {
|
|
5578
5582
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5579
5583
|
return __privateGet(this, _fhirSocketClient).PatchResource(resource, domainResource);
|
|
5580
5584
|
} else {
|
|
5581
5585
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
5582
|
-
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);
|
|
5583
5587
|
if (response) {
|
|
5584
5588
|
return response.data;
|
|
5585
5589
|
} else {
|
|
@@ -5587,12 +5591,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5587
5591
|
}
|
|
5588
5592
|
}
|
|
5589
5593
|
});
|
|
5590
|
-
__publicField(this, "PatchResources", async (resource, domainResources
|
|
5594
|
+
__publicField(this, "PatchResources", async (resource, domainResources) => {
|
|
5591
5595
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5592
5596
|
return __privateGet(this, _fhirSocketClient).PatchResources(resource, domainResources);
|
|
5593
5597
|
} else {
|
|
5594
5598
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5595
|
-
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);
|
|
5596
5600
|
if (response) {
|
|
5597
5601
|
return response.data;
|
|
5598
5602
|
} else {
|
|
@@ -5600,12 +5604,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5600
5604
|
}
|
|
5601
5605
|
}
|
|
5602
5606
|
});
|
|
5603
|
-
__publicField(this, "DeleteResource", async (resource, id
|
|
5607
|
+
__publicField(this, "DeleteResource", async (resource, id) => {
|
|
5604
5608
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5605
5609
|
return __privateGet(this, _fhirSocketClient).DeleteResource(resource, id);
|
|
5606
5610
|
} else {
|
|
5607
5611
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5608
|
-
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);
|
|
5609
5613
|
if (response) {
|
|
5610
5614
|
return response.data;
|
|
5611
5615
|
} else {
|
|
@@ -5613,12 +5617,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5613
5617
|
}
|
|
5614
5618
|
}
|
|
5615
5619
|
});
|
|
5616
|
-
__publicField(this, "DeleteResources", async (resource, domainResources
|
|
5620
|
+
__publicField(this, "DeleteResources", async (resource, domainResources) => {
|
|
5617
5621
|
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5618
5622
|
return __privateGet(this, _fhirSocketClient).DeleteResources(resource, domainResources);
|
|
5619
5623
|
} else {
|
|
5620
5624
|
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
5621
|
-
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);
|
|
5622
5626
|
if (response) {
|
|
5623
5627
|
return response.data;
|
|
5624
5628
|
} else {
|
|
@@ -5666,9 +5670,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5666
5670
|
_LogDebugMessage = new WeakMap();
|
|
5667
5671
|
_LogErrorMessage = new WeakMap();
|
|
5668
5672
|
_HandleError = new WeakMap();
|
|
5669
|
-
_InvokeResourceAPI = new WeakMap();
|
|
5670
5673
|
_TestMode = new WeakMap();
|
|
5671
|
-
|
|
5674
|
+
_InvokeResourceAPI = new WeakMap();
|
|
5672
5675
|
_BuildQueryString = new WeakMap();
|
|
5673
5676
|
exports2.FhirClient = FhirClient;
|
|
5674
5677
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|