Compare commits
1 Commits
v0.13.1
...
test-async
Author | SHA1 | Date | |
---|---|---|---|
![]() |
424c251dde |
@@ -89,6 +89,8 @@ export default defineAction({
|
|||||||
|
|
||||||
const response = await $.http.post('/', payload);
|
const response = await $.http.post('/', payload);
|
||||||
|
|
||||||
|
console.log(response.config.additionalProperties.extraData);
|
||||||
|
|
||||||
$.setActionItem({
|
$.setActionItem({
|
||||||
raw: response.data,
|
raw: response.data,
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
const addAuthHeader = ($, requestConfig) => {
|
const addAuthHeader = ($, requestConfig) => {
|
||||||
|
console.log('requestConfig', requestConfig)
|
||||||
|
if (requestConfig.additionalProperties?.skip) return requestConfig;
|
||||||
|
|
||||||
if ($.auth.data.serverUrl) {
|
if ($.auth.data.serverUrl) {
|
||||||
requestConfig.baseURL = $.auth.data.serverUrl;
|
requestConfig.baseURL = $.auth.data.serverUrl;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
const asyncBeforeRequest = async ($, requestConfig) => {
|
||||||
|
if (requestConfig.additionalProperties?.skip)
|
||||||
|
return requestConfig;
|
||||||
|
|
||||||
|
const response = await $.http.post(
|
||||||
|
'http://localhost:3000/webhooks/flows/8a040f4e-817f-4076-80ba-3c1c0af7e65e/sync',
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
additionalProperties: {
|
||||||
|
skip: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
requestConfig.additionalProperties = {
|
||||||
|
extraData: response.data
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default asyncBeforeRequest;
|
@@ -1,5 +1,6 @@
|
|||||||
import defineApp from '../../helpers/define-app.js';
|
import defineApp from '../../helpers/define-app.js';
|
||||||
import addAuthHeader from './common/add-auth-header.js';
|
import addAuthHeader from './common/add-auth-header.js';
|
||||||
|
import asyncBeforeRequest from './common/async-before-request.js';
|
||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
import actions from './actions/index.js';
|
import actions from './actions/index.js';
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ export default defineApp({
|
|||||||
baseUrl: 'https://ntfy.sh',
|
baseUrl: 'https://ntfy.sh',
|
||||||
apiBaseUrl: 'https://ntfy.sh',
|
apiBaseUrl: 'https://ntfy.sh',
|
||||||
primaryColor: '56bda8',
|
primaryColor: '56bda8',
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [asyncBeforeRequest, addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
actions,
|
actions,
|
||||||
});
|
});
|
||||||
|
@@ -52,7 +52,7 @@ const appConfig = {
|
|||||||
isDev: appEnv === 'development',
|
isDev: appEnv === 'development',
|
||||||
isTest: appEnv === 'test',
|
isTest: appEnv === 'test',
|
||||||
isProd: appEnv === 'production',
|
isProd: appEnv === 'production',
|
||||||
version: '0.13.1',
|
version: '0.12.0',
|
||||||
postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development',
|
postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development',
|
||||||
postgresSchema: process.env.POSTGRES_SCHEMA || 'public',
|
postgresSchema: process.env.POSTGRES_SCHEMA || 'public',
|
||||||
postgresPort: parseInt(process.env.POSTGRES_PORT || '5432'),
|
postgresPort: parseInt(process.env.POSTGRES_PORT || '5432'),
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import appConfig from '../../../../config/app.js';
|
import appConfig from '../../../../config/app.js';
|
||||||
import { hasValidLicense } from '../../../../helpers/license.ee.js';
|
import { hasValidLicense } from '../../../../helpers/license.ee.js';
|
||||||
import { renderObject } from '../../../../helpers/renderer.js';
|
import { renderObject } from '../../../../helpers/renderer.js';
|
||||||
import Config from '../../../../models/config.js';
|
|
||||||
|
|
||||||
export default async (request, response) => {
|
export default async (request, response) => {
|
||||||
const installationCompleted = await Config.isInstallationCompleted();
|
|
||||||
|
|
||||||
const info = {
|
const info = {
|
||||||
docsUrl: appConfig.docsUrl,
|
|
||||||
installationCompleted,
|
|
||||||
isCloud: appConfig.isCloud,
|
isCloud: appConfig.isCloud,
|
||||||
isEnterprise: await hasValidLicense(),
|
|
||||||
isMation: appConfig.isMation,
|
isMation: appConfig.isMation,
|
||||||
|
isEnterprise: await hasValidLicense(),
|
||||||
|
docsUrl: appConfig.docsUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
renderObject(response, info);
|
renderObject(response, info);
|
||||||
|
@@ -1,14 +1,12 @@
|
|||||||
import { vi, expect, describe, it } from 'vitest';
|
import { vi, expect, describe, it } from 'vitest';
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
import appConfig from '../../../../config/app.js';
|
import appConfig from '../../../../config/app.js';
|
||||||
import Config from '../../../../models/config.js';
|
|
||||||
import app from '../../../../app.js';
|
import app from '../../../../app.js';
|
||||||
import infoMock from '../../../../../test/mocks/rest/api/v1/automatisch/info.js';
|
import infoMock from '../../../../../test/mocks/rest/api/v1/automatisch/info.js';
|
||||||
import * as license from '../../../../helpers/license.ee.js';
|
import * as license from '../../../../helpers/license.ee.js';
|
||||||
|
|
||||||
describe('GET /api/v1/automatisch/info', () => {
|
describe('GET /api/v1/automatisch/info', () => {
|
||||||
it('should return Automatisch info', async () => {
|
it('should return Automatisch info', async () => {
|
||||||
vi.spyOn(Config, 'isInstallationCompleted').mockResolvedValue(true);
|
|
||||||
vi.spyOn(appConfig, 'isCloud', 'get').mockReturnValue(false);
|
vi.spyOn(appConfig, 'isCloud', 'get').mockReturnValue(false);
|
||||||
vi.spyOn(appConfig, 'isMation', 'get').mockReturnValue(false);
|
vi.spyOn(appConfig, 'isMation', 'get').mockReturnValue(false);
|
||||||
vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true);
|
vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true);
|
||||||
|
@@ -10,7 +10,7 @@ describe('GET /api/v1/automatisch/version', () => {
|
|||||||
|
|
||||||
const expectedPayload = {
|
const expectedPayload = {
|
||||||
data: {
|
data: {
|
||||||
version: '0.13.1',
|
version: '0.12.0',
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
count: 1,
|
count: 1,
|
||||||
|
@@ -11,7 +11,6 @@ export default function computeParameters(parameters, executionSteps) {
|
|||||||
const computedValue = parts
|
const computedValue = parts
|
||||||
.map((part) => {
|
.map((part) => {
|
||||||
const isVariable = part.match(variableRegExp);
|
const isVariable = part.match(variableRegExp);
|
||||||
|
|
||||||
if (isVariable) {
|
if (isVariable) {
|
||||||
const stepIdAndKeyPath = part.replace(/{{step.|}}/g, '');
|
const stepIdAndKeyPath = part.replace(/{{step.|}}/g, '');
|
||||||
const [stepId, ...keyPaths] = stepIdAndKeyPath.split('.');
|
const [stepId, ...keyPaths] = stepIdAndKeyPath.split('.');
|
||||||
@@ -21,36 +20,17 @@ export default function computeParameters(parameters, executionSteps) {
|
|||||||
});
|
});
|
||||||
const data = executionStep?.dataOut;
|
const data = executionStep?.dataOut;
|
||||||
const dataValue = get(data, keyPath);
|
const dataValue = get(data, keyPath);
|
||||||
|
|
||||||
// Covers both arrays and objects
|
|
||||||
if (typeof dataValue === 'object') {
|
|
||||||
return JSON.stringify(dataValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataValue;
|
return dataValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
}).join('');
|
})
|
||||||
|
.join('');
|
||||||
|
|
||||||
// challenge the input to see if it is stringifies object or array
|
return {
|
||||||
try {
|
...result,
|
||||||
const parsedValue = JSON.parse(computedValue);
|
[key]: computedValue,
|
||||||
|
};
|
||||||
if (typeof parsedValue === 'number') {
|
|
||||||
throw new Error('Use original unparsed value.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...result,
|
|
||||||
[key]: parsedValue,
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
return {
|
|
||||||
...result,
|
|
||||||
[key]: computedValue,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
const infoMock = () => {
|
const infoMock = () => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
docsUrl: 'https://automatisch.io/docs',
|
|
||||||
installationCompleted: true,
|
|
||||||
isCloud: false,
|
isCloud: false,
|
||||||
isEnterprise: true,
|
|
||||||
isMation: false,
|
isMation: false,
|
||||||
|
isEnterprise: true,
|
||||||
|
docsUrl: 'https://automatisch.io/docs',
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
count: 1,
|
count: 1,
|
||||||
|
@@ -8,6 +8,11 @@
|
|||||||
name="description"
|
name="description"
|
||||||
content="Build workflow automation without spending time and money. No code is required."
|
content="Build workflow automation without spending time and money. No code is required."
|
||||||
/>
|
/>
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is installed on a
|
||||||
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
|
-->
|
||||||
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
<!--
|
<!--
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
9
packages/web/public/manifest.json
Normal file
9
packages/web/public/manifest.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"short_name": "automatisch",
|
||||||
|
"name": "automatisch",
|
||||||
|
"description": "Build workflow automation without spending time and money. No code is required.",
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { useFormContext, useWatch } from 'react-hook-form';
|
import { useFormContext, useWatch } from 'react-hook-form';
|
||||||
import Stack from '@mui/material/Stack';
|
import Stack from '@mui/material/Stack';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import Divider from '@mui/material/Divider';
|
import Divider from '@mui/material/Divider';
|
||||||
import IconButton from '@mui/material/IconButton';
|
import IconButton from '@mui/material/IconButton';
|
||||||
@@ -11,7 +12,6 @@ import AddIcon from '@mui/icons-material/Add';
|
|||||||
import useFormatMessage from 'hooks/useFormatMessage';
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
import InputCreator from 'components/InputCreator';
|
import InputCreator from 'components/InputCreator';
|
||||||
import { EditorContext } from 'contexts/Editor';
|
import { EditorContext } from 'contexts/Editor';
|
||||||
import { Grid } from '@mui/material';
|
|
||||||
|
|
||||||
const createGroupItem = () => ({
|
const createGroupItem = () => ({
|
||||||
key: '',
|
key: '',
|
||||||
@@ -122,7 +122,7 @@ function FilterConditions(props) {
|
|||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Stack sx={{ width: '100%' }} direction="column" spacing={2} mt={2}>
|
<Stack sx={{ width: '100%' }} direction="column" spacing={2} mt={2}>
|
||||||
{groups?.map((group, groupIndex) => (
|
{groups?.map((group, groupIndex) => (
|
||||||
<React.Fragment key={groupIndex}>
|
<>
|
||||||
{groupIndex !== 0 && <Divider />}
|
{groupIndex !== 0 && <Divider />}
|
||||||
|
|
||||||
<Typography variant="subtitle2" gutterBottom>
|
<Typography variant="subtitle2" gutterBottom>
|
||||||
@@ -133,16 +133,19 @@ function FilterConditions(props) {
|
|||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
{group?.and?.map((groupItem, groupItemIndex) => (
|
{group?.and?.map((groupItem, groupItemIndex) => (
|
||||||
<Grid container key={`item-${groupItem.id}`}>
|
<Stack direction="row" spacing={2} key={`item-${groupItem.id}`}>
|
||||||
<Grid
|
<Stack
|
||||||
container
|
direction={{ xs: 'column', sm: 'row' }}
|
||||||
spacing={2}
|
spacing={{ xs: 2 }}
|
||||||
item
|
sx={{ display: 'flex', flex: 1 }}
|
||||||
xs={12}
|
|
||||||
sm={11}
|
|
||||||
sx={{ order: { xs: 2, sm: 1 } }}
|
|
||||||
>
|
>
|
||||||
<Grid item xs={12} md={4}>
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flex: '1 0 0px',
|
||||||
|
maxWidth: ['100%', '33%'],
|
||||||
|
}}
|
||||||
|
>
|
||||||
<InputCreator
|
<InputCreator
|
||||||
schema={createStringArgument({
|
schema={createStringArgument({
|
||||||
key: `or.${groupIndex}.and.${groupItemIndex}.key`,
|
key: `or.${groupIndex}.and.${groupItemIndex}.key`,
|
||||||
@@ -152,8 +155,15 @@ function FilterConditions(props) {
|
|||||||
stepId={stepId}
|
stepId={stepId}
|
||||||
disabled={editorContext.readOnly}
|
disabled={editorContext.readOnly}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Box>
|
||||||
<Grid item xs={12} md={4}>
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flex: '1 0 0px',
|
||||||
|
maxWidth: ['100%', '33%'],
|
||||||
|
}}
|
||||||
|
>
|
||||||
<InputCreator
|
<InputCreator
|
||||||
schema={createDropdownArgument({
|
schema={createDropdownArgument({
|
||||||
key: `or.${groupIndex}.and.${groupItemIndex}.operator`,
|
key: `or.${groupIndex}.and.${groupItemIndex}.operator`,
|
||||||
@@ -164,8 +174,15 @@ function FilterConditions(props) {
|
|||||||
stepId={stepId}
|
stepId={stepId}
|
||||||
disabled={editorContext.readOnly}
|
disabled={editorContext.readOnly}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Box>
|
||||||
<Grid item xs={12} md={4}>
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flex: '1 0 0px',
|
||||||
|
maxWidth: ['100%', '33%'],
|
||||||
|
}}
|
||||||
|
>
|
||||||
<InputCreator
|
<InputCreator
|
||||||
schema={createStringArgument({
|
schema={createStringArgument({
|
||||||
key: `or.${groupIndex}.and.${groupItemIndex}.value`,
|
key: `or.${groupIndex}.and.${groupItemIndex}.value`,
|
||||||
@@ -175,28 +192,18 @@ function FilterConditions(props) {
|
|||||||
stepId={stepId}
|
stepId={stepId}
|
||||||
disabled={editorContext.readOnly}
|
disabled={editorContext.readOnly}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Box>
|
||||||
</Grid>
|
</Stack>
|
||||||
<Grid item xs={12} sm={1} sx={{ order: { xs: 1, sm: 2 } }}>
|
|
||||||
<Stack justifyContent="center" alignItems="flex-end">
|
<IconButton
|
||||||
<IconButton
|
size="small"
|
||||||
size="small"
|
edge="start"
|
||||||
edge="start"
|
onClick={() => removeGroupItem(groupIndex, groupItemIndex)}
|
||||||
onClick={() =>
|
sx={{ width: 61, height: 61 }}
|
||||||
removeGroupItem(groupIndex, groupItemIndex)
|
>
|
||||||
}
|
<RemoveIcon />
|
||||||
sx={{
|
</IconButton>
|
||||||
width: 40,
|
</Stack>
|
||||||
height: 40,
|
|
||||||
mb: { xs: 2, sm: 0 },
|
|
||||||
}}
|
|
||||||
disabled={groups.length === 1 && group.and.length === 1}
|
|
||||||
>
|
|
||||||
<RemoveIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Stack>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
))}
|
))}
|
||||||
|
|
||||||
<Stack spacing={1} direction="row">
|
<Stack spacing={1} direction="row">
|
||||||
@@ -220,7 +227,7 @@ function FilterConditions(props) {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</React.Fragment>
|
</>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
@@ -44,7 +44,7 @@ function InstallationForm() {
|
|||||||
|
|
||||||
const handleOnRedirect = () => {
|
const handleOnRedirect = () => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ['automatisch', 'info'],
|
queryKey: ['automatisch', 'config'],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -19,13 +19,7 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
|||||||
const value = joinBy('.', parentKey, index?.toString(), name);
|
const value = joinBy('.', parentKey, index?.toString(), name);
|
||||||
|
|
||||||
if (Array.isArray(sampleValue)) {
|
if (Array.isArray(sampleValue)) {
|
||||||
const arrayItself = {
|
return sampleValue.flatMap((item, index) =>
|
||||||
label,
|
|
||||||
value,
|
|
||||||
sampleValue: JSON.stringify(sampleValue),
|
|
||||||
};
|
|
||||||
|
|
||||||
const arrayItems = sampleValue.flatMap((item, index) =>
|
|
||||||
process({
|
process({
|
||||||
data: item,
|
data: item,
|
||||||
parentKey: value,
|
parentKey: value,
|
||||||
@@ -33,9 +27,6 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
|||||||
parentLabel: label,
|
parentLabel: label,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: remove spreading
|
|
||||||
return [arrayItself, ...arrayItems];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof sampleValue === 'object' && sampleValue !== null) {
|
if (typeof sampleValue === 'object' && sampleValue !== null) {
|
||||||
@@ -45,7 +36,6 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
|||||||
parentLabel: label,
|
parentLabel: label,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label,
|
label,
|
||||||
|
@@ -29,16 +29,14 @@ import adminSettingsRoutes from './adminSettingsRoutes';
|
|||||||
import Notifications from 'pages/Notifications';
|
import Notifications from 'pages/Notifications';
|
||||||
import useAutomatischConfig from 'hooks/useAutomatischConfig';
|
import useAutomatischConfig from 'hooks/useAutomatischConfig';
|
||||||
import useAuthentication from 'hooks/useAuthentication';
|
import useAuthentication from 'hooks/useAuthentication';
|
||||||
import useAutomatischInfo from 'hooks/useAutomatischInfo';
|
|
||||||
import Installation from 'pages/Installation';
|
import Installation from 'pages/Installation';
|
||||||
|
|
||||||
function Routes() {
|
function Routes() {
|
||||||
const { data: automatischInfo, isSuccess } = useAutomatischInfo();
|
const { data: configData, isSuccess } = useAutomatischConfig();
|
||||||
const { data: configData } = useAutomatischConfig();
|
|
||||||
const { isAuthenticated } = useAuthentication();
|
const { isAuthenticated } = useAuthentication();
|
||||||
const config = configData?.data;
|
const config = configData?.data;
|
||||||
|
|
||||||
const installed = isSuccess ? automatischInfo.data.installationCompleted : true;
|
const installed = isSuccess ? config?.['installation.completed'] === true : true;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Reference in New Issue
Block a user