/* eslint-disable @typescript-eslint/unified-signatures */
import { HttpStep } from '../../HttpStep.js';
export const ReadValueStepKind = 'HttpAction#ReadValue';
/**
 * Reads the value for a given path from the input data. This works with the `ReadDataSourceStep`.
 */
export class ReadValueStep extends HttpStep {
    kind = ReadValueStepKind;
    /**
     * The path to the data.
     * For JSON value use https://jmespath.org/ syntax.
     * For XML use xpath.
     * For any other use a simple path to the data separated by dot (e.g. headers.content-type)
     */
    path;
    constructor(pathOrInit) {
        super();
        if (!pathOrInit) {
            return;
        }
        if (typeof pathOrInit === 'object') {
            const typed = pathOrInit;
            this.new(typed);
        }
        else if (typeof pathOrInit === 'string') {
            this.new({
                kind: ReadValueStepKind,
                path: pathOrInit,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = ReadValueStepKind;
        this.path = init.path;
    }
    checkValidity() {
        const { path } = this;
        return !!path;
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: ReadValueStepKind,
        };
        if (this.path) {
            result.path = this.path;
        }
        return result;
    }
}
//# sourceMappingURL=ReadValueStep.js.map