@zimic/http 0.5.0 → 0.5.1-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/dist/index.d.ts CHANGED
@@ -162,70 +162,30 @@ type HttpFormDataSerialized<Type> = [Type] extends [never] ? never : Type extend
162
162
  [Key in keyof Type as IfNever<PrimitiveHttpFormDataSerialized<Type[Key]>, never, Key>]: PrimitiveHttpFormDataSerialized<Type[Key]>;
163
163
  } : never;
164
164
 
165
- /**
166
- * An extended HTTP form data object with a strictly-typed schema. Fully compatible with the built-in
167
- * {@link https://developer.mozilla.org/docs/Web/API/FormData `FormData`} class.
168
- *
169
- * **IMPORTANT**: the input of `HttpFormData` and all of its internal types must be declared inline or as a type aliases
170
- * (`type`). They cannot be interfaces.
171
- *
172
- * @example
173
- * import { HttpFormData } from '@zimic/http';
174
- *
175
- * const formData = new HttpFormData<{
176
- * files: File[];
177
- * description?: string;
178
- * }>();
179
- *
180
- * formData.append('file', new File(['content'], 'file.txt', { type: 'text/plain' }));
181
- * formData.append('description', 'My file');
182
- *
183
- * const files = formData.getAll('file');
184
- * console.log(files); // [File { name: 'file.txt', type: 'text/plain' }]
185
- *
186
- * const description = formData.get('description');
187
- * console.log(description); // 'My file'
188
- *
189
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdata `HttpFormData` API reference}
190
- */
165
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data `HttpFormData` API reference} */
191
166
  declare class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {
192
167
  readonly _schema: HttpFormDataSerialized<LooseSchema>;
193
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/set MDN Reference} */
168
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataset `formData.set()` API reference} */
194
169
  set<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name, value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>): void;
195
170
  set<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name, blob: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, string>, fileName?: string): void;
196
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/append MDN Reference} */
171
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataappend `formData.append()` API reference} */
197
172
  append<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name, value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>): void;
198
173
  append<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name, blob: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, string>, fileName?: string): void;
199
- /**
200
- * Get the value of the entry associated to a key name.
201
- *
202
- * If the key might have multiple values, use {@link HttpFormData#getAll} instead.
203
- *
204
- * @param name The name of the key to get the value of.
205
- * @returns The value associated with the key name, or `null` if the key does not exist.
206
- * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}
207
- */
174
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */
208
175
  get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(name: Name): ReplaceBy<ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File>;
209
- /**
210
- * Get all the values of the entry associated with a key name.
211
- *
212
- * If the key has at most a single value, use {@link HttpFormData#get} instead.
213
- *
214
- * @param name The name of the key to get the values of.
215
- * @returns An array of values associated with the key name, or an empty array if the key does not exist.
216
- * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}
217
- */
176
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */
218
177
  getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(name: Name): ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[];
219
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/has MDN Reference} */
178
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */
220
179
  has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean;
221
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/delete MDN Reference} */
180
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */
222
181
  delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void;
223
- forEach<This extends HttpFormData<this['_schema']>>(callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(value: ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>, key: Key, parent: HttpFormData<this['_schema']>) => void, thisArg?: This): void;
224
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/keys MDN Reference} */
182
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
183
+ forEach<This extends HttpFormData<this['_schema']>>(callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(value: ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>, key: Key, formData: HttpFormData<this['_schema']>) => void, thisArg?: This): void;
184
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */
225
185
  keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>>;
226
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/values MDN Reference} */
186
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */
227
187
  values(): FormDataIterator<ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>>;
228
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/entries MDN Reference} */
188
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */
229
189
  entries(): FormDataIterator<[
230
190
  HttpFormDataSchemaName<this['_schema']>,
231
191
  ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>
@@ -234,48 +194,11 @@ declare class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFo
234
194
  HttpFormDataSchemaName<this['_schema']>,
235
195
  ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>
236
196
  ]>;
237
- /**
238
- * Checks if the data is equal to the other data. Equality is defined as having the same keys and values, regardless
239
- * of the order of keys.
240
- *
241
- * @param otherData The other data to compare.
242
- * @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.
243
- * Important: both form data might be read while comparing.
244
- */
197
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */
245
198
  equals<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean>;
246
- /**
247
- * Checks if the data contains the other data. This method is less strict than {@link HttpFormData#equals} and only
248
- * requires that all keys and values in the other data are present in this data.
249
- *
250
- * @param otherData The other data to compare.
251
- * @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:
252
- * both form data might be read while comparing.
253
- */
199
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */
254
200
  contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean>;
255
- /**
256
- * Converts this form data into a plain object. This method is useful for serialization and debugging purposes.
257
- *
258
- * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
259
- * only one value, the object will contain its value directly, without an array, regardless of how the value was
260
- * initialized when creating the form data.
261
- *
262
- * @example
263
- * const formData = new HttpFormData<{
264
- * title: string;
265
- * descriptions: string[];
266
- * content: Blob;
267
- * }>();
268
- *
269
- * formData.set('title', 'My title');
270
- * formData.append('descriptions', 'Description 1');
271
- * formData.append('descriptions', 'Description 2');
272
- * formData.set('content', new Blob(['content'], { type: 'text/plain' }));
273
- *
274
- * const object = formData.toObject();
275
- * console.log(object); // { title: 'My title', descriptions: ['Description 1', 'Description 2'], content: Blob { type: 'text/plain' } }
276
- *
277
- * @returns A plain object representation of this form data.
278
- */
201
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */
279
202
  toObject(): this["_schema"];
280
203
  }
281
204
 
@@ -321,7 +244,7 @@ declare namespace HttpHeadersSchema {
321
244
  type HttpHeadersSchemaTuple<Schema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> = {
322
245
  [Key in keyof Schema & string]: [Key, NonNullable<Schema[Key]>];
323
246
  }[keyof Schema & string];
324
- /** An initialization value for {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders`}. */
247
+ /** An initialization value for {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders`}. */
325
248
  type HttpHeadersInit<Schema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> = Headers | Schema | HttpHeaders<Schema> | HttpHeadersSchemaTuple<Schema>[];
326
249
  /**
327
250
  * Extracts the names of the headers defined in a {@link HttpHeadersSchema}. Each key is considered a header name.
@@ -360,47 +283,29 @@ type HttpHeadersSchemaName<Schema extends HttpHeadersSchema> = IfNever<Schema, n
360
283
  */
361
284
  type HttpHeadersSerialized<Type> = HttpPathParamsSerialized<Type>;
362
285
 
363
- /**
364
- * An extended HTTP headers object with a strictly-typed schema. Fully compatible with the built-in
365
- * {@link https://developer.mozilla.org/docs/Web/API/Headers `Headers`} class.
366
- *
367
- * @example
368
- * import { HttpHeaders } from '@zimic/http';
369
- *
370
- * const headers = new HttpHeaders<{
371
- * accept?: string;
372
- * 'content-type'?: string;
373
- * }>({
374
- * accept: '*',
375
- * 'content-type': 'application/json',
376
- * });
377
- *
378
- * const contentType = headers.get('content-type');
379
- * console.log(contentType); // 'application/json'
380
- *
381
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders` API reference}
382
- */
286
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders` API reference} */
383
287
  declare class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> extends Headers {
384
288
  readonly _schema: HttpHeadersSerialized<LooseSchema>;
385
289
  constructor(init?: HttpHeadersInit<LooseSchema>);
386
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/set MDN Reference} */
290
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API reference} */
387
291
  set<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void;
388
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/append MDN Reference} */
292
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API reference} */
389
293
  append<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void;
390
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/get MDN Reference} */
294
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */
391
295
  get<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): ReplaceBy<this['_schema'][Name], undefined, null>;
392
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
296
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
393
297
  getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[];
394
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
298
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */
395
299
  has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean;
396
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/delete MDN Reference} */
300
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */
397
301
  delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void;
398
- forEach<This extends HttpHeaders<this['_schema']>>(callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(value: NonNullable<this['_schema'][Key]> & string, key: Key, parent: Headers) => void, thisArg?: This): void;
399
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/keys MDN Reference} */
302
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
303
+ forEach<This extends HttpHeaders<this['_schema']>>(callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(value: NonNullable<this['_schema'][Key]> & string, key: Key, headers: Headers) => void, thisArg?: This): void;
304
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */
400
305
  keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>>;
401
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/values MDN Reference} */
306
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */
402
307
  values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string>;
403
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/entries MDN Reference} */
308
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API reference} */
404
309
  entries(): HeadersIterator<[
405
310
  HttpHeadersSchemaName<this['_schema']>,
406
311
  NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string
@@ -409,22 +314,9 @@ declare class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHead
409
314
  HttpHeadersSchemaName<this['_schema']>,
410
315
  NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string
411
316
  ]>;
412
- /**
413
- * Checks if this headers object is equal to another set of headers. Equality is defined as having the same keys and
414
- * values, regardless of the order of keys.
415
- *
416
- * @param otherHeaders The other headers object to compare against.
417
- * @returns `true` if the headers are equal, `false` otherwise.
418
- */
317
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */
419
318
  equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean;
420
- /**
421
- * Checks if this headers object contains another set of headers. This method is less strict than
422
- * {@link HttpHeaders#equals} and only requires that all keys and values in the other headers are present in these
423
- * headers.
424
- *
425
- * @param otherHeaders The other headers object to compare against.
426
- * @returns `true` if these headers contain the other headers, `false` otherwise.
427
- */
319
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */
428
320
  contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean;
429
321
  /**
430
322
  * Converts these headers into a plain object. This method is useful for serialization and debugging purposes.
@@ -455,10 +347,7 @@ declare namespace HttpSearchParamsSchema {
455
347
  type HttpSearchParamsSchemaTuple<Schema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose> = {
456
348
  [Key in keyof Schema & string]: [Key, ArrayItemIfArray<NonNullable<Schema[Key]>>];
457
349
  }[keyof Schema & string];
458
- /**
459
- * An initialization value for
460
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparams `HttpSearchParams`}.
461
- */
350
+ /** An initialization value for {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams`}. */
462
351
  type HttpSearchParamsInit<Schema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose> = string | URLSearchParams | Schema | HttpSearchParams<Schema> | HttpSearchParamsSchemaTuple<Schema>[];
463
352
  declare namespace HttpSearchParamsSchemaName {
464
353
  /** Extracts the names of the search params defined in a {@link HttpSearchParamsSchema} that are arrays. */
@@ -523,67 +412,30 @@ type HttpSearchParamsSerialized<Type> = [Type] extends [never] ? never : Type ex
523
412
  [Key in keyof Type as IfNever<PrimitiveHttpSearchParamsSerialized<Type[Key]>, never, Key>]: PrimitiveHttpSearchParamsSerialized<Type[Key]>;
524
413
  } : never;
525
414
 
526
- /**
527
- * An extended HTTP search params object with a strictly-typed schema. Fully compatible with the built-in
528
- * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams `URLSearchParams`} class.
529
- *
530
- * @example
531
- * import { HttpSearchParams } from '@zimic/http';
532
- *
533
- * const searchParams = new HttpSearchParams<{
534
- * names?: string[];
535
- * page?: `${number}`;
536
- * }>({
537
- * names: ['user 1', 'user 2'],
538
- * page: '1',
539
- * });
540
- *
541
- * const names = searchParams.getAll('names');
542
- * console.log(names); // ['user 1', 'user 2']
543
- *
544
- * const page = searchParams.get('page');
545
- * console.log(page); // '1'
546
- *
547
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparams `HttpSearchParams` API reference}
548
- */
415
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams` API reference} */
549
416
  declare class HttpSearchParams<LooseSchema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose> extends URLSearchParams {
550
417
  readonly _schema: HttpSearchParamsSerialized<LooseSchema>;
551
418
  constructor(init?: HttpSearchParamsInit<LooseSchema>);
552
419
  private populateInitArrayProperties;
553
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/set MDN Reference} */
420
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API reference} */
554
421
  set<Name extends HttpSearchParamsSchemaName<this['_schema']>>(name: Name, value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>): void;
555
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/append MDN Reference} */
422
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API reference} */
556
423
  append<Name extends HttpSearchParamsSchemaName<this['_schema']>>(name: Name, value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>): void;
557
- /**
558
- * Get the value of the entry associated to a key name.
559
- *
560
- * If the key might have multiple values, use {@link HttpSearchParams#getAll} instead.
561
- *
562
- * @param name The name of the key to get the value of.
563
- * @returns The value associated with the key name, or `null` if the key does not exist.
564
- * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}
565
- */
424
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */
566
425
  get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(name: Name): ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>;
567
- /**
568
- * Get all the values of the entry associated with a key name.
569
- *
570
- * If the key has at most one value, use {@link HttpSearchParams#get} instead.
571
- *
572
- * @param name The name of the key to get the values of.
573
- * @returns An array of values associated with the key name, or an empty array if the key does not exist.
574
- * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}
575
- */
426
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */
576
427
  getAll<Name extends HttpSearchParamsSchemaName.Array<this['_schema']>>(name: Name): ArrayItemIfArray<NonNullable<this['_schema'][Name]>>[];
577
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/has MDN Reference} */
428
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API reference} */
578
429
  has<Name extends HttpSearchParamsSchemaName<this['_schema']>>(name: Name, value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>): boolean;
579
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete MDN Reference} */
430
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API reference} */
580
431
  delete<Name extends HttpSearchParamsSchemaName<this['_schema']>>(name: Name, value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>): void;
581
- forEach<This extends HttpSearchParams<this['_schema']>>(callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, key: Key, parent: HttpSearchParams<this['_schema']>) => void, thisArg?: This): void;
582
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys MDN Reference} */
432
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
433
+ forEach<This extends HttpSearchParams<this['_schema']>>(callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, key: Key, searchParams: HttpSearchParams<this['_schema']>) => void, thisArg?: This): void;
434
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */
583
435
  keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>>;
584
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/values MDN Reference} */
436
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API reference} */
585
437
  values(): URLSearchParamsIterator<ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>>;
586
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries MDN Reference} */
438
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API reference} */
587
439
  entries(): URLSearchParamsIterator<[
588
440
  HttpSearchParamsSchemaName<this['_schema']>,
589
441
  ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>
@@ -592,41 +444,11 @@ declare class HttpSearchParams<LooseSchema extends HttpSearchParamsSchema.Loose
592
444
  HttpSearchParamsSchemaName<this['_schema']>,
593
445
  ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>
594
446
  ]>;
595
- /**
596
- * Checks if these search params are equal to another set of search parameters. Equality is defined as having the same
597
- * keys and values, regardless of the order of the keys.
598
- *
599
- * @param otherParams The other search parameters to compare against.
600
- * @returns `true` if the search parameters are equal, `false` otherwise.
601
- */
447
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */
602
448
  equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean;
603
- /**
604
- * Checks if these search params contain another set of search parameters. This method is less strict than
605
- * {@link HttpSearchParams#equals} and only requires that all keys and values in the other search parameters are
606
- * present in these search parameters.
607
- *
608
- * @param otherParams The other search parameters to check for containment.
609
- * @returns `true` if these search parameters contain the other search parameters, `false` otherwise.
610
- */
449
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */
611
450
  contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean;
612
- /**
613
- * Converts these search params into a plain object. This method is useful for serialization and debugging purposes.
614
- *
615
- * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
616
- * only one value, the object will contain its value directly, without an array, regardless of how the value was
617
- * initialized when creating the search params object.
618
- *
619
- * @example
620
- * const searchParams = new HttpSearchParams({
621
- * names: ['user 1', 'user 2'],
622
- * name: ['user 3'],
623
- * page: '1',
624
- * });
625
- * const object = searchParams.toObject();
626
- * console.log(object); // { names: ['user 1', 'user 2'], name: 'user 3', page: '1' }
627
- *
628
- * @returns A plain object representation of these search params.
629
- */
451
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */
630
452
  toObject(): this["_schema"];
631
453
  }
632
454
 
@@ -639,7 +461,8 @@ type HttpMethod = (typeof HTTP_METHODS)[number];
639
461
  /**
640
462
  * A schema representing the structure of an HTTP request.
641
463
  *
642
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
464
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
465
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
643
466
  */
644
467
  interface HttpRequestSchema {
645
468
  headers?: HttpHeadersSchema.Loose;
@@ -649,7 +472,8 @@ interface HttpRequestSchema {
649
472
  /**
650
473
  * A schema representing the structure of an HTTP response.
651
474
  *
652
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
475
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
476
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
653
477
  */
654
478
  interface HttpResponseSchema {
655
479
  headers?: HttpHeadersSchema.Loose;
@@ -701,7 +525,8 @@ declare namespace HttpStatusCode {
701
525
  /**
702
526
  * A schema representing the structure of HTTP responses by status code.
703
527
  *
704
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
528
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
529
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
705
530
  */
706
531
  type HttpResponseSchemaByStatusCode = {
707
532
  [StatusCode in HttpStatusCode]?: HttpResponseSchema;
@@ -709,13 +534,15 @@ type HttpResponseSchemaByStatusCode = {
709
534
  /**
710
535
  * Extracts the status codes used in a response schema by status code.
711
536
  *
712
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
537
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
538
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
713
539
  */
714
540
  type HttpResponseSchemaStatusCode<ResponseSchemaByStatusCode extends HttpResponseSchemaByStatusCode> = keyof ResponseSchemaByStatusCode & HttpStatusCode;
715
541
  /**
716
542
  * A schema representing the structure of an HTTP request and response for a given method.
717
543
  *
718
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
544
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
545
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
719
546
  */
720
547
  interface HttpMethodSchema {
721
548
  request?: HttpRequestSchema;
@@ -724,7 +551,8 @@ interface HttpMethodSchema {
724
551
  /**
725
552
  * A schema representing the structure of HTTP request and response by method.
726
553
  *
727
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
554
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
555
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
728
556
  */
729
557
  interface HttpMethodsSchema {
730
558
  GET?: HttpMethodSchema;
@@ -739,268 +567,67 @@ interface BaseHttpSchema {
739
567
  [path: string]: HttpMethodsSchema;
740
568
  }
741
569
  /**
742
- * Declares an HTTP service schema.
743
- *
744
- * @example
745
- * import { type HttpSchema } from '@zimic/http';
746
- *
747
- * interface UserListHeaders {
748
- * accept: string;
749
- * }
750
- *
751
- * interface UserListSearchParams {
752
- * name?: string;
753
- * limit?: number;
754
- * }
755
- *
756
- * type Schema = HttpSchema<{
757
- * '/users': {
758
- * GET: {
759
- * request: {
760
- * headers: UserListHeaders;
761
- * searchParams: UserListSearchParams;
762
- * };
763
- * response: {
764
- * 200: {
765
- * // Inline headers declaration
766
- * headers: { 'content-type': string };
767
- * body: User[];
768
- * };
769
- * };
770
- * };
771
- * };
772
- * }>;
773
- *
774
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
570
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
571
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
775
572
  */
776
573
  type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = Branded<Schema, 'HttpSchema'>;
777
574
  declare namespace HttpSchema {
778
575
  /**
779
- * Declares an HTTP service methods schema.
780
- *
781
- * @example
782
- * import { type HttpSchema } from '@zimic/http';
783
- *
784
- * type UserMethods = HttpSchema.Methods<{
785
- * GET: {
786
- * response: {
787
- * 200: { body: User[] };
788
- * };
789
- * };
790
- * }>;
791
- *
792
- * type Schema = HttpSchema<{
793
- * '/users': UserMethods;
794
- * }>;
576
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
577
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethods `HttpSchema.Methods` API reference}
795
578
  */
796
579
  type Methods<Schema extends HttpMethodsSchema> = Schema;
797
580
  /**
798
- * Declares an HTTP service method schema.
799
- *
800
- * @example
801
- * import { type HttpSchema } from '@zimic/http';
802
- *
803
- * type UserListMethod = HttpSchema.Method<{
804
- * response: {
805
- * 200: { body: User[] };
806
- * };
807
- * }>;
808
- *
809
- * type Schema = HttpSchema<{
810
- * '/users': {
811
- * GET: UserListMethod;
812
- * };
813
- * }>;
581
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
582
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethod `HttpSchema.Method` API reference}
814
583
  */
815
584
  type Method<Schema extends HttpMethodSchema> = Schema;
816
585
  /**
817
- * Declares an HTTP service request schema.
818
- *
819
- * @example
820
- * import { type HttpSchema } from '@zimic/http';
821
- *
822
- * type UserCreationRequest = HttpSchema.Request<{
823
- * headers: { 'content-type': 'application/json' };
824
- * body: User;
825
- * }>;
826
- *
827
- * type Schema = HttpSchema<{
828
- * '/users': {
829
- * POST: {
830
- * request: UserCreationRequest;
831
- * response: {
832
- * 201: { body: User };
833
- * };
834
- * };
835
- * };
836
- * }>;
586
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
587
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemarequest `HttpSchema.Request` API reference}
837
588
  */
838
589
  type Request<Schema extends HttpRequestSchema> = Schema;
839
590
  /**
840
- * Declares an HTTP service response schema by status code.
841
- *
842
- * @example
843
- * import { type HttpSchema } from '@zimic/http';
844
- *
845
- * type UserListResponseByStatusCode = HttpSchema.ResponseByStatusCode<{
846
- * 200: { body: User[] };
847
- * 400: { body: { message: string } };
848
- * }>;
849
- *
850
- * type Schema = HttpSchema<{
851
- * '/users': {
852
- * GET: {
853
- * response: UserListResponseByStatusCode;
854
- * };
855
- * };
856
- * }>;
591
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
592
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponsebystatuscode `HttpSchema.ResponseByStatusCode` API reference}
857
593
  */
858
594
  type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> = Schema;
859
595
  /**
860
- * Declares an HTTP service response schema.
861
- *
862
- * @example
863
- * import { type HttpSchema } from '@zimic/http';
864
- *
865
- * type UserListSuccessResponse = HttpSchema.Response<{
866
- * body: User[];
867
- * }>;
868
- *
869
- * type Schema = HttpSchema<{
870
- * '/users': {
871
- * GET: {
872
- * response: {
873
- * 200: UserListSuccessResponse;
874
- * };
875
- * };
876
- * };
877
- * }>;
596
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
597
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponse `HttpSchema.Response` API reference}
878
598
  */
879
599
  type Response<Schema extends HttpResponseSchema> = Schema;
880
600
  /**
881
- * Declares an HTTP body schema.
882
- *
883
- * @example
884
- * import { type HttpSchema } from '@zimic/http';
885
- *
886
- * type UserListSuccessResponseBody = HttpSchema.Body<User[]>;
887
- *
888
- * type Schema = HttpSchema<{
889
- * '/users': {
890
- * GET: {
891
- * response: {
892
- * 200: { body: UserListSuccessResponseBody };
893
- * };
894
- * };
895
- * };
896
- * }>;
601
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
602
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemabody `HttpSchema.Body` API reference}
897
603
  */
898
604
  type Body<Schema extends HttpBody.Loose> = Schema;
899
605
  /**
900
- * Declares an HTTP headers schema.
901
- *
902
- * @example
903
- * import { type HttpSchema } from '@zimic/http';
904
- *
905
- * type UserListHeaders = HttpSchema.Headers<{
906
- * accept: 'application/json';
907
- * }>;
908
- *
909
- * type Schema = HttpSchema<{
910
- * '/users': {
911
- * GET: {
912
- * request: {
913
- * headers: UserListHeaders;
914
- * };
915
- * response: {
916
- * 200: { body: User[] };
917
- * };
918
- * };
919
- * };
920
- * }>;
606
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
607
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaheaders `HttpSchema.Headers` API reference}
921
608
  */
922
609
  type Headers<Schema extends HttpHeadersSchema.Loose> = Schema;
923
610
  /**
924
- * Declares an HTTP search params schema.
925
- *
926
- * @example
927
- * import { type HttpSchema } from '@zimic/http';
928
- *
929
- * type UserListSearchParams = HttpSchema.SearchParams<{
930
- * limit: `${number}`;
931
- * offset: `${number}`;
932
- * }>;
933
- *
934
- * type Schema = HttpSchema<{
935
- * '/users': {
936
- * GET: {
937
- * request: {
938
- * searchParams: UserListSearchParams;
939
- * };
940
- * response: {
941
- * 200: { body: User[] };
942
- * };
943
- * };
944
- * };
945
- * }>;
611
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
612
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemasearchparams `HttpSchema.SearchParams` API reference}
946
613
  */
947
614
  type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = Schema;
948
615
  /**
949
- * Declares an HTTP path params schema.
950
- *
951
- * @example
952
- * import { type HttpSchema, InferPathParams } from '@zimic/http';
953
- *
954
- * type Schema = HttpSchema<{
955
- * '/users/:userId': {
956
- * GET: {
957
- * response: {
958
- * 200: { body: User };
959
- * };
960
- * };
961
- * };
962
- * }>;
963
- *
964
- * type UserByIdPathParams = HttpSchema.PathParams<{
965
- * userId: string;
966
- * }>;
967
- *
968
- * // Or infer from the path string
969
- * type UserByIdPathParams = InferPathParams<Schema, '/users/:userId'>;
616
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
617
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathparams `HttpSchema.PathParams` API reference}
970
618
  */
971
619
  type PathParams<Schema extends HttpPathParamsSchema.Loose> = Schema;
972
620
  /**
973
- * Declares an HTTP form data schema.
974
- *
975
- * @example
976
- * import { HttpFormData, type HttpSchema } from '@zimic/http';
977
- *
978
- * type UserCreationFormData = HttpFormData<
979
- * HttpSchema.FormData<{
980
- * name: string;
981
- * email: string;
982
- * }>
983
- * >;
984
- *
985
- * type Schema = HttpSchema<{
986
- * '/users': {
987
- * POST: {
988
- * request: {
989
- * body: UserCreationFormData;
990
- * };
991
- * response: {
992
- * 201: { body: User };
993
- * };
994
- * };
995
- * };
996
- * }>;
621
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
622
+ * @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaformdata `HttpSchema.FormData` API reference}
997
623
  */
998
624
  type FormData<Schema extends HttpFormDataSchema.Loose> = Schema;
999
625
  }
1000
626
  /**
1001
627
  * Extracts the methods from an HTTP service schema.
1002
628
  *
1003
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
629
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
630
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
1004
631
  */
1005
632
  type HttpSchemaMethod<Schema extends HttpSchema> = IfAny<Schema, any, // eslint-disable-line @typescript-eslint/no-explicit-any
1006
633
  // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -1032,7 +659,8 @@ type AllowAnyStringInPathParams<Path extends string> = Path extends `${infer Pre
1032
659
  * type GetPath = HttpSchemaPath<Schema, 'GET'>;
1033
660
  * // "/users"
1034
661
  *
1035
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
662
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
663
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}
1036
664
  */
1037
665
  declare namespace HttpSchemaPath {
1038
666
  type LooseLiteral<Schema extends HttpSchema, Method extends HttpMethod = HttpMethod> = {
@@ -1064,7 +692,8 @@ declare namespace HttpSchemaPath {
1064
692
  * type LiteralGetPath = HttpSchemaPath.Literal<Schema, 'GET'>;
1065
693
  * // "/users"
1066
694
  *
1067
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
695
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
696
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference} `}
1068
697
  */
1069
698
  export type Literal<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>> = LooseLiteral<Schema, Method>;
1070
699
  /**
@@ -1093,7 +722,8 @@ declare namespace HttpSchemaPath {
1093
722
  * type NonLiteralGetPath = HttpSchemaPath.NonLiteral<Schema, 'GET'>;
1094
723
  * // "/users"
1095
724
  *
1096
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
725
+ * @see {@link https://zimic.dev/docs/http/guides/schemas Declaring schemas}
726
+ * @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference} `}
1097
727
  */
1098
728
  export type NonLiteral<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>> = AllowAnyStringInPathParams<Literal<Schema, Method>>;
1099
729
  export { };