@nsshunt/stsfhirclient 2.0.30 → 2.0.31

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.
@@ -9166,68 +9166,6 @@ function splitUnderBase(pathname, basePath) {
9166
9166
  return pathname.slice(basePath.length).split("/").filter(Boolean);
9167
9167
  }
9168
9168
  //#endregion
9169
- //#region src/retryAxiosClient.ts
9170
- function sleep(ms) {
9171
- return new Promise((resolve) => setTimeout(resolve, ms));
9172
- }
9173
- function getJitteredDelay(base, jitter) {
9174
- return base + Math.floor(Math.random() * jitter);
9175
- }
9176
- function createRetryAxiosClient(retryConfig) {
9177
- const { maxRetries = 3, retryDelayMs = 300, retryJitterMs = 100, retryMethods = [
9178
- "get",
9179
- "head",
9180
- "put",
9181
- "delete",
9182
- "options"
9183
- ], retryStatusCodes = [
9184
- 408,
9185
- 429,
9186
- 500,
9187
- 502,
9188
- 503,
9189
- 504
9190
- ], retryErrorCodes = [
9191
- "ECONNRESET",
9192
- "ETIMEDOUT",
9193
- "EAI_AGAIN",
9194
- "ECONNREFUSED",
9195
- "ENOTFOUND",
9196
- "EHOSTUNREACH",
9197
- "EPIPE"
9198
- ], maxRetryDurationMs = 1e4, onRetryAttempt, stsAxiosConfig } = retryConfig || {};
9199
- const instance = axios.default.create();
9200
- instance.interceptors.request.use((config) => {
9201
- const retryConfig = config;
9202
- if (!retryConfig.metadata) retryConfig.metadata = {
9203
- startTime: Date.now(),
9204
- __retryCount: 0
9205
- };
9206
- if (stsAxiosConfig) Object.assign(config, stsAxiosConfig.config);
9207
- return config;
9208
- });
9209
- instance.interceptors.response.use((response) => response, async (error) => {
9210
- const config = error.config;
9211
- if (!config || !config.method || !config.metadata) return Promise.reject(error);
9212
- const elapsed = Date.now() - config.metadata.startTime;
9213
- const method = config.method.toLowerCase();
9214
- const status = error.response?.status;
9215
- const code = error.code ?? "";
9216
- const isRetryableMethod = retryMethods.includes(method);
9217
- const isRetryableStatus = retryStatusCodes.includes(status ?? 0);
9218
- const isRetryableCode = retryErrorCodes.includes(code);
9219
- if (isRetryableMethod && (isRetryableStatus || isRetryableCode) && config.metadata.__retryCount < maxRetries && elapsed < maxRetryDurationMs) {
9220
- config.metadata.__retryCount += 1;
9221
- const delayMs = getJitteredDelay(retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1), retryJitterMs);
9222
- onRetryAttempt?.(config.metadata.__retryCount, error, delayMs);
9223
- await sleep(delayMs);
9224
- return instance(config);
9225
- }
9226
- return Promise.reject(error);
9227
- });
9228
- return instance;
9229
- }
9230
- //#endregion
9231
9169
  //#region node_modules/chalk/source/vendor/ansi-styles/index.js
9232
9170
  var ANSI_BACKGROUND_OFFSET = 10;
9233
9171
  var wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
@@ -9624,16 +9562,7 @@ var FhirRESTClient = class {
9624
9562
  requestConfig.withAuthHeaders(accessToken, this.#options.user).withHeaders(headers);
9625
9563
  if (resource) requestConfig.withData(resource);
9626
9564
  if (this.#options.agentManager) requestConfig.withAgentManager(this.#options.agentManager);
9627
- return await createRetryAxiosClient({
9628
- maxRetries: 4,
9629
- retryDelayMs: 300,
9630
- retryJitterMs: 150,
9631
- maxRetryDurationMs: 5e3,
9632
- onRetryAttempt: (attempt, error, delayMs) => {
9633
- this.LogWarning("#InvokeResourceAPI", `Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
9634
- if (this.#options.onRetryAttempt) this.#options.onRetryAttempt(attempt, error, delayMs);
9635
- }
9636
- })(url, requestConfig.config);
9565
+ return await (0, axios.default)(requestConfig.config);
9637
9566
  };
9638
9567
  ProcessBatchOrTransactionResources = async (bundle) => {
9639
9568
  try {
@@ -13768,6 +13697,68 @@ var FhirSocketClientIndividual = class extends FhirSocketClient {
13768
13697
  };
13769
13698
  };
13770
13699
  //#endregion
13700
+ //#region src/retryAxiosClient.ts
13701
+ function sleep(ms) {
13702
+ return new Promise((resolve) => setTimeout(resolve, ms));
13703
+ }
13704
+ function getJitteredDelay(base, jitter) {
13705
+ return base + Math.floor(Math.random() * jitter);
13706
+ }
13707
+ function createRetryAxiosClient(retryConfig) {
13708
+ const { maxRetries = 3, retryDelayMs = 300, retryJitterMs = 100, retryMethods = [
13709
+ "get",
13710
+ "head",
13711
+ "put",
13712
+ "delete",
13713
+ "options"
13714
+ ], retryStatusCodes = [
13715
+ 408,
13716
+ 429,
13717
+ 500,
13718
+ 502,
13719
+ 503,
13720
+ 504
13721
+ ], retryErrorCodes = [
13722
+ "ECONNRESET",
13723
+ "ETIMEDOUT",
13724
+ "EAI_AGAIN",
13725
+ "ECONNREFUSED",
13726
+ "ENOTFOUND",
13727
+ "EHOSTUNREACH",
13728
+ "EPIPE"
13729
+ ], maxRetryDurationMs = 1e4, onRetryAttempt, stsAxiosConfig } = retryConfig || {};
13730
+ const instance = axios.default.create();
13731
+ instance.interceptors.request.use((config) => {
13732
+ const retryConfig = config;
13733
+ if (!retryConfig.metadata) retryConfig.metadata = {
13734
+ startTime: Date.now(),
13735
+ __retryCount: 0
13736
+ };
13737
+ if (stsAxiosConfig) Object.assign(config, stsAxiosConfig.config);
13738
+ return config;
13739
+ });
13740
+ instance.interceptors.response.use((response) => response, async (error) => {
13741
+ const config = error.config;
13742
+ if (!config || !config.method || !config.metadata) return Promise.reject(error);
13743
+ const elapsed = Date.now() - config.metadata.startTime;
13744
+ const method = config.method.toLowerCase();
13745
+ const status = error.response?.status;
13746
+ const code = error.code ?? "";
13747
+ const isRetryableMethod = retryMethods.includes(method);
13748
+ const isRetryableStatus = retryStatusCodes.includes(status ?? 0);
13749
+ const isRetryableCode = retryErrorCodes.includes(code);
13750
+ if (isRetryableMethod && (isRetryableStatus || isRetryableCode) && config.metadata.__retryCount < maxRetries && elapsed < maxRetryDurationMs) {
13751
+ config.metadata.__retryCount += 1;
13752
+ const delayMs = getJitteredDelay(retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1), retryJitterMs);
13753
+ onRetryAttempt?.(config.metadata.__retryCount, error, delayMs);
13754
+ await sleep(delayMs);
13755
+ return instance(config);
13756
+ }
13757
+ return Promise.reject(error);
13758
+ });
13759
+ return instance;
13760
+ }
13761
+ //#endregion
13771
13762
  exports.FhirRESTClient = FhirRESTClient;
13772
13763
  exports.FhirRouteError = FhirRouteError;
13773
13764
  exports.FhirSocketClient = FhirSocketClient;