@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.
@@ -3,36 +3,11 @@ import { ArrayItemIfArray, ReplaceBy } from '@zimic/utils/types';
3
3
 
4
4
  import { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';
5
5
 
6
- /**
7
- * An extended HTTP form data object with a strictly-typed schema. Fully compatible with the built-in
8
- * {@link https://developer.mozilla.org/docs/Web/API/FormData `FormData`} class.
9
- *
10
- * **IMPORTANT**: the input of `HttpFormData` and all of its internal types must be declared inline or as a type aliases
11
- * (`type`). They cannot be interfaces.
12
- *
13
- * @example
14
- * import { HttpFormData } from '@zimic/http';
15
- *
16
- * const formData = new HttpFormData<{
17
- * files: File[];
18
- * description?: string;
19
- * }>();
20
- *
21
- * formData.append('file', new File(['content'], 'file.txt', { type: 'text/plain' }));
22
- * formData.append('description', 'My file');
23
- *
24
- * const files = formData.getAll('file');
25
- * console.log(files); // [File { name: 'file.txt', type: 'text/plain' }]
26
- *
27
- * const description = formData.get('description');
28
- * console.log(description); // 'My file'
29
- *
30
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdata `HttpFormData` API reference}
31
- */
6
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data `HttpFormData` API reference} */
32
7
  class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {
33
8
  readonly _schema!: HttpFormDataSerialized<LooseSchema>;
34
9
 
35
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/set MDN Reference} */
10
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataset `formData.set()` API reference} */
36
11
  set<Name extends HttpFormDataSchemaName<this['_schema']>>(
37
12
  name: Name,
38
13
  value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>,
@@ -54,7 +29,7 @@ class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSc
54
29
  }
55
30
  }
56
31
 
57
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/append MDN Reference} */
32
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataappend `formData.append()` API reference} */
58
33
  append<Name extends HttpFormDataSchemaName<this['_schema']>>(
59
34
  name: Name,
60
35
  value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>,
@@ -76,70 +51,55 @@ class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSc
76
51
  }
77
52
  }
78
53
 
79
- /**
80
- * Get the value of the entry associated to a key name.
81
- *
82
- * If the key might have multiple values, use {@link HttpFormData#getAll} instead.
83
- *
84
- * @param name The name of the key to get the value of.
85
- * @returns The value associated with the key name, or `null` if the key does not exist.
86
- * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}
87
- */
54
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */
88
55
  get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(
89
56
  name: Name,
90
57
  ): ReplaceBy<ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {
91
58
  return super.get(name) as never;
92
59
  }
93
60
 
94
- /**
95
- * Get all the values of the entry associated with a key name.
96
- *
97
- * If the key has at most a single value, use {@link HttpFormData#get} instead.
98
- *
99
- * @param name The name of the key to get the values of.
100
- * @returns An array of values associated with the key name, or an empty array if the key does not exist.
101
- * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}
102
- */
61
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */
103
62
  getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(
104
63
  name: Name,
105
64
  ): ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {
106
65
  return super.getAll(name) as never;
107
66
  }
108
67
 
109
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/has MDN Reference} */
68
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */
110
69
  has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {
111
70
  return super.has(name);
112
71
  }
113
72
 
114
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/delete MDN Reference} */
73
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */
115
74
  delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {
116
75
  super.delete(name);
117
76
  }
118
77
 
78
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
119
79
  forEach<This extends HttpFormData<this['_schema']>>(
120
80
  callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(
121
81
  value: ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,
122
82
  key: Key,
123
- parent: HttpFormData<this['_schema']>,
83
+ formData: HttpFormData<this['_schema']>,
124
84
  ) => void,
125
85
  thisArg?: This,
126
86
  ): void {
127
87
  super.forEach(callback as (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg);
128
88
  }
129
89
 
130
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/keys MDN Reference} */
90
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */
131
91
  keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {
132
92
  return super.keys() as never;
133
93
  }
134
94
 
135
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/values MDN Reference} */
95
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */
136
96
  values(): FormDataIterator<
137
97
  ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>
138
98
  > {
139
99
  return super.values() as never;
140
100
  }
141
101
 
142
- /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/entries MDN Reference} */
102
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */
143
103
  entries(): FormDataIterator<
144
104
  [
145
105
  HttpFormDataSchemaName<this['_schema']>,
@@ -158,14 +118,7 @@ class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSc
158
118
  return super[Symbol.iterator]() as never;
159
119
  }
160
120
 
161
- /**
162
- * Checks if the data is equal to the other data. Equality is defined as having the same keys and values, regardless
163
- * of the order of keys.
164
- *
165
- * @param otherData The other data to compare.
166
- * @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.
167
- * Important: both form data might be read while comparing.
168
- */
121
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */
169
122
  async equals<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {
170
123
  if (!(await this.contains(otherData))) {
171
124
  return false;
@@ -181,14 +134,7 @@ class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSc
181
134
  return true;
182
135
  }
183
136
 
184
- /**
185
- * Checks if the data contains the other data. This method is less strict than {@link HttpFormData#equals} and only
186
- * requires that all keys and values in the other data are present in this data.
187
- *
188
- * @param otherData The other data to compare.
189
- * @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:
190
- * both form data might be read while comparing.
191
- */
137
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */
192
138
  async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {
193
139
  for (const [otherKey, otherValue] of otherData.entries()) {
194
140
  const values = super.getAll.call(this, otherKey);
@@ -218,30 +164,7 @@ class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSc
218
164
  return true;
219
165
  }
220
166
 
221
- /**
222
- * Converts this form data into a plain object. This method is useful for serialization and debugging purposes.
223
- *
224
- * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
225
- * only one value, the object will contain its value directly, without an array, regardless of how the value was
226
- * initialized when creating the form data.
227
- *
228
- * @example
229
- * const formData = new HttpFormData<{
230
- * title: string;
231
- * descriptions: string[];
232
- * content: Blob;
233
- * }>();
234
- *
235
- * formData.set('title', 'My title');
236
- * formData.append('descriptions', 'Description 1');
237
- * formData.append('descriptions', 'Description 2');
238
- * formData.set('content', new Blob(['content'], { type: 'text/plain' }));
239
- *
240
- * const object = formData.toObject();
241
- * console.log(object); // { title: 'My title', descriptions: ['Description 1', 'Description 2'], content: Blob { type: 'text/plain' } }
242
- *
243
- * @returns A plain object representation of this form data.
244
- */
167
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */
245
168
  toObject() {
246
169
  const object = {} as this['_schema'];
247
170
 
@@ -11,26 +11,7 @@ function pickPrimitiveProperties<LooseSchema extends HttpHeadersSchema.Loose>(sc
11
11
  }, {});
12
12
  }
13
13
 
14
- /**
15
- * An extended HTTP headers object with a strictly-typed schema. Fully compatible with the built-in
16
- * {@link https://developer.mozilla.org/docs/Web/API/Headers `Headers`} class.
17
- *
18
- * @example
19
- * import { HttpHeaders } from '@zimic/http';
20
- *
21
- * const headers = new HttpHeaders<{
22
- * accept?: string;
23
- * 'content-type'?: string;
24
- * }>({
25
- * accept: '*',
26
- * 'content-type': 'application/json',
27
- * });
28
- *
29
- * const contentType = headers.get('content-type');
30
- * console.log(contentType); // 'application/json'
31
- *
32
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders` API reference}
33
- */
14
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders` API reference} */
34
15
  class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> extends Headers {
35
16
  readonly _schema!: HttpHeadersSerialized<LooseSchema>;
36
17
 
@@ -42,60 +23,61 @@ class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchem
42
23
  }
43
24
  }
44
25
 
45
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/set MDN Reference} */
26
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API reference} */
46
27
  set<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {
47
28
  super.set(name, value);
48
29
  }
49
30
 
50
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/append MDN Reference} */
31
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API reference} */
51
32
  append<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {
52
33
  super.append(name, value);
53
34
  }
54
35
 
55
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/get MDN Reference} */
36
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */
56
37
  get<Name extends HttpHeadersSchemaName<this['_schema']>>(
57
38
  name: Name,
58
39
  ): ReplaceBy<this['_schema'][Name], undefined, null> {
59
40
  return super.get(name) as never;
60
41
  }
61
42
 
62
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
43
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
63
44
  getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {
64
45
  return super.getSetCookie() as never;
65
46
  }
66
47
 
67
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */
48
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */
68
49
  has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {
69
50
  return super.has(name);
70
51
  }
71
52
 
72
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/delete MDN Reference} */
53
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */
73
54
  delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {
74
55
  super.delete(name);
75
56
  }
76
57
 
58
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
77
59
  forEach<This extends HttpHeaders<this['_schema']>>(
78
60
  callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(
79
61
  value: NonNullable<this['_schema'][Key]> & string,
80
62
  key: Key,
81
- parent: Headers,
63
+ headers: Headers,
82
64
  ) => void,
83
65
  thisArg?: This,
84
66
  ): void {
85
67
  super.forEach(callback as (value: string, key: string, parent: Headers) => void, thisArg);
86
68
  }
87
69
 
88
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/keys MDN Reference} */
70
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */
89
71
  keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {
90
72
  return super.keys() as never;
91
73
  }
92
74
 
93
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/values MDN Reference} */
75
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */
94
76
  values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {
95
77
  return super.values() as never;
96
78
  }
97
79
 
98
- /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/entries MDN Reference} */
80
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API reference} */
99
81
  entries(): HeadersIterator<
100
82
  [
101
83
  HttpHeadersSchemaName<this['_schema']>,
@@ -114,13 +96,7 @@ class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchem
114
96
  return super[Symbol.iterator]() as never;
115
97
  }
116
98
 
117
- /**
118
- * Checks if this headers object is equal to another set of headers. Equality is defined as having the same keys and
119
- * values, regardless of the order of keys.
120
- *
121
- * @param otherHeaders The other headers object to compare against.
122
- * @returns `true` if the headers are equal, `false` otherwise.
123
- */
99
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */
124
100
  equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {
125
101
  if (!this.contains(otherHeaders)) {
126
102
  return false;
@@ -136,14 +112,7 @@ class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchem
136
112
  return true;
137
113
  }
138
114
 
139
- /**
140
- * Checks if this headers object contains another set of headers. This method is less strict than
141
- * {@link HttpHeaders#equals} and only requires that all keys and values in the other headers are present in these
142
- * headers.
143
- *
144
- * @param otherHeaders The other headers object to compare against.
145
- * @returns `true` if these headers contain the other headers, `false` otherwise.
146
- */
115
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */
147
116
  contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {
148
117
  for (const [key, otherValue] of otherHeaders.entries()) {
149
118
  const value = super.get.call(this, key);
@@ -19,7 +19,7 @@ export type HttpHeadersSchemaTuple<Schema extends HttpHeadersSchema.Loose = Http
19
19
  [Key in keyof Schema & string]: [Key, NonNullable<Schema[Key]>];
20
20
  }[keyof Schema & string];
21
21
 
22
- /** An initialization value for {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders`}. */
22
+ /** An initialization value for {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders`}. */
23
23
  export type HttpHeadersInit<Schema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> =
24
24
  | Headers
25
25
  | Schema
@@ -20,29 +20,7 @@ function pickPrimitiveProperties<Schema extends HttpSearchParamsSchema.Loose>(sc
20
20
  return schemaWithPrimitiveProperties;
21
21
  }
22
22
 
23
- /**
24
- * An extended HTTP search params object with a strictly-typed schema. Fully compatible with the built-in
25
- * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams `URLSearchParams`} class.
26
- *
27
- * @example
28
- * import { HttpSearchParams } from '@zimic/http';
29
- *
30
- * const searchParams = new HttpSearchParams<{
31
- * names?: string[];
32
- * page?: `${number}`;
33
- * }>({
34
- * names: ['user 1', 'user 2'],
35
- * page: '1',
36
- * });
37
- *
38
- * const names = searchParams.getAll('names');
39
- * console.log(names); // ['user 1', 'user 2']
40
- *
41
- * const page = searchParams.get('page');
42
- * console.log(page); // '1'
43
- *
44
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparams `HttpSearchParams` API reference}
45
- */
23
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams` API reference} */
46
24
  class HttpSearchParams<
47
25
  LooseSchema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose,
48
26
  > extends URLSearchParams {
@@ -67,7 +45,7 @@ class HttpSearchParams<
67
45
  }
68
46
  }
69
47
 
70
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/set MDN Reference} */
48
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API reference} */
71
49
  set<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
72
50
  name: Name,
73
51
  value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
@@ -75,7 +53,7 @@ class HttpSearchParams<
75
53
  super.set(name, value);
76
54
  }
77
55
 
78
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/append MDN Reference} */
56
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API reference} */
79
57
  append<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
80
58
  name: Name,
81
59
  value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
@@ -83,37 +61,21 @@ class HttpSearchParams<
83
61
  super.append(name, value);
84
62
  }
85
63
 
86
- /**
87
- * Get the value of the entry associated to a key name.
88
- *
89
- * If the key might have multiple values, use {@link HttpSearchParams#getAll} instead.
90
- *
91
- * @param name The name of the key to get the value of.
92
- * @returns The value associated with the key name, or `null` if the key does not exist.
93
- * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}
94
- */
64
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */
95
65
  get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(
96
66
  name: Name,
97
67
  ): ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {
98
68
  return super.get(name) as never;
99
69
  }
100
70
 
101
- /**
102
- * Get all the values of the entry associated with a key name.
103
- *
104
- * If the key has at most one value, use {@link HttpSearchParams#get} instead.
105
- *
106
- * @param name The name of the key to get the values of.
107
- * @returns An array of values associated with the key name, or an empty array if the key does not exist.
108
- * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}
109
- */
71
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */
110
72
  getAll<Name extends HttpSearchParamsSchemaName.Array<this['_schema']>>(
111
73
  name: Name,
112
74
  ): ArrayItemIfArray<NonNullable<this['_schema'][Name]>>[] {
113
75
  return super.getAll(name) as never;
114
76
  }
115
77
 
116
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/has MDN Reference} */
78
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API reference} */
117
79
  has<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
118
80
  name: Name,
119
81
  value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
@@ -121,7 +83,7 @@ class HttpSearchParams<
121
83
  return super.has(name, value);
122
84
  }
123
85
 
124
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete MDN Reference} */
86
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API reference} */
125
87
  delete<Name extends HttpSearchParamsSchemaName<this['_schema']>>(
126
88
  name: Name,
127
89
  value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
@@ -129,30 +91,31 @@ class HttpSearchParams<
129
91
  super.delete(name, value);
130
92
  }
131
93
 
94
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
132
95
  forEach<This extends HttpSearchParams<this['_schema']>>(
133
96
  callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(
134
97
  value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>,
135
98
  key: Key,
136
- parent: HttpSearchParams<this['_schema']>,
99
+ searchParams: HttpSearchParams<this['_schema']>,
137
100
  ) => void,
138
101
  thisArg?: This,
139
102
  ): void {
140
103
  super.forEach(callback as (value: string, key: string, parent: URLSearchParams) => void, thisArg);
141
104
  }
142
105
 
143
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys MDN Reference} */
106
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */
144
107
  keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {
145
108
  return super.keys() as never;
146
109
  }
147
110
 
148
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/values MDN Reference} */
111
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API reference} */
149
112
  values(): URLSearchParamsIterator<
150
113
  ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>
151
114
  > {
152
115
  return super.values() as never;
153
116
  }
154
117
 
155
- /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries MDN Reference} */
118
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API reference} */
156
119
  entries(): URLSearchParamsIterator<
157
120
  [
158
121
  HttpSearchParamsSchemaName<this['_schema']>,
@@ -171,25 +134,12 @@ class HttpSearchParams<
171
134
  return super[Symbol.iterator]() as never;
172
135
  }
173
136
 
174
- /**
175
- * Checks if these search params are equal to another set of search parameters. Equality is defined as having the same
176
- * keys and values, regardless of the order of the keys.
177
- *
178
- * @param otherParams The other search parameters to compare against.
179
- * @returns `true` if the search parameters are equal, `false` otherwise.
180
- */
137
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */
181
138
  equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {
182
139
  return this.contains(otherParams) && this.size === otherParams.size;
183
140
  }
184
141
 
185
- /**
186
- * Checks if these search params contain another set of search parameters. This method is less strict than
187
- * {@link HttpSearchParams#equals} and only requires that all keys and values in the other search parameters are
188
- * present in these search parameters.
189
- *
190
- * @param otherParams The other search parameters to check for containment.
191
- * @returns `true` if these search parameters contain the other search parameters, `false` otherwise.
192
- */
142
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */
193
143
  contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {
194
144
  for (const [key, otherValue] of otherParams.entries()) {
195
145
  const values = super.getAll.call(this, key);
@@ -208,24 +158,7 @@ class HttpSearchParams<
208
158
  return true;
209
159
  }
210
160
 
211
- /**
212
- * Converts these search params into a plain object. This method is useful for serialization and debugging purposes.
213
- *
214
- * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
215
- * only one value, the object will contain its value directly, without an array, regardless of how the value was
216
- * initialized when creating the search params object.
217
- *
218
- * @example
219
- * const searchParams = new HttpSearchParams({
220
- * names: ['user 1', 'user 2'],
221
- * name: ['user 3'],
222
- * page: '1',
223
- * });
224
- * const object = searchParams.toObject();
225
- * console.log(object); // { names: ['user 1', 'user 2'], name: 'user 3', page: '1' }
226
- *
227
- * @returns A plain object representation of these search params.
228
- */
161
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */
229
162
  toObject() {
230
163
  const object = {} as this['_schema'];
231
164
 
@@ -18,10 +18,7 @@ export type HttpSearchParamsSchemaTuple<Schema extends HttpSearchParamsSchema.Lo
18
18
  [Key in keyof Schema & string]: [Key, ArrayItemIfArray<NonNullable<Schema[Key]>>];
19
19
  }[keyof Schema & string];
20
20
 
21
- /**
22
- * An initialization value for
23
- * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparams `HttpSearchParams`}.
24
- */
21
+ /** An initialization value for {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams`}. */
25
22
  export type HttpSearchParamsInit<Schema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose> =
26
23
  | string
27
24
  | URLSearchParams
@@ -69,68 +69,18 @@ function normalizeRawNodes(rawNodes: ts.Node[], context: TypeTransformContext, o
69
69
  return normalizedNodes;
70
70
  }
71
71
 
72
- /**
73
- * The options to use when generating types from an OpenAPI schema.
74
- *
75
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐typegen#generatetypesfromopenapioptions `generateTypesFromOpenAPI(options)` API reference}
76
- */
72
+ /** @see {@link https://zimic.dev/docs/http/api/typegen#generatetypesfromopenapi `generateTypesFromOpenAPI()` API reference} */
77
73
  export interface OpenAPITypegenOptions {
78
- /**
79
- * The path to a local OpenAPI schema file or an URL to fetch it. Version 3 is supported as YAML or JSON.
80
- *
81
- * @example
82
- * './schema.yaml';
83
- * 'https://example.com/openapi/schema.yaml';
84
- */
85
74
  input: string;
86
- /**
87
- * The path to write the generated types to. If not provided, the types will be written to stdout.
88
- *
89
- * @example
90
- * './schema.ts';
91
- */
92
75
  output?: string;
93
- /**
94
- * The name of the service to use in the generated types.
95
- *
96
- * @example
97
- * 'MyService';
98
- */
99
76
  serviceName: string;
100
- /** Whether to include comments in the generated types. */
101
77
  includeComments: boolean;
102
- /**
103
- * Whether to remove unused operations and components from the generated types. This is useful for reducing the size
104
- * of the output file.
105
- */
106
78
  prune: boolean;
107
- /**
108
- * One or more expressions to filter the types to generate. Filters must follow the format `<method> <path>`, where
109
- * `<method>` is an HTTP method or `*`, and `<path>` is a literal path or a glob. Filters are case-sensitive regarding
110
- * paths. Negative filters can be created by prefixing the expression with `!`. If more than one positive filter is
111
- * provided, they will be combined with OR, while negative filters will be combined with AND.
112
- *
113
- * @example
114
- * ['GET /users', '* /users', 'GET,POST /users/*', 'DELETE /users/**\\/*', '!GET /notifications'];
115
- */
116
79
  filters?: string[];
117
- /**
118
- * A path to a file containing filter expressions. One expression is expected per line and the format is the same as
119
- * used in a `--filter` option. Comments are prefixed with `#`. A filter file can be used alongside additional
120
- * `--filter` expressions.
121
- *
122
- * @example
123
- * './filters.txt';
124
- */
125
80
  filterFile?: string;
126
81
  }
127
82
 
128
- /**
129
- * Generates TypeScript types from an OpenAPI schema.
130
- *
131
- * @param options The options to use when generating the types.
132
- * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐typegen#generatetypesfromopenapioptions `generateTypesFromOpenAPI(options)` API reference}
133
- */
83
+ /** @see {@link https://zimic.dev/docs/http/api/typegen#generatetypesfromopenapi `generateTypesFromOpenAPI()` API reference} */
134
84
  async function generateTypesFromOpenAPI({
135
85
  input: inputFilePathOrURL,
136
86
  output: outputFilePath,