feat: Restructure plugin files.

This commit is contained in:
Sam Tolmay 2021-11-22 16:10:02 +02:00
parent fef06601ba
commit f651ed7639
No known key found for this signature in database
GPG Key ID: D004126FCD1A6DF0
75 changed files with 289 additions and 461 deletions

18
.pnp.cjs generated
View File

@ -42,10 +42,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"name": "@lowdefy/blocks-antd",
"reference": "workspace:packages/blocks/blocks-antd"
},
{
"name": "@lowdefy/blocks-basic",
"reference": "workspace:packages/blocks/blocks-basic"
},
{
"name": "@lowdefy/blocks-color-selectors",
"reference": "workspace:packages/blocks/blocks-color-selectors"
@ -110,6 +106,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"name": "@lowdefy/operators",
"reference": "workspace:packages/operators"
},
{
"name": "@lowdefy/blocks-basic",
"reference": "workspace:packages/plugins/blocks/blocks-basic"
},
{
"name": "@lowdefy/connection-axios-http",
"reference": "workspace:packages/plugins/connections/connection-axios-http"
@ -159,7 +159,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@lowdefy/block-dev", ["workspace:packages/block-dev"]],
["@lowdefy/block-utils", ["workspace:packages/block-utils"]],
["@lowdefy/blocks-antd", ["workspace:packages/blocks/blocks-antd"]],
["@lowdefy/blocks-basic", ["workspace:packages/blocks/blocks-basic"]],
["@lowdefy/blocks-basic", ["workspace:packages/plugins/blocks/blocks-basic"]],
["@lowdefy/blocks-color-selectors", ["workspace:packages/blocks/blocks-color-selectors"]],
["@lowdefy/blocks-echarts", ["workspace:packages/blocks/blocks-echarts"]],
["@lowdefy/blocks-loaders", ["workspace:packages/blocks/blocks-loaders"]],
@ -5234,10 +5234,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]
]],
["@lowdefy/blocks-basic", [
["workspace:packages/blocks/blocks-basic", {
"packageLocation": "./packages/blocks/blocks-basic/",
["workspace:packages/plugins/blocks/blocks-basic", {
"packageLocation": "./packages/plugins/blocks/blocks-basic/",
"packageDependencies": [
["@lowdefy/blocks-basic", "workspace:packages/blocks/blocks-basic"],
["@lowdefy/blocks-basic", "workspace:packages/plugins/blocks/blocks-basic"],
["@babel/preset-react", "virtual:04055f037dce009b6d437327a3df2c0a05f0436e14e2b705672dd0d1e0a3dfd29d8d62e0db8cb7e152c4b95e36ad3ccd6a68c9e962121dec9e597b25e0481519#npm:7.16.0"],
["@emotion/jest", "virtual:04055f037dce009b6d437327a3df2c0a05f0436e14e2b705672dd0d1e0a3dfd29d8d62e0db8cb7e152c4b95e36ad3ccd6a68c9e962121dec9e597b25e0481519#npm:11.5.0"],
["@lowdefy/block-dev", "workspace:packages/block-dev"],
@ -5735,7 +5735,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@lowdefy/api", "workspace:packages/api"],
["@lowdefy/block-utils", "workspace:packages/block-utils"],
["@lowdefy/blocks-antd", "workspace:packages/blocks/blocks-antd"],
["@lowdefy/blocks-basic", "workspace:packages/blocks/blocks-basic"],
["@lowdefy/blocks-basic", "workspace:packages/plugins/blocks/blocks-basic"],
["@lowdefy/connection-axios-http", "workspace:packages/plugins/connections/connection-axios-http"],
["@lowdefy/engine", "workspace:packages/engine"],
["@lowdefy/helpers", "workspace:packages/helpers"],

View File

@ -21,10 +21,10 @@ import callRequestResolver from './callRequestResolver.js';
import checkConnectionRead from './checkConnectionRead.js';
import checkConnectionWrite from './checkConnectionWrite.js';
import evaluateOperators from './evaluateOperators.js';
import getConnection from './getConnection.js';
import getConnectionConfig from './getConnectionConfig.js';
import getConnectionHandler from './getConnectionHandler.js';
import getRequestConfig from './getRequestConfig.js';
import getRequestHandler from './getRequestHandler.js';
import getRequestResolver from './getRequestResolver.js';
import validateSchemas from './validateSchemas.js';
async function callRequest(context, { pageId, payload, requestId }) {
@ -34,8 +34,9 @@ async function callRequest(context, { pageId, payload, requestId }) {
const connectionConfig = await getConnectionConfig(context, { requestConfig });
authorizeRequest(context, { requestConfig });
const connectionHandler = getConnectionHandler(context, { connectionConfig });
const requestHandler = getRequestHandler(context, { connectionHandler, requestConfig });
const connection = getConnection(context, { connectionConfig });
const requestResolver = getRequestResolver(context, { connection, requestConfig });
const { connectionProperties, requestProperties } = await evaluateOperators(context, {
connectionConfig,
payload: serializer.deserialize(payload),
@ -45,25 +46,25 @@ async function callRequest(context, { pageId, payload, requestId }) {
connectionConfig,
connectionProperties,
requestConfig,
requestHandler,
requestResolver,
});
checkConnectionWrite(context, {
connectionConfig,
connectionProperties,
requestConfig,
requestHandler,
requestResolver,
});
validateSchemas(context, {
connection,
connectionProperties,
requestConfig,
requestResolver,
requestProperties,
});
// validateSchemas(context, {
// connectionHandler,
// connectionProperties,
// requestConfig,
// requestHandler,
// requestProperties,
// });
const response = await callRequestResolver(context, {
connectionProperties,
requestConfig,
requestHandler,
requestResolver,
requestProperties,
});
return {

View File

@ -18,10 +18,10 @@ import { RequestError } from '../../context/errors.js';
async function callRequestResolver(
{ logger },
{ connectionProperties, requestConfig, requestProperties, requestHandler }
{ connectionProperties, requestConfig, requestProperties, requestResolver }
) {
try {
const response = await requestHandler.resolver({
const response = await requestResolver({
request: requestProperties,
connection: connectionProperties,
});

View File

@ -17,9 +17,9 @@ import { ConfigurationError } from '../../context/errors.js';
function checkConnectionRead(
{ logger },
{ connectionConfig, connectionProperties, requestConfig, requestHandler }
{ connectionConfig, connectionProperties, requestConfig, requestResolver }
) {
if (requestHandler.meta.checkRead && connectionProperties.read === false) {
if (requestResolver.meta.checkRead && connectionProperties.read === false) {
const err = new ConfigurationError(
`Connection "${connectionConfig.connectionId}" does not allow reads.`
);

View File

@ -17,9 +17,9 @@ import { ConfigurationError } from '../../context/errors.js';
function checkConnectionWrite(
{ logger },
{ connectionConfig, connectionProperties, requestConfig, requestHandler }
{ connectionConfig, connectionProperties, requestConfig, requestResolver }
) {
if (requestHandler.meta.checkWrite && connectionProperties.write !== true) {
if (requestResolver.meta.checkWrite && connectionProperties.write !== true) {
const err = new ConfigurationError(
`Connection "${connectionConfig.connectionId}" does not allow writes.`
);

View File

@ -15,9 +15,9 @@
*/
import { ConfigurationError } from '../../context/errors.js';
function getConnectionHandler({ connections, logger }, { connectionConfig }) {
const connectionHandler = connections[connectionConfig.type];
if (!connectionHandler) {
function getConnection({ connections, logger }, { connectionConfig }) {
const connection = connections[connectionConfig.type];
if (!connection) {
const err = new ConfigurationError(
`Connection type "${connectionConfig.type}" can not be found.`
);
@ -28,7 +28,7 @@ function getConnectionHandler({ connections, logger }, { connectionConfig }) {
throw err;
}
return connectionHandler;
return connection;
}
export default getConnectionHandler;
export default getConnection;

View File

@ -16,10 +16,10 @@
import { ConfigurationError } from '../../context/errors.js';
function getRequestHandler({ logger }, { connectionHandler, requestConfig }) {
const requestHandler = connectionHandler.requests[requestConfig.type];
function getRequestResolver({ logger }, { connection, requestConfig }) {
const requestResolver = connection.requests[requestConfig.type];
if (!requestHandler) {
if (!requestResolver) {
const err = new ConfigurationError(`Request type "${requestConfig.type}" can not be found.`);
logger.debug(
{ params: { id: requestConfig.requestId, type: requestConfig.type }, err },
@ -28,7 +28,7 @@ function getRequestHandler({ logger }, { connectionHandler, requestConfig }) {
throw err;
}
return requestHandler;
return requestResolver;
}
export default getRequestHandler;
export default getRequestResolver;

View File

@ -20,11 +20,11 @@ import { ConfigurationError } from '../../context/errors.js';
function validateSchemas(
{ logger },
{ connectionHandler, connectionProperties, requestConfig, requestHandler, requestProperties }
{ connection, connectionProperties, requestConfig, requestResolver, requestProperties }
) {
try {
validate({ schema: connectionHandler.schema, data: connectionProperties });
validate({ schema: requestHandler.schema, data: requestProperties });
validate({ schema: connection.schema, data: connectionProperties });
validate({ schema: requestResolver.schema, data: requestProperties });
} catch (error) {
const err = new ConfigurationError(error.message);
logger.debug(

View File

@ -1,26 +0,0 @@
/*
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: {
block: 'blocks/Box/Box.js',
styles: [],
},
meta: {
category: 'container',
loading: false,
},
};

View File

@ -1,27 +0,0 @@
/*
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: {
block: 'blocks/List/List.js',
styles: [],
},
meta: {
category: 'list',
valueType: 'array',
loading: false,
},
};

View File

@ -1,26 +0,0 @@
/*
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: {
block: 'block/Span/Span.js',
styles: [],
},
meta: {
category: 'container',
loading: false,
},
};

View File

@ -1,38 +0,0 @@
/*
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.
*/
import Anchor from './blocks/Anchor/index.js';
import Box from './blocks/Box/index.js';
import DangerousHtml from './blocks/DangerousHtml/index.js';
import Html from './blocks/Html/index.js';
import Img from './blocks/Img/index.js';
import List from './blocks/List/index.js';
import Span from './blocks/Span/index.js';
export default {
blocks: {
Anchor,
Box,
DangerousHtml,
Html,
Img,
List,
Span,
},
import: {
styles: [],
},
};

View File

@ -27,8 +27,7 @@
},
"type": "module",
"exports": {
".": "./dist/index.js",
"./blocks/*": "./dist/blocks/*"
"./blocks.js": "./dist/blocks.js"
},
"files": [
"dist/*"
@ -37,7 +36,7 @@
"build": "yarn swc",
"clean": "rm -rf dist",
"prepare": "yarn build",
"swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start --copy-files",
"swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
"test:watch": "jest --coverage --watch",
"test": "jest --coverage"
},

View File

@ -14,18 +14,10 @@
limitations under the License.
*/
export default {
import: {
block: 'blocks/Anchor/Anchor.js',
styles: [],
},
meta: {
category: 'display',
loading: {
type: 'SkeletonParagraph',
properties: {
lines: 1,
},
},
},
};
export { default as Anchor } from './blocks/Anchor/Anchor.js';
export { default as Box } from './blocks/Box/Box.js';
export { default as DangerousHtml } from './blocks/DangerousHtml/DangerousHtml.js';
export { default as Html } from './blocks/Html/Html.js';
export { default as Img } from './blocks/Img/Img.js';
export { default as List } from './blocks/List/List.js';
export { default as Span } from './blocks/Span/Span.js';

View File

@ -81,5 +81,15 @@ const AnchorBlock = ({
};
AnchorBlock.defaultProps = blockDefaultProps;
AnchorBlock.meta = {
category: 'display',
loading: {
type: 'SkeletonParagraph',
properties: {
lines: 1,
},
},
};
AnchorBlock.styles = [];
export default AnchorBlock;

View File

@ -32,5 +32,10 @@ const Box = ({ blockId, content, events, methods, properties }) => (
);
Box.defaultProps = blockDefaultProps;
Box.meta = {
category: 'container',
loading: false,
};
Box.styles = [];
export default Box;

View File

@ -61,5 +61,10 @@ class DangerousHtml extends React.Component {
}
DangerousHtml.defaultProps = blockDefaultProps;
DangerousHtml.meta = {
category: 'display',
loading: false,
};
DangerousHtml.styles = [];
export default DangerousHtml;

View File

@ -28,5 +28,10 @@ const HtmlBlock = ({ blockId, properties, methods }) => (
);
HtmlBlock.defaultProps = blockDefaultProps;
HtmlBlock.meta = {
category: 'display',
loading: false,
};
HtmlBlock.styles = [];
export default HtmlBlock;

View File

@ -20,5 +20,10 @@ import { blockDefaultProps } from '@lowdefy/block-utils';
const IconBlock = ({ components: { Icon }, ...props }) => <Icon {...props} />;
IconBlock.defaultProps = blockDefaultProps;
IconBlock.meta = {
category: 'display',
loading: false,
};
IconBlock.styles = [];
export default IconBlock;

View File

@ -34,5 +34,10 @@ const ImgBlock = ({ blockId, events, properties, methods }) => {
};
ImgBlock.defaultProps = blockDefaultProps;
ImgBlock.meta = {
category: 'display',
loading: false,
};
ImgBlock.styles = [];
export default ImgBlock;

View File

@ -52,5 +52,11 @@ const List = ({ blockId, events, list, methods, properties }) => {
};
List.defaultProps = blockDefaultProps;
List.meta = {
category: 'list',
valueType: 'array',
loading: false,
};
List.styles = [];
export default List;

View File

@ -32,5 +32,10 @@ const Span = ({ blockId, content, events, methods, properties }) => (
);
Span.defaultProps = blockDefaultProps;
Span.meta = {
category: 'container',
loading: false,
};
Span.styles = [];
export default Span;

View File

@ -14,13 +14,4 @@
limitations under the License.
*/
export default {
import: {
block: 'blocks/Img/Img.js',
styles: [],
},
meta: {
category: 'display',
loading: false,
},
};
export default [];

View File

@ -27,8 +27,7 @@
},
"type": "module",
"exports": {
".": "./dist/index.js",
"./connections/*": "./dist/connections/*"
"./connections.js": "./dist/connections.js"
},
"files": [
"dist/*"

View File

@ -14,13 +14,4 @@
limitations under the License.
*/
export default {
import: {
block: 'blocks/Icon/Icon.js',
styles: [],
},
meta: {
category: 'display',
loading: false,
},
};
export { default as AxiosHttp } from './connections/AxiosHttp/AxiosHttp.js';

View File

@ -14,13 +14,12 @@
limitations under the License.
*/
import AxiosHttp from './AxiosHttp/AxiosHttp.js';
import schema from './schema.js';
export default {
import: {
block: 'blocks/Html/Html.js',
styles: [],
},
meta: {
category: 'display',
loading: false,
schema,
requests: {
AxiosHttp,
},
};

View File

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

View File

@ -20,7 +20,9 @@ import https from 'https';
import axios from 'axios';
import { mergeObjects } from '@lowdefy/helpers';
async function axiosHttpRequest({ request, connection }) {
import schema from '../schema.js';
async function AxiosHttp({ request, connection }) {
try {
const config = mergeObjects([connection, request]);
if (config.httpAgentOptions) {
@ -44,4 +46,10 @@ async function axiosHttpRequest({ request, connection }) {
}
}
export default axiosHttpRequest;
AxiosHttp.schema = schema;
AxiosHttp.meta = {
checkRead: false,
checkWrite: false,
};
export default AxiosHttp;

View File

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

View File

@ -1,27 +0,0 @@
/*
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.
*/
import AxiosHttp from './AxiosHttpRequest/index.js';
export default {
import: {
path: 'connections/AxiosHttp/AxiosHttpConnection.js',
schema: 'connections/AxiosHttp/AxiosHttpConnectionSchema.json',
},
requests: {
AxiosHttp,
},
};

View File

@ -1,122 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Lowdefy Connection Schema - AxiosHttp",
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "The server URL that will be used for the request.",
"errorMessage": {
"type": "AxiosHttp property \"url\" should be a string."
}
},
"method": {
"type": "string",
"enum": ["get", "delete", "head", "options", "post", "put", "patch"],
"description": "The request method to be used when making the request",
"errorMessage": {
"type": "AxiosHttp property \"method\" should be a string.",
"enum": "AxiosHttp property \"method\" is not a valid value."
}
},
"baseURL": {
"type": "string",
"description": "baseURL will be prepended to url unless url is absolute. It can be convenient to set baseURL for an axios connection so that requests can use relative urls.",
"errorMessage": {
"type": "AxiosHttp property \"baseURL\" should be a string."
}
},
"headers": {
"type": "object",
"description": "An object with custom headers to be sent with the request. The object keys should be header names, and the values should be the string header values.",
"errorMessage": {
"type": "AxiosHttp property \"headers\" should be an object."
}
},
"params": {
"type": "object",
"description": "An object with URL parameters to be sent with the request.",
"errorMessage": {
"type": "AxiosHttp property \"params\" should be an object."
}
},
"data": {
"type": ["string", "object"],
"description": "The data to be sent as the request body. Only applicable for request methods 'put', 'post', and 'patch'. Can be an object or a string in the format 'Country=USA&City=New York'.",
"errorMessage": {
"type": "AxiosHttp property \"data\" should be an object or string."
}
},
"timeout": {
"type": "number",
"description": "The number of milliseconds before the request times out. If the request takes longer than timeout, the request will be aborted. Set to 0 for no timeout.",
"default": 0,
"errorMessage": {
"type": "AxiosHttp property \"timeout\" should be a number."
}
},
"auth": {
"type": "object",
"description": "Indicates that HTTP Basic authorization should be used, and supplies credentials. This will set an Authorization header, overwriting any existing Authorization custom headers you have set using headers. Only HTTP Basic auth is configurable through this parameter, for Bearer tokens and such, use Authorization custom headers instead.",
"properties": {
"username": {
"type": "string",
"description": "HTTP Basic authorization username.",
"errorMessage": {
"type": "AxiosHttp property \"auth.username\" should be a string."
}
},
"password": {
"type": "string",
"description": "HTTP Basic authorization password.",
"errorMessage": {
"type": "AxiosHttp property \"auth.password\" should be a string."
}
}
},
"errorMessage": {
"type": "AxiosHttp property \"auth\" should be an object."
}
},
"responseType": {
"type": "string",
"enum": ["json", "document", "text"],
"description": "The type of data that the server should respond with.",
"default": "json",
"errorMessage": {
"type": "AxiosHttp property \"responseType\" should be a string.",
"enum": "AxiosHttp property \"responseType\" is not a valid value."
}
},
"responseEncoding": {
"type": "string",
"description": "Indicates encoding to use for decoding responses.",
"default": "utf8",
"errorMessage": {
"type": "AxiosHttp property \"responseEncoding\" should be a string."
}
},
"maxContentLength": {
"type": "number",
"description": "Defines the max size of the http response content allowed in bytes.",
"errorMessage": {
"type": "AxiosHttp property \"maxContentLength\" should be a number."
}
},
"maxRedirects": {
"type": "number",
"description": "Defines the maximum number of redirects to follow. If set to 0, no redirects will be followed.",
"default": 5,
"errorMessage": {
"type": "AxiosHttp property \"maxRedirects\" should be a number."
}
},
"proxy": {
"type": "object",
"description": "Defines the hostname and port of the proxy server.",
"errorMessage": {
"type": "AxiosHttp property \"proxy\" should be an object."
}
}
}
}

View File

@ -1,28 +0,0 @@
/*
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.
*/
import AxiosHttpRequest from './AxiosHttpRequest.js';
export default {
import: {
schema: 'connections/AxiosHttp/AxiosHttpConnection.json',
},
resolver: AxiosHttpRequest,
meta: {
checkRead: false,
checkWrite: false,
},
};

View File

@ -0,0 +1,144 @@
/*
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 {
$schema: 'http://json-schema.org/draft-07/schema#',
title: 'Lowdefy Connection Schema - AxiosHttp',
type: 'object',
properties: {
url: {
type: 'string',
description: 'The server URL that will be used for the request.',
errorMessage: {
type: 'AxiosHttp property "url" should be a string.',
},
},
method: {
type: 'string',
enum: ['get', 'delete', 'head', 'options', 'post', 'put', 'patch'],
description: 'The request method to be used when making the request',
errorMessage: {
type: 'AxiosHttp property "method" should be a string.',
enum: 'AxiosHttp property "method" is not a valid value.',
},
},
baseURL: {
type: 'string',
description:
'baseURL will be prepended to url unless url is absolute. It can be convenient to set baseURL for an axios connection so that requests can use relative urls.',
errorMessage: {
type: 'AxiosHttp property "baseURL" should be a string.',
},
},
headers: {
type: 'object',
description:
'An object with custom headers to be sent with the request. The object keys should be header names, and the values should be the string header values.',
errorMessage: {
type: 'AxiosHttp property "headers" should be an object.',
},
},
params: {
type: 'object',
description: 'An object with URL parameters to be sent with the request.',
errorMessage: {
type: 'AxiosHttp property "params" should be an object.',
},
},
data: {
type: ['string', 'object'],
description:
"The data to be sent as the request body. Only applicable for request methods 'put', 'post', and 'patch'. Can be an object or a string in the format 'Country=USA&City=New York'.",
errorMessage: {
type: 'AxiosHttp property "data" should be an object or string.',
},
},
timeout: {
type: 'number',
description:
'The number of milliseconds before the request times out. If the request takes longer than timeout, the request will be aborted. Set to 0 for no timeout.',
default: 0,
errorMessage: {
type: 'AxiosHttp property "timeout" should be a number.',
},
},
auth: {
type: 'object',
description:
'Indicates that HTTP Basic authorization should be used, and supplies credentials. This will set an Authorization header, overwriting any existing Authorization custom headers you have set using headers. Only HTTP Basic auth is configurable through this parameter, for Bearer tokens and such, use Authorization custom headers instead.',
properties: {
username: {
type: 'string',
description: 'HTTP Basic authorization username.',
errorMessage: {
type: 'AxiosHttp property "auth.username" should be a string.',
},
},
password: {
type: 'string',
description: 'HTTP Basic authorization password.',
errorMessage: {
type: 'AxiosHttp property "auth.password" should be a string.',
},
},
},
errorMessage: {
type: 'AxiosHttp property "auth" should be an object.',
},
},
responseType: {
type: 'string',
enum: ['json', 'document', 'text'],
description: 'The type of data that the server should respond with.',
default: 'json',
errorMessage: {
type: 'AxiosHttp property "responseType" should be a string.',
enum: 'AxiosHttp property "responseType" is not a valid value.',
},
},
responseEncoding: {
type: 'string',
description: 'Indicates encoding to use for decoding responses.',
default: 'utf8',
errorMessage: {
type: 'AxiosHttp property "responseEncoding" should be a string.',
},
},
maxContentLength: {
type: 'number',
description: 'Defines the max size of the http response content allowed in bytes.',
errorMessage: {
type: 'AxiosHttp property "maxContentLength" should be a number.',
},
},
maxRedirects: {
type: 'number',
description:
'Defines the maximum number of redirects to follow. If set to 0, no redirects will be followed.',
default: 5,
errorMessage: {
type: 'AxiosHttp property "maxRedirects" should be a number.',
},
},
proxy: {
type: 'object',
description: 'Defines the hostname and port of the proxy server.',
errorMessage: {
type: 'AxiosHttp property "proxy" should be an object.',
},
},
},
};

View File

@ -1,7 +0,0 @@
import AxiosHttp from './connections/AxiosHttp/AxiosHttpConnection.js';
export const connections = {
AxiosHttp,
};
export default { connections };

View File

@ -25,9 +25,8 @@ const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
if (!block.eval) return null; // Renderer updates before eval is executed for the first time on lists. See #520
if (block.eval.visible === false)
return <div id={`vs-${block.blockId}`} style={{ display: 'none' }} />;
const Component = lowdefy._internal.blockComponents[block.type].Component;
const meta = lowdefy._internal.blockComponents[block.type].meta;
switch (meta.category) {
const Component = lowdefy._internal.blockComponents[block.type];
switch (Component.meta.category) {
case 'list':
return (
<List

View File

@ -14,54 +14,14 @@
limitations under the License.
*/
import Anchor from '@lowdefy/blocks-basic/blocks/Anchor/Anchor.js';
import Box from '@lowdefy/blocks-basic/blocks/Box/Box.js';
import Button from '@lowdefy/blocks-antd/blocks/Button/Button.js';
import Html from '@lowdefy/blocks-basic/blocks/Html/Html.js';
/* eslint-disable import/no-duplicates */
const blocks = {
Anchor: {
Component: Anchor,
meta: {
category: 'display',
loading: {
type: 'SkeletonParagraph',
properties: {
lines: 1,
},
},
},
},
Box: {
Component: Box,
meta: {
category: 'container',
loading: false,
},
},
Button: {
Component: Button,
meta: {
category: 'display',
loading: {
type: 'SkeletonButton',
},
},
},
Html: {
Component: Html,
meta: {
category: 'display',
loading: false,
},
},
import { Anchor } from '@lowdefy/blocks-basic/blocks.js';
import { Box } from '@lowdefy/blocks-basic/blocks.js';
import { Html } from '@lowdefy/blocks-basic/blocks.js';
export default {
Anchor,
Box,
Html,
};
// const blocks = {
// Anchor,
// Box,
// Button,
// Html,
// };
export default blocks;

View File

@ -14,7 +14,7 @@
limitations under the License.
*/
import AxiosHttp from '@lowdefy/connection-axios-http/connections/AxiosHttp/AxiosHttpConnection.js';
import { AxiosHttp } from '@lowdefy/connection-axios-http/connections.js';
export default {
AxiosHttp,

View File

@ -3473,9 +3473,9 @@ __metadata:
languageName: unknown
linkType: soft
"@lowdefy/blocks-basic@3.22.0, @lowdefy/blocks-basic@workspace:packages/blocks/blocks-basic":
"@lowdefy/blocks-basic@3.22.0, @lowdefy/blocks-basic@workspace:packages/plugins/blocks/blocks-basic":
version: 0.0.0-use.local
resolution: "@lowdefy/blocks-basic@workspace:packages/blocks/blocks-basic"
resolution: "@lowdefy/blocks-basic@workspace:packages/plugins/blocks/blocks-basic"
dependencies:
"@babel/preset-react": 7.16.0
"@emotion/jest": 11.5.0