@asterflow/plugin 1.0.3 → 1.0.5
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 +3 -7
- package/dist/cjs/index.cjs +34 -71
- package/dist/mjs/index.js +23 -60
- package/dist/types/controllers/Plugin.d.ts +18 -25
- package/dist/types/types/plugin.d.ts +24 -11
- package/dist/types/types/utils.d.ts +5 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,12 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|

|
|
7
|
+

|
|
7
8
|
|
|
8
|
-

|
|
9
|
-

|
|
10
|
-

|
|
11
|
-
|
|
12
|
-

|
|
13
9
|

|
|
14
10
|
|
|
15
11
|
</div>
|
|
@@ -117,7 +113,7 @@ const loggerPlugin = Plugin.create({ name: 'logger-plugin' })
|
|
|
117
113
|
To use the created plugins, you register them with the `AsterFlow` instance.
|
|
118
114
|
|
|
119
115
|
```typescript
|
|
120
|
-
import { AsterFlow } from '
|
|
116
|
+
import { AsterFlow } from 'asterflow'
|
|
121
117
|
import { adapters } from '@asterflow/adapter'
|
|
122
118
|
import fastify from 'fastify'
|
|
123
119
|
// Import your plugins here
|
|
@@ -144,7 +140,7 @@ app.listen(server, { port: 3000 }, (err) => {
|
|
|
144
140
|
|
|
145
141
|
## 🔗 Related Packages
|
|
146
142
|
|
|
147
|
-
- [
|
|
143
|
+
- [asterflow](https://www.npmjs.com/package/asterflow) - The heart of the AsterFlow framework.
|
|
148
144
|
- [@asterflow/adapter](https://www.npmjs.com/package/@asterflow/adapter) - HTTP adapters for different runtimes.
|
|
149
145
|
- [@asterflow/router](https://www.npmjs.com/package/@asterflow/router) - Type-safe routing system.
|
|
150
146
|
- [@asterflow/request](https://www.npmjs.com/package/@asterflow/request) - Unified HTTP request system.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,97 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var r = Object.defineProperty;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var f = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var u = Object.getOwnPropertyNames;
|
|
5
|
+
var d = Object.prototype.hasOwnProperty;
|
|
6
|
+
var g = (o, e) => {
|
|
7
7
|
for (var n in e)
|
|
8
|
-
r(
|
|
9
|
-
},
|
|
8
|
+
r(o, n, { get: e[n], enumerable: !0 });
|
|
9
|
+
}, h = (o, e, n, t) => {
|
|
10
10
|
if (e && typeof e == "object" || typeof e == "function")
|
|
11
|
-
for (let
|
|
12
|
-
!
|
|
13
|
-
return
|
|
11
|
+
for (let s of u(e))
|
|
12
|
+
!d.call(o, s) && s !== n && r(o, s, { get: () => e[s], enumerable: !(t = f(e, s)) || t.enumerable });
|
|
13
|
+
return o;
|
|
14
14
|
};
|
|
15
|
-
var
|
|
15
|
+
var x = (o) => h(r({}, "__esModule", { value: !0 }), o);
|
|
16
16
|
// packages/plugin/src/index.ts
|
|
17
|
-
var
|
|
18
|
-
|
|
17
|
+
var y = {};
|
|
18
|
+
g(y, {
|
|
19
19
|
Plugin: () => a
|
|
20
20
|
});
|
|
21
|
-
module.exports =
|
|
21
|
+
module.exports = x(y);
|
|
22
22
|
// packages/plugin/src/controllers/Plugin.ts
|
|
23
|
-
var a = class
|
|
23
|
+
var a = class o {
|
|
24
24
|
name;
|
|
25
25
|
resolvers;
|
|
26
26
|
defaultConfig;
|
|
27
|
-
hooks;
|
|
27
|
+
hooks = {};
|
|
28
28
|
instance;
|
|
29
29
|
_extensionFn;
|
|
30
|
-
constructor(e, n,
|
|
31
|
-
this.name = e, this.resolvers = n, this.hooks =
|
|
30
|
+
constructor(e, n, t, s, i) {
|
|
31
|
+
this.name = e, this.resolvers = n, this.hooks = t, this.defaultConfig = s, this._extensionFn = i;
|
|
32
32
|
}
|
|
33
33
|
config(e) {
|
|
34
|
-
return
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
e,
|
|
39
|
-
this._extensionFn
|
|
40
|
-
);
|
|
34
|
+
return this.defaultConfig = {
|
|
35
|
+
...this.defaultConfig,
|
|
36
|
+
defaultConfig: e
|
|
37
|
+
}, this;
|
|
41
38
|
}
|
|
42
39
|
defineInstance(e) {
|
|
43
40
|
return this.instance = e, this;
|
|
44
41
|
}
|
|
45
42
|
decorate(e, n) {
|
|
46
|
-
let
|
|
43
|
+
let t = async (s, i) => ({
|
|
47
44
|
...i,
|
|
48
45
|
[e]: n
|
|
49
46
|
});
|
|
50
|
-
return
|
|
51
|
-
this.name,
|
|
52
|
-
[...this.resolvers, s],
|
|
53
|
-
this.hooks,
|
|
54
|
-
this.defaultConfig,
|
|
55
|
-
this._extensionFn
|
|
56
|
-
);
|
|
47
|
+
return this.resolvers = [...this.resolvers, t], this;
|
|
57
48
|
}
|
|
58
49
|
derive(e, n) {
|
|
59
|
-
let
|
|
60
|
-
let
|
|
50
|
+
let t = async (s, i) => {
|
|
51
|
+
let c = { ...i, ...s }, l = await n(c);
|
|
61
52
|
return {
|
|
62
53
|
...i,
|
|
63
|
-
[e]:
|
|
54
|
+
[e]: l
|
|
64
55
|
};
|
|
65
56
|
};
|
|
66
|
-
return
|
|
67
|
-
this.name,
|
|
68
|
-
[...this.resolvers, s],
|
|
69
|
-
this.hooks,
|
|
70
|
-
this.defaultConfig,
|
|
71
|
-
this._extensionFn
|
|
72
|
-
);
|
|
57
|
+
return this.resolvers = [...this.resolvers, t], this;
|
|
73
58
|
}
|
|
74
59
|
on(e, n) {
|
|
75
|
-
let
|
|
60
|
+
let t = this.hooks[e] || [];
|
|
61
|
+
return this.hooks = {
|
|
76
62
|
...this.hooks,
|
|
77
|
-
[e]: [...
|
|
78
|
-
};
|
|
79
|
-
return new t(
|
|
80
|
-
this.name,
|
|
81
|
-
this.resolvers,
|
|
82
|
-
o,
|
|
83
|
-
this.defaultConfig,
|
|
84
|
-
this._extensionFn
|
|
85
|
-
);
|
|
63
|
+
[e]: [...t, n]
|
|
64
|
+
}, this;
|
|
86
65
|
}
|
|
87
66
|
extends(e) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.resolvers,
|
|
91
|
-
this.hooks,
|
|
92
|
-
this.defaultConfig,
|
|
93
|
-
(n, s) => ({ ...this._extensionFn ? this._extensionFn(n, s) : {}, ...e(n, s) })
|
|
94
|
-
);
|
|
67
|
+
let n = this._extensionFn;
|
|
68
|
+
return this._extensionFn = (t, s) => ({ ...n ? n(t, s) : {}, ...e(t, s) }), this;
|
|
95
69
|
}
|
|
96
70
|
_build(e) {
|
|
97
71
|
let n = { ...this.defaultConfig, ...e };
|
|
@@ -104,18 +78,7 @@ var a = class t {
|
|
|
104
78
|
};
|
|
105
79
|
}
|
|
106
80
|
static create(e) {
|
|
107
|
-
return new
|
|
108
|
-
}
|
|
109
|
-
static instance() {
|
|
110
|
-
return {
|
|
111
|
-
create: (e) => new t(
|
|
112
|
-
e.name,
|
|
113
|
-
[],
|
|
114
|
-
{},
|
|
115
|
-
{},
|
|
116
|
-
void 0
|
|
117
|
-
)
|
|
118
|
-
};
|
|
81
|
+
return new o(e.name, [], {}, {}, void 0);
|
|
119
82
|
}
|
|
120
83
|
};
|
|
121
84
|
0 && (module.exports = {
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,76 +1,50 @@
|
|
|
1
1
|
// packages/plugin/src/controllers/Plugin.ts
|
|
2
|
-
var
|
|
2
|
+
var i = class r {
|
|
3
3
|
name;
|
|
4
4
|
resolvers;
|
|
5
5
|
defaultConfig;
|
|
6
|
-
hooks;
|
|
6
|
+
hooks = {};
|
|
7
7
|
instance;
|
|
8
8
|
_extensionFn;
|
|
9
|
-
constructor(e, n, t,
|
|
10
|
-
this.name = e, this.resolvers = n, this.hooks = t, this.defaultConfig =
|
|
9
|
+
constructor(e, n, t, s, o) {
|
|
10
|
+
this.name = e, this.resolvers = n, this.hooks = t, this.defaultConfig = s, this._extensionFn = o;
|
|
11
11
|
}
|
|
12
12
|
config(e) {
|
|
13
|
-
return
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
e,
|
|
18
|
-
this._extensionFn
|
|
19
|
-
);
|
|
13
|
+
return this.defaultConfig = {
|
|
14
|
+
...this.defaultConfig,
|
|
15
|
+
defaultConfig: e
|
|
16
|
+
}, this;
|
|
20
17
|
}
|
|
21
18
|
defineInstance(e) {
|
|
22
19
|
return this.instance = e, this;
|
|
23
20
|
}
|
|
24
21
|
decorate(e, n) {
|
|
25
|
-
let t = async (
|
|
26
|
-
...
|
|
22
|
+
let t = async (s, o) => ({
|
|
23
|
+
...o,
|
|
27
24
|
[e]: n
|
|
28
25
|
});
|
|
29
|
-
return
|
|
30
|
-
this.name,
|
|
31
|
-
[...this.resolvers, t],
|
|
32
|
-
this.hooks,
|
|
33
|
-
this.defaultConfig,
|
|
34
|
-
this._extensionFn
|
|
35
|
-
);
|
|
26
|
+
return this.resolvers = [...this.resolvers, t], this;
|
|
36
27
|
}
|
|
37
28
|
derive(e, n) {
|
|
38
|
-
let t = async (
|
|
39
|
-
let a = { ...
|
|
29
|
+
let t = async (s, o) => {
|
|
30
|
+
let a = { ...o, ...s }, c = await n(a);
|
|
40
31
|
return {
|
|
41
|
-
...
|
|
42
|
-
[e]:
|
|
32
|
+
...o,
|
|
33
|
+
[e]: c
|
|
43
34
|
};
|
|
44
35
|
};
|
|
45
|
-
return
|
|
46
|
-
this.name,
|
|
47
|
-
[...this.resolvers, t],
|
|
48
|
-
this.hooks,
|
|
49
|
-
this.defaultConfig,
|
|
50
|
-
this._extensionFn
|
|
51
|
-
);
|
|
36
|
+
return this.resolvers = [...this.resolvers, t], this;
|
|
52
37
|
}
|
|
53
38
|
on(e, n) {
|
|
54
|
-
let t = this.hooks[e] || []
|
|
39
|
+
let t = this.hooks[e] || [];
|
|
40
|
+
return this.hooks = {
|
|
55
41
|
...this.hooks,
|
|
56
42
|
[e]: [...t, n]
|
|
57
|
-
};
|
|
58
|
-
return new s(
|
|
59
|
-
this.name,
|
|
60
|
-
this.resolvers,
|
|
61
|
-
o,
|
|
62
|
-
this.defaultConfig,
|
|
63
|
-
this._extensionFn
|
|
64
|
-
);
|
|
43
|
+
}, this;
|
|
65
44
|
}
|
|
66
45
|
extends(e) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.resolvers,
|
|
70
|
-
this.hooks,
|
|
71
|
-
this.defaultConfig,
|
|
72
|
-
(n, t) => ({ ...this._extensionFn ? this._extensionFn(n, t) : {}, ...e(n, t) })
|
|
73
|
-
);
|
|
46
|
+
let n = this._extensionFn;
|
|
47
|
+
return this._extensionFn = (t, s) => ({ ...n ? n(t, s) : {}, ...e(t, s) }), this;
|
|
74
48
|
}
|
|
75
49
|
_build(e) {
|
|
76
50
|
let n = { ...this.defaultConfig, ...e };
|
|
@@ -83,20 +57,9 @@ var r = class s {
|
|
|
83
57
|
};
|
|
84
58
|
}
|
|
85
59
|
static create(e) {
|
|
86
|
-
return new
|
|
87
|
-
}
|
|
88
|
-
static instance() {
|
|
89
|
-
return {
|
|
90
|
-
create: (e) => new s(
|
|
91
|
-
e.name,
|
|
92
|
-
[],
|
|
93
|
-
{},
|
|
94
|
-
{},
|
|
95
|
-
void 0
|
|
96
|
-
)
|
|
97
|
-
};
|
|
60
|
+
return new r(e.name, [], {}, {}, void 0);
|
|
98
61
|
}
|
|
99
62
|
};
|
|
100
63
|
export {
|
|
101
|
-
|
|
64
|
+
i as Plugin
|
|
102
65
|
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import type { AnyAsterflow, ExtendedAsterflow } from '
|
|
1
|
+
import type { AnyAsterflow, ExtendedAsterflow } from 'asterflow';
|
|
2
2
|
import type { PluginHooks, Resolver } from '../types/plugin';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Plugins are defined with a series of resolvers (`decorate`, `derive`) and lifecycle
|
|
6
|
-
* hooks (`on`) that build up its context and runtime behavior.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Plugin<Path extends string, Instance extends AnyAsterflow, Config extends Record<string, any> = {}, Context extends Record<string, any> = {}, Hooks extends PluginHooks<any, Context[], any> = {}, Extension extends Record<string, any> = {}> {
|
|
3
|
+
import type { Prettify, UnionToIntersection } from '../types/utils';
|
|
4
|
+
export declare class Plugin<Path extends string = string, Instance extends AnyAsterflow = AnyAsterflow, Config extends Record<string, any> = {}, Decorate extends Record<string, any> = {}, Derive extends Record<string, any> = {}, Extension extends Record<string, any> = {}> {
|
|
9
5
|
readonly name: Path;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
resolvers: Resolver[];
|
|
7
|
+
defaultConfig: Partial<Config>;
|
|
8
|
+
hooks: PluginHooks<any, Decorate, any>;
|
|
13
9
|
instance: Instance;
|
|
14
|
-
private
|
|
10
|
+
private _extensionFn?;
|
|
15
11
|
private constructor();
|
|
16
12
|
/**
|
|
17
13
|
* Defines the shape of the configuration and its default values for this plugin.
|
|
18
14
|
*/
|
|
19
|
-
config<C extends Record<string, any>>(defaultConfig: C): Plugin<Path, Instance,
|
|
15
|
+
config<C extends Record<string, any>>(defaultConfig: C): Plugin<Path, Instance, Prettify<UnionToIntersection<{
|
|
16
|
+
defaultConfig: C;
|
|
17
|
+
} | C | Config>>, Decorate, Derive, Extension>;
|
|
20
18
|
/**
|
|
21
19
|
* O `defineInstance` agora é mais simples. Ele não precisa mais re-tipar
|
|
22
20
|
* a classe inteira. Ele só serve para passar o `this` para o `_build`.
|
|
@@ -25,12 +23,12 @@ export declare class Plugin<Path extends string, Instance extends AnyAsterflow,
|
|
|
25
23
|
/**
|
|
26
24
|
* Adds a new static value to the plugin's context (decoration).
|
|
27
25
|
*/
|
|
28
|
-
decorate<Key extends string, Value>(key: Key, value: Value): Plugin<Path, Instance, Config,
|
|
26
|
+
decorate<Key extends string, Value>(key: Key, value: Value): Plugin<Path, Instance, Config, Prettify<UnionToIntersection<Decorate | { [K in Key]: Value; }>>, Derive, Extension>;
|
|
29
27
|
/**
|
|
30
28
|
* Adds a new property to the context that is derived from the configuration and the existing context.
|
|
31
29
|
* The resolver function is executed lazily when the plugin is registered via `app.use()`.
|
|
32
30
|
*/
|
|
33
|
-
derive<Key extends string, Value>(key: Key, resolverFn: (context:
|
|
31
|
+
derive<Key extends string, Value>(key: Key, resolverFn: (context: Derive & Config & Decorate) => Value | Promise<Value>): Plugin<Path, Instance, Config, Decorate, Prettify<UnionToIntersection<Derive | { [K in Key]: Awaited<Value>; }>>, Extension>;
|
|
34
32
|
/**
|
|
35
33
|
* Registers a handler for a specific lifecycle event.
|
|
36
34
|
* Adding a hook makes the plugin "runtime-aware". AsterFlow can optimize by only
|
|
@@ -41,21 +39,21 @@ export declare class Plugin<Path extends string, Instance extends AnyAsterflow,
|
|
|
41
39
|
* .on('beforeInitialize', (app, context) => { })
|
|
42
40
|
* .on('beforeInitialize', (app, context) => { });
|
|
43
41
|
*/
|
|
44
|
-
on<Event extends keyof PluginHooks<ExtendedAsterflow<Instance>,
|
|
42
|
+
on<Event extends keyof PluginHooks<ExtendedAsterflow<Instance>, Prettify<UnionToIntersection<Derive | Config | Decorate>>, Extension>>(event: Event, handler: NonNullable<PluginHooks<ExtendedAsterflow<Instance>, Prettify<UnionToIntersection<Derive | Config | Decorate>>, Extension>[Event]>[number]): this;
|
|
45
43
|
/**
|
|
46
44
|
* Defines new properties or methods to be added to the AsterFlow instance.
|
|
47
45
|
* A função recebe a instância do app e o contexto do plugin, e deve retornar um objeto
|
|
48
46
|
* com as novas propriedades.
|
|
49
47
|
*/
|
|
50
|
-
extends<E extends Record<string, any>>(extensionFn: (app: Instance, context:
|
|
48
|
+
extends<E extends Record<string, any>>(extensionFn: (app: Instance, context: Prettify<UnionToIntersection<Config | Derive | Decorate>>) => E): Plugin<Path, Instance, Config, Decorate, Derive, Prettify<UnionToIntersection<Extension & E>>>;
|
|
51
49
|
/**
|
|
52
50
|
* Builds the final context and hooks from the provided configuration.
|
|
53
51
|
*/
|
|
54
52
|
_build(config: any): {
|
|
55
53
|
name: Path;
|
|
56
|
-
context: Config &
|
|
57
|
-
hooks:
|
|
58
|
-
_extensionFn: ((app: Instance, context:
|
|
54
|
+
context: Config & Derive & Decorate;
|
|
55
|
+
hooks: PluginHooks<any, Decorate, any>;
|
|
56
|
+
_extensionFn: ((app: Instance, context: Prettify<UnionToIntersection<Config & Decorate & Derive>>) => Extension) | undefined;
|
|
59
57
|
resolvers: Resolver[];
|
|
60
58
|
};
|
|
61
59
|
/**
|
|
@@ -63,10 +61,5 @@ export declare class Plugin<Path extends string, Instance extends AnyAsterflow,
|
|
|
63
61
|
*/
|
|
64
62
|
static create<Path extends string, Asterflow extends AnyAsterflow>(options: {
|
|
65
63
|
name: Path;
|
|
66
|
-
}): Plugin<Path, Asterflow, {}, {}, {}>;
|
|
67
|
-
static instance<T extends AnyAsterflow>(): {
|
|
68
|
-
create: <Path extends string>(options: {
|
|
69
|
-
name: Path;
|
|
70
|
-
}) => Plugin<Path, T, {}, {}, {}, {}>;
|
|
71
|
-
};
|
|
64
|
+
}): Plugin<Path, Asterflow, {}, {}, {}, {}>;
|
|
72
65
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Runtime } from '@asterflow/adapter';
|
|
2
|
+
import type { AnyAsterflow, ExtendedAsterflow } from 'asterflow';
|
|
2
3
|
import type { Request } from '@asterflow/request';
|
|
3
|
-
import type {
|
|
4
|
+
import type { AsterResponse, Prettify } from '@asterflow/response';
|
|
4
5
|
import type { Plugin } from '../controllers/Plugin';
|
|
5
|
-
|
|
6
|
+
import type { AnyRecord, UnionToIntersection } from './utils';
|
|
7
|
+
export type AnyPluginHooks = PluginHooks<AnyAsterflow, AnyRecord, AnyRecord>;
|
|
8
|
+
export type AnyPlugin = Plugin<string, AnyAsterflow, AnyRecord, AnyRecord, AnyRecord, AnyRecord>;
|
|
6
9
|
export type AnyPlugins = Record<string, ResolvedPlugin<AnyPlugin>>;
|
|
7
|
-
export type
|
|
10
|
+
export type AnyPluginInstance = ResolvedPlugin<AnyPlugin> & {
|
|
11
|
+
hooks: AnyPluginHooks;
|
|
12
|
+
};
|
|
8
13
|
export type InferPluginExtension<P> = P extends Plugin<any, any, any, any, any, infer Ext> ? Ext : {};
|
|
9
|
-
export type
|
|
14
|
+
export type InferPluginContext<P> = P extends Plugin<any, any, infer Config, infer Decorate, infer Derive, any> ? Prettify<UnionToIntersection<Config | Decorate | Derive>> : {};
|
|
15
|
+
export type ResolvedPlugin<P extends Plugin<any, any, any, any, any, any>> = P extends Plugin<infer Path, any, any, infer Ctx, any, infer Ext> ? {
|
|
10
16
|
name: Path;
|
|
11
17
|
context: Ctx;
|
|
12
18
|
hooks: PluginHooks<any, Ctx, Ext>;
|
|
@@ -17,18 +23,25 @@ export type ResolvedPlugin<P extends AnyPlugin> = P extends Plugin<infer Path, a
|
|
|
17
23
|
* Tipo para extrair o objeto de configuração de um plugin.
|
|
18
24
|
* Ele torna as propriedades com valores padrão opcionais.
|
|
19
25
|
*/
|
|
20
|
-
export type
|
|
26
|
+
export type InferConfigArgument<P extends Plugin<any, any, any, any, any, any>> = P extends Plugin<any, any, infer C, any, any, any> ? Omit<C, keyof P['defaultConfig']> & Partial<Pick<C, keyof P['defaultConfig'] & keyof C>> : never;
|
|
21
27
|
/**
|
|
22
28
|
* Defines the available lifecycle hooks a plugin can register.
|
|
23
29
|
*/
|
|
24
30
|
export type PluginHooks<Instance extends AnyAsterflow, Context extends Record<string, any>, Extension extends Record<string, any> = {}> = {
|
|
25
|
-
beforeInitialize?: ((app: ExtendedAsterflow<Instance> & Extension, context: Context) =>
|
|
26
|
-
afterInitialize?: ((app: ExtendedAsterflow<Instance> & Extension, context: Context) =>
|
|
27
|
-
onRequest?: ((request
|
|
28
|
-
|
|
31
|
+
beforeInitialize?: ((app: ExtendedAsterflow<Instance> & Extension, context: Context) => any | Promise<any>)[];
|
|
32
|
+
afterInitialize?: ((app: ExtendedAsterflow<Instance> & Extension, context: Context) => any | Promise<any>)[];
|
|
33
|
+
onRequest?: (({ context, request, response }: {
|
|
34
|
+
request: Request<Runtime>;
|
|
35
|
+
response: AsterResponse;
|
|
36
|
+
context: Context;
|
|
37
|
+
}) => any | Promise<any>)[];
|
|
38
|
+
onResponse?: (({ context, request, response }: {
|
|
39
|
+
request: Request<Runtime>;
|
|
40
|
+
response: AsterResponse;
|
|
41
|
+
context: Context;
|
|
42
|
+
}) => any | Promise<any>)[];
|
|
29
43
|
};
|
|
30
44
|
/**
|
|
31
45
|
* Represents a function that resolves a part of the plugin's context.
|
|
32
|
-
* @internal
|
|
33
46
|
*/
|
|
34
47
|
export type Resolver = (config: any, context: any) => Promise<Record<string, any>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asterflow/plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "dist/cjs/index.cjs",
|
|
5
5
|
"module": "dist/mjs/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"node": ">=20"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"
|
|
22
|
-
"@asterflow/response": "1.0.
|
|
23
|
-
"@asterflow/request": "1.0.
|
|
21
|
+
"asterflow": "0.0.1",
|
|
22
|
+
"@asterflow/response": "1.0.6",
|
|
23
|
+
"@asterflow/request": "1.0.9"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"typescript": "^5.8.3"
|