Ahmad Kholid 1 year ago
parent
commit
7ccd96a4c1

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.28.10",
+  "version": "1.28.11",
   "description": "An extension for automating your browser by connecting blocks",
   "repository": {
     "type": "git",

+ 3 - 0
secrets.blank.js

@@ -0,0 +1,3 @@
+export default {
+  baseApiUrl: '',
+};

+ 0 - 2
src/background/BackgroundUtils.js

@@ -37,8 +37,6 @@ class BackgroundUtils {
 
         if (updateTab) {
           windowOptions.focused = true;
-        } else {
-          windowOptions.state = 'minimized';
         }
 
         await browser.windows.create(windowOptions);

+ 6 - 23
src/components/newtab/workflow/edit/EditAutocomplete.vue

@@ -24,44 +24,27 @@ const state = shallowReactive({
   pathLen: -1,
 });
 
-const cache = new Map();
-
 function autocompleteFilter({ text, item }) {
-  const query = text.replace('@', '.').split('.').pop();
+  if (!text) return true;
 
+  const query = text.replace('@', '.').split('.').pop();
   return item.toLocaleLowerCase().includes(query);
 }
 function onSearch(value) {
-  const path = (value ?? '').replace('@', '.');
-  const pathArr = path.split('.');
-
-  if (pathArr.length <= 1) {
-    state.path = '';
-    state.pathLen = 0;
+  const pathArr = (value ?? '').replace('@', '.').split('.');
 
-    return;
-  }
-
-  if (pathArr.length !== state.pathLen) {
-    state.path = path.endsWith('.') ? path.slice(0, -1) : path;
-    state.pathLen = pathArr.length;
-  }
+  state.path = (pathArr.length > 1 ? pathArr.slice(0, -1) : pathArr).join('.');
+  state.pathLen = pathArr.length;
 }
 
 const autocompleteList = computed(() => {
-  if (cache.has(state.path)) {
-    return cache.get(state.path);
-  }
-
   const data =
-    !state.path || state.pathLen < 1
+    !state.path || state.pathLen <= 1
       ? autocompleteData.value
       : objectPath.get(autocompleteData.value, state.path);
 
   const list = typeof data === 'string' ? [] : Object.keys(data || {});
 
-  cache.set(state.path, list);
-
   return list;
 });
 </script>

+ 8 - 6
src/components/newtab/workflow/settings/event/EventCodeHTTP.vue

@@ -31,24 +31,26 @@
   <ui-tab-panels v-model="activeTab">
     <ui-tab-panel value="headers">
       <div class="mt-4 grid grid-cols-7 justify-items-center gap-2">
-        <template v-for="(items, index) in data.headers" :key="index">
+        <template v-for="(header, index) in data.headers" :key="index">
           <ui-input
-            v-model="items.name"
-            :title="items.name"
+            v-model="header.name"
+            :title="header.name"
             :placeholder="`Header ${index + 1}`"
             type="text"
             class="col-span-3"
           />
           <ui-input
-            v-model="items.value"
-            :title="items.value"
+            v-model="header.value"
+            :title="header.value"
             placeholder="Value"
             type="text"
             class="col-span-3"
           />
           <button
             @click="
-              emitData({ headers: data.filter((_, idx) => idx !== index) })
+              emitData({
+                headers: data.headers.filter((_, idx) => idx !== index),
+              })
             "
           >
             <v-remixicon name="riCloseCircleLine" size="20" />

+ 12 - 2
src/components/ui/UiAutocomplete.vue

@@ -134,8 +134,19 @@ function getLastKeyBeforeCaret(caretIndex) {
 }
 function getSearchText(caretIndex, charIndex) {
   if (charIndex !== -1) {
+    const closeTrigger = (props.triggerChar ?? [])[1];
+    const searchRgxp = new RegExp(
+      `\\s${closeTrigger ? `|${closeTrigger}` : ''}`
+    );
+
+    const inputValue = input.value;
+    const afterCaretTxt = inputValue.substring(caretIndex);
+    const lastClosingIdx = afterCaretTxt.search(searchRgxp);
+
     const charsLength = props.triggerChar.length;
-    const text = input.value.substring(charIndex + charsLength, caretIndex);
+    const text =
+      input.value.substring(charIndex + charsLength, caretIndex) +
+      afterCaretTxt.substring(0, lastClosingIdx);
 
     if (!/\s/.test(text)) {
       return text;
@@ -199,7 +210,6 @@ function updateValue(value) {
 }
 function selectItem(itemIndex, selected) {
   let selectedItem = filteredItems.value[itemIndex];
-
   if (!selectedItem) return;
 
   selectedItem = getItem(selectedItem);

+ 0 - 1
src/utils/helper.js

@@ -17,7 +17,6 @@ export async function getActiveTab() {
       if (isDashboard) {
         await browser.windows.update(browserWindow.id, {
           focused: false,
-          state: 'minimized',
         });
       } else if (browserWindow.focused) {
         windowId = browserWindow.id;

+ 23 - 1
src/workflowEngine/blocksHandler/handlerWebhook.js

@@ -13,6 +13,8 @@ function fileReader(blob) {
   });
 }
 
+const ALL_HTTP_RESPONSE_KEYWORD = '$response';
+
 export async function webhook({ data, id }, { refData }) {
   const nextBlockId = this.getBlockConnections(id);
   const fallbackOutput = this.getBlockConnections(id, 'fallback');
@@ -68,11 +70,17 @@ export async function webhook({ data, id }, { refData }) {
       };
     }
 
+    const includeResponse = data.dataPath.includes(ALL_HTTP_RESPONSE_KEYWORD);
     let returnData = '';
 
     if (data.responseType === 'json') {
       const jsonRes = await response.json();
-      returnData = objectPath.get(jsonRes, data.dataPath);
+
+      if (!includeResponse) {
+        returnData = objectPath.get(jsonRes, data.dataPath);
+      } else {
+        returnData = jsonRes;
+      }
     } else if (data.responseType === 'base64') {
       const blob = await response.blob();
       const base64 = await fileReader(blob);
@@ -82,6 +90,20 @@ export async function webhook({ data, id }, { refData }) {
       returnData = await response.text();
     }
 
+    if (includeResponse) {
+      const { status, statusText, url, redirected, ok } = response;
+      const responseData = {
+        ok,
+        url,
+        status,
+        statusText,
+        redirected,
+        data: returnData,
+      };
+
+      returnData = objectPath.get({ $response: responseData }, data.dataPath);
+    }
+
     if (data.assignVariable) {
       this.setVariable(data.variableName, returnData);
     }

+ 1 - 1
src/workflowEngine/templating/mustacheReplacer.js

@@ -17,7 +17,7 @@ export function extractStrFunction(str) {
   if (!extractedStr) return null;
   const { 1: name, 2: funcParams } = extractedStr;
   const params = funcParams
-    .split(/,(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/)
+    .split(/,(?=(?:[^'"\\"\\']*['"][^'"]*['"\\"\\'])*[^'"]*$)/)
     .map((param) => param.trim().replace(/^['"]|['"]$/g, '') || '');
 
   return {