@mablhq/mabl-cli 2.53.3 → 2.56.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/core/execution/ApiTestUtils.js +29 -18
- package/execution/index.js +2 -2
- package/package.json +1 -1
- package/proxy/index.js +1 -1
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = exports.executableSnippetToApiTestSnippet = exports.executableSnippetsToPostmanEvent = exports.apiTestAuthToPostmanAuth = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isBinary = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray =
|
|
6
|
+
exports.splitLines = exports.PRE_REQUEST_LISTEN = exports.convertMablAssertionsToExecArray = exports.convertMablVariableAssignmentsToExecArray = exports.createMablGeneratedScripts = exports.toPostmanScript = exports.replaceVariables = exports.getActualValue = exports.readBody = exports.getResponseContentType = exports.valueToUnquotedString = exports.assertionTypeSupportsCaseSensitivity = exports.assertionTargetSupportsCaseSensitivity = exports.humanizeAssertion = exports.getAssertionTargetArgument = exports.assertionHasTest = exports.isValidMablAssertion = exports.normalizeRegExpExpectedValue = exports.normalizeExpectedValue = exports.normalizeAssertionValue = exports.assertionRequiresValue = exports.filterValidMablAssertions = exports.filterValidMablVariableAssignments = exports.isValidMablVariableAssignment = exports.removeMablGeneratedScripts = exports.createEmptyRequestEvent = exports.findFirstMatchingEvent = exports.restoreCustomRequestFields = exports.deduplicateApiTestExecutionResults = exports.createEmptyVariable = exports.createEmptyAssertion = exports.humanizeAssertionType = exports.getAssertionTypesForTarget = exports.caseInsensitiveEquals = exports.compareStringsCaseInsensitive = exports.ASSERT_TYPES = exports.ASSERT_TARGETS = exports.COLLECTION_WITH_FOLDERS_ERROR = exports.HMAC_SHA1_SIGNATURE = exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE = exports.DEFAULT_OAUTH1_VERSION = exports.OAUTH1_AUTH = exports.NO_AUTH = exports.BEARER_TOKEN_AUTH = exports.BASIC_AUTH = exports.API_KEY_AUTH = exports.INHERIT_AUTH_FROM_PARENT_VALUE = exports.MABL_GENERATED_COMMENT = exports.MABL_GENERATED_ASSERTION_TOKEN = exports.TEST_LISTEN = void 0;
|
|
7
|
+
exports.getSnippetReferencesInTest = exports.getSnippetReferencesInCollection = exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = exports.executableSnippetToApiTestSnippet = exports.executableSnippetsToPostmanEvent = exports.apiTestAuthToPostmanAuth = exports.insertTestConfigurationIntoFlow = exports.createCommentForApiTestSnippet = exports.convertMablSnippetsToExecArray = exports.createPostmanScript = exports.insertMablScriptsIntoCollection = exports.processPostmanItem = exports.replaceRawScriptWithExecArray = exports.removeInvalidHeaders = exports.processItemAuth = exports.mablAuthToPostman = exports.formatContent = exports.getRequestMode = exports.getFormDataArray = exports.isBinary = exports.isText = exports.isXML = exports.isJson = exports.isSupportedAuthType = exports.isItemDefinition = exports.isCollectionDefinition = exports.isItemGroupDefinition = exports.isFolder = exports.validateCollectionFeaturesForApiTestEditor = exports.generateRawScriptField = exports.processPostmanItems = exports.createEmptyRequest = exports.createEmptyRequestEventArray = void 0;
|
|
8
8
|
const newman_types_1 = require("./newman-types");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
|
+
const mablApi_1 = require("../../mablApi");
|
|
11
12
|
const encodingUtil_1 = require("../../util/encodingUtil");
|
|
12
13
|
const stepValidation_1 = require("../entityValidation/stepValidation");
|
|
13
14
|
exports.TEST_LISTEN = 'test';
|
|
@@ -744,20 +745,6 @@ function toPostmanScript(assertion) {
|
|
|
744
745
|
.map((script) => script);
|
|
745
746
|
}
|
|
746
747
|
exports.toPostmanScript = toPostmanScript;
|
|
747
|
-
function insertMablAssertionScripts(item) {
|
|
748
|
-
var _a, _b;
|
|
749
|
-
const { eventValue: existingEventValue } = findFirstMatchingEvent(item.event, exports.TEST_LISTEN);
|
|
750
|
-
const eventValue = existingEventValue !== null && existingEventValue !== void 0 ? existingEventValue : createEmptyRequestEvent();
|
|
751
|
-
if (!existingEventValue) {
|
|
752
|
-
(_a = item.event) === null || _a === void 0 ? void 0 : _a.push(eventValue);
|
|
753
|
-
}
|
|
754
|
-
removeMablGeneratedScripts(eventValue);
|
|
755
|
-
eventValue.mablVariables = filterValidMablVariableAssignments(eventValue.mablVariables);
|
|
756
|
-
eventValue.mablAssertions = filterValidMablAssertions(eventValue.mablAssertions);
|
|
757
|
-
const mablScripts = createMablGeneratedScripts(eventValue);
|
|
758
|
-
(_b = eventValue.script.exec) === null || _b === void 0 ? void 0 : _b.push(...mablScripts);
|
|
759
|
-
}
|
|
760
|
-
exports.insertMablAssertionScripts = insertMablAssertionScripts;
|
|
761
748
|
function createMablGeneratedScripts(event) {
|
|
762
749
|
const mablVariables = convertMablVariableAssignmentsToExecArray(event);
|
|
763
750
|
const mablAssertions = convertMablAssertionsToExecArray(event);
|
|
@@ -1104,8 +1091,7 @@ function convertMablSnippetsToExecArray(event, getSnippetFromInvariantId) {
|
|
|
1104
1091
|
: apiTestSnippet;
|
|
1105
1092
|
if (!(snippet === null || snippet === void 0 ? void 0 : snippet.body)) {
|
|
1106
1093
|
if (apiTestSnippet.reusable) {
|
|
1107
|
-
|
|
1108
|
-
return `// Missing snippet ${apiTestSnippet.invariantId}`;
|
|
1094
|
+
throw new Error(`Unable to find reusable snippet with invariant ID ${apiTestSnippet.invariantId}`);
|
|
1109
1095
|
}
|
|
1110
1096
|
return '';
|
|
1111
1097
|
}
|
|
@@ -1348,3 +1334,28 @@ function postmanEventToExecutableSnippets(event) {
|
|
|
1348
1334
|
exports.postmanEventToExecutableSnippets = postmanEventToExecutableSnippets;
|
|
1349
1335
|
const uuid = () => (0, uuid_1.v4)();
|
|
1350
1336
|
exports.uuid = uuid;
|
|
1337
|
+
function getSnippetReferencesInCollection(collection) {
|
|
1338
|
+
var _a, _b;
|
|
1339
|
+
return (((_a = collection.item) !== null && _a !== void 0 ? _a : [])
|
|
1340
|
+
.flatMap((item) => { var _a; return (_a = item.event) !== null && _a !== void 0 ? _a : []; })
|
|
1341
|
+
.concat((_b = collection.event) !== null && _b !== void 0 ? _b : [])
|
|
1342
|
+
.flatMap((event) => { var _a; return (_a = event.mablSnippets) !== null && _a !== void 0 ? _a : []; })
|
|
1343
|
+
.filter((snippet) => snippet.reusable)
|
|
1344
|
+
.map((snippet) => snippet.invariantId)
|
|
1345
|
+
.map((invariantId) => ({
|
|
1346
|
+
id: invariantId,
|
|
1347
|
+
snippetType: mablApi_1.SnippetTypeEnum.Postman,
|
|
1348
|
+
})));
|
|
1349
|
+
}
|
|
1350
|
+
exports.getSnippetReferencesInCollection = getSnippetReferencesInCollection;
|
|
1351
|
+
function getSnippetReferencesInTest(test) {
|
|
1352
|
+
var _a, _b, _c, _d;
|
|
1353
|
+
return ((_b = (_a = test.api_configuration) === null || _a === void 0 ? void 0 : _a.pre_request_snippets) !== null && _b !== void 0 ? _b : [])
|
|
1354
|
+
.concat((_d = (_c = test.api_configuration) === null || _c === void 0 ? void 0 : _c.post_request_snippets) !== null && _d !== void 0 ? _d : [])
|
|
1355
|
+
.filter((snippet) => snippet.reusable)
|
|
1356
|
+
.map(({ invariant_id: invariantId }) => ({
|
|
1357
|
+
id: invariantId,
|
|
1358
|
+
snippetType: mablApi_1.SnippetTypeEnum.Postman,
|
|
1359
|
+
}));
|
|
1360
|
+
}
|
|
1361
|
+
exports.getSnippetReferencesInTest = getSnippetReferencesInTest;
|