@zimic/http 0.1.0-canary.2 → 0.1.0-canary.20
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/LICENSE.md +1 -1
- package/README.md +110 -180
- package/dist/{chunk-VHQRAQPQ.mjs → chunk-C5GWXTO5.mjs} +117 -140
- package/dist/chunk-C5GWXTO5.mjs.map +1 -0
- package/dist/{chunk-VUDGONB5.js → chunk-KDDZRZK6.js} +117 -140
- package/dist/chunk-KDDZRZK6.js.map +1 -0
- package/dist/cli.js +9 -9
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.ts +29 -38
- package/dist/index.js +17 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -19
- package/dist/index.mjs.map +1 -1
- package/dist/typegen.d.ts +1 -1
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +19 -16
- package/src/formData/HttpFormData.ts +2 -2
- package/src/formData/types.ts +1 -1
- package/src/headers/HttpHeaders.ts +12 -10
- package/src/headers/types.ts +1 -1
- package/src/index.ts +5 -0
- package/src/pathParams/types.ts +1 -1
- package/src/searchParams/HttpSearchParams.ts +1 -1
- package/src/searchParams/types.ts +1 -1
- package/src/typegen/index.ts +1 -1
- package/src/typegen/openapi/generate.ts +1 -2
- package/src/typegen/openapi/transform/components.ts +2 -3
- package/src/typegen/openapi/transform/filters.ts +3 -3
- package/src/typegen/openapi/transform/io.ts +3 -5
- package/src/typegen/openapi/transform/methods.ts +4 -5
- package/src/typegen/openapi/transform/operations.ts +2 -3
- package/src/typegen/openapi/transform/paths.ts +2 -3
- package/src/types/requests.ts +35 -2
- package/src/types/schema.ts +14 -32
- package/src/utils/console.ts +1 -1
- package/src/utils/files.ts +4 -24
- package/src/utils/prettier.ts +1 -1
- package/src/utils/time.ts +1 -1
- package/dist/chunk-VHQRAQPQ.mjs.map +0 -1
- package/dist/chunk-VUDGONB5.js.map +0 -1
- package/src/types/arrays.d.ts +0 -4
- package/src/types/objects.d.ts +0 -14
- package/src/types/strings.d.ts +0 -9
- package/src/types/utils.ts +0 -64
- package/src/utils/data.ts +0 -13
- package/src/utils/imports.ts +0 -12
- package/src/utils/urls.ts +0 -52
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import isDefined from '@zimic/utils/data/isDefined';
|
|
2
|
+
import { Override } from '@zimic/utils/types';
|
|
1
3
|
import ts from 'typescript';
|
|
2
4
|
|
|
3
|
-
import { Override } from '@/types/utils';
|
|
4
|
-
import { isDefined } from '@/utils/data';
|
|
5
|
-
|
|
6
5
|
import { isNeverType, isUnknownType } from '../utils/types';
|
|
7
6
|
import { ComponentPath, TypeTransformContext } from './context';
|
|
8
7
|
import { normalizeContentType, normalizeResponse } from './methods';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import isNonEmpty from '@zimic/utils/data/isNonEmpty';
|
|
2
|
+
import createRegExpFromWildcardPath from '@zimic/utils/url/createRegExpFromWildcardPath';
|
|
1
3
|
import chalk from 'chalk';
|
|
2
4
|
import filesystem from 'fs/promises';
|
|
3
5
|
import path from 'path';
|
|
4
6
|
|
|
5
7
|
import { HTTP_METHODS } from '@/types/schema';
|
|
6
8
|
import { logWithPrefix } from '@/utils/console';
|
|
7
|
-
import { isNonEmpty } from '@/utils/data';
|
|
8
|
-
import { createRegexFromWildcardPath } from '@/utils/urls';
|
|
9
9
|
|
|
10
10
|
import { TypePathFilters } from './context';
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@ export function parseRawFilter(rawFilter: string): ParsedTypePathFilter | undefi
|
|
|
36
36
|
const isNegativeMatch = filterModifier === '!';
|
|
37
37
|
|
|
38
38
|
return {
|
|
39
|
-
expression:
|
|
39
|
+
expression: createRegExpFromWildcardPath(filteredPath, { prefix: methodFilterGroup }),
|
|
40
40
|
isNegativeMatch,
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';
|
|
1
2
|
import type { SchemaObject } from 'openapi-typescript';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import ts from 'typescript';
|
|
4
5
|
|
|
5
|
-
import { createCachedDynamicImport } from '@/utils/imports';
|
|
6
|
-
import { createFileURL, createURL } from '@/utils/urls';
|
|
7
|
-
|
|
8
6
|
import { createBlobType, createNullType } from '../utils/types';
|
|
9
7
|
|
|
10
8
|
const importOpenapiTypeScript = createCachedDynamicImport(() => import('openapi-typescript'));
|
|
@@ -24,9 +22,9 @@ function transformSchemaObject(schemaObject: SchemaObject) {
|
|
|
24
22
|
|
|
25
23
|
function convertFilePathOrURLToURL(filePathOrURL: string) {
|
|
26
24
|
try {
|
|
27
|
-
return
|
|
25
|
+
return new URL(filePathOrURL);
|
|
28
26
|
} catch {
|
|
29
|
-
return
|
|
27
|
+
return new URL(`file://${path.resolve(filePathOrURL)}`);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import isDefined from '@zimic/utils/data/isDefined';
|
|
2
|
+
import { Override } from '@zimic/utils/types';
|
|
1
3
|
import chalk from 'chalk';
|
|
2
4
|
import ts from 'typescript';
|
|
3
5
|
|
|
4
6
|
import { HTTP_METHODS, HttpMethod } from '@/types/schema';
|
|
5
|
-
import { Override } from '@/types/utils';
|
|
6
7
|
import { logWithPrefix } from '@/utils/console';
|
|
7
|
-
import { isDefined } from '@/utils/data';
|
|
8
8
|
|
|
9
9
|
import { isUnknownType, isNeverType, isNullType } from '../utils/types';
|
|
10
10
|
import { renameComponentReferences } from './components';
|
|
@@ -332,9 +332,8 @@ export function normalizeContentType(
|
|
|
332
332
|
return [];
|
|
333
333
|
});
|
|
334
334
|
|
|
335
|
-
if (newBodyMembers.length
|
|
336
|
-
const
|
|
337
|
-
const newMembers = [newHeader, ...newBodyMemberPropertySignatures].filter(isDefined);
|
|
335
|
+
if (newBodyMembers.length === 0) {
|
|
336
|
+
const newMembers = [newHeader].filter(isDefined);
|
|
338
337
|
|
|
339
338
|
return ts.factory.updateTypeLiteralNode(contentType, ts.factory.createNodeArray(newMembers));
|
|
340
339
|
} else {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import isDefined from '@zimic/utils/data/isDefined';
|
|
2
|
+
import { Override } from '@zimic/utils/types';
|
|
1
3
|
import ts from 'typescript';
|
|
2
4
|
|
|
3
|
-
import { Override } from '@/types/utils';
|
|
4
|
-
import { isDefined } from '@/utils/data';
|
|
5
|
-
|
|
6
5
|
import { TypeTransformContext } from './context';
|
|
7
6
|
import { normalizeTypeLiteralMethodType } from './methods';
|
|
8
7
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import isDefined from '@zimic/utils/data/isDefined';
|
|
2
|
+
import { Override } from '@zimic/utils/types';
|
|
1
3
|
import ts from 'typescript';
|
|
2
4
|
|
|
3
|
-
import { Override } from '@/types/utils';
|
|
4
|
-
import { isDefined } from '@/utils/data';
|
|
5
|
-
|
|
6
5
|
import { renameComponentReferences } from './components';
|
|
7
6
|
import { TypeTransformContext } from './context';
|
|
8
7
|
import { normalizeMethod } from './methods';
|
package/src/types/requests.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Default, DefaultNoExclude, IfNever, ReplaceBy } from '@zimic/utils/types';
|
|
2
|
+
|
|
1
3
|
import { JSONSerialized, JSONValue } from '@/types/json';
|
|
2
|
-
import { HttpStatusCode } from '@/types/schema';
|
|
3
|
-
import { ReplaceBy } from '@/types/utils';
|
|
4
|
+
import { HttpMethodSchema, HttpStatusCode } from '@/types/schema';
|
|
4
5
|
|
|
5
6
|
import HttpFormData from '../formData/HttpFormData';
|
|
6
7
|
import { HttpFormDataSchema } from '../formData/types';
|
|
@@ -94,3 +95,35 @@ export interface HttpResponse<
|
|
|
94
95
|
>;
|
|
95
96
|
clone: () => this;
|
|
96
97
|
}
|
|
98
|
+
|
|
99
|
+
export type HttpRequestHeadersSchema<MethodSchema extends HttpMethodSchema> = Default<
|
|
100
|
+
Default<MethodSchema['request']>['headers']
|
|
101
|
+
>;
|
|
102
|
+
|
|
103
|
+
export type HttpRequestSearchParamsSchema<MethodSchema extends HttpMethodSchema> = Default<
|
|
104
|
+
Default<MethodSchema['request']>['searchParams']
|
|
105
|
+
>;
|
|
106
|
+
|
|
107
|
+
export type HttpRequestBodySchema<MethodSchema extends HttpMethodSchema> = ReplaceBy<
|
|
108
|
+
ReplaceBy<IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>, undefined, null>,
|
|
109
|
+
ArrayBuffer,
|
|
110
|
+
Blob
|
|
111
|
+
>;
|
|
112
|
+
|
|
113
|
+
export type HttpResponseHeadersSchema<
|
|
114
|
+
MethodSchema extends HttpMethodSchema,
|
|
115
|
+
StatusCode extends HttpStatusCode,
|
|
116
|
+
> = Default<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['headers']>>;
|
|
117
|
+
|
|
118
|
+
export type HttpResponseBodySchema<
|
|
119
|
+
MethodSchema extends HttpMethodSchema,
|
|
120
|
+
StatusCode extends HttpStatusCode,
|
|
121
|
+
> = ReplaceBy<
|
|
122
|
+
ReplaceBy<
|
|
123
|
+
IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>,
|
|
124
|
+
undefined,
|
|
125
|
+
null
|
|
126
|
+
>,
|
|
127
|
+
ArrayBuffer,
|
|
128
|
+
Blob
|
|
129
|
+
>;
|
package/src/types/schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IfAny, UnionToIntersection, UnionHasMoreThanOneType, Prettify, NonEmptyArray } from '
|
|
1
|
+
import { IfAny, UnionToIntersection, UnionHasMoreThanOneType, Prettify, NonEmptyArray } from '@zimic/utils/types';
|
|
2
2
|
|
|
3
3
|
import { HttpFormDataSchema, HttpFormDataSerialized } from '../formData/types';
|
|
4
4
|
import { HttpHeadersSchema, HttpHeadersSerialized } from '../headers/types';
|
|
@@ -29,7 +29,7 @@ export type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
|
29
29
|
/**
|
|
30
30
|
* A schema representing the structure of an HTTP request.
|
|
31
31
|
*
|
|
32
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
32
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
33
33
|
*/
|
|
34
34
|
export interface HttpRequestSchema {
|
|
35
35
|
headers?: HttpHeadersSchema.Loose;
|
|
@@ -50,7 +50,7 @@ type ConvertToStrictHttpRequestSchema<Schema> = {
|
|
|
50
50
|
/**
|
|
51
51
|
* A schema representing the structure of an HTTP response.
|
|
52
52
|
*
|
|
53
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
53
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
54
54
|
*/
|
|
55
55
|
export interface HttpResponseSchema {
|
|
56
56
|
headers?: HttpHeadersSchema.Loose;
|
|
@@ -204,7 +204,7 @@ export namespace HttpResponseSchemaByStatusCode {
|
|
|
204
204
|
/**
|
|
205
205
|
* A schema representing the structure of HTTP responses by status code.
|
|
206
206
|
*
|
|
207
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
207
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
208
208
|
*/
|
|
209
209
|
export type HttpResponseSchemaByStatusCode =
|
|
210
210
|
HttpResponseSchemaByStatusCode.ConvertToStrict<HttpResponseSchemaByStatusCode.Loose>;
|
|
@@ -216,7 +216,7 @@ type ConvertToStrictHttpResponseSchemaByStatusCode<Schema> = {
|
|
|
216
216
|
/**
|
|
217
217
|
* Extracts the status codes used in a response schema by status code.
|
|
218
218
|
*
|
|
219
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
219
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
220
220
|
*/
|
|
221
221
|
export type HttpResponseSchemaStatusCode<ResponseSchemaByStatusCode extends HttpResponseSchemaByStatusCode> =
|
|
222
222
|
keyof ResponseSchemaByStatusCode & HttpStatusCode;
|
|
@@ -224,7 +224,7 @@ export type HttpResponseSchemaStatusCode<ResponseSchemaByStatusCode extends Http
|
|
|
224
224
|
/**
|
|
225
225
|
* A schema representing the structure of an HTTP request and response for a given method.
|
|
226
226
|
*
|
|
227
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
227
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
228
228
|
*/
|
|
229
229
|
export interface HttpMethodSchema {
|
|
230
230
|
request?: HttpRequestSchema;
|
|
@@ -257,7 +257,7 @@ type ConvertToStrictMethod<Schema> = {
|
|
|
257
257
|
/**
|
|
258
258
|
* A schema representing the structure of HTTP request and response by method.
|
|
259
259
|
*
|
|
260
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
260
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
261
261
|
*/
|
|
262
262
|
export interface HttpMethodsSchema {
|
|
263
263
|
GET?: HttpMethodSchema.NoRequestBody;
|
|
@@ -284,9 +284,6 @@ export type ConvertToStrictHttpSchema<Schema extends HttpSchema> = {
|
|
|
284
284
|
/**
|
|
285
285
|
* Declares an HTTP service schema.
|
|
286
286
|
*
|
|
287
|
-
* **IMPORTANT**: the input of `HttpSchema` and all of its internal types, except bodies, must be declared inline or as
|
|
288
|
-
* a type aliases (`type`). Types other than bodies cannot be interfaces.
|
|
289
|
-
*
|
|
290
287
|
* @example
|
|
291
288
|
* import { type HttpSchema } from '@zimic/http';
|
|
292
289
|
*
|
|
@@ -317,7 +314,7 @@ export type ConvertToStrictHttpSchema<Schema extends HttpSchema> = {
|
|
|
317
314
|
* };
|
|
318
315
|
* }>;
|
|
319
316
|
*
|
|
320
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
317
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
321
318
|
*/
|
|
322
319
|
export type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = ConvertToStrictHttpSchema<Schema>;
|
|
323
320
|
|
|
@@ -325,9 +322,6 @@ export namespace HttpSchema {
|
|
|
325
322
|
/**
|
|
326
323
|
* Declares an HTTP service methods schema.
|
|
327
324
|
*
|
|
328
|
-
* **IMPORTANT**: the input of `HttpSchema.Methods` and all of its internal types, except bodies, must be declared
|
|
329
|
-
* inline or as a type aliases (`type`). Types other than bodies cannot be interfaces.
|
|
330
|
-
*
|
|
331
325
|
* @example
|
|
332
326
|
* import { type HttpSchema } from '@zimic/http';
|
|
333
327
|
*
|
|
@@ -348,9 +342,6 @@ export namespace HttpSchema {
|
|
|
348
342
|
/**
|
|
349
343
|
* Declares an HTTP service method schema.
|
|
350
344
|
*
|
|
351
|
-
* **IMPORTANT**: the input of `HttpSchema.Method` and all of its internal types, except bodies, must be declared
|
|
352
|
-
* inline or as a type aliases (`type`). Types other than bodies cannot be interfaces.
|
|
353
|
-
*
|
|
354
345
|
* @example
|
|
355
346
|
* import { type HttpSchema } from '@zimic/http';
|
|
356
347
|
*
|
|
@@ -371,9 +362,6 @@ export namespace HttpSchema {
|
|
|
371
362
|
/**
|
|
372
363
|
* Declares an HTTP service request schema.
|
|
373
364
|
*
|
|
374
|
-
* **IMPORTANT**: the input of `HttpSchema.Request` and all of its internal types, except bodies, must be declared
|
|
375
|
-
* inline or as a type aliases (`type`). Types other than bodies cannot be interfaces.
|
|
376
|
-
*
|
|
377
365
|
* @example
|
|
378
366
|
* import { type HttpSchema } from '@zimic/http';
|
|
379
367
|
*
|
|
@@ -398,9 +386,6 @@ export namespace HttpSchema {
|
|
|
398
386
|
/**
|
|
399
387
|
* Declares an HTTP service response schema by status code.
|
|
400
388
|
*
|
|
401
|
-
* **IMPORTANT**: the input of `HttpSchema.ResponseByStatusCode` and all of its internal types, except bodies, must be
|
|
402
|
-
* declared inline or as a type aliases (`type`). Types other than bodies cannot be interfaces.
|
|
403
|
-
*
|
|
404
389
|
* @example
|
|
405
390
|
* import { type HttpSchema } from '@zimic/http';
|
|
406
391
|
*
|
|
@@ -423,9 +408,6 @@ export namespace HttpSchema {
|
|
|
423
408
|
/**
|
|
424
409
|
* Declares an HTTP service response schema.
|
|
425
410
|
*
|
|
426
|
-
* **IMPORTANT**: the input of `HttpSchema.Response` and all of its internal types, except bodies, must be declared
|
|
427
|
-
* inline or as a type aliases (`type`). Types other than bodies cannot be interfaces.
|
|
428
|
-
*
|
|
429
411
|
* @example
|
|
430
412
|
* import { type HttpSchema } from '@zimic/http';
|
|
431
413
|
*
|
|
@@ -581,7 +563,7 @@ export namespace HttpSchema {
|
|
|
581
563
|
/**
|
|
582
564
|
* Extracts the methods from an HTTP service schema.
|
|
583
565
|
*
|
|
584
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
566
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
585
567
|
*/
|
|
586
568
|
export type HttpSchemaMethod<Schema extends HttpSchema> = IfAny<
|
|
587
569
|
Schema,
|
|
@@ -621,7 +603,7 @@ export type AllowAnyStringInPathParams<Path extends string> = Path extends `${in
|
|
|
621
603
|
* type GetPath = HttpSchemaPath<Schema, 'GET'>;
|
|
622
604
|
* // "/users"
|
|
623
605
|
*
|
|
624
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
606
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
625
607
|
*/
|
|
626
608
|
export namespace HttpSchemaPath {
|
|
627
609
|
type LooseLiteral<Schema extends HttpSchema, Method extends HttpMethod = HttpMethod> = {
|
|
@@ -654,7 +636,7 @@ export namespace HttpSchemaPath {
|
|
|
654
636
|
* type LiteralGetPath = HttpSchemaPath.Literal<Schema, 'GET'>;
|
|
655
637
|
* // "/users"
|
|
656
638
|
*
|
|
657
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
639
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
658
640
|
*/
|
|
659
641
|
export type Literal<
|
|
660
642
|
Schema extends HttpSchema,
|
|
@@ -687,7 +669,7 @@ export namespace HttpSchemaPath {
|
|
|
687
669
|
* type NonLiteralGetPath = HttpSchemaPath.NonLiteral<Schema, 'GET'>;
|
|
688
670
|
* // "/users"
|
|
689
671
|
*
|
|
690
|
-
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐
|
|
672
|
+
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}
|
|
691
673
|
*/
|
|
692
674
|
export type NonLiteral<
|
|
693
675
|
Schema extends HttpSchema,
|
|
@@ -746,7 +728,7 @@ type RecursiveInferPathParams<Path extends string> = Path extends `${infer _Pref
|
|
|
746
728
|
* @example
|
|
747
729
|
* import { HttpSchema, InferPathParams } from '@zimic/http';
|
|
748
730
|
*
|
|
749
|
-
* type
|
|
731
|
+
* type Schema = HttpSchema<{
|
|
750
732
|
* '/users/:userId': {
|
|
751
733
|
* GET: {
|
|
752
734
|
* response: { 200: { body: User } };
|
|
@@ -755,7 +737,7 @@ type RecursiveInferPathParams<Path extends string> = Path extends `${infer _Pref
|
|
|
755
737
|
* }>;
|
|
756
738
|
*
|
|
757
739
|
* // Using a schema to validate the path (recommended):
|
|
758
|
-
* type PathParams = InferPathParams<
|
|
740
|
+
* type PathParams = InferPathParams<Schema, '/users/:userId'>;
|
|
759
741
|
* // { userId: string }
|
|
760
742
|
*
|
|
761
743
|
* @example
|
package/src/utils/console.ts
CHANGED
package/src/utils/files.ts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createCachedDynamicImport } from './imports';
|
|
3
|
-
|
|
4
|
-
export const importBuffer = createCachedDynamicImport(
|
|
5
|
-
/* istanbul ignore next -- @preserve
|
|
6
|
-
* Ignoring as Node.js >=20 provides a global file and the buffer import won't run. */
|
|
7
|
-
() => import('buffer'),
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
let FileSingleton: typeof File | undefined;
|
|
11
|
-
|
|
12
|
-
export async function importFile() {
|
|
13
|
-
/* istanbul ignore if -- @preserve
|
|
14
|
-
* Ignoring as this will only run if this function is called more than once. */
|
|
15
|
-
if (FileSingleton) {
|
|
16
|
-
return FileSingleton;
|
|
17
|
-
}
|
|
1
|
+
import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';
|
|
18
2
|
|
|
3
|
+
export const importFile = createCachedDynamicImport(
|
|
19
4
|
/* istanbul ignore next -- @preserve
|
|
20
5
|
* Ignoring as Node.js >=20 provides a global File and the import fallback won't run. */
|
|
21
6
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function fileEquals(file: File, otherFile: File) {
|
|
27
|
-
return file.name === otherFile.name && (await blobEquals(file, otherFile));
|
|
28
|
-
}
|
|
7
|
+
async () => globalThis.File ?? (await import('buffer')).File,
|
|
8
|
+
);
|
package/src/utils/prettier.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import prettier, { Options } from 'prettier';
|
|
1
|
+
import prettier, { Options } from 'prettier';
|
|
2
2
|
|
|
3
3
|
export async function resolvedPrettierConfig(fileName: string): Promise<Options> {
|
|
4
4
|
const config = await prettier.resolveConfig(fileName);
|
package/src/utils/time.ts
CHANGED