@webiny/handler-client 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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.
@@ -1,4 +1,4 @@
1
- import { InvokeArgs, ClientContext } from "./types";
1
+ import type { InvokeArgs, ClientContext } from "./types";
2
2
  declare class HandlerClient {
3
3
  private readonly plugin;
4
4
  /**
package/HandlerClient.js CHANGED
@@ -1,20 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
8
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
9
  var _HandlerClientPlugin = require("./HandlerClientPlugin");
15
-
16
10
  const defaultPluginName = "handler-client";
17
-
18
11
  const getPluginFetcher = context => {
19
12
  const pl = new _HandlerClientPlugin.HandlerClientPlugin({
20
13
  invoke: async params => {
@@ -24,55 +17,43 @@ const getPluginFetcher = context => {
24
17
  await: useAwait
25
18
  } = params;
26
19
  const plugin = context.plugins.byName(name);
27
-
28
20
  if (!plugin) {
29
21
  throw new _error.default(`Could not find "${name}" handler plugin.`);
30
22
  }
31
-
32
23
  const promise = plugin.invoke(payload);
33
-
34
24
  if (useAwait === false) {
35
25
  return null;
36
26
  }
37
-
38
27
  return promise;
39
28
  }
40
29
  });
41
30
  pl.name = defaultPluginName;
42
31
  return pl;
43
32
  };
44
-
45
33
  const getHandlerClientPlugin = context => {
46
34
  const plugin = context.plugins.byName("handler-client");
47
-
48
35
  if (plugin) {
49
36
  return plugin;
50
- } // If not specified, use a fallback plugin that fetches different handlers via plugins.
37
+ }
38
+ // If not specified, use a fallback plugin that fetches different handlers via plugins.
51
39
  // This might also be useful for testing purposes.
52
-
53
-
54
40
  return getPluginFetcher(context);
55
41
  };
56
-
57
42
  class HandlerClient {
58
43
  /**
59
44
  * We need the default plugin to later on fetch another plugin than initially selected.
60
45
  * If name of the required plugin is not the default one, fetch new one.
61
46
  */
47
+
62
48
  constructor(context) {
63
- (0, _defineProperty2.default)(this, "plugin", void 0);
64
- (0, _defineProperty2.default)(this, "default", void 0);
65
49
  this.plugin = getHandlerClientPlugin(context);
66
50
  this.default = getPluginFetcher(context);
67
51
  }
68
-
69
52
  async invoke(params) {
70
53
  let plugin = this.plugin;
71
-
72
54
  if (plugin.canHandle && plugin.canHandle(params) === false) {
73
55
  plugin = this.default;
74
56
  }
75
-
76
57
  try {
77
58
  return await plugin.invoke(params);
78
59
  } catch (ex) {
@@ -86,16 +67,13 @@ class HandlerClient {
86
67
  code: ex.code
87
68
  }
88
69
  };
89
-
90
70
  if (params.description) {
91
71
  data.description = params.description;
92
72
  }
93
-
94
73
  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
74
  }
96
75
  }
97
-
98
76
  }
77
+ var _default = exports.default = HandlerClient;
99
78
 
100
- var _default = HandlerClient;
101
- exports.default = _default;
79
+ //# sourceMappingURL=HandlerClient.js.map
@@ -1 +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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;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"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_HandlerClientPlugin","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","_default","exports"],"sources":["HandlerClient.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,oBAAA,GAAAD,OAAA;AAEA,MAAME,iBAAiB,GAAG,gBAAgB;AAE1C,MAAMC,gBAAgB,GAAIC,OAAsB,IAA0B;EACtE,MAAMC,EAAE,GAAG,IAAIC,wCAAmB,CAAC;IAC/BC,MAAM,EAAE,MAAMC,MAAM,IAAI;MACpB,MAAM;QAAEC,IAAI;QAAEC,OAAO;QAAEC,KAAK,EAAEC;MAAS,CAAC,GAAGJ,MAAM;MACjD,MAAMK,MAAM,GAAGT,OAAO,CAACU,OAAO,CAACC,MAAM,CAA6BN,IAAI,CAAC;MACvE,IAAI,CAACI,MAAM,EAAE;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AE,CAACI;QACb;MACJ,CAAC;MACD,IAAInB,MAAM,CAACoB,WAAW,EAAE;QACpBJ,IAAI,CAACI,WAAW,GAAGpB,MAAM,CAACoB,WAAW;MACzC;MACA,MAAM,IAAIZ,cAAW,CACjB,uFAAuFa,IAAI,CAACC,SAAS,CACjGtB,MAAM,EACN,IAAI,EACJ,CACJ,CAAC,EAAE,EACH,cAAc,EACdgB,IACJ,CAAC;IACL;EACJ;AACJ;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEcF,aAAa","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin";
2
- import { InvokeArgs } from "./types";
3
- interface HandlerClientPluginCallable<Payload = Record<string, any>, Response = any> {
2
+ import type { InvokeArgs } from "./types";
3
+ interface HandlerClientPluginCallable<Payload = any, Response = any> {
4
4
  (params: InvokeArgs<Payload>): Promise<Response>;
5
5
  }
6
6
  export interface HandlerClientPluginParams {
@@ -1,41 +1,30 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.HandlerClientPlugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  var _Plugin = require("@webiny/plugins/Plugin");
13
-
14
8
  class HandlerClientPlugin extends _Plugin.Plugin {
9
+ static type = "handler-client";
15
10
  constructor({
16
11
  invoke,
17
12
  canUse
18
13
  }) {
19
14
  super();
20
- (0, _defineProperty2.default)(this, "_invoke", void 0);
21
- (0, _defineProperty2.default)(this, "canUse", void 0);
22
15
  this._invoke = invoke;
23
16
  this.canUse = canUse;
24
17
  }
25
-
26
18
  canHandle(params) {
27
19
  if (!this.canUse) {
28
20
  return true;
29
21
  }
30
-
31
22
  return this.canUse(params);
32
23
  }
33
-
34
24
  invoke(params) {
35
25
  return this._invoke(params);
36
26
  }
37
-
38
27
  }
39
-
40
28
  exports.HandlerClientPlugin = HandlerClientPlugin;
41
- (0, _defineProperty2.default)(HandlerClientPlugin, "type", "handler-client");
29
+
30
+ //# sourceMappingURL=HandlerClientPlugin.js.map
@@ -1 +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"}
1
+ {"version":3,"names":["_Plugin","require","HandlerClientPlugin","Plugin","type","constructor","invoke","canUse","_invoke","canHandle","params","exports"],"sources":["HandlerClientPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { InvokeArgs } from \"~/types\";\n\ninterface HandlerClientPluginCallable<Payload = 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,IAAAA,OAAA,GAAAC,OAAA;AAYO,MAAMC,mBAAmB,SAASC,cAAM,CAAC;EAC5C,OAAuBC,IAAI,GAAG,gBAAgB;EAKvCC,WAAWA,CAAC;IAAEC,MAAM;IAAEC;EAAkC,CAAC,EAAE;IAC9D,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,OAAO,GAAGF,MAAM;IACrB,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EAEOE,SAASA,CAACC,MAAkB,EAAW;IAC1C,IAAI,CAAC,IAAI,CAACH,MAAM,EAAE;MACd,OAAO,IAAI;IACf;IACA,OAAO,IAAI,CAACA,MAAM,CAACG,MAAM,CAAC;EAC9B;EAEOJ,MAAMA,CAAgCI,MAA2B,EAAqB;IACzF,OAAO,IAAI,CAACF,OAAO,CAACE,MAAM,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAT,mBAAA,GAAAA,mBAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClientContext } from "./types";
1
+ import type { ClientContext } from "./types";
2
2
  export * from "./HandlerClientPlugin";
3
3
  export declare const createHandlerClient: () => {
4
4
  type: string;
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -9,11 +8,8 @@ var _exportNames = {
9
8
  createHandlerClient: true
10
9
  };
11
10
  exports.createHandlerClient = void 0;
12
-
13
11
  var _HandlerClient = _interopRequireDefault(require("./HandlerClient"));
14
-
15
12
  var _HandlerClientPlugin = require("./HandlerClientPlugin");
16
-
17
13
  Object.keys(_HandlerClientPlugin).forEach(function (key) {
18
14
  if (key === "default" || key === "__esModule") return;
19
15
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -25,15 +21,13 @@ Object.keys(_HandlerClientPlugin).forEach(function (key) {
25
21
  }
26
22
  });
27
23
  });
28
-
29
24
  const createHandlerClient = () => ({
30
25
  type: "context",
31
26
  name: "handler-client.context",
32
-
33
27
  async apply(context) {
34
28
  context.handlerClient = new _HandlerClient.default(context);
35
29
  }
36
-
37
30
  });
31
+ exports.createHandlerClient = createHandlerClient;
38
32
 
39
- exports.createHandlerClient = createHandlerClient;
33
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"names":["_HandlerClient","_interopRequireDefault","require","_HandlerClientPlugin","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","createHandlerClient","type","name","apply","context","handlerClient","HandlerClient"],"sources":["index.ts"],"sourcesContent":["import HandlerClient from \"./HandlerClient\";\nimport type { 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,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,oBAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,oBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,oBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,oBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAEO,MAAMS,mBAAmB,GAAGA,CAAA,MAAO;EACtCC,IAAI,EAAE,SAAS;EACfC,IAAI,EAAE,wBAAwB;EAC9B,MAAMC,KAAKA,CAACC,OAAsB,EAAE;IAChCA,OAAO,CAACC,aAAa,GAAG,IAAIC,sBAAa,CAACF,OAAO,CAAC;EACtD;AACJ,CAAC,CAAC;AAACR,OAAA,CAAAI,mBAAA,GAAAA,mBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-client",
3
- "version": "0.0.0-unstable.fcdad0bc61",
3
+ "version": "0.0.0-unstable.fdd9228b5d",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,31 +14,23 @@
14
14
  ],
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@babel/runtime": "7.19.0",
18
- "@webiny/api": "0.0.0-unstable.fcdad0bc61",
19
- "@webiny/error": "0.0.0-unstable.fcdad0bc61",
20
- "@webiny/plugins": "0.0.0-unstable.fcdad0bc61"
17
+ "@webiny/api": "0.0.0-unstable.fdd9228b5d",
18
+ "@webiny/error": "0.0.0-unstable.fdd9228b5d",
19
+ "@webiny/plugins": "0.0.0-unstable.fdd9228b5d"
21
20
  },
22
21
  "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-unstable.fcdad0bc61",
28
- "@webiny/project-utils": "^0.0.0-unstable.fcdad0bc61",
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"
22
+ "@webiny/project-utils": "0.0.0-unstable.fdd9228b5d",
23
+ "jest": "29.7.0",
24
+ "rimraf": "6.0.1",
25
+ "typescript": "5.3.3"
34
26
  },
35
27
  "publishConfig": {
36
28
  "access": "public",
37
29
  "directory": "dist"
38
30
  },
39
31
  "scripts": {
40
- "build": "yarn webiny run build",
41
- "watch": "yarn webiny run watch"
32
+ "build": "node ../cli/bin.js run build",
33
+ "watch": "node ../cli/bin.js run watch"
42
34
  },
43
- "gitHead": "40d639c3665e384a5e2d26674d43ce26f3295e8c"
35
+ "gitHead": "fdd9228b5d2636463e8a34b6e0d26eea1e29c01d"
44
36
  }
package/types.d.ts CHANGED
@@ -1,13 +1,13 @@
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> = {
1
+ import type HandlerClient from "./HandlerClient";
2
+ import type { Plugin } from "@webiny/plugins/types";
3
+ import type { Context } from "@webiny/api/types";
4
+ export type InvokeArgs<TInvokeArgsPayload = any> = {
5
5
  name: string;
6
6
  payload?: TInvokeArgsPayload;
7
7
  await?: boolean;
8
8
  description?: string;
9
9
  };
10
- export declare type HandlerClientHandlerPlugin = Plugin & {
10
+ export type HandlerClientHandlerPlugin = Plugin & {
11
11
  type: "handler-client-handler";
12
12
  invoke: <TArgs = Record<string, any>, TResponse = Record<string, any>>(params: TArgs) => TResponse | Promise<TResponse>;
13
13
  };
package/types.js CHANGED
@@ -2,4 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+
7
+ //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +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":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type HandlerClient from \"./HandlerClient\";\nimport type { Plugin } from \"@webiny/plugins/types\";\nimport type { 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":"","ignoreList":[]}