@mablhq/mabl-cli 2.50.12 → 2.51.4
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/api/featureSet.js +2 -2
- package/browserLauncher/index.js +8 -0
- package/browserLauncher/index.js.LICENSE.txt +28 -0
- package/cli.js +1 -0
- package/commands/environments/environments_cmds/urls_cmds/add.js +5 -5
- package/commands/tests/testsUtil.js +1 -1
- package/commands/tests/tests_cmds/import_cmds/import_playwright.js +7 -1
- package/core/execution/ApiTestUtils.js +219 -7
- package/execution/index.js +2 -2
- package/mablApi/index.js +1 -1
- package/package.json +1 -1
- package/upload/index.js +1 -1
- package/browserLauncher/browser.js +0 -2
- package/browserLauncher/browserEvent.js +0 -11
- package/browserLauncher/browserLauncher.js +0 -17
- package/browserLauncher/browserLauncherEventEmitter.js +0 -2
- package/browserLauncher/browserLauncherFactory.js +0 -30
- package/browserLauncher/elementHandle.js +0 -30
- package/browserLauncher/errors.js +0 -26
- package/browserLauncher/frame.js +0 -17
- package/browserLauncher/frameBase.js +0 -10
- package/browserLauncher/httpRequest.js +0 -2
- package/browserLauncher/httpResponse.js +0 -2
- package/browserLauncher/jsHandle.js +0 -2
- package/browserLauncher/page.js +0 -2
- package/browserLauncher/pageEvent.js +0 -17
- package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +0 -61
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +0 -129
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +0 -24
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +0 -145
- package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +0 -50
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +0 -11
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +0 -26
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/internals.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractBrowserDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +0 -73
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractFrameDelegate.js +0 -13
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +0 -81
- package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +0 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +0 -18
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +0 -259
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +0 -97
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +0 -319
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +0 -265
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +0 -76
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +0 -26
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +0 -377
- package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +0 -36
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitBrowserDelegate.js +0 -50
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +0 -16
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +0 -19
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitPageDelegate.js +0 -15
- package/browserLauncher/playwrightBrowserLauncher/wrappers.js +0 -25
- package/browserLauncher/types.js +0 -28
- package/browserLauncher/utils.js +0 -9
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Tmp
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/*!
|
|
10
|
+
* mime-db
|
|
11
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
12
|
+
* MIT Licensed
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/*!
|
|
16
|
+
* mime-types
|
|
17
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
18
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
19
|
+
* MIT Licensed
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
23
|
+
|
|
24
|
+
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
|
|
25
|
+
|
|
26
|
+
//! moment.js
|
|
27
|
+
|
|
28
|
+
//! moment.js locale configuration
|
package/cli.js
CHANGED
|
@@ -43,6 +43,7 @@ yargs
|
|
|
43
43
|
.commandDir('./commands/branches')
|
|
44
44
|
.commandDir('./commands/config')
|
|
45
45
|
.commandDir('./commands/credentials')
|
|
46
|
+
.commandDir('./commands/databases')
|
|
46
47
|
.commandDir('./commands/datatables')
|
|
47
48
|
.commandDir('./commands/deploy')
|
|
48
49
|
.commandDir('./commands/environments')
|
|
@@ -10,12 +10,12 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
10
10
|
const loggingProvider_1 = require("../../../../providers/logging/loggingProvider");
|
|
11
11
|
const mablApi_1 = require("../../../../mablApi");
|
|
12
12
|
const mablApiClientFactory_1 = require("../../../../api/mablApiClientFactory");
|
|
13
|
-
exports.command = `add
|
|
14
|
-
exports.describe = 'Associate
|
|
13
|
+
exports.command = `add <${constants_1.CommandArgId}>`;
|
|
14
|
+
exports.describe = 'Associate URLs with an environment';
|
|
15
15
|
exports.builder = (yargs) => {
|
|
16
16
|
addEnvironmentUrlOptions(yargs)
|
|
17
17
|
.positional(constants_1.CommandArgId, {
|
|
18
|
-
describe: 'Id of environment to add
|
|
18
|
+
describe: 'Id of environment to add URL associations to',
|
|
19
19
|
type: 'string',
|
|
20
20
|
})
|
|
21
21
|
.demandOption(constants_1.CommandArgApplicationId);
|
|
@@ -29,11 +29,11 @@ function addEnvironmentUrlOptions(yargs) {
|
|
|
29
29
|
type: 'string',
|
|
30
30
|
})
|
|
31
31
|
.option(constants_1.CommandArgUrlApp, {
|
|
32
|
-
describe: 'web application
|
|
32
|
+
describe: 'web application URLs to associate with the application-environment pair',
|
|
33
33
|
type: 'array',
|
|
34
34
|
})
|
|
35
35
|
.option(constants_1.CommandArgUrlApi, {
|
|
36
|
-
describe: '
|
|
36
|
+
describe: 'API URLs to associate with the application-environment pair',
|
|
37
37
|
type: 'array',
|
|
38
38
|
})
|
|
39
39
|
.check((argv) => {
|
|
@@ -31,7 +31,7 @@ const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
32
|
const os = __importStar(require("os"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
|
-
const browserLauncher_1 = require("../../browserLauncher
|
|
34
|
+
const browserLauncher_1 = require("../../browserLauncher");
|
|
35
35
|
const trainingSessionActions_1 = require("../../core/messaging/actions/trainingSessionActions");
|
|
36
36
|
const logLineMessaging_1 = require("../../core/messaging/logLineMessaging");
|
|
37
37
|
const messaging_1 = require("../../core/messaging/messaging");
|
|
@@ -366,6 +366,9 @@ async function getProjectInfo(args) {
|
|
|
366
366
|
...process.env,
|
|
367
367
|
},
|
|
368
368
|
};
|
|
369
|
+
if (process.platform === 'win32') {
|
|
370
|
+
options.shell = true;
|
|
371
|
+
}
|
|
369
372
|
const processClosedPromise = new RichPromise_1.default();
|
|
370
373
|
const playwrightProcess = spawn('npx', commandArgs, options);
|
|
371
374
|
playwrightProcess.stdout.on('data', (data) => {
|
|
@@ -411,8 +414,11 @@ async function runPlaywrightProject(args, tracesPath, cwd) {
|
|
|
411
414
|
...process.env,
|
|
412
415
|
},
|
|
413
416
|
};
|
|
417
|
+
if (process.platform === 'win32') {
|
|
418
|
+
options.shell = true;
|
|
419
|
+
}
|
|
414
420
|
loggingProvider_1.logger.info('Checking playwright project...');
|
|
415
|
-
const playwrightProjectFile = path_1.default.join(options.cwd, 'playwright.config.ts');
|
|
421
|
+
const playwrightProjectFile = path_1.default.join(options.cwd.toString(), 'playwright.config.ts');
|
|
416
422
|
if (!fs_1.default.existsSync(playwrightProjectFile)) {
|
|
417
423
|
throw new Error('No playwright project found. Please ensure you are in the root directory of a playwright project.');
|
|
418
424
|
}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PRE_REQUEST_LISTEN = exports.convertMablAssertionsToExecArray = exports.convertMablVariableAssignmentsToExecArray = exports.createMablGeneratedScripts = exports.insertMablAssertionScripts = 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.uuid = 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.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 = exports.splitLines = void 0;
|
|
7
|
+
exports.uuid = exports.postmanEventToExecutableSnippets = exports.postmanAuthToApiTestAuth = exports.getValueFromAuthVariables = 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.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 = exports.splitLines = 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");
|
|
@@ -997,13 +997,10 @@ function processPostmanItem(item) {
|
|
|
997
997
|
removeInvalidHeaders(item);
|
|
998
998
|
}
|
|
999
999
|
exports.processPostmanItem = processPostmanItem;
|
|
1000
|
-
function insertMablScriptsIntoCollection(
|
|
1000
|
+
function insertMablScriptsIntoCollection(itemGroup, getSnippet) {
|
|
1001
1001
|
var _a, _b;
|
|
1002
|
-
(_a =
|
|
1003
|
-
(_b =
|
|
1004
|
-
var _a;
|
|
1005
|
-
return (_a = item.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => insertMablScriptsIntoEvent(event, getSnippet));
|
|
1006
|
-
});
|
|
1002
|
+
(_a = itemGroup.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => insertMablScriptsIntoEvent(event, getSnippet));
|
|
1003
|
+
(_b = itemGroup.item) === null || _b === void 0 ? void 0 : _b.forEach((item) => insertMablScriptsIntoCollection(item, getSnippet));
|
|
1007
1004
|
}
|
|
1008
1005
|
exports.insertMablScriptsIntoCollection = insertMablScriptsIntoCollection;
|
|
1009
1006
|
function insertMablScriptsIntoEvent(event, getSnippet) {
|
|
@@ -1060,5 +1057,220 @@ function createCommentForApiTestSnippet(snippet, position) {
|
|
|
1060
1057
|
return `// ${position} of one-time snippet "${(_b = snippet.name) !== null && _b !== void 0 ? _b : snippet.id}"`;
|
|
1061
1058
|
}
|
|
1062
1059
|
exports.createCommentForApiTestSnippet = createCommentForApiTestSnippet;
|
|
1060
|
+
function insertTestConfigurationIntoFlow(test, flow) {
|
|
1061
|
+
var _a;
|
|
1062
|
+
const collection = flow.api_steps;
|
|
1063
|
+
const testConfiguration = test.api_configuration;
|
|
1064
|
+
if (!testConfiguration) {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
const { authentication, pre_request_snippets: preRequestSnippets, post_request_snippets: postRequestSnippets, } = testConfiguration;
|
|
1068
|
+
if (!authentication &&
|
|
1069
|
+
!(preRequestSnippets === null || preRequestSnippets === void 0 ? void 0 : preRequestSnippets.length) &&
|
|
1070
|
+
!(postRequestSnippets === null || postRequestSnippets === void 0 ? void 0 : postRequestSnippets.length)) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
const folder = {
|
|
1074
|
+
name: (_a = flow.id) !== null && _a !== void 0 ? _a : 'Flow',
|
|
1075
|
+
item: collection.item,
|
|
1076
|
+
};
|
|
1077
|
+
folder.auth = collection.auth;
|
|
1078
|
+
folder.event = collection.event;
|
|
1079
|
+
delete collection.auth;
|
|
1080
|
+
delete collection.event;
|
|
1081
|
+
collection.item = [folder];
|
|
1082
|
+
if (authentication) {
|
|
1083
|
+
collection.auth = apiTestAuthToPostmanAuth(authentication);
|
|
1084
|
+
}
|
|
1085
|
+
const event = [];
|
|
1086
|
+
if (preRequestSnippets === null || preRequestSnippets === void 0 ? void 0 : preRequestSnippets.length) {
|
|
1087
|
+
event.push(executableSnippetsToPostmanEvent(preRequestSnippets, 'prerequest'));
|
|
1088
|
+
}
|
|
1089
|
+
if (postRequestSnippets === null || postRequestSnippets === void 0 ? void 0 : postRequestSnippets.length) {
|
|
1090
|
+
event.push(executableSnippetsToPostmanEvent(postRequestSnippets, 'test'));
|
|
1091
|
+
}
|
|
1092
|
+
if (event.length) {
|
|
1093
|
+
collection.event = event;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
exports.insertTestConfigurationIntoFlow = insertTestConfigurationIntoFlow;
|
|
1097
|
+
function apiTestAuthToPostmanAuth(apiTestAuth) {
|
|
1098
|
+
const postmanAuth = {
|
|
1099
|
+
type: `${apiTestAuth.type}`,
|
|
1100
|
+
};
|
|
1101
|
+
switch (apiTestAuth.type) {
|
|
1102
|
+
case 'apikey':
|
|
1103
|
+
postmanAuth.apikey = apiKeyAuthenticationToPostman(apiTestAuth.api_key);
|
|
1104
|
+
break;
|
|
1105
|
+
case 'basic':
|
|
1106
|
+
postmanAuth.basic = basicAuthenticationToPostman(apiTestAuth.basic);
|
|
1107
|
+
break;
|
|
1108
|
+
case 'bearer':
|
|
1109
|
+
postmanAuth.bearer = bearerAuthenticationToPostman(apiTestAuth.bearer);
|
|
1110
|
+
break;
|
|
1111
|
+
case 'oauth1':
|
|
1112
|
+
postmanAuth.oauth1 = oauth1AuthenticationToPostman(apiTestAuth.oauth1);
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
return postmanAuth;
|
|
1116
|
+
}
|
|
1117
|
+
function apiKeyAuthenticationToPostman(auth) {
|
|
1118
|
+
return removeUndefinedValues([
|
|
1119
|
+
toPostmanConfigurationValue('key', auth === null || auth === void 0 ? void 0 : auth.key),
|
|
1120
|
+
toPostmanConfigurationValue('value', auth === null || auth === void 0 ? void 0 : auth.value),
|
|
1121
|
+
toPostmanConfigurationValue('in', auth === null || auth === void 0 ? void 0 : auth.location),
|
|
1122
|
+
]);
|
|
1123
|
+
}
|
|
1124
|
+
function basicAuthenticationToPostman(auth) {
|
|
1125
|
+
return removeUndefinedValues([
|
|
1126
|
+
toPostmanConfigurationValue('username', auth === null || auth === void 0 ? void 0 : auth.username),
|
|
1127
|
+
toPostmanConfigurationValue('password', auth === null || auth === void 0 ? void 0 : auth.password),
|
|
1128
|
+
]);
|
|
1129
|
+
}
|
|
1130
|
+
function bearerAuthenticationToPostman(auth) {
|
|
1131
|
+
return removeUndefinedValues([
|
|
1132
|
+
toPostmanConfigurationValue('token', auth === null || auth === void 0 ? void 0 : auth.token),
|
|
1133
|
+
]);
|
|
1134
|
+
}
|
|
1135
|
+
function oauth1AuthenticationToPostman(auth) {
|
|
1136
|
+
return removeUndefinedValues([
|
|
1137
|
+
toPostmanConfigurationValue('addParamsToHeader', auth === null || auth === void 0 ? void 0 : auth.add_parameters_to_header, 'boolean'),
|
|
1138
|
+
toPostmanConfigurationValue('addEmptyParamsToSign', auth === null || auth === void 0 ? void 0 : auth.add_empty_parameters_to_signature, 'boolean'),
|
|
1139
|
+
toPostmanConfigurationValue('callback', auth === null || auth === void 0 ? void 0 : auth.callback_url),
|
|
1140
|
+
toPostmanConfigurationValue('consumerKey', auth === null || auth === void 0 ? void 0 : auth.consumer_key),
|
|
1141
|
+
toPostmanConfigurationValue('consumerSecret', auth === null || auth === void 0 ? void 0 : auth.consumer_secret),
|
|
1142
|
+
toPostmanConfigurationValue('includeBodyHash', auth === null || auth === void 0 ? void 0 : auth.include_body_hash, 'boolean'),
|
|
1143
|
+
toPostmanConfigurationValue('nonce', auth === null || auth === void 0 ? void 0 : auth.nonce),
|
|
1144
|
+
toPostmanConfigurationValue('realm', auth === null || auth === void 0 ? void 0 : auth.realm),
|
|
1145
|
+
toPostmanConfigurationValue('signatureMethod', auth === null || auth === void 0 ? void 0 : auth.signature_method),
|
|
1146
|
+
toPostmanConfigurationValue('timestamp', auth === null || auth === void 0 ? void 0 : auth.timestamp),
|
|
1147
|
+
toPostmanConfigurationValue('token', auth === null || auth === void 0 ? void 0 : auth.token),
|
|
1148
|
+
toPostmanConfigurationValue('tokenSecret', auth === null || auth === void 0 ? void 0 : auth.token_secret),
|
|
1149
|
+
toPostmanConfigurationValue('verifier', auth === null || auth === void 0 ? void 0 : auth.verifier),
|
|
1150
|
+
toPostmanConfigurationValue('version', auth === null || auth === void 0 ? void 0 : auth.version),
|
|
1151
|
+
]);
|
|
1152
|
+
}
|
|
1153
|
+
const removeUndefinedValues = (values) => values.filter((value) => value !== undefined);
|
|
1154
|
+
function toPostmanConfigurationValue(key, value, type = 'string') {
|
|
1155
|
+
if (!value) {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
if (type === 'string') {
|
|
1159
|
+
value = `${value}`;
|
|
1160
|
+
}
|
|
1161
|
+
if (type === 'boolean') {
|
|
1162
|
+
value = `${value}`.toLowerCase() === 'true';
|
|
1163
|
+
}
|
|
1164
|
+
return {
|
|
1165
|
+
key,
|
|
1166
|
+
value,
|
|
1167
|
+
type,
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
function executableSnippetsToPostmanEvent(snippets, type) {
|
|
1171
|
+
return {
|
|
1172
|
+
id: (0, exports.uuid)(),
|
|
1173
|
+
listen: type,
|
|
1174
|
+
mablSnippets: snippets.map((snippet) => executableSnippetToApiTestSnippet(snippet)),
|
|
1175
|
+
script: {
|
|
1176
|
+
exec: [],
|
|
1177
|
+
id: (0, exports.uuid)(),
|
|
1178
|
+
type: 'text/javascript',
|
|
1179
|
+
},
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
function executableSnippetToApiTestSnippet(executableSnippet) {
|
|
1183
|
+
const { invariant_id: invariantId, ...snippet } = { ...executableSnippet };
|
|
1184
|
+
if (executableSnippet.reusable) {
|
|
1185
|
+
return {
|
|
1186
|
+
invariantId: invariantId,
|
|
1187
|
+
reusable: true,
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
return {
|
|
1191
|
+
...snippet,
|
|
1192
|
+
reusable: false,
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
function getValueFromAuthVariables(authVariables, variableName) {
|
|
1196
|
+
var _a;
|
|
1197
|
+
return (_a = authVariables === null || authVariables === void 0 ? void 0 : authVariables.find((variable) => variable.key === variableName)) === null || _a === void 0 ? void 0 : _a.value;
|
|
1198
|
+
}
|
|
1199
|
+
exports.getValueFromAuthVariables = getValueFromAuthVariables;
|
|
1200
|
+
function postmanAuthToApiTestAuth(auth) {
|
|
1201
|
+
const { type: authType } = auth || {};
|
|
1202
|
+
if (!authType || authType === 'noauth') {
|
|
1203
|
+
return undefined;
|
|
1204
|
+
}
|
|
1205
|
+
const apiTestAuth = {
|
|
1206
|
+
type: authType,
|
|
1207
|
+
};
|
|
1208
|
+
const getValueFromVariablesForAuthType = (variableName) => getValueFromAuthVariables(auth[authType], variableName);
|
|
1209
|
+
switch (authType) {
|
|
1210
|
+
case 'apikey':
|
|
1211
|
+
apiTestAuth.api_key = {
|
|
1212
|
+
location: getValueFromVariablesForAuthType('in'),
|
|
1213
|
+
key: getValueFromVariablesForAuthType('key'),
|
|
1214
|
+
value: getValueFromVariablesForAuthType('value'),
|
|
1215
|
+
};
|
|
1216
|
+
break;
|
|
1217
|
+
case 'basic':
|
|
1218
|
+
apiTestAuth.basic = {
|
|
1219
|
+
username: getValueFromVariablesForAuthType('username'),
|
|
1220
|
+
password: getValueFromVariablesForAuthType('password'),
|
|
1221
|
+
};
|
|
1222
|
+
break;
|
|
1223
|
+
case 'bearer':
|
|
1224
|
+
apiTestAuth.bearer = {
|
|
1225
|
+
token: getValueFromVariablesForAuthType('token'),
|
|
1226
|
+
};
|
|
1227
|
+
break;
|
|
1228
|
+
case 'oauth1':
|
|
1229
|
+
apiTestAuth.oauth1 = {
|
|
1230
|
+
consumer_key: getValueFromVariablesForAuthType('consumerKey'),
|
|
1231
|
+
consumer_secret: getValueFromVariablesForAuthType('consumerSecret'),
|
|
1232
|
+
token: getValueFromVariablesForAuthType('token'),
|
|
1233
|
+
token_secret: getValueFromVariablesForAuthType('tokenSecret'),
|
|
1234
|
+
signature_method: getValueFromVariablesForAuthType('signatureMethod'),
|
|
1235
|
+
nonce: getValueFromVariablesForAuthType('nonce'),
|
|
1236
|
+
timestamp: getValueFromVariablesForAuthType('timestamp'),
|
|
1237
|
+
version: getValueFromVariablesForAuthType('version'),
|
|
1238
|
+
realm: getValueFromVariablesForAuthType('realm'),
|
|
1239
|
+
add_parameters_to_header: getValueFromVariablesForAuthType('addParamsToHeader'),
|
|
1240
|
+
add_empty_parameters_to_signature: getValueFromVariablesForAuthType('addEmptyParamsToSignature'),
|
|
1241
|
+
callback_url: getValueFromVariablesForAuthType('callbackUrl'),
|
|
1242
|
+
include_body_hash: getValueFromVariablesForAuthType('includeBodyHash'),
|
|
1243
|
+
verifier: getValueFromVariablesForAuthType('verifier'),
|
|
1244
|
+
};
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
return apiTestAuth;
|
|
1248
|
+
}
|
|
1249
|
+
exports.postmanAuthToApiTestAuth = postmanAuthToApiTestAuth;
|
|
1250
|
+
function postmanEventToExecutableSnippets(event) {
|
|
1251
|
+
var _a, _b;
|
|
1252
|
+
if (!event) {
|
|
1253
|
+
return [];
|
|
1254
|
+
}
|
|
1255
|
+
return ((_b = (_a = event.mablSnippets) === null || _a === void 0 ? void 0 : _a.map((snippet) => {
|
|
1256
|
+
if (snippet.reusable) {
|
|
1257
|
+
const executableSnippet = {
|
|
1258
|
+
invariant_id: snippet.invariantId,
|
|
1259
|
+
reusable: true,
|
|
1260
|
+
};
|
|
1261
|
+
return executableSnippet;
|
|
1262
|
+
}
|
|
1263
|
+
const executableSnippet = {
|
|
1264
|
+
reusable: false,
|
|
1265
|
+
body: snippet.body,
|
|
1266
|
+
description: snippet.description,
|
|
1267
|
+
name: snippet.name,
|
|
1268
|
+
snippet_type: snippet.snippet_type,
|
|
1269
|
+
workspace_id: snippet.workspace_id,
|
|
1270
|
+
};
|
|
1271
|
+
return executableSnippet;
|
|
1272
|
+
})) !== null && _b !== void 0 ? _b : []);
|
|
1273
|
+
}
|
|
1274
|
+
exports.postmanEventToExecutableSnippets = postmanEventToExecutableSnippets;
|
|
1063
1275
|
const uuid = () => (0, uuid_1.v4)();
|
|
1064
1276
|
exports.uuid = uuid;
|