@economic/agents 0.0.1-alpha.20 → 0.0.1-alpha.21
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/dist/index.d.mts +6 -4
- package/dist/index.mjs +5 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -191,13 +191,15 @@ type GuardFn<TBody = Record<string, unknown>> = (body: TBody | undefined) => Res
|
|
|
191
191
|
* {@link Response}, that value is returned and the original method is not called.
|
|
192
192
|
*
|
|
193
193
|
* Intended for `onChatMessage(onFinish, options?)` on subclasses of
|
|
194
|
-
* `AIChatAgent`; `options` is read as `{ body?:
|
|
194
|
+
* `AIChatAgent`; `options` is read as `{ body?: TBody }`.
|
|
195
195
|
*
|
|
196
|
-
* @param guardFn - Called with `options?.body` before the method body.
|
|
196
|
+
* @param guardFn - Called with `options?.body` (cast to `TBody`) before the method body.
|
|
197
197
|
*
|
|
198
198
|
* @example
|
|
199
199
|
* ```ts
|
|
200
|
-
*
|
|
200
|
+
* interface RequestBody { token: string }
|
|
201
|
+
*
|
|
202
|
+
* const requireToken: GuardFn<RequestBody> = async (body) => {
|
|
201
203
|
* if (!await isValidToken(body?.token)) {
|
|
202
204
|
* return new Response("Unauthorized", { status: 401 });
|
|
203
205
|
* }
|
|
@@ -211,7 +213,7 @@ type GuardFn<TBody = Record<string, unknown>> = (body: TBody | undefined) => Res
|
|
|
211
213
|
* }
|
|
212
214
|
* ```
|
|
213
215
|
*/
|
|
214
|
-
declare function guard(guardFn: GuardFn): (target: (...args: unknown[]) => Promise<Response>, _context: ClassMethodDecoratorContext) => (this: unknown, ...args: unknown[]) => Promise<Response>;
|
|
216
|
+
declare function guard<TBody = Record<string, unknown>>(guardFn: GuardFn<TBody>): (target: (...args: unknown[]) => Promise<Response>, _context: ClassMethodDecoratorContext) => (this: unknown, ...args: unknown[]) => Promise<Response>;
|
|
215
217
|
//#endregion
|
|
216
218
|
//#region src/types.d.ts
|
|
217
219
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -3956,13 +3956,15 @@ var AIChatAgent = class extends AIChatAgent$1 {
|
|
|
3956
3956
|
* {@link Response}, that value is returned and the original method is not called.
|
|
3957
3957
|
*
|
|
3958
3958
|
* Intended for `onChatMessage(onFinish, options?)` on subclasses of
|
|
3959
|
-
* `AIChatAgent`; `options` is read as `{ body?:
|
|
3959
|
+
* `AIChatAgent`; `options` is read as `{ body?: TBody }`.
|
|
3960
3960
|
*
|
|
3961
|
-
* @param guardFn - Called with `options?.body` before the method body.
|
|
3961
|
+
* @param guardFn - Called with `options?.body` (cast to `TBody`) before the method body.
|
|
3962
3962
|
*
|
|
3963
3963
|
* @example
|
|
3964
3964
|
* ```ts
|
|
3965
|
-
*
|
|
3965
|
+
* interface RequestBody { token: string }
|
|
3966
|
+
*
|
|
3967
|
+
* const requireToken: GuardFn<RequestBody> = async (body) => {
|
|
3966
3968
|
* if (!await isValidToken(body?.token)) {
|
|
3967
3969
|
* return new Response("Unauthorized", { status: 401 });
|
|
3968
3970
|
* }
|