@zimic/fetch 1.2.6 → 1.2.7-canary.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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  </h1>
8
8
 
9
9
  <p align="center">
10
- Next-gen TypeScript-first fetch API client
10
+ Next-gen TypeScript-first Fetch client
11
11
  </p>
12
12
 
13
13
  <p align="center">
package/dist/index.d.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  import { HttpSchema, HttpSchemaMethod, HttpSchemaPath, HttpMethodSchema, HttpHeadersSchema, HttpHeadersInit, HttpRequestHeadersSchema, HttpSearchParamsSchema, HttpSearchParamsInit, HttpRequestSearchParamsSchema, HttpBody, HttpRequestSchema, HttpSearchParams, HttpFormData, HttpRequest, HttpRequestBodySchema, AllowAnyStringInPathParams, HttpMethod, HttpStatusCode, HttpResponseSchemaStatusCode, HttpResponse, HttpResponseBodySchema, HttpResponseHeadersSchema, HttpHeadersSerialized, LiteralHttpSchemaPathFromNonLiteral } from '@zimic/http';
2
2
 
3
- declare const value: unique symbol;
4
- /**
5
- * Represents a value stringified by `JSON.stringify`, maintaining a reference to the original type.
6
- *
7
- * This type is used to validate that the expected stringified body is passed to `fetch`.
8
- *
9
- * @see {@link https://zimic.dev/docs/fetch/guides/bodies#json-request-body Using a JSON request body}
10
- */
11
- type JSONStringified<Value> = string & {
12
- [value]: Value;
13
- };
3
+ type JSON = {
4
+ [key: string]: JSON;
5
+ } | JSON[] | string | number | boolean | null | undefined;
6
+ declare namespace JSON {
7
+ type Loose = Record<string, any> | Loose[] | string | number | boolean | null | undefined;
8
+ }
14
9
  declare global {
15
10
  interface JSON {
11
+ readonly value: unique symbol;
16
12
  stringify<Value>(value: Value, replacer?: ((this: any, key: string, value: Value) => any) | (number | string)[] | null, space?: string | number): JSONStringified<Value>;
13
+ parse<Value>(text: JSONStringified<Value>, reviver?: (this: any, key: string, value: any) => any): Value;
17
14
  }
18
15
  }
16
+ type JSONStringified<Value> = string & {
17
+ [JSON.value]: Value;
18
+ };
19
19
 
20
20
  type Default<Type, IfEmpty = never> = [undefined | void] extends [Type] ? IfEmpty : Exclude<Type, undefined | void>;
21
21
  type PossiblePromise<Type> = Type | PromiseLike<Type>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zimic/fetch",
3
- "description": "Next-gen TypeScript-first fetch API client",
3
+ "description": "Next-gen TypeScript-first Fetch client",
4
4
  "keywords": [
5
5
  "zimic",
6
6
  "fetch",
@@ -13,7 +13,7 @@
13
13
  "api",
14
14
  "static"
15
15
  ],
16
- "version": "1.2.6",
16
+ "version": "1.2.7-canary.1",
17
17
  "homepage": "https://zimic.dev/docs/fetch",
18
18
  "repository": {
19
19
  "type": "git",
@@ -26,9 +26,9 @@ import {
26
26
  HttpFormData,
27
27
  } from '@zimic/http';
28
28
  import { Default } from '@zimic/utils/types';
29
+ import { JSONStringified } from '@zimic/utils/types/json';
29
30
 
30
31
  import FetchResponseError, { AnyFetchRequestError } from '../errors/FetchResponseError';
31
- import { JSONStringified } from './json';
32
32
  import { FetchInput } from './public';
33
33
 
34
34
  type FetchRequestInitWithHeaders<HeadersSchema extends HttpHeadersSchema | undefined> = [HeadersSchema] extends [never]
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { JSONStringified } from './client/types/json';
1
+ export type { JSONStringified } from '@zimic/utils/types/json';
2
2
 
3
3
  export type { Fetch, InferFetchSchema, FetchOptions, FetchDefaults, FetchInput } from './client/types/public';
4
4
 
@@ -1,22 +0,0 @@
1
- declare const value: unique symbol;
2
-
3
- /**
4
- * Represents a value stringified by `JSON.stringify`, maintaining a reference to the original type.
5
- *
6
- * This type is used to validate that the expected stringified body is passed to `fetch`.
7
- *
8
- * @see {@link https://zimic.dev/docs/fetch/guides/bodies#json-request-body Using a JSON request body}
9
- */
10
- export type JSONStringified<Value> = string & { [value]: Value };
11
-
12
- declare global {
13
- interface JSON {
14
- // eslint-disable-next-line @typescript-eslint/method-signature-style
15
- stringify<Value>(
16
- value: Value,
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- replacer?: ((this: any, key: string, value: Value) => any) | (number | string)[] | null,
19
- space?: string | number,
20
- ): JSONStringified<Value>;
21
- }
22
- }