@postman-cse/onboarding-repo-sync 2.4.1 → 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/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,186 @@ 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
+
135571
135762
  // src/action-version.ts
135572
135763
  var import_node_fs3 = require("node:fs");
135573
135764
  var import_node_path2 = require("node:path");
@@ -135584,7 +135775,7 @@ function resolveActionVersion2() {
135584
135775
  }
135585
135776
 
135586
135777
  // src/lib/http-error.ts
135587
- function truncate(value, limit) {
135778
+ function truncate2(value, limit) {
135588
135779
  if (value.length <= limit) {
135589
135780
  return value;
135590
135781
  }
@@ -135594,7 +135785,7 @@ function buildMessage(init) {
135594
135785
  const method = String(init.method || "GET").toUpperCase();
135595
135786
  const status = `${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
135596
135787
  const url = redactSecrets(init.url, init.secretValues);
135597
- const body = truncate(
135788
+ const body = truncate2(
135598
135789
  redactSecrets(init.responseBody || "", init.secretValues),
135599
135790
  Math.max(0, init.bodyLimit ?? 800)
135600
135791
  );
@@ -136973,30 +137164,13 @@ var PostmanAssetsClient = class {
136973
137164
  }
136974
137165
  };
136975
137166
 
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
- }
137167
+ // src/lib/postman/private-mock-auth-script.ts
136997
137168
  var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
136998
- var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
137169
+ var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
137170
+ var PRIVATE_MOCK_AUTH_V3_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
136999
137171
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
137172
+ var PRIVATE_MOCK_AUTH_ROOT_TYPE = "http:beforeRequest";
137173
+ var PRIVATE_MOCK_AUTH_ROOT_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-root`;
137000
137174
  var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137001
137175
  `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
137002
137176
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
@@ -137005,8 +137179,8 @@ var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137005
137179
  " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137006
137180
  "}"
137007
137181
  ].join("\n");
137008
- var PRIVATE_MOCK_AUTH_SCRIPT = [
137009
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137182
+ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
137183
+ `// ${PRIVATE_MOCK_AUTH_V2_MARKER}`,
137010
137184
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137011
137185
  "var privateMockHostValue = pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '';",
137012
137186
  "var privateMockHost = Array.isArray(privateMockHostValue) ? privateMockHostValue.join('.') : String(privateMockHostValue);",
@@ -137017,8 +137191,347 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
137017
137191
  ` 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.');`,
137018
137192
  "}"
137019
137193
  ].join("\n");
137020
- function removeLegacyPrivateMockAuth(code) {
137021
- return code.split(LEGACY_PRIVATE_MOCK_AUTH_SCRIPT).join("").trim();
137194
+ var PRIVATE_MOCK_AUTH_V3_SCRIPT = [
137195
+ `// ${PRIVATE_MOCK_AUTH_V3_MARKER}`,
137196
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137197
+ "var privateMockHost = '';",
137198
+ "try {",
137199
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137200
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137201
+ "} catch (error) {",
137202
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137203
+ "}",
137204
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137205
+ "if (isPrivateMockHost && privateMockApiKey) {",
137206
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137207
+ "} else if (isPrivateMockHost) {",
137208
+ ` 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.');`,
137209
+ "}"
137210
+ ].join("\n");
137211
+ var PRIVATE_MOCK_AUTH_ROOT_SCRIPT = [
137212
+ `// ${PRIVATE_MOCK_AUTH_ROOT_MARKER}`,
137213
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137214
+ "var privateMockHost = '';",
137215
+ "try {",
137216
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137217
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137218
+ "} catch (error) {",
137219
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137220
+ "}",
137221
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137222
+ "if (isPrivateMockHost && privateMockApiKey) {",
137223
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137224
+ "} else if (isPrivateMockHost) {",
137225
+ ` 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.');`,
137226
+ "}"
137227
+ ].join("\n");
137228
+ var MANAGED_ITEM_AUTH_BLOCKS = [
137229
+ LEGACY_PRIVATE_MOCK_AUTH_SCRIPT,
137230
+ PRIVATE_MOCK_AUTH_V2_SCRIPT,
137231
+ PRIVATE_MOCK_AUTH_V3_SCRIPT
137232
+ ];
137233
+ function isManagedPrivateMockAuthRootHook(script) {
137234
+ return String(script.type ?? "") === PRIVATE_MOCK_AUTH_ROOT_TYPE && String(script.code ?? "") === PRIVATE_MOCK_AUTH_ROOT_SCRIPT;
137235
+ }
137236
+ var REGEX_PREFIX_KEYWORDS = /* @__PURE__ */ new Set([
137237
+ "await",
137238
+ "case",
137239
+ "delete",
137240
+ "do",
137241
+ "else",
137242
+ "in",
137243
+ "instanceof",
137244
+ "of",
137245
+ "return",
137246
+ "throw",
137247
+ "typeof",
137248
+ "void",
137249
+ "yield"
137250
+ ]);
137251
+ function isIdentifierStart(ch) {
137252
+ return ch !== void 0 && /[A-Za-z_$]/.test(ch);
137253
+ }
137254
+ function isIdentifierPart(ch) {
137255
+ return ch !== void 0 && /[A-Za-z0-9_$]/.test(ch);
137256
+ }
137257
+ function markTopLevelScriptBytes(source) {
137258
+ const topLevel = new Uint8Array(source.length);
137259
+ let state = "script";
137260
+ let canStartRegex = true;
137261
+ let regexCharacterClass = false;
137262
+ for (let i = 0; i < source.length; i++) {
137263
+ const ch = source[i];
137264
+ const next = source[i + 1];
137265
+ if (state === "script") {
137266
+ topLevel[i] = 1;
137267
+ if (ch === "/" && next === "*") {
137268
+ topLevel[i] = 0;
137269
+ state = "block_comment";
137270
+ i++;
137271
+ topLevel[i] = 0;
137272
+ continue;
137273
+ }
137274
+ if (ch === "/" && next === "/") {
137275
+ topLevel[i + 1] = 1;
137276
+ i++;
137277
+ while (i + 1 < source.length && source[i + 1] !== "\n") {
137278
+ i++;
137279
+ topLevel[i] = 1;
137280
+ }
137281
+ continue;
137282
+ }
137283
+ if (ch === "/") {
137284
+ if (canStartRegex) {
137285
+ topLevel[i] = 0;
137286
+ state = "regex";
137287
+ regexCharacterClass = false;
137288
+ continue;
137289
+ }
137290
+ canStartRegex = true;
137291
+ if (next === "=") {
137292
+ i++;
137293
+ topLevel[i] = 1;
137294
+ }
137295
+ continue;
137296
+ }
137297
+ if (ch === "'") {
137298
+ state = "single";
137299
+ topLevel[i] = 0;
137300
+ continue;
137301
+ }
137302
+ if (ch === '"') {
137303
+ state = "double";
137304
+ topLevel[i] = 0;
137305
+ continue;
137306
+ }
137307
+ if (ch === "`") {
137308
+ state = "template";
137309
+ topLevel[i] = 0;
137310
+ continue;
137311
+ }
137312
+ if (/\s/.test(ch)) {
137313
+ continue;
137314
+ }
137315
+ if (isIdentifierStart(ch)) {
137316
+ let end = i + 1;
137317
+ while (isIdentifierPart(source[end])) {
137318
+ topLevel[end] = 1;
137319
+ end++;
137320
+ }
137321
+ canStartRegex = REGEX_PREFIX_KEYWORDS.has(source.slice(i, end));
137322
+ i = end - 1;
137323
+ continue;
137324
+ }
137325
+ if (/[0-9]/.test(ch)) {
137326
+ let end = i + 1;
137327
+ while (/[A-Za-z0-9_.]/.test(source[end] ?? "")) {
137328
+ topLevel[end] = 1;
137329
+ end++;
137330
+ }
137331
+ canStartRegex = false;
137332
+ i = end - 1;
137333
+ continue;
137334
+ }
137335
+ if ((ch === "+" || ch === "-") && next === ch) {
137336
+ const wasPrefix = canStartRegex;
137337
+ i++;
137338
+ topLevel[i] = 1;
137339
+ canStartRegex = wasPrefix;
137340
+ continue;
137341
+ }
137342
+ if (ch === "?" && next === ".") {
137343
+ i++;
137344
+ topLevel[i] = 1;
137345
+ canStartRegex = false;
137346
+ continue;
137347
+ }
137348
+ if (")]}".includes(ch) || ch === ".") {
137349
+ canStartRegex = false;
137350
+ continue;
137351
+ }
137352
+ if ("([{,;:=!~*%&|^<>+-?".includes(ch)) {
137353
+ canStartRegex = true;
137354
+ continue;
137355
+ }
137356
+ canStartRegex = false;
137357
+ continue;
137358
+ }
137359
+ if (state === "block_comment") {
137360
+ topLevel[i] = 0;
137361
+ if (ch === "*" && next === "/") {
137362
+ topLevel[i] = 0;
137363
+ i++;
137364
+ topLevel[i] = 0;
137365
+ state = "script";
137366
+ }
137367
+ continue;
137368
+ }
137369
+ if (state === "single") {
137370
+ topLevel[i] = 0;
137371
+ if (ch === "\\" && i + 1 < source.length) {
137372
+ i++;
137373
+ topLevel[i] = 0;
137374
+ continue;
137375
+ }
137376
+ if (ch === "'") {
137377
+ state = "script";
137378
+ canStartRegex = false;
137379
+ }
137380
+ continue;
137381
+ }
137382
+ if (state === "double") {
137383
+ topLevel[i] = 0;
137384
+ if (ch === "\\" && i + 1 < source.length) {
137385
+ i++;
137386
+ topLevel[i] = 0;
137387
+ continue;
137388
+ }
137389
+ if (ch === '"') {
137390
+ state = "script";
137391
+ canStartRegex = false;
137392
+ }
137393
+ continue;
137394
+ }
137395
+ if (state === "regex") {
137396
+ topLevel[i] = 0;
137397
+ if (ch === "\\" && i + 1 < source.length) {
137398
+ i++;
137399
+ topLevel[i] = 0;
137400
+ continue;
137401
+ }
137402
+ if (ch === "\n" || ch === "\r") {
137403
+ state = "script";
137404
+ canStartRegex = true;
137405
+ regexCharacterClass = false;
137406
+ continue;
137407
+ }
137408
+ if (ch === "[") {
137409
+ regexCharacterClass = true;
137410
+ continue;
137411
+ }
137412
+ if (ch === "]" && regexCharacterClass) {
137413
+ regexCharacterClass = false;
137414
+ continue;
137415
+ }
137416
+ if (ch === "/" && !regexCharacterClass) {
137417
+ while (isIdentifierPart(source[i + 1])) {
137418
+ i++;
137419
+ topLevel[i] = 0;
137420
+ }
137421
+ state = "script";
137422
+ canStartRegex = false;
137423
+ }
137424
+ continue;
137425
+ }
137426
+ topLevel[i] = 0;
137427
+ if (ch === "\\" && i + 1 < source.length) {
137428
+ i++;
137429
+ topLevel[i] = 0;
137430
+ continue;
137431
+ }
137432
+ if (ch === "`") {
137433
+ state = "script";
137434
+ canStartRegex = false;
137435
+ }
137436
+ }
137437
+ return topLevel;
137438
+ }
137439
+ function isWholeLineTopLevelMatch(source, startIndex, block, topLevel) {
137440
+ if (!source.startsWith(block, startIndex)) {
137441
+ return false;
137442
+ }
137443
+ if (startIndex > 0 && source[startIndex - 1] !== "\n") {
137444
+ return false;
137445
+ }
137446
+ const endIndex = startIndex + block.length;
137447
+ for (let lineStart = startIndex; lineStart < endIndex; ) {
137448
+ if (!topLevel[lineStart]) {
137449
+ return false;
137450
+ }
137451
+ const nextNewline = source.indexOf("\n", lineStart);
137452
+ if (nextNewline === -1 || nextNewline >= endIndex - 1) {
137453
+ break;
137454
+ }
137455
+ lineStart = nextNewline + 1;
137456
+ }
137457
+ return true;
137458
+ }
137459
+ function findManagedBlockRanges(source) {
137460
+ const topLevel = markTopLevelScriptBytes(source);
137461
+ const ranges = [];
137462
+ for (let i = 0; i < source.length; i++) {
137463
+ if (i > 0 && source[i - 1] !== "\n") {
137464
+ continue;
137465
+ }
137466
+ for (const block of MANAGED_ITEM_AUTH_BLOCKS) {
137467
+ if (!isWholeLineTopLevelMatch(source, i, block, topLevel)) {
137468
+ continue;
137469
+ }
137470
+ ranges.push({ start: i, end: i + block.length });
137471
+ break;
137472
+ }
137473
+ }
137474
+ return ranges;
137475
+ }
137476
+ function countManagedItemAuthBlocks(code) {
137477
+ if (typeof code !== "string" || !code) {
137478
+ return 0;
137479
+ }
137480
+ return findManagedBlockRanges(code).length;
137481
+ }
137482
+ function deleteRangeWithSeam(source, start, end) {
137483
+ let before = source.slice(0, start);
137484
+ let after = source.slice(end);
137485
+ const beforeHadNl = before.endsWith("\n");
137486
+ const afterHadNl = after.startsWith("\n");
137487
+ if (beforeHadNl) {
137488
+ before = before.slice(0, -1);
137489
+ }
137490
+ if (afterHadNl) {
137491
+ after = after.slice(1);
137492
+ }
137493
+ if (beforeHadNl && afterHadNl && before.length > 0 && after.length > 0) {
137494
+ return `${before}
137495
+ ${after}`;
137496
+ }
137497
+ return `${before}${after}`;
137498
+ }
137499
+ function stripManagedItemAuthBlocks(code) {
137500
+ if (typeof code !== "string" || !code) {
137501
+ return "";
137502
+ }
137503
+ const ranges = findManagedBlockRanges(code);
137504
+ if (ranges.length === 0) {
137505
+ return code;
137506
+ }
137507
+ ranges.sort((left, right) => right.start - left.start);
137508
+ let next = code;
137509
+ for (const range of ranges) {
137510
+ next = deleteRangeWithSeam(next, range.start, range.end);
137511
+ }
137512
+ return next;
137513
+ }
137514
+
137515
+ // src/lib/postman/postman-gateway-assets-client.ts
137516
+ var MockContractError = class extends Error {
137517
+ constructor(message) {
137518
+ super(message);
137519
+ this.name = "MockContractError";
137520
+ }
137521
+ };
137522
+ function requireMockVisibility(mock, requested) {
137523
+ if (mock.visibility === "unknown") {
137524
+ throw new MockContractError(
137525
+ `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
137526
+ );
137527
+ }
137528
+ if (mock.visibility !== requested) {
137529
+ const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
137530
+ throw new MockContractError(
137531
+ `${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}.`
137532
+ );
137533
+ }
137534
+ return mock;
137022
137535
  }
137023
137536
  var MAX_CREATE_FLIGHTS = 256;
137024
137537
  var createFlights = /* @__PURE__ */ new Map();
@@ -137589,51 +138102,83 @@ var PostmanGatewayAssetsClient = class {
137589
138102
  }
137590
138103
  });
137591
138104
  }
138105
+ isAmbiguousTransportError(error2) {
138106
+ return this.isRetryableIdempotentWriteOutcome(error2);
138107
+ }
138108
+ normalizeCollectionScripts(scripts) {
138109
+ if (!Array.isArray(scripts)) return [];
138110
+ return scripts.map((entry) => this.asRecord(entry)).filter((entry) => entry !== null);
138111
+ }
138112
+ rootScriptsIncludeManagedAuthHook(scripts) {
138113
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
138114
+ }
138115
+ buildPrivateMockRootScripts(existingScripts) {
138116
+ const managedScript = {
138117
+ type: PRIVATE_MOCK_AUTH_ROOT_TYPE,
138118
+ code: PRIVATE_MOCK_AUTH_ROOT_SCRIPT,
138119
+ language: "text/javascript"
138120
+ };
138121
+ return [...existingScripts, managedScript];
138122
+ }
138123
+ async readCollectionRootScripts(collectionUid) {
138124
+ const id = this.toModelId(collectionUid);
138125
+ const response = await this.gateway.requestJson({
138126
+ service: "collection",
138127
+ method: "get",
138128
+ path: `/v3/collections/${id}/export`
138129
+ });
138130
+ const data = this.asRecord(response?.data);
138131
+ const collection = this.asRecord(data?.collection);
138132
+ if (!collection) {
138133
+ throw new Error(
138134
+ `PRIVATE_MOCK_AUTH_EXPORT_INVALID: Collection ${id} export did not return data.collection; refusing to configure private-mock root auth from an unexpected envelope.`
138135
+ );
138136
+ }
138137
+ return this.normalizeCollectionScripts(collection.scripts);
138138
+ }
138139
+ async patchCollectionRootScripts(collectionUid, scripts) {
138140
+ const id = this.toModelId(collectionUid);
138141
+ await this.gateway.requestJson(
138142
+ {
138143
+ service: "collection",
138144
+ method: "patch",
138145
+ path: `/v3/collections/${id}`,
138146
+ body: [{ op: "add", path: "/scripts", value: scripts }]
138147
+ },
138148
+ { retryTransient: false }
138149
+ );
138150
+ }
137592
138151
  /**
137593
- * Add a secret-free runtime hook to every HTTP request in a collection. The
137594
- * PMAK value is supplied only by the runner as a transient variable; this
137595
- * method persists the variable name and header wiring, never the credential.
138152
+ * Add a secret-free runtime hook at the collection root. The PMAK value is
138153
+ * supplied only by the runner as a transient variable; this method persists
138154
+ * the variable name and header wiring, never the credential.
137596
138155
  */
137597
138156
  async configurePrivateMockRuntimeAuth(collectionUid) {
137598
138157
  const cid = String(collectionUid ?? "").trim();
137599
138158
  if (!cid) return 0;
137600
- const listed = await this.gateway.requestJson({
137601
- service: "collection",
137602
- method: "get",
137603
- path: `/v3/collections/${cid}/items/`
137604
- });
137605
- const items = Array.isArray(listed?.data) ? listed.data : [];
137606
- let patched = 0;
137607
- for (const listedItem of items) {
137608
- if (String(listedItem.$kind ?? "") !== "http-request") continue;
137609
- const itemId = String(listedItem.id ?? "").trim();
137610
- if (!itemId) continue;
137611
- const response = await this.gateway.requestJson({
137612
- service: "collection",
137613
- method: "get",
137614
- path: `/v3/collections/${cid}/items/${itemId}`,
137615
- headers: { "X-Entity-Type": "http-request" }
137616
- });
137617
- const item = this.asRecord(response?.data) ?? listedItem;
137618
- const scripts = Array.isArray(item.scripts) ? item.scripts.filter((entry) => Boolean(this.asRecord(entry))) : [];
137619
- const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
137620
- const existingCode = String(before?.code ?? "");
137621
- if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
137622
- const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137623
- const nextScripts = [
137624
- ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
137625
- { type: "beforeRequest", code, language: "text/javascript" }
137626
- ];
137627
- await this.gateway.requestJson({
137628
- service: "collection",
137629
- method: "patch",
137630
- path: `/v3/collections/${cid}/items/${itemId}`,
137631
- headers: { "X-Entity-Type": "http-request" },
137632
- body: [{ op: "add", path: "/scripts", value: nextScripts }]
137633
- });
137634
- patched += 1;
137635
- }
137636
- return patched;
138159
+ const installFromFreshRoot = async (existingScripts) => {
138160
+ if (this.rootScriptsIncludeManagedAuthHook(existingScripts)) {
138161
+ return 0;
138162
+ }
138163
+ const nextScripts = this.buildPrivateMockRootScripts(existingScripts);
138164
+ try {
138165
+ await this.patchCollectionRootScripts(cid, nextScripts);
138166
+ return 1;
138167
+ } catch (error2) {
138168
+ if (!this.isAmbiguousTransportError(error2)) {
138169
+ throw error2;
138170
+ }
138171
+ const freshScripts = await this.readCollectionRootScripts(cid);
138172
+ if (this.rootScriptsIncludeManagedAuthHook(freshScripts)) {
138173
+ return 1;
138174
+ }
138175
+ const recomputed = this.buildPrivateMockRootScripts(freshScripts);
138176
+ await this.patchCollectionRootScripts(cid, recomputed);
138177
+ return 1;
138178
+ }
138179
+ };
138180
+ const scripts = await this.readCollectionRootScripts(cid);
138181
+ return installFromFreshRoot(scripts);
137637
138182
  }
137638
138183
  async listMocks() {
137639
138184
  const response = await this.gateway.requestJson({
@@ -137717,12 +138262,13 @@ var PostmanGatewayAssetsClient = class {
137717
138262
  }
137718
138263
  async createMonitor(workspaceId, name, collectionUid, environmentUid, cronSchedule) {
137719
138264
  const ws = workspaceId || this.workspaceId;
137720
- const effectiveCron = cronSchedule && cronSchedule.trim() ? cronSchedule.trim() : "0 0 * * 0";
138265
+ const cronTrimmed = String(cronSchedule ?? "").trim();
138266
+ const hasCron = cronTrimmed.length > 0;
137721
138267
  const monitorName = String(name ?? "").trim();
137722
138268
  const collection = String(collectionUid ?? "").trim();
137723
138269
  const environment = String(environmentUid ?? "").trim();
137724
138270
  const flightKey = `monitor:${ws}:${collection}:${environment}:${monitorName}`;
137725
- return this.singleFlight(flightKey, effectiveCron, "monitor", async () => {
138271
+ return this.singleFlight(flightKey, hasCron ? cronTrimmed : "inactive", "monitor", async () => {
137726
138272
  const existing = await this.findMonitorByCollection(collection, environment, monitorName);
137727
138273
  if (existing?.uid) {
137728
138274
  return existing.uid;
@@ -137730,11 +138276,12 @@ var PostmanGatewayAssetsClient = class {
137730
138276
  const body = {
137731
138277
  name: monitorName,
137732
138278
  collection,
138279
+ active: hasCron,
137733
138280
  options: { strictSSL: false, followRedirects: true, requestTimeout: null, requestDelay: 0 },
137734
138281
  notifications: { onFailure: [], onError: [] },
137735
138282
  retry: {},
137736
- schedule: { cronPattern: effectiveCron, timeZone: "UTC" },
137737
138283
  distribution: null,
138284
+ ...hasCron ? { schedule: { cronPattern: cronTrimmed, timeZone: "UTC" } } : {},
137738
138285
  ...environment ? { environment } : {}
137739
138286
  };
137740
138287
  const send2 = (fallback) => this.gateway.requestJson(
@@ -137820,6 +138367,128 @@ var PostmanGatewayAssetsClient = class {
137820
138367
  }
137821
138368
  };
137822
138369
 
138370
+ // src/lib/postman/private-mock-export-cleanup.ts
138371
+ function asArray2(value) {
138372
+ return Array.isArray(value) ? value : [];
138373
+ }
138374
+ function cloneScriptRecord(script) {
138375
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
138376
+ return script;
138377
+ }
138378
+ return { ...script };
138379
+ }
138380
+ function cloneCollectionNodeIterative(collection) {
138381
+ const cloned = { ...collection };
138382
+ if (Array.isArray(collection.scripts)) {
138383
+ cloned.scripts = collection.scripts.map((script) => cloneScriptRecord(script));
138384
+ }
138385
+ const stack = [];
138386
+ const attachNested = (source, target) => {
138387
+ if (Array.isArray(source.scripts)) {
138388
+ target.scripts = source.scripts.map((script) => cloneScriptRecord(script));
138389
+ }
138390
+ for (const key of ["items", "children"]) {
138391
+ const nested = asArray2(source[key]);
138392
+ if (nested.length === 0) {
138393
+ continue;
138394
+ }
138395
+ const clonedNested = nested.map((item) => ({ ...item }));
138396
+ target[key] = clonedNested;
138397
+ for (let i = 0; i < nested.length; i += 1) {
138398
+ stack.push({ source: nested[i], target: clonedNested[i] });
138399
+ }
138400
+ }
138401
+ };
138402
+ attachNested(collection, cloned);
138403
+ while (stack.length > 0) {
138404
+ const frame = stack.pop();
138405
+ attachNested(frame.source, frame.target);
138406
+ }
138407
+ return cloned;
138408
+ }
138409
+ function cloneCollection(collection) {
138410
+ if (typeof globalThis.structuredClone === "function") {
138411
+ try {
138412
+ return globalThis.structuredClone(collection);
138413
+ } catch {
138414
+ }
138415
+ }
138416
+ try {
138417
+ return JSON.parse(JSON.stringify(collection));
138418
+ } catch {
138419
+ return cloneCollectionNodeIterative(collection);
138420
+ }
138421
+ }
138422
+ function isPrivateMockLegacyExportCleanupEnabled() {
138423
+ const value = String(process.env.POSTMAN_PRIVATE_MOCK_LEGACY_EXPORT_CLEANUP ?? "").trim().toLowerCase();
138424
+ return value !== "off";
138425
+ }
138426
+ function verifyPrivateMockRootHook(collection) {
138427
+ const scripts = asArray2(collection.scripts);
138428
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
138429
+ }
138430
+ function applyPrivateMockExportCleanup(collection, options = {}) {
138431
+ const stripManagedBlocks = options.stripManagedBlocks ?? isPrivateMockLegacyExportCleanupEnabled();
138432
+ const cloned = cloneCollection(collection);
138433
+ let strippedBlocks = 0;
138434
+ const visitItem = (item) => {
138435
+ if (!stripManagedBlocks) {
138436
+ return;
138437
+ }
138438
+ const scripts = item.scripts;
138439
+ if (!Array.isArray(scripts)) {
138440
+ return;
138441
+ }
138442
+ const nextScripts = [];
138443
+ for (const script of scripts) {
138444
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
138445
+ nextScripts.push(script);
138446
+ continue;
138447
+ }
138448
+ const record = script;
138449
+ if (String(record.type ?? "") !== "beforeRequest") {
138450
+ nextScripts.push(record);
138451
+ continue;
138452
+ }
138453
+ const originalCode = String(record.code ?? "");
138454
+ const cleaned = stripManagedItemAuthBlocks(originalCode);
138455
+ if (cleaned === originalCode) {
138456
+ nextScripts.push(record);
138457
+ continue;
138458
+ }
138459
+ strippedBlocks += countManagedItemAuthBlocks(originalCode);
138460
+ if (!cleaned) {
138461
+ continue;
138462
+ }
138463
+ nextScripts.push({ ...record, code: cleaned });
138464
+ }
138465
+ if (nextScripts.length === 0) {
138466
+ delete item.scripts;
138467
+ } else {
138468
+ item.scripts = nextScripts;
138469
+ }
138470
+ };
138471
+ const walkItemsIteratively = (rootItems) => {
138472
+ const stack = [...rootItems].reverse();
138473
+ while (stack.length > 0) {
138474
+ const item = stack.pop();
138475
+ visitItem(item);
138476
+ for (const key of ["items", "children"]) {
138477
+ const nested = asArray2(item[key]);
138478
+ for (let i = nested.length - 1; i >= 0; i -= 1) {
138479
+ stack.push(nested[i]);
138480
+ }
138481
+ }
138482
+ }
138483
+ };
138484
+ walkItemsIteratively(asArray2(cloned.items));
138485
+ return {
138486
+ collection: cloned,
138487
+ strippedBlocks,
138488
+ rootVerified: verifyPrivateMockRootHook(cloned)
138489
+ };
138490
+ }
138491
+
137823
138492
  // src/lib/postman/token-provider.ts
137824
138493
  var MintError = class extends Error {
137825
138494
  permanent;
@@ -138629,6 +139298,15 @@ var identitySecretMasker = (input) => input;
138629
139298
  function resolveRepoSyncMasker(dependencies) {
138630
139299
  return dependencies.secretMasker ?? identitySecretMasker;
138631
139300
  }
139301
+ function resolveRepoSyncLogger(dependencies) {
139302
+ return dependencies.logger ?? createLogger({
139303
+ sink: actionSink(dependencies.core),
139304
+ fields: {
139305
+ action: "postman-repo-sync-action",
139306
+ action_version: resolveActionVersion2()
139307
+ }
139308
+ });
139309
+ }
138632
139310
  function causeText(cause) {
138633
139311
  return cause instanceof Error ? cause.message : String(cause);
138634
139312
  }
@@ -139045,13 +139723,51 @@ function normalizeToPosix(filePath) {
139045
139723
  function canonicalizeRelativePath(value) {
139046
139724
  return normalizeToPosix(String(value ?? "").trim()).replace(/^\.\/+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/g, "");
139047
139725
  }
139048
- function isOpenApiSpecFile(filePath) {
139049
- if (!(filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml"))) {
139050
- return false;
139726
+ var LOCAL_SPEC_DISCOVERY_MAX_DEPTH = 6;
139727
+ var LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES = 1e4;
139728
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES = 200;
139729
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES = 512 * 1024;
139730
+ var LOCAL_SPEC_DISCOVERY_IGNORED_DIRS = /* @__PURE__ */ new Set([
139731
+ ".git",
139732
+ ".nyc_output",
139733
+ ".omc",
139734
+ ".omx",
139735
+ ".llm-plans",
139736
+ ".pulumi",
139737
+ ".terraform",
139738
+ ".venv",
139739
+ "__pycache__",
139740
+ "bin",
139741
+ "build",
139742
+ "coverage",
139743
+ "discovered-specs",
139744
+ "node_modules",
139745
+ "dist",
139746
+ "obj",
139747
+ "out",
139748
+ "target",
139749
+ "vendor",
139750
+ "venv"
139751
+ ]);
139752
+ var LocalSpecDiscoveryLimitError = class extends Error {
139753
+ code = "CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT";
139754
+ constructor(message) {
139755
+ super(`CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT: ${message}`);
139756
+ this.name = "LocalSpecDiscoveryLimitError";
139051
139757
  }
139758
+ };
139759
+ function failLocalSpecDiscoveryLimit(detail) {
139760
+ throw new LocalSpecDiscoveryLimitError(
139761
+ `${detail} Set spec-path to the OpenAPI file explicitly and keep generated trees (for example dist/, node_modules/) out of the repository layout.`
139762
+ );
139763
+ }
139764
+ function isSpecCandidateExtension(filePath) {
139765
+ return filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml");
139766
+ }
139767
+ function readOpenApiSpecFile(fullPath) {
139052
139768
  try {
139053
- const raw = (0, import_node_fs5.readFileSync)(filePath, "utf8");
139054
- const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
139769
+ const raw = (0, import_node_fs5.readFileSync)(fullPath, "utf8");
139770
+ const parsed = fullPath.endsWith(".json") ? JSON.parse(raw) : load(raw);
139055
139771
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
139056
139772
  return false;
139057
139773
  }
@@ -139067,28 +139783,75 @@ function isOpenApiSpecFile(filePath) {
139067
139783
  }
139068
139784
  return false;
139069
139785
  }
139070
- function scanLocalSpecReferences(baseDir = ".") {
139071
- const ignoredDirs = /* @__PURE__ */ new Set([
139072
- ".git",
139073
- ".omc",
139074
- ".omx",
139075
- ".llm-plans",
139076
- "node_modules",
139077
- "dist"
139078
- ]);
139786
+ function shouldIgnoreSpecDiscoveryEntry(entryName, currentDir, baseDir, ignoredPrefixes) {
139787
+ if (LOCAL_SPEC_DISCOVERY_IGNORED_DIRS.has(entryName)) {
139788
+ return true;
139789
+ }
139790
+ const relative4 = normalizeToPosix(path8.relative(baseDir, path8.join(currentDir, entryName)));
139791
+ return ignoredPrefixes.some(
139792
+ (prefix) => relative4 === prefix || relative4.startsWith(`${prefix}/`)
139793
+ );
139794
+ }
139795
+ function scanLocalSpecReferences(baseDir = ".", options = {}) {
139796
+ const ignoredPrefixes = (options.ignoredPrefixes ?? []).map((value) => canonicalizeRelativePath(value)).filter(Boolean);
139079
139797
  const found = /* @__PURE__ */ new Set();
139080
139798
  const refs = [];
139081
- const visit2 = (currentDir) => {
139082
- for (const entry of (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true })) {
139083
- if (ignoredDirs.has(entry.name)) {
139799
+ let traversalEntries = 0;
139800
+ let candidateFiles = 0;
139801
+ const pendingDirs = [{ dir: baseDir, depth: 0 }];
139802
+ while (pendingDirs.length > 0) {
139803
+ const { dir: currentDir, depth: currentDepth } = pendingDirs.shift();
139804
+ let entries;
139805
+ try {
139806
+ entries = (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true }).sort(
139807
+ (left, right) => left.name.localeCompare(right.name)
139808
+ );
139809
+ } catch {
139810
+ continue;
139811
+ }
139812
+ for (const entry of entries) {
139813
+ traversalEntries += 1;
139814
+ if (traversalEntries > LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES) {
139815
+ failLocalSpecDiscoveryLimit(
139816
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES} traversal-entry liveness budget.`
139817
+ );
139818
+ }
139819
+ if (shouldIgnoreSpecDiscoveryEntry(entry.name, currentDir, baseDir, ignoredPrefixes)) {
139084
139820
  continue;
139085
139821
  }
139086
139822
  const fullPath = path8.join(currentDir, entry.name);
139087
139823
  if (entry.isDirectory()) {
139088
- visit2(fullPath);
139824
+ const nextDepth = currentDepth + 1;
139825
+ if (nextDepth > LOCAL_SPEC_DISCOVERY_MAX_DEPTH) {
139826
+ failLocalSpecDiscoveryLimit(
139827
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_DEPTH} directory-depth budget.`
139828
+ );
139829
+ }
139830
+ pendingDirs.push({ dir: fullPath, depth: nextDepth });
139089
139831
  continue;
139090
139832
  }
139091
- if (!entry.isFile() || !isOpenApiSpecFile(fullPath)) {
139833
+ if (!entry.isFile() || !isSpecCandidateExtension(fullPath)) {
139834
+ continue;
139835
+ }
139836
+ candidateFiles += 1;
139837
+ if (candidateFiles > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES) {
139838
+ failLocalSpecDiscoveryLimit(
139839
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES} candidate-file budget.`
139840
+ );
139841
+ }
139842
+ let sizeBytes;
139843
+ try {
139844
+ sizeBytes = (0, import_node_fs5.statSync)(fullPath).size;
139845
+ } catch {
139846
+ continue;
139847
+ }
139848
+ if (sizeBytes > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES) {
139849
+ const repoRelativePath2 = normalizeToPosix(path8.relative(baseDir, fullPath));
139850
+ failLocalSpecDiscoveryLimit(
139851
+ `local spec discovery candidate ${repoRelativePath2} exceeds ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES} bytes.`
139852
+ );
139853
+ }
139854
+ if (!readOpenApiSpecFile(fullPath)) {
139092
139855
  continue;
139093
139856
  }
139094
139857
  const repoRelativePath = normalizeToPosix(path8.relative(baseDir, fullPath));
@@ -139101,20 +139864,36 @@ function scanLocalSpecReferences(baseDir = ".") {
139101
139864
  configRelativePath: normalizeToPosix(path8.join("..", repoRelativePath))
139102
139865
  });
139103
139866
  }
139104
- };
139105
- visit2(baseDir);
139867
+ }
139106
139868
  return refs.sort((left, right) => left.repoRelativePath.localeCompare(right.repoRelativePath));
139107
139869
  }
139108
- function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
139870
+ function tryResolveExplicitSpecReference(explicitSpecPath) {
139109
139871
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
139110
- if (normalizedExplicitPath) {
139111
- const explicitFullPath = path8.resolve(normalizedExplicitPath);
139112
- if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
139113
- return {
139114
- repoRelativePath: normalizedExplicitPath,
139115
- configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
139116
- };
139117
- }
139872
+ if (!normalizedExplicitPath) {
139873
+ return void 0;
139874
+ }
139875
+ const explicitFullPath = path8.resolve(normalizedExplicitPath);
139876
+ if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
139877
+ return {
139878
+ repoRelativePath: normalizedExplicitPath,
139879
+ configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
139880
+ };
139881
+ }
139882
+ return void 0;
139883
+ }
139884
+ function resolveLocalSpecReferences(explicitSpecPath, baseDir = ".", options = {}) {
139885
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
139886
+ if (explicit) {
139887
+ return { discoveredSpecs: [], mappedSpec: explicit };
139888
+ }
139889
+ const discoveredSpecs = scanLocalSpecReferences(baseDir, options);
139890
+ const mappedSpec = resolveMappedSpecReference(explicitSpecPath, discoveredSpecs);
139891
+ return { discoveredSpecs, mappedSpec };
139892
+ }
139893
+ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
139894
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
139895
+ if (explicit) {
139896
+ return explicit;
139118
139897
  }
139119
139898
  if (discoveredSpecs.length === 1) {
139120
139899
  return discoveredSpecs[0];
@@ -139935,6 +140714,18 @@ function tryReusePrebuiltCollection(options) {
139935
140714
  }
139936
140715
  return prepared.artifactDigest === entry.artifactDigest;
139937
140716
  }
140717
+ async function preparePrivateMockCloudCollection(role, collectionId, postman) {
140718
+ const col = await postman.getCollection(collectionId);
140719
+ const { collection } = applyPrivateMockExportCleanup(col, {
140720
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
140721
+ });
140722
+ if (!verifyPrivateMockRootHook(collection)) {
140723
+ throw new Error(
140724
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
140725
+ );
140726
+ }
140727
+ return collection;
140728
+ }
139938
140729
  async function exportCollectionArtifact(options) {
139939
140730
  const {
139940
140731
  role,
@@ -139943,14 +140734,17 @@ async function exportCollectionArtifact(options) {
139943
140734
  collectionsDir,
139944
140735
  prebuiltByRole,
139945
140736
  postman,
139946
- core
140737
+ core,
140738
+ privateMockAuth = false,
140739
+ preparedCloudCollection
139947
140740
  } = options;
139948
140741
  if (!collectionId) {
139949
140742
  return void 0;
139950
140743
  }
139951
140744
  const expectedPath = `${collectionsDir}/${dirName}`;
140745
+ const forceCloudExport = privateMockAuth && (role === "smoke" || role === "contract");
139952
140746
  const entry = prebuiltByRole.get(role);
139953
- if (entry) {
140747
+ if (entry && !forceCloudExport) {
139954
140748
  const reused = tryReusePrebuiltCollection({
139955
140749
  prepared: entry,
139956
140750
  expectedPath,
@@ -139965,12 +140759,30 @@ async function exportCollectionArtifact(options) {
139965
140759
  core.info(
139966
140760
  `Prebuilt ${role} collection entry present but did not exactly match; exporting from cloud`
139967
140761
  );
140762
+ } else if (entry && forceCloudExport) {
140763
+ core.info(
140764
+ `Private mock requires cloud export for ${role} collection to reconcile managed root hook; exporting from cloud`
140765
+ );
139968
140766
  }
139969
- const col = await postman.getCollection(collectionId);
139970
- await convertAndSplitAnyCollection(
139971
- col,
139972
- expectedPath
139973
- );
140767
+ let collectionForExport;
140768
+ if (forceCloudExport && preparedCloudCollection) {
140769
+ collectionForExport = preparedCloudCollection;
140770
+ } else if (forceCloudExport) {
140771
+ const col = await postman.getCollection(collectionId);
140772
+ const { collection } = applyPrivateMockExportCleanup(col, {
140773
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
140774
+ });
140775
+ if (!verifyPrivateMockRootHook(collection)) {
140776
+ throw new Error(
140777
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
140778
+ );
140779
+ }
140780
+ collectionForExport = collection;
140781
+ } else {
140782
+ const col = await postman.getCollection(collectionId);
140783
+ collectionForExport = col;
140784
+ }
140785
+ await convertAndSplitAnyCollection(collectionForExport, expectedPath);
139974
140786
  return `../${expectedPath}`;
139975
140787
  }
139976
140788
  function hasControlCharacter2(value) {
@@ -140023,32 +140835,37 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140023
140835
  const globalsDir = `${inputs.artifactDir}/globals`;
140024
140836
  const mocksDir = `${inputs.artifactDir}/mocks`;
140025
140837
  const specsDir = `${inputs.artifactDir}/specs`;
140026
- ensureDir(collectionsDir);
140027
- ensureDir(environmentsDir);
140028
- ensureDir(flowsDir);
140029
- ensureDir(globalsDir);
140030
- ensureDir(mocksDir);
140031
- ensureDir(specsDir);
140032
- ensureDir(".postman");
140033
- const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
140034
- if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
140035
- (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
140036
- }
140037
- if (inputs.generateCiWorkflow) {
140038
- const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
140039
- if (ciDir) {
140040
- ensureDir(ciDir);
140041
- }
140042
- }
140043
140838
  const manifestCollections = {};
140044
- const discoveredSpecs = scanLocalSpecReferences();
140045
- const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
140839
+ const artifactDirPrefix = canonicalizeRelativePath(inputs.artifactDir);
140840
+ const { discoveredSpecs, mappedSpec } = resolveLocalSpecReferences(inputs.specPath, ".", {
140841
+ ignoredPrefixes: artifactDirPrefix ? [artifactDirPrefix, ".postman"] : [".postman"]
140842
+ });
140046
140843
  const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
140047
140844
  mappedSpec.configRelativePath,
140048
140845
  inputs.specSyncMode,
140049
140846
  options.releaseLabel
140050
140847
  ) : void 0;
140051
140848
  const prebuiltByRole = options.preparedPrebuiltCollections;
140849
+ const privateMockAuth = options.privateMockAuth === true;
140850
+ const preparedPrivateMockCollections = /* @__PURE__ */ new Map();
140851
+ if (privateMockAuth) {
140852
+ for (const spec of [
140853
+ { role: "smoke", collectionId: inputs.smokeCollectionId },
140854
+ { role: "contract", collectionId: inputs.contractCollectionId }
140855
+ ]) {
140856
+ if (!spec.collectionId) {
140857
+ continue;
140858
+ }
140859
+ preparedPrivateMockCollections.set(
140860
+ spec.role,
140861
+ await preparePrivateMockCloudCollection(
140862
+ spec.role,
140863
+ spec.collectionId,
140864
+ dependencies.postman
140865
+ )
140866
+ );
140867
+ }
140868
+ }
140052
140869
  const baselineRef = await exportCollectionArtifact({
140053
140870
  role: "baseline",
140054
140871
  collectionId: inputs.baselineCollectionId,
@@ -140056,7 +140873,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140056
140873
  collectionsDir,
140057
140874
  prebuiltByRole,
140058
140875
  postman: dependencies.postman,
140059
- core: dependencies.core
140876
+ core: dependencies.core,
140877
+ privateMockAuth
140060
140878
  });
140061
140879
  if (baselineRef) {
140062
140880
  manifestCollections[baselineRef] = inputs.baselineCollectionId;
@@ -140068,7 +140886,9 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140068
140886
  collectionsDir,
140069
140887
  prebuiltByRole,
140070
140888
  postman: dependencies.postman,
140071
- core: dependencies.core
140889
+ core: dependencies.core,
140890
+ privateMockAuth,
140891
+ preparedCloudCollection: preparedPrivateMockCollections.get("smoke")
140072
140892
  });
140073
140893
  if (smokeRef) {
140074
140894
  manifestCollections[smokeRef] = inputs.smokeCollectionId;
@@ -140080,11 +140900,30 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140080
140900
  collectionsDir,
140081
140901
  prebuiltByRole,
140082
140902
  postman: dependencies.postman,
140083
- core: dependencies.core
140903
+ core: dependencies.core,
140904
+ privateMockAuth,
140905
+ preparedCloudCollection: preparedPrivateMockCollections.get("contract")
140084
140906
  });
140085
140907
  if (contractRef) {
140086
140908
  manifestCollections[contractRef] = inputs.contractCollectionId;
140087
140909
  }
140910
+ ensureDir(collectionsDir);
140911
+ ensureDir(environmentsDir);
140912
+ ensureDir(flowsDir);
140913
+ ensureDir(globalsDir);
140914
+ ensureDir(mocksDir);
140915
+ ensureDir(specsDir);
140916
+ ensureDir(".postman");
140917
+ const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
140918
+ if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
140919
+ (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
140920
+ }
140921
+ if (inputs.generateCiWorkflow) {
140922
+ const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
140923
+ if (ciDir) {
140924
+ ensureDir(ciDir);
140925
+ }
140926
+ }
140088
140927
  for (const [envName, envUid] of Object.entries(envUids)) {
140089
140928
  writeJsonFile(
140090
140929
  `${environmentsDir}/${envName}.postman_environment.json`,
@@ -140237,19 +141076,41 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
140237
141076
  async function runRepoSync(inputs, dependencies) {
140238
141077
  const telemetry = createTelemetryContext({ action: "postman-repo-sync-action", actionVersion: resolveActionVersion2(), logger: dependencies.core });
140239
141078
  telemetry.setTeamId(dependencies.teamId);
141079
+ const logger = resolveRepoSyncLogger(dependencies);
141080
+ for (const secret of [
141081
+ inputs.postmanApiKey,
141082
+ inputs.postmanAccessToken,
141083
+ inputs.adoToken,
141084
+ inputs.githubToken,
141085
+ inputs.ghFallbackToken,
141086
+ inputs.sslClientCert,
141087
+ inputs.sslClientKey,
141088
+ inputs.sslClientPassphrase,
141089
+ inputs.sslExtraCaCerts
141090
+ ]) {
141091
+ logger.addSecret(secret);
141092
+ }
141093
+ logger.debug("resolved inputs", {
141094
+ project: inputs.projectName,
141095
+ collection_sync_mode: inputs.collectionSyncMode,
141096
+ spec_sync_mode: inputs.specSyncMode,
141097
+ team_id: dependencies.teamId || void 0
141098
+ });
140240
141099
  try {
140241
- const result = await runRepoSyncInner(inputs, dependencies);
141100
+ const result = await runRepoSyncInner(inputs, { ...dependencies, logger });
140242
141101
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
140243
141102
  telemetry.emitCompletion("success");
140244
141103
  return result;
140245
141104
  } catch (error2) {
140246
141105
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
140247
141106
  telemetry.emitCompletion("failure");
141107
+ logger.failure("repo sync failed", error2);
140248
141108
  throw error2;
140249
141109
  }
140250
141110
  }
140251
141111
  async function runRepoSyncInner(inputs, dependencies) {
140252
141112
  const mask = resolveRepoSyncMasker(dependencies);
141113
+ const logger = resolveRepoSyncLogger(dependencies);
140253
141114
  const branchDecision = decideBranchTier(inputs);
140254
141115
  assertBranchAssetIds(inputs, branchDecision);
140255
141116
  const isCanonicalWriter = branchDecision.tier === "legacy" || branchDecision.tier === "canonical";
@@ -140309,7 +141170,10 @@ async function runRepoSyncInner(inputs, dependencies) {
140309
141170
  }
140310
141171
  }
140311
141172
  }
140312
- const preparedPrebuiltCollections = await preparePrebuiltCollections(inputs);
141173
+ const preparedPrebuiltCollections = await logger.phase(
141174
+ "prepare-collections",
141175
+ async () => preparePrebuiltCollections(inputs)
141176
+ );
140313
141177
  let skipRepositoryLinkPost = false;
140314
141178
  let repositoryLinkPreflightWasFree = false;
140315
141179
  if (inputs.workspaceLinkEnabled && inputs.workspaceId && inputs.repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
@@ -140344,7 +141208,10 @@ async function runRepoSyncInner(inputs, dependencies) {
140344
141208
  }
140345
141209
  }
140346
141210
  const branchAssetMarker = buildBranchAssetMarker(branchDecision, inputs);
140347
- const envUids = await upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker);
141211
+ const envUids = await logger.phase(
141212
+ "sync-environments",
141213
+ async () => upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker)
141214
+ );
140348
141215
  outputs["environment-uids-json"] = JSON.stringify(envUids);
140349
141216
  dependencies.core.setOutput("environment-uids-json", outputs["environment-uids-json"]);
140350
141217
  if (inputs.environmentSyncEnabled && inputs.workspaceId && dependencies.internalIntegration) {
@@ -140507,10 +141374,21 @@ async function runRepoSyncInner(inputs, dependencies) {
140507
141374
  );
140508
141375
  }
140509
141376
  const configured = [];
140510
- for (const collectionUid of [inputs.smokeCollectionId, inputs.contractCollectionId]) {
140511
- if (collectionUid) {
141377
+ for (const { role, collectionUid } of [
141378
+ { role: "smoke", collectionUid: inputs.smokeCollectionId },
141379
+ { role: "contract", collectionUid: inputs.contractCollectionId }
141380
+ ]) {
141381
+ if (!collectionUid) {
141382
+ continue;
141383
+ }
141384
+ try {
140512
141385
  await dependencies.postman.configurePrivateMockRuntimeAuth(collectionUid);
140513
141386
  configured.push(collectionUid);
141387
+ } catch (error2) {
141388
+ throw new Error(
141389
+ `PRIVATE_MOCK_AUTH_ROOT_PATCH: Failed to install managed root hook on ${role} collection ${collectionUid}: ${mask(causeText(error2))}`,
141390
+ { cause: error2 }
141391
+ );
140514
141392
  }
140515
141393
  }
140516
141394
  if (configured.length > 0) {
@@ -140662,16 +141540,23 @@ async function runRepoSyncInner(inputs, dependencies) {
140662
141540
  dependencies.core.warning(message);
140663
141541
  }
140664
141542
  }
140665
- await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
140666
- workspaceLinkStatus: outputs["workspace-link-status"],
140667
- priorWorkspaceId: resourcesState?.workspace?.id,
140668
- existingSpecs: resourcesState?.cloudResources?.specs,
140669
- mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
140670
- releaseLabel,
140671
- priorState: resourcesState,
140672
- preparedPrebuiltCollections
140673
- });
140674
- const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
141543
+ await logger.phase(
141544
+ "export-artifacts",
141545
+ async () => exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
141546
+ workspaceLinkStatus: outputs["workspace-link-status"],
141547
+ priorWorkspaceId: resourcesState?.workspace?.id,
141548
+ existingSpecs: resourcesState?.cloudResources?.specs,
141549
+ mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
141550
+ releaseLabel,
141551
+ priorState: resourcesState,
141552
+ preparedPrebuiltCollections,
141553
+ privateMockAuth: inputs.mockVisibility === "private"
141554
+ })
141555
+ );
141556
+ const commit = await logger.phase(
141557
+ "commit-and-push",
141558
+ async () => commitAndPushGeneratedFiles(inputs, dependencies)
141559
+ );
140675
141560
  outputs["commit-sha"] = commit.commitSha;
140676
141561
  if (commit.resolvedCurrentRef) {
140677
141562
  outputs["resolved-current-ref"] = commit.resolvedCurrentRef;