@ahoo-wang/fetcher-wow 1.9.6 → 2.0.0

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,7 +1,6 @@
1
- import { ClientOptions } from '../types';
2
1
  import { CommandRequest } from './commandRequest';
3
2
  import { CommandResult, CommandResultEventStream } from './commandResult';
4
- import { RequestOptions } from '@ahoo-wang/fetcher';
3
+ import { ApiMetadata, ApiMetadataCapable } from '@ahoo-wang/fetcher-decorator';
5
4
  /**
6
5
  * Command Client for sending commands to the server.
7
6
  *
@@ -44,29 +43,13 @@ import { RequestOptions } from '@ahoo-wang/fetcher';
44
43
  * }
45
44
  * ```
46
45
  */
47
- export declare class CommandClient {
48
- protected readonly options: ClientOptions;
49
- constructor(options: ClientOptions);
50
- /**
51
- * Sends a command to the specified path and returns the result.
52
- * This is a protected generic method that handles the common logic for sending commands.
53
- * @template R The type of the result to be returned
54
- * @param path - The endpoint path to send the command to
55
- * @param commandHttpRequest - The command HTTP request containing headers, method, and body
56
- * @param options - Request options including result extractor and attributes
57
- * @param options.resultExtractor - Function to extract the desired result from the exchange.
58
- * Defaults to ExchangeResultExtractor which returns the entire exchange object.
59
- * @param options.attributes - Optional shared attributes that can be accessed by interceptors
60
- * throughout the request lifecycle. These attributes allow passing
61
- * custom data between different interceptors.
62
- * @returns A promise that resolves to the extracted result of type R
63
- */
64
- protected sendCommand<R>(path: string, commandHttpRequest: CommandRequest, options?: RequestOptions): Promise<R>;
46
+ export declare class CommandClient<C extends object = object> implements ApiMetadataCapable {
47
+ readonly apiMetadata?: ApiMetadata | undefined;
48
+ constructor(apiMetadata?: ApiMetadata | undefined);
65
49
  /**
66
50
  * Send a command to the server and wait for the result.
67
51
  *
68
- * @param path - The endpoint path to send the command to
69
- * @param commandHttpRequest - The command request to send
52
+ * @param commandRequest - The command request to send
70
53
  * @param attributes - Optional shared attributes that can be accessed by interceptors
71
54
  * throughout the request lifecycle. These attributes allow passing
72
55
  * custom data between different interceptors.
@@ -83,13 +66,12 @@ export declare class CommandClient {
83
66
  * });
84
67
  * ```
85
68
  */
86
- send(path: string, commandHttpRequest: CommandRequest, attributes?: Record<string, any>): Promise<CommandResult>;
69
+ send(commandRequest: CommandRequest<C>, attributes?: Record<string, any>): Promise<CommandResult>;
87
70
  /**
88
71
  * Send a command to the server and wait for the result as a stream.
89
72
  * This is useful for long-running commands that produce multiple events.
90
73
  *
91
- * @param path - The endpoint path to send the command to
92
- * @param commandHttpRequest - The command request to send
74
+ * @param commandRequest - The command request to send
93
75
  * @param attributes - Optional shared attributes that can be accessed by interceptors
94
76
  * throughout the request lifecycle. These attributes allow passing
95
77
  * custom data between different interceptors.
@@ -113,6 +95,6 @@ export declare class CommandClient {
113
95
  * }
114
96
  * ```
115
97
  */
116
- sendAndWaitStream(path: string, commandHttpRequest: CommandRequest, attributes?: Record<string, any>): Promise<CommandResultEventStream>;
98
+ sendAndWaitStream(commandRequest: CommandRequest<C>, attributes?: Record<string, any>): Promise<CommandResultEventStream>;
117
99
  }
118
100
  //# sourceMappingURL=commandClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandClient.d.ts","sourceRoot":"","sources":["../../src/command/commandClient.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAIL,cAAc,EACf,MAAM,oBAAoB,CAAC;AAO5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,aAAa;IACZ,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa;gBAAtB,OAAO,EAAE,aAAa;IAGrD;;;;;;;;;;;;;OAaG;cACa,WAAW,CAAC,CAAC,EAC3B,IAAI,EAAE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E,cAAc,CAAC,CAAC,CAAC,EAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5C,OAAO,CAAC,wBAAwB,CAAC;CAGrC"}
@@ -17,7 +17,7 @@
17
17
  * };
18
18
  * ```
19
19
  */
20
- export declare class CommandHttpHeaders {
20
+ export declare class CommandHeaders {
21
21
  /**
22
22
  * Prefix for all command-related headers
23
23
  */
@@ -126,4 +126,4 @@ export declare class CommandHttpHeaders {
126
126
  */
127
127
  static readonly COMMAND_HEADER_X_PREFIX: string;
128
128
  }
129
- //# sourceMappingURL=commandHttpHeaders.d.ts.map
129
+ //# sourceMappingURL=commandHeaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandHeaders.d.ts","sourceRoot":"","sources":["../../src/command/commandHeaders.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,sBAAsB,cAAc;IAEpD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAuD;IAEhF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAsD;IAE9E;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,SAA0D;IAEtF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,iBAAiB,SAA+D;IAEhG;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAW,SAAmD;IAE9E;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa,SAA0C;IAGvE;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,SAAwC;IAElE;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,SAA0C;IAEtE;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,SAA4C;IAE1E;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,aAAa,SAA2C;IAIxE;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAwC;IAExE;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,SAA6C;IAE5E;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,iBAAiB,SAA+C;IAEhF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,mBAAmB,SAAiD;IAEpF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,SAAgD;IAGlF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,SAAwD;IAElF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAW,SAAyD;IAEpF;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,yBAAyB,SAA+D;IAExG;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,sBAAsB,SAA4D;IAElG;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,YAAY,SAAkD;IAE9E;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,uBAAuB,SAAqD;CAC7F"}
@@ -1,5 +1,6 @@
1
- import { FetchRequestInit, RequestHeaders, UrlParams } from '@ahoo-wang/fetcher';
2
- import { PathParams } from '../types/endpoints';
1
+ import { RequestHeaders, RequiredBy, UrlParams } from '@ahoo-wang/fetcher';
2
+ import { UrlPathParams } from '../types/endpoints';
3
+ import { ParameterRequest } from '@ahoo-wang/fetcher-decorator';
3
4
  /**
4
5
  * Command Request Headers Interface
5
6
  *
@@ -19,15 +20,15 @@ import { PathParams } from '../types/endpoints';
19
20
  export interface CommandRequestHeaders extends RequestHeaders {
20
21
  }
21
22
  export interface CommandUrlParams extends Omit<UrlParams, 'path' | 'query'> {
22
- path?: PathParams;
23
+ path?: UrlPathParams;
23
24
  }
24
25
  /**
25
- * Command HTTP Request Interface
26
+ * Command Request Interface
26
27
  *
27
28
  * Extends RequestHeaders to provide type-safe access to command-related HTTP headers.
28
29
  * This interface includes only the essential command headers commonly used in HTTP requests.
29
30
  */
30
- export interface CommandRequest<C extends object = object> extends FetchRequestInit {
31
+ export interface CommandRequest<C extends object = object> extends RequiredBy<ParameterRequest, 'path'> {
31
32
  urlParams?: CommandUrlParams;
32
33
  headers?: CommandRequestHeaders;
33
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"commandRequest.d.ts","sourceRoot":"","sources":["../../src/command/commandRequest.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;CA4G5D;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACvD,SAAQ,gBAAgB;IACxB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;CACT"}
1
+ {"version":3,"file":"commandRequest.d.ts","sourceRoot":"","sources":["../../src/command/commandRequest.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,cAAc,EAAE,UAAU,EAC1B,SAAS,EACV,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;CA4G5D;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACvD,SAAQ,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC5C,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;CACT"}
@@ -1,5 +1,5 @@
1
1
  export * from './commandClient';
2
- export * from './commandHttpHeaders';
2
+ export * from './commandHeaders';
3
3
  export * from './commandRequest';
4
4
  export * from './commandResult';
5
5
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}