feat: Add create flow from template method to user model
This commit is contained in:
@@ -22,6 +22,7 @@ import Step from './step.js';
|
||||
import Subscription from './subscription.ee.js';
|
||||
import Folder from './folder.js';
|
||||
import UsageData from './usage-data.ee.js';
|
||||
import Template from './template.ee.js';
|
||||
import Billing from '../helpers/billing/index.ee.js';
|
||||
import NotAuthorizedError from '../errors/not-authorized.js';
|
||||
|
||||
@@ -685,6 +686,16 @@ class User extends Base {
|
||||
return flow;
|
||||
}
|
||||
|
||||
async createFlowFromTemplate(templateId) {
|
||||
const template = await Template.query()
|
||||
.findById(templateId)
|
||||
.throwIfNotFound();
|
||||
|
||||
const flow = await Flow.import(this, template.flowData);
|
||||
|
||||
return flow;
|
||||
}
|
||||
|
||||
async $beforeInsert(queryContext) {
|
||||
await super.$beforeInsert(queryContext);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user