feat: emit recording editor actions by type
This commit is contained in:
@@ -199,10 +199,36 @@ export class WorkflowInterpreter {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
serializableCallback: (data: any) => {
|
serializableCallback: (data: any) => {
|
||||||
this.socket.emit('serializableCallback', data);
|
if (this.currentActionType === 'scrapeSchema') {
|
||||||
|
if (Array.isArray(data) && data.length > 0) {
|
||||||
|
this.socket.emit('serializableCallback', {
|
||||||
|
type: 'captureText',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.socket.emit('serializableCallback', {
|
||||||
|
type: 'captureText',
|
||||||
|
data : [data]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (this.currentActionType === 'scrapeList') {
|
||||||
|
this.socket.emit('serializableCallback', {
|
||||||
|
type: 'captureList',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.socket.emit('serializableCallback', {
|
||||||
|
type: 'other',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
binaryCallback: (data: string, mimetype: string) => {
|
binaryCallback: (data: string, mimetype: string) => {
|
||||||
this.socket.emit('binaryCallback', { data, mimetype });
|
this.socket.emit('binaryCallback', {
|
||||||
|
data,
|
||||||
|
mimetype,
|
||||||
|
type: 'captureScreenshot'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,6 +314,8 @@ export class WorkflowInterpreter {
|
|||||||
|
|
||||||
const processedWorkflow = processWorkflow(workflow);
|
const processedWorkflow = processWorkflow(workflow);
|
||||||
|
|
||||||
|
let mergedScrapeSchema = {};
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
...settings,
|
...settings,
|
||||||
debugChannel: {
|
debugChannel: {
|
||||||
@@ -305,7 +333,13 @@ export class WorkflowInterpreter {
|
|||||||
},
|
},
|
||||||
serializableCallback: (data: any) => {
|
serializableCallback: (data: any) => {
|
||||||
if (this.currentActionType === 'scrapeSchema') {
|
if (this.currentActionType === 'scrapeSchema') {
|
||||||
this.serializableDataByType.scrapeSchema.push(data);
|
if (Array.isArray(data) && data.length > 0) {
|
||||||
|
mergedScrapeSchema = { ...mergedScrapeSchema, ...data[0] };
|
||||||
|
this.serializableDataByType.scrapeSchema.push(data);
|
||||||
|
} else {
|
||||||
|
mergedScrapeSchema = { ...mergedScrapeSchema, ...data };
|
||||||
|
this.serializableDataByType.scrapeSchema.push([data]);
|
||||||
|
}
|
||||||
} else if (this.currentActionType === 'scrapeList') {
|
} else if (this.currentActionType === 'scrapeList') {
|
||||||
this.serializableDataByType.scrapeList.push(data);
|
this.serializableDataByType.scrapeList.push(data);
|
||||||
} else {
|
} else {
|
||||||
@@ -346,12 +380,14 @@ export class WorkflowInterpreter {
|
|||||||
const result = {
|
const result = {
|
||||||
log: this.debugMessages,
|
log: this.debugMessages,
|
||||||
result: status,
|
result: status,
|
||||||
scrapeSchemaOutput: this.serializableDataByType.scrapeSchema.reduce((reducedObject, item, index) => {
|
scrapeSchemaOutput: Object.keys(mergedScrapeSchema).length > 0
|
||||||
return {
|
? { "schema-merged": [mergedScrapeSchema] }
|
||||||
[`schema-${index}`]: item,
|
: this.serializableDataByType.scrapeSchema.reduce((reducedObject, item, index) => {
|
||||||
...reducedObject,
|
return {
|
||||||
}
|
[`schema-${index}`]: item,
|
||||||
}, {}),
|
...reducedObject,
|
||||||
|
}
|
||||||
|
}, {}),
|
||||||
scrapeListOutput: this.serializableDataByType.scrapeList.reduce((reducedObject, item, index) => {
|
scrapeListOutput: this.serializableDataByType.scrapeList.reduce((reducedObject, item, index) => {
|
||||||
return {
|
return {
|
||||||
[`list-${index}`]: item,
|
[`list-${index}`]: item,
|
||||||
|
|||||||
Reference in New Issue
Block a user