@mablhq/playwright-tools 2.49.1
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/Globals.js +69 -0
- package/LICENSE.txt +29 -0
- package/README.md +219 -0
- package/api/ApiError.js +11 -0
- package/api/atlassian/bitBucketApiClient.js +81 -0
- package/api/atlassian/entities/CodeAnnotation.js +9 -0
- package/api/atlassian/entities/CodeReport.js +15 -0
- package/api/atlassian/entities/PullRequest.js +2 -0
- package/api/basicApiClient.js +293 -0
- package/api/entities/Browser.js +11 -0
- package/api/entities/Email.js +14 -0
- package/api/entities/FindStrategy.js +10 -0
- package/api/entities/Label.js +2 -0
- package/api/entities/VersionedObject.js +2 -0
- package/api/entities/Workspace.js +2 -0
- package/api/featureSet.js +44 -0
- package/api/mablApiClient.js +1070 -0
- package/api/mablApiClientFactory.js +79 -0
- package/api/types.js +10 -0
- package/auth/AuthClient.js +38 -0
- package/auth/OktaClient.js +97 -0
- package/browserEngines/browserEngine.js +41 -0
- package/browserEngines/browserEngines.js +14 -0
- package/browserEngines/chromiumBrowserEngine.js +177 -0
- package/browserEngines/firefoxBrowserEngine.js +134 -0
- package/browserEngines/unsupportedBrowserEngine.js +29 -0
- package/browserEngines/webkitBrowerEngine.js +50 -0
- package/browserLauncher/browser.js +2 -0
- package/browserLauncher/browserEvent.js +11 -0
- package/browserLauncher/browserLauncher.js +17 -0
- package/browserLauncher/browserLauncherEventEmitter.js +2 -0
- package/browserLauncher/browserLauncherFactory.js +30 -0
- package/browserLauncher/elementHandle.js +30 -0
- package/browserLauncher/errors.js +26 -0
- package/browserLauncher/frame.js +17 -0
- package/browserLauncher/frameBase.js +10 -0
- package/browserLauncher/httpRequest.js +2 -0
- package/browserLauncher/httpResponse.js +2 -0
- package/browserLauncher/jsHandle.js +2 -0
- package/browserLauncher/page.js +2 -0
- package/browserLauncher/pageEvent.js +17 -0
- package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +61 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +129 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +24 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +145 -0
- package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +50 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +11 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +36 -0
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +15 -0
- package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/internals.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractBrowserDelegate.js +15 -0
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +73 -0
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractFrameDelegate.js +13 -0
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +81 -0
- package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +18 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +259 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +97 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +319 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +265 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +76 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +26 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +377 -0
- package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +36 -0
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitBrowserDelegate.js +50 -0
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +16 -0
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +19 -0
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitPageDelegate.js +15 -0
- package/browserLauncher/playwrightBrowserLauncher/wrappers.js +25 -0
- package/browserLauncher/types.js +28 -0
- package/browserLauncher/utils.js +9 -0
- package/cli.js +66 -0
- package/commands/applications/applications.js +5 -0
- package/commands/applications/applications_cmds/describe.js +21 -0
- package/commands/applications/applications_cmds/list.js +56 -0
- package/commands/auth/auth.js +5 -0
- package/commands/auth/auth_cmds/activate-key.js +38 -0
- package/commands/auth/auth_cmds/clear.js +10 -0
- package/commands/auth/auth_cmds/info.js +10 -0
- package/commands/auth/auth_cmds/login.js +10 -0
- package/commands/branches/branches.js +5 -0
- package/commands/branches/branches_cmds/create.js +56 -0
- package/commands/branches/branches_cmds/describe.js +50 -0
- package/commands/branches/branches_cmds/list.js +84 -0
- package/commands/branches/branches_cmds/merge.js +56 -0
- package/commands/browserTypes.js +20 -0
- package/commands/commandUtil/awaitCompletion.js +67 -0
- package/commands/commandUtil/branches.js +44 -0
- package/commands/commandUtil/codeInsights.js +181 -0
- package/commands/commandUtil/describe.js +32 -0
- package/commands/commandUtil/fileUtil.js +50 -0
- package/commands/commandUtil/interfaces.js +4 -0
- package/commands/commandUtil/list.js +70 -0
- package/commands/commandUtil/util.js +127 -0
- package/commands/commandUtil/versionUtil.js +33 -0
- package/commands/config/config.js +5 -0
- package/commands/config/config_cmds/configKeys.js +28 -0
- package/commands/config/config_cmds/delete.js +29 -0
- package/commands/config/config_cmds/get.js +52 -0
- package/commands/config/config_cmds/install.js +119 -0
- package/commands/config/config_cmds/list.js +39 -0
- package/commands/config/config_cmds/set.js +80 -0
- package/commands/constants.js +160 -0
- package/commands/credentials/credentials.js +5 -0
- package/commands/credentials/credentials_cmds/list.js +66 -0
- package/commands/datatables/datatables.js +5 -0
- package/commands/datatables/datatables_cmds/create.js +61 -0
- package/commands/datatables/datatables_cmds/describe.js +17 -0
- package/commands/datatables/datatables_cmds/export.js +86 -0
- package/commands/datatables/datatables_cmds/list.js +18 -0
- package/commands/datatables/datatables_cmds/scenarios.js +35 -0
- package/commands/datatables/datatables_cmds/update.js +120 -0
- package/commands/datatables/utils.js +145 -0
- package/commands/deploy/deploy.js +5 -0
- package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +100 -0
- package/commands/deploy/deploy_cmds/create.js +342 -0
- package/commands/deploy/deploy_cmds/describe.js +54 -0
- package/commands/deploy/deploy_cmds/executionResultPresenter.js +117 -0
- package/commands/deploy/deploy_cmds/list.js +74 -0
- package/commands/deploy/deploy_cmds/watch.js +44 -0
- package/commands/environments/environments.js +5 -0
- package/commands/environments/environments_cmds/build-files.js +5 -0
- package/commands/environments/environments_cmds/build-files_cmds/add.js +73 -0
- package/commands/environments/environments_cmds/build-files_cmds/list.js +54 -0
- package/commands/environments/environments_cmds/build-files_cmds/update.js +71 -0
- package/commands/environments/environments_cmds/create.js +153 -0
- package/commands/environments/environments_cmds/delete.js +32 -0
- package/commands/environments/environments_cmds/describe.js +28 -0
- package/commands/environments/environments_cmds/list.js +56 -0
- package/commands/environments/environments_cmds/update.js +46 -0
- package/commands/environments/environments_cmds/urls.js +5 -0
- package/commands/environments/environments_cmds/urls_cmds/add.js +91 -0
- package/commands/environments/environments_cmds/urls_cmds/list.js +49 -0
- package/commands/flows/flows.js +5 -0
- package/commands/flows/flows_cmds/export.js +78 -0
- package/commands/flows/flows_cmds/list.js +64 -0
- package/commands/internal/internal.js +6 -0
- package/commands/link-agents/link-agents.js +5 -0
- package/commands/link-agents/link-agents_cmds/delete.js +38 -0
- package/commands/link-agents/link-agents_cmds/list.js +131 -0
- package/commands/link-agents/link-agents_cmds/terminate.js +31 -0
- package/commands/mobile-build-files/mobile-build-files.js +5 -0
- package/commands/mobile-build-files/mobile-build-files_cmds/delete.js +31 -0
- package/commands/mobile-build-files/mobile-build-files_cmds/download.js +50 -0
- package/commands/mobile-build-files/mobile-build-files_cmds/list.js +72 -0
- package/commands/mobile-build-files/mobile-build-files_cmds/upload.js +101 -0
- package/commands/plans/plans.js +5 -0
- package/commands/plans/plans_cmds/describe.js +23 -0
- package/commands/plans/plans_cmds/list.js +63 -0
- package/commands/test-runs/test-runs.js +5 -0
- package/commands/test-runs/test-runs_cmds/export.js +62 -0
- package/commands/tests/mobileEmulationUtil.js +46 -0
- package/commands/tests/tests.js +5 -0
- package/commands/tests/testsUtil.js +538 -0
- package/commands/tests/tests_cmds/create.js +130 -0
- package/commands/tests/tests_cmds/edit.js +111 -0
- package/commands/tests/tests_cmds/export.js +145 -0
- package/commands/tests/tests_cmds/import.js +5 -0
- package/commands/tests/tests_cmds/import_cmds/import_playwright.js +439 -0
- package/commands/tests/tests_cmds/import_cmds/import_selenium.js +295 -0
- package/commands/tests/tests_cmds/list.js +94 -0
- package/commands/tests/tests_cmds/run-cloud.js +314 -0
- package/commands/tests/tests_cmds/run-mobile.js +260 -0
- package/commands/tests/tests_cmds/run.js +314 -0
- package/commands/tests/tests_cmds/runUtils.js +60 -0
- package/commands/tests/tests_cmds/trainerUtil.js +12 -0
- package/commands/users/users.js +5 -0
- package/commands/users/users_cmds/list.js +58 -0
- package/commands/workspaces/workspace_cmds/copy.js +108 -0
- package/commands/workspaces/workspace_cmds/describe.js +21 -0
- package/commands/workspaces/workspace_cmds/list.js +67 -0
- package/commands/workspaces/workspaces.js +5 -0
- package/core/entityValidation/environmentsValidation.js +7 -0
- package/core/entityValidation/stepValidation.js +15 -0
- package/core/execution/ApiTestUtils.js +1060 -0
- package/core/execution/MailboxConstants.js +4 -0
- package/core/execution/PostmanUtils.js +53 -0
- package/core/execution/RunConfig.js +2 -0
- package/core/execution/TestResult.js +15 -0
- package/core/execution/VariableUtils.js +154 -0
- package/core/execution/VariablesSummary.js +2 -0
- package/core/execution/basic-types.js +2 -0
- package/core/execution/newman-types.js +42 -0
- package/core/messaging/actions/MobileTrainingActions.js +17 -0
- package/core/messaging/actions/pdfActions.js +27 -0
- package/core/messaging/actions/runnerActions.js +18 -0
- package/core/messaging/actions/trainingSessionActions.js +38 -0
- package/core/messaging/logLineMessaging.js +50 -0
- package/core/messaging/messaging.js +130 -0
- package/core/messaging/pageMessaging.js +9 -0
- package/core/trainer/openUtils.js +47 -0
- package/core/trainer/trainingSessions-types.js +35 -0
- package/core/trainer/trainingSessions.js +151 -0
- package/core/util.js +52 -0
- package/coreWebVitals/index.js +77 -0
- package/domUtil/index.js +1 -0
- package/env/defaultEnv.js +17 -0
- package/env/dev.js +17 -0
- package/env/env.js +76 -0
- package/env/local.js +17 -0
- package/env/prod.js +17 -0
- package/execution/index.js +8 -0
- package/execution/index.js.LICENSE.txt +254 -0
- package/execution/runAppiumServer.js +145 -0
- package/functions/apiTest/utils.js +47 -0
- package/functions/types.js +2 -0
- package/functions/utils.js +12 -0
- package/http/MablHttpAgent.js +73 -0
- package/http/RequestFilteringHttpAgent.js +119 -0
- package/http/RequestSecurityError.js +13 -0
- package/http/axiosProxyConfig.js +101 -0
- package/http/httpUtil.js +73 -0
- package/http/requestInterceptor.js +206 -0
- package/index.d.ts +241 -0
- package/index.js +14 -0
- package/mablApi/index.js +1 -0
- package/mablscript/MablAction.js +102 -0
- package/mablscript/MablStep.js +191 -0
- package/mablscript/MablStepV2.js +73 -0
- package/mablscript/MablSymbol.js +35 -0
- package/mablscript/actions/AwaitDownloadAction.js +14 -0
- package/mablscript/actions/AwaitPDFDownloadAction.js +19 -0
- package/mablscript/actions/ConditionAction.js +123 -0
- package/mablscript/actions/CountAction.js +16 -0
- package/mablscript/actions/ExtractAction.js +71 -0
- package/mablscript/actions/FindAction.js +301 -0
- package/mablscript/actions/GenerateEmailAddressAction.js +14 -0
- package/mablscript/actions/GenerateRandomStringAction.js +20 -0
- package/mablscript/actions/GetUrlAction.js +22 -0
- package/mablscript/actions/GetVariableValue.js +31 -0
- package/mablscript/actions/GetViewportAction.js +17 -0
- package/mablscript/actions/JavaScriptAction.js +219 -0
- package/mablscript/diffing/diffingUtil.js +229 -0
- package/mablscript/importer.js +576 -0
- package/mablscript/mobile/steps/CreateVariableMobileStep.js +53 -0
- package/mablscript/mobile/steps/EnterTextStep.js +45 -0
- package/mablscript/mobile/steps/HideKeyboardStep.js +20 -0
- package/mablscript/mobile/steps/InstallAppStep.js +22 -0
- package/mablscript/mobile/steps/NavigateBackStep.js +20 -0
- package/mablscript/mobile/steps/NavigateHomeStep.js +21 -0
- package/mablscript/mobile/steps/OpenAppStep.js +22 -0
- package/mablscript/mobile/steps/OpenLinkStep.js +19 -0
- package/mablscript/mobile/steps/PrepareSessionStep.js +19 -0
- package/mablscript/mobile/steps/PushFileStep.js +27 -0
- package/mablscript/mobile/steps/ScrollStep.js +87 -0
- package/mablscript/mobile/steps/SetOrientationStep.js +20 -0
- package/mablscript/mobile/steps/TapStep.js +37 -0
- package/mablscript/mobile/steps/UninstallAppStep.js +22 -0
- package/mablscript/mobile/steps/actions/MobileFindAction.js +23 -0
- package/mablscript/mobile/steps/stepUtil.js +113 -0
- package/mablscript/mobile/tests/StepTestsUtil.js +20 -0
- package/mablscript/mobile/tests/TestMobileFindDescriptors.js +282 -0
- package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +298 -0
- package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +79 -0
- package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +304 -0
- package/mablscript/mobile/tests/steps/HideKeyboardStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/InstallAppStep.mobiletest.js +20 -0
- package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +27 -0
- package/mablscript/mobile/tests/steps/OpenLinkStep.mobiletest.js +20 -0
- package/mablscript/mobile/tests/steps/PushFileStep.mobiletest.js +55 -0
- package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +386 -0
- package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +32 -0
- package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +57 -0
- package/mablscript/mobile/tests/steps/UninstallAppStep.mobiletest.js +20 -0
- package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +52 -0
- package/mablscript/steps/AccessibilityCheck.js +108 -0
- package/mablscript/steps/ActionsUtils.js +18 -0
- package/mablscript/steps/AssertStep.js +318 -0
- package/mablscript/steps/AssertStepOld.js +159 -0
- package/mablscript/steps/AwaitTabStep.js +69 -0
- package/mablscript/steps/AwaitUploadsStep.js +26 -0
- package/mablscript/steps/ClearCookiesStep.js +26 -0
- package/mablscript/steps/ClickAndHoldStep.js +76 -0
- package/mablscript/steps/ClickStep.js +58 -0
- package/mablscript/steps/CookieUtils.js +54 -0
- package/mablscript/steps/CreateVariableStep.js +236 -0
- package/mablscript/steps/DatabaseQueryStep.js +28 -0
- package/mablscript/steps/DoubleClickStep.js +64 -0
- package/mablscript/steps/DownloadStep.js +96 -0
- package/mablscript/steps/EchoStep.js +34 -0
- package/mablscript/steps/ElseIfConditionStep.js +32 -0
- package/mablscript/steps/ElseStep.js +27 -0
- package/mablscript/steps/EndStep.js +27 -0
- package/mablscript/steps/EnterAuthCodeStep.js +59 -0
- package/mablscript/steps/EnterTextStep.js +96 -0
- package/mablscript/steps/EvaluateFlowStep.js +51 -0
- package/mablscript/steps/EvaluateJavaScriptStep.js +50 -0
- package/mablscript/steps/HoverStep.js +63 -0
- package/mablscript/steps/IfConditionStep.js +191 -0
- package/mablscript/steps/NavigateStep.js +30 -0
- package/mablscript/steps/OpenEmailStep.js +46 -0
- package/mablscript/steps/ReleaseStep.js +76 -0
- package/mablscript/steps/RemoveCookieStep.js +36 -0
- package/mablscript/steps/RightClickStep.js +58 -0
- package/mablscript/steps/SelectStep.js +82 -0
- package/mablscript/steps/SendHttpRequestStep.js +48 -0
- package/mablscript/steps/SendKeyStep.js +84 -0
- package/mablscript/steps/SetCookieStep.js +70 -0
- package/mablscript/steps/SetFilesStep.js +71 -0
- package/mablscript/steps/SetViewportStep.js +38 -0
- package/mablscript/steps/SwitchContextStep.js +122 -0
- package/mablscript/steps/SyntheticStep.js +20 -0
- package/mablscript/steps/VisitUrlStep.js +68 -0
- package/mablscript/steps/WaitStep.js +37 -0
- package/mablscript/steps/WaitUntilStep.js +46 -0
- package/mablscript/types/AccessibilityCheckStepDescriptor.js +2 -0
- package/mablscript/types/AccessibilityCheckTypes.js +9 -0
- package/mablscript/types/AssertionsAndVariablesStepDescriptor.js +2 -0
- package/mablscript/types/AwaitTabDescriptor.js +2 -0
- package/mablscript/types/AwaitUploadStepDescriptor.js +2 -0
- package/mablscript/types/ClearCookiesStepDescriptor.js +2 -0
- package/mablscript/types/ClickAndHoldStepDescriptor.js +2 -0
- package/mablscript/types/ClickStepDescriptor.js +2 -0
- package/mablscript/types/ConditionDescriptor.js +133 -0
- package/mablscript/types/CountDescriptor.js +2 -0
- package/mablscript/types/CreateVariableStepDescriptor.js +12 -0
- package/mablscript/types/DownloadStepDescriptor.js +2 -0
- package/mablscript/types/EchoStepDescriptor.js +2 -0
- package/mablscript/types/EnterTextStepDescriptor.js +2 -0
- package/mablscript/types/EvaluateFlowStepDescriptor.js +2 -0
- package/mablscript/types/EvaluateJavaScriptStepDescriptor.js +2 -0
- package/mablscript/types/ExtractDescriptor.js +21 -0
- package/mablscript/types/GetCurrentLocationDescriptor.js +12 -0
- package/mablscript/types/GetVariableDescriptor.js +16 -0
- package/mablscript/types/GetViewportDescriptor.js +12 -0
- package/mablscript/types/HoverStepDescriptor.js +2 -0
- package/mablscript/types/NavigateStepDescriptor.js +7 -0
- package/mablscript/types/OpenEmailStepDescriptor.js +2 -0
- package/mablscript/types/OperatingSystemDescriptor.js +45 -0
- package/mablscript/types/ReleaseStepDescriptor.js +7 -0
- package/mablscript/types/RemoveCookieStepDescriptor.js +2 -0
- package/mablscript/types/SelectStepDescriptor.js +2 -0
- package/mablscript/types/SendHttpRequestTypes.js +2 -0
- package/mablscript/types/SendKeyStepDescriptor.js +30 -0
- package/mablscript/types/SetCookieStepDescriptor.js +2 -0
- package/mablscript/types/SetFilesStepDescriptor.js +2 -0
- package/mablscript/types/SetViewportStepDescriptor.js +2 -0
- package/mablscript/types/SnippetsDescriptor.js +36 -0
- package/mablscript/types/StepDescriptor.js +2 -0
- package/mablscript/types/SwitchContextStepDescriptor.js +15 -0
- package/mablscript/types/VariableNamespace.js +17 -0
- package/mablscript/types/VisitUrlStepDescriptor.js +2 -0
- package/mablscript/types/WaitStepDescriptor.js +2 -0
- package/mablscript/types/WaitUntilStepDescriptor.js +2 -0
- package/mablscript/types/mobile/CreateVariableMobileStepDescriptor.js +9 -0
- package/mablscript/types/mobile/EnterTextStepDescriptor.js +2 -0
- package/mablscript/types/mobile/HideKeyboardStepDescriptor.js +2 -0
- package/mablscript/types/mobile/InstallAppStepDescriptor.js +2 -0
- package/mablscript/types/mobile/NavigateBackStepDescriptor.js +2 -0
- package/mablscript/types/mobile/NavigateHomeStepDescriptor.js +2 -0
- package/mablscript/types/mobile/OpenAppStepDescriptor.js +2 -0
- package/mablscript/types/mobile/OpenLinkStepDescriptor.js +2 -0
- package/mablscript/types/mobile/PrepareSessionStepDescriptor.js +2 -0
- package/mablscript/types/mobile/PushFileDescriptor.js +2 -0
- package/mablscript/types/mobile/ScrollStepDescriptor.js +32 -0
- package/mablscript/types/mobile/SetOrientationStepDescriptor.js +8 -0
- package/mablscript/types/mobile/StepWithMobileFindDescriptor.js +8 -0
- package/mablscript/types/mobile/TapStepDescriptor.js +8 -0
- package/mablscript/types/mobile/UninstallAppStepDescriptor.js +2 -0
- package/mablscriptFind/index.js +2 -0
- package/mablscriptFind/index.js.LICENSE.txt +25 -0
- package/middleware.js +42 -0
- package/mobile/index.js +2 -0
- package/mobile/types.js +8 -0
- package/observers/ObserverBase.js +11 -0
- package/observers/mockObserver.js +47 -0
- package/package.json +107 -0
- package/popupDismissal/candidate.js +2 -0
- package/popupDismissal/index.js +255 -0
- package/providers/authenticationProvider.js +254 -0
- package/providers/cliConfigProvider.js +271 -0
- package/providers/exportRequestProvider.js +196 -0
- package/providers/logging/loggingProvider.js +90 -0
- package/providers/scmContextInterfaces.js +14 -0
- package/providers/scmContextProvider.js +335 -0
- package/providers/scmContextProviderV2.js +122 -0
- package/providers/types.js +9 -0
- package/proxy/index.js +2 -0
- package/proxy/index.js.LICENSE.txt +12 -0
- package/proxy/lib/xpath.js +1 -0
- package/reporters/__tests__/resources/sampleData.js +162 -0
- package/reporters/mochAwesome/interfaces.js +2 -0
- package/reporters/mochAwesome/mochAwesomeReporter.js +227 -0
- package/reporters/reporter.js +46 -0
- package/resources/actionabilityCheck.js +160 -0
- package/resources/coreWebVitals.js +1 -0
- package/resources/mablFind.js +2 -0
- package/resources/media/mabl_test_audio.wav +0 -0
- package/resources/media/mabl_test_pattern.y4m +3 -0
- package/resources/pdf-viewer/EmbeddedPdfHandler.js +1 -0
- package/resources/pdf-viewer/embeddedPdfDetection.js +225 -0
- package/resources/pdf-viewer/index.html +1 -0
- package/resources/pdf-viewer/index.js +2 -0
- package/resources/pdf-viewer/libEmbeddedPdfHandler.js +279 -0
- package/resources/pdf-viewer/libmablPdfViewer.js +21909 -0
- package/resources/pdf-viewer/mabl_attention_move.gif +0 -0
- package/resources/pdf-viewer/mabl_error_artwork_Unplugged.gif +0 -0
- package/resources/pdf-viewer/pdf.worker.9251738a897f697389be.js +2 -0
- package/resources/pdf-viewer/pdf.worker.9e2021092643447a5b9f.js +81 -0
- package/resources/popupDismissal.js +1 -0
- package/resources/webdriver.js +19 -0
- package/socketTunnel/index.js +2 -0
- package/socketTunnel/index.js.LICENSE.txt +68 -0
- package/upload/index.js +2 -0
- package/upload/index.js.LICENSE.txt +27 -0
- package/util/CloudStorageWriter.js +45 -0
- package/util/FileCache.js +180 -0
- package/util/IdentifierUtil.js +57 -0
- package/util/InternalMetricsTrackingSingleton.js +36 -0
- package/util/Lazy.js +90 -0
- package/util/MobileAppFileCache.js +103 -0
- package/util/RichPromise.js +53 -0
- package/util/TestOutputWriter.js +104 -0
- package/util/actionabilityUtil.js +165 -0
- package/util/analytics-events.js +14 -0
- package/util/analytics.js +176 -0
- package/util/asyncUtil.js +61 -0
- package/util/browserTestUtils.js +17 -0
- package/util/clickUtil.js +68 -0
- package/util/downloadUtil.js +87 -0
- package/util/encodingUtil.js +50 -0
- package/util/fileUploadUtil.js +146 -0
- package/util/javaScriptStepMigration.js +115 -0
- package/util/jestUtil.js +21 -0
- package/util/logUtils.js +131 -0
- package/util/markdownUtil.js +125 -0
- package/util/postInstallMessage.js +14 -0
- package/util/pureUtil.js +175 -0
- package/util/resourceUtil.js +90 -0
- package/util/timeUtil.js +31 -0
- package/utilities.js +7 -0
- package/webdriver/index.js +44 -0
|
@@ -0,0 +1,1060 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
const newman_types_1 = require("./newman-types");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const encodingUtil_1 = require("../../util/encodingUtil");
|
|
12
|
+
const stepValidation_1 = require("../entityValidation/stepValidation");
|
|
13
|
+
exports.TEST_LISTEN = 'test';
|
|
14
|
+
exports.MABL_GENERATED_ASSERTION_TOKEN = '__MABL_GENERATED__';
|
|
15
|
+
exports.MABL_GENERATED_COMMENT = `// ${exports.MABL_GENERATED_ASSERTION_TOKEN} Do not edit below this line`;
|
|
16
|
+
exports.INHERIT_AUTH_FROM_PARENT_VALUE = 'inherit_from_parent';
|
|
17
|
+
exports.API_KEY_AUTH = 'apikey';
|
|
18
|
+
exports.BASIC_AUTH = 'basic';
|
|
19
|
+
exports.BEARER_TOKEN_AUTH = 'bearer';
|
|
20
|
+
exports.NO_AUTH = 'noauth';
|
|
21
|
+
exports.OAUTH1_AUTH = 'oauth1';
|
|
22
|
+
exports.DEFAULT_OAUTH1_VERSION = '1.0';
|
|
23
|
+
const ADD_OAUTH1_TO_HEADER = true;
|
|
24
|
+
const ADD_OAUTH1_TO_HEADER_VALUE = `${ADD_OAUTH1_TO_HEADER}`;
|
|
25
|
+
exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE = ADD_OAUTH1_TO_HEADER_VALUE;
|
|
26
|
+
exports.HMAC_SHA1_SIGNATURE = 'HMAC-SHA1';
|
|
27
|
+
exports.COLLECTION_WITH_FOLDERS_ERROR = 'Collections with folders are not supported';
|
|
28
|
+
const RESPONSE_PROPERTIES = {
|
|
29
|
+
Size: 'size().body',
|
|
30
|
+
Status: 'code',
|
|
31
|
+
};
|
|
32
|
+
exports.ASSERT_TARGETS = [
|
|
33
|
+
{ label: 'Header', value: newman_types_1.AssertionTarget.Header },
|
|
34
|
+
{ label: 'Status', value: newman_types_1.AssertionTarget.Status },
|
|
35
|
+
{ label: 'Size', value: newman_types_1.AssertionTarget.Size },
|
|
36
|
+
{ label: 'JSON Body', value: newman_types_1.AssertionTarget.JSONBody },
|
|
37
|
+
];
|
|
38
|
+
exports.ASSERT_TYPES = [
|
|
39
|
+
{ label: 'Equals', value: newman_types_1.AssertionType.Equals },
|
|
40
|
+
{ label: 'Not equals', value: newman_types_1.AssertionType.NotEquals },
|
|
41
|
+
{ label: 'Contains', value: newman_types_1.AssertionType.Contains },
|
|
42
|
+
{ label: 'Not contains', value: newman_types_1.AssertionType.DoesNotContain },
|
|
43
|
+
{ label: 'Is present', value: newman_types_1.AssertionType.Present },
|
|
44
|
+
{ label: 'Not present', value: newman_types_1.AssertionType.NotPresent },
|
|
45
|
+
{ label: 'Greater than', value: newman_types_1.AssertionType.GreaterThan },
|
|
46
|
+
{
|
|
47
|
+
label: 'Greater than or equal to',
|
|
48
|
+
value: newman_types_1.AssertionType.GreaterThanOrEqualTo,
|
|
49
|
+
},
|
|
50
|
+
{ label: 'Less than', value: newman_types_1.AssertionType.LessThan },
|
|
51
|
+
{ label: 'Less than or equal to', value: newman_types_1.AssertionType.LessThanOrEqualTo },
|
|
52
|
+
{ label: 'Starts with', value: newman_types_1.AssertionType.StartsWith },
|
|
53
|
+
{ label: 'Ends with', value: newman_types_1.AssertionType.EndsWith },
|
|
54
|
+
{ label: 'Matches regular expression', value: newman_types_1.AssertionType.MatchesRegExp },
|
|
55
|
+
];
|
|
56
|
+
const EXPECTED_VALUE_TOKEN = '!!EXPECTED_VALUE!!';
|
|
57
|
+
const EXPECT_FUNCTIONS = {
|
|
58
|
+
Equals: `eql(${EXPECTED_VALUE_TOKEN})`,
|
|
59
|
+
NotEquals: `not.eql(${EXPECTED_VALUE_TOKEN})`,
|
|
60
|
+
Contains: `include(${EXPECTED_VALUE_TOKEN})`,
|
|
61
|
+
DoesNotContain: `not.include(${EXPECTED_VALUE_TOKEN})`,
|
|
62
|
+
Present: `not.be.undefined`,
|
|
63
|
+
NotPresent: `be.undefined`,
|
|
64
|
+
GreaterThan: `be.above(${EXPECTED_VALUE_TOKEN})`,
|
|
65
|
+
GreaterThanOrEqualTo: `be.at.least(${EXPECTED_VALUE_TOKEN})`,
|
|
66
|
+
LessThan: `be.below(${EXPECTED_VALUE_TOKEN})`,
|
|
67
|
+
LessThanOrEqualTo: `be.at.most(${EXPECTED_VALUE_TOKEN})`,
|
|
68
|
+
StartsWith: `satisfy(value => value.startsWith(${EXPECTED_VALUE_TOKEN}))`,
|
|
69
|
+
EndsWith: `satisfy(value => value.endsWith(${EXPECTED_VALUE_TOKEN}))`,
|
|
70
|
+
MatchesRegExp: `match(${EXPECTED_VALUE_TOKEN})`,
|
|
71
|
+
};
|
|
72
|
+
function compareStringsCaseInsensitive(a, b) {
|
|
73
|
+
a = a === null || a === void 0 ? void 0 : a.toUpperCase().toLowerCase();
|
|
74
|
+
b = b === null || b === void 0 ? void 0 : b.toUpperCase().toLowerCase();
|
|
75
|
+
if (!a) {
|
|
76
|
+
return -1;
|
|
77
|
+
}
|
|
78
|
+
if (!b) {
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
return a.localeCompare(b, undefined, { sensitivity: 'base' });
|
|
82
|
+
}
|
|
83
|
+
exports.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
|
|
84
|
+
function caseInsensitiveEquals(a, b) {
|
|
85
|
+
return compareStringsCaseInsensitive(a, b) === 0;
|
|
86
|
+
}
|
|
87
|
+
exports.caseInsensitiveEquals = caseInsensitiveEquals;
|
|
88
|
+
function getAssertionTypesForTarget(target) {
|
|
89
|
+
switch (target) {
|
|
90
|
+
case newman_types_1.AssertionTarget.Size:
|
|
91
|
+
case newman_types_1.AssertionTarget.Status:
|
|
92
|
+
return exports.ASSERT_TYPES.filter((assertType) => [
|
|
93
|
+
newman_types_1.AssertionType.Equals,
|
|
94
|
+
newman_types_1.AssertionType.NotEquals,
|
|
95
|
+
newman_types_1.AssertionType.GreaterThan,
|
|
96
|
+
newman_types_1.AssertionType.GreaterThanOrEqualTo,
|
|
97
|
+
newman_types_1.AssertionType.LessThan,
|
|
98
|
+
newman_types_1.AssertionType.LessThanOrEqualTo,
|
|
99
|
+
].includes(assertType.value));
|
|
100
|
+
case newman_types_1.AssertionTarget.Header:
|
|
101
|
+
case newman_types_1.AssertionTarget.JSONBody:
|
|
102
|
+
return exports.ASSERT_TYPES.filter((assertType) => [
|
|
103
|
+
newman_types_1.AssertionType.Contains,
|
|
104
|
+
newman_types_1.AssertionType.DoesNotContain,
|
|
105
|
+
newman_types_1.AssertionType.EndsWith,
|
|
106
|
+
newman_types_1.AssertionType.Equals,
|
|
107
|
+
newman_types_1.AssertionType.MatchesRegExp,
|
|
108
|
+
newman_types_1.AssertionType.NotEquals,
|
|
109
|
+
newman_types_1.AssertionType.NotPresent,
|
|
110
|
+
newman_types_1.AssertionType.Present,
|
|
111
|
+
newman_types_1.AssertionType.StartsWith,
|
|
112
|
+
].includes(assertType.value));
|
|
113
|
+
default:
|
|
114
|
+
return exports.ASSERT_TYPES;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.getAssertionTypesForTarget = getAssertionTypesForTarget;
|
|
118
|
+
function humanizeAssertionType(assertionType) {
|
|
119
|
+
switch (assertionType) {
|
|
120
|
+
case 'NotEquals':
|
|
121
|
+
return 'not equals';
|
|
122
|
+
case 'DoesNotContain':
|
|
123
|
+
return 'does not contain';
|
|
124
|
+
case 'Present':
|
|
125
|
+
return 'is present';
|
|
126
|
+
case 'NotPresent':
|
|
127
|
+
return 'is not present';
|
|
128
|
+
case 'GreaterThan':
|
|
129
|
+
return 'greater than';
|
|
130
|
+
case 'GreaterThanOrEqualTo':
|
|
131
|
+
return 'greater than or equal to';
|
|
132
|
+
case 'LessThan':
|
|
133
|
+
return 'less than';
|
|
134
|
+
case 'LessThanOrEqualTo':
|
|
135
|
+
return 'less than or equal to';
|
|
136
|
+
case 'StartsWith':
|
|
137
|
+
return 'starts with';
|
|
138
|
+
case 'EndsWith':
|
|
139
|
+
return 'ends with';
|
|
140
|
+
case 'MatchesRegExp':
|
|
141
|
+
return 'matches regular expression';
|
|
142
|
+
default:
|
|
143
|
+
return assertionType.toString().toLowerCase();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.humanizeAssertionType = humanizeAssertionType;
|
|
147
|
+
function createEmptyAssertion() {
|
|
148
|
+
return {
|
|
149
|
+
id: (0, uuid_1.v4)(),
|
|
150
|
+
assertTarget: newman_types_1.AssertionTarget.JSONBody,
|
|
151
|
+
assertType: newman_types_1.AssertionType.Present,
|
|
152
|
+
description: '',
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
exports.createEmptyAssertion = createEmptyAssertion;
|
|
156
|
+
function createEmptyVariable() {
|
|
157
|
+
return {
|
|
158
|
+
id: (0, uuid_1.v4)(),
|
|
159
|
+
assertTarget: newman_types_1.AssertionTarget.JSONBody,
|
|
160
|
+
variableName: '',
|
|
161
|
+
description: '',
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
exports.createEmptyVariable = createEmptyVariable;
|
|
165
|
+
function deduplicateApiTestExecutionResults(postmanResult) {
|
|
166
|
+
var _a;
|
|
167
|
+
const executionsById = {};
|
|
168
|
+
const orderedExecutionIds = [];
|
|
169
|
+
(_a = postmanResult.run.executions) === null || _a === void 0 ? void 0 : _a.forEach((execution) => {
|
|
170
|
+
const executionId = execution.id;
|
|
171
|
+
if (!executionsById[executionId]) {
|
|
172
|
+
orderedExecutionIds.push(executionId);
|
|
173
|
+
}
|
|
174
|
+
executionsById[executionId] = execution;
|
|
175
|
+
});
|
|
176
|
+
postmanResult.run.executions = orderedExecutionIds.map((executionId) => executionsById[executionId]);
|
|
177
|
+
return postmanResult;
|
|
178
|
+
}
|
|
179
|
+
exports.deduplicateApiTestExecutionResults = deduplicateApiTestExecutionResults;
|
|
180
|
+
function restoreCustomRequestFields(postmanResult, collection) {
|
|
181
|
+
const requestItemsById = collection.item.reduce((collectionSet, itemDefinition) => {
|
|
182
|
+
collectionSet[itemDefinition.id] = itemDefinition;
|
|
183
|
+
return collectionSet;
|
|
184
|
+
}, {});
|
|
185
|
+
postmanResult.run.executions.forEach((execution) => {
|
|
186
|
+
var _a;
|
|
187
|
+
const requestItemDefinition = requestItemsById[execution.id];
|
|
188
|
+
if (((_a = execution.request.body) === null || _a === void 0 ? void 0 : _a.mode) === 'formdata' &&
|
|
189
|
+
(requestItemDefinition === null || requestItemDefinition === void 0 ? void 0 : requestItemDefinition.request)) {
|
|
190
|
+
restoreFormDataFileMetadata(execution.request, requestItemDefinition.request);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return postmanResult;
|
|
194
|
+
}
|
|
195
|
+
exports.restoreCustomRequestFields = restoreCustomRequestFields;
|
|
196
|
+
function restoreFormDataFileMetadata(resultRequest, collectionRequest) {
|
|
197
|
+
var _a, _b, _c, _d, _e;
|
|
198
|
+
if ((_a = resultRequest.body) === null || _a === void 0 ? void 0 : _a.formdata) {
|
|
199
|
+
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) => {
|
|
200
|
+
if (formData.src) {
|
|
201
|
+
set[formData.src] = formData;
|
|
202
|
+
}
|
|
203
|
+
return set;
|
|
204
|
+
}, {});
|
|
205
|
+
if (!Array.isArray((_d = resultRequest.body) === null || _d === void 0 ? void 0 : _d.formdata)) {
|
|
206
|
+
resultRequest.body.formdata = resultRequest.body.formdata
|
|
207
|
+
.all()
|
|
208
|
+
.map((formParam) => formParam);
|
|
209
|
+
}
|
|
210
|
+
for (const resultFormParam of resultRequest.body.formdata) {
|
|
211
|
+
if (resultFormParam.type === 'file' &&
|
|
212
|
+
resultFormParam.src &&
|
|
213
|
+
!resultFormParam.mablFile) {
|
|
214
|
+
resultFormParam.mablFile =
|
|
215
|
+
(_e = requestFormDataBySrc[resultFormParam.src]) === null || _e === void 0 ? void 0 : _e.mablFile;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function findFirstMatchingEvent(eventDefinition, listen) {
|
|
221
|
+
const eventIndex = lodash_1.default.findIndex(eventDefinition, { listen });
|
|
222
|
+
let eventValue;
|
|
223
|
+
if (eventIndex !== -1) {
|
|
224
|
+
eventValue = eventDefinition === null || eventDefinition === void 0 ? void 0 : eventDefinition[eventIndex];
|
|
225
|
+
}
|
|
226
|
+
return { eventIndex, eventValue };
|
|
227
|
+
}
|
|
228
|
+
exports.findFirstMatchingEvent = findFirstMatchingEvent;
|
|
229
|
+
function createEmptyRequestEvent() {
|
|
230
|
+
return {
|
|
231
|
+
listen: exports.TEST_LISTEN,
|
|
232
|
+
id: (0, exports.uuid)(),
|
|
233
|
+
script: {
|
|
234
|
+
exec: [],
|
|
235
|
+
raw: '',
|
|
236
|
+
type: 'text/javascript',
|
|
237
|
+
},
|
|
238
|
+
mablAssertions: [
|
|
239
|
+
{
|
|
240
|
+
id: (0, uuid_1.v4)(),
|
|
241
|
+
assertTarget: newman_types_1.AssertionTarget.Status,
|
|
242
|
+
assertType: newman_types_1.AssertionType.Equals,
|
|
243
|
+
value: '200',
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
mablVariables: [],
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
exports.createEmptyRequestEvent = createEmptyRequestEvent;
|
|
250
|
+
function removeMablGeneratedScriptsFromLines(lines) {
|
|
251
|
+
const mablGeneratedIndex = lines.findIndex((line) => line.includes(exports.MABL_GENERATED_ASSERTION_TOKEN));
|
|
252
|
+
if (mablGeneratedIndex >= 0) {
|
|
253
|
+
return lines.slice(0, mablGeneratedIndex);
|
|
254
|
+
}
|
|
255
|
+
return lines;
|
|
256
|
+
}
|
|
257
|
+
function removeMablGeneratedScripts(eventDefinition) {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
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 : []));
|
|
260
|
+
}
|
|
261
|
+
exports.removeMablGeneratedScripts = removeMablGeneratedScripts;
|
|
262
|
+
function isValidMablVariableAssignment(variable) {
|
|
263
|
+
return !!variable.assertTarget && !!variable.variableName;
|
|
264
|
+
}
|
|
265
|
+
exports.isValidMablVariableAssignment = isValidMablVariableAssignment;
|
|
266
|
+
function filterValidMablVariableAssignments(variables) {
|
|
267
|
+
return variables === null || variables === void 0 ? void 0 : variables.filter(isValidMablVariableAssignment);
|
|
268
|
+
}
|
|
269
|
+
exports.filterValidMablVariableAssignments = filterValidMablVariableAssignments;
|
|
270
|
+
function filterValidMablAssertions(assertions) {
|
|
271
|
+
return assertions === null || assertions === void 0 ? void 0 : assertions.filter(isValidMablAssertion);
|
|
272
|
+
}
|
|
273
|
+
exports.filterValidMablAssertions = filterValidMablAssertions;
|
|
274
|
+
function assertionRequiresValue(assertion) {
|
|
275
|
+
switch (assertion.assertType) {
|
|
276
|
+
case newman_types_1.AssertionType.Present:
|
|
277
|
+
case newman_types_1.AssertionType.NotPresent:
|
|
278
|
+
return false;
|
|
279
|
+
default:
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.assertionRequiresValue = assertionRequiresValue;
|
|
284
|
+
function normalizeAssertionValue(assertion) {
|
|
285
|
+
switch (assertion.assertType) {
|
|
286
|
+
case 'MatchesRegExp':
|
|
287
|
+
return normalizeRegExpExpectedValue(assertion.value);
|
|
288
|
+
default:
|
|
289
|
+
return normalizeExpectedValue(assertion.value);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.normalizeAssertionValue = normalizeAssertionValue;
|
|
293
|
+
function normalizeExpectedValue(value) {
|
|
294
|
+
if (value === undefined) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
value = value.trim();
|
|
298
|
+
if (value.match(/".*"/)) {
|
|
299
|
+
return `pm.variables.replaceIn(${value})`;
|
|
300
|
+
}
|
|
301
|
+
const lower = value.toUpperCase().toLowerCase();
|
|
302
|
+
if (lower === 'true' || lower === 'false' || !Number.isNaN(Number(value))) {
|
|
303
|
+
return JSON.stringify(value);
|
|
304
|
+
}
|
|
305
|
+
return `pm.variables.replaceIn(${JSON.stringify(value)})`;
|
|
306
|
+
}
|
|
307
|
+
exports.normalizeExpectedValue = normalizeExpectedValue;
|
|
308
|
+
function normalizeRegExpExpectedValue(value) {
|
|
309
|
+
if (value === undefined) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
value = value.trim();
|
|
313
|
+
if (value.match(stepValidation_1.REGEXP_LITERAL_PATTERN)) {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
return `new RegExp(${JSON.stringify(value)})`;
|
|
317
|
+
}
|
|
318
|
+
exports.normalizeRegExpExpectedValue = normalizeRegExpExpectedValue;
|
|
319
|
+
function isValidMablAssertion(assertion) {
|
|
320
|
+
var _a, _b, _c, _d, _e;
|
|
321
|
+
if (!assertion.assertType) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
const assertTarget = assertion.assertTarget;
|
|
325
|
+
const requiresValue = assertionRequiresValue(assertion);
|
|
326
|
+
const expectedValue = normalizeAssertionValue(assertion);
|
|
327
|
+
const hasExpectedValue = !!expectedValue;
|
|
328
|
+
const hasRequiredValue = !requiresValue || hasExpectedValue;
|
|
329
|
+
let valid = false;
|
|
330
|
+
switch (assertTarget) {
|
|
331
|
+
case 'JSONBody':
|
|
332
|
+
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;
|
|
333
|
+
valid = hasBodyPath && hasRequiredValue;
|
|
334
|
+
break;
|
|
335
|
+
case 'Status':
|
|
336
|
+
valid = hasExpectedValue;
|
|
337
|
+
break;
|
|
338
|
+
case 'Header':
|
|
339
|
+
const hasHeaderName = ((_e = (_d = assertion.headerName) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) > 0;
|
|
340
|
+
valid = hasHeaderName && hasRequiredValue;
|
|
341
|
+
break;
|
|
342
|
+
case 'Size':
|
|
343
|
+
valid =
|
|
344
|
+
isValidSizeAssertionType(assertion.assertType) && hasExpectedValue;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
return valid;
|
|
348
|
+
}
|
|
349
|
+
exports.isValidMablAssertion = isValidMablAssertion;
|
|
350
|
+
function isValidSizeAssertionType(assertType) {
|
|
351
|
+
switch (assertType) {
|
|
352
|
+
case newman_types_1.AssertionType.Equals:
|
|
353
|
+
case newman_types_1.AssertionType.NotEquals:
|
|
354
|
+
case newman_types_1.AssertionType.GreaterThan:
|
|
355
|
+
case newman_types_1.AssertionType.GreaterThanOrEqualTo:
|
|
356
|
+
case newman_types_1.AssertionType.LessThan:
|
|
357
|
+
case newman_types_1.AssertionType.LessThanOrEqualTo:
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
function assertionHasTest(assertion) {
|
|
363
|
+
if (!assertion.assertTarget || !assertion.assertType) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
switch (assertion.assertTarget) {
|
|
367
|
+
case 'Header':
|
|
368
|
+
return !!assertion.headerName;
|
|
369
|
+
case 'JSONBody':
|
|
370
|
+
return !!assertion.bodyPath;
|
|
371
|
+
default:
|
|
372
|
+
return !!assertion.assertType && !!assertion.value;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
exports.assertionHasTest = assertionHasTest;
|
|
376
|
+
function getAssertionTargetArgument(assertion) {
|
|
377
|
+
switch (assertion.assertTarget) {
|
|
378
|
+
case 'JSONBody':
|
|
379
|
+
return assertion.bodyPath;
|
|
380
|
+
case 'Header':
|
|
381
|
+
return assertion.headerName;
|
|
382
|
+
default:
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
exports.getAssertionTargetArgument = getAssertionTargetArgument;
|
|
387
|
+
function humanizeAssertion(assertion) {
|
|
388
|
+
const { assertTarget, assertType, value, description } = assertion;
|
|
389
|
+
if (description && description !== '') {
|
|
390
|
+
return description;
|
|
391
|
+
}
|
|
392
|
+
if (assertionHasTest(assertion)) {
|
|
393
|
+
const assertionTargetArgument = getAssertionTargetArgument(assertion);
|
|
394
|
+
const humanized = `${exports.ASSERT_TARGETS.filter((target) => target.value === assertTarget)[0].label}${assertionTargetArgument ? ` ${assertionTargetArgument}` : ''} ${humanizeAssertionType(assertType)}`;
|
|
395
|
+
return assertionRequiresValue(assertion)
|
|
396
|
+
? `${humanized} ${value}`
|
|
397
|
+
: humanized;
|
|
398
|
+
}
|
|
399
|
+
return '';
|
|
400
|
+
}
|
|
401
|
+
exports.humanizeAssertion = humanizeAssertion;
|
|
402
|
+
function generateAssertionScript(assertion) {
|
|
403
|
+
if (!assertion.assertType) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const assertTarget = assertion.assertTarget;
|
|
407
|
+
const assertType = assertion.assertType;
|
|
408
|
+
const description = humanizeAssertion(assertion);
|
|
409
|
+
const requiresValue = assertionRequiresValue(assertion);
|
|
410
|
+
const expectedValue = normalizeAssertionValue(assertion);
|
|
411
|
+
const caseSensitive = assertion.caseSensitive !== false;
|
|
412
|
+
switch (assertTarget) {
|
|
413
|
+
case 'JSONBody':
|
|
414
|
+
return generateJsonBodyAssertion(description, assertType, requiresValue, assertion.bodyPath, expectedValue, caseSensitive);
|
|
415
|
+
case 'Status':
|
|
416
|
+
return generateStatusAssertion(description, assertType, expectedValue);
|
|
417
|
+
case 'Header':
|
|
418
|
+
return generateHeaderAssertion(description, assertType, assertion.headerName, expectedValue, caseSensitive);
|
|
419
|
+
case 'Size':
|
|
420
|
+
return generateSizeAssertion(description, assertTarget, assertType, expectedValue);
|
|
421
|
+
}
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
function generateVariableAssignmentScript(variable) {
|
|
425
|
+
if (!variable.variableName) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const assertTarget = variable.assertTarget;
|
|
429
|
+
switch (assertTarget) {
|
|
430
|
+
case 'JSONBody':
|
|
431
|
+
return generateJsonBodyVariableAssignment(variable.variableName, variable.bodyPath);
|
|
432
|
+
case 'Header':
|
|
433
|
+
return generateHeaderVariableAssignment(variable.variableName, variable.headerName);
|
|
434
|
+
default:
|
|
435
|
+
return generateSimpleVariableAssignment(variable.variableName, assertTarget);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function generateJsonBodyAssertion(description, assertType, requiresValues, path, expectedValue, caseSensitive) {
|
|
439
|
+
if (!(path === null || path === void 0 ? void 0 : path.trim().length) || (requiresValues && !(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length))) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
let propertyAccessor = getJsonBodyProperty(path);
|
|
443
|
+
if (requiresValues) {
|
|
444
|
+
propertyAccessor = valueToUnquotedString(propertyAccessor);
|
|
445
|
+
}
|
|
446
|
+
return generatePostmanAssertion(description, propertyAccessor, assertType, expectedValue, caseSensitive);
|
|
447
|
+
}
|
|
448
|
+
function generateJsonBodyVariableAssignment(variableName, path) {
|
|
449
|
+
return generatePostmanVariableAssignment(variableName, getJsonBodyProperty(path));
|
|
450
|
+
}
|
|
451
|
+
function getJsonBodyProperty(path) {
|
|
452
|
+
const jsonBodyAccessor = 'pm.response.json()';
|
|
453
|
+
return path
|
|
454
|
+
? `_.get(${jsonBodyAccessor}, pm.variables.replaceIn('${path}'))`
|
|
455
|
+
: jsonBodyAccessor;
|
|
456
|
+
}
|
|
457
|
+
function generateHeaderVariableAssignment(variableName, headerName) {
|
|
458
|
+
if (!headerName) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
return generatePostmanVariableAssignment(variableName, generateGetHeaderValue(headerName));
|
|
462
|
+
}
|
|
463
|
+
function generateGetHeaderValue(headerName) {
|
|
464
|
+
return `pm.response.headers.get(${JSON.stringify(headerName)})`;
|
|
465
|
+
}
|
|
466
|
+
function generateStatusAssertion(description, assertType, expectedValue) {
|
|
467
|
+
if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
let expect;
|
|
471
|
+
let target = 'pm.response.code';
|
|
472
|
+
switch (assertType) {
|
|
473
|
+
case 'Equals':
|
|
474
|
+
expect = `pm.response.to.have.status(parseInt(${expectedValue}))`;
|
|
475
|
+
break;
|
|
476
|
+
case 'NotEquals':
|
|
477
|
+
expect = `pm.response.to.not.have.status(parseInt(${expectedValue}))`;
|
|
478
|
+
break;
|
|
479
|
+
case 'Contains':
|
|
480
|
+
case 'DoesNotContain':
|
|
481
|
+
case 'StartsWith':
|
|
482
|
+
case 'EndsWith':
|
|
483
|
+
case 'MatchesRegExp':
|
|
484
|
+
target += '.toString()';
|
|
485
|
+
break;
|
|
486
|
+
case 'GreaterThan':
|
|
487
|
+
case 'GreaterThanOrEqualTo':
|
|
488
|
+
case 'LessThan':
|
|
489
|
+
case 'LessThanOrEqualTo':
|
|
490
|
+
expectedValue = `parseInt(${expectedValue})`;
|
|
491
|
+
break;
|
|
492
|
+
default:
|
|
493
|
+
throw new Error(`Unexpected status assert type: ${assertType}`);
|
|
494
|
+
}
|
|
495
|
+
return generatePostmanTest(description, expect !== null && expect !== void 0 ? expect : generatePostmanExpect(target, assertType, expectedValue));
|
|
496
|
+
}
|
|
497
|
+
function generateHeaderAssertion(description, assertType, headerName, expectedValue, caseSensitive) {
|
|
498
|
+
if (!headerName) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const normalizedHeaderName = JSON.stringify(headerName);
|
|
502
|
+
let test;
|
|
503
|
+
switch (assertType) {
|
|
504
|
+
case 'Present':
|
|
505
|
+
test = `pm.response.to.have.header(${normalizedHeaderName})`;
|
|
506
|
+
break;
|
|
507
|
+
case 'NotPresent':
|
|
508
|
+
test = `pm.response.to.not.have.header(${normalizedHeaderName})`;
|
|
509
|
+
break;
|
|
510
|
+
case 'Equals':
|
|
511
|
+
case 'NotEquals':
|
|
512
|
+
case 'Contains':
|
|
513
|
+
case 'DoesNotContain':
|
|
514
|
+
case 'StartsWith':
|
|
515
|
+
case 'EndsWith':
|
|
516
|
+
case 'MatchesRegExp':
|
|
517
|
+
break;
|
|
518
|
+
case 'GreaterThan':
|
|
519
|
+
case 'GreaterThanOrEqualTo':
|
|
520
|
+
case 'LessThan':
|
|
521
|
+
case 'LessThanOrEqualTo':
|
|
522
|
+
return;
|
|
523
|
+
default:
|
|
524
|
+
throw new Error(`Unexpected header assert type: ${assertType}`);
|
|
525
|
+
}
|
|
526
|
+
return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(`pm.response.headers.get(${normalizedHeaderName})`, assertType, expectedValue, caseSensitive));
|
|
527
|
+
}
|
|
528
|
+
function generateSizeAssertion(description, target, type, expectedValue) {
|
|
529
|
+
if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (type !== newman_types_1.AssertionType.MatchesRegExp) {
|
|
533
|
+
expectedValue = `parseInt(${expectedValue})`;
|
|
534
|
+
}
|
|
535
|
+
return generateSimpleAssertion(description, target, type, expectedValue);
|
|
536
|
+
}
|
|
537
|
+
function generateSimpleAssertion(description, target, type, expectedValue, caseSensitive = true) {
|
|
538
|
+
return generatePostmanTest(description, generatePostmanExpect(getResponseProperty(target), type, expectedValue, caseSensitive));
|
|
539
|
+
}
|
|
540
|
+
function generateSimpleVariableAssignment(name, target) {
|
|
541
|
+
return generatePostmanVariableAssignment(name, getResponseProperty(target));
|
|
542
|
+
}
|
|
543
|
+
function getResponseProperty(target) {
|
|
544
|
+
const property = RESPONSE_PROPERTIES[target];
|
|
545
|
+
if (!property) {
|
|
546
|
+
throw new Error(`No response property found for target [${target}]`);
|
|
547
|
+
}
|
|
548
|
+
return `pm.response.${property}`;
|
|
549
|
+
}
|
|
550
|
+
function generatePostmanAssertion(description, target, assertType, expectedValue, caseSensitive) {
|
|
551
|
+
return generatePostmanTest(description, generatePostmanExpect(target, assertType, expectedValue, caseSensitive));
|
|
552
|
+
}
|
|
553
|
+
function generatePostmanExpect(target, assertType, expectedValue, caseSensitive = true) {
|
|
554
|
+
if (!caseSensitive && assertionTypeSupportsCaseSensitivity(assertType)) {
|
|
555
|
+
target += '?.toUpperCase().toLowerCase()';
|
|
556
|
+
expectedValue = `${expectedValue !== null && expectedValue !== void 0 ? expectedValue : ''}.toUpperCase().toLowerCase()`;
|
|
557
|
+
}
|
|
558
|
+
return `pm.expect(${target}).to.${EXPECT_FUNCTIONS[assertType].replace(EXPECTED_VALUE_TOKEN, () => expectedValue !== null && expectedValue !== void 0 ? expectedValue : '')}`;
|
|
559
|
+
}
|
|
560
|
+
function assertionTargetSupportsCaseSensitivity(assertTarget) {
|
|
561
|
+
switch (assertTarget) {
|
|
562
|
+
case 'Header':
|
|
563
|
+
case 'JSONBody':
|
|
564
|
+
return true;
|
|
565
|
+
default:
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
exports.assertionTargetSupportsCaseSensitivity = assertionTargetSupportsCaseSensitivity;
|
|
570
|
+
function assertionTypeSupportsCaseSensitivity(assertionType) {
|
|
571
|
+
switch (assertionType) {
|
|
572
|
+
case 'Contains':
|
|
573
|
+
case 'DoesNotContain':
|
|
574
|
+
case 'StartsWith':
|
|
575
|
+
case 'EndsWith':
|
|
576
|
+
case 'Equals':
|
|
577
|
+
case 'NotEquals':
|
|
578
|
+
return true;
|
|
579
|
+
default:
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
exports.assertionTypeSupportsCaseSensitivity = assertionTypeSupportsCaseSensitivity;
|
|
584
|
+
function generatePostmanTest(description, test) {
|
|
585
|
+
return `pm.test(${JSON.stringify(description)}, function () { ${test}; });`;
|
|
586
|
+
}
|
|
587
|
+
function generatePostmanVariableAssignment(name, value) {
|
|
588
|
+
return `pm.environment.set(${JSON.stringify(name)}, ${valueToUnquotedString(value)});`;
|
|
589
|
+
}
|
|
590
|
+
function valueToUnquotedString(value) {
|
|
591
|
+
return `JSON.stringify(${value})?.replace(/^"(.+(?="$))"$/, '$1')`;
|
|
592
|
+
}
|
|
593
|
+
exports.valueToUnquotedString = valueToUnquotedString;
|
|
594
|
+
function getResponseContentType(response) {
|
|
595
|
+
var _a, _b;
|
|
596
|
+
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;
|
|
597
|
+
return contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase();
|
|
598
|
+
}
|
|
599
|
+
exports.getResponseContentType = getResponseContentType;
|
|
600
|
+
function readBody(body, contentType) {
|
|
601
|
+
var _a;
|
|
602
|
+
const bodyLength = (_a = body === null || body === void 0 ? void 0 : body.data) === null || _a === void 0 ? void 0 : _a.length;
|
|
603
|
+
if (!body || !bodyLength) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (!contentType) {
|
|
607
|
+
return `${bodyLength} bytes of data with unknown type`;
|
|
608
|
+
}
|
|
609
|
+
else if (isJson(contentType)) {
|
|
610
|
+
let bodyAsString = `${bodyLength} bytes of data`;
|
|
611
|
+
try {
|
|
612
|
+
bodyAsString = Buffer.from(body.data).toString();
|
|
613
|
+
}
|
|
614
|
+
catch (e) {
|
|
615
|
+
console.error('Unable to convert body.data to string', e);
|
|
616
|
+
return bodyAsString;
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
return JSON.parse(bodyAsString);
|
|
620
|
+
}
|
|
621
|
+
catch (e) {
|
|
622
|
+
console.error('Unable to parse body into JSON object.', e);
|
|
623
|
+
return bodyAsString;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
try {
|
|
628
|
+
return Buffer.from(body.data).toString();
|
|
629
|
+
}
|
|
630
|
+
catch (e) {
|
|
631
|
+
console.error('Unable to convert body.data to string', e);
|
|
632
|
+
return `${bodyLength} bytes of data`;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
exports.readBody = readBody;
|
|
637
|
+
function getActualValue(assertion, apiStepExecutionResult, variables) {
|
|
638
|
+
var _a, _b, _c, _d;
|
|
639
|
+
const { assertTarget, bodyPath, headerName } = assertion;
|
|
640
|
+
switch (assertTarget) {
|
|
641
|
+
case newman_types_1.AssertionTarget.Header:
|
|
642
|
+
return lodash_1.default.find((_a = apiStepExecutionResult.response) === null || _a === void 0 ? void 0 : _a.header, (header) => caseInsensitiveEquals(header.key, headerName));
|
|
643
|
+
case newman_types_1.AssertionTarget.JSONBody:
|
|
644
|
+
const contentType = getResponseContentType(apiStepExecutionResult.response);
|
|
645
|
+
const content = readBody((_b = apiStepExecutionResult.response) === null || _b === void 0 ? void 0 : _b.stream, contentType);
|
|
646
|
+
return bodyPath
|
|
647
|
+
? lodash_1.default.get(content, replaceVariables(bodyPath, variables))
|
|
648
|
+
: content;
|
|
649
|
+
case newman_types_1.AssertionTarget.Size:
|
|
650
|
+
return (_c = apiStepExecutionResult.response) === null || _c === void 0 ? void 0 : _c.responseSize;
|
|
651
|
+
case newman_types_1.AssertionTarget.Status:
|
|
652
|
+
return (_d = apiStepExecutionResult.response) === null || _d === void 0 ? void 0 : _d.code;
|
|
653
|
+
}
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
exports.getActualValue = getActualValue;
|
|
657
|
+
function replaceVariables(value, variables) {
|
|
658
|
+
var _a, _b;
|
|
659
|
+
let toReplace = value;
|
|
660
|
+
let matches;
|
|
661
|
+
while ((matches = toReplace.match(new RegExp('{{@(?<name>[^{}]+)}}')))) {
|
|
662
|
+
const variableName = (_a = matches.groups) === null || _a === void 0 ? void 0 : _a.name;
|
|
663
|
+
const variableValue = (_b = (variableName && variables[variableName])) !== null && _b !== void 0 ? _b : '';
|
|
664
|
+
toReplace = toReplace.replace(new RegExp(`{{@${variableName}}}`, 'g'), variableValue);
|
|
665
|
+
}
|
|
666
|
+
return toReplace;
|
|
667
|
+
}
|
|
668
|
+
exports.replaceVariables = replaceVariables;
|
|
669
|
+
function toPostmanScript(assertion) {
|
|
670
|
+
return [
|
|
671
|
+
generateAssertionScript(assertion),
|
|
672
|
+
generateVariableAssignmentScript(assertion),
|
|
673
|
+
]
|
|
674
|
+
.filter((script) => script)
|
|
675
|
+
.map((script) => script);
|
|
676
|
+
}
|
|
677
|
+
exports.toPostmanScript = toPostmanScript;
|
|
678
|
+
function insertMablAssertionScripts(item) {
|
|
679
|
+
var _a, _b;
|
|
680
|
+
const { eventValue: existingEventValue } = findFirstMatchingEvent(item.event, exports.TEST_LISTEN);
|
|
681
|
+
const eventValue = existingEventValue !== null && existingEventValue !== void 0 ? existingEventValue : createEmptyRequestEvent();
|
|
682
|
+
if (!existingEventValue) {
|
|
683
|
+
(_a = item.event) === null || _a === void 0 ? void 0 : _a.push(eventValue);
|
|
684
|
+
}
|
|
685
|
+
removeMablGeneratedScripts(eventValue);
|
|
686
|
+
eventValue.mablVariables = filterValidMablVariableAssignments(eventValue.mablVariables);
|
|
687
|
+
eventValue.mablAssertions = filterValidMablAssertions(eventValue.mablAssertions);
|
|
688
|
+
const mablScripts = createMablGeneratedScripts(eventValue);
|
|
689
|
+
(_b = eventValue.script.exec) === null || _b === void 0 ? void 0 : _b.push(...mablScripts);
|
|
690
|
+
}
|
|
691
|
+
exports.insertMablAssertionScripts = insertMablAssertionScripts;
|
|
692
|
+
function createMablGeneratedScripts(event) {
|
|
693
|
+
const mablVariables = convertMablVariableAssignmentsToExecArray(event);
|
|
694
|
+
const mablAssertions = convertMablAssertionsToExecArray(event);
|
|
695
|
+
if (mablVariables.length || mablAssertions.length) {
|
|
696
|
+
return [exports.MABL_GENERATED_COMMENT, ...mablVariables, ...mablAssertions];
|
|
697
|
+
}
|
|
698
|
+
return [];
|
|
699
|
+
}
|
|
700
|
+
exports.createMablGeneratedScripts = createMablGeneratedScripts;
|
|
701
|
+
function convertMablVariableAssignmentsToExecArray(event) {
|
|
702
|
+
var _a, _b;
|
|
703
|
+
return ((_b = (_a = filterValidMablVariableAssignments(event.mablVariables)) === null || _a === void 0 ? void 0 : _a.map((variable) => toPostmanScript(variable)).flat()) !== null && _b !== void 0 ? _b : []);
|
|
704
|
+
}
|
|
705
|
+
exports.convertMablVariableAssignmentsToExecArray = convertMablVariableAssignmentsToExecArray;
|
|
706
|
+
function convertMablAssertionsToExecArray(event) {
|
|
707
|
+
var _a, _b;
|
|
708
|
+
return ((_b = (_a = filterValidMablAssertions(event.mablAssertions)) === null || _a === void 0 ? void 0 : _a.map((assertion) => toPostmanScript(assertion)).flat()) !== null && _b !== void 0 ? _b : []);
|
|
709
|
+
}
|
|
710
|
+
exports.convertMablAssertionsToExecArray = convertMablAssertionsToExecArray;
|
|
711
|
+
exports.PRE_REQUEST_LISTEN = 'prerequest';
|
|
712
|
+
function splitLines(value) {
|
|
713
|
+
return value.length ? lodash_1.default.split(value, /\r?\n/) : [];
|
|
714
|
+
}
|
|
715
|
+
exports.splitLines = splitLines;
|
|
716
|
+
function createEmptyRequestEventArray() {
|
|
717
|
+
return [createEmptyRequestEvent()];
|
|
718
|
+
}
|
|
719
|
+
exports.createEmptyRequestEventArray = createEmptyRequestEventArray;
|
|
720
|
+
const createEmptyRequest = (id = (0, uuid_1.v4)()) => ({
|
|
721
|
+
id,
|
|
722
|
+
name: '',
|
|
723
|
+
request: {
|
|
724
|
+
auth: {
|
|
725
|
+
type: '',
|
|
726
|
+
},
|
|
727
|
+
body: {
|
|
728
|
+
mode: 'none',
|
|
729
|
+
raw: '',
|
|
730
|
+
file: '',
|
|
731
|
+
graphql: '',
|
|
732
|
+
formdata: [],
|
|
733
|
+
urlencoded: [],
|
|
734
|
+
},
|
|
735
|
+
header: [],
|
|
736
|
+
method: 'GET',
|
|
737
|
+
url: '',
|
|
738
|
+
},
|
|
739
|
+
event: createEmptyRequestEventArray(),
|
|
740
|
+
});
|
|
741
|
+
exports.createEmptyRequest = createEmptyRequest;
|
|
742
|
+
function processPostmanItems(items, handleItem, handleFolder) {
|
|
743
|
+
lodash_1.default.forEach(items, (item) => {
|
|
744
|
+
if (isItemGroupDefinition(item)) {
|
|
745
|
+
handleFolder === null || handleFolder === void 0 ? void 0 : handleFolder(item);
|
|
746
|
+
processPostmanItems(item.item, handleItem, handleFolder);
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
handleItem === null || handleItem === void 0 ? void 0 : handleItem(item);
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
exports.processPostmanItems = processPostmanItems;
|
|
754
|
+
function generateRawScriptField(eventValue) {
|
|
755
|
+
if (eventValue.script) {
|
|
756
|
+
eventValue.script.raw = lodash_1.default.join(eventValue.script.exec, '\n');
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
exports.generateRawScriptField = generateRawScriptField;
|
|
760
|
+
function validateCollectionFeaturesForApiTestEditor(collection) {
|
|
761
|
+
let hasFolders = false;
|
|
762
|
+
const handleFolder = (_item) => {
|
|
763
|
+
hasFolders = true;
|
|
764
|
+
};
|
|
765
|
+
processPostmanItems(collection.item, () => { }, handleFolder);
|
|
766
|
+
if (hasFolders) {
|
|
767
|
+
return exports.COLLECTION_WITH_FOLDERS_ERROR;
|
|
768
|
+
}
|
|
769
|
+
return undefined;
|
|
770
|
+
}
|
|
771
|
+
exports.validateCollectionFeaturesForApiTestEditor = validateCollectionFeaturesForApiTestEditor;
|
|
772
|
+
function isFolder(item) {
|
|
773
|
+
return 'item' in item && !!item.item;
|
|
774
|
+
}
|
|
775
|
+
exports.isFolder = isFolder;
|
|
776
|
+
function isItemGroupDefinition(item) {
|
|
777
|
+
return isFolder(item) && !isCollectionDefinition(item);
|
|
778
|
+
}
|
|
779
|
+
exports.isItemGroupDefinition = isItemGroupDefinition;
|
|
780
|
+
function isCollectionDefinition(item) {
|
|
781
|
+
return isFolder(item) && 'info' in item;
|
|
782
|
+
}
|
|
783
|
+
exports.isCollectionDefinition = isCollectionDefinition;
|
|
784
|
+
function isItemDefinition(item) {
|
|
785
|
+
return !isFolder(item);
|
|
786
|
+
}
|
|
787
|
+
exports.isItemDefinition = isItemDefinition;
|
|
788
|
+
function isSupportedAuthType(authDefinition) {
|
|
789
|
+
if (!authDefinition.type) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
return (newman_types_1.MablSupportedPostmanAuthTypes.includes(authDefinition.type) || authDefinition.type === 'noauth');
|
|
793
|
+
}
|
|
794
|
+
exports.isSupportedAuthType = isSupportedAuthType;
|
|
795
|
+
function isJson(contentType) {
|
|
796
|
+
return (!!contentType &&
|
|
797
|
+
(contentType.startsWith('application/json') ||
|
|
798
|
+
contentType.startsWith('application/vnd.api+json')));
|
|
799
|
+
}
|
|
800
|
+
exports.isJson = isJson;
|
|
801
|
+
function isXML(contentType) {
|
|
802
|
+
return (!!contentType &&
|
|
803
|
+
(contentType.startsWith('application/xml') ||
|
|
804
|
+
contentType.startsWith('text/xml')));
|
|
805
|
+
}
|
|
806
|
+
exports.isXML = isXML;
|
|
807
|
+
function isText(contentType) {
|
|
808
|
+
return !!contentType && (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('text/'));
|
|
809
|
+
}
|
|
810
|
+
exports.isText = isText;
|
|
811
|
+
function getFormDataArray(item) {
|
|
812
|
+
var _a, _b, _c;
|
|
813
|
+
if (getRequestMode(item) === 'formdata') {
|
|
814
|
+
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;
|
|
815
|
+
if (Array.isArray(formdata)) {
|
|
816
|
+
return formdata;
|
|
817
|
+
}
|
|
818
|
+
return (_c = formdata === null || formdata === void 0 ? void 0 : formdata.all()) !== null && _c !== void 0 ? _c : [];
|
|
819
|
+
}
|
|
820
|
+
return [];
|
|
821
|
+
}
|
|
822
|
+
exports.getFormDataArray = getFormDataArray;
|
|
823
|
+
function getRequestMode(item) {
|
|
824
|
+
var _a, _b;
|
|
825
|
+
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;
|
|
826
|
+
}
|
|
827
|
+
exports.getRequestMode = getRequestMode;
|
|
828
|
+
function formatContent(contentContainer) {
|
|
829
|
+
if (contentContainer === null || contentContainer === void 0 ? void 0 : contentContainer.hasOwnProperty('content')) {
|
|
830
|
+
return contentContainer.content;
|
|
831
|
+
}
|
|
832
|
+
return contentContainer;
|
|
833
|
+
}
|
|
834
|
+
exports.formatContent = formatContent;
|
|
835
|
+
function processMablProtocolProfileBehavior(item) {
|
|
836
|
+
var _a, _b;
|
|
837
|
+
const mablProtocolProfileBehavior = (_b = (_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablProtocolProfileBehavior) !== null && _b !== void 0 ? _b : [];
|
|
838
|
+
if (mablProtocolProfileBehavior.length === 0) {
|
|
839
|
+
delete item.protocolProfileBehavior;
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
lodash_1.default.set(item, 'protocolProfileBehavior', {});
|
|
843
|
+
mablProtocolProfileBehavior === null || mablProtocolProfileBehavior === void 0 ? void 0 : mablProtocolProfileBehavior.forEach((setting) => {
|
|
844
|
+
if (setting.key && setting.value) {
|
|
845
|
+
let valueToSet;
|
|
846
|
+
try {
|
|
847
|
+
valueToSet = JSON.parse(setting.value);
|
|
848
|
+
}
|
|
849
|
+
catch (error) {
|
|
850
|
+
valueToSet = setting.value;
|
|
851
|
+
}
|
|
852
|
+
lodash_1.default.set(item, ['protocolProfileBehavior', setting.key], valueToSet);
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
function createOptionalVariable(key, type, value, defaultValue) {
|
|
857
|
+
if (value === undefined && defaultValue === undefined) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
let parsedValue = value !== null && value !== void 0 ? value : defaultValue;
|
|
861
|
+
if (type === 'boolean') {
|
|
862
|
+
parsedValue = parsedValue === 'true';
|
|
863
|
+
}
|
|
864
|
+
return { key, type, value: parsedValue };
|
|
865
|
+
}
|
|
866
|
+
function mablAuthToPostman(mablAuth, undefinedType) {
|
|
867
|
+
let auth;
|
|
868
|
+
if (mablAuth) {
|
|
869
|
+
const { apikey, basic, bearer, oauth1 } = mablAuth;
|
|
870
|
+
const type = mablAuth.type;
|
|
871
|
+
if (type === undefinedType) {
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
else if (type === exports.NO_AUTH) {
|
|
875
|
+
auth = { type };
|
|
876
|
+
}
|
|
877
|
+
else if (type === exports.API_KEY_AUTH) {
|
|
878
|
+
auth = {
|
|
879
|
+
type,
|
|
880
|
+
apikey: [
|
|
881
|
+
{
|
|
882
|
+
key: 'key',
|
|
883
|
+
value: apikey === null || apikey === void 0 ? void 0 : apikey.key,
|
|
884
|
+
type: 'string',
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
key: 'value',
|
|
888
|
+
value: apikey === null || apikey === void 0 ? void 0 : apikey.value,
|
|
889
|
+
type: 'string',
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
key: 'in',
|
|
893
|
+
value: apikey === null || apikey === void 0 ? void 0 : apikey.in,
|
|
894
|
+
type: 'string',
|
|
895
|
+
},
|
|
896
|
+
],
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
else if (type === exports.BASIC_AUTH) {
|
|
900
|
+
auth = {
|
|
901
|
+
type,
|
|
902
|
+
basic: [
|
|
903
|
+
{
|
|
904
|
+
key: 'username',
|
|
905
|
+
value: basic === null || basic === void 0 ? void 0 : basic.username,
|
|
906
|
+
type: 'string',
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
key: 'password',
|
|
910
|
+
value: basic === null || basic === void 0 ? void 0 : basic.password,
|
|
911
|
+
type: 'string',
|
|
912
|
+
},
|
|
913
|
+
],
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
else if (type === exports.BEARER_TOKEN_AUTH) {
|
|
917
|
+
auth = {
|
|
918
|
+
type,
|
|
919
|
+
bearer: [
|
|
920
|
+
{
|
|
921
|
+
key: 'token',
|
|
922
|
+
value: bearer === null || bearer === void 0 ? void 0 : bearer.token,
|
|
923
|
+
type: 'string',
|
|
924
|
+
},
|
|
925
|
+
],
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
else if (type === exports.OAUTH1_AUTH) {
|
|
929
|
+
auth = {
|
|
930
|
+
type,
|
|
931
|
+
oauth1: [
|
|
932
|
+
createOptionalVariable('addParamsToHeader', 'boolean', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.addParamsToHeader, exports.DEFAULT_ADD_OAUTH1_TO_HEADER_VALUE),
|
|
933
|
+
createOptionalVariable('addEmptyParamsToSign', 'boolean', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.addEmptyParamsToSign),
|
|
934
|
+
createOptionalVariable('callback', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.callback),
|
|
935
|
+
createOptionalVariable('consumerKey', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.consumerKey),
|
|
936
|
+
createOptionalVariable('consumerSecret', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.consumerSecret),
|
|
937
|
+
createOptionalVariable('includeBodyHash', 'boolean', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.includeBodyHash),
|
|
938
|
+
createOptionalVariable('nonce', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.nonce),
|
|
939
|
+
createOptionalVariable('realm', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.realm),
|
|
940
|
+
createOptionalVariable('signatureMethod', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.signatureMethod, exports.HMAC_SHA1_SIGNATURE),
|
|
941
|
+
createOptionalVariable('timestamp', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.timestamp),
|
|
942
|
+
createOptionalVariable('token', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.token),
|
|
943
|
+
createOptionalVariable('tokenSecret', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.tokenSecret),
|
|
944
|
+
createOptionalVariable('verifier', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.verifier),
|
|
945
|
+
createOptionalVariable('version', 'string', oauth1 === null || oauth1 === void 0 ? void 0 : oauth1.version, exports.DEFAULT_OAUTH1_VERSION),
|
|
946
|
+
].filter((variable) => variable),
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return auth;
|
|
951
|
+
}
|
|
952
|
+
exports.mablAuthToPostman = mablAuthToPostman;
|
|
953
|
+
function processItemAuth(item) {
|
|
954
|
+
var _a, _b;
|
|
955
|
+
const itemAuth = mablAuthToPostman((_a = item.mablTemporaryStorage) === null || _a === void 0 ? void 0 : _a.mablAuth, exports.INHERIT_AUTH_FROM_PARENT_VALUE);
|
|
956
|
+
if (itemAuth) {
|
|
957
|
+
lodash_1.default.set(item, 'request.auth', itemAuth);
|
|
958
|
+
}
|
|
959
|
+
else if ((_b = item.request) === null || _b === void 0 ? void 0 : _b.auth) {
|
|
960
|
+
item.request.auth = {};
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
exports.processItemAuth = processItemAuth;
|
|
964
|
+
function removeInvalidHeaders(item) {
|
|
965
|
+
var _a;
|
|
966
|
+
if ((_a = item.request) === null || _a === void 0 ? void 0 : _a.header) {
|
|
967
|
+
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; });
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
exports.removeInvalidHeaders = removeInvalidHeaders;
|
|
971
|
+
function replaceRawScriptWithExecArray(eventsContainer, processingForRepair) {
|
|
972
|
+
var _a;
|
|
973
|
+
(_a = eventsContainer.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => {
|
|
974
|
+
var _a;
|
|
975
|
+
if (event.script) {
|
|
976
|
+
if (!processingForRepair) {
|
|
977
|
+
event.script.exec = splitLines((_a = event.script.raw) !== null && _a !== void 0 ? _a : '');
|
|
978
|
+
}
|
|
979
|
+
else if (event.script.raw && event.script.raw.length > 0) {
|
|
980
|
+
event.script.exec = splitLines(event.script.raw);
|
|
981
|
+
}
|
|
982
|
+
delete event.script.raw;
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
exports.replaceRawScriptWithExecArray = replaceRawScriptWithExecArray;
|
|
987
|
+
function processPostmanItem(item) {
|
|
988
|
+
if (!item.id) {
|
|
989
|
+
item.id = (0, uuid_1.v4)();
|
|
990
|
+
}
|
|
991
|
+
processMablProtocolProfileBehavior(item);
|
|
992
|
+
processItemAuth(item);
|
|
993
|
+
removeInvalidHeaders(item);
|
|
994
|
+
}
|
|
995
|
+
exports.processPostmanItem = processPostmanItem;
|
|
996
|
+
function insertMablScriptsIntoCollection(collection, getSnippet) {
|
|
997
|
+
var _a, _b;
|
|
998
|
+
(_a = collection.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => insertMablScriptsIntoEvent(event, getSnippet));
|
|
999
|
+
(_b = collection.item) === null || _b === void 0 ? void 0 : _b.forEach((item) => {
|
|
1000
|
+
var _a;
|
|
1001
|
+
return (_a = item.event) === null || _a === void 0 ? void 0 : _a.forEach((event) => insertMablScriptsIntoEvent(event, getSnippet));
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
exports.insertMablScriptsIntoCollection = insertMablScriptsIntoCollection;
|
|
1005
|
+
function insertMablScriptsIntoEvent(event, getSnippet) {
|
|
1006
|
+
var _a;
|
|
1007
|
+
removeMablGeneratedScripts(event);
|
|
1008
|
+
const mablScripts = createPostmanScript(convertMablSnippetsToExecArray(event, getSnippet), createMablGeneratedScripts(event));
|
|
1009
|
+
if (!((_a = event.mablSnippets) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1010
|
+
mablScripts.exec = [...event.script.exec, ...mablScripts.exec];
|
|
1011
|
+
}
|
|
1012
|
+
event.script = mablScripts;
|
|
1013
|
+
delete event.mablAssertions;
|
|
1014
|
+
delete event.mablSnippets;
|
|
1015
|
+
delete event.mablVariables;
|
|
1016
|
+
}
|
|
1017
|
+
function createPostmanScript(...scripts) {
|
|
1018
|
+
return {
|
|
1019
|
+
id: (0, exports.uuid)(),
|
|
1020
|
+
exec: scripts.flatMap((lines) => lines),
|
|
1021
|
+
type: 'text/javascript',
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
exports.createPostmanScript = createPostmanScript;
|
|
1025
|
+
function convertMablSnippetsToExecArray(event, getSnippetFromInvariantId) {
|
|
1026
|
+
if (!event.mablSnippets) {
|
|
1027
|
+
return [];
|
|
1028
|
+
}
|
|
1029
|
+
const snippetBodies = event.mablSnippets.map((apiTestSnippet) => {
|
|
1030
|
+
const snippet = apiTestSnippet.reusable
|
|
1031
|
+
? getSnippetFromInvariantId(apiTestSnippet.invariantId)
|
|
1032
|
+
: apiTestSnippet;
|
|
1033
|
+
if (!(snippet === null || snippet === void 0 ? void 0 : snippet.body)) {
|
|
1034
|
+
if (apiTestSnippet.reusable) {
|
|
1035
|
+
console.warn(`Unable to find reusable snippet with invariant ID ${apiTestSnippet.invariantId}`);
|
|
1036
|
+
return `// Missing snippet ${apiTestSnippet.invariantId}`;
|
|
1037
|
+
}
|
|
1038
|
+
return '';
|
|
1039
|
+
}
|
|
1040
|
+
const body = (0, encodingUtil_1.b64DecodeUnicodeNodeOrBrowser)(snippet.body);
|
|
1041
|
+
return [
|
|
1042
|
+
createCommentForApiTestSnippet(snippet, 'start'),
|
|
1043
|
+
body,
|
|
1044
|
+
createCommentForApiTestSnippet(snippet, 'end'),
|
|
1045
|
+
'',
|
|
1046
|
+
].join('\n');
|
|
1047
|
+
});
|
|
1048
|
+
return snippetBodies.flatMap((body) => body.split('\n'));
|
|
1049
|
+
}
|
|
1050
|
+
exports.convertMablSnippetsToExecArray = convertMablSnippetsToExecArray;
|
|
1051
|
+
function createCommentForApiTestSnippet(snippet, position) {
|
|
1052
|
+
var _a, _b;
|
|
1053
|
+
if (snippet.reusable) {
|
|
1054
|
+
return `// ${position} of reusable snippet "${(_a = snippet.name) !== null && _a !== void 0 ? _a : snippet.id}"`;
|
|
1055
|
+
}
|
|
1056
|
+
return `// ${position} of one-time snippet "${(_b = snippet.name) !== null && _b !== void 0 ? _b : snippet.id}"`;
|
|
1057
|
+
}
|
|
1058
|
+
exports.createCommentForApiTestSnippet = createCommentForApiTestSnippet;
|
|
1059
|
+
const uuid = () => (0, uuid_1.v4)();
|
|
1060
|
+
exports.uuid = uuid;
|