fets 0.4.1 → 0.4.2
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/package.json
CHANGED
|
@@ -3,11 +3,14 @@ import type { O } from 'ts-toolbelt';
|
|
|
3
3
|
import { HTTPMethod, NotOkStatusCode, StatusCode, TypedResponse } from '../typed-fetch.cjs';
|
|
4
4
|
import type { FromSchema, JSONSchema, OpenAPIDocument } from '../types.cjs';
|
|
5
5
|
import type { OASOAuthPath, OAuth2AuthParams } from './auth/oauth.cjs';
|
|
6
|
+
type JSONSchema7TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
6
7
|
type Mutable<Type> = {
|
|
7
8
|
-readonly [Key in keyof Type]: Mutable<Type[Key]>;
|
|
8
9
|
};
|
|
9
10
|
type RefToPath<T extends string> = T extends `#/${infer Ref}` ? Call<Strings.Split<'/'>, Ref> : never;
|
|
10
|
-
type ResolveRef<TObj, TRef extends string> =
|
|
11
|
+
type ResolveRef<TObj, TRef extends string> = {
|
|
12
|
+
$id: TRef;
|
|
13
|
+
} & O.Path<TObj, RefToPath<TRef>>;
|
|
11
14
|
type ResolveRefInObj<T, TBase> = FixJSONSchema<T extends {
|
|
12
15
|
$ref: infer Ref;
|
|
13
16
|
} ? (Ref extends string ? ResolveRef<TBase, Ref> : T) : T>;
|
|
@@ -46,7 +49,7 @@ export type OASParamObj<TParameter extends {
|
|
|
46
49
|
[TName in TParameter['name']]: TParameter extends {
|
|
47
50
|
schema: JSONSchema;
|
|
48
51
|
} ? FromSchema<TParameter['schema']> : TParameter extends {
|
|
49
|
-
type:
|
|
52
|
+
type: JSONSchema7TypeName;
|
|
50
53
|
} ? FromSchema<{
|
|
51
54
|
type: TParameter['type'];
|
|
52
55
|
}> : unknown;
|
|
@@ -54,7 +57,7 @@ export type OASParamObj<TParameter extends {
|
|
|
54
57
|
[TName in TParameter['name']]?: TParameter extends {
|
|
55
58
|
schema: JSONSchema;
|
|
56
59
|
} ? FromSchema<TParameter['schema']> : TParameter extends {
|
|
57
|
-
type:
|
|
60
|
+
type: JSONSchema7TypeName;
|
|
58
61
|
} ? FromSchema<{
|
|
59
62
|
type: TParameter['type'];
|
|
60
63
|
}> : unknown;
|
|
@@ -3,11 +3,14 @@ import type { O } from 'ts-toolbelt';
|
|
|
3
3
|
import { HTTPMethod, NotOkStatusCode, StatusCode, TypedResponse } from '../typed-fetch.js';
|
|
4
4
|
import type { FromSchema, JSONSchema, OpenAPIDocument } from '../types.js';
|
|
5
5
|
import type { OASOAuthPath, OAuth2AuthParams } from './auth/oauth.js';
|
|
6
|
+
type JSONSchema7TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
6
7
|
type Mutable<Type> = {
|
|
7
8
|
-readonly [Key in keyof Type]: Mutable<Type[Key]>;
|
|
8
9
|
};
|
|
9
10
|
type RefToPath<T extends string> = T extends `#/${infer Ref}` ? Call<Strings.Split<'/'>, Ref> : never;
|
|
10
|
-
type ResolveRef<TObj, TRef extends string> =
|
|
11
|
+
type ResolveRef<TObj, TRef extends string> = {
|
|
12
|
+
$id: TRef;
|
|
13
|
+
} & O.Path<TObj, RefToPath<TRef>>;
|
|
11
14
|
type ResolveRefInObj<T, TBase> = FixJSONSchema<T extends {
|
|
12
15
|
$ref: infer Ref;
|
|
13
16
|
} ? (Ref extends string ? ResolveRef<TBase, Ref> : T) : T>;
|
|
@@ -46,7 +49,7 @@ export type OASParamObj<TParameter extends {
|
|
|
46
49
|
[TName in TParameter['name']]: TParameter extends {
|
|
47
50
|
schema: JSONSchema;
|
|
48
51
|
} ? FromSchema<TParameter['schema']> : TParameter extends {
|
|
49
|
-
type:
|
|
52
|
+
type: JSONSchema7TypeName;
|
|
50
53
|
} ? FromSchema<{
|
|
51
54
|
type: TParameter['type'];
|
|
52
55
|
}> : unknown;
|
|
@@ -54,7 +57,7 @@ export type OASParamObj<TParameter extends {
|
|
|
54
57
|
[TName in TParameter['name']]?: TParameter extends {
|
|
55
58
|
schema: JSONSchema;
|
|
56
59
|
} ? FromSchema<TParameter['schema']> : TParameter extends {
|
|
57
|
-
type:
|
|
60
|
+
type: JSONSchema7TypeName;
|
|
58
61
|
} ? FromSchema<{
|
|
59
62
|
type: TParameter['type'];
|
|
60
63
|
}> : unknown;
|
package/typings/index.d.cts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './types.cjs';
|
|
|
2
2
|
export * from './createRouter.cjs';
|
|
3
3
|
export { URLPattern } from '@whatwg-node/fetch';
|
|
4
4
|
export { useCORS, useErrorHandling, HTTPError } from '@whatwg-node/server';
|
|
5
|
-
export { FromSchema } from 'json-schema-to-ts';
|
|
6
5
|
export * from './client/index.cjs';
|
|
7
6
|
export * from './Response.cjs';
|
|
8
7
|
export { useAjv } from './plugins/ajv.cjs';
|
package/typings/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './types.js';
|
|
|
2
2
|
export * from './createRouter.js';
|
|
3
3
|
export { URLPattern } from '@whatwg-node/fetch';
|
|
4
4
|
export { useCORS, useErrorHandling, HTTPError } from '@whatwg-node/server';
|
|
5
|
-
export { FromSchema } from 'json-schema-to-ts';
|
|
6
5
|
export * from './client/index.js';
|
|
7
6
|
export * from './Response.js';
|
|
8
7
|
export { useAjv } from './plugins/ajv.js';
|
package/typings/types.d.cts
CHANGED
|
@@ -69,7 +69,7 @@ export type RouterComponentsBase = {
|
|
|
69
69
|
schemas?: Record<string, JSONSchema>;
|
|
70
70
|
};
|
|
71
71
|
export type FromSchema<T> = T extends JSONSchema ? FromSchemaOriginal<T, {
|
|
72
|
-
deserialize: [
|
|
72
|
+
deserialize: T extends T['properties'][keyof T['properties']] ? false : [
|
|
73
73
|
{
|
|
74
74
|
pattern: {
|
|
75
75
|
type: 'string';
|
package/typings/types.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type RouterComponentsBase = {
|
|
|
69
69
|
schemas?: Record<string, JSONSchema>;
|
|
70
70
|
};
|
|
71
71
|
export type FromSchema<T> = T extends JSONSchema ? FromSchemaOriginal<T, {
|
|
72
|
-
deserialize: [
|
|
72
|
+
deserialize: T extends T['properties'][keyof T['properties']] ? false : [
|
|
73
73
|
{
|
|
74
74
|
pattern: {
|
|
75
75
|
type: 'string';
|