-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement basic git service * cleanup connected prop * add skeleton of git functions * initial import/export setup * split out export service * refactor and improve export * begin import * more commands and basic import * clean up imports with transactions * work folder import functions * reintroduce versionid * add missing import to pull workfolder * add get-status endpoint * add cleanup to disconnect * add initRepo options * add more checks and cleanup * minor cleanup * refactor prefs * fix server.ts * fix sending deleted files * rename files to ee * add variable override and fix critical cred import bug * fix mkdir race condition * make initRepo default to true * fix front back integration * improve connect flow * add comment to generated ssh key * fix(editor): use useToast composable * fix buttons size * commenting out repo init for now * fix(editor): update UI logic * fix(editor): remove console.log * fix(editor): remove unused ref * adjust endpoints for improved UI * fix(editor): add push and pull buttons * keep or not ssh key * switching file name to id * fix(editor): add success messages, fix save button * fixed faulty diff preventing pull * fix build * fix(editor): adding loader to VC components * removing duplicate exports * improve conflict finding on push pull * manage pull conflict * alternate push pull * fix pull confirmation * fix rm and credential export/import * switch to alternative pull implementation * fix initial commit * fix(editor): subscribing to VC store action to refresh lists * fix(editor): wrap VC store actions with try * feat: add fine-grained file selection for push action * fix: close modal after successful push * fix(editor): VC preferences validation * fix confirm * fix: update endpoint to /get-status * feat: update pull modal override changes message * fix missing wf error * undo * removing connect endpoint * fix(editor): add button titles * fix(editor): cleaning up store action * add version-control/set-read-only protection * fix(editor): adding set branch readonly * fix(editor): remove Push button if branch set to readonly * fix(editor): fix some styles * fix(editor): remove duplicate and delete actions in WF list when branch is readonly * fix: load status before opening selective push modal * fix(editor): extend readonly logic * add cleanup after failed initRepo * fix deleted files crashing get-status * fix n8n-checkbox in staging dialog * fix(editor): fix loading * fix(editor): resize buttons * fix(editor): fix translation * fix(editor): fix copy text size * fix(editor): fix copy text size * fix(editor): add disconnection confirmation * fix(editor): add disconnection confirmation * fix(editor): set large buttons * add public api Pull endpoint * feat: add refresh ssh key * return prefs when new keys are generated * fix(editor): adding readOnly mode to main header * fix(editor): adding readOnly mode to workflow settings * improve credential owner import * add middleware to endpoints * improve public api error/doc * do not create branch if one already exists * update wordings for connect toasts * fix(editor): updating and separating readonly modes * fix(editor): fix readonly mode in WF list * fix(editor): disable elements dragging on canvas in readonly mode (WIP: not working when NodeView page is loaded first) * fix(editor): fix canvas draggables in readonly env * fix(editor): remove unused variables * fix(editor): hide actions in node connections when readonly * fix(editor): hide actions in node connections when readonly * fix(editor): disable Save button when readonly * fix(editor): disable Save settings if no branch is selected * fix(editor): lint fix * fix(editor): update snapshots * fix(editor): replace Loading... text * fix(editor): reset Loading... text * reset branchname on disconnect * fix(editor): adding some translations * fix(editor): fix unit test * fix(editor): fix loading * fix(editor): set settings saved message * fix(editor): update connection flag * fix branchName not returning after connect * temporary (but still breaking) fix for postgres * fix(editor): adding tooltip to Push/Pull buttons when they're collapsed * fix(editor): enabled activator in readonly mode * fix test * fix(editor): disabling new item addition for workflows in readonly mode * fix(editor): modify Pull/Push button tooltips * do not commit empty variables file --------- Co-authored-by: Michael Auerswald <michael.auerswald@gmail.com> Co-authored-by: Romain Minaud <romain.minaud@gmail.com> Co-authored-by: Alex Grozav <alex@grozav.com>
- Loading branch information
1 parent
04cfa54
commit 1b32141
Showing
75 changed files
with
3,710 additions
and
450 deletions.
There are no files selected for viewing
This file contains 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 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
25 changes: 25 additions & 0 deletions
25
packages/cli/src/PublicApi/v1/handlers/versionControl/spec/paths/versionControl.yml
This file contains 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,25 @@ | ||
post: | ||
x-eov-operation-id: pull | ||
x-eov-operation-handler: v1/handlers/versionControl/versionControl.handler | ||
tags: | ||
- VersionControl | ||
summary: Pull changes from the remote repository | ||
description: Requires the Version Control feature to be licensed and connected to a repository. | ||
requestBody: | ||
description: Pull options | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../schemas/pull.yml" | ||
responses: | ||
"200": | ||
description: Import result | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "../schemas/importResult.yml" | ||
"400": | ||
$ref: "../../../../shared/spec/responses/badRequest.yml" | ||
"409": | ||
$ref: "../../../../shared/spec/responses/conflict.yml" |
55 changes: 55 additions & 0 deletions
55
packages/cli/src/PublicApi/v1/handlers/versionControl/spec/schemas/importResult.yml
This file contains 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,55 @@ | ||
type: object | ||
additionalProperties: true | ||
properties: | ||
variables: | ||
type: object | ||
properties: | ||
added: | ||
type: array | ||
items: | ||
type: string | ||
changed: | ||
type: array | ||
items: | ||
type: string | ||
credentials: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
type: | ||
type: string | ||
workflows: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
tags: | ||
type: object | ||
properties: | ||
tags: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
mappings: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
workflowId: | ||
type: string | ||
tagId: | ||
type: string |
8 changes: 8 additions & 0 deletions
8
packages/cli/src/PublicApi/v1/handlers/versionControl/spec/schemas/pull.yml
This file contains 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,8 @@ | ||
type: object | ||
properties: | ||
force: | ||
type: boolean | ||
example: true | ||
variables: | ||
type: object | ||
example: { "foo": "bar" } |
47 changes: 47 additions & 0 deletions
47
packages/cli/src/PublicApi/v1/handlers/versionControl/versionControl.handler.ts
This file contains 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,47 @@ | ||
import type express from 'express'; | ||
import type { StatusResult } from 'simple-git'; | ||
import type { PublicVersionControlRequest } from '../../../types'; | ||
import { authorize } from '../../shared/middlewares/global.middleware'; | ||
import type { ImportResult } from '@/environments/versionControl/types/importResult'; | ||
import Container from 'typedi'; | ||
import { VersionControlService } from '@/environments/versionControl/versionControl.service.ee'; | ||
import { VersionControlPreferencesService } from '@/environments/versionControl/versionControlPreferences.service.ee'; | ||
import { isVersionControlLicensed } from '@/environments/versionControl/versionControlHelper.ee'; | ||
|
||
export = { | ||
pull: [ | ||
authorize(['owner', 'member']), | ||
async ( | ||
req: PublicVersionControlRequest.Pull, | ||
res: express.Response, | ||
): Promise<ImportResult | StatusResult | Promise<express.Response>> => { | ||
const versionControlPreferencesService = Container.get(VersionControlPreferencesService); | ||
if (!isVersionControlLicensed()) { | ||
return res | ||
.status(401) | ||
.json({ status: 'Error', message: 'Version Control feature is not licensed' }); | ||
} | ||
if (!versionControlPreferencesService.isVersionControlConnected()) { | ||
return res | ||
.status(400) | ||
.json({ status: 'Error', message: 'Version Control is not connected to a repository' }); | ||
} | ||
try { | ||
const versionControlService = Container.get(VersionControlService); | ||
const result = await versionControlService.pullWorkfolder({ | ||
force: req.body.force, | ||
variables: req.body.variables, | ||
userId: req.user.id, | ||
importAfterPull: true, | ||
}); | ||
if ((result as ImportResult)?.workflows) { | ||
return res.status(200).send(result as ImportResult); | ||
} else { | ||
return res.status(409).send(result); | ||
} | ||
} catch (error) { | ||
return res.status(400).send((error as { message: string }).message); | ||
} | ||
}, | ||
], | ||
}; |
This file contains 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
8 changes: 5 additions & 3 deletions
8
packages/cli/src/PublicApi/v1/shared/spec/responses/_index.yml
This file contains 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
NotFound: | ||
$ref: './notFound.yml' | ||
$ref: "./notFound.yml" | ||
Unauthorized: | ||
$ref: './unauthorized.yml' | ||
$ref: "./unauthorized.yml" | ||
BadRequest: | ||
$ref: './badRequest.yml' | ||
$ref: "./badRequest.yml" | ||
Conflict: | ||
$ref: "./conflict.yml" |
1 change: 1 addition & 0 deletions
1
packages/cli/src/PublicApi/v1/shared/spec/responses/conflict.yml
This file contains 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 @@ | ||
description: Conflict |
26 changes: 15 additions & 11 deletions
26
packages/cli/src/PublicApi/v1/shared/spec/schemas/_index.yml
This file contains 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 |
---|---|---|
@@ -1,22 +1,26 @@ | ||
Error: | ||
$ref: './error.yml' | ||
$ref: "./error.yml" | ||
Execution: | ||
$ref: './../../../handlers/executions/spec/schemas/execution.yml' | ||
$ref: "./../../../handlers/executions/spec/schemas/execution.yml" | ||
Node: | ||
$ref: './../../../handlers/workflows/spec/schemas/node.yml' | ||
$ref: "./../../../handlers/workflows/spec/schemas/node.yml" | ||
Tag: | ||
$ref: './../../../handlers/workflows/spec/schemas/tag.yml' | ||
$ref: "./../../../handlers/workflows/spec/schemas/tag.yml" | ||
Workflow: | ||
$ref: './../../../handlers/workflows/spec/schemas/workflow.yml' | ||
$ref: "./../../../handlers/workflows/spec/schemas/workflow.yml" | ||
WorkflowSettings: | ||
$ref: './../../../handlers/workflows/spec/schemas/workflowSettings.yml' | ||
$ref: "./../../../handlers/workflows/spec/schemas/workflowSettings.yml" | ||
ExecutionList: | ||
$ref: './../../../handlers/executions/spec/schemas/executionList.yml' | ||
$ref: "./../../../handlers/executions/spec/schemas/executionList.yml" | ||
WorkflowList: | ||
$ref: './../../../handlers/workflows/spec/schemas/workflowList.yml' | ||
$ref: "./../../../handlers/workflows/spec/schemas/workflowList.yml" | ||
Credential: | ||
$ref: './../../../handlers/credentials/spec/schemas/credential.yml' | ||
$ref: "./../../../handlers/credentials/spec/schemas/credential.yml" | ||
CredentialType: | ||
$ref: './../../../handlers/credentials/spec/schemas/credentialType.yml' | ||
$ref: "./../../../handlers/credentials/spec/schemas/credentialType.yml" | ||
Audit: | ||
$ref: './../../../handlers/audit/spec/schemas/audit.yml' | ||
$ref: "./../../../handlers/audit/spec/schemas/audit.yml" | ||
Pull: | ||
$ref: "./../../../handlers/versionControl/spec/schemas/pull.yml" | ||
ImportResult: | ||
$ref: "./../../../handlers/versionControl/spec/schemas/importResult.yml" |
This file contains 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 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 |
---|---|---|
@@ -1 +1,15 @@ | ||
export const VERSION_CONTROL_PREFERENCES_DB_KEY = 'features.versionControl'; | ||
export const VERSION_CONTROL_GIT_FOLDER = 'git'; | ||
export const VERSION_CONTROL_GIT_KEY_COMMENT = 'n8n deploy key'; | ||
export const VERSION_CONTROL_WORKFLOW_EXPORT_FOLDER = 'workflows'; | ||
export const VERSION_CONTROL_CREDENTIAL_EXPORT_FOLDER = 'credentials'; | ||
export const VERSION_CONTROL_VARIABLES_EXPORT_FILE = 'variables.json'; | ||
export const VERSION_CONTROL_TAGS_EXPORT_FILE = 'tags.json'; | ||
export const VERSION_CONTROL_SSH_FOLDER = 'ssh'; | ||
export const VERSION_CONTROL_SSH_KEY_NAME = 'key'; | ||
export const VERSION_CONTROL_DEFAULT_BRANCH = 'main'; | ||
export const VERSION_CONTROL_ORIGIN = 'origin'; | ||
export const VERSION_CONTROL_API_ROOT = 'version-control'; | ||
export const VERSION_CONTROL_README = ` | ||
# n8n Version Control | ||
`; |
10 changes: 5 additions & 5 deletions
10
...leware/versionControlEnabledMiddleware.ts → ...are/versionControlEnabledMiddleware.ee.ts
This file contains 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
9 changes: 9 additions & 0 deletions
9
packages/cli/src/environments/versionControl/types/exportResult.ts
This file contains 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,9 @@ | ||
export interface ExportResult { | ||
count: number; | ||
folder: string; | ||
files: Array<{ | ||
id: string; | ||
name: string; | ||
}>; | ||
removedFiles?: string[]; | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/cli/src/environments/versionControl/types/exportableCredential.ts
This file contains 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,8 @@ | ||
import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; | ||
|
||
export interface ExportableCredential { | ||
id: string; | ||
name: string; | ||
type: string; | ||
data: ICredentialDataDecryptedObject; | ||
} |
Oops, something went wrong.