@dreamboard-games/cli 0.1.30-alpha.32 → 0.1.30-alpha.33

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.
@@ -24,7 +24,7 @@ import {
24
24
  writeWorkspaceJsonFile,
25
25
  writeWorkspaceTextFile,
26
26
  zProblemDetails
27
- } from "./chunk-TRF7IPXK.js";
27
+ } from "./chunk-BN5UBK47.js";
28
28
  import {
29
29
  getStoredSession,
30
30
  loadGlobalConfig,
@@ -41,7 +41,7 @@ import {
41
41
 
42
42
  // src/build-target.ts
43
43
  var injectedBuildChannel = true ? "development" : void 0;
44
- var injectedPackageVersion = true ? "0.1.30-alpha.32" : void 0;
44
+ var injectedPackageVersion = true ? "0.1.30-alpha.33" : void 0;
45
45
  var BUILD_CHANNEL = injectedBuildChannel === "published" ? "published" : "development";
46
46
  var PACKAGE_VERSION = injectedPackageVersion ?? "0.0.0-development";
47
47
  function isAlphaReleaseVersion(version) {
@@ -716,12 +716,18 @@ function createRetryingReadFetch(fetchImpl) {
716
716
  return (async (input, init) => {
717
717
  const method = resolveFetchMethod(input, init);
718
718
  if (method !== "GET" && method !== "HEAD") {
719
- return fetchImpl(input, init);
719
+ return fetchWithOptionalTrace(fetchImpl, input, init, {
720
+ attempt: 0,
721
+ willRetry: false
722
+ });
720
723
  }
721
724
  let lastError;
722
725
  for (let attempt = 0; attempt <= TRANSIENT_READ_RETRY_DELAYS_MS.length; attempt += 1) {
723
726
  try {
724
- return await fetchImpl(input, init);
727
+ return await fetchWithOptionalTrace(fetchImpl, input, init, {
728
+ attempt,
729
+ willRetry: attempt < TRANSIENT_READ_RETRY_DELAYS_MS.length
730
+ });
725
731
  } catch (error) {
726
732
  lastError = error;
727
733
  if (attempt >= TRANSIENT_READ_RETRY_DELAYS_MS.length || !isTransientFetchError(error)) {
@@ -733,6 +739,88 @@ function createRetryingReadFetch(fetchImpl) {
733
739
  throw lastError;
734
740
  });
735
741
  }
742
+ async function fetchWithOptionalTrace(fetchImpl, input, init, options) {
743
+ if (!isHttpTraceEnabled()) {
744
+ return fetchImpl(input, init);
745
+ }
746
+ const request = describeRequest(input, init);
747
+ const startedAt = Date.now();
748
+ try {
749
+ const response = await fetchImpl(input, init);
750
+ writeHttpTrace({
751
+ ...request,
752
+ attempt: options.attempt,
753
+ status: response.status,
754
+ durationMs: Date.now() - startedAt
755
+ });
756
+ return response;
757
+ } catch (error) {
758
+ writeHttpTrace({
759
+ ...request,
760
+ attempt: options.attempt,
761
+ durationMs: Date.now() - startedAt,
762
+ error: error instanceof Error ? error.name : "UnknownError",
763
+ willRetry: options.willRetry
764
+ });
765
+ throw error;
766
+ }
767
+ }
768
+ function isHttpTraceEnabled() {
769
+ return process.env.DREAMBOARD_CLI_HTTP_TRACE === "1";
770
+ }
771
+ function describeRequest(input, init) {
772
+ return {
773
+ method: resolveFetchMethod(input, init),
774
+ url: redactUrl(input),
775
+ hasAuthorization: hasAuthorizationHeader(input, init)
776
+ };
777
+ }
778
+ function redactUrl(input) {
779
+ const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
780
+ try {
781
+ const url = new URL(rawUrl);
782
+ return `${url.origin}${url.pathname}`;
783
+ } catch {
784
+ return "<unparseable-url>";
785
+ }
786
+ }
787
+ function hasAuthorizationHeader(input, init) {
788
+ return headersContainAuthorization(init?.headers) || typeof Request !== "undefined" && input instanceof Request && input.headers.has("Authorization");
789
+ }
790
+ function headersContainAuthorization(headers) {
791
+ if (!headers) {
792
+ return false;
793
+ }
794
+ if (headers instanceof Headers) {
795
+ return headers.has("Authorization");
796
+ }
797
+ if (Array.isArray(headers)) {
798
+ return headers.some(([name]) => name.toLowerCase() === "authorization");
799
+ }
800
+ return Object.keys(headers).some(
801
+ (name) => name.toLowerCase() === "authorization"
802
+ );
803
+ }
804
+ function writeHttpTrace(event) {
805
+ const parts = [
806
+ "[dreamboard-cli:http]",
807
+ `method=${event.method}`,
808
+ `url=${event.url}`,
809
+ `auth=${event.hasAuthorization ? "present" : "missing"}`,
810
+ `attempt=${event.attempt + 1}`,
811
+ `durationMs=${event.durationMs}`
812
+ ];
813
+ if (typeof event.status === "number") {
814
+ parts.push(`status=${event.status}`);
815
+ }
816
+ if (event.error) {
817
+ parts.push(`error=${event.error}`);
818
+ }
819
+ if (event.willRetry) {
820
+ parts.push("willRetry=true");
821
+ }
822
+ console.error(parts.join(" "));
823
+ }
736
824
  function resolveFetchMethod(input, init) {
737
825
  const method = init?.method ?? (typeof Request !== "undefined" && input instanceof Request ? input.method : void 0);
738
826
  return (method ?? "GET").toUpperCase();
@@ -3821,4 +3909,4 @@ export {
3821
3909
  isLocalMaintainerRegistryEnabled,
3822
3910
  didLocalMaintainerSnapshotChange
3823
3911
  };
3824
- //# sourceMappingURL=chunk-DWWMZBFB.js.map
3912
+ //# sourceMappingURL=chunk-E67GR2SL.js.map