@postman-cse/onboarding-repo-sync 2.4.2 → 2.5.0

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/cli.cjs CHANGED
@@ -42722,14 +42722,14 @@ var require_description = __commonJS({
42722
42722
  var z = __importStar(require_mini());
42723
42723
  var metadata_1 = require_metadata();
42724
42724
  var MAX_CONTENT_LENGTH = 1e6;
42725
- function truncate2(value) {
42725
+ function truncate3(value) {
42726
42726
  return value.length > MAX_CONTENT_LENGTH ? value.slice(0, MAX_CONTENT_LENGTH) : value;
42727
42727
  }
42728
42728
  exports2.Description = (0, schemas_1.model)(z.union([
42729
- z.pipe(z.string(), z.transform(truncate2)),
42729
+ z.pipe(z.string(), z.transform(truncate3)),
42730
42730
  z.null(),
42731
42731
  z.object({
42732
- content: z.pipe(z.optional(z.string()), z.transform((value) => truncate2(value ?? ""))),
42732
+ content: z.pipe(z.optional(z.string()), z.transform((value) => truncate3(value ?? ""))),
42733
42733
  type: z.optional(z.string()),
42734
42734
  version: z.optional(z.unknown())
42735
42735
  })
@@ -57955,7 +57955,7 @@ var require_lodash = __commonJS({
57955
57955
  var strSymbols = stringToArray(string), start = charsStartIndex(strSymbols, stringToArray(chars));
57956
57956
  return castSlice(strSymbols, start).join("");
57957
57957
  }
57958
- function truncate2(string, options) {
57958
+ function truncate3(string, options) {
57959
57959
  var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
57960
57960
  if (isObject(options)) {
57961
57961
  var separator = "separator" in options ? options.separator : separator;
@@ -58515,7 +58515,7 @@ var require_lodash = __commonJS({
58515
58515
  lodash.trim = trim;
58516
58516
  lodash.trimEnd = trimEnd;
58517
58517
  lodash.trimStart = trimStart;
58518
- lodash.truncate = truncate2;
58518
+ lodash.truncate = truncate3;
58519
58519
  lodash.unescape = unescape2;
58520
58520
  lodash.uniqueId = uniqueId;
58521
58521
  lodash.upperCase = upperCase;
@@ -95746,10 +95746,10 @@ var require_unicode = __commonJS({
95746
95746
  module2.exports.isLineTerminatorJSON = function isLineTerminatorJSON(x) {
95747
95747
  return x === "\n" || x === "\r";
95748
95748
  };
95749
- module2.exports.isIdentifierStart = function isIdentifierStart(x) {
95749
+ module2.exports.isIdentifierStart = function isIdentifierStart2(x) {
95750
95750
  return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "\x80" && Uni.NonAsciiIdentifierStart.test(x);
95751
95751
  };
95752
- module2.exports.isIdentifierPart = function isIdentifierPart(x) {
95752
+ module2.exports.isIdentifierPart = function isIdentifierPart2(x) {
95753
95753
  return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "0" && x <= "9" || x >= "\x80" && Uni.NonAsciiIdentifierPart.test(x);
95754
95754
  };
95755
95755
  module2.exports.NonAsciiIdentifierStart = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
@@ -118663,7 +118663,7 @@ var require_truncate = __commonJS({
118663
118663
  function isLowSurrogate(codePoint) {
118664
118664
  return codePoint >= 56320 && codePoint <= 57343;
118665
118665
  }
118666
- module2.exports = function truncate2(getLength, string, byteLength) {
118666
+ module2.exports = function truncate3(getLength, string, byteLength) {
118667
118667
  if (typeof string !== "string") {
118668
118668
  throw new Error("Input must be string");
118669
118669
  }
@@ -118694,9 +118694,9 @@ var require_truncate = __commonJS({
118694
118694
  var require_truncate_utf8_bytes = __commonJS({
118695
118695
  "node_modules/truncate-utf8-bytes/index.js"(exports2, module2) {
118696
118696
  "use strict";
118697
- var truncate2 = require_truncate();
118697
+ var truncate3 = require_truncate();
118698
118698
  var getLength = Buffer.byteLength.bind(Buffer);
118699
- module2.exports = truncate2.bind(null, getLength);
118699
+ module2.exports = truncate3.bind(null, getLength);
118700
118700
  }
118701
118701
  });
118702
118702
 
@@ -132414,7 +132414,9 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
132414
132414
  ` POSTMAN_CLI_INSTALL_URL: ${installUrl}`,
132415
132415
  ' run: curl -fsSL "$POSTMAN_CLI_INSTALL_URL" | sh',
132416
132416
  " - name: Login to Postman CLI",
132417
- " run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}" + (postmanRegion === "eu" ? " --region eu" : ""),
132417
+ " env:",
132418
+ " POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}",
132419
+ ' run: postman login --with-api-key "$POSTMAN_API_KEY"' + (postmanRegion === "eu" ? " --region eu" : ""),
132418
132420
  " - name: Resolve Postman Resource IDs",
132419
132421
  " run: |",
132420
132422
  " ruby <<'RUBY'",
@@ -132453,12 +132455,13 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
132453
132455
  " - name: Run Smoke Tests",
132454
132456
  " env:",
132455
132457
  " POSTMAN_SSL_CLIENT_PASSPHRASE: ${{ secrets.POSTMAN_SSL_CLIENT_PASSPHRASE }}",
132458
+ ...privateMockAuth ? [" POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}"] : [],
132456
132459
  " run: |",
132457
132460
  ' CMD=(postman collection run "$POSTMAN_SMOKE_COLLECTION_UID"',
132458
132461
  ' -e "$POSTMAN_ENVIRONMENT_UID"',
132459
132462
  " --report-events",
132460
132463
  ` --env-var "CI_ENVIRONMENT=\${{ vars.CI_ENVIRONMENT || 'Production' }}")`,
132461
- ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=${{ secrets.POSTMAN_API_KEY }}")'] : [],
132464
+ ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=$POSTMAN_API_KEY")'] : [],
132462
132465
  ' if [ -f "$RUNNER_TEMP/postman-ssl/client.crt" ]; then',
132463
132466
  ' CMD+=(--ssl-client-cert "$RUNNER_TEMP/postman-ssl/client.crt"',
132464
132467
  ' --ssl-client-key "$RUNNER_TEMP/postman-ssl/client.key")',
@@ -132473,12 +132476,13 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
132473
132476
  " - name: Run Contract Tests",
132474
132477
  " env:",
132475
132478
  " POSTMAN_SSL_CLIENT_PASSPHRASE: ${{ secrets.POSTMAN_SSL_CLIENT_PASSPHRASE }}",
132479
+ ...privateMockAuth ? [" POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}"] : [],
132476
132480
  " run: |",
132477
132481
  ' CMD=(postman collection run "$POSTMAN_CONTRACT_COLLECTION_UID"',
132478
132482
  ' -e "$POSTMAN_ENVIRONMENT_UID"',
132479
132483
  " --report-events",
132480
132484
  ` --env-var "CI_ENVIRONMENT=\${{ vars.CI_ENVIRONMENT || 'Production' }}")`,
132481
- ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=${{ secrets.POSTMAN_API_KEY }}")'] : [],
132485
+ ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=$POSTMAN_API_KEY")'] : [],
132482
132486
  ' if [ -f "$RUNNER_TEMP/postman-ssl/client.crt" ]; then',
132483
132487
  ' CMD+=(--ssl-client-cert "$RUNNER_TEMP/postman-ssl/client.crt"',
132484
132488
  ' --ssl-client-key "$RUNNER_TEMP/postman-ssl/client.key")',
@@ -132505,7 +132509,9 @@ function buildAdoWindowsCollectionRunLines(displayName, collectionEnvironmentNam
132505
132509
  ` $collectionUid = $env:${collectionEnvironmentName}`,
132506
132510
  " $ciEnvironment = Resolve-AdoOptional $env:CI_ENVIRONMENT",
132507
132511
  " if ([string]::IsNullOrWhiteSpace($ciEnvironment)) { $ciEnvironment = 'Production' }",
132508
- ` $arguments = @('collection', 'run', $collectionUid, '-e', $env:POSTMAN_ENVIRONMENT_UID, '--report-events', '--env-var', "CI_ENVIRONMENT=$ciEnvironment")`,
132512
+ " $responseTimeThreshold = Resolve-AdoOptional $env:RESPONSE_TIME_THRESHOLD",
132513
+ " if ([string]::IsNullOrWhiteSpace($responseTimeThreshold)) { $responseTimeThreshold = '10000' }",
132514
+ ` $arguments = @('collection', 'run', $collectionUid, '-e', $env:POSTMAN_ENVIRONMENT_UID, '--report-events', '--env-var', "CI_ENVIRONMENT=$ciEnvironment", '--env-var', "RESPONSE_TIME_THRESHOLD=$responseTimeThreshold")`,
132509
132515
  ...privateMockAuth ? [` $arguments += @('--env-var', "${PRIVATE_MOCK_AUTH_VARIABLE}=$env:POSTMAN_API_KEY")`] : [],
132510
132516
  " $sslRoot = Join-Path $env:AGENT_TEMPDIRECTORY 'postman-ssl'",
132511
132517
  " $clientCert = Join-Path $sslRoot 'client.crt'",
@@ -132528,6 +132534,7 @@ function buildAdoWindowsCollectionRunLines(displayName, collectionEnvironmentNam
132528
132534
  ` ${collectionEnvironmentName}: $(${collectionEnvironmentName})`,
132529
132535
  " POSTMAN_ENVIRONMENT_UID: $(POSTMAN_ENVIRONMENT_UID)",
132530
132536
  " CI_ENVIRONMENT: $(CI_ENVIRONMENT)",
132537
+ " RESPONSE_TIME_THRESHOLD: $(RESPONSE_TIME_THRESHOLD)",
132531
132538
  " POSTMAN_SSL_CLIENT_PASSPHRASE: $(POSTMAN_SSL_CLIENT_PASSPHRASE)",
132532
132539
  ...privateMockAuth ? [" POSTMAN_API_KEY: $(POSTMAN_API_KEY)"] : []
132533
132540
  ];
@@ -133297,7 +133304,7 @@ function detectRepoContext(input, env = process.env) {
133297
133304
  };
133298
133305
  }
133299
133306
 
133300
- // node_modules/@postman-cse/automation-telemetry-core/dist/ci-context.js
133307
+ // node_modules/@postman-cse/automation-core/dist/ci-context.js
133301
133308
  function norm(value) {
133302
133309
  const trimmed = (value ?? "").trim();
133303
133310
  return trimmed.length > 0 ? trimmed : void 0;
@@ -133448,7 +133455,7 @@ function detectCiProviderContext(env = process.env) {
133448
133455
  return { ciProvider: "unknown", runnerKind: "unknown" };
133449
133456
  }
133450
133457
 
133451
- // node_modules/@postman-cse/automation-telemetry-core/dist/repo-context.js
133458
+ // node_modules/@postman-cse/automation-core/dist/repo-context.js
133452
133459
  function normalize2(value) {
133453
133460
  const trimmed = (value ?? "").trim();
133454
133461
  return trimmed.length > 0 ? trimmed : void 0;
@@ -133537,7 +133544,7 @@ function detectRepoContext2(input, env = process.env) {
133537
133544
  };
133538
133545
  }
133539
133546
 
133540
- // node_modules/@postman-cse/automation-telemetry-core/dist/telemetry.js
133547
+ // node_modules/@postman-cse/automation-core/dist/telemetry.js
133541
133548
  var import_node_crypto = require("node:crypto");
133542
133549
  var import_undici2 = __toESM(require_undici(), 1);
133543
133550
  var SCHEMA_VERSION = 3;
@@ -133547,10 +133554,14 @@ var proxyDispatcher;
133547
133554
  function getProxyDispatcher() {
133548
133555
  return proxyDispatcher ??= new import_undici2.EnvHttpProxyAgent();
133549
133556
  }
133550
- function resolveActionVersion(explicit) {
133557
+ function resolveActionVersion(explicit, env = process.env) {
133551
133558
  if (explicit) {
133552
133559
  return explicit;
133553
133560
  }
133561
+ const ref = env.GITHUB_ACTION_REF?.trim();
133562
+ if (ref) {
133563
+ return ref;
133564
+ }
133554
133565
  return typeof __ACTION_VERSION__ !== "undefined" && __ACTION_VERSION__ ? __ACTION_VERSION__ : "unknown";
133555
133566
  }
133556
133567
  function telemetryDisabled(env) {
@@ -133633,7 +133644,7 @@ async function send(event, options) {
133633
133644
  function createTelemetryContext(options) {
133634
133645
  const env = options.env ?? process.env;
133635
133646
  const now = options.now ?? Date.now;
133636
- const actionVersion = resolveActionVersion(options.actionVersion);
133647
+ const actionVersion = resolveActionVersion(options.actionVersion, env);
133637
133648
  let teamId = "";
133638
133649
  let accountType = "unknown";
133639
133650
  let emitted = false;
@@ -133673,6 +133684,186 @@ function createTelemetryContext(options) {
133673
133684
  };
133674
133685
  }
133675
133686
 
133687
+ // node_modules/@postman-cse/automation-core/dist/logger.js
133688
+ var LEVEL_ORDER = {
133689
+ debug: 10,
133690
+ info: 20,
133691
+ warning: 30,
133692
+ error: 40
133693
+ };
133694
+ function defaultCorrelationId() {
133695
+ return Math.random().toString(36).slice(2, 10);
133696
+ }
133697
+ function resolveLogLevel(env = process.env) {
133698
+ const explicit = String(env.POSTMAN_ACTIONS_LOG_LEVEL ?? "").trim().toLowerCase();
133699
+ if (explicit === "debug" || explicit === "trace" || explicit === "verbose")
133700
+ return "debug";
133701
+ if (explicit === "info")
133702
+ return "info";
133703
+ if (explicit === "warn" || explicit === "warning")
133704
+ return "warning";
133705
+ if (explicit === "error" || explicit === "quiet")
133706
+ return "error";
133707
+ if (isTruthyFlag(env.RUNNER_DEBUG) || isTruthyFlag(env.ACTIONS_STEP_DEBUG))
133708
+ return "debug";
133709
+ if (isTruthyFlag(env.POSTMAN_ACTIONS_DEBUG))
133710
+ return "debug";
133711
+ return "info";
133712
+ }
133713
+ function isTruthyFlag(value) {
133714
+ if (!value)
133715
+ return false;
133716
+ const flag = value.trim().toLowerCase();
133717
+ return flag === "1" || flag === "true" || flag === "yes" || flag === "on";
133718
+ }
133719
+ function actionSink(core) {
133720
+ return {
133721
+ debug: (message) => core.debug?.(message),
133722
+ info: (message) => core.info(message),
133723
+ warning: (message) => (core.warning ?? core.info)(message),
133724
+ error: (message) => (core.error ?? core.warning ?? core.info)(message),
133725
+ startGroup: core.startGroup ? (name) => core.startGroup?.(name) : void 0,
133726
+ endGroup: core.endGroup ? () => core.endGroup?.() : void 0,
133727
+ isDebug: core.isDebug ? () => core.isDebug?.() ?? false : void 0
133728
+ };
133729
+ }
133730
+ var MIN_SECRET_LENGTH = 4;
133731
+ function renderValue(value, maxLength = 512) {
133732
+ if (value === void 0)
133733
+ return "undefined";
133734
+ if (value === null)
133735
+ return "null";
133736
+ if (typeof value === "string")
133737
+ return truncate(value, maxLength);
133738
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
133739
+ return String(value);
133740
+ }
133741
+ if (value instanceof Error)
133742
+ return truncate(describeError(value), maxLength);
133743
+ if (Array.isArray(value)) {
133744
+ return truncate(`[${value.map((entry) => renderValue(entry, 120)).join(", ")}]`, maxLength);
133745
+ }
133746
+ try {
133747
+ return truncate(JSON.stringify(value) ?? String(value), maxLength);
133748
+ } catch {
133749
+ return "<unserializable>";
133750
+ }
133751
+ }
133752
+ function truncate(text, maxLength) {
133753
+ if (text.length <= maxLength)
133754
+ return text;
133755
+ return `${text.slice(0, maxLength)}\u2026 (+${text.length - maxLength} chars)`;
133756
+ }
133757
+ function describeError(error, maxDepth = 5) {
133758
+ const parts = [];
133759
+ let current = error;
133760
+ let depth = 0;
133761
+ while (current !== void 0 && current !== null && depth < maxDepth) {
133762
+ if (current instanceof Error) {
133763
+ const code = current.code;
133764
+ parts.push(code ? `${current.name}[${code}]: ${current.message}` : `${current.name}: ${current.message}`);
133765
+ current = current.cause;
133766
+ } else if (typeof current === "object") {
133767
+ try {
133768
+ parts.push(JSON.stringify(current) ?? String(current));
133769
+ } catch {
133770
+ parts.push(String(current));
133771
+ }
133772
+ current = void 0;
133773
+ } else {
133774
+ parts.push(String(current));
133775
+ current = void 0;
133776
+ }
133777
+ depth += 1;
133778
+ }
133779
+ if (parts.length === 0)
133780
+ return "unknown error";
133781
+ return parts.join(" <- caused by ");
133782
+ }
133783
+ function createLogger(options) {
133784
+ const env = options.env ?? process.env;
133785
+ const level = options.level ?? resolveLogLevel(env);
133786
+ const secrets = options.secrets ?? /* @__PURE__ */ new Set();
133787
+ const correlationId = options.correlationId ?? defaultCorrelationId();
133788
+ const now = options.now ?? (() => Date.now());
133789
+ const threshold = LEVEL_ORDER[level];
133790
+ function addSecret(value) {
133791
+ if (typeof value !== "string")
133792
+ return;
133793
+ const trimmed = value.trim();
133794
+ if (trimmed.length < MIN_SECRET_LENGTH)
133795
+ return;
133796
+ secrets.add(trimmed);
133797
+ }
133798
+ function redact(text) {
133799
+ let output = typeof text === "string" ? text : renderValue(text, 4096);
133800
+ for (const secret of secrets) {
133801
+ if (!secret)
133802
+ continue;
133803
+ output = output.split(secret).join("***");
133804
+ const encoded = encodeURIComponent(secret);
133805
+ if (encoded !== secret)
133806
+ output = output.split(encoded).join("***");
133807
+ }
133808
+ return output;
133809
+ }
133810
+ function build2(baseFields) {
133811
+ function emit(target, message, fields) {
133812
+ if (LEVEL_ORDER[target] < threshold)
133813
+ return;
133814
+ const merged = { ...baseFields, ...fields ?? {} };
133815
+ const rendered = Object.entries(merged).filter(([, value]) => value !== void 0).map(([key, value]) => `${key}=${redact(renderValue(value))}`).join(" ");
133816
+ const line = rendered ? `${redact(message)} | ${rendered}` : redact(message);
133817
+ switch (target) {
133818
+ case "debug":
133819
+ options.sink.debug(line);
133820
+ break;
133821
+ case "info":
133822
+ options.sink.info(line);
133823
+ break;
133824
+ case "warning":
133825
+ options.sink.warning(line);
133826
+ break;
133827
+ case "error":
133828
+ options.sink.error(line);
133829
+ break;
133830
+ }
133831
+ }
133832
+ const logger = {
133833
+ level,
133834
+ correlationId,
133835
+ addSecret,
133836
+ redact,
133837
+ isDebug: () => threshold <= LEVEL_ORDER.debug,
133838
+ debug: (message, fields) => emit("debug", message, fields),
133839
+ info: (message, fields) => emit("info", message, fields),
133840
+ warning: (message, fields) => emit("warning", message, fields),
133841
+ error: (message, fields) => emit("error", message, fields),
133842
+ failure: (message, error, fields) => emit("error", message, { ...fields ?? {}, error: describeError(error) }),
133843
+ child: (fields) => build2({ ...baseFields, ...fields }),
133844
+ async phase(name, fn, fields) {
133845
+ const scoped = build2({ ...baseFields, ...fields ?? {}, phase: name });
133846
+ const started = now();
133847
+ scoped.debug("phase start");
133848
+ options.sink.startGroup?.(name);
133849
+ try {
133850
+ const result = await fn();
133851
+ scoped.debug("phase ok", { duration_ms: Math.round(now() - started) });
133852
+ return result;
133853
+ } catch (error) {
133854
+ scoped.failure("phase failed", error, { duration_ms: Math.round(now() - started) });
133855
+ throw error;
133856
+ } finally {
133857
+ options.sink.endGroup?.();
133858
+ }
133859
+ }
133860
+ };
133861
+ return logger;
133862
+ }
133863
+ const root = build2({ run: correlationId, ...options.fields ?? {} });
133864
+ return root;
133865
+ }
133866
+
133676
133867
  // src/action-version.ts
133677
133868
  var import_node_fs3 = require("node:fs");
133678
133869
  var import_node_path2 = require("node:path");
@@ -133689,7 +133880,7 @@ function resolveActionVersion2() {
133689
133880
  }
133690
133881
 
133691
133882
  // src/lib/http-error.ts
133692
- function truncate(value, limit) {
133883
+ function truncate2(value, limit) {
133693
133884
  if (value.length <= limit) {
133694
133885
  return value;
133695
133886
  }
@@ -133699,7 +133890,7 @@ function buildMessage(init) {
133699
133890
  const method = String(init.method || "GET").toUpperCase();
133700
133891
  const status = `${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
133701
133892
  const url = redactSecrets(init.url, init.secretValues);
133702
- const body = truncate(
133893
+ const body = truncate2(
133703
133894
  redactSecrets(init.responseBody || "", init.secretValues),
133704
133895
  Math.max(0, init.bodyLimit ?? 800)
133705
133896
  );
@@ -135078,31 +135269,13 @@ var PostmanAssetsClient = class {
135078
135269
  }
135079
135270
  };
135080
135271
 
135081
- // src/lib/postman/postman-gateway-assets-client.ts
135082
- var MockContractError = class extends Error {
135083
- constructor(message) {
135084
- super(message);
135085
- this.name = "MockContractError";
135086
- }
135087
- };
135088
- function requireMockVisibility(mock, requested) {
135089
- if (mock.visibility === "unknown") {
135090
- throw new MockContractError(
135091
- `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
135092
- );
135093
- }
135094
- if (mock.visibility !== requested) {
135095
- const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
135096
- throw new MockContractError(
135097
- `${code}: Mock ${mock.uid} is ${mock.visibility}, but mock-visibility requires ${requested}. Change the mock visibility in Postman or set mock-visibility to ${mock.visibility}.`
135098
- );
135099
- }
135100
- return mock;
135101
- }
135272
+ // src/lib/postman/private-mock-auth-script.ts
135102
135273
  var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
135103
135274
  var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
135104
- var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
135275
+ var PRIVATE_MOCK_AUTH_V3_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
135105
135276
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
135277
+ var PRIVATE_MOCK_AUTH_ROOT_TYPE = "http:beforeRequest";
135278
+ var PRIVATE_MOCK_AUTH_ROOT_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-root`;
135106
135279
  var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
135107
135280
  `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
135108
135281
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
@@ -135123,8 +135296,25 @@ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
135123
135296
  ` console.warn('This mock server is private. Set the ${PRIVATE_MOCK_AUTH_VARIABLE2} variable to a Postman API key with access to it, or the request returns 401.');`,
135124
135297
  "}"
135125
135298
  ].join("\n");
135126
- var PRIVATE_MOCK_AUTH_SCRIPT = [
135127
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
135299
+ var PRIVATE_MOCK_AUTH_V3_SCRIPT = [
135300
+ `// ${PRIVATE_MOCK_AUTH_V3_MARKER}`,
135301
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
135302
+ "var privateMockHost = '';",
135303
+ "try {",
135304
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
135305
+ " privateMockHost = new URL(privateMockUrl).hostname;",
135306
+ "} catch (error) {",
135307
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
135308
+ "}",
135309
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
135310
+ "if (isPrivateMockHost && privateMockApiKey) {",
135311
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
135312
+ "} else if (isPrivateMockHost) {",
135313
+ ` console.warn('This mock server is private. Set the ${PRIVATE_MOCK_AUTH_VARIABLE2} variable to a Postman API key with access to it, or the request returns 401.');`,
135314
+ "}"
135315
+ ].join("\n");
135316
+ var PRIVATE_MOCK_AUTH_ROOT_SCRIPT = [
135317
+ `// ${PRIVATE_MOCK_AUTH_ROOT_MARKER}`,
135128
135318
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
135129
135319
  "var privateMockHost = '';",
135130
135320
  "try {",
@@ -135140,8 +135330,313 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
135140
135330
  ` console.warn('This mock server is private. Set the ${PRIVATE_MOCK_AUTH_VARIABLE2} variable to a Postman API key with access to it, or the request returns 401.');`,
135141
135331
  "}"
135142
135332
  ].join("\n");
135143
- function removeLegacyPrivateMockAuth(code) {
135144
- return [LEGACY_PRIVATE_MOCK_AUTH_SCRIPT, PRIVATE_MOCK_AUTH_V2_SCRIPT].reduce((next, script) => next.split(script).join(""), code).trim();
135333
+ var MANAGED_ITEM_AUTH_BLOCKS = [
135334
+ LEGACY_PRIVATE_MOCK_AUTH_SCRIPT,
135335
+ PRIVATE_MOCK_AUTH_V2_SCRIPT,
135336
+ PRIVATE_MOCK_AUTH_V3_SCRIPT
135337
+ ];
135338
+ function isManagedPrivateMockAuthRootHook(script) {
135339
+ return String(script.type ?? "") === PRIVATE_MOCK_AUTH_ROOT_TYPE && String(script.code ?? "") === PRIVATE_MOCK_AUTH_ROOT_SCRIPT;
135340
+ }
135341
+ var REGEX_PREFIX_KEYWORDS = /* @__PURE__ */ new Set([
135342
+ "await",
135343
+ "case",
135344
+ "delete",
135345
+ "do",
135346
+ "else",
135347
+ "in",
135348
+ "instanceof",
135349
+ "of",
135350
+ "return",
135351
+ "throw",
135352
+ "typeof",
135353
+ "void",
135354
+ "yield"
135355
+ ]);
135356
+ function isIdentifierStart(ch) {
135357
+ return ch !== void 0 && /[A-Za-z_$]/.test(ch);
135358
+ }
135359
+ function isIdentifierPart(ch) {
135360
+ return ch !== void 0 && /[A-Za-z0-9_$]/.test(ch);
135361
+ }
135362
+ function markTopLevelScriptBytes(source) {
135363
+ const topLevel = new Uint8Array(source.length);
135364
+ let state = "script";
135365
+ let canStartRegex = true;
135366
+ let regexCharacterClass = false;
135367
+ for (let i = 0; i < source.length; i++) {
135368
+ const ch = source[i];
135369
+ const next = source[i + 1];
135370
+ if (state === "script") {
135371
+ topLevel[i] = 1;
135372
+ if (ch === "/" && next === "*") {
135373
+ topLevel[i] = 0;
135374
+ state = "block_comment";
135375
+ i++;
135376
+ topLevel[i] = 0;
135377
+ continue;
135378
+ }
135379
+ if (ch === "/" && next === "/") {
135380
+ topLevel[i + 1] = 1;
135381
+ i++;
135382
+ while (i + 1 < source.length && source[i + 1] !== "\n") {
135383
+ i++;
135384
+ topLevel[i] = 1;
135385
+ }
135386
+ continue;
135387
+ }
135388
+ if (ch === "/") {
135389
+ if (canStartRegex) {
135390
+ topLevel[i] = 0;
135391
+ state = "regex";
135392
+ regexCharacterClass = false;
135393
+ continue;
135394
+ }
135395
+ canStartRegex = true;
135396
+ if (next === "=") {
135397
+ i++;
135398
+ topLevel[i] = 1;
135399
+ }
135400
+ continue;
135401
+ }
135402
+ if (ch === "'") {
135403
+ state = "single";
135404
+ topLevel[i] = 0;
135405
+ continue;
135406
+ }
135407
+ if (ch === '"') {
135408
+ state = "double";
135409
+ topLevel[i] = 0;
135410
+ continue;
135411
+ }
135412
+ if (ch === "`") {
135413
+ state = "template";
135414
+ topLevel[i] = 0;
135415
+ continue;
135416
+ }
135417
+ if (/\s/.test(ch)) {
135418
+ continue;
135419
+ }
135420
+ if (isIdentifierStart(ch)) {
135421
+ let end = i + 1;
135422
+ while (isIdentifierPart(source[end])) {
135423
+ topLevel[end] = 1;
135424
+ end++;
135425
+ }
135426
+ canStartRegex = REGEX_PREFIX_KEYWORDS.has(source.slice(i, end));
135427
+ i = end - 1;
135428
+ continue;
135429
+ }
135430
+ if (/[0-9]/.test(ch)) {
135431
+ let end = i + 1;
135432
+ while (/[A-Za-z0-9_.]/.test(source[end] ?? "")) {
135433
+ topLevel[end] = 1;
135434
+ end++;
135435
+ }
135436
+ canStartRegex = false;
135437
+ i = end - 1;
135438
+ continue;
135439
+ }
135440
+ if ((ch === "+" || ch === "-") && next === ch) {
135441
+ const wasPrefix = canStartRegex;
135442
+ i++;
135443
+ topLevel[i] = 1;
135444
+ canStartRegex = wasPrefix;
135445
+ continue;
135446
+ }
135447
+ if (ch === "?" && next === ".") {
135448
+ i++;
135449
+ topLevel[i] = 1;
135450
+ canStartRegex = false;
135451
+ continue;
135452
+ }
135453
+ if (")]}".includes(ch) || ch === ".") {
135454
+ canStartRegex = false;
135455
+ continue;
135456
+ }
135457
+ if ("([{,;:=!~*%&|^<>+-?".includes(ch)) {
135458
+ canStartRegex = true;
135459
+ continue;
135460
+ }
135461
+ canStartRegex = false;
135462
+ continue;
135463
+ }
135464
+ if (state === "block_comment") {
135465
+ topLevel[i] = 0;
135466
+ if (ch === "*" && next === "/") {
135467
+ topLevel[i] = 0;
135468
+ i++;
135469
+ topLevel[i] = 0;
135470
+ state = "script";
135471
+ }
135472
+ continue;
135473
+ }
135474
+ if (state === "single") {
135475
+ topLevel[i] = 0;
135476
+ if (ch === "\\" && i + 1 < source.length) {
135477
+ i++;
135478
+ topLevel[i] = 0;
135479
+ continue;
135480
+ }
135481
+ if (ch === "'") {
135482
+ state = "script";
135483
+ canStartRegex = false;
135484
+ }
135485
+ continue;
135486
+ }
135487
+ if (state === "double") {
135488
+ topLevel[i] = 0;
135489
+ if (ch === "\\" && i + 1 < source.length) {
135490
+ i++;
135491
+ topLevel[i] = 0;
135492
+ continue;
135493
+ }
135494
+ if (ch === '"') {
135495
+ state = "script";
135496
+ canStartRegex = false;
135497
+ }
135498
+ continue;
135499
+ }
135500
+ if (state === "regex") {
135501
+ topLevel[i] = 0;
135502
+ if (ch === "\\" && i + 1 < source.length) {
135503
+ i++;
135504
+ topLevel[i] = 0;
135505
+ continue;
135506
+ }
135507
+ if (ch === "\n" || ch === "\r") {
135508
+ state = "script";
135509
+ canStartRegex = true;
135510
+ regexCharacterClass = false;
135511
+ continue;
135512
+ }
135513
+ if (ch === "[") {
135514
+ regexCharacterClass = true;
135515
+ continue;
135516
+ }
135517
+ if (ch === "]" && regexCharacterClass) {
135518
+ regexCharacterClass = false;
135519
+ continue;
135520
+ }
135521
+ if (ch === "/" && !regexCharacterClass) {
135522
+ while (isIdentifierPart(source[i + 1])) {
135523
+ i++;
135524
+ topLevel[i] = 0;
135525
+ }
135526
+ state = "script";
135527
+ canStartRegex = false;
135528
+ }
135529
+ continue;
135530
+ }
135531
+ topLevel[i] = 0;
135532
+ if (ch === "\\" && i + 1 < source.length) {
135533
+ i++;
135534
+ topLevel[i] = 0;
135535
+ continue;
135536
+ }
135537
+ if (ch === "`") {
135538
+ state = "script";
135539
+ canStartRegex = false;
135540
+ }
135541
+ }
135542
+ return topLevel;
135543
+ }
135544
+ function isWholeLineTopLevelMatch(source, startIndex, block, topLevel) {
135545
+ if (!source.startsWith(block, startIndex)) {
135546
+ return false;
135547
+ }
135548
+ if (startIndex > 0 && source[startIndex - 1] !== "\n") {
135549
+ return false;
135550
+ }
135551
+ const endIndex = startIndex + block.length;
135552
+ for (let lineStart = startIndex; lineStart < endIndex; ) {
135553
+ if (!topLevel[lineStart]) {
135554
+ return false;
135555
+ }
135556
+ const nextNewline = source.indexOf("\n", lineStart);
135557
+ if (nextNewline === -1 || nextNewline >= endIndex - 1) {
135558
+ break;
135559
+ }
135560
+ lineStart = nextNewline + 1;
135561
+ }
135562
+ return true;
135563
+ }
135564
+ function findManagedBlockRanges(source) {
135565
+ const topLevel = markTopLevelScriptBytes(source);
135566
+ const ranges = [];
135567
+ for (let i = 0; i < source.length; i++) {
135568
+ if (i > 0 && source[i - 1] !== "\n") {
135569
+ continue;
135570
+ }
135571
+ for (const block of MANAGED_ITEM_AUTH_BLOCKS) {
135572
+ if (!isWholeLineTopLevelMatch(source, i, block, topLevel)) {
135573
+ continue;
135574
+ }
135575
+ ranges.push({ start: i, end: i + block.length });
135576
+ break;
135577
+ }
135578
+ }
135579
+ return ranges;
135580
+ }
135581
+ function countManagedItemAuthBlocks(code) {
135582
+ if (typeof code !== "string" || !code) {
135583
+ return 0;
135584
+ }
135585
+ return findManagedBlockRanges(code).length;
135586
+ }
135587
+ function deleteRangeWithSeam(source, start, end) {
135588
+ let before = source.slice(0, start);
135589
+ let after = source.slice(end);
135590
+ const beforeHadNl = before.endsWith("\n");
135591
+ const afterHadNl = after.startsWith("\n");
135592
+ if (beforeHadNl) {
135593
+ before = before.slice(0, -1);
135594
+ }
135595
+ if (afterHadNl) {
135596
+ after = after.slice(1);
135597
+ }
135598
+ if (beforeHadNl && afterHadNl && before.length > 0 && after.length > 0) {
135599
+ return `${before}
135600
+ ${after}`;
135601
+ }
135602
+ return `${before}${after}`;
135603
+ }
135604
+ function stripManagedItemAuthBlocks(code) {
135605
+ if (typeof code !== "string" || !code) {
135606
+ return "";
135607
+ }
135608
+ const ranges = findManagedBlockRanges(code);
135609
+ if (ranges.length === 0) {
135610
+ return code;
135611
+ }
135612
+ ranges.sort((left, right) => right.start - left.start);
135613
+ let next = code;
135614
+ for (const range of ranges) {
135615
+ next = deleteRangeWithSeam(next, range.start, range.end);
135616
+ }
135617
+ return next;
135618
+ }
135619
+
135620
+ // src/lib/postman/postman-gateway-assets-client.ts
135621
+ var MockContractError = class extends Error {
135622
+ constructor(message) {
135623
+ super(message);
135624
+ this.name = "MockContractError";
135625
+ }
135626
+ };
135627
+ function requireMockVisibility(mock, requested) {
135628
+ if (mock.visibility === "unknown") {
135629
+ throw new MockContractError(
135630
+ `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
135631
+ );
135632
+ }
135633
+ if (mock.visibility !== requested) {
135634
+ const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
135635
+ throw new MockContractError(
135636
+ `${code}: Mock ${mock.uid} is ${mock.visibility}, but mock-visibility requires ${requested}. Change the mock visibility in Postman or set mock-visibility to ${mock.visibility}.`
135637
+ );
135638
+ }
135639
+ return mock;
135145
135640
  }
135146
135641
  var MAX_CREATE_FLIGHTS = 256;
135147
135642
  var createFlights = /* @__PURE__ */ new Map();
@@ -135712,51 +136207,83 @@ var PostmanGatewayAssetsClient = class {
135712
136207
  }
135713
136208
  });
135714
136209
  }
136210
+ isAmbiguousTransportError(error) {
136211
+ return this.isRetryableIdempotentWriteOutcome(error);
136212
+ }
136213
+ normalizeCollectionScripts(scripts) {
136214
+ if (!Array.isArray(scripts)) return [];
136215
+ return scripts.map((entry) => this.asRecord(entry)).filter((entry) => entry !== null);
136216
+ }
136217
+ rootScriptsIncludeManagedAuthHook(scripts) {
136218
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
136219
+ }
136220
+ buildPrivateMockRootScripts(existingScripts) {
136221
+ const managedScript = {
136222
+ type: PRIVATE_MOCK_AUTH_ROOT_TYPE,
136223
+ code: PRIVATE_MOCK_AUTH_ROOT_SCRIPT,
136224
+ language: "text/javascript"
136225
+ };
136226
+ return [...existingScripts, managedScript];
136227
+ }
136228
+ async readCollectionRootScripts(collectionUid) {
136229
+ const id = this.toModelId(collectionUid);
136230
+ const response = await this.gateway.requestJson({
136231
+ service: "collection",
136232
+ method: "get",
136233
+ path: `/v3/collections/${id}/export`
136234
+ });
136235
+ const data = this.asRecord(response?.data);
136236
+ const collection = this.asRecord(data?.collection);
136237
+ if (!collection) {
136238
+ throw new Error(
136239
+ `PRIVATE_MOCK_AUTH_EXPORT_INVALID: Collection ${id} export did not return data.collection; refusing to configure private-mock root auth from an unexpected envelope.`
136240
+ );
136241
+ }
136242
+ return this.normalizeCollectionScripts(collection.scripts);
136243
+ }
136244
+ async patchCollectionRootScripts(collectionUid, scripts) {
136245
+ const id = this.toModelId(collectionUid);
136246
+ await this.gateway.requestJson(
136247
+ {
136248
+ service: "collection",
136249
+ method: "patch",
136250
+ path: `/v3/collections/${id}`,
136251
+ body: [{ op: "add", path: "/scripts", value: scripts }]
136252
+ },
136253
+ { retryTransient: false }
136254
+ );
136255
+ }
135715
136256
  /**
135716
- * Add a secret-free runtime hook to every HTTP request in a collection. The
135717
- * PMAK value is supplied only by the runner as a transient variable; this
135718
- * method persists the variable name and header wiring, never the credential.
136257
+ * Add a secret-free runtime hook at the collection root. The PMAK value is
136258
+ * supplied only by the runner as a transient variable; this method persists
136259
+ * the variable name and header wiring, never the credential.
135719
136260
  */
135720
136261
  async configurePrivateMockRuntimeAuth(collectionUid) {
135721
136262
  const cid = String(collectionUid ?? "").trim();
135722
136263
  if (!cid) return 0;
135723
- const listed = await this.gateway.requestJson({
135724
- service: "collection",
135725
- method: "get",
135726
- path: `/v3/collections/${cid}/items/`
135727
- });
135728
- const items = Array.isArray(listed?.data) ? listed.data : [];
135729
- let patched = 0;
135730
- for (const listedItem of items) {
135731
- if (String(listedItem.$kind ?? "") !== "http-request") continue;
135732
- const itemId = String(listedItem.id ?? "").trim();
135733
- if (!itemId) continue;
135734
- const response = await this.gateway.requestJson({
135735
- service: "collection",
135736
- method: "get",
135737
- path: `/v3/collections/${cid}/items/${itemId}`,
135738
- headers: { "X-Entity-Type": "http-request" }
135739
- });
135740
- const item = this.asRecord(response?.data) ?? listedItem;
135741
- const scripts = Array.isArray(item.scripts) ? item.scripts.filter((entry) => Boolean(this.asRecord(entry))) : [];
135742
- const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
135743
- const existingCode = String(before?.code ?? "");
135744
- if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
135745
- const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
135746
- const nextScripts = [
135747
- ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
135748
- { type: "beforeRequest", code, language: "text/javascript" }
135749
- ];
135750
- await this.gateway.requestJson({
135751
- service: "collection",
135752
- method: "patch",
135753
- path: `/v3/collections/${cid}/items/${itemId}`,
135754
- headers: { "X-Entity-Type": "http-request" },
135755
- body: [{ op: "add", path: "/scripts", value: nextScripts }]
135756
- });
135757
- patched += 1;
135758
- }
135759
- return patched;
136264
+ const installFromFreshRoot = async (existingScripts) => {
136265
+ if (this.rootScriptsIncludeManagedAuthHook(existingScripts)) {
136266
+ return 0;
136267
+ }
136268
+ const nextScripts = this.buildPrivateMockRootScripts(existingScripts);
136269
+ try {
136270
+ await this.patchCollectionRootScripts(cid, nextScripts);
136271
+ return 1;
136272
+ } catch (error) {
136273
+ if (!this.isAmbiguousTransportError(error)) {
136274
+ throw error;
136275
+ }
136276
+ const freshScripts = await this.readCollectionRootScripts(cid);
136277
+ if (this.rootScriptsIncludeManagedAuthHook(freshScripts)) {
136278
+ return 1;
136279
+ }
136280
+ const recomputed = this.buildPrivateMockRootScripts(freshScripts);
136281
+ await this.patchCollectionRootScripts(cid, recomputed);
136282
+ return 1;
136283
+ }
136284
+ };
136285
+ const scripts = await this.readCollectionRootScripts(cid);
136286
+ return installFromFreshRoot(scripts);
135760
136287
  }
135761
136288
  async listMocks() {
135762
136289
  const response = await this.gateway.requestJson({
@@ -135840,12 +136367,13 @@ var PostmanGatewayAssetsClient = class {
135840
136367
  }
135841
136368
  async createMonitor(workspaceId, name, collectionUid, environmentUid, cronSchedule) {
135842
136369
  const ws = workspaceId || this.workspaceId;
135843
- const effectiveCron = cronSchedule && cronSchedule.trim() ? cronSchedule.trim() : "0 0 * * 0";
136370
+ const cronTrimmed = String(cronSchedule ?? "").trim();
136371
+ const hasCron = cronTrimmed.length > 0;
135844
136372
  const monitorName = String(name ?? "").trim();
135845
136373
  const collection = String(collectionUid ?? "").trim();
135846
136374
  const environment = String(environmentUid ?? "").trim();
135847
136375
  const flightKey = `monitor:${ws}:${collection}:${environment}:${monitorName}`;
135848
- return this.singleFlight(flightKey, effectiveCron, "monitor", async () => {
136376
+ return this.singleFlight(flightKey, hasCron ? cronTrimmed : "inactive", "monitor", async () => {
135849
136377
  const existing = await this.findMonitorByCollection(collection, environment, monitorName);
135850
136378
  if (existing?.uid) {
135851
136379
  return existing.uid;
@@ -135853,11 +136381,12 @@ var PostmanGatewayAssetsClient = class {
135853
136381
  const body = {
135854
136382
  name: monitorName,
135855
136383
  collection,
136384
+ active: hasCron,
135856
136385
  options: { strictSSL: false, followRedirects: true, requestTimeout: null, requestDelay: 0 },
135857
136386
  notifications: { onFailure: [], onError: [] },
135858
136387
  retry: {},
135859
- schedule: { cronPattern: effectiveCron, timeZone: "UTC" },
135860
136388
  distribution: null,
136389
+ ...hasCron ? { schedule: { cronPattern: cronTrimmed, timeZone: "UTC" } } : {},
135861
136390
  ...environment ? { environment } : {}
135862
136391
  };
135863
136392
  const send2 = (fallback) => this.gateway.requestJson(
@@ -135943,6 +136472,128 @@ var PostmanGatewayAssetsClient = class {
135943
136472
  }
135944
136473
  };
135945
136474
 
136475
+ // src/lib/postman/private-mock-export-cleanup.ts
136476
+ function asArray2(value) {
136477
+ return Array.isArray(value) ? value : [];
136478
+ }
136479
+ function cloneScriptRecord(script) {
136480
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
136481
+ return script;
136482
+ }
136483
+ return { ...script };
136484
+ }
136485
+ function cloneCollectionNodeIterative(collection) {
136486
+ const cloned = { ...collection };
136487
+ if (Array.isArray(collection.scripts)) {
136488
+ cloned.scripts = collection.scripts.map((script) => cloneScriptRecord(script));
136489
+ }
136490
+ const stack = [];
136491
+ const attachNested = (source, target) => {
136492
+ if (Array.isArray(source.scripts)) {
136493
+ target.scripts = source.scripts.map((script) => cloneScriptRecord(script));
136494
+ }
136495
+ for (const key of ["items", "children"]) {
136496
+ const nested = asArray2(source[key]);
136497
+ if (nested.length === 0) {
136498
+ continue;
136499
+ }
136500
+ const clonedNested = nested.map((item) => ({ ...item }));
136501
+ target[key] = clonedNested;
136502
+ for (let i = 0; i < nested.length; i += 1) {
136503
+ stack.push({ source: nested[i], target: clonedNested[i] });
136504
+ }
136505
+ }
136506
+ };
136507
+ attachNested(collection, cloned);
136508
+ while (stack.length > 0) {
136509
+ const frame = stack.pop();
136510
+ attachNested(frame.source, frame.target);
136511
+ }
136512
+ return cloned;
136513
+ }
136514
+ function cloneCollection(collection) {
136515
+ if (typeof globalThis.structuredClone === "function") {
136516
+ try {
136517
+ return globalThis.structuredClone(collection);
136518
+ } catch {
136519
+ }
136520
+ }
136521
+ try {
136522
+ return JSON.parse(JSON.stringify(collection));
136523
+ } catch {
136524
+ return cloneCollectionNodeIterative(collection);
136525
+ }
136526
+ }
136527
+ function isPrivateMockLegacyExportCleanupEnabled() {
136528
+ const value = String(process.env.POSTMAN_PRIVATE_MOCK_LEGACY_EXPORT_CLEANUP ?? "").trim().toLowerCase();
136529
+ return value !== "off";
136530
+ }
136531
+ function verifyPrivateMockRootHook(collection) {
136532
+ const scripts = asArray2(collection.scripts);
136533
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
136534
+ }
136535
+ function applyPrivateMockExportCleanup(collection, options = {}) {
136536
+ const stripManagedBlocks = options.stripManagedBlocks ?? isPrivateMockLegacyExportCleanupEnabled();
136537
+ const cloned = cloneCollection(collection);
136538
+ let strippedBlocks = 0;
136539
+ const visitItem = (item) => {
136540
+ if (!stripManagedBlocks) {
136541
+ return;
136542
+ }
136543
+ const scripts = item.scripts;
136544
+ if (!Array.isArray(scripts)) {
136545
+ return;
136546
+ }
136547
+ const nextScripts = [];
136548
+ for (const script of scripts) {
136549
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
136550
+ nextScripts.push(script);
136551
+ continue;
136552
+ }
136553
+ const record = script;
136554
+ if (String(record.type ?? "") !== "beforeRequest") {
136555
+ nextScripts.push(record);
136556
+ continue;
136557
+ }
136558
+ const originalCode = String(record.code ?? "");
136559
+ const cleaned = stripManagedItemAuthBlocks(originalCode);
136560
+ if (cleaned === originalCode) {
136561
+ nextScripts.push(record);
136562
+ continue;
136563
+ }
136564
+ strippedBlocks += countManagedItemAuthBlocks(originalCode);
136565
+ if (!cleaned) {
136566
+ continue;
136567
+ }
136568
+ nextScripts.push({ ...record, code: cleaned });
136569
+ }
136570
+ if (nextScripts.length === 0) {
136571
+ delete item.scripts;
136572
+ } else {
136573
+ item.scripts = nextScripts;
136574
+ }
136575
+ };
136576
+ const walkItemsIteratively = (rootItems) => {
136577
+ const stack = [...rootItems].reverse();
136578
+ while (stack.length > 0) {
136579
+ const item = stack.pop();
136580
+ visitItem(item);
136581
+ for (const key of ["items", "children"]) {
136582
+ const nested = asArray2(item[key]);
136583
+ for (let i = nested.length - 1; i >= 0; i -= 1) {
136584
+ stack.push(nested[i]);
136585
+ }
136586
+ }
136587
+ }
136588
+ };
136589
+ walkItemsIteratively(asArray2(cloned.items));
136590
+ return {
136591
+ collection: cloned,
136592
+ strippedBlocks,
136593
+ rootVerified: verifyPrivateMockRootHook(cloned)
136594
+ };
136595
+ }
136596
+
135946
136597
  // src/lib/postman/token-provider.ts
135947
136598
  var MintError = class extends Error {
135948
136599
  permanent;
@@ -136700,6 +137351,15 @@ var identitySecretMasker = (input) => input;
136700
137351
  function resolveRepoSyncMasker(dependencies) {
136701
137352
  return dependencies.secretMasker ?? identitySecretMasker;
136702
137353
  }
137354
+ function resolveRepoSyncLogger(dependencies) {
137355
+ return dependencies.logger ?? createLogger({
137356
+ sink: actionSink(dependencies.core),
137357
+ fields: {
137358
+ action: "postman-repo-sync-action",
137359
+ action_version: resolveActionVersion2()
137360
+ }
137361
+ });
137362
+ }
136703
137363
  function causeText(cause) {
136704
137364
  return cause instanceof Error ? cause.message : String(cause);
136705
137365
  }
@@ -137113,13 +137773,51 @@ function normalizeToPosix(filePath) {
137113
137773
  function canonicalizeRelativePath(value) {
137114
137774
  return normalizeToPosix(String(value ?? "").trim()).replace(/^\.\/+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/g, "");
137115
137775
  }
137116
- function isOpenApiSpecFile(filePath) {
137117
- if (!(filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml"))) {
137118
- return false;
137776
+ var LOCAL_SPEC_DISCOVERY_MAX_DEPTH = 6;
137777
+ var LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES = 1e4;
137778
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES = 200;
137779
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES = 512 * 1024;
137780
+ var LOCAL_SPEC_DISCOVERY_IGNORED_DIRS = /* @__PURE__ */ new Set([
137781
+ ".git",
137782
+ ".nyc_output",
137783
+ ".omc",
137784
+ ".omx",
137785
+ ".llm-plans",
137786
+ ".pulumi",
137787
+ ".terraform",
137788
+ ".venv",
137789
+ "__pycache__",
137790
+ "bin",
137791
+ "build",
137792
+ "coverage",
137793
+ "discovered-specs",
137794
+ "node_modules",
137795
+ "dist",
137796
+ "obj",
137797
+ "out",
137798
+ "target",
137799
+ "vendor",
137800
+ "venv"
137801
+ ]);
137802
+ var LocalSpecDiscoveryLimitError = class extends Error {
137803
+ code = "CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT";
137804
+ constructor(message) {
137805
+ super(`CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT: ${message}`);
137806
+ this.name = "LocalSpecDiscoveryLimitError";
137119
137807
  }
137808
+ };
137809
+ function failLocalSpecDiscoveryLimit(detail) {
137810
+ throw new LocalSpecDiscoveryLimitError(
137811
+ `${detail} Set spec-path to the OpenAPI file explicitly and keep generated trees (for example dist/, node_modules/) out of the repository layout.`
137812
+ );
137813
+ }
137814
+ function isSpecCandidateExtension(filePath) {
137815
+ return filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml");
137816
+ }
137817
+ function readOpenApiSpecFile(fullPath) {
137120
137818
  try {
137121
- const raw = (0, import_node_fs5.readFileSync)(filePath, "utf8");
137122
- const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
137819
+ const raw = (0, import_node_fs5.readFileSync)(fullPath, "utf8");
137820
+ const parsed = fullPath.endsWith(".json") ? JSON.parse(raw) : load(raw);
137123
137821
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
137124
137822
  return false;
137125
137823
  }
@@ -137135,28 +137833,75 @@ function isOpenApiSpecFile(filePath) {
137135
137833
  }
137136
137834
  return false;
137137
137835
  }
137138
- function scanLocalSpecReferences(baseDir = ".") {
137139
- const ignoredDirs = /* @__PURE__ */ new Set([
137140
- ".git",
137141
- ".omc",
137142
- ".omx",
137143
- ".llm-plans",
137144
- "node_modules",
137145
- "dist"
137146
- ]);
137836
+ function shouldIgnoreSpecDiscoveryEntry(entryName, currentDir, baseDir, ignoredPrefixes) {
137837
+ if (LOCAL_SPEC_DISCOVERY_IGNORED_DIRS.has(entryName)) {
137838
+ return true;
137839
+ }
137840
+ const relative3 = normalizeToPosix(path3.relative(baseDir, path3.join(currentDir, entryName)));
137841
+ return ignoredPrefixes.some(
137842
+ (prefix) => relative3 === prefix || relative3.startsWith(`${prefix}/`)
137843
+ );
137844
+ }
137845
+ function scanLocalSpecReferences(baseDir = ".", options = {}) {
137846
+ const ignoredPrefixes = (options.ignoredPrefixes ?? []).map((value) => canonicalizeRelativePath(value)).filter(Boolean);
137147
137847
  const found = /* @__PURE__ */ new Set();
137148
137848
  const refs = [];
137149
- const visit2 = (currentDir) => {
137150
- for (const entry of (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true })) {
137151
- if (ignoredDirs.has(entry.name)) {
137849
+ let traversalEntries = 0;
137850
+ let candidateFiles = 0;
137851
+ const pendingDirs = [{ dir: baseDir, depth: 0 }];
137852
+ while (pendingDirs.length > 0) {
137853
+ const { dir: currentDir, depth: currentDepth } = pendingDirs.shift();
137854
+ let entries;
137855
+ try {
137856
+ entries = (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true }).sort(
137857
+ (left, right) => left.name.localeCompare(right.name)
137858
+ );
137859
+ } catch {
137860
+ continue;
137861
+ }
137862
+ for (const entry of entries) {
137863
+ traversalEntries += 1;
137864
+ if (traversalEntries > LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES) {
137865
+ failLocalSpecDiscoveryLimit(
137866
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES} traversal-entry liveness budget.`
137867
+ );
137868
+ }
137869
+ if (shouldIgnoreSpecDiscoveryEntry(entry.name, currentDir, baseDir, ignoredPrefixes)) {
137152
137870
  continue;
137153
137871
  }
137154
137872
  const fullPath = path3.join(currentDir, entry.name);
137155
137873
  if (entry.isDirectory()) {
137156
- visit2(fullPath);
137874
+ const nextDepth = currentDepth + 1;
137875
+ if (nextDepth > LOCAL_SPEC_DISCOVERY_MAX_DEPTH) {
137876
+ failLocalSpecDiscoveryLimit(
137877
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_DEPTH} directory-depth budget.`
137878
+ );
137879
+ }
137880
+ pendingDirs.push({ dir: fullPath, depth: nextDepth });
137157
137881
  continue;
137158
137882
  }
137159
- if (!entry.isFile() || !isOpenApiSpecFile(fullPath)) {
137883
+ if (!entry.isFile() || !isSpecCandidateExtension(fullPath)) {
137884
+ continue;
137885
+ }
137886
+ candidateFiles += 1;
137887
+ if (candidateFiles > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES) {
137888
+ failLocalSpecDiscoveryLimit(
137889
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES} candidate-file budget.`
137890
+ );
137891
+ }
137892
+ let sizeBytes;
137893
+ try {
137894
+ sizeBytes = (0, import_node_fs5.statSync)(fullPath).size;
137895
+ } catch {
137896
+ continue;
137897
+ }
137898
+ if (sizeBytes > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES) {
137899
+ const repoRelativePath2 = normalizeToPosix(path3.relative(baseDir, fullPath));
137900
+ failLocalSpecDiscoveryLimit(
137901
+ `local spec discovery candidate ${repoRelativePath2} exceeds ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES} bytes.`
137902
+ );
137903
+ }
137904
+ if (!readOpenApiSpecFile(fullPath)) {
137160
137905
  continue;
137161
137906
  }
137162
137907
  const repoRelativePath = normalizeToPosix(path3.relative(baseDir, fullPath));
@@ -137169,20 +137914,36 @@ function scanLocalSpecReferences(baseDir = ".") {
137169
137914
  configRelativePath: normalizeToPosix(path3.join("..", repoRelativePath))
137170
137915
  });
137171
137916
  }
137172
- };
137173
- visit2(baseDir);
137917
+ }
137174
137918
  return refs.sort((left, right) => left.repoRelativePath.localeCompare(right.repoRelativePath));
137175
137919
  }
137176
- function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
137920
+ function tryResolveExplicitSpecReference(explicitSpecPath) {
137177
137921
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
137178
- if (normalizedExplicitPath) {
137179
- const explicitFullPath = path3.resolve(normalizedExplicitPath);
137180
- if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
137181
- return {
137182
- repoRelativePath: normalizedExplicitPath,
137183
- configRelativePath: normalizeToPosix(path3.join("..", normalizedExplicitPath))
137184
- };
137185
- }
137922
+ if (!normalizedExplicitPath) {
137923
+ return void 0;
137924
+ }
137925
+ const explicitFullPath = path3.resolve(normalizedExplicitPath);
137926
+ if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
137927
+ return {
137928
+ repoRelativePath: normalizedExplicitPath,
137929
+ configRelativePath: normalizeToPosix(path3.join("..", normalizedExplicitPath))
137930
+ };
137931
+ }
137932
+ return void 0;
137933
+ }
137934
+ function resolveLocalSpecReferences(explicitSpecPath, baseDir = ".", options = {}) {
137935
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
137936
+ if (explicit) {
137937
+ return { discoveredSpecs: [], mappedSpec: explicit };
137938
+ }
137939
+ const discoveredSpecs = scanLocalSpecReferences(baseDir, options);
137940
+ const mappedSpec = resolveMappedSpecReference(explicitSpecPath, discoveredSpecs);
137941
+ return { discoveredSpecs, mappedSpec };
137942
+ }
137943
+ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
137944
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
137945
+ if (explicit) {
137946
+ return explicit;
137186
137947
  }
137187
137948
  if (discoveredSpecs.length === 1) {
137188
137949
  return discoveredSpecs[0];
@@ -137861,6 +138622,18 @@ function tryReusePrebuiltCollection(options) {
137861
138622
  }
137862
138623
  return prepared.artifactDigest === entry.artifactDigest;
137863
138624
  }
138625
+ async function preparePrivateMockCloudCollection(role, collectionId, postman) {
138626
+ const col = await postman.getCollection(collectionId);
138627
+ const { collection } = applyPrivateMockExportCleanup(col, {
138628
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
138629
+ });
138630
+ if (!verifyPrivateMockRootHook(collection)) {
138631
+ throw new Error(
138632
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
138633
+ );
138634
+ }
138635
+ return collection;
138636
+ }
137864
138637
  async function exportCollectionArtifact(options) {
137865
138638
  const {
137866
138639
  role,
@@ -137869,14 +138642,17 @@ async function exportCollectionArtifact(options) {
137869
138642
  collectionsDir,
137870
138643
  prebuiltByRole,
137871
138644
  postman,
137872
- core
138645
+ core,
138646
+ privateMockAuth = false,
138647
+ preparedCloudCollection
137873
138648
  } = options;
137874
138649
  if (!collectionId) {
137875
138650
  return void 0;
137876
138651
  }
137877
138652
  const expectedPath = `${collectionsDir}/${dirName}`;
138653
+ const forceCloudExport = privateMockAuth && (role === "smoke" || role === "contract");
137878
138654
  const entry = prebuiltByRole.get(role);
137879
- if (entry) {
138655
+ if (entry && !forceCloudExport) {
137880
138656
  const reused = tryReusePrebuiltCollection({
137881
138657
  prepared: entry,
137882
138658
  expectedPath,
@@ -137891,12 +138667,30 @@ async function exportCollectionArtifact(options) {
137891
138667
  core.info(
137892
138668
  `Prebuilt ${role} collection entry present but did not exactly match; exporting from cloud`
137893
138669
  );
138670
+ } else if (entry && forceCloudExport) {
138671
+ core.info(
138672
+ `Private mock requires cloud export for ${role} collection to reconcile managed root hook; exporting from cloud`
138673
+ );
137894
138674
  }
137895
- const col = await postman.getCollection(collectionId);
137896
- await convertAndSplitAnyCollection(
137897
- col,
137898
- expectedPath
137899
- );
138675
+ let collectionForExport;
138676
+ if (forceCloudExport && preparedCloudCollection) {
138677
+ collectionForExport = preparedCloudCollection;
138678
+ } else if (forceCloudExport) {
138679
+ const col = await postman.getCollection(collectionId);
138680
+ const { collection } = applyPrivateMockExportCleanup(col, {
138681
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
138682
+ });
138683
+ if (!verifyPrivateMockRootHook(collection)) {
138684
+ throw new Error(
138685
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
138686
+ );
138687
+ }
138688
+ collectionForExport = collection;
138689
+ } else {
138690
+ const col = await postman.getCollection(collectionId);
138691
+ collectionForExport = col;
138692
+ }
138693
+ await convertAndSplitAnyCollection(collectionForExport, expectedPath);
137900
138694
  return `../${expectedPath}`;
137901
138695
  }
137902
138696
  function hasControlCharacter2(value) {
@@ -137949,32 +138743,37 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
137949
138743
  const globalsDir = `${inputs.artifactDir}/globals`;
137950
138744
  const mocksDir = `${inputs.artifactDir}/mocks`;
137951
138745
  const specsDir = `${inputs.artifactDir}/specs`;
137952
- ensureDir(collectionsDir);
137953
- ensureDir(environmentsDir);
137954
- ensureDir(flowsDir);
137955
- ensureDir(globalsDir);
137956
- ensureDir(mocksDir);
137957
- ensureDir(specsDir);
137958
- ensureDir(".postman");
137959
- const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
137960
- if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
137961
- (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
137962
- }
137963
- if (inputs.generateCiWorkflow) {
137964
- const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
137965
- if (ciDir) {
137966
- ensureDir(ciDir);
137967
- }
137968
- }
137969
138746
  const manifestCollections = {};
137970
- const discoveredSpecs = scanLocalSpecReferences();
137971
- const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
138747
+ const artifactDirPrefix = canonicalizeRelativePath(inputs.artifactDir);
138748
+ const { discoveredSpecs, mappedSpec } = resolveLocalSpecReferences(inputs.specPath, ".", {
138749
+ ignoredPrefixes: artifactDirPrefix ? [artifactDirPrefix, ".postman"] : [".postman"]
138750
+ });
137972
138751
  const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
137973
138752
  mappedSpec.configRelativePath,
137974
138753
  inputs.specSyncMode,
137975
138754
  options.releaseLabel
137976
138755
  ) : void 0;
137977
138756
  const prebuiltByRole = options.preparedPrebuiltCollections;
138757
+ const privateMockAuth = options.privateMockAuth === true;
138758
+ const preparedPrivateMockCollections = /* @__PURE__ */ new Map();
138759
+ if (privateMockAuth) {
138760
+ for (const spec of [
138761
+ { role: "smoke", collectionId: inputs.smokeCollectionId },
138762
+ { role: "contract", collectionId: inputs.contractCollectionId }
138763
+ ]) {
138764
+ if (!spec.collectionId) {
138765
+ continue;
138766
+ }
138767
+ preparedPrivateMockCollections.set(
138768
+ spec.role,
138769
+ await preparePrivateMockCloudCollection(
138770
+ spec.role,
138771
+ spec.collectionId,
138772
+ dependencies.postman
138773
+ )
138774
+ );
138775
+ }
138776
+ }
137978
138777
  const baselineRef = await exportCollectionArtifact({
137979
138778
  role: "baseline",
137980
138779
  collectionId: inputs.baselineCollectionId,
@@ -137982,7 +138781,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
137982
138781
  collectionsDir,
137983
138782
  prebuiltByRole,
137984
138783
  postman: dependencies.postman,
137985
- core: dependencies.core
138784
+ core: dependencies.core,
138785
+ privateMockAuth
137986
138786
  });
137987
138787
  if (baselineRef) {
137988
138788
  manifestCollections[baselineRef] = inputs.baselineCollectionId;
@@ -137994,7 +138794,9 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
137994
138794
  collectionsDir,
137995
138795
  prebuiltByRole,
137996
138796
  postman: dependencies.postman,
137997
- core: dependencies.core
138797
+ core: dependencies.core,
138798
+ privateMockAuth,
138799
+ preparedCloudCollection: preparedPrivateMockCollections.get("smoke")
137998
138800
  });
137999
138801
  if (smokeRef) {
138000
138802
  manifestCollections[smokeRef] = inputs.smokeCollectionId;
@@ -138006,11 +138808,30 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
138006
138808
  collectionsDir,
138007
138809
  prebuiltByRole,
138008
138810
  postman: dependencies.postman,
138009
- core: dependencies.core
138811
+ core: dependencies.core,
138812
+ privateMockAuth,
138813
+ preparedCloudCollection: preparedPrivateMockCollections.get("contract")
138010
138814
  });
138011
138815
  if (contractRef) {
138012
138816
  manifestCollections[contractRef] = inputs.contractCollectionId;
138013
138817
  }
138818
+ ensureDir(collectionsDir);
138819
+ ensureDir(environmentsDir);
138820
+ ensureDir(flowsDir);
138821
+ ensureDir(globalsDir);
138822
+ ensureDir(mocksDir);
138823
+ ensureDir(specsDir);
138824
+ ensureDir(".postman");
138825
+ const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
138826
+ if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
138827
+ (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
138828
+ }
138829
+ if (inputs.generateCiWorkflow) {
138830
+ const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
138831
+ if (ciDir) {
138832
+ ensureDir(ciDir);
138833
+ }
138834
+ }
138014
138835
  for (const [envName, envUid] of Object.entries(envUids)) {
138015
138836
  writeJsonFile(
138016
138837
  `${environmentsDir}/${envName}.postman_environment.json`,
@@ -138163,19 +138984,41 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
138163
138984
  async function runRepoSync(inputs, dependencies) {
138164
138985
  const telemetry = createTelemetryContext({ action: "postman-repo-sync-action", actionVersion: resolveActionVersion2(), logger: dependencies.core });
138165
138986
  telemetry.setTeamId(dependencies.teamId);
138987
+ const logger = resolveRepoSyncLogger(dependencies);
138988
+ for (const secret of [
138989
+ inputs.postmanApiKey,
138990
+ inputs.postmanAccessToken,
138991
+ inputs.adoToken,
138992
+ inputs.githubToken,
138993
+ inputs.ghFallbackToken,
138994
+ inputs.sslClientCert,
138995
+ inputs.sslClientKey,
138996
+ inputs.sslClientPassphrase,
138997
+ inputs.sslExtraCaCerts
138998
+ ]) {
138999
+ logger.addSecret(secret);
139000
+ }
139001
+ logger.debug("resolved inputs", {
139002
+ project: inputs.projectName,
139003
+ collection_sync_mode: inputs.collectionSyncMode,
139004
+ spec_sync_mode: inputs.specSyncMode,
139005
+ team_id: dependencies.teamId || void 0
139006
+ });
138166
139007
  try {
138167
- const result = await runRepoSyncInner(inputs, dependencies);
139008
+ const result = await runRepoSyncInner(inputs, { ...dependencies, logger });
138168
139009
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
138169
139010
  telemetry.emitCompletion("success");
138170
139011
  return result;
138171
139012
  } catch (error) {
138172
139013
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
138173
139014
  telemetry.emitCompletion("failure");
139015
+ logger.failure("repo sync failed", error);
138174
139016
  throw error;
138175
139017
  }
138176
139018
  }
138177
139019
  async function runRepoSyncInner(inputs, dependencies) {
138178
139020
  const mask = resolveRepoSyncMasker(dependencies);
139021
+ const logger = resolveRepoSyncLogger(dependencies);
138179
139022
  const branchDecision = decideBranchTier(inputs);
138180
139023
  assertBranchAssetIds(inputs, branchDecision);
138181
139024
  const isCanonicalWriter = branchDecision.tier === "legacy" || branchDecision.tier === "canonical";
@@ -138235,7 +139078,10 @@ async function runRepoSyncInner(inputs, dependencies) {
138235
139078
  }
138236
139079
  }
138237
139080
  }
138238
- const preparedPrebuiltCollections = await preparePrebuiltCollections(inputs);
139081
+ const preparedPrebuiltCollections = await logger.phase(
139082
+ "prepare-collections",
139083
+ async () => preparePrebuiltCollections(inputs)
139084
+ );
138239
139085
  let skipRepositoryLinkPost = false;
138240
139086
  let repositoryLinkPreflightWasFree = false;
138241
139087
  if (inputs.workspaceLinkEnabled && inputs.workspaceId && inputs.repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
@@ -138270,7 +139116,10 @@ async function runRepoSyncInner(inputs, dependencies) {
138270
139116
  }
138271
139117
  }
138272
139118
  const branchAssetMarker = buildBranchAssetMarker(branchDecision, inputs);
138273
- const envUids = await upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker);
139119
+ const envUids = await logger.phase(
139120
+ "sync-environments",
139121
+ async () => upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker)
139122
+ );
138274
139123
  outputs["environment-uids-json"] = JSON.stringify(envUids);
138275
139124
  dependencies.core.setOutput("environment-uids-json", outputs["environment-uids-json"]);
138276
139125
  if (inputs.environmentSyncEnabled && inputs.workspaceId && dependencies.internalIntegration) {
@@ -138433,10 +139282,21 @@ async function runRepoSyncInner(inputs, dependencies) {
138433
139282
  );
138434
139283
  }
138435
139284
  const configured = [];
138436
- for (const collectionUid of [inputs.smokeCollectionId, inputs.contractCollectionId]) {
138437
- if (collectionUid) {
139285
+ for (const { role, collectionUid } of [
139286
+ { role: "smoke", collectionUid: inputs.smokeCollectionId },
139287
+ { role: "contract", collectionUid: inputs.contractCollectionId }
139288
+ ]) {
139289
+ if (!collectionUid) {
139290
+ continue;
139291
+ }
139292
+ try {
138438
139293
  await dependencies.postman.configurePrivateMockRuntimeAuth(collectionUid);
138439
139294
  configured.push(collectionUid);
139295
+ } catch (error) {
139296
+ throw new Error(
139297
+ `PRIVATE_MOCK_AUTH_ROOT_PATCH: Failed to install managed root hook on ${role} collection ${collectionUid}: ${mask(causeText(error))}`,
139298
+ { cause: error }
139299
+ );
138440
139300
  }
138441
139301
  }
138442
139302
  if (configured.length > 0) {
@@ -138588,16 +139448,23 @@ async function runRepoSyncInner(inputs, dependencies) {
138588
139448
  dependencies.core.warning(message);
138589
139449
  }
138590
139450
  }
138591
- await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
138592
- workspaceLinkStatus: outputs["workspace-link-status"],
138593
- priorWorkspaceId: resourcesState?.workspace?.id,
138594
- existingSpecs: resourcesState?.cloudResources?.specs,
138595
- mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
138596
- releaseLabel,
138597
- priorState: resourcesState,
138598
- preparedPrebuiltCollections
138599
- });
138600
- const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
139451
+ await logger.phase(
139452
+ "export-artifacts",
139453
+ async () => exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
139454
+ workspaceLinkStatus: outputs["workspace-link-status"],
139455
+ priorWorkspaceId: resourcesState?.workspace?.id,
139456
+ existingSpecs: resourcesState?.cloudResources?.specs,
139457
+ mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
139458
+ releaseLabel,
139459
+ priorState: resourcesState,
139460
+ preparedPrebuiltCollections,
139461
+ privateMockAuth: inputs.mockVisibility === "private"
139462
+ })
139463
+ );
139464
+ const commit = await logger.phase(
139465
+ "commit-and-push",
139466
+ async () => commitAndPushGeneratedFiles(inputs, dependencies)
139467
+ );
138601
139468
  outputs["commit-sha"] = commit.commitSha;
138602
139469
  if (commit.resolvedCurrentRef) {
138603
139470
  outputs["resolved-current-ref"] = commit.resolvedCurrentRef;