@mablhq/mabl-cli 1.58.25 → 1.58.28

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