@fuman/fetch 0.1.1 → 0.1.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/README.md +3 -1
- package/addons/bundle.cjs +1 -0
- package/addons/bundle.js +2 -1
- package/addons/parse/addon.cjs +29 -3
- package/addons/parse/addon.d.cts +11 -6
- package/addons/parse/addon.d.ts +11 -6
- package/addons/parse/addon.js +29 -3
- package/default.cjs +3 -1
- package/default.d.cts +3 -2
- package/default.d.ts +3 -2
- package/default.js +3 -1
- package/package.json +4 -59
- package/addons/parse/_types.d.cts +0 -16
- package/addons/parse/_types.d.ts +0 -16
- package/addons/parse/adapters/valibot.d.cts +0 -9
- package/addons/parse/adapters/valibot.d.ts +0 -9
- package/addons/parse/adapters/valita.d.cts +0 -9
- package/addons/parse/adapters/valita.d.ts +0 -9
- package/addons/parse/adapters/yup.d.cts +0 -22
- package/addons/parse/adapters/yup.d.ts +0 -22
- package/addons/parse/adapters/zod.d.cts +0 -7
- package/addons/parse/adapters/zod.d.ts +0 -7
- package/valibot.cjs +0 -22
- package/valibot.d.cts +0 -1
- package/valibot.d.ts +0 -1
- package/valibot.js +0 -22
- package/valita.cjs +0 -15
- package/valita.d.cts +0 -1
- package/valita.d.ts +0 -1
- package/valita.js +0 -15
- package/yup.cjs +0 -34
- package/yup.d.cts +0 -1
- package/yup.d.ts +0 -1
- package/yup.js +0 -34
- package/zod.cjs +0 -21
- package/zod.d.cts +0 -1
- package/zod.d.ts +0 -1
- package/zod.js +0 -21
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# `@fuman/fetch`
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
no-bullshit minimal wrapper around `window.fetch` that aims to improve dx
|
|
4
6
|
by adding commonly used features, while having low runtime overhead,
|
|
5
7
|
small bundle size and staying close to the web standards.
|
|
@@ -10,4 +12,4 @@ small bundle size and staying close to the web standards.
|
|
|
10
12
|
- base url, base headers, etc.
|
|
11
13
|
- retries, timeouts, validation built in
|
|
12
14
|
- basic middlewares
|
|
13
|
-
- **type-safe** compatibility with popular parsing libraries
|
|
15
|
+
- **type-safe** compatibility with popular parsing libraries thanks to [standard-schema](https://github.com/standard-schema/standard-schema)
|
package/addons/bundle.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const retry = require("./retry.cjs");
|
|
|
9
9
|
const timeout = require("./timeout.cjs");
|
|
10
10
|
exports.form = form.form;
|
|
11
11
|
exports.multipart = multipart.multipart;
|
|
12
|
+
exports.SchemaValidationError = addon.SchemaValidationError;
|
|
12
13
|
exports.parser = addon.parser;
|
|
13
14
|
exports.query = query.query;
|
|
14
15
|
exports.rateLimitHandler = rateLimit.rateLimitHandler;
|
package/addons/bundle.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { form } from "./form.js";
|
|
2
2
|
import { multipart } from "./multipart.js";
|
|
3
|
-
import { parser } from "./parse/addon.js";
|
|
3
|
+
import { SchemaValidationError, parser } from "./parse/addon.js";
|
|
4
4
|
import { query } from "./query.js";
|
|
5
5
|
import { rateLimitHandler } from "./rate-limit.js";
|
|
6
6
|
import { RetriesExceededError, retry } from "./retry.js";
|
|
7
7
|
import { TimeoutError, timeout } from "./timeout.js";
|
|
8
8
|
export {
|
|
9
9
|
RetriesExceededError,
|
|
10
|
+
SchemaValidationError,
|
|
10
11
|
TimeoutError,
|
|
11
12
|
form,
|
|
12
13
|
multipart,
|
package/addons/parse/addon.cjs
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
3
|
+
class SchemaValidationError extends Error {
|
|
4
|
+
constructor(issues) {
|
|
5
|
+
let message = "Schema validation failed";
|
|
6
|
+
for (const issue of issues) {
|
|
7
|
+
message += `: ${issue.message}`;
|
|
8
|
+
if (issue.path) {
|
|
9
|
+
const pathStr = [];
|
|
10
|
+
for (const path of issue.path) {
|
|
11
|
+
if (typeof path === "object") {
|
|
12
|
+
pathStr.push(String(path.key));
|
|
13
|
+
} else {
|
|
14
|
+
pathStr.push(String(path));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
message += ` at .${pathStr.join(".")}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
super(message);
|
|
21
|
+
this.issues = issues;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function parser() {
|
|
4
25
|
return {
|
|
5
26
|
response: {
|
|
6
27
|
async parsedJson(schema) {
|
|
7
|
-
|
|
28
|
+
const res = await schema["~standard"].validate(await this.json());
|
|
29
|
+
if (res.issues) {
|
|
30
|
+
throw new SchemaValidationError(res.issues);
|
|
31
|
+
}
|
|
32
|
+
return res.value;
|
|
8
33
|
},
|
|
9
34
|
async safelyParsedJson(schema) {
|
|
10
|
-
return
|
|
35
|
+
return schema["~standard"].validate(await this.json());
|
|
11
36
|
}
|
|
12
37
|
}
|
|
13
38
|
};
|
|
14
39
|
}
|
|
40
|
+
exports.SchemaValidationError = SchemaValidationError;
|
|
15
41
|
exports.parser = parser;
|
package/addons/parse/addon.d.cts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { FfetchAddon } from '../types.js';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
/** Schema validation failed when calling `parsedJson` */
|
|
4
|
+
export declare class SchemaValidationError extends Error {
|
|
5
|
+
readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
6
|
+
constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>);
|
|
7
|
+
}
|
|
8
|
+
export interface ParserAddon {
|
|
9
|
+
parsedJson: <T extends StandardSchemaV1>(schema: T) => Promise<StandardSchemaV1.InferOutput<T>>;
|
|
10
|
+
safelyParsedJson: <T extends StandardSchemaV1>(schema: T) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<T>>>;
|
|
11
|
+
}
|
|
12
|
+
export declare function parser(): FfetchAddon<object, ParserAddon>;
|
package/addons/parse/addon.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { FfetchAddon } from '../types.js';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
/** Schema validation failed when calling `parsedJson` */
|
|
4
|
+
export declare class SchemaValidationError extends Error {
|
|
5
|
+
readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
6
|
+
constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>);
|
|
7
|
+
}
|
|
8
|
+
export interface ParserAddon {
|
|
9
|
+
parsedJson: <T extends StandardSchemaV1>(schema: T) => Promise<StandardSchemaV1.InferOutput<T>>;
|
|
10
|
+
safelyParsedJson: <T extends StandardSchemaV1>(schema: T) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<T>>>;
|
|
11
|
+
}
|
|
12
|
+
export declare function parser(): FfetchAddon<object, ParserAddon>;
|
package/addons/parse/addon.js
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
class SchemaValidationError extends Error {
|
|
2
|
+
constructor(issues) {
|
|
3
|
+
let message = "Schema validation failed";
|
|
4
|
+
for (const issue of issues) {
|
|
5
|
+
message += `: ${issue.message}`;
|
|
6
|
+
if (issue.path) {
|
|
7
|
+
const pathStr = [];
|
|
8
|
+
for (const path of issue.path) {
|
|
9
|
+
if (typeof path === "object") {
|
|
10
|
+
pathStr.push(String(path.key));
|
|
11
|
+
} else {
|
|
12
|
+
pathStr.push(String(path));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
message += ` at .${pathStr.join(".")}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
super(message);
|
|
19
|
+
this.issues = issues;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function parser() {
|
|
2
23
|
return {
|
|
3
24
|
response: {
|
|
4
25
|
async parsedJson(schema) {
|
|
5
|
-
|
|
26
|
+
const res = await schema["~standard"].validate(await this.json());
|
|
27
|
+
if (res.issues) {
|
|
28
|
+
throw new SchemaValidationError(res.issues);
|
|
29
|
+
}
|
|
30
|
+
return res.value;
|
|
6
31
|
},
|
|
7
32
|
async safelyParsedJson(schema) {
|
|
8
|
-
return
|
|
33
|
+
return schema["~standard"].validate(await this.json());
|
|
9
34
|
}
|
|
10
35
|
}
|
|
11
36
|
};
|
|
12
37
|
}
|
|
13
38
|
export {
|
|
39
|
+
SchemaValidationError,
|
|
14
40
|
parser
|
|
15
41
|
};
|
package/default.cjs
CHANGED
|
@@ -6,12 +6,14 @@ const query = require("./addons/query.cjs");
|
|
|
6
6
|
const form = require("./addons/form.cjs");
|
|
7
7
|
const multipart = require("./addons/multipart.cjs");
|
|
8
8
|
const retry = require("./addons/retry.cjs");
|
|
9
|
+
const addon = require("./addons/parse/addon.cjs");
|
|
9
10
|
const ffetchDefaultAddons = [
|
|
10
11
|
/* @__PURE__ */ timeout.timeout(),
|
|
11
12
|
/* @__PURE__ */ query.query(),
|
|
12
13
|
/* @__PURE__ */ form.form(),
|
|
13
14
|
/* @__PURE__ */ multipart.multipart(),
|
|
14
|
-
/* @__PURE__ */ retry.retry()
|
|
15
|
+
/* @__PURE__ */ retry.retry(),
|
|
16
|
+
/* @__PURE__ */ addon.parser()
|
|
15
17
|
];
|
|
16
18
|
const ffetchBase = /* @__PURE__ */ ffetch.createFfetch({
|
|
17
19
|
addons: ffetchDefaultAddons
|
package/default.d.cts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const ffetchDefaultAddons: [
|
|
|
5
5
|
FfetchAddon<ffetchAddons.QueryAddon, object>,
|
|
6
6
|
FfetchAddon<ffetchAddons.FormAddon, object>,
|
|
7
7
|
FfetchAddon<ffetchAddons.MultipartAddon, object>,
|
|
8
|
-
FfetchAddon<ffetchAddons.RetryAddon, object
|
|
8
|
+
FfetchAddon<ffetchAddons.RetryAddon, object>,
|
|
9
|
+
FfetchAddon<object, ffetchAddons.ParserAddon>
|
|
9
10
|
];
|
|
10
11
|
/**
|
|
11
12
|
* the default ffetch instance with a reasonable default set of addons
|
|
@@ -28,4 +29,4 @@ export declare const ffetchDefaultAddons: [
|
|
|
28
29
|
* })
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
|
-
export declare const ffetchBase: Ffetch<ffetchAddons.TimeoutAddon & ffetchAddons.QueryAddon & ffetchAddons.FormAddon & ffetchAddons.MultipartAddon & ffetchAddons.RetryAddon,
|
|
32
|
+
export declare const ffetchBase: Ffetch<ffetchAddons.TimeoutAddon & ffetchAddons.QueryAddon & ffetchAddons.FormAddon & ffetchAddons.MultipartAddon & ffetchAddons.RetryAddon, ffetchAddons.ParserAddon>;
|
package/default.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const ffetchDefaultAddons: [
|
|
|
5
5
|
FfetchAddon<ffetchAddons.QueryAddon, object>,
|
|
6
6
|
FfetchAddon<ffetchAddons.FormAddon, object>,
|
|
7
7
|
FfetchAddon<ffetchAddons.MultipartAddon, object>,
|
|
8
|
-
FfetchAddon<ffetchAddons.RetryAddon, object
|
|
8
|
+
FfetchAddon<ffetchAddons.RetryAddon, object>,
|
|
9
|
+
FfetchAddon<object, ffetchAddons.ParserAddon>
|
|
9
10
|
];
|
|
10
11
|
/**
|
|
11
12
|
* the default ffetch instance with a reasonable default set of addons
|
|
@@ -28,4 +29,4 @@ export declare const ffetchDefaultAddons: [
|
|
|
28
29
|
* })
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
|
-
export declare const ffetchBase: Ffetch<ffetchAddons.TimeoutAddon & ffetchAddons.QueryAddon & ffetchAddons.FormAddon & ffetchAddons.MultipartAddon & ffetchAddons.RetryAddon,
|
|
32
|
+
export declare const ffetchBase: Ffetch<ffetchAddons.TimeoutAddon & ffetchAddons.QueryAddon & ffetchAddons.FormAddon & ffetchAddons.MultipartAddon & ffetchAddons.RetryAddon, ffetchAddons.ParserAddon>;
|
package/default.js
CHANGED
|
@@ -4,12 +4,14 @@ import { query } from "./addons/query.js";
|
|
|
4
4
|
import { form } from "./addons/form.js";
|
|
5
5
|
import { multipart } from "./addons/multipart.js";
|
|
6
6
|
import { retry } from "./addons/retry.js";
|
|
7
|
+
import { parser } from "./addons/parse/addon.js";
|
|
7
8
|
const ffetchDefaultAddons = [
|
|
8
9
|
/* @__PURE__ */ timeout(),
|
|
9
10
|
/* @__PURE__ */ query(),
|
|
10
11
|
/* @__PURE__ */ form(),
|
|
11
12
|
/* @__PURE__ */ multipart(),
|
|
12
|
-
/* @__PURE__ */ retry()
|
|
13
|
+
/* @__PURE__ */ retry(),
|
|
14
|
+
/* @__PURE__ */ parser()
|
|
13
15
|
];
|
|
14
16
|
const ffetchBase = /* @__PURE__ */ createFfetch({
|
|
15
17
|
addons: ffetchDefaultAddons
|
package/package.json
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuman/fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "tiny wrapper over fetch",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@fuman/utils": "^0.0.
|
|
8
|
+
"@fuman/utils": "^0.0.16",
|
|
9
|
+
"@standard-schema/spec": "^1.0.0"
|
|
9
10
|
},
|
|
10
11
|
"peerDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"tough-cookie": "^5.0.0 || ^4.0.0",
|
|
13
|
-
"valibot": "^0.42.0",
|
|
14
|
-
"yup": "^1.0.0",
|
|
15
|
-
"zod": "^3.0.0"
|
|
12
|
+
"tough-cookie": "^6.0.0 || ^5.0.0 || ^4.0.0"
|
|
16
13
|
},
|
|
17
14
|
"exports": {
|
|
18
15
|
".": {
|
|
@@ -25,46 +22,6 @@
|
|
|
25
22
|
"default": "./index.cjs"
|
|
26
23
|
}
|
|
27
24
|
},
|
|
28
|
-
"./zod": {
|
|
29
|
-
"import": {
|
|
30
|
-
"types": "./zod.d.ts",
|
|
31
|
-
"default": "./zod.js"
|
|
32
|
-
},
|
|
33
|
-
"require": {
|
|
34
|
-
"types": "./zod.d.cts",
|
|
35
|
-
"default": "./zod.cjs"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"./valibot": {
|
|
39
|
-
"import": {
|
|
40
|
-
"types": "./valibot.d.ts",
|
|
41
|
-
"default": "./valibot.js"
|
|
42
|
-
},
|
|
43
|
-
"require": {
|
|
44
|
-
"types": "./valibot.d.cts",
|
|
45
|
-
"default": "./valibot.cjs"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"./yup": {
|
|
49
|
-
"import": {
|
|
50
|
-
"types": "./yup.d.ts",
|
|
51
|
-
"default": "./yup.js"
|
|
52
|
-
},
|
|
53
|
-
"require": {
|
|
54
|
-
"types": "./yup.d.cts",
|
|
55
|
-
"default": "./yup.cjs"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"./valita": {
|
|
59
|
-
"import": {
|
|
60
|
-
"types": "./valita.d.ts",
|
|
61
|
-
"default": "./valita.js"
|
|
62
|
-
},
|
|
63
|
-
"require": {
|
|
64
|
-
"types": "./valita.d.cts",
|
|
65
|
-
"default": "./valita.cjs"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
25
|
"./tough": {
|
|
69
26
|
"import": {
|
|
70
27
|
"types": "./tough.d.ts",
|
|
@@ -78,20 +35,8 @@
|
|
|
78
35
|
},
|
|
79
36
|
"sideEffects": false,
|
|
80
37
|
"peerDependenciesMeta": {
|
|
81
|
-
"@badrap/valita": {
|
|
82
|
-
"optional": true
|
|
83
|
-
},
|
|
84
38
|
"tough-cookie": {
|
|
85
39
|
"optional": true
|
|
86
|
-
},
|
|
87
|
-
"valibot": {
|
|
88
|
-
"optional": true
|
|
89
|
-
},
|
|
90
|
-
"yup": {
|
|
91
|
-
"optional": true
|
|
92
|
-
},
|
|
93
|
-
"zod": {
|
|
94
|
-
"optional": true
|
|
95
40
|
}
|
|
96
41
|
},
|
|
97
42
|
"author": "",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface FfetchTypeProvider {
|
|
2
|
-
readonly schema: unknown;
|
|
3
|
-
readonly parsed: unknown;
|
|
4
|
-
readonly safeParsed: unknown;
|
|
5
|
-
}
|
|
6
|
-
export interface FfetchParser<TypeProvider extends FfetchTypeProvider> {
|
|
7
|
-
readonly _provider: TypeProvider;
|
|
8
|
-
parse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
9
|
-
safeParse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
10
|
-
}
|
|
11
|
-
export type CallTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
12
|
-
schema: Schema;
|
|
13
|
-
})['parsed'];
|
|
14
|
-
export type CallSafeTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
15
|
-
schema: Schema;
|
|
16
|
-
})['safeParsed'];
|
package/addons/parse/_types.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface FfetchTypeProvider {
|
|
2
|
-
readonly schema: unknown;
|
|
3
|
-
readonly parsed: unknown;
|
|
4
|
-
readonly safeParsed: unknown;
|
|
5
|
-
}
|
|
6
|
-
export interface FfetchParser<TypeProvider extends FfetchTypeProvider> {
|
|
7
|
-
readonly _provider: TypeProvider;
|
|
8
|
-
parse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
9
|
-
safeParse: (schema: unknown, value: unknown) => unknown | Promise<unknown>;
|
|
10
|
-
}
|
|
11
|
-
export type CallTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
12
|
-
schema: Schema;
|
|
13
|
-
})['parsed'];
|
|
14
|
-
export type CallSafeTypeProvider<TypeProvider extends FfetchTypeProvider, Schema> = (TypeProvider & {
|
|
15
|
-
schema: Schema;
|
|
16
|
-
})['safeParsed'];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferOutput, SafeParseResult } from 'valibot';
|
|
2
|
-
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
|
-
export interface ValibotTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
6
|
-
}
|
|
7
|
-
export declare function ffetchValibotAdapter({ async, ...rest }?: Partial<Config<BaseIssue<unknown>>> & {
|
|
8
|
-
async?: boolean;
|
|
9
|
-
}): FfetchParser<ValibotTypeProvider>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseIssue, BaseSchema, BaseSchemaAsync, Config, InferOutput, SafeParseResult } from 'valibot';
|
|
2
|
-
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
|
-
export interface ValibotTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
6
|
-
}
|
|
7
|
-
export declare function ffetchValibotAdapter({ async, ...rest }?: Partial<Config<BaseIssue<unknown>>> & {
|
|
8
|
-
async?: boolean;
|
|
9
|
-
}): FfetchParser<ValibotTypeProvider>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
2
|
-
import type * as v from '@badrap/valita';
|
|
3
|
-
export interface ValitaTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
6
|
-
}
|
|
7
|
-
type ParseOptions = NonNullable<Parameters<v.Type<any>['parse']>[1]>;
|
|
8
|
-
export declare function ffetchValitaAdapter(options?: ParseOptions): FfetchParser<ValitaTypeProvider>;
|
|
9
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
2
|
-
import type * as v from '@badrap/valita';
|
|
3
|
-
export interface ValitaTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
6
|
-
}
|
|
7
|
-
type ParseOptions = NonNullable<Parameters<v.Type<any>['parse']>[1]>;
|
|
8
|
-
export declare function ffetchValitaAdapter(options?: ParseOptions): FfetchParser<ValitaTypeProvider>;
|
|
9
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CastOptions, InferType, ISchema, ValidateOptions, ValidationError } from 'yup';
|
|
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
|
-
};
|
|
10
|
-
export interface YupTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
13
|
-
}
|
|
14
|
-
export type FfetchYupAdapterOptions = {
|
|
15
|
-
action: 'cast';
|
|
16
|
-
options?: CastOptions;
|
|
17
|
-
} | {
|
|
18
|
-
action: 'validate';
|
|
19
|
-
options?: ValidateOptions;
|
|
20
|
-
};
|
|
21
|
-
export declare function ffetchYupAdapter({ action, options, }?: FfetchYupAdapterOptions): FfetchParser<YupTypeProvider>;
|
|
22
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CastOptions, InferType, ISchema, ValidateOptions, ValidationError } from 'yup';
|
|
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
|
-
};
|
|
10
|
-
export interface YupTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
13
|
-
}
|
|
14
|
-
export type FfetchYupAdapterOptions = {
|
|
15
|
-
action: 'cast';
|
|
16
|
-
options?: CastOptions;
|
|
17
|
-
} | {
|
|
18
|
-
action: 'validate';
|
|
19
|
-
options?: ValidateOptions;
|
|
20
|
-
};
|
|
21
|
-
export declare function ffetchYupAdapter({ action, options, }?: FfetchYupAdapterOptions): FfetchParser<YupTypeProvider>;
|
|
22
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ParseParams, SafeParseReturnType, z } from 'zod';
|
|
2
|
-
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
|
-
export interface ZodTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
6
|
-
}
|
|
7
|
-
export declare function ffetchZodAdapter({ async, ...rest }?: Partial<ParseParams>): FfetchParser<ZodTypeProvider>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ParseParams, SafeParseReturnType, z } from 'zod';
|
|
2
|
-
import { FfetchParser, FfetchTypeProvider } from '../_types.js';
|
|
3
|
-
export interface ZodTypeProvider extends FfetchTypeProvider {
|
|
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;
|
|
6
|
-
}
|
|
7
|
-
export declare function ffetchZodAdapter({ async, ...rest }?: Partial<ParseParams>): FfetchParser<ZodTypeProvider>;
|
package/valibot.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const valibot = require("valibot");
|
|
4
|
-
function ffetchValibotAdapter({ async, ...rest } = {}) {
|
|
5
|
-
const _provider = null;
|
|
6
|
-
const parser = async ? async function(schema, value) {
|
|
7
|
-
return valibot.parseAsync(schema, value, rest);
|
|
8
|
-
} : function(schema, value) {
|
|
9
|
-
return valibot.parse(schema, value, rest);
|
|
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
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
_provider,
|
|
18
|
-
parse: parser,
|
|
19
|
-
safeParse: safeParser
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
exports.ffetchValibotAdapter = ffetchValibotAdapter;
|
package/valibot.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/valibot.js"
|
package/valibot.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/valibot.js"
|
package/valibot.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { parseAsync, parse, safeParseAsync, safeParse } from "valibot";
|
|
2
|
-
function ffetchValibotAdapter({ async, ...rest } = {}) {
|
|
3
|
-
const _provider = null;
|
|
4
|
-
const parser = async ? async function(schema, value) {
|
|
5
|
-
return parseAsync(schema, value, rest);
|
|
6
|
-
} : function(schema, value) {
|
|
7
|
-
return parse(schema, value, rest);
|
|
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
|
-
};
|
|
14
|
-
return {
|
|
15
|
-
_provider,
|
|
16
|
-
parse: parser,
|
|
17
|
-
safeParse: safeParser
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
ffetchValibotAdapter
|
|
22
|
-
};
|
package/valita.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function ffetchValitaAdapter(options) {
|
|
4
|
-
const _provider = null;
|
|
5
|
-
return {
|
|
6
|
-
_provider,
|
|
7
|
-
parse(schema, value) {
|
|
8
|
-
return schema.parse(value, options);
|
|
9
|
-
},
|
|
10
|
-
safeParse(schema, value) {
|
|
11
|
-
return schema.try(value, options);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.ffetchValitaAdapter = ffetchValitaAdapter;
|
package/valita.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/valita.js"
|
package/valita.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/valita.js"
|
package/valita.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function ffetchValitaAdapter(options) {
|
|
2
|
-
const _provider = null;
|
|
3
|
-
return {
|
|
4
|
-
_provider,
|
|
5
|
-
parse(schema, value) {
|
|
6
|
-
return schema.parse(value, options);
|
|
7
|
-
},
|
|
8
|
-
safeParse(schema, value) {
|
|
9
|
-
return schema.try(value, options);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
ffetchValitaAdapter
|
|
15
|
-
};
|
package/yup.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function ffetchYupAdapter({
|
|
4
|
-
action,
|
|
5
|
-
options
|
|
6
|
-
} = { action: "validate" }) {
|
|
7
|
-
const _provider = null;
|
|
8
|
-
const parse = action === "cast" ? function(schema, value) {
|
|
9
|
-
return schema.cast(value, options);
|
|
10
|
-
} : async function(schema, value) {
|
|
11
|
-
return schema.validate(value, options);
|
|
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
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
_provider,
|
|
30
|
-
parse,
|
|
31
|
-
safeParse
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.ffetchYupAdapter = ffetchYupAdapter;
|
package/yup.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/yup.js"
|
package/yup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/yup.js"
|
package/yup.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
function ffetchYupAdapter({
|
|
2
|
-
action,
|
|
3
|
-
options
|
|
4
|
-
} = { action: "validate" }) {
|
|
5
|
-
const _provider = null;
|
|
6
|
-
const parse = action === "cast" ? function(schema, value) {
|
|
7
|
-
return schema.cast(value, options);
|
|
8
|
-
} : async function(schema, value) {
|
|
9
|
-
return schema.validate(value, options);
|
|
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
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
_provider,
|
|
28
|
-
parse,
|
|
29
|
-
safeParse
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
ffetchYupAdapter
|
|
34
|
-
};
|
package/zod.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function ffetchZodAdapter({ async, ...rest } = {}) {
|
|
4
|
-
const _provider = null;
|
|
5
|
-
const parse = async ? async function(schema, value) {
|
|
6
|
-
return schema.parseAsync(value, rest);
|
|
7
|
-
} : function(schema, value) {
|
|
8
|
-
return schema.parse(value, rest);
|
|
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
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
_provider,
|
|
17
|
-
parse,
|
|
18
|
-
safeParse
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
exports.ffetchZodAdapter = ffetchZodAdapter;
|
package/zod.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/zod.js"
|
package/zod.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./addons/parse/adapters/zod.js"
|
package/zod.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
function ffetchZodAdapter({ async, ...rest } = {}) {
|
|
2
|
-
const _provider = null;
|
|
3
|
-
const parse = async ? async function(schema, value) {
|
|
4
|
-
return schema.parseAsync(value, rest);
|
|
5
|
-
} : function(schema, value) {
|
|
6
|
-
return schema.parse(value, rest);
|
|
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
|
-
};
|
|
13
|
-
return {
|
|
14
|
-
_provider,
|
|
15
|
-
parse,
|
|
16
|
-
safeParse
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
ffetchZodAdapter
|
|
21
|
-
};
|