repos / starfx

supercharged async flow control library.
git clone https://github.com/neurosnap/starfx.git

commit
ed175e3
parent
8b15e81
author
Eric Bower
date
2023-09-16 14:46:53 +0000 UTC
chore: type improvements
4 files changed,  +8, -7
M query/api-types.ts
+3, -2
 1@@ -13,6 +13,7 @@ import type {
 2   Supervisor,
 3 } from "./types.ts";
 4 import type { Payload } from "../types.ts";
 5+import type { Operation } from "../deps.ts";
 6 
 7 export type ApiName = string | string[];
 8 
 9@@ -20,8 +21,8 @@ export interface SagaQueryApi<Ctx extends ApiCtx = ApiCtx>
10   extends SagaApi<Ctx> {
11   request: (
12     r: Partial<RequestInit>,
13-  ) => (ctx: Ctx, next: Next) => Iterator<unknown>;
14-  cache: () => (ctx: Ctx, next: Next) => Iterator<unknown>;
15+  ) => (ctx: Ctx, next: Next) => Operation<unknown>;
16+  cache: () => (ctx: Ctx, next: Next) => Operation<unknown>;
17 
18   uri: (uri: string) => {
19     /**
M query/api.test.ts
+1, -1
1@@ -48,7 +48,7 @@ it(tests, "createApi - POST", async () => {
2   query.use(queryCtx);
3   query.use(urlParser);
4   query.use(query.routes());
5-  query.use(function* fetchApi(ctx, next): Iterator<unknown> {
6+  query.use(function* fetchApi(ctx, next) {
7     expect(ctx.req()).toEqual({
8       url: "/users",
9       headers: {},
M query/types.ts
+3, -3
 1@@ -64,7 +64,7 @@ export interface ApiCtx<Payload = any, ApiSuccess = any, ApiError = any>
 2 export type Middleware<Ctx extends PipeCtx = PipeCtx> = (
 3   ctx: Ctx,
 4   next: Next,
 5-) => any;
 6+) => Operation<any>;
 7 export type MiddlewareCo<Ctx extends PipeCtx = PipeCtx> =
 8   | Middleware<Ctx>
 9   | Middleware<Ctx>[];
10@@ -72,12 +72,12 @@ export type MiddlewareCo<Ctx extends PipeCtx = PipeCtx> =
11 export type MiddlewareApi<Ctx extends ApiCtx = ApiCtx> = (
12   ctx: Ctx,
13   next: Next,
14-) => any;
15+) => Operation<any>;
16 export type MiddlewareApiCo<Ctx extends ApiCtx = ApiCtx> =
17   | Middleware<Ctx>
18   | Middleware<Ctx>[];
19 
20-export type Next = () => any;
21+export type Next = () => Operation<unknown>;
22 
23 export interface Action {
24   type: string;
M query/util.ts
+1, -1
1@@ -1,6 +1,6 @@
2 import type { ApiRequest, RequiredApiRequest } from "./types.ts";
3 
4-export const noop = () => {};
5+export function* noop() {}
6 // deno-lint-ignore no-explicit-any
7 export const isFn = (fn?: any) => fn && typeof fn === "function";
8 // deno-lint-ignore no-explicit-any