feat: Add create flow from template method to user model

This commit is contained in:
Faruk AYDIN
2025-03-10 16:26:10 +01:00
parent 8246adec03
commit cf80ba28eb
2 changed files with 46 additions and 0 deletions

View File

@@ -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);