@webiny/handler 5.21.0-beta.0 → 5.22.0-beta.2

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/createHandler.js CHANGED
@@ -7,25 +7,39 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _plugins = require("@webiny/plugins");
10
+ var _HandlerPlugin = require("./plugins/HandlerPlugin");
11
+
12
+ var _ContextPlugin = require("./plugins/ContextPlugin");
11
13
 
12
14
  var _middleware = _interopRequireDefault(require("./middleware"));
13
15
 
16
+ var _BeforeHandlerPlugin = require("./plugins/BeforeHandlerPlugin");
17
+
18
+ var _Context = require("./plugins/Context");
19
+
20
+ var _HandlerErrorPlugin = require("./plugins/HandlerErrorPlugin");
21
+
22
+ var _HandlerResultPlugin = require("./plugins/HandlerResultPlugin");
23
+
14
24
  var _default = (...plugins) => async (...args) => {
15
- const context = {
16
- plugins: new _plugins.PluginsContainer(plugins),
25
+ const context = new _Context.Context({
26
+ plugins,
17
27
  args,
18
- // @ts-ignore
19
- // this is injected using webpack.DefinePlugin at build time
28
+
29
+ /**
30
+ * Inserted via webpack on build time.
31
+ */
20
32
  WEBINY_VERSION: process.env.WEBINY_VERSION
21
- };
22
- const result = await handle(args, context);
23
- const handlerPlugins = context.plugins.byType("handler-result");
33
+ });
34
+ const result = await handle(context);
35
+ const handlerPlugins = context.plugins.byType(_HandlerResultPlugin.HandlerResultPlugin.type);
24
36
 
25
37
  for (let i = 0; i < handlerPlugins.length; i++) {
26
- if (handlerPlugins[i].apply) {
27
- await handlerPlugins[i].apply(result, context);
38
+ if (!handlerPlugins[i].handle) {
39
+ continue;
28
40
  }
41
+
42
+ await handlerPlugins[i].handle(context, result);
29
43
  }
30
44
 
31
45
  return result;
@@ -33,38 +47,58 @@ var _default = (...plugins) => async (...args) => {
33
47
 
34
48
  exports.default = _default;
35
49
 
36
- async function handle(_, context) {
50
+ async function handle(context) {
37
51
  try {
38
- const contextPlugins = context.plugins.byType("context");
52
+ const contextPlugins = context.plugins.byType(_ContextPlugin.ContextPlugin.type);
39
53
 
40
54
  for (let i = 0; i < contextPlugins.length; i++) {
41
- if (contextPlugins[i].apply) {
42
- await contextPlugins[i].apply(context);
55
+ if (!contextPlugins[i].apply) {
56
+ continue;
57
+ }
58
+
59
+ await contextPlugins[i].apply(context);
60
+
61
+ if (context.hasResult()) {
62
+ return context.getResult();
43
63
  }
44
64
  }
45
65
 
46
- const beforeHandlerPlugins = context.plugins.byType("before-handler");
66
+ const beforeHandlerPlugins = context.plugins.byType(_BeforeHandlerPlugin.BeforeHandlerPlugin.type);
47
67
 
48
68
  for (let i = 0; i < beforeHandlerPlugins.length; i++) {
49
- if (beforeHandlerPlugins[i].apply) {
50
- await beforeHandlerPlugins[i].apply(context);
69
+ if (!beforeHandlerPlugins[i].apply) {
70
+ continue;
71
+ }
72
+
73
+ await beforeHandlerPlugins[i].apply(context);
74
+
75
+ if (context.hasResult()) {
76
+ return context.getResult();
51
77
  }
52
78
  }
53
79
 
54
- const handlers = context.plugins.byType("handler");
55
- const handler = (0, _middleware.default)(handlers.map(pl => pl.handle));
80
+ const handlers = context.plugins.byType(_HandlerPlugin.HandlerPlugin.type);
81
+ const handler = (0, _middleware.default)(handlers.map(pl => {
82
+ return (context, next) => {
83
+ return pl.handle(context, next);
84
+ };
85
+ }));
56
86
  const result = await handler(context);
57
87
 
58
88
  if (!result) {
59
- throw Error(`No result was returned from registered handlers.`);
89
+ throw new Error(`No result was returned from registered handlers.`);
60
90
  }
61
91
 
62
92
  return result;
63
93
  } catch (error) {
64
94
  // Log error to cloud, as these can be extremely annoying to debug!
65
95
  console.log(error);
66
- const handlers = context.plugins.byType("handler-error");
67
- const handler = (0, _middleware.default)(handlers.map(pl => pl.handle));
96
+ const handlers = context.plugins.byType(_HandlerErrorPlugin.HandlerErrorPlugin.type);
97
+ const handler = (0, _middleware.default)(handlers.map(pl => {
98
+ return (context, error, next) => {
99
+ return pl.handle(context, error, next);
100
+ };
101
+ }));
68
102
  return handler(context, error);
69
103
  }
70
104
  }
package/index.d.ts CHANGED
@@ -1 +1,7 @@
1
1
  export { default as createHandler } from "./createHandler";
2
+ export * from "./plugins/ContextPlugin";
3
+ export * from "./plugins/Context";
4
+ export * from "./plugins/HandlerPlugin";
5
+ export * from "./plugins/HandlerErrorPlugin";
6
+ export * from "./plugins/HandlerResultPlugin";
7
+ export * from "./plugins/BeforeHandlerPlugin";
package/index.js CHANGED
@@ -5,6 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ var _exportNames = {
9
+ createHandler: true
10
+ };
8
11
  Object.defineProperty(exports, "createHandler", {
9
12
  enumerable: true,
10
13
  get: function () {
@@ -12,4 +15,88 @@ Object.defineProperty(exports, "createHandler", {
12
15
  }
13
16
  });
14
17
 
15
- var _createHandler = _interopRequireDefault(require("./createHandler"));
18
+ var _createHandler = _interopRequireDefault(require("./createHandler"));
19
+
20
+ var _ContextPlugin = require("./plugins/ContextPlugin");
21
+
22
+ Object.keys(_ContextPlugin).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
25
+ if (key in exports && exports[key] === _ContextPlugin[key]) return;
26
+ Object.defineProperty(exports, key, {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _ContextPlugin[key];
30
+ }
31
+ });
32
+ });
33
+
34
+ var _Context = require("./plugins/Context");
35
+
36
+ Object.keys(_Context).forEach(function (key) {
37
+ if (key === "default" || key === "__esModule") return;
38
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39
+ if (key in exports && exports[key] === _Context[key]) return;
40
+ Object.defineProperty(exports, key, {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _Context[key];
44
+ }
45
+ });
46
+ });
47
+
48
+ var _HandlerPlugin = require("./plugins/HandlerPlugin");
49
+
50
+ Object.keys(_HandlerPlugin).forEach(function (key) {
51
+ if (key === "default" || key === "__esModule") return;
52
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
53
+ if (key in exports && exports[key] === _HandlerPlugin[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _HandlerPlugin[key];
58
+ }
59
+ });
60
+ });
61
+
62
+ var _HandlerErrorPlugin = require("./plugins/HandlerErrorPlugin");
63
+
64
+ Object.keys(_HandlerErrorPlugin).forEach(function (key) {
65
+ if (key === "default" || key === "__esModule") return;
66
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
67
+ if (key in exports && exports[key] === _HandlerErrorPlugin[key]) return;
68
+ Object.defineProperty(exports, key, {
69
+ enumerable: true,
70
+ get: function () {
71
+ return _HandlerErrorPlugin[key];
72
+ }
73
+ });
74
+ });
75
+
76
+ var _HandlerResultPlugin = require("./plugins/HandlerResultPlugin");
77
+
78
+ Object.keys(_HandlerResultPlugin).forEach(function (key) {
79
+ if (key === "default" || key === "__esModule") return;
80
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
81
+ if (key in exports && exports[key] === _HandlerResultPlugin[key]) return;
82
+ Object.defineProperty(exports, key, {
83
+ enumerable: true,
84
+ get: function () {
85
+ return _HandlerResultPlugin[key];
86
+ }
87
+ });
88
+ });
89
+
90
+ var _BeforeHandlerPlugin = require("./plugins/BeforeHandlerPlugin");
91
+
92
+ Object.keys(_BeforeHandlerPlugin).forEach(function (key) {
93
+ if (key === "default" || key === "__esModule") return;
94
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
95
+ if (key in exports && exports[key] === _BeforeHandlerPlugin[key]) return;
96
+ Object.defineProperty(exports, key, {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _BeforeHandlerPlugin[key];
100
+ }
101
+ });
102
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler",
3
- "version": "5.21.0-beta.0",
3
+ "version": "5.22.0-beta.2",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,16 +14,17 @@
14
14
  "Adrian Smijulj <adrian@webiny.com>"
15
15
  ],
16
16
  "dependencies": {
17
- "@babel/runtime": "7.16.3",
18
- "@webiny/plugins": "5.21.0-beta.0"
17
+ "@babel/runtime": "7.16.7",
18
+ "@webiny/plugins": "5.22.0-beta.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@babel/cli": "^7.5.5",
22
- "@babel/core": "^7.5.5",
23
- "@babel/preset-env": "^7.5.5",
24
- "@webiny/cli": "^5.21.0-beta.0",
25
- "@webiny/project-utils": "^5.21.0-beta.0",
21
+ "@babel/cli": "^7.16.0",
22
+ "@babel/core": "^7.16.0",
23
+ "@babel/preset-env": "^7.16.4",
24
+ "@webiny/cli": "^5.22.0-beta.2",
25
+ "@webiny/project-utils": "^5.22.0-beta.2",
26
26
  "rimraf": "^3.0.2",
27
+ "ttypescript": "^1.5.13",
27
28
  "typescript": "^4.1.3"
28
29
  },
29
30
  "publishConfig": {
@@ -34,5 +35,5 @@
34
35
  "build": "yarn webiny run build",
35
36
  "watch": "yarn webiny run watch"
36
37
  },
37
- "gitHead": "cad155812edbdd577a1cc858b41038fdd7a6d2d9"
38
+ "gitHead": "c472d20682885fb538354c206a148deaae14bfe8"
38
39
  }
@@ -1,11 +1,11 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- interface Callable<TContext> {
3
- (context: TContext): void | Promise<void>;
2
+ import { Context } from "../types";
3
+ export interface BeforeHandlerCallable<T extends Context = Context> {
4
+ (context: T): void | Promise<void>;
4
5
  }
5
- export declare class BeforeHandlerPlugin<TContext> extends Plugin {
6
- static readonly type = "before-handler";
6
+ export declare class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {
7
+ static readonly type: string;
7
8
  private readonly _callable;
8
- constructor(callable?: Callable<TContext>);
9
- apply(context: TContext): void | Promise<void>;
9
+ constructor(callable?: BeforeHandlerCallable<T>);
10
+ apply(context: T): void | Promise<void>;
10
11
  }
11
- export {};
@@ -0,0 +1,19 @@
1
+ import { Context as ContextInterface, HandlerArgs } from "../types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ export interface Params {
4
+ args?: HandlerArgs;
5
+ plugins?: Plugin | Plugin[] | Plugin[][] | PluginsContainer;
6
+ WEBINY_VERSION: string;
7
+ }
8
+ export declare class Context implements ContextInterface {
9
+ _result: any;
10
+ readonly plugins: PluginsContainer;
11
+ readonly args: HandlerArgs;
12
+ readonly WEBINY_VERSION: string;
13
+ private readonly waiters;
14
+ constructor(params: Params);
15
+ getResult(): any;
16
+ hasResult(): boolean;
17
+ setResult(value: any): void;
18
+ waitFor<T extends ContextInterface = ContextInterface>(obj: string | string[], cb: (context: T) => void): void;
19
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Context = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class Context {
15
+ constructor(params) {
16
+ (0, _defineProperty2.default)(this, "_result", void 0);
17
+ (0, _defineProperty2.default)(this, "plugins", void 0);
18
+ (0, _defineProperty2.default)(this, "args", void 0);
19
+ (0, _defineProperty2.default)(this, "WEBINY_VERSION", void 0);
20
+ (0, _defineProperty2.default)(this, "waiters", []);
21
+ const {
22
+ plugins,
23
+ args,
24
+ WEBINY_VERSION
25
+ } = params;
26
+ this.plugins = new _plugins.PluginsContainer(plugins || []);
27
+ this.args = args || [];
28
+ this.WEBINY_VERSION = WEBINY_VERSION;
29
+ }
30
+
31
+ getResult() {
32
+ return this._result;
33
+ }
34
+
35
+ hasResult() {
36
+ return !!this._result;
37
+ }
38
+
39
+ setResult(value) {
40
+ this._result = value;
41
+ }
42
+
43
+ waitFor(obj, cb) {
44
+ const initialTargets = Array.isArray(obj) ? obj : [obj];
45
+ const targets = [];
46
+ /**
47
+ * We go only through the first level properties
48
+ */
49
+
50
+ for (const target of initialTargets) {
51
+ /**
52
+ * If property already exists, there is no need to wait for it, so we just continue the loop.
53
+ */
54
+ if (this[target]) {
55
+ continue;
56
+ }
57
+ /**
58
+ * Since there is no property, we must define it with its setter and getter.
59
+ * We could not know when it got defined otherwise.
60
+ */
61
+
62
+
63
+ Object.defineProperty(this, target, {
64
+ /**
65
+ * Setter sets the given value to this object.
66
+ * We cannot set it on exact property name it is defined because it would go into loop of setting itself.
67
+ * And that is why we add __ around the property name.
68
+ */
69
+ set: value => {
70
+ this[`__${target}__`] = value;
71
+ /**
72
+ * WWhen the property is set, we will go through all the waiters and, if any of them include currently set property, act on it.
73
+ */
74
+
75
+ for (const waiter of this.waiters) {
76
+ if (waiter.targets.includes(target) === false) {
77
+ continue;
78
+ }
79
+ /**
80
+ * Remove currently set property so we know if there are any more to be waited for.
81
+ */
82
+
83
+
84
+ waiter.targets = waiter.targets.filter(t => t !== target);
85
+ /**
86
+ * If there are more to be waited, eg. user added [cms, pageBuilder] as waited properties, we just continue the loop.
87
+ */
88
+
89
+ if (waiter.targets.length > 0) {
90
+ continue;
91
+ }
92
+ /**
93
+ * And if there is nothing more to be waited for, we execute the callable.
94
+ * Note that this callable is not async.
95
+ */
96
+
97
+
98
+ waiter.cb(this);
99
+ }
100
+ },
101
+
102
+ /**
103
+ * As we have set property with __ around it, we must get it as well.
104
+ */
105
+ get: () => {
106
+ return this[`__${target}__`];
107
+ },
108
+ configurable: false
109
+ });
110
+ /**
111
+ * We add the target to be awaited.
112
+ */
113
+
114
+ targets.push(target);
115
+ }
116
+ /**
117
+ * If there are no targets to be awaited, just fire the callable.
118
+ */
119
+
120
+
121
+ if (targets.length === 0) {
122
+ cb(this);
123
+ return;
124
+ }
125
+ /**
126
+ * Otherwise add the waiter for the target properties.
127
+ */
128
+
129
+
130
+ this.waiters.push({
131
+ targets,
132
+ cb
133
+ });
134
+ }
135
+
136
+ }
137
+
138
+ exports.Context = Context;
@@ -1,11 +1,11 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- interface Callable<TContext> {
3
- (context: TContext): void | Promise<void>;
2
+ import { Context } from "../types";
3
+ export interface ContextCallable<T extends Context = Context> {
4
+ (context: T): void | Promise<void>;
4
5
  }
5
- export declare class ContextPlugin<TContext> extends Plugin {
6
+ export declare class ContextPlugin<T extends Context = Context> extends Plugin {
6
7
  static readonly type = "context";
7
8
  private readonly _callable;
8
- constructor(callable?: Callable<TContext>);
9
- apply(context: TContext): void | Promise<void>;
9
+ constructor(callable?: ContextCallable<T>);
10
+ apply(context: T): void | Promise<void>;
10
11
  }
11
- export {};
@@ -0,0 +1,11 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Context } from "../types";
3
+ export interface HandlerErrorCallable<T extends Context = Context> {
4
+ (context: T, error: Error, next: Function): Promise<any>;
5
+ }
6
+ export declare class HandlerErrorPlugin<T extends Context = Context> extends Plugin {
7
+ static readonly type: string;
8
+ private readonly _callable;
9
+ constructor(callable: HandlerErrorCallable<T>);
10
+ handle(context: T, error: Error, next: Function): Promise<any>;
11
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.HandlerErrorPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class HandlerErrorPlugin extends _plugins.Plugin {
15
+ constructor(callable) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "_callable", void 0);
18
+ this._callable = callable;
19
+ }
20
+
21
+ async handle(context, error, next) {
22
+ return this._callable(context, error, next);
23
+ }
24
+
25
+ }
26
+
27
+ exports.HandlerErrorPlugin = HandlerErrorPlugin;
28
+ (0, _defineProperty2.default)(HandlerErrorPlugin, "type", "handler-error");
@@ -0,0 +1,11 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Context } from "../types";
3
+ export interface HandlerCallable<T extends Context = Context> {
4
+ (context: T, next: Function): Promise<any>;
5
+ }
6
+ export declare class HandlerPlugin<T extends Context = Context> extends Plugin {
7
+ static readonly type: string;
8
+ private readonly _callable;
9
+ constructor(callable: HandlerCallable<T>);
10
+ handle(context: T, next: Function): Promise<any>;
11
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.HandlerPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class HandlerPlugin extends _plugins.Plugin {
15
+ constructor(callable) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "_callable", void 0);
18
+ this._callable = callable;
19
+ }
20
+
21
+ async handle(context, next) {
22
+ return this._callable(context, next);
23
+ }
24
+
25
+ }
26
+
27
+ exports.HandlerPlugin = HandlerPlugin;
28
+ (0, _defineProperty2.default)(HandlerPlugin, "type", "handler");
@@ -0,0 +1,11 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { Context } from "../types";
3
+ export interface HandlerResultCallable<T extends Context = Context> {
4
+ (context: T, result: any): Promise<any>;
5
+ }
6
+ export declare class HandlerResultPlugin<T extends Context = Context> extends Plugin {
7
+ static readonly type: string;
8
+ private readonly _callable;
9
+ constructor(callable: HandlerResultCallable<T>);
10
+ handle(context: T, result: any): Promise<any>;
11
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.HandlerResultPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _plugins = require("@webiny/plugins");
13
+
14
+ class HandlerResultPlugin extends _plugins.Plugin {
15
+ constructor(callable) {
16
+ super();
17
+ (0, _defineProperty2.default)(this, "_callable", void 0);
18
+ this._callable = callable;
19
+ }
20
+
21
+ async handle(context, result) {
22
+ return this._callable(context, result);
23
+ }
24
+
25
+ }
26
+
27
+ exports.HandlerResultPlugin = HandlerResultPlugin;
28
+ (0, _defineProperty2.default)(HandlerResultPlugin, "type", "handler-result");
package/types.d.ts CHANGED
@@ -1,36 +1,82 @@
1
1
  import { Plugin, PluginsContainer } from "@webiny/plugins/types";
2
2
  export declare type HandlerArgs = any[];
3
- export interface HandlerContext {
3
+ /**
4
+ * Left for backwards compatibility.
5
+ * @deprecated
6
+ */
7
+ export declare type HandlerContext = Context;
8
+ /**
9
+ * The main context which is constructed on every request.
10
+ * All other contexts should extend this one.
11
+ */
12
+ export interface Context {
4
13
  plugins: PluginsContainer;
5
14
  args: HandlerArgs;
6
15
  readonly WEBINY_VERSION: string;
16
+ /**
17
+ * Not to be used outside of Webiny internal code.
18
+ * @internal
19
+ */
20
+ hasResult: () => boolean;
21
+ /**
22
+ * Not to be used outside of Webiny internal code.
23
+ * @internal
24
+ *
25
+ * @private
26
+ */
27
+ _result?: any;
28
+ /**
29
+ * Not to be used outside of Webiny internal code.
30
+ * @internal
31
+ */
32
+ setResult: (value: any) => void;
33
+ /**
34
+ * Not to be used outside of Webiny internal code.
35
+ * @internal
36
+ */
37
+ getResult: () => void;
38
+ /**
39
+ * Wait for property to be defined on the object and then execute the callable.
40
+ * In case of multiple objects defined, wait for all of them.
41
+ */
42
+ waitFor: <T extends Context = Context>(obj: string[] | string, cb: (context: T) => void) => void;
7
43
  }
8
- export interface ContextInterface {
9
- plugins: PluginsContainer;
10
- args: HandlerArgs;
11
- readonly WEBINY_VERSION: string;
12
- }
13
- export declare type Context<C0 = Record<string, any>, C1 = Record<string, any>, C2 = Record<string, any>, C3 = Record<string, any>, C4 = Record<string, any>, C5 = Record<string, any>, C6 = Record<string, any>, C7 = Record<string, any>, C8 = Record<string, any>, C9 = Record<string, any>> = {
14
- plugins: PluginsContainer;
15
- args: HandlerArgs;
16
- readonly WEBINY_VERSION: string;
17
- } & C0 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 & C9;
18
- export interface BeforeHandlerPlugin<T extends ContextInterface = ContextInterface> extends Plugin {
19
- type: "before-handler";
20
- apply: (context: T) => Promise<void>;
21
- }
44
+ /**
45
+ * Left for backwards-compatibility.
46
+ *
47
+ * @internal
48
+ * @deprecated
49
+ */
22
50
  export declare type ContextPlugin<C0 = Context, C1 = Context, C2 = Context, C3 = Context, C4 = Context, C5 = Context, C6 = Context, C7 = Context, C8 = Context, C9 = Context> = Plugin & {
23
51
  type: "context";
24
52
  apply(context: C0 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 & C9): Promise<void>;
25
53
  };
54
+ /**
55
+ * Left for backwards-compatibility.
56
+ *
57
+ * @internal
58
+ * @deprecated
59
+ */
26
60
  export declare type HandlerPlugin<C0 = Context, C1 = Context, C2 = Context, C3 = Context, C4 = Context, C5 = Context, C6 = Context, C7 = Context, C8 = Context, C9 = Context> = Plugin & {
27
61
  type: "handler";
28
62
  handle(context: C0 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 & C9, next: Function): any;
29
63
  };
64
+ /**
65
+ * Left for backwards-compatibility.
66
+ *
67
+ * @internal
68
+ * @deprecated
69
+ */
30
70
  export declare type HandlerResultPlugin<C0 = Context, C1 = Context, C2 = Context, C3 = Context, C4 = Context, C5 = Context, C6 = Context, C7 = Context, C8 = Context, C9 = Context> = Plugin & {
31
71
  type: "handler-result";
32
72
  handle(context: C0 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 & C9, result: any): any;
33
73
  };
74
+ /**
75
+ * Left for backwards-compatibility.
76
+ *
77
+ * @internal
78
+ * @deprecated
79
+ */
34
80
  export declare type HandlerErrorPlugin<C0 = Context, C1 = Context, C2 = Context, C3 = Context, C4 = Context, C5 = Context, C6 = Context, C7 = Context, C8 = Context, C9 = Context> = Plugin & {
35
81
  type: "handler-error";
36
82
  handle(context: C0 & C1 & C2 & C3 & C4 & C5 & C6 & C7 & C8 & C9, error: any, next: Function): Promise<any>;