@mablhq/mabl-cli 2.45.2 → 2.45.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FeatureSet = exports.FindImplementationVersion = exports.PRIVATE_BETA_AI_ASSERTIONS_FEATURE_FLAG = exports.AI_ASSERTIONS_FEATURE_FLAG = exports.ADVANCED_AUTO_HEALING_FEATURE_FLAG = exports.GENERATIVE_AI_FEATURE_FLAG = void 0;
3
+ exports.FeatureSet = exports.FindImplementationVersion = exports.AI_ASSERTIONS_FEATURE_FLAG = exports.ADVANCED_AUTO_HEALING_FEATURE_FLAG = exports.GENERATIVE_AI_FEATURE_FLAG = void 0;
4
4
  const types_1 = require("../browserLauncher/types");
5
5
  const ACCESSIBILITY_CHECK_FEATURE_FLAG = 'accessibility_checks';
6
6
  const PERFORMANCE_TESTING_FEATURE_FLAG = 'performance_testing';
@@ -8,7 +8,6 @@ const SMARTER_WAIT_FEATURE_FLAG = 'smarter_wait';
8
8
  exports.GENERATIVE_AI_FEATURE_FLAG = 'generative_ai';
9
9
  exports.ADVANCED_AUTO_HEALING_FEATURE_FLAG = 'advanced_auto_healing';
10
10
  exports.AI_ASSERTIONS_FEATURE_FLAG = 'ai_assertion_steps';
11
- exports.PRIVATE_BETA_AI_ASSERTIONS_FEATURE_FLAG = 'ai_assertions';
12
11
  var FindImplementationVersion;
13
12
  (function (FindImplementationVersion) {
14
13
  FindImplementationVersion[FindImplementationVersion["V1"] = 0] = "V1";
@@ -35,9 +34,6 @@ class FeatureSet {
35
34
  hasAiAssertions() {
36
35
  return this.featureFlags.has(exports.AI_ASSERTIONS_FEATURE_FLAG);
37
36
  }
38
- hasPrivateBetaAiAssertions() {
39
- return this.featureFlags.has(exports.PRIVATE_BETA_AI_ASSERTIONS_FEATURE_FLAG);
40
- }
41
37
  allowGenerativeAi() {
42
38
  return this.featureFlags.has(exports.GENERATIVE_AI_FEATURE_FLAG);
43
39
  }
@@ -418,7 +418,8 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
418
418
  throw toApiError(`Failed to get Flows`, error);
419
419
  }
420
420
  }
421
- async getSnippet(snippetId, preferLatestIfReusable, workspaceId) {
421
+ async getSnippet(snippetId, isQuery, preferLatestIfReusable, workspaceId) {
422
+ const entity = isQuery ? 'query' : 'snippet';
422
423
  try {
423
424
  const queryParameter = typeof preferLatestIfReusable === 'boolean'
424
425
  ? `?=preferLatestIfReusable=${preferLatestIfReusable}`
@@ -426,9 +427,9 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
426
427
  return await this.makeGetRequest(`${this.baseApiUrl}/snippets/${snippetId}${queryParameter}`);
427
428
  }
428
429
  catch (error) {
429
- throw toApiError(`Failed to get Snippet [${snippetId}]. ${workspaceId
430
- ? `The Snippet was likely deleted. To recover this snippet, visit the activity feed [workspaces/${workspaceId}/settings/activity-log?activityLogEntity=snippet&activityLogEvent=delete]`
431
- : 'The Snippet was likely deleted. To recover this snippet, visit the activity feed.'}`, error);
430
+ throw toApiError(`Failed to get ${entity} [${snippetId}]. ${workspaceId
431
+ ? `The ${entity} was likely deleted. To recover this ${entity}, visit the activity feed [workspaces/${workspaceId}/settings/activity-log?activityLogEntity=${entity}&activityLogEvent=delete]`
432
+ : `The ${entity} was likely deleted. To recover this ${entity}, visit the activity feed.`}`, error);
432
433
  }
433
434
  }
434
435
  async getBranchById(branchId) {
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createEmptyRequestEventArray = exports.splitLines = 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.normalizeExpectedValue = 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 = void 0;
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;
8
8
  const newman_types_1 = require("./newman-types");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const uuid_1 = require("uuid");
@@ -266,6 +266,15 @@ function assertionRequiresValue(assertion) {
266
266
  }
267
267
  }
268
268
  exports.assertionRequiresValue = assertionRequiresValue;
269
+ function normalizeAssertionValue(assertion) {
270
+ switch (assertion.assertType) {
271
+ case 'MatchesRegExp':
272
+ return normalizeRegExpExpectedValue(assertion.value);
273
+ default:
274
+ return normalizeExpectedValue(assertion.value);
275
+ }
276
+ }
277
+ exports.normalizeAssertionValue = normalizeAssertionValue;
269
278
  function normalizeExpectedValue(value) {
270
279
  if (value === undefined) {
271
280
  return;
@@ -281,27 +290,38 @@ function normalizeExpectedValue(value) {
281
290
  return `pm.variables.replaceIn(${JSON.stringify(value)})`;
282
291
  }
283
292
  exports.normalizeExpectedValue = normalizeExpectedValue;
293
+ function normalizeRegExpExpectedValue(value) {
294
+ if (value === undefined) {
295
+ return;
296
+ }
297
+ value = value.trim();
298
+ if (value.match(/^\/.*\/[a-z]*$/)) {
299
+ return value;
300
+ }
301
+ return `new RegExp(${JSON.stringify(value)})`;
302
+ }
303
+ exports.normalizeRegExpExpectedValue = normalizeRegExpExpectedValue;
284
304
  function isValidMablAssertion(assertion) {
285
- var _a, _b, _c, _d, _e, _f;
305
+ var _a, _b, _c, _d, _e;
286
306
  if (!assertion.assertType) {
287
307
  return false;
288
308
  }
289
309
  const assertTarget = assertion.assertTarget;
290
310
  const requiresValue = assertionRequiresValue(assertion);
291
- const expectedValue = normalizeExpectedValue(assertion.value);
292
- const hasExpectedValue = ((_a = expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length) !== null && _a !== void 0 ? _a : 0) > 0;
311
+ const expectedValue = normalizeAssertionValue(assertion);
312
+ const hasExpectedValue = !!expectedValue;
293
313
  const hasRequiredValue = !requiresValue || hasExpectedValue;
294
314
  let valid = false;
295
315
  switch (assertTarget) {
296
316
  case 'JSONBody':
297
- 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;
317
+ const hasBodyPath = ((_c = (_b = (_a = assertion.bodyPath) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) > 0;
298
318
  valid = hasBodyPath && hasRequiredValue;
299
319
  break;
300
320
  case 'Status':
301
321
  valid = hasExpectedValue;
302
322
  break;
303
323
  case 'Header':
304
- const hasHeaderName = ((_f = (_e = assertion.headerName) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0;
324
+ const hasHeaderName = ((_e = (_d = assertion.headerName) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) > 0;
305
325
  valid = hasHeaderName && hasRequiredValue;
306
326
  break;
307
327
  case 'Size':
@@ -372,7 +392,7 @@ function generateAssertionScript(assertion) {
372
392
  const assertType = assertion.assertType;
373
393
  const description = humanizeAssertion(assertion);
374
394
  const requiresValue = assertionRequiresValue(assertion);
375
- const expectedValue = normalizeExpectedValue(assertion.value);
395
+ const expectedValue = normalizeAssertionValue(assertion);
376
396
  const caseSensitive = assertion.caseSensitive !== false;
377
397
  switch (assertTarget) {
378
398
  case 'JSONBody':
@@ -408,9 +428,6 @@ function generateJsonBodyAssertion(description, assertType, requiresValues, path
408
428
  if (requiresValues) {
409
429
  propertyAccessor = valueToUnquotedString(propertyAccessor);
410
430
  }
411
- if (assertType === newman_types_1.AssertionType.MatchesRegExp) {
412
- expectedValue = `new RegExp(${expectedValue})`;
413
- }
414
431
  return generatePostmanAssertion(description, propertyAccessor, assertType, expectedValue, caseSensitive);
415
432
  }
416
433
  function generateJsonBodyVariableAssignment(variableName, path) {
@@ -448,6 +465,7 @@ function generateStatusAssertion(description, assertType, expectedValue) {
448
465
  case 'DoesNotContain':
449
466
  case 'StartsWith':
450
467
  case 'EndsWith':
468
+ case 'MatchesRegExp':
451
469
  target += '.toString()';
452
470
  break;
453
471
  case 'GreaterThan':
@@ -456,10 +474,6 @@ function generateStatusAssertion(description, assertType, expectedValue) {
456
474
  case 'LessThanOrEqualTo':
457
475
  expectedValue = `parseInt(${expectedValue})`;
458
476
  break;
459
- case 'MatchesRegExp':
460
- target += '.toString()';
461
- expectedValue = `new RegExp(${expectedValue})`;
462
- break;
463
477
  default:
464
478
  throw new Error(`Unexpected status assert type: ${assertType}`);
465
479
  }
@@ -484,9 +498,7 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
484
498
  case 'DoesNotContain':
485
499
  case 'StartsWith':
486
500
  case 'EndsWith':
487
- break;
488
501
  case 'MatchesRegExp':
489
- expectedValue = `new RegExp(${expectedValue})`;
490
502
  break;
491
503
  case 'GreaterThan':
492
504
  case 'GreaterThanOrEqualTo':
@@ -502,10 +514,7 @@ function generateSizeAssertion(description, target, type, expectedValue) {
502
514
  if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
503
515
  return;
504
516
  }
505
- if (type === newman_types_1.AssertionType.MatchesRegExp) {
506
- expectedValue = `new RegExp(${expectedValue})`;
507
- }
508
- else {
517
+ if (type !== newman_types_1.AssertionType.MatchesRegExp) {
509
518
  expectedValue = `parseInt(${expectedValue})`;
510
519
  }
511
520
  return generateSimpleAssertion(description, target, type, expectedValue);