@zap-studio/fetch 2.1.2 → 2.1.3
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 +7 -0
- package/dist/errors.d.ts +1 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +7 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
## 2.1.3
|
|
9
|
+
<sub>2026-09-13</sub>
|
|
10
|
+
|
|
11
|
+
- [#613](https://github.com/zap-studio/monorepo/pull/613) *(patch)* Thanks [@alexandretrotel](https://github.com/alexandretrotel)!
|
|
12
|
+
Widen internal peer dependency ranges from an exact pin to a caret range, so consumers no longer resolve a duplicate copy of the peer on version skew.
|
|
13
|
+
|
|
7
14
|
## [2.1.2]
|
|
8
15
|
|
|
9
16
|
### Fixed
|
package/dist/errors.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* }
|
|
23
23
|
* }
|
|
24
24
|
*/
|
|
25
|
-
declare class FetchError extends Error {
|
|
25
|
+
export declare class FetchError extends Error {
|
|
26
26
|
/**
|
|
27
27
|
* HTTP status code from the failing response.
|
|
28
28
|
*/
|
|
@@ -37,5 +37,4 @@ declare class FetchError extends Error {
|
|
|
37
37
|
constructor(message: string, response: Response);
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
-
export { FetchError };
|
|
41
40
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBAwBa,mBAAmB;;;;EAI9B,QAAQ;;;;EAIR,UAAU;;;;EAKV,YAAY,iBAAiB,UAAU"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { StandardSchemaV1 } from "@zap-studio/validation";
|
|
|
13
13
|
*
|
|
14
14
|
* console.log(GLOBAL_DEFAULTS.throwOnFetchError); // true
|
|
15
15
|
*/
|
|
16
|
-
declare const GLOBAL_DEFAULTS: FetchDefaults;
|
|
16
|
+
export declare const GLOBAL_DEFAULTS: FetchDefaults;
|
|
17
17
|
/**
|
|
18
18
|
* Type-safe fetch wrapper with Standard Schema validation.
|
|
19
19
|
*
|
|
@@ -60,13 +60,13 @@ declare const GLOBAL_DEFAULTS: FetchDefaults;
|
|
|
60
60
|
* console.log("Validated user:", result.value);
|
|
61
61
|
* }
|
|
62
62
|
*/
|
|
63
|
-
declare function $fetch<TSchema extends StandardSchemaV1>(input: FetchInput, schema: TSchema, options: ExtendedRequestInit & {
|
|
63
|
+
export declare function $fetch<TSchema extends StandardSchemaV1>(input: FetchInput, schema: TSchema, options: ExtendedRequestInit & {
|
|
64
64
|
throwOnValidationError: false;
|
|
65
65
|
}): Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
66
|
-
declare function $fetch<TSchema extends StandardSchemaV1>(input: FetchInput, schema: TSchema, options?: ExtendedRequestInit & {
|
|
66
|
+
export declare function $fetch<TSchema extends StandardSchemaV1>(input: FetchInput, schema: TSchema, options?: ExtendedRequestInit & {
|
|
67
67
|
throwOnValidationError?: true;
|
|
68
68
|
}): Promise<StandardSchemaV1.InferOutput<TSchema>>;
|
|
69
|
-
declare function $fetch(input: FetchInput, options?: ExtendedRequestInit): Promise<Response>;
|
|
69
|
+
export declare function $fetch(input: FetchInput, options?: ExtendedRequestInit): Promise<Response>;
|
|
70
70
|
/**
|
|
71
71
|
* Convenience methods for common HTTP verbs.
|
|
72
72
|
*
|
|
@@ -90,7 +90,7 @@ declare function $fetch(input: FetchInput, options?: ExtendedRequestInit): Promi
|
|
|
90
90
|
* return post; // post is typed as { id: number; title: string; content: string; }
|
|
91
91
|
* }
|
|
92
92
|
*/
|
|
93
|
-
declare const api: ApiMethods;
|
|
93
|
+
export declare const api: ApiMethods;
|
|
94
94
|
/**
|
|
95
95
|
* Creates a custom fetch instance with pre-configured defaults.
|
|
96
96
|
*
|
|
@@ -118,7 +118,7 @@ declare const api: ApiMethods;
|
|
|
118
118
|
* // Or use $fetch directly
|
|
119
119
|
* const response = await $fetch("/users", UserSchema, { method: "POST", json: { name: "John" } });
|
|
120
120
|
*/
|
|
121
|
-
declare const createFetch: (factoryOptions?: Partial<FetchDefaults>) => FetchInstance;
|
|
121
|
+
export declare const createFetch: (factoryOptions?: Partial<FetchDefaults>) => FetchInstance;
|
|
122
122
|
//#endregion
|
|
123
|
-
export { type $Fetch,
|
|
123
|
+
export { type $Fetch, type ApiMethods, type ExtendedRequestInit, type FetchDefaults, FetchError, type FetchInput, type FetchInstance, type NormalizedRequest };
|
|
124
124
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;qBA2Da,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsbR,OAAO,gBAAgB,kBAC3C,OAAO,YACP,QAAQ,SACR,SAAS;EAAwB;IAChC,QAAQ,iBAAiB,OAAO,iBAAiB,YAAY;wBAE1C,OAAO,gBAAgB,kBAC3C,OAAO,YACP,QAAQ,SACR,UAAU;EAAwB;IACjC,QAAQ,iBAAiB,YAAY;wBAElB,OAAO,OAAO,YAAY,UAAU,sBAAsB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;qBAqC3E,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCL,cAAe,iBAAgB,QAAQ,mBAAsB"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { isStandardSchema, standardValidate } from "@zap-studio/validation";
|
|
|
8
8
|
* `TracerProvider`; a no-op provider (the default until an app registers an
|
|
9
9
|
* SDK) makes every span/propagation call below a no-op too.
|
|
10
10
|
*/
|
|
11
|
-
const tracer = trace.getTracer("@zap-studio/fetch", "2.1.
|
|
11
|
+
const tracer = trace.getTracer("@zap-studio/fetch", "2.1.3");
|
|
12
12
|
/**
|
|
13
13
|
* `TextMapSetter` for the Web `Headers` API, used to inject `traceparent`
|
|
14
14
|
* (and any other registered propagator fields) into the outgoing request.
|
package/dist/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Logger } from "@zap-studio/logger";
|
|
|
8
8
|
* const input: FetchInput = "/users/1";
|
|
9
9
|
* const withUrl: FetchInput = new URL("https://api.example.com/users/1");
|
|
10
10
|
*/
|
|
11
|
-
type FetchInput = Parameters<typeof fetch>[0];
|
|
11
|
+
export type FetchInput = Parameters<typeof fetch>[0];
|
|
12
12
|
type URLSearchParamsInput = ConstructorParameters<typeof URLSearchParams>[0];
|
|
13
13
|
type RequestBodyInit = RequestInit & {
|
|
14
14
|
json?: never;
|
|
@@ -48,7 +48,7 @@ interface CustomRequestInit {
|
|
|
48
48
|
* throwOnFetchError: true,
|
|
49
49
|
* };
|
|
50
50
|
*/
|
|
51
|
-
type ExtendedRequestInit = (RequestBodyInit | JsonBodyInit) & CustomRequestInit;
|
|
51
|
+
export type ExtendedRequestInit = (RequestBodyInit | JsonBodyInit) & CustomRequestInit;
|
|
52
52
|
/**
|
|
53
53
|
* Internal defaults used by fetchInternal
|
|
54
54
|
*
|
|
@@ -59,7 +59,7 @@ type ExtendedRequestInit = (RequestBodyInit | JsonBodyInit) & CustomRequestInit;
|
|
|
59
59
|
* throwOnValidationError: true,
|
|
60
60
|
* };
|
|
61
61
|
*/
|
|
62
|
-
interface FetchDefaults {
|
|
62
|
+
export interface FetchDefaults {
|
|
63
63
|
/**
|
|
64
64
|
* Base URL to prepend to all requests
|
|
65
65
|
* @default ""
|
|
@@ -104,7 +104,7 @@ interface FetchDefaults {
|
|
|
104
104
|
* const fetchUser: $Fetch = $fetch;
|
|
105
105
|
* const user = await fetchUser("/users/1", UserSchema);
|
|
106
106
|
*/
|
|
107
|
-
interface $Fetch {
|
|
107
|
+
export interface $Fetch {
|
|
108
108
|
/**
|
|
109
109
|
* Fetch with schema validation and throwOnValidationError: false
|
|
110
110
|
* @param input - URL or path to fetch
|
|
@@ -164,7 +164,7 @@ interface $Fetch {
|
|
|
164
164
|
* options: {},
|
|
165
165
|
* };
|
|
166
166
|
*/
|
|
167
|
-
interface NormalizedRequest {
|
|
167
|
+
export interface NormalizedRequest {
|
|
168
168
|
/** Resolved string URL from the input (string or `URL`; `Request` uses `request.url`). */
|
|
169
169
|
url: string;
|
|
170
170
|
/** Original `Request` clone, present when the input was a `Request`. */
|
|
@@ -178,7 +178,7 @@ interface NormalizedRequest {
|
|
|
178
178
|
* @example
|
|
179
179
|
* const user = await api.get("/users/1", UserSchema);
|
|
180
180
|
*/
|
|
181
|
-
interface ApiMethods {
|
|
181
|
+
export interface ApiMethods {
|
|
182
182
|
/**
|
|
183
183
|
* DELETE method fetch function
|
|
184
184
|
*/
|
|
@@ -206,7 +206,7 @@ interface ApiMethods {
|
|
|
206
206
|
* @example
|
|
207
207
|
* const { $fetch, api } = createFetch({ baseURL: "https://api.example.com" });
|
|
208
208
|
*/
|
|
209
|
-
interface FetchInstance {
|
|
209
|
+
export interface FetchInstance {
|
|
210
210
|
/**
|
|
211
211
|
* Configured `$fetch` function.
|
|
212
212
|
*/
|
|
@@ -217,5 +217,4 @@ interface FetchInstance {
|
|
|
217
217
|
api: ApiMethods;
|
|
218
218
|
}
|
|
219
219
|
//#endregion
|
|
220
|
-
export { $Fetch, ApiMethods, ExtendedRequestInit, FetchDefaults, FetchInput, FetchInstance, NormalizedRequest };
|
|
221
220
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;YAgBY,aAAa,kBAAkB;KAEtC,uBAAuB,6BAA6B;KAEpD,kBAAkB;EACrB;;KAGG,eAAe,KAAK;;;;;EAKvB;EACA;;UAGQ;;;;;EAKR,eAAe;;;;;EAKf;;;;;EAKA;;;;;;;;;;;;YAaU,uBAAuB,kBAAkB,gBAAgB;;;;;;;;;;;iBAYpD;;;;;EAKf;;;;;EAKA,UAAU;;;;;EAKV,eAAe;;;;;EAKf;;;;;EAKA;;;;;;;;EAQA,SAAS;;;;;;;;;;;;iBAaM;;;;;;;;;;;;;;;;GAgBd,gBAAgB,kBACf,OAAO,YACP,QAAQ,SACR,SAAS;IAAwB;MAChC,QAAQ,iBAAiB,OAAO,iBAAiB,YAAY;;;;;;;;;;;;;;;;;GAkB/D,gBAAgB,kBACf,OAAO,YACP,QAAQ,SACR,UAAU;IACR;MAED,QAAQ,iBAAiB,YAAY;;;;;;;;;;;;GAavC,OAAO,YAAY,UAAU,sBAAsB,QAAQ;;;;;;;;;;;iBAY7C;;EAEf;;EAEA,UAAU;;EAEV,SAAS;;;;;;;;iBASM;;;;EAIf,QAAQ;;;;EAIR,KAAK;;;;EAIL,OAAO;;;;EAIP,MAAM;;;;EAIN,KAAK;;;;;;;;iBASU;;;;EAIf,QAAQ;;;;EAIR,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zap-studio/fetch",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A type-safe, tree-shakeable fetch wrapper for HTTP requests with runtime schema validation.",
|
|
6
6
|
"keywords": [
|
|
@@ -50,21 +50,21 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@opentelemetry/api": "^1.9.1",
|
|
53
|
-
"@opentelemetry/context-async-hooks": "^2.
|
|
54
|
-
"@opentelemetry/core": "^2.
|
|
55
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
53
|
+
"@opentelemetry/context-async-hooks": "^2.11.0",
|
|
54
|
+
"@opentelemetry/core": "^2.11.0",
|
|
55
|
+
"@opentelemetry/sdk-trace-base": "^2.11.0",
|
|
56
56
|
"@zap-studio/logger": "2.1.0",
|
|
57
57
|
"@zap-studio/typescript": "0.0.0",
|
|
58
58
|
"arktype": "^2.2.3",
|
|
59
|
-
"tsdown": "^0.
|
|
59
|
+
"tsdown": "^0.23.0",
|
|
60
60
|
"typescript": "^7.0.2",
|
|
61
|
-
"valibot": "^1.
|
|
62
|
-
"vitest": "^
|
|
63
|
-
"zod": "^4.
|
|
61
|
+
"valibot": "^1.5.0",
|
|
62
|
+
"vitest": "^5.0.0",
|
|
63
|
+
"zod": "^4.6.2"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@opentelemetry/api": "^1.9.1",
|
|
67
|
-
"@zap-studio/logger": "2.1.0"
|
|
67
|
+
"@zap-studio/logger": "^2.1.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@zap-studio/logger": {
|