Merge branch 'main' into issue-553
This commit is contained in:
@@ -50,6 +50,10 @@ class ExecutionStep extends Base {
|
||||
},
|
||||
});
|
||||
|
||||
get isFailed() {
|
||||
return this.status === 'failure';
|
||||
}
|
||||
|
||||
async $afterInsert(queryContext: QueryContext) {
|
||||
await super.$afterInsert(queryContext);
|
||||
Telemetry.executionStepCreated(this);
|
||||
|
@@ -13,6 +13,7 @@ class Flow extends Base {
|
||||
active: boolean;
|
||||
steps: Step[];
|
||||
published_at: string;
|
||||
executions?: Execution[];
|
||||
|
||||
static tableName = 'flows';
|
||||
|
||||
@@ -58,6 +59,15 @@ class Flow extends Base {
|
||||
return lastExecution ? (lastExecution as Execution).internalId : null;
|
||||
}
|
||||
|
||||
async lastInternalIds(itemCount = 50) {
|
||||
const lastExecutions = await this.$relatedQuery('executions')
|
||||
.select('internal_id')
|
||||
.orderBy('created_at', 'desc')
|
||||
.limit(itemCount);
|
||||
|
||||
return lastExecutions.map((execution) => execution.internalId);
|
||||
}
|
||||
|
||||
async $beforeUpdate(
|
||||
opt: ModelOptions,
|
||||
queryContext: QueryContext
|
||||
|
@@ -92,16 +92,43 @@ class Step extends Base {
|
||||
return this.type === 'trigger';
|
||||
}
|
||||
|
||||
async getTrigger() {
|
||||
if (!this.isTrigger) return null;
|
||||
get isAction(): boolean {
|
||||
return this.type === 'action';
|
||||
}
|
||||
|
||||
const { appKey, key } = this;
|
||||
async getApp() {
|
||||
if (!this.appKey) return null;
|
||||
|
||||
return await App.findOneByKey(this.appKey);
|
||||
}
|
||||
|
||||
async getNextStep() {
|
||||
const flow = await this.$relatedQuery('flow');
|
||||
|
||||
return await flow
|
||||
.$relatedQuery('steps')
|
||||
.findOne({ position: this.position + 1 });
|
||||
}
|
||||
|
||||
async getTriggerCommand() {
|
||||
const { appKey, key, isTrigger } = this;
|
||||
if (!isTrigger || !appKey || !key) return null;
|
||||
|
||||
const app = await App.findOneByKey(appKey);
|
||||
const command = app.triggers.find((trigger) => trigger.key === key);
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
async getActionCommand() {
|
||||
const { appKey, key, isAction } = this;
|
||||
if (!isAction || !appKey || !key) return null;
|
||||
|
||||
const app = await App.findOneByKey(appKey);
|
||||
const command = app.actions.find((action) => action.key === key);
|
||||
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
export default Step;
|
||||
|
Reference in New Issue
Block a user