@faasjs/func 8.0.0-beta.5 → 8.0.0-beta.6

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 CHANGED
@@ -29,6 +29,10 @@ npm install @faasjs/func
29
29
 
30
30
  - [Func](classes/Func.md)
31
31
 
32
+ ## Interfaces
33
+
34
+ - [FaasPluginEventMap](interfaces/FaasPluginEventMap.md)
35
+
32
36
  ## Type Aliases
33
37
 
34
38
  - [Config](type-aliases/Config.md)
@@ -37,9 +41,14 @@ npm install @faasjs/func
37
41
  - [FuncEventType](type-aliases/FuncEventType.md)
38
42
  - [FuncReturnType](type-aliases/FuncReturnType.md)
39
43
  - [Handler](type-aliases/Handler.md)
44
+ - [InferPluginEvent](type-aliases/InferPluginEvent.md)
40
45
  - [InvokeData](type-aliases/InvokeData.md)
41
46
  - [LifeCycleKey](type-aliases/LifeCycleKey.md)
42
47
  - [MountData](type-aliases/MountData.md)
43
48
  - [Next](type-aliases/Next.md)
49
+ - [NormalizePluginType](type-aliases/NormalizePluginType.md)
44
50
  - [Plugin](type-aliases/Plugin.md)
51
+ - [ResolvePluginEvent](type-aliases/ResolvePluginEvent.md)
52
+ - [Simplify](type-aliases/Simplify.md)
53
+ - [UnionToIntersection](type-aliases/UnionToIntersection.md)
45
54
  - [UseifyPlugin](type-aliases/UseifyPlugin.md)
package/dist/index.d.ts CHANGED
@@ -110,6 +110,29 @@ type FuncEventType<T extends Func<any, any, any>> = T extends Func<infer P, any,
110
110
  * ```
111
111
  */
112
112
  type FuncReturnType<T extends Func<any, any, any>> = T extends Func<any, any, infer R> ? R : any;
113
+ type NormalizePluginType<TType extends string> = TType extends `npm:${infer Name}` ? Name : TType extends `@faasjs/${infer Name}` ? Name : TType;
114
+ type UnionToIntersection<T> = (T extends unknown ? (arg: T) => void : never) extends (arg: infer TResult) => void ? TResult : never;
115
+ type Simplify<T> = {
116
+ [K in keyof T]: T[K];
117
+ } & {};
118
+ /**
119
+ * Plugin event augmentation map.
120
+ *
121
+ * Extend this interface in plugin packages to describe which event fields are
122
+ * injected when the plugin is enabled through `faas.yaml`.
123
+ */
124
+ interface FaasPluginEventMap {
125
+ }
126
+ type ResolvePluginEvent<TType extends string> = NormalizePluginType<TType> extends keyof FaasPluginEventMap ? FaasPluginEventMap[NormalizePluginType<TType>] : Record<never, never>;
127
+ /**
128
+ * Infer event type from plugin type names.
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * type Event = InferPluginEvent<['http']>
133
+ * ```
134
+ */
135
+ type InferPluginEvent<TPlugins extends readonly string[]> = Simplify<Record<string, any> & UnionToIntersection<ResolvePluginEvent<TPlugins[number]>>>;
113
136
  declare function parseFuncFilenameFromStack(stack?: string): string | undefined;
114
137
  declare class Func<TEvent = any, TContext = any, TResult = any> {
115
138
  [key: string]: any;
@@ -197,4 +220,4 @@ declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: (
197
220
  */
198
221
  declare function defineFunc<TEvent = any, TContext = any, TResult = any>(handler: Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
199
222
 
200
- export { type Config, type ExportedHandler, Func, type FuncConfig, type FuncEventType, type FuncReturnType, type Handler, type InvokeData, type LifeCycleKey, type MountData, type Next, type Plugin, type UseifyPlugin, defineFunc, nameFunc, parseFuncFilenameFromStack, useFunc, usePlugin };
223
+ export { type Config, type ExportedHandler, type FaasPluginEventMap, Func, type FuncConfig, type FuncEventType, type FuncReturnType, type Handler, type InferPluginEvent, type InvokeData, type LifeCycleKey, type MountData, type Next, type NormalizePluginType, type Plugin, type ResolvePluginEvent, type Simplify, type UnionToIntersection, type UseifyPlugin, defineFunc, nameFunc, parseFuncFilenameFromStack, useFunc, usePlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/func",
3
- "version": "v8.0.0-beta.5",
3
+ "version": "8.0.0-beta.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -30,12 +30,12 @@
30
30
  "dist"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@faasjs/deep_merge": ">=v8.0.0-beta.5",
34
- "@faasjs/logger": ">=v8.0.0-beta.5"
33
+ "@faasjs/deep_merge": ">=8.0.0-beta.6",
34
+ "@faasjs/logger": ">=8.0.0-beta.6"
35
35
  },
36
36
  "devDependencies": {
37
- "@faasjs/deep_merge": ">=v8.0.0-beta.5",
38
- "@faasjs/logger": ">=v8.0.0-beta.5"
37
+ "@faasjs/deep_merge": ">=8.0.0-beta.6",
38
+ "@faasjs/logger": ">=8.0.0-beta.6"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=24.0.0",