@ahoo-wang/fetcher-decorator 0.9.0 → 0.9.2
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/apiDecorator.d.ts +6 -6
- package/dist/apiDecorator.d.ts.map +1 -1
- package/dist/endpointDecorator.d.ts +6 -6
- package/dist/endpointDecorator.d.ts.map +1 -1
- package/dist/generated.d.ts +2 -7
- package/dist/generated.d.ts.map +1 -1
- package/dist/index.es.js +8 -8
- package/dist/parameterDecorator.d.ts +18 -18
- package/dist/reflection.d.ts +2 -2
- package/dist/requestExecutor.d.ts +15 -15
- package/package.json +2 -2
package/dist/apiDecorator.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { RequestHeaders, RequestHeadersCapable, TimeoutCapable } from '@ahoo-wang/fetcher';
|
|
2
2
|
/**
|
|
3
|
-
* Metadata for class-level API configuration
|
|
3
|
+
* Metadata for class-level API configuration.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Defines the configuration options that can be applied to an entire API class.
|
|
6
6
|
* These settings will be used as defaults for all endpoints within the class unless overridden
|
|
7
7
|
* at the method level.
|
|
8
8
|
*/
|
|
9
9
|
export interface ApiMetadata extends TimeoutCapable, RequestHeadersCapable {
|
|
10
10
|
/**
|
|
11
|
-
* Base path for all endpoints in the class
|
|
11
|
+
* Base path for all endpoints in the class.
|
|
12
12
|
*
|
|
13
13
|
* This path will be prepended to all endpoint paths defined in the class.
|
|
14
14
|
* For example, if basePath is '/api/v1' and an endpoint has path '/users',
|
|
@@ -16,21 +16,21 @@ export interface ApiMetadata extends TimeoutCapable, RequestHeadersCapable {
|
|
|
16
16
|
*/
|
|
17
17
|
basePath?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Default headers for all requests in the class
|
|
19
|
+
* Default headers for all requests in the class.
|
|
20
20
|
*
|
|
21
21
|
* These headers will be included in every request made by methods in this class.
|
|
22
22
|
* They can be overridden or extended at the method level.
|
|
23
23
|
*/
|
|
24
24
|
headers?: RequestHeaders;
|
|
25
25
|
/**
|
|
26
|
-
* Default timeout for all requests in the class (in milliseconds)
|
|
26
|
+
* Default timeout for all requests in the class (in milliseconds).
|
|
27
27
|
*
|
|
28
28
|
* This timeout value will be applied to all requests made by methods in this class.
|
|
29
29
|
* Individual methods can specify their own timeout values to override this default.
|
|
30
30
|
*/
|
|
31
31
|
timeout?: number;
|
|
32
32
|
/**
|
|
33
|
-
* Name of the fetcher instance to use, default: 'default'
|
|
33
|
+
* Name of the fetcher instance to use, default: 'default'.
|
|
34
34
|
*
|
|
35
35
|
* This allows you to specify which fetcher instance should be used for requests
|
|
36
36
|
* from this API class. The fetcher must be registered with the FetcherRegistrar.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiDecorator.d.ts","sourceRoot":"","sources":["../src/apiDecorator.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"apiDecorator.d.ts","sourceRoot":"","sources":["../src/apiDecorator.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAI5B,OAAO,kBAAkB,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,WAAW,WAAY,SAAQ,cAAc,EAAE,qBAAqB;IACxE;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,gBAAgB,eAAyB,CAAC;AAwDvD,wBAAgB,GAAG,CACjB,QAAQ,GAAE,MAAW,EACrB,QAAQ,GAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAM,IAE3B,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,aAAa,CAAC,KAAG,CAAC,CAgB3E"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { HttpMethod } from '@ahoo-wang/fetcher';
|
|
2
2
|
import { ApiMetadata } from './apiDecorator';
|
|
3
3
|
/**
|
|
4
|
-
* Metadata for HTTP endpoints
|
|
4
|
+
* Metadata for HTTP endpoints.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Defines the configuration options for individual HTTP endpoints (methods).
|
|
7
7
|
* These settings will override any corresponding class-level settings from ApiMetadata.
|
|
8
8
|
*/
|
|
9
9
|
export interface EndpointMetadata extends ApiMetadata {
|
|
10
10
|
/**
|
|
11
|
-
* HTTP method for the endpoint
|
|
11
|
+
* HTTP method for the endpoint.
|
|
12
12
|
*
|
|
13
13
|
* Specifies the HTTP verb to be used for this endpoint (GET, POST, PUT, DELETE, etc.)
|
|
14
14
|
*/
|
|
15
15
|
method: HttpMethod;
|
|
16
16
|
/**
|
|
17
|
-
* Path for the endpoint (relative to class base path)
|
|
17
|
+
* Path for the endpoint (relative to class base path).
|
|
18
18
|
*
|
|
19
19
|
* This path will be appended to the class's base path to form the complete URL.
|
|
20
20
|
* Path parameters can be specified using curly braces, e.g., '/users/{id}'
|
|
@@ -24,9 +24,9 @@ export interface EndpointMetadata extends ApiMetadata {
|
|
|
24
24
|
export declare const ENDPOINT_METADATA_KEY: unique symbol;
|
|
25
25
|
export type MethodEndpointMetadata = Omit<EndpointMetadata, 'method' | 'path'>;
|
|
26
26
|
/**
|
|
27
|
-
* Decorator factory for defining HTTP endpoints
|
|
27
|
+
* Decorator factory for defining HTTP endpoints.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
29
|
+
* Creates a decorator that can be used to define HTTP endpoints
|
|
30
30
|
* on class methods. It stores metadata about the endpoint that will be used
|
|
31
31
|
* to generate the actual HTTP request.
|
|
32
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointDecorator.d.ts","sourceRoot":"","sources":["../src/endpointDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD;;;;OAIG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,qBAAqB,eAA8B,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE,MAAW,EACjB,QAAQ,GAAE,sBAA2B,
|
|
1
|
+
{"version":3,"file":"endpointDecorator.d.ts","sourceRoot":"","sources":["../src/endpointDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD;;;;OAIG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,qBAAqB,eAA8B,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE,MAAW,EACjB,QAAQ,GAAE,sBAA2B,IAEpB,QAAQ,MAAM,EAAE,aAAa,MAAM,GAAG,MAAM,KAAG,IAAI,CAcrE;AAED,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,sBAA2B,YAhBjD,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CAkBrE;AAED,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,sBAA2B,YApBlD,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CAsBrE;AAED,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,sBAA2B,YAxBjD,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CA0BrE;AAED,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,sBAA2B,YA5BjD,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CA8BrE;AAED,wBAAgB,KAAK,CACnB,IAAI,GAAE,MAAW,EACjB,QAAQ,GAAE,sBAA2B,YAlCZ,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CAqCrE;AAED,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,sBAA2B,YAvClD,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CAyCrE;AAED,wBAAgB,OAAO,CACrB,IAAI,GAAE,MAAW,EACjB,QAAQ,GAAE,sBAA2B,YA7CZ,MAAM,eAAe,MAAM,GAAG,MAAM,KAAG,IAAI,CAgDrE"}
|
package/dist/generated.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* a method implementation will be automatically generated.
|
|
2
|
+
* Custom error class that indicates a method implementation will be automatically generated.
|
|
4
3
|
*
|
|
5
4
|
* @example
|
|
6
5
|
* ```
|
|
@@ -10,17 +9,13 @@
|
|
|
10
9
|
* }
|
|
11
10
|
* ```
|
|
12
11
|
*/
|
|
13
|
-
/**
|
|
14
|
-
* AutoGenerated is a custom error class that indicates
|
|
15
|
-
* a method implementation will be automatically generated.
|
|
16
|
-
*/
|
|
17
12
|
export declare class AutoGenerated extends Error {
|
|
18
13
|
constructor();
|
|
19
14
|
}
|
|
20
15
|
/**
|
|
21
16
|
* Factory function to create an AutoGenerated instance.
|
|
22
17
|
*
|
|
23
|
-
* @returns
|
|
18
|
+
* @returns A new AutoGenerated instance
|
|
24
19
|
*/
|
|
25
20
|
export declare const autoGeneratedError: () => AutoGenerated;
|
|
26
21
|
//# sourceMappingURL=generated.d.ts.map
|
package/dist/generated.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../src/generated.ts"],"names":[],"mappings":"AAaA
|
|
1
|
+
{"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../src/generated.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,KAAK;;CAKvC;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,aAErC,CAAC"}
|
package/dist/index.es.js
CHANGED
|
@@ -976,7 +976,7 @@ function bt() {
|
|
|
976
976
|
}
|
|
977
977
|
class it {
|
|
978
978
|
/**
|
|
979
|
-
* Creates a new FunctionMetadata instance
|
|
979
|
+
* Creates a new FunctionMetadata instance.
|
|
980
980
|
*
|
|
981
981
|
* @param name - The name of the function
|
|
982
982
|
* @param api - API-level metadata
|
|
@@ -987,7 +987,7 @@ class it {
|
|
|
987
987
|
this.name = i, this.api = c, this.endpoint = d, this.parameters = v;
|
|
988
988
|
}
|
|
989
989
|
/**
|
|
990
|
-
* Gets the fetcher instance to use for this function
|
|
990
|
+
* Gets the fetcher instance to use for this function.
|
|
991
991
|
*
|
|
992
992
|
* Returns the fetcher specified in the endpoint metadata, or the API metadata,
|
|
993
993
|
* or falls back to the default fetcher if none is specified.
|
|
@@ -999,7 +999,7 @@ class it {
|
|
|
999
999
|
return Ve.requiredGet(i);
|
|
1000
1000
|
}
|
|
1001
1001
|
/**
|
|
1002
|
-
* Resolves the request configuration from the method arguments
|
|
1002
|
+
* Resolves the request configuration from the method arguments.
|
|
1003
1003
|
*
|
|
1004
1004
|
* This method processes the runtime arguments according to the parameter metadata
|
|
1005
1005
|
* and constructs a FetcherRequest object with path parameters, query parameters,
|
|
@@ -1101,7 +1101,7 @@ class it {
|
|
|
1101
1101
|
i.name && c !== void 0 && (d[i.name] = String(c));
|
|
1102
1102
|
}
|
|
1103
1103
|
/**
|
|
1104
|
-
* Processes a request parameter value
|
|
1104
|
+
* Processes a request parameter value.
|
|
1105
1105
|
*
|
|
1106
1106
|
* This method handles the @request() decorator parameter by casting
|
|
1107
1107
|
* the provided value to a FetcherRequest. The @request() decorator
|
|
@@ -1128,7 +1128,7 @@ class it {
|
|
|
1128
1128
|
return i;
|
|
1129
1129
|
}
|
|
1130
1130
|
/**
|
|
1131
|
-
* Resolves the full path for the request
|
|
1131
|
+
* Resolves the full path for the request.
|
|
1132
1132
|
*
|
|
1133
1133
|
* Combines the base path from API metadata with the endpoint path
|
|
1134
1134
|
* from endpoint metadata to create the complete path.
|
|
@@ -1140,7 +1140,7 @@ class it {
|
|
|
1140
1140
|
return Le(i, c);
|
|
1141
1141
|
}
|
|
1142
1142
|
/**
|
|
1143
|
-
* Resolves the timeout for the request
|
|
1143
|
+
* Resolves the timeout for the request.
|
|
1144
1144
|
*
|
|
1145
1145
|
* Returns the timeout specified in the endpoint metadata, or the API metadata,
|
|
1146
1146
|
* or undefined if no timeout is specified.
|
|
@@ -1153,7 +1153,7 @@ class it {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
class ot {
|
|
1155
1155
|
/**
|
|
1156
|
-
* Creates a new RequestExecutor instance
|
|
1156
|
+
* Creates a new RequestExecutor instance.
|
|
1157
1157
|
*
|
|
1158
1158
|
* @param metadata - The function metadata containing all request information
|
|
1159
1159
|
*/
|
|
@@ -1161,7 +1161,7 @@ class ot {
|
|
|
1161
1161
|
this.metadata = i;
|
|
1162
1162
|
}
|
|
1163
1163
|
/**
|
|
1164
|
-
* Executes the HTTP request
|
|
1164
|
+
* Executes the HTTP request.
|
|
1165
1165
|
*
|
|
1166
1166
|
* This method resolves the path and request configuration from the metadata
|
|
1167
1167
|
* and arguments, then executes the request using the configured fetcher.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Parameter types for decorator parameters
|
|
2
|
+
* Parameter types for decorator parameters.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Defines the different types of parameters that can be used
|
|
5
5
|
* in API method decorators to specify how arguments should be handled
|
|
6
6
|
* in the HTTP request.
|
|
7
7
|
*/
|
|
8
8
|
export declare enum ParameterType {
|
|
9
9
|
/**
|
|
10
|
-
* Path parameter that will be inserted into the URL path
|
|
10
|
+
* Path parameter that will be inserted into the URL path.
|
|
11
11
|
*
|
|
12
12
|
* Path parameters are used to specify dynamic parts of the URL path.
|
|
13
13
|
* They are defined using curly braces in the endpoint path.
|
|
@@ -20,7 +20,7 @@ export declare enum ParameterType {
|
|
|
20
20
|
*/
|
|
21
21
|
PATH = "path",
|
|
22
22
|
/**
|
|
23
|
-
* Query parameter that will be appended to the URL query string
|
|
23
|
+
* Query parameter that will be appended to the URL query string.
|
|
24
24
|
*
|
|
25
25
|
* Query parameters are used to pass non-hierarchical data to the server.
|
|
26
26
|
* They appear after the '?' in the URL.
|
|
@@ -33,7 +33,7 @@ export declare enum ParameterType {
|
|
|
33
33
|
*/
|
|
34
34
|
QUERY = "query",
|
|
35
35
|
/**
|
|
36
|
-
* Header parameter that will be added to the request headers
|
|
36
|
+
* Header parameter that will be added to the request headers.
|
|
37
37
|
*
|
|
38
38
|
* Header parameters are used to pass metadata about the request,
|
|
39
39
|
* such as authentication tokens or content type information.
|
|
@@ -46,7 +46,7 @@ export declare enum ParameterType {
|
|
|
46
46
|
*/
|
|
47
47
|
HEADER = "header",
|
|
48
48
|
/**
|
|
49
|
-
* Body parameter that will be sent as the request body
|
|
49
|
+
* Body parameter that will be sent as the request body.
|
|
50
50
|
*
|
|
51
51
|
* The body parameter represents the main data payload of the request.
|
|
52
52
|
* It is typically used with POST, PUT, and PATCH requests.
|
|
@@ -64,20 +64,20 @@ export declare enum ParameterType {
|
|
|
64
64
|
REQUEST = "request"
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* Metadata for method parameters
|
|
67
|
+
* Metadata for method parameters.
|
|
68
68
|
*
|
|
69
|
-
*
|
|
69
|
+
* Defines the metadata stored for each parameter
|
|
70
70
|
* decorated with @path, @query, @header, or @body decorators.
|
|
71
71
|
*/
|
|
72
72
|
export interface ParameterMetadata {
|
|
73
73
|
/**
|
|
74
|
-
* Type of parameter (path, query, header, body)
|
|
74
|
+
* Type of parameter (path, query, header, body).
|
|
75
75
|
*
|
|
76
76
|
* Specifies how this parameter should be handled in the HTTP request.
|
|
77
77
|
*/
|
|
78
78
|
type: ParameterType;
|
|
79
79
|
/**
|
|
80
|
-
* Name of the parameter (used for path, query, and header parameters)
|
|
80
|
+
* Name of the parameter (used for path, query, and header parameters).
|
|
81
81
|
*
|
|
82
82
|
* For path and query parameters, this corresponds to the key in the URL.
|
|
83
83
|
* For header parameters, this corresponds to the header name.
|
|
@@ -85,7 +85,7 @@ export interface ParameterMetadata {
|
|
|
85
85
|
*/
|
|
86
86
|
name?: string;
|
|
87
87
|
/**
|
|
88
|
-
* Index of the parameter in the method signature
|
|
88
|
+
* Index of the parameter in the method signature.
|
|
89
89
|
*
|
|
90
90
|
* This is used to map the runtime argument values to the correct parameter metadata.
|
|
91
91
|
*/
|
|
@@ -93,9 +93,9 @@ export interface ParameterMetadata {
|
|
|
93
93
|
}
|
|
94
94
|
export declare const PARAMETER_METADATA_KEY: unique symbol;
|
|
95
95
|
/**
|
|
96
|
-
* Decorator factory for method parameters
|
|
96
|
+
* Decorator factory for method parameters.
|
|
97
97
|
*
|
|
98
|
-
*
|
|
98
|
+
* Creates a decorator that can be used to specify how a method parameter
|
|
99
99
|
* should be handled in the HTTP request. It stores metadata about the parameter
|
|
100
100
|
* that will be used during request execution.
|
|
101
101
|
* The name is optional - if not provided, it will be automatically extracted
|
|
@@ -118,7 +118,7 @@ export declare const PARAMETER_METADATA_KEY: unique symbol;
|
|
|
118
118
|
*/
|
|
119
119
|
export declare function parameter(type: ParameterType, name?: string): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
120
120
|
/**
|
|
121
|
-
* Path parameter decorator
|
|
121
|
+
* Path parameter decorator.
|
|
122
122
|
*
|
|
123
123
|
* Defines a path parameter that will be inserted into the URL path.
|
|
124
124
|
* The name is optional - if not provided, it will be automatically extracted
|
|
@@ -140,7 +140,7 @@ export declare function parameter(type: ParameterType, name?: string): (target:
|
|
|
140
140
|
*/
|
|
141
141
|
export declare function path(name?: string): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
142
142
|
/**
|
|
143
|
-
* Query parameter decorator
|
|
143
|
+
* Query parameter decorator.
|
|
144
144
|
*
|
|
145
145
|
* Defines a query parameter that will be appended to the URL query string.
|
|
146
146
|
* The name is optional - if not provided, it will be automatically extracted
|
|
@@ -162,7 +162,7 @@ export declare function path(name?: string): (target: object, propertyKey: strin
|
|
|
162
162
|
*/
|
|
163
163
|
export declare function query(name?: string): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
164
164
|
/**
|
|
165
|
-
* Header parameter decorator
|
|
165
|
+
* Header parameter decorator.
|
|
166
166
|
*
|
|
167
167
|
* Defines a header parameter that will be added to the request headers.
|
|
168
168
|
* The name is optional - if not provided, it will be automatically extracted
|
|
@@ -184,7 +184,7 @@ export declare function query(name?: string): (target: object, propertyKey: stri
|
|
|
184
184
|
*/
|
|
185
185
|
export declare function header(name?: string): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
186
186
|
/**
|
|
187
|
-
* Body parameter decorator
|
|
187
|
+
* Body parameter decorator.
|
|
188
188
|
*
|
|
189
189
|
* Defines a body parameter that will be sent as the request body.
|
|
190
190
|
* Note that body parameters don't have names since there's only one body per request.
|
|
@@ -199,7 +199,7 @@ export declare function header(name?: string): (target: object, propertyKey: str
|
|
|
199
199
|
*/
|
|
200
200
|
export declare function body(): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
201
201
|
/**
|
|
202
|
-
* Request parameter decorator
|
|
202
|
+
* Request parameter decorator.
|
|
203
203
|
*
|
|
204
204
|
* Defines a request parameter that will be used as the base request object.
|
|
205
205
|
* This allows you to pass a complete FetcherRequest object to customize
|
package/dist/reflection.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Extracts parameter names from a function
|
|
2
|
+
* Extracts parameter names from a function.
|
|
3
3
|
*
|
|
4
4
|
* This function parses the string representation of a function to extract
|
|
5
5
|
* the names of its parameters. It handles various function formats including
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function getParameterNames(func: (...args: any[]) => any): string[];
|
|
31
31
|
/**
|
|
32
|
-
* Helper function to automatically extract parameter name when not provided
|
|
32
|
+
* Helper function to automatically extract parameter name when not provided.
|
|
33
33
|
*
|
|
34
34
|
* @param target - The target object (class prototype)
|
|
35
35
|
* @param propertyKey - The method name
|
|
@@ -3,31 +3,31 @@ import { ApiMetadata } from './apiDecorator';
|
|
|
3
3
|
import { EndpointMetadata } from './endpointDecorator';
|
|
4
4
|
import { ParameterMetadata } from './parameterDecorator';
|
|
5
5
|
/**
|
|
6
|
-
* Metadata container for a function with HTTP endpoint decorators
|
|
6
|
+
* Metadata container for a function with HTTP endpoint decorators.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Encapsulates all the metadata needed to execute an HTTP request
|
|
9
9
|
* for a decorated method, including API-level defaults, endpoint-specific
|
|
10
10
|
* configuration, and parameter metadata.
|
|
11
11
|
*/
|
|
12
12
|
export declare class FunctionMetadata implements NamedCapable {
|
|
13
13
|
/**
|
|
14
|
-
* Name of the function
|
|
14
|
+
* Name of the function.
|
|
15
15
|
*/
|
|
16
16
|
name: string;
|
|
17
17
|
/**
|
|
18
|
-
* API-level metadata (class-level configuration)
|
|
18
|
+
* API-level metadata (class-level configuration).
|
|
19
19
|
*/
|
|
20
20
|
api: ApiMetadata;
|
|
21
21
|
/**
|
|
22
|
-
* Endpoint-level metadata (method-level configuration)
|
|
22
|
+
* Endpoint-level metadata (method-level configuration).
|
|
23
23
|
*/
|
|
24
24
|
endpoint: EndpointMetadata;
|
|
25
25
|
/**
|
|
26
|
-
* Parameter metadata for all decorated parameters
|
|
26
|
+
* Parameter metadata for all decorated parameters.
|
|
27
27
|
*/
|
|
28
28
|
parameters: ParameterMetadata[];
|
|
29
29
|
/**
|
|
30
|
-
* Creates a new FunctionMetadata instance
|
|
30
|
+
* Creates a new FunctionMetadata instance.
|
|
31
31
|
*
|
|
32
32
|
* @param name - The name of the function
|
|
33
33
|
* @param api - API-level metadata
|
|
@@ -36,7 +36,7 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
36
36
|
*/
|
|
37
37
|
constructor(name: string, api: ApiMetadata, endpoint: EndpointMetadata, parameters: ParameterMetadata[]);
|
|
38
38
|
/**
|
|
39
|
-
* Gets the fetcher instance to use for this function
|
|
39
|
+
* Gets the fetcher instance to use for this function.
|
|
40
40
|
*
|
|
41
41
|
* Returns the fetcher specified in the endpoint metadata, or the API metadata,
|
|
42
42
|
* or falls back to the default fetcher if none is specified.
|
|
@@ -45,7 +45,7 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
45
45
|
*/
|
|
46
46
|
get fetcher(): Fetcher;
|
|
47
47
|
/**
|
|
48
|
-
* Resolves the request configuration from the method arguments
|
|
48
|
+
* Resolves the request configuration from the method arguments.
|
|
49
49
|
*
|
|
50
50
|
* This method processes the runtime arguments according to the parameter metadata
|
|
51
51
|
* and constructs a FetcherRequest object with path parameters, query parameters,
|
|
@@ -95,7 +95,7 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
95
95
|
private processQueryParam;
|
|
96
96
|
private processHeaderParam;
|
|
97
97
|
/**
|
|
98
|
-
* Processes a request parameter value
|
|
98
|
+
* Processes a request parameter value.
|
|
99
99
|
*
|
|
100
100
|
* This method handles the @request() decorator parameter by casting
|
|
101
101
|
* the provided value to a FetcherRequest. The @request() decorator
|
|
@@ -120,7 +120,7 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
120
120
|
*/
|
|
121
121
|
private processRequestParam;
|
|
122
122
|
/**
|
|
123
|
-
* Resolves the full path for the request
|
|
123
|
+
* Resolves the full path for the request.
|
|
124
124
|
*
|
|
125
125
|
* Combines the base path from API metadata with the endpoint path
|
|
126
126
|
* from endpoint metadata to create the complete path.
|
|
@@ -129,7 +129,7 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
129
129
|
*/
|
|
130
130
|
resolvePath(): string;
|
|
131
131
|
/**
|
|
132
|
-
* Resolves the timeout for the request
|
|
132
|
+
* Resolves the timeout for the request.
|
|
133
133
|
*
|
|
134
134
|
* Returns the timeout specified in the endpoint metadata, or the API metadata,
|
|
135
135
|
* or undefined if no timeout is specified.
|
|
@@ -139,7 +139,7 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
139
139
|
resolveTimeout(): number | undefined;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Executor for HTTP requests based on decorated method metadata
|
|
142
|
+
* Executor for HTTP requests based on decorated method metadata.
|
|
143
143
|
*
|
|
144
144
|
* This class is responsible for executing HTTP requests based on the metadata
|
|
145
145
|
* collected from decorators. It resolves the path, constructs the request,
|
|
@@ -148,13 +148,13 @@ export declare class FunctionMetadata implements NamedCapable {
|
|
|
148
148
|
export declare class RequestExecutor {
|
|
149
149
|
private readonly metadata;
|
|
150
150
|
/**
|
|
151
|
-
* Creates a new RequestExecutor instance
|
|
151
|
+
* Creates a new RequestExecutor instance.
|
|
152
152
|
*
|
|
153
153
|
* @param metadata - The function metadata containing all request information
|
|
154
154
|
*/
|
|
155
155
|
constructor(metadata: FunctionMetadata);
|
|
156
156
|
/**
|
|
157
|
-
* Executes the HTTP request
|
|
157
|
+
* Executes the HTTP request.
|
|
158
158
|
*
|
|
159
159
|
* This method resolves the path and request configuration from the metadata
|
|
160
160
|
* and arguments, then executes the request using the configured fetcher.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-decorator",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "TypeScript decorators for clean API service definitions with Fetcher HTTP client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"reflect-metadata": "^0.2.2",
|
|
39
|
-
"@ahoo-wang/fetcher": "0.9.
|
|
39
|
+
"@ahoo-wang/fetcher": "0.9.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@vitest/coverage-v8": "^3.2.4",
|