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

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
@@ -136994,11 +136994,20 @@ function requireMockVisibility(mock, requested) {
136994
136994
  }
136995
136995
  return mock;
136996
136996
  }
136997
- var PRIVATE_MOCK_AUTH_MARKER_PREFIX = "postman-enterprise-automation: private-mock-auth";
136998
- var PRIVATE_MOCK_AUTH_MARKER = `${PRIVATE_MOCK_AUTH_MARKER_PREFIX}-v2`;
136997
+ var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
136998
+ var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
136999
+ var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
136999
137000
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
137000
- var PRIVATE_MOCK_AUTH_SCRIPT = [
137001
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137001
+ var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137002
+ `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
137003
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137004
+ "var privateMockHost = String(pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '');",
137005
+ "if (privateMockApiKey && /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost)) {",
137006
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137007
+ "}"
137008
+ ].join("\n");
137009
+ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
137010
+ `// ${PRIVATE_MOCK_AUTH_V2_MARKER}`,
137002
137011
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137003
137012
  "var privateMockHostValue = pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '';",
137004
137013
  "var privateMockHost = Array.isArray(privateMockHostValue) ? privateMockHostValue.join('.') : String(privateMockHostValue);",
@@ -137009,23 +137018,25 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
137009
137018
  ` 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.');`,
137010
137019
  "}"
137011
137020
  ].join("\n");
137012
- function stripPrivateMockAuthBlocks(code) {
137013
- if (!code.includes(PRIVATE_MOCK_AUTH_MARKER_PREFIX)) return code.trim();
137014
- const lines = code.split("\n");
137015
- const kept = [];
137016
- let skipping = false;
137017
- for (const line of lines) {
137018
- if (line.includes(PRIVATE_MOCK_AUTH_MARKER_PREFIX)) {
137019
- skipping = true;
137020
- continue;
137021
- }
137022
- if (skipping) {
137023
- if (/^\s*(?:(?:var|if)\s|\}\selse\sif\s|\}|pm\.request|console\.warn)/.test(line)) continue;
137024
- skipping = false;
137025
- }
137026
- kept.push(line);
137027
- }
137028
- return kept.join("\n").trim();
137021
+ var PRIVATE_MOCK_AUTH_SCRIPT = [
137022
+ `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137023
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137024
+ "var privateMockHost = '';",
137025
+ "try {",
137026
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137027
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137028
+ "} catch (error) {",
137029
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137030
+ "}",
137031
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137032
+ "if (isPrivateMockHost && privateMockApiKey) {",
137033
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137034
+ "} else if (isPrivateMockHost) {",
137035
+ ` console.warn('This mock server is private. Set the ${PRIVATE_MOCK_AUTH_VARIABLE2} variable to a Postman API key with access to it, or the request returns 401.');`,
137036
+ "}"
137037
+ ].join("\n");
137038
+ function removeLegacyPrivateMockAuth(code) {
137039
+ return [LEGACY_PRIVATE_MOCK_AUTH_SCRIPT, PRIVATE_MOCK_AUTH_V2_SCRIPT].reduce((next, script) => next.split(script).join(""), code).trim();
137029
137040
  }
137030
137041
  var MAX_CREATE_FLIGHTS = 256;
137031
137042
  var createFlights = /* @__PURE__ */ new Map();
@@ -137626,7 +137637,7 @@ var PostmanGatewayAssetsClient = class {
137626
137637
  const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
137627
137638
  const existingCode = String(before?.code ?? "");
137628
137639
  if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
137629
- const code = [stripPrivateMockAuthBlocks(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137640
+ const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137630
137641
  const nextScripts = [
137631
137642
  ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
137632
137643
  { type: "beforeRequest", code, language: "text/javascript" }
package/dist/cli.cjs CHANGED
@@ -135099,11 +135099,20 @@ function requireMockVisibility(mock, requested) {
135099
135099
  }
135100
135100
  return mock;
135101
135101
  }
135102
- var PRIVATE_MOCK_AUTH_MARKER_PREFIX = "postman-enterprise-automation: private-mock-auth";
135103
- var PRIVATE_MOCK_AUTH_MARKER = `${PRIVATE_MOCK_AUTH_MARKER_PREFIX}-v2`;
135102
+ var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
135103
+ var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
135104
+ var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
135104
135105
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
135105
- var PRIVATE_MOCK_AUTH_SCRIPT = [
135106
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
135106
+ var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
135107
+ `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
135108
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
135109
+ "var privateMockHost = String(pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '');",
135110
+ "if (privateMockApiKey && /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost)) {",
135111
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
135112
+ "}"
135113
+ ].join("\n");
135114
+ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
135115
+ `// ${PRIVATE_MOCK_AUTH_V2_MARKER}`,
135107
135116
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
135108
135117
  "var privateMockHostValue = pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '';",
135109
135118
  "var privateMockHost = Array.isArray(privateMockHostValue) ? privateMockHostValue.join('.') : String(privateMockHostValue);",
@@ -135114,23 +135123,25 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
135114
135123
  ` 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.');`,
135115
135124
  "}"
135116
135125
  ].join("\n");
135117
- function stripPrivateMockAuthBlocks(code) {
135118
- if (!code.includes(PRIVATE_MOCK_AUTH_MARKER_PREFIX)) return code.trim();
135119
- const lines = code.split("\n");
135120
- const kept = [];
135121
- let skipping = false;
135122
- for (const line of lines) {
135123
- if (line.includes(PRIVATE_MOCK_AUTH_MARKER_PREFIX)) {
135124
- skipping = true;
135125
- continue;
135126
- }
135127
- if (skipping) {
135128
- if (/^\s*(?:(?:var|if)\s|\}\selse\sif\s|\}|pm\.request|console\.warn)/.test(line)) continue;
135129
- skipping = false;
135130
- }
135131
- kept.push(line);
135132
- }
135133
- return kept.join("\n").trim();
135126
+ var PRIVATE_MOCK_AUTH_SCRIPT = [
135127
+ `// ${PRIVATE_MOCK_AUTH_MARKER}`,
135128
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
135129
+ "var privateMockHost = '';",
135130
+ "try {",
135131
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
135132
+ " privateMockHost = new URL(privateMockUrl).hostname;",
135133
+ "} catch (error) {",
135134
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
135135
+ "}",
135136
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
135137
+ "if (isPrivateMockHost && privateMockApiKey) {",
135138
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
135139
+ "} else if (isPrivateMockHost) {",
135140
+ ` console.warn('This mock server is private. Set the ${PRIVATE_MOCK_AUTH_VARIABLE2} variable to a Postman API key with access to it, or the request returns 401.');`,
135141
+ "}"
135142
+ ].join("\n");
135143
+ function removeLegacyPrivateMockAuth(code) {
135144
+ return [LEGACY_PRIVATE_MOCK_AUTH_SCRIPT, PRIVATE_MOCK_AUTH_V2_SCRIPT].reduce((next, script) => next.split(script).join(""), code).trim();
135134
135145
  }
135135
135146
  var MAX_CREATE_FLIGHTS = 256;
135136
135147
  var createFlights = /* @__PURE__ */ new Map();
@@ -135731,7 +135742,7 @@ var PostmanGatewayAssetsClient = class {
135731
135742
  const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
135732
135743
  const existingCode = String(before?.code ?? "");
135733
135744
  if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
135734
- const code = [stripPrivateMockAuthBlocks(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
135745
+ const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
135735
135746
  const nextScripts = [
135736
135747
  ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
135737
135748
  { type: "beforeRequest", code, language: "text/javascript" }
package/dist/index.cjs CHANGED
@@ -137016,11 +137016,20 @@ function requireMockVisibility(mock, requested) {
137016
137016
  }
137017
137017
  return mock;
137018
137018
  }
137019
- var PRIVATE_MOCK_AUTH_MARKER_PREFIX = "postman-enterprise-automation: private-mock-auth";
137020
- var PRIVATE_MOCK_AUTH_MARKER = `${PRIVATE_MOCK_AUTH_MARKER_PREFIX}-v2`;
137019
+ var LEGACY_PRIVATE_MOCK_AUTH_MARKER = "postman-enterprise-automation: private-mock-auth";
137020
+ var PRIVATE_MOCK_AUTH_V2_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v2`;
137021
+ var PRIVATE_MOCK_AUTH_MARKER = `${LEGACY_PRIVATE_MOCK_AUTH_MARKER}-v3`;
137021
137022
  var PRIVATE_MOCK_AUTH_VARIABLE2 = "postmanPrivateMockApiKey";
137022
- var PRIVATE_MOCK_AUTH_SCRIPT = [
137023
- `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137023
+ var LEGACY_PRIVATE_MOCK_AUTH_SCRIPT = [
137024
+ `// ${LEGACY_PRIVATE_MOCK_AUTH_MARKER}`,
137025
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137026
+ "var privateMockHost = String(pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '');",
137027
+ "if (privateMockApiKey && /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost)) {",
137028
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137029
+ "}"
137030
+ ].join("\n");
137031
+ var PRIVATE_MOCK_AUTH_V2_SCRIPT = [
137032
+ `// ${PRIVATE_MOCK_AUTH_V2_MARKER}`,
137024
137033
  `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137025
137034
  "var privateMockHostValue = pm.request.url && pm.request.url.getHost ? pm.request.url.getHost() : '';",
137026
137035
  "var privateMockHost = Array.isArray(privateMockHostValue) ? privateMockHostValue.join('.') : String(privateMockHostValue);",
@@ -137031,23 +137040,25 @@ var PRIVATE_MOCK_AUTH_SCRIPT = [
137031
137040
  ` 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.');`,
137032
137041
  "}"
137033
137042
  ].join("\n");
137034
- function stripPrivateMockAuthBlocks(code) {
137035
- if (!code.includes(PRIVATE_MOCK_AUTH_MARKER_PREFIX)) return code.trim();
137036
- const lines = code.split("\n");
137037
- const kept = [];
137038
- let skipping = false;
137039
- for (const line of lines) {
137040
- if (line.includes(PRIVATE_MOCK_AUTH_MARKER_PREFIX)) {
137041
- skipping = true;
137042
- continue;
137043
- }
137044
- if (skipping) {
137045
- if (/^\s*(?:(?:var|if)\s|\}\selse\sif\s|\}|pm\.request|console\.warn)/.test(line)) continue;
137046
- skipping = false;
137047
- }
137048
- kept.push(line);
137049
- }
137050
- return kept.join("\n").trim();
137043
+ var PRIVATE_MOCK_AUTH_SCRIPT = [
137044
+ `// ${PRIVATE_MOCK_AUTH_MARKER}`,
137045
+ `var privateMockApiKey = pm.variables.get('${PRIVATE_MOCK_AUTH_VARIABLE2}');`,
137046
+ "var privateMockHost = '';",
137047
+ "try {",
137048
+ " var privateMockUrl = pm.variables.replaceIn(pm.request.url.toString());",
137049
+ " privateMockHost = new URL(privateMockUrl).hostname;",
137050
+ "} catch (error) {",
137051
+ " console.warn('Could not resolve the request URL for private mock authentication; x-api-key was not added.');",
137052
+ "}",
137053
+ "var isPrivateMockHost = /(^|\\.)mock\\.pstmn\\.io$/i.test(privateMockHost);",
137054
+ "if (isPrivateMockHost && privateMockApiKey) {",
137055
+ " pm.request.headers.upsert({ key: 'x-api-key', value: privateMockApiKey });",
137056
+ "} else if (isPrivateMockHost) {",
137057
+ ` 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.');`,
137058
+ "}"
137059
+ ].join("\n");
137060
+ function removeLegacyPrivateMockAuth(code) {
137061
+ return [LEGACY_PRIVATE_MOCK_AUTH_SCRIPT, PRIVATE_MOCK_AUTH_V2_SCRIPT].reduce((next, script) => next.split(script).join(""), code).trim();
137051
137062
  }
137052
137063
  var MAX_CREATE_FLIGHTS = 256;
137053
137064
  var createFlights = /* @__PURE__ */ new Map();
@@ -137648,7 +137659,7 @@ var PostmanGatewayAssetsClient = class {
137648
137659
  const before = scripts.find((script) => String(script.type ?? "") === "beforeRequest");
137649
137660
  const existingCode = String(before?.code ?? "");
137650
137661
  if (existingCode.includes(PRIVATE_MOCK_AUTH_MARKER)) continue;
137651
- const code = [stripPrivateMockAuthBlocks(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137662
+ const code = [removeLegacyPrivateMockAuth(existingCode), PRIVATE_MOCK_AUTH_SCRIPT].filter(Boolean).join("\n");
137652
137663
  const nextScripts = [
137653
137664
  ...scripts.filter((script) => String(script.type ?? "") !== "beforeRequest"),
137654
137665
  { type: "beforeRequest", code, language: "text/javascript" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cse/onboarding-repo-sync",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Postman repo sync GitHub Action.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",