@cacheable/net 1.0.2 → 2.0.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/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Cacheable, CacheableOptions } from 'cacheable';
2
2
  import { HookifiedOptions, Hookified } from 'hookified';
3
- import { Response as Response$1, RequestInit } from 'undici';
3
+ import { RequestInit, Response as Response$1 } from 'undici';
4
4
  export { RequestInit as FetchRequestInit } from 'undici';
5
5
 
6
6
  type FetchOptions = Omit<RequestInit, "cache"> & {
7
- cache: Cacheable;
7
+ cache?: Cacheable;
8
8
  /**
9
9
  * Enable HTTP cache semantics for intelligent response caching.
10
10
  *
@@ -27,17 +27,19 @@ type FetchOptions = Omit<RequestInit, "cache"> & {
27
27
  *
28
28
  * @default true
29
29
  */
30
- useHttpCache?: boolean;
30
+ httpCachePolicy?: boolean;
31
31
  };
32
32
  /**
33
33
  * Fetch data from a URL with optional request options.
34
34
  *
35
- * When `useHttpCache` is enabled (default), cache entries will have their TTL
35
+ * When `httpCachePolicy` is enabled (default), cache entries will have their TTL
36
36
  * set based on HTTP cache headers (e.g., Cache-Control: max-age). When disabled,
37
37
  * the default TTL from the Cacheable instance is used.
38
38
  *
39
+ * If no cache is provided, the request will be made without any caching.
40
+ *
39
41
  * @param {string} url The URL to fetch.
40
- * @param {FetchOptions} options Optional request options. The `cache` property is required.
42
+ * @param {FetchOptions} options Optional request options. If `cache` is not provided, no caching will be used.
41
43
  * @returns {Promise<UndiciResponse>} The response from the fetch.
42
44
  */
43
45
  declare function fetch(url: string, options: FetchOptions): Promise<Response$1>;
@@ -86,7 +88,39 @@ declare function del<T = unknown>(url: string, data?: unknown, options?: Omit<Fe
86
88
  declare function head(url: string, options: Omit<FetchOptions, "method">): Promise<Response$1>;
87
89
  type Response = Response$1;
88
90
 
91
+ type NetFetchOptions = {
92
+ /**
93
+ * Controls whether caching is enabled for this specific request.
94
+ * - `true`: Enable caching for this request
95
+ * - `false`: Disable caching for this request
96
+ * - `undefined`: Use default caching behavior based on the method (GET/HEAD are cached by default)
97
+ * @default undefined
98
+ */
99
+ caching?: boolean;
100
+ /**
101
+ * Custom function for converting JavaScript values to strings for this request.
102
+ * Overrides the instance-level stringify function if provided.
103
+ * @example
104
+ * // Use custom serialization for this request only
105
+ * stringify: (value) => superjson.stringify(value)
106
+ */
107
+ stringify?: StringifyType;
108
+ /**
109
+ * Custom function for parsing strings back to JavaScript values for this request.
110
+ * Overrides the instance-level parse function if provided.
111
+ * @example
112
+ * // Use custom parsing for this request only
113
+ * parse: (text) => superjson.parse(text)
114
+ */
115
+ parse?: ParseType;
116
+ } & Omit<FetchOptions, "method" | "cache">;
89
117
  type CacheableNetOptions = {
118
+ /**
119
+ * The cache instance or configuration options for caching responses.
120
+ * Can be either an existing Cacheable instance or options to create a new one.
121
+ * If not provided, a default Cacheable instance will be created.
122
+ * @default new Cacheable()
123
+ */
90
124
  cache?: Cacheable | CacheableOptions;
91
125
  /**
92
126
  * Enable HTTP cache semantics for intelligent response caching.
@@ -110,75 +144,153 @@ type CacheableNetOptions = {
110
144
  *
111
145
  * @default true
112
146
  */
113
- useHttpCache?: boolean;
147
+ httpCachePolicy?: boolean;
148
+ /**
149
+ * Custom function for converting JavaScript values to strings.
150
+ * This is used when serializing request bodies for POST, PUT, PATCH, and DELETE methods.
151
+ * Useful for handling complex data types that JSON.stringify doesn't support natively.
152
+ * @default JSON.stringify
153
+ * @example
154
+ * // Using superjson for enhanced serialization
155
+ * stringify: (value) => superjson.stringify(value)
156
+ */
157
+ stringify?: StringifyType;
158
+ /**
159
+ * Custom function for parsing strings back to JavaScript values.
160
+ * This is used when deserializing response bodies.
161
+ * Should be compatible with the stringify function for proper round-trip serialization.
162
+ * @default JSON.parse
163
+ * @example
164
+ * // Using superjson for enhanced parsing
165
+ * parse: (text) => superjson.parse(text)
166
+ */
167
+ parse?: ParseType;
114
168
  } & HookifiedOptions;
169
+ /**
170
+ * Function type for converting JavaScript values to strings.
171
+ * Used for serializing request bodies and data.
172
+ * @param value - The JavaScript value to stringify
173
+ * @returns The string representation of the value
174
+ */
175
+ type StringifyType = (value: unknown) => string;
176
+ /**
177
+ * Function type for parsing strings back to JavaScript values.
178
+ * Used for deserializing response bodies.
179
+ * @param value - The string to parse
180
+ * @returns The parsed JavaScript value
181
+ */
182
+ type ParseType = (value: string) => unknown;
115
183
  declare class CacheableNet extends Hookified {
116
184
  private _cache;
117
- private _useHttpCache;
185
+ private _httpCachePolicy;
186
+ private _stringify;
187
+ private _parse;
118
188
  constructor(options?: CacheableNetOptions);
189
+ /**
190
+ * Get the stringify function used for converting objects to strings.
191
+ * @returns {StringifyType} The current stringify function
192
+ */
193
+ get stringify(): StringifyType;
194
+ /**
195
+ * Set the stringify function for converting objects to strings.
196
+ * @param {StringifyType} value - The stringify function to use
197
+ */
198
+ set stringify(value: StringifyType);
199
+ /**
200
+ * Get the parse function used for converting strings to objects.
201
+ * @returns {ParseType} The current parse function
202
+ */
203
+ get parse(): ParseType;
204
+ /**
205
+ * Set the parse function for converting strings to objects.
206
+ * @param {ParseType} value - The parse function to use
207
+ */
208
+ set parse(value: ParseType);
209
+ /**
210
+ * Get the Cacheable instance used for caching fetch operations.
211
+ * @returns {Cacheable} The current Cacheable instance
212
+ */
119
213
  get cache(): Cacheable;
214
+ /**
215
+ * Set the Cacheable instance for caching fetch operations.
216
+ * @param {Cacheable} value - The Cacheable instance to use for caching
217
+ */
120
218
  set cache(value: Cacheable);
121
219
  /**
122
- * Get the current HTTP cache setting.
220
+ * Get the current HTTP cache policy setting.
123
221
  * @returns {boolean} Whether HTTP cache semantics are enabled
124
222
  */
125
- get useHttpCache(): boolean;
223
+ get httpCachePolicy(): boolean;
126
224
  /**
127
225
  * Set whether to use HTTP cache semantics.
128
226
  * @param {boolean} value - Enable or disable HTTP cache semantics
129
227
  */
130
- set useHttpCache(value: boolean);
228
+ set httpCachePolicy(value: boolean);
131
229
  /**
132
230
  * Fetch data from a URL with optional request options. Will use the cache that is already set in the instance.
133
231
  *
134
- * When `useHttpCache` is enabled (default), cache entries will have their TTL
232
+ * When `httpCachePolicy` is enabled (default), cache entries will have their TTL
135
233
  * set based on HTTP cache headers (e.g., Cache-Control: max-age). When disabled,
136
234
  * the default TTL from the Cacheable instance is used.
137
235
  *
138
236
  * @param {string} url The URL to fetch.
139
- * @param {FetchRequestInit} options Optional request options.
237
+ * @param {Omit<FetchOptions, "cache">} options Optional request options.
140
238
  * @returns {Promise<FetchResponse>} The response from the fetch.
141
239
  */
142
- fetch(url: string, options?: RequestInit): Promise<Response>;
240
+ fetch(url: string, options?: Omit<FetchOptions, "cache">): Promise<Response>;
143
241
  /**
144
- * Perform a GET request to a URL with optional request options. Will use the cache that is already set in the instance.
242
+ * Perform a GET request to a URL with optional request options. By default caching is enabled on all requests. To
243
+ * disable set `options.caching` to false.
145
244
  * @param {string} url The URL to fetch.
146
- * @param {Omit<FetchRequestInit, 'method'>} options Optional request options (method will be set to GET).
245
+ * @param {NetFetchOptions} options Optional request options (method will be set to GET).
147
246
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
148
247
  */
149
- get<T = unknown>(url: string, options?: Omit<RequestInit, "method">): Promise<DataResponse<T>>;
248
+ get<T = unknown>(url: string, options?: NetFetchOptions): Promise<DataResponse<T>>;
150
249
  /**
151
- * Perform a POST request to a URL with data and optional request options. Will use the cache that is already set in the instance.
250
+ * Perform a POST request to a URL with data and optional request options. By default caching is not enabled. To enable it
251
+ * set `options.caching` to true. Note, setting caching to tru means it will not post if the data is the same.
152
252
  * @param {string} url The URL to fetch.
153
253
  * @param {unknown} data The data to send in the request body.
154
- * @param {Omit<FetchRequestInit, 'method' | 'body'>} options Optional request options (method and body will be set).
254
+ * @param {Omit<NetFetchOptions, "method" | "body" >} options Optional request options (method and body will be set).
155
255
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
156
256
  */
157
- post<T = unknown>(url: string, data?: unknown, options?: Omit<RequestInit, "method" | "body">): Promise<DataResponse<T>>;
257
+ post<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
158
258
  /**
159
- * Perform a HEAD request to a URL with optional request options. Will use the cache that is already set in the instance.
259
+ * Perform a HEAD request to a URL with optional request options. By default caching is enabled on all requests. To
260
+ * disable set `options.caching` to false.
160
261
  * @param {string} url The URL to fetch.
161
- * @param {Omit<FetchRequestInit, 'method'>} options Optional request options (method will be set to HEAD).
262
+ * @param {NetFetchOptions} options Optional request options (method will be set to HEAD).
162
263
  * @returns {Promise<FetchResponse>} The response from the fetch (no body).
163
264
  */
164
- head(url: string, options?: Omit<RequestInit, "method">): Promise<Response>;
265
+ head(url: string, options?: NetFetchOptions): Promise<Response>;
266
+ /**
267
+ * Perform a PUT request to a URL with data and optional request options. By default caching is not enabled. To enable it
268
+ * set `options.caching` to true. Note, setting caching to true means it will not put if the data is the same.
269
+ * @param {string} url The URL to fetch.
270
+ * @param {unknown} data The data to send in the request body.
271
+ * @param {Omit<NetFetchOptions, 'method' | 'body'>} options Optional request options (method and body will be set).
272
+ * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
273
+ */
274
+ put<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
165
275
  /**
166
- * Perform a PATCH request to a URL with data and optional request options. Will use the cache that is already set in the instance.
276
+ * Perform a PATCH request to a URL with data and optional request options. By default caching is not enabled. To enable it
277
+ * set `options.caching` to true. Note, setting caching to true means it will not patch if the data is the same.
167
278
  * @param {string} url The URL to fetch.
168
279
  * @param {unknown} data The data to send in the request body.
169
- * @param {Omit<FetchRequestInit, 'method' | 'body'>} options Optional request options (method and body will be set).
280
+ * @param {Omit<NetFetchOptions, 'method' | 'body'>} options Optional request options (method and body will be set).
170
281
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
171
282
  */
172
- patch<T = unknown>(url: string, data?: unknown, options?: Omit<RequestInit, "method" | "body">): Promise<DataResponse<T>>;
283
+ patch<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
173
284
  /**
174
- * Perform a DELETE request to a URL with optional data and request options. Will use the cache that is already set in the instance.
285
+ * Perform a DELETE request to a URL with optional data and request options. By default caching is not enabled. To enable it
286
+ * set `options.caching` to true. Note, setting caching to true means it will not delete if the data is the same.
175
287
  * @param {string} url The URL to fetch.
176
288
  * @param {unknown} data Optional data to send in the request body.
177
- * @param {Omit<FetchRequestInit, 'method' | 'body'>} options Optional request options (method and body will be set).
289
+ * @param {Omit<NetFetchOptions, 'method' | 'body'>} options Optional request options (method and body will be set).
178
290
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
179
291
  */
180
- delete<T = unknown>(url: string, data?: unknown, options?: Omit<RequestInit, "method" | "body">): Promise<DataResponse<T>>;
292
+ delete<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
181
293
  }
182
294
  declare const Net: typeof CacheableNet;
183
295
 
184
- export { CacheableNet, type CacheableNetOptions, type DataResponse, type FetchOptions, type Response as FetchResponse, type GetResponse, Net, del, fetch, get, head, patch, post };
296
+ export { CacheableNet, type CacheableNetOptions, type DataResponse, type FetchOptions, type Response as FetchResponse, type GetResponse, Net, type NetFetchOptions, type ParseType, type StringifyType, del, fetch, get, head, patch, post };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Cacheable, CacheableOptions } from 'cacheable';
2
2
  import { HookifiedOptions, Hookified } from 'hookified';
3
- import { Response as Response$1, RequestInit } from 'undici';
3
+ import { RequestInit, Response as Response$1 } from 'undici';
4
4
  export { RequestInit as FetchRequestInit } from 'undici';
5
5
 
6
6
  type FetchOptions = Omit<RequestInit, "cache"> & {
7
- cache: Cacheable;
7
+ cache?: Cacheable;
8
8
  /**
9
9
  * Enable HTTP cache semantics for intelligent response caching.
10
10
  *
@@ -27,17 +27,19 @@ type FetchOptions = Omit<RequestInit, "cache"> & {
27
27
  *
28
28
  * @default true
29
29
  */
30
- useHttpCache?: boolean;
30
+ httpCachePolicy?: boolean;
31
31
  };
32
32
  /**
33
33
  * Fetch data from a URL with optional request options.
34
34
  *
35
- * When `useHttpCache` is enabled (default), cache entries will have their TTL
35
+ * When `httpCachePolicy` is enabled (default), cache entries will have their TTL
36
36
  * set based on HTTP cache headers (e.g., Cache-Control: max-age). When disabled,
37
37
  * the default TTL from the Cacheable instance is used.
38
38
  *
39
+ * If no cache is provided, the request will be made without any caching.
40
+ *
39
41
  * @param {string} url The URL to fetch.
40
- * @param {FetchOptions} options Optional request options. The `cache` property is required.
42
+ * @param {FetchOptions} options Optional request options. If `cache` is not provided, no caching will be used.
41
43
  * @returns {Promise<UndiciResponse>} The response from the fetch.
42
44
  */
43
45
  declare function fetch(url: string, options: FetchOptions): Promise<Response$1>;
@@ -86,7 +88,39 @@ declare function del<T = unknown>(url: string, data?: unknown, options?: Omit<Fe
86
88
  declare function head(url: string, options: Omit<FetchOptions, "method">): Promise<Response$1>;
87
89
  type Response = Response$1;
88
90
 
91
+ type NetFetchOptions = {
92
+ /**
93
+ * Controls whether caching is enabled for this specific request.
94
+ * - `true`: Enable caching for this request
95
+ * - `false`: Disable caching for this request
96
+ * - `undefined`: Use default caching behavior based on the method (GET/HEAD are cached by default)
97
+ * @default undefined
98
+ */
99
+ caching?: boolean;
100
+ /**
101
+ * Custom function for converting JavaScript values to strings for this request.
102
+ * Overrides the instance-level stringify function if provided.
103
+ * @example
104
+ * // Use custom serialization for this request only
105
+ * stringify: (value) => superjson.stringify(value)
106
+ */
107
+ stringify?: StringifyType;
108
+ /**
109
+ * Custom function for parsing strings back to JavaScript values for this request.
110
+ * Overrides the instance-level parse function if provided.
111
+ * @example
112
+ * // Use custom parsing for this request only
113
+ * parse: (text) => superjson.parse(text)
114
+ */
115
+ parse?: ParseType;
116
+ } & Omit<FetchOptions, "method" | "cache">;
89
117
  type CacheableNetOptions = {
118
+ /**
119
+ * The cache instance or configuration options for caching responses.
120
+ * Can be either an existing Cacheable instance or options to create a new one.
121
+ * If not provided, a default Cacheable instance will be created.
122
+ * @default new Cacheable()
123
+ */
90
124
  cache?: Cacheable | CacheableOptions;
91
125
  /**
92
126
  * Enable HTTP cache semantics for intelligent response caching.
@@ -110,75 +144,153 @@ type CacheableNetOptions = {
110
144
  *
111
145
  * @default true
112
146
  */
113
- useHttpCache?: boolean;
147
+ httpCachePolicy?: boolean;
148
+ /**
149
+ * Custom function for converting JavaScript values to strings.
150
+ * This is used when serializing request bodies for POST, PUT, PATCH, and DELETE methods.
151
+ * Useful for handling complex data types that JSON.stringify doesn't support natively.
152
+ * @default JSON.stringify
153
+ * @example
154
+ * // Using superjson for enhanced serialization
155
+ * stringify: (value) => superjson.stringify(value)
156
+ */
157
+ stringify?: StringifyType;
158
+ /**
159
+ * Custom function for parsing strings back to JavaScript values.
160
+ * This is used when deserializing response bodies.
161
+ * Should be compatible with the stringify function for proper round-trip serialization.
162
+ * @default JSON.parse
163
+ * @example
164
+ * // Using superjson for enhanced parsing
165
+ * parse: (text) => superjson.parse(text)
166
+ */
167
+ parse?: ParseType;
114
168
  } & HookifiedOptions;
169
+ /**
170
+ * Function type for converting JavaScript values to strings.
171
+ * Used for serializing request bodies and data.
172
+ * @param value - The JavaScript value to stringify
173
+ * @returns The string representation of the value
174
+ */
175
+ type StringifyType = (value: unknown) => string;
176
+ /**
177
+ * Function type for parsing strings back to JavaScript values.
178
+ * Used for deserializing response bodies.
179
+ * @param value - The string to parse
180
+ * @returns The parsed JavaScript value
181
+ */
182
+ type ParseType = (value: string) => unknown;
115
183
  declare class CacheableNet extends Hookified {
116
184
  private _cache;
117
- private _useHttpCache;
185
+ private _httpCachePolicy;
186
+ private _stringify;
187
+ private _parse;
118
188
  constructor(options?: CacheableNetOptions);
189
+ /**
190
+ * Get the stringify function used for converting objects to strings.
191
+ * @returns {StringifyType} The current stringify function
192
+ */
193
+ get stringify(): StringifyType;
194
+ /**
195
+ * Set the stringify function for converting objects to strings.
196
+ * @param {StringifyType} value - The stringify function to use
197
+ */
198
+ set stringify(value: StringifyType);
199
+ /**
200
+ * Get the parse function used for converting strings to objects.
201
+ * @returns {ParseType} The current parse function
202
+ */
203
+ get parse(): ParseType;
204
+ /**
205
+ * Set the parse function for converting strings to objects.
206
+ * @param {ParseType} value - The parse function to use
207
+ */
208
+ set parse(value: ParseType);
209
+ /**
210
+ * Get the Cacheable instance used for caching fetch operations.
211
+ * @returns {Cacheable} The current Cacheable instance
212
+ */
119
213
  get cache(): Cacheable;
214
+ /**
215
+ * Set the Cacheable instance for caching fetch operations.
216
+ * @param {Cacheable} value - The Cacheable instance to use for caching
217
+ */
120
218
  set cache(value: Cacheable);
121
219
  /**
122
- * Get the current HTTP cache setting.
220
+ * Get the current HTTP cache policy setting.
123
221
  * @returns {boolean} Whether HTTP cache semantics are enabled
124
222
  */
125
- get useHttpCache(): boolean;
223
+ get httpCachePolicy(): boolean;
126
224
  /**
127
225
  * Set whether to use HTTP cache semantics.
128
226
  * @param {boolean} value - Enable or disable HTTP cache semantics
129
227
  */
130
- set useHttpCache(value: boolean);
228
+ set httpCachePolicy(value: boolean);
131
229
  /**
132
230
  * Fetch data from a URL with optional request options. Will use the cache that is already set in the instance.
133
231
  *
134
- * When `useHttpCache` is enabled (default), cache entries will have their TTL
232
+ * When `httpCachePolicy` is enabled (default), cache entries will have their TTL
135
233
  * set based on HTTP cache headers (e.g., Cache-Control: max-age). When disabled,
136
234
  * the default TTL from the Cacheable instance is used.
137
235
  *
138
236
  * @param {string} url The URL to fetch.
139
- * @param {FetchRequestInit} options Optional request options.
237
+ * @param {Omit<FetchOptions, "cache">} options Optional request options.
140
238
  * @returns {Promise<FetchResponse>} The response from the fetch.
141
239
  */
142
- fetch(url: string, options?: RequestInit): Promise<Response>;
240
+ fetch(url: string, options?: Omit<FetchOptions, "cache">): Promise<Response>;
143
241
  /**
144
- * Perform a GET request to a URL with optional request options. Will use the cache that is already set in the instance.
242
+ * Perform a GET request to a URL with optional request options. By default caching is enabled on all requests. To
243
+ * disable set `options.caching` to false.
145
244
  * @param {string} url The URL to fetch.
146
- * @param {Omit<FetchRequestInit, 'method'>} options Optional request options (method will be set to GET).
245
+ * @param {NetFetchOptions} options Optional request options (method will be set to GET).
147
246
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
148
247
  */
149
- get<T = unknown>(url: string, options?: Omit<RequestInit, "method">): Promise<DataResponse<T>>;
248
+ get<T = unknown>(url: string, options?: NetFetchOptions): Promise<DataResponse<T>>;
150
249
  /**
151
- * Perform a POST request to a URL with data and optional request options. Will use the cache that is already set in the instance.
250
+ * Perform a POST request to a URL with data and optional request options. By default caching is not enabled. To enable it
251
+ * set `options.caching` to true. Note, setting caching to tru means it will not post if the data is the same.
152
252
  * @param {string} url The URL to fetch.
153
253
  * @param {unknown} data The data to send in the request body.
154
- * @param {Omit<FetchRequestInit, 'method' | 'body'>} options Optional request options (method and body will be set).
254
+ * @param {Omit<NetFetchOptions, "method" | "body" >} options Optional request options (method and body will be set).
155
255
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
156
256
  */
157
- post<T = unknown>(url: string, data?: unknown, options?: Omit<RequestInit, "method" | "body">): Promise<DataResponse<T>>;
257
+ post<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
158
258
  /**
159
- * Perform a HEAD request to a URL with optional request options. Will use the cache that is already set in the instance.
259
+ * Perform a HEAD request to a URL with optional request options. By default caching is enabled on all requests. To
260
+ * disable set `options.caching` to false.
160
261
  * @param {string} url The URL to fetch.
161
- * @param {Omit<FetchRequestInit, 'method'>} options Optional request options (method will be set to HEAD).
262
+ * @param {NetFetchOptions} options Optional request options (method will be set to HEAD).
162
263
  * @returns {Promise<FetchResponse>} The response from the fetch (no body).
163
264
  */
164
- head(url: string, options?: Omit<RequestInit, "method">): Promise<Response>;
265
+ head(url: string, options?: NetFetchOptions): Promise<Response>;
266
+ /**
267
+ * Perform a PUT request to a URL with data and optional request options. By default caching is not enabled. To enable it
268
+ * set `options.caching` to true. Note, setting caching to true means it will not put if the data is the same.
269
+ * @param {string} url The URL to fetch.
270
+ * @param {unknown} data The data to send in the request body.
271
+ * @param {Omit<NetFetchOptions, 'method' | 'body'>} options Optional request options (method and body will be set).
272
+ * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
273
+ */
274
+ put<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
165
275
  /**
166
- * Perform a PATCH request to a URL with data and optional request options. Will use the cache that is already set in the instance.
276
+ * Perform a PATCH request to a URL with data and optional request options. By default caching is not enabled. To enable it
277
+ * set `options.caching` to true. Note, setting caching to true means it will not patch if the data is the same.
167
278
  * @param {string} url The URL to fetch.
168
279
  * @param {unknown} data The data to send in the request body.
169
- * @param {Omit<FetchRequestInit, 'method' | 'body'>} options Optional request options (method and body will be set).
280
+ * @param {Omit<NetFetchOptions, 'method' | 'body'>} options Optional request options (method and body will be set).
170
281
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
171
282
  */
172
- patch<T = unknown>(url: string, data?: unknown, options?: Omit<RequestInit, "method" | "body">): Promise<DataResponse<T>>;
283
+ patch<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
173
284
  /**
174
- * Perform a DELETE request to a URL with optional data and request options. Will use the cache that is already set in the instance.
285
+ * Perform a DELETE request to a URL with optional data and request options. By default caching is not enabled. To enable it
286
+ * set `options.caching` to true. Note, setting caching to true means it will not delete if the data is the same.
175
287
  * @param {string} url The URL to fetch.
176
288
  * @param {unknown} data Optional data to send in the request body.
177
- * @param {Omit<FetchRequestInit, 'method' | 'body'>} options Optional request options (method and body will be set).
289
+ * @param {Omit<NetFetchOptions, 'method' | 'body'>} options Optional request options (method and body will be set).
178
290
  * @returns {Promise<DataResponse<T>>} The typed data and response from the fetch.
179
291
  */
180
- delete<T = unknown>(url: string, data?: unknown, options?: Omit<RequestInit, "method" | "body">): Promise<DataResponse<T>>;
292
+ delete<T = unknown>(url: string, data?: unknown, options?: Omit<NetFetchOptions, "method" | "body">): Promise<DataResponse<T>>;
181
293
  }
182
294
  declare const Net: typeof CacheableNet;
183
295
 
184
- export { CacheableNet, type CacheableNetOptions, type DataResponse, type FetchOptions, type Response as FetchResponse, type GetResponse, Net, del, fetch, get, head, patch, post };
296
+ export { CacheableNet, type CacheableNetOptions, type DataResponse, type FetchOptions, type Response as FetchResponse, type GetResponse, Net, type NetFetchOptions, type ParseType, type StringifyType, del, fetch, get, head, patch, post };