@ubio/job-input-bundler

Provides random job input for test job

Usage no npm install needed!

<script type="module">
  import ubioJobInputBundler from 'https://cdn.skypack.dev/@ubio/job-input-bundler';
</script>

README

job-input-bundler

Collects data from different sources in order to run a test job (it doesn't run test job itself)

How this project does its job

  • asks data generation api to generate high-quality data fragments, such as person, account, payment method, address
  • generates some of the data itself (dates within range, numbers, boolean flags)
  • runs data extraction job in automation cloud to gather data from third-parties

Where this project can be used

  • test runner (running csi job)
  • dashboard (interactive docs)
  • backoffice / qa tooling frontend (scenario configuration)

API

Setup

Install

yarn add @ubio/job-input-bundler

Use

const init = require('@ubio/job-input-bundler');
const { getData, getSpecSchema } = await init(fetch, config);

See another usage example here.

Functions

getData

async getData(domain: String, spec: DataCollectionSpec): { [string]: any }

getSpecSchema

Return schema describing DataCollectionSpec for particular automation domain

getSpecSchema(domain: String): JsonSchema

Data Structures

DataCollectionSpec is an object which configures data collection procedures (input for various data generation step)

type DataCollectionSpec = {
   [string]: any
}

Config

{
    // secret key of automation cloud public client which will be used to authorize job creation requests
    automationcloudClientSecretKey: String,

    // url of automation cloud api, e.g. https://api.automationcloud.net
    automationcloudApiUrl: String,

    // url of protocol, e.g. https://protocol.automationcloud.net/schema.json
    automationcloudApiUrl: String,

    // url of automation cloud api, e.g. https://data-genenration.automationcloud.net
    dataGenerationApiUrl: String,

    // url of automation cloud api, e.g. https://vault.automationcloud.net
    automationcloudVaultUrl: String,

    // automation-cloud compliant progress reporter
    progressReporter: Function(
        progressReport: { [string]: any }
    ),

    // google-cloud compliant error reporter
    errorLogger: Function(
        message: String,
        {
            error: { message, stack },
            httpRequest: { method, url, userAgent, referrer, responseStatusCode, remoteIp }
        }
    )
}

Usage example

const init = require('@ubio/job-input-bundler');
const clientSecretKey = 'public client secret key';

async function main() {
    const bundler = await init(fetch, {
        protocolUrl: 'https://protocol.automationcloud.net/',
        automationcloudApiUrl: 'https://api-staging.automationcloud.net',
        automationcloudVaultUrl: 'https://vault-staging.automationcloud.net',
        dataGenerationApiUrl: 'https://data-generation-next-staging.automationcloud.net',
        // old-school auth
        authHeader: 'Basic ' + btoa(clientSecretKey + ':')
        // alternative, jwt auth
        // authHeader: 'Bearer ' + jwt
    });

    const { getData } = bundler;

    console.info(JSON.stringify(await getData('HotelBooking', {
        staticData: {},
        generatorInput: {
            mainGuest: { dateOfBirth: { age: 19 } }
        }
    }), null, '  '));


    console.info(JSON.stringify(await getData('FlightBooking', {
        staticData: { url: 'https://ubioair-staging.automationcloud.net' },
        generatorInput: {
            inboundMonthYear: 10,
            outboundMonthYear: 20,
            passengers: {
                items: [
                    {
                        dateOfBirth: { age: 33 },
                        document: { number: '123' }
                    }
                ]
            },
            extractionServiceId: 'e44a4f1b-aa5c-4b36-8db3-a7c78c404b90' // ubio-air extract on staging
        },
    }), null, '  '));
}

/* peer dependencies for backend

const btoa = str => new Buffer(str.toString(), 'binary').toString('base64');
const fetch = require('node-fetch');

*/