@fuman/fetch 0.0.8 → 0.0.11
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/addons/parse/_types.d.cts +5 -0
- package/addons/parse/_types.d.ts +5 -0
- package/addons/parse/adapters/valibot.d.cts +2 -1
- package/addons/parse/adapters/valibot.d.ts +2 -1
- package/addons/parse/adapters/valita.d.cts +1 -0
- package/addons/parse/adapters/valita.d.ts +1 -0
- package/addons/parse/adapters/yup.d.cts +10 -1
- package/addons/parse/adapters/yup.d.ts +10 -1
- package/addons/parse/adapters/zod.d.cts +2 -1
- package/addons/parse/adapters/zod.d.ts +2 -1
- package/addons/parse/addon.cjs +3 -0
- package/addons/parse/addon.d.cts +2 -1
- package/addons/parse/addon.d.ts +2 -1
- package/addons/parse/addon.js +3 -0
- package/ffetch.cjs +3 -0
- package/ffetch.d.cts +1 -1
- package/ffetch.d.ts +1 -1
- package/ffetch.js +3 -0
- package/package.json +2 -2
- package/valibot.cjs +7 -1
- package/valibot.js +8 -2
- package/valita.cjs +3 -0
- package/valita.js +3 -0
- package/yup.cjs +19 -3
- package/yup.js +19 -3
- package/zod.cjs +7 -1
- package/zod.js +7 -1
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export interface FfetchTypeProvider {
|
|
2
2
|
readonly schema: unknown;
|
|
3
3
|
readonly parsed: unknown;
|
|
4
|
+
readonly safeParsed: unknown;
|
|
4
5
|
}
|
|
5
6
|
export interface FfetchParser<TypeProvider extends FfetchTypeProvider> {
|
|
6
7
|
readonly _provider: TypeProvider;
|
|
7
8
|
parse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
9
|
+
safeParse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
8
10
|
}
|
|
9
11
|
export type CallTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
10
12
|
schema: Schema;
|
|
11
13
|
})['parsed'];
|
|
14
|
+
export type CallSafeTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
15
|
+
schema: Schema;
|
|
16
|
+
})['safeParsed'];
|
package/addons/parse/_types.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export interface FfetchTypeProvider {
|
|
2
2
|
readonly schema: unknown;
|
|
3
3
|
readonly parsed: unknown;
|
|
4
|
+
readonly safeParsed: unknown;
|
|
4
5
|
}
|
|
5
6
|
export interface FfetchParser<TypeProvider extends FfetchTypeProvider> {
|
|
6
7
|
readonly _provider: TypeProvider;
|
|
7
8
|
parse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
9
|
+
safeParse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
8
10
|
}
|
|
9
11
|
export type CallTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
10
12
|
schema: Schema;
|
|
11
13
|
})['parsed'];
|
|
14
|
+
export type CallSafeTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
15
|
+
schema: Schema;
|
|
16
|
+
})['safeParsed'];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferOutput } from 'valibot';
|
|
1
|
+
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferOutput, SafeParseResult } from 'valibot';
|
|
2
2
|
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
3
|
export interface ValibotTypeProvider extends FfetchTypeProvider {
|
|
4
4
|
readonly parsed: this['schema'] extends (BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>) ? InferOutput<this['schema']> : never;
|
|
5
|
+
readonly safeParsed: this['schema'] extends (BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>) ? SafeParseResult<this['schema']> : never;
|
|
5
6
|
}
|
|
6
7
|
export declare function ffetchValibotAdapter({ async, ...rest }?: Partial<Config<BaseIssue<unknown>>> & {
|
|
7
8
|
async?: boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferOutput } from 'valibot';
|
|
1
|
+
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferOutput, SafeParseResult } from 'valibot';
|
|
2
2
|
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
3
|
export interface ValibotTypeProvider extends FfetchTypeProvider {
|
|
4
4
|
readonly parsed: this['schema'] extends (BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>) ? InferOutput<this['schema']> : never;
|
|
5
|
+
readonly safeParsed: this['schema'] extends (BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>) ? SafeParseResult<this['schema']> : never;
|
|
5
6
|
}
|
|
6
7
|
export declare function ffetchValibotAdapter({ async, ...rest }?: Partial<Config<BaseIssue<unknown>>> & {
|
|
7
8
|
async?: boolean;
|
|
@@ -2,6 +2,7 @@ import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
|
2
2
|
import type * as v from '@badrap/valita';
|
|
3
3
|
export interface ValitaTypeProvider extends FfetchTypeProvider {
|
|
4
4
|
readonly parsed: this['schema'] extends v.Type<any> ? v.Infer<this['schema']> : never;
|
|
5
|
+
readonly safeParsed: this['schema'] extends v.Type<any> ? v.ValitaResult<v.Infer<this['schema']>> : never;
|
|
5
6
|
}
|
|
6
7
|
type ParseOptions = NonNullable<Parameters<v.Type<any>['parse']>[1]>;
|
|
7
8
|
export declare function ffetchValitaAdapter(options?: ParseOptions): FfetchParser<ValitaTypeProvider>;
|
|
@@ -2,6 +2,7 @@ import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
|
2
2
|
import type * as v from '@badrap/valita';
|
|
3
3
|
export interface ValitaTypeProvider extends FfetchTypeProvider {
|
|
4
4
|
readonly parsed: this['schema'] extends v.Type<any> ? v.Infer<this['schema']> : never;
|
|
5
|
+
readonly safeParsed: this['schema'] extends v.Type<any> ? v.ValitaResult<v.Infer<this['schema']>> : never;
|
|
5
6
|
}
|
|
6
7
|
type ParseOptions = NonNullable<Parameters<v.Type<any>['parse']>[1]>;
|
|
7
8
|
export declare function ffetchValitaAdapter(options?: ParseOptions): FfetchParser<ValitaTypeProvider>;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { CastOptions, InferType, ISchema, ValidateOptions } from 'yup';
|
|
1
|
+
import { CastOptions, InferType, ISchema, ValidateOptions, ValidationError } from 'yup';
|
|
2
2
|
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
|
+
type YupSafeParseResult<R> = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: R;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
error: ValidationError;
|
|
9
|
+
};
|
|
3
10
|
export interface YupTypeProvider extends FfetchTypeProvider {
|
|
4
11
|
readonly parsed: this['schema'] extends ISchema<any, any> ? InferType<this['schema']> : never;
|
|
12
|
+
readonly safeParsed: this['schema'] extends ISchema<any, any> ? YupSafeParseResult<InferType<this['schema']>> : never;
|
|
5
13
|
}
|
|
6
14
|
export type FfetchYupAdapterOptions = {
|
|
7
15
|
action: 'cast';
|
|
@@ -11,3 +19,4 @@ export type FfetchYupAdapterOptions = {
|
|
|
11
19
|
options?: ValidateOptions;
|
|
12
20
|
};
|
|
13
21
|
export declare function ffetchYupAdapter({ action, options, }?: FfetchYupAdapterOptions): FfetchParser<YupTypeProvider>;
|
|
22
|
+
export {};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { CastOptions, InferType, ISchema, ValidateOptions } from 'yup';
|
|
1
|
+
import { CastOptions, InferType, ISchema, ValidateOptions, ValidationError } from 'yup';
|
|
2
2
|
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
|
+
type YupSafeParseResult<R> = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: R;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
error: ValidationError;
|
|
9
|
+
};
|
|
3
10
|
export interface YupTypeProvider extends FfetchTypeProvider {
|
|
4
11
|
readonly parsed: this['schema'] extends ISchema<any, any> ? InferType<this['schema']> : never;
|
|
12
|
+
readonly safeParsed: this['schema'] extends ISchema<any, any> ? YupSafeParseResult<InferType<this['schema']>> : never;
|
|
5
13
|
}
|
|
6
14
|
export type FfetchYupAdapterOptions = {
|
|
7
15
|
action: 'cast';
|
|
@@ -11,3 +19,4 @@ export type FfetchYupAdapterOptions = {
|
|
|
11
19
|
options?: ValidateOptions;
|
|
12
20
|
};
|
|
13
21
|
export declare function ffetchYupAdapter({ action, options, }?: FfetchYupAdapterOptions): FfetchParser<YupTypeProvider>;
|
|
22
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ParseParams, z } from 'zod';
|
|
1
|
+
import { ParseParams, SafeParseReturnType, z } from 'zod';
|
|
2
2
|
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
3
|
export interface ZodTypeProvider extends FfetchTypeProvider {
|
|
4
4
|
readonly parsed: this['schema'] extends z.ZodTypeAny ? z.infer<this['schema']> : never;
|
|
5
|
+
readonly safeParsed: this['schema'] extends z.ZodTypeAny ? SafeParseReturnType<this['schema'], z.infer<this['schema']>> : never;
|
|
5
6
|
}
|
|
6
7
|
export declare function ffetchZodAdapter({ async, ...rest }?: Partial<ParseParams>): FfetchParser<ZodTypeProvider>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ParseParams, z } from 'zod';
|
|
1
|
+
import { ParseParams, SafeParseReturnType, z } from 'zod';
|
|
2
2
|
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
3
|
export interface ZodTypeProvider extends FfetchTypeProvider {
|
|
4
4
|
readonly parsed: this['schema'] extends z.ZodTypeAny ? z.infer<this['schema']> : never;
|
|
5
|
+
readonly safeParsed: this['schema'] extends z.ZodTypeAny ? SafeParseReturnType<this['schema'], z.infer<this['schema']>> : never;
|
|
5
6
|
}
|
|
6
7
|
export declare function ffetchZodAdapter({ async, ...rest }?: Partial<ParseParams>): FfetchParser<ZodTypeProvider>;
|
package/addons/parse/addon.cjs
CHANGED
package/addons/parse/addon.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FfetchAddon } from '../types.js';
|
|
2
|
-
import { CallTypeProvider, FfetchParser, FfetchTypeProvider } from './_types.js';
|
|
2
|
+
import { CallSafeTypeProvider, CallTypeProvider, FfetchParser, FfetchTypeProvider } from './_types.js';
|
|
3
3
|
export { FfetchParser, FfetchTypeProvider };
|
|
4
4
|
export declare function parser<TypeProvider extends FfetchTypeProvider>(parser: FfetchParser<TypeProvider>): FfetchAddon<object, {
|
|
5
5
|
parsedJson: <Schema>(schema: Schema) => Promise<CallTypeProvider<TypeProvider, Schema>>;
|
|
6
|
+
safelyParsedJson: <Schema>(schema: Schema) => Promise<CallSafeTypeProvider<TypeProvider, Schema>>;
|
|
6
7
|
}>;
|
package/addons/parse/addon.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FfetchAddon } from '../types.js';
|
|
2
|
-
import { CallTypeProvider, FfetchParser, FfetchTypeProvider } from './_types.js';
|
|
2
|
+
import { CallSafeTypeProvider, CallTypeProvider, FfetchParser, FfetchTypeProvider } from './_types.js';
|
|
3
3
|
export { FfetchParser, FfetchTypeProvider };
|
|
4
4
|
export declare function parser<TypeProvider extends FfetchTypeProvider>(parser: FfetchParser<TypeProvider>): FfetchAddon<object, {
|
|
5
5
|
parsedJson: <Schema>(schema: Schema) => Promise<CallTypeProvider<TypeProvider, Schema>>;
|
|
6
|
+
safelyParsedJson: <Schema>(schema: Schema) => Promise<CallSafeTypeProvider<TypeProvider, Schema>>;
|
|
6
7
|
}>;
|
package/addons/parse/addon.js
CHANGED
package/ffetch.cjs
CHANGED
|
@@ -108,6 +108,9 @@ ${stack}`;
|
|
|
108
108
|
const res = await this.raw();
|
|
109
109
|
return res.arrayBuffer();
|
|
110
110
|
}
|
|
111
|
+
async bytes() {
|
|
112
|
+
return new Uint8Array(await this.arrayBuffer());
|
|
113
|
+
}
|
|
111
114
|
async blob() {
|
|
112
115
|
this._headers ??= {};
|
|
113
116
|
this._headers.Accept ??= OCTET_STREAM_CONTENT_TYPE;
|
package/ffetch.d.cts
CHANGED
|
@@ -96,7 +96,7 @@ export interface Ffetch<RequestMixin, ResponseMixin> {
|
|
|
96
96
|
extend: <const Addons extends FfetchAddon<any, any>[], Combined extends {
|
|
97
97
|
request: object;
|
|
98
98
|
response: object;
|
|
99
|
-
} = CombineAddons<Addons>>(baseOptions: FfetchBaseOptions<Addons> & Combined['request']) => Ffetch<RequestMixin & Combined['request'], ResponseMixin & Combined['response']>;
|
|
99
|
+
} = CombineAddons<Addons>>(baseOptions: FfetchBaseOptions<Addons> & RequestMixin & Combined['request']) => Ffetch<RequestMixin & Combined['request'], ResponseMixin & Combined['response']>;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* an error that is thrown when the response status is not 2xx,
|
package/ffetch.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export interface Ffetch<RequestMixin, ResponseMixin> {
|
|
|
96
96
|
extend: <const Addons extends FfetchAddon<any, any>[], Combined extends {
|
|
97
97
|
request: object;
|
|
98
98
|
response: object;
|
|
99
|
-
} = CombineAddons<Addons>>(baseOptions: FfetchBaseOptions<Addons> & Combined['request']) => Ffetch<RequestMixin & Combined['request'], ResponseMixin & Combined['response']>;
|
|
99
|
+
} = CombineAddons<Addons>>(baseOptions: FfetchBaseOptions<Addons> & RequestMixin & Combined['request']) => Ffetch<RequestMixin & Combined['request'], ResponseMixin & Combined['response']>;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* an error that is thrown when the response status is not 2xx,
|
package/ffetch.js
CHANGED
|
@@ -106,6 +106,9 @@ ${stack}`;
|
|
|
106
106
|
const res = await this.raw();
|
|
107
107
|
return res.arrayBuffer();
|
|
108
108
|
}
|
|
109
|
+
async bytes() {
|
|
110
|
+
return new Uint8Array(await this.arrayBuffer());
|
|
111
|
+
}
|
|
109
112
|
async blob() {
|
|
110
113
|
this._headers ??= {};
|
|
111
114
|
this._headers.Accept ??= OCTET_STREAM_CONTENT_TYPE;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuman/fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"description": "tiny wrapper over fetch",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@fuman/utils": "^0.0.
|
|
8
|
+
"@fuman/utils": "^0.0.11"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@badrap/valita": ">=0.4.0",
|
package/valibot.cjs
CHANGED
|
@@ -8,9 +8,15 @@ function ffetchValibotAdapter({ async, ...rest } = {}) {
|
|
|
8
8
|
} : function(schema, value) {
|
|
9
9
|
return valibot.parse(schema, value, rest);
|
|
10
10
|
};
|
|
11
|
+
const safeParser = async ? async function(schema, value) {
|
|
12
|
+
return valibot.safeParseAsync(schema, value, rest);
|
|
13
|
+
} : function(schema, value) {
|
|
14
|
+
return valibot.safeParse(schema, value, rest);
|
|
15
|
+
};
|
|
11
16
|
return {
|
|
12
17
|
_provider,
|
|
13
|
-
parse: parser
|
|
18
|
+
parse: parser,
|
|
19
|
+
safeParse: safeParser
|
|
14
20
|
};
|
|
15
21
|
}
|
|
16
22
|
exports.ffetchValibotAdapter = ffetchValibotAdapter;
|
package/valibot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseAsync, parse } from "valibot";
|
|
1
|
+
import { parseAsync, parse, safeParseAsync, safeParse } from "valibot";
|
|
2
2
|
function ffetchValibotAdapter({ async, ...rest } = {}) {
|
|
3
3
|
const _provider = null;
|
|
4
4
|
const parser = async ? async function(schema, value) {
|
|
@@ -6,9 +6,15 @@ function ffetchValibotAdapter({ async, ...rest } = {}) {
|
|
|
6
6
|
} : function(schema, value) {
|
|
7
7
|
return parse(schema, value, rest);
|
|
8
8
|
};
|
|
9
|
+
const safeParser = async ? async function(schema, value) {
|
|
10
|
+
return safeParseAsync(schema, value, rest);
|
|
11
|
+
} : function(schema, value) {
|
|
12
|
+
return safeParse(schema, value, rest);
|
|
13
|
+
};
|
|
9
14
|
return {
|
|
10
15
|
_provider,
|
|
11
|
-
parse: parser
|
|
16
|
+
parse: parser,
|
|
17
|
+
safeParse: safeParser
|
|
12
18
|
};
|
|
13
19
|
}
|
|
14
20
|
export {
|
package/valita.cjs
CHANGED
package/valita.js
CHANGED
package/yup.cjs
CHANGED
|
@@ -5,14 +5,30 @@ function ffetchYupAdapter({
|
|
|
5
5
|
options
|
|
6
6
|
} = { action: "validate" }) {
|
|
7
7
|
const _provider = null;
|
|
8
|
-
const parse = action === "cast" ?
|
|
8
|
+
const parse = action === "cast" ? function(schema, value) {
|
|
9
9
|
return schema.cast(value, options);
|
|
10
|
-
} : function(schema, value) {
|
|
10
|
+
} : async function(schema, value) {
|
|
11
11
|
return schema.validate(value, options);
|
|
12
12
|
};
|
|
13
|
+
const safeParse = action === "cast" ? function(schema, value) {
|
|
14
|
+
try {
|
|
15
|
+
const data = schema.cast(value, options);
|
|
16
|
+
return { success: true, data };
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return { success: false, error: e };
|
|
19
|
+
}
|
|
20
|
+
} : async function(schema, value) {
|
|
21
|
+
try {
|
|
22
|
+
const data = await schema.validate(value, options);
|
|
23
|
+
return { success: true, data };
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return { success: false, error: e };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
13
28
|
return {
|
|
14
29
|
_provider,
|
|
15
|
-
parse
|
|
30
|
+
parse,
|
|
31
|
+
safeParse
|
|
16
32
|
};
|
|
17
33
|
}
|
|
18
34
|
exports.ffetchYupAdapter = ffetchYupAdapter;
|
package/yup.js
CHANGED
|
@@ -3,14 +3,30 @@ function ffetchYupAdapter({
|
|
|
3
3
|
options
|
|
4
4
|
} = { action: "validate" }) {
|
|
5
5
|
const _provider = null;
|
|
6
|
-
const parse = action === "cast" ?
|
|
6
|
+
const parse = action === "cast" ? function(schema, value) {
|
|
7
7
|
return schema.cast(value, options);
|
|
8
|
-
} : function(schema, value) {
|
|
8
|
+
} : async function(schema, value) {
|
|
9
9
|
return schema.validate(value, options);
|
|
10
10
|
};
|
|
11
|
+
const safeParse = action === "cast" ? function(schema, value) {
|
|
12
|
+
try {
|
|
13
|
+
const data = schema.cast(value, options);
|
|
14
|
+
return { success: true, data };
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return { success: false, error: e };
|
|
17
|
+
}
|
|
18
|
+
} : async function(schema, value) {
|
|
19
|
+
try {
|
|
20
|
+
const data = await schema.validate(value, options);
|
|
21
|
+
return { success: true, data };
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return { success: false, error: e };
|
|
24
|
+
}
|
|
25
|
+
};
|
|
11
26
|
return {
|
|
12
27
|
_provider,
|
|
13
|
-
parse
|
|
28
|
+
parse,
|
|
29
|
+
safeParse
|
|
14
30
|
};
|
|
15
31
|
}
|
|
16
32
|
export {
|
package/zod.cjs
CHANGED
|
@@ -7,9 +7,15 @@ function ffetchZodAdapter({ async, ...rest } = {}) {
|
|
|
7
7
|
} : function(schema, value) {
|
|
8
8
|
return schema.parse(value, rest);
|
|
9
9
|
};
|
|
10
|
+
const safeParse = async ? async function(schema, value) {
|
|
11
|
+
return schema.safeParseAsync(value, rest);
|
|
12
|
+
} : function(schema, value) {
|
|
13
|
+
return schema.safeParse(value, rest);
|
|
14
|
+
};
|
|
10
15
|
return {
|
|
11
16
|
_provider,
|
|
12
|
-
parse
|
|
17
|
+
parse,
|
|
18
|
+
safeParse
|
|
13
19
|
};
|
|
14
20
|
}
|
|
15
21
|
exports.ffetchZodAdapter = ffetchZodAdapter;
|
package/zod.js
CHANGED
|
@@ -5,9 +5,15 @@ function ffetchZodAdapter({ async, ...rest } = {}) {
|
|
|
5
5
|
} : function(schema, value) {
|
|
6
6
|
return schema.parse(value, rest);
|
|
7
7
|
};
|
|
8
|
+
const safeParse = async ? async function(schema, value) {
|
|
9
|
+
return schema.safeParseAsync(value, rest);
|
|
10
|
+
} : function(schema, value) {
|
|
11
|
+
return schema.safeParse(value, rest);
|
|
12
|
+
};
|
|
8
13
|
return {
|
|
9
14
|
_provider,
|
|
10
|
-
parse
|
|
15
|
+
parse,
|
|
16
|
+
safeParse
|
|
11
17
|
};
|
|
12
18
|
}
|
|
13
19
|
export {
|