Compare commits

...

8 Commits

Author SHA1 Message Date
Faruk AYDIN
50d91405a9 Update version to 0.13.0 2024-08-01 17:32:19 +02:00
Ali BARIN
69eed65c9b Merge pull request #1991 from automatisch/AUT-1064
fix: introduce fix for overflowing inputs with long parameters names
2024-08-01 16:22:17 +02:00
kasia.oczkowska
f1355cd0ab fix: introduce fix for overflowing inputs with long parameters names 2024-08-01 15:10:41 +01:00
Ali BARIN
dffbdf544c Merge pull request #2000 from automatisch/AUT-1131
fix: prevent removing last filter criteria
2024-08-01 10:50:42 +02:00
kasia.oczkowska
e2dbf1a215 fix: prevent removing last filter criteria 2024-08-01 08:40:54 +01:00
Ömer Faruk Aydın
c1396b97f0 Merge pull request #1996 from automatisch/support-arrays-in-flows
feat: support arrays in flows
2024-07-30 13:26:56 +02:00
Ali BARIN
920a711c00 feat: support arrays in flows 2024-07-29 11:33:36 +00:00
Ömer Faruk Aydın
02a872a376 Merge pull request #1995 from automatisch/support-async-before-request
feat(http-client): support async beforeRequest interceptors
2024-07-27 18:41:40 +02:00
5 changed files with 73 additions and 54 deletions

View File

@@ -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.12.0', version: '0.13.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'),

View File

@@ -10,7 +10,7 @@ describe('GET /api/v1/automatisch/version', () => {
const expectedPayload = { const expectedPayload = {
data: { data: {
version: '0.12.0', version: '0.13.0',
}, },
meta: { meta: {
count: 1, count: 1,

View File

@@ -11,6 +11,7 @@ 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('.');
@@ -20,18 +21,33 @@ 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
try {
const parsedValue = JSON.parse(computedValue);
return {
...result,
[key]: parsedValue,
};
} catch (error) {
return { return {
...result, ...result,
[key]: computedValue, [key]: computedValue,
}; };
} }
}
if (Array.isArray(value)) { if (Array.isArray(value)) {
return { return {

View File

@@ -3,7 +3,6 @@ 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';
@@ -12,6 +11,7 @@ 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,19 +133,16 @@ function FilterConditions(props) {
</Typography> </Typography>
{group?.and?.map((groupItem, groupItemIndex) => ( {group?.and?.map((groupItem, groupItemIndex) => (
<Stack direction="row" spacing={2} key={`item-${groupItem.id}`}> <Grid container key={`item-${groupItem.id}`}>
<Stack <Grid
direction={{ xs: 'column', sm: 'row' }} container
spacing={{ xs: 2 }} spacing={2}
sx={{ display: 'flex', flex: 1 }} item
> xs={12}
<Box sm={11}
sx={{ sx={{ order: { xs: 2, sm: 1 } }}
display: 'flex',
flex: '1 0 0px',
maxWidth: ['100%', '33%'],
}}
> >
<Grid item xs={12} md={4}>
<InputCreator <InputCreator
schema={createStringArgument({ schema={createStringArgument({
key: `or.${groupIndex}.and.${groupItemIndex}.key`, key: `or.${groupIndex}.and.${groupItemIndex}.key`,
@@ -155,15 +152,8 @@ function FilterConditions(props) {
stepId={stepId} stepId={stepId}
disabled={editorContext.readOnly} disabled={editorContext.readOnly}
/> />
</Box> </Grid>
<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`,
@@ -174,15 +164,8 @@ function FilterConditions(props) {
stepId={stepId} stepId={stepId}
disabled={editorContext.readOnly} disabled={editorContext.readOnly}
/> />
</Box> </Grid>
<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`,
@@ -192,18 +175,28 @@ function FilterConditions(props) {
stepId={stepId} stepId={stepId}
disabled={editorContext.readOnly} disabled={editorContext.readOnly}
/> />
</Box> </Grid>
</Stack> </Grid>
<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)
}
sx={{
width: 40,
height: 40,
mb: { xs: 2, sm: 0 },
}}
disabled={groups.length === 1 && group.and.length === 1}
> >
<RemoveIcon /> <RemoveIcon />
</IconButton> </IconButton>
</Stack> </Stack>
</Grid>
</Grid>
))} ))}
<Stack spacing={1} direction="row"> <Stack spacing={1} direction="row">
@@ -227,7 +220,7 @@ function FilterConditions(props) {
</IconButton> </IconButton>
)} )}
</Stack> </Stack>
</> </React.Fragment>
))} ))}
</Stack> </Stack>
</React.Fragment> </React.Fragment>

View File

@@ -19,7 +19,13 @@ 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)) {
return sampleValue.flatMap((item, index) => const arrayItself = {
label,
value,
sampleValue: JSON.stringify(sampleValue),
};
const arrayItems = sampleValue.flatMap((item, index) =>
process({ process({
data: item, data: item,
parentKey: value, parentKey: value,
@@ -27,6 +33,9 @@ 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) {
@@ -36,6 +45,7 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
parentLabel: label, parentLabel: label,
}); });
} }
return [ return [
{ {
label, label,