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