/* eslint-disable @typescript-eslint/unified-signatures */
import { HttpStep } from '../../HttpStep.js';
export const SetDataStepKind = 'HttpAction#SetData';
export class SetDataStep extends HttpStep {
    kind = SetDataStepKind;
    /**
     * The value to return to the next step.
     * This is always a string. Use the `dataType` to determine the correct data type.
     */
    value = '';
    /**
     * The data type of the value. This is a value prefixed with
     * `http://www.w3.org/2001/XMLSchema#` or `http://a.ml/vocabularies/shapes#`.
     *
     * Examples:
     *
     * - `http://www.w3.org/2001/XMLSchema#boolean`
     * - `http://www.w3.org/2001/XMLSchema#string`
     * - `http://www.w3.org/2001/XMLSchema#number`
     * - `http://www.w3.org/2001/XMLSchema#integer`
     * - `http://www.w3.org/2001/XMLSchema#long`
     * - `http://a.ml/vocabularies/shapes#number`
     * - `http://a.ml/vocabularies/shapes#integer`
     * - `http://a.ml/vocabularies/shapes#double`
     * - ...
     *
     * @default `http://www.w3.org/2001/XMLSchema#string`
     */
    dataType;
    constructor(valueOrInit, dataType) {
        super();
        if (!valueOrInit) {
            return;
        }
        if (typeof valueOrInit === 'object') {
            const typed = valueOrInit;
            this.new(typed);
        }
        else if (typeof valueOrInit === 'string') {
            this.new({
                kind: SetDataStepKind,
                value: valueOrInit,
                dataType,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = SetDataStepKind;
        this.value = init.value;
        this.dataType = init.dataType;
    }
    checkValidity() {
        const { value } = this;
        return !!value;
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: SetDataStepKind,
            value: this.value,
        };
        if (this.dataType) {
            result.dataType = this.dataType;
        }
        return result;
    }
}
//# sourceMappingURL=SetDataStep.js.map