kb-server 0.0.1-beta.14 → 0.0.1-beta.16

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.
@@ -1,19 +1,19 @@
1
1
  import { Class } from "utility-types";
2
- export interface ServerContext {
2
+ export interface ServerContext<A = any> {
3
3
  /** 被调用方的 RequestId */
4
4
  RequestId: string;
5
5
  /** 权限信息 */
6
- AuthInfo?: Record<string, any>;
6
+ AuthInfo?: A;
7
7
  }
8
8
  export type API<P, R> = (param: P) => Promise<R>;
9
- export type APIExecution<P, R> = (
9
+ export type APIExecution<P, R, A> = (
10
10
  /** 请求入参 */
11
11
  params: P,
12
12
  /** 请求上下文 */
13
- ctx: ServerContext) => Promise<R>;
14
- export type AnyAPIExecution = APIExecution<any, any>;
13
+ ctx: ServerContext<A>) => Promise<R>;
14
+ export type AnyAPIExecution = APIExecution<any, any, any>;
15
15
  export type APIs = Record<string, AnyAPIExecution>;
16
- export declare function createAPI<P, R>(ParamsClass: Class<P>, execution: APIExecution<P, R>): API<P, R>;
16
+ export declare function createAPI<P, R, A>(ParamsClass: Class<P>, execution: APIExecution<P, R, A>): API<P, R>;
17
17
  type StubParam<T> = T extends (params: infer P) => any ? P : never;
18
- export declare function implementAPI<A extends (params: any) => any>(_actionStub: A, ParamsClass: Class<StubParam<A>>, execution: APIExecution<StubParam<A>, ReturnType<A>>): API<StubParam<A>, ReturnType<A>>;
18
+ export declare function implementAPI<F extends (params: any) => any, A = any>(_actionStub: F, ParamsClass: Class<StubParam<F>>, execution: APIExecution<StubParam<F>, ReturnType<F>, A>): API<StubParam<F>, ReturnType<F>>;
19
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kb-server",
3
- "version": "0.0.1-beta.14",
3
+ "version": "0.0.1-beta.16",
4
4
  "description": "A fast server for Node.JS,made by express.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {