@autometa/http 1.4.6 → 1.4.8
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 +23 -0
- package/dist/esm/index.js +52 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +52 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/http-request.ts +29 -5
- package/src/http.spec.ts +21 -1
- package/src/http.ts +28 -7
- package/src/request-meta.config.ts +4 -2
package/src/http.ts
CHANGED
|
@@ -145,7 +145,7 @@ export class HTTP {
|
|
|
145
145
|
> = new HTTPRequestBuilder(),
|
|
146
146
|
metaConfig: MetaConfigBuilder = new MetaConfigBuilder()
|
|
147
147
|
) {
|
|
148
|
-
this.#request = builder
|
|
148
|
+
this.#request = builder;
|
|
149
149
|
this.#metaConfig = metaConfig.derive();
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -156,7 +156,8 @@ export class HTTP {
|
|
|
156
156
|
> = new HTTPRequestBuilder(),
|
|
157
157
|
metaConfig: MetaConfigBuilder = new MetaConfigBuilder()
|
|
158
158
|
) {
|
|
159
|
-
|
|
159
|
+
const derived = new HTTP(client, builder, metaConfig);
|
|
160
|
+
return derived;
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
/**
|
|
@@ -300,7 +301,11 @@ export class HTTP {
|
|
|
300
301
|
*/
|
|
301
302
|
route(...route: (string | number | boolean)[]) {
|
|
302
303
|
const mapped = route.map((r) => String(r));
|
|
303
|
-
return HTTP.create(
|
|
304
|
+
return HTTP.create(
|
|
305
|
+
this.client,
|
|
306
|
+
this.#request.derive().route(...mapped),
|
|
307
|
+
this.#metaConfig.derive()
|
|
308
|
+
);
|
|
304
309
|
}
|
|
305
310
|
|
|
306
311
|
/**
|
|
@@ -540,7 +545,11 @@ export class HTTP {
|
|
|
540
545
|
param(name: string, ...value: (string | number | boolean)[]): HTTP;
|
|
541
546
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
542
547
|
param(name: string, value: any) {
|
|
543
|
-
return HTTP.create(
|
|
548
|
+
return HTTP.create(
|
|
549
|
+
this.client,
|
|
550
|
+
this.#request.derive().param(name, value),
|
|
551
|
+
this.#metaConfig.derive()
|
|
552
|
+
);
|
|
544
553
|
}
|
|
545
554
|
|
|
546
555
|
/**
|
|
@@ -564,7 +573,11 @@ export class HTTP {
|
|
|
564
573
|
*/
|
|
565
574
|
params(dict: Record<string, string>) {
|
|
566
575
|
this.#request.params(dict);
|
|
567
|
-
return HTTP.create(
|
|
576
|
+
return HTTP.create(
|
|
577
|
+
this.client,
|
|
578
|
+
this.#request.derive().params(dict),
|
|
579
|
+
this.#metaConfig.derive()
|
|
580
|
+
);
|
|
568
581
|
}
|
|
569
582
|
|
|
570
583
|
/**
|
|
@@ -624,7 +637,11 @@ export class HTTP {
|
|
|
624
637
|
| (() => string | number | boolean | null)
|
|
625
638
|
| (() => Promise<string | number | boolean | null>)
|
|
626
639
|
) {
|
|
627
|
-
return HTTP.create(
|
|
640
|
+
return HTTP.create(
|
|
641
|
+
this.client,
|
|
642
|
+
this.#request.derive().header(name, value),
|
|
643
|
+
this.#metaConfig.derive()
|
|
644
|
+
);
|
|
628
645
|
}
|
|
629
646
|
|
|
630
647
|
/**
|
|
@@ -640,7 +657,11 @@ export class HTTP {
|
|
|
640
657
|
*/
|
|
641
658
|
data<T>(data: T) {
|
|
642
659
|
this.#request.data(data);
|
|
643
|
-
return HTTP.create(
|
|
660
|
+
return HTTP.create(
|
|
661
|
+
this.client,
|
|
662
|
+
this.#request.derive().data(data),
|
|
663
|
+
this.#metaConfig.derive()
|
|
664
|
+
);
|
|
644
665
|
}
|
|
645
666
|
|
|
646
667
|
/**
|
|
@@ -52,6 +52,8 @@ export class MetaConfigBuilder {
|
|
|
52
52
|
args.forEach((arg) => {
|
|
53
53
|
if (typeof arg === "number") {
|
|
54
54
|
this.#schemaMap.registerStatus(parser, arg);
|
|
55
|
+
} else if (Array.isArray(arg)) {
|
|
56
|
+
this.#schemaMap.registerStatus(parser, ...arg);
|
|
55
57
|
} else {
|
|
56
58
|
this.#schemaMap.registerRange(parser, arg.from, arg.to);
|
|
57
59
|
}
|
|
@@ -76,7 +78,7 @@ export class MetaConfigBuilder {
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
#setOnSend(hooks: [string, RequestHook][]) {
|
|
79
|
-
this.#onBeforeSend = hooks;
|
|
81
|
+
this.#onBeforeSend = [...hooks];
|
|
80
82
|
return this;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -91,7 +93,7 @@ export class MetaConfigBuilder {
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
#setOnReceive(hooks: [string, ResponseHook<unknown>][]) {
|
|
94
|
-
this.#onAfterSend = hooks;
|
|
96
|
+
this.#onAfterSend = [...hooks];
|
|
95
97
|
return this;
|
|
96
98
|
}
|
|
97
99
|
|