@webiny/handler-client 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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 +8 -4
- package/HandlerClient.js +64 -46
- package/HandlerClient.js.map +1 -0
- package/HandlerClientPlugin.d.ts +18 -0
- package/HandlerClientPlugin.js +30 -0
- package/HandlerClientPlugin.js.map +1 -0
- package/index.d.ts +5 -4
- package/index.js +22 -10
- package/index.js.map +1 -0
- package/package.json +11 -19
- package/types.d.ts +8 -11
- package/types.js +3 -1
- package/types.js.map +1 -0
package/HandlerClient.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HandlerClientPlugin, InvokeArgs } from "./types";
|
|
1
|
+
import type { InvokeArgs, ClientContext } from "./types";
|
|
3
2
|
declare class HandlerClient {
|
|
4
|
-
plugin
|
|
5
|
-
|
|
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);
|
|
6
10
|
invoke<TInvokeArgsPayload = any, TResponse = any>(params: InvokeArgs<TInvokeArgsPayload>): Promise<TResponse>;
|
|
7
11
|
}
|
|
8
12
|
export default HandlerClient;
|
package/HandlerClient.js
CHANGED
|
@@ -1,61 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!plugin) {
|
|
34
|
-
throw new _error.default(`Could not find "${name}" handler plugin.`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const promise = plugin.invoke(payload);
|
|
38
|
-
|
|
39
|
-
if (useAwait === false) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return promise;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
};
|
|
9
|
+
var _HandlerClientPlugin = require("./HandlerClientPlugin");
|
|
10
|
+
const defaultPluginName = "handler-client";
|
|
11
|
+
const getPluginFetcher = context => {
|
|
12
|
+
const pl = new _HandlerClientPlugin.HandlerClientPlugin({
|
|
13
|
+
invoke: async params => {
|
|
14
|
+
const {
|
|
15
|
+
name,
|
|
16
|
+
payload,
|
|
17
|
+
await: useAwait
|
|
18
|
+
} = params;
|
|
19
|
+
const plugin = context.plugins.byName(name);
|
|
20
|
+
if (!plugin) {
|
|
21
|
+
throw new _error.default(`Could not find "${name}" handler plugin.`);
|
|
22
|
+
}
|
|
23
|
+
const promise = plugin.invoke(payload);
|
|
24
|
+
if (useAwait === false) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return promise;
|
|
47
28
|
}
|
|
29
|
+
});
|
|
30
|
+
pl.name = defaultPluginName;
|
|
31
|
+
return pl;
|
|
32
|
+
};
|
|
33
|
+
const getHandlerClientPlugin = context => {
|
|
34
|
+
const plugin = context.plugins.byName("handler-client");
|
|
35
|
+
if (plugin) {
|
|
36
|
+
return plugin;
|
|
48
37
|
}
|
|
38
|
+
// If not specified, use a fallback plugin that fetches different handlers via plugins.
|
|
39
|
+
// This might also be useful for testing purposes.
|
|
40
|
+
return getPluginFetcher(context);
|
|
41
|
+
};
|
|
42
|
+
class HandlerClient {
|
|
43
|
+
/**
|
|
44
|
+
* We need the default plugin to later on fetch another plugin than initially selected.
|
|
45
|
+
* If name of the required plugin is not the default one, fetch new one.
|
|
46
|
+
*/
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
constructor(context) {
|
|
49
|
+
this.plugin = getHandlerClientPlugin(context);
|
|
50
|
+
this.default = getPluginFetcher(context);
|
|
51
|
+
}
|
|
52
|
+
async invoke(params) {
|
|
53
|
+
let plugin = this.plugin;
|
|
54
|
+
if (plugin.canHandle && plugin.canHandle(params) === false) {
|
|
55
|
+
plugin = this.default;
|
|
56
|
+
}
|
|
51
57
|
try {
|
|
52
|
-
return
|
|
53
|
-
} catch (
|
|
54
|
-
|
|
58
|
+
return await plugin.invoke(params);
|
|
59
|
+
} catch (ex) {
|
|
60
|
+
/**
|
|
61
|
+
* We collect error that was caught and the description of the invoke, if any.
|
|
62
|
+
*/
|
|
63
|
+
const data = {
|
|
64
|
+
error: {
|
|
65
|
+
message: ex.message,
|
|
66
|
+
data: ex.data,
|
|
67
|
+
code: ex.code
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (params.description) {
|
|
71
|
+
data.description = params.description;
|
|
72
|
+
}
|
|
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);
|
|
55
74
|
}
|
|
56
75
|
}
|
|
57
|
-
|
|
58
76
|
}
|
|
77
|
+
var _default = exports.default = HandlerClient;
|
|
59
78
|
|
|
60
|
-
|
|
61
|
-
exports.default = _default;
|
|
79
|
+
//# sourceMappingURL=HandlerClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;QACT,MAAM,IAAIG,cAAW,CAAC,mBAAmBP,IAAI,mBAAmB,CAAC;MACrE;MAEA,MAAMQ,OAAO,GAAGJ,MAAM,CAACN,MAAM,CAACG,OAAO,CAAC;MACtC,IAAIE,QAAQ,KAAK,KAAK,EAAE;QACpB,OAAO,IAAI;MACf;MAEA,OAAOK,OAAO;IAClB;EACJ,CAAC,CAAC;EACFZ,EAAE,CAACI,IAAI,GAAGP,iBAAiB;EAC3B,OAAOG,EAAE;AACb,CAAC;AAED,MAAMa,sBAAsB,GAAId,OAAsB,IAA0B;EAC5E,MAAMS,MAAM,GAAGT,OAAO,CAACU,OAAO,CAACC,MAAM,CAAsB,gBAAgB,CAAC;EAC5E,IAAIF,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;EACA;EACA;EACA,OAAOV,gBAAgB,CAACC,OAAO,CAAC;AACpC,CAAC;AAED,MAAMe,aAAa,CAAC;EAEhB;AACJ;AACA;AACA;;EAGIC,WAAWA,CAAChB,OAAsB,EAAE;IAChC,IAAI,CAACS,MAAM,GAAGK,sBAAsB,CAACd,OAAO,CAAC;IAC7C,IAAI,CAACiB,OAAO,GAAGlB,gBAAgB,CAACC,OAAO,CAAC;EAC5C;EAEA,MAAaG,MAAMA,CACfC,MAAsC,EACpB;IAClB,IAAIK,MAA2B,GAAG,IAAI,CAACA,MAAM;IAC7C,IAAIA,MAAM,CAACS,SAAS,IAAIT,MAAM,CAACS,SAAS,CAACd,MAAM,CAAC,KAAK,KAAK,EAAE;MACxDK,MAAM,GAAG,IAAI,CAACQ,OAAO;IACzB;IACA,IAAI;MACA,OAAO,MAAMR,MAAM,CAACN,MAAM,CAACC,MAAM,CAAC;IACtC,CAAC,CAAC,OAAOe,EAAE,EAAE;MACT;AACZ;AACA;MACY,MAAMC,IAAyB,GAAG;QAC9BC,KAAK,EAAE;UACHC,OAAO,EAAEH,EAAE,CAACG,OAAO;UACnBF,IAAI,EAAED,EAAE,CAACC,IAAI;UACbG,IAAI,EAAEJ,EAAE,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":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import type { InvokeArgs } from "./types";
|
|
3
|
+
interface HandlerClientPluginCallable<Payload = 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,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HandlerClientPlugin = void 0;
|
|
7
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
+
class HandlerClientPlugin extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler-client";
|
|
10
|
+
constructor({
|
|
11
|
+
invoke,
|
|
12
|
+
canUse
|
|
13
|
+
}) {
|
|
14
|
+
super();
|
|
15
|
+
this._invoke = invoke;
|
|
16
|
+
this.canUse = canUse;
|
|
17
|
+
}
|
|
18
|
+
canHandle(params) {
|
|
19
|
+
if (!this.canUse) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return this.canUse(params);
|
|
23
|
+
}
|
|
24
|
+
invoke(params) {
|
|
25
|
+
return this._invoke(params);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.HandlerClientPlugin = HandlerClientPlugin;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=HandlerClientPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { ClientContext } from "./types";
|
|
2
|
+
export * from "./HandlerClientPlugin";
|
|
3
|
+
export declare const createHandlerClient: () => {
|
|
3
4
|
type: string;
|
|
4
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
apply(context: ClientContext): Promise<void>;
|
|
5
7
|
};
|
|
6
|
-
export default _default;
|
package/index.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
createHandlerClient: true
|
|
9
|
+
};
|
|
10
|
+
exports.createHandlerClient = void 0;
|
|
10
11
|
var _HandlerClient = _interopRequireDefault(require("./HandlerClient"));
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
var _HandlerClientPlugin = require("./HandlerClientPlugin");
|
|
13
|
+
Object.keys(_HandlerClientPlugin).forEach(function (key) {
|
|
14
|
+
if (key === "default" || key === "__esModule") return;
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
+
if (key in exports && exports[key] === _HandlerClientPlugin[key]) return;
|
|
17
|
+
Object.defineProperty(exports, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _HandlerClientPlugin[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
const createHandlerClient = () => ({
|
|
13
25
|
type: "context",
|
|
14
|
-
|
|
15
|
-
apply(context) {
|
|
26
|
+
name: "handler-client.context",
|
|
27
|
+
async apply(context) {
|
|
16
28
|
context.handlerClient = new _HandlerClient.default(context);
|
|
17
29
|
}
|
|
18
|
-
|
|
19
30
|
});
|
|
31
|
+
exports.createHandlerClient = createHandlerClient;
|
|
20
32
|
|
|
21
|
-
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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-
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
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
|
-
"@
|
|
18
|
-
"@webiny/error": "0.0.0-
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/plugins": "0.0.0-mt-2"
|
|
17
|
+
"@webiny/api": "0.0.0-unstable.06b2ede40f",
|
|
18
|
+
"@webiny/error": "0.0.0-unstable.06b2ede40f",
|
|
19
|
+
"@webiny/plugins": "0.0.0-unstable.06b2ede40f"
|
|
21
20
|
},
|
|
22
21
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"@webiny/cli": "^0.0.0-mt-2",
|
|
28
|
-
"@webiny/project-utils": "^0.0.0-mt-2",
|
|
29
|
-
"babel-plugin-lodash": "^3.3.4",
|
|
30
|
-
"jest": "^26.6.3",
|
|
31
|
-
"merge": "^1.2.1",
|
|
32
|
-
"rimraf": "^3.0.2",
|
|
33
|
-
"typescript": "^4.1.3"
|
|
22
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
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": "
|
|
41
|
-
"watch": "
|
|
32
|
+
"build": "node ../cli/bin.js run build",
|
|
33
|
+
"watch": "node ../cli/bin.js run watch"
|
|
42
34
|
},
|
|
43
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
44
36
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import HandlerClient from "./HandlerClient";
|
|
2
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
-
|
|
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> = {
|
|
4
5
|
name: string;
|
|
5
6
|
payload?: TInvokeArgsPayload;
|
|
6
7
|
await?: boolean;
|
|
8
|
+
description?: string;
|
|
7
9
|
};
|
|
8
|
-
export
|
|
9
|
-
type: "handler-client";
|
|
10
|
-
name: "handler-client";
|
|
11
|
-
invoke: <TInvokeArgsPayload = Record<string, any>>(params: InvokeArgs<TInvokeArgsPayload>) => any;
|
|
12
|
-
};
|
|
13
|
-
export declare type HandlerClientHandlerPlugin = Plugin & {
|
|
10
|
+
export type HandlerClientHandlerPlugin = Plugin & {
|
|
14
11
|
type: "handler-client-handler";
|
|
15
12
|
invoke: <TArgs = Record<string, any>, TResponse = Record<string, any>>(params: TArgs) => TResponse | Promise<TResponse>;
|
|
16
13
|
};
|
|
17
|
-
export
|
|
14
|
+
export interface ClientContext extends Context {
|
|
18
15
|
handlerClient: HandlerClient;
|
|
19
|
-
}
|
|
16
|
+
}
|
package/types.js
CHANGED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|