@autometa/http 1.3.0 → 1.4.1
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/CHANGELOG.md +22 -0
- package/dist/esm/index.js +10 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +23 -7
- package/dist/index.d.ts +23 -7
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/http-request.spec.ts +98 -67
- package/src/http-request.ts +14 -7
- package/src/http-response.ts +3 -3
- package/src/http.ts +14 -2
- package/src/request.config.ts +17 -2
package/src/http.ts
CHANGED
|
@@ -605,13 +605,25 @@ export class HTTP {
|
|
|
605
605
|
| number
|
|
606
606
|
| boolean
|
|
607
607
|
| null
|
|
608
|
+
| (string | number | boolean)[]
|
|
608
609
|
| (() => string | number | boolean | null)
|
|
610
|
+
| (() => Promise<string | number | boolean | null>)
|
|
609
611
|
) {
|
|
610
612
|
this.#request.header(name, value);
|
|
611
613
|
return this;
|
|
612
614
|
}
|
|
613
615
|
|
|
614
|
-
header(
|
|
616
|
+
header(
|
|
617
|
+
name: string,
|
|
618
|
+
value:
|
|
619
|
+
| string
|
|
620
|
+
| number
|
|
621
|
+
| boolean
|
|
622
|
+
| null
|
|
623
|
+
| (string | number | boolean)[]
|
|
624
|
+
| (() => string | number | boolean | null)
|
|
625
|
+
| (() => Promise<string | number | boolean | null>)
|
|
626
|
+
) {
|
|
615
627
|
return HTTP.create(this.client, this.#request.derive().header(name, value));
|
|
616
628
|
}
|
|
617
629
|
|
|
@@ -812,7 +824,7 @@ export class HTTP {
|
|
|
812
824
|
builder: HTTPRequestBuilder<HTTPRequest<unknown>>,
|
|
813
825
|
options?: HTTPAdditionalOptions<unknown>
|
|
814
826
|
) {
|
|
815
|
-
const request = builder.resolveDynamicHeaders().build();
|
|
827
|
+
const request = (await builder.resolveDynamicHeaders()).build();
|
|
816
828
|
const meta = this.#metaConfig.derive().build();
|
|
817
829
|
await this.runOnSendHooks(meta, request);
|
|
818
830
|
const result = await this.client.request<unknown, string>(request, options);
|
package/src/request.config.ts
CHANGED
|
@@ -6,8 +6,23 @@ export interface RequestBaseConfig {
|
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
route?: string[];
|
|
8
8
|
method: HTTPMethod;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Returns the full URL of the request, including the base url,
|
|
11
|
+
* routes, and query parameters.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* console.log(request.fullUrl())// https://example.com/foo?bar=baz?array=1,2,3
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Note characters may be converted to escape codes. I.e (space => %20) and (comma => %2C)
|
|
18
|
+
*
|
|
19
|
+
* N.B this method estimates what the url will be. The actual value
|
|
20
|
+
* might be different depending on your underlying HTTPClient and
|
|
21
|
+
* configuration. For example, query parameters might
|
|
22
|
+
* use different array formats.
|
|
23
|
+
* @returns The full url of the request
|
|
24
|
+
*/
|
|
25
|
+
get fullUrl(): string;
|
|
11
26
|
}
|
|
12
27
|
|
|
13
28
|
export interface RequestData<T = unknown> {
|