@faasjs/func 0.0.4-beta.9 → 0.0.5-beta.2
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 +29 -29
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,8 +50,8 @@ FaasJS's function module.
|
|
|
50
50
|
|
|
51
51
|
| Name | Type |
|
|
52
52
|
| :------ | :------ |
|
|
53
|
-
| `plugins?` | { `[key: string]`: { `[key: string]`: `any`; `config?`: { `[key: string]`: `any`; } ; `provider?`: `string` \| [`ProviderConfig`](#providerconfig) ; `type`: `string` }; } |
|
|
54
|
-
| `providers?` | { `[key: string]`: [`ProviderConfig`](#providerconfig); } |
|
|
53
|
+
| `plugins?` | \{ `[key: string]`: \{ `[key: string]`: `any`; `config?`: \{ `[key: string]`: `any`; } ; `provider?`: `string` \| [`ProviderConfig`](#providerconfig) ; `type`: `string` }; } |
|
|
54
|
+
| `providers?` | \{ `[key: string]`: [`ProviderConfig`](#providerconfig); } |
|
|
55
55
|
|
|
56
56
|
___
|
|
57
57
|
|
|
@@ -68,12 +68,12 @@ ___
|
|
|
68
68
|
| Name | Type |
|
|
69
69
|
| :------ | :------ |
|
|
70
70
|
| `config?` | [`Config`](#config) |
|
|
71
|
-
| `dependencies` | { `[name: string]`: `string`; } |
|
|
71
|
+
| `dependencies` | \{ `[name: string]`: `string`; } |
|
|
72
72
|
| `env?` | `string` |
|
|
73
73
|
| `filename` | `string` |
|
|
74
74
|
| `logger?` | `Logger` |
|
|
75
75
|
| `name?` | `string` |
|
|
76
|
-
| `plugins?` | { `[name: string]`: { `[key: string]`: `any`; `config`: { `[key: string]`: `any`; } ; `name?`: `string` ; `plugin`: [`Plugin`](#plugin) ; `provider?`: `string` ; `type`: `string` }; } |
|
|
76
|
+
| `plugins?` | \{ `[name: string]`: \{ `[key: string]`: `any`; `config`: \{ `[key: string]`: `any`; } ; `name?`: `string` ; `plugin`: [`Plugin`](#plugin) ; `provider?`: `string` ; `type`: `string` }; } |
|
|
77
77
|
| `root` | `string` |
|
|
78
78
|
| `version?` | `string` |
|
|
79
79
|
|
|
@@ -81,7 +81,7 @@ ___
|
|
|
81
81
|
|
|
82
82
|
### ExportedHandler
|
|
83
83
|
|
|
84
|
-
Ƭ **ExportedHandler
|
|
84
|
+
Ƭ **ExportedHandler**\<`TEvent`, `TContext`, `TResult`\>: (`event`: `TEvent`, `context?`: `TContext`, `callback?`: (...`args`: `any`) => `any`) => `Promise`\<`TResult`\>
|
|
85
85
|
|
|
86
86
|
#### Type parameters
|
|
87
87
|
|
|
@@ -93,7 +93,7 @@ ___
|
|
|
93
93
|
|
|
94
94
|
#### Type declaration
|
|
95
95
|
|
|
96
|
-
▸ (`event`, `context?`, `callback?`): `Promise
|
|
96
|
+
▸ (`event`, `context?`, `callback?`): `Promise`\<`TResult`\>
|
|
97
97
|
|
|
98
98
|
##### Parameters
|
|
99
99
|
|
|
@@ -105,13 +105,13 @@ ___
|
|
|
105
105
|
|
|
106
106
|
##### Returns
|
|
107
107
|
|
|
108
|
-
`Promise
|
|
108
|
+
`Promise`\<`TResult`\>
|
|
109
109
|
|
|
110
110
|
___
|
|
111
111
|
|
|
112
112
|
### FuncConfig
|
|
113
113
|
|
|
114
|
-
Ƭ **FuncConfig
|
|
114
|
+
Ƭ **FuncConfig**\<`TEvent`, `TContext`, `TResult`\>: `Object`
|
|
115
115
|
|
|
116
116
|
#### Type parameters
|
|
117
117
|
|
|
@@ -125,14 +125,14 @@ ___
|
|
|
125
125
|
|
|
126
126
|
| Name | Type |
|
|
127
127
|
| :------ | :------ |
|
|
128
|
-
| `handler?` | [`Handler`](#handler)
|
|
128
|
+
| `handler?` | [`Handler`](#handler)\<`TEvent`, `TContext`, `TResult`\> |
|
|
129
129
|
| `plugins?` | [`Plugin`](#plugin)[] |
|
|
130
130
|
|
|
131
131
|
___
|
|
132
132
|
|
|
133
133
|
### Handler
|
|
134
134
|
|
|
135
|
-
Ƭ **Handler
|
|
135
|
+
Ƭ **Handler**\<`TEvent`, `TContext`, `TResult`\>: (`data`: [`InvokeData`](#invokedata)\<`TEvent`, `TContext`\>) => `Promise`\<`TResult`\>
|
|
136
136
|
|
|
137
137
|
#### Type parameters
|
|
138
138
|
|
|
@@ -144,23 +144,23 @@ ___
|
|
|
144
144
|
|
|
145
145
|
#### Type declaration
|
|
146
146
|
|
|
147
|
-
▸ (`data`): `Promise
|
|
147
|
+
▸ (`data`): `Promise`\<`TResult`\>
|
|
148
148
|
|
|
149
149
|
##### Parameters
|
|
150
150
|
|
|
151
151
|
| Name | Type |
|
|
152
152
|
| :------ | :------ |
|
|
153
|
-
| `data` | [`InvokeData`](#invokedata)
|
|
153
|
+
| `data` | [`InvokeData`](#invokedata)\<`TEvent`, `TContext`\> |
|
|
154
154
|
|
|
155
155
|
##### Returns
|
|
156
156
|
|
|
157
|
-
`Promise
|
|
157
|
+
`Promise`\<`TResult`\>
|
|
158
158
|
|
|
159
159
|
___
|
|
160
160
|
|
|
161
161
|
### InvokeData
|
|
162
162
|
|
|
163
|
-
Ƭ **InvokeData
|
|
163
|
+
Ƭ **InvokeData**\<`TEvent`, `TContext`, `TResult`\>: `Object`
|
|
164
164
|
|
|
165
165
|
#### Type parameters
|
|
166
166
|
|
|
@@ -182,7 +182,7 @@ ___
|
|
|
182
182
|
| `config` | [`Config`](#config) |
|
|
183
183
|
| `context` | `TContext` |
|
|
184
184
|
| `event` | `TEvent` |
|
|
185
|
-
| `handler?` | [`Handler`](#handler)
|
|
185
|
+
| `handler?` | [`Handler`](#handler)\<`TEvent`, `TContext`, `TResult`\> |
|
|
186
186
|
| `logger` | `Logger` |
|
|
187
187
|
| `response` | `any` |
|
|
188
188
|
|
|
@@ -214,15 +214,15 @@ ___
|
|
|
214
214
|
|
|
215
215
|
### Next
|
|
216
216
|
|
|
217
|
-
Ƭ **Next**: () => `Promise
|
|
217
|
+
Ƭ **Next**: () => `Promise`\<`void`\>
|
|
218
218
|
|
|
219
219
|
#### Type declaration
|
|
220
220
|
|
|
221
|
-
▸ (): `Promise
|
|
221
|
+
▸ (): `Promise`\<`void`\>
|
|
222
222
|
|
|
223
223
|
##### Returns
|
|
224
224
|
|
|
225
|
-
`Promise
|
|
225
|
+
`Promise`\<`void`\>
|
|
226
226
|
|
|
227
227
|
___
|
|
228
228
|
|
|
@@ -239,9 +239,9 @@ ___
|
|
|
239
239
|
| Name | Type |
|
|
240
240
|
| :------ | :------ |
|
|
241
241
|
| `name` | `string` |
|
|
242
|
-
| `onDeploy?` | (`data`: [`DeployData`](#deploydata), `next`: [`Next`](#next)) => `Promise
|
|
243
|
-
| `onInvoke?` | (`data`: [`InvokeData`](#invokedata), `next`: [`Next`](#next)) => `Promise
|
|
244
|
-
| `onMount?` | (`data`: [`MountData`](#mountdata), `next`: [`Next`](#next)) => `Promise
|
|
242
|
+
| `onDeploy?` | (`data`: [`DeployData`](#deploydata), `next`: [`Next`](#next)) => `Promise`\<`void`\> |
|
|
243
|
+
| `onInvoke?` | (`data`: [`InvokeData`](#invokedata), `next`: [`Next`](#next)) => `Promise`\<`void`\> |
|
|
244
|
+
| `onMount?` | (`data`: [`MountData`](#mountdata), `next`: [`Next`](#next)) => `Promise`\<`void`\> |
|
|
245
245
|
| `type` | `string` |
|
|
246
246
|
|
|
247
247
|
___
|
|
@@ -254,14 +254,14 @@ ___
|
|
|
254
254
|
|
|
255
255
|
| Name | Type |
|
|
256
256
|
| :------ | :------ |
|
|
257
|
-
| `config` | { `[key: string]`: `any`; } |
|
|
257
|
+
| `config` | \{ `[key: string]`: `any`; } |
|
|
258
258
|
| `type` | `string` |
|
|
259
259
|
|
|
260
260
|
___
|
|
261
261
|
|
|
262
262
|
### UseifyPlugin
|
|
263
263
|
|
|
264
|
-
Ƭ **UseifyPlugin
|
|
264
|
+
Ƭ **UseifyPlugin**\<`T`\>: `T` & \{ `mount?`: (`data?`: \{ `config?`: [`Config`](#config) }) => `Promise`\<`T`\> }
|
|
265
265
|
|
|
266
266
|
#### Type parameters
|
|
267
267
|
|
|
@@ -273,7 +273,7 @@ ___
|
|
|
273
273
|
|
|
274
274
|
### useFunc
|
|
275
275
|
|
|
276
|
-
▸ **useFunc
|
|
276
|
+
▸ **useFunc**\<`TEvent`, `TContext`, `TResult`\>(`handler`): [`Func`](classes/Func.md)\<`TEvent`, `TContext`, `TResult`\>
|
|
277
277
|
|
|
278
278
|
```ts
|
|
279
279
|
// pure function
|
|
@@ -307,17 +307,17 @@ export default useFunc(() => {
|
|
|
307
307
|
|
|
308
308
|
| Name | Type |
|
|
309
309
|
| :------ | :------ |
|
|
310
|
-
| `handler` | () => [`Handler`](#handler)
|
|
310
|
+
| `handler` | () => [`Handler`](#handler)\<`TEvent`, `TContext`, `TResult`\> |
|
|
311
311
|
|
|
312
312
|
#### Returns
|
|
313
313
|
|
|
314
|
-
[`Func`](classes/Func.md)
|
|
314
|
+
[`Func`](classes/Func.md)\<`TEvent`, `TContext`, `TResult`\>
|
|
315
315
|
|
|
316
316
|
___
|
|
317
317
|
|
|
318
318
|
### usePlugin
|
|
319
319
|
|
|
320
|
-
▸ **usePlugin
|
|
320
|
+
▸ **usePlugin**\<`T`\>(`plugin`): [`UseifyPlugin`](#useifyplugin)\<`T`\>
|
|
321
321
|
|
|
322
322
|
#### Type parameters
|
|
323
323
|
|
|
@@ -329,8 +329,8 @@ ___
|
|
|
329
329
|
|
|
330
330
|
| Name | Type |
|
|
331
331
|
| :------ | :------ |
|
|
332
|
-
| `plugin` | [`UseifyPlugin`](#useifyplugin)
|
|
332
|
+
| `plugin` | [`UseifyPlugin`](#useifyplugin)\<`T`\> |
|
|
333
333
|
|
|
334
334
|
#### Returns
|
|
335
335
|
|
|
336
|
-
[`UseifyPlugin`](#useifyplugin)
|
|
336
|
+
[`UseifyPlugin`](#useifyplugin)\<`T`\>
|
package/dist/index.d.mts
CHANGED
|
@@ -153,4 +153,4 @@ declare function usePlugin<T extends Plugin>(plugin: UseifyPlugin<T>): UseifyPlu
|
|
|
153
153
|
*/
|
|
154
154
|
declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: () => Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
|
|
155
155
|
|
|
156
|
-
export { Config, DeployData, ExportedHandler, Func, FuncConfig, Handler, InvokeData, LifeCycleKey, MountData, Next, Plugin, ProviderConfig, UseifyPlugin, useFunc, usePlugin };
|
|
156
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -153,4 +153,4 @@ declare function usePlugin<T extends Plugin>(plugin: UseifyPlugin<T>): UseifyPlu
|
|
|
153
153
|
*/
|
|
154
154
|
declare function useFunc<TEvent = any, TContext = any, TResult = any>(handler: () => Handler<TEvent, TContext, TResult>): Func<TEvent, TContext, TResult>;
|
|
155
155
|
|
|
156
|
-
export { Config, DeployData, ExportedHandler, Func, FuncConfig, Handler, InvokeData, LifeCycleKey, MountData, Next, Plugin, ProviderConfig, UseifyPlugin, useFunc, usePlugin };
|
|
156
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,8 @@ var RunHandler = class {
|
|
|
15
15
|
if (data.handler)
|
|
16
16
|
if (!data.runHandler) {
|
|
17
17
|
try {
|
|
18
|
-
data.response = await new Promise(
|
|
19
|
-
data.callback =
|
|
18
|
+
data.response = await new Promise((resolve, reject) => {
|
|
19
|
+
data.callback = (error, result) => {
|
|
20
20
|
if (error)
|
|
21
21
|
reject(error);
|
|
22
22
|
else
|
|
@@ -72,10 +72,10 @@ var Func = class {
|
|
|
72
72
|
}
|
|
73
73
|
this.cachedFunctions[key] = list;
|
|
74
74
|
}
|
|
75
|
-
return async
|
|
75
|
+
return async (data, next) => {
|
|
76
76
|
let index = -1;
|
|
77
77
|
const logger$1 = (data == null ? void 0 : data.logger) || new logger.Logger();
|
|
78
|
-
const dispatch = async
|
|
78
|
+
const dispatch = async (i) => {
|
|
79
79
|
if (i <= index)
|
|
80
80
|
return Promise.reject(Error("next() called multiple times"));
|
|
81
81
|
index = i;
|
|
@@ -205,7 +205,7 @@ function usePlugin(plugin) {
|
|
|
205
205
|
if (!plugins.find((p) => p.name === plugin.name))
|
|
206
206
|
plugins.push(plugin);
|
|
207
207
|
if (!plugin.mount)
|
|
208
|
-
plugin.mount = async
|
|
208
|
+
plugin.mount = async (data) => {
|
|
209
209
|
if (plugin.onMount)
|
|
210
210
|
await plugin.onMount(
|
|
211
211
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -13,8 +13,8 @@ var RunHandler = class {
|
|
|
13
13
|
if (data.handler)
|
|
14
14
|
if (!data.runHandler) {
|
|
15
15
|
try {
|
|
16
|
-
data.response = await new Promise(
|
|
17
|
-
data.callback =
|
|
16
|
+
data.response = await new Promise((resolve, reject) => {
|
|
17
|
+
data.callback = (error, result) => {
|
|
18
18
|
if (error)
|
|
19
19
|
reject(error);
|
|
20
20
|
else
|
|
@@ -70,10 +70,10 @@ var Func = class {
|
|
|
70
70
|
}
|
|
71
71
|
this.cachedFunctions[key] = list;
|
|
72
72
|
}
|
|
73
|
-
return async
|
|
73
|
+
return async (data, next) => {
|
|
74
74
|
let index = -1;
|
|
75
75
|
const logger = (data == null ? void 0 : data.logger) || new Logger();
|
|
76
|
-
const dispatch = async
|
|
76
|
+
const dispatch = async (i) => {
|
|
77
77
|
if (i <= index)
|
|
78
78
|
return Promise.reject(Error("next() called multiple times"));
|
|
79
79
|
index = i;
|
|
@@ -203,7 +203,7 @@ function usePlugin(plugin) {
|
|
|
203
203
|
if (!plugins.find((p) => p.name === plugin.name))
|
|
204
204
|
plugins.push(plugin);
|
|
205
205
|
if (!plugin.mount)
|
|
206
|
-
plugin.mount = async
|
|
206
|
+
plugin.mount = async (data) => {
|
|
207
207
|
if (plugin.onMount)
|
|
208
208
|
await plugin.onMount(
|
|
209
209
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/func",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-beta.2",
|
|
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": "0.0.
|
|
25
|
-
"@faasjs/logger": "0.0.
|
|
24
|
+
"@faasjs/deep_merge": "0.0.5-beta.2",
|
|
25
|
+
"@faasjs/logger": "0.0.5-beta.2"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"npm": ">=9.0.0",
|