@n8n/decorators 0.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.
- package/LICENSE.md +88 -0
- package/LICENSE_EE.md +27 -0
- package/dist/args.d.ts +3 -0
- package/dist/args.js +14 -0
- package/dist/args.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -0
- package/dist/controller-registry-metadata.d.ts +7 -0
- package/dist/controller-registry-metadata.js +45 -0
- package/dist/controller-registry-metadata.js.map +1 -0
- package/dist/debounce.d.ts +1 -0
- package/dist/debounce.js +20 -0
- package/dist/debounce.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/licensed.d.ts +2 -0
- package/dist/licensed.js +11 -0
- package/dist/licensed.js.map +1 -0
- package/dist/memoized.d.ts +1 -0
- package/dist/memoized.js +23 -0
- package/dist/memoized.js.map +1 -0
- package/dist/middleware.d.ts +1 -0
- package/dist/middleware.js +11 -0
- package/dist/middleware.js.map +1 -0
- package/dist/module.d.ts +14 -0
- package/dist/module.js +39 -0
- package/dist/module.js.map +1 -0
- package/dist/multi-main-metadata.d.ts +17 -0
- package/dist/multi-main-metadata.js +28 -0
- package/dist/multi-main-metadata.js.map +1 -0
- package/dist/on-multi-main-event.d.ts +6 -0
- package/dist/on-multi-main-event.js +29 -0
- package/dist/on-multi-main-event.js.map +1 -0
- package/dist/on-shutdown.d.ts +1 -0
- package/dist/on-shutdown.js +20 -0
- package/dist/on-shutdown.js.map +1 -0
- package/dist/redactable.d.ts +7 -0
- package/dist/redactable.js +34 -0
- package/dist/redactable.js.map +1 -0
- package/dist/rest-controller.d.ts +1 -0
- package/dist/rest-controller.js +12 -0
- package/dist/rest-controller.js.map +1 -0
- package/dist/route.d.ts +14 -0
- package/dist/route.js +20 -0
- package/dist/route.js.map +1 -0
- package/dist/scoped.d.ts +3 -0
- package/dist/scoped.js +14 -0
- package/dist/scoped.js.map +1 -0
- package/dist/shutdown/constants.d.ts +3 -0
- package/dist/shutdown/constants.js +7 -0
- package/dist/shutdown/constants.js.map +1 -0
- package/dist/shutdown-registry-metadata.d.ts +7 -0
- package/dist/shutdown-registry-metadata.js +36 -0
- package/dist/shutdown-registry-metadata.js.map +1 -0
- package/dist/types.d.ts +45 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ControllerRegistryMetadata = void 0;
|
|
10
|
+
const di_1 = require("@n8n/di");
|
|
11
|
+
let ControllerRegistryMetadata = class ControllerRegistryMetadata {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.registry = new Map();
|
|
14
|
+
}
|
|
15
|
+
getControllerMetadata(controllerClass) {
|
|
16
|
+
let metadata = this.registry.get(controllerClass);
|
|
17
|
+
if (!metadata) {
|
|
18
|
+
metadata = {
|
|
19
|
+
basePath: '/',
|
|
20
|
+
middlewares: [],
|
|
21
|
+
routes: new Map(),
|
|
22
|
+
};
|
|
23
|
+
this.registry.set(controllerClass, metadata);
|
|
24
|
+
}
|
|
25
|
+
return metadata;
|
|
26
|
+
}
|
|
27
|
+
getRouteMetadata(controllerClass, handlerName) {
|
|
28
|
+
const metadata = this.getControllerMetadata(controllerClass);
|
|
29
|
+
let route = metadata.routes.get(handlerName);
|
|
30
|
+
if (!route) {
|
|
31
|
+
route = {};
|
|
32
|
+
route.args = [];
|
|
33
|
+
metadata.routes.set(handlerName, route);
|
|
34
|
+
}
|
|
35
|
+
return route;
|
|
36
|
+
}
|
|
37
|
+
get controllerClasses() {
|
|
38
|
+
return this.registry.keys();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.ControllerRegistryMetadata = ControllerRegistryMetadata;
|
|
42
|
+
exports.ControllerRegistryMetadata = ControllerRegistryMetadata = __decorate([
|
|
43
|
+
(0, di_1.Service)()
|
|
44
|
+
], ControllerRegistryMetadata);
|
|
45
|
+
//# sourceMappingURL=controller-registry-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-registry-metadata.js","sourceRoot":"","sources":["../src/controller-registry-metadata.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gCAAkC;AAK3B,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QACE,aAAQ,GAAG,IAAI,GAAG,EAAkC,CAAC;IA6B9D,CAAC;IA3BA,qBAAqB,CAAC,eAA2B;QAChD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,QAAQ,GAAG;gBACV,QAAQ,EAAE,GAAG;gBACb,WAAW,EAAE,EAAE;gBACf,MAAM,EAAE,IAAI,GAAG,EAAE;aACjB,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,gBAAgB,CAAC,eAA2B,EAAE,WAAwB;QACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;QAC7D,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,KAAK,GAAG,EAAmB,CAAC;YAC5B,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;YAChB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,iBAAiB;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;CACD,CAAA;AA9BY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,YAAO,GAAE;GACG,0BAA0B,CA8BtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Debounce: (waitMs: number) => MethodDecorator;
|
package/dist/debounce.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Debounce = void 0;
|
|
7
|
+
const debounce_1 = __importDefault(require("lodash/debounce"));
|
|
8
|
+
const Debounce = (waitMs) => (_, methodName, originalDescriptor) => ({
|
|
9
|
+
configurable: true,
|
|
10
|
+
get() {
|
|
11
|
+
const debouncedFn = (0, debounce_1.default)(originalDescriptor.value, waitMs);
|
|
12
|
+
Object.defineProperty(this, methodName, {
|
|
13
|
+
configurable: false,
|
|
14
|
+
value: debouncedFn,
|
|
15
|
+
});
|
|
16
|
+
return debouncedFn;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
exports.Debounce = Debounce;
|
|
20
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../src/debounce.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuC;AAiBhC,MAAM,QAAQ,GACpB,CAAC,MAAc,EAAmB,EAAE,CACpC,CACC,CAAS,EACT,UAA2B,EAC3B,kBAAsC,EACT,EAAE,CAAC,CAAC;IACjC,YAAY,EAAE,IAAI;IAElB,GAAG;QACF,MAAM,WAAW,GAAG,IAAA,kBAAQ,EAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE/D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE;YACvC,YAAY,EAAE,KAAK;YACnB,KAAK,EAAE,WAAW;SAClB,CAAC,CAAC;QAEH,OAAO,WAAgB,CAAC;IACzB,CAAC;CACD,CAAC,CAAC;AAnBS,QAAA,QAAQ,YAmBjB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Body, Query, Param } from './args';
|
|
2
|
+
export { RestController } from './rest-controller';
|
|
3
|
+
export { Get, Post, Put, Patch, Delete } from './route';
|
|
4
|
+
export { Middleware } from './middleware';
|
|
5
|
+
export { ControllerRegistryMetadata } from './controller-registry-metadata';
|
|
6
|
+
export { Licensed } from './licensed';
|
|
7
|
+
export { GlobalScope, ProjectScope } from './scoped';
|
|
8
|
+
export { HIGHEST_SHUTDOWN_PRIORITY, DEFAULT_SHUTDOWN_PRIORITY, LOWEST_SHUTDOWN_PRIORITY, } from './shutdown/constants';
|
|
9
|
+
export { ShutdownRegistryMetadata } from './shutdown-registry-metadata';
|
|
10
|
+
export { ModuleRegistry } from './module';
|
|
11
|
+
export { OnShutdown } from './on-shutdown';
|
|
12
|
+
export { Redactable } from './redactable';
|
|
13
|
+
export { BaseN8nModule, N8nModule } from './module';
|
|
14
|
+
export { Debounce } from './debounce';
|
|
15
|
+
export type { AccessScope, Controller, RateLimit } from './types';
|
|
16
|
+
export type { ShutdownHandler } from './types';
|
|
17
|
+
export { MultiMainMetadata } from './multi-main-metadata';
|
|
18
|
+
export { OnLeaderTakeover, OnLeaderStepdown } from './on-multi-main-event';
|
|
19
|
+
export { Memoized } from './memoized';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Memoized = exports.OnLeaderStepdown = exports.OnLeaderTakeover = exports.MultiMainMetadata = exports.Debounce = exports.N8nModule = exports.Redactable = exports.OnShutdown = exports.ModuleRegistry = exports.ShutdownRegistryMetadata = exports.LOWEST_SHUTDOWN_PRIORITY = exports.DEFAULT_SHUTDOWN_PRIORITY = exports.HIGHEST_SHUTDOWN_PRIORITY = exports.ProjectScope = exports.GlobalScope = exports.Licensed = exports.ControllerRegistryMetadata = exports.Middleware = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.RestController = exports.Param = exports.Query = exports.Body = void 0;
|
|
4
|
+
var args_1 = require("./args");
|
|
5
|
+
Object.defineProperty(exports, "Body", { enumerable: true, get: function () { return args_1.Body; } });
|
|
6
|
+
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return args_1.Query; } });
|
|
7
|
+
Object.defineProperty(exports, "Param", { enumerable: true, get: function () { return args_1.Param; } });
|
|
8
|
+
var rest_controller_1 = require("./rest-controller");
|
|
9
|
+
Object.defineProperty(exports, "RestController", { enumerable: true, get: function () { return rest_controller_1.RestController; } });
|
|
10
|
+
var route_1 = require("./route");
|
|
11
|
+
Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return route_1.Get; } });
|
|
12
|
+
Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return route_1.Post; } });
|
|
13
|
+
Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return route_1.Put; } });
|
|
14
|
+
Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return route_1.Patch; } });
|
|
15
|
+
Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return route_1.Delete; } });
|
|
16
|
+
var middleware_1 = require("./middleware");
|
|
17
|
+
Object.defineProperty(exports, "Middleware", { enumerable: true, get: function () { return middleware_1.Middleware; } });
|
|
18
|
+
var controller_registry_metadata_1 = require("./controller-registry-metadata");
|
|
19
|
+
Object.defineProperty(exports, "ControllerRegistryMetadata", { enumerable: true, get: function () { return controller_registry_metadata_1.ControllerRegistryMetadata; } });
|
|
20
|
+
var licensed_1 = require("./licensed");
|
|
21
|
+
Object.defineProperty(exports, "Licensed", { enumerable: true, get: function () { return licensed_1.Licensed; } });
|
|
22
|
+
var scoped_1 = require("./scoped");
|
|
23
|
+
Object.defineProperty(exports, "GlobalScope", { enumerable: true, get: function () { return scoped_1.GlobalScope; } });
|
|
24
|
+
Object.defineProperty(exports, "ProjectScope", { enumerable: true, get: function () { return scoped_1.ProjectScope; } });
|
|
25
|
+
var constants_1 = require("./shutdown/constants");
|
|
26
|
+
Object.defineProperty(exports, "HIGHEST_SHUTDOWN_PRIORITY", { enumerable: true, get: function () { return constants_1.HIGHEST_SHUTDOWN_PRIORITY; } });
|
|
27
|
+
Object.defineProperty(exports, "DEFAULT_SHUTDOWN_PRIORITY", { enumerable: true, get: function () { return constants_1.DEFAULT_SHUTDOWN_PRIORITY; } });
|
|
28
|
+
Object.defineProperty(exports, "LOWEST_SHUTDOWN_PRIORITY", { enumerable: true, get: function () { return constants_1.LOWEST_SHUTDOWN_PRIORITY; } });
|
|
29
|
+
var shutdown_registry_metadata_1 = require("./shutdown-registry-metadata");
|
|
30
|
+
Object.defineProperty(exports, "ShutdownRegistryMetadata", { enumerable: true, get: function () { return shutdown_registry_metadata_1.ShutdownRegistryMetadata; } });
|
|
31
|
+
var module_1 = require("./module");
|
|
32
|
+
Object.defineProperty(exports, "ModuleRegistry", { enumerable: true, get: function () { return module_1.ModuleRegistry; } });
|
|
33
|
+
var on_shutdown_1 = require("./on-shutdown");
|
|
34
|
+
Object.defineProperty(exports, "OnShutdown", { enumerable: true, get: function () { return on_shutdown_1.OnShutdown; } });
|
|
35
|
+
var redactable_1 = require("./redactable");
|
|
36
|
+
Object.defineProperty(exports, "Redactable", { enumerable: true, get: function () { return redactable_1.Redactable; } });
|
|
37
|
+
var module_2 = require("./module");
|
|
38
|
+
Object.defineProperty(exports, "N8nModule", { enumerable: true, get: function () { return module_2.N8nModule; } });
|
|
39
|
+
var debounce_1 = require("./debounce");
|
|
40
|
+
Object.defineProperty(exports, "Debounce", { enumerable: true, get: function () { return debounce_1.Debounce; } });
|
|
41
|
+
var multi_main_metadata_1 = require("./multi-main-metadata");
|
|
42
|
+
Object.defineProperty(exports, "MultiMainMetadata", { enumerable: true, get: function () { return multi_main_metadata_1.MultiMainMetadata; } });
|
|
43
|
+
var on_multi_main_event_1 = require("./on-multi-main-event");
|
|
44
|
+
Object.defineProperty(exports, "OnLeaderTakeover", { enumerable: true, get: function () { return on_multi_main_event_1.OnLeaderTakeover; } });
|
|
45
|
+
Object.defineProperty(exports, "OnLeaderStepdown", { enumerable: true, get: function () { return on_multi_main_event_1.OnLeaderStepdown; } });
|
|
46
|
+
var memoized_1 = require("./memoized");
|
|
47
|
+
Object.defineProperty(exports, "Memoized", { enumerable: true, get: function () { return memoized_1.Memoized; } });
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAA4C;AAAnC,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AAAE,6FAAA,KAAK,OAAA;AAC3B,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,iCAAwD;AAA/C,4FAAA,GAAG,OAAA;AAAE,6FAAA,IAAI,OAAA;AAAE,4FAAA,GAAG,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,+FAAA,MAAM,OAAA;AACtC,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+EAA4E;AAAnE,0IAAA,0BAA0B,OAAA;AACnC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAqD;AAA5C,qGAAA,WAAW,OAAA;AAAE,sGAAA,YAAY,OAAA;AAClC,kDAI8B;AAH7B,sHAAA,yBAAyB,OAAA;AACzB,sHAAA,yBAAyB,OAAA;AACzB,qHAAA,wBAAwB,OAAA;AAEzB,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA;AACjC,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAAoD;AAA5B,mGAAA,SAAS,OAAA;AACjC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAGjB,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,6DAA2E;AAAlE,uHAAA,gBAAgB,OAAA;AAAE,uHAAA,gBAAgB,OAAA;AAC3C,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA"}
|
package/dist/licensed.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Licensed = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const controller_registry_metadata_1 = require("./controller-registry-metadata");
|
|
6
|
+
const Licensed = (licenseFeature) => (target, handlerName) => {
|
|
7
|
+
const routeMetadata = di_1.Container.get(controller_registry_metadata_1.ControllerRegistryMetadata).getRouteMetadata(target.constructor, String(handlerName));
|
|
8
|
+
routeMetadata.licenseFeature = licenseFeature;
|
|
9
|
+
};
|
|
10
|
+
exports.Licensed = Licensed;
|
|
11
|
+
//# sourceMappingURL=licensed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"licensed.js","sourceRoot":"","sources":["../src/licensed.ts"],"names":[],"mappings":";;;AACA,gCAAoC;AAEpC,iFAA4E;AAGrE,MAAM,QAAQ,GACpB,CAAC,cAAqC,EAAmB,EAAE,CAC3D,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;IACvB,MAAM,aAAa,GAAG,cAAS,CAAC,GAAG,CAAC,yDAA0B,CAAC,CAAC,gBAAgB,CAC/E,MAAM,CAAC,WAAyB,EAChC,MAAM,CAAC,WAAW,CAAC,CACnB,CAAC;IACF,aAAa,CAAC,cAAc,GAAG,cAAc,CAAC;AAC/C,CAAC,CAAC;AARU,QAAA,QAAQ,YAQlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Memoized<T = unknown>(target: object, propertyKey: string | symbol, descriptor?: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
package/dist/memoized.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Memoized = Memoized;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
function Memoized(target, propertyKey, descriptor) {
|
|
9
|
+
const originalGetter = descriptor?.get;
|
|
10
|
+
(0, node_assert_1.default)(originalGetter, '@Memoized can only be used on getters');
|
|
11
|
+
descriptor.get = function () {
|
|
12
|
+
const value = originalGetter.call(this);
|
|
13
|
+
Object.defineProperty(this, propertyKey, {
|
|
14
|
+
value,
|
|
15
|
+
configurable: false,
|
|
16
|
+
enumerable: false,
|
|
17
|
+
writable: false,
|
|
18
|
+
});
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
return descriptor;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=memoized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoized.js","sourceRoot":"","sources":["../src/memoized.ts"],"names":[],"mappings":";;;;;AAkBA,4BAsBC;AAxCD,8DAAiC;AAkBjC,SAAgB,QAAQ,CACvB,MAAc,EACd,WAA4B,EAC5B,UAAuC;IAEvC,MAAM,cAAc,GAAG,UAAU,EAAE,GAAG,CAAC;IACvC,IAAA,qBAAM,EAAC,cAAc,EAAE,uCAAuC,CAAC,CAAC;IAGhE,UAAU,CAAC,GAAG,GAAG;QAChB,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE;YACxC,KAAK;YACL,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SACf,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Middleware: () => MethodDecorator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Middleware = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const controller_registry_metadata_1 = require("./controller-registry-metadata");
|
|
6
|
+
const Middleware = () => (target, handlerName) => {
|
|
7
|
+
const metadata = di_1.Container.get(controller_registry_metadata_1.ControllerRegistryMetadata).getControllerMetadata(target.constructor);
|
|
8
|
+
metadata.middlewares.push(String(handlerName));
|
|
9
|
+
};
|
|
10
|
+
exports.Middleware = Middleware;
|
|
11
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AAEpC,iFAA4E;AAGrE,MAAM,UAAU,GAAG,GAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;IACxE,MAAM,QAAQ,GAAG,cAAS,CAAC,GAAG,CAAC,yDAA0B,CAAC,CAAC,qBAAqB,CAC/E,MAAM,CAAC,WAAyB,CAChC,CAAC;IACF,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AALW,QAAA,UAAU,cAKrB"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Constructable } from '@n8n/di';
|
|
2
|
+
export type ExecutionLifecycleHooks = object;
|
|
3
|
+
export interface BaseN8nModule {
|
|
4
|
+
initialize?(): void;
|
|
5
|
+
registerLifecycleHooks?(hooks: ExecutionLifecycleHooks): void;
|
|
6
|
+
}
|
|
7
|
+
type Module = Constructable<BaseN8nModule>;
|
|
8
|
+
export declare const registry: Set<Module>;
|
|
9
|
+
export declare const N8nModule: () => ClassDecorator;
|
|
10
|
+
export declare class ModuleRegistry {
|
|
11
|
+
initializeModules(): void;
|
|
12
|
+
registerLifecycleHooks(hooks: ExecutionLifecycleHooks): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ModuleRegistry = exports.N8nModule = exports.registry = void 0;
|
|
10
|
+
const di_1 = require("@n8n/di");
|
|
11
|
+
exports.registry = new Set();
|
|
12
|
+
const N8nModule = () => (target) => {
|
|
13
|
+
exports.registry.add(target);
|
|
14
|
+
return (0, di_1.Service)()(target);
|
|
15
|
+
};
|
|
16
|
+
exports.N8nModule = N8nModule;
|
|
17
|
+
let ModuleRegistry = class ModuleRegistry {
|
|
18
|
+
initializeModules() {
|
|
19
|
+
for (const ModuleClass of exports.registry.keys()) {
|
|
20
|
+
const instance = di_1.Container.get(ModuleClass);
|
|
21
|
+
if (instance.initialize) {
|
|
22
|
+
instance.initialize();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
registerLifecycleHooks(hooks) {
|
|
27
|
+
for (const ModuleClass of exports.registry.keys()) {
|
|
28
|
+
const instance = di_1.Container.get(ModuleClass);
|
|
29
|
+
if (instance.registerLifecycleHooks) {
|
|
30
|
+
instance.registerLifecycleHooks(hooks);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.ModuleRegistry = ModuleRegistry;
|
|
36
|
+
exports.ModuleRegistry = ModuleRegistry = __decorate([
|
|
37
|
+
(0, di_1.Service)()
|
|
38
|
+
], ModuleRegistry);
|
|
39
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gCAAiE;AAcpD,QAAA,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;AAEnC,MAAM,SAAS,GAAG,GAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IACzD,gBAAQ,CAAC,GAAG,CAAC,MAA2B,CAAC,CAAC;IAG1C,OAAO,IAAA,YAAO,GAAE,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB;AAGK,IAAM,cAAc,GAApB,MAAM,cAAc;IAC1B,iBAAiB;QAChB,KAAK,MAAM,WAAW,IAAI,gBAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAG,cAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAC5C,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACzB,QAAQ,CAAC,UAAU,EAAE,CAAC;YACvB,CAAC;QACF,CAAC;IACF,CAAC;IAED,sBAAsB,CAAC,KAA8B;QACpD,KAAK,MAAM,WAAW,IAAI,gBAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAG,cAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAC5C,IAAI,QAAQ,CAAC,sBAAsB,EAAE,CAAC;gBACrC,QAAQ,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AAlBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,YAAO,GAAE;GACG,cAAc,CAkB1B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Class } from './types';
|
|
2
|
+
export declare const LEADER_TAKEOVER_EVENT_NAME = "leader-takeover";
|
|
3
|
+
export declare const LEADER_STEPDOWN_EVENT_NAME = "leader-stepdown";
|
|
4
|
+
export type MultiMainEvent = typeof LEADER_TAKEOVER_EVENT_NAME | typeof LEADER_STEPDOWN_EVENT_NAME;
|
|
5
|
+
type EventHandlerFn = () => Promise<void> | void;
|
|
6
|
+
export type EventHandlerClass = Class<Record<string, EventHandlerFn>>;
|
|
7
|
+
type EventHandler = {
|
|
8
|
+
eventHandlerClass: EventHandlerClass;
|
|
9
|
+
methodName: string;
|
|
10
|
+
eventName: MultiMainEvent;
|
|
11
|
+
};
|
|
12
|
+
export declare class MultiMainMetadata {
|
|
13
|
+
private readonly handlers;
|
|
14
|
+
register(handler: EventHandler): void;
|
|
15
|
+
getHandlers(): EventHandler[];
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MultiMainMetadata = exports.LEADER_STEPDOWN_EVENT_NAME = exports.LEADER_TAKEOVER_EVENT_NAME = void 0;
|
|
10
|
+
const di_1 = require("@n8n/di");
|
|
11
|
+
exports.LEADER_TAKEOVER_EVENT_NAME = 'leader-takeover';
|
|
12
|
+
exports.LEADER_STEPDOWN_EVENT_NAME = 'leader-stepdown';
|
|
13
|
+
let MultiMainMetadata = class MultiMainMetadata {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.handlers = [];
|
|
16
|
+
}
|
|
17
|
+
register(handler) {
|
|
18
|
+
this.handlers.push(handler);
|
|
19
|
+
}
|
|
20
|
+
getHandlers() {
|
|
21
|
+
return this.handlers;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.MultiMainMetadata = MultiMainMetadata;
|
|
25
|
+
exports.MultiMainMetadata = MultiMainMetadata = __decorate([
|
|
26
|
+
(0, di_1.Service)()
|
|
27
|
+
], MultiMainMetadata);
|
|
28
|
+
//# sourceMappingURL=multi-main-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-main-metadata.js","sourceRoot":"","sources":["../src/multi-main-metadata.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gCAAkC;AAIrB,QAAA,0BAA0B,GAAG,iBAAiB,CAAC;AAC/C,QAAA,0BAA0B,GAAG,iBAAiB,CAAC;AAoBrD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QACW,aAAQ,GAAmB,EAAE,CAAC;IAShD,CAAC;IAPA,QAAQ,CAAC,OAAqB;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED,WAAW;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACD,CAAA;AAVY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,YAAO,GAAE;GACG,iBAAiB,CAU7B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UnexpectedError } from 'n8n-workflow';
|
|
2
|
+
export declare class NonMethodError extends UnexpectedError {
|
|
3
|
+
constructor(name: string);
|
|
4
|
+
}
|
|
5
|
+
export declare const OnLeaderTakeover: () => MethodDecorator;
|
|
6
|
+
export declare const OnLeaderStepdown: () => MethodDecorator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnLeaderStepdown = exports.OnLeaderTakeover = exports.NonMethodError = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const multi_main_metadata_1 = require("./multi-main-metadata");
|
|
7
|
+
class NonMethodError extends n8n_workflow_1.UnexpectedError {
|
|
8
|
+
constructor(name) {
|
|
9
|
+
super(`${name} must be a method on a class to use this decorator`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.NonMethodError = NonMethodError;
|
|
13
|
+
const OnMultiMainEvent = (eventName) => (prototype, propertyKey, descriptor) => {
|
|
14
|
+
const eventHandlerClass = prototype.constructor;
|
|
15
|
+
const methodName = String(propertyKey);
|
|
16
|
+
if (typeof descriptor?.value !== 'function') {
|
|
17
|
+
throw new NonMethodError(`${eventHandlerClass.name}.${methodName}()`);
|
|
18
|
+
}
|
|
19
|
+
di_1.Container.get(multi_main_metadata_1.MultiMainMetadata).register({
|
|
20
|
+
eventHandlerClass,
|
|
21
|
+
methodName,
|
|
22
|
+
eventName,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const OnLeaderTakeover = () => OnMultiMainEvent(multi_main_metadata_1.LEADER_TAKEOVER_EVENT_NAME);
|
|
26
|
+
exports.OnLeaderTakeover = OnLeaderTakeover;
|
|
27
|
+
const OnLeaderStepdown = () => OnMultiMainEvent(multi_main_metadata_1.LEADER_STEPDOWN_EVENT_NAME);
|
|
28
|
+
exports.OnLeaderStepdown = OnLeaderStepdown;
|
|
29
|
+
//# sourceMappingURL=on-multi-main-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-multi-main-event.js","sourceRoot":"","sources":["../src/on-multi-main-event.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AACpC,+CAA+C;AAG/C,+DAI+B;AAE/B,MAAa,cAAe,SAAQ,8BAAe;IAClD,YAAY,IAAY;QACvB,KAAK,CAAC,GAAG,IAAI,oDAAoD,CAAC,CAAC;IACpE,CAAC;CACD;AAJD,wCAIC;AAED,MAAM,gBAAgB,GACrB,CAAC,SAAyB,EAAmB,EAAE,CAC/C,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IACtC,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAgC,CAAC;IACrE,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvC,IAAI,OAAO,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE,CAAC;QAC7C,MAAM,IAAI,cAAc,CAAC,GAAG,iBAAiB,CAAC,IAAI,IAAI,UAAU,IAAI,CAAC,CAAC;IACvE,CAAC;IAED,cAAS,CAAC,GAAG,CAAC,uCAAiB,CAAC,CAAC,QAAQ,CAAC;QACzC,iBAAiB;QACjB,UAAU;QACV,SAAS;KACT,CAAC,CAAC;AACJ,CAAC,CAAC;AAiBI,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,gDAA0B,CAAC,CAAC;AAAtE,QAAA,gBAAgB,oBAAsD;AAiB5E,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,gDAA0B,CAAC,CAAC;AAAtE,QAAA,gBAAgB,oBAAsD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OnShutdown: (priority?: number) => MethodDecorator;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnShutdown = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const constants_1 = require("./shutdown/constants");
|
|
7
|
+
const shutdown_registry_metadata_1 = require("./shutdown-registry-metadata");
|
|
8
|
+
const OnShutdown = (priority = constants_1.DEFAULT_SHUTDOWN_PRIORITY) => (prototype, propertyKey, descriptor) => {
|
|
9
|
+
const serviceClass = prototype.constructor;
|
|
10
|
+
const methodName = String(propertyKey);
|
|
11
|
+
if (typeof descriptor?.value === 'function') {
|
|
12
|
+
di_1.Container.get(shutdown_registry_metadata_1.ShutdownRegistryMetadata).register(priority, { serviceClass, methodName });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const name = `${serviceClass.name}.${methodName}()`;
|
|
16
|
+
throw new n8n_workflow_1.UnexpectedError(`${name} must be a method on ${serviceClass.name} to use "OnShutdown"`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.OnShutdown = OnShutdown;
|
|
20
|
+
//# sourceMappingURL=on-shutdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-shutdown.js","sourceRoot":"","sources":["../src/on-shutdown.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AACpC,+CAA+C;AAE/C,oDAAiE;AACjE,6EAAwE;AAsBjE,MAAM,UAAU,GACtB,CAAC,QAAQ,GAAG,qCAAyB,EAAmB,EAAE,CAC1D,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IACtC,MAAM,YAAY,GAAG,SAAS,CAAC,WAA2B,CAAC;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvC,IAAI,OAAO,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE,CAAC;QAC7C,cAAS,CAAC,GAAG,CAAC,qDAAwB,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1F,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,GAAG,GAAG,YAAY,CAAC,IAAI,IAAI,UAAU,IAAI,CAAC;QACpD,MAAM,IAAI,8BAAe,CACxB,GAAG,IAAI,wBAAwB,YAAY,CAAC,IAAI,sBAAsB,CACtE,CAAC;IACH,CAAC;AACF,CAAC,CAAC;AAdU,QAAA,UAAU,cAcpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UnexpectedError } from 'n8n-workflow';
|
|
2
|
+
export declare class RedactableError extends UnexpectedError {
|
|
3
|
+
constructor(fieldName: string, args: string);
|
|
4
|
+
}
|
|
5
|
+
type FieldName = 'user' | 'inviter' | 'invitee';
|
|
6
|
+
export declare const Redactable: (fieldName?: FieldName) => MethodDecorator;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Redactable = exports.RedactableError = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
class RedactableError extends n8n_workflow_1.UnexpectedError {
|
|
6
|
+
constructor(fieldName, args) {
|
|
7
|
+
super(`Failed to find "${fieldName}" property in argument "${args.toString()}". Please set the decorator \`@Redactable()\` only on \`LogStreamingEventRelay\` methods where the argument contains a "${fieldName}" property.`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.RedactableError = RedactableError;
|
|
11
|
+
function toRedactable(userLike) {
|
|
12
|
+
return {
|
|
13
|
+
userId: userLike.id,
|
|
14
|
+
_email: userLike.email,
|
|
15
|
+
_firstName: userLike.firstName,
|
|
16
|
+
_lastName: userLike.lastName,
|
|
17
|
+
globalRole: userLike.role,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const Redactable = (fieldName = 'user') => (_target, _propertyName, propertyDescriptor) => {
|
|
21
|
+
const originalMethod = propertyDescriptor.value;
|
|
22
|
+
propertyDescriptor.value = function (...args) {
|
|
23
|
+
const index = args.findIndex((arg) => arg[fieldName] !== undefined);
|
|
24
|
+
if (index === -1)
|
|
25
|
+
throw new RedactableError(fieldName, args.toString());
|
|
26
|
+
const userLike = args[index]?.[fieldName];
|
|
27
|
+
if (userLike)
|
|
28
|
+
args[index][fieldName] = toRedactable(userLike);
|
|
29
|
+
return originalMethod.apply(this, args);
|
|
30
|
+
};
|
|
31
|
+
return propertyDescriptor;
|
|
32
|
+
};
|
|
33
|
+
exports.Redactable = Redactable;
|
|
34
|
+
//# sourceMappingURL=redactable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redactable.js","sourceRoot":"","sources":["../src/redactable.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAU/C,MAAa,eAAgB,SAAQ,8BAAe;IACnD,YAAY,SAAiB,EAAE,IAAY;QAC1C,KAAK,CACJ,mBAAmB,SAAS,2BAA2B,IAAI,CAAC,QAAQ,EAAE,2HAA2H,SAAS,aAAa,CACvN,CAAC;IACH,CAAC;CACD;AAND,0CAMC;AAED,SAAS,YAAY,CAAC,QAAkB;IACvC,OAAO;QACN,MAAM,EAAE,QAAQ,CAAC,EAAE;QACnB,MAAM,EAAE,QAAQ,CAAC,KAAK;QACtB,UAAU,EAAE,QAAQ,CAAC,SAAS;QAC9B,SAAS,EAAE,QAAQ,CAAC,QAAQ;QAC5B,UAAU,EAAE,QAAQ,CAAC,IAAI;KACzB,CAAC;AACH,CAAC;AAgBM,MAAM,UAAU,GACtB,CAAC,YAAuB,MAAM,EAAmB,EAAE,CACnD,CAAC,OAAO,EAAE,aAAa,EAAE,kBAAsC,EAAE,EAAE;IAElE,MAAM,cAAc,GAAG,kBAAkB,CAAC,KAAiB,CAAC;IAI5D,kBAAkB,CAAC,KAAK,GAAG,UAAU,GAAG,IAAgB;QACvD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC;QAEpE,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,MAAM,IAAI,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAExE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QAG1C,IAAI,QAAQ;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAG9D,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAvBU,QAAA,UAAU,cAuBpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RestController: (basePath?: `/${string}`) => ClassDecorator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestController = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const controller_registry_metadata_1 = require("./controller-registry-metadata");
|
|
6
|
+
const RestController = (basePath = '/') => (target) => {
|
|
7
|
+
const metadata = di_1.Container.get(controller_registry_metadata_1.ControllerRegistryMetadata).getControllerMetadata(target);
|
|
8
|
+
metadata.basePath = basePath;
|
|
9
|
+
return (0, di_1.Service)()(target);
|
|
10
|
+
};
|
|
11
|
+
exports.RestController = RestController;
|
|
12
|
+
//# sourceMappingURL=rest-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-controller.js","sourceRoot":"","sources":["../src/rest-controller.ts"],"names":[],"mappings":";;;AAAA,gCAA6C;AAE7C,iFAA4E;AAGrE,MAAM,cAAc,GAC1B,CAAC,WAAyB,GAAG,EAAkB,EAAE,CACjD,CAAC,MAAM,EAAE,EAAE;IACV,MAAM,QAAQ,GAAG,cAAS,CAAC,GAAG,CAAC,yDAA0B,CAAC,CAAC,qBAAqB,CAC/E,MAA+B,CAC/B,CAAC;IACF,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAE7B,OAAO,IAAA,YAAO,GAAE,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC;AATU,QAAA,cAAc,kBASxB"}
|
package/dist/route.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RequestHandler } from 'express';
|
|
2
|
+
import type { RateLimit } from './types';
|
|
3
|
+
interface RouteOptions {
|
|
4
|
+
middlewares?: RequestHandler[];
|
|
5
|
+
usesTemplates?: boolean;
|
|
6
|
+
skipAuth?: boolean;
|
|
7
|
+
rateLimit?: boolean | RateLimit;
|
|
8
|
+
}
|
|
9
|
+
export declare const Get: (path: `/${string}`, options?: RouteOptions) => MethodDecorator;
|
|
10
|
+
export declare const Post: (path: `/${string}`, options?: RouteOptions) => MethodDecorator;
|
|
11
|
+
export declare const Put: (path: `/${string}`, options?: RouteOptions) => MethodDecorator;
|
|
12
|
+
export declare const Patch: (path: `/${string}`, options?: RouteOptions) => MethodDecorator;
|
|
13
|
+
export declare const Delete: (path: `/${string}`, options?: RouteOptions) => MethodDecorator;
|
|
14
|
+
export {};
|
package/dist/route.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const controller_registry_metadata_1 = require("./controller-registry-metadata");
|
|
6
|
+
const RouteFactory = (method) => (path, options = {}) => (target, handlerName) => {
|
|
7
|
+
const routeMetadata = di_1.Container.get(controller_registry_metadata_1.ControllerRegistryMetadata).getRouteMetadata(target.constructor, String(handlerName));
|
|
8
|
+
routeMetadata.method = method;
|
|
9
|
+
routeMetadata.path = path;
|
|
10
|
+
routeMetadata.middlewares = options.middlewares ?? [];
|
|
11
|
+
routeMetadata.usesTemplates = options.usesTemplates ?? false;
|
|
12
|
+
routeMetadata.skipAuth = options.skipAuth ?? false;
|
|
13
|
+
routeMetadata.rateLimit = options.rateLimit;
|
|
14
|
+
};
|
|
15
|
+
exports.Get = RouteFactory('get');
|
|
16
|
+
exports.Post = RouteFactory('post');
|
|
17
|
+
exports.Put = RouteFactory('put');
|
|
18
|
+
exports.Patch = RouteFactory('patch');
|
|
19
|
+
exports.Delete = RouteFactory('delete');
|
|
20
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../src/route.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AAGpC,iFAA4E;AAY5E,MAAM,YAAY,GACjB,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,IAAkB,EAAE,UAAwB,EAAE,EAAmB,EAAE,CACpE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;IACvB,MAAM,aAAa,GAAG,cAAS,CAAC,GAAG,CAAC,yDAA0B,CAAC,CAAC,gBAAgB,CAC/E,MAAM,CAAC,WAAyB,EAChC,MAAM,CAAC,WAAW,CAAC,CACnB,CAAC;IACF,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC;IAC9B,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC;IAC1B,aAAa,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IACtD,aAAa,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;IAC7D,aAAa,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IACnD,aAAa,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;AAC7C,CAAC,CAAC;AAEU,QAAA,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAC1B,QAAA,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5B,QAAA,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAC1B,QAAA,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AAC9B,QAAA,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/scoped.d.ts
ADDED
package/dist/scoped.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectScope = exports.GlobalScope = void 0;
|
|
4
|
+
const di_1 = require("@n8n/di");
|
|
5
|
+
const controller_registry_metadata_1 = require("./controller-registry-metadata");
|
|
6
|
+
const Scoped = (scope, { globalOnly } = { globalOnly: false }) => (target, handlerName) => {
|
|
7
|
+
const routeMetadata = di_1.Container.get(controller_registry_metadata_1.ControllerRegistryMetadata).getRouteMetadata(target.constructor, String(handlerName));
|
|
8
|
+
routeMetadata.accessScope = { scope, globalOnly };
|
|
9
|
+
};
|
|
10
|
+
const GlobalScope = (scope) => Scoped(scope, { globalOnly: true });
|
|
11
|
+
exports.GlobalScope = GlobalScope;
|
|
12
|
+
const ProjectScope = (scope) => Scoped(scope);
|
|
13
|
+
exports.ProjectScope = ProjectScope;
|
|
14
|
+
//# sourceMappingURL=scoped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped.js","sourceRoot":"","sources":["../src/scoped.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AAGpC,iFAA4E;AAG5E,MAAM,MAAM,GACX,CAAC,KAAY,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,EAAmB,EAAE,CAC1E,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;IACvB,MAAM,aAAa,GAAG,cAAS,CAAC,GAAG,CAAC,yDAA0B,CAAC,CAAC,gBAAgB,CAC/E,MAAM,CAAC,WAAyB,EAChC,MAAM,CAAC,WAAW,CAAC,CACnB,CAAC;IACF,aAAa,CAAC,WAAW,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACnD,CAAC,CAAC;AAkBI,MAAM,WAAW,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;AAApE,QAAA,WAAW,eAAyD;AAmB1E,MAAM,YAAY,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAA/C,QAAA,YAAY,gBAAmC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HIGHEST_SHUTDOWN_PRIORITY = exports.DEFAULT_SHUTDOWN_PRIORITY = exports.LOWEST_SHUTDOWN_PRIORITY = void 0;
|
|
4
|
+
exports.LOWEST_SHUTDOWN_PRIORITY = 0;
|
|
5
|
+
exports.DEFAULT_SHUTDOWN_PRIORITY = 100;
|
|
6
|
+
exports.HIGHEST_SHUTDOWN_PRIORITY = 200;
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shutdown/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAC7B,QAAA,yBAAyB,GAAG,GAAG,CAAC;AAChC,QAAA,yBAAyB,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ShutdownRegistryMetadata = void 0;
|
|
10
|
+
const di_1 = require("@n8n/di");
|
|
11
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
12
|
+
const constants_1 = require("./shutdown/constants");
|
|
13
|
+
let ShutdownRegistryMetadata = class ShutdownRegistryMetadata {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.handlersByPriority = [];
|
|
16
|
+
}
|
|
17
|
+
register(priority, handler) {
|
|
18
|
+
if (priority < constants_1.LOWEST_SHUTDOWN_PRIORITY || priority > constants_1.HIGHEST_SHUTDOWN_PRIORITY) {
|
|
19
|
+
throw new n8n_workflow_1.UserError(`Invalid shutdown priority. Please set it between ${constants_1.LOWEST_SHUTDOWN_PRIORITY} and ${constants_1.HIGHEST_SHUTDOWN_PRIORITY}.`, { extra: { priority } });
|
|
20
|
+
}
|
|
21
|
+
if (!this.handlersByPriority[priority])
|
|
22
|
+
this.handlersByPriority[priority] = [];
|
|
23
|
+
this.handlersByPriority[priority].push(handler);
|
|
24
|
+
}
|
|
25
|
+
getHandlersByPriority() {
|
|
26
|
+
return this.handlersByPriority;
|
|
27
|
+
}
|
|
28
|
+
clear() {
|
|
29
|
+
this.handlersByPriority = [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.ShutdownRegistryMetadata = ShutdownRegistryMetadata;
|
|
33
|
+
exports.ShutdownRegistryMetadata = ShutdownRegistryMetadata = __decorate([
|
|
34
|
+
(0, di_1.Service)()
|
|
35
|
+
], ShutdownRegistryMetadata);
|
|
36
|
+
//# sourceMappingURL=shutdown-registry-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown-registry-metadata.js","sourceRoot":"","sources":["../src/shutdown-registry-metadata.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gCAAkC;AAClC,+CAAyC;AAEzC,oDAA2F;AAIpF,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QACE,uBAAkB,GAAwB,EAAE,CAAC;IAsBtD,CAAC;IApBA,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QAClD,IAAI,QAAQ,GAAG,oCAAwB,IAAI,QAAQ,GAAG,qCAAyB,EAAE,CAAC;YACjF,MAAM,IAAI,wBAAS,CAClB,oDAAoD,oCAAwB,QAAQ,qCAAyB,GAAG,EAChH,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,CACvB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC;YAAE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAE/E,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,qBAAqB;QACpB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IAChC,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD,CAAA;AAvBY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,YAAO,GAAE;GACG,wBAAwB,CAuBpC"}
|