Skip to content

Commit 6972828

Browse files
authored
v1.28.25
2 parents c12f395 + 3928ab1 commit 6972828

File tree

9 files changed

+48
-26
lines changed

9 files changed

+48
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "automa",
3-
"version": "1.28.24",
3+
"version": "1.28.25",
44
"description": "An extension for automating your browser by connecting blocks",
55
"repository": {
66
"type": "git",

src/components/newtab/workflow/edit/EditWebhook.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ const emit = defineEmits(['update:data']);
173173
174174
const { t } = useI18n();
175175
176-
const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
177-
const notHaveBody = ['GET'];
176+
const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'];
177+
const notHaveBody = ['GET', 'HEAD'];
178178
const copyHeaders = JSON.parse(JSON.stringify(props.data.headers));
179179
180180
const activeTab = ref('headers');

src/stores/workflow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const defaultWorkflow = (data = null, options = {}) => {
4747
settings: {
4848
publicId: '',
4949
blockDelay: 0,
50-
saveLog: true,
50+
saveLog: false,
5151
debugMode: false,
5252
restartTimes: 3,
5353
notification: true,

src/workflowEngine/blocksHandler/handlerInsertData.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ async function insertData({ id, data }, { refData }) {
8181
this.addDataToColumn(item.name, tableValue);
8282
});
8383
} else {
84-
await this.setVariable(item.name, value);
84+
const variableName = await renderString(
85+
item.name,
86+
refData,
87+
this.engine.isPopup
88+
);
89+
await this.setVariable(variableName.value, value);
8590
}
8691
}
8792

src/workflowEngine/blocksHandler/handlerJavascriptCode.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,12 @@ export async function javascriptCode({ outputs, data, ...block }, { refData }) {
257257
? columnDataObj
258258
: [columnDataObj];
259259

260-
if (replaceTable) this.engine.referenceData.table = [];
260+
if (replaceTable) {
261+
this.engine.referenceData.table = [];
262+
Object.keys(this.engine.columns).forEach((key) => {
263+
this.engine.columns[key].index = 0;
264+
});
265+
}
261266

262267
this.addDataToColumn(params);
263268
}

src/workflowEngine/blocksHandler/handlerWebhook.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ import { isWhitespace } from '@/utils/helper';
33
import { executeWebhook } from '../utils/webhookUtil';
44
import renderString from '../templating/renderString';
55

6-
function fileReader(blob) {
7-
return new Promise((resolve) => {
8-
const reader = new FileReader();
9-
reader.onload = () => {
10-
resolve(reader.result);
11-
};
12-
reader.readAsDataURL(blob);
13-
});
14-
}
15-
166
const ALL_HTTP_RESPONSE_KEYWORD = '$response';
177

188
export async function webhook({ data, id }, { refData }) {
@@ -83,7 +73,13 @@ export async function webhook({ data, id }, { refData }) {
8373
}
8474
} else if (data.responseType === 'base64') {
8575
const blob = await response.blob();
86-
const base64 = await fileReader(blob);
76+
const base64 = await new Promise((resolve) => {
77+
const reader = new FileReader();
78+
reader.onload = () => {
79+
resolve(reader.result);
80+
};
81+
reader.readAsDataURL(blob);
82+
});
8783

8884
returnData = base64;
8985
} else {

src/workflowEngine/templating/mustacheReplacer.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ export function keyParser(key, data) {
6363

6464
function replacer(
6565
str,
66-
{ regex, tagLen, modifyPath, data, disableStringify = false }
66+
{
67+
data,
68+
regex,
69+
tagLen,
70+
modifyPath,
71+
checkExistence = false,
72+
disableStringify = false,
73+
}
6774
) {
6875
const replaceResult = {
6976
list: {},
@@ -106,6 +113,8 @@ function replacer(
106113
dataKey = dataKey.slice(1);
107114
}
108115

116+
if (checkExistence) return objectPath.has(data[dataKey], path);
117+
109118
result = objectPath.get(data[dataKey], path);
110119
if (typeof result === 'undefined') result = match;
111120

@@ -144,6 +153,7 @@ export default function (str, refData, options = {}) {
144153
tagLen: 1,
145154
regex: /\[(.*?)\]/g,
146155
...options,
156+
checkExistence: false,
147157
});
148158
Object.assign(replacedList, list);
149159

src/workflowEngine/utils/testConditions.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import cloneDeep from 'lodash.clonedeep';
2-
import objectPath from 'object-path';
32
import { parseJSON } from '@/utils/helper';
43
import { conditionBuilder } from '@/utils/shared';
54
import renderString from '../templating/renderString';
6-
import { keyParser } from '../templating/mustacheReplacer';
75

86
const isBoolStr = (str) => {
97
if (str === 'true') return true;
@@ -56,14 +54,22 @@ export default async function (conditionsArr, workflowData) {
5654
const isInsideBrackets =
5755
dataPath.startsWith('{{') && dataPath.endsWith('}}');
5856

59-
if (isInsideBrackets) {
60-
dataPath = dataPath.slice(2, -2).trim();
57+
if (!isInsideBrackets) {
58+
dataPath = `{{${dataPath}}}`;
6159
}
6260

63-
const parsedPath = keyParser(dataPath, workflowData.refData);
64-
dataPath = `${parsedPath.dataKey}.${parsedPath.path}`;
61+
let dataExists = await renderString(
62+
dataPath,
63+
workflowData.refData,
64+
workflowData.isPopup,
65+
{
66+
checkExistence: true,
67+
}
68+
);
69+
// It return string for some reason
70+
dataExists = Boolean(parseJSON(dataExists.value, false));
6571

66-
return objectPath.has(workflowData.refData, dataPath);
72+
return dataExists;
6773
}
6874

6975
const copyData = cloneDeep(data);

src/workflowEngine/utils/webhookUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const contentTypes = {
7979
'form-data': 'multipart/form-data',
8080
form: 'application/x-www-form-urlencoded',
8181
};
82-
const notHaveBody = ['GET', 'DELETE'];
82+
const notHaveBody = ['GET', 'HEAD'];
8383

8484
export async function executeWebhook({
8585
url,

0 commit comments

Comments
 (0)