@n8n/decorators 0.15.2 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './pubsub';
9
9
  export { Redactable } from './redactable';
10
10
  export * from './shutdown';
11
11
  export * from './module/module-metadata';
12
+ export { Timed, TimedOptions } from './timed';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Redactable = exports.Memoized = exports.Debounce = void 0;
17
+ exports.Timed = exports.Redactable = exports.Memoized = exports.Debounce = void 0;
18
18
  __exportStar(require("./controller"), exports);
19
19
  __exportStar(require("./command"), exports);
20
20
  var debounce_1 = require("./debounce");
@@ -29,4 +29,6 @@ var redactable_1 = require("./redactable");
29
29
  Object.defineProperty(exports, "Redactable", { enumerable: true, get: function () { return redactable_1.Redactable; } });
30
30
  __exportStar(require("./shutdown"), exports);
31
31
  __exportStar(require("./module/module-metadata"), exports);
32
+ var timed_1 = require("./timed");
33
+ Object.defineProperty(exports, "Timed", { enumerable: true, get: function () { return timed_1.Timed; } });
32
34
  //# 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,+CAA6B;AAC7B,4CAA0B;AAC1B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,wDAAsC;AACtC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,6CAA2B;AAC3B,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,wDAAsC;AACtC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,6CAA2B;AAC3B,2DAAyC;AACzC,iCAA8C;AAArC,8FAAA,KAAK,OAAA"}
@@ -0,0 +1,9 @@
1
+ export interface TimedOptions {
2
+ threshold?: number;
3
+ logArgs?: boolean;
4
+ }
5
+ interface Logger {
6
+ warn(message: string, meta?: object): void;
7
+ }
8
+ export declare const Timed: (logger: Logger, msg?: string) => (options?: TimedOptions) => MethodDecorator;
9
+ export {};
package/dist/timed.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Timed = void 0;
4
+ const Timed = (logger, msg = 'Slow method call') => (options = {}) => (_target, propertyKey, descriptor) => {
5
+ const originalMethod = descriptor.value;
6
+ const thresholdMs = options.threshold ?? 100;
7
+ const logArgs = options.logArgs ?? false;
8
+ descriptor.value = async function (...args) {
9
+ const methodName = `${this.constructor.name}.${String(propertyKey)}`;
10
+ const start = performance.now();
11
+ const result = await originalMethod.apply(this, args);
12
+ const durationMs = performance.now() - start;
13
+ if (durationMs > thresholdMs) {
14
+ logger.warn(msg, {
15
+ method: methodName,
16
+ durationMs: Math.round(durationMs),
17
+ thresholdMs,
18
+ params: logArgs ? args : '[hidden]',
19
+ });
20
+ }
21
+ return result;
22
+ };
23
+ return descriptor;
24
+ };
25
+ exports.Timed = Timed;
26
+ //# sourceMappingURL=timed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timed.js","sourceRoot":"","sources":["../src/timed.ts"],"names":[],"mappings":";;;AAcO,MAAM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  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist/**/*",
9
- "LICENSE.md",
10
- "LICENSE_EE.md"
9
+ "LICENSE_EE.md",
10
+ "LICENSE.md"
11
11
  ],
12
12
  "devDependencies": {
13
13
  "@types/express": "^5.0.1",
@@ -16,10 +16,10 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "lodash": "4.17.21",
19
- "@n8n/constants": "^0.10.0",
20
19
  "@n8n/permissions": "^0.31.0",
21
20
  "@n8n/di": "^0.9.0",
22
- "n8n-workflow": "^1.102.2"
21
+ "@n8n/constants": "^0.10.0",
22
+ "n8n-workflow": "^1.103.1"
23
23
  },
24
24
  "license": "SEE LICENSE IN LICENSE.md",
25
25
  "homepage": "https://n8n.io",