|
@@ -39,6 +39,7 @@ class WorkflowEngine {
|
|
|
this.blocks = {};
|
|
|
this.history = [];
|
|
|
this.columnsId = {};
|
|
|
+ this.historyCtxData = {};
|
|
|
this.eventListeners = {};
|
|
|
this.preloadScripts = [];
|
|
|
this.columns = { column: { index: 0, name: 'column', type: 'any' } };
|
|
@@ -97,6 +98,7 @@ class WorkflowEngine {
|
|
|
this.isUsingProxy = false;
|
|
|
|
|
|
this.history = [];
|
|
|
+ this.preloadScripts = [];
|
|
|
this.columns = { column: { index: 0, name: 'column', type: 'any' } };
|
|
|
|
|
|
this.activeTab = {
|
|
@@ -205,6 +207,26 @@ class WorkflowEngine {
|
|
|
)
|
|
|
return;
|
|
|
|
|
|
+ const historyId = nanoid();
|
|
|
+ detail.id = historyId;
|
|
|
+
|
|
|
+ if (tasks[detail.name]?.refDataKeys && this.saveLog) {
|
|
|
+ const { activeTabUrl, loopData, prevBlockData } = JSON.parse(
|
|
|
+ JSON.stringify(this.referenceData)
|
|
|
+ );
|
|
|
+
|
|
|
+ this.historyCtxData[historyId] = {
|
|
|
+ referenceData: {
|
|
|
+ loopData,
|
|
|
+ activeTabUrl,
|
|
|
+ prevBlockData,
|
|
|
+ },
|
|
|
+ replacedValue: detail.replacedValue,
|
|
|
+ };
|
|
|
+
|
|
|
+ delete detail.replacedValue;
|
|
|
+ }
|
|
|
+
|
|
|
this.history.push(detail);
|
|
|
}
|
|
|
|
|
@@ -237,6 +259,10 @@ class WorkflowEngine {
|
|
|
currentColumn.index += 1;
|
|
|
}
|
|
|
|
|
|
+ setVariable(name, value) {
|
|
|
+ this.referenceData.variables[name] = value;
|
|
|
+ }
|
|
|
+
|
|
|
async stop() {
|
|
|
try {
|
|
|
if (this.childWorkflowId) {
|
|
@@ -286,6 +312,11 @@ class WorkflowEngine {
|
|
|
if (!this.workflow.isTesting) {
|
|
|
const { name, id } = this.workflow;
|
|
|
|
|
|
+ let { logsCtxData } = await browser.storage.local.get('logsCtxData');
|
|
|
+ if (!logsCtxData) logsCtxData = {};
|
|
|
+ logsCtxData[this.id] = this.historyCtxData;
|
|
|
+ await browser.storage.local.set({ logsCtxData });
|
|
|
+
|
|
|
await this.logger.add({
|
|
|
name,
|
|
|
status,
|
|
@@ -313,16 +344,18 @@ class WorkflowEngine {
|
|
|
currentBlock: this.currentBlock,
|
|
|
});
|
|
|
|
|
|
- browser.storage.local.set({
|
|
|
- [`last-state:${this.workflow.id}`]: {
|
|
|
- columns: this.columns,
|
|
|
- referenceData: {
|
|
|
- table: this.referenceData.table,
|
|
|
- variables: this.referenceData.variables,
|
|
|
- globalData: this.referenceData.globalData,
|
|
|
+ if (this.workflow.settings.reuseLastState) {
|
|
|
+ browser.storage.local.set({
|
|
|
+ [`last-state:${this.workflow.id}`]: {
|
|
|
+ columns: this.columns,
|
|
|
+ referenceData: {
|
|
|
+ table: this.referenceData.table,
|
|
|
+ variables: this.referenceData.variables,
|
|
|
+ globalData: this.referenceData.globalData,
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
this.isDestroyed = true;
|
|
|
this.eventListeners = {};
|
|
@@ -375,10 +408,15 @@ class WorkflowEngine {
|
|
|
refData: this.referenceData,
|
|
|
});
|
|
|
|
|
|
+ if (result.replacedValue)
|
|
|
+ replacedBlock.replacedValue = result.replacedValue;
|
|
|
+
|
|
|
this.addLogHistory({
|
|
|
name: block.name,
|
|
|
logId: result.logId,
|
|
|
type: result.status || 'success',
|
|
|
+ description: block.data.description,
|
|
|
+ replacedValue: replacedBlock.replacedValue,
|
|
|
duration: Math.round(Date.now() - startExecuteTime),
|
|
|
});
|
|
|
|
|
@@ -399,6 +437,8 @@ class WorkflowEngine {
|
|
|
type: 'error',
|
|
|
message: error.message,
|
|
|
name: block.name,
|
|
|
+ description: block.data.description,
|
|
|
+ replacedValue: replacedBlock.replacedValue,
|
|
|
...(error.data || {}),
|
|
|
});
|
|
|
|