@n8n/decorators 0.2.0 → 0.3.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.
@@ -0,0 +1,4 @@
1
+ import { UnexpectedError } from 'n8n-workflow';
2
+ export declare class NonMethodError extends UnexpectedError {
3
+ constructor(name: string);
4
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NonMethodError = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class NonMethodError extends n8n_workflow_1.UnexpectedError {
6
+ constructor(name) {
7
+ super(`${name} must be a method on a class to use this decorator`);
8
+ }
9
+ }
10
+ exports.NonMethodError = NonMethodError;
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,MAAa,cAAe,SAAQ,8BAAe;IAClD,YAAY,IAAY;QACvB,KAAK,CAAC,GAAG,IAAI,oDAAoD,CAAC,CAAC;IACpE,CAAC;CACD;AAJD,wCAIC"}
package/dist/index.d.ts CHANGED
@@ -7,13 +7,16 @@ export { Licensed } from './licensed';
7
7
  export { GlobalScope, ProjectScope } from './scoped';
8
8
  export { HIGHEST_SHUTDOWN_PRIORITY, DEFAULT_SHUTDOWN_PRIORITY, LOWEST_SHUTDOWN_PRIORITY, } from './shutdown/constants';
9
9
  export { ShutdownRegistryMetadata } from './shutdown-registry-metadata';
10
- export { ModuleRegistry } from './module';
11
10
  export { OnShutdown } from './on-shutdown';
12
11
  export { Redactable } from './redactable';
13
12
  export { BaseN8nModule, N8nModule } from './module';
13
+ export { ModuleMetadata } from './module-metadata';
14
14
  export { Debounce } from './debounce';
15
15
  export type { AccessScope, Controller, RateLimit } from './types';
16
16
  export type { ShutdownHandler } from './types';
17
17
  export { MultiMainMetadata } from './multi-main-metadata';
18
18
  export { OnLeaderTakeover, OnLeaderStepdown } from './on-multi-main-event';
19
19
  export { Memoized } from './memoized';
20
+ export { OnLifecycleEvent } from './on-lifecycle-event';
21
+ export type { LifecycleContext, NodeExecuteBeforeContext, NodeExecuteAfterContext, WorkflowExecuteBeforeContext, WorkflowExecuteAfterContext, } from './lifecycle-metadata';
22
+ export { LifecycleMetadata } from './lifecycle-metadata';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
3
+ exports.LifecycleMetadata = exports.OnLifecycleEvent = exports.Memoized = exports.OnLeaderStepdown = exports.OnLeaderTakeover = exports.MultiMainMetadata = exports.Debounce = exports.ModuleMetadata = exports.N8nModule = exports.Redactable = exports.OnShutdown = 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
4
  var args_1 = require("./args");
5
5
  Object.defineProperty(exports, "Body", { enumerable: true, get: function () { return args_1.Body; } });
6
6
  Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return args_1.Query; } });
@@ -28,14 +28,14 @@ Object.defineProperty(exports, "DEFAULT_SHUTDOWN_PRIORITY", { enumerable: true,
28
28
  Object.defineProperty(exports, "LOWEST_SHUTDOWN_PRIORITY", { enumerable: true, get: function () { return constants_1.LOWEST_SHUTDOWN_PRIORITY; } });
29
29
  var shutdown_registry_metadata_1 = require("./shutdown-registry-metadata");
30
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
31
  var on_shutdown_1 = require("./on-shutdown");
34
32
  Object.defineProperty(exports, "OnShutdown", { enumerable: true, get: function () { return on_shutdown_1.OnShutdown; } });
35
33
  var redactable_1 = require("./redactable");
36
34
  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; } });
35
+ var module_1 = require("./module");
36
+ Object.defineProperty(exports, "N8nModule", { enumerable: true, get: function () { return module_1.N8nModule; } });
37
+ var module_metadata_1 = require("./module-metadata");
38
+ Object.defineProperty(exports, "ModuleMetadata", { enumerable: true, get: function () { return module_metadata_1.ModuleMetadata; } });
39
39
  var debounce_1 = require("./debounce");
40
40
  Object.defineProperty(exports, "Debounce", { enumerable: true, get: function () { return debounce_1.Debounce; } });
41
41
  var multi_main_metadata_1 = require("./multi-main-metadata");
@@ -45,4 +45,8 @@ Object.defineProperty(exports, "OnLeaderTakeover", { enumerable: true, get: func
45
45
  Object.defineProperty(exports, "OnLeaderStepdown", { enumerable: true, get: function () { return on_multi_main_event_1.OnLeaderStepdown; } });
46
46
  var memoized_1 = require("./memoized");
47
47
  Object.defineProperty(exports, "Memoized", { enumerable: true, get: function () { return memoized_1.Memoized; } });
48
+ var on_lifecycle_event_1 = require("./on-lifecycle-event");
49
+ Object.defineProperty(exports, "OnLifecycleEvent", { enumerable: true, get: function () { return on_lifecycle_event_1.OnLifecycleEvent; } });
50
+ var lifecycle_metadata_1 = require("./lifecycle-metadata");
51
+ Object.defineProperty(exports, "LifecycleMetadata", { enumerable: true, get: function () { return lifecycle_metadata_1.LifecycleMetadata; } });
48
52
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"}
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,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAAoD;AAA5B,mGAAA,SAAS,OAAA;AACjC,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,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;AACjB,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AAQzB,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,41 @@
1
+ import type { IDataObject, IRun, IRunExecutionData, ITaskData, ITaskStartedData, IWorkflowBase, Workflow } from 'n8n-workflow';
2
+ import type { Class } from './types';
3
+ export type LifecycleHandlerClass = Class<Record<string, (ctx: LifecycleContext) => Promise<void> | void>>;
4
+ export type NodeExecuteBeforeContext = {
5
+ type: 'nodeExecuteBefore';
6
+ workflow: IWorkflowBase;
7
+ nodeName: string;
8
+ taskData: ITaskStartedData;
9
+ };
10
+ export type NodeExecuteAfterContext = {
11
+ type: 'nodeExecuteAfter';
12
+ workflow: IWorkflowBase;
13
+ nodeName: string;
14
+ taskData: ITaskData;
15
+ executionData: IRunExecutionData;
16
+ };
17
+ export type WorkflowExecuteBeforeContext = {
18
+ type: 'workflowExecuteBefore';
19
+ workflow: IWorkflowBase;
20
+ workflowInstance: Workflow;
21
+ executionData?: IRunExecutionData;
22
+ };
23
+ export type WorkflowExecuteAfterContext = {
24
+ type: 'workflowExecuteAfter';
25
+ workflow: IWorkflowBase;
26
+ runData: IRun;
27
+ newStaticData: IDataObject;
28
+ };
29
+ export type LifecycleContext = NodeExecuteBeforeContext | NodeExecuteAfterContext | WorkflowExecuteBeforeContext | WorkflowExecuteAfterContext;
30
+ type LifecycleHandler = {
31
+ handlerClass: LifecycleHandlerClass;
32
+ methodName: string;
33
+ eventName: LifecycleEvent;
34
+ };
35
+ export type LifecycleEvent = LifecycleContext['type'];
36
+ export declare class LifecycleMetadata {
37
+ private readonly handlers;
38
+ register(handler: LifecycleHandler): void;
39
+ getHandlers(): LifecycleHandler[];
40
+ }
41
+ export {};
@@ -0,0 +1,26 @@
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.LifecycleMetadata = void 0;
10
+ const di_1 = require("@n8n/di");
11
+ let LifecycleMetadata = class LifecycleMetadata {
12
+ constructor() {
13
+ this.handlers = [];
14
+ }
15
+ register(handler) {
16
+ this.handlers.push(handler);
17
+ }
18
+ getHandlers() {
19
+ return this.handlers;
20
+ }
21
+ };
22
+ exports.LifecycleMetadata = LifecycleMetadata;
23
+ exports.LifecycleMetadata = LifecycleMetadata = __decorate([
24
+ (0, di_1.Service)()
25
+ ], LifecycleMetadata);
26
+ //# sourceMappingURL=lifecycle-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-metadata.js","sourceRoot":"","sources":["../src/lifecycle-metadata.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gCAAkC;AAmE3B,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QACW,aAAQ,GAAuB,EAAE,CAAC;IASpD,CAAC;IAPA,QAAQ,CAAC,OAAyB;QACjC,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 type { Module } from './module';
2
+ export declare class ModuleMetadata {
3
+ private readonly modules;
4
+ register(module: Module): void;
5
+ getModules(): SetIterator<Module>;
6
+ }
@@ -0,0 +1,26 @@
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.ModuleMetadata = void 0;
10
+ const di_1 = require("@n8n/di");
11
+ let ModuleMetadata = class ModuleMetadata {
12
+ constructor() {
13
+ this.modules = new Set();
14
+ }
15
+ register(module) {
16
+ this.modules.add(module);
17
+ }
18
+ getModules() {
19
+ return this.modules.keys();
20
+ }
21
+ };
22
+ exports.ModuleMetadata = ModuleMetadata;
23
+ exports.ModuleMetadata = ModuleMetadata = __decorate([
24
+ (0, di_1.Service)()
25
+ ], ModuleMetadata);
26
+ //# sourceMappingURL=module-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-metadata.js","sourceRoot":"","sources":["../src/module-metadata.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gCAAkC;AAK3B,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QACW,YAAO,GAAgB,IAAI,GAAG,EAAE,CAAC;IASnD,CAAC;IAPA,QAAQ,CAAC,MAAc;QACtB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,UAAU;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;CACD,CAAA;AAVY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,YAAO,GAAE;GACG,cAAc,CAU1B"}
package/dist/module.d.ts CHANGED
@@ -1,14 +1,6 @@
1
1
  import { type Constructable } from '@n8n/di';
2
- export type ExecutionLifecycleHooks = object;
3
2
  export interface BaseN8nModule {
4
3
  initialize?(): void;
5
- registerLifecycleHooks?(hooks: ExecutionLifecycleHooks): void;
6
4
  }
7
- type Module = Constructable<BaseN8nModule>;
8
- export declare const registry: Set<Module>;
5
+ export type Module = Constructable<BaseN8nModule>;
9
6
  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 CHANGED
@@ -1,39 +1,11 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ModuleRegistry = exports.N8nModule = exports.registry = void 0;
3
+ exports.N8nModule = void 0;
10
4
  const di_1 = require("@n8n/di");
11
- exports.registry = new Set();
5
+ const module_metadata_1 = require("./module-metadata");
12
6
  const N8nModule = () => (target) => {
13
- exports.registry.add(target);
7
+ di_1.Container.get(module_metadata_1.ModuleMetadata).register(target);
14
8
  return (0, di_1.Service)()(target);
15
9
  };
16
10
  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
11
  //# sourceMappingURL=module.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;AAAA,gCAAiE;AAEjE,uDAAmD;AAQ5C,MAAM,SAAS,GAAG,GAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IACzD,cAAS,CAAC,GAAG,CAAC,gCAAc,CAAC,CAAC,QAAQ,CAAC,MAA2B,CAAC,CAAC;IAGpE,OAAO,IAAA,YAAO,GAAE,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB"}
@@ -0,0 +1,2 @@
1
+ import type { LifecycleEvent } from './lifecycle-metadata';
2
+ export declare const OnLifecycleEvent: (eventName: LifecycleEvent) => MethodDecorator;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnLifecycleEvent = void 0;
4
+ const di_1 = require("@n8n/di");
5
+ const errors_1 = require("./errors");
6
+ const lifecycle_metadata_1 = require("./lifecycle-metadata");
7
+ const OnLifecycleEvent = (eventName) => (prototype, propertyKey, descriptor) => {
8
+ const handlerClass = prototype.constructor;
9
+ const methodName = String(propertyKey);
10
+ if (typeof descriptor?.value !== 'function') {
11
+ throw new errors_1.NonMethodError(`${handlerClass.name}.${methodName}()`);
12
+ }
13
+ di_1.Container.get(lifecycle_metadata_1.LifecycleMetadata).register({
14
+ handlerClass,
15
+ methodName,
16
+ eventName,
17
+ });
18
+ };
19
+ exports.OnLifecycleEvent = OnLifecycleEvent;
20
+ //# sourceMappingURL=on-lifecycle-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-lifecycle-event.js","sourceRoot":"","sources":["../src/on-lifecycle-event.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AAEpC,qCAA0C;AAE1C,6DAAyD;AAkBlD,MAAM,gBAAgB,GAC5B,CAAC,SAAyB,EAAmB,EAAE,CAC/C,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;IACtC,MAAM,YAAY,GAAG,SAAS,CAAC,WAAoC,CAAC;IACpE,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvC,IAAI,OAAO,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE,CAAC;QAC7C,MAAM,IAAI,uBAAc,CAAC,GAAG,YAAY,CAAC,IAAI,IAAI,UAAU,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,cAAS,CAAC,GAAG,CAAC,sCAAiB,CAAC,CAAC,QAAQ,CAAC;QACzC,YAAY;QACZ,UAAU;QACV,SAAS;KACT,CAAC,CAAC;AACJ,CAAC,CAAC;AAfU,QAAA,gBAAgB,oBAe1B"}
@@ -1,6 +1,2 @@
1
- import { UnexpectedError } from 'n8n-workflow';
2
- export declare class NonMethodError extends UnexpectedError {
3
- constructor(name: string);
4
- }
5
1
  export declare const OnLeaderTakeover: () => MethodDecorator;
6
2
  export declare const OnLeaderStepdown: () => MethodDecorator;
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnLeaderStepdown = exports.OnLeaderTakeover = exports.NonMethodError = void 0;
3
+ exports.OnLeaderStepdown = exports.OnLeaderTakeover = void 0;
4
4
  const di_1 = require("@n8n/di");
5
- const n8n_workflow_1 = require("n8n-workflow");
5
+ const errors_1 = require("./errors");
6
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
7
  const OnMultiMainEvent = (eventName) => (prototype, propertyKey, descriptor) => {
14
8
  const eventHandlerClass = prototype.constructor;
15
9
  const methodName = String(propertyKey);
16
10
  if (typeof descriptor?.value !== 'function') {
17
- throw new NonMethodError(`${eventHandlerClass.name}.${methodName}()`);
11
+ throw new errors_1.NonMethodError(`${eventHandlerClass.name}.${methodName}()`);
18
12
  }
19
13
  di_1.Container.get(multi_main_metadata_1.MultiMainMetadata).register({
20
14
  eventHandlerClass,
@@ -1 +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"}
1
+ {"version":3,"file":"on-multi-main-event.js","sourceRoot":"","sources":["../src/on-multi-main-event.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AAEpC,qCAA0C;AAE1C,+DAI+B;AAE/B,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,uBAAc,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n/decorators",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "src/index.ts",
6
6
  "types": "dist/index.d.ts",
@@ -17,9 +17,9 @@
17
17
  "dependencies": {
18
18
  "lodash": "4.17.21",
19
19
  "@n8n/constants": "^0.2.0",
20
- "@n8n/di": "^0.5.0",
21
- "n8n-workflow": "^1.89.0",
22
- "@n8n/permissions": "^0.22.0"
20
+ "@n8n/permissions": "^0.23.0",
21
+ "n8n-workflow": "^1.90.0",
22
+ "@n8n/di": "^0.5.0"
23
23
  },
24
24
  "license": "SEE LICENSE IN LICENSE.md",
25
25
  "homepage": "https://n8n.io",