@mablhq/mabl-cli 1.58.20 → 1.58.25

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.
Files changed (108) hide show
  1. package/api/basicApiClient.js +21 -15
  2. package/api/mablApiClient.js +40 -48
  3. package/api/mablApiClientFactory.js +1 -1
  4. package/auth/OktaClient.js +1 -2
  5. package/browserEngines/chromiumBrowserEngine.js +1 -2
  6. package/browserEngines/firefoxBrowserEngine.js +2 -2
  7. package/browserEngines/webkitBrowerEngine.js +2 -2
  8. package/browserLauncher/browserLauncherFactory.js +2 -3
  9. package/browserLauncher/elementHandle.js +1 -2
  10. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +12 -20
  11. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +1 -1
  12. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +7 -10
  13. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +3 -4
  14. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +4 -5
  15. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +4 -7
  16. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +1 -1
  17. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +6 -5
  18. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +31 -37
  19. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +8 -9
  20. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +4 -8
  21. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +4 -6
  22. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +1 -2
  23. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +1 -1
  24. package/browserTestMonitoring/metricsRecorder.js +6 -6
  25. package/commands/commandUtil/branches.js +2 -3
  26. package/commands/commandUtil/codeInsights.js +13 -16
  27. package/commands/commandUtil/fileUtil.js +1 -1
  28. package/commands/commandUtil/util.js +3 -4
  29. package/commands/commandUtil/versionUtil.js +4 -5
  30. package/commands/config/config_cmds/list.js +2 -2
  31. package/commands/constants.js +3 -1
  32. package/commands/datatables/datatables_cmds/create.js +2 -3
  33. package/commands/datatables/datatables_cmds/export.js +3 -5
  34. package/commands/datatables/datatables_cmds/list.js +1 -2
  35. package/commands/datatables/datatables_cmds/scenarios.js +1 -2
  36. package/commands/datatables/datatables_cmds/update.js +11 -11
  37. package/commands/datatables/utils.js +9 -9
  38. package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +6 -8
  39. package/commands/deploy/deploy_cmds/create.js +11 -13
  40. package/commands/deploy/deploy_cmds/executionResultPresenter.js +8 -11
  41. package/commands/deploy/deploy_cmds/list.js +3 -4
  42. package/commands/deploy/deploy_cmds/watch.js +1 -2
  43. package/commands/environments/environments_cmds/create.js +1 -2
  44. package/commands/environments/environments_cmds/delete.js +1 -2
  45. package/commands/environments/environments_cmds/update.js +1 -2
  46. package/commands/environments/environments_cmds/urls_cmds/list.js +1 -2
  47. package/commands/flows/flows_cmds/export.js +1 -2
  48. package/commands/plans/plans_cmds/describe.js +1 -2
  49. package/commands/tests/mobileEmulationUtil.js +5 -7
  50. package/commands/tests/testsUtil.js +40 -42
  51. package/commands/tests/tests_cmds/export.js +1 -2
  52. package/commands/tests/tests_cmds/import.js +4 -5
  53. package/commands/tests/tests_cmds/run-cloud.js +12 -13
  54. package/commands/tests/tests_cmds/run.js +30 -11
  55. package/commands/users/users_cmds/list.js +2 -2
  56. package/commands/workspaces/workspace_cmds/copy.js +1 -2
  57. package/core/execution/ApiTestUtils.js +82 -94
  58. package/core/execution/LocalizationOptionsLists.js +1253 -0
  59. package/core/messaging/logLineMessaging.js +2 -3
  60. package/core/messaging/messaging.js +6 -7
  61. package/core/trainer/trainingSessions.js +15 -15
  62. package/coreWebVitals/index.js +14 -18
  63. package/domUtil/index.js +1 -1
  64. package/execution/index.js +1 -1
  65. package/functions/apiTest/utils.js +4 -5
  66. package/http/MablHttpAgent.js +4 -6
  67. package/http/RequestSecurityError.js +1 -1
  68. package/http/axiosProxyConfig.js +3 -5
  69. package/http/httpUtil.js +2 -3
  70. package/http/requestInterceptor.js +11 -15
  71. package/mablApi/index.js +1 -1
  72. package/mablscript/MablAction.js +2 -3
  73. package/mablscript/MablStep.js +2 -4
  74. package/mablscript/MablSymbol.js +1 -1
  75. package/mablscript/actions/ConditionAction.js +2 -4
  76. package/mablscript/actions/FindAction.js +2 -4
  77. package/mablscript/diffing/diffingUtil.js +8 -7
  78. package/mablscript/importer.js +1 -2
  79. package/mablscript/steps/AccessibilityCheck.js +7 -9
  80. package/mablscript/steps/AssertStep.js +11 -16
  81. package/mablscript/steps/ClickAndHoldStep.js +1 -2
  82. package/mablscript/steps/CookieUtils.js +40 -7
  83. package/mablscript/steps/CreateVariableStep.js +1 -2
  84. package/mablscript/steps/DownloadStep.js +1 -2
  85. package/mablscript/steps/EnterTextStep.js +1 -2
  86. package/mablscript/steps/EvaluateFlowStep.js +1 -1
  87. package/mablscript/steps/IfConditionStep.js +4 -6
  88. package/mablscript/steps/ReleaseStep.js +1 -2
  89. package/mablscript/steps/SendHttpRequestStep.js +2 -4
  90. package/mablscript/steps/SendKeyStep.js +1 -1
  91. package/mablscript/steps/SetCookieStep.js +35 -20
  92. package/mablscript/steps/SetViewportStep.js +1 -1
  93. package/mablscript/steps/SwitchContextStep.js +3 -6
  94. package/mablscript/steps/SyntheticStep.js +1 -2
  95. package/mablscriptFind/index.js +1 -1
  96. package/middleware.js +1 -2
  97. package/package.json +2 -2
  98. package/popupDismissal/index.js +4 -5
  99. package/providers/authenticationProvider.js +5 -6
  100. package/providers/cliConfigProvider.js +10 -12
  101. package/providers/exportRequestProvider.js +3 -5
  102. package/providers/logging/loggingProvider.js +1 -1
  103. package/reporters/mochAwesome/mochAwesomeReporter.js +12 -14
  104. package/resources/mablFind.js +1 -1
  105. package/util/actionabilityUtil.js +1 -1
  106. package/util/analytics.js +6 -9
  107. package/util/browserTestUtils.js +1 -2
  108. package/util/markdownUtil.js +9 -11
@@ -49,8 +49,8 @@ const EXPECT_FUNCTIONS = {
49
49
  NotPresent: 'be.undefined',
50
50
  };
51
51
  function compareStringsCaseInsensitive(a, b) {
52
- a = a === null || a === void 0 ? void 0 : a.toLowerCase();
53
- b = b === null || b === void 0 ? void 0 : b.toLowerCase();
52
+ a = a?.toLowerCase();
53
+ b = b?.toLowerCase();
54
54
  if (!a) {
55
55
  return -1;
56
56
  }
@@ -109,10 +109,9 @@ function createEmptyVariable() {
109
109
  }
110
110
  exports.createEmptyVariable = createEmptyVariable;
111
111
  function deduplicateApiTestExecutionResults(postmanResult) {
112
- var _a;
113
112
  const executionsById = {};
114
113
  const orderedExecutionIds = [];
115
- (_a = postmanResult.run.executions) === null || _a === void 0 ? void 0 : _a.forEach((execution) => {
114
+ postmanResult.run.executions?.forEach((execution) => {
116
115
  const executionId = execution.id;
117
116
  if (!executionsById[executionId]) {
118
117
  orderedExecutionIds.push(executionId);
@@ -129,10 +128,9 @@ function restoreCustomRequestFields(postmanResult, collection) {
129
128
  return collectionSet;
130
129
  }, {});
131
130
  postmanResult.run.executions.forEach((execution) => {
132
- var _a;
133
131
  const requestItemDefinition = requestItemsById[execution.id];
134
- if (((_a = execution.request.body) === null || _a === void 0 ? void 0 : _a.mode) === 'formdata' &&
135
- (requestItemDefinition === null || requestItemDefinition === void 0 ? void 0 : requestItemDefinition.request)) {
132
+ if (execution.request.body?.mode === 'formdata' &&
133
+ requestItemDefinition?.request) {
136
134
  restoreFormDataFileMetadata(execution.request, requestItemDefinition.request);
137
135
  }
138
136
  });
@@ -140,15 +138,14 @@ function restoreCustomRequestFields(postmanResult, collection) {
140
138
  }
141
139
  exports.restoreCustomRequestFields = restoreCustomRequestFields;
142
140
  function restoreFormDataFileMetadata(resultRequest, collectionRequest) {
143
- var _a, _b, _c, _d, _e;
144
- if ((_a = resultRequest.body) === null || _a === void 0 ? void 0 : _a.formdata) {
145
- const requestFormDataBySrc = (_c = (_b = collectionRequest === null || collectionRequest === void 0 ? void 0 : collectionRequest.body) === null || _b === void 0 ? void 0 : _b.formdata) === null || _c === void 0 ? void 0 : _c.reduce((set, formData) => {
141
+ if (resultRequest.body?.formdata) {
142
+ const requestFormDataBySrc = collectionRequest?.body?.formdata?.reduce((set, formData) => {
146
143
  if (formData.src) {
147
144
  set[formData.src] = formData;
148
145
  }
149
146
  return set;
150
147
  }, {});
151
- if (!Array.isArray((_d = resultRequest.body) === null || _d === void 0 ? void 0 : _d.formdata)) {
148
+ if (!Array.isArray(resultRequest.body?.formdata)) {
152
149
  resultRequest.body.formdata = resultRequest.body.formdata
153
150
  .all()
154
151
  .map((formParam) => formParam);
@@ -158,7 +155,7 @@ function restoreFormDataFileMetadata(resultRequest, collectionRequest) {
158
155
  resultFormParam.src &&
159
156
  !resultFormParam.mablFile) {
160
157
  resultFormParam.mablFile =
161
- (_e = requestFormDataBySrc[resultFormParam.src]) === null || _e === void 0 ? void 0 : _e.mablFile;
158
+ requestFormDataBySrc[resultFormParam.src]?.mablFile;
162
159
  }
163
160
  }
164
161
  }
@@ -167,7 +164,7 @@ function findFirstMatchingEvent(eventDefinition, listen) {
167
164
  const eventIndex = lodash_1.default.findIndex(eventDefinition, { listen });
168
165
  let eventValue;
169
166
  if (eventIndex !== -1) {
170
- eventValue = eventDefinition === null || eventDefinition === void 0 ? void 0 : eventDefinition[eventIndex];
167
+ eventValue = eventDefinition?.[eventIndex];
171
168
  }
172
169
  return { eventIndex, eventValue };
173
170
  }
@@ -200,8 +197,7 @@ function removeMablGeneratedScriptsFromLines(lines) {
200
197
  return lines;
201
198
  }
202
199
  function removeMablGeneratedScripts(eventDefinition) {
203
- var _a, _b;
204
- lodash_1.default.set(eventDefinition, 'script.exec', removeMablGeneratedScriptsFromLines((_b = (_a = eventDefinition.script) === null || _a === void 0 ? void 0 : _a.exec) !== null && _b !== void 0 ? _b : []));
200
+ lodash_1.default.set(eventDefinition, 'script.exec', removeMablGeneratedScriptsFromLines(eventDefinition.script?.exec ?? []));
205
201
  }
206
202
  exports.removeMablGeneratedScripts = removeMablGeneratedScripts;
207
203
  function isValidMablVariableAssignment(variable) {
@@ -209,11 +205,11 @@ function isValidMablVariableAssignment(variable) {
209
205
  }
210
206
  exports.isValidMablVariableAssignment = isValidMablVariableAssignment;
211
207
  function filterValidMablVariableAssignments(variables) {
212
- return variables === null || variables === void 0 ? void 0 : variables.filter(isValidMablVariableAssignment);
208
+ return variables?.filter(isValidMablVariableAssignment);
213
209
  }
214
210
  exports.filterValidMablVariableAssignments = filterValidMablVariableAssignments;
215
211
  function filterValidMablAssertions(assertions) {
216
- return assertions === null || assertions === void 0 ? void 0 : assertions.filter(isValidMablAssertion);
212
+ return assertions?.filter(isValidMablAssertion);
217
213
  }
218
214
  exports.filterValidMablAssertions = filterValidMablAssertions;
219
215
  function assertionRequiresValue(assertion) {
@@ -242,29 +238,28 @@ function normalizeExpectedValue(value) {
242
238
  }
243
239
  exports.normalizeExpectedValue = normalizeExpectedValue;
244
240
  function isValidMablAssertion(assertion) {
245
- var _a, _b, _c, _d, _e, _f, _g, _h;
246
241
  if (!assertion.assertType) {
247
242
  return false;
248
243
  }
249
244
  const assertTarget = assertion.assertTarget;
250
245
  const requiresValue = assertionRequiresValue(assertion);
251
246
  const expectedValue = normalizeExpectedValue(assertion.value);
252
- const hasRequiredValue = !requiresValue || ((_a = expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length) !== null && _a !== void 0 ? _a : 0) > 0;
247
+ const hasRequiredValue = !requiresValue || (expectedValue?.length ?? 0) > 0;
253
248
  let valid = false;
254
249
  switch (assertTarget) {
255
250
  case 'JSONBody':
256
- const hasBodyPath = ((_d = (_c = (_b = assertion.bodyPath) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
251
+ const hasBodyPath = (assertion.bodyPath?.trim()?.length ?? 0) > 0;
257
252
  valid = hasBodyPath && hasRequiredValue;
258
253
  break;
259
254
  case 'Status':
260
- valid = ((_e = expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length) !== null && _e !== void 0 ? _e : 0) > 0;
255
+ valid = (expectedValue?.length ?? 0) > 0;
261
256
  break;
262
257
  case 'Header':
263
- const hasHeaderName = ((_g = (_f = assertion.headerName) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0) > 0;
258
+ const hasHeaderName = (assertion.headerName?.length ?? 0) > 0;
264
259
  valid = hasHeaderName && hasRequiredValue;
265
260
  break;
266
261
  case 'Size':
267
- valid = ((_h = expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length) !== null && _h !== void 0 ? _h : 0) > 0;
262
+ valid = (expectedValue?.length ?? 0) > 0;
268
263
  break;
269
264
  }
270
265
  return valid;
@@ -346,7 +341,7 @@ function generateVariableAssignmentScript(variable) {
346
341
  }
347
342
  }
348
343
  function generateJsonBodyAssertion(description, assertType, requiresValues, path, expectedValue) {
349
- if (!(path === null || path === void 0 ? void 0 : path.trim().length) || (requiresValues && !(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length))) {
344
+ if (!path?.trim().length || (requiresValues && !expectedValue?.length)) {
350
345
  return;
351
346
  }
352
347
  let propertyAccessor = getJsonBodyProperty(path);
@@ -379,7 +374,7 @@ function generateGetHeaderValue(headerName) {
379
374
  return `pm.response.headers.get(${JSON.stringify(headerName)})`;
380
375
  }
381
376
  function generateStatusAssertion(description, assertType, expectedValue) {
382
- if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
377
+ if (!expectedValue?.length) {
383
378
  return;
384
379
  }
385
380
  let expect;
@@ -402,7 +397,7 @@ function generateStatusAssertion(description, assertType, expectedValue) {
402
397
  default:
403
398
  throw new Error(`Unexpected status assert type: ${assertType}`);
404
399
  }
405
- return generatePostmanTest(description, test !== null && test !== void 0 ? test : `pm.response.${expect}(parseInt(${expectedValue}))`);
400
+ return generatePostmanTest(description, test ?? `pm.response.${expect}(parseInt(${expectedValue}))`);
406
401
  }
407
402
  function generateHeaderAssertion(description, assertType, headerName, expectedValue) {
408
403
  if (!headerName) {
@@ -429,10 +424,11 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
429
424
  default:
430
425
  throw new Error(`Unexpected header assert type: ${assertType}`);
431
426
  }
432
- return generatePostmanTest(description, test !== null && test !== void 0 ? test : `pm.expect(pm.response.headers.get(${normalizedHeaderName})).to.${expect}(${expectedValue})`);
427
+ return generatePostmanTest(description, test ??
428
+ `pm.expect(pm.response.headers.get(${normalizedHeaderName})).to.${expect}(${expectedValue})`);
433
429
  }
434
430
  function generateSizeAssertion(description, target, type, expectedValue) {
435
- if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
431
+ if (!expectedValue?.length) {
436
432
  return;
437
433
  }
438
434
  return generateSimpleAssertion(description, target, type, `parseInt(${expectedValue})`);
@@ -462,14 +458,12 @@ function valueToUnquotedString(value) {
462
458
  }
463
459
  exports.valueToUnquotedString = valueToUnquotedString;
464
460
  function getResponseContentType(response) {
465
- var _a, _b;
466
- const contentType = (_b = (_a = response === null || response === void 0 ? void 0 : response.header) === null || _a === void 0 ? void 0 : _a.find((header) => header.key.toLowerCase() === 'content-type')) === null || _b === void 0 ? void 0 : _b.value;
467
- return contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase();
461
+ const contentType = response?.header?.find((header) => header.key.toLowerCase() === 'content-type')?.value;
462
+ return contentType?.toLowerCase();
468
463
  }
469
464
  exports.getResponseContentType = getResponseContentType;
470
465
  function readBody(body, contentType) {
471
- var _a;
472
- const bodyLength = (_a = body === null || body === void 0 ? void 0 : body.data) === null || _a === void 0 ? void 0 : _a.length;
466
+ const bodyLength = body?.data?.length;
473
467
  if (!body || !bodyLength) {
474
468
  return;
475
469
  }
@@ -505,32 +499,30 @@ function readBody(body, contentType) {
505
499
  }
506
500
  exports.readBody = readBody;
507
501
  function getActualValue(assertion, apiStepExecutionResult, variables) {
508
- var _a, _b, _c, _d;
509
502
  const { assertTarget, bodyPath, headerName } = assertion;
510
503
  switch (assertTarget) {
511
504
  case newman_types_1.AssertionTarget.Header:
512
- return lodash_1.default.find((_a = apiStepExecutionResult.response) === null || _a === void 0 ? void 0 : _a.header, (header) => caseInsensitiveEquals(header.key, headerName));
505
+ return lodash_1.default.find(apiStepExecutionResult.response?.header, (header) => caseInsensitiveEquals(header.key, headerName));
513
506
  case newman_types_1.AssertionTarget.JSONBody:
514
507
  const contentType = getResponseContentType(apiStepExecutionResult.response);
515
- const content = readBody((_b = apiStepExecutionResult.response) === null || _b === void 0 ? void 0 : _b.stream, contentType);
508
+ const content = readBody(apiStepExecutionResult.response?.stream, contentType);
516
509
  return bodyPath
517
510
  ? lodash_1.default.get(content, replaceVariables(bodyPath, variables))
518
511
  : content;
519
512
  case newman_types_1.AssertionTarget.Size:
520
- return (_c = apiStepExecutionResult.response) === null || _c === void 0 ? void 0 : _c.responseSize;
513
+ return apiStepExecutionResult.response?.responseSize;
521
514
  case newman_types_1.AssertionTarget.Status:
522
- return (_d = apiStepExecutionResult.response) === null || _d === void 0 ? void 0 : _d.code;
515
+ return apiStepExecutionResult.response?.code;
523
516
  }
524
517
  return null;
525
518
  }
526
519
  exports.getActualValue = getActualValue;
527
520
  function replaceVariables(value, variables) {
528
- var _a, _b;
529
521
  let toReplace = value;
530
522
  let matches;
531
523
  while ((matches = toReplace.match(new RegExp('{{@(?<name>[^{}]+)}}')))) {
532
- const variableName = (_a = matches.groups) === null || _a === void 0 ? void 0 : _a.name;
533
- const variableValue = (_b = (variableName && variables[variableName])) !== null && _b !== void 0 ? _b : '';
524
+ const variableName = matches.groups?.name;
525
+ const variableValue = (variableName && variables[variableName]) ?? '';
534
526
  toReplace = toReplace.replace(new RegExp(`{{@${variableName}}}`, 'g'), variableValue);
535
527
  }
536
528
  return toReplace;
@@ -546,25 +538,28 @@ function toPostmanScript(assertion) {
546
538
  }
547
539
  exports.toPostmanScript = toPostmanScript;
548
540
  function insertMablAssertionScripts(item) {
549
- var _a, _b, _c, _d, _e, _f;
550
541
  const { eventValue: existingEventValue } = findFirstMatchingEvent(item.event, exports.TEST_LISTEN);
551
- const eventValue = existingEventValue !== null && existingEventValue !== void 0 ? existingEventValue : createEmptyRequestEvent();
542
+ const eventValue = existingEventValue ?? createEmptyRequestEvent();
552
543
  if (!existingEventValue) {
553
- (_a = item.event) === null || _a === void 0 ? void 0 : _a.push(eventValue);
544
+ item.event?.push(eventValue);
554
545
  }
555
546
  removeMablGeneratedScripts(eventValue);
556
547
  eventValue.mablVariables = filterValidMablVariableAssignments(eventValue.mablVariables);
557
548
  eventValue.mablAssertions = filterValidMablAssertions(eventValue.mablAssertions);
558
- const mablVariables = (_b = eventValue.mablVariables) === null || _b === void 0 ? void 0 : _b.map((variable) => toPostmanScript(variable)).flat();
559
- const mablAssertions = (_c = eventValue.mablAssertions) === null || _c === void 0 ? void 0 : _c.map((assertion) => toPostmanScript(assertion)).flat();
560
- if ((mablAssertions === null || mablAssertions === void 0 ? void 0 : mablAssertions.length) || (mablVariables === null || mablVariables === void 0 ? void 0 : mablVariables.length)) {
561
- (_d = eventValue.script.exec) === null || _d === void 0 ? void 0 : _d.push(`// ${exports.MABL_GENERATED_ASSERTION_TOKEN} Do not edit below this line`);
549
+ const mablVariables = eventValue.mablVariables
550
+ ?.map((variable) => toPostmanScript(variable))
551
+ .flat();
552
+ const mablAssertions = eventValue.mablAssertions
553
+ ?.map((assertion) => toPostmanScript(assertion))
554
+ .flat();
555
+ if (mablAssertions?.length || mablVariables?.length) {
556
+ eventValue.script.exec?.push(`// ${exports.MABL_GENERATED_ASSERTION_TOKEN} Do not edit below this line`);
562
557
  }
563
- if (mablVariables === null || mablVariables === void 0 ? void 0 : mablVariables.length) {
564
- (_e = eventValue.script.exec) === null || _e === void 0 ? void 0 : _e.push(...mablVariables);
558
+ if (mablVariables?.length) {
559
+ eventValue.script.exec?.push(...mablVariables);
565
560
  }
566
- if (mablAssertions === null || mablAssertions === void 0 ? void 0 : mablAssertions.length) {
567
- (_f = eventValue.script.exec) === null || _f === void 0 ? void 0 : _f.push(...mablAssertions);
561
+ if (mablAssertions?.length) {
562
+ eventValue.script.exec?.push(...mablAssertions);
568
563
  }
569
564
  }
570
565
  exports.insertMablAssertionScripts = insertMablAssertionScripts;
@@ -649,42 +644,39 @@ function isXML(contentType) {
649
644
  }
650
645
  exports.isXML = isXML;
651
646
  function isText(contentType) {
652
- return !!contentType && (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('text/'));
647
+ return !!contentType && contentType?.startsWith('text/');
653
648
  }
654
649
  exports.isText = isText;
655
650
  function getFormDataArray(item) {
656
- var _a, _b, _c;
657
651
  if (getRequestMode(item) === 'formdata') {
658
- const formdata = (_b = (_a = item === null || item === void 0 ? void 0 : item.request) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.formdata;
652
+ const formdata = item?.request?.body?.formdata;
659
653
  if (Array.isArray(formdata)) {
660
654
  return formdata;
661
655
  }
662
- return (_c = formdata === null || formdata === void 0 ? void 0 : formdata.all()) !== null && _c !== void 0 ? _c : [];
656
+ return formdata?.all() ?? [];
663
657
  }
664
658
  return [];
665
659
  }
666
660
  exports.getFormDataArray = getFormDataArray;
667
661
  function getRequestMode(item) {
668
- var _a, _b;
669
- return (_b = (_a = item === null || item === void 0 ? void 0 : item.request) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.mode;
662
+ return item?.request?.body?.mode;
670
663
  }
671
664
  exports.getRequestMode = getRequestMode;
672
665
  function formatContent(contentContainer) {
673
- if (contentContainer === null || contentContainer === void 0 ? void 0 : contentContainer.hasOwnProperty('content')) {
666
+ if (contentContainer?.hasOwnProperty('content')) {
674
667
  return contentContainer.content;
675
668
  }
676
669
  return contentContainer;
677
670
  }
678
671
  exports.formatContent = formatContent;
679
672
  function processMablProtocolProfileBehavior(item) {
680
- var _a, _b;
681
- const mablProtocolProfileBehavior = (_b = (_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablProtocolProfileBehavior) !== null && _b !== void 0 ? _b : [];
673
+ const mablProtocolProfileBehavior = item.mablTemporaryStorage?.mablProtocolProfileBehavior ?? [];
682
674
  if (mablProtocolProfileBehavior.length === 0) {
683
675
  delete item.protocolProfileBehavior;
684
676
  return;
685
677
  }
686
678
  lodash_1.default.set(item, 'protocolProfileBehavior', {});
687
- mablProtocolProfileBehavior === null || mablProtocolProfileBehavior === void 0 ? void 0 : mablProtocolProfileBehavior.forEach((setting) => {
679
+ mablProtocolProfileBehavior?.forEach((setting) => {
688
680
  if (setting.key && setting.value) {
689
681
  let valueToSet;
690
682
  try {
@@ -701,7 +693,7 @@ function createOptionalVariable(key, type, value, defaultValue) {
701
693
  if (value === undefined && defaultValue === undefined) {
702
694
  return;
703
695
  }
704
- let parsedValue = value !== null && value !== void 0 ? value : defaultValue;
696
+ let parsedValue = value ?? defaultValue;
705
697
  if (type === 'boolean') {
706
698
  parsedValue = parsedValue === 'true';
707
699
  }
@@ -724,17 +716,17 @@ function mablAuthToPostman(mablAuth, undefinedType) {
724
716
  apikey: [
725
717
  {
726
718
  key: 'key',
727
- value: apikey === null || apikey === void 0 ? void 0 : apikey.key,
719
+ value: apikey?.key,
728
720
  type: 'string',
729
721
  },
730
722
  {
731
723
  key: 'value',
732
- value: apikey === null || apikey === void 0 ? void 0 : apikey.value,
724
+ value: apikey?.value,
733
725
  type: 'string',
734
726
  },
735
727
  {
736
728
  key: 'in',
737
- value: apikey === null || apikey === void 0 ? void 0 : apikey.in,
729
+ value: apikey?.in,
738
730
  type: 'string',
739
731
  },
740
732
  ],
@@ -746,12 +738,12 @@ function mablAuthToPostman(mablAuth, undefinedType) {
746
738
  basic: [
747
739
  {
748
740
  key: 'username',
749
- value: basic === null || basic === void 0 ? void 0 : basic.username,
741
+ value: basic?.username,
750
742
  type: 'string',
751
743
  },
752
744
  {
753
745
  key: 'password',
754
- value: basic === null || basic === void 0 ? void 0 : basic.password,
746
+ value: basic?.password,
755
747
  type: 'string',
756
748
  },
757
749
  ],
@@ -763,7 +755,7 @@ function mablAuthToPostman(mablAuth, undefinedType) {
763
755
  bearer: [
764
756
  {
765
757
  key: 'token',
766
- value: bearer === null || bearer === void 0 ? void 0 : bearer.token,
758
+ value: bearer?.token,
767
759
  type: 'string',
768
760
  },
769
761
  ],
@@ -773,20 +765,20 @@ function mablAuthToPostman(mablAuth, undefinedType) {
773
765
  auth = {
774
766
  type,
775
767
  oauth1: [
776
- createOptionalVariable('addParamsToHeader', 'boolean', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.addParamsToHeader, exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE),
777
- createOptionalVariable('addEmptyParamsToSign', 'boolean', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.addEmptyParamsToSign),
778
- createOptionalVariable('callback', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.callback),
779
- createOptionalVariable('consumerKey', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.consumerKey),
780
- createOptionalVariable('consumerSecret', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.consumerSecret),
781
- createOptionalVariable('includeBodyHash', 'boolean', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.includeBodyHash),
782
- createOptionalVariable('nonce', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.nonce),
783
- createOptionalVariable('realm', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.realm),
784
- createOptionalVariable('signatureMethod', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.signatureMethod, exports.HMAC_SHA1_SIGNATURE),
785
- createOptionalVariable('timestamp', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.timestamp),
786
- createOptionalVariable('token', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.token),
787
- createOptionalVariable('tokenSecret', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.tokenSecret),
788
- createOptionalVariable('verifier', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.verifier),
789
- createOptionalVariable('version', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.version, exports.DEFAULT_OAUTH1_VERSION),
768
+ createOptionalVariable('addParamsToHeader', 'boolean', oauth1?.addParamsToHeader, exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE),
769
+ createOptionalVariable('addEmptyParamsToSign', 'boolean', oauth1?.addEmptyParamsToSign),
770
+ createOptionalVariable('callback', 'string', oauth1?.callback),
771
+ createOptionalVariable('consumerKey', 'string', oauth1?.consumerKey),
772
+ createOptionalVariable('consumerSecret', 'string', oauth1?.consumerSecret),
773
+ createOptionalVariable('includeBodyHash', 'boolean', oauth1?.includeBodyHash),
774
+ createOptionalVariable('nonce', 'string', oauth1?.nonce),
775
+ createOptionalVariable('realm', 'string', oauth1?.realm),
776
+ createOptionalVariable('signatureMethod', 'string', oauth1?.signatureMethod, exports.HMAC_SHA1_SIGNATURE),
777
+ createOptionalVariable('timestamp', 'string', oauth1?.timestamp),
778
+ createOptionalVariable('token', 'string', oauth1?.token),
779
+ createOptionalVariable('tokenSecret', 'string', oauth1?.tokenSecret),
780
+ createOptionalVariable('verifier', 'string', oauth1?.verifier),
781
+ createOptionalVariable('version', 'string', oauth1?.version, exports.DEFAULT_OAUTH1_VERSION),
790
782
  ].filter((variable) => variable),
791
783
  };
792
784
  }
@@ -795,29 +787,25 @@ function mablAuthToPostman(mablAuth, undefinedType) {
795
787
  }
796
788
  exports.mablAuthToPostman = mablAuthToPostman;
797
789
  function processItemAuth(item) {
798
- var _a, _b;
799
- const itemAuth = mablAuthToPostman((_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablAuth, exports.INHERIT_AUTH_FROM_PARENT_VALUE);
790
+ const itemAuth = mablAuthToPostman(item.mablTemporaryStorage?.mablAuth, exports.INHERIT_AUTH_FROM_PARENT_VALUE);
800
791
  if (itemAuth) {
801
792
  lodash_1.default.set(item, 'request.auth', itemAuth);
802
793
  }
803
- else if ((_b = item.request) === null || _b === void 0 ? void 0 : _b.auth) {
794
+ else if (item.request?.auth) {
804
795
  item.request.auth = {};
805
796
  }
806
797
  }
807
798
  exports.processItemAuth = processItemAuth;
808
799
  function removeInvalidHeaders(item) {
809
- var _a;
810
- if ((_a = item.request) === null || _a === void 0 ? void 0 : _a.header) {
811
- item.request.header = item.request.header.filter((header) => { var _a, _b; return (_b = (_a = header.key) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.length; });
800
+ if (item.request?.header) {
801
+ item.request.header = item.request.header.filter((header) => header.key?.trim()?.length);
812
802
  }
813
803
  }
814
804
  exports.removeInvalidHeaders = removeInvalidHeaders;
815
805
  function replaceRawScriptWithExecArray(eventsContainer) {
816
- var _a;
817
- (_a = eventsContainer.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => {
818
- var _a, _b, _c;
819
- if (((_a = event.script) === null || _a === void 0 ? void 0 : _a.raw) !== undefined) {
820
- if (((_c = (_b = event.script) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.length) > 0) {
806
+ eventsContainer.event?.forEach((event) => {
807
+ if (event.script?.raw !== undefined) {
808
+ if (event.script?.raw?.length > 0) {
821
809
  event.script.exec = splitLines(event.script.raw);
822
810
  }
823
811
  delete event.script.raw;