@faasjs/func 2.1.0 → 2.2.0
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/README.md +2 -0
- package/dist/index.d.mts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@ npm install @faasjs/func
|
|
|
21
21
|
- [DeployData](type-aliases/DeployData.md)
|
|
22
22
|
- [ExportedHandler](type-aliases/ExportedHandler.md)
|
|
23
23
|
- [FuncConfig](type-aliases/FuncConfig.md)
|
|
24
|
+
- [FuncEventType](type-aliases/FuncEventType.md)
|
|
25
|
+
- [FuncReturnType](type-aliases/FuncReturnType.md)
|
|
24
26
|
- [Handler](type-aliases/Handler.md)
|
|
25
27
|
- [InvokeData](type-aliases/InvokeData.md)
|
|
26
28
|
- [LifeCycleKey](type-aliases/LifeCycleKey.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -93,6 +93,32 @@ type FuncConfig<TEvent = any, TContext = any, TResult = any> = {
|
|
|
93
93
|
plugins?: Plugin[];
|
|
94
94
|
handler?: Handler<TEvent, TContext, TResult>;
|
|
95
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Get the event type of a func
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { useFunc, type FuncEventType } from '@faasjs/func'
|
|
102
|
+
*
|
|
103
|
+
* const func = useFunc<{ counter: number }>(() => async () => {})
|
|
104
|
+
*
|
|
105
|
+
* FuncEventType<typeof func> // => { counter: number }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
type FuncEventType<T extends Func<any, any, any>> = T extends Func<infer P, any, any> ? P : any;
|
|
109
|
+
/**
|
|
110
|
+
* Get the return type of a func
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { useFunc, type FuncReturnType } from '@faasjs/func'
|
|
115
|
+
*
|
|
116
|
+
* const func = useFunc(() => async () => 1)
|
|
117
|
+
*
|
|
118
|
+
* FuncReturnType<typeof func> // => number
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type FuncReturnType<T extends Func<any, any, any>> = T extends Func<any, any, infer R> ? R : any;
|
|
96
122
|
declare class Func<TEvent = any, TContext = any, TResult = any> {
|
|
97
123
|
[key: string]: any;
|
|
98
124
|
plugins: Plugin[];
|
|
@@ -167,4 +193,4 @@ declare function usePlugin<T extends Plugin>(plugin: UseifyPlugin<T>): UseifyPlu
|
|
|
167
193
|
*/
|
|
168
194
|
declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: () => Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
|
|
169
195
|
|
|
170
|
-
export { type Config, type DeployData, type ExportedHandler, Func, type FuncConfig, type Handler, type InvokeData, type LifeCycleKey, type MountData, type Next, type Plugin, type ProviderConfig, type UseifyPlugin, useFunc, usePlugin };
|
|
196
|
+
export { type Config, type DeployData, type ExportedHandler, Func, type FuncConfig, type FuncEventType, type FuncReturnType, type Handler, type InvokeData, type LifeCycleKey, type MountData, type Next, type Plugin, type ProviderConfig, type UseifyPlugin, useFunc, usePlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,32 @@ type FuncConfig<TEvent = any, TContext = any, TResult = any> = {
|
|
|
93
93
|
plugins?: Plugin[];
|
|
94
94
|
handler?: Handler<TEvent, TContext, TResult>;
|
|
95
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Get the event type of a func
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { useFunc, type FuncEventType } from '@faasjs/func'
|
|
102
|
+
*
|
|
103
|
+
* const func = useFunc<{ counter: number }>(() => async () => {})
|
|
104
|
+
*
|
|
105
|
+
* FuncEventType<typeof func> // => { counter: number }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
type FuncEventType<T extends Func<any, any, any>> = T extends Func<infer P, any, any> ? P : any;
|
|
109
|
+
/**
|
|
110
|
+
* Get the return type of a func
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { useFunc, type FuncReturnType } from '@faasjs/func'
|
|
115
|
+
*
|
|
116
|
+
* const func = useFunc(() => async () => 1)
|
|
117
|
+
*
|
|
118
|
+
* FuncReturnType<typeof func> // => number
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
type FuncReturnType<T extends Func<any, any, any>> = T extends Func<any, any, infer R> ? R : any;
|
|
96
122
|
declare class Func<TEvent = any, TContext = any, TResult = any> {
|
|
97
123
|
[key: string]: any;
|
|
98
124
|
plugins: Plugin[];
|
|
@@ -167,4 +193,4 @@ declare function usePlugin<T extends Plugin>(plugin: UseifyPlugin<T>): UseifyPlu
|
|
|
167
193
|
*/
|
|
168
194
|
declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: () => Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
|
|
169
195
|
|
|
170
|
-
export { type Config, type DeployData, type ExportedHandler, Func, type FuncConfig, type Handler, type InvokeData, type LifeCycleKey, type MountData, type Next, type Plugin, type ProviderConfig, type UseifyPlugin, useFunc, usePlugin };
|
|
196
|
+
export { type Config, type DeployData, type ExportedHandler, Func, type FuncConfig, type FuncEventType, type FuncReturnType, type Handler, type InvokeData, type LifeCycleKey, type MountData, type Next, type Plugin, type ProviderConfig, type UseifyPlugin, useFunc, usePlugin };
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/func",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@faasjs/deep_merge": "2.
|
|
25
|
-
"@faasjs/logger": "2.
|
|
24
|
+
"@faasjs/deep_merge": "2.2.0",
|
|
25
|
+
"@faasjs/logger": "2.2.0"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"npm": ">=9.0.0",
|