@postman-cse/onboarding-repo-sync 2.4.2 → 2.6.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/action.cjs CHANGED
@@ -42720,14 +42720,14 @@ var require_description = __commonJS({
42720
42720
  var z = __importStar(require_mini());
42721
42721
  var metadata_1 = require_metadata();
42722
42722
  var MAX_CONTENT_LENGTH = 1e6;
42723
- function truncate2(value) {
42723
+ function truncate3(value) {
42724
42724
  return value.length > MAX_CONTENT_LENGTH ? value.slice(0, MAX_CONTENT_LENGTH) : value;
42725
42725
  }
42726
42726
  exports2.Description = (0, schemas_1.model)(z.union([
42727
- z.pipe(z.string(), z.transform(truncate2)),
42727
+ z.pipe(z.string(), z.transform(truncate3)),
42728
42728
  z.null(),
42729
42729
  z.object({
42730
- content: z.pipe(z.optional(z.string()), z.transform((value) => truncate2(value ?? ""))),
42730
+ content: z.pipe(z.optional(z.string()), z.transform((value) => truncate3(value ?? ""))),
42731
42731
  type: z.optional(z.string()),
42732
42732
  version: z.optional(z.unknown())
42733
42733
  })
@@ -57953,7 +57953,7 @@ var require_lodash = __commonJS({
57953
57953
  var strSymbols = stringToArray(string), start = charsStartIndex(strSymbols, stringToArray(chars));
57954
57954
  return castSlice(strSymbols, start).join("");
57955
57955
  }
57956
- function truncate2(string, options) {
57956
+ function truncate3(string, options) {
57957
57957
  var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
57958
57958
  if (isObject(options)) {
57959
57959
  var separator = "separator" in options ? options.separator : separator;
@@ -58513,7 +58513,7 @@ var require_lodash = __commonJS({
58513
58513
  lodash.trim = trim;
58514
58514
  lodash.trimEnd = trimEnd;
58515
58515
  lodash.trimStart = trimStart;
58516
- lodash.truncate = truncate2;
58516
+ lodash.truncate = truncate3;
58517
58517
  lodash.unescape = unescape2;
58518
58518
  lodash.uniqueId = uniqueId;
58519
58519
  lodash.upperCase = upperCase;
@@ -95744,10 +95744,10 @@ var require_unicode = __commonJS({
95744
95744
  module2.exports.isLineTerminatorJSON = function isLineTerminatorJSON(x) {
95745
95745
  return x === "\n" || x === "\r";
95746
95746
  };
95747
- module2.exports.isIdentifierStart = function isIdentifierStart(x) {
95747
+ module2.exports.isIdentifierStart = function isIdentifierStart2(x) {
95748
95748
  return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "\x80" && Uni.NonAsciiIdentifierStart.test(x);
95749
95749
  };
95750
- module2.exports.isIdentifierPart = function isIdentifierPart(x) {
95750
+ module2.exports.isIdentifierPart = function isIdentifierPart2(x) {
95751
95751
  return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "0" && x <= "9" || x >= "\x80" && Uni.NonAsciiIdentifierPart.test(x);
95752
95752
  };
95753
95753
  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]/;
@@ -118661,7 +118661,7 @@ var require_truncate = __commonJS({
118661
118661
  function isLowSurrogate(codePoint) {
118662
118662
  return codePoint >= 56320 && codePoint <= 57343;
118663
118663
  }
118664
- module2.exports = function truncate2(getLength, string, byteLength) {
118664
+ module2.exports = function truncate3(getLength, string, byteLength) {
118665
118665
  if (typeof string !== "string") {
118666
118666
  throw new Error("Input must be string");
118667
118667
  }
@@ -118692,9 +118692,9 @@ var require_truncate = __commonJS({
118692
118692
  var require_truncate_utf8_bytes = __commonJS({
118693
118693
  "node_modules/truncate-utf8-bytes/index.js"(exports2, module2) {
118694
118694
  "use strict";
118695
- var truncate2 = require_truncate();
118695
+ var truncate3 = require_truncate();
118696
118696
  var getLength = Buffer.byteLength.bind(Buffer);
118697
- module2.exports = truncate2.bind(null, getLength);
118697
+ module2.exports = truncate3.bind(null, getLength);
118698
118698
  }
118699
118699
  });
118700
118700
 
@@ -134309,7 +134309,9 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
134309
134309
  ` POSTMAN_CLI_INSTALL_URL: ${installUrl}`,
134310
134310
  ' run: curl -fsSL "$POSTMAN_CLI_INSTALL_URL" | sh',
134311
134311
  " - name: Login to Postman CLI",
134312
- " run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}" + (postmanRegion === "eu" ? " --region eu" : ""),
134312
+ " env:",
134313
+ " POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}",
134314
+ ' run: postman login --with-api-key "$POSTMAN_API_KEY"' + (postmanRegion === "eu" ? " --region eu" : ""),
134313
134315
  " - name: Resolve Postman Resource IDs",
134314
134316
  " run: |",
134315
134317
  " ruby <<'RUBY'",
@@ -134348,12 +134350,13 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
134348
134350
  " - name: Run Smoke Tests",
134349
134351
  " env:",
134350
134352
  " POSTMAN_SSL_CLIENT_PASSPHRASE: ${{ secrets.POSTMAN_SSL_CLIENT_PASSPHRASE }}",
134353
+ ...privateMockAuth ? [" POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}"] : [],
134351
134354
  " run: |",
134352
134355
  ' CMD=(postman collection run "$POSTMAN_SMOKE_COLLECTION_UID"',
134353
134356
  ' -e "$POSTMAN_ENVIRONMENT_UID"',
134354
134357
  " --report-events",
134355
134358
  ` --env-var "CI_ENVIRONMENT=\${{ vars.CI_ENVIRONMENT || 'Production' }}")`,
134356
- ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=${{ secrets.POSTMAN_API_KEY }}")'] : [],
134359
+ ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=$POSTMAN_API_KEY")'] : [],
134357
134360
  ' if [ -f "$RUNNER_TEMP/postman-ssl/client.crt" ]; then',
134358
134361
  ' CMD+=(--ssl-client-cert "$RUNNER_TEMP/postman-ssl/client.crt"',
134359
134362
  ' --ssl-client-key "$RUNNER_TEMP/postman-ssl/client.key")',
@@ -134368,12 +134371,13 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
134368
134371
  " - name: Run Contract Tests",
134369
134372
  " env:",
134370
134373
  " POSTMAN_SSL_CLIENT_PASSPHRASE: ${{ secrets.POSTMAN_SSL_CLIENT_PASSPHRASE }}",
134374
+ ...privateMockAuth ? [" POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}"] : [],
134371
134375
  " run: |",
134372
134376
  ' CMD=(postman collection run "$POSTMAN_CONTRACT_COLLECTION_UID"',
134373
134377
  ' -e "$POSTMAN_ENVIRONMENT_UID"',
134374
134378
  " --report-events",
134375
134379
  ` --env-var "CI_ENVIRONMENT=\${{ vars.CI_ENVIRONMENT || 'Production' }}")`,
134376
- ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=${{ secrets.POSTMAN_API_KEY }}")'] : [],
134380
+ ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=$POSTMAN_API_KEY")'] : [],
134377
134381
  ' if [ -f "$RUNNER_TEMP/postman-ssl/client.crt" ]; then',
134378
134382
  ' CMD+=(--ssl-client-cert "$RUNNER_TEMP/postman-ssl/client.crt"',
134379
134383
  ' --ssl-client-key "$RUNNER_TEMP/postman-ssl/client.key")',
@@ -134400,7 +134404,9 @@ function buildAdoWindowsCollectionRunLines(displayName, collectionEnvironmentNam
134400
134404
  ` $collectionUid = $env:${collectionEnvironmentName}`,
134401
134405
  " $ciEnvironment = Resolve-AdoOptional $env:CI_ENVIRONMENT",
134402
134406
  " if ([string]::IsNullOrWhiteSpace($ciEnvironment)) { $ciEnvironment = 'Production' }",
134403
- ` $arguments = @('collection', 'run', $collectionUid, '-e', $env:POSTMAN_ENVIRONMENT_UID, '--report-events', '--env-var', "CI_ENVIRONMENT=$ciEnvironment")`,
134407
+ " $responseTimeThreshold = Resolve-AdoOptional $env:RESPONSE_TIME_THRESHOLD",
134408
+ " if ([string]::IsNullOrWhiteSpace($responseTimeThreshold)) { $responseTimeThreshold = '10000' }",
134409
+ ` $arguments = @('collection', 'run', $collectionUid, '-e', $env:POSTMAN_ENVIRONMENT_UID, '--report-events', '--env-var', "CI_ENVIRONMENT=$ciEnvironment", '--env-var', "RESPONSE_TIME_THRESHOLD=$responseTimeThreshold")`,
134404
134410
  ...privateMockAuth ? [` $arguments += @('--env-var', "${PRIVATE_MOCK_AUTH_VARIABLE}=$env:POSTMAN_API_KEY")`] : [],
134405
134411
  " $sslRoot = Join-Path $env:AGENT_TEMPDIRECTORY 'postman-ssl'",
134406
134412
  " $clientCert = Join-Path $sslRoot 'client.crt'",
@@ -134423,6 +134429,7 @@ function buildAdoWindowsCollectionRunLines(displayName, collectionEnvironmentNam
134423
134429
  ` ${collectionEnvironmentName}: $(${collectionEnvironmentName})`,
134424
134430
  " POSTMAN_ENVIRONMENT_UID: $(POSTMAN_ENVIRONMENT_UID)",
134425
134431
  " CI_ENVIRONMENT: $(CI_ENVIRONMENT)",
134432
+ " RESPONSE_TIME_THRESHOLD: $(RESPONSE_TIME_THRESHOLD)",
134426
134433
  " POSTMAN_SSL_CLIENT_PASSPHRASE: $(POSTMAN_SSL_CLIENT_PASSPHRASE)",
134427
134434
  ...privateMockAuth ? [" POSTMAN_API_KEY: $(POSTMAN_API_KEY)"] : []
134428
134435
  ];
@@ -135192,7 +135199,7 @@ function detectRepoContext(input, env = process.env) {
135192
135199
  };
135193
135200
  }
135194
135201
 
135195
- // node_modules/@postman-cse/automation-telemetry-core/dist/ci-context.js
135202
+ // node_modules/@postman-cse/automation-core/dist/ci-context.js
135196
135203
  function norm(value) {
135197
135204
  const trimmed = (value ?? "").trim();
135198
135205
  return trimmed.length > 0 ? trimmed : void 0;
@@ -135343,7 +135350,7 @@ function detectCiProviderContext(env = process.env) {
135343
135350
  return { ciProvider: "unknown", runnerKind: "unknown" };
135344
135351
  }
135345
135352
 
135346
- // node_modules/@postman-cse/automation-telemetry-core/dist/repo-context.js
135353
+ // node_modules/@postman-cse/automation-core/dist/repo-context.js
135347
135354
  function normalize2(value) {
135348
135355
  const trimmed = (value ?? "").trim();
135349
135356
  return trimmed.length > 0 ? trimmed : void 0;
@@ -135432,7 +135439,7 @@ function detectRepoContext2(input, env = process.env) {
135432
135439
  };
135433
135440
  }
135434
135441
 
135435
- // node_modules/@postman-cse/automation-telemetry-core/dist/telemetry.js
135442
+ // node_modules/@postman-cse/automation-core/dist/telemetry.js
135436
135443
  var import_node_crypto = require("node:crypto");
135437
135444
  var import_undici2 = __toESM(require_undici(), 1);
135438
135445
  var SCHEMA_VERSION = 3;
@@ -135442,10 +135449,14 @@ var proxyDispatcher;
135442
135449
  function getProxyDispatcher() {
135443
135450
  return proxyDispatcher ??= new import_undici2.EnvHttpProxyAgent();
135444
135451
  }
135445
- function resolveActionVersion(explicit) {
135452
+ function resolveActionVersion(explicit, env = process.env) {
135446
135453
  if (explicit) {
135447
135454
  return explicit;
135448
135455
  }
135456
+ const ref = env.GITHUB_ACTION_REF?.trim();
135457
+ if (ref) {
135458
+ return ref;
135459
+ }
135449
135460
  return typeof __ACTION_VERSION__ !== "undefined" && __ACTION_VERSION__ ? __ACTION_VERSION__ : "unknown";
135450
135461
  }
135451
135462
  function telemetryDisabled(env) {
@@ -135528,7 +135539,7 @@ async function send(event, options) {
135528
135539
  function createTelemetryContext(options) {
135529
135540
  const env = options.env ?? process.env;
135530
135541
  const now = options.now ?? Date.now;
135531
- const actionVersion = resolveActionVersion(options.actionVersion);
135542
+ const actionVersion = resolveActionVersion(options.actionVersion, env);
135532
135543
  let teamId = "";
135533
135544
  let accountType = "unknown";
135534
135545
  let emitted = false;
@@ -135568,6 +135579,229 @@ function createTelemetryContext(options) {
135568
135579
  };
135569
135580
  }
135570
135581
 
135582
+ // node_modules/@postman-cse/automation-core/dist/logger.js
135583
+ var LEVEL_ORDER = {
135584
+ debug: 10,
135585
+ info: 20,
135586
+ warning: 30,
135587
+ error: 40
135588
+ };
135589
+ function defaultCorrelationId() {
135590
+ return Math.random().toString(36).slice(2, 10);
135591
+ }
135592
+ function resolveLogLevel(env = process.env) {
135593
+ const explicit = String(env.POSTMAN_ACTIONS_LOG_LEVEL ?? "").trim().toLowerCase();
135594
+ if (explicit === "debug" || explicit === "trace" || explicit === "verbose")
135595
+ return "debug";
135596
+ if (explicit === "info")
135597
+ return "info";
135598
+ if (explicit === "warn" || explicit === "warning")
135599
+ return "warning";
135600
+ if (explicit === "error" || explicit === "quiet")
135601
+ return "error";
135602
+ if (isTruthyFlag(env.RUNNER_DEBUG) || isTruthyFlag(env.ACTIONS_STEP_DEBUG))
135603
+ return "debug";
135604
+ if (isTruthyFlag(env.POSTMAN_ACTIONS_DEBUG))
135605
+ return "debug";
135606
+ return "info";
135607
+ }
135608
+ function isTruthyFlag(value) {
135609
+ if (!value)
135610
+ return false;
135611
+ const flag = value.trim().toLowerCase();
135612
+ return flag === "1" || flag === "true" || flag === "yes" || flag === "on";
135613
+ }
135614
+ function actionSink(core) {
135615
+ return {
135616
+ debug: (message) => core.debug?.(message),
135617
+ info: (message) => core.info(message),
135618
+ warning: (message) => (core.warning ?? core.info)(message),
135619
+ error: (message) => (core.error ?? core.warning ?? core.info)(message),
135620
+ startGroup: core.startGroup ? (name) => core.startGroup?.(name) : void 0,
135621
+ endGroup: core.endGroup ? () => core.endGroup?.() : void 0,
135622
+ isDebug: core.isDebug ? () => core.isDebug?.() ?? false : void 0
135623
+ };
135624
+ }
135625
+ var MIN_SECRET_LENGTH = 4;
135626
+ function renderValue(value, maxLength = 512) {
135627
+ if (value === void 0)
135628
+ return "undefined";
135629
+ if (value === null)
135630
+ return "null";
135631
+ if (typeof value === "string")
135632
+ return truncate(value, maxLength);
135633
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
135634
+ return String(value);
135635
+ }
135636
+ if (value instanceof Error)
135637
+ return truncate(describeError(value), maxLength);
135638
+ if (Array.isArray(value)) {
135639
+ return truncate(`[${value.map((entry) => renderValue(entry, 120)).join(", ")}]`, maxLength);
135640
+ }
135641
+ try {
135642
+ return truncate(JSON.stringify(value) ?? String(value), maxLength);
135643
+ } catch {
135644
+ return "<unserializable>";
135645
+ }
135646
+ }
135647
+ function truncate(text, maxLength) {
135648
+ if (text.length <= maxLength)
135649
+ return text;
135650
+ return `${text.slice(0, maxLength)}\u2026 (+${text.length - maxLength} chars)`;
135651
+ }
135652
+ function describeError(error2, maxDepth = 5) {
135653
+ const parts = [];
135654
+ let current = error2;
135655
+ let depth = 0;
135656
+ while (current !== void 0 && current !== null && depth < maxDepth) {
135657
+ if (current instanceof Error) {
135658
+ const code = current.code;
135659
+ parts.push(code ? `${current.name}[${code}]: ${current.message}` : `${current.name}: ${current.message}`);
135660
+ current = current.cause;
135661
+ } else if (typeof current === "object") {
135662
+ try {
135663
+ parts.push(JSON.stringify(current) ?? String(current));
135664
+ } catch {
135665
+ parts.push(String(current));
135666
+ }
135667
+ current = void 0;
135668
+ } else {
135669
+ parts.push(String(current));
135670
+ current = void 0;
135671
+ }
135672
+ depth += 1;
135673
+ }
135674
+ if (parts.length === 0)
135675
+ return "unknown error";
135676
+ return parts.join(" <- caused by ");
135677
+ }
135678
+ function createLogger(options) {
135679
+ const env = options.env ?? process.env;
135680
+ const level = options.level ?? resolveLogLevel(env);
135681
+ const secrets = options.secrets ?? /* @__PURE__ */ new Set();
135682
+ const correlationId = options.correlationId ?? defaultCorrelationId();
135683
+ const now = options.now ?? (() => Date.now());
135684
+ const threshold = LEVEL_ORDER[level];
135685
+ function addSecret(value) {
135686
+ if (typeof value !== "string")
135687
+ return;
135688
+ const trimmed = value.trim();
135689
+ if (trimmed.length < MIN_SECRET_LENGTH)
135690
+ return;
135691
+ secrets.add(trimmed);
135692
+ }
135693
+ function redact(text) {
135694
+ let output = typeof text === "string" ? text : renderValue(text, 4096);
135695
+ for (const secret of secrets) {
135696
+ if (!secret)
135697
+ continue;
135698
+ output = output.split(secret).join("***");
135699
+ const encoded = encodeURIComponent(secret);
135700
+ if (encoded !== secret)
135701
+ output = output.split(encoded).join("***");
135702
+ }
135703
+ return output;
135704
+ }
135705
+ function build2(baseFields) {
135706
+ function emit(target, message, fields) {
135707
+ if (LEVEL_ORDER[target] < threshold)
135708
+ return;
135709
+ const merged = { ...baseFields, ...fields ?? {} };
135710
+ const rendered = Object.entries(merged).filter(([, value]) => value !== void 0).map(([key, value]) => `${key}=${redact(renderValue(value))}`).join(" ");
135711
+ const line = rendered ? `${redact(message)} | ${rendered}` : redact(message);
135712
+ switch (target) {
135713
+ case "debug":
135714
+ options.sink.debug(line);
135715
+ break;
135716
+ case "info":
135717
+ options.sink.info(line);
135718
+ break;
135719
+ case "warning":
135720
+ options.sink.warning(line);
135721
+ break;
135722
+ case "error":
135723
+ options.sink.error(line);
135724
+ break;
135725
+ }
135726
+ }
135727
+ const logger = {
135728
+ level,
135729
+ correlationId,
135730
+ addSecret,
135731
+ redact,
135732
+ isDebug: () => threshold <= LEVEL_ORDER.debug,
135733
+ debug: (message, fields) => emit("debug", message, fields),
135734
+ info: (message, fields) => emit("info", message, fields),
135735
+ warning: (message, fields) => emit("warning", message, fields),
135736
+ error: (message, fields) => emit("error", message, fields),
135737
+ failure: (message, error2, fields) => emit("error", message, { ...fields ?? {}, error: describeError(error2) }),
135738
+ child: (fields) => build2({ ...baseFields, ...fields }),
135739
+ async phase(name, fn, fields) {
135740
+ const scoped = build2({ ...baseFields, ...fields ?? {}, phase: name });
135741
+ const started = now();
135742
+ scoped.debug("phase start");
135743
+ options.sink.startGroup?.(name);
135744
+ try {
135745
+ const result = await fn();
135746
+ scoped.debug("phase ok", { duration_ms: Math.round(now() - started) });
135747
+ return result;
135748
+ } catch (error2) {
135749
+ scoped.failure("phase failed", error2, { duration_ms: Math.round(now() - started) });
135750
+ throw error2;
135751
+ } finally {
135752
+ options.sink.endGroup?.();
135753
+ }
135754
+ }
135755
+ };
135756
+ return logger;
135757
+ }
135758
+ const root = build2({ run: correlationId, ...options.fields ?? {} });
135759
+ return root;
135760
+ }
135761
+
135762
+ // node_modules/@postman-cse/automation-core/dist/secrets-resolver.js
135763
+ var SECRETS_RESOLVER_PROVIDERS = ["none", "aws", "azure", "gcp"];
135764
+ var DEFAULT_SECRETS_RESOLVER_PROVIDER = "none";
135765
+ function parseSecretsResolverProvider(value, fallback = DEFAULT_SECRETS_RESOLVER_PROVIDER) {
135766
+ const raw = String(value ?? "").trim().toLowerCase();
135767
+ if (!raw)
135768
+ return fallback;
135769
+ if (raw === "true")
135770
+ return "aws";
135771
+ if (raw === "false" || raw === "off")
135772
+ return "none";
135773
+ if (SECRETS_RESOLVER_PROVIDERS.includes(raw)) {
135774
+ return raw;
135775
+ }
135776
+ throw new Error(`SECRETS_RESOLVER_PROVIDER_INVALID: expected one of ${SECRETS_RESOLVER_PROVIDERS.join(", ")} (or legacy true/false), received "${value}"`);
135777
+ }
135778
+ function secretsResolverEnvironmentKeys(provider) {
135779
+ switch (provider) {
135780
+ case "aws":
135781
+ return [
135782
+ { key: "AWS_ACCESS_KEY_ID", secret: true },
135783
+ { key: "AWS_SECRET_ACCESS_KEY", secret: true },
135784
+ { key: "AWS_REGION", secret: false },
135785
+ { key: "AWS_SECRET_NAME", secret: false }
135786
+ ];
135787
+ case "azure":
135788
+ return [
135789
+ { key: "AZURE_KEY_VAULT_NAME", secret: false },
135790
+ { key: "AZURE_SECRET_NAME", secret: false },
135791
+ { key: "AZURE_ACCESS_TOKEN", secret: true }
135792
+ ];
135793
+ case "gcp":
135794
+ return [
135795
+ { key: "GCP_PROJECT_ID", secret: false },
135796
+ { key: "GCP_SECRET_NAME", secret: false },
135797
+ { key: "GCP_ACCESS_TOKEN", secret: true }
135798
+ ];
135799
+ case "none":
135800
+ default:
135801
+ return [];
135802
+ }
135803
+ }
135804
+
135571
135805
  // src/action-version.ts
135572
135806
  var import_node_fs3 = require("node:fs");
135573
135807
  var import_node_path2 = require("node:path");
@@ -135584,7 +135818,7 @@ function resolveActionVersion2() {
135584
135818
  }
135585
135819
 
135586
135820
  // src/lib/http-error.ts
135587
- function truncate(value, limit) {
135821
+ function truncate2(value, limit) {
135588
135822
  if (value.length <= limit) {
135589
135823
  return value;
135590
135824
  }
@@ -135594,7 +135828,7 @@ function buildMessage(init) {
135594
135828
  const method = String(init.method || "GET").toUpperCase();
135595
135829
  const status = `${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
135596
135830
  const url = redactSecrets(init.url, init.secretValues);
135597
- const body = truncate(
135831
+ const body = truncate2(
135598
135832
  redactSecrets(init.responseBody || "", init.secretValues),
135599
135833
  Math.max(0, init.bodyLimit ?? 800)
135600
135834
  );
@@ -136771,6 +137005,12 @@ var postmanRepoSyncActionContract = {
136771
137005
  required: false,
136772
137006
  default: ""
136773
137007
  },
137008
+ "secrets-resolver": {
137009
+ description: "Cloud secret store the generated environments seed credential slots for (none, aws, azure, gcp). Must match the value passed to bootstrap and smoke-flow.",
137010
+ required: false,
137011
+ default: "none",
137012
+ allowedValues: ["none", "aws", "azure", "gcp"]
137013
+ },
136774
137014
  "credential-preflight": {
136775
137015
  description: "Credential identity preflight policy. warn (default) logs a note and continues when postman-api-key and postman-access-token resolve to different parent orgs; enforce fails the run on that condition before any workspace is created. Both modes warn when postman-access-token is not a service-account token.",
136776
137016
  required: false,
@@ -136973,31 +137213,13 @@ var PostmanAssetsClient = class {
136973
137213
  }
136974
137214
  };
136975
137215
 
136976
- // src/lib/postman/postman-gateway-assets-client.ts
136977
- var MockContractError = class extends Error {
136978
- constructor(message) {
136979
- super(message);
136980
- this.name = "MockContractError";
136981
- }
136982
- };
136983
- function requireMockVisibility(mock, requested) {
136984
- if (mock.visibility === "unknown") {
136985
- throw new MockContractError(
136986
- `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
136987
- );
136988
- }
136989
- if (mock.visibility !== requested) {
136990
- const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
136991
- throw new MockContractError(
136992
- `${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}.`
136993
- );
136994
- }
136995
- return mock;
136996
- }
137216
+ // src/lib/postman/private-mock-auth-script.ts
136997
137217
  var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
136998
137218
  var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
136999
- var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
137219
+ var PRIVATE_MOCK_AUTH_V3_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
137000
137220
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
137221
+ var PRIVATE_MOCK_AUTH_ROOT_TYPE = "http:beforeRequest";
137222
+ var PRIVATE_MOCK_AUTH_ROOT_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-root`;
137001
137223
  var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137002
137224
  `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
137003
137225
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
@@ -137018,8 +137240,8 @@ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
137018
137240
  ` 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.');`,
137019
137241
  "}"
137020
137242
  ].join("\n");
137021
- var PRIVATE_MOCK_AUTH_SCRIPT = [
137022
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137243
+ var PRIVATE_MOCK_AUTH_V3_SCRIPT = [
137244
+ `// ${PRIVATE_MOCK_AUTH_V3_MARKER}`,
137023
137245
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137024
137246
  "var privateMockHost = '';",
137025
137247
  "try {",
@@ -137035,8 +137257,336 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
137035
137257
  ` 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.');`,
137036
137258
  "}"
137037
137259
  ].join("\n");
137038
- function removeLegacyPrivateMockAuth(code) {
137039
- return [LEGACY_PRIVATE_MOCK_AUTH_SCRIPT, PRIVATE_MOCK_AUTH_V2_SCRIPT].reduce((next, script) => next.split(script).join(""), code).trim();
137260
+ var PRIVATE_MOCK_AUTH_ROOT_SCRIPT = [
137261
+ `// ${PRIVATE_MOCK_AUTH_ROOT_MARKER}`,
137262
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137263
+ "var privateMockHost = '';",
137264
+ "try {",
137265
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137266
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137267
+ "} catch (error) {",
137268
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137269
+ "}",
137270
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137271
+ "if (isPrivateMockHost && privateMockApiKey) {",
137272
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137273
+ "} else if (isPrivateMockHost) {",
137274
+ ` 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.');`,
137275
+ "}"
137276
+ ].join("\n");
137277
+ var MANAGED_ITEM_AUTH_BLOCKS = [
137278
+ LEGACY_PRIVATE_MOCK_AUTH_SCRIPT,
137279
+ PRIVATE_MOCK_AUTH_V2_SCRIPT,
137280
+ PRIVATE_MOCK_AUTH_V3_SCRIPT
137281
+ ];
137282
+ function isManagedPrivateMockAuthRootHook(script) {
137283
+ return String(script.type ?? "") === PRIVATE_MOCK_AUTH_ROOT_TYPE && String(script.code ?? "") === PRIVATE_MOCK_AUTH_ROOT_SCRIPT;
137284
+ }
137285
+ var REGEX_PREFIX_KEYWORDS = /* @__PURE__ */ new Set([
137286
+ "await",
137287
+ "case",
137288
+ "delete",
137289
+ "do",
137290
+ "else",
137291
+ "in",
137292
+ "instanceof",
137293
+ "of",
137294
+ "return",
137295
+ "throw",
137296
+ "typeof",
137297
+ "void",
137298
+ "yield"
137299
+ ]);
137300
+ function isIdentifierStart(ch) {
137301
+ return ch !== void 0 && /[A-Za-z_$]/.test(ch);
137302
+ }
137303
+ function isIdentifierPart(ch) {
137304
+ return ch !== void 0 && /[A-Za-z0-9_$]/.test(ch);
137305
+ }
137306
+ function markTopLevelScriptBytes(source) {
137307
+ const topLevel = new Uint8Array(source.length);
137308
+ let state = "script";
137309
+ let canStartRegex = true;
137310
+ let regexCharacterClass = false;
137311
+ for (let i = 0; i < source.length; i++) {
137312
+ const ch = source[i];
137313
+ const next = source[i + 1];
137314
+ if (state === "script") {
137315
+ topLevel[i] = 1;
137316
+ if (ch === "/" && next === "*") {
137317
+ topLevel[i] = 0;
137318
+ state = "block_comment";
137319
+ i++;
137320
+ topLevel[i] = 0;
137321
+ continue;
137322
+ }
137323
+ if (ch === "/" && next === "/") {
137324
+ topLevel[i + 1] = 1;
137325
+ i++;
137326
+ while (i + 1 < source.length && source[i + 1] !== "\n") {
137327
+ i++;
137328
+ topLevel[i] = 1;
137329
+ }
137330
+ continue;
137331
+ }
137332
+ if (ch === "/") {
137333
+ if (canStartRegex) {
137334
+ topLevel[i] = 0;
137335
+ state = "regex";
137336
+ regexCharacterClass = false;
137337
+ continue;
137338
+ }
137339
+ canStartRegex = true;
137340
+ if (next === "=") {
137341
+ i++;
137342
+ topLevel[i] = 1;
137343
+ }
137344
+ continue;
137345
+ }
137346
+ if (ch === "'") {
137347
+ state = "single";
137348
+ topLevel[i] = 0;
137349
+ continue;
137350
+ }
137351
+ if (ch === '"') {
137352
+ state = "double";
137353
+ topLevel[i] = 0;
137354
+ continue;
137355
+ }
137356
+ if (ch === "`") {
137357
+ state = "template";
137358
+ topLevel[i] = 0;
137359
+ continue;
137360
+ }
137361
+ if (/\s/.test(ch)) {
137362
+ continue;
137363
+ }
137364
+ if (isIdentifierStart(ch)) {
137365
+ let end = i + 1;
137366
+ while (isIdentifierPart(source[end])) {
137367
+ topLevel[end] = 1;
137368
+ end++;
137369
+ }
137370
+ canStartRegex = REGEX_PREFIX_KEYWORDS.has(source.slice(i, end));
137371
+ i = end - 1;
137372
+ continue;
137373
+ }
137374
+ if (/[0-9]/.test(ch)) {
137375
+ let end = i + 1;
137376
+ while (/[A-Za-z0-9_.]/.test(source[end] ?? "")) {
137377
+ topLevel[end] = 1;
137378
+ end++;
137379
+ }
137380
+ canStartRegex = false;
137381
+ i = end - 1;
137382
+ continue;
137383
+ }
137384
+ if ((ch === "+" || ch === "-") && next === ch) {
137385
+ const wasPrefix = canStartRegex;
137386
+ i++;
137387
+ topLevel[i] = 1;
137388
+ canStartRegex = wasPrefix;
137389
+ continue;
137390
+ }
137391
+ if (ch === "?" && next === ".") {
137392
+ i++;
137393
+ topLevel[i] = 1;
137394
+ canStartRegex = false;
137395
+ continue;
137396
+ }
137397
+ if (")]}".includes(ch) || ch === ".") {
137398
+ canStartRegex = false;
137399
+ continue;
137400
+ }
137401
+ if ("([{,;:=!~*%&|^<>+-?".includes(ch)) {
137402
+ canStartRegex = true;
137403
+ continue;
137404
+ }
137405
+ canStartRegex = false;
137406
+ continue;
137407
+ }
137408
+ if (state === "block_comment") {
137409
+ topLevel[i] = 0;
137410
+ if (ch === "*" && next === "/") {
137411
+ topLevel[i] = 0;
137412
+ i++;
137413
+ topLevel[i] = 0;
137414
+ state = "script";
137415
+ }
137416
+ continue;
137417
+ }
137418
+ if (state === "single") {
137419
+ topLevel[i] = 0;
137420
+ if (ch === "\\" && i + 1 < source.length) {
137421
+ i++;
137422
+ topLevel[i] = 0;
137423
+ continue;
137424
+ }
137425
+ if (ch === "'") {
137426
+ state = "script";
137427
+ canStartRegex = false;
137428
+ }
137429
+ continue;
137430
+ }
137431
+ if (state === "double") {
137432
+ topLevel[i] = 0;
137433
+ if (ch === "\\" && i + 1 < source.length) {
137434
+ i++;
137435
+ topLevel[i] = 0;
137436
+ continue;
137437
+ }
137438
+ if (ch === '"') {
137439
+ state = "script";
137440
+ canStartRegex = false;
137441
+ }
137442
+ continue;
137443
+ }
137444
+ if (state === "regex") {
137445
+ topLevel[i] = 0;
137446
+ if (ch === "\\" && i + 1 < source.length) {
137447
+ i++;
137448
+ topLevel[i] = 0;
137449
+ continue;
137450
+ }
137451
+ if (ch === "\n" || ch === "\r") {
137452
+ state = "script";
137453
+ canStartRegex = true;
137454
+ regexCharacterClass = false;
137455
+ continue;
137456
+ }
137457
+ if (ch === "[") {
137458
+ regexCharacterClass = true;
137459
+ continue;
137460
+ }
137461
+ if (ch === "]" && regexCharacterClass) {
137462
+ regexCharacterClass = false;
137463
+ continue;
137464
+ }
137465
+ if (ch === "/" && !regexCharacterClass) {
137466
+ while (isIdentifierPart(source[i + 1])) {
137467
+ i++;
137468
+ topLevel[i] = 0;
137469
+ }
137470
+ state = "script";
137471
+ canStartRegex = false;
137472
+ }
137473
+ continue;
137474
+ }
137475
+ topLevel[i] = 0;
137476
+ if (ch === "\\" && i + 1 < source.length) {
137477
+ i++;
137478
+ topLevel[i] = 0;
137479
+ continue;
137480
+ }
137481
+ if (ch === "`") {
137482
+ state = "script";
137483
+ canStartRegex = false;
137484
+ }
137485
+ }
137486
+ return topLevel;
137487
+ }
137488
+ function isWholeLineTopLevelMatch(source, startIndex, block, topLevel) {
137489
+ if (!source.startsWith(block, startIndex)) {
137490
+ return false;
137491
+ }
137492
+ if (startIndex > 0 && source[startIndex - 1] !== "\n") {
137493
+ return false;
137494
+ }
137495
+ const endIndex = startIndex + block.length;
137496
+ for (let lineStart = startIndex; lineStart < endIndex; ) {
137497
+ if (!topLevel[lineStart]) {
137498
+ return false;
137499
+ }
137500
+ const nextNewline = source.indexOf("\n", lineStart);
137501
+ if (nextNewline === -1 || nextNewline >= endIndex - 1) {
137502
+ break;
137503
+ }
137504
+ lineStart = nextNewline + 1;
137505
+ }
137506
+ return true;
137507
+ }
137508
+ function findManagedBlockRanges(source) {
137509
+ const topLevel = markTopLevelScriptBytes(source);
137510
+ const ranges = [];
137511
+ for (let i = 0; i < source.length; i++) {
137512
+ if (i > 0 && source[i - 1] !== "\n") {
137513
+ continue;
137514
+ }
137515
+ for (const block of MANAGED_ITEM_AUTH_BLOCKS) {
137516
+ if (!isWholeLineTopLevelMatch(source, i, block, topLevel)) {
137517
+ continue;
137518
+ }
137519
+ ranges.push({ start: i, end: i + block.length });
137520
+ break;
137521
+ }
137522
+ }
137523
+ return ranges;
137524
+ }
137525
+ function countManagedItemAuthBlocks(code) {
137526
+ if (typeof code !== "string" || !code) {
137527
+ return 0;
137528
+ }
137529
+ return findManagedBlockRanges(code).length;
137530
+ }
137531
+ function deleteRangeWithSeam(source, start, end) {
137532
+ let before = source.slice(0, start);
137533
+ let after = source.slice(end);
137534
+ const beforeHadNl = before.endsWith("\n");
137535
+ const afterHadNl = after.startsWith("\n");
137536
+ if (beforeHadNl) {
137537
+ before = before.slice(0, -1);
137538
+ }
137539
+ if (afterHadNl) {
137540
+ after = after.slice(1);
137541
+ }
137542
+ if (beforeHadNl && afterHadNl && before.length > 0 && after.length > 0) {
137543
+ return `${before}
137544
+ ${after}`;
137545
+ }
137546
+ return `${before}${after}`;
137547
+ }
137548
+ function stripManagedItemAuthBlocks(code) {
137549
+ if (typeof code !== "string" || !code) {
137550
+ return "";
137551
+ }
137552
+ const ranges = findManagedBlockRanges(code);
137553
+ if (ranges.length === 0) {
137554
+ return code;
137555
+ }
137556
+ ranges.sort((left, right) => right.start - left.start);
137557
+ let next = code;
137558
+ for (const range of ranges) {
137559
+ next = deleteRangeWithSeam(next, range.start, range.end);
137560
+ }
137561
+ return next;
137562
+ }
137563
+
137564
+ // src/lib/postman/postman-gateway-assets-client.ts
137565
+ var MockContractError = class extends Error {
137566
+ constructor(message) {
137567
+ super(message);
137568
+ this.name = "MockContractError";
137569
+ }
137570
+ };
137571
+ var AmbiguousMonitorRebindError = class extends Error {
137572
+ constructor(message, options) {
137573
+ super(message, options);
137574
+ this.name = "AmbiguousMonitorRebindError";
137575
+ }
137576
+ };
137577
+ function requireMockVisibility(mock, requested) {
137578
+ if (mock.visibility === "unknown") {
137579
+ throw new MockContractError(
137580
+ `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
137581
+ );
137582
+ }
137583
+ if (mock.visibility !== requested) {
137584
+ const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
137585
+ throw new MockContractError(
137586
+ `${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}.`
137587
+ );
137588
+ }
137589
+ return mock;
137040
137590
  }
137041
137591
  var MAX_CREATE_FLIGHTS = 256;
137042
137592
  var createFlights = /* @__PURE__ */ new Map();
@@ -137607,51 +138157,83 @@ var PostmanGatewayAssetsClient = class {
137607
138157
  }
137608
138158
  });
137609
138159
  }
138160
+ isAmbiguousTransportError(error2) {
138161
+ return this.isRetryableIdempotentWriteOutcome(error2);
138162
+ }
138163
+ normalizeCollectionScripts(scripts) {
138164
+ if (!Array.isArray(scripts)) return [];
138165
+ return scripts.map((entry) => this.asRecord(entry)).filter((entry) => entry !== null);
138166
+ }
138167
+ rootScriptsIncludeManagedAuthHook(scripts) {
138168
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
138169
+ }
138170
+ buildPrivateMockRootScripts(existingScripts) {
138171
+ const managedScript = {
138172
+ type: PRIVATE_MOCK_AUTH_ROOT_TYPE,
138173
+ code: PRIVATE_MOCK_AUTH_ROOT_SCRIPT,
138174
+ language: "text/javascript"
138175
+ };
138176
+ return [...existingScripts, managedScript];
138177
+ }
138178
+ async readCollectionRootScripts(collectionUid) {
138179
+ const id = this.toModelId(collectionUid);
138180
+ const response = await this.gateway.requestJson({
138181
+ service: "collection",
138182
+ method: "get",
138183
+ path: `/v3/collections/${id}/export`
138184
+ });
138185
+ const data = this.asRecord(response?.data);
138186
+ const collection = this.asRecord(data?.collection);
138187
+ if (!collection) {
138188
+ throw new Error(
138189
+ `PRIVATE_MOCK_AUTH_EXPORT_INVALID: Collection ${id} export did not return data.collection; refusing to configure private-mock root auth from an unexpected envelope.`
138190
+ );
138191
+ }
138192
+ return this.normalizeCollectionScripts(collection.scripts);
138193
+ }
138194
+ async patchCollectionRootScripts(collectionUid, scripts) {
138195
+ const id = this.toModelId(collectionUid);
138196
+ await this.gateway.requestJson(
138197
+ {
138198
+ service: "collection",
138199
+ method: "patch",
138200
+ path: `/v3/collections/${id}`,
138201
+ body: [{ op: "add", path: "/scripts", value: scripts }]
138202
+ },
138203
+ { retryTransient: false }
138204
+ );
138205
+ }
137610
138206
  /**
137611
- * Add a secret-free runtime hook to every HTTP request in a collection. The
137612
- * PMAK value is supplied only by the runner as a transient variable; this
137613
- * method persists the variable name and header wiring, never the credential.
138207
+ * Add a secret-free runtime hook at the collection root. The PMAK value is
138208
+ * supplied only by the runner as a transient variable; this method persists
138209
+ * the variable name and header wiring, never the credential.
137614
138210
  */
137615
138211
  async configurePrivateMockRuntimeAuth(collectionUid) {
137616
138212
  const cid = String(collectionUid ?? "").trim();
137617
138213
  if (!cid) return 0;
137618
- const listed = await this.gateway.requestJson({
137619
- service: "collection",
137620
- method: "get",
137621
- path: `/v3/collections/${cid}/items/`
137622
- });
137623
- const items = Array.isArray(listed?.data) ? listed.data : [];
137624
- let patched = 0;
137625
- for (const listedItem of items) {
137626
- if (String(listedItem.$kind ?? "") !== "http-request") continue;
137627
- const itemId = String(listedItem.id ?? "").trim();
137628
- if (!itemId) continue;
137629
- const response = await this.gateway.requestJson({
137630
- service: "collection",
137631
- method: "get",
137632
- path: `/v3/collections/${cid}/items/${itemId}`,
137633
- headers: { "X-Entity-Type": "http-request" }
137634
- });
137635
- const item = this.asRecord(response?.data) ?? listedItem;
137636
- const scripts = Array.isArray(item.scripts) ? item.scripts.filter((entry) => Boolean(this.asRecord(entry))) : [];
137637
- const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
137638
- const existingCode = String(before?.code ?? "");
137639
- if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
137640
- const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137641
- const nextScripts = [
137642
- ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
137643
- { type: "beforeRequest", code, language: "text/javascript" }
137644
- ];
137645
- await this.gateway.requestJson({
137646
- service: "collection",
137647
- method: "patch",
137648
- path: `/v3/collections/${cid}/items/${itemId}`,
137649
- headers: { "X-Entity-Type": "http-request" },
137650
- body: [{ op: "add", path: "/scripts", value: nextScripts }]
137651
- });
137652
- patched += 1;
137653
- }
137654
- return patched;
138214
+ const installFromFreshRoot = async (existingScripts) => {
138215
+ if (this.rootScriptsIncludeManagedAuthHook(existingScripts)) {
138216
+ return 0;
138217
+ }
138218
+ const nextScripts = this.buildPrivateMockRootScripts(existingScripts);
138219
+ try {
138220
+ await this.patchCollectionRootScripts(cid, nextScripts);
138221
+ return 1;
138222
+ } catch (error2) {
138223
+ if (!this.isAmbiguousTransportError(error2)) {
138224
+ throw error2;
138225
+ }
138226
+ const freshScripts = await this.readCollectionRootScripts(cid);
138227
+ if (this.rootScriptsIncludeManagedAuthHook(freshScripts)) {
138228
+ return 1;
138229
+ }
138230
+ const recomputed = this.buildPrivateMockRootScripts(freshScripts);
138231
+ await this.patchCollectionRootScripts(cid, recomputed);
138232
+ return 1;
138233
+ }
138234
+ };
138235
+ const scripts = await this.readCollectionRootScripts(cid);
138236
+ return installFromFreshRoot(scripts);
137655
138237
  }
137656
138238
  async listMocks() {
137657
138239
  const response = await this.gateway.requestJson({
@@ -137735,12 +138317,13 @@ var PostmanGatewayAssetsClient = class {
137735
138317
  }
137736
138318
  async createMonitor(workspaceId, name, collectionUid, environmentUid, cronSchedule) {
137737
138319
  const ws = workspaceId || this.workspaceId;
137738
- const effectiveCron = cronSchedule && cronSchedule.trim() ? cronSchedule.trim() : "0 0 * * 0";
138320
+ const cronTrimmed = String(cronSchedule ?? "").trim();
138321
+ const hasCron = cronTrimmed.length > 0;
137739
138322
  const monitorName = String(name ?? "").trim();
137740
138323
  const collection = String(collectionUid ?? "").trim();
137741
138324
  const environment = String(environmentUid ?? "").trim();
137742
138325
  const flightKey = `monitor:${ws}:${collection}:${environment}:${monitorName}`;
137743
- return this.singleFlight(flightKey, effectiveCron, "monitor", async () => {
138326
+ return this.singleFlight(flightKey, hasCron ? cronTrimmed : "inactive", "monitor", async () => {
137744
138327
  const existing = await this.findMonitorByCollection(collection, environment, monitorName);
137745
138328
  if (existing?.uid) {
137746
138329
  return existing.uid;
@@ -137748,11 +138331,12 @@ var PostmanGatewayAssetsClient = class {
137748
138331
  const body = {
137749
138332
  name: monitorName,
137750
138333
  collection,
138334
+ active: hasCron,
137751
138335
  options: { strictSSL: false, followRedirects: true, requestTimeout: null, requestDelay: 0 },
137752
138336
  notifications: { onFailure: [], onError: [] },
137753
138337
  retry: {},
137754
- schedule: { cronPattern: effectiveCron, timeZone: "UTC" },
137755
138338
  distribution: null,
138339
+ ...hasCron ? { schedule: { cronPattern: cronTrimmed, timeZone: "UTC" } } : {},
137756
138340
  ...environment ? { environment } : {}
137757
138341
  };
137758
138342
  const send2 = (fallback) => this.gateway.requestJson(
@@ -137826,6 +138410,73 @@ var PostmanGatewayAssetsClient = class {
137826
138410
  );
137827
138411
  return match?.uid ? { uid: match.uid, name: match.name } : null;
137828
138412
  }
138413
+ pickRebindMonitorCandidates(monitors, monitorName, environment) {
138414
+ const nameOnly = monitors.filter((monitor) => monitor.name === monitorName);
138415
+ const nameOnlyEnvironments = [
138416
+ ...new Set(nameOnly.map((monitor) => monitor.environmentUid || "(none)"))
138417
+ ];
138418
+ const candidates = nameOnly.filter((monitor) => monitor.environmentUid === environment);
138419
+ return { candidates, nameOnlyMatchCount: nameOnly.length, nameOnlyEnvironments };
138420
+ }
138421
+ /**
138422
+ * Rebind the sole same-name monitor in this workspace onto the current
138423
+ * collection UID.
138424
+ *
138425
+ * The canonical Smoke collection can legitimately change UID (a bootstrap
138426
+ * re-import after a marker/stranger miss, or an operator rebuild). The
138427
+ * monitor still points at the previous UID, so `findMonitorByCollection`
138428
+ * (which requires the full collection+environment+name triple) misses and a
138429
+ * second monitor with the same name would be created on every run, orphaning
138430
+ * the old one. Name plus environment is the stable identity across a
138431
+ * collection re-import, so recover it here instead.
138432
+ *
138433
+ * Returns null when nothing needs rebinding (no same-name monitor, or it is
138434
+ * already bound to this collection). Refuses to guess when several same-name
138435
+ * monitors match, matching `selectExactMatch` semantics elsewhere.
138436
+ */
138437
+ async rebindMonitorByName(name, collectionUid, environmentUid) {
138438
+ const monitorName = String(name ?? "").trim();
138439
+ const collection = String(collectionUid ?? "").trim();
138440
+ const environment = String(environmentUid ?? "").trim();
138441
+ if (!monitorName || !collection) {
138442
+ return null;
138443
+ }
138444
+ const monitors = await this.listMonitors();
138445
+ const { candidates, nameOnlyMatchCount, nameOnlyEnvironments } = this.pickRebindMonitorCandidates(
138446
+ monitors,
138447
+ monitorName,
138448
+ environment
138449
+ );
138450
+ let match;
138451
+ try {
138452
+ match = this.selectExactMatch(
138453
+ "monitor",
138454
+ `workspace ${this.workspaceId}, name "${monitorName}", and environment ${environment || "(none)"}`,
138455
+ candidates
138456
+ );
138457
+ } catch (error2) {
138458
+ const message = error2 instanceof Error && nameOnlyMatchCount > 0 ? `${error2.message} Same-name monitor(s) also exist on environment(s): ${nameOnlyEnvironments.join(", ")}.` : error2 instanceof Error ? error2.message : String(error2);
138459
+ throw new AmbiguousMonitorRebindError(message, { cause: error2 });
138460
+ }
138461
+ if (!match?.uid) {
138462
+ if (nameOnlyMatchCount > 0) {
138463
+ }
138464
+ return null;
138465
+ }
138466
+ if (match.collectionUid === collection) {
138467
+ return null;
138468
+ }
138469
+ await this.gateway.requestJson(
138470
+ {
138471
+ service: "monitors",
138472
+ method: "put",
138473
+ path: `/jobTemplates/${this.toModelId(match.uid)}?_etc=true`,
138474
+ body: { collection }
138475
+ },
138476
+ { retryTransient: false }
138477
+ );
138478
+ return { uid: match.uid, previousCollectionUid: match.collectionUid };
138479
+ }
137829
138480
  async runMonitor(uid) {
137830
138481
  await this.gateway.requestJson(
137831
138482
  {
@@ -137838,6 +138489,128 @@ var PostmanGatewayAssetsClient = class {
137838
138489
  }
137839
138490
  };
137840
138491
 
138492
+ // src/lib/postman/private-mock-export-cleanup.ts
138493
+ function asArray2(value) {
138494
+ return Array.isArray(value) ? value : [];
138495
+ }
138496
+ function cloneScriptRecord(script) {
138497
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
138498
+ return script;
138499
+ }
138500
+ return { ...script };
138501
+ }
138502
+ function cloneCollectionNodeIterative(collection) {
138503
+ const cloned = { ...collection };
138504
+ if (Array.isArray(collection.scripts)) {
138505
+ cloned.scripts = collection.scripts.map((script) => cloneScriptRecord(script));
138506
+ }
138507
+ const stack = [];
138508
+ const attachNested = (source, target) => {
138509
+ if (Array.isArray(source.scripts)) {
138510
+ target.scripts = source.scripts.map((script) => cloneScriptRecord(script));
138511
+ }
138512
+ for (const key of ["items", "children"]) {
138513
+ const nested = asArray2(source[key]);
138514
+ if (nested.length === 0) {
138515
+ continue;
138516
+ }
138517
+ const clonedNested = nested.map((item) => ({ ...item }));
138518
+ target[key] = clonedNested;
138519
+ for (let i = 0; i < nested.length; i += 1) {
138520
+ stack.push({ source: nested[i], target: clonedNested[i] });
138521
+ }
138522
+ }
138523
+ };
138524
+ attachNested(collection, cloned);
138525
+ while (stack.length > 0) {
138526
+ const frame = stack.pop();
138527
+ attachNested(frame.source, frame.target);
138528
+ }
138529
+ return cloned;
138530
+ }
138531
+ function cloneCollection(collection) {
138532
+ if (typeof globalThis.structuredClone === "function") {
138533
+ try {
138534
+ return globalThis.structuredClone(collection);
138535
+ } catch {
138536
+ }
138537
+ }
138538
+ try {
138539
+ return JSON.parse(JSON.stringify(collection));
138540
+ } catch {
138541
+ return cloneCollectionNodeIterative(collection);
138542
+ }
138543
+ }
138544
+ function isPrivateMockLegacyExportCleanupEnabled() {
138545
+ const value = String(process.env.POSTMAN_PRIVATE_MOCK_LEGACY_EXPORT_CLEANUP ?? "").trim().toLowerCase();
138546
+ return value !== "off";
138547
+ }
138548
+ function verifyPrivateMockRootHook(collection) {
138549
+ const scripts = asArray2(collection.scripts);
138550
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
138551
+ }
138552
+ function applyPrivateMockExportCleanup(collection, options = {}) {
138553
+ const stripManagedBlocks = options.stripManagedBlocks ?? isPrivateMockLegacyExportCleanupEnabled();
138554
+ const cloned = cloneCollection(collection);
138555
+ let strippedBlocks = 0;
138556
+ const visitItem = (item) => {
138557
+ if (!stripManagedBlocks) {
138558
+ return;
138559
+ }
138560
+ const scripts = item.scripts;
138561
+ if (!Array.isArray(scripts)) {
138562
+ return;
138563
+ }
138564
+ const nextScripts = [];
138565
+ for (const script of scripts) {
138566
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
138567
+ nextScripts.push(script);
138568
+ continue;
138569
+ }
138570
+ const record = script;
138571
+ if (String(record.type ?? "") !== "beforeRequest") {
138572
+ nextScripts.push(record);
138573
+ continue;
138574
+ }
138575
+ const originalCode = String(record.code ?? "");
138576
+ const cleaned = stripManagedItemAuthBlocks(originalCode);
138577
+ if (cleaned === originalCode) {
138578
+ nextScripts.push(record);
138579
+ continue;
138580
+ }
138581
+ strippedBlocks += countManagedItemAuthBlocks(originalCode);
138582
+ if (!cleaned) {
138583
+ continue;
138584
+ }
138585
+ nextScripts.push({ ...record, code: cleaned });
138586
+ }
138587
+ if (nextScripts.length === 0) {
138588
+ delete item.scripts;
138589
+ } else {
138590
+ item.scripts = nextScripts;
138591
+ }
138592
+ };
138593
+ const walkItemsIteratively = (rootItems) => {
138594
+ const stack = [...rootItems].reverse();
138595
+ while (stack.length > 0) {
138596
+ const item = stack.pop();
138597
+ visitItem(item);
138598
+ for (const key of ["items", "children"]) {
138599
+ const nested = asArray2(item[key]);
138600
+ for (let i = nested.length - 1; i >= 0; i -= 1) {
138601
+ stack.push(nested[i]);
138602
+ }
138603
+ }
138604
+ }
138605
+ };
138606
+ walkItemsIteratively(asArray2(cloned.items));
138607
+ return {
138608
+ collection: cloned,
138609
+ strippedBlocks,
138610
+ rootVerified: verifyPrivateMockRootHook(cloned)
138611
+ };
138612
+ }
138613
+
137841
138614
  // src/lib/postman/token-provider.ts
137842
138615
  var MintError = class extends Error {
137843
138616
  permanent;
@@ -138647,6 +139420,15 @@ var identitySecretMasker = (input) => input;
138647
139420
  function resolveRepoSyncMasker(dependencies) {
138648
139421
  return dependencies.secretMasker ?? identitySecretMasker;
138649
139422
  }
139423
+ function resolveRepoSyncLogger(dependencies) {
139424
+ return dependencies.logger ?? createLogger({
139425
+ sink: actionSink(dependencies.core),
139426
+ fields: {
139427
+ action: "postman-repo-sync-action",
139428
+ action_version: resolveActionVersion2()
139429
+ }
139430
+ });
139431
+ }
138650
139432
  function causeText(cause) {
138651
139433
  return cause instanceof Error ? cause.message : String(cause);
138652
139434
  }
@@ -138867,6 +139649,7 @@ function resolveInputs(env = process.env) {
138867
139649
  env
138868
139650
  );
138869
139651
  const environments = parseJsonArray(getInput2("environments-json", env) || '["prod"]');
139652
+ const secretsResolverProvider = parseSecretsResolverProvider(getInput2("secrets-resolver", env));
138870
139653
  const systemEnvMap = parseJsonMap(getInput2("system-env-map-json", env) || "{}");
138871
139654
  const environmentUids = parseJsonMap(getInput2("environment-uids-json", env) || "{}");
138872
139655
  const envRuntimeUrls = parseJsonMap(getInput2("env-runtime-urls-json", env) || "{}");
@@ -138884,6 +139667,7 @@ function resolveInputs(env = process.env) {
138884
139667
  specContentChanged: parseBooleanInput(getInput2("spec-content-changed", env), true),
138885
139668
  specPath: getInput2("spec-path", env),
138886
139669
  collectionSyncMode: normalizeCollectionSyncMode(getInput2("collection-sync-mode", env) || "refresh"),
139670
+ secretsResolverProvider,
138887
139671
  specSyncMode: normalizeSpecSyncMode(getInput2("spec-sync-mode", env) || "update"),
138888
139672
  releaseLabel: normalizeReleaseLabel(getInput2("release-label", env)) || void 0,
138889
139673
  environments: environments.length > 0 ? environments : ["prod"],
@@ -138982,10 +139766,14 @@ function buildEnvironmentValues(envName, baseUrl, options = {}) {
138982
139766
  ...options.privateMockAuth ? [{ key: PRIVATE_MOCK_AUTH_VARIABLE2, value: "", type: "secret" }] : [],
138983
139767
  { key: "CI", value: "false", type: "default" },
138984
139768
  { key: "RESPONSE_TIME_THRESHOLD", value: "2000", type: "default" },
138985
- { key: "AWS_ACCESS_KEY_ID", value: "", type: "secret" },
138986
- { key: "AWS_SECRET_ACCESS_KEY", value: "", type: "secret" },
138987
- { key: "AWS_REGION", value: "eu-west-2", type: "default" },
138988
- { key: "AWS_SECRET_NAME", value: `api-credentials-${envName}`, type: "default" }
139769
+ // Provider-scoped credential slots. `none` (the default) seeds nothing, so a
139770
+ // consumer that does not use a cloud secret store gets a clean environment
139771
+ // instead of four dead AWS variables.
139772
+ ...secretsResolverEnvironmentKeys(options.secretsResolverProvider ?? "none").map((entry) => ({
139773
+ key: entry.key,
139774
+ value: entry.key.endsWith("_SECRET_NAME") && !entry.secret ? `api-credentials-${envName}` : entry.defaultValue ?? "",
139775
+ type: entry.secret ? "secret" : "default"
139776
+ }))
138989
139777
  ];
138990
139778
  }
138991
139779
  var LEGACY_BASELINE_COLLECTION_PREFIX = "[Baseline]";
@@ -139063,13 +139851,51 @@ function normalizeToPosix(filePath) {
139063
139851
  function canonicalizeRelativePath(value) {
139064
139852
  return normalizeToPosix(String(value ?? "").trim()).replace(/^\.\/+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/g, "");
139065
139853
  }
139066
- function isOpenApiSpecFile(filePath) {
139067
- if (!(filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml"))) {
139068
- return false;
139854
+ var LOCAL_SPEC_DISCOVERY_MAX_DEPTH = 6;
139855
+ var LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES = 1e4;
139856
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES = 200;
139857
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES = 512 * 1024;
139858
+ var LOCAL_SPEC_DISCOVERY_IGNORED_DIRS = /* @__PURE__ */ new Set([
139859
+ ".git",
139860
+ ".nyc_output",
139861
+ ".omc",
139862
+ ".omx",
139863
+ ".llm-plans",
139864
+ ".pulumi",
139865
+ ".terraform",
139866
+ ".venv",
139867
+ "__pycache__",
139868
+ "bin",
139869
+ "build",
139870
+ "coverage",
139871
+ "discovered-specs",
139872
+ "node_modules",
139873
+ "dist",
139874
+ "obj",
139875
+ "out",
139876
+ "target",
139877
+ "vendor",
139878
+ "venv"
139879
+ ]);
139880
+ var LocalSpecDiscoveryLimitError = class extends Error {
139881
+ code = "CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT";
139882
+ constructor(message) {
139883
+ super(`CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT: ${message}`);
139884
+ this.name = "LocalSpecDiscoveryLimitError";
139069
139885
  }
139886
+ };
139887
+ function failLocalSpecDiscoveryLimit(detail) {
139888
+ throw new LocalSpecDiscoveryLimitError(
139889
+ `${detail} Set spec-path to the OpenAPI file explicitly and keep generated trees (for example dist/, node_modules/) out of the repository layout.`
139890
+ );
139891
+ }
139892
+ function isSpecCandidateExtension(filePath) {
139893
+ return filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml");
139894
+ }
139895
+ function readOpenApiSpecFile(fullPath) {
139070
139896
  try {
139071
- const raw = (0, import_node_fs5.readFileSync)(filePath, "utf8");
139072
- const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
139897
+ const raw = (0, import_node_fs5.readFileSync)(fullPath, "utf8");
139898
+ const parsed = fullPath.endsWith(".json") ? JSON.parse(raw) : load(raw);
139073
139899
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
139074
139900
  return false;
139075
139901
  }
@@ -139085,28 +139911,75 @@ function isOpenApiSpecFile(filePath) {
139085
139911
  }
139086
139912
  return false;
139087
139913
  }
139088
- function scanLocalSpecReferences(baseDir = ".") {
139089
- const ignoredDirs = /* @__PURE__ */ new Set([
139090
- ".git",
139091
- ".omc",
139092
- ".omx",
139093
- ".llm-plans",
139094
- "node_modules",
139095
- "dist"
139096
- ]);
139914
+ function shouldIgnoreSpecDiscoveryEntry(entryName, currentDir, baseDir, ignoredPrefixes) {
139915
+ if (LOCAL_SPEC_DISCOVERY_IGNORED_DIRS.has(entryName)) {
139916
+ return true;
139917
+ }
139918
+ const relative4 = normalizeToPosix(path8.relative(baseDir, path8.join(currentDir, entryName)));
139919
+ return ignoredPrefixes.some(
139920
+ (prefix) => relative4 === prefix || relative4.startsWith(`${prefix}/`)
139921
+ );
139922
+ }
139923
+ function scanLocalSpecReferences(baseDir = ".", options = {}) {
139924
+ const ignoredPrefixes = (options.ignoredPrefixes ?? []).map((value) => canonicalizeRelativePath(value)).filter(Boolean);
139097
139925
  const found = /* @__PURE__ */ new Set();
139098
139926
  const refs = [];
139099
- const visit2 = (currentDir) => {
139100
- for (const entry of (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true })) {
139101
- if (ignoredDirs.has(entry.name)) {
139927
+ let traversalEntries = 0;
139928
+ let candidateFiles = 0;
139929
+ const pendingDirs = [{ dir: baseDir, depth: 0 }];
139930
+ while (pendingDirs.length > 0) {
139931
+ const { dir: currentDir, depth: currentDepth } = pendingDirs.shift();
139932
+ let entries;
139933
+ try {
139934
+ entries = (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true }).sort(
139935
+ (left, right) => left.name.localeCompare(right.name)
139936
+ );
139937
+ } catch {
139938
+ continue;
139939
+ }
139940
+ for (const entry of entries) {
139941
+ traversalEntries += 1;
139942
+ if (traversalEntries > LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES) {
139943
+ failLocalSpecDiscoveryLimit(
139944
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES} traversal-entry liveness budget.`
139945
+ );
139946
+ }
139947
+ if (shouldIgnoreSpecDiscoveryEntry(entry.name, currentDir, baseDir, ignoredPrefixes)) {
139102
139948
  continue;
139103
139949
  }
139104
139950
  const fullPath = path8.join(currentDir, entry.name);
139105
139951
  if (entry.isDirectory()) {
139106
- visit2(fullPath);
139952
+ const nextDepth = currentDepth + 1;
139953
+ if (nextDepth > LOCAL_SPEC_DISCOVERY_MAX_DEPTH) {
139954
+ failLocalSpecDiscoveryLimit(
139955
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_DEPTH} directory-depth budget.`
139956
+ );
139957
+ }
139958
+ pendingDirs.push({ dir: fullPath, depth: nextDepth });
139107
139959
  continue;
139108
139960
  }
139109
- if (!entry.isFile() || !isOpenApiSpecFile(fullPath)) {
139961
+ if (!entry.isFile() || !isSpecCandidateExtension(fullPath)) {
139962
+ continue;
139963
+ }
139964
+ candidateFiles += 1;
139965
+ if (candidateFiles > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES) {
139966
+ failLocalSpecDiscoveryLimit(
139967
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES} candidate-file budget.`
139968
+ );
139969
+ }
139970
+ let sizeBytes;
139971
+ try {
139972
+ sizeBytes = (0, import_node_fs5.statSync)(fullPath).size;
139973
+ } catch {
139974
+ continue;
139975
+ }
139976
+ if (sizeBytes > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES) {
139977
+ const repoRelativePath2 = normalizeToPosix(path8.relative(baseDir, fullPath));
139978
+ failLocalSpecDiscoveryLimit(
139979
+ `local spec discovery candidate ${repoRelativePath2} exceeds ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES} bytes.`
139980
+ );
139981
+ }
139982
+ if (!readOpenApiSpecFile(fullPath)) {
139110
139983
  continue;
139111
139984
  }
139112
139985
  const repoRelativePath = normalizeToPosix(path8.relative(baseDir, fullPath));
@@ -139119,20 +139992,36 @@ function scanLocalSpecReferences(baseDir = ".") {
139119
139992
  configRelativePath: normalizeToPosix(path8.join("..", repoRelativePath))
139120
139993
  });
139121
139994
  }
139122
- };
139123
- visit2(baseDir);
139995
+ }
139124
139996
  return refs.sort((left, right) => left.repoRelativePath.localeCompare(right.repoRelativePath));
139125
139997
  }
139126
- function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
139998
+ function tryResolveExplicitSpecReference(explicitSpecPath) {
139127
139999
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
139128
- if (normalizedExplicitPath) {
139129
- const explicitFullPath = path8.resolve(normalizedExplicitPath);
139130
- if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
139131
- return {
139132
- repoRelativePath: normalizedExplicitPath,
139133
- configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
139134
- };
139135
- }
140000
+ if (!normalizedExplicitPath) {
140001
+ return void 0;
140002
+ }
140003
+ const explicitFullPath = path8.resolve(normalizedExplicitPath);
140004
+ if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
140005
+ return {
140006
+ repoRelativePath: normalizedExplicitPath,
140007
+ configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
140008
+ };
140009
+ }
140010
+ return void 0;
140011
+ }
140012
+ function resolveLocalSpecReferences(explicitSpecPath, baseDir = ".", options = {}) {
140013
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
140014
+ if (explicit) {
140015
+ return { discoveredSpecs: [], mappedSpec: explicit };
140016
+ }
140017
+ const discoveredSpecs = scanLocalSpecReferences(baseDir, options);
140018
+ const mappedSpec = resolveMappedSpecReference(explicitSpecPath, discoveredSpecs);
140019
+ return { discoveredSpecs, mappedSpec };
140020
+ }
140021
+ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
140022
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
140023
+ if (explicit) {
140024
+ return explicit;
139136
140025
  }
139137
140026
  if (discoveredSpecs.length === 1) {
139138
140027
  return discoveredSpecs[0];
@@ -139382,7 +140271,9 @@ async function upsertEnvironments(inputs, dependencies, resourcesState, assetMar
139382
140271
  } catch {
139383
140272
  }
139384
140273
  }
139385
- const values2 = buildEnvironmentValues(envName, runtimeUrl);
140274
+ const values2 = buildEnvironmentValues(envName, runtimeUrl, {
140275
+ secretsResolverProvider: inputs.secretsResolverProvider
140276
+ });
139386
140277
  if (marker) values2.push({ key: "x-pm-onboarding", value: JSON.stringify(marker), type: "default" });
139387
140278
  try {
139388
140279
  await dependencies.postman.updateEnvironment(existingUid, displayName, values2);
@@ -139402,7 +140293,9 @@ async function upsertEnvironments(inputs, dependencies, resourcesState, assetMar
139402
140293
  dependencies.core.setOutput("environment-uids-json", JSON.stringify(envUids));
139403
140294
  continue;
139404
140295
  }
139405
- const values = buildEnvironmentValues(envName, runtimeUrl);
140296
+ const values = buildEnvironmentValues(envName, runtimeUrl, {
140297
+ secretsResolverProvider: inputs.secretsResolverProvider
140298
+ });
139406
140299
  if (assetMarker) values.push({ key: "x-pm-onboarding", value: JSON.stringify(assetMarker), type: "default" });
139407
140300
  try {
139408
140301
  envUids[envName] = await dependencies.postman.createEnvironment(
@@ -139431,7 +140324,10 @@ async function upsertMockEnvironment(inputs, dependencies, assetProjectName, moc
139431
140324
  return "";
139432
140325
  }
139433
140326
  const displayName = `${assetProjectName} - Mock`;
139434
- const values = buildEnvironmentValues("mock", mockUrl, { privateMockAuth });
140327
+ const values = buildEnvironmentValues("mock", mockUrl, {
140328
+ privateMockAuth,
140329
+ secretsResolverProvider: inputs.secretsResolverProvider
140330
+ });
139435
140331
  const mask = resolveRepoSyncMasker(dependencies);
139436
140332
  try {
139437
140333
  const discovered = await dependencies.postman.findEnvironmentByName(
@@ -139953,6 +140849,18 @@ function tryReusePrebuiltCollection(options) {
139953
140849
  }
139954
140850
  return prepared.artifactDigest === entry.artifactDigest;
139955
140851
  }
140852
+ async function preparePrivateMockCloudCollection(role, collectionId, postman) {
140853
+ const col = await postman.getCollection(collectionId);
140854
+ const { collection } = applyPrivateMockExportCleanup(col, {
140855
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
140856
+ });
140857
+ if (!verifyPrivateMockRootHook(collection)) {
140858
+ throw new Error(
140859
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
140860
+ );
140861
+ }
140862
+ return collection;
140863
+ }
139956
140864
  async function exportCollectionArtifact(options) {
139957
140865
  const {
139958
140866
  role,
@@ -139961,14 +140869,17 @@ async function exportCollectionArtifact(options) {
139961
140869
  collectionsDir,
139962
140870
  prebuiltByRole,
139963
140871
  postman,
139964
- core
140872
+ core,
140873
+ privateMockAuth = false,
140874
+ preparedCloudCollection
139965
140875
  } = options;
139966
140876
  if (!collectionId) {
139967
140877
  return void 0;
139968
140878
  }
139969
140879
  const expectedPath = `${collectionsDir}/${dirName}`;
140880
+ const forceCloudExport = privateMockAuth && (role === "smoke" || role === "contract");
139970
140881
  const entry = prebuiltByRole.get(role);
139971
- if (entry) {
140882
+ if (entry && !forceCloudExport) {
139972
140883
  const reused = tryReusePrebuiltCollection({
139973
140884
  prepared: entry,
139974
140885
  expectedPath,
@@ -139983,12 +140894,30 @@ async function exportCollectionArtifact(options) {
139983
140894
  core.info(
139984
140895
  `Prebuilt ${role} collection entry present but did not exactly match; exporting from cloud`
139985
140896
  );
140897
+ } else if (entry && forceCloudExport) {
140898
+ core.info(
140899
+ `Private mock requires cloud export for ${role} collection to reconcile managed root hook; exporting from cloud`
140900
+ );
139986
140901
  }
139987
- const col = await postman.getCollection(collectionId);
139988
- await convertAndSplitAnyCollection(
139989
- col,
139990
- expectedPath
139991
- );
140902
+ let collectionForExport;
140903
+ if (forceCloudExport && preparedCloudCollection) {
140904
+ collectionForExport = preparedCloudCollection;
140905
+ } else if (forceCloudExport) {
140906
+ const col = await postman.getCollection(collectionId);
140907
+ const { collection } = applyPrivateMockExportCleanup(col, {
140908
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
140909
+ });
140910
+ if (!verifyPrivateMockRootHook(collection)) {
140911
+ throw new Error(
140912
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
140913
+ );
140914
+ }
140915
+ collectionForExport = collection;
140916
+ } else {
140917
+ const col = await postman.getCollection(collectionId);
140918
+ collectionForExport = col;
140919
+ }
140920
+ await convertAndSplitAnyCollection(collectionForExport, expectedPath);
139992
140921
  return `../${expectedPath}`;
139993
140922
  }
139994
140923
  function hasControlCharacter2(value) {
@@ -140041,32 +140970,37 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140041
140970
  const globalsDir = `${inputs.artifactDir}/globals`;
140042
140971
  const mocksDir = `${inputs.artifactDir}/mocks`;
140043
140972
  const specsDir = `${inputs.artifactDir}/specs`;
140044
- ensureDir(collectionsDir);
140045
- ensureDir(environmentsDir);
140046
- ensureDir(flowsDir);
140047
- ensureDir(globalsDir);
140048
- ensureDir(mocksDir);
140049
- ensureDir(specsDir);
140050
- ensureDir(".postman");
140051
- const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
140052
- if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
140053
- (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
140054
- }
140055
- if (inputs.generateCiWorkflow) {
140056
- const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
140057
- if (ciDir) {
140058
- ensureDir(ciDir);
140059
- }
140060
- }
140061
140973
  const manifestCollections = {};
140062
- const discoveredSpecs = scanLocalSpecReferences();
140063
- const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
140974
+ const artifactDirPrefix = canonicalizeRelativePath(inputs.artifactDir);
140975
+ const { discoveredSpecs, mappedSpec } = resolveLocalSpecReferences(inputs.specPath, ".", {
140976
+ ignoredPrefixes: artifactDirPrefix ? [artifactDirPrefix, ".postman"] : [".postman"]
140977
+ });
140064
140978
  const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
140065
140979
  mappedSpec.configRelativePath,
140066
140980
  inputs.specSyncMode,
140067
140981
  options.releaseLabel
140068
140982
  ) : void 0;
140069
140983
  const prebuiltByRole = options.preparedPrebuiltCollections;
140984
+ const privateMockAuth = options.privateMockAuth === true;
140985
+ const preparedPrivateMockCollections = /* @__PURE__ */ new Map();
140986
+ if (privateMockAuth) {
140987
+ for (const spec of [
140988
+ { role: "smoke", collectionId: inputs.smokeCollectionId },
140989
+ { role: "contract", collectionId: inputs.contractCollectionId }
140990
+ ]) {
140991
+ if (!spec.collectionId) {
140992
+ continue;
140993
+ }
140994
+ preparedPrivateMockCollections.set(
140995
+ spec.role,
140996
+ await preparePrivateMockCloudCollection(
140997
+ spec.role,
140998
+ spec.collectionId,
140999
+ dependencies.postman
141000
+ )
141001
+ );
141002
+ }
141003
+ }
140070
141004
  const baselineRef = await exportCollectionArtifact({
140071
141005
  role: "baseline",
140072
141006
  collectionId: inputs.baselineCollectionId,
@@ -140074,7 +141008,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140074
141008
  collectionsDir,
140075
141009
  prebuiltByRole,
140076
141010
  postman: dependencies.postman,
140077
- core: dependencies.core
141011
+ core: dependencies.core,
141012
+ privateMockAuth
140078
141013
  });
140079
141014
  if (baselineRef) {
140080
141015
  manifestCollections[baselineRef] = inputs.baselineCollectionId;
@@ -140086,7 +141021,9 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140086
141021
  collectionsDir,
140087
141022
  prebuiltByRole,
140088
141023
  postman: dependencies.postman,
140089
- core: dependencies.core
141024
+ core: dependencies.core,
141025
+ privateMockAuth,
141026
+ preparedCloudCollection: preparedPrivateMockCollections.get("smoke")
140090
141027
  });
140091
141028
  if (smokeRef) {
140092
141029
  manifestCollections[smokeRef] = inputs.smokeCollectionId;
@@ -140098,11 +141035,30 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140098
141035
  collectionsDir,
140099
141036
  prebuiltByRole,
140100
141037
  postman: dependencies.postman,
140101
- core: dependencies.core
141038
+ core: dependencies.core,
141039
+ privateMockAuth,
141040
+ preparedCloudCollection: preparedPrivateMockCollections.get("contract")
140102
141041
  });
140103
141042
  if (contractRef) {
140104
141043
  manifestCollections[contractRef] = inputs.contractCollectionId;
140105
141044
  }
141045
+ ensureDir(collectionsDir);
141046
+ ensureDir(environmentsDir);
141047
+ ensureDir(flowsDir);
141048
+ ensureDir(globalsDir);
141049
+ ensureDir(mocksDir);
141050
+ ensureDir(specsDir);
141051
+ ensureDir(".postman");
141052
+ const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
141053
+ if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
141054
+ (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
141055
+ }
141056
+ if (inputs.generateCiWorkflow) {
141057
+ const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
141058
+ if (ciDir) {
141059
+ ensureDir(ciDir);
141060
+ }
141061
+ }
140106
141062
  for (const [envName, envUid] of Object.entries(envUids)) {
140107
141063
  writeJsonFile(
140108
141064
  `${environmentsDir}/${envName}.postman_environment.json`,
@@ -140255,19 +141211,41 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
140255
141211
  async function runRepoSync(inputs, dependencies) {
140256
141212
  const telemetry = createTelemetryContext({ action: "postman-repo-sync-action", actionVersion: resolveActionVersion2(), logger: dependencies.core });
140257
141213
  telemetry.setTeamId(dependencies.teamId);
141214
+ const logger = resolveRepoSyncLogger(dependencies);
141215
+ for (const secret of [
141216
+ inputs.postmanApiKey,
141217
+ inputs.postmanAccessToken,
141218
+ inputs.adoToken,
141219
+ inputs.githubToken,
141220
+ inputs.ghFallbackToken,
141221
+ inputs.sslClientCert,
141222
+ inputs.sslClientKey,
141223
+ inputs.sslClientPassphrase,
141224
+ inputs.sslExtraCaCerts
141225
+ ]) {
141226
+ logger.addSecret(secret);
141227
+ }
141228
+ logger.debug("resolved inputs", {
141229
+ project: inputs.projectName,
141230
+ collection_sync_mode: inputs.collectionSyncMode,
141231
+ spec_sync_mode: inputs.specSyncMode,
141232
+ team_id: dependencies.teamId || void 0
141233
+ });
140258
141234
  try {
140259
- const result = await runRepoSyncInner(inputs, dependencies);
141235
+ const result = await runRepoSyncInner(inputs, { ...dependencies, logger });
140260
141236
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
140261
141237
  telemetry.emitCompletion("success");
140262
141238
  return result;
140263
141239
  } catch (error2) {
140264
141240
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
140265
141241
  telemetry.emitCompletion("failure");
141242
+ logger.failure("repo sync failed", error2);
140266
141243
  throw error2;
140267
141244
  }
140268
141245
  }
140269
141246
  async function runRepoSyncInner(inputs, dependencies) {
140270
141247
  const mask = resolveRepoSyncMasker(dependencies);
141248
+ const logger = resolveRepoSyncLogger(dependencies);
140271
141249
  const branchDecision = decideBranchTier(inputs);
140272
141250
  assertBranchAssetIds(inputs, branchDecision);
140273
141251
  const isCanonicalWriter = branchDecision.tier === "legacy" || branchDecision.tier === "canonical";
@@ -140327,7 +141305,10 @@ async function runRepoSyncInner(inputs, dependencies) {
140327
141305
  }
140328
141306
  }
140329
141307
  }
140330
- const preparedPrebuiltCollections = await preparePrebuiltCollections(inputs);
141308
+ const preparedPrebuiltCollections = await logger.phase(
141309
+ "prepare-collections",
141310
+ async () => preparePrebuiltCollections(inputs)
141311
+ );
140331
141312
  let skipRepositoryLinkPost = false;
140332
141313
  let repositoryLinkPreflightWasFree = false;
140333
141314
  if (inputs.workspaceLinkEnabled && inputs.workspaceId && inputs.repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
@@ -140362,7 +141343,10 @@ async function runRepoSyncInner(inputs, dependencies) {
140362
141343
  }
140363
141344
  }
140364
141345
  const branchAssetMarker = buildBranchAssetMarker(branchDecision, inputs);
140365
- const envUids = await upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker);
141346
+ const envUids = await logger.phase(
141347
+ "sync-environments",
141348
+ async () => upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker)
141349
+ );
140366
141350
  outputs["environment-uids-json"] = JSON.stringify(envUids);
140367
141351
  dependencies.core.setOutput("environment-uids-json", outputs["environment-uids-json"]);
140368
141352
  if (inputs.environmentSyncEnabled && inputs.workspaceId && dependencies.internalIntegration) {
@@ -140525,10 +141509,21 @@ async function runRepoSyncInner(inputs, dependencies) {
140525
141509
  );
140526
141510
  }
140527
141511
  const configured = [];
140528
- for (const collectionUid of [inputs.smokeCollectionId, inputs.contractCollectionId]) {
140529
- if (collectionUid) {
141512
+ for (const { role, collectionUid } of [
141513
+ { role: "smoke", collectionUid: inputs.smokeCollectionId },
141514
+ { role: "contract", collectionUid: inputs.contractCollectionId }
141515
+ ]) {
141516
+ if (!collectionUid) {
141517
+ continue;
141518
+ }
141519
+ try {
140530
141520
  await dependencies.postman.configurePrivateMockRuntimeAuth(collectionUid);
140531
141521
  configured.push(collectionUid);
141522
+ } catch (error2) {
141523
+ throw new Error(
141524
+ `PRIVATE_MOCK_AUTH_ROOT_PATCH: Failed to install managed root hook on ${role} collection ${collectionUid}: ${mask(causeText(error2))}`,
141525
+ { cause: error2 }
141526
+ );
140532
141527
  }
140533
141528
  }
140534
141529
  if (configured.length > 0) {
@@ -140603,6 +141598,43 @@ async function runRepoSyncInner(inputs, dependencies) {
140603
141598
  );
140604
141599
  }
140605
141600
  }
141601
+ if (!resolvedMonitorId && inputs.smokeCollectionId && dependencies.postman.rebindMonitorByName) {
141602
+ try {
141603
+ const rebound = await dependencies.postman.rebindMonitorByName(
141604
+ monitorName,
141605
+ inputs.smokeCollectionId,
141606
+ monitorEnvUid
141607
+ );
141608
+ if (rebound) {
141609
+ resolvedMonitorId = rebound.uid;
141610
+ dependencies.core.info(
141611
+ `Rebound existing monitor ${rebound.uid} ("${monitorName}") from collection ${rebound.previousCollectionUid} to ${inputs.smokeCollectionId}`
141612
+ );
141613
+ }
141614
+ } catch (error2) {
141615
+ if (error2 instanceof AmbiguousMonitorRebindError) {
141616
+ throw new Error(
141617
+ formatOrchestrationIssue({
141618
+ operation: "Monitor rebind",
141619
+ entity: `monitor "${monitorName}" workspace ${inputs.workspaceId} collection ${inputs.smokeCollectionId} environment ${monitorEnvUid}`,
141620
+ cause: error2,
141621
+ remediation: monitorRemediation,
141622
+ mask
141623
+ }),
141624
+ { cause: error2 }
141625
+ );
141626
+ }
141627
+ dependencies.core.warning(
141628
+ formatOrchestrationIssue({
141629
+ operation: "Monitor rebind",
141630
+ entity: `monitor "${monitorName}" workspace ${inputs.workspaceId} collection ${inputs.smokeCollectionId} environment ${monitorEnvUid}`,
141631
+ cause: error2,
141632
+ remediation: monitorRemediation,
141633
+ mask
141634
+ })
141635
+ );
141636
+ }
141637
+ }
140606
141638
  if (!resolvedMonitorId) {
140607
141639
  try {
140608
141640
  resolvedMonitorId = await dependencies.postman.createMonitor(
@@ -140680,16 +141712,23 @@ async function runRepoSyncInner(inputs, dependencies) {
140680
141712
  dependencies.core.warning(message);
140681
141713
  }
140682
141714
  }
140683
- await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
140684
- workspaceLinkStatus: outputs["workspace-link-status"],
140685
- priorWorkspaceId: resourcesState?.workspace?.id,
140686
- existingSpecs: resourcesState?.cloudResources?.specs,
140687
- mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
140688
- releaseLabel,
140689
- priorState: resourcesState,
140690
- preparedPrebuiltCollections
140691
- });
140692
- const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
141715
+ await logger.phase(
141716
+ "export-artifacts",
141717
+ async () => exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
141718
+ workspaceLinkStatus: outputs["workspace-link-status"],
141719
+ priorWorkspaceId: resourcesState?.workspace?.id,
141720
+ existingSpecs: resourcesState?.cloudResources?.specs,
141721
+ mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
141722
+ releaseLabel,
141723
+ priorState: resourcesState,
141724
+ preparedPrebuiltCollections,
141725
+ privateMockAuth: inputs.mockVisibility === "private"
141726
+ })
141727
+ );
141728
+ const commit = await logger.phase(
141729
+ "commit-and-push",
141730
+ async () => commitAndPushGeneratedFiles(inputs, dependencies)
141731
+ );
140693
141732
  outputs["commit-sha"] = commit.commitSha;
140694
141733
  if (commit.resolvedCurrentRef) {
140695
141734
  outputs["resolved-current-ref"] = commit.resolvedCurrentRef;
@@ -141017,6 +142056,7 @@ function createRepoSyncDependencies(inputs, resolved, factories, options = {}) {
141017
142056
  listMonitors: gatewayAssets.listMonitors.bind(gatewayAssets),
141018
142057
  monitorExists: gatewayAssets.monitorExists.bind(gatewayAssets),
141019
142058
  findMonitorByCollection: gatewayAssets.findMonitorByCollection.bind(gatewayAssets),
142059
+ rebindMonitorByName: gatewayAssets.rebindMonitorByName.bind(gatewayAssets),
141020
142060
  runMonitor: gatewayAssets.runMonitor.bind(gatewayAssets),
141021
142061
  listEnvironments: gatewayAssets.listEnvironments.bind(gatewayAssets),
141022
142062
  // GC path (preview/channel retention machine — lib/repo/preview-gc.ts).