@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/README.md +18 -170
- package/dist/{chunk-KVTV4E5K.mjs → chunk-3DBBG4IX.mjs} +2 -2
- package/dist/chunk-3DBBG4IX.mjs.map +1 -0
- package/dist/{chunk-LOHINQWU.js → chunk-6NKD7JVQ.js} +2 -2
- package/dist/chunk-6NKD7JVQ.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.ts +88 -458
- package/dist/index.js +36 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -145
- package/dist/index.mjs.map +1 -1
- package/dist/typegen.d.ts +2 -52
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +5 -5
- package/src/formData/HttpFormData.ts +15 -92
- package/src/headers/HttpHeaders.ts +14 -45
- package/src/headers/types.ts +1 -1
- package/src/searchParams/HttpSearchParams.ts +15 -82
- package/src/searchParams/types.ts +1 -4
- package/src/typegen/openapi/generate.ts +2 -52
- package/src/types/schema.ts +42 -234
- package/dist/chunk-KVTV4E5K.mjs.map +0 -1
- package/dist/chunk-LOHINQWU.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -84,64 +84,42 @@ var HttpFormData = class extends FormData {
|
|
|
84
84
|
super.append(name, blobOrValue, fileName);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Get the value of the entry associated to a key name.
|
|
89
|
-
*
|
|
90
|
-
* If the key might have multiple values, use {@link HttpFormData#getAll} instead.
|
|
91
|
-
*
|
|
92
|
-
* @param name The name of the key to get the value of.
|
|
93
|
-
* @returns The value associated with the key name, or `null` if the key does not exist.
|
|
94
|
-
* @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}
|
|
95
|
-
*/
|
|
87
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */
|
|
96
88
|
get(name) {
|
|
97
89
|
return super.get(name);
|
|
98
90
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Get all the values of the entry associated with a key name.
|
|
101
|
-
*
|
|
102
|
-
* If the key has at most a single value, use {@link HttpFormData#get} instead.
|
|
103
|
-
*
|
|
104
|
-
* @param name The name of the key to get the values of.
|
|
105
|
-
* @returns An array of values associated with the key name, or an empty array if the key does not exist.
|
|
106
|
-
* @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}
|
|
107
|
-
*/
|
|
91
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */
|
|
108
92
|
getAll(name) {
|
|
109
93
|
return super.getAll(name);
|
|
110
94
|
}
|
|
111
|
-
/** @see {@link https://
|
|
95
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */
|
|
112
96
|
has(name) {
|
|
113
97
|
return super.has(name);
|
|
114
98
|
}
|
|
115
|
-
/** @see {@link https://
|
|
99
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */
|
|
116
100
|
delete(name) {
|
|
117
101
|
super.delete(name);
|
|
118
102
|
}
|
|
103
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
|
|
119
104
|
forEach(callback, thisArg) {
|
|
120
105
|
super.forEach(callback, thisArg);
|
|
121
106
|
}
|
|
122
|
-
/** @see {@link https://
|
|
107
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */
|
|
123
108
|
keys() {
|
|
124
109
|
return super.keys();
|
|
125
110
|
}
|
|
126
|
-
/** @see {@link https://
|
|
111
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */
|
|
127
112
|
values() {
|
|
128
113
|
return super.values();
|
|
129
114
|
}
|
|
130
|
-
/** @see {@link https://
|
|
115
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */
|
|
131
116
|
entries() {
|
|
132
117
|
return super.entries();
|
|
133
118
|
}
|
|
134
119
|
[Symbol.iterator]() {
|
|
135
120
|
return super[Symbol.iterator]();
|
|
136
121
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Checks if the data is equal to the other data. Equality is defined as having the same keys and values, regardless
|
|
139
|
-
* of the order of keys.
|
|
140
|
-
*
|
|
141
|
-
* @param otherData The other data to compare.
|
|
142
|
-
* @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.
|
|
143
|
-
* Important: both form data might be read while comparing.
|
|
144
|
-
*/
|
|
122
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */
|
|
145
123
|
async equals(otherData) {
|
|
146
124
|
if (!await this.contains(otherData)) {
|
|
147
125
|
return false;
|
|
@@ -154,14 +132,7 @@ var HttpFormData = class extends FormData {
|
|
|
154
132
|
}
|
|
155
133
|
return true;
|
|
156
134
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Checks if the data contains the other data. This method is less strict than {@link HttpFormData#equals} and only
|
|
159
|
-
* requires that all keys and values in the other data are present in this data.
|
|
160
|
-
*
|
|
161
|
-
* @param otherData The other data to compare.
|
|
162
|
-
* @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:
|
|
163
|
-
* both form data might be read while comparing.
|
|
164
|
-
*/
|
|
135
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */
|
|
165
136
|
async contains(otherData) {
|
|
166
137
|
for (const [otherKey, otherValue] of otherData.entries()) {
|
|
167
138
|
const values = super.getAll.call(this, otherKey);
|
|
@@ -182,30 +153,7 @@ var HttpFormData = class extends FormData {
|
|
|
182
153
|
}
|
|
183
154
|
return true;
|
|
184
155
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Converts this form data into a plain object. This method is useful for serialization and debugging purposes.
|
|
187
|
-
*
|
|
188
|
-
* **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
|
|
189
|
-
* only one value, the object will contain its value directly, without an array, regardless of how the value was
|
|
190
|
-
* initialized when creating the form data.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* const formData = new HttpFormData<{
|
|
194
|
-
* title: string;
|
|
195
|
-
* descriptions: string[];
|
|
196
|
-
* content: Blob;
|
|
197
|
-
* }>();
|
|
198
|
-
*
|
|
199
|
-
* formData.set('title', 'My title');
|
|
200
|
-
* formData.append('descriptions', 'Description 1');
|
|
201
|
-
* formData.append('descriptions', 'Description 2');
|
|
202
|
-
* formData.set('content', new Blob(['content'], { type: 'text/plain' }));
|
|
203
|
-
*
|
|
204
|
-
* const object = formData.toObject();
|
|
205
|
-
* console.log(object); // { title: 'My title', descriptions: ['Description 1', 'Description 2'], content: Blob { type: 'text/plain' } }
|
|
206
|
-
*
|
|
207
|
-
* @returns A plain object representation of this form data.
|
|
208
|
-
*/
|
|
156
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */
|
|
209
157
|
toObject() {
|
|
210
158
|
const object = {};
|
|
211
159
|
for (const [key, value] of this.entries()) {
|
|
@@ -247,55 +195,50 @@ var HttpHeaders = class extends Headers {
|
|
|
247
195
|
super(pickPrimitiveProperties(init));
|
|
248
196
|
}
|
|
249
197
|
}
|
|
250
|
-
/** @see {@link https://
|
|
198
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API reference} */
|
|
251
199
|
set(name, value) {
|
|
252
200
|
super.set(name, value);
|
|
253
201
|
}
|
|
254
|
-
/** @see {@link https://
|
|
202
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API reference} */
|
|
255
203
|
append(name, value) {
|
|
256
204
|
super.append(name, value);
|
|
257
205
|
}
|
|
258
|
-
/** @see {@link https://
|
|
206
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */
|
|
259
207
|
get(name) {
|
|
260
208
|
return super.get(name);
|
|
261
209
|
}
|
|
262
|
-
/** @see {@link https://
|
|
210
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
|
|
263
211
|
getSetCookie() {
|
|
264
212
|
return super.getSetCookie();
|
|
265
213
|
}
|
|
266
|
-
/** @see {@link https://
|
|
214
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */
|
|
267
215
|
has(name) {
|
|
268
216
|
return super.has(name);
|
|
269
217
|
}
|
|
270
|
-
/** @see {@link https://
|
|
218
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */
|
|
271
219
|
delete(name) {
|
|
272
220
|
super.delete(name);
|
|
273
221
|
}
|
|
222
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
|
|
274
223
|
forEach(callback, thisArg) {
|
|
275
224
|
super.forEach(callback, thisArg);
|
|
276
225
|
}
|
|
277
|
-
/** @see {@link https://
|
|
226
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */
|
|
278
227
|
keys() {
|
|
279
228
|
return super.keys();
|
|
280
229
|
}
|
|
281
|
-
/** @see {@link https://
|
|
230
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */
|
|
282
231
|
values() {
|
|
283
232
|
return super.values();
|
|
284
233
|
}
|
|
285
|
-
/** @see {@link https://
|
|
234
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API reference} */
|
|
286
235
|
entries() {
|
|
287
236
|
return super.entries();
|
|
288
237
|
}
|
|
289
238
|
[Symbol.iterator]() {
|
|
290
239
|
return super[Symbol.iterator]();
|
|
291
240
|
}
|
|
292
|
-
/**
|
|
293
|
-
* Checks if this headers object is equal to another set of headers. Equality is defined as having the same keys and
|
|
294
|
-
* values, regardless of the order of keys.
|
|
295
|
-
*
|
|
296
|
-
* @param otherHeaders The other headers object to compare against.
|
|
297
|
-
* @returns `true` if the headers are equal, `false` otherwise.
|
|
298
|
-
*/
|
|
241
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */
|
|
299
242
|
equals(otherHeaders) {
|
|
300
243
|
if (!this.contains(otherHeaders)) {
|
|
301
244
|
return false;
|
|
@@ -308,14 +251,7 @@ var HttpHeaders = class extends Headers {
|
|
|
308
251
|
}
|
|
309
252
|
return true;
|
|
310
253
|
}
|
|
311
|
-
/**
|
|
312
|
-
* Checks if this headers object contains another set of headers. This method is less strict than
|
|
313
|
-
* {@link HttpHeaders#equals} and only requires that all keys and values in the other headers are present in these
|
|
314
|
-
* headers.
|
|
315
|
-
*
|
|
316
|
-
* @param otherHeaders The other headers object to compare against.
|
|
317
|
-
* @returns `true` if these headers contain the other headers, `false` otherwise.
|
|
318
|
-
*/
|
|
254
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */
|
|
319
255
|
contains(otherHeaders) {
|
|
320
256
|
for (const [key, otherValue] of otherHeaders.entries()) {
|
|
321
257
|
const value = super.get.call(this, key);
|
|
@@ -398,82 +334,54 @@ var HttpSearchParams = class extends URLSearchParams {
|
|
|
398
334
|
}
|
|
399
335
|
}
|
|
400
336
|
}
|
|
401
|
-
/** @see {@link https://
|
|
337
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API reference} */
|
|
402
338
|
set(name, value) {
|
|
403
339
|
super.set(name, value);
|
|
404
340
|
}
|
|
405
|
-
/** @see {@link https://
|
|
341
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API reference} */
|
|
406
342
|
append(name, value) {
|
|
407
343
|
super.append(name, value);
|
|
408
344
|
}
|
|
409
|
-
/**
|
|
410
|
-
* Get the value of the entry associated to a key name.
|
|
411
|
-
*
|
|
412
|
-
* If the key might have multiple values, use {@link HttpSearchParams#getAll} instead.
|
|
413
|
-
*
|
|
414
|
-
* @param name The name of the key to get the value of.
|
|
415
|
-
* @returns The value associated with the key name, or `null` if the key does not exist.
|
|
416
|
-
* @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}
|
|
417
|
-
*/
|
|
345
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */
|
|
418
346
|
get(name) {
|
|
419
347
|
return super.get(name);
|
|
420
348
|
}
|
|
421
|
-
/**
|
|
422
|
-
* Get all the values of the entry associated with a key name.
|
|
423
|
-
*
|
|
424
|
-
* If the key has at most one value, use {@link HttpSearchParams#get} instead.
|
|
425
|
-
*
|
|
426
|
-
* @param name The name of the key to get the values of.
|
|
427
|
-
* @returns An array of values associated with the key name, or an empty array if the key does not exist.
|
|
428
|
-
* @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}
|
|
429
|
-
*/
|
|
349
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */
|
|
430
350
|
getAll(name) {
|
|
431
351
|
return super.getAll(name);
|
|
432
352
|
}
|
|
433
|
-
/** @see {@link https://
|
|
353
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API reference} */
|
|
434
354
|
has(name, value) {
|
|
435
355
|
return super.has(name, value);
|
|
436
356
|
}
|
|
437
|
-
/** @see {@link https://
|
|
357
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API reference} */
|
|
438
358
|
delete(name, value) {
|
|
439
359
|
super.delete(name, value);
|
|
440
360
|
}
|
|
361
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
|
|
441
362
|
forEach(callback, thisArg) {
|
|
442
363
|
super.forEach(callback, thisArg);
|
|
443
364
|
}
|
|
444
|
-
/** @see {@link https://
|
|
365
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */
|
|
445
366
|
keys() {
|
|
446
367
|
return super.keys();
|
|
447
368
|
}
|
|
448
|
-
/** @see {@link https://
|
|
369
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API reference} */
|
|
449
370
|
values() {
|
|
450
371
|
return super.values();
|
|
451
372
|
}
|
|
452
|
-
/** @see {@link https://
|
|
373
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API reference} */
|
|
453
374
|
entries() {
|
|
454
375
|
return super.entries();
|
|
455
376
|
}
|
|
456
377
|
[Symbol.iterator]() {
|
|
457
378
|
return super[Symbol.iterator]();
|
|
458
379
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Checks if these search params are equal to another set of search parameters. Equality is defined as having the same
|
|
461
|
-
* keys and values, regardless of the order of the keys.
|
|
462
|
-
*
|
|
463
|
-
* @param otherParams The other search parameters to compare against.
|
|
464
|
-
* @returns `true` if the search parameters are equal, `false` otherwise.
|
|
465
|
-
*/
|
|
380
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */
|
|
466
381
|
equals(otherParams) {
|
|
467
382
|
return this.contains(otherParams) && this.size === otherParams.size;
|
|
468
383
|
}
|
|
469
|
-
/**
|
|
470
|
-
* Checks if these search params contain another set of search parameters. This method is less strict than
|
|
471
|
-
* {@link HttpSearchParams#equals} and only requires that all keys and values in the other search parameters are
|
|
472
|
-
* present in these search parameters.
|
|
473
|
-
*
|
|
474
|
-
* @param otherParams The other search parameters to check for containment.
|
|
475
|
-
* @returns `true` if these search parameters contain the other search parameters, `false` otherwise.
|
|
476
|
-
*/
|
|
384
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */
|
|
477
385
|
contains(otherParams) {
|
|
478
386
|
for (const [key, otherValue] of otherParams.entries()) {
|
|
479
387
|
const values = super.getAll.call(this, key);
|
|
@@ -488,24 +396,7 @@ var HttpSearchParams = class extends URLSearchParams {
|
|
|
488
396
|
}
|
|
489
397
|
return true;
|
|
490
398
|
}
|
|
491
|
-
/**
|
|
492
|
-
* Converts these search params into a plain object. This method is useful for serialization and debugging purposes.
|
|
493
|
-
*
|
|
494
|
-
* **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has
|
|
495
|
-
* only one value, the object will contain its value directly, without an array, regardless of how the value was
|
|
496
|
-
* initialized when creating the search params object.
|
|
497
|
-
*
|
|
498
|
-
* @example
|
|
499
|
-
* const searchParams = new HttpSearchParams({
|
|
500
|
-
* names: ['user 1', 'user 2'],
|
|
501
|
-
* name: ['user 3'],
|
|
502
|
-
* page: '1',
|
|
503
|
-
* });
|
|
504
|
-
* const object = searchParams.toObject();
|
|
505
|
-
* console.log(object); // { names: ['user 1', 'user 2'], name: 'user 3', page: '1' }
|
|
506
|
-
*
|
|
507
|
-
* @returns A plain object representation of these search params.
|
|
508
|
-
*/
|
|
399
|
+
/** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */
|
|
509
400
|
toObject() {
|
|
510
401
|
const object = {};
|
|
511
402
|
for (const [key, value] of this.entries()) {
|