@atom8n/n8n 2.4.7 → 2.5.1

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.
Files changed (231) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/chat/chat-service.types.d.ts +6 -6
  3. package/dist/commands/execute-batch.d.ts +2 -2
  4. package/dist/commands/execute.js +0 -0
  5. package/dist/commands/import/credentials.d.ts +2 -2
  6. package/dist/commands/import/credentials.js +0 -0
  7. package/dist/commands/import/workflow.d.ts +2 -2
  8. package/dist/commands/ldap/reset.d.ts +2 -2
  9. package/dist/commands/mcp.d.ts +23 -0
  10. package/dist/commands/mcp.js +315 -0
  11. package/dist/commands/run.d.ts +23 -0
  12. package/dist/commands/run.js +162 -0
  13. package/dist/controllers/annotation-tags.controller.ee.d.ts +1 -1
  14. package/dist/controllers/cli.controller.d.ts +26 -0
  15. package/dist/controllers/cli.controller.js +334 -0
  16. package/dist/controllers/orchestration.controller.js +0 -0
  17. package/dist/controllers/users.controller.d.ts +1 -1
  18. package/dist/environments.ee/source-control/source-control-status.service.ee.d.ts +2 -2
  19. package/dist/environments.ee/source-control/source-control.controller.ee.d.ts +4 -4
  20. package/dist/environments.ee/source-control/source-control.service.ee.d.ts +2 -2
  21. package/dist/environments.ee/source-control/types/source-control-set-branch.js +0 -0
  22. package/dist/eventbus/event-message-classes/index.js +0 -0
  23. package/dist/events/relays/workflow-failure-notification.event-relay.d.ts +13 -0
  24. package/dist/events/relays/workflow-failure-notification.event-relay.js +77 -0
  25. package/dist/executions/execution-data/types.d.ts +17 -0
  26. package/dist/executions/execution-data/types.js +2 -0
  27. package/dist/executions/failed-run-factory.d.ts +4 -0
  28. package/dist/executions/failed-run-factory.js +71 -0
  29. package/dist/index.d.ts +2 -1
  30. package/dist/index.js +8 -0
  31. package/dist/interfaces.d.ts +1 -1
  32. package/dist/license.js +1 -1
  33. package/dist/middlewares/webview-frame-options.d.ts +2 -0
  34. package/dist/middlewares/webview-frame-options.js +22 -0
  35. package/dist/modules/chat-hub/chat-hub-extractor.d.ts +22 -0
  36. package/dist/modules/chat-hub/chat-hub-extractor.js +63 -0
  37. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-user-entry-storage.d.ts +11 -0
  38. package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-user-entry-storage.js +58 -0
  39. package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-user-entry.d.ts +12 -0
  40. package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-user-entry.js +64 -0
  41. package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-user-entry.repository.d.ts +5 -0
  42. package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-user-entry.repository.js +25 -0
  43. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.d.ts +5 -0
  44. package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.js +36 -0
  45. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.d.ts +12 -0
  46. package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.js +69 -0
  47. package/dist/modules/dynamic-credentials.ee/services/resolver-config-expression.service.d.ts +7 -0
  48. package/dist/modules/dynamic-credentials.ee/services/resolver-config-expression.service.js +46 -0
  49. package/dist/modules/insights/database/entities/insights-metadata.js +1 -1
  50. package/dist/modules/insights/database/repositories/insights-by-period-query.helper.js +4 -1
  51. package/dist/modules/insights/database/repositories/insights-by-period.repository.d.ts +1 -1
  52. package/dist/modules/insights/insights.module.d.ts +1 -1
  53. package/dist/modules/insights/insights.service.d.ts +1 -1
  54. package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.d.ts +6 -0
  55. package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.js +28 -0
  56. package/dist/modules/log-streaming.ee/database/entities/index.d.ts +1 -0
  57. package/dist/modules/log-streaming.ee/database/entities/index.js +5 -0
  58. package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.d.ts +5 -0
  59. package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.js +25 -0
  60. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.d.ts +4 -0
  61. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.js +24 -0
  62. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-sentry.ee.d.ts +17 -0
  63. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-sentry.ee.js +131 -0
  64. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.d.ts +22 -0
  65. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.js +116 -0
  66. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.d.ts +35 -0
  67. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.js +328 -0
  68. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination.ee.d.ts +28 -0
  69. package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination.ee.js +74 -0
  70. package/dist/modules/log-streaming.ee/log-streaming-destination.service.d.ts +32 -0
  71. package/dist/modules/log-streaming.ee/log-streaming-destination.service.js +175 -0
  72. package/dist/modules/log-streaming.ee/log-streaming.controller.d.ts +15 -0
  73. package/dist/modules/log-streaming.ee/log-streaming.controller.js +149 -0
  74. package/dist/modules/log-streaming.ee/log-streaming.module.d.ts +5 -0
  75. package/dist/modules/log-streaming.ee/log-streaming.module.js +66 -0
  76. package/dist/modules/mcp/mcp-oauth.helpers.js +0 -0
  77. package/dist/modules/mcp/mcp.oauth-clients.controller.js +0 -0
  78. package/dist/modules/mcp/tools/execute-workflow.tool.d.ts +10 -10
  79. package/dist/modules/mcp/tools/schemas.d.ts +10 -10
  80. package/dist/modules/source-control.ee/constants.d.ts +17 -0
  81. package/dist/modules/source-control.ee/constants.js +22 -0
  82. package/dist/modules/source-control.ee/middleware/source-control-enabled-middleware.ee.d.ts +2 -0
  83. package/dist/modules/source-control.ee/middleware/source-control-enabled-middleware.ee.js +18 -0
  84. package/dist/modules/source-control.ee/source-control-export.service.ee.d.ts +37 -0
  85. package/dist/modules/source-control.ee/source-control-export.service.ee.js +426 -0
  86. package/dist/modules/source-control.ee/source-control-git.service.ee.d.ts +59 -0
  87. package/dist/modules/source-control.ee/source-control-git.service.ee.js +427 -0
  88. package/dist/modules/source-control.ee/source-control-helper.ee.d.ts +49 -0
  89. package/dist/modules/source-control.ee/source-control-helper.ee.js +241 -0
  90. package/dist/modules/source-control.ee/source-control-import.service.ee.d.ts +110 -0
  91. package/dist/modules/source-control.ee/source-control-import.service.ee.js +957 -0
  92. package/dist/modules/source-control.ee/source-control-preferences.service.ee.d.ts +46 -0
  93. package/dist/modules/source-control.ee/source-control-preferences.service.ee.js +309 -0
  94. package/dist/modules/source-control.ee/source-control-resource-helper.d.ts +4 -0
  95. package/dist/modules/source-control.ee/source-control-resource-helper.js +20 -0
  96. package/dist/modules/source-control.ee/source-control-scoped.service.d.ts +17 -0
  97. package/dist/modules/source-control.ee/source-control-scoped.service.js +134 -0
  98. package/dist/modules/source-control.ee/source-control-status.service.ee.d.ts +90 -0
  99. package/dist/modules/source-control.ee/source-control-status.service.ee.js +596 -0
  100. package/dist/modules/source-control.ee/source-control.config.d.ts +3 -0
  101. package/dist/modules/source-control.ee/source-control.config.js +26 -0
  102. package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +157 -0
  103. package/dist/modules/source-control.ee/source-control.controller.ee.js +347 -0
  104. package/dist/modules/source-control.ee/source-control.module.d.ts +4 -0
  105. package/dist/modules/source-control.ee/source-control.module.js +59 -0
  106. package/dist/modules/source-control.ee/source-control.service.ee.d.ts +125 -0
  107. package/dist/modules/source-control.ee/source-control.service.ee.js +466 -0
  108. package/dist/modules/source-control.ee/types/export-result.d.ts +10 -0
  109. package/dist/modules/source-control.ee/types/export-result.js +2 -0
  110. package/dist/modules/source-control.ee/types/exportable-credential.d.ts +14 -0
  111. package/dist/modules/source-control.ee/types/exportable-credential.js +2 -0
  112. package/dist/modules/source-control.ee/types/exportable-folders.d.ts +11 -0
  113. package/dist/modules/source-control.ee/types/exportable-folders.js +2 -0
  114. package/dist/modules/source-control.ee/types/exportable-project.d.ts +17 -0
  115. package/dist/modules/source-control.ee/types/exportable-project.js +2 -0
  116. package/dist/modules/source-control.ee/types/exportable-tags.d.ts +5 -0
  117. package/dist/modules/source-control.ee/types/exportable-tags.js +2 -0
  118. package/dist/modules/source-control.ee/types/exportable-variable.d.ts +7 -0
  119. package/dist/modules/source-control.ee/types/exportable-variable.js +2 -0
  120. package/dist/modules/source-control.ee/types/exportable-workflow.d.ts +14 -0
  121. package/dist/modules/source-control.ee/types/exportable-workflow.js +2 -0
  122. package/dist/modules/source-control.ee/types/import-result.d.ts +20 -0
  123. package/dist/modules/source-control.ee/types/import-result.js +2 -0
  124. package/dist/modules/source-control.ee/types/key-pair-type.d.ts +1 -0
  125. package/dist/modules/source-control.ee/types/key-pair-type.js +2 -0
  126. package/dist/modules/source-control.ee/types/key-pair.d.ts +4 -0
  127. package/dist/modules/source-control.ee/types/key-pair.js +2 -0
  128. package/dist/modules/source-control.ee/types/requests.d.ts +21 -0
  129. package/dist/modules/source-control.ee/types/requests.js +2 -0
  130. package/dist/modules/source-control.ee/types/resource-owner.d.ts +17 -0
  131. package/dist/modules/source-control.ee/types/resource-owner.js +2 -0
  132. package/dist/modules/source-control.ee/types/source-control-commit.d.ts +3 -0
  133. package/dist/modules/source-control.ee/types/source-control-commit.js +20 -0
  134. package/dist/modules/source-control.ee/types/source-control-context.d.ts +7 -0
  135. package/dist/modules/source-control.ee/types/source-control-context.js +16 -0
  136. package/dist/modules/source-control.ee/types/source-control-disconnect.d.ts +3 -0
  137. package/dist/modules/source-control.ee/types/source-control-disconnect.js +21 -0
  138. package/dist/modules/source-control.ee/types/source-control-generate-key-pair.d.ts +4 -0
  139. package/dist/modules/source-control.ee/types/source-control-generate-key-pair.js +21 -0
  140. package/dist/modules/source-control.ee/types/source-control-get-status.d.ts +10 -0
  141. package/dist/modules/source-control.ee/types/source-control-get-status.js +42 -0
  142. package/dist/modules/source-control.ee/types/source-control-preferences.d.ts +17 -0
  143. package/dist/modules/source-control.ee/types/source-control-preferences.js +88 -0
  144. package/dist/modules/source-control.ee/types/source-control-push.d.ts +3 -0
  145. package/dist/modules/source-control.ee/types/source-control-push.js +21 -0
  146. package/dist/modules/source-control.ee/types/source-control-set-branch.d.ts +3 -0
  147. package/dist/modules/source-control.ee/types/source-control-set-branch.js +20 -0
  148. package/dist/modules/source-control.ee/types/source-control-set-read-only.d.ts +3 -0
  149. package/dist/modules/source-control.ee/types/source-control-set-read-only.js +20 -0
  150. package/dist/modules/source-control.ee/types/source-control-stage.d.ts +5 -0
  151. package/dist/modules/source-control.ee/types/source-control-stage.js +31 -0
  152. package/dist/modules/source-control.ee/types/source-control-workflow-version-id.d.ts +12 -0
  153. package/dist/modules/source-control.ee/types/source-control-workflow-version-id.js +2 -0
  154. package/dist/modules/sso-oidc/constants.d.ts +3 -0
  155. package/dist/modules/sso-oidc/constants.js +6 -0
  156. package/dist/modules/sso-oidc/oidc.controller.ee.d.ts +23 -0
  157. package/dist/modules/sso-oidc/oidc.controller.ee.js +123 -0
  158. package/dist/modules/sso-oidc/oidc.service.ee.d.ts +56 -0
  159. package/dist/modules/sso-oidc/oidc.service.ee.js +468 -0
  160. package/dist/modules/sso-oidc/sso-oidc.module.d.ts +4 -0
  161. package/dist/modules/sso-oidc/sso-oidc.module.js +55 -0
  162. package/dist/modules/sso-saml/constants.d.ts +3 -0
  163. package/dist/modules/sso-saml/constants.js +6 -0
  164. package/dist/modules/sso-saml/errors/invalid-saml-metadata-url.error.d.ts +4 -0
  165. package/dist/modules/sso-saml/errors/invalid-saml-metadata-url.error.js +10 -0
  166. package/dist/modules/sso-saml/errors/invalid-saml-metadata.error.d.ts +4 -0
  167. package/dist/modules/sso-saml/errors/invalid-saml-metadata.error.js +10 -0
  168. package/dist/modules/sso-saml/middleware/saml-enabled-middleware.d.ts +3 -0
  169. package/dist/modules/sso-saml/middleware/saml-enabled-middleware.js +22 -0
  170. package/dist/modules/sso-saml/saml-helpers.d.ts +19 -0
  171. package/dist/modules/sso-saml/saml-helpers.js +129 -0
  172. package/dist/modules/sso-saml/saml-validator.d.ts +16 -0
  173. package/dist/modules/sso-saml/saml-validator.js +129 -0
  174. package/dist/modules/sso-saml/saml.controller.ee.d.ts +50 -0
  175. package/dist/modules/sso-saml/saml.controller.ee.js +227 -0
  176. package/dist/modules/sso-saml/saml.service.ee.d.ts +52 -0
  177. package/dist/modules/sso-saml/saml.service.ee.js +462 -0
  178. package/dist/modules/sso-saml/schema/metadata-exchange.xsd.d.ts +2 -0
  179. package/dist/modules/sso-saml/schema/metadata-exchange.xsd.js +118 -0
  180. package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.d.ts +2 -0
  181. package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.js +201 -0
  182. package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.d.ts +2 -0
  183. package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.js +114 -0
  184. package/dist/modules/sso-saml/schema/saml-schema-assertion-2.0.xsd.d.ts +2 -0
  185. package/dist/modules/sso-saml/schema/saml-schema-assertion-2.0.xsd.js +289 -0
  186. package/dist/modules/sso-saml/schema/saml-schema-metadata-2.0.xsd.d.ts +2 -0
  187. package/dist/modules/sso-saml/schema/saml-schema-metadata-2.0.xsd.js +344 -0
  188. package/dist/modules/sso-saml/schema/saml-schema-protocol-2.0.xsd.d.ts +2 -0
  189. package/dist/modules/sso-saml/schema/saml-schema-protocol-2.0.xsd.js +308 -0
  190. package/dist/modules/sso-saml/schema/ws-addr.xsd.d.ts +2 -0
  191. package/dist/modules/sso-saml/schema/ws-addr.xsd.js +143 -0
  192. package/dist/modules/sso-saml/schema/ws-authorization.xsd.d.ts +2 -0
  193. package/dist/modules/sso-saml/schema/ws-authorization.xsd.js +151 -0
  194. package/dist/modules/sso-saml/schema/ws-federation.xsd.d.ts +2 -0
  195. package/dist/modules/sso-saml/schema/ws-federation.xsd.js +476 -0
  196. package/dist/modules/sso-saml/schema/ws-securitypolicy-1.2.xsd.d.ts +2 -0
  197. package/dist/modules/sso-saml/schema/ws-securitypolicy-1.2.xsd.js +1211 -0
  198. package/dist/modules/sso-saml/schema/xenc-schema.xsd.d.ts +2 -0
  199. package/dist/modules/sso-saml/schema/xenc-schema.xsd.js +151 -0
  200. package/dist/modules/sso-saml/schema/xml.xsd.d.ts +2 -0
  201. package/dist/modules/sso-saml/schema/xml.xsd.js +123 -0
  202. package/dist/modules/sso-saml/schema/xmldsig-core-schema.xsd.d.ts +2 -0
  203. package/dist/modules/sso-saml/schema/xmldsig-core-schema.xsd.js +324 -0
  204. package/dist/modules/sso-saml/service-provider.ee.d.ts +6 -0
  205. package/dist/modules/sso-saml/service-provider.ee.js +44 -0
  206. package/dist/modules/sso-saml/sso-saml.module.d.ts +4 -0
  207. package/dist/modules/sso-saml/sso-saml.module.js +55 -0
  208. package/dist/modules/sso-saml/types.d.ts +4 -0
  209. package/dist/modules/sso-saml/types.js +2 -0
  210. package/dist/modules/sso-saml/views/init-sso-post.d.ts +2 -0
  211. package/dist/modules/sso-saml/views/init-sso-post.js +16 -0
  212. package/dist/node-lib.d.ts +10 -0
  213. package/dist/node-lib.js +137 -0
  214. package/dist/push/index.d.ts +1 -1
  215. package/dist/server.d.ts +1 -0
  216. package/dist/server.js +1 -0
  217. package/dist/services/cors-service.d.ts +7 -0
  218. package/dist/services/cors-service.js +50 -0
  219. package/dist/services/static-auth-service.d.ts +4 -0
  220. package/dist/services/static-auth-service.js +29 -0
  221. package/dist/sso.ee/saml/schema/metadata-exchange.xsd.js +0 -0
  222. package/dist/task-runners/task-broker/errors/task-runner-accept-timeout.error.js +0 -0
  223. package/dist/typecheck.tsbuildinfo +1 -0
  224. package/dist/user-management/email/templates/workflow-failure.handlebars +211 -0
  225. package/dist/utils/cors.util.d.ts +2 -0
  226. package/dist/utils/cors.util.js +17 -0
  227. package/dist/webhooks/waiting-forms.js +3 -3
  228. package/dist/webhooks/waiting-webhooks.js +2 -0
  229. package/dist/workflows/workflow.service.d.ts +2 -2
  230. package/dist/workflows/workflows.controller.d.ts +6 -6
  231. package/package.json +22 -21
@@ -0,0 +1,427 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.SourceControlGitService = void 0;
49
+ const backend_common_1 = require("@n8n/backend-common");
50
+ const di_1 = require("@n8n/di");
51
+ const child_process_1 = require("child_process");
52
+ const n8n_workflow_1 = require("n8n-workflow");
53
+ const path = __importStar(require("path"));
54
+ const proxy_from_env_1 = __importDefault(require("proxy-from-env"));
55
+ const ownership_service_1 = require("../../services/ownership.service");
56
+ const constants_1 = require("./constants");
57
+ const source_control_helper_ee_1 = require("./source-control-helper.ee");
58
+ const source_control_preferences_service_ee_1 = require("./source-control-preferences.service.ee");
59
+ let SourceControlGitService = class SourceControlGitService {
60
+ constructor(logger, ownershipService, sourceControlPreferencesService) {
61
+ this.logger = logger;
62
+ this.ownershipService = ownershipService;
63
+ this.sourceControlPreferencesService = sourceControlPreferencesService;
64
+ this.git = null;
65
+ this.gitOptions = {};
66
+ }
67
+ preInitCheck() {
68
+ this.logger.debug('GitService.preCheck');
69
+ try {
70
+ const gitResult = (0, child_process_1.execSync)('git --version', {
71
+ stdio: ['pipe', 'pipe', 'pipe'],
72
+ });
73
+ this.logger.debug(`Git binary found: ${gitResult.toString()}`);
74
+ }
75
+ catch (error) {
76
+ this.logger.error('Git binary check failed', { error });
77
+ throw new n8n_workflow_1.UnexpectedError('Git binary not found', { cause: error });
78
+ }
79
+ try {
80
+ const sshResult = (0, child_process_1.execSync)('ssh -V', {
81
+ stdio: ['pipe', 'pipe', 'pipe'],
82
+ });
83
+ this.logger.debug(`SSH binary found: ${sshResult.toString()}`);
84
+ }
85
+ catch (error) {
86
+ this.logger.error('SSH binary check failed', { error });
87
+ throw new n8n_workflow_1.UnexpectedError('SSH binary not found', { cause: error });
88
+ }
89
+ return true;
90
+ }
91
+ async initService(options) {
92
+ const { sourceControlPreferences: sourceControlPreferences, gitFolder, sshFolder } = options;
93
+ this.logger.debug('GitService.init');
94
+ if (this.git !== null) {
95
+ return;
96
+ }
97
+ this.preInitCheck();
98
+ this.logger.debug('Git pre-check passed');
99
+ (0, source_control_helper_ee_1.sourceControlFoldersExistCheck)([gitFolder, sshFolder]);
100
+ await this.setGitCommand(gitFolder, sshFolder);
101
+ if (!(await this.checkRepositorySetup())) {
102
+ await this.git.init();
103
+ }
104
+ if (!(await this.hasRemote(sourceControlPreferences.repositoryUrl))) {
105
+ if (sourceControlPreferences.connected && sourceControlPreferences.repositoryUrl) {
106
+ const instanceOwner = await this.ownershipService.getInstanceOwner();
107
+ await this.initRepository(sourceControlPreferences, instanceOwner);
108
+ }
109
+ }
110
+ if (sourceControlPreferences.connected && sourceControlPreferences.branchName) {
111
+ await this.ensureBranchSetup(sourceControlPreferences.branchName);
112
+ }
113
+ }
114
+ async setGitCommand(gitFolder = this.sourceControlPreferencesService.gitFolder, sshFolder = this.sourceControlPreferencesService.sshFolder) {
115
+ const preferences = this.sourceControlPreferencesService.getPreferences();
116
+ this.gitOptions = {
117
+ baseDir: gitFolder,
118
+ binary: 'git',
119
+ maxConcurrentProcesses: 6,
120
+ trimmed: false,
121
+ };
122
+ const { simpleGit } = await Promise.resolve().then(() => __importStar(require('simple-git')));
123
+ if (preferences.connectionType === 'https') {
124
+ const credentials = await this.sourceControlPreferencesService.getDecryptedHttpsCredentials();
125
+ const escapeShellArg = (arg) => `'${arg.replace(/'/g, "'\"'\"'")}'`;
126
+ const credentialScript = `!f() { echo username=${escapeShellArg(credentials.username)}; echo password=${escapeShellArg(credentials.password)}; }; f`;
127
+ const httpsGitOptions = {
128
+ ...this.gitOptions,
129
+ config: [
130
+ 'credential.helper=' + credentialScript,
131
+ 'credential.useHttpPath=true',
132
+ ],
133
+ };
134
+ const repositoryUrl = preferences.repositoryUrl;
135
+ const proxyUrl = proxy_from_env_1.default.getProxyForUrl(repositoryUrl);
136
+ if (proxyUrl) {
137
+ this.logger.debug('Proxy configuration added', { proxyUrl });
138
+ httpsGitOptions.config.push(`http.proxy=${proxyUrl}`);
139
+ }
140
+ this.git = simpleGit(httpsGitOptions).env('GIT_TERMINAL_PROMPT', '0');
141
+ }
142
+ else if (preferences.connectionType === 'ssh') {
143
+ const privateKeyPath = await this.sourceControlPreferencesService.getPrivateKeyPath();
144
+ const sshKnownHosts = path.join(sshFolder, 'known_hosts');
145
+ const normalizedPrivateKeyPath = privateKeyPath.split(/[/\\]/).join('/');
146
+ const normalizedKnownHostsPath = sshKnownHosts.split(/[/\\]/).join('/');
147
+ const escapedPrivateKeyPath = normalizedPrivateKeyPath.replace(/"/g, '\\"');
148
+ const escapedKnownHostsPath = normalizedKnownHostsPath.replace(/"/g, '\\"');
149
+ const sshCommand = `ssh -o UserKnownHostsFile="${escapedKnownHostsPath}" -o StrictHostKeyChecking=accept-new -i "${escapedPrivateKeyPath}"`;
150
+ this.git = simpleGit(this.gitOptions)
151
+ .env('GIT_SSH_COMMAND', sshCommand)
152
+ .env('GIT_TERMINAL_PROMPT', '0');
153
+ }
154
+ }
155
+ resetService() {
156
+ this.git = null;
157
+ }
158
+ async checkRepositorySetup() {
159
+ if (!this.git) {
160
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (async)');
161
+ }
162
+ if (!(await this.git.checkIsRepo())) {
163
+ return false;
164
+ }
165
+ try {
166
+ await this.git.status();
167
+ return true;
168
+ }
169
+ catch (error) {
170
+ return false;
171
+ }
172
+ }
173
+ async hasRemote(remote) {
174
+ if (!this.git) {
175
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (async)');
176
+ }
177
+ try {
178
+ const remotes = await this.git.getRemotes(true);
179
+ const foundRemote = remotes.find((e) => e.name === constants_1.SOURCE_CONTROL_ORIGIN && e.refs.push === remote);
180
+ if (foundRemote) {
181
+ this.logger.debug(`Git remote found: ${foundRemote.name}: ${foundRemote.refs.push}`);
182
+ return true;
183
+ }
184
+ }
185
+ catch (error) {
186
+ this.logger.error('Git remote check failed', { error });
187
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized', { cause: error });
188
+ }
189
+ this.logger.debug(`Git remote not found: ${remote}`);
190
+ return false;
191
+ }
192
+ async initRepository(sourceControlPreferences, user) {
193
+ if (!this.git) {
194
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (Promise)');
195
+ }
196
+ const { branchName, initRepo, repositoryUrl } = sourceControlPreferences;
197
+ if (initRepo) {
198
+ try {
199
+ await this.git.init();
200
+ }
201
+ catch (error) {
202
+ this.logger.debug(`Git init: ${error.message}`);
203
+ }
204
+ }
205
+ try {
206
+ await this.git.addRemote(constants_1.SOURCE_CONTROL_ORIGIN, repositoryUrl);
207
+ this.logger.debug(`Git remote added: ${repositoryUrl}`);
208
+ }
209
+ catch (error) {
210
+ if (error.message.includes('remote origin already exists')) {
211
+ this.logger.debug(`Git remote already exists: ${error.message}`);
212
+ }
213
+ else {
214
+ throw error;
215
+ }
216
+ }
217
+ await this.setGitUserDetails(user.firstName && user.lastName
218
+ ? `${user.firstName} ${user.lastName}`
219
+ : constants_1.SOURCE_CONTROL_DEFAULT_NAME, user.email ?? constants_1.SOURCE_CONTROL_DEFAULT_EMAIL);
220
+ await this.trackRemoteIfReady(branchName);
221
+ if (initRepo) {
222
+ try {
223
+ const branches = await this.getBranches();
224
+ if (branches.branches?.length === 0) {
225
+ await this.git.raw(['branch', '-M', branchName]);
226
+ }
227
+ }
228
+ catch (error) {
229
+ this.logger.debug(`Git init: ${error.message}`);
230
+ }
231
+ }
232
+ }
233
+ async trackRemoteIfReady(targetBranch) {
234
+ if (!this.git)
235
+ return;
236
+ await this.fetch();
237
+ const { currentBranch, branches: remoteBranches } = await this.getBranches();
238
+ if (!currentBranch && remoteBranches.some((b) => b === targetBranch)) {
239
+ await this.git.checkout(targetBranch);
240
+ const upstream = [constants_1.SOURCE_CONTROL_ORIGIN, targetBranch].join('/');
241
+ await this.git.branch([`--set-upstream-to=${upstream}`, targetBranch]);
242
+ this.logger.info('Set local git repository to track remote', { upstream });
243
+ }
244
+ }
245
+ async ensureBranchSetup(targetBranch) {
246
+ if (!this.git)
247
+ return;
248
+ const { current: currentBranch } = await this.git.branch();
249
+ if (currentBranch === targetBranch) {
250
+ return;
251
+ }
252
+ try {
253
+ await this.fetch();
254
+ }
255
+ catch (error) {
256
+ this.logger.warn('Failed to fetch during branch setup recovery', { error });
257
+ return;
258
+ }
259
+ const { branches: remoteBranches } = await this.getBranches();
260
+ if (remoteBranches.includes(targetBranch)) {
261
+ try {
262
+ await this.git.checkout(targetBranch);
263
+ const upstream = [constants_1.SOURCE_CONTROL_ORIGIN, targetBranch].join('/');
264
+ await this.git.branch([`--set-upstream-to=${upstream}`, targetBranch]);
265
+ this.logger.info('Recovered source control branch setup', { targetBranch, upstream });
266
+ }
267
+ catch (error) {
268
+ this.logger.warn('Failed to checkout branch during recovery', { targetBranch, error });
269
+ }
270
+ }
271
+ }
272
+ async setGitUserDetails(name, email) {
273
+ if (!this.git) {
274
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (setGitUserDetails)');
275
+ }
276
+ await this.git.addConfig('user.email', email);
277
+ await this.git.addConfig('user.name', name);
278
+ }
279
+ async getBranches() {
280
+ if (!this.git) {
281
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (getBranches)');
282
+ }
283
+ try {
284
+ const { branches } = await this.git.branch(['-r']);
285
+ const remoteBranches = Object.keys(branches)
286
+ .map((name) => name.split('/').slice(1).join('/'))
287
+ .filter((name) => name !== 'HEAD');
288
+ const { current } = await this.git.branch();
289
+ return {
290
+ branches: remoteBranches,
291
+ currentBranch: current,
292
+ };
293
+ }
294
+ catch (error) {
295
+ this.logger.error('Failed to get branches', { error });
296
+ throw new n8n_workflow_1.UnexpectedError('Could not get remote branches from repository', { cause: error });
297
+ }
298
+ }
299
+ async setBranch(branch) {
300
+ if (!this.git) {
301
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (setBranch)');
302
+ }
303
+ await this.git.checkout(branch);
304
+ await this.git.branch([`--set-upstream-to=${constants_1.SOURCE_CONTROL_ORIGIN}/${branch}`, branch]);
305
+ return await this.getBranches();
306
+ }
307
+ async getCurrentBranch() {
308
+ if (!this.git) {
309
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (getCurrentBranch)');
310
+ }
311
+ const currentBranch = (await this.git.branch()).current;
312
+ return {
313
+ current: currentBranch,
314
+ remote: 'origin/' + currentBranch,
315
+ };
316
+ }
317
+ async diffRemote() {
318
+ if (!this.git) {
319
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (diffRemote)');
320
+ }
321
+ const currentBranch = await this.getCurrentBranch();
322
+ if (currentBranch.remote) {
323
+ const target = currentBranch.remote;
324
+ return await this.git.diffSummary(['...' + target, '--ignore-all-space']);
325
+ }
326
+ return;
327
+ }
328
+ async diffLocal() {
329
+ if (!this.git) {
330
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (diffLocal)');
331
+ }
332
+ const currentBranch = await this.getCurrentBranch();
333
+ if (currentBranch.remote) {
334
+ const target = currentBranch.current;
335
+ return await this.git.diffSummary([target, '--ignore-all-space']);
336
+ }
337
+ return;
338
+ }
339
+ async fetch() {
340
+ if (!this.git) {
341
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (fetch)');
342
+ }
343
+ await this.setGitCommand();
344
+ return await this.git.fetch();
345
+ }
346
+ async pull(options = { ffOnly: true }) {
347
+ if (!this.git) {
348
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (pull)');
349
+ }
350
+ await this.setGitCommand();
351
+ const params = {};
352
+ if (options.ffOnly) {
353
+ Object.assign(params, { '--ff-only': true });
354
+ }
355
+ return await this.git.pull(params);
356
+ }
357
+ async push(options = {
358
+ force: false,
359
+ branch: constants_1.SOURCE_CONTROL_DEFAULT_BRANCH,
360
+ }) {
361
+ const { force, branch } = options;
362
+ if (!this.git) {
363
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized ({)');
364
+ }
365
+ await this.setGitCommand();
366
+ if (force) {
367
+ return await this.git.push(constants_1.SOURCE_CONTROL_ORIGIN, branch, ['-f']);
368
+ }
369
+ return await this.git.push(constants_1.SOURCE_CONTROL_ORIGIN, branch);
370
+ }
371
+ async stage(files, deletedFiles) {
372
+ if (!this.git) {
373
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (stage)');
374
+ }
375
+ if (deletedFiles?.size) {
376
+ try {
377
+ await this.git.rm(Array.from(deletedFiles));
378
+ }
379
+ catch (error) {
380
+ this.logger.debug(`Git rm: ${error.message}`);
381
+ }
382
+ }
383
+ return await this.git.add(Array.from(files));
384
+ }
385
+ async resetBranch(options = { hard: true, target: 'HEAD' }) {
386
+ if (!this.git) {
387
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (Promise)');
388
+ }
389
+ if (options?.hard) {
390
+ return await this.git.raw(['reset', '--hard', options.target]);
391
+ }
392
+ return await this.git.raw(['reset', options.target]);
393
+ }
394
+ async commit(message) {
395
+ if (!this.git) {
396
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (commit)');
397
+ }
398
+ return await this.git.commit(message);
399
+ }
400
+ async status() {
401
+ if (!this.git) {
402
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (status)');
403
+ }
404
+ const statusResult = await this.git.status();
405
+ return statusResult;
406
+ }
407
+ async getFileContent(filePath, commit = 'HEAD') {
408
+ if (!this.git) {
409
+ throw new n8n_workflow_1.UnexpectedError('Git is not initialized (getFileContent)');
410
+ }
411
+ try {
412
+ const content = await this.git.show([`${commit}:${filePath}`]);
413
+ return content;
414
+ }
415
+ catch (error) {
416
+ this.logger.error('Failed to get file content', { filePath, error });
417
+ throw new n8n_workflow_1.UnexpectedError(`Could not get content for file: ${filePath}: ${error?.message}`, { cause: error });
418
+ }
419
+ }
420
+ };
421
+ exports.SourceControlGitService = SourceControlGitService;
422
+ exports.SourceControlGitService = SourceControlGitService = __decorate([
423
+ (0, di_1.Service)(),
424
+ __metadata("design:paramtypes", [backend_common_1.Logger,
425
+ ownership_service_1.OwnershipService,
426
+ source_control_preferences_service_ee_1.SourceControlPreferencesService])
427
+ ], SourceControlGitService);
@@ -0,0 +1,49 @@
1
+ import type { SourceControlledFile } from '@n8n/api-types';
2
+ import type { TagEntity, WorkflowTagMapping } from '@n8n/db';
3
+ import type { ExportedFolders } from './types/exportable-folders';
4
+ import type { KeyPairType } from './types/key-pair-type';
5
+ import type { SourceControlWorkflowVersionId } from './types/source-control-workflow-version-id';
6
+ import type { StatusResourceOwner } from './types/resource-owner';
7
+ export declare function stringContainsExpression(testString: string): boolean;
8
+ export declare function getWorkflowExportPath(workflowId: string, workflowExportFolder: string): string;
9
+ export declare function getProjectExportPath(projectId: string, projectExportFolder: string): string;
10
+ export declare function getCredentialExportPath(credentialId: string, credentialExportFolder: string): string;
11
+ export declare function getVariablesPath(gitFolder: string): string;
12
+ export declare function getTagsPath(gitFolder: string): string;
13
+ export declare function getFoldersPath(gitFolder: string): string;
14
+ export declare function readTagAndMappingsFromSourceControlFile(file: string): Promise<{
15
+ tags: TagEntity[];
16
+ mappings: WorkflowTagMapping[];
17
+ }>;
18
+ export declare function readFoldersFromSourceControlFile(file: string): Promise<ExportedFolders>;
19
+ export declare function sourceControlFoldersExistCheck(folders: string[], createIfNotExists?: boolean): boolean;
20
+ export declare function isSourceControlLicensed(): boolean;
21
+ export declare function generateSshKeyPair(keyType: KeyPairType): Promise<{
22
+ privateKey: string;
23
+ publicKey: string;
24
+ }>;
25
+ export declare function getRepoType(repoUrl: string): 'github' | 'gitlab' | 'other';
26
+ export declare function getTrackingInformationFromPullResult(userId: string, result: SourceControlledFile[]): {
27
+ userId: string;
28
+ credConflicts: number;
29
+ workflowConflicts: number;
30
+ workflowUpdates: number;
31
+ };
32
+ export declare function getTrackingInformationFromPrePushResult(userId: string, result: SourceControlledFile[]): {
33
+ userId: string;
34
+ workflowsEligible: number;
35
+ workflowsEligibleWithConflicts: number;
36
+ credsEligible: number;
37
+ credsEligibleWithConflicts: number;
38
+ variablesEligible: number;
39
+ };
40
+ export declare function getTrackingInformationFromPostPushResult(userId: string, result: SourceControlledFile[]): {
41
+ userId: string;
42
+ workflowsPushed: number;
43
+ workflowsEligible: number;
44
+ credsPushed: number;
45
+ variablesPushed: number;
46
+ };
47
+ export declare function normalizeAndValidateSourceControlledFilePath(gitFolderPath: string, filePath: string): string;
48
+ export declare function hasOwnerChanged(owner1?: StatusResourceOwner, owner2?: StatusResourceOwner): boolean;
49
+ export declare function isWorkflowModified(local: SourceControlWorkflowVersionId, remote: SourceControlWorkflowVersionId): boolean;