lissa 1.0.4 → 1.0.5

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.
Files changed (2) hide show
  1. package/lib/index.d.ts +15 -8
  2. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -6,14 +6,21 @@ import { RequestInit, HeadersInit, BodyInit, Headers } from 'undici-types';
6
6
 
7
7
  export type JsonPrimitive = null | string | number | boolean;
8
8
 
9
- export type JsonObject = {
10
- [key: string]: Json;
11
- };
9
+ export type JsonObject = Record<string, Json>;
12
10
 
13
11
  export type JsonArray = Json[];
14
12
 
15
13
  export type Json = JsonPrimitive | JsonObject | JsonArray;
16
14
 
15
+
16
+ export type JsonStringifyablePrimitive = null | undefined | string | number | boolean;
17
+
18
+ export type JsonStringifyableObject = Record<string, JsonStringifyable>;
19
+
20
+ export type JsonStringifyableArray = JsonStringifyable[];
21
+
22
+ export type JsonStringifyable = JsonStringifyablePrimitive | JsonStringifyableObject | JsonStringifyableArray | { toJSON(): JsonStringifyable };
23
+
17
24
  /*
18
25
  * Param typing (like json but it supports dates if paramsSerializer is set to extended mode)
19
26
  */
@@ -49,7 +56,7 @@ export type LissaOptionsInit = Omit<RequestInit, 'method' | 'body'> & {
49
56
  timeout?: number;
50
57
  onUploadProgress?: (uploaded: number, total: number) => void;
51
58
  onDownloadProgress?: (downloaded: number, total: number) => void;
52
- body?: BodyInit | JsonObject;
59
+ body?: BodyInit | JsonStringifyableObject;
53
60
  };
54
61
 
55
62
  export type LissaOptions = Omit<LissaOptionsInit, 'headers'> & {
@@ -140,7 +147,7 @@ export declare class LissaRequest extends Promise<ResultValue> {
140
147
  *
141
148
  * The body gets json stringified if it is a plain object
142
149
  */
143
- body(body: BodyInit | JsonObject): LissaRequest;
150
+ body(body: BodyInit | JsonStringifyableObject): LissaRequest;
144
151
 
145
152
  /**
146
153
  * Set request timeout in milliseconds
@@ -207,7 +214,7 @@ interface MakeRequest {
207
214
  */
208
215
  post(
209
216
  url?: string,
210
- body?: BodyInit | JsonObject,
217
+ body?: BodyInit | JsonStringifyableObject,
211
218
  options?: Omit<LissaOptionsInit, 'method' | 'url' | 'body'>
212
219
  ): LissaRequest;
213
220
 
@@ -216,7 +223,7 @@ interface MakeRequest {
216
223
  */
217
224
  put(
218
225
  url?: string,
219
- body?: BodyInit | JsonObject,
226
+ body?: BodyInit | JsonStringifyableObject,
220
227
  options?: Omit<LissaOptionsInit, 'method' | 'url' | 'body'>
221
228
  ): LissaRequest;
222
229
 
@@ -225,7 +232,7 @@ interface MakeRequest {
225
232
  */
226
233
  patch(
227
234
  url?: string,
228
- body?: BodyInit | JsonObject,
235
+ body?: BodyInit | JsonStringifyableObject,
229
236
  options?: Omit<LissaOptionsInit, 'method' | 'url' | 'body'>
230
237
  ): LissaRequest;
231
238
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lissa",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A lightweight, extensible HTTP client for modern JavaScript applications with fluent api syntax, hooks, plugins and more.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",