-
-
Notifications
You must be signed in to change notification settings - Fork 22k
ability store (and version) flows in github repo #4767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vinodkiran
wants to merge
14
commits into
FlowiseAI:main
Choose a base branch
from
vinodkiran:feature/git-version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
aff1869
ability store (and version) flows in github repo
vinodkiran 652cd7c
fix Data type "timestamp" in "ChatFlow.lastPublishedAt" is not suppor…
HenryHengZJ f4d588e
Implement chatflow version retrieval by commit ID and enhance UI for …
vinodkiran 3c2e187
Enhance chatflow retrieval by integrating FlowVersionService to load …
vinodkiran eab59dd
- Implemented a new endpoint to create a draft from a specific commit…
vinodkiran 14cd4c7
Add draft display and actions in VersionSideDrawer
vinodkiran 05f83ac
Add check endpoint and service method for active Git configuration an…
vinodkiran 09206b3
change of path for storing flow.json..now uses workspaceId, wsName an…
vinodkiran ff8038c
Add Git provider abstraction with implementations for GitHub and GitLab
vinodkiran 568496e
Enhance Git provider and FlowVersionService functionality
vinodkiran d89e424
copilot review - fixes and minor cleanup
vinodkiran 84efd87
Edit / Delete Git Config
vinodkiran 5aa12ff
Refactor GitHubProvider API request methods and enhance deleteFlow fu…
vinodkiran e3434b0
Improve GitHubProvider API request handling and validation checks for…
vinodkiran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/server/src/enterprise/controllers/flow-version.controller.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Request, Response, NextFunction } from 'express' | ||
import { StatusCodes } from 'http-status-codes' | ||
import { InternalFlowiseError } from '../../errors/internalFlowiseError' | ||
import { FlowVersionService } from '../services/flow-version.service' | ||
|
||
export class FlowVersionController { | ||
public async publishFlow(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.params || !req.params.id) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
const message = req.body?.message | ||
if (!message) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'message not provided!') | ||
} | ||
const service = new FlowVersionService() | ||
const result = await service.publishFlow(req.params.id, message) | ||
if (result.success) { | ||
return res.status(StatusCodes.OK).json(result) | ||
} else { | ||
return res.status(StatusCodes.BAD_REQUEST).json(result) | ||
} | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async getVersions(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.params || !req.params.id || req.params.id === "undefined") { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
const service = new FlowVersionService() | ||
const result = await service.getVersions(req.params.id) | ||
return res.status(StatusCodes.OK).json(result) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async makeDraft(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.params || !req.params.id || req.params.id === "undefined") { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
if (!req.params || !req.params.commitId || req.params.commitId === "undefined") { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'commitId not provided!') | ||
} | ||
const service = new FlowVersionService() | ||
const result = await service.makeDraft(req.params.id, req.params.commitId) | ||
return res.status(StatusCodes.OK).json(result) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async check(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const service = new FlowVersionService() | ||
const result = await service.check() | ||
return res.status(StatusCodes.OK).json({ | ||
isActive: result | ||
}) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
} |
145 changes: 145 additions & 0 deletions
145
packages/server/src/enterprise/controllers/git-config.controller.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { Request, Response, NextFunction } from 'express' | ||
import { StatusCodes } from 'http-status-codes' | ||
import { GitConfigService } from '../services/git-config.service' | ||
import { InternalFlowiseError } from '../../errors/internalFlowiseError' | ||
import { GitConfig } from '../database/entities/git-config.entity' | ||
|
||
export class GitConfigController { | ||
public async getAll(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const currentUser = req.user | ||
if (!currentUser) { | ||
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, 'User not found') | ||
} | ||
const organizationId = currentUser.activeOrganizationId | ||
const service = new GitConfigService() | ||
const configs = await service.getAllGitConfigs(organizationId) | ||
return res.status(StatusCodes.OK).json(configs) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async getById(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const currentUser = req.user | ||
if (!currentUser) { | ||
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, 'User not found') | ||
} | ||
const organizationId = currentUser.activeOrganizationId | ||
|
||
if (!req.params || !req.params.id) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
const service = new GitConfigService() | ||
const config = await service.getGitConfigById(req.params.id, organizationId) | ||
if (!config) return res.status(StatusCodes.NOT_FOUND).json({ message: 'Git config not found' }) | ||
return res.status(StatusCodes.OK).json(config) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async create(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.body) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'body not provided!') | ||
} | ||
const currentUser = req.user | ||
if (!currentUser) { | ||
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, 'User not found') | ||
} | ||
const organizationId = currentUser.activeOrganizationId | ||
const body: Partial<GitConfig> = { | ||
...req.body, | ||
organizationId, | ||
createdBy: currentUser.id, | ||
createdByUser: currentUser, | ||
updatedBy: currentUser.id, | ||
updatedByUser: currentUser, | ||
isActive: true | ||
} | ||
const service = new GitConfigService() | ||
const config = await service.createGitConfig(body) | ||
return res.status(StatusCodes.CREATED).json(config) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async testConnection(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.body || !req.body.username || !req.body.secret || !req.body.repository) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'username, secret, and repository are required!') | ||
} | ||
const service = new GitConfigService() | ||
const config = await service.testGitConfig(req.body) | ||
return res.status(StatusCodes.OK).json(config) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async getBranches(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.params || !req.params.id) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
const currentUser = req.user | ||
if (!currentUser) { | ||
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, 'User not found') | ||
} | ||
const organizationId = currentUser.activeOrganizationId | ||
const service = new GitConfigService() | ||
const branches = await service.getBranches(req.params.id, organizationId) | ||
return res.status(StatusCodes.OK).json(branches) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async update(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.params || !req.params.id) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
if (!req.body) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'body not provided!') | ||
} | ||
const currentUser = req.user | ||
if (!currentUser) { | ||
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, 'User not found') | ||
} | ||
const organizationId = currentUser.activeOrganizationId | ||
const body = { | ||
...req.body, | ||
organizationId | ||
} | ||
const service = new GitConfigService() | ||
const config = await service.updateGitConfig(req.params.id, body) | ||
if (!config) return res.status(StatusCodes.NOT_FOUND).json({ message: 'Git config not found' }) | ||
return res.status(StatusCodes.OK).json(config) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
public async delete(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
if (!req.params || !req.params.id) { | ||
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'id not provided!') | ||
} | ||
const currentUser = req.user | ||
if (!currentUser) { | ||
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, 'User not found') | ||
} | ||
const organizationId = currentUser.activeOrganizationId | ||
const service = new GitConfigService() | ||
const result = await service.deleteGitConfig(req.params.id, organizationId) | ||
if (!result) return res.status(StatusCodes.NOT_FOUND).json({ message: 'Git config not found' }) | ||
return res.status(StatusCodes.NO_CONTENT).send() | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,4 @@ export class LoginActivity implements ILoginActivity { | |
@UpdateDateColumn() | ||
attemptedDateTime: Date | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.