@webiny/handler-client 0.0.0-ee-vpcs.549378cf03
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/HandlerClient.d.ts +12 -0
- package/HandlerClient.js +101 -0
- package/HandlerClient.js.map +1 -0
- package/HandlerClientPlugin.d.ts +18 -0
- package/HandlerClientPlugin.js +41 -0
- package/HandlerClientPlugin.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/index.d.ts +7 -0
- package/index.js +39 -0
- package/index.js.map +1 -0
- package/package.json +44 -0
- package/types.d.ts +16 -0
- package/types.js +5 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InvokeArgs, ClientContext } from "./types";
|
|
2
|
+
declare class HandlerClient {
|
|
3
|
+
private readonly plugin;
|
|
4
|
+
/**
|
|
5
|
+
* We need the default plugin to later on fetch another plugin than initially selected.
|
|
6
|
+
* If name of the required plugin is not the default one, fetch new one.
|
|
7
|
+
*/
|
|
8
|
+
private readonly default;
|
|
9
|
+
constructor(context: ClientContext);
|
|
10
|
+
invoke<TInvokeArgsPayload = any, TResponse = any>(params: InvokeArgs<TInvokeArgsPayload>): Promise<TResponse>;
|
|
11
|
+
}
|
|
12
|
+
export default HandlerClient;
|
package/HandlerClient.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
14
|
+
var _HandlerClientPlugin = require("./HandlerClientPlugin");
|
|
15
|
+
|
|
16
|
+
const defaultPluginName = "handler-client";
|
|
17
|
+
|
|
18
|
+
const getPluginFetcher = context => {
|
|
19
|
+
const pl = new _HandlerClientPlugin.HandlerClientPlugin({
|
|
20
|
+
invoke: async params => {
|
|
21
|
+
const {
|
|
22
|
+
name,
|
|
23
|
+
payload,
|
|
24
|
+
await: useAwait
|
|
25
|
+
} = params;
|
|
26
|
+
const plugin = context.plugins.byName(name);
|
|
27
|
+
|
|
28
|
+
if (!plugin) {
|
|
29
|
+
throw new _error.default(`Could not find "${name}" handler plugin.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const promise = plugin.invoke(payload);
|
|
33
|
+
|
|
34
|
+
if (useAwait === false) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return promise;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
pl.name = defaultPluginName;
|
|
42
|
+
return pl;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getHandlerClientPlugin = context => {
|
|
46
|
+
const plugin = context.plugins.byName("handler-client");
|
|
47
|
+
|
|
48
|
+
if (plugin) {
|
|
49
|
+
return plugin;
|
|
50
|
+
} // If not specified, use a fallback plugin that fetches different handlers via plugins.
|
|
51
|
+
// This might also be useful for testing purposes.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
return getPluginFetcher(context);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
class HandlerClient {
|
|
58
|
+
/**
|
|
59
|
+
* We need the default plugin to later on fetch another plugin than initially selected.
|
|
60
|
+
* If name of the required plugin is not the default one, fetch new one.
|
|
61
|
+
*/
|
|
62
|
+
constructor(context) {
|
|
63
|
+
(0, _defineProperty2.default)(this, "plugin", void 0);
|
|
64
|
+
(0, _defineProperty2.default)(this, "default", void 0);
|
|
65
|
+
this.plugin = getHandlerClientPlugin(context);
|
|
66
|
+
this.default = getPluginFetcher(context);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async invoke(params) {
|
|
70
|
+
let plugin = this.plugin;
|
|
71
|
+
|
|
72
|
+
if (plugin.canHandle && plugin.canHandle(params) === false) {
|
|
73
|
+
plugin = this.default;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
return await plugin.invoke(params);
|
|
78
|
+
} catch (ex) {
|
|
79
|
+
/**
|
|
80
|
+
* We collect error that was caught and the description of the invoke, if any.
|
|
81
|
+
*/
|
|
82
|
+
const data = {
|
|
83
|
+
error: {
|
|
84
|
+
message: ex.message,
|
|
85
|
+
data: ex.data,
|
|
86
|
+
code: ex.code
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
if (params.description) {
|
|
91
|
+
data.description = params.description;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
throw new _error.default(`An error occurred while trying to invoke another handler with the following params: ${JSON.stringify(params, null, 2)}`, "INVOKE_ERROR", data);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var _default = HandlerClient;
|
|
101
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultPluginName","getPluginFetcher","context","pl","HandlerClientPlugin","invoke","params","name","payload","await","useAwait","plugin","plugins","byName","WebinyError","promise","getHandlerClientPlugin","HandlerClient","constructor","default","canHandle","ex","data","error","message","code","description","JSON","stringify"],"sources":["HandlerClient.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { HandlerClientHandlerPlugin, InvokeArgs, ClientContext } from \"./types\";\nimport { HandlerClientPlugin } from \"~/HandlerClientPlugin\";\n\nconst defaultPluginName = \"handler-client\";\n\nconst getPluginFetcher = (context: ClientContext): HandlerClientPlugin => {\n const pl = new HandlerClientPlugin({\n invoke: async params => {\n const { name, payload, await: useAwait } = params;\n const plugin = context.plugins.byName<HandlerClientHandlerPlugin>(name);\n if (!plugin) {\n throw new WebinyError(`Could not find \"${name}\" handler plugin.`);\n }\n\n const promise = plugin.invoke(payload);\n if (useAwait === false) {\n return null;\n }\n\n return promise;\n }\n });\n pl.name = defaultPluginName;\n return pl;\n};\n\nconst getHandlerClientPlugin = (context: ClientContext): HandlerClientPlugin => {\n const plugin = context.plugins.byName<HandlerClientPlugin>(\"handler-client\");\n if (plugin) {\n return plugin;\n }\n // If not specified, use a fallback plugin that fetches different handlers via plugins.\n // This might also be useful for testing purposes.\n return getPluginFetcher(context);\n};\n\nclass HandlerClient {\n private readonly plugin: HandlerClientPlugin;\n /**\n * We need the default plugin to later on fetch another plugin than initially selected.\n * If name of the required plugin is not the default one, fetch new one.\n */\n private readonly default: HandlerClientPlugin;\n\n constructor(context: ClientContext) {\n this.plugin = getHandlerClientPlugin(context);\n this.default = getPluginFetcher(context);\n }\n\n public async invoke<TInvokeArgsPayload = any, TResponse = any>(\n params: InvokeArgs<TInvokeArgsPayload>\n ): Promise<TResponse> {\n let plugin: HandlerClientPlugin = this.plugin;\n if (plugin.canHandle && plugin.canHandle(params) === false) {\n plugin = this.default;\n }\n try {\n return await plugin.invoke(params);\n } catch (ex) {\n /**\n * We collect error that was caught and the description of the invoke, if any.\n */\n const data: Record<string, any> = {\n error: {\n message: ex.message,\n data: ex.data,\n code: ex.code\n }\n };\n if (params.description) {\n data.description = params.description;\n }\n throw new WebinyError(\n `An error occurred while trying to invoke another handler with the following params: ${JSON.stringify(\n params,\n null,\n 2\n )}`,\n \"INVOKE_ERROR\",\n data\n );\n }\n }\n}\n\nexport default HandlerClient;\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AAEA,MAAMA,iBAAiB,GAAG,gBAA1B;;AAEA,MAAMC,gBAAgB,GAAIC,OAAD,IAAiD;EACtE,MAAMC,EAAE,GAAG,IAAIC,wCAAJ,CAAwB;IAC/BC,MAAM,EAAE,MAAMC,MAAN,IAAgB;MACpB,MAAM;QAAEC,IAAF;QAAQC,OAAR;QAAiBC,KAAK,EAAEC;MAAxB,IAAqCJ,MAA3C;MACA,MAAMK,MAAM,GAAGT,OAAO,CAACU,OAAR,CAAgBC,MAAhB,CAAmDN,IAAnD,CAAf;;MACA,IAAI,CAACI,MAAL,EAAa;QACT,MAAM,IAAIG,cAAJ,CAAiB,mBAAkBP,IAAK,mBAAxC,CAAN;MACH;;MAED,MAAMQ,OAAO,GAAGJ,MAAM,CAACN,MAAP,CAAcG,OAAd,CAAhB;;MACA,IAAIE,QAAQ,KAAK,KAAjB,EAAwB;QACpB,OAAO,IAAP;MACH;;MAED,OAAOK,OAAP;IACH;EAd8B,CAAxB,CAAX;EAgBAZ,EAAE,CAACI,IAAH,GAAUP,iBAAV;EACA,OAAOG,EAAP;AACH,CAnBD;;AAqBA,MAAMa,sBAAsB,GAAId,OAAD,IAAiD;EAC5E,MAAMS,MAAM,GAAGT,OAAO,CAACU,OAAR,CAAgBC,MAAhB,CAA4C,gBAA5C,CAAf;;EACA,IAAIF,MAAJ,EAAY;IACR,OAAOA,MAAP;EACH,CAJ2E,CAK5E;EACA;;;EACA,OAAOV,gBAAgB,CAACC,OAAD,CAAvB;AACH,CARD;;AAUA,MAAMe,aAAN,CAAoB;EAEhB;AACJ;AACA;AACA;EAGIC,WAAW,CAAChB,OAAD,EAAyB;IAAA;IAAA;IAChC,KAAKS,MAAL,GAAcK,sBAAsB,CAACd,OAAD,CAApC;IACA,KAAKiB,OAAL,GAAelB,gBAAgB,CAACC,OAAD,CAA/B;EACH;;EAEkB,MAANG,MAAM,CACfC,MADe,EAEG;IAClB,IAAIK,MAA2B,GAAG,KAAKA,MAAvC;;IACA,IAAIA,MAAM,CAACS,SAAP,IAAoBT,MAAM,CAACS,SAAP,CAAiBd,MAAjB,MAA6B,KAArD,EAA4D;MACxDK,MAAM,GAAG,KAAKQ,OAAd;IACH;;IACD,IAAI;MACA,OAAO,MAAMR,MAAM,CAACN,MAAP,CAAcC,MAAd,CAAb;IACH,CAFD,CAEE,OAAOe,EAAP,EAAW;MACT;AACZ;AACA;MACY,MAAMC,IAAyB,GAAG;QAC9BC,KAAK,EAAE;UACHC,OAAO,EAAEH,EAAE,CAACG,OADT;UAEHF,IAAI,EAAED,EAAE,CAACC,IAFN;UAGHG,IAAI,EAAEJ,EAAE,CAACI;QAHN;MADuB,CAAlC;;MAOA,IAAInB,MAAM,CAACoB,WAAX,EAAwB;QACpBJ,IAAI,CAACI,WAAL,GAAmBpB,MAAM,CAACoB,WAA1B;MACH;;MACD,MAAM,IAAIZ,cAAJ,CACD,uFAAsFa,IAAI,CAACC,SAAL,CACnFtB,MADmF,EAEnF,IAFmF,EAGnF,CAHmF,CAIrF,EALA,EAMF,cANE,EAOFgB,IAPE,CAAN;IASH;EACJ;;AA9Ce;;eAiDLL,a"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import { InvokeArgs } from "./types";
|
|
3
|
+
interface HandlerClientPluginCallable<Payload = Record<string, any>, Response = any> {
|
|
4
|
+
(params: InvokeArgs<Payload>): Promise<Response>;
|
|
5
|
+
}
|
|
6
|
+
export interface HandlerClientPluginParams {
|
|
7
|
+
invoke: HandlerClientPluginCallable;
|
|
8
|
+
canUse?: (params: InvokeArgs) => boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class HandlerClientPlugin extends Plugin {
|
|
11
|
+
static type: string;
|
|
12
|
+
private readonly _invoke;
|
|
13
|
+
private readonly canUse?;
|
|
14
|
+
constructor({ invoke, canUse }: HandlerClientPluginParams);
|
|
15
|
+
canHandle(params: InvokeArgs): boolean;
|
|
16
|
+
invoke<Payload = any, Response = any>(params: InvokeArgs<Payload>): Promise<Response>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.HandlerClientPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
+
|
|
14
|
+
class HandlerClientPlugin extends _Plugin.Plugin {
|
|
15
|
+
constructor({
|
|
16
|
+
invoke,
|
|
17
|
+
canUse
|
|
18
|
+
}) {
|
|
19
|
+
super();
|
|
20
|
+
(0, _defineProperty2.default)(this, "_invoke", void 0);
|
|
21
|
+
(0, _defineProperty2.default)(this, "canUse", void 0);
|
|
22
|
+
this._invoke = invoke;
|
|
23
|
+
this.canUse = canUse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
canHandle(params) {
|
|
27
|
+
if (!this.canUse) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return this.canUse(params);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
invoke(params) {
|
|
35
|
+
return this._invoke(params);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.HandlerClientPlugin = HandlerClientPlugin;
|
|
41
|
+
(0, _defineProperty2.default)(HandlerClientPlugin, "type", "handler-client");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HandlerClientPlugin","Plugin","constructor","invoke","canUse","_invoke","canHandle","params"],"sources":["HandlerClientPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { InvokeArgs } from \"~/types\";\n\ninterface HandlerClientPluginCallable<Payload = Record<string, any>, Response = any> {\n (params: InvokeArgs<Payload>): Promise<Response>;\n}\n\nexport interface HandlerClientPluginParams {\n invoke: HandlerClientPluginCallable;\n canUse?: (params: InvokeArgs) => boolean;\n}\n\nexport class HandlerClientPlugin extends Plugin {\n public static override type = \"handler-client\";\n\n private readonly _invoke: HandlerClientPluginCallable;\n private readonly canUse?: (params: InvokeArgs) => boolean;\n\n public constructor({ invoke, canUse }: HandlerClientPluginParams) {\n super();\n this._invoke = invoke;\n this.canUse = canUse;\n }\n\n public canHandle(params: InvokeArgs): boolean {\n if (!this.canUse) {\n return true;\n }\n return this.canUse(params);\n }\n\n public invoke<Payload = any, Response = any>(params: InvokeArgs<Payload>): Promise<Response> {\n return this._invoke(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAYO,MAAMA,mBAAN,SAAkCC,cAAlC,CAAyC;EAMrCC,WAAW,CAAC;IAAEC,MAAF;IAAUC;EAAV,CAAD,EAAgD;IAC9D;IAD8D;IAAA;IAE9D,KAAKC,OAAL,GAAeF,MAAf;IACA,KAAKC,MAAL,GAAcA,MAAd;EACH;;EAEME,SAAS,CAACC,MAAD,EAA8B;IAC1C,IAAI,CAAC,KAAKH,MAAV,EAAkB;MACd,OAAO,IAAP;IACH;;IACD,OAAO,KAAKA,MAAL,CAAYG,MAAZ,CAAP;EACH;;EAEMJ,MAAM,CAAgCI,MAAhC,EAAgF;IACzF,OAAO,KAAKF,OAAL,CAAaE,MAAb,CAAP;EACH;;AArB2C;;;8BAAnCP,mB,UACqB,gB"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @webiny/handler-client
|
|
2
|
+
[](https://www.npmjs.com/package/@webiny/handler-client)
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/handler-client)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
The base package for building Webiny and React powered web apps.
|
|
8
|
+
|
|
9
|
+
For more information, please visit [the official docs](https://docs.webiny.com/docs/webiny/introduction).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
```
|
|
13
|
+
npm install --save @webiny/handler-client
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or if you prefer yarn:
|
|
17
|
+
```
|
|
18
|
+
yarn add @webiny/handler-client
|
|
19
|
+
```
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
createHandlerClient: true
|
|
10
|
+
};
|
|
11
|
+
exports.createHandlerClient = void 0;
|
|
12
|
+
|
|
13
|
+
var _HandlerClient = _interopRequireDefault(require("./HandlerClient"));
|
|
14
|
+
|
|
15
|
+
var _HandlerClientPlugin = require("./HandlerClientPlugin");
|
|
16
|
+
|
|
17
|
+
Object.keys(_HandlerClientPlugin).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _HandlerClientPlugin[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _HandlerClientPlugin[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const createHandlerClient = () => ({
|
|
30
|
+
type: "context",
|
|
31
|
+
name: "handler-client.context",
|
|
32
|
+
|
|
33
|
+
async apply(context) {
|
|
34
|
+
context.handlerClient = new _HandlerClient.default(context);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.createHandlerClient = createHandlerClient;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createHandlerClient","type","name","apply","context","handlerClient","HandlerClient"],"sources":["index.ts"],"sourcesContent":["import HandlerClient from \"./HandlerClient\";\nimport { ClientContext } from \"~/types\";\n\nexport * from \"./HandlerClientPlugin\";\n\nexport const createHandlerClient = () => ({\n type: \"context\",\n name: \"handler-client.context\",\n async apply(context: ClientContext) {\n context.handlerClient = new HandlerClient(context);\n }\n});\n"],"mappings":";;;;;;;;;;;;AAAA;;AAGA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEO,MAAMA,mBAAmB,GAAG,OAAO;EACtCC,IAAI,EAAE,SADgC;EAEtCC,IAAI,EAAE,wBAFgC;;EAGtC,MAAMC,KAAN,CAAYC,OAAZ,EAAoC;IAChCA,OAAO,CAACC,aAAR,GAAwB,IAAIC,sBAAJ,CAAkBF,OAAlB,CAAxB;EACH;;AALqC,CAAP,CAA5B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/handler-client",
|
|
3
|
+
"version": "0.0.0-ee-vpcs.549378cf03",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "A package that contains plugins for developing Webiny API in the AWS cloud.",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
|
12
|
+
"Sven Al Hamad <sven@webiny.com>",
|
|
13
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@babel/runtime": "7.19.0",
|
|
18
|
+
"@webiny/api": "0.0.0-ee-vpcs.549378cf03",
|
|
19
|
+
"@webiny/error": "0.0.0-ee-vpcs.549378cf03",
|
|
20
|
+
"@webiny/plugins": "0.0.0-ee-vpcs.549378cf03"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@babel/cli": "^7.19.3",
|
|
24
|
+
"@babel/core": "^7.19.3",
|
|
25
|
+
"@babel/preset-env": "^7.19.4",
|
|
26
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
27
|
+
"@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
|
|
28
|
+
"@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
|
|
29
|
+
"babel-plugin-lodash": "^3.3.4",
|
|
30
|
+
"jest": "^28.1.0",
|
|
31
|
+
"merge": "^1.2.1",
|
|
32
|
+
"rimraf": "^3.0.2",
|
|
33
|
+
"typescript": "4.7.4"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"directory": "dist"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "yarn webiny run build",
|
|
41
|
+
"watch": "yarn webiny run watch"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
|
|
44
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import HandlerClient from "./HandlerClient";
|
|
2
|
+
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
+
import { Context } from "@webiny/api/types";
|
|
4
|
+
export declare type InvokeArgs<TInvokeArgsPayload = any> = {
|
|
5
|
+
name: string;
|
|
6
|
+
payload?: TInvokeArgsPayload;
|
|
7
|
+
await?: boolean;
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type HandlerClientHandlerPlugin = Plugin & {
|
|
11
|
+
type: "handler-client-handler";
|
|
12
|
+
invoke: <TArgs = Record<string, any>, TResponse = Record<string, any>>(params: TArgs) => TResponse | Promise<TResponse>;
|
|
13
|
+
};
|
|
14
|
+
export interface ClientContext extends Context {
|
|
15
|
+
handlerClient: HandlerClient;
|
|
16
|
+
}
|
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import HandlerClient from \"./HandlerClient\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport type InvokeArgs<TInvokeArgsPayload = any> = {\n name: string;\n payload?: TInvokeArgsPayload;\n await?: boolean;\n description?: string;\n};\n\nexport type HandlerClientHandlerPlugin = Plugin & {\n type: \"handler-client-handler\";\n invoke: <TArgs = Record<string, any>, TResponse = Record<string, any>>(\n params: TArgs\n ) => TResponse | Promise<TResponse>;\n};\n\nexport interface ClientContext extends Context {\n handlerClient: HandlerClient;\n}\n"],"mappings":""}
|