@postman-cse/onboarding-repo-sync 2.1.10 → 2.1.14

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.
package/dist/action.cjs CHANGED
@@ -19745,7 +19745,7 @@ var require_response = __commonJS({
19745
19745
  var assert = require("node:assert");
19746
19746
  var { isomorphicEncode, serializeJavascriptValueToJSONString } = require_infra();
19747
19747
  var textEncoder = new TextEncoder("utf-8");
19748
- var Response = class _Response {
19748
+ var Response2 = class _Response {
19749
19749
  /** @type {Headers} */
19750
19750
  #headers;
19751
19751
  #state;
@@ -19915,13 +19915,13 @@ var require_response = __commonJS({
19915
19915
  response.#state = newState;
19916
19916
  }
19917
19917
  };
19918
- var { getResponseHeaders, setResponseHeaders, getResponseState, setResponseState } = Response;
19919
- Reflect.deleteProperty(Response, "getResponseHeaders");
19920
- Reflect.deleteProperty(Response, "setResponseHeaders");
19921
- Reflect.deleteProperty(Response, "getResponseState");
19922
- Reflect.deleteProperty(Response, "setResponseState");
19923
- mixinBody(Response, getResponseState);
19924
- Object.defineProperties(Response.prototype, {
19918
+ var { getResponseHeaders, setResponseHeaders, getResponseState, setResponseState } = Response2;
19919
+ Reflect.deleteProperty(Response2, "getResponseHeaders");
19920
+ Reflect.deleteProperty(Response2, "setResponseHeaders");
19921
+ Reflect.deleteProperty(Response2, "getResponseState");
19922
+ Reflect.deleteProperty(Response2, "setResponseState");
19923
+ mixinBody(Response2, getResponseState);
19924
+ Object.defineProperties(Response2.prototype, {
19925
19925
  type: kEnumerableProperty,
19926
19926
  url: kEnumerableProperty,
19927
19927
  status: kEnumerableProperty,
@@ -19937,7 +19937,7 @@ var require_response = __commonJS({
19937
19937
  configurable: true
19938
19938
  }
19939
19939
  });
19940
- Object.defineProperties(Response, {
19940
+ Object.defineProperties(Response2, {
19941
19941
  json: kEnumerableProperty,
19942
19942
  redirect: kEnumerableProperty,
19943
19943
  error: kEnumerableProperty
@@ -20070,7 +20070,7 @@ var require_response = __commonJS({
20070
20070
  }
20071
20071
  }
20072
20072
  function fromInnerResponse(innerResponse, guard) {
20073
- const response = new Response(kConstruct);
20073
+ const response = new Response2(kConstruct);
20074
20074
  setResponseState(response, innerResponse);
20075
20075
  const headers = new Headers3(kConstruct);
20076
20076
  setResponseHeaders(response, headers);
@@ -20124,14 +20124,14 @@ var require_response = __commonJS({
20124
20124
  converter: webidl.converters.HeadersInit
20125
20125
  }
20126
20126
  ]);
20127
- webidl.is.Response = webidl.util.MakeTypeAssertion(Response);
20127
+ webidl.is.Response = webidl.util.MakeTypeAssertion(Response2);
20128
20128
  module2.exports = {
20129
20129
  isNetworkError,
20130
20130
  makeNetworkError,
20131
20131
  makeResponse,
20132
20132
  makeAppropriateNetworkError,
20133
20133
  filterResponse,
20134
- Response,
20134
+ Response: Response2,
20135
20135
  cloneResponse,
20136
20136
  fromInnerResponse,
20137
20137
  getResponseState
@@ -26569,7 +26569,7 @@ var require_util7 = __commonJS({
26569
26569
  exports2.esc = esc;
26570
26570
  exports2.slugify = slugify;
26571
26571
  exports2.isObject = isObject;
26572
- exports2.isPlainObject = isPlainObject2;
26572
+ exports2.isPlainObject = isPlainObject3;
26573
26573
  exports2.shallowClone = shallowClone;
26574
26574
  exports2.numKeys = numKeys;
26575
26575
  exports2.escapeRegex = escapeRegex;
@@ -26752,7 +26752,7 @@ var require_util7 = __commonJS({
26752
26752
  return false;
26753
26753
  }
26754
26754
  });
26755
- function isPlainObject2(o) {
26755
+ function isPlainObject3(o) {
26756
26756
  if (isObject(o) === false)
26757
26757
  return false;
26758
26758
  const ctor = o.constructor;
@@ -26769,7 +26769,7 @@ var require_util7 = __commonJS({
26769
26769
  return true;
26770
26770
  }
26771
26771
  function shallowClone(o) {
26772
- if (isPlainObject2(o))
26772
+ if (isPlainObject3(o))
26773
26773
  return { ...o };
26774
26774
  if (Array.isArray(o))
26775
26775
  return [...o];
@@ -26974,7 +26974,7 @@ var require_util7 = __commonJS({
26974
26974
  return clone(schema, def);
26975
26975
  }
26976
26976
  function extend(schema, shape) {
26977
- if (!isPlainObject2(shape)) {
26977
+ if (!isPlainObject3(shape)) {
26978
26978
  throw new Error("Invalid input to extend: expected a plain object");
26979
26979
  }
26980
26980
  const checks = schema._zod.def.checks;
@@ -26997,7 +26997,7 @@ var require_util7 = __commonJS({
26997
26997
  return clone(schema, def);
26998
26998
  }
26999
26999
  function safeExtend(schema, shape) {
27000
- if (!isPlainObject2(shape)) {
27000
+ if (!isPlainObject3(shape)) {
27001
27001
  throw new Error("Invalid input to safeExtend: expected a plain object");
27002
27002
  }
27003
27003
  const def = mergeDefs(schema._zod.def, {
@@ -54816,7 +54816,7 @@ var require_lodash = __commonJS({
54816
54816
  } else {
54817
54817
  newValue = [];
54818
54818
  }
54819
- } else if (isPlainObject2(srcValue) || isArguments(srcValue)) {
54819
+ } else if (isPlainObject3(srcValue) || isArguments(srcValue)) {
54820
54820
  newValue = objValue;
54821
54821
  if (isArguments(objValue)) {
54822
54822
  newValue = toPlainObject(objValue);
@@ -55780,7 +55780,7 @@ var require_lodash = __commonJS({
55780
55780
  return objValue;
55781
55781
  }
55782
55782
  function customOmitClone(value) {
55783
- return isPlainObject2(value) ? undefined2 : value;
55783
+ return isPlainObject3(value) ? undefined2 : value;
55784
55784
  }
55785
55785
  function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
55786
55786
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
@@ -57281,7 +57281,7 @@ var require_lodash = __commonJS({
57281
57281
  var isBuffer = nativeIsBuffer || stubFalse;
57282
57282
  var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
57283
57283
  function isElement(value) {
57284
- return isObjectLike(value) && value.nodeType === 1 && !isPlainObject2(value);
57284
+ return isObjectLike(value) && value.nodeType === 1 && !isPlainObject3(value);
57285
57285
  }
57286
57286
  function isEmpty(value) {
57287
57287
  if (value == null) {
@@ -57317,7 +57317,7 @@ var require_lodash = __commonJS({
57317
57317
  return false;
57318
57318
  }
57319
57319
  var tag = baseGetTag(value);
57320
- return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject2(value);
57320
+ return tag == errorTag || tag == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject3(value);
57321
57321
  }
57322
57322
  function isFinite2(value) {
57323
57323
  return typeof value == "number" && nativeIsFinite(value);
@@ -57368,7 +57368,7 @@ var require_lodash = __commonJS({
57368
57368
  function isNumber(value) {
57369
57369
  return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
57370
57370
  }
57371
- function isPlainObject2(value) {
57371
+ function isPlainObject3(value) {
57372
57372
  if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
57373
57373
  return false;
57374
57374
  }
@@ -58439,7 +58439,7 @@ var require_lodash = __commonJS({
58439
58439
  lodash.isNumber = isNumber;
58440
58440
  lodash.isObject = isObject;
58441
58441
  lodash.isObjectLike = isObjectLike;
58442
- lodash.isPlainObject = isPlainObject2;
58442
+ lodash.isPlainObject = isPlainObject3;
58443
58443
  lodash.isRegExp = isRegExp;
58444
58444
  lodash.isSafeInteger = isSafeInteger;
58445
58445
  lodash.isSet = isSet;
@@ -99439,7 +99439,7 @@ var require_response2 = __commonJS({
99439
99439
  }
99440
99440
  return stream;
99441
99441
  };
99442
- var Response;
99442
+ var Response2;
99443
99443
  _.inherit(
99444
99444
  /**
99445
99445
  * Response holds data related to the request body. By default, it provides a nice wrapper for url-encoded,
@@ -99450,14 +99450,14 @@ var require_response2 = __commonJS({
99450
99450
  *
99451
99451
  * @param {Response.definition} options -
99452
99452
  */
99453
- Response = function PostmanResponse(options) {
99454
- Response.super_.apply(this, arguments);
99453
+ Response2 = function PostmanResponse(options) {
99454
+ Response2.super_.apply(this, arguments);
99455
99455
  this.update(options || {});
99456
99456
  },
99457
99457
  Property
99458
99458
  );
99459
99459
  _.assign(
99460
- Response.prototype,
99460
+ Response2.prototype,
99461
99461
  /** @lends Response.prototype */
99462
99462
  {
99463
99463
  update(options) {
@@ -99523,7 +99523,7 @@ var require_response2 = __commonJS({
99523
99523
  }
99524
99524
  );
99525
99525
  _.assign(
99526
- Response.prototype,
99526
+ Response2.prototype,
99527
99527
  /** @lends Response.prototype */
99528
99528
  {
99529
99529
  /**
@@ -99701,7 +99701,7 @@ var require_response2 = __commonJS({
99701
99701
  }
99702
99702
  );
99703
99703
  _.assign(
99704
- Response,
99704
+ Response2,
99705
99705
  /** @lends Response */
99706
99706
  {
99707
99707
  /**
@@ -99719,7 +99719,7 @@ var require_response2 = __commonJS({
99719
99719
  * @returns {Boolean}
99720
99720
  */
99721
99721
  isResponse: function(obj) {
99722
- return Boolean(obj) && (obj instanceof Response || _.inSuperChain(obj.constructor, "_postman_propertyName", Response._postman_propertyName));
99722
+ return Boolean(obj) && (obj instanceof Response2 || _.inSuperChain(obj.constructor, "_postman_propertyName", Response2._postman_propertyName));
99723
99723
  },
99724
99724
  /**
99725
99725
  * Converts the response object from the request module to the postman responseBody format
@@ -99730,7 +99730,7 @@ var require_response2 = __commonJS({
99730
99730
  * @todo Add a key: `originalRequest` to the returned object as well, referring to response.request
99731
99731
  */
99732
99732
  createFromNode: function(response, cookies) {
99733
- return new Response({
99733
+ return new Response2({
99734
99734
  cookie: cookies,
99735
99735
  body: response.body.toString(),
99736
99736
  stream: response.body,
@@ -99809,7 +99809,7 @@ var require_response2 = __commonJS({
99809
99809
  }
99810
99810
  );
99811
99811
  module2.exports = {
99812
- Response
99812
+ Response: Response2
99813
99813
  };
99814
99814
  }
99815
99815
  });
@@ -99823,7 +99823,7 @@ var require_item = __commonJS({
99823
99823
  var EventList = require_event_list().EventList;
99824
99824
  var Request = require_request13().Request;
99825
99825
  var RequestAuth = require_request_auth().RequestAuth;
99826
- var Response = require_response2().Response;
99826
+ var Response2 = require_response2().Response;
99827
99827
  var Item;
99828
99828
  var OBJECT = "object";
99829
99829
  var STRING = "string";
@@ -99890,7 +99890,7 @@ var require_item = __commonJS({
99890
99890
  *
99891
99891
  * @type {PropertyList<Response>}
99892
99892
  */
99893
- responses: new PropertyList(Response, this, definition && definition.response),
99893
+ responses: new PropertyList(Response2, this, definition && definition.response),
99894
99894
  /**
99895
99895
  * Events are a set of of {@link Script}s that are executed when certain activities are triggered on an
99896
99896
  * Item. For example, on defining an event that listens to the "test" event, would cause the associated
@@ -131082,7 +131082,8 @@ function getIDToken(aud) {
131082
131082
  }
131083
131083
 
131084
131084
  // src/index.ts
131085
- var import_node_fs4 = require("node:fs");
131085
+ var import_node_crypto4 = require("node:crypto");
131086
+ var import_node_fs5 = require("node:fs");
131086
131087
  var path8 = __toESM(require("node:path"), 1);
131087
131088
 
131088
131089
  // node_modules/js-yaml/dist/js-yaml.mjs
@@ -133998,6 +133999,7 @@ function dump(input, options = {}) {
133998
133999
  }
133999
134000
 
134000
134001
  // src/postman-v3/converter.ts
134002
+ var import_node_fs = require("node:fs");
134001
134003
  var fs3 = __toESM(require("node:fs/promises"), 1);
134002
134004
  var path6 = __toESM(require("node:path"), 1);
134003
134005
  var V2 = __toESM(require_v2(), 1);
@@ -134068,6 +134070,72 @@ function structuredCloneSafe(value) {
134068
134070
  if (typeof structuredClone === "function") return structuredClone(value);
134069
134071
  return JSON.parse(JSON.stringify(value));
134070
134072
  }
134073
+ var ArtifactDigestStreamError = class extends Error {
134074
+ code = "ARTIFACT_DIGEST_STREAM";
134075
+ constructor(message, options) {
134076
+ super(message, options);
134077
+ this.name = "ArtifactDigestStreamError";
134078
+ }
134079
+ };
134080
+ function sameFileIdentity(left, right) {
134081
+ return left.dev === right.dev && left.ino === right.ino && left.size === right.size;
134082
+ }
134083
+ async function appendArtifactDigestFileStreaming(hash, relative4, absolute, expected) {
134084
+ const flags = typeof import_node_fs.constants.O_NOFOLLOW === "number" ? import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NOFOLLOW : import_node_fs.constants.O_RDONLY;
134085
+ let handle;
134086
+ try {
134087
+ handle = await fs3.open(absolute, flags);
134088
+ } catch (error2) {
134089
+ const code = error2?.code;
134090
+ if (code === "ELOOP" || code === "EMLINK" || code === "EINVAL") {
134091
+ throw new ArtifactDigestStreamError(
134092
+ `prebuilt collection tree file became a symlink or unsupported node at ${relative4}`,
134093
+ { cause: error2 }
134094
+ );
134095
+ }
134096
+ throw new ArtifactDigestStreamError(
134097
+ `prebuilt collection tree file changed or became unsupported at ${relative4}`,
134098
+ { cause: error2 }
134099
+ );
134100
+ }
134101
+ try {
134102
+ const before = await handle.stat();
134103
+ if (!before.isFile() || !sameFileIdentity(before, expected)) {
134104
+ throw new ArtifactDigestStreamError(
134105
+ `prebuilt collection tree file changed or became unsupported at ${relative4}`
134106
+ );
134107
+ }
134108
+ hash.update(relative4);
134109
+ hash.update("\0");
134110
+ const content = Buffer.allocUnsafe(expected.size);
134111
+ let total = 0;
134112
+ const buffer = Buffer.alloc(64 * 1024);
134113
+ for (; ; ) {
134114
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, null);
134115
+ if (bytesRead === 0) {
134116
+ break;
134117
+ }
134118
+ if (total + bytesRead > expected.size) {
134119
+ throw new ArtifactDigestStreamError(
134120
+ `prebuilt collection tree file changed while reading at ${relative4}`
134121
+ );
134122
+ }
134123
+ buffer.copy(content, total, 0, bytesRead);
134124
+ hash.update(buffer.subarray(0, bytesRead));
134125
+ total += bytesRead;
134126
+ }
134127
+ hash.update("\0");
134128
+ const after = await handle.stat();
134129
+ if (!after.isFile() || !sameFileIdentity(after, expected) || total !== expected.size) {
134130
+ throw new ArtifactDigestStreamError(
134131
+ `prebuilt collection tree file changed while reading at ${relative4}`
134132
+ );
134133
+ }
134134
+ return total === expected.size ? content : content.subarray(0, total);
134135
+ } finally {
134136
+ await handle.close();
134137
+ }
134138
+ }
134071
134139
  async function listFilesRelative(dir, base) {
134072
134140
  let entries;
134073
134141
  try {
@@ -134628,7 +134696,7 @@ function getCiWorkflowTemplate(provider, options = {}) {
134628
134696
  }
134629
134697
 
134630
134698
  // src/lib/github/repo-mutation.ts
134631
- var import_node_fs = require("node:fs");
134699
+ var import_node_fs2 = require("node:fs");
134632
134700
  var import_node_path = __toESM(require("node:path"), 1);
134633
134701
 
134634
134702
  // src/lib/secrets.ts
@@ -134918,7 +134986,7 @@ var RepoMutationService = class {
134918
134986
  throw new Error(this.secretMasker(changed.stderr || changed.stdout || "Failed to inspect generated changes"));
134919
134987
  }
134920
134988
  const hasPlannedRemoval = removePaths.some(
134921
- (removePath) => (0, import_node_fs.existsSync)(import_node_path.default.resolve(this.cwd, removePath))
134989
+ (removePath) => (0, import_node_fs2.existsSync)(import_node_path.default.resolve(this.cwd, removePath))
134922
134990
  );
134923
134991
  if (!changed.stdout.trim() && !hasPlannedRemoval) {
134924
134992
  return {
@@ -134942,7 +135010,7 @@ var RepoMutationService = class {
134942
135010
  await this.execute("git", ["config", "user.name", options.committerName]);
134943
135011
  await this.execute("git", ["config", "user.email", options.committerEmail]);
134944
135012
  for (const removePath of removePaths) {
134945
- (0, import_node_fs.rmSync)(import_node_path.default.resolve(this.cwd, removePath), { force: true });
135013
+ (0, import_node_fs2.rmSync)(import_node_path.default.resolve(this.cwd, removePath), { force: true });
134946
135014
  }
134947
135015
  await this.execute("git", ["add", "-A", "--", ...stagePaths]);
134948
135016
  const staged = await this.execute("git", ["diff", "--cached", "--quiet"]);
@@ -135485,14 +135553,14 @@ function createTelemetryContext(options) {
135485
135553
  }
135486
135554
 
135487
135555
  // src/action-version.ts
135488
- var import_node_fs2 = require("node:fs");
135556
+ var import_node_fs3 = require("node:fs");
135489
135557
  var import_node_path2 = require("node:path");
135490
135558
  function resolveActionVersion2() {
135491
135559
  if (false) {
135492
135560
  return void 0;
135493
135561
  }
135494
135562
  try {
135495
- const raw = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
135563
+ const raw = (0, import_node_fs3.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
135496
135564
  return JSON.parse(raw).version ?? "unknown";
135497
135565
  } catch {
135498
135566
  return "unknown";
@@ -135557,6 +135625,54 @@ var HttpError = class _HttpError extends Error {
135557
135625
  }
135558
135626
  };
135559
135627
 
135628
+ // src/lib/postman/pmak-diagnostics.ts
135629
+ var memo = /* @__PURE__ */ new Map();
135630
+ var normalize3 = (value) => new URL(value.trim()).toString().replace(/\/+$/, "");
135631
+ function maskPmakDiagnostic(message, secrets) {
135632
+ let masked = String(message);
135633
+ for (const secret of secrets) if (secret) masked = masked.split(secret).join("***");
135634
+ return Array.from(masked, (character) => {
135635
+ const code = character.codePointAt(0) ?? 0;
135636
+ return code <= 31 || code >= 127 && code <= 159 ? " " : character;
135637
+ }).join("").replace(/\s+/g, " ").trim();
135638
+ }
135639
+ function formatRejectedMint(original, result) {
135640
+ const teamId = typeof result.payload?.user?.teamId === "number" ? ` (team ${(result.payload?.user).teamId})` : "";
135641
+ if (result.kind === "personal") return `Personal API key detected, cannot mint a service-account access token${teamId}.`;
135642
+ if (result.kind === "service-account") return `The postman-api-key authenticates (GET /me OK) but was rejected by POST /service-account-tokens${teamId} and lacks permission to mint access tokens.`;
135643
+ if (result.kind === "invalid") return "The postman-api-key is invalid, disabled, or expired.";
135644
+ return original;
135645
+ }
135646
+ async function inspectPmakIdentity(options) {
135647
+ const apiBaseUrl = normalize3(options.apiBaseUrl);
135648
+ const key = `${apiBaseUrl}\0${options.apiKey}`;
135649
+ let pending = memo.get(key);
135650
+ if (!pending) {
135651
+ pending = (async () => {
135652
+ try {
135653
+ const timeout = AbortSignal.timeout(options.timeoutMs ?? 2e3);
135654
+ const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
135655
+ const response = await (options.fetchImpl ?? fetch)(`${apiBaseUrl}/me`, { method: "GET", headers: { "X-Api-Key": options.apiKey }, signal });
135656
+ if (response.status === 401 || response.status === 403) return { kind: "invalid", status: response.status };
135657
+ if (!response.ok) return { kind: "inconclusive", status: response.status };
135658
+ const payload = await response.json().catch(() => void 0);
135659
+ const user = payload?.user;
135660
+ if (!user || typeof user !== "object" || Array.isArray(user)) return { kind: "inconclusive", payload };
135661
+ const record = user;
135662
+ if (typeof record.username === "string" && record.username || typeof record.email === "string" && record.email) return { kind: "personal", status: response.status, payload };
135663
+ if ("username" in record && "email" in record && (record.username == null || record.username === "") && (record.email == null || record.email === "")) return { kind: "service-account", status: response.status, payload };
135664
+ return { kind: "inconclusive", payload };
135665
+ } catch {
135666
+ return { kind: "inconclusive" };
135667
+ }
135668
+ })();
135669
+ memo.set(key, pending);
135670
+ }
135671
+ const result = await pending;
135672
+ if (options.mode === "preflight" && result.kind === "inconclusive") memo.delete(key);
135673
+ return result;
135674
+ }
135675
+
135560
135676
  // src/lib/postman/credential-identity.ts
135561
135677
  var sessionPath = "/api/sessions/current";
135562
135678
  var SESSION_MAX_ATTEMPTS = 3;
@@ -135650,14 +135766,8 @@ async function resolvePmakIdentity(opts) {
135650
135766
  }
135651
135767
  async function probePmakIdentity(baseUrl, apiKey, fetchImpl) {
135652
135768
  try {
135653
- const response = await fetchImpl(`${baseUrl}/me`, {
135654
- method: "GET",
135655
- headers: { "X-Api-Key": apiKey }
135656
- });
135657
- if (!response.ok) {
135658
- return void 0;
135659
- }
135660
- const payload = asRecord(await response.json());
135769
+ const diagnostic = await inspectPmakIdentity({ apiBaseUrl: baseUrl, apiKey, fetchImpl });
135770
+ const payload = asRecord(diagnostic.payload);
135661
135771
  const user = asRecord(payload?.user);
135662
135772
  if (!user) {
135663
135773
  return void 0;
@@ -135689,7 +135799,8 @@ async function resolveSessionIdentity(opts) {
135689
135799
  opts.fetchImpl ?? fetch,
135690
135800
  Math.max(1, opts.maxAttempts ?? SESSION_MAX_ATTEMPTS),
135691
135801
  opts.sleepImpl ?? defaultSessionSleep,
135692
- opts.randomImpl ?? defaultRandom
135802
+ opts.randomImpl ?? defaultRandom,
135803
+ opts.onRetryEvent
135693
135804
  );
135694
135805
  sessionMemo.set(memoKey, pending);
135695
135806
  }
@@ -135723,7 +135834,7 @@ async function parseSessionResponse(response) {
135723
135834
  consumerType: coerceText(root.consumerType) ?? coerceText(data?.consumerType) ?? coerceText(user?.consumerType)
135724
135835
  };
135725
135836
  }
135726
- async function probeSessionIdentity(baseUrl, accessToken, fetchImpl, maxAttempts, sleepImpl, random) {
135837
+ async function probeSessionIdentity(baseUrl, accessToken, fetchImpl, maxAttempts, sleepImpl, random, onRetryEvent) {
135727
135838
  let failure = "unavailable";
135728
135839
  for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
135729
135840
  let response;
@@ -135735,7 +135846,9 @@ async function probeSessionIdentity(baseUrl, accessToken, fetchImpl, maxAttempts
135735
135846
  } catch {
135736
135847
  failure = "unavailable";
135737
135848
  if (attempt < maxAttempts) {
135738
- await sleepImpl(computeSessionRetryDelayMs(void 0, attempt, random));
135849
+ const delay = computeSessionRetryDelayMs(void 0, attempt, random);
135850
+ onRetryEvent?.({ class: "transport", attempt, delay });
135851
+ await sleepImpl(delay);
135739
135852
  continue;
135740
135853
  }
135741
135854
  break;
@@ -135757,7 +135870,9 @@ async function probeSessionIdentity(baseUrl, accessToken, fetchImpl, maxAttempts
135757
135870
  if (response.status === 429 || response.status >= 500) {
135758
135871
  failure = "unavailable";
135759
135872
  if (attempt < maxAttempts) {
135760
- await sleepImpl(computeSessionRetryDelayMs(response, attempt, random));
135873
+ const delay = computeSessionRetryDelayMs(response, attempt, random);
135874
+ onRetryEvent?.({ class: "http", status: response.status, attempt, delay });
135875
+ await sleepImpl(delay);
135761
135876
  continue;
135762
135877
  }
135763
135878
  break;
@@ -135859,7 +135974,8 @@ async function runCredentialPreflight(args) {
135859
135974
  accessToken,
135860
135975
  fetchImpl: args.fetchImpl,
135861
135976
  ...args.sleepImpl ? { sleepImpl: args.sleepImpl } : {},
135862
- ...args.randomImpl ? { randomImpl: args.randomImpl } : {}
135977
+ ...args.randomImpl ? { randomImpl: args.randomImpl } : {},
135978
+ onRetryEvent: args.retryEvent ?? args.log.retryEvent
135863
135979
  });
135864
135980
  } catch (error2) {
135865
135981
  args.log.warning(
@@ -135959,6 +136075,39 @@ function adviseFromHttpError(err, ctx) {
135959
136075
  return new Error(ctx.mask(advice), { cause: err });
135960
136076
  }
135961
136077
 
136078
+ // src/lib/postman/app-version.ts
136079
+ var UPDATE_URL = "https://dl.pstmn.io/update/status?currentVersion=12.0.0&platform=osx_arm64";
136080
+ var FLOOR_VERSION = "12.0.0";
136081
+ var VERSION_PATTERN = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
136082
+ var PostmanAppVersionProvider = class {
136083
+ fetchImpl;
136084
+ requestTimeoutMs;
136085
+ pending;
136086
+ constructor(options = {}) {
136087
+ this.fetchImpl = options.fetchImpl ?? fetch;
136088
+ this.requestTimeoutMs = options.requestTimeoutMs ?? 2e3;
136089
+ }
136090
+ async get() {
136091
+ if (process.env.POSTMAN_GATEWAY_APP_VERSION === "off") return void 0;
136092
+ this.pending ??= this.resolve();
136093
+ return this.pending;
136094
+ }
136095
+ async resolve() {
136096
+ try {
136097
+ const response = await this.fetchImpl(UPDATE_URL, {
136098
+ signal: AbortSignal.timeout(this.requestTimeoutMs)
136099
+ });
136100
+ if (!response.ok) return FLOOR_VERSION;
136101
+ const payload = await response.json();
136102
+ const version = typeof payload.version === "string" ? payload.version : "";
136103
+ return VERSION_PATTERN.test(version) ? version : FLOOR_VERSION;
136104
+ } catch {
136105
+ return FLOOR_VERSION;
136106
+ }
136107
+ }
136108
+ };
136109
+ var defaultPostmanAppVersionProvider = new PostmanAppVersionProvider();
136110
+
135962
136111
  // src/lib/postman/internal-integration-adapter.ts
135963
136112
  function extractDuplicateWorkspaceId(body) {
135964
136113
  try {
@@ -135978,6 +136127,8 @@ var BifrostInternalIntegrationAdapter = class {
135978
136127
  secretMasker;
135979
136128
  teamId;
135980
136129
  workerBaseUrl;
136130
+ gateway;
136131
+ appVersionProvider;
135981
136132
  constructor(options) {
135982
136133
  this.accessToken = String(options.accessToken || "").trim();
135983
136134
  this.getAccessToken = options.getAccessToken;
@@ -135990,6 +136141,8 @@ var BifrostInternalIntegrationAdapter = class {
135990
136141
  this.workerBaseUrl = String(
135991
136142
  options.workerBaseUrl || "https://catalog-admin.postman-account2009.workers.dev"
135992
136143
  ).replace(/\/+$/, "");
136144
+ this.gateway = options.gateway;
136145
+ this.appVersionProvider = options.appVersionProvider ?? defaultPostmanAppVersionProvider;
135993
136146
  this.secretMasker = options.secretMasker ?? createSecretMasker([this.accessToken]);
135994
136147
  }
135995
136148
  /** Live access token: re-minted value when a provider accessor is wired, else the captured one. */
@@ -135997,7 +136150,7 @@ var BifrostInternalIntegrationAdapter = class {
135997
136150
  return this.getAccessToken ? String(this.getAccessToken() || "").trim() : this.accessToken;
135998
136151
  }
135999
136152
  /** Build Bifrost proxy headers. Only includes x-entity-team-id for org-mode teams. */
136000
- bifrostHeaders() {
136153
+ async bifrostHeaders() {
136001
136154
  const headers = {
136002
136155
  "Content-Type": "application/json",
136003
136156
  "x-access-token": this.currentToken()
@@ -136005,6 +136158,8 @@ var BifrostInternalIntegrationAdapter = class {
136005
136158
  if (this.teamId && this.orgMode) {
136006
136159
  headers["x-entity-team-id"] = this.teamId;
136007
136160
  }
136161
+ const appVersion = await this.appVersionProvider.get();
136162
+ if (appVersion) headers["x-app-version"] = appVersion;
136008
136163
  return headers;
136009
136164
  }
136010
136165
  /** Reactive error-advice context, enriched with the preflight session memo when present. */
@@ -136035,6 +136190,58 @@ var BifrostInternalIntegrationAdapter = class {
136035
136190
  if (associations.length === 0) {
136036
136191
  return;
136037
136192
  }
136193
+ const mode = process.env.POSTMAN_SYSTEM_ENV_ASSOCIATION_MODE ?? "direct";
136194
+ if (mode !== "direct" && mode !== "worker") {
136195
+ throw new Error("POSTMAN_SYSTEM_ENV_ASSOCIATION_MODE must be direct or worker");
136196
+ }
136197
+ if (mode === "direct") {
136198
+ if (!this.gateway) {
136199
+ throw new Error("Direct system-environment association requires the access-token gateway");
136200
+ }
136201
+ const groups = /* @__PURE__ */ new Map();
136202
+ for (const association of associations) {
136203
+ const systemEnvId = String(association.systemEnvId || "").trim();
136204
+ const uid = String(association.envUid || "").trim();
136205
+ if (!systemEnvId || !uid) continue;
136206
+ const key = `${systemEnvId}\0${workspaceId}`;
136207
+ const uids = groups.get(key) ?? /* @__PURE__ */ new Set();
136208
+ uids.add(uid);
136209
+ groups.set(key, uids);
136210
+ }
136211
+ for (const [key, uids] of [...groups.entries()].sort(([a], [b]) => a.localeCompare(b))) {
136212
+ const [systemEnvironmentId, groupedWorkspaceId] = key.split("\0");
136213
+ const postmanEnvironmentIds = [...uids].sort();
136214
+ let response2;
136215
+ try {
136216
+ response2 = await this.gateway.requestJson({
136217
+ service: "api-catalog",
136218
+ method: "post",
136219
+ path: "/api/system-envs/associations",
136220
+ body: {
136221
+ systemEnvironmentId,
136222
+ workspaceEntries: [{ workspaceId: groupedWorkspaceId, postmanEnvironmentIds }]
136223
+ },
136224
+ fallback: "none"
136225
+ }, { retryTransient: true });
136226
+ } catch (error2) {
136227
+ if (error2 instanceof HttpError) {
136228
+ throw adviseFromHttpError(error2, this.adviceContext("system environment association")) ?? error2;
136229
+ }
136230
+ throw error2;
136231
+ }
136232
+ if (!response2 || response2.success !== true) {
136233
+ throw new Error("SYSTEM_ENV_ASSOCIATION_INCOMPLETE");
136234
+ }
136235
+ if (response2.data !== void 0) {
136236
+ if (!Array.isArray(response2.data)) throw new Error("SYSTEM_ENV_ASSOCIATION_INCOMPLETE");
136237
+ const seen = new Set(response2.data.filter((row) => !!row && typeof row === "object").map((row) => `${row.systemEnvironmentId}\0${row.workspaceId}\0${row.postmanEnvironmentId}`));
136238
+ if (!postmanEnvironmentIds.every((uid) => seen.has(`${systemEnvironmentId}\0${groupedWorkspaceId}\0${uid}`))) {
136239
+ throw new Error("SYSTEM_ENV_ASSOCIATION_INCOMPLETE");
136240
+ }
136241
+ }
136242
+ }
136243
+ return;
136244
+ }
136038
136245
  const token = this.currentToken();
136039
136246
  const response = await this.fetchImpl(
136040
136247
  `${this.workerBaseUrl}/api/internal/system-envs/associate`,
@@ -136092,7 +136299,7 @@ var BifrostInternalIntegrationAdapter = class {
136092
136299
  try {
136093
136300
  const response = await this.fetchImpl(url, {
136094
136301
  method: "POST",
136095
- headers: this.bifrostHeaders(),
136302
+ headers: await this.bifrostHeaders(),
136096
136303
  body: JSON.stringify(payload)
136097
136304
  });
136098
136305
  let parsed = {};
@@ -136181,7 +136388,7 @@ var BifrostInternalIntegrationAdapter = class {
136181
136388
  versionControl: true
136182
136389
  }
136183
136390
  };
136184
- const headers = this.bifrostHeaders();
136391
+ const headers = await this.bifrostHeaders();
136185
136392
  const response = await this.fetchImpl(url, {
136186
136393
  method: "POST",
136187
136394
  headers,
@@ -136236,7 +136443,7 @@ var BifrostInternalIntegrationAdapter = class {
136236
136443
  try {
136237
136444
  const response = await this.fetchImpl(`${this.bifrostBaseUrl}/ws/proxy`, {
136238
136445
  method: "POST",
136239
- headers: this.bifrostHeaders(),
136446
+ headers: await this.bifrostHeaders(),
136240
136447
  body: JSON.stringify({
136241
136448
  service: "workspaces",
136242
136449
  method: "GET",
@@ -136267,7 +136474,7 @@ var BifrostInternalIntegrationAdapter = class {
136267
136474
  }
136268
136475
  async createApiKey(name) {
136269
136476
  const url = `${this.bifrostBaseUrl}/ws/proxy`;
136270
- const headers = this.bifrostHeaders();
136477
+ const headers = await this.bifrostHeaders();
136271
136478
  const payload = {
136272
136479
  service: "identity",
136273
136480
  method: "POST",
@@ -136352,6 +136559,16 @@ async function retry(operation, options = {}) {
136352
136559
  }
136353
136560
  throw new Error("Retry exhausted without returning or throwing");
136354
136561
  }
136562
+ function fullJitterDelayMs(attempt, baseMs, capMs, random = Math.random) {
136563
+ return Math.floor(random() * Math.max(0, Math.min(capMs, baseMs * 2 ** Math.max(0, attempt))));
136564
+ }
136565
+ function parseRetryAfterMs2(value) {
136566
+ const trimmed = value?.trim();
136567
+ if (!trimmed) return void 0;
136568
+ if (/^\d+$/.test(trimmed)) return Number(trimmed) * 1e3;
136569
+ const time = Date.parse(trimmed);
136570
+ return Number.isNaN(time) ? void 0 : Math.max(0, time - Date.now());
136571
+ }
136355
136572
 
136356
136573
  // src/contracts.ts
136357
136574
  var postmanRepoSyncActionContract = {
@@ -136410,6 +136627,11 @@ var postmanRepoSyncActionContract = {
136410
136627
  description: "Contract collection ID used for exported artifacts.",
136411
136628
  required: false
136412
136629
  },
136630
+ "prebuilt-collections-json": {
136631
+ description: "Optional digest-bound JSON manifest of unique baseline, smoke, or contract roles with confined repo-relative path, SHA-256 artifact digest of the on-disk v3 collection tree (sorted relative-path + NUL + bytes + NUL), and canonical cloud ID. The optional payloadDigest field is the semantic v2 payload digest carried for provenance (format-validated only, not the reuse gate). Exact role, path, cloudId, and artifactDigest matches reuse the on-disk tree without cloud export.",
136632
+ required: false,
136633
+ default: ""
136634
+ },
136413
136635
  "collection-sync-mode": {
136414
136636
  description: "Collection sync lifecycle mode (refresh or version).",
136415
136637
  required: false,
@@ -136652,7 +136874,7 @@ var postmanRepoSyncActionContract = {
136652
136874
  "Create or update Postman environments from runtime URLs.",
136653
136875
  "Associate Postman environments to system environments through Postman integration APIs.",
136654
136876
  "Create mock servers and smoke monitors from generated collections.",
136655
- "Export Postman collections in the Collection v3 multi-file YAML directory structure under `postman/collections/` (e.g., `<name>/collection.yaml`, nested folder and request YAML files), and export environments plus `.postman/resources.yaml` into the repository.",
136877
+ "Export Postman collections in the Collection v3 multi-file YAML directory structure under `postman/collections/` (canonical `.resources/definition.yaml` plus request/resource YAML files), and export environments plus `.postman/resources.yaml` into the repository.",
136656
136878
  "Link the Postman workspace to the repository (GitHub or GitLab) through Postman integration APIs.",
136657
136879
  "Commit synced artifacts and push them back to the current checked out ref."
136658
136880
  ],
@@ -136781,6 +137003,17 @@ var PostmanGatewayAssetsClient = class {
136781
137003
  return data.map((entry) => this.asRecord(entry)).filter((entry) => entry !== null).map((entry) => ({ uid: String(entry.id ?? entry.uid ?? "").trim(), name: String(entry.name ?? "").trim() })).filter((entry) => entry.uid && entry.name);
136782
137004
  }
136783
137005
  async getSpecContent(specId) {
137006
+ if (process.env.POSTMAN_SPEC_TREE_FAST_PATH !== "off") {
137007
+ try {
137008
+ const treeContent = await this.getSpecContentFromTree(specId);
137009
+ if (treeContent !== void 0) return treeContent;
137010
+ } catch (error2) {
137011
+ if (!(error2 instanceof HttpError) || ![403, 404, 405, 501].includes(error2.status)) throw error2;
137012
+ }
137013
+ }
137014
+ return this.getSpecContentLegacy(specId);
137015
+ }
137016
+ async getSpecContentLegacy(specId) {
136784
137017
  const files = await this.gateway.requestJson({
136785
137018
  service: "specification",
136786
137019
  method: "get",
@@ -136799,6 +137032,46 @@ var PostmanGatewayAssetsClient = class {
136799
137032
  const record = this.dataOf(file);
136800
137033
  return typeof record?.content === "string" ? record.content : void 0;
136801
137034
  }
137035
+ /** Minimal `/tree` reader: validate the entire returned inventory before selecting ROOT. */
137036
+ async getSpecContentFromTree(specId) {
137037
+ const rows = [];
137038
+ const cursors = /* @__PURE__ */ new Set();
137039
+ let cursor;
137040
+ for (let page = 0; page < 100; page += 1) {
137041
+ const response = await this.gateway.requestJson({
137042
+ service: "specification",
137043
+ method: "get",
137044
+ path: `/specifications/${specId}/tree`,
137045
+ query: { fields: "id,name,type,path,parentId,fileType,content", limit: 100, ...cursor ? { cursor } : {} }
137046
+ });
137047
+ if (!Array.isArray(response?.data)) return void 0;
137048
+ for (const value of response.data) {
137049
+ const row = this.asRecord(value);
137050
+ if (!row || row.type === "FOLDER") continue;
137051
+ if (row.type !== "FILE" || typeof row.id !== "string" || !row.id.trim() || typeof row.path !== "string" || !row.path.trim() || typeof row.content !== "string" || typeof row.fileType !== "string" || !row.fileType.trim()) return void 0;
137052
+ const path9 = row.path.replace(/\\/g, "/").normalize("NFC");
137053
+ if (path9.startsWith("/") || path9.split("/").some((part) => part === ".." || !part)) throw new Error("CONTRACT_DEFINITION_PATH_INVALID");
137054
+ rows.push({ ...row, path: path9 });
137055
+ }
137056
+ const meta = this.asRecord(response?.meta);
137057
+ const cursorValue = this.asRecord(meta?.cursor)?.next;
137058
+ const next = typeof cursorValue === "string" && cursorValue.trim() ? cursorValue.trim() : void 0;
137059
+ if (!next) break;
137060
+ if (cursors.has(next)) throw new Error("SPEC_TREE_CURSOR_REPEATED");
137061
+ cursors.add(next);
137062
+ if (page === 99) throw new Error("SPEC_TREE_PAGE_LIMIT_EXCEEDED");
137063
+ cursor = next;
137064
+ }
137065
+ const paths = /* @__PURE__ */ new Set();
137066
+ for (const row of rows) {
137067
+ const path9 = String(row.path).toLocaleLowerCase();
137068
+ if (paths.has(path9)) throw new Error("CONTRACT_DEFINITION_DUPLICATE_PATH");
137069
+ paths.add(path9);
137070
+ }
137071
+ const roots = rows.filter((row) => row.fileType === "ROOT");
137072
+ if (roots.length !== 1) throw new Error("CONTRACT_DEFINITION_INVENTORY_INVALID");
137073
+ return String(roots[0]?.content);
137074
+ }
136802
137075
  async listSpecCollections(specId) {
136803
137076
  const response = await this.gateway.requestJson({
136804
137077
  service: "specification",
@@ -137358,10 +137631,12 @@ var PostmanGatewayAssetsClient = class {
137358
137631
  // src/lib/postman/token-provider.ts
137359
137632
  var MintError = class extends Error {
137360
137633
  permanent;
137361
- constructor(message, permanent) {
137634
+ status;
137635
+ constructor(message, permanent, status) {
137362
137636
  super(message);
137363
137637
  this.name = "MintError";
137364
137638
  this.permanent = permanent;
137639
+ this.status = status;
137365
137640
  }
137366
137641
  };
137367
137642
  function extractAccessToken(payload) {
@@ -137384,6 +137659,7 @@ var AccessTokenProvider = class {
137384
137659
  maxAttempts;
137385
137660
  onToken;
137386
137661
  sleep;
137662
+ onRetryEvent;
137387
137663
  inflight;
137388
137664
  constructor(options) {
137389
137665
  this.token = String(options.accessToken || "").trim();
@@ -137395,6 +137671,7 @@ var AccessTokenProvider = class {
137395
137671
  this.maxAttempts = Math.max(1, options.maxAttempts ?? 2);
137396
137672
  this.onToken = options.onToken;
137397
137673
  this.sleep = options.sleep;
137674
+ this.onRetryEvent = options.onRetryEvent;
137398
137675
  }
137399
137676
  current() {
137400
137677
  return this.token;
@@ -137420,7 +137697,12 @@ var AccessTokenProvider = class {
137420
137697
  delayMs: 1e3,
137421
137698
  backoffMultiplier: 2,
137422
137699
  ...this.sleep ? { sleep: this.sleep } : {},
137423
- shouldRetry: (error2) => !(error2 instanceof MintError && error2.permanent)
137700
+ shouldRetry: (error2) => !(error2 instanceof MintError && error2.permanent),
137701
+ onRetry: ({ attempt, delayMs, error: error2 }) => {
137702
+ const status = error2 instanceof MintError ? error2.status : void 0;
137703
+ const retryClass = status === void 0 ? "transport" : "http";
137704
+ this.onRetryEvent?.({ class: retryClass, ...status === void 0 ? {} : { status }, attempt, delay: Math.max(0, delayMs) });
137705
+ }
137424
137706
  });
137425
137707
  this.token = token;
137426
137708
  this.onToken?.(token);
@@ -137441,7 +137723,8 @@ var AccessTokenProvider = class {
137441
137723
  if (status === 401 || status === 403) {
137442
137724
  throw new MintError(
137443
137725
  `postman: re-mint failed because the postman-api-key was rejected (PMAK rejected, HTTP ${status}); confirm it is a valid, enabled service-account PMAK for the intended team.`,
137444
- true
137726
+ true,
137727
+ status
137445
137728
  );
137446
137729
  }
137447
137730
  if (status === 400 && body.toLowerCase().includes("service accounts not enabled")) {
@@ -137450,7 +137733,7 @@ var AccessTokenProvider = class {
137450
137733
  true
137451
137734
  );
137452
137735
  }
137453
- throw new MintError(`postman: re-mint failed (service-account-tokens HTTP ${status}).`, false);
137736
+ throw new MintError(`postman: re-mint failed (service-account-tokens HTTP ${status}).`, false, status);
137454
137737
  }
137455
137738
  let parsed;
137456
137739
  try {
@@ -137466,26 +137749,9 @@ var AccessTokenProvider = class {
137466
137749
  }
137467
137750
  };
137468
137751
  async function describeMintFailure(mintError, apiKey, apiBaseUrl, fetchImpl) {
137469
- const raw = mintError instanceof Error ? mintError.message : String(mintError);
137470
- const rejected = /HTTP 40[13]|PMAK rejected/.test(raw);
137471
- if (!rejected) {
137472
- return raw;
137473
- }
137474
- try {
137475
- const me = await fetchImpl(`${apiBaseUrl}/me`, { headers: { "x-api-key": apiKey } });
137476
- if (me.ok) {
137477
- const body = await me.json().catch(() => void 0);
137478
- const user = body?.user;
137479
- const looksPersonal = Boolean(user && (user.username || user.email));
137480
- if (looksPersonal) {
137481
- return "Personal API key detected, cannot mint a service-account access token. POST /service-account-tokens only accepts a SERVICE-ACCOUNT API key; this postman-api-key belongs to a user account" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". Create a service account in Team Settings and use its PMAK, or mint the token elsewhere and pass postman-access-token.";
137482
- }
137483
- return "The postman-api-key authenticates (GET /me OK) but was rejected by POST /service-account-tokens" + (user?.teamId ? ` (team ${user.teamId})` : "") + ". The service account likely lacks permission to mint access tokens, or service accounts are restricted for this team. Check the service account role in Team Settings, or pass a pre-minted postman-access-token.";
137484
- }
137485
- return "The postman-api-key is invalid, disabled, or expired (rejected by both POST /service-account-tokens and GET /me). Generate a fresh service-account PMAK in Team Settings and update the secret.";
137486
- } catch {
137487
- return raw;
137488
- }
137752
+ const raw = maskPmakDiagnostic(mintError instanceof Error ? mintError.message : String(mintError), [apiKey]);
137753
+ if (!(mintError instanceof MintError) || mintError.status !== 401 && mintError.status !== 403) return raw;
137754
+ return formatRejectedMint(raw, await inspectPmakIdentity({ apiBaseUrl, apiKey, fetchImpl }));
137489
137755
  }
137490
137756
  async function mintAccessTokenIfNeeded(inputs, log, setSecret2, fetchImpl = fetch) {
137491
137757
  if (inputs.postmanAccessToken || !inputs.postmanApiKey) {
@@ -137498,7 +137764,8 @@ async function mintAccessTokenIfNeeded(inputs, log, setSecret2, fetchImpl = fetc
137498
137764
  apiKey: inputs.postmanApiKey,
137499
137765
  apiBaseUrl,
137500
137766
  fetchImpl,
137501
- onToken: (token) => setSecret2?.(token)
137767
+ onToken: (token) => setSecret2?.(token),
137768
+ onRetryEvent: (event) => log.retryEvent?.(event)
137502
137769
  });
137503
137770
  try {
137504
137771
  inputs.postmanAccessToken = await provider.refresh();
@@ -137534,6 +137801,11 @@ var AccessTokenGatewayClient = class {
137534
137801
  fallbackBaseUrl;
137535
137802
  retryBaseDelayMs;
137536
137803
  sleepImpl;
137804
+ appVersionProvider;
137805
+ requestTimeoutMs;
137806
+ retryMaxDelayMs;
137807
+ randomImpl;
137808
+ onRetryEvent;
137537
137809
  constructor(options) {
137538
137810
  this.tokenProvider = options.tokenProvider;
137539
137811
  this.bifrostBaseUrl = String(
@@ -137548,16 +137820,23 @@ var AccessTokenGatewayClient = class {
137548
137820
  this.fallbackBaseUrl = fallbackEnv === "off" ? void 0 : options.fallbackBaseUrl?.replace(/\/+$/, "");
137549
137821
  this.retryBaseDelayMs = options.retryBaseDelayMs ?? 400;
137550
137822
  this.sleepImpl = options.sleepImpl ?? defaultSleep;
137823
+ this.appVersionProvider = options.appVersionProvider ?? defaultPostmanAppVersionProvider;
137824
+ this.requestTimeoutMs = options.requestTimeoutMs ?? 3e4;
137825
+ this.retryMaxDelayMs = options.retryMaxDelayMs ?? 5e3;
137826
+ this.randomImpl = options.randomImpl ?? Math.random;
137827
+ this.onRetryEvent = options.onRetryEvent;
137551
137828
  }
137552
137829
  configureTeamContext(teamId, orgMode) {
137553
137830
  this.teamId = String(teamId || "").trim();
137554
137831
  this.orgMode = orgMode;
137555
137832
  }
137556
- buildHeaders(extra) {
137833
+ async buildHeaders(extra) {
137834
+ const appVersion = await this.appVersionProvider.get();
137557
137835
  const headers = {
137558
137836
  "Content-Type": "application/json",
137559
137837
  "x-access-token": this.tokenProvider.current(),
137560
- ...extra || {}
137838
+ ...extra || {},
137839
+ ...appVersion ? { "x-app-version": appVersion } : {}
137561
137840
  };
137562
137841
  if (this.teamId && this.orgMode) {
137563
137842
  headers["x-entity-team-id"] = this.teamId;
@@ -137566,17 +137845,24 @@ var AccessTokenGatewayClient = class {
137566
137845
  }
137567
137846
  async send(request, baseUrl) {
137568
137847
  const url = `${baseUrl ?? this.bifrostBaseUrl}/ws/proxy`;
137569
- return this.fetchImpl(url, {
137570
- method: "POST",
137571
- headers: this.buildHeaders(request.headers),
137572
- body: JSON.stringify({
137573
- service: request.service,
137574
- method: request.method,
137575
- path: request.path,
137576
- ...request.query !== void 0 ? { query: request.query } : {},
137577
- ...request.body !== void 0 ? { body: request.body } : {}
137578
- })
137579
- });
137848
+ const controller = new AbortController();
137849
+ const timer = setTimeout(() => controller.abort(), this.requestTimeoutMs);
137850
+ try {
137851
+ return await this.fetchImpl(url, {
137852
+ method: "POST",
137853
+ headers: await this.buildHeaders(request.headers),
137854
+ signal: controller.signal,
137855
+ body: JSON.stringify({
137856
+ service: request.service,
137857
+ method: request.method,
137858
+ path: request.path,
137859
+ ...request.query !== void 0 ? { query: request.query } : {},
137860
+ ...request.body !== void 0 ? { body: request.body } : {}
137861
+ })
137862
+ });
137863
+ } finally {
137864
+ clearTimeout(timer);
137865
+ }
137580
137866
  }
137581
137867
  /**
137582
137868
  * One cold, serial attempt against the fallback base URL after the primary
@@ -137603,11 +137889,13 @@ var AccessTokenGatewayClient = class {
137603
137889
  * they are the freshest authoritative answer.
137604
137890
  */
137605
137891
  fallbackEligible(request, retryTransient) {
137892
+ if (request.fallback === "none") return false;
137606
137893
  if (!this.fallbackBaseUrl) return false;
137607
137894
  return retryTransient || request.fallback === "auto";
137608
137895
  }
137609
- async attemptFallback(request, retryTransient) {
137896
+ async attemptFallback(request, retryTransient, status) {
137610
137897
  if (!this.fallbackEligible(request, retryTransient)) return null;
137898
+ this.emitRetryEvent("fallback", status, 1, 0);
137611
137899
  const response = await this.tryFallback(request);
137612
137900
  if (!response) return null;
137613
137901
  if (response.ok) return response;
@@ -137632,7 +137920,8 @@ var AccessTokenGatewayClient = class {
137632
137920
  response = await this.send(request);
137633
137921
  } catch (error2) {
137634
137922
  if (retryTransient && attempt < this.maxRetries) {
137635
- const delay = this.retryBaseDelayMs * 2 ** attempt;
137923
+ const delay = this.retryDelayMs(attempt);
137924
+ this.emitRetryEvent("transport", void 0, attempt + 1, delay);
137636
137925
  attempt += 1;
137637
137926
  await this.sleepImpl(delay);
137638
137927
  continue;
@@ -137642,10 +137931,23 @@ var AccessTokenGatewayClient = class {
137642
137931
  throw error2;
137643
137932
  }
137644
137933
  if (response.ok) {
137645
- return response;
137934
+ const okBody = await response.text().catch(() => "");
137935
+ const inner = this.innerStatus(okBody);
137936
+ if (inner !== void 0) {
137937
+ if (retryTransient && this.isTransient(inner, okBody) && attempt < this.maxRetries) {
137938
+ const delay = this.retryDelayMs(attempt);
137939
+ this.emitRetryEvent("inner", inner, attempt + 1, delay);
137940
+ await this.sleepImpl(delay);
137941
+ attempt += 1;
137942
+ continue;
137943
+ }
137944
+ throw this.toInnerHttpError(request, inner, okBody);
137945
+ }
137946
+ return this.rebuildResponse(response, okBody);
137646
137947
  }
137647
137948
  const body = await response.text().catch(() => "");
137648
137949
  if (isExpiredAuthError(response.status, body) && this.tokenProvider.canRefresh()) {
137950
+ this.emitRetryEvent("auth", response.status, 1, 0);
137649
137951
  await this.tokenProvider.refresh();
137650
137952
  response = await this.send(request);
137651
137953
  if (response.ok) {
@@ -137654,17 +137956,44 @@ var AccessTokenGatewayClient = class {
137654
137956
  const retryBody = await response.text().catch(() => "");
137655
137957
  throw this.toHttpError(request, response, retryBody);
137656
137958
  }
137657
- if (retryTransient && isRetryableSafeReadResponse(response.status) && attempt < this.maxRetries) {
137658
- const delay = this.retryBaseDelayMs * 2 ** attempt;
137959
+ if (retryTransient && this.isTransient(response.status, body) && attempt < this.maxRetries) {
137960
+ const delay = this.retryDelayMs(attempt, parseRetryAfterMs2(response.headers.get("retry-after")));
137961
+ this.emitRetryEvent("http", response.status, attempt + 1, delay);
137659
137962
  attempt += 1;
137660
137963
  await this.sleepImpl(delay);
137661
137964
  continue;
137662
137965
  }
137663
- const fallbackResponse = await this.attemptFallback(request, retryTransient);
137966
+ const fallbackResponse = await this.attemptFallback(request, retryTransient, response.status);
137664
137967
  if (fallbackResponse) return fallbackResponse;
137665
137968
  throw this.toHttpError(request, response, body);
137666
137969
  }
137667
137970
  }
137971
+ retryDelayMs(attempt, retryAfter) {
137972
+ return retryAfter === void 0 ? fullJitterDelayMs(attempt, this.retryBaseDelayMs, this.retryMaxDelayMs, this.randomImpl) : Math.min(this.retryMaxDelayMs, retryAfter);
137973
+ }
137974
+ emitRetryEvent(retryClass, status, attempt, delay) {
137975
+ this.onRetryEvent?.({
137976
+ class: retryClass,
137977
+ ...status === void 0 ? {} : { status },
137978
+ attempt: Math.max(1, attempt),
137979
+ delay: Math.max(0, delay)
137980
+ });
137981
+ }
137982
+ isTransient(status, body) {
137983
+ return status === 408 || status === 429 || status >= 500 || /ESOCKETTIMEDOUT|ETIMEDOUT|ECONNRESET|serverError|downstream/.test(body);
137984
+ }
137985
+ innerStatus(body) {
137986
+ try {
137987
+ const value = JSON.parse(body);
137988
+ const status = Number(value.status ?? value.statusCode);
137989
+ return value.error || value.success === false || status >= 400 ? status >= 400 ? status : 502 : void 0;
137990
+ } catch {
137991
+ return void 0;
137992
+ }
137993
+ }
137994
+ rebuildResponse(response, body) {
137995
+ return new Response([204, 205, 304].includes(response.status) ? null : body, { status: response.status, statusText: response.statusText, headers: response.headers });
137996
+ }
137668
137997
  /** Send a gateway request and parse the JSON body, or null when empty. */
137669
137998
  async requestJson(request, options = {}) {
137670
137999
  const response = await this.request(request, options);
@@ -137711,11 +138040,19 @@ var AccessTokenGatewayClient = class {
137711
138040
  url: `${this.bifrostBaseUrl}/ws/proxy (${request.service}: ${request.method} ${request.path})`,
137712
138041
  status: response.status,
137713
138042
  statusText: response.statusText,
137714
- requestHeaders: this.buildHeaders(request.headers),
138043
+ requestHeaders: {
138044
+ "Content-Type": "application/json",
138045
+ "x-access-token": this.tokenProvider.current(),
138046
+ ...request.headers || {},
138047
+ ...this.teamId && this.orgMode ? { "x-entity-team-id": this.teamId } : {}
138048
+ },
137715
138049
  responseBody: this.secretMasker(body),
137716
138050
  secretValues: [this.tokenProvider.current()]
137717
138051
  });
137718
138052
  }
138053
+ toInnerHttpError(request, status, body) {
138054
+ return new HttpError({ method: request.method.toUpperCase(), url: `${this.bifrostBaseUrl}/ws/proxy (${request.service}: ${request.method} ${request.path}) [inner]`, status, statusText: "Inner Error", requestHeaders: { "x-access-token": this.tokenProvider.current() }, responseBody: this.secretMasker(body), secretValues: [this.tokenProvider.current()] });
138055
+ }
137719
138056
  };
137720
138057
 
137721
138058
  // src/lib/ssl-validation.ts
@@ -137771,7 +138108,7 @@ function validateCertMaterial(certBase64, keyBase64, passphrase) {
137771
138108
  }
137772
138109
 
137773
138110
  // src/lib/repo/branch-decision.ts
137774
- var import_node_fs3 = require("node:fs");
138111
+ var import_node_fs4 = require("node:fs");
137775
138112
  var import_node_crypto3 = require("node:crypto");
137776
138113
  var ContractError = class extends Error {
137777
138114
  code;
@@ -137812,7 +138149,7 @@ function readGithubEvent(env) {
137812
138149
  const path9 = clean(env.GITHUB_EVENT_PATH);
137813
138150
  if (!path9) return void 0;
137814
138151
  try {
137815
- return JSON.parse((0, import_node_fs3.readFileSync)(path9, "utf8"));
138152
+ return JSON.parse((0, import_node_fs4.readFileSync)(path9, "utf8"));
137816
138153
  } catch {
137817
138154
  return void 0;
137818
138155
  }
@@ -138268,6 +138605,7 @@ function resolveInputs(env = process.env) {
138268
138605
  baselineCollectionId: getInput2("baseline-collection-id", env),
138269
138606
  smokeCollectionId: getInput2("smoke-collection-id", env),
138270
138607
  contractCollectionId: getInput2("contract-collection-id", env),
138608
+ prebuiltCollectionsJson: getInput2("prebuilt-collections-json", env),
138271
138609
  specId: getInput2("spec-id", env),
138272
138610
  specContentChanged: parseBooleanInput(getInput2("spec-content-changed", env), true),
138273
138611
  specPath: getInput2("spec-path", env),
@@ -138383,7 +138721,7 @@ var StateUnreadableError = class extends Error {
138383
138721
  function readResourcesState() {
138384
138722
  let raw;
138385
138723
  try {
138386
- raw = (0, import_node_fs4.readFileSync)(".postman/resources.yaml", "utf8");
138724
+ raw = (0, import_node_fs5.readFileSync)(".postman/resources.yaml", "utf8");
138387
138725
  } catch {
138388
138726
  return null;
138389
138727
  }
@@ -138442,12 +138780,15 @@ function getEnvironmentUidsFromResources(resourcesState) {
138442
138780
  function normalizeToPosix(filePath) {
138443
138781
  return filePath.split(path8.sep).join("/").replace(/\\/g, "/");
138444
138782
  }
138783
+ function canonicalizeRelativePath(value) {
138784
+ return normalizeToPosix(String(value ?? "").trim()).replace(/^\.\/+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/g, "");
138785
+ }
138445
138786
  function isOpenApiSpecFile(filePath) {
138446
138787
  if (!(filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml"))) {
138447
138788
  return false;
138448
138789
  }
138449
138790
  try {
138450
- const raw = (0, import_node_fs4.readFileSync)(filePath, "utf8");
138791
+ const raw = (0, import_node_fs5.readFileSync)(filePath, "utf8");
138451
138792
  const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
138452
138793
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
138453
138794
  return false;
@@ -138476,7 +138817,7 @@ function scanLocalSpecReferences(baseDir = ".") {
138476
138817
  const found = /* @__PURE__ */ new Set();
138477
138818
  const refs = [];
138478
138819
  const visit2 = (currentDir) => {
138479
- for (const entry of (0, import_node_fs4.readdirSync)(currentDir, { withFileTypes: true })) {
138820
+ for (const entry of (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true })) {
138480
138821
  if (ignoredDirs.has(entry.name)) {
138481
138822
  continue;
138482
138823
  }
@@ -138506,7 +138847,7 @@ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
138506
138847
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
138507
138848
  if (normalizedExplicitPath) {
138508
138849
  const explicitFullPath = path8.resolve(normalizedExplicitPath);
138509
- if ((0, import_node_fs4.existsSync)(explicitFullPath) && (0, import_node_fs4.statSync)(explicitFullPath).isFile()) {
138850
+ if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
138510
138851
  return {
138511
138852
  repoRelativePath: normalizedExplicitPath,
138512
138853
  configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
@@ -138558,6 +138899,7 @@ function readActionInputs(actionCore) {
138558
138899
  INPUT_BASELINE_COLLECTION_ID: readInput(actionCore, "baseline-collection-id"),
138559
138900
  INPUT_SMOKE_COLLECTION_ID: readInput(actionCore, "smoke-collection-id"),
138560
138901
  INPUT_CONTRACT_COLLECTION_ID: readInput(actionCore, "contract-collection-id"),
138902
+ INPUT_PREBUILT_COLLECTIONS_JSON: readInput(actionCore, "prebuilt-collections-json"),
138561
138903
  INPUT_SPEC_ID: readInput(actionCore, "spec-id"),
138562
138904
  INPUT_SPEC_PATH: readInput(actionCore, "spec-path"),
138563
138905
  INPUT_COLLECTION_SYNC_MODE: readInput(actionCore, "collection-sync-mode") || "refresh",
@@ -138771,6 +139113,7 @@ async function upsertEnvironments(inputs, dependencies, resourcesState, assetMar
138771
139113
  );
138772
139114
  }
138773
139115
  envUids[envName] = existingUid;
139116
+ dependencies.core.setOutput("environment-uids-json", JSON.stringify(envUids));
138774
139117
  continue;
138775
139118
  }
138776
139119
  const values = buildEnvironmentValues(envName, runtimeUrl);
@@ -138781,6 +139124,7 @@ async function upsertEnvironments(inputs, dependencies, resourcesState, assetMar
138781
139124
  displayName,
138782
139125
  values
138783
139126
  );
139127
+ dependencies.core.setOutput("environment-uids-json", JSON.stringify(envUids));
138784
139128
  } catch (error2) {
138785
139129
  throw new Error(
138786
139130
  formatOrchestrationIssue({
@@ -138797,7 +139141,7 @@ async function upsertEnvironments(inputs, dependencies, resourcesState, assetMar
138797
139141
  return envUids;
138798
139142
  }
138799
139143
  function ensureDir(path9) {
138800
- (0, import_node_fs4.mkdirSync)(path9, { recursive: true });
139144
+ (0, import_node_fs5.mkdirSync)(path9, { recursive: true });
138801
139145
  }
138802
139146
  function getCollectionDirectoryName(kind, projectName) {
138803
139147
  if (kind === "Baseline") {
@@ -138832,9 +139176,9 @@ function stripVolatileFields(obj) {
138832
139176
  }
138833
139177
  return obj;
138834
139178
  }
138835
- function writeJsonFile(path9, content, normalize3 = false) {
138836
- const data = normalize3 ? stripVolatileFields(content) : content;
138837
- (0, import_node_fs4.writeFileSync)(path9, JSON.stringify(data, null, 2));
139179
+ function writeJsonFile(path9, content, normalize4 = false) {
139180
+ const data = normalize4 ? stripVolatileFields(content) : content;
139181
+ (0, import_node_fs5.writeFileSync)(path9, JSON.stringify(data, null, 2));
138838
139182
  }
138839
139183
  function buildMappedSpecCloudKey(mappedSource, specSyncMode, releaseLabel) {
138840
139184
  if (specSyncMode !== "version") {
@@ -138898,22 +139242,422 @@ function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir,
138898
139242
  sortKeys: false
138899
139243
  });
138900
139244
  }
138901
- function buildSpecCollectionWorkflowManifest(specRef, collectionRefs) {
138902
- return dump(
138903
- {
138904
- workflows: {
138905
- syncSpecToCollection: collectionRefs.map((collectionRef) => ({
138906
- spec: specRef,
138907
- collection: collectionRef
138908
- }))
139245
+ function isPlainObject2(value) {
139246
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
139247
+ }
139248
+ function buildSpecCollectionWorkflowManifest(specRef, collectionRefs, existingRaw) {
139249
+ const pairs = collectionRefs.map((collectionRef) => ({
139250
+ spec: specRef,
139251
+ collection: collectionRef
139252
+ }));
139253
+ let root = {};
139254
+ if (typeof existingRaw === "string" && existingRaw.trim()) {
139255
+ let parsed;
139256
+ try {
139257
+ parsed = load(existingRaw);
139258
+ } catch (error2) {
139259
+ throw new Error(
139260
+ `CONTRACT_WORKFLOWS_UNREADABLE: .postman/workflows.yaml exists but is not parseable YAML (${error2 instanceof Error ? error2.message : String(error2)}). Fix or delete the file; refusing to overwrite unrelated workflow data.`,
139261
+ { cause: error2 }
139262
+ );
139263
+ }
139264
+ if (parsed === null || parsed === void 0) {
139265
+ root = {};
139266
+ } else if (!isPlainObject2(parsed)) {
139267
+ throw new Error(
139268
+ "CONTRACT_WORKFLOWS_UNREADABLE: .postman/workflows.yaml exists but does not contain a YAML mapping. Fix or delete the file; refusing to overwrite unrelated workflow data."
139269
+ );
139270
+ } else {
139271
+ root = { ...parsed };
139272
+ }
139273
+ }
139274
+ const workflows = isPlainObject2(root.workflows) ? { ...root.workflows } : {};
139275
+ const desiredCollections = new Set(collectionRefs);
139276
+ const currentPairs = (Array.isArray(workflows.syncSpecToCollection) ? workflows.syncSpecToCollection : []).map((entry) => isPlainObject2(entry) ? { ...entry } : null).filter((entry) => Boolean(entry)).filter(
139277
+ (entry) => String(entry.spec ?? "") !== specRef || desiredCollections.has(String(entry.collection ?? ""))
139278
+ );
139279
+ for (const pair of pairs) {
139280
+ const index = currentPairs.findIndex(
139281
+ (entry) => String(entry.spec ?? "") === pair.spec && String(entry.collection ?? "") === pair.collection
139282
+ );
139283
+ if (index >= 0) {
139284
+ const previous = currentPairs[index];
139285
+ currentPairs[index] = { ...previous, spec: pair.spec, collection: pair.collection };
139286
+ } else {
139287
+ currentPairs.push({ spec: pair.spec, collection: pair.collection });
139288
+ }
139289
+ }
139290
+ workflows.syncSpecToCollection = currentPairs;
139291
+ root.workflows = workflows;
139292
+ return dump(root, {
139293
+ lineWidth: -1,
139294
+ noRefs: true,
139295
+ sortKeys: false
139296
+ });
139297
+ }
139298
+ var PREBUILT_COLLECTION_ROLES = /* @__PURE__ */ new Set([
139299
+ "baseline",
139300
+ "smoke",
139301
+ "contract"
139302
+ ]);
139303
+ var SHA256_HEX = /^[a-f0-9]{64}$/;
139304
+ var PREBUILT_CLOUD_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/;
139305
+ function failPrebuiltCollections(detail) {
139306
+ throw new Error(`CONTRACT_PREBUILT_COLLECTIONS_INVALID: ${detail}`);
139307
+ }
139308
+ function parsePrebuiltCollectionsJson(raw) {
139309
+ const trimmed = String(raw ?? "").trim();
139310
+ if (!trimmed) {
139311
+ return [];
139312
+ }
139313
+ let parsed;
139314
+ try {
139315
+ parsed = JSON.parse(trimmed);
139316
+ } catch (error2) {
139317
+ throw new Error(
139318
+ `CONTRACT_PREBUILT_COLLECTIONS_INVALID: malformed JSON (${error2 instanceof Error ? error2.message : String(error2)})`,
139319
+ { cause: error2 }
139320
+ );
139321
+ }
139322
+ let entriesRaw;
139323
+ if (Array.isArray(parsed)) {
139324
+ entriesRaw = parsed;
139325
+ } else if (isPlainObject2(parsed)) {
139326
+ if (parsed.schemaVersion !== 1) {
139327
+ failPrebuiltCollections("schemaVersion must be 1");
139328
+ }
139329
+ if (!Array.isArray(parsed.collections)) {
139330
+ failPrebuiltCollections("collections must be an array when schemaVersion is set");
139331
+ }
139332
+ entriesRaw = parsed.collections;
139333
+ } else {
139334
+ failPrebuiltCollections("expected a JSON array or {schemaVersion:1,collections:[]}");
139335
+ }
139336
+ const seenRoles = /* @__PURE__ */ new Set();
139337
+ const entries = [];
139338
+ for (const [index, value] of entriesRaw.entries()) {
139339
+ if (!isPlainObject2(value)) {
139340
+ failPrebuiltCollections(`collections[${index}] must be an object`);
139341
+ }
139342
+ const roleRaw = String(value.role ?? "").trim();
139343
+ if (!PREBUILT_COLLECTION_ROLES.has(roleRaw)) {
139344
+ failPrebuiltCollections(
139345
+ `collections[${index}].role must be one of baseline|smoke|contract`
139346
+ );
139347
+ }
139348
+ const role = roleRaw;
139349
+ if (seenRoles.has(role)) {
139350
+ failPrebuiltCollections(`duplicate role ${role}`);
139351
+ }
139352
+ seenRoles.add(role);
139353
+ const collectionPath = String(
139354
+ value.collectionPath ?? value.path ?? ""
139355
+ ).trim();
139356
+ if (!collectionPath || hasControlCharacter2(collectionPath)) {
139357
+ failPrebuiltCollections(
139358
+ `collections[${index}].collectionPath must be a non-empty confined relative path`
139359
+ );
139360
+ }
139361
+ const cloudId = String(value.cloudId ?? "").trim();
139362
+ if (!cloudId || !PREBUILT_CLOUD_ID.test(cloudId)) {
139363
+ failPrebuiltCollections(
139364
+ `collections[${index}].cloudId must be a non-empty Postman collection id`
139365
+ );
139366
+ }
139367
+ let payloadDigest;
139368
+ if (Object.prototype.hasOwnProperty.call(value, "payloadDigest")) {
139369
+ const payloadDigestRaw = value.payloadDigest;
139370
+ if (payloadDigestRaw !== void 0 && payloadDigestRaw !== null) {
139371
+ payloadDigest = String(payloadDigestRaw).trim();
139372
+ if (!SHA256_HEX.test(payloadDigest)) {
139373
+ failPrebuiltCollections(
139374
+ `collections[${index}].payloadDigest must be lowercase 64-hex`
139375
+ );
139376
+ }
138909
139377
  }
138910
- },
138911
- {
138912
- lineWidth: -1,
138913
- noRefs: true,
138914
- sortKeys: false
138915
139378
  }
139379
+ const artifactDigest = String(value.artifactDigest ?? "").trim();
139380
+ if (!SHA256_HEX.test(artifactDigest)) {
139381
+ failPrebuiltCollections(
139382
+ `collections[${index}].artifactDigest must be lowercase 64-hex`
139383
+ );
139384
+ }
139385
+ entries.push({
139386
+ role,
139387
+ collectionPath,
139388
+ cloudId,
139389
+ ...payloadDigest !== void 0 ? { payloadDigest } : {},
139390
+ artifactDigest
139391
+ });
139392
+ }
139393
+ return entries;
139394
+ }
139395
+ function assertPathWithinArtifactRoot(targetPath, artifactDir, fieldName) {
139396
+ assertPathWithinCwd(targetPath, fieldName);
139397
+ assertPathWithinCwd(artifactDir, "artifact-dir");
139398
+ const cwd = (0, import_node_fs5.realpathSync)(process.cwd());
139399
+ const artifactRoot = path8.resolve(cwd, artifactDir.trim());
139400
+ const resolved = path8.resolve(cwd, targetPath.trim());
139401
+ const relativeToArtifact = path8.relative(artifactRoot, resolved);
139402
+ if (!relativeToArtifact || relativeToArtifact.startsWith("..") || path8.isAbsolute(relativeToArtifact)) {
139403
+ failPrebuiltCollections(
139404
+ `${fieldName} must stay under artifact-dir (${artifactDir}); received ${targetPath}`
139405
+ );
139406
+ }
139407
+ let existingPath = resolved;
139408
+ while (!(0, import_node_fs5.existsSync)(existingPath)) {
139409
+ const parent = path8.dirname(existingPath);
139410
+ if (parent === existingPath) {
139411
+ break;
139412
+ }
139413
+ existingPath = parent;
139414
+ }
139415
+ const realExisting = (0, import_node_fs5.realpathSync)(existingPath);
139416
+ const realRelative = path8.relative(artifactRoot, realExisting);
139417
+ if (realRelative.startsWith("..") || path8.isAbsolute(realRelative)) {
139418
+ failPrebuiltCollections(
139419
+ `${fieldName} resolves outside artifact-dir via symlink; received ${targetPath}`
139420
+ );
139421
+ }
139422
+ return normalizeToPosix(path8.relative(cwd, resolved));
139423
+ }
139424
+ function prebuiltDirectoryTraversalIdentity(absolutePath, stats, options = {}) {
139425
+ const platform2 = options.platform ?? process.platform;
139426
+ const inodeIsZero = stats.ino === 0 || stats.ino === 0n;
139427
+ if (platform2 !== "win32" && !inodeIsZero) {
139428
+ return `${stats.dev}:${stats.ino}`;
139429
+ }
139430
+ const resolveCanonicalPath = options.resolveCanonicalPath ?? ((candidate) => import_node_fs5.realpathSync.native(candidate));
139431
+ const canonical = resolveCanonicalPath(absolutePath);
139432
+ return platform2 === "win32" ? canonical.toLowerCase() : canonical;
139433
+ }
139434
+ function listPrebuiltCollectionTreeFiles(collectionPath, artifactDir) {
139435
+ const confined = assertPathWithinArtifactRoot(
139436
+ collectionPath,
139437
+ artifactDir,
139438
+ "prebuilt collection path"
139439
+ );
139440
+ const absRoot = path8.resolve(process.cwd(), confined);
139441
+ if (!(0, import_node_fs5.existsSync)(absRoot)) {
139442
+ return [];
139443
+ }
139444
+ let rootStat;
139445
+ try {
139446
+ rootStat = (0, import_node_fs5.lstatSync)(absRoot);
139447
+ } catch {
139448
+ return [];
139449
+ }
139450
+ if (rootStat.isSymbolicLink()) {
139451
+ failPrebuiltCollections(
139452
+ `prebuilt collection path must not be a symlink; received ${collectionPath}`
139453
+ );
139454
+ }
139455
+ if (!rootStat.isDirectory()) {
139456
+ return [];
139457
+ }
139458
+ const files = [];
139459
+ const pendingDirectories = [absRoot];
139460
+ const seenDirectories = /* @__PURE__ */ new Set();
139461
+ while (pendingDirectories.length > 0) {
139462
+ const currentAbsolute = pendingDirectories.pop();
139463
+ if (!currentAbsolute) {
139464
+ break;
139465
+ }
139466
+ const currentStat = (0, import_node_fs5.lstatSync)(currentAbsolute);
139467
+ if (currentStat.isSymbolicLink() || !currentStat.isDirectory()) {
139468
+ failPrebuiltCollections(
139469
+ `prebuilt collection tree directory changed or became unsupported at ${normalizeToPosix(path8.relative(absRoot, currentAbsolute)) || "."}`
139470
+ );
139471
+ }
139472
+ const currentKey = prebuiltDirectoryTraversalIdentity(currentAbsolute, currentStat);
139473
+ if (seenDirectories.has(currentKey)) {
139474
+ failPrebuiltCollections(
139475
+ `prebuilt collection tree directory cycle detected at ${normalizeToPosix(path8.relative(absRoot, currentAbsolute)) || "."}`
139476
+ );
139477
+ }
139478
+ seenDirectories.add(currentKey);
139479
+ const entries = (0, import_node_fs5.readdirSync)(currentAbsolute, { withFileTypes: true });
139480
+ for (const entry of entries) {
139481
+ const abs = path8.join(currentAbsolute, entry.name);
139482
+ if (entry.isSymbolicLink()) {
139483
+ failPrebuiltCollections(
139484
+ `prebuilt collection tree must not contain symlinks; received ${normalizeToPosix(path8.relative(absRoot, abs))}`
139485
+ );
139486
+ }
139487
+ if (entry.isDirectory()) {
139488
+ pendingDirectories.push(abs);
139489
+ continue;
139490
+ }
139491
+ if (!entry.isFile()) {
139492
+ failPrebuiltCollections(
139493
+ `prebuilt collection tree contains unsupported entry type at ${normalizeToPosix(path8.relative(absRoot, abs))}`
139494
+ );
139495
+ }
139496
+ const fileLstat = (0, import_node_fs5.lstatSync)(abs);
139497
+ if (fileLstat.isSymbolicLink() || !fileLstat.isFile()) {
139498
+ failPrebuiltCollections(
139499
+ `prebuilt collection tree file changed or became unsupported at ${normalizeToPosix(path8.relative(absRoot, abs))}`
139500
+ );
139501
+ }
139502
+ files.push({
139503
+ absolute: abs,
139504
+ relative: normalizeToPosix(path8.relative(absRoot, abs)),
139505
+ dev: fileLstat.dev,
139506
+ ino: fileLstat.ino,
139507
+ size: fileLstat.size
139508
+ });
139509
+ }
139510
+ }
139511
+ files.sort((a, b) => a.relative.localeCompare(b.relative));
139512
+ return files;
139513
+ }
139514
+ function validateCanonicalV3CollectionFile(relative4, bytes) {
139515
+ let expectedKind;
139516
+ if (/(^|\/)\.resources\/definition\.yaml$/.test(relative4)) {
139517
+ expectedKind = "collection";
139518
+ } else if (relative4.endsWith(".request.yaml")) {
139519
+ expectedKind = "request";
139520
+ } else if (relative4.endsWith(".example.yaml")) {
139521
+ expectedKind = "example";
139522
+ } else if (relative4.endsWith(".message.yaml")) {
139523
+ expectedKind = "message";
139524
+ } else {
139525
+ failPrebuiltCollections(`prebuilt collection tree contains unexpected file ${relative4}`);
139526
+ }
139527
+ let parsed;
139528
+ try {
139529
+ parsed = load(bytes.toString("utf8"));
139530
+ } catch (error2) {
139531
+ failPrebuiltCollections(
139532
+ `prebuilt collection tree contains malformed YAML at ${relative4} (${error2 instanceof Error ? error2.message : String(error2)})`
139533
+ );
139534
+ }
139535
+ if (!isPlainObject2(parsed)) {
139536
+ failPrebuiltCollections(`prebuilt collection tree file ${relative4} must contain a YAML mapping`);
139537
+ }
139538
+ const kind = typeof parsed.$kind === "string" ? parsed.$kind.trim() : "";
139539
+ if (!kind) {
139540
+ failPrebuiltCollections(`prebuilt collection tree file ${relative4} must contain a nonempty $kind`);
139541
+ }
139542
+ const agrees = expectedKind === "collection" ? kind === "collection" : kind.endsWith(`-${expectedKind}`);
139543
+ if (!agrees) {
139544
+ failPrebuiltCollections(
139545
+ `prebuilt collection tree file ${relative4} has $kind ${kind} inconsistent with its filename`
139546
+ );
139547
+ }
139548
+ }
139549
+ async function digestAndValidatePrebuiltCollectionTree(files) {
139550
+ if (!files.some((file) => file.relative === ".resources/definition.yaml")) {
139551
+ failPrebuiltCollections("prebuilt collection tree is missing .resources/definition.yaml");
139552
+ }
139553
+ const hash = (0, import_node_crypto4.createHash)("sha256");
139554
+ for (const file of files) {
139555
+ let bytes;
139556
+ try {
139557
+ bytes = await appendArtifactDigestFileStreaming(hash, file.relative, file.absolute, {
139558
+ dev: file.dev,
139559
+ ino: file.ino,
139560
+ size: file.size
139561
+ });
139562
+ } catch (error2) {
139563
+ if (error2 instanceof ArtifactDigestStreamError) {
139564
+ failPrebuiltCollections(error2.message);
139565
+ }
139566
+ const code = error2?.code;
139567
+ if (code === "ELOOP" || code === "EPERM") {
139568
+ failPrebuiltCollections(
139569
+ `prebuilt collection tree file became a symlink or unsupported node at ${file.relative}`
139570
+ );
139571
+ }
139572
+ failPrebuiltCollections(
139573
+ `prebuilt collection tree file changed or became unsupported at ${file.relative}`
139574
+ );
139575
+ }
139576
+ validateCanonicalV3CollectionFile(file.relative, bytes);
139577
+ }
139578
+ return hash.digest("hex");
139579
+ }
139580
+ async function preparePrebuiltCollections(inputs) {
139581
+ const prepared = /* @__PURE__ */ new Map();
139582
+ for (const entry of parsePrebuiltCollectionsJson(inputs.prebuiltCollectionsJson ?? "")) {
139583
+ const confinedPath = assertPathWithinArtifactRoot(
139584
+ entry.collectionPath,
139585
+ inputs.artifactDir,
139586
+ `prebuilt ${entry.role} collection path`
139587
+ );
139588
+ const absolute = path8.resolve(process.cwd(), confinedPath);
139589
+ if (!(0, import_node_fs5.existsSync)(absolute)) {
139590
+ prepared.set(entry.role, { entry, confinedPath });
139591
+ continue;
139592
+ }
139593
+ const files = listPrebuiltCollectionTreeFiles(confinedPath, inputs.artifactDir);
139594
+ const artifactDigest = await digestAndValidatePrebuiltCollectionTree(files);
139595
+ prepared.set(entry.role, {
139596
+ entry,
139597
+ confinedPath,
139598
+ artifactDigest
139599
+ });
139600
+ }
139601
+ return prepared;
139602
+ }
139603
+ function tryReusePrebuiltCollection(options) {
139604
+ const { prepared, expectedPath, expectedCloudId } = options;
139605
+ const { entry } = prepared;
139606
+ if (!expectedCloudId || entry.cloudId !== expectedCloudId) {
139607
+ return false;
139608
+ }
139609
+ const expectedNormalized = canonicalizeRelativePath(expectedPath);
139610
+ const entryNormalized = canonicalizeRelativePath(entry.collectionPath);
139611
+ if (entryNormalized !== expectedNormalized) {
139612
+ return false;
139613
+ }
139614
+ const confined = canonicalizeRelativePath(prepared.confinedPath);
139615
+ if (confined !== expectedNormalized) {
139616
+ return false;
139617
+ }
139618
+ const expectedName = path8.posix.basename(expectedNormalized);
139619
+ if (path8.posix.basename(confined) !== expectedName) {
139620
+ return false;
139621
+ }
139622
+ return prepared.artifactDigest === entry.artifactDigest;
139623
+ }
139624
+ async function exportCollectionArtifact(options) {
139625
+ const {
139626
+ role,
139627
+ collectionId,
139628
+ dirName,
139629
+ collectionsDir,
139630
+ prebuiltByRole,
139631
+ postman,
139632
+ core
139633
+ } = options;
139634
+ if (!collectionId) {
139635
+ return void 0;
139636
+ }
139637
+ const expectedPath = `${collectionsDir}/${dirName}`;
139638
+ const entry = prebuiltByRole.get(role);
139639
+ if (entry) {
139640
+ const reused = tryReusePrebuiltCollection({
139641
+ prepared: entry,
139642
+ expectedPath,
139643
+ expectedCloudId: collectionId
139644
+ });
139645
+ if (reused) {
139646
+ core.info(
139647
+ `Reusing prebuilt ${role} collection tree at ${expectedPath} (artifactDigest match)`
139648
+ );
139649
+ return `../${expectedPath}`;
139650
+ }
139651
+ core.info(
139652
+ `Prebuilt ${role} collection entry present but did not exactly match; exporting from cloud`
139653
+ );
139654
+ }
139655
+ const col = await postman.getCollection(collectionId);
139656
+ await convertAndSplitAnyCollection(
139657
+ col,
139658
+ expectedPath
138916
139659
  );
139660
+ return `../${expectedPath}`;
138917
139661
  }
138918
139662
  function hasControlCharacter2(value) {
138919
139663
  for (let index = 0; index < value.length; index += 1) {
@@ -138931,21 +139675,21 @@ function assertPathWithinCwd(targetPath, fieldName) {
138931
139675
  if (!rawPath || hasControlCharacter2(originalPath) || path8.isAbsolute(rawPath) || path8.win32.isAbsolute(rawPath) || segments.includes("..") || rawPath.startsWith(":") || hasControlCharacter2(rawPath)) {
138932
139676
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
138933
139677
  }
138934
- const base = (0, import_node_fs4.realpathSync)(process.cwd());
139678
+ const base = (0, import_node_fs5.realpathSync)(process.cwd());
138935
139679
  const resolved = path8.resolve(base, rawPath);
138936
139680
  const relative4 = path8.relative(base, resolved);
138937
139681
  if (relative4.startsWith("..") || path8.isAbsolute(relative4)) {
138938
139682
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
138939
139683
  }
138940
139684
  let existingPath = resolved;
138941
- while (!(0, import_node_fs4.existsSync)(existingPath)) {
139685
+ while (!(0, import_node_fs5.existsSync)(existingPath)) {
138942
139686
  const parent = path8.dirname(existingPath);
138943
139687
  if (parent === existingPath) {
138944
139688
  break;
138945
139689
  }
138946
139690
  existingPath = parent;
138947
139691
  }
138948
- const realExistingPath = (0, import_node_fs4.realpathSync)(existingPath);
139692
+ const realExistingPath = (0, import_node_fs5.realpathSync)(existingPath);
138949
139693
  const realRelative = path8.relative(base, realExistingPath);
138950
139694
  if (realRelative.startsWith("..") || path8.isAbsolute(realRelative)) {
138951
139695
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
@@ -138973,8 +139717,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
138973
139717
  ensureDir(specsDir);
138974
139718
  ensureDir(".postman");
138975
139719
  const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
138976
- if (!(0, import_node_fs4.existsSync)(globalsFilePath)) {
138977
- (0, import_node_fs4.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
139720
+ if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
139721
+ (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
138978
139722
  }
138979
139723
  if (inputs.generateCiWorkflow) {
138980
139724
  const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
@@ -138990,23 +139734,42 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
138990
139734
  inputs.specSyncMode,
138991
139735
  options.releaseLabel
138992
139736
  ) : void 0;
138993
- if (inputs.baselineCollectionId) {
138994
- const col = await dependencies.postman.getCollection(inputs.baselineCollectionId);
138995
- const dirName = getCollectionDirectoryName("Baseline", assetProjectName);
138996
- await convertAndSplitAnyCollection(col, `${collectionsDir}/${dirName}`);
138997
- manifestCollections[`../${collectionsDir}/${dirName}`] = inputs.baselineCollectionId;
138998
- }
138999
- if (inputs.smokeCollectionId) {
139000
- const col = await dependencies.postman.getCollection(inputs.smokeCollectionId);
139001
- const dirName = getCollectionDirectoryName("Smoke", assetProjectName);
139002
- await convertAndSplitAnyCollection(col, `${collectionsDir}/${dirName}`);
139003
- manifestCollections[`../${collectionsDir}/${dirName}`] = inputs.smokeCollectionId;
139004
- }
139005
- if (inputs.contractCollectionId) {
139006
- const col = await dependencies.postman.getCollection(inputs.contractCollectionId);
139007
- const dirName = getCollectionDirectoryName("Contract", assetProjectName);
139008
- await convertAndSplitAnyCollection(col, `${collectionsDir}/${dirName}`);
139009
- manifestCollections[`../${collectionsDir}/${dirName}`] = inputs.contractCollectionId;
139737
+ const prebuiltByRole = options.preparedPrebuiltCollections;
139738
+ const baselineRef = await exportCollectionArtifact({
139739
+ role: "baseline",
139740
+ collectionId: inputs.baselineCollectionId,
139741
+ dirName: getCollectionDirectoryName("Baseline", assetProjectName),
139742
+ collectionsDir,
139743
+ prebuiltByRole,
139744
+ postman: dependencies.postman,
139745
+ core: dependencies.core
139746
+ });
139747
+ if (baselineRef) {
139748
+ manifestCollections[baselineRef] = inputs.baselineCollectionId;
139749
+ }
139750
+ const smokeRef = await exportCollectionArtifact({
139751
+ role: "smoke",
139752
+ collectionId: inputs.smokeCollectionId,
139753
+ dirName: getCollectionDirectoryName("Smoke", assetProjectName),
139754
+ collectionsDir,
139755
+ prebuiltByRole,
139756
+ postman: dependencies.postman,
139757
+ core: dependencies.core
139758
+ });
139759
+ if (smokeRef) {
139760
+ manifestCollections[smokeRef] = inputs.smokeCollectionId;
139761
+ }
139762
+ const contractRef = await exportCollectionArtifact({
139763
+ role: "contract",
139764
+ collectionId: inputs.contractCollectionId,
139765
+ dirName: getCollectionDirectoryName("Contract", assetProjectName),
139766
+ collectionsDir,
139767
+ prebuiltByRole,
139768
+ postman: dependencies.postman,
139769
+ core: dependencies.core
139770
+ });
139771
+ if (contractRef) {
139772
+ manifestCollections[contractRef] = inputs.contractCollectionId;
139010
139773
  }
139011
139774
  for (const [envName, envUid] of Object.entries(envUids)) {
139012
139775
  writeJsonFile(
@@ -139021,7 +139784,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
139021
139784
  workspaceLinkEnabled: inputs.workspaceLinkEnabled,
139022
139785
  workspaceLinkStatus: options.workspaceLinkStatus
139023
139786
  });
139024
- (0, import_node_fs4.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
139787
+ (0, import_node_fs5.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
139025
139788
  durableWorkspaceId,
139026
139789
  manifestCollections,
139027
139790
  envUids,
@@ -139033,11 +139796,18 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
139033
139796
  options.priorState
139034
139797
  ));
139035
139798
  if (mappedSpec && Object.keys(manifestCollections).length > 0) {
139036
- (0, import_node_fs4.writeFileSync)(
139799
+ let existingWorkflows;
139800
+ try {
139801
+ existingWorkflows = (0, import_node_fs5.readFileSync)(".postman/workflows.yaml", "utf8");
139802
+ } catch {
139803
+ existingWorkflows = void 0;
139804
+ }
139805
+ (0, import_node_fs5.writeFileSync)(
139037
139806
  ".postman/workflows.yaml",
139038
139807
  buildSpecCollectionWorkflowManifest(
139039
139808
  mappedSpec.configRelativePath,
139040
- Object.keys(manifestCollections)
139809
+ Object.keys(manifestCollections),
139810
+ existingWorkflows
139041
139811
  )
139042
139812
  );
139043
139813
  }
@@ -139082,12 +139852,12 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
139082
139852
  const dir = parts.slice(0, -1).join("/");
139083
139853
  ensureDir(dir);
139084
139854
  }
139085
- (0, import_node_fs4.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
139855
+ (0, import_node_fs5.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
139086
139856
  if (inputs.provider === "github" || inputs.provider === "unknown") {
139087
139857
  const gcPath = ".github/workflows/postman-preview-gc.yml";
139088
139858
  if (inputs.ciWorkflowPath.endsWith(".github/workflows/ci.yml") || inputs.ciWorkflowPath === ".github/workflows/ci.yml") {
139089
139859
  ensureDir(".github/workflows");
139090
- (0, import_node_fs4.writeFileSync)(gcPath, renderGcWorkflowTemplate());
139860
+ (0, import_node_fs5.writeFileSync)(gcPath, renderGcWorkflowTemplate());
139091
139861
  }
139092
139862
  }
139093
139863
  }
@@ -139095,16 +139865,16 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
139095
139865
  return { commitSha: "", resolvedCurrentRef: "", pushed: false };
139096
139866
  }
139097
139867
  const provisionPath = ".github/workflows/provision.yml";
139098
- const provisionExists = inputs.provider === "github" && (0, import_node_fs4.existsSync)(provisionPath);
139868
+ const provisionExists = inputs.provider === "github" && (0, import_node_fs5.existsSync)(provisionPath);
139099
139869
  const gcWorkflowPath = ".github/workflows/postman-preview-gc.yml";
139100
- const gcExists = inputs.generateCiWorkflow && (0, import_node_fs4.existsSync)(gcWorkflowPath);
139870
+ const gcExists = inputs.generateCiWorkflow && (0, import_node_fs5.existsSync)(gcWorkflowPath);
139101
139871
  const stagePaths = [
139102
139872
  inputs.artifactDir,
139103
139873
  ".postman",
139104
139874
  inputs.generateCiWorkflow ? inputs.ciWorkflowPath : null,
139105
139875
  gcExists ? gcWorkflowPath : null,
139106
139876
  provisionExists ? provisionPath : null
139107
- ].filter((entry) => typeof entry === "string" && ((0, import_node_fs4.existsSync)(entry) || entry === provisionPath));
139877
+ ].filter((entry) => typeof entry === "string" && ((0, import_node_fs5.existsSync)(entry) || entry === provisionPath));
139108
139878
  if (stagePaths.length === 0) {
139109
139879
  dependencies.core.info("No generated repository paths were found; skipping repo mutation.");
139110
139880
  return {
@@ -139212,6 +139982,7 @@ async function runRepoSyncInner(inputs, dependencies) {
139212
139982
  }
139213
139983
  }
139214
139984
  }
139985
+ const preparedPrebuiltCollections = await preparePrebuiltCollections(inputs);
139215
139986
  let skipRepositoryLinkPost = false;
139216
139987
  let repositoryLinkPreflightWasFree = false;
139217
139988
  if (inputs.workspaceLinkEnabled && inputs.workspaceId && inputs.repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
@@ -139248,6 +140019,7 @@ async function runRepoSyncInner(inputs, dependencies) {
139248
140019
  const branchAssetMarker = buildBranchAssetMarker(branchDecision, inputs);
139249
140020
  const envUids = await upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker);
139250
140021
  outputs["environment-uids-json"] = JSON.stringify(envUids);
140022
+ dependencies.core.setOutput("environment-uids-json", outputs["environment-uids-json"]);
139251
140023
  if (inputs.environmentSyncEnabled && inputs.workspaceId && dependencies.internalIntegration) {
139252
140024
  const associations = Object.entries(envUids).map(([envName, envUid]) => ({
139253
140025
  envUid,
@@ -139366,6 +140138,7 @@ async function runRepoSyncInner(inputs, dependencies) {
139366
140138
  }
139367
140139
  }
139368
140140
  outputs["mock-url"] = resolvedMockUrl;
140141
+ dependencies.core.setOutput("mock-url", resolvedMockUrl);
139369
140142
  }
139370
140143
  }
139371
140144
  if (inputs.workspaceId && inputs.smokeCollectionId && Object.keys(envUids).length > 0) {
@@ -139441,6 +140214,7 @@ async function runRepoSyncInner(inputs, dependencies) {
139441
140214
  }
139442
140215
  }
139443
140216
  outputs["monitor-id"] = resolvedMonitorId;
140217
+ dependencies.core.setOutput("monitor-id", resolvedMonitorId);
139444
140218
  if (!effectiveCron && resolvedMonitorId) {
139445
140219
  try {
139446
140220
  await dependencies.postman.runMonitor(resolvedMonitorId);
@@ -139498,7 +140272,8 @@ async function runRepoSyncInner(inputs, dependencies) {
139498
140272
  priorWorkspaceId: resourcesState?.workspace?.id,
139499
140273
  existingSpecs: resourcesState?.cloudResources?.specs,
139500
140274
  releaseLabel,
139501
- priorState: resourcesState
140275
+ priorState: resourcesState,
140276
+ preparedPrebuiltCollections
139502
140277
  });
139503
140278
  const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
139504
140279
  outputs["commit-sha"] = commit.commitSha;
@@ -139724,7 +140499,12 @@ async function resolvePostmanApiKeyAndTeamId(inputs, actionCore, actionExec, mas
139724
140499
  bifrostBaseUrl: inputs.postmanBifrostBase,
139725
140500
  // No fallback on the org-mode probe: the expected non-org 400 must
139726
140501
  // surface verbatim, not be re-fired against the /_api alias.
139727
- secretMasker: masker
140502
+ secretMasker: masker,
140503
+ onRetryEvent: (event) => {
140504
+ actionCore.info(
140505
+ `[postman retry] action=repo-sync class=${event.class} status=${event.status ?? "none"} attempt=${event.attempt} delayMs=${event.delay}`
140506
+ );
140507
+ }
139728
140508
  });
139729
140509
  const squads = await gateway.getSquads(teamId);
139730
140510
  if (squads.length > 0) {
@@ -139788,7 +140568,12 @@ function createRepoSyncDependencies(inputs, resolved, factories, options = {}) {
139788
140568
  fallbackBaseUrl: inputs.postmanFallbackBase,
139789
140569
  teamId: resolved.teamId,
139790
140570
  orgMode: inputs.orgMode,
139791
- secretMasker: masker
140571
+ secretMasker: masker,
140572
+ onRetryEvent: (event) => {
140573
+ factories.core.info(
140574
+ `[postman retry] action=repo-sync class=${event.class} status=${event.status ?? "none"} attempt=${event.attempt} delayMs=${event.delay}`
140575
+ );
140576
+ }
139792
140577
  });
139793
140578
  const gatewayAssets = new PostmanGatewayAssetsClient({
139794
140579
  gateway,
@@ -139856,7 +140641,8 @@ function createRepoSyncDependencies(inputs, resolved, factories, options = {}) {
139856
140641
  bifrostBaseUrl: inputs.postmanBifrostBase,
139857
140642
  orgMode: inputs.orgMode,
139858
140643
  teamId: resolved.teamId,
139859
- secretMasker: masker
140644
+ secretMasker: masker,
140645
+ gateway
139860
140646
  });
139861
140647
  return {
139862
140648
  teamId: resolved.teamId,
@@ -139906,7 +140692,10 @@ async function runAction(actionCore = core_exports, actionExec = exec_exports) {
139906
140692
  }
139907
140693
  await mintAccessTokenIfNeeded(inputs, {
139908
140694
  info: (message) => actionCore.info(message),
139909
- warning: (message) => actionCore.warning(message)
140695
+ warning: (message) => actionCore.warning(message),
140696
+ retryEvent: (event) => actionCore.info(
140697
+ `[postman retry] action=repo-sync class=${event.class} status=${event.status ?? "none"} attempt=${event.attempt} delayMs=${event.delay}`
140698
+ )
139910
140699
  }, (secret) => actionCore.setSecret(secret));
139911
140700
  const masker = createSecretMasker([
139912
140701
  inputs.postmanApiKey,
@@ -139927,7 +140716,12 @@ async function runAction(actionCore = core_exports, actionExec = exec_exports) {
139927
140716
  explicitTeamId: inputs.teamId || void 0,
139928
140717
  mode: inputs.credentialPreflight,
139929
140718
  mask: masker,
139930
- log: actionCore
140719
+ log: {
140720
+ ...actionCore,
140721
+ retryEvent: (event) => actionCore.info(
140722
+ `[postman retry] action=repo-sync class=${event.class} status=${event.status ?? "none"} attempt=${event.attempt} delayMs=${event.delay}`
140723
+ )
140724
+ }
139931
140725
  });
139932
140726
  const resolved = await resolvePostmanApiKeyAndTeamId(inputs, actionCore, actionExec, masker, {
139933
140727
  env: process.env