@whatsaaaa/form-builder-schema 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +38 -2
- package/dist/index.d.ts +83 -0
- package/dist/index.js +124 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Whatsaaaa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @whatsaaaa/form-builder-schema
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build [Valibot](https://valibot.dev) schemas from JSON form definitions, ready to use with [Formisch](https://formisch.dev).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @whatsaaaa/form-builder-schema valibot
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createSchemaBuilder, type JsonFormSchema } from '@whatsaaaa/form-builder-schema'
|
|
15
|
+
|
|
16
|
+
const json: JsonFormSchema = {
|
|
17
|
+
version: '1',
|
|
18
|
+
fields: [
|
|
19
|
+
{ name: 'email', type: 'email', required: { message: 'Email is required' } },
|
|
20
|
+
{
|
|
21
|
+
name: 'password',
|
|
22
|
+
type: 'password',
|
|
23
|
+
required: true,
|
|
24
|
+
rules: [{ rule: 'minLength', value: 10, message: 'At least 10 characters' }],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const build = createSchemaBuilder()
|
|
30
|
+
const schema = build(json) // v.ObjectSchema, ready for Formisch or v.parse
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Built-in field types are `text`, `email`, `password` and `number`. Empty inputs of optional `number` fields (`''` or `undefined`) produce `undefined`.
|
|
34
|
+
|
|
35
|
+
Custom field types and rules can be passed to `createSchemaBuilder({ fieldTypes, rules })`. Use `defineRule` to get typed rule params.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
type AnySchema = v.GenericSchema;
|
|
3
|
+
type AnyAction = v.GenericPipeAction;
|
|
4
|
+
type ValueKind = 'string' | 'number';
|
|
5
|
+
type FieldType = 'text' | 'email' | 'password' | 'number';
|
|
6
|
+
interface JsonField {
|
|
7
|
+
name: string;
|
|
8
|
+
type: FieldType;
|
|
9
|
+
required?: boolean | {
|
|
10
|
+
message?: string;
|
|
11
|
+
};
|
|
12
|
+
rules?: readonly JsonRule[];
|
|
13
|
+
}
|
|
14
|
+
interface JsonRule {
|
|
15
|
+
rule: string;
|
|
16
|
+
message?: string;
|
|
17
|
+
[param: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
interface JsonFormSchema {
|
|
20
|
+
version: '1';
|
|
21
|
+
fields: readonly JsonField[];
|
|
22
|
+
}
|
|
23
|
+
interface RuleDef<TParams extends AnySchema = AnySchema> {
|
|
24
|
+
kinds: readonly ValueKind[];
|
|
25
|
+
params: TParams;
|
|
26
|
+
create(params: v.InferOutput<TParams>, message?: string): AnyAction;
|
|
27
|
+
}
|
|
28
|
+
interface FieldTypeDef {
|
|
29
|
+
kind: ValueKind;
|
|
30
|
+
base: (message?: string) => AnySchema;
|
|
31
|
+
defaultRules?: readonly JsonRule[];
|
|
32
|
+
}
|
|
33
|
+
interface SchemaBuilderOptions {
|
|
34
|
+
fieldTypes?: Record<string, FieldTypeDef>;
|
|
35
|
+
rules?: Record<string, RuleDef>;
|
|
36
|
+
}
|
|
37
|
+
export declare function createSchemaBuilder(opts?: SchemaBuilderOptions): (json: JsonFormSchema) => v.ObjectSchema<v.ObjectEntries, undefined>;
|
|
38
|
+
export declare const defaultFieldTypes: {
|
|
39
|
+
text: {
|
|
40
|
+
kind: "string";
|
|
41
|
+
base: (m: string | undefined) => v.StringSchema<string | undefined>;
|
|
42
|
+
};
|
|
43
|
+
password: {
|
|
44
|
+
kind: "string";
|
|
45
|
+
base: (m: string | undefined) => v.StringSchema<string | undefined>;
|
|
46
|
+
};
|
|
47
|
+
email: {
|
|
48
|
+
kind: "string";
|
|
49
|
+
base: (m: string | undefined) => v.StringSchema<string | undefined>;
|
|
50
|
+
defaultRules: {
|
|
51
|
+
rule: string;
|
|
52
|
+
message: string;
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
number: {
|
|
56
|
+
kind: "number";
|
|
57
|
+
base: (m: string | undefined) => v.NumberSchema<string | undefined>;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare const defineRule: <T extends AnySchema>(def: RuleDef<T>) => RuleDef<T>;
|
|
61
|
+
export declare const defaultRules: {
|
|
62
|
+
minLength: RuleDef<v.ObjectSchema<{
|
|
63
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
64
|
+
}, undefined>>;
|
|
65
|
+
maxLength: RuleDef<v.ObjectSchema<{
|
|
66
|
+
readonly value: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
67
|
+
}, undefined>>;
|
|
68
|
+
regex: RuleDef<v.ObjectSchema<{
|
|
69
|
+
readonly pattern: v.StringSchema<undefined>;
|
|
70
|
+
readonly flags: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
+
}, undefined>>;
|
|
72
|
+
email: RuleDef<v.ObjectSchema<{}, undefined>>;
|
|
73
|
+
url: RuleDef<v.ObjectSchema<{}, undefined>>;
|
|
74
|
+
minValue: RuleDef<v.ObjectSchema<{
|
|
75
|
+
readonly value: v.NumberSchema<undefined>;
|
|
76
|
+
}, undefined>>;
|
|
77
|
+
maxValue: RuleDef<v.ObjectSchema<{
|
|
78
|
+
readonly value: v.NumberSchema<undefined>;
|
|
79
|
+
}, undefined>>;
|
|
80
|
+
integer: RuleDef<v.ObjectSchema<{}, undefined>>;
|
|
81
|
+
};
|
|
82
|
+
export type { AnyAction, AnySchema, FieldType, FieldTypeDef, JsonField, JsonFormSchema, JsonRule, RuleDef, SchemaBuilderOptions, ValueKind };
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
// src/field-types.ts
|
|
3
|
+
const defaultFieldTypes = {
|
|
4
|
+
text: {
|
|
5
|
+
kind: "string",
|
|
6
|
+
base: (m) => v.string(m)
|
|
7
|
+
},
|
|
8
|
+
password: {
|
|
9
|
+
kind: "string",
|
|
10
|
+
base: (m) => v.string(m)
|
|
11
|
+
},
|
|
12
|
+
email: {
|
|
13
|
+
kind: "string",
|
|
14
|
+
base: (m) => v.string(m),
|
|
15
|
+
defaultRules: [{
|
|
16
|
+
rule: "email",
|
|
17
|
+
message: "Invalid email"
|
|
18
|
+
}]
|
|
19
|
+
},
|
|
20
|
+
number: {
|
|
21
|
+
kind: "number",
|
|
22
|
+
base: (m) => v.number(m)
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// src/rules.ts
|
|
26
|
+
const defineRule = (def) => def;
|
|
27
|
+
const nonNegInt = v.pipe(v.number(), v.integer(), v.minValue(0));
|
|
28
|
+
const noParams = v.object({});
|
|
29
|
+
const defaultRules = {
|
|
30
|
+
minLength: defineRule({
|
|
31
|
+
kinds: ["string"],
|
|
32
|
+
params: v.object({ value: nonNegInt }),
|
|
33
|
+
create: (p, m) => v.minLength(p.value, m)
|
|
34
|
+
}),
|
|
35
|
+
maxLength: defineRule({
|
|
36
|
+
kinds: ["string"],
|
|
37
|
+
params: v.object({ value: nonNegInt }),
|
|
38
|
+
create: (p, m) => v.maxLength(p.value, m)
|
|
39
|
+
}),
|
|
40
|
+
regex: defineRule({
|
|
41
|
+
kinds: ["string"],
|
|
42
|
+
params: v.object({
|
|
43
|
+
pattern: v.string(),
|
|
44
|
+
flags: v.optional(v.string())
|
|
45
|
+
}),
|
|
46
|
+
create: (p, m) => v.regex(new RegExp(p.pattern, p.flags), m)
|
|
47
|
+
}),
|
|
48
|
+
email: defineRule({
|
|
49
|
+
kinds: ["string"],
|
|
50
|
+
params: noParams,
|
|
51
|
+
create: (_, m) => v.email(m)
|
|
52
|
+
}),
|
|
53
|
+
url: defineRule({
|
|
54
|
+
kinds: ["string"],
|
|
55
|
+
params: noParams,
|
|
56
|
+
create: (_, m) => v.url(m)
|
|
57
|
+
}),
|
|
58
|
+
minValue: defineRule({
|
|
59
|
+
kinds: ["number"],
|
|
60
|
+
params: v.object({ value: v.number() }),
|
|
61
|
+
create: (p, m) => v.minValue(p.value, m)
|
|
62
|
+
}),
|
|
63
|
+
maxValue: defineRule({
|
|
64
|
+
kinds: ["number"],
|
|
65
|
+
params: v.object({ value: v.number() }),
|
|
66
|
+
create: (p, m) => v.maxValue(p.value, m)
|
|
67
|
+
}),
|
|
68
|
+
integer: defineRule({
|
|
69
|
+
kinds: ["number"],
|
|
70
|
+
params: noParams,
|
|
71
|
+
create: (_, m) => v.integer(m)
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
// src/create-schema-builder.ts
|
|
75
|
+
function createSchemaBuilder(opts = {}) {
|
|
76
|
+
const fieldTypes = {
|
|
77
|
+
...defaultFieldTypes,
|
|
78
|
+
...opts.fieldTypes
|
|
79
|
+
};
|
|
80
|
+
const rules = {
|
|
81
|
+
...defaultRules,
|
|
82
|
+
...opts.rules
|
|
83
|
+
};
|
|
84
|
+
function buildAction(rule, kind, at) {
|
|
85
|
+
const def = rules[rule.rule];
|
|
86
|
+
if (!def) throw new Error(`${at}: unknown rule "${rule.rule}"`);
|
|
87
|
+
if (!def.kinds.includes(kind)) throw new Error(`${at}: rule "${rule.rule}" can't be used on ${kind} fields`);
|
|
88
|
+
const parsed = v.safeParse(def.params, rule);
|
|
89
|
+
if (!parsed.success) throw new Error(`${at}: invalid params for "${rule.rule}"\n${v.summarize(parsed.issues)}`);
|
|
90
|
+
return def.create(parsed.output, rule.message);
|
|
91
|
+
}
|
|
92
|
+
function buildField(field, i) {
|
|
93
|
+
const at = `fields[${i}] "${field.name}"`;
|
|
94
|
+
const type = fieldTypes[field.type];
|
|
95
|
+
if (!type) throw new Error(`${at}: unknown field type "${field.type}"`);
|
|
96
|
+
const userRules = field.rules ?? [];
|
|
97
|
+
const overridden = new Set(userRules.map((r) => r.rule));
|
|
98
|
+
const allRules = [...(type.defaultRules ?? []).filter((r) => !overridden.has(r.rule)), ...userRules];
|
|
99
|
+
const required = !!field.required;
|
|
100
|
+
const requiredMsg = typeof field.required === "object" ? field.required.message : void 0;
|
|
101
|
+
const actions = [];
|
|
102
|
+
if (required && type.kind === "string") actions.push(v.nonEmpty(requiredMsg ?? "Required"));
|
|
103
|
+
allRules.forEach((r, j) => {
|
|
104
|
+
actions.push(buildAction(r, type.kind, `${at}.rules[${j}]`));
|
|
105
|
+
});
|
|
106
|
+
const baseMsg = required && type.kind === "number" ? requiredMsg ?? "Required" : requiredMsg;
|
|
107
|
+
const schema = actions.reduce((s, a) => v.pipe(s, a), type.base(baseMsg));
|
|
108
|
+
if (required) return schema;
|
|
109
|
+
if (type.kind === "string") return v.optional(v.union([v.literal(""), schema]));
|
|
110
|
+
const empty = v.pipe(v.literal(""), v.transform(() => void 0));
|
|
111
|
+
return v.optional(v.union([empty, schema]));
|
|
112
|
+
}
|
|
113
|
+
return function build(json) {
|
|
114
|
+
const entries = {};
|
|
115
|
+
json.fields.forEach((field, i) => {
|
|
116
|
+
if (field.name in entries) throw new Error(`fields[${i}]: duplicate name "${field.name}"`);
|
|
117
|
+
entries[field.name] = buildField(field, i);
|
|
118
|
+
});
|
|
119
|
+
return v.object(entries);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export { createSchemaBuilder, defaultFieldTypes, defaultRules, defineRule };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/field-types.ts","../src/rules.ts","../src/create-schema-builder.ts"],"sourcesContent":["import * as v from 'valibot'\nimport type { FieldTypeDef } from './types'\n\nexport const defaultFieldTypes = {\n text: { kind: 'string', base: (m) => v.string(m) },\n password: { kind: 'string', base: (m) => v.string(m) },\n email: {\n kind: 'string',\n base: (m) => v.string(m),\n defaultRules: [{ rule: 'email', message: 'Invalid email' }],\n },\n number: { kind: 'number', base: (m) => v.number(m) },\n} satisfies Record<string, FieldTypeDef>\n","import * as v from 'valibot'\nimport type { AnySchema, RuleDef } from './types'\n\nexport const defineRule = <T extends AnySchema>(def: RuleDef<T>): RuleDef<T> => def\n\nconst nonNegInt = v.pipe(v.number(), v.integer(), v.minValue(0))\nconst noParams = v.object({})\n\nexport const defaultRules = {\n minLength: defineRule({\n kinds: ['string'],\n params: v.object({ value: nonNegInt }),\n create: (p, m) => v.minLength(p.value, m),\n }),\n maxLength: defineRule({\n kinds: ['string'],\n params: v.object({ value: nonNegInt }),\n create: (p, m) => v.maxLength(p.value, m),\n }),\n regex: defineRule({\n kinds: ['string'],\n params: v.object({ pattern: v.string(), flags: v.optional(v.string()) }),\n create: (p, m) => v.regex(new RegExp(p.pattern, p.flags), m),\n }),\n email: defineRule({ kinds: ['string'], params: noParams, create: (_, m) => v.email(m) }),\n url: defineRule({ kinds: ['string'], params: noParams, create: (_, m) => v.url(m) }),\n minValue: defineRule({\n kinds: ['number'],\n params: v.object({ value: v.number() }),\n create: (p, m) => v.minValue(p.value, m),\n }),\n maxValue: defineRule({\n kinds: ['number'],\n params: v.object({ value: v.number() }),\n create: (p, m) => v.maxValue(p.value, m),\n }),\n integer: defineRule({ kinds: ['number'], params: noParams, create: (_, m) => v.integer(m) }),\n} satisfies Record<string, RuleDef>\n","import * as v from 'valibot'\nimport { defaultFieldTypes } from './field-types'\nimport { defaultRules } from './rules'\nimport type {\n AnyAction,\n AnySchema,\n FieldTypeDef,\n JsonField,\n JsonFormSchema,\n JsonRule,\n RuleDef,\n ValueKind,\n} from './types'\n\nexport interface SchemaBuilderOptions {\n fieldTypes?: Record<string, FieldTypeDef>\n rules?: Record<string, RuleDef>\n}\n\nexport function createSchemaBuilder(opts: SchemaBuilderOptions = {}) {\n const fieldTypes: Record<string, FieldTypeDef> = { ...defaultFieldTypes, ...opts.fieldTypes }\n const rules: Record<string, RuleDef> = { ...defaultRules, ...opts.rules }\n\n function buildAction(rule: JsonRule, kind: ValueKind, at: string): AnyAction {\n const def = rules[rule.rule]\n if (!def) throw new Error(`${at}: unknown rule \"${rule.rule}\"`)\n if (!def.kinds.includes(kind))\n throw new Error(`${at}: rule \"${rule.rule}\" can't be used on ${kind} fields`)\n\n const parsed = v.safeParse(def.params, rule)\n if (!parsed.success)\n throw new Error(`${at}: invalid params for \"${rule.rule}\"\\n${v.summarize(parsed.issues)}`)\n\n return def.create(parsed.output, rule.message)\n }\n\n function buildField(field: JsonField, i: number): AnySchema {\n const at = `fields[${i}] \"${field.name}\"`\n const type = fieldTypes[field.type]\n if (!type) throw new Error(`${at}: unknown field type \"${field.type}\"`)\n\n const userRules = field.rules ?? []\n const overridden = new Set(userRules.map((r) => r.rule))\n const allRules = [\n ...(type.defaultRules ?? []).filter((r) => !overridden.has(r.rule)),\n ...userRules,\n ]\n\n const required = !!field.required\n const requiredMsg = typeof field.required === 'object' ? field.required.message : undefined\n\n const actions: AnyAction[] = []\n\n if (required && type.kind === 'string') {\n actions.push(v.nonEmpty(requiredMsg ?? 'Required'))\n }\n\n allRules.forEach((r, j) => {\n actions.push(buildAction(r, type.kind, `${at}.rules[${j}]`))\n })\n\n // An empty number input is not a number, so required ones report it via the type check.\n const baseMsg = required && type.kind === 'number' ? (requiredMsg ?? 'Required') : requiredMsg\n const schema = actions.reduce<AnySchema>((s, a) => v.pipe(s, a), type.base(baseMsg))\n\n if (required) return schema\n if (type.kind === 'string') return v.optional(v.union([v.literal(''), schema]))\n\n // A cleared number input holds '', which means \"no value\".\n const empty = v.pipe(\n v.literal(''),\n v.transform(() => undefined),\n )\n return v.optional(v.union([empty, schema]))\n }\n\n return function build(json: JsonFormSchema) {\n const entries: v.ObjectEntries = {}\n\n json.fields.forEach((field, i) => {\n if (field.name in entries) throw new Error(`fields[${i}]: duplicate name \"${field.name}\"`)\n entries[field.name] = buildField(field, i)\n })\n\n return v.object(entries)\n }\n}\n"],"mappings":";;AAGA,MAAa,oBAAoB;CAC/B,M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GAChC,IAAI,MAAM,QAAQ,SAAS,MAAM,IAAI,MAAM,UAAU,EAAE,qBAAqB,MAAM,KAAK,EAAE;GACzF,QAAQ,MAAM,QAAQ,WAAW,OAAO,CAAC;EAC3C,CAAC;EAED,OAAO,EAAE,OAAO,OAAO;CACzB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatsaaaa/form-builder-schema",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Build Formisch-ready Valibot schemas from JSON form definitions.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Whatsaaaa",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/whatsaaaa/form-builder.git",
|
|
10
|
+
"directory": "packages/schema"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/whatsaaaa/form-builder",
|
|
16
|
+
"bugs": "https://github.com/whatsaaaa/form-builder/issues",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"formisch",
|
|
19
|
+
"form",
|
|
20
|
+
"json",
|
|
21
|
+
"schema"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
36
|
+
"publint": "^0.3.25",
|
|
37
|
+
"tsdown": "^0.23.2",
|
|
38
|
+
"typescript": "~6.0.3",
|
|
39
|
+
"valibot": "^1.5.0",
|
|
40
|
+
"vitest": "^5.0.5"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"valibot": "^1.0.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsdown",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"type-check": "tsc --noEmit",
|
|
49
|
+
"lint:pkg": "publint && pnpm pack --pack-destination .attw && attw .attw/*.tgz --profile esm-only"
|
|
50
|
+
}
|
|
6
51
|
}
|