@nsshunt/stsfhirclient 2.0.15 → 2.0.17
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.cjs +15 -9
- package/dist/stsfhirclient.cjs.map +1 -1
- package/dist/stsfhirclient.mjs +15 -9
- package/dist/stsfhirclient.mjs.map +1 -1
- package/package.json +1 -1
- package/types/cv2/fhirRESTClient.d.ts +2 -0
- package/types/cv2/fhirRESTClient.d.ts.map +1 -1
- package/types/cv2/fhirSocketClient.d.ts +1 -1
- package/types/cv2/fhirSocketClient.d.ts.map +1 -1
- package/types/retryAxiosClient.d.ts.map +1 -1
package/dist/stsfhirclient.mjs
CHANGED
|
@@ -9180,7 +9180,9 @@ function createRetryAxiosClient(retryConfig) {
|
|
|
9180
9180
|
"head",
|
|
9181
9181
|
"put",
|
|
9182
9182
|
"delete",
|
|
9183
|
-
"options"
|
|
9183
|
+
"options",
|
|
9184
|
+
"post",
|
|
9185
|
+
"patch"
|
|
9184
9186
|
], retryStatusCodes = [
|
|
9185
9187
|
408,
|
|
9186
9188
|
429,
|
|
@@ -9199,7 +9201,8 @@ function createRetryAxiosClient(retryConfig) {
|
|
|
9199
9201
|
], maxRetryDurationMs = 1e4, onRetryAttempt, stsAxiosConfig } = retryConfig || {};
|
|
9200
9202
|
const instance = axios.create();
|
|
9201
9203
|
instance.interceptors.request.use((config) => {
|
|
9202
|
-
|
|
9204
|
+
const retryConfig = config;
|
|
9205
|
+
if (!retryConfig.metadata) retryConfig.metadata = {
|
|
9203
9206
|
startTime: Date.now(),
|
|
9204
9207
|
__retryCount: 0
|
|
9205
9208
|
};
|
|
@@ -9212,13 +9215,15 @@ function createRetryAxiosClient(retryConfig) {
|
|
|
9212
9215
|
const elapsed = Date.now() - config.metadata.startTime;
|
|
9213
9216
|
const method = config.method.toLowerCase();
|
|
9214
9217
|
const status = error.response?.status;
|
|
9215
|
-
const code = error.code;
|
|
9216
|
-
const
|
|
9217
|
-
|
|
9218
|
+
const code = error.code ?? "";
|
|
9219
|
+
const isRetryableMethod = retryMethods.includes(method);
|
|
9220
|
+
const isRetryableStatus = retryStatusCodes.includes(status ?? 0);
|
|
9221
|
+
const isRetryableCode = retryErrorCodes.includes(code);
|
|
9222
|
+
if (isRetryableMethod && (isRetryableStatus || isRetryableCode) && config.metadata.__retryCount < maxRetries && elapsed < maxRetryDurationMs) {
|
|
9218
9223
|
config.metadata.__retryCount += 1;
|
|
9219
|
-
const
|
|
9220
|
-
|
|
9221
|
-
await sleep(
|
|
9224
|
+
const delayMs = getJitteredDelay(retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1), retryJitterMs);
|
|
9225
|
+
onRetryAttempt?.(config.metadata.__retryCount, error, delayMs);
|
|
9226
|
+
await sleep(delayMs);
|
|
9222
9227
|
return instance(config);
|
|
9223
9228
|
}
|
|
9224
9229
|
return Promise.reject(error);
|
|
@@ -9274,6 +9279,7 @@ var FhirRESTClient = class {
|
|
|
9274
9279
|
maxRetryDurationMs: 5e3,
|
|
9275
9280
|
onRetryAttempt: (attempt, error, delayMs) => {
|
|
9276
9281
|
this.LogWarning("#InvokeResourceAPI", `Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
|
|
9282
|
+
if (this.#options.onRetryAttempt) this.#options.onRetryAttempt(attempt, error, delayMs);
|
|
9277
9283
|
}
|
|
9278
9284
|
})(url, requestConfig.config);
|
|
9279
9285
|
};
|
|
@@ -14965,7 +14971,7 @@ var FhirSocketClient = class extends SocketIoClient {
|
|
|
14965
14971
|
SetupSocketEvents(socket) {}
|
|
14966
14972
|
SetupWSSClient = async () => {
|
|
14967
14973
|
this.LogDebugMessage(import_source.default.yellow(`FhirSocketClient:SetupWSSClient(): ID: [${this.id}] clientName: [${this.name}] Starting ...`));
|
|
14968
|
-
const cstr = `${this.options.fhirServerEndpoint}:${this.options.
|
|
14974
|
+
const cstr = `${this.options.fhirServerEndpoint}:${this.options.fhirServerPort}/nsstsfhir/`;
|
|
14969
14975
|
this.LogDebugMessage(import_source.default.yellow(`FhirSocketClient:SetupWSSClient(): Socket connection string: [${cstr}]`));
|
|
14970
14976
|
this.WithAddress(cstr).WithSocketIoCustomPath(this.options.socketIoCustomPath).WithAuthToken(this.options.authToken);
|
|
14971
14977
|
if (this.options.agentManager) this.WithAgentManager(this.options.agentManager);
|