wenay-common2 1.0.37 → 1.0.38

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,12 +1,12 @@
1
1
  import { funcListenCallbackBase } from "../events/Listen";
2
2
  import type { DeepSocketListen } from "./listen-deep";
3
- import type { ClientAPI } from "./rpc-client";
3
+ import type { ClientAPIStrict } from "./rpc-client";
4
4
  type ClientAutoOptions = {
5
5
  readonly mode?: "smart" | "first" | "all";
6
6
  readonly status?: () => boolean;
7
7
  readonly addListenClose?: ReturnType<typeof funcListenCallbackBase<any>>;
8
8
  };
9
9
  export type ClientAutoResult<T> = DeepSocketListen<T>;
10
- export type AutoClientAPI<T> = ClientAPI<DeepSocketListen<T>>;
10
+ export type AutoClientAPI<T> = ClientAPIStrict<DeepSocketListen<T>>;
11
11
  export declare function createRpcClientAuto<T>(api: T, options?: ClientAutoOptions): ClientAutoResult<T>;
12
12
  export {};
@@ -3,8 +3,12 @@ type UnwrapPromise<T> = T extends Promise<infer R> ? R : T;
3
3
  export type DeepDataOnly<T> = T extends Function ? never : T extends Array<infer U> ? Array<DeepDataOnly<U>> : T extends object ? {
4
4
  [K in keyof T as T[K] extends Function ? never : K]: DeepDataOnly<T[K]>;
5
5
  } : T;
6
- export type ClientAPI<T> = {
7
- [K in keyof T as T[K] extends Function ? K : T[K] extends object ? K : never]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<DeepDataOnly<UnwrapPromise<R>>> : T[K] extends object ? ClientAPI<T[K]> : never;
6
+ export type ClientAPIAll<T> = {
7
+ [K in keyof T as T[K] extends Function ? K : T[K] extends object ? K : never]: T[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<DeepDataOnly<UnwrapPromise<R>>> : T[K] extends object ? ClientAPIAll<T[K]> : never;
8
+ };
9
+ type NonFalsy<T> = Exclude<T, false | null | 0 | "" | undefined>;
10
+ export type ClientAPIStrict<T> = {
11
+ [K in keyof T as NonFalsy<T[K]> extends Function ? K : NonFalsy<T[K]> extends object ? K : never]: NonFalsy<T[K]> extends (...args: infer A) => infer R ? (...args: A) => Promise<DeepDataOnly<UnwrapPromise<R>>> : NonFalsy<T[K]> extends object ? ClientAPIStrict<NonFalsy<T[K]>> : never;
8
12
  };
9
13
  export interface PipeArrayAPI<T> extends Promise<DeepDataOnly<T[]>> {
10
14
  [index: number]: PipeAPI<T>;
@@ -22,12 +26,12 @@ type ClientApiHandle = {
22
26
  end: (fn: Function) => void;
23
27
  };
24
28
  export type RpcClientReturn<T extends object> = {
25
- func: ClientAPI<T>;
29
+ func: ClientAPIAll<T>;
26
30
  pipe: PipeAPI<T>;
27
31
  pipeStrict: PipeAPI<T>;
28
- space: ClientAPI<T>;
29
- all: ClientAPI<T>;
30
- strict: ClientAPI<T>;
32
+ space: ClientAPIAll<T>;
33
+ all: ClientAPIAll<T>;
34
+ strict: ClientAPIStrict<T>;
31
35
  api: ClientApiHandle;
32
36
  abortAll: (reason: string) => void;
33
37
  schema: () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wenay-common2",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "Common library",
5
5
  "strict": true,
6
6
  "main": "lib/index.js",