mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
chore/plugins: fixes lint warning and errors (#2502)
This commit is contained in:
parent
966428095b
commit
930b4bf3f1
32 changed files with 363 additions and 255 deletions
|
|
@ -4,36 +4,38 @@ const airtable = require('../lib');
|
|||
const nock = require('nock');
|
||||
|
||||
describe('airtable', () => {
|
||||
const _airtable = new airtable.default()
|
||||
describe('airtable operations', () => {
|
||||
const sourceOptions = { api_key: '123456' };
|
||||
test('#list_records', async () => {
|
||||
nock(`https://api.airtable.com`).get('/v0/1/consumer/').query({ pageSize: '', offset: '' })
|
||||
const _airtable = new airtable.default();
|
||||
describe('airtable operations', () => {
|
||||
const sourceOptions = { api_key: '123456' };
|
||||
test('#list_records', async () => {
|
||||
nock(`https://api.airtable.com`)
|
||||
.get('/v0/1/consumer/')
|
||||
.query({ pageSize: '', offset: '' })
|
||||
.reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'list_records', base_id: 1, table_name: 'consumer' }
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
|
||||
test('#retrieve_record', async () => {
|
||||
nock(`https://api.airtable.com`).get('/v0/1/consumer/1').reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'retrieve_record', base_id: 1, table_name: 'consumer', record_id: 1 }
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
|
||||
test('#update_record', async () => {
|
||||
nock(`https://api.airtable.com`).intercept('/v0/1/consumer', 'patch').reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'update_record', base_id: 1, table_name: 'consumer', record_id: 1, body: "{}" }
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
|
||||
test('#delete_record', async () => {
|
||||
nock(`https://api.airtable.com`).intercept('/v0/1/consumer/1', 'delete').reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'delete_record', base_id: 1, table_name: 'consumer', record_id: 1 }
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
const queryOptions = { operation: 'list_records', base_id: 1, table_name: 'consumer' };
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
|
||||
test('#retrieve_record', async () => {
|
||||
nock(`https://api.airtable.com`).get('/v0/1/consumer/1').reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'retrieve_record', base_id: 1, table_name: 'consumer', record_id: 1 };
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
|
||||
test('#update_record', async () => {
|
||||
nock(`https://api.airtable.com`).intercept('/v0/1/consumer', 'patch').reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'update_record', base_id: 1, table_name: 'consumer', record_id: 1, body: '{}' };
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
|
||||
test('#delete_record', async () => {
|
||||
nock(`https://api.airtable.com`).intercept('/v0/1/consumer/1', 'delete').reply(200, { message: 'ok' });
|
||||
const queryOptions = { operation: 'delete_record', base_id: 1, table_name: 'consumer', record_id: 1 };
|
||||
const response = await _airtable.run(sourceOptions, queryOptions);
|
||||
expect(response.status).toEqual('ok');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const bigquery = require('../lib');
|
||||
// const bigquery = require('../lib');
|
||||
|
||||
describe('bigquery', () => {
|
||||
it.todo('needs tests');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../lib/utils.helper');
|
||||
// const common = require('../lib/utils.helper');
|
||||
|
||||
describe('common', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const couchdb = require('../lib');
|
||||
// const couchdb = require('../lib');
|
||||
|
||||
describe('couchdb', () => {
|
||||
it.todo('needs tests');
|
||||
});
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,75 +1,50 @@
|
|||
import {
|
||||
QueryError,
|
||||
QueryResult,
|
||||
QueryService,
|
||||
ConnectionTestResult,
|
||||
} from "@tooljet-plugins/common";
|
||||
import { SourceOptions, QueryOptions } from "./types";
|
||||
import got from "got";
|
||||
const JSON5 = require("json5");
|
||||
import { QueryError, QueryResult, QueryService, ConnectionTestResult } from '@tooljet-plugins/common';
|
||||
import { SourceOptions, QueryOptions } from './types';
|
||||
import got from 'got';
|
||||
const JSON5 = require('json5');
|
||||
export default class Couchdb implements QueryService {
|
||||
async run(
|
||||
sourceOptions: SourceOptions,
|
||||
queryOptions: QueryOptions
|
||||
): Promise<QueryResult> {
|
||||
async run(sourceOptions: SourceOptions, queryOptions: QueryOptions): Promise<QueryResult> {
|
||||
let result = {};
|
||||
let response = null;
|
||||
const {
|
||||
operation,
|
||||
record_id,
|
||||
limit,
|
||||
view_url,
|
||||
start_key,
|
||||
end_key,
|
||||
skip,
|
||||
descending,
|
||||
include_docs
|
||||
} = queryOptions;
|
||||
const { username, password, port, host, database, protocol } =
|
||||
sourceOptions;
|
||||
const { operation, record_id, limit, view_url, start_key, end_key, skip, descending, include_docs } = queryOptions;
|
||||
const { username, password, port, host, database, protocol } = sourceOptions;
|
||||
const revision_id = queryOptions.rev_id;
|
||||
|
||||
const authHeader = () => {
|
||||
const combined = `${username}:${password}`;
|
||||
const key = Buffer.from(combined).toString("base64");
|
||||
const key = Buffer.from(combined).toString('base64');
|
||||
return { Authorization: `Basic ${key}` };
|
||||
};
|
||||
|
||||
try {
|
||||
switch (operation) {
|
||||
case "list_records": {
|
||||
response = await got(
|
||||
`${protocol}://${host}:${port}/${database}/_all_docs`,
|
||||
{
|
||||
method: "get",
|
||||
headers: authHeader(),
|
||||
searchParams: {
|
||||
...(limit?.length > 0 && { limit }),
|
||||
...(skip?.length > 0 && { skip }),
|
||||
...(descending && { descending }),
|
||||
...(include_docs && { include_docs }),
|
||||
},
|
||||
}
|
||||
);
|
||||
case 'list_records': {
|
||||
response = await got(`${protocol}://${host}:${port}/${database}/_all_docs`, {
|
||||
method: 'get',
|
||||
headers: authHeader(),
|
||||
searchParams: {
|
||||
...(limit?.length > 0 && { limit }),
|
||||
...(skip?.length > 0 && { skip }),
|
||||
...(descending && { descending }),
|
||||
...(include_docs && { include_docs }),
|
||||
},
|
||||
});
|
||||
result = this.parseJSON(response.body);
|
||||
break;
|
||||
}
|
||||
|
||||
case "retrieve_record": {
|
||||
response = await got(
|
||||
`${protocol}://${host}:${port}/${database}/${record_id}`,
|
||||
{
|
||||
headers: authHeader(),
|
||||
method: "get",
|
||||
}
|
||||
);
|
||||
case 'retrieve_record': {
|
||||
response = await got(`${protocol}://${host}:${port}/${database}/${record_id}`, {
|
||||
headers: authHeader(),
|
||||
method: 'get',
|
||||
});
|
||||
result = this.parseJSON(response.body);
|
||||
break;
|
||||
}
|
||||
|
||||
case "create_record": {
|
||||
case 'create_record': {
|
||||
response = await got(`${protocol}://${host}:${port}/${database}`, {
|
||||
method: "post",
|
||||
method: 'post',
|
||||
headers: authHeader(),
|
||||
json: {
|
||||
records: this.parseJSON(queryOptions.body),
|
||||
|
|
@ -79,53 +54,44 @@ export default class Couchdb implements QueryService {
|
|||
break;
|
||||
}
|
||||
|
||||
case "update_record": {
|
||||
response = await got(
|
||||
`${protocol}://${host}:${port}/${database}/${record_id}`,
|
||||
{
|
||||
method: "put",
|
||||
headers: authHeader(),
|
||||
json: {
|
||||
_rev: revision_id,
|
||||
records: this.parseJSON(queryOptions.body),
|
||||
},
|
||||
}
|
||||
);
|
||||
case 'update_record': {
|
||||
response = await got(`${protocol}://${host}:${port}/${database}/${record_id}`, {
|
||||
method: 'put',
|
||||
headers: authHeader(),
|
||||
json: {
|
||||
_rev: revision_id,
|
||||
records: this.parseJSON(queryOptions.body),
|
||||
},
|
||||
});
|
||||
result = this.parseJSON(response.body);
|
||||
break;
|
||||
}
|
||||
|
||||
case "delete_record": {
|
||||
response = await got(
|
||||
`${protocol}://${host}:${port}/${database}/${record_id}`,
|
||||
{
|
||||
method: "delete",
|
||||
headers: authHeader(),
|
||||
searchParams: {
|
||||
rev: revision_id,
|
||||
},
|
||||
}
|
||||
);
|
||||
case 'delete_record': {
|
||||
response = await got(`${protocol}://${host}:${port}/${database}/${record_id}`, {
|
||||
method: 'delete',
|
||||
headers: authHeader(),
|
||||
searchParams: {
|
||||
rev: revision_id,
|
||||
},
|
||||
});
|
||||
result = this.parseJSON(response.body);
|
||||
break;
|
||||
}
|
||||
|
||||
case "find": {
|
||||
response = await got(
|
||||
`${protocol}://${host}:${port}/${database}/_find`,
|
||||
{
|
||||
method: "post",
|
||||
headers: authHeader(),
|
||||
json: this.parseJSON(queryOptions.body),
|
||||
}
|
||||
);
|
||||
case 'find': {
|
||||
response = await got(`${protocol}://${host}:${port}/${database}/_find`, {
|
||||
method: 'post',
|
||||
headers: authHeader(),
|
||||
json: this.parseJSON(queryOptions.body),
|
||||
});
|
||||
result = this.parseJSON(response.body);
|
||||
break;
|
||||
}
|
||||
|
||||
case "get_view": {
|
||||
case 'get_view': {
|
||||
response = await got(`${view_url}`, {
|
||||
method: "get",
|
||||
method: 'get',
|
||||
headers: authHeader(),
|
||||
searchParams: {
|
||||
...(limit?.length > 0 && { limit }),
|
||||
|
|
@ -141,32 +107,30 @@ export default class Couchdb implements QueryService {
|
|||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw new QueryError("Query could not be completed", error.message, {});
|
||||
throw new QueryError('Query could not be completed', error.message, {});
|
||||
}
|
||||
|
||||
return {
|
||||
status: "ok",
|
||||
status: 'ok',
|
||||
data: result,
|
||||
};
|
||||
}
|
||||
|
||||
async testConnection(
|
||||
sourceOptions: SourceOptions
|
||||
): Promise<ConnectionTestResult> {
|
||||
const { username, password, port, host, database, protocol } =
|
||||
sourceOptions;
|
||||
async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { username, password, port, host, database, protocol } = sourceOptions;
|
||||
const combined = `${username}:${password}`;
|
||||
const key = Buffer.from(combined).toString("base64");
|
||||
const key = Buffer.from(combined).toString('base64');
|
||||
const client = await got(`${protocol}://${host}:${port}/_all_dbs`, {
|
||||
method: "get",
|
||||
method: 'get',
|
||||
headers: { Authorization: `Basic ${key}` },
|
||||
});
|
||||
if (!client) {
|
||||
throw new Error("Error");
|
||||
throw new Error('Error');
|
||||
}
|
||||
|
||||
return {
|
||||
status: "ok",
|
||||
status: 'ok',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,21 @@
|
|||
export type SourceOptions = {
|
||||
username: string;
|
||||
password: string;
|
||||
database: string;
|
||||
database: string;
|
||||
port: string;
|
||||
host:string;
|
||||
protocol: string;
|
||||
host: string;
|
||||
protocol: string;
|
||||
};
|
||||
export type QueryOptions = {
|
||||
operation: string;
|
||||
record_id: string;
|
||||
body: string;
|
||||
rev_id:string;
|
||||
view_url:string;
|
||||
start_key?:string;
|
||||
end_key?:string;
|
||||
limit?:string;
|
||||
skip?:string;
|
||||
descending?:boolean;
|
||||
include_docs?:boolean;
|
||||
|
||||
rev_id: string;
|
||||
view_url: string;
|
||||
start_key?: string;
|
||||
end_key?: string;
|
||||
limit?: string;
|
||||
skip?: string;
|
||||
descending?: boolean;
|
||||
include_docs?: boolean;
|
||||
};
|
||||
|
|
|
|||
99
plugins/packages/couchdb/package-lock.json
generated
Normal file
99
plugins/packages/couchdb/package-lock.json
generated
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
{
|
||||
"name": "@tooljet-plugins/couchdb",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@tooljet-plugins/couchdb",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@tooljet-plugins/common": "file:../common",
|
||||
"react": "^17.0.2"
|
||||
}
|
||||
},
|
||||
"../common": {
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"react": "^17.0.2",
|
||||
"rimraf": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tooljet-plugins/common": {
|
||||
"resolved": "../common",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
|
||||
},
|
||||
"node_modules/loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||
"dependencies": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"loose-envify": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "17.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
|
||||
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@tooljet-plugins/common": {
|
||||
"version": "file:../common",
|
||||
"requires": {
|
||||
"react": "^17.0.2",
|
||||
"rimraf": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
|
||||
},
|
||||
"loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||
"requires": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
}
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||
},
|
||||
"react": {
|
||||
"version": "17.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
|
||||
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const dynamodb = require('../lib');
|
||||
// const dynamodb = require('../lib');
|
||||
|
||||
describe('dynamodb', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const elasticsearch = require('../lib');
|
||||
// const elasticsearch = require('../lib');
|
||||
|
||||
describe('elasticsearch', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const firestore = require('../lib');
|
||||
// const firestore = require('../lib');
|
||||
|
||||
describe('firestore', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const gcs = require('../lib');
|
||||
// const gcs = require('../lib');
|
||||
|
||||
describe('gcs', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,30 +1,74 @@
|
|||
'use strict';
|
||||
const { makeRequestBodyToBatchUpdate } =require('../lib/operations');
|
||||
const { makeRequestBodyToBatchUpdate } = require('../lib/operations');
|
||||
|
||||
describe('googlesheets', () => {
|
||||
it('should generate the request body for update operation' ,() => {
|
||||
const requestBody = {
|
||||
caseOne: { Gender: 'Female' },
|
||||
caseTwo: { extra: '0 points' },
|
||||
caseThree: { Gender: 'Female', extra: '0 points' }
|
||||
}
|
||||
const filterCondition = { key: 'Student Name', value: 'Anna' }
|
||||
const filterOperator = '==='
|
||||
const data = [
|
||||
[ 'ID', '1', '2' ],[ 'Student Name', 'John', 'Anna' ],[ 'Major', 'Science', 'English' ],[],[ 'Gender', 'Male', 'Female' ],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[ 'extra', 'extra-update', '0 points' ]
|
||||
]
|
||||
it('should generate the request body for update operation', () => {
|
||||
const requestBody = {
|
||||
caseOne: { Gender: 'Female' },
|
||||
caseTwo: { extra: '0 points' },
|
||||
caseThree: { Gender: 'Female', extra: '0 points' },
|
||||
};
|
||||
const filterCondition = { key: 'Student Name', value: 'Anna' };
|
||||
const filterOperator = '===';
|
||||
const data = [
|
||||
['ID', '1', '2'],
|
||||
['Student Name', 'John', 'Anna'],
|
||||
['Major', 'Science', 'English'],
|
||||
[],
|
||||
['Gender', 'Male', 'Female'],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
['extra', 'extra-update', '0 points'],
|
||||
];
|
||||
|
||||
const queryOptionsOne = { requestBody: requestBody.caseOne, filterCondition, filterOperator, data }
|
||||
const queryOptionsTwo = { requestBody: requestBody.caseTwo, filterCondition, filterOperator, data }
|
||||
const queryOptionsThree = { requestBody: requestBody.caseThree, filterCondition, filterOperator, data }
|
||||
const queryOptionsOne = { requestBody: requestBody.caseOne, filterCondition, filterOperator, data };
|
||||
const queryOptionsTwo = { requestBody: requestBody.caseTwo, filterCondition, filterOperator, data };
|
||||
const queryOptionsThree = { requestBody: requestBody.caseThree, filterCondition, filterOperator, data };
|
||||
|
||||
const expectedBodyForCaseOne = makeRequestBodyToBatchUpdate(queryOptionsOne.requestBody, queryOptionsOne.filterCondition, queryOptionsOne.filterOperator, queryOptionsOne.data)
|
||||
const expectedBodyForCaseTwo = makeRequestBodyToBatchUpdate(queryOptionsTwo.requestBody, queryOptionsOne.filterCondition, queryOptionsOne.filterOperator, queryOptionsOne.data)
|
||||
const expectedBodyForCaseThree = makeRequestBodyToBatchUpdate(queryOptionsThree.requestBody, queryOptionsOne.filterCondition, queryOptionsOne.filterOperator, queryOptionsOne.data)
|
||||
const expectedBodyForCaseOne = makeRequestBodyToBatchUpdate(
|
||||
queryOptionsOne.requestBody,
|
||||
queryOptionsOne.filterCondition,
|
||||
queryOptionsOne.filterOperator,
|
||||
queryOptionsOne.data
|
||||
);
|
||||
const expectedBodyForCaseTwo = makeRequestBodyToBatchUpdate(
|
||||
queryOptionsTwo.requestBody,
|
||||
queryOptionsOne.filterCondition,
|
||||
queryOptionsOne.filterOperator,
|
||||
queryOptionsOne.data
|
||||
);
|
||||
const expectedBodyForCaseThree = makeRequestBodyToBatchUpdate(
|
||||
queryOptionsThree.requestBody,
|
||||
queryOptionsOne.filterCondition,
|
||||
queryOptionsOne.filterOperator,
|
||||
queryOptionsOne.data
|
||||
);
|
||||
|
||||
|
||||
expect(expectedBodyForCaseOne).toEqual([{ cellValue: 'Female', cellIndex: 'E3' }]);
|
||||
expect(expectedBodyForCaseTwo).toEqual([{ cellValue: '0 points', cellIndex: 'AB3' }]);
|
||||
expect(expectedBodyForCaseThree).toEqual([{ cellValue: 'Female', cellIndex: 'E3' }, { cellValue: '0 points', cellIndex: 'AB3' }]);
|
||||
});
|
||||
expect(expectedBodyForCaseOne).toEqual([{ cellValue: 'Female', cellIndex: 'E3' }]);
|
||||
expect(expectedBodyForCaseTwo).toEqual([{ cellValue: '0 points', cellIndex: 'AB3' }]);
|
||||
expect(expectedBodyForCaseThree).toEqual([
|
||||
{ cellValue: 'Female', cellIndex: 'E3' },
|
||||
{ cellValue: '0 points', cellIndex: 'AB3' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@
|
|||
const graphql = require('../lib');
|
||||
|
||||
describe('graphql', () => {
|
||||
it('should query graphql datasources', async () => {
|
||||
const sourceOptions = {
|
||||
url: 'https://api.spacex.land/graphql/',
|
||||
headers: [],
|
||||
url_params: [],
|
||||
};
|
||||
|
||||
const queryOptions = { query: '{ launchesPast(limit: 10) { mission_name } }' };
|
||||
it('should query graphql datasources', async () => {
|
||||
const sourceOptions = {
|
||||
url: 'https://api.spacex.land/graphql/',
|
||||
headers: [],
|
||||
url_params: [],
|
||||
};
|
||||
|
||||
const _graphql = new graphql.default()
|
||||
|
||||
const result = await _graphql.run(sourceOptions, queryOptions, 'no-datasource-id');
|
||||
|
||||
expect(result.data['data']['launchesPast'].length).toBe(10);
|
||||
});
|
||||
const queryOptions = { query: '{ launchesPast(limit: 10) { mission_name } }' };
|
||||
|
||||
const _graphql = new graphql.default();
|
||||
|
||||
const result = await _graphql.run(sourceOptions, queryOptions, 'no-datasource-id');
|
||||
|
||||
expect(result.data['data']['launchesPast'].length).toBe(10);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const mailgun = require('../lib');
|
||||
// const mailgun = require('../lib');
|
||||
|
||||
describe('mailgun', () => {
|
||||
it.todo('needs tests');
|
||||
});
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { QueryError, QueryResult, QueryService, ConnectionTestResult } from '@tooljet-plugins/common';
|
||||
import {SourceOptions, QueryOptions, EmailOptions} from "./types";
|
||||
import { QueryError, QueryResult, QueryService } from '@tooljet-plugins/common';
|
||||
import { SourceOptions, QueryOptions, EmailOptions } from './types';
|
||||
import MailgunSdk from 'mailgun.js';
|
||||
import FormData from 'form-data';
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ export default class Mailgun implements QueryService {
|
|||
}
|
||||
|
||||
const sdk = new MailgunSdk(FormData);
|
||||
const mailgunOptions = {username: 'api', key: sourceOptions.api_key, url: null}
|
||||
const mailgunOptions = { username: 'api', key: sourceOptions.api_key, url: null };
|
||||
if (sourceOptions.eu_hosted) {
|
||||
mailgunOptions.url = 'https://api.eu.mailgun.net';
|
||||
}
|
||||
|
|
@ -21,8 +21,8 @@ export default class Mailgun implements QueryService {
|
|||
to: queryOptions.send_mail_to,
|
||||
from: queryOptions.send_mail_from,
|
||||
subject: queryOptions.subject,
|
||||
text: queryOptions.text
|
||||
}
|
||||
text: queryOptions.text,
|
||||
};
|
||||
|
||||
if (queryOptions.html && queryOptions.html.length > 0) {
|
||||
emailOptions.html = queryOptions.html;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const minioapi = require('../lib');
|
||||
// const minioapi = require('../lib');
|
||||
|
||||
describe('minioapi', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
'use strict';
|
||||
|
||||
const mongodb = require("../lib");
|
||||
// const mongodb = require('../lib');
|
||||
|
||||
describe("mongodb", () => {
|
||||
it.todo("needs tests");
|
||||
describe('mongodb', () => {
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const mssql = require('../lib');
|
||||
// const mssql = require('../lib');
|
||||
|
||||
describe('mssql', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ export default class MssqlQueryService implements QueryService {
|
|||
database: sourceOptions.database,
|
||||
port: +sourceOptions.port,
|
||||
options: {
|
||||
encrypt: sourceOptions.azure ?? false
|
||||
}
|
||||
}
|
||||
encrypt: sourceOptions.azure ?? false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return knex(config);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ describe('mysql', () => {
|
|||
],
|
||||
};
|
||||
|
||||
const _mysql = new mysql.default()
|
||||
|
||||
const _mysql = new mysql.default();
|
||||
|
||||
const builtQuery = await _mysql.buildBulkUpdateQuery(queryOptions);
|
||||
const expectedQuery =
|
||||
"UPDATE customers SET name = 'sam', email = 'sam@example.com' WHERE id = 1; UPDATE customers SET name = 'jon', email = 'jon@example.com' WHERE id = 2;";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const n8n = require('../lib');
|
||||
// const n8n = require('../lib');
|
||||
|
||||
describe('n8n', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,30 +3,30 @@
|
|||
const postgresql = require('../lib');
|
||||
|
||||
describe('postgresql', () => {
|
||||
it('should generate the query for bulk update operation', async () => {
|
||||
const queryOptions = {
|
||||
table: 'customers',
|
||||
primary_key_column: 'id',
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'sam',
|
||||
email: 'sam@example.com',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'jon',
|
||||
email: 'jon@example.com',
|
||||
},
|
||||
],
|
||||
};
|
||||
it('should generate the query for bulk update operation', async () => {
|
||||
const queryOptions = {
|
||||
table: 'customers',
|
||||
primary_key_column: 'id',
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'sam',
|
||||
email: 'sam@example.com',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'jon',
|
||||
email: 'jon@example.com',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const _postgresql = new postgresql.default()
|
||||
|
||||
const builtQuery = await _postgresql.buildBulkUpdateQuery(queryOptions);
|
||||
const expectedQuery =
|
||||
"UPDATE customers SET name = 'sam', email = 'sam@example.com' WHERE id = 1; UPDATE customers SET name = 'jon', email = 'jon@example.com' WHERE id = 2;";
|
||||
|
||||
expect(builtQuery).toBe(expectedQuery);
|
||||
});
|
||||
const _postgresql = new postgresql.default();
|
||||
|
||||
const builtQuery = await _postgresql.buildBulkUpdateQuery(queryOptions);
|
||||
const expectedQuery =
|
||||
"UPDATE customers SET name = 'sam', email = 'sam@example.com' WHERE id = 1; UPDATE customers SET name = 'jon', email = 'jon@example.com' WHERE id = 2;";
|
||||
|
||||
expect(builtQuery).toBe(expectedQuery);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const redis = require('../lib');
|
||||
// const redis = require('../lib');
|
||||
|
||||
describe('redis', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const restapi = require('../lib');
|
||||
// const restapi = require('../lib');
|
||||
|
||||
describe('restapi', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const s3 = require('../lib');
|
||||
// const s3 = require('../lib');
|
||||
|
||||
describe('s3', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const sendgrid = require('../lib');
|
||||
// const sendgrid = require('../lib');
|
||||
|
||||
describe('sendgrid', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const slack = require('../lib');
|
||||
// const slack = require('../lib');
|
||||
|
||||
describe('slack', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const smtp = require('../lib');
|
||||
// const smtp = require('../lib');
|
||||
|
||||
describe('smtp', () => {
|
||||
it.todo('needs tests');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const snowflake = require('../lib');
|
||||
// const snowflake = require('../lib');
|
||||
|
||||
describe('snowflake', () => {
|
||||
it.todo('needs tests');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const stripe = require('../lib');
|
||||
// const stripe = require('../lib');
|
||||
|
||||
describe('stripe', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const twilioapi = require('../lib');
|
||||
// const twilioapi = require('../lib');
|
||||
|
||||
describe('twilioapi', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const typesenseapi = require('../lib');
|
||||
// const typesenseapi = require('../lib');
|
||||
|
||||
describe('typesenseapi', () => {
|
||||
it.todo('needs tests');
|
||||
it.todo('needs tests');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue