@faasjs/func 1.4.2 → 1.6.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 CHANGED
@@ -1,338 +1,36 @@
1
1
  # @faasjs/func
2
2
 
3
- [![License: MIT](https://img.shields.io/npm/l/@faasjs/func.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/func/LICENSE)
4
- [![NPM Stable Version](https://img.shields.io/npm/v/@faasjs/func/stable.svg)](https://www.npmjs.com/package/@faasjs/func)
5
- [![NPM Beta Version](https://img.shields.io/npm/v/@faasjs/func/beta.svg)](https://www.npmjs.com/package/@faasjs/func)
6
-
7
3
  FaasJS's function module.
8
4
 
5
+ [![License: MIT](https://img.shields.io/npm/l/@faasjs/func.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/func/LICENSE)
6
+ [![NPM Version](https://img.shields.io/npm/v/@faasjs/func.svg)](https://www.npmjs.com/package/@faasjs/func)
7
+
9
8
  ## Install
10
9
 
11
10
  ```sh
12
11
  npm install @faasjs/func
13
12
  ```
14
13
 
15
- ## Modules
16
-
17
- ### Classes
14
+ ## Classes
18
15
 
19
16
  - [Func](classes/Func.md)
20
17
 
21
- ### Type Aliases
22
-
23
- - [Config](#config)
24
- - [DeployData](#deploydata)
25
- - [ExportedHandler](#exportedhandler)
26
- - [FuncConfig](#funcconfig)
27
- - [Handler](#handler)
28
- - [InvokeData](#invokedata)
29
- - [LifeCycleKey](#lifecyclekey)
30
- - [MountData](#mountdata)
31
- - [Next](#next)
32
- - [Plugin](#plugin)
33
- - [ProviderConfig](#providerconfig)
34
- - [UseifyPlugin](#useifyplugin)
35
-
36
- ### Functions
37
-
38
- - [useFunc](#usefunc)
39
- - [usePlugin](#useplugin)
40
-
41
18
  ## Type Aliases
42
19
 
43
- ### Config
44
-
45
- Ƭ **Config**: `Object`
46
-
47
- #### Index signature
48
-
49
- [key: `string`]: `any`
50
-
51
- #### Type declaration
52
-
53
- | Name | Type |
54
- | :------ | :------ |
55
- | `plugins?` | \{ `[key: string]`: \{ `[key: string]`: `any`; `config?`: \{ `[key: string]`: `any`; } ; `provider?`: `string` \| [`ProviderConfig`](#providerconfig) ; `type`: `string` }; } |
56
- | `providers?` | \{ `[key: string]`: [`ProviderConfig`](#providerconfig); } |
57
-
58
- ___
59
-
60
- ### DeployData
61
-
62
- Ƭ **DeployData**: `Object`
63
-
64
- #### Index signature
65
-
66
- ▪ [key: `string`]: `any`
67
-
68
- #### Type declaration
69
-
70
- | Name | Type |
71
- | :------ | :------ |
72
- | `config?` | [`Config`](#config) |
73
- | `dependencies` | \{ `[name: string]`: `string`; } |
74
- | `env?` | `string` |
75
- | `filename` | `string` |
76
- | `logger?` | `Logger` |
77
- | `name?` | `string` |
78
- | `plugins?` | \{ `[name: string]`: \{ `[key: string]`: `any`; `config`: \{ `[key: string]`: `any`; } ; `name?`: `string` ; `plugin`: [`Plugin`](#plugin) ; `provider?`: `string` ; `type`: `string` }; } |
79
- | `root` | `string` |
80
- | `version?` | `string` |
81
-
82
- ___
83
-
84
- ### ExportedHandler
85
-
86
- Ƭ **ExportedHandler**\<`TEvent`, `TContext`, `TResult`\>: (`event`: `TEvent`, `context?`: `TContext`, `callback?`: (...`args`: `any`) => `any`) => `Promise`\<`TResult`\>
87
-
88
- #### Type parameters
89
-
90
- | Name | Type |
91
- | :------ | :------ |
92
- | `TEvent` | `any` |
93
- | `TContext` | `any` |
94
- | `TResult` | `any` |
95
-
96
- #### Type declaration
97
-
98
- ▸ (`event`, `context?`, `callback?`): `Promise`\<`TResult`\>
99
-
100
- ##### Parameters
101
-
102
- | Name | Type |
103
- | :------ | :------ |
104
- | `event` | `TEvent` |
105
- | `context?` | `TContext` |
106
- | `callback?` | (...`args`: `any`) => `any` |
107
-
108
- ##### Returns
109
-
110
- `Promise`\<`TResult`\>
111
-
112
- ___
113
-
114
- ### FuncConfig
115
-
116
- Ƭ **FuncConfig**\<`TEvent`, `TContext`, `TResult`\>: `Object`
117
-
118
- #### Type parameters
119
-
120
- | Name | Type |
121
- | :------ | :------ |
122
- | `TEvent` | `any` |
123
- | `TContext` | `any` |
124
- | `TResult` | `any` |
125
-
126
- #### Type declaration
127
-
128
- | Name | Type |
129
- | :------ | :------ |
130
- | `handler?` | [`Handler`](#handler)\<`TEvent`, `TContext`, `TResult`\> |
131
- | `plugins?` | [`Plugin`](#plugin)[] |
132
-
133
- ___
134
-
135
- ### Handler
136
-
137
- Ƭ **Handler**\<`TEvent`, `TContext`, `TResult`\>: (`data`: [`InvokeData`](#invokedata)\<`TEvent`, `TContext`\>) => `Promise`\<`TResult`\>
138
-
139
- #### Type parameters
140
-
141
- | Name | Type |
142
- | :------ | :------ |
143
- | `TEvent` | `any` |
144
- | `TContext` | `any` |
145
- | `TResult` | `any` |
146
-
147
- #### Type declaration
148
-
149
- ▸ (`data`): `Promise`\<`TResult`\>
150
-
151
- ##### Parameters
152
-
153
- | Name | Type |
154
- | :------ | :------ |
155
- | `data` | [`InvokeData`](#invokedata)\<`TEvent`, `TContext`\> |
156
-
157
- ##### Returns
158
-
159
- `Promise`\<`TResult`\>
160
-
161
- ___
162
-
163
- ### InvokeData
164
-
165
- Ƭ **InvokeData**\<`TEvent`, `TContext`, `TResult`\>: `Object`
166
-
167
- #### Type parameters
168
-
169
- | Name | Type |
170
- | :------ | :------ |
171
- | `TEvent` | `any` |
172
- | `TContext` | `any` |
173
- | `TResult` | `any` |
174
-
175
- #### Index signature
176
-
177
- ▪ [key: `string`]: `any`
178
-
179
- #### Type declaration
180
-
181
- | Name | Type |
182
- | :------ | :------ |
183
- | `callback` | `any` |
184
- | `config` | [`Config`](#config) |
185
- | `context` | `TContext` |
186
- | `event` | `TEvent` |
187
- | `handler?` | [`Handler`](#handler)\<`TEvent`, `TContext`, `TResult`\> |
188
- | `logger` | `Logger` |
189
- | `response` | `any` |
190
-
191
- ___
192
-
193
- ### LifeCycleKey
194
-
195
- Ƭ **LifeCycleKey**: ``"onDeploy"`` \| ``"onMount"`` \| ``"onInvoke"``
196
-
197
- ___
198
-
199
- ### MountData
200
-
201
- Ƭ **MountData**: `Object`
202
-
203
- #### Index signature
204
-
205
- ▪ [key: `string`]: `any`
206
-
207
- #### Type declaration
208
-
209
- | Name | Type |
210
- | :------ | :------ |
211
- | `config` | [`Config`](#config) |
212
- | `context` | `any` |
213
- | `event` | `any` |
214
-
215
- ___
216
-
217
- ### Next
218
-
219
- Ƭ **Next**: () => `Promise`\<`void`\>
220
-
221
- #### Type declaration
222
-
223
- ▸ (): `Promise`\<`void`\>
224
-
225
- ##### Returns
226
-
227
- `Promise`\<`void`\>
228
-
229
- ___
230
-
231
- ### Plugin
232
-
233
- Ƭ **Plugin**: `Object`
234
-
235
- #### Index signature
236
-
237
- ▪ [key: `string`]: `any`
238
-
239
- #### Type declaration
240
-
241
- | Name | Type |
242
- | :------ | :------ |
243
- | `name` | `string` |
244
- | `onDeploy?` | (`data`: [`DeployData`](#deploydata), `next`: [`Next`](#next)) => `Promise`\<`void`\> |
245
- | `onInvoke?` | (`data`: [`InvokeData`](#invokedata), `next`: [`Next`](#next)) => `Promise`\<`void`\> |
246
- | `onMount?` | (`data`: [`MountData`](#mountdata), `next`: [`Next`](#next)) => `Promise`\<`void`\> |
247
- | `type` | `string` |
248
-
249
- ___
250
-
251
- ### ProviderConfig
252
-
253
- Ƭ **ProviderConfig**: `Object`
254
-
255
- #### Type declaration
256
-
257
- | Name | Type |
258
- | :------ | :------ |
259
- | `config` | \{ `[key: string]`: `any`; } |
260
- | `type` | `string` |
261
-
262
- ___
263
-
264
- ### UseifyPlugin
265
-
266
- Ƭ **UseifyPlugin**\<`T`\>: `T` & \{ `mount?`: (`data?`: \{ `config?`: [`Config`](#config) }) => `Promise`\<`T`\> }
267
-
268
- #### Type parameters
269
-
270
- | Name |
271
- | :------ |
272
- | `T` |
20
+ - [Config](type-aliases/Config.md)
21
+ - [DeployData](type-aliases/DeployData.md)
22
+ - [ExportedHandler](type-aliases/ExportedHandler.md)
23
+ - [FuncConfig](type-aliases/FuncConfig.md)
24
+ - [Handler](type-aliases/Handler.md)
25
+ - [InvokeData](type-aliases/InvokeData.md)
26
+ - [LifeCycleKey](type-aliases/LifeCycleKey.md)
27
+ - [MountData](type-aliases/MountData.md)
28
+ - [Next](type-aliases/Next.md)
29
+ - [Plugin](type-aliases/Plugin.md)
30
+ - [ProviderConfig](type-aliases/ProviderConfig.md)
31
+ - [UseifyPlugin](type-aliases/UseifyPlugin.md)
273
32
 
274
33
  ## Functions
275
34
 
276
- ### useFunc
277
-
278
- ▸ **useFunc**\<`TEvent`, `TContext`, `TResult`\>(`handler`): [`Func`](classes/Func.md)\<`TEvent`, `TContext`, `TResult`\>
279
-
280
- ```ts
281
- // pure function
282
- export default useFunc(() => {
283
- return () => {
284
- return 'Hello World'
285
- }
286
- })
287
-
288
- // with http
289
- import { useHttp } from '@faasjs/http'
290
-
291
- export default useFunc(() => {
292
- const http = useHttp<{ name: string }>()
293
-
294
- return () => {
295
- return `Hello ${http.params.name}`
296
- }
297
- })
298
- ```
299
-
300
- #### Type parameters
301
-
302
- | Name | Type |
303
- | :------ | :------ |
304
- | `TEvent` | `any` |
305
- | `TContext` | `any` |
306
- | `TResult` | `any` |
307
-
308
- #### Parameters
309
-
310
- | Name | Type |
311
- | :------ | :------ |
312
- | `handler` | () => [`Handler`](#handler)\<`TEvent`, `TContext`, `TResult`\> |
313
-
314
- #### Returns
315
-
316
- [`Func`](classes/Func.md)\<`TEvent`, `TContext`, `TResult`\>
317
-
318
- ___
319
-
320
- ### usePlugin
321
-
322
- ▸ **usePlugin**\<`T`\>(`plugin`): [`UseifyPlugin`](#useifyplugin)\<`T`\>
323
-
324
- #### Type parameters
325
-
326
- | Name | Type |
327
- | :------ | :------ |
328
- | `T` | extends [`Plugin`](#plugin) |
329
-
330
- #### Parameters
331
-
332
- | Name | Type |
333
- | :------ | :------ |
334
- | `plugin` | [`UseifyPlugin`](#useifyplugin)\<`T`\> |
335
-
336
- #### Returns
337
-
338
- [`UseifyPlugin`](#useifyplugin)\<`T`\>
35
+ - [useFunc](functions/useFunc.md)
36
+ - [usePlugin](functions/usePlugin.md)
package/dist/index.d.mts CHANGED
@@ -1,5 +1,19 @@
1
1
  import { Logger } from '@faasjs/logger';
2
2
 
3
+ /**
4
+ * FaasJS's function module.
5
+ *
6
+ * [![License: MIT](https://img.shields.io/npm/l/@faasjs/func.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/func/LICENSE)
7
+ * [![NPM Version](https://img.shields.io/npm/v/@faasjs/func.svg)](https://www.npmjs.com/package/@faasjs/func)
8
+ *
9
+ * ## Install
10
+ *
11
+ * ```sh
12
+ * npm install @faasjs/func
13
+ * ```
14
+ * @packageDocumentation
15
+ */
16
+
3
17
  type Handler<TEvent = any, TContext = any, TResult = any> = (data: InvokeData<TEvent, TContext>) => Promise<TResult>;
4
18
  type Next = () => Promise<void>;
5
19
  type ExportedHandler<TEvent = any, TContext = any, TResult = any> = (event: TEvent, context?: TContext, callback?: (...args: any) => any) => Promise<TResult>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  import { Logger } from '@faasjs/logger';
2
2
 
3
+ /**
4
+ * FaasJS's function module.
5
+ *
6
+ * [![License: MIT](https://img.shields.io/npm/l/@faasjs/func.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/func/LICENSE)
7
+ * [![NPM Version](https://img.shields.io/npm/v/@faasjs/func.svg)](https://www.npmjs.com/package/@faasjs/func)
8
+ *
9
+ * ## Install
10
+ *
11
+ * ```sh
12
+ * npm install @faasjs/func
13
+ * ```
14
+ * @packageDocumentation
15
+ */
16
+
3
17
  type Handler<TEvent = any, TContext = any, TResult = any> = (data: InvokeData<TEvent, TContext>) => Promise<TResult>;
4
18
  type Next = () => Promise<void>;
5
19
  type ExportedHandler<TEvent = any, TContext = any, TResult = any> = (event: TEvent, context?: TContext, callback?: (...args: any) => any) => Promise<TResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/func",
3
- "version": "1.4.2",
3
+ "version": "1.6.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": "1.4.2",
25
- "@faasjs/logger": "1.4.2"
24
+ "@faasjs/deep_merge": "1.6.0",
25
+ "@faasjs/logger": "1.6.0"
26
26
  },
27
27
  "engines": {
28
28
  "npm": ">=9.0.0",