@atom8n/backend-common 1.2.0

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 (44) hide show
  1. package/dist/build.tsbuildinfo +1 -0
  2. package/dist/cli-parser.d.ts +18 -0
  3. package/dist/cli-parser.js +55 -0
  4. package/dist/cli-parser.js.map +1 -0
  5. package/dist/environment.d.ts +3 -0
  6. package/dist/environment.js +8 -0
  7. package/dist/environment.js.map +1 -0
  8. package/dist/index.d.ts +10 -0
  9. package/dist/index.js +36 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/license-state.d.ts +51 -0
  12. package/dist/license-state.js +175 -0
  13. package/dist/license-state.js.map +1 -0
  14. package/dist/logging/index.d.ts +1 -0
  15. package/dist/logging/index.js +6 -0
  16. package/dist/logging/index.js.map +1 -0
  17. package/dist/logging/logger.d.ts +37 -0
  18. package/dist/logging/logger.js +250 -0
  19. package/dist/logging/logger.js.map +1 -0
  20. package/dist/modules/errors/missing-module.error.d.ts +4 -0
  21. package/dist/modules/errors/missing-module.error.js +11 -0
  22. package/dist/modules/errors/missing-module.error.js.map +1 -0
  23. package/dist/modules/errors/module-confusion.error.d.ts +4 -0
  24. package/dist/modules/errors/module-confusion.error.js +12 -0
  25. package/dist/modules/errors/module-confusion.error.js.map +1 -0
  26. package/dist/modules/errors/unknown-module.error.d.ts +4 -0
  27. package/dist/modules/errors/unknown-module.error.js +11 -0
  28. package/dist/modules/errors/unknown-module.error.js.map +1 -0
  29. package/dist/modules/module-registry.d.ts +27 -0
  30. package/dist/modules/module-registry.js +187 -0
  31. package/dist/modules/module-registry.js.map +1 -0
  32. package/dist/modules/modules.config.d.ts +11 -0
  33. package/dist/modules/modules.config.js +53 -0
  34. package/dist/modules/modules.config.js.map +1 -0
  35. package/dist/types.d.ts +12 -0
  36. package/dist/types.js +3 -0
  37. package/dist/types.js.map +1 -0
  38. package/dist/utils/is-object-literal.d.ts +5 -0
  39. package/dist/utils/is-object-literal.js +10 -0
  40. package/dist/utils/is-object-literal.js.map +1 -0
  41. package/dist/utils/path-util.d.ts +2 -0
  42. package/dist/utils/path-util.js +55 -0
  43. package/dist/utils/path-util.js.map +1 -0
  44. package/package.json +41 -0
@@ -0,0 +1,250 @@
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
+ var Logger_1;
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.Logger = void 0;
50
+ const config_1 = require("@n8n/config");
51
+ const di_1 = require("@n8n/di");
52
+ const callsites_1 = __importDefault(require("callsites"));
53
+ const n8n_workflow_1 = require("n8n-workflow");
54
+ const node_path_1 = __importStar(require("node:path"));
55
+ const picocolors_1 = __importDefault(require("picocolors"));
56
+ const winston_1 = __importDefault(require("winston"));
57
+ const environment_1 = require("../environment");
58
+ const is_object_literal_1 = require("../utils/is-object-literal");
59
+ const noOp = () => { };
60
+ let Logger = Logger_1 = class Logger {
61
+ get isScopingEnabled() {
62
+ return this.scopes.size > 0;
63
+ }
64
+ constructor(globalConfig, instanceSettingsConfig, { isRoot } = { isRoot: true }) {
65
+ this.globalConfig = globalConfig;
66
+ this.instanceSettingsConfig = instanceSettingsConfig;
67
+ this.noColor = process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== '';
68
+ this.noColorDefaultTrue = process.env.NO_COLOR !== 'false' && process.env.NO_COLOR !== '0';
69
+ this.level = this.globalConfig.logging.level;
70
+ const isSilent = this.level === 'silent';
71
+ this.internalLogger = winston_1.default.createLogger({
72
+ level: this.level,
73
+ silent: isSilent,
74
+ });
75
+ if (!isSilent) {
76
+ this.setLevel();
77
+ const { outputs, scopes } = this.globalConfig.logging;
78
+ if (outputs.includes('console'))
79
+ this.setConsoleTransport();
80
+ if (outputs.includes('file'))
81
+ this.setFileTransport();
82
+ this.scopes = new Set(scopes);
83
+ }
84
+ else {
85
+ this.scopes = new Set();
86
+ }
87
+ if (isRoot)
88
+ n8n_workflow_1.LoggerProxy.init(this);
89
+ }
90
+ setInternalLogger(internalLogger) {
91
+ this.internalLogger = internalLogger;
92
+ }
93
+ scoped(scopes) {
94
+ scopes = Array.isArray(scopes) ? scopes : [scopes];
95
+ const scopedLogger = new Logger_1(this.globalConfig, this.instanceSettingsConfig, {
96
+ isRoot: false,
97
+ });
98
+ const childLogger = this.internalLogger.child({ scopes });
99
+ scopedLogger.setInternalLogger(childLogger);
100
+ return scopedLogger;
101
+ }
102
+ serializeError(error, seen = new Set()) {
103
+ if (!(error instanceof Error))
104
+ return String(error);
105
+ let cause;
106
+ if (error.cause && !seen.has(error.cause)) {
107
+ seen.add(error.cause);
108
+ cause = this.serializeError(error.cause, seen);
109
+ }
110
+ return {
111
+ name: error.name,
112
+ message: error.message,
113
+ stack: error.stack,
114
+ cause,
115
+ };
116
+ }
117
+ log(level, message, metadata) {
118
+ const location = {};
119
+ const caller = (0, callsites_1.default)().at(2);
120
+ if (caller !== undefined) {
121
+ location.file = (0, node_path_1.basename)(caller.getFileName() ?? '');
122
+ const fnName = caller.getFunctionName();
123
+ if (fnName)
124
+ location.function = fnName;
125
+ }
126
+ for (const key of Object.keys(metadata)) {
127
+ const value = metadata[key];
128
+ if (value instanceof Error) {
129
+ metadata[key] = this.serializeError(value);
130
+ }
131
+ }
132
+ this.internalLogger.log(level, message, { ...metadata, ...location });
133
+ }
134
+ setLevel() {
135
+ const { levels } = this.internalLogger;
136
+ for (const logLevel of n8n_workflow_1.LOG_LEVELS) {
137
+ if (levels[logLevel] > levels[this.level]) {
138
+ Object.defineProperty(this, logLevel, { value: noOp });
139
+ }
140
+ }
141
+ }
142
+ jsonConsoleFormat() {
143
+ return winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.metadata(), winston_1.default.format.json(), this.scopeFilter());
144
+ }
145
+ pickConsoleTransportFormat() {
146
+ if (this.globalConfig.logging.format === 'json') {
147
+ return this.jsonConsoleFormat();
148
+ }
149
+ else if (this.level === 'debug' && environment_1.inDevelopment) {
150
+ return this.debugDevConsoleFormat();
151
+ }
152
+ else if (this.level === 'debug' && environment_1.inProduction) {
153
+ return this.debugProdConsoleFormat();
154
+ }
155
+ else {
156
+ return winston_1.default.format.printf(({ message }) => message);
157
+ }
158
+ }
159
+ setConsoleTransport() {
160
+ const format = this.pickConsoleTransportFormat();
161
+ this.internalLogger.add(new winston_1.default.transports.Console({ format }));
162
+ }
163
+ scopeFilter() {
164
+ return winston_1.default.format((info) => {
165
+ if (!this.isScopingEnabled)
166
+ return info;
167
+ const { scopes } = info.metadata;
168
+ const shouldIncludeScope = scopes && scopes?.length > 0 && scopes.some((s) => this.scopes.has(s));
169
+ return shouldIncludeScope ? info : false;
170
+ })();
171
+ }
172
+ color(defaultToTrue = false) {
173
+ if (defaultToTrue) {
174
+ return this.noColorDefaultTrue
175
+ ? winston_1.default.format.uncolorize()
176
+ : winston_1.default.format.colorize({ all: true });
177
+ }
178
+ return this.noColor ? winston_1.default.format.uncolorize() : winston_1.default.format.colorize({ all: true });
179
+ }
180
+ debugDevConsoleFormat() {
181
+ return winston_1.default.format.combine(winston_1.default.format.metadata(), winston_1.default.format.timestamp({ format: () => this.devTsFormat() }), this.color(), this.scopeFilter(), winston_1.default.format.printf(({ level: rawLevel, message, timestamp, metadata: rawMetadata }) => {
182
+ const separator = ' '.repeat(3);
183
+ const logLevelColumnWidth = this.noColor ? 5 : 15;
184
+ const level = rawLevel.toLowerCase().padEnd(logLevelColumnWidth, ' ');
185
+ const metadata = this.toPrintable(rawMetadata);
186
+ return [timestamp, level, message + ' ' + picocolors_1.default.dim(metadata)].join(separator);
187
+ }));
188
+ }
189
+ debugProdConsoleFormat() {
190
+ return winston_1.default.format.combine(winston_1.default.format.metadata(), winston_1.default.format.timestamp(), this.color(true), this.scopeFilter(), winston_1.default.format.printf(({ level, message, timestamp, metadata: rawMetadata }) => {
191
+ const metadata = this.toPrintable(rawMetadata);
192
+ return `${timestamp} | ${level.padEnd(5)} | ${message}${metadata ? ' ' + metadata : ''}`;
193
+ }));
194
+ }
195
+ devTsFormat() {
196
+ const now = new Date();
197
+ const pad = (num, digits = 2) => num.toString().padStart(digits, '0');
198
+ const hours = pad(now.getHours());
199
+ const minutes = pad(now.getMinutes());
200
+ const seconds = pad(now.getSeconds());
201
+ const milliseconds = pad(now.getMilliseconds(), 3);
202
+ return `${hours}:${minutes}:${seconds}.${milliseconds}`;
203
+ }
204
+ toPrintable(metadata) {
205
+ if ((0, is_object_literal_1.isObjectLiteral)(metadata) && Object.keys(metadata).length > 0) {
206
+ return environment_1.inProduction
207
+ ? JSON.stringify(metadata)
208
+ : JSON.stringify(metadata)
209
+ .replace(/{"/g, '{ "')
210
+ .replace(/,"/g, ', "')
211
+ .replace(/:/g, ': ')
212
+ .replace(/}/g, ' }');
213
+ }
214
+ return '';
215
+ }
216
+ setFileTransport() {
217
+ const filename = node_path_1.default.isAbsolute(this.globalConfig.logging.file.location)
218
+ ? this.globalConfig.logging.file.location
219
+ : node_path_1.default.join(this.instanceSettingsConfig.n8nFolder, this.globalConfig.logging.file.location);
220
+ const { fileSizeMax, fileCountMax } = this.globalConfig.logging.file;
221
+ this.internalLogger.add(new winston_1.default.transports.File({
222
+ filename,
223
+ format: this.jsonConsoleFormat(),
224
+ maxsize: fileSizeMax * 1_048_576,
225
+ maxFiles: fileCountMax,
226
+ }));
227
+ }
228
+ error(message, metadata = {}) {
229
+ this.log('error', message, metadata);
230
+ }
231
+ warn(message, metadata = {}) {
232
+ this.log('warn', message, metadata);
233
+ }
234
+ info(message, metadata = {}) {
235
+ this.log('info', message, metadata);
236
+ }
237
+ debug(message, metadata = {}) {
238
+ this.log('debug', message, metadata);
239
+ }
240
+ getInternalLogger() {
241
+ return this.internalLogger;
242
+ }
243
+ };
244
+ exports.Logger = Logger;
245
+ exports.Logger = Logger = Logger_1 = __decorate([
246
+ (0, di_1.Service)(),
247
+ __metadata("design:paramtypes", [config_1.GlobalConfig,
248
+ config_1.Inst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AE;QAChD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAMD,iBAAiB;QAChB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC5B,CAAC;CAGD,CAAA;AA1QY,wBAAM;iBAAN,MAAM;IADlB,IAAA,YAAO,GAAE;qCAoBuB,qBAAY;QACF,+BAAsB;GApBpD,MAAM,CA0QlB"}
@@ -0,0 +1,4 @@
1
+ import { UserError } from 'n8n-workflow';
2
+ export declare class MissingModuleError extends UserError {
3
+ constructor(moduleName: string, errorMsg: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MissingModuleError = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class MissingModuleError extends n8n_workflow_1.UserError {
6
+ constructor(moduleName, errorMsg) {
7
+ super(`Failed to load module "${moduleName}": ${errorMsg}. Please review the module's entrypoint file name and the module's directory name.`);
8
+ }
9
+ }
10
+ exports.MissingModuleError = MissingModuleError;
11
+ //# sourceMappingURL=missing-module.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"missing-module.error.js","sourceRoot":"","sources":["../../../src/modules/errors/missing-module.error.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC,MAAa,kBAAmB,SAAQ,wBAAS;IAChD,YAAY,UAAkB,EAAE,QAAgB;QAC/C,KAAK,CACJ,0BAA0B,UAAU,MAAM,QAAQ,oFAAoF,CACtI,CAAC;IACH,CAAC;CACD;AAND,gDAMC"}
@@ -0,0 +1,4 @@
1
+ import { UserError } from 'n8n-workflow';
2
+ export declare class ModuleConfusionError extends UserError {
3
+ constructor(moduleNames: string[]);
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModuleConfusionError = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class ModuleConfusionError extends n8n_workflow_1.UserError {
6
+ constructor(moduleNames) {
7
+ const modules = moduleNames.length > 1 ? 'modules' : 'a module';
8
+ super(`Found ${modules} listed in both \`N8N_ENABLED_MODULES\` and \`N8N_DISABLED_MODULES\`: ${moduleNames.join(', ')}. Please review your environment variables, as a module cannot be both enabled and disabled.`);
9
+ }
10
+ }
11
+ exports.ModuleConfusionError = ModuleConfusionError;
12
+ //# sourceMappingURL=module-confusion.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-confusion.error.js","sourceRoot":"","sources":["../../../src/modules/errors/module-confusion.error.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC,MAAa,oBAAqB,SAAQ,wBAAS;IAClD,YAAY,WAAqB;QAChC,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;QAEhE,KAAK,CACJ,SAAS,OAAO,yEAAyE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,8FAA8F,CAC7M,CAAC;IACH,CAAC;CACD;AARD,oDAQC"}
@@ -0,0 +1,4 @@
1
+ import { UnexpectedError } from 'n8n-workflow';
2
+ export declare class UnknownModuleError extends UnexpectedError {
3
+ constructor(moduleName: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownModuleError = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class UnknownModuleError extends n8n_workflow_1.UnexpectedError {
6
+ constructor(moduleName) {
7
+ super(`Unknown module "${moduleName}"`, { level: 'fatal' });
8
+ }
9
+ }
10
+ exports.UnknownModuleError = UnknownModuleError;
11
+ //# sourceMappingURL=unknown-module.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown-module.error.js","sourceRoot":"","sources":["../../../src/modules/errors/unknown-module.error.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,MAAa,kBAAmB,SAAQ,8BAAe;IACtD,YAAY,UAAkB;QAC7B,KAAK,CAAC,mBAAmB,UAAU,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;CACD;AAJD,gDAIC"}
@@ -0,0 +1,27 @@
1
+ import type { InstanceType } from '@n8n/constants';
2
+ import { ModuleMetadata } from '@n8n/decorators';
3
+ import type { EntityClass, ModuleContext, ModuleSettings } from '@n8n/decorators';
4
+ import { ModulesConfig } from './modules.config';
5
+ import type { ModuleName } from './modules.config';
6
+ import { LicenseState } from '../license-state';
7
+ import { Logger } from '../logging/logger';
8
+ export declare class ModuleRegistry {
9
+ private readonly moduleMetadata;
10
+ private readonly licenseState;
11
+ private readonly logger;
12
+ private readonly modulesConfig;
13
+ readonly entities: EntityClass[];
14
+ readonly loadDirs: string[];
15
+ readonly settings: Map<string, ModuleSettings>;
16
+ readonly context: Map<string, ModuleContext>;
17
+ constructor(moduleMetadata: ModuleMetadata, licenseState: LicenseState, logger: Logger, modulesConfig: ModulesConfig);
18
+ private readonly defaultModules;
19
+ private readonly activeModules;
20
+ get eligibleModules(): ModuleName[];
21
+ loadModules(modules?: ModuleName[]): Promise<void>;
22
+ initModules(instanceType: InstanceType): Promise<void>;
23
+ refreshModuleSettings(moduleName: ModuleName): Promise<ModuleSettings | null>;
24
+ shutdownModule(moduleName: ModuleName): Promise<void>;
25
+ isActive(moduleName: ModuleName): boolean;
26
+ getActiveModules(): string[];
27
+ }
@@ -0,0 +1,187 @@
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.ModuleRegistry = void 0;
49
+ const decorators_1 = require("@n8n/decorators");
50
+ const di_1 = require("@n8n/di");
51
+ const fs_1 = require("fs");
52
+ const path_1 = __importDefault(require("path"));
53
+ const missing_module_error_1 = require("./errors/missing-module.error");
54
+ const module_confusion_error_1 = require("./errors/module-confusion.error");
55
+ const modules_config_1 = require("./modules.config");
56
+ const license_state_1 = require("../license-state");
57
+ const logger_1 = require("../logging/logger");
58
+ let ModuleRegistry = class ModuleRegistry {
59
+ constructor(moduleMetadata, licenseState, logger, modulesConfig) {
60
+ this.moduleMetadata = moduleMetadata;
61
+ this.licenseState = licenseState;
62
+ this.logger = logger;
63
+ this.modulesConfig = modulesConfig;
64
+ this.entities = [];
65
+ this.loadDirs = [];
66
+ this.settings = new Map();
67
+ this.context = new Map();
68
+ this.defaultModules = [
69
+ 'insights',
70
+ 'external-secrets',
71
+ 'community-packages',
72
+ 'data-table',
73
+ 'mcp',
74
+ 'provisioning',
75
+ 'breaking-changes',
76
+ 'dynamic-credentials',
77
+ 'chat-hub',
78
+ ];
79
+ this.activeModules = [];
80
+ }
81
+ get eligibleModules() {
82
+ const { enabledModules, disabledModules } = this.modulesConfig;
83
+ const doubleListed = enabledModules.filter((m) => disabledModules.includes(m));
84
+ if (doubleListed.length > 0)
85
+ throw new module_confusion_error_1.ModuleConfusionError(doubleListed);
86
+ const defaultPlusEnabled = [...new Set([...this.defaultModules, ...enabledModules])];
87
+ return defaultPlusEnabled.filter((m) => !disabledModules.includes(m));
88
+ }
89
+ async loadModules(modules) {
90
+ let modulesDir;
91
+ try {
92
+ const n8nPackagePath = require.resolve('n8n/package.json');
93
+ const n8nRoot = path_1.default.dirname(n8nPackagePath);
94
+ const srcDirExists = (0, fs_1.existsSync)(path_1.default.join(n8nRoot, 'src'));
95
+ const dir = process.env.NODE_ENV === 'test' && srcDirExists ? 'src' : 'dist';
96
+ modulesDir = path_1.default.join(n8nRoot, dir, 'modules');
97
+ }
98
+ catch {
99
+ modulesDir = path_1.default.resolve(process.argv[1], '../../dist/modules');
100
+ }
101
+ for (const moduleName of modules ?? this.eligibleModules) {
102
+ try {
103
+ await Promise.resolve(`${`${modulesDir}/${moduleName}/${moduleName}.module`}`).then(s => __importStar(require(s)));
104
+ }
105
+ catch {
106
+ try {
107
+ await Promise.resolve(`${`${modulesDir}/${moduleName}.ee/${moduleName}.module`}`).then(s => __importStar(require(s)));
108
+ }
109
+ catch (error) {
110
+ throw new missing_module_error_1.MissingModuleError(moduleName, error instanceof Error ? error.message : '');
111
+ }
112
+ }
113
+ }
114
+ for (const ModuleClass of this.moduleMetadata.getClasses()) {
115
+ const entities = await di_1.Container.get(ModuleClass).entities?.();
116
+ if (entities?.length)
117
+ this.entities.push(...entities);
118
+ const loadDir = await di_1.Container.get(ModuleClass).loadDir?.();
119
+ if (loadDir)
120
+ this.loadDirs.push(loadDir);
121
+ }
122
+ }
123
+ async initModules(instanceType) {
124
+ for (const [moduleName, moduleEntry] of this.moduleMetadata.getEntries()) {
125
+ const { licenseFlag, instanceTypes, class: ModuleClass } = moduleEntry;
126
+ if (licenseFlag !== undefined && !this.licenseState.isLicensed(licenseFlag)) {
127
+ this.logger.debug(`Skipped init for unlicensed module "${moduleName}"`);
128
+ continue;
129
+ }
130
+ if (instanceTypes !== undefined && !instanceTypes.includes(instanceType)) {
131
+ this.logger.debug(`Skipped init for module "${moduleName}" (instance type "${instanceType}" not in: ${instanceTypes.join(', ')})`);
132
+ continue;
133
+ }
134
+ await di_1.Container.get(ModuleClass).init?.();
135
+ const moduleSettings = await di_1.Container.get(ModuleClass).settings?.();
136
+ if (moduleSettings)
137
+ this.settings.set(moduleName, moduleSettings);
138
+ const moduleContext = await di_1.Container.get(ModuleClass).context?.();
139
+ if (moduleContext)
140
+ this.context.set(moduleName, moduleContext);
141
+ this.logger.debug(`Initialized module "${moduleName}"`);
142
+ this.activeModules.push(moduleName);
143
+ }
144
+ }
145
+ async refreshModuleSettings(moduleName) {
146
+ const moduleEntry = this.moduleMetadata.get(moduleName);
147
+ if (!moduleEntry) {
148
+ this.logger.debug('Skipping settings refresh for unregistered module', { moduleName });
149
+ return null;
150
+ }
151
+ const moduleSettings = await di_1.Container.get(moduleEntry.class).settings?.();
152
+ if (moduleSettings) {
153
+ this.settings.set(moduleName, moduleSettings);
154
+ }
155
+ else {
156
+ this.settings.delete(moduleName);
157
+ }
158
+ return moduleSettings ?? null;
159
+ }
160
+ async shutdownModule(moduleName) {
161
+ const moduleEntry = this.moduleMetadata.get(moduleName);
162
+ if (!moduleEntry) {
163
+ this.logger.debug('Skipping shutdown for unregistered module', { moduleName });
164
+ return;
165
+ }
166
+ await di_1.Container.get(moduleEntry.class).shutdown?.();
167
+ const index = this.activeModules.indexOf(moduleName);
168
+ if (index > -1)
169
+ this.activeModules.splice(index, 1);
170
+ this.logger.debug(`Shut down module "${moduleName}"`);
171
+ }
172
+ isActive(moduleName) {
173
+ return this.activeModules.includes(moduleName);
174
+ }
175
+ getActiveModules() {
176
+ return this.activeModules;
177
+ }
178
+ };
179
+ exports.ModuleRegistry = ModuleRegistry;
180
+ exports.ModuleRegistry = ModuleRegistry = __decorate([
181
+ (0, di_1.Service)(),
182
+ __metadata("design:paramtypes", [decorators_1.ModuleMetadata,
183
+ license_state_1.LicenseState,
184
+ logger_1.Logger,
185
+ modules_config_1.ModulesConfig])
186
+ ], ModuleRegistry);
187
+ //# sourceMappingURL=module-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-registry.js","sourceRoot":"","sources":["../../src/modules/module-registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAAiD;AAEjD,gCAA6C;AAC7C,2BAAgC;AAChC,gDAAwB;AAExB,wEAAmE;AACnE,4EAAuE;AACvE,qDAAiD;AAEjD,oDAAgD;AAChD,8CAA2C;AAGpC,IAAM,cAAc,GAApB,MAAM,cAAc;IAS1B,YACkB,cAA8B,EAC9B,YAA0B,EAC1B,MAAc,EACd,aAA4B;QAH5B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAQ;QACd,kBAAa,GAAb,aAAa,CAAe;QA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AC,UAAU,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,CAAC,CAAC;YAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,UAAU,GAAG,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ,CAAC,UAAsB;QAC9B,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD,CAAA;AAjLY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,YAAO,GAAE;qCAWyB,2BAAc;QAChB,4BAAY;QAClB,eAAM;QACC,8BAAa;GAblC,cAAc,CAiL1B"}
@@ -0,0 +1,11 @@
1
+ import { CommaSeparatedStringArray } from '@n8n/config';
2
+ export declare const MODULE_NAMES: readonly ["insights", "external-secrets", "community-packages", "data-table", "mcp", "provisioning", "breaking-changes", "dynamic-credentials", "chat-hub"];
3
+ export type ModuleName = (typeof MODULE_NAMES)[number];
4
+ declare class ModuleArray extends CommaSeparatedStringArray<ModuleName> {
5
+ constructor(str: string);
6
+ }
7
+ export declare class ModulesConfig {
8
+ enabledModules: ModuleArray;
9
+ disabledModules: ModuleArray;
10
+ }
11
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ModulesConfig = exports.MODULE_NAMES = void 0;
13
+ const config_1 = require("@n8n/config");
14
+ const unknown_module_error_1 = require("./errors/unknown-module.error");
15
+ exports.MODULE_NAMES = [
16
+ 'insights',
17
+ 'external-secrets',
18
+ 'community-packages',
19
+ 'data-table',
20
+ 'mcp',
21
+ 'provisioning',
22
+ 'breaking-changes',
23
+ 'dynamic-credentials',
24
+ 'chat-hub',
25
+ ];
26
+ class ModuleArray extends config_1.CommaSeparatedStringArray {
27
+ constructor(str) {
28
+ super(str);
29
+ for (const moduleName of this) {
30
+ if (!exports.MODULE_NAMES.includes(moduleName))
31
+ throw new unknown_module_error_1.UnknownModuleError(moduleName);
32
+ }
33
+ }
34
+ }
35
+ let ModulesConfig = class ModulesConfig {
36
+ constructor() {
37
+ this.enabledModules = [];
38
+ this.disabledModules = [];
39
+ }
40
+ };
41
+ exports.ModulesConfig = ModulesConfig;
42
+ __decorate([
43
+ (0, config_1.Env)('N8N_ENABLED_MODULES'),
44
+ __metadata("design:type", ModuleArray)
45
+ ], ModulesConfig.prototype, "enabledModules", void 0);
46
+ __decorate([
47
+ (0, config_1.Env)('N8N_DISABLED_MODULES'),
48
+ __metadata("design:type", ModuleArray)
49
+ ], ModulesConfig.prototype, "disabledModules", void 0);
50
+ exports.ModulesConfig = ModulesConfig = __decorate([
51
+ config_1.Config
52
+ ], ModulesConfig);
53
+ //# sourceMappingURL=modules.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.config.js","sourceRoot":"","sources":["../../src/modules/modules.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAqE;AAErE,wEAAmE;AAEtD,QAAA,YAAY,GAAG;IAC3B,UAAU;IACV,kBAAkB;IAClB,oBAAoB;IACpB,YAAY;IACZ,KAAK;IACL,cAAc;IACd,kBAAkB;IAClB,qBAAqB;IACrB,UAAU;CACD,CAAC;AAIX,MAAM,WAAY,SAAQ,kCAAqC;IAC9D,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,KAAK,MAAM,UAAU,IAAI,IAAI,EAAE,CAAC;YAC/B,IAAI,CAAC,oBAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAAE,MAAM,IAAI,yCAAkB,CAAC,UAAU,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;CACD;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;IAAnB;QAGN,mBAAc,GAAgB,EAAE,CAAC;QAIjC,oBAAe,GAAgB,EAAE,CAAC;IACnC,CAAC;CAAA,CAAA;AARY,sCAAa;AAGzB;IADC,IAAA,YAAG,EAAC,qBAAqB,CAAC;8BACX,WAAW;qDAAM;AAIjC;IADC,IAAA,YAAG,EAAC,sBAAsB,CAAC;8BACX,WAAW;sDAAM;wBAPtB,aAAa;IADzB,eAAM;GACM,aAAa,CAQzB"}
@@ -0,0 +1,12 @@
1
+ import type { BooleanLicenseFeature, NumericLicenseFeature } from '@n8n/constants';
2
+ export type FeatureReturnType = Partial<{
3
+ planName: string;
4
+ } & {
5
+ [K in NumericLicenseFeature]: number;
6
+ } & {
7
+ [K in BooleanLicenseFeature]: boolean;
8
+ }>;
9
+ export interface LicenseProvider {
10
+ isLicensed(feature: BooleanLicenseFeature): boolean;
11
+ getValue<T extends keyof FeatureReturnType>(feature: T): FeatureReturnType[T];
12
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map