@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/index.cjs CHANGED
@@ -42721,14 +42721,14 @@ var require_description = __commonJS({
42721
42721
  var z = __importStar(require_mini());
42722
42722
  var metadata_1 = require_metadata();
42723
42723
  var MAX_CONTENT_LENGTH = 1e6;
42724
- function truncate2(value) {
42724
+ function truncate3(value) {
42725
42725
  return value.length > MAX_CONTENT_LENGTH ? value.slice(0, MAX_CONTENT_LENGTH) : value;
42726
42726
  }
42727
42727
  exports2.Description = (0, schemas_1.model)(z.union([
42728
- z.pipe(z.string(), z.transform(truncate2)),
42728
+ z.pipe(z.string(), z.transform(truncate3)),
42729
42729
  z.null(),
42730
42730
  z.object({
42731
- content: z.pipe(z.optional(z.string()), z.transform((value) => truncate2(value ?? ""))),
42731
+ content: z.pipe(z.optional(z.string()), z.transform((value) => truncate3(value ?? ""))),
42732
42732
  type: z.optional(z.string()),
42733
42733
  version: z.optional(z.unknown())
42734
42734
  })
@@ -57954,7 +57954,7 @@ var require_lodash = __commonJS({
57954
57954
  var strSymbols = stringToArray(string), start = charsStartIndex(strSymbols, stringToArray(chars));
57955
57955
  return castSlice(strSymbols, start).join("");
57956
57956
  }
57957
- function truncate2(string, options) {
57957
+ function truncate3(string, options) {
57958
57958
  var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
57959
57959
  if (isObject(options)) {
57960
57960
  var separator = "separator" in options ? options.separator : separator;
@@ -58514,7 +58514,7 @@ var require_lodash = __commonJS({
58514
58514
  lodash.trim = trim;
58515
58515
  lodash.trimEnd = trimEnd;
58516
58516
  lodash.trimStart = trimStart;
58517
- lodash.truncate = truncate2;
58517
+ lodash.truncate = truncate3;
58518
58518
  lodash.unescape = unescape2;
58519
58519
  lodash.uniqueId = uniqueId;
58520
58520
  lodash.upperCase = upperCase;
@@ -95745,10 +95745,10 @@ var require_unicode = __commonJS({
95745
95745
  module2.exports.isLineTerminatorJSON = function isLineTerminatorJSON(x) {
95746
95746
  return x === "\n" || x === "\r";
95747
95747
  };
95748
- module2.exports.isIdentifierStart = function isIdentifierStart(x) {
95748
+ module2.exports.isIdentifierStart = function isIdentifierStart2(x) {
95749
95749
  return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "\x80" && Uni.NonAsciiIdentifierStart.test(x);
95750
95750
  };
95751
- module2.exports.isIdentifierPart = function isIdentifierPart(x) {
95751
+ module2.exports.isIdentifierPart = function isIdentifierPart2(x) {
95752
95752
  return x === "$" || x === "_" || x >= "A" && x <= "Z" || x >= "a" && x <= "z" || x >= "0" && x <= "9" || x >= "\x80" && Uni.NonAsciiIdentifierPart.test(x);
95753
95753
  };
95754
95754
  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]/;
@@ -118662,7 +118662,7 @@ var require_truncate = __commonJS({
118662
118662
  function isLowSurrogate(codePoint) {
118663
118663
  return codePoint >= 56320 && codePoint <= 57343;
118664
118664
  }
118665
- module2.exports = function truncate2(getLength, string, byteLength) {
118665
+ module2.exports = function truncate3(getLength, string, byteLength) {
118666
118666
  if (typeof string !== "string") {
118667
118667
  throw new Error("Input must be string");
118668
118668
  }
@@ -118693,9 +118693,9 @@ var require_truncate = __commonJS({
118693
118693
  var require_truncate_utf8_bytes = __commonJS({
118694
118694
  "node_modules/truncate-utf8-bytes/index.js"(exports2, module2) {
118695
118695
  "use strict";
118696
- var truncate2 = require_truncate();
118696
+ var truncate3 = require_truncate();
118697
118697
  var getLength = Buffer.byteLength.bind(Buffer);
118698
- module2.exports = truncate2.bind(null, getLength);
118698
+ module2.exports = truncate3.bind(null, getLength);
118699
118699
  }
118700
118700
  });
118701
118701
 
@@ -128807,6 +128807,7 @@ var require_node2 = __commonJS({
128807
128807
  // src/index.ts
128808
128808
  var index_exports = {};
128809
128809
  __export(index_exports, {
128810
+ LocalSpecDiscoveryLimitError: () => LocalSpecDiscoveryLimitError,
128810
128811
  StateUnreadableError: () => StateUnreadableError,
128811
128812
  assertBranchAssetIds: () => assertBranchAssetIds,
128812
128813
  assertPathWithinCwd: () => assertPathWithinCwd,
@@ -134331,7 +134332,9 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
134331
134332
  ` POSTMAN_CLI_INSTALL_URL: ${installUrl}`,
134332
134333
  ' run: curl -fsSL "$POSTMAN_CLI_INSTALL_URL" | sh',
134333
134334
  " - name: Login to Postman CLI",
134334
- " run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}" + (postmanRegion === "eu" ? " --region eu" : ""),
134335
+ " env:",
134336
+ " POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}",
134337
+ ' run: postman login --with-api-key "$POSTMAN_API_KEY"' + (postmanRegion === "eu" ? " --region eu" : ""),
134335
134338
  " - name: Resolve Postman Resource IDs",
134336
134339
  " run: |",
134337
134340
  " ruby <<'RUBY'",
@@ -134370,12 +134373,13 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
134370
134373
  " - name: Run Smoke Tests",
134371
134374
  " env:",
134372
134375
  " POSTMAN_SSL_CLIENT_PASSPHRASE: ${{ secrets.POSTMAN_SSL_CLIENT_PASSPHRASE }}",
134376
+ ...privateMockAuth ? [" POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}"] : [],
134373
134377
  " run: |",
134374
134378
  ' CMD=(postman collection run "$POSTMAN_SMOKE_COLLECTION_UID"',
134375
134379
  ' -e "$POSTMAN_ENVIRONMENT_UID"',
134376
134380
  " --report-events",
134377
134381
  ` --env-var "CI_ENVIRONMENT=\${{ vars.CI_ENVIRONMENT || 'Production' }}")`,
134378
- ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=${{ secrets.POSTMAN_API_KEY }}")'] : [],
134382
+ ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=$POSTMAN_API_KEY")'] : [],
134379
134383
  ' if [ -f "$RUNNER_TEMP/postman-ssl/client.crt" ]; then',
134380
134384
  ' CMD+=(--ssl-client-cert "$RUNNER_TEMP/postman-ssl/client.crt"',
134381
134385
  ' --ssl-client-key "$RUNNER_TEMP/postman-ssl/client.key")',
@@ -134390,12 +134394,13 @@ function buildCiWorkflowLines(installUrl, postmanRegion, privateMockAuth) {
134390
134394
  " - name: Run Contract Tests",
134391
134395
  " env:",
134392
134396
  " POSTMAN_SSL_CLIENT_PASSPHRASE: ${{ secrets.POSTMAN_SSL_CLIENT_PASSPHRASE }}",
134397
+ ...privateMockAuth ? [" POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}"] : [],
134393
134398
  " run: |",
134394
134399
  ' CMD=(postman collection run "$POSTMAN_CONTRACT_COLLECTION_UID"',
134395
134400
  ' -e "$POSTMAN_ENVIRONMENT_UID"',
134396
134401
  " --report-events",
134397
134402
  ` --env-var "CI_ENVIRONMENT=\${{ vars.CI_ENVIRONMENT || 'Production' }}")`,
134398
- ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=${{ secrets.POSTMAN_API_KEY }}")'] : [],
134403
+ ...privateMockAuth ? [' CMD+=(--env-var "' + PRIVATE_MOCK_AUTH_VARIABLE + '=$POSTMAN_API_KEY")'] : [],
134399
134404
  ' if [ -f "$RUNNER_TEMP/postman-ssl/client.crt" ]; then',
134400
134405
  ' CMD+=(--ssl-client-cert "$RUNNER_TEMP/postman-ssl/client.crt"',
134401
134406
  ' --ssl-client-key "$RUNNER_TEMP/postman-ssl/client.key")',
@@ -134422,7 +134427,9 @@ function buildAdoWindowsCollectionRunLines(displayName, collectionEnvironmentNam
134422
134427
  ` $collectionUid = $env:${collectionEnvironmentName}`,
134423
134428
  " $ciEnvironment = Resolve-AdoOptional $env:CI_ENVIRONMENT",
134424
134429
  " if ([string]::IsNullOrWhiteSpace($ciEnvironment)) { $ciEnvironment = 'Production' }",
134425
- ` $arguments = @('collection', 'run', $collectionUid, '-e', $env:POSTMAN_ENVIRONMENT_UID, '--report-events', '--env-var', "CI_ENVIRONMENT=$ciEnvironment")`,
134430
+ " $responseTimeThreshold = Resolve-AdoOptional $env:RESPONSE_TIME_THRESHOLD",
134431
+ " if ([string]::IsNullOrWhiteSpace($responseTimeThreshold)) { $responseTimeThreshold = '10000' }",
134432
+ ` $arguments = @('collection', 'run', $collectionUid, '-e', $env:POSTMAN_ENVIRONMENT_UID, '--report-events', '--env-var', "CI_ENVIRONMENT=$ciEnvironment", '--env-var', "RESPONSE_TIME_THRESHOLD=$responseTimeThreshold")`,
134426
134433
  ...privateMockAuth ? [` $arguments += @('--env-var', "${PRIVATE_MOCK_AUTH_VARIABLE}=$env:POSTMAN_API_KEY")`] : [],
134427
134434
  " $sslRoot = Join-Path $env:AGENT_TEMPDIRECTORY 'postman-ssl'",
134428
134435
  " $clientCert = Join-Path $sslRoot 'client.crt'",
@@ -134445,6 +134452,7 @@ function buildAdoWindowsCollectionRunLines(displayName, collectionEnvironmentNam
134445
134452
  ` ${collectionEnvironmentName}: $(${collectionEnvironmentName})`,
134446
134453
  " POSTMAN_ENVIRONMENT_UID: $(POSTMAN_ENVIRONMENT_UID)",
134447
134454
  " CI_ENVIRONMENT: $(CI_ENVIRONMENT)",
134455
+ " RESPONSE_TIME_THRESHOLD: $(RESPONSE_TIME_THRESHOLD)",
134448
134456
  " POSTMAN_SSL_CLIENT_PASSPHRASE: $(POSTMAN_SSL_CLIENT_PASSPHRASE)",
134449
134457
  ...privateMockAuth ? [" POSTMAN_API_KEY: $(POSTMAN_API_KEY)"] : []
134450
134458
  ];
@@ -135214,7 +135222,7 @@ function detectRepoContext(input, env = process.env) {
135214
135222
  };
135215
135223
  }
135216
135224
 
135217
- // node_modules/@postman-cse/automation-telemetry-core/dist/ci-context.js
135225
+ // node_modules/@postman-cse/automation-core/dist/ci-context.js
135218
135226
  function norm(value) {
135219
135227
  const trimmed = (value ?? "").trim();
135220
135228
  return trimmed.length > 0 ? trimmed : void 0;
@@ -135365,7 +135373,7 @@ function detectCiProviderContext(env = process.env) {
135365
135373
  return { ciProvider: "unknown", runnerKind: "unknown" };
135366
135374
  }
135367
135375
 
135368
- // node_modules/@postman-cse/automation-telemetry-core/dist/repo-context.js
135376
+ // node_modules/@postman-cse/automation-core/dist/repo-context.js
135369
135377
  function normalize2(value) {
135370
135378
  const trimmed = (value ?? "").trim();
135371
135379
  return trimmed.length > 0 ? trimmed : void 0;
@@ -135454,7 +135462,7 @@ function detectRepoContext2(input, env = process.env) {
135454
135462
  };
135455
135463
  }
135456
135464
 
135457
- // node_modules/@postman-cse/automation-telemetry-core/dist/telemetry.js
135465
+ // node_modules/@postman-cse/automation-core/dist/telemetry.js
135458
135466
  var import_node_crypto = require("node:crypto");
135459
135467
  var import_undici2 = __toESM(require_undici(), 1);
135460
135468
  var SCHEMA_VERSION = 3;
@@ -135464,10 +135472,14 @@ var proxyDispatcher;
135464
135472
  function getProxyDispatcher() {
135465
135473
  return proxyDispatcher ??= new import_undici2.EnvHttpProxyAgent();
135466
135474
  }
135467
- function resolveActionVersion(explicit) {
135475
+ function resolveActionVersion(explicit, env = process.env) {
135468
135476
  if (explicit) {
135469
135477
  return explicit;
135470
135478
  }
135479
+ const ref = env.GITHUB_ACTION_REF?.trim();
135480
+ if (ref) {
135481
+ return ref;
135482
+ }
135471
135483
  return typeof __ACTION_VERSION__ !== "undefined" && __ACTION_VERSION__ ? __ACTION_VERSION__ : "unknown";
135472
135484
  }
135473
135485
  function telemetryDisabled(env) {
@@ -135550,7 +135562,7 @@ async function send(event, options) {
135550
135562
  function createTelemetryContext(options) {
135551
135563
  const env = options.env ?? process.env;
135552
135564
  const now = options.now ?? Date.now;
135553
- const actionVersion = resolveActionVersion(options.actionVersion);
135565
+ const actionVersion = resolveActionVersion(options.actionVersion, env);
135554
135566
  let teamId = "";
135555
135567
  let accountType = "unknown";
135556
135568
  let emitted = false;
@@ -135590,6 +135602,186 @@ function createTelemetryContext(options) {
135590
135602
  };
135591
135603
  }
135592
135604
 
135605
+ // node_modules/@postman-cse/automation-core/dist/logger.js
135606
+ var LEVEL_ORDER = {
135607
+ debug: 10,
135608
+ info: 20,
135609
+ warning: 30,
135610
+ error: 40
135611
+ };
135612
+ function defaultCorrelationId() {
135613
+ return Math.random().toString(36).slice(2, 10);
135614
+ }
135615
+ function resolveLogLevel(env = process.env) {
135616
+ const explicit = String(env.POSTMAN_ACTIONS_LOG_LEVEL ?? "").trim().toLowerCase();
135617
+ if (explicit === "debug" || explicit === "trace" || explicit === "verbose")
135618
+ return "debug";
135619
+ if (explicit === "info")
135620
+ return "info";
135621
+ if (explicit === "warn" || explicit === "warning")
135622
+ return "warning";
135623
+ if (explicit === "error" || explicit === "quiet")
135624
+ return "error";
135625
+ if (isTruthyFlag(env.RUNNER_DEBUG) || isTruthyFlag(env.ACTIONS_STEP_DEBUG))
135626
+ return "debug";
135627
+ if (isTruthyFlag(env.POSTMAN_ACTIONS_DEBUG))
135628
+ return "debug";
135629
+ return "info";
135630
+ }
135631
+ function isTruthyFlag(value) {
135632
+ if (!value)
135633
+ return false;
135634
+ const flag = value.trim().toLowerCase();
135635
+ return flag === "1" || flag === "true" || flag === "yes" || flag === "on";
135636
+ }
135637
+ function actionSink(core) {
135638
+ return {
135639
+ debug: (message) => core.debug?.(message),
135640
+ info: (message) => core.info(message),
135641
+ warning: (message) => (core.warning ?? core.info)(message),
135642
+ error: (message) => (core.error ?? core.warning ?? core.info)(message),
135643
+ startGroup: core.startGroup ? (name) => core.startGroup?.(name) : void 0,
135644
+ endGroup: core.endGroup ? () => core.endGroup?.() : void 0,
135645
+ isDebug: core.isDebug ? () => core.isDebug?.() ?? false : void 0
135646
+ };
135647
+ }
135648
+ var MIN_SECRET_LENGTH = 4;
135649
+ function renderValue(value, maxLength = 512) {
135650
+ if (value === void 0)
135651
+ return "undefined";
135652
+ if (value === null)
135653
+ return "null";
135654
+ if (typeof value === "string")
135655
+ return truncate(value, maxLength);
135656
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
135657
+ return String(value);
135658
+ }
135659
+ if (value instanceof Error)
135660
+ return truncate(describeError(value), maxLength);
135661
+ if (Array.isArray(value)) {
135662
+ return truncate(`[${value.map((entry) => renderValue(entry, 120)).join(", ")}]`, maxLength);
135663
+ }
135664
+ try {
135665
+ return truncate(JSON.stringify(value) ?? String(value), maxLength);
135666
+ } catch {
135667
+ return "<unserializable>";
135668
+ }
135669
+ }
135670
+ function truncate(text, maxLength) {
135671
+ if (text.length <= maxLength)
135672
+ return text;
135673
+ return `${text.slice(0, maxLength)}\u2026 (+${text.length - maxLength} chars)`;
135674
+ }
135675
+ function describeError(error2, maxDepth = 5) {
135676
+ const parts = [];
135677
+ let current = error2;
135678
+ let depth = 0;
135679
+ while (current !== void 0 && current !== null && depth < maxDepth) {
135680
+ if (current instanceof Error) {
135681
+ const code = current.code;
135682
+ parts.push(code ? `${current.name}[${code}]: ${current.message}` : `${current.name}: ${current.message}`);
135683
+ current = current.cause;
135684
+ } else if (typeof current === "object") {
135685
+ try {
135686
+ parts.push(JSON.stringify(current) ?? String(current));
135687
+ } catch {
135688
+ parts.push(String(current));
135689
+ }
135690
+ current = void 0;
135691
+ } else {
135692
+ parts.push(String(current));
135693
+ current = void 0;
135694
+ }
135695
+ depth += 1;
135696
+ }
135697
+ if (parts.length === 0)
135698
+ return "unknown error";
135699
+ return parts.join(" <- caused by ");
135700
+ }
135701
+ function createLogger(options) {
135702
+ const env = options.env ?? process.env;
135703
+ const level = options.level ?? resolveLogLevel(env);
135704
+ const secrets = options.secrets ?? /* @__PURE__ */ new Set();
135705
+ const correlationId = options.correlationId ?? defaultCorrelationId();
135706
+ const now = options.now ?? (() => Date.now());
135707
+ const threshold = LEVEL_ORDER[level];
135708
+ function addSecret(value) {
135709
+ if (typeof value !== "string")
135710
+ return;
135711
+ const trimmed = value.trim();
135712
+ if (trimmed.length < MIN_SECRET_LENGTH)
135713
+ return;
135714
+ secrets.add(trimmed);
135715
+ }
135716
+ function redact(text) {
135717
+ let output = typeof text === "string" ? text : renderValue(text, 4096);
135718
+ for (const secret of secrets) {
135719
+ if (!secret)
135720
+ continue;
135721
+ output = output.split(secret).join("***");
135722
+ const encoded = encodeURIComponent(secret);
135723
+ if (encoded !== secret)
135724
+ output = output.split(encoded).join("***");
135725
+ }
135726
+ return output;
135727
+ }
135728
+ function build2(baseFields) {
135729
+ function emit(target, message, fields) {
135730
+ if (LEVEL_ORDER[target] < threshold)
135731
+ return;
135732
+ const merged = { ...baseFields, ...fields ?? {} };
135733
+ const rendered = Object.entries(merged).filter(([, value]) => value !== void 0).map(([key, value]) => `${key}=${redact(renderValue(value))}`).join(" ");
135734
+ const line = rendered ? `${redact(message)} | ${rendered}` : redact(message);
135735
+ switch (target) {
135736
+ case "debug":
135737
+ options.sink.debug(line);
135738
+ break;
135739
+ case "info":
135740
+ options.sink.info(line);
135741
+ break;
135742
+ case "warning":
135743
+ options.sink.warning(line);
135744
+ break;
135745
+ case "error":
135746
+ options.sink.error(line);
135747
+ break;
135748
+ }
135749
+ }
135750
+ const logger = {
135751
+ level,
135752
+ correlationId,
135753
+ addSecret,
135754
+ redact,
135755
+ isDebug: () => threshold <= LEVEL_ORDER.debug,
135756
+ debug: (message, fields) => emit("debug", message, fields),
135757
+ info: (message, fields) => emit("info", message, fields),
135758
+ warning: (message, fields) => emit("warning", message, fields),
135759
+ error: (message, fields) => emit("error", message, fields),
135760
+ failure: (message, error2, fields) => emit("error", message, { ...fields ?? {}, error: describeError(error2) }),
135761
+ child: (fields) => build2({ ...baseFields, ...fields }),
135762
+ async phase(name, fn, fields) {
135763
+ const scoped = build2({ ...baseFields, ...fields ?? {}, phase: name });
135764
+ const started = now();
135765
+ scoped.debug("phase start");
135766
+ options.sink.startGroup?.(name);
135767
+ try {
135768
+ const result = await fn();
135769
+ scoped.debug("phase ok", { duration_ms: Math.round(now() - started) });
135770
+ return result;
135771
+ } catch (error2) {
135772
+ scoped.failure("phase failed", error2, { duration_ms: Math.round(now() - started) });
135773
+ throw error2;
135774
+ } finally {
135775
+ options.sink.endGroup?.();
135776
+ }
135777
+ }
135778
+ };
135779
+ return logger;
135780
+ }
135781
+ const root = build2({ run: correlationId, ...options.fields ?? {} });
135782
+ return root;
135783
+ }
135784
+
135593
135785
  // src/action-version.ts
135594
135786
  var import_node_fs3 = require("node:fs");
135595
135787
  var import_node_path2 = require("node:path");
@@ -135606,7 +135798,7 @@ function resolveActionVersion2() {
135606
135798
  }
135607
135799
 
135608
135800
  // src/lib/http-error.ts
135609
- function truncate(value, limit) {
135801
+ function truncate2(value, limit) {
135610
135802
  if (value.length <= limit) {
135611
135803
  return value;
135612
135804
  }
@@ -135616,7 +135808,7 @@ function buildMessage(init) {
135616
135808
  const method = String(init.method || "GET").toUpperCase();
135617
135809
  const status = `${init.status}${init.statusText ? ` ${init.statusText}` : ""}`;
135618
135810
  const url = redactSecrets(init.url, init.secretValues);
135619
- const body = truncate(
135811
+ const body = truncate2(
135620
135812
  redactSecrets(init.responseBody || "", init.secretValues),
135621
135813
  Math.max(0, init.bodyLimit ?? 800)
135622
135814
  );
@@ -136995,30 +137187,13 @@ var PostmanAssetsClient = class {
136995
137187
  }
136996
137188
  };
136997
137189
 
136998
- // src/lib/postman/postman-gateway-assets-client.ts
136999
- var MockContractError = class extends Error {
137000
- constructor(message) {
137001
- super(message);
137002
- this.name = "MockContractError";
137003
- }
137004
- };
137005
- function requireMockVisibility(mock, requested) {
137006
- if (mock.visibility === "unknown") {
137007
- throw new MockContractError(
137008
- `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
137009
- );
137010
- }
137011
- if (mock.visibility !== requested) {
137012
- const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
137013
- throw new MockContractError(
137014
- `${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}.`
137015
- );
137016
- }
137017
- return mock;
137018
- }
137190
+ // src/lib/postman/private-mock-auth-script.ts
137019
137191
  var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
137020
- var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
137192
+ var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
137193
+ var PRIVATE_MOCK_AUTH_V3_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
137021
137194
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
137195
+ var PRIVATE_MOCK_AUTH_ROOT_TYPE = "http:beforeRequest";
137196
+ var PRIVATE_MOCK_AUTH_ROOT_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-root`;
137022
137197
  var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137023
137198
  `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
137024
137199
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
@@ -137027,8 +137202,8 @@ var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137027
137202
  " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137028
137203
  "}"
137029
137204
  ].join("\n");
137030
- var PRIVATE_MOCK_AUTH_SCRIPT = [
137031
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137205
+ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
137206
+ `// ${PRIVATE_MOCK_AUTH_V2_MARKER}`,
137032
137207
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137033
137208
  "var privateMockHostValue = pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '';",
137034
137209
  "var privateMockHost = Array.isArray(privateMockHostValue) ? privateMockHostValue.join('.') : String(privateMockHostValue);",
@@ -137039,8 +137214,347 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
137039
137214
  ` 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.');`,
137040
137215
  "}"
137041
137216
  ].join("\n");
137042
- function removeLegacyPrivateMockAuth(code) {
137043
- return code.split(LEGACY_PRIVATE_MOCK_AUTH_SCRIPT).join("").trim();
137217
+ var PRIVATE_MOCK_AUTH_V3_SCRIPT = [
137218
+ `// ${PRIVATE_MOCK_AUTH_V3_MARKER}`,
137219
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137220
+ "var privateMockHost = '';",
137221
+ "try {",
137222
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137223
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137224
+ "} catch (error) {",
137225
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137226
+ "}",
137227
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137228
+ "if (isPrivateMockHost && privateMockApiKey) {",
137229
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137230
+ "} else if (isPrivateMockHost) {",
137231
+ ` 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.');`,
137232
+ "}"
137233
+ ].join("\n");
137234
+ var PRIVATE_MOCK_AUTH_ROOT_SCRIPT = [
137235
+ `// ${PRIVATE_MOCK_AUTH_ROOT_MARKER}`,
137236
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137237
+ "var privateMockHost = '';",
137238
+ "try {",
137239
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137240
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137241
+ "} catch (error) {",
137242
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137243
+ "}",
137244
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137245
+ "if (isPrivateMockHost && privateMockApiKey) {",
137246
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137247
+ "} else if (isPrivateMockHost) {",
137248
+ ` 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.');`,
137249
+ "}"
137250
+ ].join("\n");
137251
+ var MANAGED_ITEM_AUTH_BLOCKS = [
137252
+ LEGACY_PRIVATE_MOCK_AUTH_SCRIPT,
137253
+ PRIVATE_MOCK_AUTH_V2_SCRIPT,
137254
+ PRIVATE_MOCK_AUTH_V3_SCRIPT
137255
+ ];
137256
+ function isManagedPrivateMockAuthRootHook(script) {
137257
+ return String(script.type ?? "") === PRIVATE_MOCK_AUTH_ROOT_TYPE && String(script.code ?? "") === PRIVATE_MOCK_AUTH_ROOT_SCRIPT;
137258
+ }
137259
+ var REGEX_PREFIX_KEYWORDS = /* @__PURE__ */ new Set([
137260
+ "await",
137261
+ "case",
137262
+ "delete",
137263
+ "do",
137264
+ "else",
137265
+ "in",
137266
+ "instanceof",
137267
+ "of",
137268
+ "return",
137269
+ "throw",
137270
+ "typeof",
137271
+ "void",
137272
+ "yield"
137273
+ ]);
137274
+ function isIdentifierStart(ch) {
137275
+ return ch !== void 0 && /[A-Za-z_$]/.test(ch);
137276
+ }
137277
+ function isIdentifierPart(ch) {
137278
+ return ch !== void 0 && /[A-Za-z0-9_$]/.test(ch);
137279
+ }
137280
+ function markTopLevelScriptBytes(source) {
137281
+ const topLevel = new Uint8Array(source.length);
137282
+ let state = "script";
137283
+ let canStartRegex = true;
137284
+ let regexCharacterClass = false;
137285
+ for (let i = 0; i < source.length; i++) {
137286
+ const ch = source[i];
137287
+ const next = source[i + 1];
137288
+ if (state === "script") {
137289
+ topLevel[i] = 1;
137290
+ if (ch === "/" && next === "*") {
137291
+ topLevel[i] = 0;
137292
+ state = "block_comment";
137293
+ i++;
137294
+ topLevel[i] = 0;
137295
+ continue;
137296
+ }
137297
+ if (ch === "/" && next === "/") {
137298
+ topLevel[i + 1] = 1;
137299
+ i++;
137300
+ while (i + 1 < source.length && source[i + 1] !== "\n") {
137301
+ i++;
137302
+ topLevel[i] = 1;
137303
+ }
137304
+ continue;
137305
+ }
137306
+ if (ch === "/") {
137307
+ if (canStartRegex) {
137308
+ topLevel[i] = 0;
137309
+ state = "regex";
137310
+ regexCharacterClass = false;
137311
+ continue;
137312
+ }
137313
+ canStartRegex = true;
137314
+ if (next === "=") {
137315
+ i++;
137316
+ topLevel[i] = 1;
137317
+ }
137318
+ continue;
137319
+ }
137320
+ if (ch === "'") {
137321
+ state = "single";
137322
+ topLevel[i] = 0;
137323
+ continue;
137324
+ }
137325
+ if (ch === '"') {
137326
+ state = "double";
137327
+ topLevel[i] = 0;
137328
+ continue;
137329
+ }
137330
+ if (ch === "`") {
137331
+ state = "template";
137332
+ topLevel[i] = 0;
137333
+ continue;
137334
+ }
137335
+ if (/\s/.test(ch)) {
137336
+ continue;
137337
+ }
137338
+ if (isIdentifierStart(ch)) {
137339
+ let end = i + 1;
137340
+ while (isIdentifierPart(source[end])) {
137341
+ topLevel[end] = 1;
137342
+ end++;
137343
+ }
137344
+ canStartRegex = REGEX_PREFIX_KEYWORDS.has(source.slice(i, end));
137345
+ i = end - 1;
137346
+ continue;
137347
+ }
137348
+ if (/[0-9]/.test(ch)) {
137349
+ let end = i + 1;
137350
+ while (/[A-Za-z0-9_.]/.test(source[end] ?? "")) {
137351
+ topLevel[end] = 1;
137352
+ end++;
137353
+ }
137354
+ canStartRegex = false;
137355
+ i = end - 1;
137356
+ continue;
137357
+ }
137358
+ if ((ch === "+" || ch === "-") && next === ch) {
137359
+ const wasPrefix = canStartRegex;
137360
+ i++;
137361
+ topLevel[i] = 1;
137362
+ canStartRegex = wasPrefix;
137363
+ continue;
137364
+ }
137365
+ if (ch === "?" && next === ".") {
137366
+ i++;
137367
+ topLevel[i] = 1;
137368
+ canStartRegex = false;
137369
+ continue;
137370
+ }
137371
+ if (")]}".includes(ch) || ch === ".") {
137372
+ canStartRegex = false;
137373
+ continue;
137374
+ }
137375
+ if ("([{,;:=!~*%&|^<>+-?".includes(ch)) {
137376
+ canStartRegex = true;
137377
+ continue;
137378
+ }
137379
+ canStartRegex = false;
137380
+ continue;
137381
+ }
137382
+ if (state === "block_comment") {
137383
+ topLevel[i] = 0;
137384
+ if (ch === "*" && next === "/") {
137385
+ topLevel[i] = 0;
137386
+ i++;
137387
+ topLevel[i] = 0;
137388
+ state = "script";
137389
+ }
137390
+ continue;
137391
+ }
137392
+ if (state === "single") {
137393
+ topLevel[i] = 0;
137394
+ if (ch === "\\" && i + 1 < source.length) {
137395
+ i++;
137396
+ topLevel[i] = 0;
137397
+ continue;
137398
+ }
137399
+ if (ch === "'") {
137400
+ state = "script";
137401
+ canStartRegex = false;
137402
+ }
137403
+ continue;
137404
+ }
137405
+ if (state === "double") {
137406
+ topLevel[i] = 0;
137407
+ if (ch === "\\" && i + 1 < source.length) {
137408
+ i++;
137409
+ topLevel[i] = 0;
137410
+ continue;
137411
+ }
137412
+ if (ch === '"') {
137413
+ state = "script";
137414
+ canStartRegex = false;
137415
+ }
137416
+ continue;
137417
+ }
137418
+ if (state === "regex") {
137419
+ topLevel[i] = 0;
137420
+ if (ch === "\\" && i + 1 < source.length) {
137421
+ i++;
137422
+ topLevel[i] = 0;
137423
+ continue;
137424
+ }
137425
+ if (ch === "\n" || ch === "\r") {
137426
+ state = "script";
137427
+ canStartRegex = true;
137428
+ regexCharacterClass = false;
137429
+ continue;
137430
+ }
137431
+ if (ch === "[") {
137432
+ regexCharacterClass = true;
137433
+ continue;
137434
+ }
137435
+ if (ch === "]" && regexCharacterClass) {
137436
+ regexCharacterClass = false;
137437
+ continue;
137438
+ }
137439
+ if (ch === "/" && !regexCharacterClass) {
137440
+ while (isIdentifierPart(source[i + 1])) {
137441
+ i++;
137442
+ topLevel[i] = 0;
137443
+ }
137444
+ state = "script";
137445
+ canStartRegex = false;
137446
+ }
137447
+ continue;
137448
+ }
137449
+ topLevel[i] = 0;
137450
+ if (ch === "\\" && i + 1 < source.length) {
137451
+ i++;
137452
+ topLevel[i] = 0;
137453
+ continue;
137454
+ }
137455
+ if (ch === "`") {
137456
+ state = "script";
137457
+ canStartRegex = false;
137458
+ }
137459
+ }
137460
+ return topLevel;
137461
+ }
137462
+ function isWholeLineTopLevelMatch(source, startIndex, block, topLevel) {
137463
+ if (!source.startsWith(block, startIndex)) {
137464
+ return false;
137465
+ }
137466
+ if (startIndex > 0 && source[startIndex - 1] !== "\n") {
137467
+ return false;
137468
+ }
137469
+ const endIndex = startIndex + block.length;
137470
+ for (let lineStart = startIndex; lineStart < endIndex; ) {
137471
+ if (!topLevel[lineStart]) {
137472
+ return false;
137473
+ }
137474
+ const nextNewline = source.indexOf("\n", lineStart);
137475
+ if (nextNewline === -1 || nextNewline >= endIndex - 1) {
137476
+ break;
137477
+ }
137478
+ lineStart = nextNewline + 1;
137479
+ }
137480
+ return true;
137481
+ }
137482
+ function findManagedBlockRanges(source) {
137483
+ const topLevel = markTopLevelScriptBytes(source);
137484
+ const ranges = [];
137485
+ for (let i = 0; i < source.length; i++) {
137486
+ if (i > 0 && source[i - 1] !== "\n") {
137487
+ continue;
137488
+ }
137489
+ for (const block of MANAGED_ITEM_AUTH_BLOCKS) {
137490
+ if (!isWholeLineTopLevelMatch(source, i, block, topLevel)) {
137491
+ continue;
137492
+ }
137493
+ ranges.push({ start: i, end: i + block.length });
137494
+ break;
137495
+ }
137496
+ }
137497
+ return ranges;
137498
+ }
137499
+ function countManagedItemAuthBlocks(code) {
137500
+ if (typeof code !== "string" || !code) {
137501
+ return 0;
137502
+ }
137503
+ return findManagedBlockRanges(code).length;
137504
+ }
137505
+ function deleteRangeWithSeam(source, start, end) {
137506
+ let before = source.slice(0, start);
137507
+ let after = source.slice(end);
137508
+ const beforeHadNl = before.endsWith("\n");
137509
+ const afterHadNl = after.startsWith("\n");
137510
+ if (beforeHadNl) {
137511
+ before = before.slice(0, -1);
137512
+ }
137513
+ if (afterHadNl) {
137514
+ after = after.slice(1);
137515
+ }
137516
+ if (beforeHadNl && afterHadNl && before.length > 0 && after.length > 0) {
137517
+ return `${before}
137518
+ ${after}`;
137519
+ }
137520
+ return `${before}${after}`;
137521
+ }
137522
+ function stripManagedItemAuthBlocks(code) {
137523
+ if (typeof code !== "string" || !code) {
137524
+ return "";
137525
+ }
137526
+ const ranges = findManagedBlockRanges(code);
137527
+ if (ranges.length === 0) {
137528
+ return code;
137529
+ }
137530
+ ranges.sort((left, right) => right.start - left.start);
137531
+ let next = code;
137532
+ for (const range of ranges) {
137533
+ next = deleteRangeWithSeam(next, range.start, range.end);
137534
+ }
137535
+ return next;
137536
+ }
137537
+
137538
+ // src/lib/postman/postman-gateway-assets-client.ts
137539
+ var MockContractError = class extends Error {
137540
+ constructor(message) {
137541
+ super(message);
137542
+ this.name = "MockContractError";
137543
+ }
137544
+ };
137545
+ function requireMockVisibility(mock, requested) {
137546
+ if (mock.visibility === "unknown") {
137547
+ throw new MockContractError(
137548
+ `MOCK_VISIBILITY_UNKNOWN: Mock ${mock.uid} did not expose a supported visibility field. Refusing to assume it is callable.`
137549
+ );
137550
+ }
137551
+ if (mock.visibility !== requested) {
137552
+ const code = requested === "public" ? "MOCK_NOT_PUBLIC" : "MOCK_NOT_PRIVATE";
137553
+ throw new MockContractError(
137554
+ `${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}.`
137555
+ );
137556
+ }
137557
+ return mock;
137044
137558
  }
137045
137559
  var MAX_CREATE_FLIGHTS = 256;
137046
137560
  var createFlights = /* @__PURE__ */ new Map();
@@ -137611,51 +138125,83 @@ var PostmanGatewayAssetsClient = class {
137611
138125
  }
137612
138126
  });
137613
138127
  }
138128
+ isAmbiguousTransportError(error2) {
138129
+ return this.isRetryableIdempotentWriteOutcome(error2);
138130
+ }
138131
+ normalizeCollectionScripts(scripts) {
138132
+ if (!Array.isArray(scripts)) return [];
138133
+ return scripts.map((entry) => this.asRecord(entry)).filter((entry) => entry !== null);
138134
+ }
138135
+ rootScriptsIncludeManagedAuthHook(scripts) {
138136
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
138137
+ }
138138
+ buildPrivateMockRootScripts(existingScripts) {
138139
+ const managedScript = {
138140
+ type: PRIVATE_MOCK_AUTH_ROOT_TYPE,
138141
+ code: PRIVATE_MOCK_AUTH_ROOT_SCRIPT,
138142
+ language: "text/javascript"
138143
+ };
138144
+ return [...existingScripts, managedScript];
138145
+ }
138146
+ async readCollectionRootScripts(collectionUid) {
138147
+ const id = this.toModelId(collectionUid);
138148
+ const response = await this.gateway.requestJson({
138149
+ service: "collection",
138150
+ method: "get",
138151
+ path: `/v3/collections/${id}/export`
138152
+ });
138153
+ const data = this.asRecord(response?.data);
138154
+ const collection = this.asRecord(data?.collection);
138155
+ if (!collection) {
138156
+ throw new Error(
138157
+ `PRIVATE_MOCK_AUTH_EXPORT_INVALID: Collection ${id} export did not return data.collection; refusing to configure private-mock root auth from an unexpected envelope.`
138158
+ );
138159
+ }
138160
+ return this.normalizeCollectionScripts(collection.scripts);
138161
+ }
138162
+ async patchCollectionRootScripts(collectionUid, scripts) {
138163
+ const id = this.toModelId(collectionUid);
138164
+ await this.gateway.requestJson(
138165
+ {
138166
+ service: "collection",
138167
+ method: "patch",
138168
+ path: `/v3/collections/${id}`,
138169
+ body: [{ op: "add", path: "/scripts", value: scripts }]
138170
+ },
138171
+ { retryTransient: false }
138172
+ );
138173
+ }
137614
138174
  /**
137615
- * Add a secret-free runtime hook to every HTTP request in a collection. The
137616
- * PMAK value is supplied only by the runner as a transient variable; this
137617
- * method persists the variable name and header wiring, never the credential.
138175
+ * Add a secret-free runtime hook at the collection root. The PMAK value is
138176
+ * supplied only by the runner as a transient variable; this method persists
138177
+ * the variable name and header wiring, never the credential.
137618
138178
  */
137619
138179
  async configurePrivateMockRuntimeAuth(collectionUid) {
137620
138180
  const cid = String(collectionUid ?? "").trim();
137621
138181
  if (!cid) return 0;
137622
- const listed = await this.gateway.requestJson({
137623
- service: "collection",
137624
- method: "get",
137625
- path: `/v3/collections/${cid}/items/`
137626
- });
137627
- const items = Array.isArray(listed?.data) ? listed.data : [];
137628
- let patched = 0;
137629
- for (const listedItem of items) {
137630
- if (String(listedItem.$kind ?? "") !== "http-request") continue;
137631
- const itemId = String(listedItem.id ?? "").trim();
137632
- if (!itemId) continue;
137633
- const response = await this.gateway.requestJson({
137634
- service: "collection",
137635
- method: "get",
137636
- path: `/v3/collections/${cid}/items/${itemId}`,
137637
- headers: { "X-Entity-Type": "http-request" }
137638
- });
137639
- const item = this.asRecord(response?.data) ?? listedItem;
137640
- const scripts = Array.isArray(item.scripts) ? item.scripts.filter((entry) => Boolean(this.asRecord(entry))) : [];
137641
- const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
137642
- const existingCode = String(before?.code ?? "");
137643
- if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
137644
- const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137645
- const nextScripts = [
137646
- ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
137647
- { type: "beforeRequest", code, language: "text/javascript" }
137648
- ];
137649
- await this.gateway.requestJson({
137650
- service: "collection",
137651
- method: "patch",
137652
- path: `/v3/collections/${cid}/items/${itemId}`,
137653
- headers: { "X-Entity-Type": "http-request" },
137654
- body: [{ op: "add", path: "/scripts", value: nextScripts }]
137655
- });
137656
- patched += 1;
137657
- }
137658
- return patched;
138182
+ const installFromFreshRoot = async (existingScripts) => {
138183
+ if (this.rootScriptsIncludeManagedAuthHook(existingScripts)) {
138184
+ return 0;
138185
+ }
138186
+ const nextScripts = this.buildPrivateMockRootScripts(existingScripts);
138187
+ try {
138188
+ await this.patchCollectionRootScripts(cid, nextScripts);
138189
+ return 1;
138190
+ } catch (error2) {
138191
+ if (!this.isAmbiguousTransportError(error2)) {
138192
+ throw error2;
138193
+ }
138194
+ const freshScripts = await this.readCollectionRootScripts(cid);
138195
+ if (this.rootScriptsIncludeManagedAuthHook(freshScripts)) {
138196
+ return 1;
138197
+ }
138198
+ const recomputed = this.buildPrivateMockRootScripts(freshScripts);
138199
+ await this.patchCollectionRootScripts(cid, recomputed);
138200
+ return 1;
138201
+ }
138202
+ };
138203
+ const scripts = await this.readCollectionRootScripts(cid);
138204
+ return installFromFreshRoot(scripts);
137659
138205
  }
137660
138206
  async listMocks() {
137661
138207
  const response = await this.gateway.requestJson({
@@ -137739,12 +138285,13 @@ var PostmanGatewayAssetsClient = class {
137739
138285
  }
137740
138286
  async createMonitor(workspaceId, name, collectionUid, environmentUid, cronSchedule) {
137741
138287
  const ws = workspaceId || this.workspaceId;
137742
- const effectiveCron = cronSchedule && cronSchedule.trim() ? cronSchedule.trim() : "0 0 * * 0";
138288
+ const cronTrimmed = String(cronSchedule ?? "").trim();
138289
+ const hasCron = cronTrimmed.length > 0;
137743
138290
  const monitorName = String(name ?? "").trim();
137744
138291
  const collection = String(collectionUid ?? "").trim();
137745
138292
  const environment = String(environmentUid ?? "").trim();
137746
138293
  const flightKey = `monitor:${ws}:${collection}:${environment}:${monitorName}`;
137747
- return this.singleFlight(flightKey, effectiveCron, "monitor", async () => {
138294
+ return this.singleFlight(flightKey, hasCron ? cronTrimmed : "inactive", "monitor", async () => {
137748
138295
  const existing = await this.findMonitorByCollection(collection, environment, monitorName);
137749
138296
  if (existing?.uid) {
137750
138297
  return existing.uid;
@@ -137752,11 +138299,12 @@ var PostmanGatewayAssetsClient = class {
137752
138299
  const body = {
137753
138300
  name: monitorName,
137754
138301
  collection,
138302
+ active: hasCron,
137755
138303
  options: { strictSSL: false, followRedirects: true, requestTimeout: null, requestDelay: 0 },
137756
138304
  notifications: { onFailure: [], onError: [] },
137757
138305
  retry: {},
137758
- schedule: { cronPattern: effectiveCron, timeZone: "UTC" },
137759
138306
  distribution: null,
138307
+ ...hasCron ? { schedule: { cronPattern: cronTrimmed, timeZone: "UTC" } } : {},
137760
138308
  ...environment ? { environment } : {}
137761
138309
  };
137762
138310
  const send2 = (fallback) => this.gateway.requestJson(
@@ -137842,6 +138390,128 @@ var PostmanGatewayAssetsClient = class {
137842
138390
  }
137843
138391
  };
137844
138392
 
138393
+ // src/lib/postman/private-mock-export-cleanup.ts
138394
+ function asArray2(value) {
138395
+ return Array.isArray(value) ? value : [];
138396
+ }
138397
+ function cloneScriptRecord(script) {
138398
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
138399
+ return script;
138400
+ }
138401
+ return { ...script };
138402
+ }
138403
+ function cloneCollectionNodeIterative(collection) {
138404
+ const cloned = { ...collection };
138405
+ if (Array.isArray(collection.scripts)) {
138406
+ cloned.scripts = collection.scripts.map((script) => cloneScriptRecord(script));
138407
+ }
138408
+ const stack = [];
138409
+ const attachNested = (source, target) => {
138410
+ if (Array.isArray(source.scripts)) {
138411
+ target.scripts = source.scripts.map((script) => cloneScriptRecord(script));
138412
+ }
138413
+ for (const key of ["items", "children"]) {
138414
+ const nested = asArray2(source[key]);
138415
+ if (nested.length === 0) {
138416
+ continue;
138417
+ }
138418
+ const clonedNested = nested.map((item) => ({ ...item }));
138419
+ target[key] = clonedNested;
138420
+ for (let i = 0; i < nested.length; i += 1) {
138421
+ stack.push({ source: nested[i], target: clonedNested[i] });
138422
+ }
138423
+ }
138424
+ };
138425
+ attachNested(collection, cloned);
138426
+ while (stack.length > 0) {
138427
+ const frame = stack.pop();
138428
+ attachNested(frame.source, frame.target);
138429
+ }
138430
+ return cloned;
138431
+ }
138432
+ function cloneCollection(collection) {
138433
+ if (typeof globalThis.structuredClone === "function") {
138434
+ try {
138435
+ return globalThis.structuredClone(collection);
138436
+ } catch {
138437
+ }
138438
+ }
138439
+ try {
138440
+ return JSON.parse(JSON.stringify(collection));
138441
+ } catch {
138442
+ return cloneCollectionNodeIterative(collection);
138443
+ }
138444
+ }
138445
+ function isPrivateMockLegacyExportCleanupEnabled() {
138446
+ const value = String(process.env.POSTMAN_PRIVATE_MOCK_LEGACY_EXPORT_CLEANUP ?? "").trim().toLowerCase();
138447
+ return value !== "off";
138448
+ }
138449
+ function verifyPrivateMockRootHook(collection) {
138450
+ const scripts = asArray2(collection.scripts);
138451
+ return scripts.some((script) => isManagedPrivateMockAuthRootHook(script));
138452
+ }
138453
+ function applyPrivateMockExportCleanup(collection, options = {}) {
138454
+ const stripManagedBlocks = options.stripManagedBlocks ?? isPrivateMockLegacyExportCleanupEnabled();
138455
+ const cloned = cloneCollection(collection);
138456
+ let strippedBlocks = 0;
138457
+ const visitItem = (item) => {
138458
+ if (!stripManagedBlocks) {
138459
+ return;
138460
+ }
138461
+ const scripts = item.scripts;
138462
+ if (!Array.isArray(scripts)) {
138463
+ return;
138464
+ }
138465
+ const nextScripts = [];
138466
+ for (const script of scripts) {
138467
+ if (!script || typeof script !== "object" || Array.isArray(script)) {
138468
+ nextScripts.push(script);
138469
+ continue;
138470
+ }
138471
+ const record = script;
138472
+ if (String(record.type ?? "") !== "beforeRequest") {
138473
+ nextScripts.push(record);
138474
+ continue;
138475
+ }
138476
+ const originalCode = String(record.code ?? "");
138477
+ const cleaned = stripManagedItemAuthBlocks(originalCode);
138478
+ if (cleaned === originalCode) {
138479
+ nextScripts.push(record);
138480
+ continue;
138481
+ }
138482
+ strippedBlocks += countManagedItemAuthBlocks(originalCode);
138483
+ if (!cleaned) {
138484
+ continue;
138485
+ }
138486
+ nextScripts.push({ ...record, code: cleaned });
138487
+ }
138488
+ if (nextScripts.length === 0) {
138489
+ delete item.scripts;
138490
+ } else {
138491
+ item.scripts = nextScripts;
138492
+ }
138493
+ };
138494
+ const walkItemsIteratively = (rootItems) => {
138495
+ const stack = [...rootItems].reverse();
138496
+ while (stack.length > 0) {
138497
+ const item = stack.pop();
138498
+ visitItem(item);
138499
+ for (const key of ["items", "children"]) {
138500
+ const nested = asArray2(item[key]);
138501
+ for (let i = nested.length - 1; i >= 0; i -= 1) {
138502
+ stack.push(nested[i]);
138503
+ }
138504
+ }
138505
+ }
138506
+ };
138507
+ walkItemsIteratively(asArray2(cloned.items));
138508
+ return {
138509
+ collection: cloned,
138510
+ strippedBlocks,
138511
+ rootVerified: verifyPrivateMockRootHook(cloned)
138512
+ };
138513
+ }
138514
+
137845
138515
  // src/lib/postman/token-provider.ts
137846
138516
  var MintError = class extends Error {
137847
138517
  permanent;
@@ -138651,6 +139321,15 @@ var identitySecretMasker = (input) => input;
138651
139321
  function resolveRepoSyncMasker(dependencies) {
138652
139322
  return dependencies.secretMasker ?? identitySecretMasker;
138653
139323
  }
139324
+ function resolveRepoSyncLogger(dependencies) {
139325
+ return dependencies.logger ?? createLogger({
139326
+ sink: actionSink(dependencies.core),
139327
+ fields: {
139328
+ action: "postman-repo-sync-action",
139329
+ action_version: resolveActionVersion2()
139330
+ }
139331
+ });
139332
+ }
138654
139333
  function causeText(cause) {
138655
139334
  return cause instanceof Error ? cause.message : String(cause);
138656
139335
  }
@@ -139067,13 +139746,51 @@ function normalizeToPosix(filePath) {
139067
139746
  function canonicalizeRelativePath(value) {
139068
139747
  return normalizeToPosix(String(value ?? "").trim()).replace(/^\.\/+/, "").replace(/\/{2,}/g, "/").replace(/\/+$/g, "");
139069
139748
  }
139070
- function isOpenApiSpecFile(filePath) {
139071
- if (!(filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml"))) {
139072
- return false;
139749
+ var LOCAL_SPEC_DISCOVERY_MAX_DEPTH = 6;
139750
+ var LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES = 1e4;
139751
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES = 200;
139752
+ var LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES = 512 * 1024;
139753
+ var LOCAL_SPEC_DISCOVERY_IGNORED_DIRS = /* @__PURE__ */ new Set([
139754
+ ".git",
139755
+ ".nyc_output",
139756
+ ".omc",
139757
+ ".omx",
139758
+ ".llm-plans",
139759
+ ".pulumi",
139760
+ ".terraform",
139761
+ ".venv",
139762
+ "__pycache__",
139763
+ "bin",
139764
+ "build",
139765
+ "coverage",
139766
+ "discovered-specs",
139767
+ "node_modules",
139768
+ "dist",
139769
+ "obj",
139770
+ "out",
139771
+ "target",
139772
+ "vendor",
139773
+ "venv"
139774
+ ]);
139775
+ var LocalSpecDiscoveryLimitError = class extends Error {
139776
+ code = "CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT";
139777
+ constructor(message) {
139778
+ super(`CONTRACT_LOCAL_SPEC_DISCOVERY_LIMIT: ${message}`);
139779
+ this.name = "LocalSpecDiscoveryLimitError";
139073
139780
  }
139781
+ };
139782
+ function failLocalSpecDiscoveryLimit(detail) {
139783
+ throw new LocalSpecDiscoveryLimitError(
139784
+ `${detail} Set spec-path to the OpenAPI file explicitly and keep generated trees (for example dist/, node_modules/) out of the repository layout.`
139785
+ );
139786
+ }
139787
+ function isSpecCandidateExtension(filePath) {
139788
+ return filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml");
139789
+ }
139790
+ function readOpenApiSpecFile(fullPath) {
139074
139791
  try {
139075
- const raw = (0, import_node_fs5.readFileSync)(filePath, "utf8");
139076
- const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
139792
+ const raw = (0, import_node_fs5.readFileSync)(fullPath, "utf8");
139793
+ const parsed = fullPath.endsWith(".json") ? JSON.parse(raw) : load(raw);
139077
139794
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
139078
139795
  return false;
139079
139796
  }
@@ -139089,28 +139806,75 @@ function isOpenApiSpecFile(filePath) {
139089
139806
  }
139090
139807
  return false;
139091
139808
  }
139092
- function scanLocalSpecReferences(baseDir = ".") {
139093
- const ignoredDirs = /* @__PURE__ */ new Set([
139094
- ".git",
139095
- ".omc",
139096
- ".omx",
139097
- ".llm-plans",
139098
- "node_modules",
139099
- "dist"
139100
- ]);
139809
+ function shouldIgnoreSpecDiscoveryEntry(entryName, currentDir, baseDir, ignoredPrefixes) {
139810
+ if (LOCAL_SPEC_DISCOVERY_IGNORED_DIRS.has(entryName)) {
139811
+ return true;
139812
+ }
139813
+ const relative4 = normalizeToPosix(path8.relative(baseDir, path8.join(currentDir, entryName)));
139814
+ return ignoredPrefixes.some(
139815
+ (prefix) => relative4 === prefix || relative4.startsWith(`${prefix}/`)
139816
+ );
139817
+ }
139818
+ function scanLocalSpecReferences(baseDir = ".", options = {}) {
139819
+ const ignoredPrefixes = (options.ignoredPrefixes ?? []).map((value) => canonicalizeRelativePath(value)).filter(Boolean);
139101
139820
  const found = /* @__PURE__ */ new Set();
139102
139821
  const refs = [];
139103
- const visit2 = (currentDir) => {
139104
- for (const entry of (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true })) {
139105
- if (ignoredDirs.has(entry.name)) {
139822
+ let traversalEntries = 0;
139823
+ let candidateFiles = 0;
139824
+ const pendingDirs = [{ dir: baseDir, depth: 0 }];
139825
+ while (pendingDirs.length > 0) {
139826
+ const { dir: currentDir, depth: currentDepth } = pendingDirs.shift();
139827
+ let entries;
139828
+ try {
139829
+ entries = (0, import_node_fs5.readdirSync)(currentDir, { withFileTypes: true }).sort(
139830
+ (left, right) => left.name.localeCompare(right.name)
139831
+ );
139832
+ } catch {
139833
+ continue;
139834
+ }
139835
+ for (const entry of entries) {
139836
+ traversalEntries += 1;
139837
+ if (traversalEntries > LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES) {
139838
+ failLocalSpecDiscoveryLimit(
139839
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_TRAVERSAL_ENTRIES} traversal-entry liveness budget.`
139840
+ );
139841
+ }
139842
+ if (shouldIgnoreSpecDiscoveryEntry(entry.name, currentDir, baseDir, ignoredPrefixes)) {
139106
139843
  continue;
139107
139844
  }
139108
139845
  const fullPath = path8.join(currentDir, entry.name);
139109
139846
  if (entry.isDirectory()) {
139110
- visit2(fullPath);
139847
+ const nextDepth = currentDepth + 1;
139848
+ if (nextDepth > LOCAL_SPEC_DISCOVERY_MAX_DEPTH) {
139849
+ failLocalSpecDiscoveryLimit(
139850
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_DEPTH} directory-depth budget.`
139851
+ );
139852
+ }
139853
+ pendingDirs.push({ dir: fullPath, depth: nextDepth });
139111
139854
  continue;
139112
139855
  }
139113
- if (!entry.isFile() || !isOpenApiSpecFile(fullPath)) {
139856
+ if (!entry.isFile() || !isSpecCandidateExtension(fullPath)) {
139857
+ continue;
139858
+ }
139859
+ candidateFiles += 1;
139860
+ if (candidateFiles > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES) {
139861
+ failLocalSpecDiscoveryLimit(
139862
+ `local spec discovery exceeded the ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILES} candidate-file budget.`
139863
+ );
139864
+ }
139865
+ let sizeBytes;
139866
+ try {
139867
+ sizeBytes = (0, import_node_fs5.statSync)(fullPath).size;
139868
+ } catch {
139869
+ continue;
139870
+ }
139871
+ if (sizeBytes > LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES) {
139872
+ const repoRelativePath2 = normalizeToPosix(path8.relative(baseDir, fullPath));
139873
+ failLocalSpecDiscoveryLimit(
139874
+ `local spec discovery candidate ${repoRelativePath2} exceeds ${LOCAL_SPEC_DISCOVERY_MAX_CANDIDATE_FILE_BYTES} bytes.`
139875
+ );
139876
+ }
139877
+ if (!readOpenApiSpecFile(fullPath)) {
139114
139878
  continue;
139115
139879
  }
139116
139880
  const repoRelativePath = normalizeToPosix(path8.relative(baseDir, fullPath));
@@ -139123,20 +139887,36 @@ function scanLocalSpecReferences(baseDir = ".") {
139123
139887
  configRelativePath: normalizeToPosix(path8.join("..", repoRelativePath))
139124
139888
  });
139125
139889
  }
139126
- };
139127
- visit2(baseDir);
139890
+ }
139128
139891
  return refs.sort((left, right) => left.repoRelativePath.localeCompare(right.repoRelativePath));
139129
139892
  }
139130
- function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
139893
+ function tryResolveExplicitSpecReference(explicitSpecPath) {
139131
139894
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
139132
- if (normalizedExplicitPath) {
139133
- const explicitFullPath = path8.resolve(normalizedExplicitPath);
139134
- if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
139135
- return {
139136
- repoRelativePath: normalizedExplicitPath,
139137
- configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
139138
- };
139139
- }
139895
+ if (!normalizedExplicitPath) {
139896
+ return void 0;
139897
+ }
139898
+ const explicitFullPath = path8.resolve(normalizedExplicitPath);
139899
+ if ((0, import_node_fs5.existsSync)(explicitFullPath) && (0, import_node_fs5.statSync)(explicitFullPath).isFile()) {
139900
+ return {
139901
+ repoRelativePath: normalizedExplicitPath,
139902
+ configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
139903
+ };
139904
+ }
139905
+ return void 0;
139906
+ }
139907
+ function resolveLocalSpecReferences(explicitSpecPath, baseDir = ".", options = {}) {
139908
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
139909
+ if (explicit) {
139910
+ return { discoveredSpecs: [], mappedSpec: explicit };
139911
+ }
139912
+ const discoveredSpecs = scanLocalSpecReferences(baseDir, options);
139913
+ const mappedSpec = resolveMappedSpecReference(explicitSpecPath, discoveredSpecs);
139914
+ return { discoveredSpecs, mappedSpec };
139915
+ }
139916
+ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
139917
+ const explicit = tryResolveExplicitSpecReference(explicitSpecPath);
139918
+ if (explicit) {
139919
+ return explicit;
139140
139920
  }
139141
139921
  if (discoveredSpecs.length === 1) {
139142
139922
  return discoveredSpecs[0];
@@ -139957,6 +140737,18 @@ function tryReusePrebuiltCollection(options) {
139957
140737
  }
139958
140738
  return prepared.artifactDigest === entry.artifactDigest;
139959
140739
  }
140740
+ async function preparePrivateMockCloudCollection(role, collectionId, postman) {
140741
+ const col = await postman.getCollection(collectionId);
140742
+ const { collection } = applyPrivateMockExportCleanup(col, {
140743
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
140744
+ });
140745
+ if (!verifyPrivateMockRootHook(collection)) {
140746
+ throw new Error(
140747
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
140748
+ );
140749
+ }
140750
+ return collection;
140751
+ }
139960
140752
  async function exportCollectionArtifact(options) {
139961
140753
  const {
139962
140754
  role,
@@ -139965,14 +140757,17 @@ async function exportCollectionArtifact(options) {
139965
140757
  collectionsDir,
139966
140758
  prebuiltByRole,
139967
140759
  postman,
139968
- core
140760
+ core,
140761
+ privateMockAuth = false,
140762
+ preparedCloudCollection
139969
140763
  } = options;
139970
140764
  if (!collectionId) {
139971
140765
  return void 0;
139972
140766
  }
139973
140767
  const expectedPath = `${collectionsDir}/${dirName}`;
140768
+ const forceCloudExport = privateMockAuth && (role === "smoke" || role === "contract");
139974
140769
  const entry = prebuiltByRole.get(role);
139975
- if (entry) {
140770
+ if (entry && !forceCloudExport) {
139976
140771
  const reused = tryReusePrebuiltCollection({
139977
140772
  prepared: entry,
139978
140773
  expectedPath,
@@ -139987,12 +140782,30 @@ async function exportCollectionArtifact(options) {
139987
140782
  core.info(
139988
140783
  `Prebuilt ${role} collection entry present but did not exactly match; exporting from cloud`
139989
140784
  );
140785
+ } else if (entry && forceCloudExport) {
140786
+ core.info(
140787
+ `Private mock requires cloud export for ${role} collection to reconcile managed root hook; exporting from cloud`
140788
+ );
139990
140789
  }
139991
- const col = await postman.getCollection(collectionId);
139992
- await convertAndSplitAnyCollection(
139993
- col,
139994
- expectedPath
139995
- );
140790
+ let collectionForExport;
140791
+ if (forceCloudExport && preparedCloudCollection) {
140792
+ collectionForExport = preparedCloudCollection;
140793
+ } else if (forceCloudExport) {
140794
+ const col = await postman.getCollection(collectionId);
140795
+ const { collection } = applyPrivateMockExportCleanup(col, {
140796
+ stripManagedBlocks: isPrivateMockLegacyExportCleanupEnabled()
140797
+ });
140798
+ if (!verifyPrivateMockRootHook(collection)) {
140799
+ throw new Error(
140800
+ `PRIVATE_MOCK_AUTH_ROOT_UNVERIFIED: Managed root hook missing from exported ${role} collection ${collectionId}`
140801
+ );
140802
+ }
140803
+ collectionForExport = collection;
140804
+ } else {
140805
+ const col = await postman.getCollection(collectionId);
140806
+ collectionForExport = col;
140807
+ }
140808
+ await convertAndSplitAnyCollection(collectionForExport, expectedPath);
139996
140809
  return `../${expectedPath}`;
139997
140810
  }
139998
140811
  function hasControlCharacter2(value) {
@@ -140045,32 +140858,37 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140045
140858
  const globalsDir = `${inputs.artifactDir}/globals`;
140046
140859
  const mocksDir = `${inputs.artifactDir}/mocks`;
140047
140860
  const specsDir = `${inputs.artifactDir}/specs`;
140048
- ensureDir(collectionsDir);
140049
- ensureDir(environmentsDir);
140050
- ensureDir(flowsDir);
140051
- ensureDir(globalsDir);
140052
- ensureDir(mocksDir);
140053
- ensureDir(specsDir);
140054
- ensureDir(".postman");
140055
- const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
140056
- if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
140057
- (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
140058
- }
140059
- if (inputs.generateCiWorkflow) {
140060
- const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
140061
- if (ciDir) {
140062
- ensureDir(ciDir);
140063
- }
140064
- }
140065
140861
  const manifestCollections = {};
140066
- const discoveredSpecs = scanLocalSpecReferences();
140067
- const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
140862
+ const artifactDirPrefix = canonicalizeRelativePath(inputs.artifactDir);
140863
+ const { discoveredSpecs, mappedSpec } = resolveLocalSpecReferences(inputs.specPath, ".", {
140864
+ ignoredPrefixes: artifactDirPrefix ? [artifactDirPrefix, ".postman"] : [".postman"]
140865
+ });
140068
140866
  const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
140069
140867
  mappedSpec.configRelativePath,
140070
140868
  inputs.specSyncMode,
140071
140869
  options.releaseLabel
140072
140870
  ) : void 0;
140073
140871
  const prebuiltByRole = options.preparedPrebuiltCollections;
140872
+ const privateMockAuth = options.privateMockAuth === true;
140873
+ const preparedPrivateMockCollections = /* @__PURE__ */ new Map();
140874
+ if (privateMockAuth) {
140875
+ for (const spec of [
140876
+ { role: "smoke", collectionId: inputs.smokeCollectionId },
140877
+ { role: "contract", collectionId: inputs.contractCollectionId }
140878
+ ]) {
140879
+ if (!spec.collectionId) {
140880
+ continue;
140881
+ }
140882
+ preparedPrivateMockCollections.set(
140883
+ spec.role,
140884
+ await preparePrivateMockCloudCollection(
140885
+ spec.role,
140886
+ spec.collectionId,
140887
+ dependencies.postman
140888
+ )
140889
+ );
140890
+ }
140891
+ }
140074
140892
  const baselineRef = await exportCollectionArtifact({
140075
140893
  role: "baseline",
140076
140894
  collectionId: inputs.baselineCollectionId,
@@ -140078,7 +140896,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140078
140896
  collectionsDir,
140079
140897
  prebuiltByRole,
140080
140898
  postman: dependencies.postman,
140081
- core: dependencies.core
140899
+ core: dependencies.core,
140900
+ privateMockAuth
140082
140901
  });
140083
140902
  if (baselineRef) {
140084
140903
  manifestCollections[baselineRef] = inputs.baselineCollectionId;
@@ -140090,7 +140909,9 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140090
140909
  collectionsDir,
140091
140910
  prebuiltByRole,
140092
140911
  postman: dependencies.postman,
140093
- core: dependencies.core
140912
+ core: dependencies.core,
140913
+ privateMockAuth,
140914
+ preparedCloudCollection: preparedPrivateMockCollections.get("smoke")
140094
140915
  });
140095
140916
  if (smokeRef) {
140096
140917
  manifestCollections[smokeRef] = inputs.smokeCollectionId;
@@ -140102,11 +140923,30 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName,
140102
140923
  collectionsDir,
140103
140924
  prebuiltByRole,
140104
140925
  postman: dependencies.postman,
140105
- core: dependencies.core
140926
+ core: dependencies.core,
140927
+ privateMockAuth,
140928
+ preparedCloudCollection: preparedPrivateMockCollections.get("contract")
140106
140929
  });
140107
140930
  if (contractRef) {
140108
140931
  manifestCollections[contractRef] = inputs.contractCollectionId;
140109
140932
  }
140933
+ ensureDir(collectionsDir);
140934
+ ensureDir(environmentsDir);
140935
+ ensureDir(flowsDir);
140936
+ ensureDir(globalsDir);
140937
+ ensureDir(mocksDir);
140938
+ ensureDir(specsDir);
140939
+ ensureDir(".postman");
140940
+ const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
140941
+ if (!(0, import_node_fs5.existsSync)(globalsFilePath)) {
140942
+ (0, import_node_fs5.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
140943
+ }
140944
+ if (inputs.generateCiWorkflow) {
140945
+ const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
140946
+ if (ciDir) {
140947
+ ensureDir(ciDir);
140948
+ }
140949
+ }
140110
140950
  for (const [envName, envUid] of Object.entries(envUids)) {
140111
140951
  writeJsonFile(
140112
140952
  `${environmentsDir}/${envName}.postman_environment.json`,
@@ -140259,19 +141099,41 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
140259
141099
  async function runRepoSync(inputs, dependencies) {
140260
141100
  const telemetry = createTelemetryContext({ action: "postman-repo-sync-action", actionVersion: resolveActionVersion2(), logger: dependencies.core });
140261
141101
  telemetry.setTeamId(dependencies.teamId);
141102
+ const logger = resolveRepoSyncLogger(dependencies);
141103
+ for (const secret of [
141104
+ inputs.postmanApiKey,
141105
+ inputs.postmanAccessToken,
141106
+ inputs.adoToken,
141107
+ inputs.githubToken,
141108
+ inputs.ghFallbackToken,
141109
+ inputs.sslClientCert,
141110
+ inputs.sslClientKey,
141111
+ inputs.sslClientPassphrase,
141112
+ inputs.sslExtraCaCerts
141113
+ ]) {
141114
+ logger.addSecret(secret);
141115
+ }
141116
+ logger.debug("resolved inputs", {
141117
+ project: inputs.projectName,
141118
+ collection_sync_mode: inputs.collectionSyncMode,
141119
+ spec_sync_mode: inputs.specSyncMode,
141120
+ team_id: dependencies.teamId || void 0
141121
+ });
140262
141122
  try {
140263
- const result = await runRepoSyncInner(inputs, dependencies);
141123
+ const result = await runRepoSyncInner(inputs, { ...dependencies, logger });
140264
141124
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
140265
141125
  telemetry.emitCompletion("success");
140266
141126
  return result;
140267
141127
  } catch (error2) {
140268
141128
  telemetry.setAccountType(getMemoizedSessionIdentity()?.consumerType);
140269
141129
  telemetry.emitCompletion("failure");
141130
+ logger.failure("repo sync failed", error2);
140270
141131
  throw error2;
140271
141132
  }
140272
141133
  }
140273
141134
  async function runRepoSyncInner(inputs, dependencies) {
140274
141135
  const mask = resolveRepoSyncMasker(dependencies);
141136
+ const logger = resolveRepoSyncLogger(dependencies);
140275
141137
  const branchDecision = decideBranchTier(inputs);
140276
141138
  assertBranchAssetIds(inputs, branchDecision);
140277
141139
  const isCanonicalWriter = branchDecision.tier === "legacy" || branchDecision.tier === "canonical";
@@ -140331,7 +141193,10 @@ async function runRepoSyncInner(inputs, dependencies) {
140331
141193
  }
140332
141194
  }
140333
141195
  }
140334
- const preparedPrebuiltCollections = await preparePrebuiltCollections(inputs);
141196
+ const preparedPrebuiltCollections = await logger.phase(
141197
+ "prepare-collections",
141198
+ async () => preparePrebuiltCollections(inputs)
141199
+ );
140335
141200
  let skipRepositoryLinkPost = false;
140336
141201
  let repositoryLinkPreflightWasFree = false;
140337
141202
  if (inputs.workspaceLinkEnabled && inputs.workspaceId && inputs.repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
@@ -140366,7 +141231,10 @@ async function runRepoSyncInner(inputs, dependencies) {
140366
141231
  }
140367
141232
  }
140368
141233
  const branchAssetMarker = buildBranchAssetMarker(branchDecision, inputs);
140369
- const envUids = await upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker);
141234
+ const envUids = await logger.phase(
141235
+ "sync-environments",
141236
+ async () => upsertEnvironments(inputs, dependencies, resourcesState, branchAssetMarker)
141237
+ );
140370
141238
  outputs["environment-uids-json"] = JSON.stringify(envUids);
140371
141239
  dependencies.core.setOutput("environment-uids-json", outputs["environment-uids-json"]);
140372
141240
  if (inputs.environmentSyncEnabled && inputs.workspaceId && dependencies.internalIntegration) {
@@ -140529,10 +141397,21 @@ async function runRepoSyncInner(inputs, dependencies) {
140529
141397
  );
140530
141398
  }
140531
141399
  const configured = [];
140532
- for (const collectionUid of [inputs.smokeCollectionId, inputs.contractCollectionId]) {
140533
- if (collectionUid) {
141400
+ for (const { role, collectionUid } of [
141401
+ { role: "smoke", collectionUid: inputs.smokeCollectionId },
141402
+ { role: "contract", collectionUid: inputs.contractCollectionId }
141403
+ ]) {
141404
+ if (!collectionUid) {
141405
+ continue;
141406
+ }
141407
+ try {
140534
141408
  await dependencies.postman.configurePrivateMockRuntimeAuth(collectionUid);
140535
141409
  configured.push(collectionUid);
141410
+ } catch (error2) {
141411
+ throw new Error(
141412
+ `PRIVATE_MOCK_AUTH_ROOT_PATCH: Failed to install managed root hook on ${role} collection ${collectionUid}: ${mask(causeText(error2))}`,
141413
+ { cause: error2 }
141414
+ );
140536
141415
  }
140537
141416
  }
140538
141417
  if (configured.length > 0) {
@@ -140684,16 +141563,23 @@ async function runRepoSyncInner(inputs, dependencies) {
140684
141563
  dependencies.core.warning(message);
140685
141564
  }
140686
141565
  }
140687
- await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
140688
- workspaceLinkStatus: outputs["workspace-link-status"],
140689
- priorWorkspaceId: resourcesState?.workspace?.id,
140690
- existingSpecs: resourcesState?.cloudResources?.specs,
140691
- mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
140692
- releaseLabel,
140693
- priorState: resourcesState,
140694
- preparedPrebuiltCollections
140695
- });
140696
- const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
141566
+ await logger.phase(
141567
+ "export-artifacts",
141568
+ async () => exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
141569
+ workspaceLinkStatus: outputs["workspace-link-status"],
141570
+ priorWorkspaceId: resourcesState?.workspace?.id,
141571
+ existingSpecs: resourcesState?.cloudResources?.specs,
141572
+ mockEnvironmentUid: outputs["mock-environment-uid"] || void 0,
141573
+ releaseLabel,
141574
+ priorState: resourcesState,
141575
+ preparedPrebuiltCollections,
141576
+ privateMockAuth: inputs.mockVisibility === "private"
141577
+ })
141578
+ );
141579
+ const commit = await logger.phase(
141580
+ "commit-and-push",
141581
+ async () => commitAndPushGeneratedFiles(inputs, dependencies)
141582
+ );
140697
141583
  outputs["commit-sha"] = commit.commitSha;
140698
141584
  if (commit.resolvedCurrentRef) {
140699
141585
  outputs["resolved-current-ref"] = commit.resolvedCurrentRef;
@@ -141173,6 +142059,7 @@ async function runAction(actionCore = core_exports, actionExec = exec_exports) {
141173
142059
  }
141174
142060
  // Annotate the CommonJS export names for ESM import in node:
141175
142061
  0 && (module.exports = {
142062
+ LocalSpecDiscoveryLimitError,
141176
142063
  StateUnreadableError,
141177
142064
  assertBranchAssetIds,
141178
142065
  assertPathWithinCwd,