How to use the @terascope/job-components.schemaShim function in @terascope/job-components

To help you get started, we’ve selected a few @terascope/job-components examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terascope / teraslice / packages / teraslice-op-test-harness / index.js View on Github external
opConfig: newOpConfig = null,
        executionConfig: newExConfig,
        retryData = [],
        clients = null,
        type = 'slicer'
    }) {
        const {
            context,
            logger,
            operationFn: op,
        } = this;

        const exConfig = executionSpec(newExConfig);

        const isProcessor = op.Processor || (op.newProcessor != null);
        const Schema = op.schema ? schemaShim(op).Schema : op.Schema;
        const schema = new Schema(context);

        let opConfig;
        // This is kind of pain to deal with
        // this can only work with exectionConfig
        // with two operations
        if (exConfig.operations.length < 2) {
            opConfig = schema.validate(newOpConfig || exConfig.operations[0]);
            if (isProcessor) {
                exConfig.operations = [{ _op: 'test-reader' }, opConfig];
            } else {
                exConfig.operations = [opConfig, { _op: 'noop' }];
            }
        } else {
            const opPosition = isProcessor ? 1 : 0;
            opConfig = schema.validate(newOpConfig || exConfig.operations[opPosition]);