feat: Update aws and axios packages to use new plugin structure.

This commit is contained in:
Sam Tolmay 2021-11-09 11:14:41 +02:00
parent 2da55b2534
commit f20cfef49d
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
162 changed files with 272 additions and 1058 deletions

992
.pnp.cjs generated

File diff suppressed because it is too large Load Diff

View File

@ -12,5 +12,6 @@
"type": "es6",
"noInterop": true,
"ignoreDynamic": true
}
},
"sourceMaps": true
}

View File

@ -4,6 +4,7 @@
"src/packages/*",
"src/packages/blocks/*",
"src/packages/connections/*",
"src/packages/plugins/**",
"src/packages/servers/*"
],
"npmClient": "yarn",

View File

@ -26,6 +26,7 @@
"packages/*",
"packages/blocks/*",
"packages/connections/*",
"packages/plugins/**",
"packages/servers/*"
],
"scripts": {

View File

@ -26,7 +26,10 @@
"url": "https://github.com/lowdefy/lowdefy.git"
},
"type": "module",
"exports": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./connections/*": "./dist/connections/*"
},
"files": [
"dist/*"
],

View File

@ -14,11 +14,12 @@
limitations under the License.
*/
import schema from './AxiosHttpConnectionSchema.json';
import AxiosHttp from './AxiosHttpRequest/AxiosHttpRequest.js';
export default {
schema,
import: {
schema: 'connections/AxiosHttpConnectionSchema.json',
},
requests: {
AxiosHttp,
},

View File

@ -16,8 +16,7 @@
import { validate } from '@lowdefy/ajv';
import AxiosHttp from './AxiosHttpConnection.js';
const { schema } = AxiosHttp;
import schema from './AxiosHttpConnectionSchema.json';
test('All requests are present', () => {
expect(AxiosHttp.requests.AxiosHttp).toBeDefined();

View File

@ -20,8 +20,6 @@ import https from 'https';
import axios from 'axios';
import { mergeObjects } from '@lowdefy/helpers';
import schema from '../AxiosHttpConnectionSchema.json';
async function axiosHttpRequest({ request, connection }) {
try {
const config = mergeObjects([connection, request]);
@ -46,4 +44,4 @@ async function axiosHttpRequest({ request, connection }) {
}
}
export default { resolver: axiosHttpRequest, schema, checkRead: false, checkWrite: false };
export default axiosHttpRequest;

View File

@ -14,16 +14,17 @@
limitations under the License.
*/
import AxiosHttpRequest from './AxiosHttpRequest.js';
import axiosHttpRequest from './AxiosHttpRequest.js';
import requestIndex from './index.js';
const { resolver } = AxiosHttpRequest;
const { checkRead, checkWrite } = requestIndex.meta;
test('get default method,', async () => {
const request = {
url: 'https://postman-echo.com/get',
};
const connection = {};
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.status).toBe(200);
expect(res.statusText).toBe('OK');
expect(res.method).toBe(undefined);
@ -51,7 +52,7 @@ test('get specify method', async () => {
method: 'get',
};
const connection = {};
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.status).toBe(200);
expect(res.statusText).toBe('OK');
expect(res.method).toBe(undefined);
@ -82,7 +83,7 @@ test('get with params', async () => {
},
};
const connection = {};
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.status).toBe(200);
expect(res.statusText).toBe('OK');
expect(res.method).toBe(undefined);
@ -115,13 +116,13 @@ test('axios error', async () => {
},
};
const connection = {};
await expect(resolver({ request, connection })).rejects.toThrow(
await expect(axiosHttpRequest({ request, connection })).rejects.toThrow(
'Request failed with status code 404; Http response "404: Not Found"; Data: "".'
);
});
test('other error', async () => {
await expect(resolver({ request: { url: true } })).rejects.toThrow(
await expect(axiosHttpRequest({ request: { url: true } })).rejects.toThrow(
'The "url" argument must be of type string. Received type boolean (true)'
);
});
@ -132,7 +133,7 @@ test('https Agent options in request', async () => {
httpsAgentOptions: { keepAlive: true },
};
const connection = {};
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.headers.connection).toEqual('keep-alive');
});
@ -141,7 +142,7 @@ test('https Agent options in connection', async () => {
url: 'https://postman-echo.com/get',
};
const connection = { httpsAgentOptions: { keepAlive: true } };
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.headers.connection).toEqual('keep-alive');
});
@ -151,7 +152,7 @@ test('http Agent options in request', async () => {
httpAgentOptions: { keepAlive: true },
};
const connection = {};
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.headers.connection).toEqual('keep-alive');
});
@ -160,6 +161,14 @@ test('http Agent options in connection', async () => {
url: 'http://postman-echo.com/get',
};
const connection = { httpAgentOptions: { keepAlive: true } };
const res = await resolver({ request, connection });
const res = await axiosHttpRequest({ request, connection });
expect(res.headers.connection).toEqual('keep-alive');
});
test('checkRead should be false', async () => {
expect(checkRead).toBe(false);
});
test('checkWrite should be false', async () => {
expect(checkWrite).toBe(false);
});

View File

@ -0,0 +1,26 @@
/*
Copyright 2020-2021 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export default {
import: {
path: 'connections/AxiosHttp/AxiosHttpRequest/AxiosHttpRequest.js',
schema: 'connections/AxiosHttp/AxiosHttpConnectionSchema.json',
},
meta: {
checkRead: false,
checkWrite: false,
},
};

View File

@ -1,4 +1,4 @@
import AxiosHttp from './AxiosHttp/AxiosHttpConnection.js';
import AxiosHttp from './connections/AxiosHttp/AxiosHttpConnection.js';
export const connections = {
AxiosHttp,

View File

@ -26,7 +26,10 @@
"url": "https://github.com/lowdefy/lowdefy.git"
},
"type": "module",
"exports": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./*": "./dist/*"
},
"files": [
"dist/*"
],

View File

@ -26,7 +26,10 @@
"url": "https://github.com/lowdefy/lowdefy.git"
},
"type": "module",
"exports": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./*": "./dist/*"
},
"files": [
"dist/*"
],

View File

@ -26,7 +26,10 @@
"url": "https://github.com/lowdefy/lowdefy.git"
},
"type": "module",
"exports": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./*": "./dist/*"
},
"files": [
"dist/*"
],

View File

@ -0,0 +1 @@
{"mongoUri":"mongodb://127.0.0.1:56526/"}

View File

@ -26,7 +26,10 @@
"url": "https://github.com/lowdefy/lowdefy.git"
},
"type": "module",
"exports": "./dist/index.js",
"exports": {
".": "./dist/index.js",
"./*": "./dist/*"
},
"files": [
"dist/*"
],

Some files were not shown because too many files have changed in this diff Show More