Skip to content

Commit

Permalink
Fixed #20 - Could not resolve "valibot"
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 1, 2024
1 parent 28cdd5e commit 6b8412c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 50 deletions.
4 changes: 2 additions & 2 deletions packages/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@primeuix/forms",
"version": "0.0.1",
"version": "0.0.2",
"author": "PrimeTek Informatics",
"description": "",
"license": "MIT",
Expand Down Expand Up @@ -47,4 +47,4 @@
"engines": {
"node": ">=12.11.0"
}
}
}
26 changes: 1 addition & 25 deletions packages/forms/scripts/prebuild.mjs
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
import fs from 'fs-extra';
import path from 'path';
import { removeBuild, resolvePath, updatePackageJson } from '../../../scripts/build-helper.mjs';

removeBuild(import.meta.url);

const { __dirname, INPUT_DIR } = resolvePath(import.meta.url);
const { __dirname } = resolvePath(import.meta.url);
const __root = path.resolve(__dirname, '../');
const pkg = path.resolve(__root, './package.json');

updatePackageJson(pkg);

// Fill * > index.ts in subfolders
let exports = [
`export interface ResolverOptions {
sync?: boolean;
raw?: boolean;
}
export interface ResolverResult<T> {
values: T;
errors: Record<string, any>;
}
`
];

fs.readdirSync(path.resolve(__root, INPUT_DIR + '/resolvers'), { withFileTypes: true })
.filter((dir) => dir.isDirectory())
.forEach(({ name: folderName }) => {
exports.push(`export * from '@primeuix/forms/resolvers/${folderName}';\n`);

exports.length && fs.writeFileSync(path.resolve(INPUT_DIR + '/resolvers', 'index.ts'), exports.join(''));
});
9 changes: 9 additions & 0 deletions packages/forms/src/resolvers/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface ResolverOptions {
sync?: boolean;
raw?: boolean;
}

export interface ResolverResult<T> {
values: T;
errors: Record<string, any>;
}
15 changes: 0 additions & 15 deletions packages/forms/src/resolvers/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/forms/src/resolvers/joi/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toValues } from '@primeuix/forms/utils';
import { isNotEmpty } from '@primeuix/utils/object';
import { ResolverOptions, ResolverResult } from '..';
import type { ResolverOptions, ResolverResult } from '..';

export const joiResolver =
<T>(schema: any, schemaOptions?: any, resolverOptions?: ResolverOptions) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/resolvers/superstruct/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toValues } from '@primeuix/forms/utils';
import { isNotEmpty } from '@primeuix/utils/object';
import { Struct } from 'superstruct';
import { ResolverOptions, ResolverResult } from '..';
import type { Struct } from 'superstruct';
import type { ResolverOptions, ResolverResult } from '..';

export const superStructResolver =
<T>(schema: Struct<T>, schemaOptions?: any, resolverOptions?: ResolverOptions) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/resolvers/valibot/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toValues } from '@primeuix/forms/utils';
import { isNotEmpty } from '@primeuix/utils/object';
import { getDotPath, InferOutput, safeParse, safeParseAsync } from 'valibot';
import { ResolverOptions, ResolverResult } from '..';
import type { ResolverOptions, ResolverResult } from '..';

export const valibotResolver =
<T>(schema: any, schemaOptions?: any, resolverOptions?: ResolverOptions) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/resolvers/yup/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toValues } from '@primeuix/forms/utils';
import { isNotEmpty } from '@primeuix/utils/object';
import { AnyObjectSchema, ValidateOptions, ValidationError } from 'yup';
import { ResolverOptions, ResolverResult } from '..';
import type { AnyObjectSchema, ValidateOptions, ValidationError } from 'yup';
import type { ResolverOptions, ResolverResult } from '..';

export const yupResolver =
<T>(schema: AnyObjectSchema, schemaOptions?: ValidateOptions<any>, resolverOptions?: ResolverOptions) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/resolvers/zod/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toValues } from '@primeuix/forms/utils';
import { isNotEmpty } from '@primeuix/utils/object';
import { ParseParams, Schema } from 'zod';
import { ResolverOptions, ResolverResult } from '..';
import type { ParseParams, Schema } from 'zod';
import type { ResolverOptions, ResolverResult } from '..';

export const zodResolver =
<T extends Schema<any, any>>(schema: T, schemaOptions?: ParseParams, resolverOptions?: ResolverOptions) =>
Expand Down

0 comments on commit 6b8412c

Please sign in to comment.