@webiny/handler-client 5.24.0 → 5.25.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/HandlerClient.js CHANGED
@@ -11,40 +11,46 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
14
- class HandlerClient {
15
- constructor(context) {
16
- (0, _defineProperty2.default)(this, "plugin", void 0);
17
- this.plugin = context.plugins.byName("handler-client");
14
+ const getHandlerClientPlugin = context => {
15
+ const plugin = context.plugins.byName("handler-client");
18
16
 
19
- if (!this.plugin) {
20
- // If not specified, use a fallback plugin that fetches different handlers via plugins.
21
- // This might also be useful for testing purposes.
22
- this.plugin = {
23
- type: "handler-client",
24
- name: "handler-client",
17
+ if (plugin) {
18
+ return plugin;
19
+ } // If not specified, use a fallback plugin that fetches different handlers via plugins.
20
+ // This might also be useful for testing purposes.
25
21
 
26
- async invoke({
27
- name,
28
- payload,
29
- await: useAwait
30
- }) {
31
- const plugin = context.plugins.byName(name);
32
22
 
33
- if (!plugin) {
34
- throw new _error.default(`Could not find "${name}" handler plugin.`);
35
- }
23
+ return {
24
+ type: "handler-client",
25
+ name: "handler-client",
36
26
 
37
- const promise = plugin.invoke(payload);
27
+ async invoke({
28
+ name,
29
+ payload,
30
+ await: useAwait
31
+ }) {
32
+ const plugin = context.plugins.byName(name);
38
33
 
39
- if (useAwait === false) {
40
- return null;
41
- }
34
+ if (!plugin) {
35
+ throw new _error.default(`Could not find "${name}" handler plugin.`);
36
+ }
42
37
 
43
- return promise;
44
- }
38
+ const promise = plugin.invoke(payload);
45
39
 
46
- };
40
+ if (useAwait === false) {
41
+ return null;
42
+ }
43
+
44
+ return promise;
47
45
  }
46
+
47
+ };
48
+ };
49
+
50
+ class HandlerClient {
51
+ constructor(context) {
52
+ (0, _defineProperty2.default)(this, "plugin", void 0);
53
+ this.plugin = getHandlerClientPlugin(context);
48
54
  }
49
55
 
50
56
  invoke(params) {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["HandlerClient.ts"],"names":["getHandlerClientPlugin","context","plugin","plugins","byName","type","name","invoke","payload","await","useAwait","WebinyError","promise","HandlerClient","constructor","params","e","JSON","stringify"],"mappings":";;;;;;;;;;;AAMA;;AAEA,MAAMA,sBAAsB,GAAIC,OAAD,IAAiD;AAC5E,QAAMC,MAAM,GAAGD,OAAO,CAACE,OAAR,CAAgBC,MAAhB,CAA4C,gBAA5C,CAAf;;AACA,MAAIF,MAAJ,EAAY;AACR,WAAOA,MAAP;AACH,GAJ2E,CAK5E;AACA;;;AACA,SAAO;AACHG,IAAAA,IAAI,EAAE,gBADH;AAEHC,IAAAA,IAAI,EAAE,gBAFH;;AAGH,UAAMC,MAAN,CAAa;AAAED,MAAAA,IAAF;AAAQE,MAAAA,OAAR;AAAiBC,MAAAA,KAAK,EAAEC;AAAxB,KAAb,EAAiD;AAC7C,YAAMR,MAAM,GAAGD,OAAO,CAACE,OAAR,CAAgBC,MAAhB,CAAmDE,IAAnD,CAAf;;AACA,UAAI,CAACJ,MAAL,EAAa;AACT,cAAM,IAAIS,cAAJ,CAAiB,mBAAkBL,IAAK,mBAAxC,CAAN;AACH;;AAED,YAAMM,OAAO,GAAGV,MAAM,CAACK,MAAP,CAAcC,OAAd,CAAhB;;AACA,UAAIE,QAAQ,KAAK,KAAjB,EAAwB;AACpB,eAAO,IAAP;AACH;;AAED,aAAOE,OAAP;AACH;;AAfE,GAAP;AAiBH,CAxBD;;AA0BA,MAAMC,aAAN,CAAoB;AAEhBC,EAAAA,WAAW,CAACb,OAAD,EAAyB;AAAA;AAChC,SAAKC,MAAL,GAAcF,sBAAsB,CAACC,OAAD,CAApC;AACH;;AAEDM,EAAAA,MAAM,CACFQ,MADE,EAEgB;AAClB,QAAI;AACA,aAAO,KAAKb,MAAL,CAAYK,MAAZ,CAAmBQ,MAAnB,CAAP;AACH,KAFD,CAEE,OAAOC,CAAP,EAAU;AACR,YAAM,IAAIL,cAAJ,CACD,uFAAsFM,IAAI,CAACC,SAAL,CACnFH,MADmF,EAEnF,IAFmF,EAGnF,CAHmF,CAIrF,EALA,CAAN;AAOH;AACJ;;AApBe;;eAuBLF,a","sourcesContent":["import {\n HandlerClientPlugin,\n HandlerClientHandlerPlugin,\n InvokeArgs,\n ClientContext\n} from \"./types\";\nimport WebinyError from \"@webiny/error\";\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 {\n type: \"handler-client\",\n name: \"handler-client\",\n async invoke({ name, payload, await: useAwait }) {\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};\n\nclass HandlerClient {\n private readonly plugin: HandlerClientPlugin;\n constructor(context: ClientContext) {\n this.plugin = getHandlerClientPlugin(context);\n }\n\n invoke<TInvokeArgsPayload = any, TResponse = any>(\n params: InvokeArgs<TInvokeArgsPayload>\n ): Promise<TResponse> {\n try {\n return this.plugin.invoke(params);\n } catch (e) {\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 );\n }\n }\n}\n\nexport default HandlerClient;\n"]}
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["type","apply","context","handlerClient","HandlerClient"],"mappings":";;;;;;;;;AAAA;;eAGe,OAAO;AAClBA,EAAAA,IAAI,EAAE,SADY;;AAElBC,EAAAA,KAAK,CAACC,OAAD,EAAyB;AAC1BA,IAAAA,OAAO,CAACC,aAAR,GAAwB,IAAIC,sBAAJ,CAAkBF,OAAlB,CAAxB;AACH;;AAJiB,CAAP,C","sourcesContent":["import HandlerClient from \"./HandlerClient\";\nimport { ClientContext } from \"~/types\";\n\nexport default () => ({\n type: \"context\",\n apply(context: ClientContext) {\n context.handlerClient = new HandlerClient(context);\n }\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-client",
3
- "version": "5.24.0",
3
+ "version": "5.25.0-beta.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,23 +14,23 @@
14
14
  ],
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@babel/runtime": "7.16.7",
18
- "@webiny/error": "5.24.0",
19
- "@webiny/handler": "5.24.0",
20
- "@webiny/plugins": "5.24.0"
17
+ "@babel/runtime": "7.17.7",
18
+ "@webiny/error": "5.25.0-beta.2",
19
+ "@webiny/handler": "5.25.0-beta.2",
20
+ "@webiny/plugins": "5.25.0-beta.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@babel/cli": "^7.16.0",
24
24
  "@babel/core": "^7.16.0",
25
25
  "@babel/preset-env": "^7.16.4",
26
26
  "@babel/preset-typescript": "^7.16.0",
27
- "@webiny/cli": "^5.24.0",
28
- "@webiny/project-utils": "^5.24.0",
27
+ "@webiny/cli": "^5.25.0-beta.2",
28
+ "@webiny/project-utils": "^5.25.0-beta.2",
29
29
  "babel-plugin-lodash": "^3.3.4",
30
30
  "jest": "^26.6.3",
31
31
  "merge": "^1.2.1",
32
32
  "rimraf": "^3.0.2",
33
- "typescript": "^4.1.3"
33
+ "typescript": "4.5.5"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public",
@@ -40,5 +40,5 @@
40
40
  "build": "yarn webiny run build",
41
41
  "watch": "yarn webiny run watch"
42
42
  },
43
- "gitHead": "be0cbfcaa9247c658c44179af7943cc5d6d71bc7"
43
+ "gitHead": "ed2f22976af47aea0b6b5d638f8afdc39951b014"
44
44
  }
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}