n8n 1.113.0 → 1.113.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.tsbuildinfo +1 -1
- package/dist/environments.ee/source-control/source-control-resource-helper.d.ts +4 -0
- package/dist/environments.ee/source-control/source-control-resource-helper.js +21 -0
- package/dist/environments.ee/source-control/source-control-resource-helper.js.map +1 -0
- package/dist/environments.ee/source-control/source-control-status.service.ee.d.ts +79 -0
- package/dist/environments.ee/source-control/source-control-status.service.ee.js +439 -0
- package/dist/environments.ee/source-control/source-control-status.service.ee.js.map +1 -0
- package/dist/environments.ee/source-control/source-control.service.ee.d.ts +22 -40
- package/dist/environments.ee/source-control/source-control.service.ee.js +23 -428
- package/dist/environments.ee/source-control/source-control.service.ee.js.map +1 -1
- package/dist/modules/data-table/data-store.repository.js +7 -4
- package/dist/modules/data-table/data-store.repository.js.map +1 -1
- package/dist/webhooks/webhook-request-handler.js +26 -4
- package/dist/webhooks/webhook-request-handler.js.map +1 -1
- package/package.json +13 -13
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { IWorkflowToImport } from '../../interfaces';
|
|
2
1
|
import type { PullWorkFolderRequestDto, PushWorkFolderRequestDto, SourceControlledFile } from '@n8n/api-types';
|
|
3
2
|
import { Logger } from '@n8n/backend-common';
|
|
4
|
-
import { type
|
|
3
|
+
import { type User } from '@n8n/db';
|
|
5
4
|
import type { PushResult } from 'simple-git';
|
|
6
5
|
import { SourceControlExportService } from './source-control-export.service.ee';
|
|
7
6
|
import { SourceControlGitService } from './source-control-git.service.ee';
|
|
8
7
|
import { SourceControlImportService } from './source-control-import.service.ee';
|
|
9
8
|
import { SourceControlPreferencesService } from './source-control-preferences.service.ee';
|
|
9
|
+
import { SourceControlStatusService } from './source-control-status.service.ee';
|
|
10
10
|
import { SourceControlScopedService } from './source-control-scoped.service';
|
|
11
|
-
import type { StatusExportableCredential } from './types/exportable-credential';
|
|
12
|
-
import type { ExportableFolder } from './types/exportable-folders';
|
|
13
11
|
import type { ImportResult } from './types/import-result';
|
|
14
12
|
import type { SourceControlGetStatus } from './types/source-control-get-status';
|
|
15
13
|
import type { SourceControlPreferences } from './types/source-control-preferences';
|
|
16
|
-
import type { SourceControlWorkflowVersionId } from './types/source-control-workflow-version-id';
|
|
17
14
|
import { EventService } from '../../events/event.service';
|
|
15
|
+
import { IWorkflowToImport } from '../../interfaces';
|
|
18
16
|
export declare class SourceControlService {
|
|
19
17
|
private readonly logger;
|
|
20
18
|
private gitService;
|
|
@@ -22,13 +20,12 @@ export declare class SourceControlService {
|
|
|
22
20
|
private sourceControlExportService;
|
|
23
21
|
private sourceControlImportService;
|
|
24
22
|
private sourceControlScopedService;
|
|
25
|
-
private tagRepository;
|
|
26
|
-
private folderRepository;
|
|
27
23
|
private readonly eventService;
|
|
24
|
+
private readonly sourceControlStatusService;
|
|
28
25
|
private sshKeyName;
|
|
29
26
|
private sshFolder;
|
|
30
27
|
private gitFolder;
|
|
31
|
-
constructor(logger: Logger, gitService: SourceControlGitService, sourceControlPreferencesService: SourceControlPreferencesService, sourceControlExportService: SourceControlExportService, sourceControlImportService: SourceControlImportService, sourceControlScopedService: SourceControlScopedService,
|
|
28
|
+
constructor(logger: Logger, gitService: SourceControlGitService, sourceControlPreferencesService: SourceControlPreferencesService, sourceControlExportService: SourceControlExportService, sourceControlImportService: SourceControlImportService, sourceControlScopedService: SourceControlScopedService, eventService: EventService, sourceControlStatusService: SourceControlStatusService);
|
|
32
29
|
init(): Promise<void>;
|
|
33
30
|
private initGitService;
|
|
34
31
|
sanityCheck(): Promise<void>;
|
|
@@ -54,16 +51,6 @@ export declare class SourceControlService {
|
|
|
54
51
|
statusResult: SourceControlledFile[];
|
|
55
52
|
}>;
|
|
56
53
|
private getConflicts;
|
|
57
|
-
private getWorkflowsToImport;
|
|
58
|
-
private getWorkflowsToDelete;
|
|
59
|
-
private getCredentialsToImport;
|
|
60
|
-
private getCredentialsToDelete;
|
|
61
|
-
private getTagsToImport;
|
|
62
|
-
private getTagsToDelete;
|
|
63
|
-
private getVariablesToImport;
|
|
64
|
-
private getFoldersToImport;
|
|
65
|
-
private getFoldersToDelete;
|
|
66
|
-
private getVariablesToDelete;
|
|
67
54
|
pullWorkfolder(user: User, options: PullWorkFolderRequestDto): Promise<{
|
|
68
55
|
statusCode: number;
|
|
69
56
|
statusResult: SourceControlledFile[];
|
|
@@ -84,25 +71,25 @@ export declare class SourceControlService {
|
|
|
84
71
|
projectName: string;
|
|
85
72
|
} | undefined;
|
|
86
73
|
}[] | {
|
|
87
|
-
wfRemoteVersionIds: SourceControlWorkflowVersionId[];
|
|
88
|
-
wfLocalVersionIds: SourceControlWorkflowVersionId[];
|
|
89
|
-
wfMissingInLocal: SourceControlWorkflowVersionId[];
|
|
90
|
-
wfMissingInRemote: SourceControlWorkflowVersionId[];
|
|
91
|
-
wfModifiedInEither: SourceControlWorkflowVersionId[];
|
|
92
|
-
credMissingInLocal: StatusExportableCredential[];
|
|
93
|
-
credMissingInRemote: StatusExportableCredential[];
|
|
94
|
-
credModifiedInEither: StatusExportableCredential[];
|
|
95
|
-
varMissingInLocal: Variables[];
|
|
96
|
-
varMissingInRemote: Variables[];
|
|
97
|
-
varModifiedInEither: Variables[];
|
|
98
|
-
tagsMissingInLocal: TagEntity[];
|
|
99
|
-
tagsMissingInRemote: TagEntity[];
|
|
100
|
-
tagsModifiedInEither: TagEntity[];
|
|
74
|
+
wfRemoteVersionIds: import("./types/source-control-workflow-version-id").SourceControlWorkflowVersionId[];
|
|
75
|
+
wfLocalVersionIds: import("./types/source-control-workflow-version-id").SourceControlWorkflowVersionId[];
|
|
76
|
+
wfMissingInLocal: import("./types/source-control-workflow-version-id").SourceControlWorkflowVersionId[];
|
|
77
|
+
wfMissingInRemote: import("./types/source-control-workflow-version-id").SourceControlWorkflowVersionId[];
|
|
78
|
+
wfModifiedInEither: import("./types/source-control-workflow-version-id").SourceControlWorkflowVersionId[];
|
|
79
|
+
credMissingInLocal: import("./types/exportable-credential").StatusExportableCredential[];
|
|
80
|
+
credMissingInRemote: import("./types/exportable-credential").StatusExportableCredential[];
|
|
81
|
+
credModifiedInEither: import("./types/exportable-credential").StatusExportableCredential[];
|
|
82
|
+
varMissingInLocal: import("@n8n/db").Variables[];
|
|
83
|
+
varMissingInRemote: import("@n8n/db").Variables[];
|
|
84
|
+
varModifiedInEither: import("@n8n/db").Variables[];
|
|
85
|
+
tagsMissingInLocal: import("@n8n/db").TagEntity[];
|
|
86
|
+
tagsMissingInRemote: import("@n8n/db").TagEntity[];
|
|
87
|
+
tagsModifiedInEither: import("@n8n/db").TagEntity[];
|
|
101
88
|
mappingsMissingInLocal: import("@n8n/db").WorkflowTagMapping[];
|
|
102
89
|
mappingsMissingInRemote: import("@n8n/db").WorkflowTagMapping[];
|
|
103
|
-
foldersMissingInLocal: ExportableFolder[];
|
|
104
|
-
foldersMissingInRemote: ExportableFolder[];
|
|
105
|
-
foldersModifiedInEither: ExportableFolder[];
|
|
90
|
+
foldersMissingInLocal: import("./types/exportable-folders").ExportableFolder[];
|
|
91
|
+
foldersMissingInRemote: import("./types/exportable-folders").ExportableFolder[];
|
|
92
|
+
foldersModifiedInEither: import("./types/exportable-folders").ExportableFolder[];
|
|
106
93
|
sourceControlledFiles: {
|
|
107
94
|
type: "workflow" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
108
95
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
@@ -120,11 +107,6 @@ export declare class SourceControlService {
|
|
|
120
107
|
} | undefined;
|
|
121
108
|
}[];
|
|
122
109
|
}>;
|
|
123
|
-
private getStatusWorkflows;
|
|
124
|
-
private getStatusCredentials;
|
|
125
|
-
private getStatusVariables;
|
|
126
|
-
private getStatusTagsMappings;
|
|
127
|
-
private getStatusFoldersMapping;
|
|
128
110
|
setGitUserDetails(name?: string, email?: string): Promise<void>;
|
|
129
111
|
getRemoteFileEntity({ user, type, id, commit, }: {
|
|
130
112
|
user: User;
|
|
@@ -14,9 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SourceControlService = void 0;
|
|
16
16
|
const backend_common_1 = require("@n8n/backend-common");
|
|
17
|
-
const db_1 = require("@n8n/db");
|
|
18
17
|
const di_1 = require("@n8n/di");
|
|
19
|
-
const permissions_1 = require("@n8n/permissions");
|
|
20
18
|
const fs_1 = require("fs");
|
|
21
19
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
22
20
|
const path_1 = __importDefault(require("path"));
|
|
@@ -26,22 +24,23 @@ const source_control_git_service_ee_1 = require("./source-control-git.service.ee
|
|
|
26
24
|
const source_control_helper_ee_1 = require("./source-control-helper.ee");
|
|
27
25
|
const source_control_import_service_ee_1 = require("./source-control-import.service.ee");
|
|
28
26
|
const source_control_preferences_service_ee_1 = require("./source-control-preferences.service.ee");
|
|
27
|
+
const source_control_status_service_ee_1 = require("./source-control-status.service.ee");
|
|
29
28
|
const source_control_scoped_service_1 = require("./source-control-scoped.service");
|
|
30
29
|
const source_control_context_1 = require("./types/source-control-context");
|
|
31
30
|
const bad_request_error_1 = require("../../errors/response-errors/bad-request.error");
|
|
32
31
|
const forbidden_error_1 = require("../../errors/response-errors/forbidden.error");
|
|
33
32
|
const event_service_1 = require("../../events/event.service");
|
|
33
|
+
const source_control_resource_helper_1 = require("./source-control-resource-helper");
|
|
34
34
|
let SourceControlService = class SourceControlService {
|
|
35
|
-
constructor(logger, gitService, sourceControlPreferencesService, sourceControlExportService, sourceControlImportService, sourceControlScopedService,
|
|
35
|
+
constructor(logger, gitService, sourceControlPreferencesService, sourceControlExportService, sourceControlImportService, sourceControlScopedService, eventService, sourceControlStatusService) {
|
|
36
36
|
this.logger = logger;
|
|
37
37
|
this.gitService = gitService;
|
|
38
38
|
this.sourceControlPreferencesService = sourceControlPreferencesService;
|
|
39
39
|
this.sourceControlExportService = sourceControlExportService;
|
|
40
40
|
this.sourceControlImportService = sourceControlImportService;
|
|
41
41
|
this.sourceControlScopedService = sourceControlScopedService;
|
|
42
|
-
this.tagRepository = tagRepository;
|
|
43
|
-
this.folderRepository = folderRepository;
|
|
44
42
|
this.eventService = eventService;
|
|
43
|
+
this.sourceControlStatusService = sourceControlStatusService;
|
|
45
44
|
const { gitFolder, sshFolder, sshKeyName } = sourceControlPreferencesService;
|
|
46
45
|
this.gitFolder = gitFolder;
|
|
47
46
|
this.sshFolder = sshFolder;
|
|
@@ -190,7 +189,7 @@ let SourceControlService = class SourceControlService {
|
|
|
190
189
|
file: normalizedPath,
|
|
191
190
|
};
|
|
192
191
|
});
|
|
193
|
-
const allowedResources = (await this.getStatus(user, {
|
|
192
|
+
const allowedResources = (await this.sourceControlStatusService.getStatus(user, {
|
|
194
193
|
direction: 'push',
|
|
195
194
|
verbose: false,
|
|
196
195
|
preferLocalVersion: true,
|
|
@@ -228,9 +227,9 @@ let SourceControlService = class SourceControlService {
|
|
|
228
227
|
}
|
|
229
228
|
});
|
|
230
229
|
this.sourceControlExportService.rmFilesFromExportFolder(filesToBeDeleted);
|
|
231
|
-
const workflowsToBeExported =
|
|
230
|
+
const workflowsToBeExported = (0, source_control_resource_helper_1.getNonDeletedResources)(filesToPush, 'workflow');
|
|
232
231
|
await this.sourceControlExportService.exportWorkflowsToWorkFolder(workflowsToBeExported);
|
|
233
|
-
const credentialsToBeExported =
|
|
232
|
+
const credentialsToBeExported = (0, source_control_resource_helper_1.getNonDeletedResources)(filesToPush, 'credential');
|
|
234
233
|
const credentialExportResult = await this.sourceControlExportService.exportCredentialsToWorkFolder(credentialsToBeExported);
|
|
235
234
|
if (credentialExportResult.missingIds && credentialExportResult.missingIds.length > 0) {
|
|
236
235
|
credentialExportResult.missingIds.forEach((id) => {
|
|
@@ -240,12 +239,12 @@ let SourceControlService = class SourceControlService {
|
|
|
240
239
|
}
|
|
241
240
|
filesToBePushed.add((0, source_control_helper_ee_1.getTagsPath)(this.gitFolder));
|
|
242
241
|
await this.sourceControlExportService.exportTagsToWorkFolder(context);
|
|
243
|
-
const folderChanges =
|
|
242
|
+
const folderChanges = (0, source_control_resource_helper_1.filterByType)(filesToPush, 'folders')[0];
|
|
244
243
|
if (folderChanges) {
|
|
245
244
|
filesToBePushed.add(folderChanges.file);
|
|
246
245
|
await this.sourceControlExportService.exportFoldersToWorkFolder(context);
|
|
247
246
|
}
|
|
248
|
-
const variablesChanges =
|
|
247
|
+
const variablesChanges = (0, source_control_resource_helper_1.filterByType)(filesToPush, 'variables')[0];
|
|
249
248
|
if (variablesChanges) {
|
|
250
249
|
filesToBePushed.add(variablesChanges.file);
|
|
251
250
|
await this.sourceControlExportService.exportVariablesToWorkFolder();
|
|
@@ -267,39 +266,9 @@ let SourceControlService = class SourceControlService {
|
|
|
267
266
|
getConflicts(files) {
|
|
268
267
|
return files.filter((file) => file.conflict || file.status === 'modified');
|
|
269
268
|
}
|
|
270
|
-
getWorkflowsToImport(files) {
|
|
271
|
-
return files.filter((e) => e.type === 'workflow' && e.status !== 'deleted');
|
|
272
|
-
}
|
|
273
|
-
getWorkflowsToDelete(files) {
|
|
274
|
-
return files.filter((e) => e.type === 'workflow' && e.status === 'deleted');
|
|
275
|
-
}
|
|
276
|
-
getCredentialsToImport(files) {
|
|
277
|
-
return files.filter((e) => e.type === 'credential' && e.status !== 'deleted');
|
|
278
|
-
}
|
|
279
|
-
getCredentialsToDelete(files) {
|
|
280
|
-
return files.filter((e) => e.type === 'credential' && e.status === 'deleted');
|
|
281
|
-
}
|
|
282
|
-
getTagsToImport(files) {
|
|
283
|
-
return files.find((e) => e.type === 'tags' && e.status !== 'deleted');
|
|
284
|
-
}
|
|
285
|
-
getTagsToDelete(files) {
|
|
286
|
-
return files.filter((e) => e.type === 'tags' && e.status === 'deleted');
|
|
287
|
-
}
|
|
288
|
-
getVariablesToImport(files) {
|
|
289
|
-
return files.find((e) => e.type === 'variables' && e.status !== 'deleted');
|
|
290
|
-
}
|
|
291
|
-
getFoldersToImport(files) {
|
|
292
|
-
return files.find((e) => e.type === 'folders' && e.status !== 'deleted');
|
|
293
|
-
}
|
|
294
|
-
getFoldersToDelete(files) {
|
|
295
|
-
return files.filter((e) => e.type === 'folders' && e.status === 'deleted');
|
|
296
|
-
}
|
|
297
|
-
getVariablesToDelete(files) {
|
|
298
|
-
return files.filter((e) => e.type === 'variables' && e.status === 'deleted');
|
|
299
|
-
}
|
|
300
269
|
async pullWorkfolder(user, options) {
|
|
301
270
|
await this.sanityCheck();
|
|
302
|
-
const statusResult = (await this.getStatus(user, {
|
|
271
|
+
const statusResult = (await this.sourceControlStatusService.getStatus(user, {
|
|
303
272
|
direction: 'pull',
|
|
304
273
|
verbose: false,
|
|
305
274
|
preferLocalVersion: false,
|
|
@@ -314,31 +283,31 @@ let SourceControlService = class SourceControlService {
|
|
|
314
283
|
};
|
|
315
284
|
}
|
|
316
285
|
}
|
|
317
|
-
const foldersToBeImported =
|
|
286
|
+
const foldersToBeImported = (0, source_control_resource_helper_1.getNonDeletedResources)(statusResult, 'folders')[0];
|
|
318
287
|
if (foldersToBeImported) {
|
|
319
288
|
await this.sourceControlImportService.importFoldersFromWorkFolder(user, foldersToBeImported);
|
|
320
289
|
}
|
|
321
|
-
const workflowsToBeImported =
|
|
290
|
+
const workflowsToBeImported = (0, source_control_resource_helper_1.getNonDeletedResources)(statusResult, 'workflow');
|
|
322
291
|
await this.sourceControlImportService.importWorkflowFromWorkFolder(workflowsToBeImported, user.id);
|
|
323
|
-
const workflowsToBeDeleted =
|
|
292
|
+
const workflowsToBeDeleted = (0, source_control_resource_helper_1.getDeletedResources)(statusResult, 'workflow');
|
|
324
293
|
await this.sourceControlImportService.deleteWorkflowsNotInWorkfolder(user, workflowsToBeDeleted);
|
|
325
|
-
const credentialsToBeImported =
|
|
294
|
+
const credentialsToBeImported = (0, source_control_resource_helper_1.getNonDeletedResources)(statusResult, 'credential');
|
|
326
295
|
await this.sourceControlImportService.importCredentialsFromWorkFolder(credentialsToBeImported, user.id);
|
|
327
|
-
const credentialsToBeDeleted =
|
|
296
|
+
const credentialsToBeDeleted = (0, source_control_resource_helper_1.getDeletedResources)(statusResult, 'credential');
|
|
328
297
|
await this.sourceControlImportService.deleteCredentialsNotInWorkfolder(user, credentialsToBeDeleted);
|
|
329
|
-
const tagsToBeImported =
|
|
298
|
+
const tagsToBeImported = (0, source_control_resource_helper_1.getNonDeletedResources)(statusResult, 'tags')[0];
|
|
330
299
|
if (tagsToBeImported) {
|
|
331
300
|
await this.sourceControlImportService.importTagsFromWorkFolder(tagsToBeImported);
|
|
332
301
|
}
|
|
333
|
-
const tagsToBeDeleted =
|
|
302
|
+
const tagsToBeDeleted = (0, source_control_resource_helper_1.getDeletedResources)(statusResult, 'tags');
|
|
334
303
|
await this.sourceControlImportService.deleteTagsNotInWorkfolder(tagsToBeDeleted);
|
|
335
|
-
const variablesToBeImported =
|
|
304
|
+
const variablesToBeImported = (0, source_control_resource_helper_1.getNonDeletedResources)(statusResult, 'variables')[0];
|
|
336
305
|
if (variablesToBeImported) {
|
|
337
306
|
await this.sourceControlImportService.importVariablesFromWorkFolder(variablesToBeImported);
|
|
338
307
|
}
|
|
339
|
-
const variablesToBeDeleted =
|
|
308
|
+
const variablesToBeDeleted = (0, source_control_resource_helper_1.getDeletedResources)(statusResult, 'variables');
|
|
340
309
|
await this.sourceControlImportService.deleteVariablesNotInWorkfolder(variablesToBeDeleted);
|
|
341
|
-
const foldersToBeDeleted =
|
|
310
|
+
const foldersToBeDeleted = (0, source_control_resource_helper_1.getDeletedResources)(statusResult, 'folders');
|
|
342
311
|
await this.sourceControlImportService.deleteFoldersNotInWorkfolder(foldersToBeDeleted);
|
|
343
312
|
this.eventService.emit('source-control-user-finished-pull-ui', (0, source_control_helper_ee_1.getTrackingInformationFromPullResult)(user.id, statusResult));
|
|
344
313
|
return {
|
|
@@ -348,380 +317,7 @@ let SourceControlService = class SourceControlService {
|
|
|
348
317
|
}
|
|
349
318
|
async getStatus(user, options) {
|
|
350
319
|
await this.sanityCheck();
|
|
351
|
-
|
|
352
|
-
if (options.direction === 'pull' && !(0, permissions_1.hasGlobalScope)(user, 'sourceControl:pull')) {
|
|
353
|
-
throw new forbidden_error_1.ForbiddenError('You do not have permission to pull from source control');
|
|
354
|
-
}
|
|
355
|
-
const sourceControlledFiles = [];
|
|
356
|
-
await this.resetWorkfolder();
|
|
357
|
-
const { wfRemoteVersionIds, wfLocalVersionIds, wfMissingInLocal, wfMissingInRemote, wfModifiedInEither, } = await this.getStatusWorkflows(options, context, sourceControlledFiles);
|
|
358
|
-
const { credMissingInLocal, credMissingInRemote, credModifiedInEither } = await this.getStatusCredentials(options, context, sourceControlledFiles);
|
|
359
|
-
const { varMissingInLocal, varMissingInRemote, varModifiedInEither } = await this.getStatusVariables(options, sourceControlledFiles);
|
|
360
|
-
const { tagsMissingInLocal, tagsMissingInRemote, tagsModifiedInEither, mappingsMissingInLocal, mappingsMissingInRemote, } = await this.getStatusTagsMappings(options, context, sourceControlledFiles);
|
|
361
|
-
const { foldersMissingInLocal, foldersMissingInRemote, foldersModifiedInEither } = await this.getStatusFoldersMapping(options, context, sourceControlledFiles);
|
|
362
|
-
if (options.direction === 'push') {
|
|
363
|
-
this.eventService.emit('source-control-user-started-push-ui', (0, source_control_helper_ee_1.getTrackingInformationFromPrePushResult)(user.id, sourceControlledFiles));
|
|
364
|
-
}
|
|
365
|
-
else if (options.direction === 'pull') {
|
|
366
|
-
this.eventService.emit('source-control-user-started-pull-ui', (0, source_control_helper_ee_1.getTrackingInformationFromPullResult)(user.id, sourceControlledFiles));
|
|
367
|
-
}
|
|
368
|
-
if (options?.verbose) {
|
|
369
|
-
return {
|
|
370
|
-
wfRemoteVersionIds,
|
|
371
|
-
wfLocalVersionIds,
|
|
372
|
-
wfMissingInLocal,
|
|
373
|
-
wfMissingInRemote,
|
|
374
|
-
wfModifiedInEither,
|
|
375
|
-
credMissingInLocal,
|
|
376
|
-
credMissingInRemote,
|
|
377
|
-
credModifiedInEither,
|
|
378
|
-
varMissingInLocal,
|
|
379
|
-
varMissingInRemote,
|
|
380
|
-
varModifiedInEither,
|
|
381
|
-
tagsMissingInLocal,
|
|
382
|
-
tagsMissingInRemote,
|
|
383
|
-
tagsModifiedInEither,
|
|
384
|
-
mappingsMissingInLocal,
|
|
385
|
-
mappingsMissingInRemote,
|
|
386
|
-
foldersMissingInLocal,
|
|
387
|
-
foldersMissingInRemote,
|
|
388
|
-
foldersModifiedInEither,
|
|
389
|
-
sourceControlledFiles,
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
return sourceControlledFiles;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
async getStatusWorkflows(options, context, sourceControlledFiles) {
|
|
397
|
-
const wfRemoteVersionIds = await this.sourceControlImportService.getRemoteVersionIdsFromFiles(context);
|
|
398
|
-
const wfLocalVersionIds = await this.sourceControlImportService.getLocalVersionIdsFromDb(context);
|
|
399
|
-
let outOfScopeWF = [];
|
|
400
|
-
if (!context.hasAccessToAllProjects()) {
|
|
401
|
-
outOfScopeWF = await this.sourceControlImportService.getAllLocalVersionIdsFromDb();
|
|
402
|
-
outOfScopeWF = outOfScopeWF.filter((wf) => !wfLocalVersionIds.some((local) => local.id === wf.id));
|
|
403
|
-
}
|
|
404
|
-
const wfMissingInLocal = wfRemoteVersionIds
|
|
405
|
-
.filter((remote) => wfLocalVersionIds.findIndex((local) => local.id === remote.id) === -1)
|
|
406
|
-
.filter((remote) => !outOfScopeWF.some((outOfScope) => outOfScope.id === remote.id));
|
|
407
|
-
const wfMissingInRemote = wfLocalVersionIds.filter((local) => wfRemoteVersionIds.findIndex((remote) => remote.id === local.id) === -1);
|
|
408
|
-
const wfModifiedInEither = [];
|
|
409
|
-
wfLocalVersionIds.forEach((localWorkflow) => {
|
|
410
|
-
const remoteWorkflowWithSameId = wfRemoteVersionIds.find((removeWorkflow) => removeWorkflow.id === localWorkflow.id);
|
|
411
|
-
if (!remoteWorkflowWithSameId) {
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
if ((0, source_control_helper_ee_1.isWorkflowModified)(localWorkflow, remoteWorkflowWithSameId)) {
|
|
415
|
-
let name = (options?.preferLocalVersion ? localWorkflow?.name : remoteWorkflowWithSameId?.name) ??
|
|
416
|
-
'Workflow';
|
|
417
|
-
if (localWorkflow.name &&
|
|
418
|
-
remoteWorkflowWithSameId?.name &&
|
|
419
|
-
localWorkflow.name !== remoteWorkflowWithSameId.name) {
|
|
420
|
-
name = options?.preferLocalVersion
|
|
421
|
-
? `${localWorkflow.name} (Remote: ${remoteWorkflowWithSameId.name})`
|
|
422
|
-
: (name = `${remoteWorkflowWithSameId.name} (Local: ${localWorkflow.name})`);
|
|
423
|
-
}
|
|
424
|
-
wfModifiedInEither.push({
|
|
425
|
-
...localWorkflow,
|
|
426
|
-
name,
|
|
427
|
-
versionId: options.preferLocalVersion
|
|
428
|
-
? localWorkflow.versionId
|
|
429
|
-
: remoteWorkflowWithSameId.versionId,
|
|
430
|
-
localId: localWorkflow.versionId,
|
|
431
|
-
remoteId: remoteWorkflowWithSameId.versionId,
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
wfMissingInLocal.forEach((item) => {
|
|
436
|
-
sourceControlledFiles.push({
|
|
437
|
-
id: item.id,
|
|
438
|
-
name: item.name ?? 'Workflow',
|
|
439
|
-
type: 'workflow',
|
|
440
|
-
status: options.direction === 'push' ? 'deleted' : 'created',
|
|
441
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
442
|
-
conflict: false,
|
|
443
|
-
file: item.filename,
|
|
444
|
-
updatedAt: item.updatedAt ?? new Date().toISOString(),
|
|
445
|
-
owner: item.owner,
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
wfMissingInRemote.forEach((item) => {
|
|
449
|
-
sourceControlledFiles.push({
|
|
450
|
-
id: item.id,
|
|
451
|
-
name: item.name ?? 'Workflow',
|
|
452
|
-
type: 'workflow',
|
|
453
|
-
status: options.direction === 'push' ? 'created' : 'deleted',
|
|
454
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
455
|
-
conflict: options.direction === 'push' ? false : true,
|
|
456
|
-
file: item.filename,
|
|
457
|
-
updatedAt: item.updatedAt ?? new Date().toISOString(),
|
|
458
|
-
owner: item.owner,
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
wfModifiedInEither.forEach((item) => {
|
|
462
|
-
sourceControlledFiles.push({
|
|
463
|
-
id: item.id,
|
|
464
|
-
name: item.name ?? 'Workflow',
|
|
465
|
-
type: 'workflow',
|
|
466
|
-
status: 'modified',
|
|
467
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
468
|
-
conflict: true,
|
|
469
|
-
file: item.filename,
|
|
470
|
-
updatedAt: item.updatedAt ?? new Date().toISOString(),
|
|
471
|
-
owner: item.owner,
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
return {
|
|
475
|
-
wfRemoteVersionIds,
|
|
476
|
-
wfLocalVersionIds,
|
|
477
|
-
wfMissingInLocal,
|
|
478
|
-
wfMissingInRemote,
|
|
479
|
-
wfModifiedInEither,
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
async getStatusCredentials(options, context, sourceControlledFiles) {
|
|
483
|
-
const credRemoteIds = await this.sourceControlImportService.getRemoteCredentialsFromFiles(context);
|
|
484
|
-
const credLocalIds = await this.sourceControlImportService.getLocalCredentialsFromDb(context);
|
|
485
|
-
const credMissingInLocal = credRemoteIds.filter((remote) => credLocalIds.findIndex((local) => local.id === remote.id) === -1);
|
|
486
|
-
const credMissingInRemote = credLocalIds.filter((local) => credRemoteIds.findIndex((remote) => remote.id === local.id) === -1);
|
|
487
|
-
const credModifiedInEither = [];
|
|
488
|
-
credLocalIds.forEach((local) => {
|
|
489
|
-
const mismatchingCreds = credRemoteIds.find((remote) => {
|
|
490
|
-
return remote.id === local.id && (remote.name !== local.name || remote.type !== local.type);
|
|
491
|
-
});
|
|
492
|
-
if (mismatchingCreds) {
|
|
493
|
-
credModifiedInEither.push({
|
|
494
|
-
...local,
|
|
495
|
-
name: options?.preferLocalVersion ? local.name : mismatchingCreds.name,
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
credMissingInLocal.forEach((item) => {
|
|
500
|
-
sourceControlledFiles.push({
|
|
501
|
-
id: item.id,
|
|
502
|
-
name: item.name ?? 'Credential',
|
|
503
|
-
type: 'credential',
|
|
504
|
-
status: options.direction === 'push' ? 'deleted' : 'created',
|
|
505
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
506
|
-
conflict: false,
|
|
507
|
-
file: item.filename,
|
|
508
|
-
updatedAt: new Date().toISOString(),
|
|
509
|
-
owner: item.ownedBy,
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
credMissingInRemote.forEach((item) => {
|
|
513
|
-
sourceControlledFiles.push({
|
|
514
|
-
id: item.id,
|
|
515
|
-
name: item.name ?? 'Credential',
|
|
516
|
-
type: 'credential',
|
|
517
|
-
status: options.direction === 'push' ? 'created' : 'deleted',
|
|
518
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
519
|
-
conflict: options.direction === 'push' ? false : true,
|
|
520
|
-
file: item.filename,
|
|
521
|
-
updatedAt: new Date().toISOString(),
|
|
522
|
-
owner: item.ownedBy,
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
credModifiedInEither.forEach((item) => {
|
|
526
|
-
sourceControlledFiles.push({
|
|
527
|
-
id: item.id,
|
|
528
|
-
name: item.name ?? 'Credential',
|
|
529
|
-
type: 'credential',
|
|
530
|
-
status: 'modified',
|
|
531
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
532
|
-
conflict: true,
|
|
533
|
-
file: item.filename,
|
|
534
|
-
updatedAt: new Date().toISOString(),
|
|
535
|
-
owner: item.ownedBy,
|
|
536
|
-
});
|
|
537
|
-
});
|
|
538
|
-
return {
|
|
539
|
-
credMissingInLocal,
|
|
540
|
-
credMissingInRemote,
|
|
541
|
-
credModifiedInEither,
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
async getStatusVariables(options, sourceControlledFiles) {
|
|
545
|
-
const varRemoteIds = await this.sourceControlImportService.getRemoteVariablesFromFile();
|
|
546
|
-
const varLocalIds = await this.sourceControlImportService.getLocalVariablesFromDb();
|
|
547
|
-
const varMissingInLocal = varRemoteIds.filter((remote) => varLocalIds.findIndex((local) => local.id === remote.id) === -1);
|
|
548
|
-
const varMissingInRemote = varLocalIds.filter((local) => varRemoteIds.findIndex((remote) => remote.id === local.id) === -1);
|
|
549
|
-
const varModifiedInEither = [];
|
|
550
|
-
varLocalIds.forEach((local) => {
|
|
551
|
-
const mismatchingIds = varRemoteIds.find((remote) => (remote.id === local.id && remote.key !== local.key) ||
|
|
552
|
-
(remote.id !== local.id && remote.key === local.key));
|
|
553
|
-
if (mismatchingIds) {
|
|
554
|
-
varModifiedInEither.push(options.preferLocalVersion ? local : mismatchingIds);
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
varMissingInLocal.forEach((item) => {
|
|
558
|
-
sourceControlledFiles.push({
|
|
559
|
-
id: item.id,
|
|
560
|
-
name: item.key,
|
|
561
|
-
type: 'variables',
|
|
562
|
-
status: options.direction === 'push' ? 'deleted' : 'created',
|
|
563
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
564
|
-
conflict: false,
|
|
565
|
-
file: (0, source_control_helper_ee_1.getVariablesPath)(this.gitFolder),
|
|
566
|
-
updatedAt: new Date().toISOString(),
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
varMissingInRemote.forEach((item) => {
|
|
570
|
-
sourceControlledFiles.push({
|
|
571
|
-
id: item.id,
|
|
572
|
-
name: item.key,
|
|
573
|
-
type: 'variables',
|
|
574
|
-
status: options.direction === 'push' ? 'created' : 'deleted',
|
|
575
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
576
|
-
conflict: options.direction === 'push' ? false : true,
|
|
577
|
-
file: (0, source_control_helper_ee_1.getVariablesPath)(this.gitFolder),
|
|
578
|
-
updatedAt: new Date().toISOString(),
|
|
579
|
-
});
|
|
580
|
-
});
|
|
581
|
-
varModifiedInEither.forEach((item) => {
|
|
582
|
-
sourceControlledFiles.push({
|
|
583
|
-
id: item.id,
|
|
584
|
-
name: item.key,
|
|
585
|
-
type: 'variables',
|
|
586
|
-
status: 'modified',
|
|
587
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
588
|
-
conflict: true,
|
|
589
|
-
file: (0, source_control_helper_ee_1.getVariablesPath)(this.gitFolder),
|
|
590
|
-
updatedAt: new Date().toISOString(),
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
return {
|
|
594
|
-
varMissingInLocal,
|
|
595
|
-
varMissingInRemote,
|
|
596
|
-
varModifiedInEither,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
async getStatusTagsMappings(options, context, sourceControlledFiles) {
|
|
600
|
-
const lastUpdatedTag = await this.tagRepository.find({
|
|
601
|
-
order: { updatedAt: 'DESC' },
|
|
602
|
-
take: 1,
|
|
603
|
-
select: ['updatedAt'],
|
|
604
|
-
});
|
|
605
|
-
const lastUpdatedDate = lastUpdatedTag[0]?.updatedAt ?? new Date();
|
|
606
|
-
const tagMappingsRemote = await this.sourceControlImportService.getRemoteTagsAndMappingsFromFile(context);
|
|
607
|
-
const tagMappingsLocal = await this.sourceControlImportService.getLocalTagsAndMappingsFromDb(context);
|
|
608
|
-
const tagsMissingInLocal = tagMappingsRemote.tags.filter((remote) => tagMappingsLocal.tags.findIndex((local) => local.id === remote.id) === -1);
|
|
609
|
-
const tagsMissingInRemote = tagMappingsLocal.tags.filter((local) => tagMappingsRemote.tags.findIndex((remote) => remote.id === local.id) === -1);
|
|
610
|
-
const tagsModifiedInEither = [];
|
|
611
|
-
tagMappingsLocal.tags.forEach((local) => {
|
|
612
|
-
const mismatchingIds = tagMappingsRemote.tags.find((remote) => remote.id === local.id && remote.name !== local.name);
|
|
613
|
-
if (!mismatchingIds) {
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
tagsModifiedInEither.push(options.preferLocalVersion ? local : mismatchingIds);
|
|
617
|
-
});
|
|
618
|
-
const mappingsMissingInLocal = tagMappingsRemote.mappings.filter((remote) => tagMappingsLocal.mappings.findIndex((local) => local.tagId === remote.tagId && local.workflowId === remote.workflowId) === -1);
|
|
619
|
-
const mappingsMissingInRemote = tagMappingsLocal.mappings.filter((local) => tagMappingsRemote.mappings.findIndex((remote) => remote.tagId === local.tagId && remote.workflowId === remote.workflowId) === -1);
|
|
620
|
-
tagsMissingInLocal.forEach((item) => {
|
|
621
|
-
sourceControlledFiles.push({
|
|
622
|
-
id: item.id,
|
|
623
|
-
name: item.name,
|
|
624
|
-
type: 'tags',
|
|
625
|
-
status: options.direction === 'push' ? 'deleted' : 'created',
|
|
626
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
627
|
-
conflict: false,
|
|
628
|
-
file: (0, source_control_helper_ee_1.getTagsPath)(this.gitFolder),
|
|
629
|
-
updatedAt: lastUpdatedDate.toISOString(),
|
|
630
|
-
});
|
|
631
|
-
});
|
|
632
|
-
tagsMissingInRemote.forEach((item) => {
|
|
633
|
-
sourceControlledFiles.push({
|
|
634
|
-
id: item.id,
|
|
635
|
-
name: item.name,
|
|
636
|
-
type: 'tags',
|
|
637
|
-
status: options.direction === 'push' ? 'created' : 'deleted',
|
|
638
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
639
|
-
conflict: options.direction === 'push' ? false : true,
|
|
640
|
-
file: (0, source_control_helper_ee_1.getTagsPath)(this.gitFolder),
|
|
641
|
-
updatedAt: lastUpdatedDate.toISOString(),
|
|
642
|
-
});
|
|
643
|
-
});
|
|
644
|
-
tagsModifiedInEither.forEach((item) => {
|
|
645
|
-
sourceControlledFiles.push({
|
|
646
|
-
id: item.id,
|
|
647
|
-
name: item.name,
|
|
648
|
-
type: 'tags',
|
|
649
|
-
status: 'modified',
|
|
650
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
651
|
-
conflict: true,
|
|
652
|
-
file: (0, source_control_helper_ee_1.getTagsPath)(this.gitFolder),
|
|
653
|
-
updatedAt: lastUpdatedDate.toISOString(),
|
|
654
|
-
});
|
|
655
|
-
});
|
|
656
|
-
return {
|
|
657
|
-
tagsMissingInLocal,
|
|
658
|
-
tagsMissingInRemote,
|
|
659
|
-
tagsModifiedInEither,
|
|
660
|
-
mappingsMissingInLocal,
|
|
661
|
-
mappingsMissingInRemote,
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
async getStatusFoldersMapping(options, context, sourceControlledFiles) {
|
|
665
|
-
const lastUpdatedFolder = await this.folderRepository.find({
|
|
666
|
-
order: { updatedAt: 'DESC' },
|
|
667
|
-
take: 1,
|
|
668
|
-
select: ['updatedAt'],
|
|
669
|
-
});
|
|
670
|
-
const lastUpdatedDate = lastUpdatedFolder[0]?.updatedAt ?? new Date();
|
|
671
|
-
const foldersMappingsRemote = await this.sourceControlImportService.getRemoteFoldersAndMappingsFromFile(context);
|
|
672
|
-
const foldersMappingsLocal = await this.sourceControlImportService.getLocalFoldersAndMappingsFromDb(context);
|
|
673
|
-
const foldersMissingInLocal = foldersMappingsRemote.folders.filter((remote) => foldersMappingsLocal.folders.findIndex((local) => local.id === remote.id) === -1);
|
|
674
|
-
const foldersMissingInRemote = foldersMappingsLocal.folders.filter((local) => foldersMappingsRemote.folders.findIndex((remote) => remote.id === local.id) === -1);
|
|
675
|
-
const foldersModifiedInEither = [];
|
|
676
|
-
foldersMappingsLocal.folders.forEach((local) => {
|
|
677
|
-
const mismatchingIds = foldersMappingsRemote.folders.find((remote) => remote.id === local.id &&
|
|
678
|
-
(remote.name !== local.name || remote.parentFolderId !== local.parentFolderId));
|
|
679
|
-
if (!mismatchingIds) {
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
foldersModifiedInEither.push(options.preferLocalVersion ? local : mismatchingIds);
|
|
683
|
-
});
|
|
684
|
-
foldersMissingInLocal.forEach((item) => {
|
|
685
|
-
sourceControlledFiles.push({
|
|
686
|
-
id: item.id,
|
|
687
|
-
name: item.name,
|
|
688
|
-
type: 'folders',
|
|
689
|
-
status: options.direction === 'push' ? 'deleted' : 'created',
|
|
690
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
691
|
-
conflict: false,
|
|
692
|
-
file: (0, source_control_helper_ee_1.getFoldersPath)(this.gitFolder),
|
|
693
|
-
updatedAt: lastUpdatedDate.toISOString(),
|
|
694
|
-
});
|
|
695
|
-
});
|
|
696
|
-
foldersMissingInRemote.forEach((item) => {
|
|
697
|
-
sourceControlledFiles.push({
|
|
698
|
-
id: item.id,
|
|
699
|
-
name: item.name,
|
|
700
|
-
type: 'folders',
|
|
701
|
-
status: options.direction === 'push' ? 'created' : 'deleted',
|
|
702
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
703
|
-
conflict: options.direction === 'push' ? false : true,
|
|
704
|
-
file: (0, source_control_helper_ee_1.getFoldersPath)(this.gitFolder),
|
|
705
|
-
updatedAt: lastUpdatedDate.toISOString(),
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
foldersModifiedInEither.forEach((item) => {
|
|
709
|
-
sourceControlledFiles.push({
|
|
710
|
-
id: item.id,
|
|
711
|
-
name: item.name,
|
|
712
|
-
type: 'folders',
|
|
713
|
-
status: 'modified',
|
|
714
|
-
location: options.direction === 'push' ? 'local' : 'remote',
|
|
715
|
-
conflict: true,
|
|
716
|
-
file: (0, source_control_helper_ee_1.getFoldersPath)(this.gitFolder),
|
|
717
|
-
updatedAt: lastUpdatedDate.toISOString(),
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
return {
|
|
721
|
-
foldersMissingInLocal,
|
|
722
|
-
foldersMissingInRemote,
|
|
723
|
-
foldersModifiedInEither,
|
|
724
|
-
};
|
|
320
|
+
return await this.sourceControlStatusService.getStatus(user, options);
|
|
725
321
|
}
|
|
726
322
|
async setGitUserDetails(name = constants_1.SOURCE_CONTROL_DEFAULT_NAME, email = constants_1.SOURCE_CONTROL_DEFAULT_EMAIL) {
|
|
727
323
|
await this.sanityCheck();
|
|
@@ -756,8 +352,7 @@ exports.SourceControlService = SourceControlService = __decorate([
|
|
|
756
352
|
source_control_export_service_ee_1.SourceControlExportService,
|
|
757
353
|
source_control_import_service_ee_1.SourceControlImportService,
|
|
758
354
|
source_control_scoped_service_1.SourceControlScopedService,
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
event_service_1.EventService])
|
|
355
|
+
event_service_1.EventService,
|
|
356
|
+
source_control_status_service_ee_1.SourceControlStatusService])
|
|
762
357
|
], SourceControlService);
|
|
763
358
|
//# sourceMappingURL=source-control.service.ee.js.map
|