import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { DynamicSelectFieldConfig, SelectOption } from '../../dynamic-select/dynamic-select-field.component'; import { CqaAutocompleteOption } from '../../autocomplete/autocomplete.model'; import * as i0 from "@angular/core"; export declare const API_EDIT_STEP_LABELS: { readonly REQUEST_DETAILS: "Request Details"; readonly STORE_RESPONSE: "Store Response"; readonly VALIDATION: "Validation"; }; export declare type ApiEditPayloadTab = 'headers' | 'body' | 'params' | 'authorization'; /** Which body content block is visible: headers (tabs) or import cURL textarea. */ export declare type ApiEditBodyView = 'headers' | 'import-curl'; export interface ApiEditHeaderRow { name: string; type: string; value: string; } /** Payload emitted when user clicks Send Request (environment, method, url, headers, body). */ export interface ApiEditSendRequestPayload { environment: string; method: string; url: string; headers: ApiEditHeaderRow[]; payload?: string; authType?: string; bearerToken?: string; oauth2?: ApiEditOAuth2Payload; payloadType?: 'raw' | 'x-www-form-urlencoded' | 'form-data'; payloadFormat?: string; payloadText?: string; keyValueRows?: { key: string; value: string; }[]; keyTypeValueRows?: { key: string; type: string; value: string; }[]; paramsRows?: { key: string; value: string; }[]; } /** OAuth 2.0 auth fields (when auth type is OAuth 2.0). */ export interface ApiEditOAuth2Payload { grantType: string; accessTokenUrl: string; clientId: string; clientSecret: string; scope: string; clientAuthentication: string; } /** Step 1 request + body payload. */ export interface ApiEditStep1Payload { summary?: string; environment: string; method: string; url: string; headers: ApiEditHeaderRow[]; /** Selected auth type: e.g. 'no-auth', 'bearer', 'oauth2'. */ authType: string; /** Bearer token value when authType is 'bearer'. */ bearerToken?: string; /** OAuth 2.0 fields when authType is 'oauth2'. */ oauth2?: ApiEditOAuth2Payload; activePayloadTab: ApiEditPayloadTab; payloadType: 'raw' | 'x-www-form-urlencoded' | 'form-data'; payloadFormat: string; payloadText: string; keyValueRows: { key: string; value: string; }[]; keyTypeValueRows: { key: string; type: string; value: string; }[]; paramsRows: { key: string; value: string; }[]; } /** Step 2 store-response payload. */ export interface ApiEditStep2Payload { variableName: string; } /** Response body verification row. */ export interface ApiEditResponseBodyVerificationRow { jsonPath: string; verification: string; dataType: string; expectedValue: string; } /** Status verification row. */ export interface ApiEditStatusVerificationRow { verification: string; expectedValue: string; } /** Step 3 validation payload. */ export interface ApiEditStep3Payload { activeResponseVerificationTab: 'response-body' | 'status'; responseBodyVerifications: ApiEditResponseBodyVerificationRow[]; statusVerifications: ApiEditStatusVerificationRow[]; } /** Full payload emitted when user clicks Create (all steps’ data). */ export interface ApiEditCreatePayload { step1: ApiEditStep1Payload; step2: ApiEditStep2Payload; step3: ApiEditStep3Payload; /** Advanced settings variables for this API step (e.g. isStepOptional, shouldSkip). */ advancedSettingsVariables?: any[]; } /** Environment option: either a string (display = value) or an object with id, name, value, label. */ export declare type EnvironmentOptionInput = string | SelectOption; /** Result of parsing a cURL command. */ export interface ParsedCurl { method: string; url: string; headers: ApiEditHeaderRow[]; body: string; /** Entries from -F / --form flags (multipart/form-data). */ formData: { key: string; type: 'text' | 'file'; value: string; }[]; } export declare class ApiEditStepComponent implements OnChanges, OnInit, AfterViewInit, OnDestroy { private readonly fb; private readonly cdr; initialMethod?: string; initialEnvironment?: string; initialStep?: number; initialUrl?: string; initialPayloadTab?: ApiEditPayloadTab; /** Initial payload type (raw, x-www-form-urlencoded, form-data) when editing an existing step. */ initialPayloadType?: 'raw' | 'x-www-form-urlencoded' | 'form-data'; /** Initial payload text (body) when editing an existing step. */ initialPayloadText?: string; /** Initial summary when editing an existing step (maps to step description). */ initialSummary?: string; initialHeaders?: ApiEditHeaderRow[]; initialResponsePreview?: string; initialVariableName?: string; /** Initial response body verifications when editing an existing step. */ initialResponseBodyVerifications?: ApiEditResponseBodyVerificationRow[]; /** Initial status verifications when editing an existing step. */ initialStatusVerifications?: ApiEditStatusVerificationRow[]; /** Initial active response verification tab when editing an existing step. */ initialActiveResponseVerificationTab?: 'response-body' | 'status'; editMode?: boolean; /** True while parent is creating the step (API in progress); show loader on Create/Update button */ isCreatingStep: boolean; /** Emits the cURL string when user clicks Import (value from the textarea control). */ importCurl: EventEmitter; /** Emits when user cancels the Import cURL panel (clicks Cancel). */ importCurlCancel: EventEmitter; /** Emits when user clicks Send Request, with environment, method, url, and headers. */ sendRequest: EventEmitter; back: EventEmitter; /** Emits when user clicks the Cancel button (step 1). */ cancel: EventEmitter; next: EventEmitter; /** Emits when user clicks Create with all entered details: step1 (environment, HTTP method, URL, headers, body), step2 (variable name), step3 (verifications). */ create: EventEmitter; /** Emits whenever headers change (add, remove, or edit) so the parent can reflect them in the canvas/controls. */ headersChange: EventEmitter; /** Emits when the environment dropdown selection changes (selected value/id or null for None) so the parent can provide urlOptions. */ environmentChange: EventEmitter; /** Form control for Import cURL textarea; value is emitted when user clicks Import. */ readonly importCurlControl: FormControl; variableName: string; variableNameError: string; urlError: string; /** Step summary (displayed in API step title; maps to step description). */ summary: string; /** Controls which body content is visible: headers (default) or import-curl. */ bodyView: ApiEditBodyView; readonly stepLabels: ({ index: number; label: "Request Details"; } | { index: number; label: "Store Response"; } | { index: number; label: "Validation"; })[]; currentStep: number; /** The label for the current step only (used when showing a single step in the indicator). */ get activeStepLabel(): { index: number; label: string; } | undefined; private readonly minStep; private readonly maxStep; /** Percentage to translate the step strip (0, -33.333, -66.666) for CSS transition. */ get stripTranslatePercent(): number; setStep(step: number): void; private applyInitialStep; /** HTTP method options: array of strings or objects with id, name, value, label (passed from parent). */ httpMethodOptions: EnvironmentOptionInput[]; /** Form for HTTP method select (cqa-dynamic-select) */ methodForm: FormGroup; /** Config for method dropdown (updated when httpMethodOptions changes to avoid new reference every CD) */ methodSelectConfig: DynamicSelectFieldConfig; private updateMethodSelectConfig; private getMethodValues; /** Form for environment select (cqa-dynamic-select) */ environmentForm: FormGroup; /** Environment options: array of strings or objects with id, name, value, label (passed from parent). */ environmentOptions: EnvironmentOptionInput[]; /** Whether more environments are available for infinite scroll (provided by parent). */ hasMoreEnvironments: boolean; /** True while parent is loading environments (search or load more). */ isLoadingEnvironments: boolean; /** URL field options when an environment is selected (base URL + parameters as *|key|). Parent fills this when environmentChange fires. */ urlOptions: CqaAutocompleteOption[]; /** Config for environment dropdown (updated when environmentOptions changes to avoid new reference every CD) */ environmentSelectConfig: DynamicSelectFieldConfig; private static toSelectOption; private static getOptionValue; private updateEnvironmentSelectConfig; private getEnvironmentValues; /** Emit when user searches environments from the dropdown. */ environmentSearch: EventEmitter; /** Emit when user scrolls to load more environments. */ environmentLoadMore: EventEmitter; /** Form for Auth Type select (Authorization tab) */ authTypeForm: FormGroup; /** Auth type options: array of strings or objects with id, name, value, label (passed from parent). Falls back to built-in list when empty. */ authTypeOptions: EnvironmentOptionInput[]; /** Initial auth type (string or option object). When not set, first of authTypeOptions or default "No Auth" is used. */ initialAuthType?: string | EnvironmentOptionInput; /** Default options when authTypeOptions is empty (same shape as environment) */ private static readonly DEFAULT_AUTH_TYPE_OPTIONS; /** Config for Auth Type dropdown (updated when authTypeOptions changes, like environment) */ authTypeSelectConfig: DynamicSelectFieldConfig; private updateAuthTypeSelectConfig; private getAuthTypeValues; /** Current auth type value (e.g. 'no-auth') for template */ get selectedAuthType(): string; /** Bearer token value (Authorization tab, when auth type is Bearer Token). */ bearerToken: string; /** Form for OAuth 2.0 fields (Authorization tab when auth type is OAuth 2.0). */ oauth2Form: FormGroup; /** Grant type options for OAuth 2.0 */ private static readonly OAUTH_GRANT_TYPE_OPTIONS; /** Client authentication method options for OAuth 2.0 */ private static readonly OAUTH_CLIENT_AUTH_OPTIONS; readonly oauth2GrantTypeSelectConfig: DynamicSelectFieldConfig; readonly oauth2ClientAuthSelectConfig: DynamicSelectFieldConfig; /** Current HTTP method (from form or default: first of httpMethodOptions). Treats empty string as unset. */ get selectedMethod(): string; set selectedMethod(v: string); /** True when the selected HTTP method is GET, HEAD, or DELETE (no request body). */ get isMethodWithoutBody(): boolean; /** Cached environment value from last selection (so Create payload has the selected value). */ private currentEnvironmentValue; /** Cached HTTP method from last selection (so Create payload has the selected value). */ private currentMethodValue; /** Current environment (from form or default: first of environmentOptions). Treats empty string as unset. */ get selectedEnvironment(): string; set selectedEnvironment(v: string); /** Called when user selects an environment; keeps currentEnvironmentValue in sync, sets request URL from environment when available, and notifies parent for urlOptions. */ onEnvironmentSelectionChange(event: { key: string; value: unknown; }): void; /** When user selects an option from the URL autocomplete (e.g. environment parameter *|key|), set the URL field to that value. */ onUrlOptionSelect(option: CqaAutocompleteOption): void; /** * Resolve the request URL for the selected environment option. * Environment options may carry an optional `url` (e.g. from Environment model); "None" has no url. */ private getSelectedEnvironmentUrl; /** Called when user selects an HTTP method; keeps currentMethodValue in sync for create payload. */ onMethodSelectionChange(event: { key: string; value: unknown; }): void; private _url; /** URL for the request. Getter/setter syncs query params with the Params tab (Postman-style). */ get url(): string; set url(value: string); /** When true, params form changes should not update the URL (we're syncing from URL). */ private paramsSyncingFromUrl; /** Placeholder for the URL field: show "Enter URL or select Parameter *" when urlOptions are available (environment selected). */ get urlPlaceholder(): string; readonly payloadTabs: { value: ApiEditPayloadTab; label: string; }[]; activePayloadTab: ApiEditPayloadTab; /** Step 3: Response verification tabs */ readonly responseVerificationTabs: { value: 'response-body' | 'status'; label: string; }[]; activeResponseVerificationTab: 'response-body' | 'status'; /** Payload type for Body/Params/Authorization: raw, x-www-form-urlencoded, form-data */ payloadType: 'raw' | 'x-www-form-urlencoded' | 'form-data'; /** Segment options for payload type (used by cqa-segment-control) */ readonly payloadTypeSegments: { label: string; value: string; }[]; onPayloadTypeChange(val: string): void; /** Form for Format select (Body/Params/Authorization) */ payloadFormatForm: FormGroup; /** Format options: array of strings or objects (passed from parent). Falls back to JSON, XML, HTML, Text when empty. */ formatOptions: EnvironmentOptionInput[]; initialFormat?: string; private static readonly DEFAULT_FORMAT_OPTIONS; /** Config for Format dropdown (updated when formatOptions changes, like Method dropdown) */ payloadFormatSelectConfig: DynamicSelectFieldConfig; private updatePayloadFormatSelectConfig; private getFormatValues; /** Payload text area value for Body/Params/Authorization */ payloadText: string; /** JSON parse error when format is JSON and payload is invalid; null when valid or not JSON. */ payloadJsonError: { line: number; column: number; message: string; excerpt: string; caretOffset: number; } | null; /** Line numbers for payload textarea (1, 2, 3, ...) based on current line count. */ get payloadLineNumbers(): number[]; /** Whether current payload format is JSON (so we validate and show JSON editor behavior). */ get isPayloadFormatJson(): boolean; /** Error messages for the payload textarea (red border + bottom line). */ get payloadJsonErrors(): string[]; /** Tooltip content for the line-level error icon (parse error on line X, excerpt, caret, message). */ get payloadJsonErrorTooltip(): string; onPayloadTextChange(value: string): void; onPayloadInput(event: Event): void; onPayloadKeydown(event: KeyboardEvent): void; /** Validate payload when format is JSON; sets payloadJsonError or clears it. */ validatePayloadJson(): void; private extractPositionFromJsonError; private positionToLineColumn; private normalizeJsonErrorMessage; payloadEditorWithLinesRef?: ElementRef; payloadTextareaRef?: ElementRef; private static readonly DEFAULT_HEADER_NAME_OPTIONS; /** Header name options: array of strings or objects with id, name, value, label (passed from parent). Falls back to built-in list when empty. */ headerNameOptions: EnvironmentOptionInput[]; /** Form array for header rows; each item is FormGroup({ name, value }) for cqa-dynamic-select and value input */ headersFormArray: FormArray; /** Typed accessor for template (FormArray.controls is AbstractControl[]) */ get headerRows(): FormGroup[]; /** Config for header name dropdown (updated when headerNameOptions changes to avoid new reference every CD) */ headerNameSelectConfig: DynamicSelectFieldConfig; private updateHeaderNameSelectConfig; /** Collects distinct non-empty header names currently in the headers form (for dynamic options). */ private getCurrentHeaderNamesFromForm; private readonly defaultHeaders; /** Form array for key-value rows (Body payload); each item is FormGroup({ key, value }) */ keyValueFormArray: FormArray; get keyValueRows(): FormGroup[]; /** Form array for key-type-value rows; each item is FormGroup({ key, type, value }) */ keyTypeValueFormArray: FormArray; get keyTypeValueRows(): FormGroup[]; /** Form array for Params tab key-value rows; each item is FormGroup({ key, value }) */ paramsFormArray: FormArray; get paramsRows(): FormGroup[]; /** Config for Type dropdown in key-type-value rows (Text, File) */ readonly keyTypeValueTypeSelectConfig: DynamicSelectFieldConfig; /** Form array for response body verification rows; each item is FormGroup({ jsonPath, verification, dataType, expectedValue }) */ verificationFormArray: FormArray; get verificationRows(): FormGroup[]; /** Verification options: array of strings or objects (passed from parent). Falls back to built-in list when empty. */ verificationOptions: EnvironmentOptionInput[]; private static readonly DEFAULT_VERIFICATION_OPTIONS; /** Config for Verification dropdown (updated when verificationOptions changes, like Method dropdown) */ verificationSelectConfig: DynamicSelectFieldConfig; private updateVerificationSelectConfig; private getVerificationValues; private getDefaultVerification; /** Data Type options: array of strings or objects (passed from parent). Falls back to built-in list when empty. */ verificationDataTypeOptions: EnvironmentOptionInput[]; private static readonly DEFAULT_DATA_TYPE_OPTIONS; /** Config for Data Type dropdown (updated when verificationDataTypeOptions changes, like Method dropdown) */ verificationDataTypeSelectConfig: DynamicSelectFieldConfig; private updateVerificationDataTypeSelectConfig; private getDataTypeValues; private getDefaultDataType; /** Config for Expected Value when Data Type is Boolean (true/false dropdown) */ readonly verificationExpectedValueBooleanSelectConfig: DynamicSelectFieldConfig; /** Form array for Status tab verification rows; each item is FormGroup({ verification, expectedValue }) */ statusVerificationFormArray: FormArray; get statusVerificationRows(): FormGroup[]; /** Config for Status tab Verification dropdown (Equals, Not equal, Less than, Greater than) */ /** Status tab Verification options (Equals, Not equal, etc.). Falls back to built-in list when empty. */ statusVerificationOptions: EnvironmentOptionInput[]; private static readonly DEFAULT_STATUS_VERIFICATION_OPTIONS; /** Config for Status tab Verification dropdown (updated when statusVerificationOptions changes). */ statusVerificationSelectConfig: DynamicSelectFieldConfig; private updateStatusVerificationSelectConfig; private getStatusVerificationValues; private getDefaultStatusVerification; responsePreview: string; /** Reference to the response preview section, used to scroll into view after Send Request completes. */ responsePreviewRef?: ElementRef; private methodChangesSub?; private formatChangesSub?; private headerNameOptionsChangesSub?; private environmentFormChangesSub?; private methodFormChangesSub?; private paramsFormArrayChangesSub?; advancedExpanded: boolean; advancedSettingsVariables: any[]; advancedVariablesForm: FormArray; constructor(fb: FormBuilder, cdr: ChangeDetectorRef); ngOnInit(): void; ngAfterViewInit(): void; ngOnDestroy(): void; /** Sync line numbers column scroll with payload textarea scroll (Postman-style). */ private setupPayloadTextareaScrollSync; private buildKeyValueFormArray; private buildKeyTypeValueFormArray; private buildParamsFormArray; /** True if URL is a parameter placeholder (e.g. *|param|); must not be parsed with URL() which encodes | to %7C. */ private static isParameterUrl; /** Decode URL for display/payload: strip /* prefix and decode %7C to | so *|param| shows correctly. */ private static decodeUrlForDisplay; /** Parse URL into base (without query/fragment) and query key-value pairs. Preserves relative URLs and parameter placeholders. */ private parseQueryParamsFromUrl; /** Get base URL (without query/fragment) for building URL from params. Preserves relative URLs and parameter placeholders. */ private getBaseUrl; /** * Set the payload format dropdown using the Content-Type header first, then * fall back to inspecting the body content (JSON braces, XML tags, HTML doctype). */ private applyBodyFormat; /** Parse application/x-www-form-urlencoded body (key=value&...) into key-value rows. */ private parseFormUrlEncodedBody; /** * If form body has a single key whose value is URL-decoded JSON, return it pretty-printed for Raw body. * Otherwise return null (caller keeps x-www-form-urlencoded view). */ private tryFormBodyValueAsRawJson; /** Update Params table from current URL query string (Postman-style). */ private syncParamsFromUrl; /** Update URL query string from Params table (Postman-style). */ private syncUrlFromParams; private buildVerificationFormArray; private buildStatusVerificationFormArray; private buildHeadersFormArray; /** Reset all three steps and all entered data to initial/default state. Used when user cancels on step 1. */ private resetAllStepsAndData; /** Handler: show import cURL panel (called when user clicks "Import API cURL"). Resets textarea so it is cleared each time. */ openImportCurlPanel(): void; /** Reset URL, method, headers, body, and params to empty/default before applying imported cURL. */ private resetRequestFieldsBeforeCurlImport; /** Handler: parse cURL from control, bind to form fields, emit and close panel. */ onImportCurlConfirm(): void; /** Handler: emit cancel and close panel. Called when user clicks Cancel in import cURL panel. */ onCancelImportCurl(): void; /** Handler: show headers section (called from Cancel or after Import in import panel). */ closeImportCurlPanel(): void; /** * Validate URL: must be required and match http/https pattern * Also allows parameter placeholders like @|paramName| */ private validateUrl; /** * Check if URL is valid (for button disabled state) */ get isUrlValid(): boolean; onSendRequest(): void; onVariableNameChange(): void; onBack(): void; /** Called when user clicks the Cancel button (step 1). Emits cancel then runs normal back flow. */ onCancel(): void; onNext(): void; setPayloadTab(value: ApiEditPayloadTab): void; setResponseVerificationTab(value: 'response-body' | 'status'): void; addHeader(): void; removeHeader(index: number): void; /** When user adds a custom header name via the dropdown "Add '…'" option, set the control value. */ onHeaderNameAddCustomValue(event: { key: string; value: string; }, row: FormGroup): void; trackByHeader(index: number): number; addKeyValueRow(): void; removeKeyValueRow(index: number): void; trackByKeyValue(index: number): number; addKeyTypeValueRow(): void; removeKeyTypeValueRow(index: number): void; trackByKeyTypeValue(index: number): number; addParamsRow(): void; removeParamsRow(index: number): void; trackByParams(index: number): number; addVerificationRow(): void; removeVerificationRow(index: number): void; trackByVerification(index: number): number; /** When Data Type changes in Response Body verification, reset Expected Value for that row. */ onVerificationDataTypeChange(row: FormGroup, event: { key: string; value: unknown; }): void; addStatusVerificationRow(): void; removeStatusVerificationRow(index: number): void; trackByStatusVerification(index: number): number; /** * Build reactive form for advanced settings variables. */ private buildAdvancedVariablesForm; /** * Handle advanced boolean changes and keep both data and form in sync. */ onAdvancedVariableBooleanChange(variableName: string, value: boolean): void; /** * Handle non-boolean advanced values (kept for API compatibility; currently unused). */ onAdvancedVariableValueChange(variableName: string, value: any): void; /** Emit all entered details (environment, HTTP method, URL, headers, body, step2 variable, step3 verifications) when user clicks Create. */ onCreate(): void; /** Minimal payload when getCreatePayload throws (so create always emits). */ private getCreatePayloadFallback; /** Normalize form control value to string (handles object or string). */ private static getControlValue; /** Build full create payload: environment, HTTP method, URL, headers, body (step1), variable name (step2), verifications (step3). */ private getCreatePayload; /** Current header rows from form (for consumers that read headers) */ get headers(): ApiEditHeaderRow[]; ngOnChanges(changes: SimpleChanges): void; /** * Smoothly scrolls the response preview section into view within the scrollable container. * Called when a fresh response preview value is set from the parent (API builder). */ private scrollPreviewIntoView; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }