/** * @crowdstrike/logscale-parser-edit * * Allows you to embed an editor for LogScale parsers as a WebComponent. * * ```ts * // Importing the module defines the "logscale-parser-edit" custom element as a side-effect. * import {createElement, Options} from "@crowdstrike/logscale-parser-edit"; * * // See documentation for `createElement` * const element : ParserEdit = createElement(options); * document.body.appendChild(element); * ``` * * @packageDocumentation */ /** Common options shared by all LogScale Webcomponents * @public */ export declare interface CommonOptions { /** The current unix time as millisecs. Defaults to `Date.now` if not set. */ currentTime?: number; /** Allows you to open the webcomponent's internal shadow DOM. * * This is useful for writing E2E tests where you want to inspect the internal DOM of the WebComponent. * Do this sparingly, since the internal DOM elements can change between releases of * the webcomponents. */ shadowRootMode?: "open" | "closed"; /** Names of experimental features to be enabled. The names of features are provided by LogScale on a case-by-case basis. * Should be left empty or undefined by default. */ featureFlags?: Array | Record; } /** Helper function that creates a `logscale-parser-edit` webcomponent and initializes it with the provided options. * * ```ts * const options : Options = { * parserId: "some-parser-id", * repoName: "some-repo-name", * apiURL: "https://...", * theme: "dark", * // ... * }; * * const element : ParserEdit = createElement(options); * * // To trigger the save behavior, you need to register a callback * element.onSave((error: Error) => { * if (error) { * console.error("SAVE FAILED", error); * return; * } * console.log("SAVE SUCCESS"); * }); * // then you can call the `save` method as needed: * element.save(); * * // ParserEdit inherits from HtmlElement and can be added to the DOM: * document.body.appendChild(element); * ``` * * @public */ export declare function createElement(options: Options): ParserEdit; /** Initialization options. * @public */ export declare interface Options extends CommonOptions { /** Base URL where the LogScale cluster is accessed. */ apiURL: string; /** If the LSP websocket server is accessed from a different URL than the `apiUrl`, you can set this. */ lspURL?: string; /** If provided, this token will be passed in the Authentication header as a Bearer token. * This can be a user's personal API token or an OICD token. * * This method of setting the authentication token is not recommended, since it exposes the authorization token to be read from JavaScript. * Consider using a secure HTTP-only cookie instead. */ authToken?: string; /** If provided, HTTP calls will have the "X-CSRF-Token" header set to this value. */ csrfToken?: string; /** Will initialize the webcomponent in light or dark mode. The theme can be switched through the `setTheme()` method after initialization. */ theme: 'light' | 'dark'; /** Language to start the webcomponent in. */ locale?: "jp" | "en"; /** Advanced feature: Set the language version to be used. This depends on the backend configuration and might crash if set inappropriately. */ languageVersion?: string; /** Name of the repository containing the parser to be edited. */ repoName: string; /** ID of the parser to be edited. */ parserId: string; } /** Custom element that embeds the LogScale parser editor. * @public @sealed */ export declare class ParserEdit extends WebcomponentBase { /** Requests the parser to be saved. Will trigger the callback provided by `#onSave` once completed (on success or failure). * @public */ save(): void; /** Saves a callback for when a parser is saved. * @public */ onSave(callback: (error: Error) => void): void; } /** Base class for LogScale's webcomponents. * @public */ export declare abstract class WebcomponentBase extends HTMLElement { /** Initializes the webcomponent with options. * * This should be called only once per webcomponent. * You should not need to call this if you are using the `createElement` helper function. * @public */ init(options: Opts): void; /** Set the UI theme to dark or light. * @public */ setTheme(theme: "dark" | "light"): void; } export { }