test-this-package-today
Version:
Event Inc is a fully managed event bus lets you send and receive data across mission-critical cloud apps, databases and warehouses.
233 lines • 11.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const setEvents_1 = require("../logic/sources/setEvents");
const createSource_1 = require("../logic/sources/createSource");
const logic_1 = require("../logic");
const utils_1 = require("@event-inc/utils");
const client_1 = require("../client");
require('dotenv').config();
jest.setTimeout(30000);
describe('Connections APIs Specs', () => {
it('Should create a Stripe source, subscribe to customer.created event, create a mongodb destination', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, createSource_1.createSource)(client, {
type: 'stripe',
group: `my-stripe-source-${(0, utils_1.makeId)(4)}`,
label: `My Stripe Source ${(0, utils_1.makeId)(4)}`,
config: {
STRIPE_SECRET_KEY: process.env.CONNECTIONS_TEST_STRIPE_SECRET_KEY,
},
});
expect(source).toHaveProperty('key');
yield new Promise((resolve) => setTimeout(resolve, 5000));
const subscribe = yield (0, setEvents_1.setEvents)(client, {
type: 'stripe',
key: source.key,
events: ['customer.created'],
});
expect(subscribe).toHaveProperty('success', true);
const destination = yield (0, logic_1.createDestination)(client, {
type: 'mongodb',
group: `my-mongodb-destination-${(0, utils_1.makeId)(4)}`,
label: `My MongoDB Destination ${(0, utils_1.makeId)(4)}`,
config: {
MONGODB_URI: process.env.CONNECTIONS_TEST_MONGODB_URI,
},
});
expect(destination).toHaveProperty('key');
yield new Promise((resolve) => setTimeout(resolve, 5000));
const deleteSourceResult = yield (0, logic_1.deleteSource)(client, {
key: source.key,
});
expect(deleteSourceResult).toHaveProperty('success', true);
const deleteDestinationResult = yield (0, logic_1.deleteDestination)(client, {
key: destination.key,
});
expect(deleteDestinationResult).toHaveProperty('success', true);
}));
it('Should create an FTP source with a custom parser', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, createSource_1.createSource)(client, {
type: 'ftp',
group: `my-ftp-${(0, utils_1.makeId)(4)}`,
label: `FTP Source with a custom parser - ${(0, utils_1.makeId)(4)}`,
config: {
FTP_HOST: process.env.CONNECTIONS_TEST_FTP_HOST,
FTP_USER: process.env.CONNECTIONS_TEST_FTP_USER,
FTP_PASSWORD: process.env.CONNECTIONS_TEST_FTP_PASSWORD,
FTP_PATH: process.env.CONNECTIONS_TEST_FTP_PATH,
FTP_PORT: process.env.CONNECTIONS_TEST_FTP_PORT,
FTP_SCAN_INTERVAL: '*/1 * * * *',
FTP_FILE_ARCHIVING_ENABLED: "Y",
FTP_FILE_EXTRACTION_ENABLED: "Y",
FTP_EXTRACTOR_FILE_TYPE: "csv",
FTP_PARSER: function parseCSV(payload) {
const [headerLine, ...dataLines] = payload.split("\n");
const delimiter = ",";
const headers = headerLine.split(delimiter);
return dataLines.map((line) => {
const cells = line.split(delimiter);
return headers.reduce((obj, header, index) => {
obj[header] = cells[index] + " | custom";
return obj;
}, {});
});
},
FTP_EXTRACTOR_FILE_SIZE_LIMIT: "2mb",
FTP_EXTRACTOR_RECORD_COUNT_LIMIT: "25"
}
});
console.log(source);
expect(source.parser).toBeDefined();
}));
it('Should create an FTP source with a default CSV parser', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, createSource_1.createSource)(client, {
type: 'ftp',
group: `my-ftp-${(0, utils_1.makeId)(4)}`,
label: `FTP Source with a default csv parser - ${(0, utils_1.makeId)(4)}`,
config: {
FTP_HOST: process.env.CONNECTIONS_TEST_FTP_HOST,
FTP_USER: process.env.CONNECTIONS_TEST_FTP_USER,
FTP_PASSWORD: process.env.CONNECTIONS_TEST_FTP_PASSWORD,
FTP_PATH: process.env.CONNECTIONS_TEST_FTP_PATH,
FTP_PORT: process.env.CONNECTIONS_TEST_FTP_PORT,
FTP_SCAN_INTERVAL: '*/1 * * * *',
FTP_FILE_ARCHIVING_ENABLED: "Y",
FTP_FILE_EXTRACTION_ENABLED: "Y",
FTP_EXTRACTOR_FILE_TYPE: "csv",
FTP_PARSER: "csv",
FTP_EXTRACTOR_FILE_SIZE_LIMIT: "2mb",
FTP_EXTRACTOR_RECORD_COUNT_LIMIT: "25"
}
});
console.log(source);
expect(source.parser).toBeDefined();
}));
it('Should create an FTP source with a default JSON parser', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, createSource_1.createSource)(client, {
type: 'ftp',
group: `my-ftp-${(0, utils_1.makeId)(4)}`,
label: `FTP Source with a default JSON parser - ${(0, utils_1.makeId)(4)}`,
config: {
FTP_HOST: process.env.CONNECTIONS_TEST_FTP_HOST,
FTP_USER: process.env.CONNECTIONS_TEST_FTP_USER,
FTP_PASSWORD: process.env.CONNECTIONS_TEST_FTP_PASSWORD,
FTP_PATH: process.env.CONNECTIONS_TEST_FTP_PATH,
FTP_PORT: process.env.CONNECTIONS_TEST_FTP_PORT,
FTP_SCAN_INTERVAL: '*/1 * * * *',
FTP_FILE_ARCHIVING_ENABLED: "Y",
FTP_FILE_EXTRACTION_ENABLED: "Y",
FTP_EXTRACTOR_FILE_TYPE: "json",
FTP_PARSER: "json",
FTP_EXTRACTOR_FILE_SIZE_LIMIT: "2mb",
FTP_EXTRACTOR_RECORD_COUNT_LIMIT: "25"
}
});
console.log(source);
expect(source.parser).toBeDefined();
}));
it('Should get an FTP source parser function', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, createSource_1.createSource)(client, {
type: 'ftp',
group: `my-ftp-${(0, utils_1.makeId)(4)}`,
label: `FTP Source - ${(0, utils_1.makeId)(4)}`,
config: {
FTP_HOST: process.env.CONNECTIONS_TEST_FTP_HOST,
FTP_USER: process.env.CONNECTIONS_TEST_FTP_USER,
FTP_PASSWORD: process.env.CONNECTIONS_TEST_FTP_PASSWORD,
FTP_PATH: process.env.CONNECTIONS_TEST_FTP_PATH,
FTP_PORT: process.env.CONNECTIONS_TEST_FTP_PORT,
FTP_SCAN_INTERVAL: '*/1 * * * *',
FTP_FILE_ARCHIVING_ENABLED: "Y",
FTP_FILE_EXTRACTION_ENABLED: "Y",
FTP_EXTRACTOR_FILE_TYPE: "json",
FTP_PARSER: "json",
FTP_EXTRACTOR_FILE_SIZE_LIMIT: "2mb",
FTP_EXTRACTOR_RECORD_COUNT_LIMIT: "25"
}
});
const parser = yield (0, logic_1.getParser)(client, {
key: source.key
});
console.log(parser);
expect(parser).toBeDefined();
}));
it('Should list all sources', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const sourceList = yield (0, logic_1.listSources)(client);
expect(sourceList).toHaveProperty('rows');
}));
it('Should list all destinations', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const destinationList = yield (0, logic_1.listDestinations)(client);
expect(destinationList).toHaveProperty('rows');
}));
it('Should create a kafka destination', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const destination = yield (0, logic_1.createDestination)(client, {
type: 'kafka',
group: `my-kafka-${(0, utils_1.makeId)(4)}`,
label: `Kafka Destination - ${(0, utils_1.makeId)(4)}`,
config: {
KAFKA_CLIENT_ID: 'my-kafka-client-id',
KAFKA_BROKER_URLS: process.env.KAFKA_BROKER_URLS,
KAFKA_USERNAME: process.env.KAFKA_USERNAME,
KAFKA_PASSWORD: process.env.KAFKA_PASSWORD,
}
});
console.log('destination', destination);
expect(destination).toBeDefined();
}));
it('Should create a Rutter source', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, createSource_1.createSource)(client, {
type: 'rutter',
group: `my-rutter-${(0, utils_1.makeId)(4)}`,
label: `Rutter - ${(0, utils_1.makeId)(4)}`
});
console.log(source);
expect(source.frontend.spec.type).toBe("rutter");
}));
it('Should create an Microsort SQL Server Destination', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const client = (0, client_1.createClient)(process.env.BUILDABLE_SECRET_KEY, {
baseUrl: process.env.EVENT_INC_API_BASE_URL
});
const source = yield (0, logic_1.createDestination)(client, {
type: 'mssql',
group: `my-mssql-${(0, utils_1.makeId)(4)}`,
label: `Microsoft SQL Server - ${(0, utils_1.makeId)(4)}`,
config: {
MSSQL_DATABASE: process.env.MSSQL_DATABASE,
MSSQL_HOST: process.env.MSSQL_HOST,
MSSQL_PASSWORD: process.env.MSSQL_PASSWORD,
MSSQL_PORT: process.env.MSSQL_PORT,
MSSQL_USERNAME: process.env.MSSQL_USERNAME,
}
});
console.log(source);
expect(source.frontend.spec.type).toBe("mssql");
}));
});
//# sourceMappingURL=connections.spec.js.map