@nsshunt/stsfhirclient 2.0.30 → 2.0.32

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.
@@ -9158,68 +9158,6 @@ function splitUnderBase(pathname, basePath) {
9158
9158
  return pathname.slice(basePath.length).split("/").filter(Boolean);
9159
9159
  }
9160
9160
  //#endregion
9161
- //#region src/retryAxiosClient.ts
9162
- function sleep(ms) {
9163
- return new Promise((resolve) => setTimeout(resolve, ms));
9164
- }
9165
- function getJitteredDelay(base, jitter) {
9166
- return base + Math.floor(Math.random() * jitter);
9167
- }
9168
- function createRetryAxiosClient(retryConfig) {
9169
- const { maxRetries = 3, retryDelayMs = 300, retryJitterMs = 100, retryMethods = [
9170
- "get",
9171
- "head",
9172
- "put",
9173
- "delete",
9174
- "options"
9175
- ], retryStatusCodes = [
9176
- 408,
9177
- 429,
9178
- 500,
9179
- 502,
9180
- 503,
9181
- 504
9182
- ], retryErrorCodes = [
9183
- "ECONNRESET",
9184
- "ETIMEDOUT",
9185
- "EAI_AGAIN",
9186
- "ECONNREFUSED",
9187
- "ENOTFOUND",
9188
- "EHOSTUNREACH",
9189
- "EPIPE"
9190
- ], maxRetryDurationMs = 1e4, onRetryAttempt, stsAxiosConfig } = retryConfig || {};
9191
- const instance = axios.create();
9192
- instance.interceptors.request.use((config) => {
9193
- const retryConfig = config;
9194
- if (!retryConfig.metadata) retryConfig.metadata = {
9195
- startTime: Date.now(),
9196
- __retryCount: 0
9197
- };
9198
- if (stsAxiosConfig) Object.assign(config, stsAxiosConfig.config);
9199
- return config;
9200
- });
9201
- instance.interceptors.response.use((response) => response, async (error) => {
9202
- const config = error.config;
9203
- if (!config || !config.method || !config.metadata) return Promise.reject(error);
9204
- const elapsed = Date.now() - config.metadata.startTime;
9205
- const method = config.method.toLowerCase();
9206
- const status = error.response?.status;
9207
- const code = error.code ?? "";
9208
- const isRetryableMethod = retryMethods.includes(method);
9209
- const isRetryableStatus = retryStatusCodes.includes(status ?? 0);
9210
- const isRetryableCode = retryErrorCodes.includes(code);
9211
- if (isRetryableMethod && (isRetryableStatus || isRetryableCode) && config.metadata.__retryCount < maxRetries && elapsed < maxRetryDurationMs) {
9212
- config.metadata.__retryCount += 1;
9213
- const delayMs = getJitteredDelay(retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1), retryJitterMs);
9214
- onRetryAttempt?.(config.metadata.__retryCount, error, delayMs);
9215
- await sleep(delayMs);
9216
- return instance(config);
9217
- }
9218
- return Promise.reject(error);
9219
- });
9220
- return instance;
9221
- }
9222
- //#endregion
9223
9161
  //#region node_modules/chalk/source/vendor/ansi-styles/index.js
9224
9162
  var ANSI_BACKGROUND_OFFSET = 10;
9225
9163
  var wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
@@ -9585,7 +9523,6 @@ var FhirRESTClient = class {
9585
9523
  this.#options.logger.error(error);
9586
9524
  console.error(error);
9587
9525
  this.HandleError(error);
9588
- process.exit(0);
9589
9526
  };
9590
9527
  LogWarning = (method, message) => {
9591
9528
  this.#options.logger.warn(`FhirRESTClient:${method}(): Warn: [${message}]`);
@@ -9616,16 +9553,7 @@ var FhirRESTClient = class {
9616
9553
  requestConfig.withAuthHeaders(accessToken, this.#options.user).withHeaders(headers);
9617
9554
  if (resource) requestConfig.withData(resource);
9618
9555
  if (this.#options.agentManager) requestConfig.withAgentManager(this.#options.agentManager);
9619
- return await createRetryAxiosClient({
9620
- maxRetries: 4,
9621
- retryDelayMs: 300,
9622
- retryJitterMs: 150,
9623
- maxRetryDurationMs: 5e3,
9624
- onRetryAttempt: (attempt, error, delayMs) => {
9625
- this.LogWarning("#InvokeResourceAPI", `Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
9626
- if (this.#options.onRetryAttempt) this.#options.onRetryAttempt(attempt, error, delayMs);
9627
- }
9628
- })(url, requestConfig.config);
9556
+ return await axios(requestConfig.config);
9629
9557
  };
9630
9558
  ProcessBatchOrTransactionResources = async (bundle) => {
9631
9559
  try {
@@ -13760,6 +13688,68 @@ var FhirSocketClientIndividual = class extends FhirSocketClient {
13760
13688
  };
13761
13689
  };
13762
13690
  //#endregion
13691
+ //#region src/retryAxiosClient.ts
13692
+ function sleep(ms) {
13693
+ return new Promise((resolve) => setTimeout(resolve, ms));
13694
+ }
13695
+ function getJitteredDelay(base, jitter) {
13696
+ return base + Math.floor(Math.random() * jitter);
13697
+ }
13698
+ function createRetryAxiosClient(retryConfig) {
13699
+ const { maxRetries = 3, retryDelayMs = 300, retryJitterMs = 100, retryMethods = [
13700
+ "get",
13701
+ "head",
13702
+ "put",
13703
+ "delete",
13704
+ "options"
13705
+ ], retryStatusCodes = [
13706
+ 408,
13707
+ 429,
13708
+ 500,
13709
+ 502,
13710
+ 503,
13711
+ 504
13712
+ ], retryErrorCodes = [
13713
+ "ECONNRESET",
13714
+ "ETIMEDOUT",
13715
+ "EAI_AGAIN",
13716
+ "ECONNREFUSED",
13717
+ "ENOTFOUND",
13718
+ "EHOSTUNREACH",
13719
+ "EPIPE"
13720
+ ], maxRetryDurationMs = 1e4, onRetryAttempt, stsAxiosConfig } = retryConfig || {};
13721
+ const instance = axios.create();
13722
+ instance.interceptors.request.use((config) => {
13723
+ const retryConfig = config;
13724
+ if (!retryConfig.metadata) retryConfig.metadata = {
13725
+ startTime: Date.now(),
13726
+ __retryCount: 0
13727
+ };
13728
+ if (stsAxiosConfig) Object.assign(config, stsAxiosConfig.config);
13729
+ return config;
13730
+ });
13731
+ instance.interceptors.response.use((response) => response, async (error) => {
13732
+ const config = error.config;
13733
+ if (!config || !config.method || !config.metadata) return Promise.reject(error);
13734
+ const elapsed = Date.now() - config.metadata.startTime;
13735
+ const method = config.method.toLowerCase();
13736
+ const status = error.response?.status;
13737
+ const code = error.code ?? "";
13738
+ const isRetryableMethod = retryMethods.includes(method);
13739
+ const isRetryableStatus = retryStatusCodes.includes(status ?? 0);
13740
+ const isRetryableCode = retryErrorCodes.includes(code);
13741
+ if (isRetryableMethod && (isRetryableStatus || isRetryableCode) && config.metadata.__retryCount < maxRetries && elapsed < maxRetryDurationMs) {
13742
+ config.metadata.__retryCount += 1;
13743
+ const delayMs = getJitteredDelay(retryDelayMs * Math.pow(2, config.metadata.__retryCount - 1), retryJitterMs);
13744
+ onRetryAttempt?.(config.metadata.__retryCount, error, delayMs);
13745
+ await sleep(delayMs);
13746
+ return instance(config);
13747
+ }
13748
+ return Promise.reject(error);
13749
+ });
13750
+ return instance;
13751
+ }
13752
+ //#endregion
13763
13753
  export { FhirRESTClient, FhirRouteError, FhirSocketClient, FhirSocketClientAllInOne, FhirSocketClientIndividual, GetAboveHierarchy, STSFhirValidator, createRetryAxiosClient, fhirRT, fhirSP, fhirSPRefOnly, getBaseResource, isAbsoluteUrl, normalizeUri, splitUnderBase };
13764
13754
 
13765
13755
  //# sourceMappingURL=stsfhirclient.mjs.map