UNPKG

@event-inc/pipelines

Version:

Event Inc is a fully managed event bus lets you send and receive data across mission-critical cloud apps, databases and warehouses.

141 lines (118 loc) 3.3 kB
import { ValidAccessKey } from '@event-inc/types'; import { createDestination, createSource, deleteDestination, deleteSource, createClient, setEvents, } from '@event-inc/connections'; import { createPipeline } from '../logic/createPipeline'; import { deletePipeline, listPipelines, updatePipeline } from '../logic'; import { makeId } from '@event-inc/utils'; import transformer from './transform'; require('dotenv').config(); jest.setTimeout(60000); describe('Connections APIs Specs', () => { it('Should create a Stripe to MongoDB pipeline', async () => { const client = createClient(process.env.BUILDABLE_SECRET_KEY, { baseUrl: process.env.EVENT_INC_API_BASE_URL }); const source = await createSource(client, { type: 'stripe', group: `my-stripe-source-${makeId(4)}`, label: `My Stripe Source ${makeId(4)}`, config: { STRIPE_SECRET_KEY: process.env.CONNECTIONS_TEST_STRIPE_SECRET_KEY, }, }); expect(source).toHaveProperty('key'); const destination = await createDestination(client, { type: 'mongodb', group: `my-mongodb-destination-${makeId(4)}`, label: `My MongoDB Destination ${makeId(4)}`, config: { MONGODB_URI: process.env.CONNECTIONS_TEST_MONGODB_URI, }, }); expect(destination).toHaveProperty('key'); const subscribe = await setEvents(client, { type: 'stripe', key: source.key, events: ['customer.created', 'customer.deleted'], }); expect(subscribe).toHaveProperty('success', true); const pipeline = await createPipeline<'stripe', 'mongodb'>(client, { label: `my-pipeline-${makeId(4)}`, source: { key: source.key, events: ['customer.created'], }, destination: { key: destination.key, action: 'insertOne', }, settings: { startToCloseTimeout: '30 minutes', retry: { maximumAttempts: 100, }, }, transformation: { type: 'javascript', func: transformer, }, extractors: [ { settings: { startToCloseTimeout: '30 minutes', retry: { maximumAttempts: 100, }, }, type: 'http', label: 'some_http_extractor', config: { url: 'abc.com', method: 'POST', headers: { 'Content-Type': 'application/json', }, data: { name: 'someName', age: 25, }, }, }, ], }); expect(pipeline).toHaveProperty('key'); const updatedPipeline = await updatePipeline(client, { key: pipeline.key, active: false, }); expect(updatedPipeline).toHaveProperty('key'); const deletePipelineResult = await deletePipeline(client, { key: pipeline.key, }); expect(deletePipelineResult).toHaveProperty('success', true); const deleteSourceResult = await deleteSource(client, { key: source.key, }); expect(deleteSourceResult).toHaveProperty('success', true); const deleteDestinationResult = await deleteDestination(client, { key: destination.key, }); expect(deleteDestinationResult).toHaveProperty('success', true); }); it('Should list all pipelines', async () => { const client = createClient( process.env.BUILDABLE_SECRET_KEY, { baseUrl: process.env.EVENT_INC_API_BASE_URL } ); const pipelineList = await listPipelines(client); expect(pipelineList).toHaveProperty('rows'); }); });