@sjawhar/pi-envoy 16.41.0 → 16.41.1

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.
Files changed (3) hide show
  1. package/dist/dispatch.js +15 -22
  2. package/dist/envoy.js +2217 -2224
  3. package/package.json +1 -1
package/dist/dispatch.js CHANGED
@@ -17592,6 +17592,14 @@ async function resolveOrigin(env, exec, cwd) {
17592
17592
  return origin;
17593
17593
  }
17594
17594
 
17595
+ // ../contracts/src/trailing-slash.ts
17596
+ function withoutTrailingSlashes(url) {
17597
+ let end = url.length;
17598
+ while (end > 0 && url[end - 1] === "/")
17599
+ end -= 1;
17600
+ return url.slice(0, end);
17601
+ }
17602
+
17595
17603
  // ../envoy-client/src/dispatch-http.ts
17596
17604
  class DispatchServiceError extends Error {
17597
17605
  code;
@@ -17900,7 +17908,7 @@ class DispatchClient {
17900
17908
  this.fetchImpl = fetchImpl;
17901
17909
  this.writeRetry = writeRetry;
17902
17910
  this.#credential = credential;
17903
- this.#baseUrl = baseUrl.replace(/\/+$/, "");
17911
+ this.#baseUrl = withoutTrailingSlashes(baseUrl);
17904
17912
  this.#signal = requestSignal(signal);
17905
17913
  this.#madeAt = this.#now();
17906
17914
  }
@@ -25674,12 +25682,6 @@ function statusOf(error) {
25674
25682
  }
25675
25683
  return 0;
25676
25684
  }
25677
- function withoutTrailingSlashes(url) {
25678
- let end = url.length;
25679
- while (end > 0 && url[end - 1] === "/")
25680
- end -= 1;
25681
- return url.slice(0, end);
25682
- }
25683
25685
 
25684
25686
  class BrokerTokenClient {
25685
25687
  #brokerUrl;
@@ -25957,12 +25959,6 @@ function brokerCredential(env, session) {
25957
25959
 
25958
25960
  // ../envoy-client/src/dispatch-config.ts
25959
25961
  var DEFAULT_SERVER_URL = "http://localhost:8766";
25960
- function withoutTrailingSlashes2(url) {
25961
- let end = url.length;
25962
- while (end > 0 && url[end - 1] === "/")
25963
- end -= 1;
25964
- return url.slice(0, end);
25965
- }
25966
25962
  function checkoutPair(checkout, serverUrl) {
25967
25963
  const { token } = checkout.dispatch;
25968
25964
  if (token === undefined) {
@@ -26024,7 +26020,7 @@ function dispatchSettings(env, config, options = {}) {
26024
26020
  enabled: true,
26025
26021
  url,
26026
26022
  credential,
26027
- ...publicUrl === undefined ? {} : { publicUrl: publicUrl.replace(/\/+$/, "") }
26023
+ ...publicUrl === undefined ? {} : { publicUrl: withoutTrailingSlashes(publicUrl) }
26028
26024
  };
26029
26025
  }
26030
26026
  function brokerRouteForced(env) {
@@ -26080,7 +26076,7 @@ function dispatchTarget(env, config) {
26080
26076
  return offWithError(messageFor(error));
26081
26077
  }
26082
26078
  if (route.traded) {
26083
- const brokered = withoutTrailingSlashes2(explicitUrl ?? own.serverUrl ?? DEFAULT_SERVER_URL);
26079
+ const brokered = withoutTrailingSlashes(explicitUrl ?? own.serverUrl ?? DEFAULT_SERVER_URL);
26084
26080
  return { enabled: true, url: brokered, source: { kind: "broker" } };
26085
26081
  }
26086
26082
  if (forced) {
@@ -26088,7 +26084,7 @@ function dispatchTarget(env, config) {
26088
26084
  }
26089
26085
  return offWithError(explicitUrl === undefined ? `${config.path}: dispatch is enabled and no token is: set dispatch.token, or DISPATCH_TOKEN or DISPATCH_TOKEN_FILE` : `DISPATCH_URL is set and no token is: set DISPATCH_TOKEN or DISPATCH_TOKEN_FILE, or dispatch.token in ${config.path}`);
26090
26086
  }
26091
- const url = (explicitUrl ?? (source.kind === "file" ? source.server : own.serverUrl ?? DEFAULT_SERVER_URL)).replace(/\/+$/, "");
26087
+ const url = withoutTrailingSlashes(explicitUrl ?? (source.kind === "file" ? source.server : own.serverUrl ?? DEFAULT_SERVER_URL));
26092
26088
  return { enabled: true, url, source };
26093
26089
  }
26094
26090
 
@@ -26131,7 +26127,7 @@ function natsServerKey(url) {
26131
26127
  if (match === null)
26132
26128
  return url;
26133
26129
  const [, scheme = "", userinfo = "", host = "", port = "4222", rest = ""] = match;
26134
- return `${scheme.toLowerCase()}://${userinfo}${host.toLowerCase()}:${port}${rest.replace(/\/+$/, "")}`;
26130
+ return `${scheme.toLowerCase()}://${userinfo}${host.toLowerCase()}:${port}${withoutTrailingSlashes(rest)}`;
26135
26131
  }
26136
26132
  function natsCredential(env, section, namedNatsUrls, filePath) {
26137
26133
  const fromEnvironment = natsSeedFromEnvironment(env);
@@ -26202,7 +26198,7 @@ function envoySettings(env, config, options = {}) {
26202
26198
  const namedPassDeadlineMs = namedInterval(env.ENVOY_PASS_DEADLINE_MS);
26203
26199
  return {
26204
26200
  enabled: true,
26205
- url: normalizeEnvoyUrl(url),
26201
+ url: withoutTrailingSlashes(url),
26206
26202
  credential,
26207
26203
  inbound,
26208
26204
  heartbeatMs,
@@ -26211,9 +26207,6 @@ function envoySettings(env, config, options = {}) {
26211
26207
  passDeadlineRaisedFrom: namedPassDeadlineMs !== undefined && namedPassDeadlineMs < heartbeatMs ? namedPassDeadlineMs : undefined
26212
26208
  };
26213
26209
  }
26214
- function normalizeEnvoyUrl(value) {
26215
- return value.replace(/\/+$/, "");
26216
- }
26217
26210
 
26218
26211
  // ../envoy-client/src/session-settings.ts
26219
26212
  function sessionConfigFile(harness, env) {
@@ -26460,7 +26453,7 @@ function resolveCallTiming(config) {
26460
26453
  };
26461
26454
  }
26462
26455
  function createEnvoyClient(config) {
26463
- const baseUrl = normalizeEnvoyUrl(config.baseUrl);
26456
+ const baseUrl = withoutTrailingSlashes(config.baseUrl);
26464
26457
  const { timeoutMs, attempts, retryDelayMs } = resolveCallTiming(config);
26465
26458
  const credential = config.credential;
26466
26459
  const attemptOnce = async (url, init, deadlineMs, actingSession) => {